@snaha/swarm-id 0.0.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 (223) hide show
  1. package/README.md +431 -0
  2. package/dist/chunk/bmt.d.ts +17 -0
  3. package/dist/chunk/bmt.d.ts.map +1 -0
  4. package/dist/chunk/cac.d.ts +18 -0
  5. package/dist/chunk/cac.d.ts.map +1 -0
  6. package/dist/chunk/constants.d.ts +10 -0
  7. package/dist/chunk/constants.d.ts.map +1 -0
  8. package/dist/chunk/encrypted-cac.d.ts +48 -0
  9. package/dist/chunk/encrypted-cac.d.ts.map +1 -0
  10. package/dist/chunk/encryption.d.ts +86 -0
  11. package/dist/chunk/encryption.d.ts.map +1 -0
  12. package/dist/chunk/index.d.ts +6 -0
  13. package/dist/chunk/index.d.ts.map +1 -0
  14. package/dist/index.d.ts +46 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/proxy/act/act.d.ts +78 -0
  17. package/dist/proxy/act/act.d.ts.map +1 -0
  18. package/dist/proxy/act/crypto.d.ts +44 -0
  19. package/dist/proxy/act/crypto.d.ts.map +1 -0
  20. package/dist/proxy/act/grantee-list.d.ts +82 -0
  21. package/dist/proxy/act/grantee-list.d.ts.map +1 -0
  22. package/dist/proxy/act/history.d.ts +183 -0
  23. package/dist/proxy/act/history.d.ts.map +1 -0
  24. package/dist/proxy/act/index.d.ts +104 -0
  25. package/dist/proxy/act/index.d.ts.map +1 -0
  26. package/dist/proxy/chunking-encrypted.d.ts +14 -0
  27. package/dist/proxy/chunking-encrypted.d.ts.map +1 -0
  28. package/dist/proxy/chunking.d.ts +15 -0
  29. package/dist/proxy/chunking.d.ts.map +1 -0
  30. package/dist/proxy/download-data.d.ts +16 -0
  31. package/dist/proxy/download-data.d.ts.map +1 -0
  32. package/dist/proxy/feed-manifest.d.ts +62 -0
  33. package/dist/proxy/feed-manifest.d.ts.map +1 -0
  34. package/dist/proxy/feeds/epochs/async-finder.d.ts +77 -0
  35. package/dist/proxy/feeds/epochs/async-finder.d.ts.map +1 -0
  36. package/dist/proxy/feeds/epochs/epoch.d.ts +88 -0
  37. package/dist/proxy/feeds/epochs/epoch.d.ts.map +1 -0
  38. package/dist/proxy/feeds/epochs/finder.d.ts +67 -0
  39. package/dist/proxy/feeds/epochs/finder.d.ts.map +1 -0
  40. package/dist/proxy/feeds/epochs/index.d.ts +35 -0
  41. package/dist/proxy/feeds/epochs/index.d.ts.map +1 -0
  42. package/dist/proxy/feeds/epochs/test-utils.d.ts +93 -0
  43. package/dist/proxy/feeds/epochs/test-utils.d.ts.map +1 -0
  44. package/dist/proxy/feeds/epochs/types.d.ts +109 -0
  45. package/dist/proxy/feeds/epochs/types.d.ts.map +1 -0
  46. package/dist/proxy/feeds/epochs/updater.d.ts +68 -0
  47. package/dist/proxy/feeds/epochs/updater.d.ts.map +1 -0
  48. package/dist/proxy/feeds/epochs/utils.d.ts +22 -0
  49. package/dist/proxy/feeds/epochs/utils.d.ts.map +1 -0
  50. package/dist/proxy/feeds/index.d.ts +5 -0
  51. package/dist/proxy/feeds/index.d.ts.map +1 -0
  52. package/dist/proxy/feeds/sequence/async-finder.d.ts +14 -0
  53. package/dist/proxy/feeds/sequence/async-finder.d.ts.map +1 -0
  54. package/dist/proxy/feeds/sequence/finder.d.ts +17 -0
  55. package/dist/proxy/feeds/sequence/finder.d.ts.map +1 -0
  56. package/dist/proxy/feeds/sequence/index.d.ts +23 -0
  57. package/dist/proxy/feeds/sequence/index.d.ts.map +1 -0
  58. package/dist/proxy/feeds/sequence/types.d.ts +80 -0
  59. package/dist/proxy/feeds/sequence/types.d.ts.map +1 -0
  60. package/dist/proxy/feeds/sequence/updater.d.ts +26 -0
  61. package/dist/proxy/feeds/sequence/updater.d.ts.map +1 -0
  62. package/dist/proxy/index.d.ts +6 -0
  63. package/dist/proxy/index.d.ts.map +1 -0
  64. package/dist/proxy/manifest-builder.d.ts +183 -0
  65. package/dist/proxy/manifest-builder.d.ts.map +1 -0
  66. package/dist/proxy/mantaray-encrypted.d.ts +27 -0
  67. package/dist/proxy/mantaray-encrypted.d.ts.map +1 -0
  68. package/dist/proxy/mantaray.d.ts +26 -0
  69. package/dist/proxy/mantaray.d.ts.map +1 -0
  70. package/dist/proxy/types.d.ts +29 -0
  71. package/dist/proxy/types.d.ts.map +1 -0
  72. package/dist/proxy/upload-data.d.ts +17 -0
  73. package/dist/proxy/upload-data.d.ts.map +1 -0
  74. package/dist/proxy/upload-encrypted-data.d.ts +103 -0
  75. package/dist/proxy/upload-encrypted-data.d.ts.map +1 -0
  76. package/dist/schemas.d.ts +240 -0
  77. package/dist/schemas.d.ts.map +1 -0
  78. package/dist/storage/debounced-uploader.d.ts +62 -0
  79. package/dist/storage/debounced-uploader.d.ts.map +1 -0
  80. package/dist/storage/utilization-store.d.ts +108 -0
  81. package/dist/storage/utilization-store.d.ts.map +1 -0
  82. package/dist/swarm-id-auth.d.ts +74 -0
  83. package/dist/swarm-id-auth.d.ts.map +1 -0
  84. package/dist/swarm-id-auth.js +2 -0
  85. package/dist/swarm-id-auth.js.map +1 -0
  86. package/dist/swarm-id-client.d.ts +878 -0
  87. package/dist/swarm-id-client.d.ts.map +1 -0
  88. package/dist/swarm-id-client.js +2 -0
  89. package/dist/swarm-id-client.js.map +1 -0
  90. package/dist/swarm-id-proxy.d.ts +236 -0
  91. package/dist/swarm-id-proxy.d.ts.map +1 -0
  92. package/dist/swarm-id-proxy.js +2 -0
  93. package/dist/swarm-id-proxy.js.map +1 -0
  94. package/dist/swarm-id.esm.js +2 -0
  95. package/dist/swarm-id.esm.js.map +1 -0
  96. package/dist/swarm-id.umd.js +2 -0
  97. package/dist/swarm-id.umd.js.map +1 -0
  98. package/dist/sync/index.d.ts +9 -0
  99. package/dist/sync/index.d.ts.map +1 -0
  100. package/dist/sync/key-derivation.d.ts +25 -0
  101. package/dist/sync/key-derivation.d.ts.map +1 -0
  102. package/dist/sync/restore-account.d.ts +28 -0
  103. package/dist/sync/restore-account.d.ts.map +1 -0
  104. package/dist/sync/serialization.d.ts +16 -0
  105. package/dist/sync/serialization.d.ts.map +1 -0
  106. package/dist/sync/store-interfaces.d.ts +53 -0
  107. package/dist/sync/store-interfaces.d.ts.map +1 -0
  108. package/dist/sync/sync-account.d.ts +44 -0
  109. package/dist/sync/sync-account.d.ts.map +1 -0
  110. package/dist/sync/types.d.ts +13 -0
  111. package/dist/sync/types.d.ts.map +1 -0
  112. package/dist/test-fixtures.d.ts +17 -0
  113. package/dist/test-fixtures.d.ts.map +1 -0
  114. package/dist/types-BD_VkNn0.js +2 -0
  115. package/dist/types-BD_VkNn0.js.map +1 -0
  116. package/dist/types-lJCaT-50.js +2 -0
  117. package/dist/types-lJCaT-50.js.map +1 -0
  118. package/dist/types.d.ts +2157 -0
  119. package/dist/types.d.ts.map +1 -0
  120. package/dist/utils/account-payload.d.ts +94 -0
  121. package/dist/utils/account-payload.d.ts.map +1 -0
  122. package/dist/utils/account-state-snapshot.d.ts +38 -0
  123. package/dist/utils/account-state-snapshot.d.ts.map +1 -0
  124. package/dist/utils/backup-encryption.d.ts +127 -0
  125. package/dist/utils/backup-encryption.d.ts.map +1 -0
  126. package/dist/utils/batch-utilization.d.ts +432 -0
  127. package/dist/utils/batch-utilization.d.ts.map +1 -0
  128. package/dist/utils/constants.d.ts +11 -0
  129. package/dist/utils/constants.d.ts.map +1 -0
  130. package/dist/utils/hex.d.ts +17 -0
  131. package/dist/utils/hex.d.ts.map +1 -0
  132. package/dist/utils/key-derivation.d.ts +92 -0
  133. package/dist/utils/key-derivation.d.ts.map +1 -0
  134. package/dist/utils/storage-managers.d.ts +65 -0
  135. package/dist/utils/storage-managers.d.ts.map +1 -0
  136. package/dist/utils/swarm-id-export.d.ts +24 -0
  137. package/dist/utils/swarm-id-export.d.ts.map +1 -0
  138. package/dist/utils/ttl.d.ts +49 -0
  139. package/dist/utils/ttl.d.ts.map +1 -0
  140. package/dist/utils/url.d.ts +41 -0
  141. package/dist/utils/url.d.ts.map +1 -0
  142. package/dist/utils/versioned-storage.d.ts +131 -0
  143. package/dist/utils/versioned-storage.d.ts.map +1 -0
  144. package/package.json +78 -0
  145. package/src/chunk/bmt.test.ts +217 -0
  146. package/src/chunk/bmt.ts +57 -0
  147. package/src/chunk/cac.test.ts +214 -0
  148. package/src/chunk/cac.ts +65 -0
  149. package/src/chunk/constants.ts +18 -0
  150. package/src/chunk/encrypted-cac.test.ts +385 -0
  151. package/src/chunk/encrypted-cac.ts +131 -0
  152. package/src/chunk/encryption.test.ts +352 -0
  153. package/src/chunk/encryption.ts +300 -0
  154. package/src/chunk/index.ts +47 -0
  155. package/src/index.ts +430 -0
  156. package/src/proxy/act/act.test.ts +278 -0
  157. package/src/proxy/act/act.ts +158 -0
  158. package/src/proxy/act/bee-compat.test.ts +948 -0
  159. package/src/proxy/act/crypto.test.ts +436 -0
  160. package/src/proxy/act/crypto.ts +376 -0
  161. package/src/proxy/act/grantee-list.test.ts +393 -0
  162. package/src/proxy/act/grantee-list.ts +239 -0
  163. package/src/proxy/act/history.test.ts +360 -0
  164. package/src/proxy/act/history.ts +413 -0
  165. package/src/proxy/act/index.test.ts +748 -0
  166. package/src/proxy/act/index.ts +853 -0
  167. package/src/proxy/chunking-encrypted.ts +95 -0
  168. package/src/proxy/chunking.ts +65 -0
  169. package/src/proxy/download-data.ts +448 -0
  170. package/src/proxy/feed-manifest.ts +174 -0
  171. package/src/proxy/feeds/epochs/async-finder.ts +372 -0
  172. package/src/proxy/feeds/epochs/epoch.test.ts +249 -0
  173. package/src/proxy/feeds/epochs/epoch.ts +181 -0
  174. package/src/proxy/feeds/epochs/finder.ts +282 -0
  175. package/src/proxy/feeds/epochs/index.ts +73 -0
  176. package/src/proxy/feeds/epochs/integration.test.ts +1336 -0
  177. package/src/proxy/feeds/epochs/test-utils.ts +274 -0
  178. package/src/proxy/feeds/epochs/types.ts +128 -0
  179. package/src/proxy/feeds/epochs/updater.ts +192 -0
  180. package/src/proxy/feeds/epochs/utils.ts +62 -0
  181. package/src/proxy/feeds/index.ts +5 -0
  182. package/src/proxy/feeds/sequence/async-finder.ts +31 -0
  183. package/src/proxy/feeds/sequence/finder.ts +73 -0
  184. package/src/proxy/feeds/sequence/index.ts +54 -0
  185. package/src/proxy/feeds/sequence/integration.test.ts +966 -0
  186. package/src/proxy/feeds/sequence/types.ts +103 -0
  187. package/src/proxy/feeds/sequence/updater.ts +71 -0
  188. package/src/proxy/index.ts +5 -0
  189. package/src/proxy/manifest-builder.test.ts +427 -0
  190. package/src/proxy/manifest-builder.ts +679 -0
  191. package/src/proxy/mantaray-encrypted.ts +78 -0
  192. package/src/proxy/mantaray.ts +104 -0
  193. package/src/proxy/types.ts +32 -0
  194. package/src/proxy/upload-data.ts +189 -0
  195. package/src/proxy/upload-encrypted-data.ts +658 -0
  196. package/src/schemas.ts +299 -0
  197. package/src/storage/debounced-uploader.ts +192 -0
  198. package/src/storage/utilization-store.ts +397 -0
  199. package/src/swarm-id-client.test.ts +99 -0
  200. package/src/swarm-id-client.ts +3095 -0
  201. package/src/swarm-id-proxy.ts +3891 -0
  202. package/src/sync/index.ts +28 -0
  203. package/src/sync/restore-account.ts +90 -0
  204. package/src/sync/serialization.ts +39 -0
  205. package/src/sync/store-interfaces.ts +62 -0
  206. package/src/sync/sync-account.test.ts +302 -0
  207. package/src/sync/sync-account.ts +396 -0
  208. package/src/sync/types.ts +11 -0
  209. package/src/test-fixtures.ts +109 -0
  210. package/src/types.ts +1651 -0
  211. package/src/utils/account-state-snapshot.test.ts +595 -0
  212. package/src/utils/account-state-snapshot.ts +94 -0
  213. package/src/utils/backup-encryption.test.ts +442 -0
  214. package/src/utils/backup-encryption.ts +352 -0
  215. package/src/utils/batch-utilization.ts +1309 -0
  216. package/src/utils/constants.ts +20 -0
  217. package/src/utils/hex.ts +27 -0
  218. package/src/utils/key-derivation.ts +197 -0
  219. package/src/utils/storage-managers.ts +365 -0
  220. package/src/utils/ttl.ts +129 -0
  221. package/src/utils/url.test.ts +136 -0
  222. package/src/utils/url.ts +71 -0
  223. package/src/utils/versioned-storage.ts +323 -0
@@ -0,0 +1,2 @@
1
+ function e(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:a,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);const o=a.prototype,i=Object.keys(o);for(let e=0;e<i.length;e++){const t=i[e];t in n||(n[t]=o[t].bind(n))}}const o=n?.Parent??Object;class i extends o{}function a(e){var t;const o=n?.Parent?new i:this;r(o,e),(t=o._zod).deferred??(t.deferred=[]);for(const e of o._zod.deferred)e();return o}return Object.defineProperty(i,"name",{value:e}),Object.defineProperty(a,"init",{value:r}),Object.defineProperty(a,Symbol.hasInstance,{value:t=>!!(n?.Parent&&t instanceof n.Parent)||t?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}class t extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class n extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name="ZodEncodeError"}}const r={};function o(e){return r}function i(e,t){return"bigint"==typeof t?t.toString():t}function a(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function s(e){return null==e}function c(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}const u=Symbol("evaluating");function l(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==u)return void 0===r&&(r=u,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function f(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function h(...e){const t={};for(const n of e){const e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function d(e){return JSON.stringify(e)}const p="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function m(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}const g=a(()=>{if("undefined"!=typeof navigator&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(e){return!1}});function y(e){if(!1===m(e))return!1;const t=e.constructor;if(void 0===t)return!0;if("function"!=typeof t)return!0;const n=t.prototype;return!1!==m(n)&&!1!==Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")}function b(e){return y(e)?{...e}:Array.isArray(e)?[...e]:e}const w=new Set(["string","number","symbol"]);function v(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function E(e,t,n){const r=new e._zod.constr(t??e._zod.def);return t&&!n?.parent||(r._zod.parent=e),r}function x(e){const t=e;if(!t)return{};if("string"==typeof t)return{error:()=>t};if(void 0!==t?.message){if(void 0!==t?.error)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,"string"==typeof t.error?{...t,error:()=>t.error}:t}const B={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function T(e,t=0){if(!0===e.aborted)return!0;for(let n=t;n<e.issues.length;n++)if(!0!==e.issues[n]?.continue)return!0;return!1}function A(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function O(e){return"string"==typeof e?e:e?.message}function R(e,t,n){const r={...e,path:e.path??[]};if(!e.message){const o=O(e.inst?._zod.def?.error?.(e))??O(t?.error?.(e))??O(n.customError?.(e))??O(n.localeError?.(e))??"Invalid input";r.message=o}return delete r.inst,delete r.continue,t?.reportInput||delete r.input,r}function k(e){return Array.isArray(e)?"array":"string"==typeof e?"string":"unknown"}function S(...e){const[t,n,r]=e;return"string"==typeof t?{message:t,code:"custom",input:n,inst:r}:{...t}}const $=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,i,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},z=e("$ZodError",$),D=e("$ZodError",$,{Parent:Error});const I=e=>(n,r,i,a)=>{const s=i?Object.assign(i,{async:!1}):{async:!1},c=n._zod.run({value:r,issues:[]},s);if(c instanceof Promise)throw new t;if(c.issues.length){const t=new(a?.Err??e)(c.issues.map(e=>R(e,s,o())));throw p(t,a?.callee),t}return c.value},P=e=>async(t,n,r,i)=>{const a=r?Object.assign(r,{async:!0}):{async:!0};let s=t._zod.run({value:n,issues:[]},a);if(s instanceof Promise&&(s=await s),s.issues.length){const t=new(i?.Err??e)(s.issues.map(e=>R(e,a,o())));throw p(t,i?.callee),t}return s.value},C=e=>(n,r,i)=>{const a=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},a);if(s instanceof Promise)throw new t;return s.issues.length?{success:!1,error:new(e??z)(s.issues.map(e=>R(e,a,o())))}:{success:!0,data:s.value}},N=C(D),_=e=>async(t,n,r)=>{const i=r?Object.assign(r,{async:!0}):{async:!0};let a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>R(e,i,o())))}:{success:!0,data:a.value}},V=_(D),U=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return I(e)(t,n,o)},F=e=>(t,n,r)=>I(e)(t,n,r),M=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return P(e)(t,n,o)},j=e=>async(t,n,r)=>P(e)(t,n,r),L=e=>(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return C(e)(t,n,o)},G=e=>(t,n,r)=>C(e)(t,n,r),q=e=>async(t,n,r)=>{const o=r?Object.assign(r,{direction:"backward"}):{direction:"backward"};return _(e)(t,n,o)},H=e=>async(t,n,r)=>_(e)(t,n,r),Z=/^[cC][^\s-]{8,}$/,W=/^[0-9a-z]+$/,K=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,J=/^[0-9a-vA-V]{20}$/,X=/^[A-Za-z0-9]{27}$/,Y=/^[a-zA-Z0-9_-]{21}$/,Q=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,ee=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,te=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,ne=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;const re=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,oe=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,ie=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,ae=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,se=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,ce=/^[A-Za-z0-9_-]*$/,ue=/^\+(?:[0-9]){6,14}[0-9]$/,le="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",fe=new RegExp(`^${le}$`);function he(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return"number"==typeof e.precision?-1===e.precision?`${t}`:0===e.precision?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}const de=/^-?\d+$/,pe=/^-?\d+(?:\.\d+)?/,me=/^(?:true|false)$/i,ge=/^[^A-Z]*$/,ye=/^[^a-z]*$/,be=e("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),we={number:"number",bigint:"bigint",object:"date"},ve=e("$ZodCheckLessThan",(e,t)=>{be.init(e,t);const n=we[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:"too_big",maximum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ee=e("$ZodCheckGreaterThan",(e,t)=>{be.init(e,t);const n=we[typeof t.value];e._zod.onattach.push(e=>{const n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:"too_small",minimum:t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xe=e("$ZodCheckMultipleOf",(e,t)=>{be.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");("bigint"==typeof n.value?n.value%t.value===BigInt(0):0===function(e,t){const n=(e.toString().split(".")[1]||"").length,r=t.toString();let o=(r.split(".")[1]||"").length;if(0===o&&/\d?e-\d?/.test(r)){const e=r.match(/\d?e-(\d?)/);e?.[1]&&(o=Number.parseInt(e[1]))}const i=n>o?n:o;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}(n.value,t.value))||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Be=e("$ZodCheckNumberFormat",(e,t)=>{be.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=B[t.format];e._zod.onattach.push(e=>{const r=e._zod.bag;r.format=t.format,r.minimum=o,r.maximum=i,n&&(r.pattern=de)}),e._zod.check=a=>{const s=a.value;if(n){if(!Number.isInteger(s))return void a.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});if(!Number.isSafeInteger(s))return void(s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,continue:!t.abort}))}s<o&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),Te=e("$ZodCheckMaxLength",(e,t)=>{var n;be.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!s(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{const r=n.value;if(r.length<=t.maximum)return;const o=k(r);n.issues.push({origin:o,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ae=e("$ZodCheckMinLength",(e,t)=>{var n;be.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!s(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{const r=n.value;if(r.length>=t.minimum)return;const o=k(r);n.issues.push({origin:o,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Oe=e("$ZodCheckLengthEquals",(e,t)=>{var n;be.init(e,t),(n=e._zod.def).when??(n.when=e=>{const t=e.value;return!s(t)&&void 0!==t.length}),e._zod.onattach.push(e=>{const n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{const r=n.value,o=r.length;if(o===t.length)return;const i=k(r),a=o>t.length;n.issues.push({origin:i,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Re=e("$ZodCheckStringFormat",(e,t)=>{var n,r;be.init(e,t),e._zod.onattach.push(e=>{const n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??(n.patterns=new Set),n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),ke=e("$ZodCheckRegex",(e,t)=>{Re.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Se=e("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=ge),Re.init(e,t)}),$e=e("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=ye),Re.init(e,t)}),ze=e("$ZodCheckIncludes",(e,t)=>{be.init(e,t);const n=v(t.includes),r=new RegExp("number"==typeof t.position?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),De=e("$ZodCheckStartsWith",(e,t)=>{be.init(e,t);const n=new RegExp(`^${v(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Ie=e("$ZodCheckEndsWith",(e,t)=>{be.init(e,t);const n=new RegExp(`.*${v(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(e=>{const t=e._zod.bag;t.patterns??(t.patterns=new Set),t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Pe=e("$ZodCheckOverwrite",(e,t)=>{be.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}});class Ce{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),this.indent-=1}write(e){if("function"==typeof e)return e(this,{execution:"sync"}),void e(this,{execution:"async"});const t=e.split("\n").filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>" ".repeat(2*this.indent)+e);for(const e of r)this.content.push(e)}compile(){const e=Function,t=this?.args;return new e(...t,[...(this?.content??[""]).map(e=>` ${e}`)].join("\n"))}}const Ne={major:4,minor:1,patch:13},_e=e("$ZodType",(e,n)=>{var r;e??(e={}),e._zod.def=n,e._zod.bag=e._zod.bag||{},e._zod.version=Ne;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const t of o)for(const n of t._zod.onattach)n(e);if(0===o.length)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const n=(e,n,r)=>{let o,i=T(e);for(const a of n){if(a._zod.def.when){if(!a._zod.def.when(e))continue}else if(i)continue;const n=e.issues.length,s=a._zod.check(e);if(s instanceof Promise&&!1===r?.async)throw new t;if(o||s instanceof Promise)o=(o??Promise.resolve()).then(async()=>{await s;e.issues.length!==n&&(i||(i=T(e,n)))});else{if(e.issues.length===n)continue;i||(i=T(e,n))}}return o?o.then(()=>e):e},r=(r,i,a)=>{if(T(r))return r.aborted=!0,r;const s=n(i,o,a);if(s instanceof Promise){if(!1===a.async)throw new t;return s.then(t=>e._zod.parse(t,a))}return e._zod.parse(s,a)};e._zod.run=(i,a)=>{if(a.skipChecks)return e._zod.parse(i,a);if("backward"===a.direction){const t=e._zod.parse({value:i.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>r(e,i,a)):r(t,i,a)}const s=e._zod.parse(i,a);if(s instanceof Promise){if(!1===a.async)throw new t;return s.then(e=>n(e,o,a))}return n(s,o,a)}}e["~standard"]={validate:t=>{try{const n=N(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch(n){return V(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:"zod",version:1}}),Ve=e("$ZodString",(e,t)=>{var n;_e.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??(n=e._zod.bag,new RegExp(`^${n?`[\\s\\S]{${n?.minimum??0},${n?.maximum??""}}`:"[\\s\\S]*"}$`)),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch(r){}return"string"==typeof n.value||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),Ue=e("$ZodStringFormat",(e,t)=>{Re.init(e,t),Ve.init(e,t)}),Fe=e("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ee),Ue.init(e,t)}),Me=e("$ZodUUID",(e,t)=>{if(t.version){const e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(void 0===e)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=te(e))}else t.pattern??(t.pattern=te());Ue.init(e,t)}),je=e("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=ne),Ue.init(e,t)}),Le=e("$ZodURL",(e,t)=>{Ue.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=new URL(r);return t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(o.hostname)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(o.protocol.endsWith(":")?o.protocol.slice(0,-1):o.protocol)||n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),void(t.normalize?n.value=o.href:n.value=r)}catch(r){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Ge=e("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ue.init(e,t)}),qe=e("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Y),Ue.init(e,t)}),He=e("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Z),Ue.init(e,t)}),Ze=e("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=W),Ue.init(e,t)}),We=e("$ZodULID",(e,t)=>{t.pattern??(t.pattern=K),Ue.init(e,t)}),Ke=e("$ZodXID",(e,t)=>{t.pattern??(t.pattern=J),Ue.init(e,t)}),Je=e("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=X),Ue.init(e,t)}),Xe=e("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=function(e){const t=he({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const r=`${t}(?:${n.join("|")})`;return new RegExp(`^${le}T(?:${r})$`)}(t)),Ue.init(e,t)}),Ye=e("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=fe),Ue.init(e,t)}),Qe=e("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=new RegExp(`^${he(t)}$`)),Ue.init(e,t)}),et=e("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Q),Ue.init(e,t)}),tt=e("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=re),Ue.init(e,t),e._zod.bag.format="ipv4"}),nt=e("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=oe),Ue.init(e,t),e._zod.bag.format="ipv6",e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}}),rt=e("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ie),Ue.init(e,t)}),ot=e("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=ae),Ue.init(e,t),e._zod.check=n=>{const r=n.value.split("/");try{if(2!==r.length)throw new Error;const[e,t]=r;if(!t)throw new Error;const n=Number(t);if(`${n}`!==t)throw new Error;if(n<0||n>128)throw new Error;new URL(`http://[${e}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function it(e){if(""===e)return!0;if(e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}const at=e("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=se),Ue.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{it(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});const st=e("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=ce),Ue.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{(function(e){if(!ce.test(e))return!1;const t=e.replace(/[-_]/g,e=>"-"===e?"+":"/");return it(t.padEnd(4*Math.ceil(t.length/4),"="))})(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),ct=e("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ue),Ue.init(e,t)});const ut=e("$ZodJWT",(e,t)=>{Ue.init(e,t),e._zod.check=n=>{(function(e,t=null){try{const n=e.split(".");if(3!==n.length)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&"JWT"!==o?.typ||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}})(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),lt=e("$ZodNumber",(e,t)=>{_e.init(e,t),e._zod.pattern=e._zod.bag.pattern??pe,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch(e){}const o=n.value;if("number"==typeof o&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i="number"==typeof o?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),ft=e("$ZodNumberFormat",(e,t)=>{Be.init(e,t),lt.init(e,t)}),ht=e("$ZodBoolean",(e,t)=>{_e.init(e,t),e._zod.pattern=me,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Boolean(n.value)}catch(e){}const o=n.value;return"boolean"==typeof o||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),dt=e("$ZodUnknown",(e,t)=>{_e.init(e,t),e._zod.parse=e=>e}),pt=e("$ZodNever",(e,t)=>{_e.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:"never",code:"invalid_type",input:t.value,inst:e}),t)});function mt(e,t,n){e.issues.length&&t.issues.push(...A(n,e.issues)),t.value[n]=e.value}const gt=e("$ZodArray",(e,t)=>{_e.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;if(!Array.isArray(o))return n.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),n;n.value=Array(o.length);const i=[];for(let e=0;e<o.length;e++){const a=o[e],s=t.element._zod.run({value:a,issues:[]},r);s instanceof Promise?i.push(s.then(t=>mt(t,n,e))):mt(s,n,e)}return i.length?Promise.all(i).then(()=>n):n}});function yt(e,t,n,r){e.issues.length&&t.issues.push(...A(n,e.issues)),void 0===e.value?n in r&&(t.value[n]=void 0):t.value[n]=e.value}function bt(e){const t=Object.keys(e.shape);for(const n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);const n=(r=e.shape,Object.keys(r).filter(e=>"optional"===r[e]._zod.optin&&"optional"===r[e]._zod.optout));var r;return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function wt(e,t,n,r,o,i){const a=[],s=o.keySet,c=o.catchall._zod,u=c.def.type;for(const o in t){if(s.has(o))continue;if("never"===u){a.push(o);continue}const i=c.run({value:t[o],issues:[]},r);i instanceof Promise?e.push(i.then(e=>yt(e,n,o,t))):yt(i,n,o,t)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const vt=e("$ZodObject",(e,t)=>{_e.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape");if(!n?.get){const e=t.shape;Object.defineProperty(t,"shape",{get:()=>{const n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}const r=a(()=>bt(t));l(e._zod,"propValues",()=>{const e=t.shape,n={};for(const t in e){const r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(const e of r.values)n[t].add(e)}}return n});const o=m,i=t.catchall;let s;e._zod.parse=(t,n)=>{s??(s=r.value);const a=t.value;if(!o(a))return t.issues.push({expected:"object",code:"invalid_type",input:a,inst:e}),t;t.value={};const c=[],u=s.shape;for(const e of s.keys){const r=u[e]._zod.run({value:a[e],issues:[]},n);r instanceof Promise?c.push(r.then(n=>yt(n,t,e,a))):yt(r,t,e,a)}return i?wt(c,a,t,n,r.value,e):c.length?Promise.all(c).then(()=>t):t}}),Et=e("$ZodObjectJIT",(e,t)=>{vt.init(e,t);const n=e._zod.parse,o=a(()=>bt(t));let i;const s=m,c=!r.jitless,u=c&&g.value,l=t.catchall;let f;e._zod.parse=(r,a)=>{f??(f=o.value);const h=r.value;return s(h)?c&&u&&!1===a?.async&&!0!==a.jitless?(i||(i=(e=>{const t=new Ce(["shape","payload","ctx"]),n=o.value,r=e=>{const t=d(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write("const input = payload.value;");const i=Object.create(null);let a=0;for(const e of n.keys)i[e]="key_"+a++;t.write("const newResult = {};");for(const e of n.keys){const n=i[e],o=d(e);t.write(`const ${n} = ${r(e)};`),t.write(`\n if (${n}.issues.length) {\n payload.issues = payload.issues.concat(${n}.issues.map(iss => ({\n ...iss,\n path: iss.path ? [${o}, ...iss.path] : [${o}]\n })));\n }\n \n \n if (${n}.value === undefined) {\n if (${o} in input) {\n newResult[${o}] = undefined;\n }\n } else {\n newResult[${o}] = ${n}.value;\n }\n \n `)}t.write("payload.value = newResult;"),t.write("return payload;");const s=t.compile();return(t,n)=>s(e,t,n)})(t.shape)),r=i(r,a),l?wt([],h,r,a,f,e):r):n(r,a):(r.issues.push({expected:"object",code:"invalid_type",input:h,inst:e}),r)}});function xt(e,t,n,r){for(const n of e)if(0===n.issues.length)return t.value=n.value,t;const i=e.filter(e=>!T(e));return 1===i.length?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>R(e,r,o())))}),t)}const Bt=e("$ZodUnion",(e,t)=>{_e.init(e,t),l(e._zod,"optin",()=>t.options.some(e=>"optional"===e._zod.optin)?"optional":void 0),l(e._zod,"optout",()=>t.options.some(e=>"optional"===e._zod.optout)?"optional":void 0),l(e._zod,"values",()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),l(e._zod,"pattern",()=>{if(t.options.every(e=>e._zod.pattern)){const e=t.options.map(e=>e._zod.pattern);return new RegExp(`^(${e.map(e=>c(e.source)).join("|")})$`)}});const n=1===t.options.length,r=t.options[0]._zod.run;e._zod.parse=(o,i)=>{if(n)return r(o,i);let a=!1;const s=[];for(const e of t.options){const t=e._zod.run({value:o.value,issues:[]},i);if(t instanceof Promise)s.push(t),a=!0;else{if(0===t.issues.length)return t;s.push(t)}}return a?Promise.all(s).then(t=>xt(t,o,e,i)):xt(s,o,e,i)}}),Tt=e("$ZodDiscriminatedUnion",(e,t)=>{Bt.init(e,t);const n=e._zod.parse;l(e._zod,"propValues",()=>{const e={};for(const n of t.options){const r=n._zod.propValues;if(!r||0===Object.keys(r).length)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(n)}"`);for(const[t,n]of Object.entries(r)){e[t]||(e[t]=new Set);for(const r of n)e[t].add(r)}}return e});const r=a(()=>{const e=t.options,n=new Map;for(const r of e){const e=r._zod.propValues?.[t.discriminator];if(!e||0===e.size)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(r)}"`);for(const t of e){if(n.has(t))throw new Error(`Duplicate discriminator value "${String(t)}"`);n.set(t,r)}}return n});e._zod.parse=(o,i)=>{const a=o.value;if(!m(a))return o.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),o;const s=r.value.get(a?.[t.discriminator]);return s?s._zod.run(o,i):t.unionFallback?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),o)}}),At=e("$ZodIntersection",(e,t)=>{_e.init(e,t),e._zod.parse=(e,n)=>{const r=e.value,o=t.left._zod.run({value:r,issues:[]},n),i=t.right._zod.run({value:r,issues:[]},n);return o instanceof Promise||i instanceof Promise?Promise.all([o,i]).then(([t,n])=>Rt(e,t,n)):Rt(e,o,i)}});function Ot(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e===+t)return{valid:!0,data:e};if(y(e)&&y(t)){const n=Object.keys(t),r=Object.keys(e).filter(e=>-1!==n.indexOf(e)),o={...e,...t};for(const n of r){const r=Ot(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};o[n]=r.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=Ot(e[r],t[r]);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Rt(e,t,n){if(t.issues.length&&e.issues.push(...t.issues),n.issues.length&&e.issues.push(...n.issues),T(e))return e;const r=Ot(t.value,n.value);if(!r.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(r.mergeErrorPath)}`);return e.value=r.data,e}const kt=e("$ZodEnum",(e,t)=>{_e.init(e,t);const n=function(e){const t=Object.values(e).filter(e=>"number"==typeof e);return Object.entries(e).filter(([e,n])=>-1===t.indexOf(+e)).map(([e,t])=>t)}(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=new RegExp(`^(${n.filter(e=>w.has(typeof e)).map(e=>"string"==typeof e?v(e):e.toString()).join("|")})$`),e._zod.parse=(t,o)=>{const i=t.value;return r.has(i)||t.issues.push({code:"invalid_value",values:n,input:i,inst:e}),t}}),St=e("$ZodLiteral",(e,t)=>{if(_e.init(e,t),0===t.values.length)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(e=>"string"==typeof e?v(e):e?v(e.toString()):String(e)).join("|")})$`),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),$t=e("$ZodTransform",(e,r)=>{_e.init(e,r),e._zod.parse=(o,i)=>{if("backward"===i.direction)throw new n(e.constructor.name);const a=r.transform(o.value,o);if(i.async){return(a instanceof Promise?a:Promise.resolve(a)).then(e=>(o.value=e,o))}if(a instanceof Promise)throw new t;return o.value=a,o}});function zt(e,t){return e.issues.length&&void 0===t?{issues:[],value:void 0}:e}const Dt=e("$ZodOptional",(e,t)=>{_e.init(e,t),e._zod.optin="optional",e._zod.optout="optional",l(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),l(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${c(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if("optional"===t.innerType._zod.optin){const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(t=>zt(t,e.value)):zt(r,e.value)}return void 0===e.value?e:t.innerType._zod.run(e,n)}}),It=e("$ZodNullable",(e,t)=>{_e.init(e,t),l(e._zod,"optin",()=>t.innerType._zod.optin),l(e._zod,"optout",()=>t.innerType._zod.optout),l(e._zod,"pattern",()=>{const e=t.innerType._zod.pattern;return e?new RegExp(`^(${c(e.source)}|null)$`):void 0}),l(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>null===e.value?e:t.innerType._zod.run(e,n)}),Pt=e("$ZodDefault",(e,t)=>{_e.init(e,t),e._zod.optin="optional",l(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);if(void 0===e.value)return e.value=t.defaultValue,e;const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Ct(e,t)):Ct(r,t)}});function Ct(e,t){return void 0===e.value&&(e.value=t.defaultValue),e}const Nt=e("$ZodPrefault",(e,t)=>{_e.init(e,t),e._zod.optin="optional",l(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>("backward"===n.direction||void 0===e.value&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),_t=e("$ZodNonOptional",(e,t)=>{_e.init(e,t),l(e._zod,"values",()=>{const e=t.innerType._zod.values;return e?new Set([...e].filter(e=>void 0!==e)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(t=>Vt(t,e)):Vt(o,e)}});function Vt(e,t){return e.issues.length||void 0!==e.value||e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const Ut=e("$ZodCatch",(e,t)=>{_e.init(e,t),l(e._zod,"optin",()=>t.innerType._zod.optin),l(e._zod,"optout",()=>t.innerType._zod.optout),l(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>R(e,n,o()))},input:e.value}),e.issues=[]),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>R(e,n,o()))},input:e.value}),e.issues=[]),e)}}),Ft=e("$ZodPipe",(e,t)=>{_e.init(e,t),l(e._zod,"values",()=>t.in._zod.values),l(e._zod,"optin",()=>t.in._zod.optin),l(e._zod,"optout",()=>t.out._zod.optout),l(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if("backward"===n.direction){const r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Mt(e,t.in,n)):Mt(r,t.in,n)}const r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Mt(e,t.out,n)):Mt(r,t.out,n)}});function Mt(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const jt=e("$ZodReadonly",(e,t)=>{_e.init(e,t),l(e._zod,"propValues",()=>t.innerType._zod.propValues),l(e._zod,"values",()=>t.innerType._zod.values),l(e._zod,"optin",()=>t.innerType?._zod?.optin),l(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if("backward"===n.direction)return t.innerType._zod.run(e,n);const r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Lt):Lt(r)}});function Lt(e){return e.value=Object.freeze(e.value),e}const Gt=e("$ZodCustom",(e,t)=>{be.init(e,t),_e.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(t=>qt(t,n,r,e));qt(o,n,r,e)}});function qt(e,t,n,r){if(!e){const e={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(S(e))}}var Ht;class Zt{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){const n=t[0];if(this._map.set(e,n),n&&"object"==typeof n&&"id"in n){if(this._idmap.has(n.id))throw new Error(`ID ${n.id} already exists in the registry`);this._idmap.set(n.id,e)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){const t=this._map.get(e);return t&&"object"==typeof t&&"id"in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){const t=e._zod.parent;if(t){const n={...this.get(t)??{}};delete n.id;const r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}}(Ht=globalThis).__zod_globalRegistry??(Ht.__zod_globalRegistry=new Zt);const Wt=globalThis.__zod_globalRegistry;function Kt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...x(t)})}function Jt(e,t){return new ve({check:"less_than",...x(t),value:e,inclusive:!1})}function Xt(e,t){return new ve({check:"less_than",...x(t),value:e,inclusive:!0})}function Yt(e,t){return new Ee({check:"greater_than",...x(t),value:e,inclusive:!1})}function Qt(e,t){return new Ee({check:"greater_than",...x(t),value:e,inclusive:!0})}function en(e,t){return new xe({check:"multiple_of",...x(t),value:e})}function tn(e,t){return new Te({check:"max_length",...x(t),maximum:e})}function nn(e,t){return new Ae({check:"min_length",...x(t),minimum:e})}function rn(e,t){return new Oe({check:"length_equals",...x(t),length:e})}function on(e){return new Pe({check:"overwrite",tx:e})}function an(e){const t=function(e,t){const n=new be({check:"custom",...x(t)});return n._zod.check=e,n}(n=>(n.addIssue=e=>{if("string"==typeof e)n.issues.push(S(e,n.value,t._zod.def));else{const r=e;r.fatal&&(r.continue=!1),r.code??(r.code="custom"),r.input??(r.input=n.value),r.inst??(r.inst=t),r.continue??(r.continue=!t._zod.def.abort),n.issues.push(S(r))}},e(n.value,n)));return t}const sn=e("ZodISODateTime",(e,t)=>{Xe.init(e,t),Dn.init(e,t)});function cn(e){return function(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...x(t)})}(sn,e)}const un=e("ZodISODate",(e,t)=>{Ye.init(e,t),Dn.init(e,t)});function ln(e){return function(e,t){return new e({type:"string",format:"date",check:"string_format",...x(t)})}(un,e)}const fn=e("ZodISOTime",(e,t)=>{Qe.init(e,t),Dn.init(e,t)});function hn(e){return function(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...x(t)})}(fn,e)}const dn=e("ZodISODuration",(e,t)=>{et.init(e,t),Dn.init(e,t)});function pn(e){return function(e,t){return new e({type:"string",format:"duration",check:"string_format",...x(t)})}(dn,e)}const mn=e("ZodError",(e,t)=>{z.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:t=>function(e,t=e=>e.message){const n={_errors:[]},r=e=>{for(const o of e.issues)if("invalid_union"===o.code&&o.errors.length)o.errors.map(e=>r({issues:e}));else if("invalid_key"===o.code)r({issues:o.issues});else if("invalid_element"===o.code)r({issues:o.issues});else if(0===o.path.length)n._errors.push(t(o));else{let e=n,r=0;for(;r<o.path.length;){const n=o.path[r];r===o.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(o))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(e),n}(e,t)},flatten:{value:t=>function(e,t=e=>e.message){const n={},r=[];for(const o of e.issues)o.path.length>0?(n[o.path[0]]=n[o.path[0]]||[],n[o.path[0]].push(t(o))):r.push(t(o));return{formErrors:r,fieldErrors:n}}(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,i,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,i,2)}},isEmpty:{get:()=>0===e.issues.length}})},{Parent:Error}),gn=I(mn),yn=P(mn),bn=C(mn),wn=_(mn),vn=U(mn),En=F(mn),xn=M(mn),Bn=j(mn),Tn=L(mn),An=G(mn),On=q(mn),Rn=H(mn),kn=e("ZodType",(e,t)=>(_e.init(e,t),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...n)=>e.clone(h(t,{checks:[...t.checks??[],...n.map(e=>"function"==typeof e?{_zod:{check:e,def:{check:"custom"},onattach:[]}}:e)]})),e.clone=(t,n)=>E(e,t,n),e.brand=()=>e,e.register=(t,n)=>(t.add(e,n),e),e.parse=(t,n)=>gn(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>bn(e,t,n),e.parseAsync=async(t,n)=>yn(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>wn(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>vn(e,t,n),e.decode=(t,n)=>En(e,t,n),e.encodeAsync=async(t,n)=>xn(e,t,n),e.decodeAsync=async(t,n)=>Bn(e,t,n),e.safeEncode=(t,n)=>Tn(e,t,n),e.safeDecode=(t,n)=>An(e,t,n),e.safeEncodeAsync=async(t,n)=>On(e,t,n),e.safeDecodeAsync=async(t,n)=>Rn(e,t,n),e.refine=(t,n)=>e.check(function(e,t={}){return function(e,t,n){return new e({type:"custom",check:"custom",fn:t,...x(n)})}(Dr,e,t)}(t,n)),e.superRefine=t=>e.check(an(t)),e.overwrite=t=>e.check(on(t)),e.optional=()=>xr(e),e.nullable=()=>Tr(e),e.nullish=()=>xr(Tr(e)),e.nonoptional=t=>function(e,t){return new Rr({type:"nonoptional",innerType:e,...x(t)})}(e,t),e.array=()=>{return function(e,t,n){return new e({type:"array",element:t,...x(n)})}(cr,e,t);var t},e.or=t=>hr([e,t]),e.and=t=>new mr({type:"intersection",left:e,right:t}),e.transform=t=>$r(e,new vr({type:"transform",transform:t})),e.default=t=>{return n=t,new Ar({type:"default",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.prefault=t=>{return n=t,new Or({type:"prefault",innerType:e,get defaultValue(){return"function"==typeof n?n():b(n)}});var n},e.catch=t=>{return new kr({type:"catch",innerType:e,catchValue:"function"==typeof(n=t)?n:()=>n});var n},e.pipe=t=>$r(e,t),e.readonly=()=>new zr({type:"readonly",innerType:e}),e.describe=t=>{const n=e.clone();return Wt.add(n,{description:t}),n},Object.defineProperty(e,"description",{get:()=>Wt.get(e)?.description,configurable:!0}),e.meta=(...t)=>{if(0===t.length)return Wt.get(e);const n=e.clone();return Wt.add(n,t[0]),n},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),Sn=e("_ZodString",(e,t)=>{Ve.init(e,t),kn.init(e,t);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,e.regex=(...t)=>e.check(function(e,t){return new ke({check:"string_format",format:"regex",...x(t),pattern:e})}(...t)),e.includes=(...t)=>e.check(function(e,t){return new ze({check:"string_format",format:"includes",...x(t),includes:e})}(...t)),e.startsWith=(...t)=>e.check(function(e,t){return new De({check:"string_format",format:"starts_with",...x(t),prefix:e})}(...t)),e.endsWith=(...t)=>e.check(function(e,t){return new Ie({check:"string_format",format:"ends_with",...x(t),suffix:e})}(...t)),e.min=(...t)=>e.check(nn(...t)),e.max=(...t)=>e.check(tn(...t)),e.length=(...t)=>e.check(rn(...t)),e.nonempty=(...t)=>e.check(nn(1,...t)),e.lowercase=t=>e.check(function(e){return new Se({check:"string_format",format:"lowercase",...x(e)})}(t)),e.uppercase=t=>e.check(function(e){return new $e({check:"string_format",format:"uppercase",...x(e)})}(t)),e.trim=()=>e.check(on(e=>e.trim())),e.normalize=(...t)=>e.check(function(e){return on(t=>t.normalize(e))}(...t)),e.toLowerCase=()=>e.check(on(e=>e.toLowerCase())),e.toUpperCase=()=>e.check(on(e=>e.toUpperCase())),e.slugify=()=>e.check(on(e=>function(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}(e)))}),$n=e("ZodString",(e,t)=>{Ve.init(e,t),Sn.init(e,t),e.email=t=>e.check(function(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...x(t)})}(In,t)),e.url=t=>e.check(function(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...x(t)})}(Nn,t)),e.jwt=t=>e.check(function(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...x(t)})}(Xn,t)),e.emoji=t=>e.check(function(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...x(t)})}(_n,t)),e.guid=t=>e.check(Kt(Pn,t)),e.uuid=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...x(t)})}(Cn,t)),e.uuidv4=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...x(t)})}(Cn,t)),e.uuidv6=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...x(t)})}(Cn,t)),e.uuidv7=t=>e.check(function(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...x(t)})}(Cn,t)),e.nanoid=t=>e.check(function(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...x(t)})}(Vn,t)),e.guid=t=>e.check(Kt(Pn,t)),e.cuid=t=>e.check(function(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...x(t)})}(Un,t)),e.cuid2=t=>e.check(function(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...x(t)})}(Fn,t)),e.ulid=t=>e.check(function(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...x(t)})}(Mn,t)),e.base64=t=>e.check(function(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...x(t)})}(Wn,t)),e.base64url=t=>e.check(function(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...x(t)})}(Kn,t)),e.xid=t=>e.check(function(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...x(t)})}(jn,t)),e.ksuid=t=>e.check(function(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...x(t)})}(Ln,t)),e.ipv4=t=>e.check(function(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...x(t)})}(Gn,t)),e.ipv6=t=>e.check(function(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...x(t)})}(qn,t)),e.cidrv4=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...x(t)})}(Hn,t)),e.cidrv6=t=>e.check(function(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...x(t)})}(Zn,t)),e.e164=t=>e.check(function(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...x(t)})}(Jn,t)),e.datetime=t=>e.check(cn(t)),e.date=t=>e.check(ln(t)),e.time=t=>e.check(hn(t)),e.duration=t=>e.check(pn(t))});function zn(e){return function(e,t){return new e({type:"string",...x(t)})}($n,e)}const Dn=e("ZodStringFormat",(e,t)=>{Ue.init(e,t),Sn.init(e,t)}),In=e("ZodEmail",(e,t)=>{je.init(e,t),Dn.init(e,t)}),Pn=e("ZodGUID",(e,t)=>{Fe.init(e,t),Dn.init(e,t)}),Cn=e("ZodUUID",(e,t)=>{Me.init(e,t),Dn.init(e,t)}),Nn=e("ZodURL",(e,t)=>{Le.init(e,t),Dn.init(e,t)}),_n=e("ZodEmoji",(e,t)=>{Ge.init(e,t),Dn.init(e,t)}),Vn=e("ZodNanoID",(e,t)=>{qe.init(e,t),Dn.init(e,t)}),Un=e("ZodCUID",(e,t)=>{He.init(e,t),Dn.init(e,t)}),Fn=e("ZodCUID2",(e,t)=>{Ze.init(e,t),Dn.init(e,t)}),Mn=e("ZodULID",(e,t)=>{We.init(e,t),Dn.init(e,t)}),jn=e("ZodXID",(e,t)=>{Ke.init(e,t),Dn.init(e,t)}),Ln=e("ZodKSUID",(e,t)=>{Je.init(e,t),Dn.init(e,t)}),Gn=e("ZodIPv4",(e,t)=>{tt.init(e,t),Dn.init(e,t)}),qn=e("ZodIPv6",(e,t)=>{nt.init(e,t),Dn.init(e,t)}),Hn=e("ZodCIDRv4",(e,t)=>{rt.init(e,t),Dn.init(e,t)}),Zn=e("ZodCIDRv6",(e,t)=>{ot.init(e,t),Dn.init(e,t)}),Wn=e("ZodBase64",(e,t)=>{at.init(e,t),Dn.init(e,t)}),Kn=e("ZodBase64URL",(e,t)=>{st.init(e,t),Dn.init(e,t)}),Jn=e("ZodE164",(e,t)=>{ct.init(e,t),Dn.init(e,t)}),Xn=e("ZodJWT",(e,t)=>{ut.init(e,t),Dn.init(e,t)}),Yn=e("ZodNumber",(e,t)=>{lt.init(e,t),kn.init(e,t),e.gt=(t,n)=>e.check(Yt(t,n)),e.gte=(t,n)=>e.check(Qt(t,n)),e.min=(t,n)=>e.check(Qt(t,n)),e.lt=(t,n)=>e.check(Jt(t,n)),e.lte=(t,n)=>e.check(Xt(t,n)),e.max=(t,n)=>e.check(Xt(t,n)),e.int=t=>e.check(tr(t)),e.safe=t=>e.check(tr(t)),e.positive=t=>e.check(Yt(0,t)),e.nonnegative=t=>e.check(Qt(0,t)),e.negative=t=>e.check(Jt(0,t)),e.nonpositive=t=>e.check(Xt(0,t)),e.multipleOf=(t,n)=>e.check(en(t,n)),e.step=(t,n)=>e.check(en(t,n)),e.finite=()=>e;const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function Qn(e){return function(e,t){return new e({type:"number",checks:[],...x(t)})}(Yn,e)}const er=e("ZodNumberFormat",(e,t)=>{ft.init(e,t),Yn.init(e,t)});function tr(e){return function(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...x(t)})}(er,e)}const nr=e("ZodBoolean",(e,t)=>{ht.init(e,t),kn.init(e,t)});function rr(e){return function(e,t){return new e({type:"boolean",...x(t)})}(nr,e)}const or=e("ZodUnknown",(e,t)=>{dt.init(e,t),kn.init(e,t)});function ir(){return new or({type:"unknown"})}const ar=e("ZodNever",(e,t)=>{pt.init(e,t),kn.init(e,t)});function sr(e){return function(e,t){return new e({type:"never",...x(t)})}(ar,e)}const cr=e("ZodArray",(e,t)=>{gt.init(e,t),kn.init(e,t),e.element=t.element,e.min=(t,n)=>e.check(nn(t,n)),e.nonempty=t=>e.check(nn(1,t)),e.max=(t,n)=>e.check(tn(t,n)),e.length=(t,n)=>e.check(rn(t,n)),e.unwrap=()=>e.element});const ur=e("ZodObject",(e,t)=>{Et.init(e,t),kn.init(e,t),l(e,"shape",()=>t.shape),e.keyof=()=>yr(Object.keys(e._zod.def.shape)),e.catchall=t=>e.clone({...e._zod.def,catchall:t}),e.passthrough=()=>e.clone({...e._zod.def,catchall:ir()}),e.loose=()=>e.clone({...e._zod.def,catchall:ir()}),e.strict=()=>e.clone({...e._zod.def,catchall:sr()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=t=>function(e,t){if(!y(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const r=h(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t};return f(this,"shape",n),n},checks:[]});return E(e,r)}(e,t),e.safeExtend=t=>function(e,t){if(!y(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n={...e._zod.def,get shape(){const n={...e._zod.def.shape,...t};return f(this,"shape",n),n},checks:e._zod.def.checks};return E(e,n)}(e,t),e.merge=t=>function(e,t){const n=h(e._zod.def,{get shape(){const n={...e._zod.def.shape,...t._zod.def.shape};return f(this,"shape",n),n},get catchall(){return t._zod.def.catchall},checks:[]});return E(e,n)}(e,t),e.pick=t=>function(e,t){const n=e._zod.def;return E(e,h(e._zod.def,{get shape(){const e={};for(const r in t){if(!(r in n.shape))throw new Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return f(this,"shape",e),e},checks:[]}))}(e,t),e.omit=t=>function(e,t){const n=e._zod.def,r=h(e._zod.def,{get shape(){const r={...e._zod.def.shape};for(const e in t){if(!(e in n.shape))throw new Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return f(this,"shape",r),r},checks:[]});return E(e,r)}(e,t),e.partial=(...t)=>function(e,t,n){const r=h(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in r))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=e?new e({type:"optional",innerType:r[t]}):r[t])}else for(const t in r)o[t]=e?new e({type:"optional",innerType:r[t]}):r[t];return f(this,"shape",o),o},checks:[]});return E(t,r)}(Er,e,t[0]),e.required=(...t)=>function(e,t,n){const r=h(t._zod.def,{get shape(){const r=t._zod.def.shape,o={...r};if(n)for(const t in n){if(!(t in o))throw new Error(`Unrecognized key: "${t}"`);n[t]&&(o[t]=new e({type:"nonoptional",innerType:r[t]}))}else for(const t in r)o[t]=new e({type:"nonoptional",innerType:r[t]});return f(this,"shape",o),o},checks:[]});return E(t,r)}(Rr,e,t[0])});function lr(e,t){const n={type:"object",shape:e??{},...x(t)};return new ur(n)}const fr=e("ZodUnion",(e,t)=>{Bt.init(e,t),kn.init(e,t),e.options=t.options});function hr(e,t){return new fr({type:"union",options:e,...x(t)})}const dr=e("ZodDiscriminatedUnion",(e,t)=>{fr.init(e,t),Tt.init(e,t)});function pr(e,t,n){return new dr({type:"union",options:t,discriminator:e,...x(n)})}const mr=e("ZodIntersection",(e,t)=>{At.init(e,t),kn.init(e,t)});const gr=e("ZodEnum",(e,t)=>{kt.init(e,t),kn.init(e,t),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{const o={};for(const r of e){if(!n.has(r))throw new Error(`Key ${r} not found in enum`);o[r]=t.entries[r]}return new gr({...t,checks:[],...x(r),entries:o})},e.exclude=(e,r)=>{const o={...t.entries};for(const t of e){if(!n.has(t))throw new Error(`Key ${t} not found in enum`);delete o[t]}return new gr({...t,checks:[],...x(r),entries:o})}});function yr(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e;return new gr({type:"enum",entries:n,...x(t)})}const br=e("ZodLiteral",(e,t)=>{St.init(e,t),kn.init(e,t),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function wr(e,t){return new br({type:"literal",values:Array.isArray(e)?e:[e],...x(t)})}const vr=e("ZodTransform",(e,t)=>{$t.init(e,t),kn.init(e,t),e._zod.parse=(r,o)=>{if("backward"===o.direction)throw new n(e.constructor.name);r.addIssue=n=>{if("string"==typeof n)r.issues.push(S(n,r.value,t));else{const t=n;t.fatal&&(t.continue=!1),t.code??(t.code="custom"),t.input??(t.input=r.value),t.inst??(t.inst=e),r.issues.push(S(t))}};const i=t.transform(r.value,r);return i instanceof Promise?i.then(e=>(r.value=e,r)):(r.value=i,r)}});const Er=e("ZodOptional",(e,t)=>{Dt.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function xr(e){return new Er({type:"optional",innerType:e})}const Br=e("ZodNullable",(e,t)=>{It.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType});function Tr(e){return new Br({type:"nullable",innerType:e})}const Ar=e("ZodDefault",(e,t)=>{Pt.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});const Or=e("ZodPrefault",(e,t)=>{Nt.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Rr=e("ZodNonOptional",(e,t)=>{_t.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const kr=e("ZodCatch",(e,t)=>{Ut.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});const Sr=e("ZodPipe",(e,t)=>{Ft.init(e,t),kn.init(e,t),e.in=t.in,e.out=t.out});function $r(e,t){return new Sr({type:"pipe",in:e,out:t})}const zr=e("ZodReadonly",(e,t)=>{jt.init(e,t),kn.init(e,t),e.unwrap=()=>e._zod.def.innerType});const Dr=e("ZodCustom",(e,t)=>{Gt.init(e,t),kn.init(e,t)});function Ir(e,t={error:`Input not instance of ${e.name}`}){const n=new Dr({type:"custom",check:"custom",fn:t=>t instanceof e,abort:!0,...x(t)});return n._zod.bag.Class=e,n}const Pr=zn().refine(e=>64===e.length||128===e.length,{message:"Reference must be 64 chars (32 bytes) or 128 chars (64 bytes for encrypted)"}),Cr=zn().length(64);zn().length(40);const Nr=lr({pin:rr().optional(),encrypt:rr().optional(),tag:Qn().optional(),deferred:rr().optional(),redundancyLevel:Qn().min(0).max(4).optional()}).optional(),_r=lr({redundancyStrategy:hr([wr(0),wr(1),wr(2),wr(3)]).optional(),fallback:rr().optional(),timeoutMs:Qn().optional(),actPublisher:hr([Ir(Uint8Array),zn()]),actHistoryAddress:hr([Ir(Uint8Array),zn()]),actTimestamp:hr([Qn(),zn()])}).optional();lr({reference:Pr,tagUid:Qn().optional()}),lr({name:zn(),data:Ir(Uint8Array)}),lr({batchID:Cr,utilization:Qn(),usable:rr(),label:zn(),depth:Qn(),amount:zn(),bucketDepth:Qn(),blockNumber:Qn(),immutableFlag:rr(),exists:rr(),batchTTL:Qn().optional()}),lr({authenticated:rr(),origin:zn().optional()});const Vr=lr({backgroundColor:zn().optional(),color:zn().optional(),border:zn().optional(),borderRadius:zn().optional(),padding:zn().optional(),fontSize:zn().optional(),fontFamily:zn().optional(),fontWeight:zn().optional(),cursor:zn().optional(),width:zn().optional(),height:zn().optional()}).optional(),Ur=pr("type",[lr({type:wr("parentIdentify"),beeApiUrl:zn().url().optional(),popupMode:yr(["popup","window"]).optional()}),lr({type:wr("checkAuth"),requestId:zn()}),lr({type:wr("requestAuth"),styles:Vr}),lr({type:wr("uploadData"),requestId:zn(),data:Ir(Uint8Array),options:Nr,enableProgress:rr().optional()}),lr({type:wr("downloadData"),requestId:zn(),reference:Pr,options:_r}),lr({type:wr("uploadFile"),requestId:zn(),data:Ir(Uint8Array),name:zn().optional(),options:Nr}),lr({type:wr("downloadFile"),requestId:zn(),reference:Pr,path:zn().optional(),options:_r}),lr({type:wr("uploadChunk"),requestId:zn(),data:Ir(Uint8Array),options:Nr}),lr({type:wr("downloadChunk"),requestId:zn(),reference:Pr,options:_r})]);pr("type",[lr({type:wr("proxyReady"),authenticated:rr(),parentOrigin:zn()}),lr({type:wr("initError"),error:zn()}),lr({type:wr("authStatusResponse"),requestId:zn(),authenticated:rr(),origin:zn().optional()}),lr({type:wr("authSuccess"),origin:zn()}),lr({type:wr("uploadDataResponse"),requestId:zn(),reference:Pr,tagUid:Qn().optional()}),lr({type:wr("downloadDataResponse"),requestId:zn(),data:Ir(Uint8Array)}),lr({type:wr("uploadFileResponse"),requestId:zn(),reference:Pr,tagUid:Qn().optional()}),lr({type:wr("downloadFileResponse"),requestId:zn(),name:zn(),data:Ir(Uint8Array)}),lr({type:wr("uploadChunkResponse"),requestId:zn(),reference:Pr}),lr({type:wr("downloadChunkResponse"),requestId:zn(),data:Ir(Uint8Array)}),lr({type:wr("uploadProgress"),requestId:zn(),total:Qn(),processed:Qn()}),lr({type:wr("error"),requestId:zn(),error:zn()})]);const Fr=lr({secret:zn(),postageBatchId:Cr.optional(),signerKey:zn().length(64).optional()}).refine(e=>!!e.postageBatchId,{message:"postageBatchId is required. signerKey is optional for client-side signing."}),Mr=pr("type",[lr({type:wr("setSecret"),appOrigin:zn(),data:Fr})]);var jr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Lr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gr,qr={};var Hr=(Gr||(Gr=1,function(e){var t;async function n(e){return new Promise((t,n)=>e.then(n,t))}async function r(e){return new Promise(t=>setTimeout(()=>{t(!0)},e))}function o(e,t=Math.random){for(let n=e.length-1;n>0;n--){const r=Math.floor(t()*(n+1)),o=e[n];e[n]=e[r],e[r]=o}return e}function i(e,t,n=Math.random){return o(G(0,e.length-1),n).slice(0,t)}function a(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function s(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function c(e,t=Math.random){return t()<e}function u(e,t=Math.random){return e[Math.floor(e.length*t())]}function l(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function f(e,t,n){return n(t.reduce((e,t)=>t(e),e))}function h(e,t){if(null==e)return null;const n=t.split(".");let r=e;for(const e of n){if(null===r[e]||void 0===r[e])return null;r=r[e]}return r}function d(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let e=0;e<r.length;e++){const t=r[e],i=e<r.length-1&&r[e+1].includes("]"),a=t.includes("]")?t.replace(/\[|\]/g,""):t;if(e===r.length-1)return o[a]=n,n;m(o[a])||(o[a]=i?[]:{}),o=o[a]}return n}function p(e,t){return Math.round(e/t)*t}function m(e,t=!0){return!(!e||t&&!b(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||"Uint8Array"==e.constructor.name||"ArrayBuffer"===e.constructor.name||"ReadableStream"===e.constructor.name))&&"object"==typeof e}function g(e){return m(e)&&!Array.isArray(e)}function y(e){return Array.isArray(e)&&0===e.length}function b(e){return void 0===e}function w(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function v(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function x(e){return!0===e||!1===e}function B(e){return"[object Date]"===Object.prototype.toString.call(e)}function T(e){return!v(e)||0===e.trim().length}function A(e){return E(e)&&Number.isInteger(e)&&e>=1}function O(e){return v(e)&&null!==e.match(/^-?\d+$/)}function R(e){return v(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}Object.defineProperty(e,"__esModule",{value:!0}),e.Vector=e.Cache=e.Assertions=e.Strings=e.Types=e.Objects=e.Dates=e.Promises=e.Numbers=e.System=e.Arrays=e.Random=e.Elliptic=e.Binary=e.TrieRouter=e.AsyncQueue=e.PubSubChannel=e.FixedPointNumber=e.MerkleTree=e.Chunk=e.Uint8ArrayWriter=e.Uint8ArrayReader=e.AsyncLazy=e.Lazy=e.Optional=void 0;const k="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),S="abcdefghijklmnopqrstuvwxyz",$=S+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",z=$+"!@#$%^&*()_+-=[]{}|;:<>?,./",D=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],I="0123456789abcdef";function P(e,t){if(T(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);if(t&&(void 0!==t.min&&e.length<t.min||void 0!==t.max&&e.length>t.max))throw RangeError(`Expected string${t?.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function C(e,t){if(void 0!==t.min&&e<t.min||void 0!==t.max&&e>t.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function N(e,t){if(E(e))return t&&C(e,t),e;if(!v(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&C(n,t),n}function _(e,t){return 0|N(e,t)}function V(e,t){if(!g(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function U(e){return v(e)&&null!==e.match(/^https?:\/\/.+/)}function F(e,t){for(const[n,r]of Object.entries(t))if(!r(e[n]))throw TypeError(`${n} in value does not exist or match shape`);for(const n of Object.keys(e))if(!t[n])throw TypeError(`${n} exists in value but not in shape`);return!0}function M(e,t){if(g(e)&&g(t))for(const n in t)g(t[n])?(e[n]||(e[n]={}),M(e[n],t[n])):Array.isArray(t[n])?e[n]=[...t[n]]:(null!==t[n]&&void 0!==t[n]||null===e[n]||void 0===e[n])&&(e[n]=t[n]);return e}function j(e,t){const n={};for(const r of e)for(const e of Object.keys(r))n[e]?n[e]=t(n[e],r[e]):n[e]=r[e];return n}function L(e,t){Array.prototype.push.apply(e,t)}function G(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function q(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(e=>/[a-z0-9]/.test(e)||t(e)?e:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function H(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const Z={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function W(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function K(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function J(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function X(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function Y(e,t,n=!1){const r=n?e.lastIndexOf(t):e.indexOf(t);return-1===r?n?[null,e]:[e,null]:[e.slice(0,r),e.slice(r+t.length)]}function Q(e,t){let n=[e];for(const e of t)n=n.flatMap(t=>t.split(e));return n.filter(e=>e)}function ee(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function te(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function ne(e){return e.split("\n").map(e=>e.trim().replace(/\s+/g," ")).filter(e=>e.length>0).join("\n")}function re(e){return e.charAt(0).toUpperCase()+e.slice(1)}function oe(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ie(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ae(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function se(e){return ie(e)||ae(e)}const ce=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function ue(e){return ce.includes(e)}function le(e,t,n=0){const r=t.exec(e.slice(n));return r?{index:r.index,match:r[0]}:null}function fe(e,t,n=!0){if(!n)return t.every(t=>t instanceof RegExp?t.test(e):-1!==e.indexOf(t,0));let r=0;for(const n of t)if(n instanceof RegExp){const t=le(e,n,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(n,r);if(-1===t)return!1;r=t+n.length}return!0}function he(e,t,n=0){const r=[];let o=e.indexOf(t,n);for(;-1!==o;)r.push(o),o=e.indexOf(t,o+t.length);return r}function de(e,t,n=0){let r=-1;for(const o of t){const t=e.indexOf(o,n);-1!==t&&(-1===r||t<r)&&(r=t)}return r}function pe(e,t=0){for(let n=t;n<e.length;n++)if(ue(e[n]))return n;return-1}function me(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&se(e[n+1]))return n;return-1}function ge(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function ye(e,t=0,n="{",r="}"){let o=1;for(let i=t;i<e.length;i++)if(e.slice(i,i+r.length)===r){if(0===--o)return i}else e.slice(i,i+n.length)===n&&o++;return-1}function be(e,t){const n=t.wordBoundary?de(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=ye(e,n+t.opening.length,t.opening,t.closing);return-1===r?null:t.exclusive?e.slice(n+t.opening.length,r):e.slice(n,r+t.closing.length)}const we="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Ee(e,t){const n=t.length;let r=0,o=0;const i=[];for(let a=0;a<e.length;a++){const s=e[a];if("="===s)break;const c=t.indexOf(s);if(-1===c)throw new Error(`Invalid character: ${s}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function xe(e,t){const n=t.length;let r=0,o=0,i="";for(let a=0;a<e.length;a++)for(o=o<<8|e[a],r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t[o>>r&n-1];return r>0&&(i+=t[o<<Math.log2(n)-r&n-1]),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function Be(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Te(e){const t=e.lastIndexOf(" ");return-1===t?{line:e,rest:""}:{line:e.slice(0,t),rest:e.slice(t+1)}}function Ae(e){const t=e.reduce((e,t)=>e.length<t.length?e:t);let n="";for(let r=0;r<t.length;r++){const o=t[r];if(!e.every(e=>e[r]===o))break;n+=o}return n}function Oe(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Re(e,t,n=[]){let r="";for(;t<e.length&&(se(e[t])||n.includes(e[t]));)r+=e[t++];return r}function ke(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const a=Re(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${a}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function Se(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Re(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Re(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function $e(e,t=!0){const n=Object.entries(e).filter(([e,t])=>null!=t).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join("&");return n?(t?"?":"")+n:""}function ze(e){return String(Math.floor(e)).padStart(2,"0")}function De(e){const t=Math.floor(e/36e5);e%=36e5;const n=Math.floor(e/6e4);e%=6e4;const r=Math.floor(e/1e3);return t?`${ze(t)}:${ze(n)}:${ze(r)}`:`${ze(n)}:${ze(r)}`}function Ie(e){return Math.floor((B(e)?e.getTime():e)/864e5)}const Pe={today:(e,t)=>ze(e)+":"+ze(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`},Ce={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Ne(t,n){const r=n?.now??Date.now(),o=n?.labels||Ce;let i=(r-(e.Types.isDate(t)?t.getTime():t))/1e3;return i<10?o.now():i<120?o.seconds(Math.floor(i)):(i/=60,i<120?o.minutes(Math.floor(i)):(i/=60,i<48?o.hours(Math.floor(i)):(i/=24,i<14?o.days(Math.floor(i)):(i/=7,o.weeks(Math.floor(i))))))}const _e={},Ve={s:1e3,m:6e4,h:36e5,d:864e5},Ue={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Fe(e){return{zeroBasedIndex:e,day:Ue[e]}}function Me(e){return Fe(e.getDay())}const je={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6},Le={b:0,byte:0,bytes:0,kb:1,kilobyte:1,kilobytes:1,mb:2,megabyte:2,megabytes:2,gb:3,gigabyte:3,gigabytes:3,tb:4,terabyte:4,terabytes:4},Ge=new Map;function qe(e,t=!1){e=e.filter(e=>e),t&&v(e[1])&&(e[1]="../"+e[1]);let n="";v(e[0])&&e[0].includes("://")&&(n=W(e[0],"://")??"",e[0]=K(e[0],"://")??"");const r=e.map(e=>String(e)).flatMap(e=>e.split("/")),o=[];for(let e=0;e<r.length;e++)"."!==r[e]&&(".."===r[e]?(!n||o.length>1)&&o.pop():o.push(r[e]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function He(e){const t=Object.keys(e).sort((e,t)=>e.localeCompare(t)),n={};for(const r of t)n[r]=We(e[r]);return n}function Ze(e){const t=[];return e.sort((e,t)=>JSON.stringify(We(e)).localeCompare(JSON.stringify(We(t)))).forEach(e=>t.push(We(e))),t}function We(e){return Array.isArray(e)?Ze(e):m(e)?He(e):e}function Ke(e,t){return JSON.stringify(We(e))===JSON.stringify(We(t))}function Je(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const Xe=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],Ye=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],Qe=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function et(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=Qe.findIndex(e=>e.toLowerCase()===n.toLowerCase());return-1===r?t:t*Xe[r]}function tt(e,t,n){return e<t?t:e>n?n:e}function nt(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function rt(e,t,n,r,o){if(!m(t))return t;for(const[i,a]of Object.entries(t)){const t=nt(n,i,r);Array.isArray(a)?o?rt(e,a,t,!0,o):e[t]=a.map(e=>rt(Array.isArray(e)?[]:{},e,"",!1,o)):m(a)?rt(e,a,t,!1,o):e[t]=a}return e}function ot(e,t){const n={};for(const r of e)n[t(r)]=r;return n}function it(e,t){const n=Math.ceil(e.length/t),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function at(e,t){const n=[],r=Math.ceil(e.length/t);for(let o=0;o<r;o++)n.push(e.slice(o*t,o*t+t));return n}function st(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function ct(e,t){const n=[];let r=[];return e.forEach((o,i)=>{(0===i||!t(o,e[i-1]))&&(r=[],n.push(r)),r.push(o)}),n}function ut(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.push(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}}class lt{constructor(e){this.value=e}static of(e){return new lt(e)}static empty(){return new lt(null)}map(e){return new lt(null!==this.value&&void 0!==this.value?e(this.value):null)}mapAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then(e=>lt.of(e)):Promise.resolve(lt.empty())}ifPresent(e){return null!==this.value&&void 0!==this.value&&e(this.value),this}ifPresentAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(e){return(null===this.value||void 0===this.value)&&e(),this}ifAbsentAsync(e){return null===this.value||void 0===this.value?e().then(()=>this):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return null!==this.value&&void 0!==this.value?Promise.resolve(this.value):e()}getOrThrow(){if(null===this.value||void 0===this.value)throw Error("Optional.value is empty");return this.value}}e.Optional=lt,e.Lazy=class{constructor(e){this.supplier=e,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}},e.AsyncLazy=class{constructor(e){this.supplier=e,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}};class ft{constructor(e){this.value=e,this.children=[]}}function ht(e,t){if(Math.log2(e.length)%1!=0)throw new Error("Array length must be a power of 2");let n=[...e];for(;n.length>1;){const e=[];for(let r=0;r<n.length;r+=2){const o=n[r+1];e.push(t(n[r],o))}n=e}return n[0]}function dt(...e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;return e.forEach(e=>{n.set(e,r),r+=e.length}),n}function pt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function mt(e){return 255===e[0]&&216===e[1]}function gt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function yt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function bt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let e=31;e>=0;e--)n[e]=Number(0xffn&r),r>>=8n;return n}function wt(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let t=0;t<32;t++)n=n<<8n|BigInt(e[t]);return n}function vt(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const Et=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function xt(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],s=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(a<<1|s>>>31),m=r^(s<<1|a>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),b=a^(l<<1|f>>>31),w=s^(f<<1|l>>>31),v=c^(n<<1|r>>>31),E=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=b,e[7]^=w,e[8]^=v,e[9]^=E,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=b,e[17]^=w,e[18]^=v,e[19]^=E,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=b,e[27]^=w,e[28]^=v,e[29]^=E,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=b,e[37]^=w,e[38]^=v,e[39]^=E,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=b,e[47]^=w,e[48]^=v,e[49]^=E;const x=e[0],B=e[1],T=e[2]<<1|e[3]>>>31,A=e[3]<<1|e[2]>>>31,O=e[5]<<30|e[4]>>>2,R=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,$=e[8]<<27|e[9]>>>5,z=e[9]<<27|e[8]>>>5,D=e[11]<<4|e[10]>>>28,I=e[10]<<4|e[11]>>>28,P=e[13]<<12|e[12]>>>20,C=e[12]<<12|e[13]>>>20,N=e[14]<<6|e[15]>>>26,_=e[15]<<6|e[14]>>>26,V=e[17]<<23|e[16]>>>9,U=e[16]<<23|e[17]>>>9,F=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,j=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,G=e[22]<<10|e[23]>>>22,q=e[23]<<10|e[22]>>>22,H=e[25]<<11|e[24]>>>21,Z=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,ae=e[38]<<8|e[39]>>>24,se=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=x^~P&H,e[1]=B^~C&Z,e[2]=P^~H&oe,e[3]=C^~Z&ie,e[4]=H^~oe&ge,e[5]=Z^~ie&ye,e[6]=oe^~ge&x,e[7]=ie^~ye&B,e[8]=ge^~x&P,e[9]=ye^~B&C,e[10]=k^~F&j,e[11]=S^~M&L,e[12]=F^~j&ee,e[13]=M^~L&te,e[14]=j^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&F,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=A^~_&K,e[22]=N^~W&ae,e[23]=_^~K&se,e[24]=W^~ae&ce,e[25]=K^~se&ue,e[26]=ae^~ce&T,e[27]=se^~ue&A,e[28]=ce^~T&N,e[29]=ue^~A&_,e[30]=$^~D&G,e[31]=z^~I&q,e[32]=D^~G&ne,e[33]=I^~q&re,e[34]=G^~ne&pe,e[35]=q^~re&me,e[36]=ne^~pe&$,e[37]=re^~me&z,e[38]=pe^~$&D,e[39]=me^~z&I,e[40]=O^~V&J,e[41]=R^~U&X,e[42]=V^~J&Y,e[43]=U^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&O,e[47]=Q^~fe&R,e[48]=le^~O&V,e[49]=fe^~R&U,e[0]^=Et[2*t],e[1]^=Et[2*t+1]}}function Bt(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}function Tt(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[Bt(e)]}const n=vt(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]|=128,n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(Bt)}function At(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]^=n[t+1],e[t+1]^=n[t];xt(e)}return e}function Ot(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function Rt(e){return Ot(At(new Array(50).fill(0),Tt(e,1)))}function kt(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,t-e.length),r}function St(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,0),r}function $t(e,t){return(e%t+t)%t}function zt(e,t){e=$t(e,t);let[n,r]=[0n,1n],[o,i]=[t,e];for(;0n!==i;){const e=o/i;[n,r]=[r,n-e*r],[o,i]=[i,o-e*i]}if(o>1n)throw new Error("a is not invertible");return n<0n&&(n+=t),n}function Dt(e,t){return 0n===$t(e,t)?0n:t%4n==3n?function(e,t,n){let r=1n;for(e=$t(e,n);t>0;)t%2n==1n&&(r=$t(r*e,n)),e=$t(e*e,n),t/=2n;return r}(e,(t+1n)/4n,t):null}const It=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Nt=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function _t(e,t,n){if(0n===t)return[0n,0n];const r=$t(3n*e*e*zt(2n*t,n),n),o=$t(r*r-2n*e,n);return[o,$t(r*(e-o)-t,n)]}function Vt(e,t,n,r,o){if(0n===e&&0n===t)return[n,r];if(0n===n&&0n===r)return[e,t];if(e===n&&t===$t(-r,o))return[0n,0n];if(e===n&&t===r)return _t(e,t,o);const i=$t((r-t)*zt(n-e,o),o),a=$t(i*i-e-n,o);return[a,$t(i*(e-a)-t,o)]}function Ut(e,t,n,r){let o=[0n,0n],i=[e,t];const a=n.toString(2);for(const e of a)"0"===e?(i=Vt(o[0],o[1],i[0],i[1],r),o=_t(o[0],o[1],r)):(o=Vt(o[0],o[1],i[0],i[1],r),i=_t(i[0],i[1],r));return o}function Ft(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||(n=$t(wt(Rt(dt(Rt(bt(t,"BE")),bt(e,"BE"))),"BE"),Pt)),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=$t(e,Pt),o=Ut(Ct,Nt,n,It),i=$t(o[0],Pt);let a=$t((r+$t(i,Pt)*t)*zt(n,Pt),Pt);if(0n===i||0n===a)throw new Error("Invalid r or s value");let s=o[1]%2n==0n?27n:28n;return a>Pt/2n&&(a=Pt-a,s=27n===s?28n:27n),[i,a,s]}class Mt{constructor(e){this.cursor=0,this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}}e.Uint8ArrayReader=Mt;class jt{constructor(e){this.buffer=e,this.cursor=0}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}}e.Uint8ArrayWriter=jt;class Lt{constructor(e,t=0n){this.span=t,this.writer=new jt(new Uint8Array(e))}build(){return dt(yt(this.span,"LE"),this.writer.buffer)}hash(){const e=ht(vt(this.writer.buffer,32),(e,t)=>Lt.hashFunction(dt(e,t)));return Lt.hashFunction(dt(yt(this.span,"LE"),e))}}e.Chunk=Lt,Lt.hashFunction=Rt;class Gt{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new Lt(t)],this.onChunk=e}static async root(e,n=4096){const r=new t(t.NOOP,n);return await r.append(e),r.finalize()}async append(e,t=0,n=0n){const r=new Mt(e);for(;r.max()>0;){0===this.chunks[t].writer.max()&&await this.elevate(t);const e=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(e)}}async elevate(e){this.counters[e]=++this.counters[e]%(this.capacity/32),this.chunks[e+1]||(this.chunks.push(new Lt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[e].hash(),e+1,this.chunks[e].span),await this.onChunk(this.chunks[e]),this.chunks[e]=new Lt(this.capacity)}async finalize(e=0){return this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),this.finalize(e+1)):(await this.onChunk(this.chunks[e]),this.chunks[e])}}e.MerkleTree=Gt,t=Gt,Gt.NOOP=async e=>{};class qt{constructor(e,t){if(t<0)throw Error("Scale must be non-negative");this.value=BigInt(e),this.scale=t}static fromDecimalString(e,t){let[n,r]=e.split(".");return r=(r||"").padEnd(t,"0").slice(0,t),new qt(BigInt(n+r),t)}add(e){return this.assertSameScale(e),new qt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new qt(this.value-e.value,this.scale)}multiply(e){return new qt(this.value*e,this.scale)}divmod(e){if(0n===e)throw new Error("Division by zero is not allowed");const t=this.value/e,n=this.value%e;return[new qt(t,this.scale),new qt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new qt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new qt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Ht(e,t,n,r){const o=e.findIndex(e=>e===`--${t}`||e.startsWith(`--${t}=`)),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const a=e[o+1];return a&&!a.startsWith("-")?a:(n||{})[r||t||""]||null}function Zt(e,t,n,r){const o=Ht(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Wt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Kt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Jt(e,t){return{x:e.x*t,y:e.y*t}}function Xt(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Yt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Qt(e,t,n="row-first"){const r=[];if("column-first"===n)for(let n=0;n<e.length;n++)for(let o=0;o<e[0].length;o++)t(n,o)&&r.push({x:n,y:o});else for(let n=0;n<e[0].length;n++)for(let o=0;o<e.length;o++)t(o,n)&&r.push({x:o,y:n});return r}function en(e,t,n){return!e[t-1]?.[n]}function tn(e,t,n){return!e[t+1]?.[n]}function nn(e,t,n){return!e[t][n-1]}function rn(e,t,n){return!e[t][n+1]}function on(e,t,n){const r=[];return e[t][n]?function(e,t,n){return e[t+1]?.[n]&&e[t-1]?.[n]&&!e[t][n-1]&&!e[t][n+1]}(e,t,n)||function(e,t,n){return e[t][n+1]&&e[t][n-1]&&!e[t-1]?.[n]&&!e[t+1]?.[n]}(e,t,n)?[]:(!e[t-1]?.[n-1]&&en(e,t,n)&&nn(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&tn(e,t,n)&&nn(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&en(e,t,n)&&rn(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&tn(e,t,n)&&rn(e,t,n)&&r.push({x:t+1,y:n+1}),r):(e[t-1]?.[n]&&e[t][n-1]&&r.push({x:t,y:n}),e[t+1]?.[n]&&e[t][n-1]&&r.push({x:t+1,y:n}),e[t-1]?.[n]&&e[t][n+1]&&r.push({x:t,y:n+1}),e[t+1]?.[n]&&e[t][n+1]&&r.push({x:t+1,y:n+1}),r)}function an(e,t){return t.map(t=>function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t)).sort((e,t)=>e-t)}function sn(e,t,n,r){const o=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y);if(0===o)return null;let i=e.y-n.y,a=e.x-n.x;const s=(r.x-n.x)*i-(r.y-n.y)*a,c=(t.x-e.x)*i-(t.y-e.y)*a;return i=s/o,a=c/o,i>0&&i<1&&a>0&&a<1?{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}:null}function cn(e,t,n){const r=[],o=Xt(e,n,1e4);for(const n of t){const t=sn(e,o,n.start,n.end);t&&r.push(t)}return r.length?r.reduce((t,n)=>Yt(e,n)<Yt(e,t)?n:t):null}e.FixedPointNumber=qt;class un{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}publish(e){this.subscribers.forEach(t=>t(e))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}e.PubSubChannel=un,e.AsyncQueue=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new un,this.onDrained=new un,this.concurrency=e,this.capacity=t}process(){if(this.running>=this.concurrency)return;const e=this.queue.shift();e&&(this.running++,e().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),0===this.running&&this.onDrained.publish()}))}enqueue(e){if(this.queue.length<this.capacity)return this.queue.push(e),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(t=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(e),this.process(),this.onProcessed.clear(),t())})})}drain(){if(0===this.running)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(e=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),e()})})}};class ln{constructor(){this.forks=new Map}insert(e,t){if(0===e.length)return void(this.handler=t);const n=e[0];let r,o=n;if(n.startsWith(":")&&(o=":",r=n.slice(1)),!this.forks.has(o)){const e=new ln;r&&(e.variableName=r),this.forks.set(o,e)}this.forks.get(o).insert(e.slice(1),t)}async handle(e,t,n,r){if(0===e.length)return!!this.handler&&(await this.handler(t,n,r),!0);const o=e[0],i=this.forks.get(o);if(i)return i.handle(e.slice(1),t,n,r);const a=this.forks.get(":");if(a)return a.variableName&&r.set(a.variableName,decodeURIComponent(o)),a.handle(e.slice(1),t,n,r);const s=this.forks.get("*");return!!s&&(r.set("wildcard",e.join("/")),!!s.handler&&(await s.handler(t,n,r),!0))}}e.TrieRouter=ln,e.Binary={hexToUint8Array:function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(2*r,2*r+2),16);n[r]=t}return n},uint8ArrayToHex:function(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")},binaryToUint8Array:function(e){const t=Math.ceil(e.length/8),n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(8*r,8*r+8),2);n[r]=t}return n},uint8ArrayToBinary:function(e){return Array.from(e).map(e=>e.toString(2).padStart(8,"0")).join("")},base64ToUint8Array:function(e){return Ee(e,we)},uint8ArrayToBase64:function(e){return xe(e,we)},base32ToUint8Array:function(e){return Ee(e,ve)},uint8ArrayToBase32:function(e){return xe(e,ve)},log2Reduce:ht,partition:vt,concatBytes:dt,numberToUint8:function(e){return new Uint8Array([e])},uint8ToNumber:function(e){return e[0]},numberToUint16:function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)},uint16ToNumber:function(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,"LE"===t)},numberToUint32:function(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)},uint32ToNumber:function(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,"LE"===t)},numberToUint64:yt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:bt,uint256ToNumber:wt,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:Rt,sha3_256:function(e){return Ot(At(new Array(50).fill(0),Tt(e,6)))},proximity:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e[r]^t[r];for(let e=0;e<8;e++)if(n>>7-e&1)return 8*r+e}return 8*Math.min(e.length,t.length)},commonPrefix:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)},setBit:function(e,t,n,r){const o=Math.floor(t/8),i=t%8;1===n?e[o]|=1<<("BE"===r?7-i:i):e[o]&=~(1<<("BE"===r?7-i:i))},getBit:function(e,t,n){const r=t%8;return e[Math.floor(t/8)]>>("BE"===n?7-r:r)&1},indexOf:function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1},equals:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},padStart:kt,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:kt(e,e.length+t-r,n)},padEnd:St,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:St(e,e.length+t-r,n)},xorCypher:function(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n},isUtf8:function(e){for(let t=0;t<e.length;t++){const n=e[t];if(!(n<128))if(192==(224&n)){if(t+1>=e.length||128!=(192&e[t+1]))return!1;t+=1}else if(224==(240&n)){if(t+2>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2]))return!1;t+=2}else{if(240!=(248&n))return!1;if(t+3>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2])||128!=(192&e[t+3]))return!1;t+=3}}return!0}},e.Elliptic={privateKeyToPublicKey:function(e){if(e<=0n||e>=Pt)throw new Error("Invalid private key");return Ut(Ct,Nt,e,It)},compressPublicKey:function(e){const t=e[1]%2n==0n?2:3;return new Uint8Array([t,...bt(e[0],"BE")])},publicKeyFromCompressed:function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=wt(e.slice(1),"BE"),n=Dt($t(t**3n+7n,It),It);if(!n)throw Error("Invalid x: does not correspond to a valid curve point");const r=$t(-n,It),o=n%2n==0n;return[t,2===e[0]?o?n:r:o?r:n]},publicKeyToAddress:function(e){const t=new Uint8Array(20),n=Rt(dt(bt(e[0],"BE"),bt(e[1],"BE")));return t.set(n.subarray(12)),t},signMessage:function(e,t,n){return Ft(wt(Rt(e),"BE"),t,n)},signHash:Ft,verifySignature:function(e,t,n,r){const o=$t(wt(Rt(e),"BE"),Pt),i=zt(r,Pt),a=$t(o*i,Pt),s=$t(n*i,Pt),c=Ut(Ct,Nt,a,It),u=Ut(t[0],t[1],s,It);return n===$t(Vt(c[0],c[1],u[0],u[1],It)[0],Pt)},recoverPublicKey:function(e,t,n,r){const o=Dt($t(t**3n+7n,It),It);if(!o)throw new Error("Invalid r: does not correspond to a valid curve point");const i=o%2n==(27n===r?0n:1n)?o:It-o,a=$t(wt(Rt(e),"BE"),Pt),s=Ut(t,i,n,It),c=Ut(Ct,Nt,a,It),u=Vt(s[0],s[1],c[0],$t(-c[1],It),It);return Ut(u[0],u[1],zt(t,Pt),It)},checksumEncode:function(t){const n=e.Binary.uint8ArrayToHex(t),r=e.Binary.uint8ArrayToHex(e.Binary.keccak256(new Uint8Array([...n].map(e=>e.charCodeAt(0)))));let o="0x";for(let e=0;e<n.length;e++)parseInt(r[e],16)>7?o+=n[e].toUpperCase():o+=n[e];return o}},e.Random={intBetween:a,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:c,signed:function(){return 2*Math.random()-1},makeSeededRng:function(e){let t=e,n=3405648695,r=3735928559;return function(){return t+=n,n^=t<<7,t*=r,r^=t<<13,t^=n^r,(t>>>0)/4294967296}},point:function(e,t,n,r=Math.random){let o,i;do{o=a(0,e-1,r),i=a(0,t-1,r)}while(n&&s(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return c(e-n,t)?n+1:n}},e.Arrays={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,a={};for(const e of i)a[e]=(a[e]||0)+1;const s=r?st(a,o?(e,t)=>e[1]-t[1]:(e,t)=>t[1]-e[1]):a;return n?Object.keys(s):s},makeUnique:function(e,t){return Object.values(ot(e,t))},splitBySize:function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},splitByCount:it,index:ot,indexCollection:function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]=[]),n[e].push(r)}return n},onlyOrThrow:function(e){if(1===e.length)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)},onlyOrNull:function(e){return 1===e.length?e[0]:null},firstOrThrow:function(e){if(!e.length)throw Error("Received empty array");return e[0]},firstOrNull:function(e){return e.length>0?e[0]:null},shuffle:o,initialize:function(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},initialize2D:function(e,t,n){const r=[];for(let o=0;o<e;o++){r.push([]);for(let e=0;e<t;e++)r[o].push(n)}return r},rotate2D:function(e){const t=[];for(let n=0;n<e[0].length;n++){t.push([]);for(let r=0;r<e.length;r++)t[n].push(e[r][n])}return t},containsShape:function(e,t,n,r){if(n<0||r<0||r+t[0].length>e[0].length||n+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let i=0;i<t[o].length;i++)if(void 0!==t[o][i]&&e[n+o][r+i]!==t[o][i])return!1;return!0},glue:function(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<e.length-1&&(w(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map(e=>e[t])},pick:u,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return i(e,t,n).map(t=>e[t])},pickManyUnique:function(e,t,n,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const t=u(e,r);o.some(e=>n(e,t))||o.push(t)}return o},pickWeighted:function(e,t,n){if(void 0===n&&(n=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let r=t.reduce((e,t)=>e+t,0);const o=n*r;for(let n=0;n<e.length-1;n++)if(r-=t[n],o>=r)return e[n];return l(e)},pickRandomIndices:i,pickGuaranteed:function(t,n,r,i,a,s=Math.random){const c=t.filter(e=>e!==n&&e!==r),u=[];for(null!==n&&u.push(n);c.length&&u.length<i;){const t=e.Random.intBetween(0,c.length-1,s);a(c[t],u)&&u.push(c[t]),c.splice(t,1)}return o(u,s),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:l,pipe:f,makePipe:function(e,t){return n=>f(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map(e=>n()*e),o=[];for(let t=0;t<e.length;t++)o.push([e[t],r[t]]);return o.sort((e,t)=>t[1]-e[1]).map(e=>e[0])},pushAll:L,unshiftAll:function(e,t){Array.prototype.unshift.apply(e,t)},filterAndRemove:function(e,t){const n=[];for(let r=e.length-1;r>=0;r--)t(e[r])&&n.push(e.splice(r,1)[0]);return n},merge:function(e,t){const n=Object.keys(t);for(const r of n)Array.isArray(t[r])&&Array.isArray(e[r])&&L(e[r],t[r])},empty:function(e){return e.splice(0,e.length),e},pushToBucket:function(e,t,n){e[t]||(e[t]=[]),e[t].push(n)},unshiftAndLimit:function(e,t,n){for(e.unshift(t);e.length>n;)e.pop()},atRolling:function(e,t){let n=t%e.length;return n<0&&(n+=e.length),e[n]},group:ct,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const e of Object.keys(t))i[e]=[];i[r]=[],o&&(e=e.sort(o));for(const o of e){const e=o[n],a=t[e]?e:r;i[a].length>=t[a]?i[r].push(o):i[a].push(o)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Ht,getBooleanArgument:function(e,t,n,r){const o=e.some(e=>e.endsWith("-"+t)),i=Ht(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Ht(e,t,n,r);if(!o)return null;try{return et(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Zt,requireNumberArgument:function(e,t,n,r){const o=Zt(e,t,n,r);try{return et(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Wt(n,t),n},bringToFrontInPlace:Wt,findInstance:function(e,t){const n=e.find(e=>e instanceof t);return lt.of(n)},filterInstances:function(e,t){return e.filter(e=>e instanceof t)},interleave:function(e,t){const n=[],r=Math.max(e.length,t.length);for(let o=0;o<r;o++)e[o]&&n.push(e[o]),t[o]&&n.push(t[o]);return n},toggle:function(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]},createHierarchy:function(e,t,n,r,o=!1){const i=new Map,a=[];e.forEach(e=>{const n=new ft(e);i.set(e[t],n)}),e.forEach(e=>{const r=i.get(e[t]);if(!r)return;const o=e[n];if(o){const e=i.get(o);e&&e.children.push(r)}else a.push(r)});const s=e=>{e.children.sort((e,t)=>{const n=e.value[r],i=t.value[r];return o?i-n:n-i}),e.children.forEach(s)};return a.forEach(s),a},multicall:function(e){return()=>e.forEach(e=>e())},maxBy:function(e,t){return e.reduce((e,n)=>t(e)>t(n)?e:n)}},e.System={sleepMillis:r,forever:async function(e,t,n){for(;;){try{await e()}catch(e){n&&n("Error in forever",e)}await r(t)}},scheduleMany:function(e,t){for(let n=0;n<e.length;n++){const r=e[n],o=t[n],i=Math.max(0,o.getTime()-Date.now());setTimeout(r,i)}},waitFor:async function(e,t){let n=t.requiredConsecutivePasses||1,o=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(o++,o>=n)return}else o=0}catch{o=0}i<t.attempts-1&&await r(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(v(e))return e;const n=Object.keys(e);e.message&&!n.includes("message")&&n.push("message");const r=n.map(t=>`${t}: ${e[t]}`).join("; ");return t&&e.stack?r+"\n"+e.stack:r},runAndSetInterval:function(e,t){e();const n=setInterval(()=>{e()},t);return()=>clearInterval(n)},whereAmI:function(){const e=globalThis.process;return e?!0===e.browser?"browser":"node":"browser"}},e.Numbers={make:et,sum:function(e){return e.reduce((e,t)=>e+t,0)},average:function(e){return e.reduce((e,t)=>e+t,0)/e.length},median:function(e){const t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n]+t[n-1])/2:t[n]},getDistanceFromMidpoint:function(e,t){return e-(t-1)/2},clamp:tt,range:G,interpolate:function(e,t,n){return e+(t-e)*n},createSequence:function(){let e=0;return{next:()=>e++}},increment:function(e,t,n){const r=e+t;return r>n?n:r},decrement:function(e,t,n){const r=e-t;return r<n?n:r},format:function(e,t){const n=t?.longForm??!1,r=t?.unit?` ${t.unit}`:"",o=n?Ye:Qe,i=t?.precision??1;if(e<Xe[0])return`${e}${r}`;for(let t=0;t<Xe.length-1;t++)if(e<Xe[t+1])return`${(e/Xe[t]).toFixed(i)}${n?" ":""}${o[t]}${r}`;return`${(e/Xe[Xe.length-1]).toFixed(i)}${n?" ":""}${o[Xe.length-1]}${r}`},fromDecimals:function(e,t,n){let r=e.length-t;if(r<=0)return"0."+"0".repeat(-r)+e+(n?" "+n:"");let o=e.substring(0,r);return""===o&&(o="0"),o+"."+e.substring(r)+(n?" "+n:"")},makeStorage:function(e,t=1024){const n=parseFloat(e);if(isNaN(n))throw Error("makeStorage got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),o=""===r?0:Le[r];if(null==o)throw Error(`Unknown unit: "${r}"`);return Math.ceil(n*t**o)},asMegabytes:function(e){return e/1024/1024},convertBytes:function(e,t=1024){return e>=t*t*t*t?(e/t/t/t/t).toFixed(3)+" TB":e>=t*t*t?(e/t/t/t).toFixed(3)+" GB":e>=t*t?(e/t/t).toFixed(3)+" MB":e>=t?(e/t).toFixed(3)+" KB":e+" B"},hexToRgb:function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]},rgbToHex:function(e){return"#"+e.map(e=>e.toString(16).padStart(2,"0")).join("")},haversineDistanceToMeters:function(e,t,n,r){const o=e*Math.PI/180,i=n*Math.PI/180,a=(n-e)*Math.PI/180,s=(r-t)*Math.PI/180,c=Math.sin(a/2)*Math.sin(a/2)+Math.cos(o)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},roundToNearest:p,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?p(e,100)+" m":e>=100?p(e,50)+" m":p(e,10)+" m"},triangularNumber:function(e){return e*(e+1)/2},searchFloat:function(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])},binomialSample:function(e,t,n=Math.random){const r=e*t,o=Math.sqrt(e*t*(1-t)),i=(n()+n()+n()+n()+n()+n()-3)*Math.SQRT2,a=Math.round(r+o*i);return Math.max(0,Math.min(e,a))}},e.Promises={raceFulfilled:async function(e){return n(Promise.all(e.map(n)))},invert:n,runInParallelBatches:async function(e,t=1){const n=it(e,t),r=[],o=n.map(async e=>{for(const t of e)r.push(await t())});return await Promise.all(o),r}},e.Dates={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Pe,o=B(e)?e:new Date(e);if(Ie(n)===Ie(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ie(n)-Ie(o)===1)return r.yesterday();const i=Me(o);return Ie(n)-Ie(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Ne,secondsToHumanTime:function(e,t=Ce){return Ne(0,{now:1e3*e,labels:t})},countCycles:function(e,t,n){const r=(n?.now??Date.now())-e;return{cycles:Math.floor(r/t),remaining:t/(n?.precision??1)-Math.ceil(r%t/(n?.precision??1))}},isoDate:function(e){return(e||new Date).toISOString().slice(0,10)},throttle:function(e,t){return(!_e[e]||Date.now()>_e[e])&&(_e[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=B(t)?t.getTime():t,((n=n?B(n)?n.getTime():n:Date.now())-t)/Ve[e]},dateTimeSlug:function(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")},unixTimestamp:function(e){return Math.ceil((e||Date.now())/1e3)},fromUtcString:function(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset())},fromMillis:function(e){return new Date(e)},getProgress:function(e,t,n,r){r||(r=Date.now());const o=r-e,i=o/t,a=i*n;return{deltaMs:o,progress:t/n,baseTimeMs:i,totalTimeMs:a,remainingTimeMs:a-o}},humanizeTime:De,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${De(e.deltaMs)} out of ${De(e.totalTimeMs)} (${De(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:ze,mapDayNumber:Fe,getDayInfoFromDate:Me,getDayInfoFromDateTimeString:function(e){return Me(new Date(e))},seconds:function(e){return 1e3*e},minutes:function(e){return 6e4*e},hours:function(e){return 36e5*e},days:function(e){return 864e5*e},make:function(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),r=""===n?1:je[n];if(!r)throw Error(`Unknown unit: "${n}"`);return Math.ceil(t*r)},normalizeTime:function(e){let[t,n]=e.split(":");E(parseInt(t,10))||(t="0"),E(parseInt(n,10))||(n="0");let r=tt(_(t),0,23),o=tt(_(n),0,59);return`${ze(r)}:${ze(o)}`},absoluteDays:Ie},e.Objects={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=J(t,"."),r=X(t,".");if(!n||!r)return;const o=h(e,n);o&&delete o[r]},getDeep:h,setDeep:d,incrementDeep:function(e,t,n=1){const r=h(e,t)||0;return d(e,t,r+n),r},ensureDeep:function(e,t,n){return h(e,t)||d(e,t,n)},replaceDeep:function(e,t,n){const r=h(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return d(e,t,n),r},getFirstDeep:function(e,t,n){for(const n of t){const t=h(e,n);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:M,deepMerge2:function(e,t){const n={};return M(n,e),M(n,t),n},deepMerge3:function(e,t,n){const r={};return M(r,e),M(r,t),M(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:He,sortArray:Ze,sortAny:We,deepEquals:Ke,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Ke(e[t-1],e[t]))return!1;return!0},runOn:function(e,t){return t(e),e},ifPresent:function(e,t){e&&t(e)},zip:j,zipSum:function(e){return j(e,(e,t)=>e+t)},removeEmptyArrays:function(e){for(const t of Object.keys(e))(y(e[t])||Array.isArray(e[t])&&e[t].every(e=>null==e))&&delete e[t];return e},removeEmptyValues:function(e){for(const t of Object.entries(e))(null===t[1]||void 0===t[1]||v(t[1])&&T(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return rt({},e,n||"",!1,t)},unflatten:function e(t){if(!m(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?d(n,r,o.map(t=>e(t))):d(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:st,map:function(e,t){const n={};for(const r of Object.entries(e))n[r[0]]=t(r[1]);return n},mapIterable:function(e,t){const n=[];let r=0;for(const o of e)n.push(t(o,r++));return n},filterKeys:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(r)&&(n[r]=o);return n},filterValues:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(o)&&(n[r]=o);return n},rethrow:async function(e,t){try{return await e()}catch{throw t}},setSomeOnObject:function(e,t,n){null!=n&&(e[t]=n)},setSomeDeep:function(e,t,n,r){const o=h(n,r);null!=o&&d(e,t,o)},flip:function(e){const t={};for(const[n,r]of Object.entries(e))t[r]=n;return t},getAllPermutations:function(e){const t=Object.keys(e),n=t.map(t=>e[t].length),r=n.reduce((e,t)=>e*t);let o=1;const i=[1];for(let e=0;e<n.length-1;e++)o*=n[e],i.push(o);const a=[];for(let n=0;n<r;n++){const r={};for(let o=0;o<t.length;o++){const a=e[t[o]],s=Math.floor(n/i[o])%a.length;r[t[o]]=a[s]}a.push(r)}return a},countTruthyValues:function(e){return Object.values(e).filter(e=>e).length},transformToArray:function(e){const t=[],n=Object.keys(e),r=e[n[0]].length;for(let o=0;o<r;o++){const r={};for(const t of n)r[t]=e[t][o];t.push(r)}return t},setMulti:function(e,t,n){for(const r of e)r[t]=n},incrementMulti:function(e,t,n=1){for(const r of e)r[t]+=n},createBidirectionalMap:function(){return{map:new Map,keys:[]}},createTemporalBidirectionalMap:function(){return{map:new Map,keys:[]}},pushToBidirectionalMap:ut,unshiftToBidirectionalMap:function(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.unshift(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}},addToTemporalBidirectionalMap:function(e,t,n,r,o=100){ut(e,t,{validUntil:Date.now()+r,data:n},o)},getFromTemporalBidirectionalMap:function(e,t){const n=e.map.get(t);return n&&n.validUntil>Date.now()?n.data:null},createStatefulToggle:function(e){let t;return n=>{const r=n===e&&t!==e;return t=n,r}},diffKeys:function(e,t){const n=Object.keys(e),r=Object.keys(t);return{uniqueToA:n.filter(e=>!r.includes(e)),uniqueToB:r.filter(e=>!n.includes(e))}},pickRandomKey:Je,mapRandomKey:function(e,t){const n=Je(e);return e[n]=t(e[n]),n},fromObjectString:function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/(\w+)\((.+)\)/g,(e,t,n)=>`${t}(${n.replaceAll(",","&comma;")})`)).replace(/(,)(\s+})/g,"$2")).replace(/\.\.\..+?,/g,"")).replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/:(.+)\?(.+):/g,(e,t,n)=>`: (${t.trim()} && ${n.trim()}) ||`)).replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2')).replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(e,t,n,r)=>`"${t}":"${n.trim()}"${r}`)).replace(/("'|'")/g,'"')).replaceAll("&comma;",","),JSON.parse(e)},toQueryString:$e,parseQueryString:function(e){const t={},n=e.split("&");for(const e of n){const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}return t},hasKey:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},selectMax:function(e,t){let n=null,r=-1/0;for(const[o,i]of Object.entries(e)){const e=t(i);e>r&&(r=e,n=o)}return n?[n,e[n]]:null},reposition:function(e,t,n,r){const o=e.find(e=>e[t]===n),i=e.find(e=>e[t]===n+r);o&&i?(o[t]=n+r,i[t]=n):o&&(o[t]=n+r),e.sort((e,n)=>N(e[t])-N(n[t])),e.forEach((e,n)=>e[t]=n+1)},unwrapSingleKey:function(e){const t=Object.keys(e);if(1===t.length)return e[t[0]];throw new Error("Expected object to have a single key")},parseKeyValues:function(e,t=":"){return Object.fromEntries(e.map(e=>Y(e,t)).map(e=>e[0]&&e[1]?[ne(e[0]),ne(e[1])]:null).filter(e=>e))}},e.Types={isFunction:w,isObject:m,isStrictlyObject:g,isEmptyArray:y,isEmptyObject:function(e){return g(e)&&0===Object.keys(e).length},isUndefined:b,isString:v,isNumber:E,isBoolean:x,isDate:B,isBlank:T,isId:A,isIntegerString:O,isHexString:R,isUrl:U,isNullable:function(e,t){return null==t||e(t)},asString:P,asHexString:function(e,t){if(!R(e))throw new TypeError(`Expected hex string${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.replace(/^0x/,"");if(n.length%2!=0)throw RangeError(`Expected even number of hex digits${t?.name?` for ${t.name}`:""}; got: `+e);if(t&&t.byteLength&&n.length!==2*t.byteLength)throw RangeError(`Expected hex string${t?.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+n);return n},asSafeString:function(e,t){if(!P(e,t).split("").every(e=>"_"===e||se(e)))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!O(e))throw new TypeError(`Expected integer string${t?.name?` for ${t.name}`:""}, got: `+e);const n=BigInt(e);if(t&&(t.min&&n<t.min||t.max&&n>t.max))throw RangeError(`Expected integer string${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+n);return e},asNumber:N,asFunction:function(e,t){if(!w(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:_,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!B(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return T(e)?null:e},asEmptiableString:function(e,t){if(!v(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(A(e))return e;const n=parseInt(e,10);if(!A(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!v(e))throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.split(":");if(2!==n.length)throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const r=parseInt(n[0],10),o=parseInt(n[1],10);if(!E(r)||!E(o)||r<0||r>23||o<0||o>59)throw new TypeError(`Expected time, got${t?.name?` for ${t.name}`:""}: `+e);return`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`},asArray:function(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t?.name?` for ${t.name}`:""}, got: `+e);return e},asObject:V,asNullableObject:function(e,t){return null===e?null:V(e,t)},asStringMap:function(e,t){const n=V(e,t);for(const r of Object.keys(n))if(!v(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=V(e),r=Object.keys(n),o=Object.values(n);if(!r.every(v)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!U(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asEmptiable:function(e,t){return""===t?void 0:e(t)},asNullable:function(e,t){return null==t?null:e(t)},asOptional:function(e,t){return null==t?void 0:e(t)},enforceObjectShape:F,enforceArrayShape:function(e,t){return e.every(e=>F(e,t))},isPng:pt,isJpg:mt,isWebp:gt,isImage:function(e){return pt(e)||mt(e)||gt(e)}},e.Strings={tokenizeByCount:function(e,t){return at(e,Math.ceil(e.length/t))},tokenizeByLength:at,searchHex:function(e,t){const n=new RegExp(`[0-9a-f]{${t}}`,"i"),r=e.match(n);return r?r[0]:null},searchSubstring:function(e,t,n=k){const r=Q(e,n);for(const e of r)if(t(e))return e;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=I[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=S[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=$[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=z[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=D[Math.floor(t()*D.length)];return n},includesAny:function(e,t){return t.some(t=>e.includes(t))},slugify:q,normalForm:function(e){return q(e).replaceAll("-","")},enumify:function(e){return q(e).replace(/-/g,"_").toUpperCase()},escapeHtml:function(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},decodeHtmlEntities:function(e){let t=e.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(t)).replace(/&#x(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,16)));for(const[e,n]of Object.entries(Z))t=t.replaceAll(e,n);return t},after:K,afterLast:X,before:W,beforeLast:J,betweenWide:function(e,t,n){const r=J(e,n);return r?K(r,t):null},betweenNarrow:function(e,t,n){const r=K(e,t);return r?W(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Oe,containsWords:function(e,t,n){return"any"===n?t.some(t=>Oe(e,t)):t.every(t=>Oe(e,t))},joinUrl:qe,getFuzzyMatchScore:H,sortByFuzzyScore:function(e,t){return e.filter(e=>H(e,t)).sort((e,n)=>H(n,t)-H(e,t))},splitOnce:Y,splitAll:Q,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,(e,n)=>u(n.split("|"),t))},expand:function e(t){const n=t.match(/\{(.+?)\}/);if(!n||!n.index)return[t];const r=n[1].split(","),o=t.slice(0,n.index),i=t.slice(n.index+n[0].length);let a=[];for(const t of r){const n=e(o+t+i);a=a.concat(n)}return a},shrinkTrim:ne,capitalize:re,decapitalize:oe,csvEscape:function(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e},parseCsv:function(e,t=",",n='"'){const r=[];let o="",i=!1;const a=e.split("");for(const e of a)e!==t||i?e!==n||(o||i)&&!i?o+=e:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:ee,getBasename:te,normalizeEmail:function(e){let[t,n]=e.split("@");t=ne(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[r]=t.split("+");if(!r||!n||-1===n.indexOf(".")||n.indexOf(".")===n.length-1)throw new Error("Invalid email");return n=ne(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=te(e),n=ee(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=te(e),n=ee(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return re(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(re).join(" ")},slugToCamel:function(e){return oe(e.split("-").map(re).join(""))},joinHumanly:function(e,t=", ",n=" and "){return e&&e.length?1===e.length?e[0]:2===e.length?`${e[0]}${n}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${n}${e[e.length-1]}`:""},findWeightedPair:ye,extractBlock:be,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?de(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=be(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?de(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(t,n,r){let o=0;for(;;){const i=e.Strings.extractBlock(t,{...r,start:o});if(!i)return t;const a=n(i);o=t.indexOf(i,o)+a.length,t=t.replace(i,a)}},indexOfEarliest:de,lastIndexOfBefore:ge,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const e of n){const[n,r]=Y(e,"=");t[n]=r.slice(1,r.length-1)}return t},readNextWord:Re,readWordsAfterAll:function(e,t,n=[]){const r=he(e,t),o=[];for(const i of r)o.push(Re(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=ke(e,o,t[o],n,r);return e=Se(e)},resolveVariableWithDefaultSyntax:ke,resolveRemainingVariablesWithDefaults:Se,isLetter:ie,isDigit:ae,isLetterOrDigit:se,isValidObjectPathCharacter:function(e){return se(e)||"."===e||"["===e||"]"===e||"_"===e},insert:function(e,t,n,r,o){return e.slice(0,t)+r+e.slice(t,t+n)+o+e.slice(t+n)},indexOfRegex:le,allIndexOf:he,lineMatches:fe,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)fe(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&w(t.represent)){const e=t.represent();if(v(e))return"json"===n&&0===r?JSON.stringify(e):e}if(m(t,!1)){if(r>1)return"[object Object]";if("json"===n){if(Array.isArray(t)){const n=t.map(t=>e(t,"json",r+1));return 0===r?JSON.stringify(n):n}const n={};t.message&&(n.message=e(t.message,"json",r+1));for(const[o,i]of Object.entries(t))n[o]=e(i,"json",r+1);return 0===r?JSON.stringify(n):n}if("key-value"===n){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map(n=>`${n}=${JSON.stringify(e(t[n],"json",r+1))}`).join(" ")}}return b(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=ge(e,"[",n),o=e.indexOf(")",n);if(-1!==r&&-1!==o){const[n,i]=e.slice(r+1,o).split("]("),a=t(n,i);e=e.slice(0,r)+a+e.slice(o+1)}n=e.indexOf("](",n+1)}return e},buildUrl:function(e,t,n){return qe([e,t])+$e(n||{})},isChinese:function(e){return/^[\u4E00-\u9FA5]+$/.test(e)},replaceBetweenStrings:function(e,t,n,r,o=!0){const i=e.indexOf(t),a=e.indexOf(n,i+t.length);if(-1===i||-1===a)throw Error("Start or end not found");return o?e.substring(0,i+t.length)+r+e.substring(a):e.substring(0,i)+r+e.substring(a+n.length)},describeMarkdown:function(e){let t="p";return e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim()),{type:t,isCapitalized:e[0]===e[0].toUpperCase(),hasPunctuation:/[.?!]$/.test(e),endsWithColon:/:$/.test(e)}},isBalanced:function(e,t="(",n=")"){let r=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(r++,o+=t.length):e.startsWith(n,o)?(r--,o+=n.length):o++,r<0)return!1;return t===n?r%2==0:0===r},textToFormat:function(e){let t=(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")).length;for(;(e=e.replace(/(\w+)[\s,']+\w+/g,"$1")).length!==t;)t=e.length;return e=(e=(e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A")).replaceAll(/[a-z][a-zA-Z0-9]*/g,"a")).replaceAll(/[\u4E00-\u9FA5]+/g,"Z")},splitFormatting:function(e,t){const n=[];let r=0;for(;r<e.length;){const o=e.indexOf(t,r);if(-1===o){n.push({string:e.slice(r),symbol:null});break}const i=e.indexOf(t,o+t.length);if(o>r&&-1!==i&&n.push({string:e.slice(r,o),symbol:null}),-1===i){n.push({string:e.slice(r),symbol:null});break}n.push({string:e.slice(o+t.length,i),symbol:t}),r=i+t.length}return n},splitHashtags:function(e){const t=[];let n=0;for(;n<e.length;){const r=me(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=pe(e,r+1);if(-1===o){t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1),symbol:"#"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1,o),symbol:"#"}),n=o}return t},splitUrls:function(e){const t=[];let n=0;for(;n<e.length;){const r=de(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=de(e,[" ","\n"],r);if(-1===o){r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r),symbol:"http"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r,o),symbol:"http"}),n=o}return t},route:function(e,t){const n=e.split("/").filter(e=>e),r=t.split("/").filter(e=>e);if(n.length!==r.length)return null;const o={};for(let e=0;e<n.length;e++){const t=n[e];if(t.startsWith(":"))o[t.slice(1)]=r[e];else if(t!==r[e])return null}return o},explodeReplace:Be,generateVariants:function(t,n,r,o=Math.random){const i=e.Arrays.shuffle(n.map(t=>({variants:e.Arrays.shuffle(t.variants.map(e=>e),o),avoid:t.avoid})),o),a=[];for(const e of i){const n=e.variants.filter(t=>t!==e.avoid),o=n.find(e=>t.includes(e));if(o&&(L(a,Be(t,o,n)),a.length>=r))break}if(a.length<r)for(const e of i){const n=e.variants.find(e=>t.includes(e));if(n&&(L(a,Be(t,n,e.variants)),a.length>=r))break}return a.slice(0,r)},replaceWord:function(e,t,n,r=!1){const o=new RegExp(r?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,n)},replacePascalCaseWords:function(e,t){return e.replace(/\b[A-Z][a-zA-Z0-9]*\b/g,e=>e.toUpperCase()===e?e:t(e))},stripHtml:function(e){return e.replace(/<[^>]*>/g,"")},breakLine:Te,measureTextWidth:function(e,t={}){return[...e].reduce((e,n)=>e+(t[n]||1),0)},toLines:function(e,t,n={}){const r=[];let o="",i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o+=s,i+=n[s]||1,i>t){const{line:e,rest:t}=Te(o);r.push(e),o=t,i=t.split("").map(e=>n[e]||1).reduce((e,t)=>e+t,0)}}return o&&r.push(o),r},levenshteinDistance:function(e,t){const n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=e.length;r++)for(let o=1;o<=t.length;o++){const i=e[r-1]===t[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]},findCommonPrefix:Ae,findCommonDirectory:function(e){const t=Ae(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}},e.Assertions={asEqual:function(e,t){if(e!==t)throw Error(`Expected [${e}] to equal [${t}]`);return[e,t]},asTrue:function(e){if(!0!==e)throw Error(`Expected [true], got: [${e}]`);return e},asTruthy:function(e){if(!e)throw Error(`Expected truthy value, got: [${e}]`);return e},asFalse:function(e){if(!1!==e)throw Error(`Expected [false], got: [${e}]`);return e},asFalsy:function(e){if(e)throw Error(`Expected falsy value, got: [${e}]`);return e},asEither:function(e,t){if(!t.includes(e))throw Error(`Expected any of [${t.join(", ")}], got: [${e}]`);return e}},e.Cache={get:async function(e,t,n){const r=Date.now(),o=Ge.get(e);if(o&&o.validUntil>r)return o.value;const i=await n(),a=r+t;return Ge.set(e,{value:i,validUntil:a}),i},delete:function(e){Ge.delete(e)},deleteExpired:function(){const e=Date.now();for(const[t,n]of Ge.entries())n.validUntil<=e&&Ge.delete(t)},size:function(){return Ge.size}},e.Vector={addPoint:Kt,subtractPoint:function(e,t){return{x:e.x-t.x,y:e.y-t.y}},multiplyPoint:Jt,normalizePoint:function(e){const t=Math.sqrt(e.x*e.x+e.y*e.y);return{x:e.x/t,y:e.y/t}},pushPoint:Xt,filterCoordinates:Qt,findCorners:function(e,t,n,r){const o=[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}];for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const r=on(e,t,n);for(const e of r)o.some(t=>t.x===e.x&&t.y===e.y)||o.push(e)}return o.map(e=>({x:e.x*t,y:e.y*t}))},findLines:function(e,t){const n=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t][n+1],"row-first").map(e=>({...e,dx:1,dy:0})),r=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t][n-1],"row-first").map(e=>({...e,dx:1,dy:0})),o=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t-1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1})),i=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t+1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1}));return n.forEach(e=>e.y++),i.forEach(e=>e.x++),[...ct([...o,...i],(e,t)=>e.x===t.x&&e.y-1===t.y),...ct([...r,...n],(e,t)=>e.y===t.y&&e.x-1===t.x)].map(e=>({start:e[0],end:l(e)})).map(e=>({start:Jt(e.start,t),end:Jt(Kt(e.end,{x:e.start.dx,y:e.start.dy}),t)}))},raycast:cn,raycastCircle:function(e,t,n){const r=an(e,n),o=[];for(const n of r){const r=cn(e,t,n-.001),i=cn(e,t,n+.001);r&&o.push(r),i&&o.push(i)}return o},getLineIntersectionPoint:sn}}(qr)),qr),Zr=Lr(Hr);Zr.Arrays,Zr.Assertions;const Wr=Zr.Binary;Zr.Cache;const Kr=Zr.Dates,Jr=Zr.Elliptic,Xr=Zr.Numbers,Yr=Zr.Objects;Zr.Pagination,Zr.Promises,Zr.Random;const Qr=Zr.Strings,eo=Zr.System,to=Zr.Types,no=Zr.Optional;Zr.Vector,Zr.PubSubChannel,Zr.Chunk;const ro=Zr.MerkleTree,oo=Zr.FixedPointNumber;Zr.Lazy,Zr.AsyncLazy;const io=Zr.AsyncQueue,ao=Zr.Uint8ArrayReader;Zr.Uint8ArrayWriter,Zr.TrieRouter;var so,co,uo,lo,fo,ho={exports:{}};function po(){if(co)return so;co=1;var e=1e3,t=60*e,n=60*t,r=24*n,o=7*r,i=365.25*r;function a(e,t,n,r){var o=t>=1.5*n;return Math.round(e/n)+" "+r+(o?"s":"")}return so=function(s,c){c=c||{};var u=typeof s;if("string"===u&&s.length>0)return function(a){if((a=String(a)).length>100)return;var s=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(a);if(!s)return;var c=parseFloat(s[1]);switch((s[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*i;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*r;case"hours":case"hour":case"hrs":case"hr":case"h":return c*n;case"minutes":case"minute":case"mins":case"min":case"m":return c*t;case"seconds":case"second":case"secs":case"sec":case"s":return c*e;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(s);if("number"===u&&isFinite(s))return c.long?function(o){var i=Math.abs(o);if(i>=r)return a(o,i,r,"day");if(i>=n)return a(o,i,n,"hour");if(i>=t)return a(o,i,t,"minute");if(i>=e)return a(o,i,e,"second");return o+" ms"}(s):function(o){var i=Math.abs(o);if(i>=r)return Math.round(o/r)+"d";if(i>=n)return Math.round(o/n)+"h";if(i>=t)return Math.round(o/t)+"m";if(i>=e)return Math.round(o/e)+"s";return o+"ms"}(s);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(s))}}var mo=(fo||(fo=1,function(e,t){t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,o=0;t[0].replace(/%[a-zA-Z%]/g,e=>{"%%"!==e&&(r++,"%c"===e&&(o=r))}),t.splice(o,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")||t.storage.getItem("DEBUG")}catch(e){}return!e&&"undefined"!=typeof process&&"env"in process&&(e=process.env.DEBUG),e},t.useColors=function(){if("undefined"!=typeof window&&window.process&&("renderer"===window.process.type||window.process.__nwjs))return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;let e;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&(e=navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/))&&parseInt(e[1],10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=(lo||(lo=1,uo=function(e){function t(e){let r,o,i,a=null;function s(...e){if(!s.enabled)return;const n=s,o=Number(new Date),i=o-(r||o);n.diff=i,n.prev=r,n.curr=o,r=o,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,(r,o)=>{if("%%"===r)return"%";a++;const i=t.formatters[o];if("function"==typeof i){const t=e[a];r=i.call(n,t),e.splice(a,1),a--}return r}),t.formatArgs.call(n,e),(n.log||t.log).apply(n,e)}return s.namespace=e,s.useColors=t.useColors(),s.color=t.selectColor(e),s.extend=n,s.destroy=t.destroy,Object.defineProperty(s,"enabled",{enumerable:!0,configurable:!1,get:()=>null!==a?a:(o!==t.namespaces&&(o=t.namespaces,i=t.enabled(e)),i),set:e=>{a=e}}),"function"==typeof t.init&&t.init(s),s}function n(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function r(e,t){let n=0,r=0,o=-1,i=0;for(;n<e.length;)if(r<t.length&&(t[r]===e[n]||"*"===t[r]))"*"===t[r]?(o=r,i=n,r++):(n++,r++);else{if(-1===o)return!1;r=o+1,i++,n=i}for(;r<t.length&&"*"===t[r];)r++;return r===t.length}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names,...t.skips.map(e=>"-"+e)].join(",");return t.enable(""),e},t.enable=function(e){t.save(e),t.namespaces=e,t.names=[],t.skips=[];const n=("string"==typeof e?e:"").trim().replace(/\s+/g,",").split(",").filter(Boolean);for(const e of n)"-"===e[0]?t.skips.push(e.slice(1)):t.names.push(e)},t.enabled=function(e){for(const n of t.skips)if(r(e,n))return!1;for(const n of t.names)if(r(e,n))return!0;return!1},t.humanize=po(),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach(n=>{t[n]=e[n]}),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}),uo)(t);const{formatters:n}=e.exports;n.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}}(ho,ho.exports)),ho.exports),go=Lr(mo);const yo=go("bee-js:bytes"),bo=new TextDecoder,wo=new TextEncoder;class vo{constructor(e,t){if(!e)throw Error(`Bytes#constructor: constructor parameter is falsy: ${e}`);if(e instanceof vo)this.bytes=e.bytes;else if("string"==typeof e)this.bytes=Wr.hexToUint8Array(to.asHexString(e,{name:"Bytes#constructor(bytes)"}));else if(e instanceof ArrayBuffer)this.bytes=new Uint8Array(e);else if(e instanceof Uint8Array)this.bytes=e;else{const t=e,n=Yr.getDeep(t,"toHex");if(!to.isFunction(n))throw yo("bytes",e),new Error("Bytes#constructor: unsupported type: "+typeof e);{const e=n.call(t);this.bytes=Wr.hexToUint8Array(to.asHexString(e,{name:"Bytes#constructor(bytes)"}))}}if(this.length=this.bytes.length,t)if(Array.isArray(t)){if(!t.includes(this.length))throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${t.join(" or ")}`)}else if(this.length!==t)throw new Error(`Bytes#checkByteLength: bytes length is ${this.length} but expected ${t}`)}static keccak256(e){return new vo(Wr.keccak256(new vo(e).toUint8Array()))}static fromUtf8(e){return new vo(wo.encode(e))}static fromSlice(e,t,n){return new vo(void 0===n?e.slice(t):e.slice(t,t+n))}offset(e){return new Uint8Array(this.bytes.slice(e))}toUint8Array(){return new Uint8Array(this.bytes)}toHex(){return Wr.uint8ArrayToHex(this.bytes)}toBase64(){return Wr.uint8ArrayToBase64(this.bytes)}toBase32(){return Wr.uint8ArrayToBase32(this.bytes)}toString(){return this.toHex()}toUtf8(){return bo.decode(this.bytes)}toJSON(){return JSON.parse(this.toUtf8())}equals(e){return this.toHex()===new vo(e).toHex()}represent(){return this.toHex()}}function Eo(e){const t=e.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);if(!t)throw new Error(`Invalid size format: ${e}`);const n=parseFloat(t[1]),r=t[2];return Math.ceil(n*{B:1,kB:1e3,MB:1e6,GB:1e3**3,TB:1e3**4,PB:1e3**5}[r])}const xo=250,Bo=251,To={[xo]:"manifest",[Bo]:"feed"};const Ao=new TextEncoder;class Oo extends vo{constructor(e){super(e,32)}publicKey(){const[e,t]=Jr.privateKeyToPublicKey(Wr.uint256ToNumber(this.bytes,"BE"));return new Ro(Wr.concatBytes(Wr.numberToUint256(e,"BE"),Wr.numberToUint256(t,"BE")))}sign(e){const t=Wr.concatBytes(Ao.encode("Ethereum Signed Message:\n32"),Wr.keccak256(e instanceof Uint8Array?e:Ao.encode(e))),[n,r,o]=Jr.signMessage(t,Wr.uint256ToNumber(this.bytes,"BE"));return new Co(Wr.concatBytes(Wr.numberToUint256(n,"BE"),Wr.numberToUint256(r,"BE"),new Uint8Array([Number(o)])))}}Oo.LENGTH=32;class Ro extends vo{constructor(e){const t=new vo(e);if(33===t.length){const[e,n]=Jr.publicKeyFromCompressed(t.toUint8Array());super(Wr.concatBytes(Wr.numberToUint256(e,"BE"),Wr.numberToUint256(n,"BE")),64)}else super(e,64)}address(){const e=Wr.uint256ToNumber(this.bytes.slice(0,32),"BE"),t=Wr.uint256ToNumber(this.bytes.slice(32,64),"BE");return new ko(Jr.publicKeyToAddress([e,t]))}toCompressedUint8Array(){const e=Wr.uint256ToNumber(this.bytes.slice(0,32),"BE"),t=Wr.uint256ToNumber(this.bytes.slice(32,64),"BE");return Jr.compressPublicKey([e,t])}toCompressedHex(){return Wr.uint8ArrayToHex(this.toCompressedUint8Array())}}Ro.LENGTH=64;class ko extends vo{constructor(e){super(e,20)}toChecksum(){return Jr.checksumEncode(this.bytes)}}ko.LENGTH=20;class So extends vo{constructor(e){super(e,32)}static fromString(e){return new So(Wr.keccak256(Ao.encode(e)))}}So.LENGTH=32;class $o extends vo{constructor(e){if("string"==typeof e&&e.startsWith("bah5")){const t=function(e){const t=Wr.base32ToUint8Array(e.toUpperCase().slice(1)),n=t[1];if(!To[n])throw new Error("Unknown codec");const r=new $o(t.slice(-32));return{type:To[n],reference:r}}(e);super(t.reference.bytes,32)}else super(e,[32,64])}toCid(e){return function(e,t){e=new $o(e);const n=new Uint8Array([1]),r=new Uint8Array(["feed"===t?251:250]),o=new Uint8Array([1]),i=new Uint8Array([27]),a=new Uint8Array([32]);return`b${Wr.uint8ArrayToBase32(Wr.concatBytes(n,r,o,i,a)).replace(/\=+$/,"")}${e.toBase32().replace(/\=+$/,"")}`.toLowerCase()}(this.bytes,e)}static isValid(e){try{return new $o(e),!0}catch{return!1}}}$o.LENGTH=32;class zo extends vo{constructor(e){super(e,32)}}zo.LENGTH=32;class Do extends vo{constructor(e){super(e,8)}static fromBigInt(e){return new Do(Wr.numberToUint64(e,"LE"))}toBigInt(){return Wr.uint64ToNumber(this.bytes,"LE")}static fromSlice(e,t){return new Do(e.slice(t,t+Do.LENGTH))}}Do.LENGTH=8;class Io extends vo{constructor(e){super(e,32)}}Io.LENGTH=32;class Po extends vo{constructor(e){super(e,32)}}Po.LENGTH=32;class Co extends vo{constructor(e){super(e,65)}static fromSlice(e,t){return new Co(e.slice(t,t+Co.LENGTH))}recoverPublicKey(e){const t=Wr.uint256ToNumber(this.bytes.slice(0,32),"BE"),n=Wr.uint256ToNumber(this.bytes.slice(32,64),"BE"),r=BigInt(this.bytes[64]),[o,i]=Jr.recoverPublicKey(Wr.concatBytes(Ao.encode("Ethereum Signed Message:\n32"),Wr.keccak256(e instanceof Uint8Array?e:Ao.encode(e))),t,n,r);return new Ro(Wr.concatBytes(Wr.numberToUint256(o,"BE"),Wr.numberToUint256(i,"BE")))}isValid(e,t){return this.recoverPublicKey(e).address().equals(t)}}Co.LENGTH=65;class No extends vo{constructor(e){super(e,32)}static fromString(e){return new No(Wr.keccak256(Ao.encode(e)))}}No.LENGTH=32;const _o=new Uint8Array(8).fill(255,0,8);class Vo extends vo{constructor(e){super(e,8)}static fromBigInt(e){return new Vo(Wr.numberToUint64(e,"BE"))}toBigInt(){return Wr.uint64ToNumber(this.bytes,"BE")}next(){return Wr.equals(this.bytes,_o)?Vo.fromBigInt(0n):Vo.fromBigInt(this.toBigInt()+1n)}}Vo.LENGTH=8,Vo.MINUS_ONE=new Vo(_o);class Uo extends Error{constructor(e){super(e)}}class Fo extends Uo{constructor(e,t){super(e),this.value=t}}class Mo extends Uo{constructor(e,t,n,r,o,i){super(n),this.method=e,this.url=t,this.responseBody=r,this.status=o,this.statusText=i}}const jo=4096;function Lo(e){const t=e.slice(0,Do.LENGTH),n=function(e){if(e.length>jo)throw new Fo(`payload size ${e.length} exceeds maximum chunk payload size 4096`,e);const t=new Uint8Array(jo);t.set(e);let n=Wr.partition(t,32);for(;n.length>1;){const e=[];for(let t=0;t<n.length;t+=2){const r=n[t],o=n[t+1],i=Wr.concatBytes(r,o),a=Wr.keccak256(i);e.push(a)}n=e}return n[0]}(e.slice(Do.LENGTH)),r=Wr.keccak256(Wr.concatBytes(t,n));return new $o(r)}const Go=4096,qo=new TextEncoder;function Ho(e){if(e instanceof Uint8Array||(e=qo.encode(e)),e.length<1||e.length>Go)throw new RangeError(`payload size ${e.length} exceeds limits [1, 4096]`);const t=Do.fromBigInt(BigInt(e.length)),n=Wr.concatBytes(t.toUint8Array(),e);return{data:n,span:t,payload:vo.fromSlice(n,Do.LENGTH),address:Lo(n)}}function Zo(e){if(e.length<1+Do.LENGTH||e.length>Go+Do.LENGTH)throw new RangeError(`chunk size ${e.length} exceeds limits [${1+Do.LENGTH}, ${Do.LENGTH}]`);const t=Do.fromSlice(e,0),n=Wr.concatBytes(t.toUint8Array(),e.slice(Do.LENGTH));return{data:n,span:t,payload:vo.fromSlice(n,Do.LENGTH),address:Lo(n)}}var Wo;function Ko(e){switch(e){case"full":return Wo.FULL;case"light":return Wo.LIGHT;case"ultra-light":return Wo.ULTRA_LIGHT;case"dev":return Wo.DEV;default:throw new Error(`Unknown Bee mode: ${e}`)}}!function(e){e.FULL="full",e.LIGHT="light",e.ULTRA_LIGHT="ultra-light",e.DEV="dev"}(Wo||(Wo={}));var Jo,Xo;!function(e){e[e.OFF=0]="OFF",e[e.MEDIUM=1]="MEDIUM",e[e.STRONG=2]="STRONG",e[e.INSANE=3]="INSANE",e[e.PARANOID=4]="PARANOID"}(Jo||(Jo={})),function(e){e[e.NONE=0]="NONE",e[e.DATA=1]="DATA",e[e.PROX=2]="PROX",e[e.RACE=3]="RACE"}(Xo||(Xo={}));const Yo={ENCRYPTION_OFF:{[Jo.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.70 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.66 MB",batchDepth:18,utilizationRate:"0.61%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"112.06 MB",batchDepth:19,utilizationRate:"5.09%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"687.62 MB",batchDepth:20,utilizationRate:"15.65%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.60 GB",batchDepth:21,utilizationRate:"30.27%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.73 GB",batchDepth:22,utilizationRate:"44.99%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.94 GB",batchDepth:23,utilizationRate:"58.03%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"47.06 GB",batchDepth:24,utilizationRate:"68.48%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"105.51 GB",batchDepth:25,utilizationRate:"76.77%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"227.98 GB",batchDepth:26,utilizationRate:"82.94%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"476.68 GB",batchDepth:27,utilizationRate:"86.71%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"993.65 GB",batchDepth:28,utilizationRate:"88.37%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.04 TB",batchDepth:29,utilizationRate:"92.88%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.17 TB",batchDepth:30,utilizationRate:"94.81%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.45 TB",batchDepth:31,utilizationRate:"96.06%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"17.07 TB",batchDepth:32,utilizationRate:"97.01%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.36 TB",batchDepth:33,utilizationRate:"97.65%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"69.04 TB",batchDepth:34,utilizationRate:"98.11%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"138.54 TB",batchDepth:35,utilizationRate:"98.44%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"277.72 TB",batchDepth:36,utilizationRate:"98.67%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"556.35 TB",batchDepth:37,utilizationRate:"98.83%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.91%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.23 PB",batchDepth:39,utilizationRate:"98.96%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.46 PB",batchDepth:40,utilizationRate:"98.98%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.93 PB",batchDepth:41,utilizationRate:"99.11%"}],[Jo.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"41.56 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.19 MB",batchDepth:18,utilizationRate:"0.57%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"104.18 MB",batchDepth:19,utilizationRate:"4.73%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"639.27 MB",batchDepth:20,utilizationRate:"14.54%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.41 GB",batchDepth:21,utilizationRate:"28.11%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.18 GB",batchDepth:22,utilizationRate:"41.79%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.54 GB",batchDepth:23,utilizationRate:"53.95%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.75 GB",batchDepth:24,utilizationRate:"63.66%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"98.09 GB",batchDepth:25,utilizationRate:"71.37%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"211.95 GB",batchDepth:26,utilizationRate:"77.11%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"443.16 GB",batchDepth:27,utilizationRate:"80.61%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"923.78 GB",batchDepth:28,utilizationRate:"82.16%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.90 TB",batchDepth:29,utilizationRate:"86.30%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.88 TB",batchDepth:30,utilizationRate:"88.14%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.86 TB",batchDepth:31,utilizationRate:"89.26%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.87 TB",batchDepth:32,utilizationRate:"90.21%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.94 TB",batchDepth:33,utilizationRate:"90.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"64.19 TB",batchDepth:34,utilizationRate:"91.22%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"128.80 TB",batchDepth:35,utilizationRate:"91.52%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"258.19 TB",batchDepth:36,utilizationRate:"91.73%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"517.23 TB",batchDepth:37,utilizationRate:"91.88%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.04 PB",batchDepth:38,utilizationRate:"91.95%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.07 PB",batchDepth:39,utilizationRate:"92.00%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.15 PB",batchDepth:40,utilizationRate:"92.15%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.30 PB",batchDepth:41,utilizationRate:"92.14%"}],[Jo.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"37.37 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.57 MB",batchDepth:18,utilizationRate:"0.51%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"93.68 MB",batchDepth:19,utilizationRate:"4.25%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"574.81 MB",batchDepth:20,utilizationRate:"13.07%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.17 GB",batchDepth:21,utilizationRate:"25.26%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.46 GB",batchDepth:22,utilizationRate:"37.58%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.67 GB",batchDepth:23,utilizationRate:"48.50%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"39.34 GB",batchDepth:24,utilizationRate:"57.24%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"88.20 GB",batchDepth:25,utilizationRate:"64.17%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"190.58 GB",batchDepth:26,utilizationRate:"69.33%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"398.47 GB",batchDepth:27,utilizationRate:"72.48%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"830.63 GB",batchDepth:28,utilizationRate:"73.85%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.71 TB",batchDepth:29,utilizationRate:"77.59%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.49 TB",batchDepth:30,utilizationRate:"79.27%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.07 TB",batchDepth:31,utilizationRate:"80.34%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.27 TB",batchDepth:32,utilizationRate:"81.12%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.72 TB",batchDepth:33,utilizationRate:"81.63%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"57.71 TB",batchDepth:34,utilizationRate:"82.01%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"115.81 TB",batchDepth:35,utilizationRate:"82.29%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"232.16 TB",batchDepth:36,utilizationRate:"82.48%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"465.07 TB",batchDepth:37,utilizationRate:"82.61%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"931.23 TB",batchDepth:38,utilizationRate:"82.67%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.86 PB",batchDepth:39,utilizationRate:"82.71%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.73 PB",batchDepth:40,utilizationRate:"82.78%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.46 PB",batchDepth:41,utilizationRate:"82.79%"}],[Jo.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.88 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.05 MB",batchDepth:18,utilizationRate:"0.46%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"84.92 MB",batchDepth:19,utilizationRate:"3.86%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"521.09 MB",batchDepth:20,utilizationRate:"11.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.97 GB",batchDepth:21,utilizationRate:"22.90%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.86 GB",batchDepth:22,utilizationRate:"34.09%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"15.11 GB",batchDepth:23,utilizationRate:"43.97%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.66 GB",batchDepth:24,utilizationRate:"51.90%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"79.96 GB",batchDepth:25,utilizationRate:"58.18%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"172.77 GB",batchDepth:26,utilizationRate:"62.85%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"361.23 GB",batchDepth:27,utilizationRate:"65.70%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"753.00 GB",batchDepth:28,utilizationRate:"66.95%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.55 TB",batchDepth:29,utilizationRate:"70.38%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.16 TB",batchDepth:30,utilizationRate:"71.92%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.41 TB",batchDepth:31,utilizationRate:"72.85%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.93 TB",batchDepth:32,utilizationRate:"73.53%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"26.04 TB",batchDepth:33,utilizationRate:"74.01%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"52.32 TB",batchDepth:34,utilizationRate:"74.35%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"104.99 TB",batchDepth:35,utilizationRate:"74.60%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"210.46 TB",batchDepth:36,utilizationRate:"74.77%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"421.61 TB",batchDepth:37,utilizationRate:"74.89%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"844.20 TB",batchDepth:38,utilizationRate:"74.94%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.69 PB",batchDepth:39,utilizationRate:"74.98%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.38 PB",batchDepth:40,utilizationRate:"75.03%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.77 PB",batchDepth:41,utilizationRate:"75.10%"}],[Jo.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.27 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.98 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.27 MB",batchDepth:19,utilizationRate:"1.51%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"204.14 MB",batchDepth:20,utilizationRate:"4.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"771.13 MB",batchDepth:21,utilizationRate:"8.75%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.29 GB",batchDepth:22,utilizationRate:"13.34%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.92 GB",batchDepth:23,utilizationRate:"17.22%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.97 GB",batchDepth:24,utilizationRate:"20.33%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.32 GB",batchDepth:25,utilizationRate:"22.79%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.68 GB",batchDepth:26,utilizationRate:"24.62%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"141.51 GB",batchDepth:27,utilizationRate:"25.74%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"294.99 GB",batchDepth:28,utilizationRate:"26.23%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"606.90 GB",batchDepth:29,utilizationRate:"27.56%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.24 TB",batchDepth:30,utilizationRate:"28.15%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.51 TB",batchDepth:31,utilizationRate:"28.54%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.07 TB",batchDepth:32,utilizationRate:"28.82%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.20 TB",batchDepth:33,utilizationRate:"28.99%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.50 TB",batchDepth:34,utilizationRate:"29.13%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"41.13 TB",batchDepth:35,utilizationRate:"29.22%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"82.45 TB",batchDepth:36,utilizationRate:"29.29%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"165.17 TB",batchDepth:37,utilizationRate:"29.34%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"330.72 TB",batchDepth:38,utilizationRate:"29.37%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"661.97 TB",batchDepth:39,utilizationRate:"29.39%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.32 PB",batchDepth:40,utilizationRate:"29.41%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.65 PB",batchDepth:41,utilizationRate:"29.43%"}]},ENCRYPTION_ON:{[Jo.OFF]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"44.35 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.61 MB",batchDepth:18,utilizationRate:"0.60%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"111.18 MB",batchDepth:19,utilizationRate:"5.05%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"682.21 MB",batchDepth:20,utilizationRate:"15.52%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.58 GB",batchDepth:21,utilizationRate:"30.04%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.67 GB",batchDepth:22,utilizationRate:"44.62%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"19.78 GB",batchDepth:23,utilizationRate:"57.56%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"46.69 GB",batchDepth:24,utilizationRate:"67.93%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"104.68 GB",batchDepth:25,utilizationRate:"76.16%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"226.19 GB",batchDepth:26,utilizationRate:"82.29%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"472.93 GB",batchDepth:27,utilizationRate:"86.02%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"985.83 GB",batchDepth:28,utilizationRate:"87.66%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"2.03 TB",batchDepth:29,utilizationRate:"92.25%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"4.14 TB",batchDepth:30,utilizationRate:"94.21%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"8.39 TB",batchDepth:31,utilizationRate:"95.37%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"16.93 TB",batchDepth:32,utilizationRate:"96.22%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"34.09 TB",batchDepth:33,utilizationRate:"96.88%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"68.50 TB",batchDepth:34,utilizationRate:"97.34%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"137.45 TB",batchDepth:35,utilizationRate:"97.67%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"275.53 TB",batchDepth:36,utilizationRate:"97.89%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"551.97 TB",batchDepth:37,utilizationRate:"98.05%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.11 PB",batchDepth:38,utilizationRate:"98.13%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.21 PB",batchDepth:39,utilizationRate:"98.18%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.43 PB",batchDepth:40,utilizationRate:"98.36%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.86 PB",batchDepth:41,utilizationRate:"98.37%"}],[Jo.MEDIUM]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"40.89 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"6.09 MB",batchDepth:18,utilizationRate:"0.56%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"102.49 MB",batchDepth:19,utilizationRate:"4.65%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"628.91 MB",batchDepth:20,utilizationRate:"14.30%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.38 GB",batchDepth:21,utilizationRate:"27.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"7.07 GB",batchDepth:22,utilizationRate:"41.15%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"18.24 GB",batchDepth:23,utilizationRate:"53.09%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"43.04 GB",batchDepth:24,utilizationRate:"62.63%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"96.50 GB",batchDepth:25,utilizationRate:"70.21%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"208.52 GB",batchDepth:26,utilizationRate:"75.86%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"435.98 GB",batchDepth:27,utilizationRate:"79.30%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"908.81 GB",batchDepth:28,utilizationRate:"80.82%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.87 TB",batchDepth:29,utilizationRate:"84.98%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.81 TB",batchDepth:30,utilizationRate:"86.67%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"7.73 TB",batchDepth:31,utilizationRate:"87.84%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"15.61 TB",batchDepth:32,utilizationRate:"88.74%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"31.43 TB",batchDepth:33,utilizationRate:"89.34%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"63.15 TB",batchDepth:34,utilizationRate:"89.74%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"126.71 TB",batchDepth:35,utilizationRate:"90.03%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"254.01 TB",batchDepth:36,utilizationRate:"90.24%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"508.85 TB",batchDepth:37,utilizationRate:"90.39%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"1.02 PB",batchDepth:38,utilizationRate:"90.47%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"2.04 PB",batchDepth:39,utilizationRate:"90.51%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"4.08 PB",batchDepth:40,utilizationRate:"90.64%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"8.17 PB",batchDepth:41,utilizationRate:"90.65%"}],[Jo.STRONG]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"36.73 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"5.47 MB",batchDepth:18,utilizationRate:"0.50%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"92.07 MB",batchDepth:19,utilizationRate:"4.18%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"564.95 MB",batchDepth:20,utilizationRate:"12.85%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"2.13 GB",batchDepth:21,utilizationRate:"24.86%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"6.35 GB",batchDepth:22,utilizationRate:"36.97%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"16.38 GB",batchDepth:23,utilizationRate:"47.67%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"38.66 GB",batchDepth:24,utilizationRate:"56.26%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"86.69 GB",batchDepth:25,utilizationRate:"63.07%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"187.31 GB",batchDepth:26,utilizationRate:"68.14%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"391.64 GB",batchDepth:27,utilizationRate:"71.24%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"816.39 GB",batchDepth:28,utilizationRate:"72.59%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.68 TB",batchDepth:29,utilizationRate:"76.34%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.43 TB",batchDepth:30,utilizationRate:"77.89%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.94 TB",batchDepth:31,utilizationRate:"78.86%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"14.02 TB",batchDepth:32,utilizationRate:"79.71%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"28.23 TB",batchDepth:33,utilizationRate:"80.23%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"56.72 TB",batchDepth:34,utilizationRate:"80.60%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"113.82 TB",batchDepth:35,utilizationRate:"80.88%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"228.18 TB",batchDepth:36,utilizationRate:"81.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"457.10 TB",batchDepth:37,utilizationRate:"81.20%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"915.26 TB",batchDepth:38,utilizationRate:"81.26%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.83 PB",batchDepth:39,utilizationRate:"81.30%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.67 PB",batchDepth:40,utilizationRate:"81.43%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"7.34 PB",batchDepth:41,utilizationRate:"81.45%"}],[Jo.INSANE]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"33.26 kB",batchDepth:17,utilizationRate:"0.01%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"4.96 MB",batchDepth:18,utilizationRate:"0.45%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"83.38 MB",batchDepth:19,utilizationRate:"3.79%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"511.65 MB",batchDepth:20,utilizationRate:"11.64%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"1.93 GB",batchDepth:21,utilizationRate:"22.52%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"5.75 GB",batchDepth:22,utilizationRate:"33.50%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"14.84 GB",batchDepth:23,utilizationRate:"43.19%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"35.02 GB",batchDepth:24,utilizationRate:"50.96%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"78.51 GB",batchDepth:25,utilizationRate:"57.12%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"169.64 GB",batchDepth:26,utilizationRate:"61.71%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"354.69 GB",batchDepth:27,utilizationRate:"64.52%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"739.37 GB",batchDepth:28,utilizationRate:"65.74%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"1.52 TB",batchDepth:29,utilizationRate:"69.15%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"3.10 TB",batchDepth:30,utilizationRate:"70.56%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"6.29 TB",batchDepth:31,utilizationRate:"71.48%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"12.70 TB",batchDepth:32,utilizationRate:"72.18%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"25.57 TB",batchDepth:33,utilizationRate:"72.67%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"51.37 TB",batchDepth:34,utilizationRate:"73.00%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"103.08 TB",batchDepth:35,utilizationRate:"73.24%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"206.65 TB",batchDepth:36,utilizationRate:"73.42%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"413.98 TB",batchDepth:37,utilizationRate:"73.54%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"828.91 TB",batchDepth:38,utilizationRate:"73.59%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"1.66 PB",batchDepth:39,utilizationRate:"73.62%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"3.32 PB",batchDepth:40,utilizationRate:"73.72%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"6.64 PB",batchDepth:41,utilizationRate:"73.74%"}],[Jo.PARANOID]:[{theoreticalVolume:"536.87 MB",effectiveVolume:"13.17 kB",batchDepth:17,utilizationRate:"0.00%"},{theoreticalVolume:"1.07 GB",effectiveVolume:"1.96 MB",batchDepth:18,utilizationRate:"0.18%"},{theoreticalVolume:"2.15 GB",effectiveVolume:"33.01 MB",batchDepth:19,utilizationRate:"1.50%"},{theoreticalVolume:"4.29 GB",effectiveVolume:"202.53 MB",batchDepth:20,utilizationRate:"4.61%"},{theoreticalVolume:"8.59 GB",effectiveVolume:"765.05 MB",batchDepth:21,utilizationRate:"8.68%"},{theoreticalVolume:"17.18 GB",effectiveVolume:"2.28 GB",batchDepth:22,utilizationRate:"13.27%"},{theoreticalVolume:"34.36 GB",effectiveVolume:"5.87 GB",batchDepth:23,utilizationRate:"17.08%"},{theoreticalVolume:"68.72 GB",effectiveVolume:"13.86 GB",batchDepth:24,utilizationRate:"20.17%"},{theoreticalVolume:"137.44 GB",effectiveVolume:"31.08 GB",batchDepth:25,utilizationRate:"22.61%"},{theoreticalVolume:"274.88 GB",effectiveVolume:"67.15 GB",batchDepth:26,utilizationRate:"24.43%"},{theoreticalVolume:"549.76 GB",effectiveVolume:"140.40 GB",batchDepth:27,utilizationRate:"25.54%"},{theoreticalVolume:"1.10 TB",effectiveVolume:"292.67 GB",batchDepth:28,utilizationRate:"26.03%"},{theoreticalVolume:"2.20 TB",effectiveVolume:"602.12 GB",batchDepth:29,utilizationRate:"27.35%"},{theoreticalVolume:"4.40 TB",effectiveVolume:"1.23 TB",batchDepth:30,utilizationRate:"27.94%"},{theoreticalVolume:"8.80 TB",effectiveVolume:"2.49 TB",batchDepth:31,utilizationRate:"28.32%"},{theoreticalVolume:"17.59 TB",effectiveVolume:"5.03 TB",batchDepth:32,utilizationRate:"28.60%"},{theoreticalVolume:"35.18 TB",effectiveVolume:"10.12 TB",batchDepth:33,utilizationRate:"28.77%"},{theoreticalVolume:"70.37 TB",effectiveVolume:"20.34 TB",batchDepth:34,utilizationRate:"28.91%"},{theoreticalVolume:"140.74 TB",effectiveVolume:"40.80 TB",batchDepth:35,utilizationRate:"29.00%"},{theoreticalVolume:"281.47 TB",effectiveVolume:"81.80 TB",batchDepth:36,utilizationRate:"29.06%"},{theoreticalVolume:"562.95 TB",effectiveVolume:"163.87 TB",batchDepth:37,utilizationRate:"29.11%"},{theoreticalVolume:"1.13 PB",effectiveVolume:"328.11 TB",batchDepth:38,utilizationRate:"29.14%"},{theoreticalVolume:"2.25 PB",effectiveVolume:"656.76 TB",batchDepth:39,utilizationRate:"29.16%"},{theoreticalVolume:"4.50 PB",effectiveVolume:"1.31 PB",batchDepth:40,utilizationRate:"29.18%"},{theoreticalVolume:"9.01 PB",effectiveVolume:"2.63 PB",batchDepth:41,utilizationRate:"29.19%"}]}};class Qo{constructor(e){this.seconds=Math.ceil(e),e<0&&(this.seconds=0)}static fromMilliseconds(e){return new Qo(e/1e3)}static fromSeconds(e){return new Qo(e)}static fromHours(e){return new Qo(60*e*60)}static fromDays(e){return new Qo(24*e*60*60)}static fromWeeks(e){return new Qo(7*e*24*60*60)}static fromYears(e){return new Qo(365*e*24*60*60)}static fromEndDate(e,t){return new Qo((e.getTime()-(t??new Date).getTime())/1e3)}static parseFromString(e){return Qo.fromSeconds(Kr.make(e)/1e3)}toSeconds(){return this.seconds}toHours(){return this.seconds/60/60}toDays(){return this.seconds/24/60/60}toWeeks(){return this.seconds/7/24/60/60}toYears(){return this.seconds/365/24/60/60}toEndDate(e){return new Date((e??new Date).getTime()+1e3*this.seconds)}represent(){return Kr.secondsToHumanTime(this.seconds)}isZero(){return 0===this.seconds}}Qo.ZERO=new Qo(0);class ei{constructor(e){this.state=e}static fromDecimalString(e){return new ei(oo.fromDecimalString(e,ei.DIGITS))}static fromPLUR(e){return new ei(new oo(e,ei.DIGITS))}toPLURString(){return this.state.toString()}toPLURBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}plus(e){return new ei(this.state.add(e instanceof ei?e.state:new oo(e,ei.DIGITS)))}minus(e){return new ei(this.state.subtract(e instanceof ei?e.state:new oo(e,ei.DIGITS)))}divide(e){return new ei(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToDAI(e){return ti.fromWei(this.state.exchange("*",new oo(e.toWeiBigInt(),ti.DIGITS),ti.DIGITS).value)}}ei.DIGITS=16;class ti{constructor(e){this.state=e}static fromDecimalString(e){return new ti(oo.fromDecimalString(e,ti.DIGITS))}static fromWei(e){return new ti(new oo(e,ti.DIGITS))}toWeiString(){return this.state.toString()}toWeiBigInt(){return this.state.value}toDecimalString(){return this.state.toDecimalString()}toSignificantDigits(e){return this.toDecimalString().slice(0,this.toDecimalString().indexOf(".")+e+1)}plus(e){return new ti(this.state.add(e instanceof ti?e.state:new oo(e,ti.DIGITS)))}minus(e){return new ti(this.state.subtract(e instanceof ti?e.state:new oo(e,ti.DIGITS)))}divide(e){return new ti(this.state.divmod(e)[0])}gt(e){return 1===this.state.compare(e.state)}gte(e){return-1!==this.state.compare(e.state)}lt(e){return-1===this.state.compare(e.state)}lte(e){return 1!==this.state.compare(e.state)}eq(e){return 0===this.state.compare(e.state)}exchangeToBZZ(e){return ei.fromPLUR(this.state.exchange("/",new oo(e.toWeiBigInt(),ti.DIGITS),ei.DIGITS).value)}}function ni(e){if("function"==typeof File&&e instanceof File)return!0;const t=e;return"object"==typeof t&&"string"==typeof t.name&&("function"==typeof t.stream||"function"==typeof t.arrayBuffer)}async function ri(e){return e.arrayBuffer?e.arrayBuffer():new Promise(t=>{const n=new FileReader;n.onload=()=>t(n.result),n.readAsArrayBuffer(e)})}function oi(e,t){return"bigint"==typeof e&&(e=e.toString()),to.asIntegerString(e,t)}function ii(e){const t=to.asObject(e,{name:"DownloadOptions"});return{redundancyStrategy:to.asOptional(e=>to.asInteger(e,{name:"redundancyStrategy"}),t.redundancyStrategy),fallback:to.asOptional(e=>to.asBoolean(e,{name:"fallback"}),t.fallback),timeoutMs:to.asOptional(e=>to.asInteger(e,{name:"timeoutMs",min:0}),t.timeoutMs),actPublisher:to.asOptional(e=>new Ro(e),t.actPublisher),actHistoryAddress:to.asOptional(e=>new $o(e),t.actHistoryAddress),actTimestamp:to.asOptional(e=>to.asNumber(e,{name:"actTimestamp"}),t.actTimestamp)}}function ai(e,t="UploadOptions"){const n=to.asObject(e,{name:t});return{act:to.asOptional(e=>to.asBoolean(e,{name:"act"}),n.act),actHistoryAddress:to.asOptional(e=>new $o(e),n.actHistoryAddress),deferred:to.asOptional(e=>to.asBoolean(e,{name:"deferred"}),n.deferred),encrypt:to.asOptional(e=>to.asBoolean(e,{name:"encrypt"}),n.encrypt),pin:to.asOptional(e=>to.asBoolean(e,{name:"pin"}),n.pin),tag:to.asOptional(e=>to.asInteger(e,{name:"tag",min:0}),n.tag)}}function si(e){const t=ai(e,"CollectionUploadOptions"),n=to.asObject(e,{name:"CollectionUploadOptions"});return{...t,errorDocument:to.asOptional(e=>to.asString(e,{name:"errorDocument"}),n.errorDocument),indexDocument:to.asOptional(e=>to.asString(e,{name:"indexDocument"}),n.indexDocument),redundancyLevel:to.asOptional(e=>to.asInteger(e,{name:"redundancyLevel",min:0}),n.redundancyLevel)}}function ci(e){const t=to.asObject(e,{name:"PostageBatchOptions"});return{gasPrice:to.asOptional(e=>oi(e,{name:"gasPrice"}),t.gasPrice),immutableFlag:to.asOptional(e=>to.asBoolean(e,{name:"immutableFlag"}),t.immutableFlag),label:to.asOptional(e=>to.asString(e,{name:"label"}),t.label),waitForUsable:to.asOptional(e=>to.asBoolean(e,{name:"waitForUsable"}),t.waitForUsable),waitForUsableTimeout:to.asOptional(e=>to.asInteger(e,{name:"waitForUsableTimeout",min:0}),t.waitForUsableTimeout)}}function ui(e,t="TransactionOptions"){const n=to.asObject(e,{name:t});return{gasLimit:to.asOptional(e=>oi(e,{name:"gasLimit",min:0n}),n.gasLimit),gasPrice:to.asOptional(e=>oi(e,{name:"gasPrice",min:0n}),n.gasPrice)}}function li(e){if("string"!=typeof e&&!(e instanceof Uint8Array))throw new TypeError("Data must be either string or Uint8Array!")}function fi(e){if(null==e)throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`);if(function(e){try{const t=to.asObject(e,{name:"Tag"});return to.asInteger(t.uid,{name:"Tag.uid"}),!0}catch{return!1}}(e))return e.uid;if("number"==typeof e||"string"==typeof e)return to.asNumber(e,{name:"tagUid",min:0});throw new TypeError(`Expected number | Tag | string from tagUid, got: ${e}`)}ti.DIGITS=18;function hi(e,t,n){return e/Math.pow(2,t-n)}function di(e){return 4096*2**e}const pi=[[17,4089e-8],[18,.00609],[19,.10249],[20,.62891],[21,2.38],[22,7.07],[23,18.24],[24,43.04],[25,96.5],[26,208.52],[27,435.98],[28,908.81],[29,1870],[30,3810],[31,7730],[32,15610],[33,31430],[34,63150]];function mi(e,t,n){if(e<17)return 0;if(void 0!==t&&void 0!==n){const r=Yo[t?"ENCRYPTION_ON":"ENCRYPTION_OFF"][n].find(t=>t.batchDepth===e);if(r?.effectiveVolume)return Eo(r.effectiveVolume)}else{const t=pi.find(([t,n])=>{if(e===t)return n});if(t)return 1e3*t[1]*1e3*1e3}return Math.ceil(.9*di(e))}function gi(e,t){return ei.fromPLUR(2n**BigInt(e)*BigInt(t))}function yi(e,t,n){return BigInt(e.toSeconds())/BigInt(n)*BigInt(t)+1n}function bi(e,t,n){if(void 0!==t&&void 0!==n){const r=Yo[t?"ENCRYPTION_ON":"ENCRYPTION_OFF"][n].find(t=>e.toBytes()<=Eo(t.effectiveVolume));if(r?.effectiveVolume)return r.batchDepth}else for(const[t,n]of pi)if(e.toBytes()<=1e3*n*1e3*1e3)return t;return 35}function wi(e){return function(e,t,n,r){if(65!==e.length)throw Error("invalid signature length");if(32!==t.length)throw Error("invalid batch ID length");if(8!==n.length)throw Error("invalid timestamp length");if(8!==r.length)throw Error("invalid index length");return new vo(Wr.concatBytes(t,r,n,e))}(e.signature,e.batchId.toUint8Array(),e.timestamp,e.index)}function vi(e){return{name:function(e){if(!e)throw new Uo("missing content-disposition header");const t=e.match(/filename\*?=['"]?(?:UTF-\d['"]*)?([^;\r\n"']*)['"]?;?/i);if(t&&t.length>0)return t[1];throw new Uo("invalid content-disposition header")}(e["content-disposition"]),tagUid:function(e){if(!e)return;return parseInt(e,10)}(e["swarm-tag-uid"]),contentType:e["content-type"]||void 0}}function Ei(e,t){const n={};if(!function(e){if(!to.isObject(e))return!1;const t=e;return void 0!==t.issuer&&void 0!==t.index&&void 0!==t.signature&&void 0!==t.timestamp&&void 0!==t.batchId}(e)?e&&(e=new Po(e),n["swarm-postage-batch-id"]=e.toHex()):n["swarm-postage-stamp"]=wi(e).toHex(),!t)return n;const r=to.asObject(t);return r.size&&(n["content-length"]=String(r.size)),r.contentType&&(n["content-type"]=String(r.contentType)),r.redundancyLevel&&(n["swarm-redundancy-level"]=String(r.redundancyLevel)),to.isBoolean(r.act)&&(n["swarm-act"]=String(r.act)),to.isBoolean(r.pin)&&(n["swarm-pin"]=String(r.pin)),to.isBoolean(r.encrypt)&&(n["swarm-encrypt"]=r.encrypt.toString()),r.tag&&(n["swarm-tag"]=String(r.tag)),to.isBoolean(r.deferred)&&(n["swarm-deferred-upload"]=r.deferred.toString()),r.redundancyStrategy&&(n["swarm-redundancy-strategy"]=String(r.redundancyStrategy)),to.isBoolean(r.fallback)&&(n["swarm-redundancy-fallback-mode"]=r.fallback.toString()),r.timeoutMs&&(n["swarm-chunk-retrieval-timeout"]=String(r.timeoutMs)),r.indexDocument&&(n["swarm-index-document"]=String(r.indexDocument)),r.errorDocument&&(n["swarm-error-document"]=String(r.errorDocument)),r.actPublisher&&(n["swarm-act-publisher"]=new Ro(r.actPublisher).toCompressedHex()),r.actHistoryAddress&&(n["swarm-act-history-address"]=new $o(r.actHistoryAddress).toHex()),r.actTimestamp&&(n["swarm-act-timestamp"]=String(r.actTimestamp)),(r.actPublisher||r.actHistoryAddress||r.actTimestamp)&&(n["swarm-act"]="true"),r.gasPrice&&(n["gas-price"]=String(r.gasPrice)),r.gasLimit&&(n["gas-limit"]=String(r.gasLimit)),n}var xi,Bi,Ti,Ai,Oi,Ri,ki,Si,$i,zi,Di,Ii,Pi,Ci,Ni,_i,Vi,Ui,Fi,Mi,ji,Li,Gi,qi,Hi,Zi,Wi,Ki,Ji,Xi,Yi,Qi,ea,ta,na,ra,oa,ia,aa,sa,ca,ua,la,fa,ha,da,pa,ma,ga,ya,ba,wa,va,Ea,xa,Ba,Ta,Aa,Oa,Ra,ka,Sa,$a,za,Da,Ia,Pa,Ca,Na,_a,Va,Ua,Fa,Ma,ja,La,Ga,qa,Ha,Za={exports:{}};function Wa(){return Bi||(Bi=1,xi=function(e,t){return function(){return e.apply(t,arguments)}}),xi}function Ka(){if(Ai)return Ti;Ai=1;var e,t=Wa(),n=Object.prototype.toString,r=(e=Object.create(null),function(t){var r=n.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())});function o(e){return e=e.toLowerCase(),function(t){return r(t)===e}}function i(e){return Array.isArray(e)}function a(e){return void 0===e}var s=o("ArrayBuffer");function c(e){return"number"==typeof e}function u(e){return null!==e&&"object"==typeof e}function l(e){if("object"!==r(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var f=o("Date"),h=o("File"),d=o("Blob"),p=o("FileList");function m(e){return"[object Function]"===n.call(e)}var g=o("URLSearchParams");function y(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var n=0,r=e.length;n<r;n++)t.call(null,e[n],n,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var b,w=(b="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return b&&e instanceof b});var v,E=o("HTMLFormElement"),x=(v=Object.prototype.hasOwnProperty,function(e,t){return v.call(e,t)});return Ti={isArray:i,isArrayBuffer:s,isBuffer:function(e){return null!==e&&!a(e)&&null!==e.constructor&&!a(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||n.call(e)===t||m(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&s(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:c,isObject:u,isPlainObject:l,isEmptyObject:function(e){return e&&0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype},isUndefined:a,isDate:f,isFile:h,isBlob:d,isFunction:m,isStream:function(e){return u(e)&&m(e.pipe)},isURLSearchParams:g,isStandardBrowserEnv:function(){var e;return("undefined"==typeof navigator||"ReactNative"!==(e=navigator.product)&&"NativeScript"!==e&&"NS"!==e)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:y,merge:function e(){var t={};function n(n,r){l(t[r])&&l(n)?t[r]=e(t[r],n):l(n)?t[r]=e({},n):i(n)?t[r]=n.slice():t[r]=n}for(var r=0,o=arguments.length;r<o;r++)y(arguments[r],n);return t},extend:function(e,n,r){return y(n,function(n,o){e[o]=r&&"function"==typeof n?t(n,r):n}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var o,i,a,s={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&Object.getPrototypeOf(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:r,kindOfTest:o,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(i(e))return e;var t=e.length;if(!c(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},isTypedArray:w,isFileList:p,forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var o=n.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:E,hasOwnProperty:x},Ti}function Ja(){if(Ri)return Oi;Ri=1;var e=Ka();function t(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}e.inherits(t,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var n=t.prototype,r={};return["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(function(e){r[e]={value:e}}),Object.defineProperties(t,r),Object.defineProperty(n,"isAxiosError",{value:!0}),t.from=function(r,o,i,a,s,c){var u=Object.create(n);return e.toFlatObject(r,u,function(e){return e!==Error.prototype}),t.call(u,r.message,o,i,a,s),u.cause=r,u.name=r.name,c&&Object.assign(u,c),u},Oi=t}function Xa(){return zi?$i:(zi=1,$i=Si?ki:(Si=1,ki="object"==typeof self?self.FormData:window.FormData))}function Ya(){if(Ii)return Di;Ii=1;var e=Ka(),t=Ja(),n=Xa();function r(t){return e.isPlainObject(t)||e.isArray(t)}function o(t){return e.endsWith(t,"[]")?t.slice(0,-2):t}function i(e,t,n){return e?e.concat(t).map(function(e,t){return e=o(e),!n&&t?"["+e+"]":e}).join(n?".":""):t}var a=e.toFlatObject(e,{},null,function(e){return/^is[A-Z]/.test(e)});return Di=function(s,c,u){if(!e.isObject(s))throw new TypeError("target must be an object");c=c||new(n||FormData);var l,f=(u=e.toFlatObject(u,{metaTokens:!0,dots:!1,indexes:!1},!1,function(t,n){return!e.isUndefined(n[t])})).metaTokens,h=u.visitor||y,d=u.dots,p=u.indexes,m=(u.Blob||"undefined"!=typeof Blob&&Blob)&&((l=c)&&e.isFunction(l.append)&&"FormData"===l[Symbol.toStringTag]&&l[Symbol.iterator]);if(!e.isFunction(h))throw new TypeError("visitor must be a function");function g(n){if(null===n)return"";if(e.isDate(n))return n.toISOString();if(!m&&e.isBlob(n))throw new t("Blob is not supported. Use a Buffer instead.");return e.isArrayBuffer(n)||e.isTypedArray(n)?m&&"function"==typeof Blob?new Blob([n]):Buffer.from(n):n}function y(t,n,a){var s=t;if(t&&!a&&"object"==typeof t)if(e.endsWith(n,"{}"))n=f?n:n.slice(0,-2),t=JSON.stringify(t);else if(e.isArray(t)&&function(t){return e.isArray(t)&&!t.some(r)}(t)||e.isFileList(t)||e.endsWith(n,"[]")&&(s=e.toArray(t)))return n=o(n),s.forEach(function(t,r){!e.isUndefined(t)&&null!==t&&c.append(!0===p?i([n],r,d):null===p?n:n+"[]",g(t))}),!1;return!!r(t)||(c.append(i(a,n,d),g(t)),!1)}var b=[],w=Object.assign(a,{defaultVisitor:y,convertValue:g,isVisitable:r});if(!e.isObject(s))throw new TypeError("data must be an object");return function t(n,r){if(!e.isUndefined(n)){if(-1!==b.indexOf(n))throw Error("Circular reference detected in "+r.join("."));b.push(n),e.forEach(n,function(n,o){!0===(!(e.isUndefined(n)||null===n)&&h.call(c,n,e.isString(o)?o.trim():o,r,w))&&t(n,r?r.concat(o):[o])}),b.pop()}}(s),c}}function Qa(){if(Ci)return Pi;Ci=1;var e=Ya();function t(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'\(\)~]|%20|%00/g,function(e){return t[e]})}function n(t,n){this._pairs=[],t&&e(t,this,n)}var r=n.prototype;return r.append=function(e,t){this._pairs.push([e,t])},r.toString=function(e){var n=e?function(n){return e.call(this,n,t)}:t;return this._pairs.map(function(e){return n(e[0])+"="+n(e[1])},"").join("&")},Pi=n}function es(){if(_i)return Ni;_i=1;var e=Ka(),t=Qa();function n(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}return Ni=function(r,o,i){if(!o)return r;var a=r.indexOf("#");-1!==a&&(r=r.slice(0,a));var s,c=i&&i.encode||n,u=i&&i.serialize;return(s=u?u(o,i):e.isURLSearchParams(o)?o.toString():new t(o,i).toString(c))&&(r+=(-1===r.indexOf("?")?"?":"&")+s),r},Ni}function ts(){if(Mi)return Fi;Mi=1;var e=Ka();return Fi=function(t,n){e.forEach(t,function(e,r){r!==n&&r.toUpperCase()===n.toUpperCase()&&(t[n]=e,delete t[r])})}}function ns(){return Li?ji:(Li=1,ji={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1})}function rs(){if(qi)return Gi;qi=1;var e=Qa();return Gi="undefined"!=typeof URLSearchParams?URLSearchParams:e}function os(){return Xi?Ji:(Xi=1,Ji=Ki?Wi:(Ki=1,Wi={isBrowser:!0,classes:{URLSearchParams:rs(),FormData:Zi?Hi:(Zi=1,Hi=FormData),Blob:Blob},protocols:["http","https","file","blob","url","data"]}))}function is(){if(Qi)return Yi;Qi=1;var e=Ka(),t=Ya(),n=os();return Yi=function(r,o){return t(r,new n.classes.URLSearchParams,Object.assign({visitor:function(t,r,o,i){return n.isNode&&e.isBuffer(t)?(this.append(r,t.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},o))},Yi}function as(){if(ta)return ea;ta=1;var e=Ka();return ea=function(t){function n(t,r,o,i){var a=t[i++];if("__proto__"===a)return!0;var s=Number.isFinite(+a),c=i>=t.length;return a=!a&&e.isArray(o)?o.length:a,c?(e.hasOwnProperty(o,a)?o[a]=[o[a],r]:o[a]=r,!s):(o[a]&&e.isObject(o[a])||(o[a]=[]),n(t,r,o[a],i)&&e.isArray(o[a])&&(o[a]=function(e){var t,n,r={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)r[n=o[t]]=e[n];return r}(o[a])),!s)}if(e.isFormData(t)&&e.isFunction(t.entries)){var r={};return e.forEachEntry(t,function(t,o){n(function(t){return e.matchAll(/\w+|\[(\w*)]/g,t).map(function(e){return"[]"===e[0]?"":e[1]||e[0]})}(t),o,r,0)}),r}return null}}function ss(){if(ra)return na;ra=1;var e=Ja();return na=function(t,n,r){var o=r.config.validateStatus;r.status&&o&&!o(r.status)?n(new e("Request failed with status code "+r.status,[e.ERR_BAD_REQUEST,e.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):t(r)}}function cs(){if(ia)return oa;ia=1;var e=Ka();return oa=e.isStandardBrowserEnv()?{write:function(t,n,r,o,i,a){var s=[];s.push(t+"="+encodeURIComponent(n)),e.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),e.isString(o)&&s.push("path="+o),e.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}}function us(){return sa?aa:(sa=1,aa=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)})}function ls(){return ua?ca:(ua=1,ca=function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e})}function fs(){if(fa)return la;fa=1;var e=us(),t=ls();return la=function(n,r,o){var i=!e(r);return n&&(i||!1===o)?t(n,r):r}}function hs(){if(da)return ha;da=1;var e=Ka(),t=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];return ha=function(n){var r,o,i,a={};return n?(e.forEach(n.split("\n"),function(n){if(i=n.indexOf(":"),r=e.trim(n.slice(0,i)).toLowerCase(),o=e.trim(n.slice(i+1)),r){if(a[r]&&t.indexOf(r)>=0)return;a[r]="set-cookie"===r?(a[r]?a[r]:[]).concat([o]):a[r]?a[r]+", "+o:o}}),a):a}}function ds(){if(ma)return pa;ma=1;var e=Ka();return pa=e.isStandardBrowserEnv()?function(){var t,n=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function o(e){var t=e;return n&&(r.setAttribute("href",t),t=r.href),r.setAttribute("href",t),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return t=o(window.location.href),function(n){var r=e.isString(n)?o(n):n;return r.protocol===t.protocol&&r.host===t.host}}():function(){return!0}}function ps(){if(ya)return ga;ya=1;var e=Ja();function t(t,n,r){e.call(this,null==t?"canceled":t,e.ERR_CANCELED,n,r),this.name="CanceledError"}return Ka().inherits(t,e,{__CANCEL__:!0}),ga=t}function ms(){return wa?ba:(wa=1,ba=function(e){var t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""})}function gs(){if(Ea)return va;Ea=1;var e=Ka(),t=ss(),n=cs(),r=es(),o=fs(),i=hs(),a=ds(),s=ns(),c=Ja(),u=ps(),l=ms(),f=os();return va=function(h){return new Promise(function(d,p){var m,g=h.data,y=h.headers,b=h.responseType,w=h.withXSRFToken;function v(){h.cancelToken&&h.cancelToken.unsubscribe(m),h.signal&&h.signal.removeEventListener("abort",m)}e.isFormData(g)&&e.isStandardBrowserEnv()&&delete y["Content-Type"];var E=new XMLHttpRequest;if(h.auth){var x=h.auth.username||"",B=h.auth.password?unescape(encodeURIComponent(h.auth.password)):"";y.Authorization="Basic "+btoa(x+":"+B)}var T=o(h.baseURL,h.url,h.allowAbsoluteUrls);function A(){if(E){var e="getAllResponseHeaders"in E?i(E.getAllResponseHeaders()):null,n={data:b&&"text"!==b&&"json"!==b?E.response:E.responseText,status:E.status,statusText:E.statusText,headers:e,config:h,request:E};t(function(e){d(e),v()},function(e){p(e),v()},n),E=null}}if(E.open(h.method.toUpperCase(),r(T,h.params,h.paramsSerializer),!0),E.timeout=h.timeout,"onloadend"in E?E.onloadend=A:E.onreadystatechange=function(){E&&4===E.readyState&&(0!==E.status||E.responseURL&&0===E.responseURL.indexOf("file:"))&&setTimeout(A)},E.onabort=function(){E&&(p(new c("Request aborted",c.ECONNABORTED,h,E)),E=null)},E.onerror=function(){p(new c("Network Error",c.ERR_NETWORK,h,E)),E=null},E.ontimeout=function(){var e=h.timeout?"timeout of "+h.timeout+"ms exceeded":"timeout exceeded",t=h.transitional||s;h.timeoutErrorMessage&&(e=h.timeoutErrorMessage),p(new c(e,t.clarifyTimeoutError?c.ETIMEDOUT:c.ECONNABORTED,h,E)),E=null},e.isStandardBrowserEnv()&&(w&&e.isFunction(w)&&(w=w(h)),w||!1!==w&&a(T))){var O=h.xsrfHeaderName&&h.xsrfCookieName&&n.read(h.xsrfCookieName);O&&(y[h.xsrfHeaderName]=O)}"setRequestHeader"in E&&e.forEach(y,function(e,t){void 0===g&&"content-type"===t.toLowerCase()?delete y[t]:E.setRequestHeader(t,e)}),e.isUndefined(h.withCredentials)||(E.withCredentials=!!h.withCredentials),b&&"json"!==b&&(E.responseType=h.responseType),"function"==typeof h.onDownloadProgress&&E.addEventListener("progress",h.onDownloadProgress),"function"==typeof h.onUploadProgress&&E.upload&&E.upload.addEventListener("progress",h.onUploadProgress),(h.cancelToken||h.signal)&&(m=function(e){E&&(p(!e||e.type?new u(null,h,E):e),E.abort(),E=null)},h.cancelToken&&h.cancelToken.subscribe(m),h.signal&&(h.signal.aborted?m():h.signal.addEventListener("abort",m))),g||!1===g||0===g||""===g||(g=null);var R=l(T);R&&-1===f.protocols.indexOf(R)?p(new c("Unsupported protocol "+R+":",c.ERR_BAD_REQUEST,h)):E.send(g)})},va}function ys(){if(Ba)return xa;Ba=1;var e=Ka(),t=ts(),n=Ja(),r=ns(),o=Ya(),i=is(),a=os(),s=as(),c={"Content-Type":"application/x-www-form-urlencoded"};function u(t,n){!e.isUndefined(t)&&e.isUndefined(t["Content-Type"])&&(t["Content-Type"]=n)}var l,f={transitional:r,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(l=gs()),l),transformRequest:[function(n,r){t(r,"Accept"),t(r,"Content-Type");var a,c=r&&r["Content-Type"]||"",l=c.indexOf("application/json")>-1,f=e.isObject(n);if(f&&e.isHTMLForm(n)&&(n=new FormData(n)),e.isFormData(n))return l?JSON.stringify(s(n)):n;if(e.isArrayBuffer(n)||e.isBuffer(n)||e.isStream(n)||e.isFile(n)||e.isBlob(n))return n;if(e.isArrayBufferView(n))return n.buffer;if(e.isURLSearchParams(n))return u(r,"application/x-www-form-urlencoded;charset=utf-8"),n.toString();if(f){if(-1!==c.indexOf("application/x-www-form-urlencoded"))return i(n,this.formSerializer).toString();if((a=e.isFileList(n))||c.indexOf("multipart/form-data")>-1){var h=this.env&&this.env.FormData;return o(a?{"files[]":n}:n,h&&new h,this.formSerializer)}}return f||l?(u(r,"application/json"),function(t,n,r){if(e.isString(t))try{return(n||JSON.parse)(t),e.trim(t)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(t)}(n)):n}],transformResponse:[function(t){var r=this.transitional||f.transitional,o=r&&r.forcedJSONParsing,i="json"===this.responseType;if(t&&e.isString(t)&&(o&&!this.responseType||i)){var a=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(t)}catch(e){if(a){if("SyntaxError"===e.name)throw n.from(e,n.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:a.classes.FormData,Blob:a.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};return e.forEach(["delete","get","head"],function(e){f.headers[e]={}}),e.forEach(["post","put","patch"],function(t){f.headers[t]=e.merge(c)}),xa=f}function bs(){if(Aa)return Ta;Aa=1;var e=Ka(),t=ys();return Ta=function(n,r,o,i){var a=this||t;return e.forEach(i,function(e){n=e.call(a,n,r,o)}),n},Ta}function ws(){return Ra?Oa:(Ra=1,Oa=function(e){return!(!e||!e.__CANCEL__)})}function vs(){if(Sa)return ka;Sa=1;var e=Ka(),t=bs(),n=ws(),r=ys(),o=ps(),i=ts();function a(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new o}return ka=function(o){return a(o),o.headers=o.headers||{},o.data=t.call(o,o.data,o.headers,null,o.transformRequest),i(o.headers,"Accept"),i(o.headers,"Content-Type"),o.headers=e.merge(o.headers.common||{},o.headers[o.method]||{},o.headers),e.forEach(["delete","get","head","post","put","patch","common"],function(e){delete o.headers[e]}),(o.adapter||r.adapter)(o).then(function(e){return a(o),e.data=t.call(o,e.data,e.headers,e.status,o.transformResponse),e},function(e){return n(e)||(a(o),e&&e.response&&(e.response.data=t.call(o,e.response.data,e.response.headers,e.response.status,o.transformResponse))),Promise.reject(e)})},ka}function Es(){if(za)return $a;za=1;var e=Ka();return $a=function(t,n){n=n||{};var r={};function o(t,n){return e.isPlainObject(t)&&e.isPlainObject(n)?e.merge(t,n):e.isEmptyObject(n)?e.merge({},t):e.isPlainObject(n)?e.merge({},n):e.isArray(n)?n.slice():n}function i(r){return e.isUndefined(n[r])?e.isUndefined(t[r])?void 0:o(void 0,t[r]):o(t[r],n[r])}function a(t){if(!e.isUndefined(n[t]))return o(void 0,n[t])}function s(r){return e.isUndefined(n[r])?e.isUndefined(t[r])?void 0:o(void 0,t[r]):o(void 0,n[r])}function c(e){return e in n?o(t[e],n[e]):e in t?o(void 0,t[e]):void 0}var u={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:c};return e.forEach(Object.keys(t).concat(Object.keys(n)),function(t){var n=u[t]||i,o=n(t);e.isUndefined(o)&&n!==c||(r[t]=o)}),r},$a}function xs(){return Ia?Da:(Ia=1,Da={version:"0.30.2"})}function Bs(){if(Ca)return Pa;Ca=1;var e=xs().version,t=Ja(),n={};["object","boolean","number","function","string","symbol"].forEach(function(e,t){n[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});var r={};return n.transitional=function(n,o,i){function a(t,n){return"[Axios v"+e+"] Transitional option '"+t+"'"+n+(i?". "+i:"")}return function(e,i,s){if(!1===n)throw new t(a(i," has been removed"+(o?" in "+o:"")),t.ERR_DEPRECATED);return o&&!r[i]&&(r[i]=!0,console.warn(a(i," has been deprecated since v"+o+" and will be removed in the near future"))),!n||n(e,i,s)}},Pa={assertOptions:function(e,n,r){if("object"!=typeof e)throw new t("options must be an object",t.ERR_BAD_OPTION_VALUE);for(var o=Object.keys(e),i=o.length;i-- >0;){var a=o[i],s=n[a];if(s){var c=e[a],u=void 0===c||s(c,a,e);if(!0!==u)throw new t("option "+a+" must be "+u,t.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new t("Unknown option "+a,t.ERR_BAD_OPTION)}},validators:n}}function Ts(){if(_a)return Na;_a=1;var e=Ka(),t=es(),n=function(){if(Ui)return Vi;Ui=1;var e=Ka();function t(){this.handlers=[]}return t.prototype.use=function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1},t.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},t.prototype.clear=function(){this.handlers&&(this.handlers=[])},t.prototype.forEach=function(t){e.forEach(this.handlers,function(e){null!==e&&t(e)})},Vi=t}(),r=vs(),o=Es(),i=fs(),a=Bs(),s=a.validators;function c(e){this.defaults=e,this.interceptors={request:new n,response:new n}}return c.prototype.request=function(t,n){"string"==typeof t?(n=n||{}).url=t:n=t||{},(n=o(this.defaults,n)).method?n.method=n.method.toLowerCase():this.defaults.method?n.method=this.defaults.method.toLowerCase():n.method="get";var i=n.transitional;void 0!==i&&a.assertOptions(i,{silentJSONParsing:s.transitional(s.boolean),forcedJSONParsing:s.transitional(s.boolean),clarifyTimeoutError:s.transitional(s.boolean)},!1);var c=n.paramsSerializer;null!=c&&(e.isFunction(c)?n.paramsSerializer={serialize:c}:a.assertOptions(c,{encode:s.function,serialize:s.function},!0));var u=[],l=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(n)||(l=l&&e.synchronous,u.unshift(e.fulfilled,e.rejected))});var f,h=[];if(this.interceptors.response.forEach(function(e){h.push(e.fulfilled,e.rejected)}),!l){var d=[r,void 0];for(Array.prototype.unshift.apply(d,u),d=d.concat(h),f=Promise.resolve(n);d.length;)f=f.then(d.shift(),d.shift());return f}for(var p=n;u.length;){var m=u.shift(),g=u.shift();try{p=m(p)}catch(e){g(e);break}}try{f=r(p)}catch(e){return Promise.reject(e)}for(;h.length;)f=f.then(h.shift(),h.shift());return f},c.prototype.getUri=function(e){e=o(this.defaults,e);var n=i(e.baseURL,e.url,e.allowAbsoluteUrls);return t(n,e.params,e.paramsSerializer)},e.forEach(["delete","get","head","options"],function(e){c.prototype[e]=function(t,n){return this.request(o(n||{},{method:e,url:t,data:(n||{}).data}))}}),e.forEach(["post","put","patch"],function(e){function t(t){return function(n,r,i){return this.request(o(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}c.prototype[e]=t(),c.prototype[e+"Form"]=t(!0)}),Na=c}function As(){if(Ga)return Za.exports;Ga=1;var e=Ka(),t=Wa(),n=Ts(),r=Es(),o=ys(),i=as();var a=function o(i){var a=new n(i),s=t(n.prototype.request,a);return e.extend(s,n.prototype,a),e.extend(s,a),s.create=function(e){return o(r(i,e))},s}(o);return a.Axios=n,a.CanceledError=ps(),a.CancelToken=function(){if(Ua)return Va;Ua=1;var e=ps();function t(t){if("function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise(function(e){n=e});var r=this;this.promise.then(function(e){if(r._listeners){for(var t=r._listeners.length;t-- >0;)r._listeners[t](e);r._listeners=null}}),this.promise.then=function(e){var t,n=new Promise(function(e){r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},t(function(t,o,i){r.reason||(r.reason=new e(t,o,i),n(r.reason))})}return t.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},t.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},t.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},t.source=function(){var e;return{token:new t(function(t){e=t}),cancel:e}},Va=t}(),a.isCancel=ws(),a.VERSION=xs().version,a.toFormData=Ya(),a.AxiosError=Ja(),a.Cancel=a.CanceledError,a.all=function(e){return Promise.all(e)},a.spread=Ma?Fa:(Ma=1,Fa=function(e){return function(t){return e.apply(null,t)}}),a.isAxiosError=function(){if(La)return ja;La=1;var e=Ka();return ja=function(t){return e.isObject(t)&&!0===t.isAxiosError}}(),a.formToJSON=function(t){return i(e.isHTMLForm(t)?new FormData(t):t)},Za.exports=a,Za.exports.default=a,Za.exports}var Os=Lr(Ha?qa:(Ha=1,qa=As()));const Rs=go("bee-js:http"),{AxiosError:ks}=Os,Ss=Kr.minutes(1)/200,$s={headers:{accept:"application/json, text/plain, */*"},maxBodyLength:1/0,maxContentLength:1/0};async function zs(e,t){const n=Yr.deepMerge3($s,t,e);if(n.data&&"undefined"!=typeof Buffer&&Buffer.isBuffer(n.data)&&(n.data=n.data.buffer.slice(n.data.byteOffset,n.data.byteOffset+n.data.byteLength)),n.params){const e=Object.keys(n.params);for(const t of e){void 0===n.params[t]&&delete n.params[t]}}let r=0;for(;r<1e5;)try{Rs(`${n.method||"get"} ${Qr.joinUrl([n.baseURL,n.url])}`,{headers:{...n.headers},params:n.params}),Ds(e,n);return await Os(n)}catch(n){if(!(n instanceof ks))throw n;if("ECONNABORTED"!==n.code||!e.endlesslyRetry)throw new Mo(t.method||"get",t.url||"<unknown>",n.message,n.response?.data,n.response?.status,n.code);r++,await eo.sleepMillis(r<Ss?200:1e3)}throw Error("Max number of failed attempts reached")}function Ds(e,t){e.onRequest&&e.onRequest({method:t.method||"GET",url:Qr.joinUrl([t.baseURL,t.url]),headers:{...t.headers},params:t.params})}const Is="chunks";async function Ps(e,t,n){t=new $o(t);const r=await zs(e,{responseType:"arraybuffer",url:`${Is}/${t}`,headers:Ei(null,n)});return new Uint8Array(r.data)}const Cs=So.LENGTH,Ns=Cs+Co.LENGTH,_s=Ns+Do.LENGTH;function Vs(e,t){e=e instanceof vo?e.toUint8Array():e,t=new $o(t);const n=function(e){const t=Lo(e.slice(Ns)),n=Co.fromSlice(e,Cs),r=vo.fromSlice(e,0,So.LENGTH),o=Wr.concatBytes(r.toUint8Array(),t.toUint8Array());return n.recoverPublicKey(o).address()}(e),r=vo.fromSlice(e,0,So.LENGTH),o=new $o(Wr.keccak256(Wr.concatBytes(r.toUint8Array(),n.toUint8Array())));if(!Wr.equals(t.toUint8Array(),o.toUint8Array()))throw new Uo("SOC Data does not match given address!");return{data:e,identifier:r,signature:Co.fromSlice(e,Cs),span:Do.fromSlice(e,Ns),payload:vo.fromSlice(e,_s),address:o,owner:n}}function Us(e,t){return new $o(Wr.keccak256(Wr.concatBytes(e.toUint8Array(),t.toUint8Array())))}function Fs(e,t,n){const r=Us(t=new So(t),(n=new Oo(n)).publicKey().address()),o=n.sign(Wr.concatBytes(t.toUint8Array(),e.address.toUint8Array()));return{data:Wr.concatBytes(t.toUint8Array(),o.toUint8Array(),e.data),identifier:t,signature:o,span:Do.fromSlice(e.data,0),payload:vo.fromSlice(e.data,Do.LENGTH),address:r,owner:n.publicKey().address()}}async function Ms(e,t,n,r){const o=Wr.concatBytes(t.span.toUint8Array(),t.payload.toUint8Array());return async function(e,t,n,r,o,i,a){const s=await zs(e,{method:"post",url:`soc/${t}/${n}`,data:o,headers:{"content-type":"application/octet-stream",...Ei(i,a)},responseType:"json",params:{sig:r.toHex()}}),c=to.asObject(s.data,{name:"response.data"});return{reference:new $o(to.asHexString(c.reference)),tagUid:s.headers["swarm-tag"]?fi(s.headers["swarm-tag"]):void 0,historyAddress:s.headers["swarm-act-history-address"]?no.of(new $o(s.headers["swarm-act-history-address"])):no.empty()}}(e,t.owner,t.identifier,t.signature,o,n,r)}async function js(e,t,n,r,o,i){t=new Oo(t),r=new So(r);return Ms(e,Fs(Ho(o),r,t),n,i)}async function Ls(e,t,n){const r=Us(n=new So(n),t=new ko(t));return Vs(await Ps(e,r.toHex()),r)}const Gs="bytes";async function qs(e,t,n,r){const o=await zs(e,{url:Gs,method:"post",responseType:"json",data:t,headers:{"content-type":"application/octet-stream",...Ei(n,r)}}),i=to.asObject(o.data,{name:"response.data"});return{reference:new $o(to.asHexString(i.reference)),tagUid:o.headers["swarm-tag"]?fi(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?no.of(new $o(o.headers["swarm-act-history-address"])):no.empty()}}async function Hs(e,t,n){n&&(n=ii(n));const r=await zs(e,{responseType:"arraybuffer",url:`${Gs}/${t}`,headers:Ei(null,n)});return new vo(r.data)}const Zs="feeds";function Ws(e){const t=e["swarm-feed-index"],n=e["swarm-feed-index-next"];if(!t)throw new Uo("Response did not contain expected swarm-feed-index!");if(!n)throw new Uo("Response did not contain expected swarm-feed-index-next!");return{feedIndex:new Vo(t),feedIndexNext:new Vo(n)}}async function Ks(e,t,n,r){const o=await zs(e,{responseType:"arraybuffer",url:`${Zs}/${t}/${n}`,params:r});return{payload:new vo(o.data),...Ws(o.headers)}}class Js{constructor(e){this.raw=e}toString(){return to.isString(this.raw)&&this.raw.includes(".eth")?this.raw:new $o(this.raw).toHex()}}function Xs(e,t){return t="number"==typeof t?Vo.fromBigInt(BigInt(t)):t,new So(Wr.keccak256(Wr.concatBytes(e.toUint8Array(),t.toUint8Array())))}async function Ys(e,t,n){try{const r=await Ks(e,t,n);if(!r.feedIndexNext)throw Error("Feed index next is not defined. This should happen when fetching an exact index.");return r.feedIndexNext}catch(e){if(e instanceof Mo)return Vo.fromBigInt(0n);throw e}}async function Qs(e,t,n,r,o,i){const a=Xs(n,i?.index??await Ys(e,t.publicKey().address(),n));if(r.length>4096){const n=await qs(e,r,o,i);return async function(e,t,n,r,o,i){return t=new Oo(t),r=new So(r),Ms(e,Fs(Zo(o),r,t),n,i)}(e,t,o,a,await Ps(e,n.reference),i)}return js(e,t,o,a,to.isString(r)?vo.fromUtf8(r).toUint8Array():r,i)}function ec(e,t,n){const r=Xs(t,n);return new $o(Wr.keccak256(Wr.concatBytes(r.toUint8Array(),e.toUint8Array())))}async function tc(e,t,n,r,o=!1){const i=ec(t,n,r="number"==typeof r?Vo.fromBigInt(BigInt(r)):r),a=Vs(await Ps(e,i.toHex()),i);let s=no.empty();if(o){const e=vo.fromSlice(a.payload.toUint8Array(),0,8);s=no.of(Number(Wr.uint64ToNumber(e.toUint8Array(),"BE")))}return{timestamp:s,payload:new vo(a.payload.offset(o?8:0))}}async function nc(e,t,n,r){const o=ec(t,n,r="number"==typeof r?Vo.fromBigInt(BigInt(r)):r);return Zo((await Ps(e,o)).slice(So.LENGTH+Co.LENGTH))}function rc(e,t,n){const r=async r=>{if(void 0===r?.index)return Ks(e,n,t);const o=await tc(e,n,t,r.index,r.hasTimestamp??!0),i="number"==typeof r.index?Vo.fromBigInt(BigInt(r.index)):r.index;return{payload:o.payload,feedIndex:i,feedIndexNext:i.next()}};return{download:r,downloadPayload:async r=>{if(void 0===r?.index)return Ks(e,n,t);const o=await nc(e,n,t,r.index),i=o.span.toBigInt()<=4096n?o.payload:await Hs(e,new Js(o.address)),a="number"==typeof r.index?Vo.fromBigInt(BigInt(r.index)):r.index;return{payload:i,feedIndex:a,feedIndexNext:a.next()}},downloadReference:async o=>{let i=o?.index;void 0===i&&(i=(await async function(e,t,n){return Ws((await zs(e,{responseType:"arraybuffer",url:`${Zs}/${t}/${n}`,params:{"Swarm-Only-Root-Chunk":!0}})).headers)}(e,n,t)).feedIndex);const a=await r({...o,index:i});return{reference:new $o(a.payload.toUint8Array()),feedIndex:a.feedIndex,feedIndexNext:a.feedIndexNext??a.feedIndex.next()}},owner:n,topic:t}}function oc(e,t,n){const r=async(r,o,i)=>async function(e,t,n,r,o,i){r=new $o(r);const a=Xs(n,i?.index??await Ys(e,t.publicKey().address(),n)),s=i?.at??Date.now()/1e3,c=Wr.numberToUint64(BigInt(Math.floor(s)),"BE");return js(e,t,o,a,Wr.concatBytes(c,r.toUint8Array()),i)}(e,n,t,o,r,i);return{...rc(e,t,n.publicKey().address()),upload:r,uploadReference:r,uploadPayload:async(r,o,i)=>Qs(e,n,t,o,r,i)}}async function ic(e,t,n,r,o,i){const a=function(e,t,n){const r=n.toBigInt(),o=[];for(let n=0n;n<=r;n++)o.push(ec(e,t,Vo.fromBigInt(n)));return o}(t,n,r).map(async t=>async function(e,t,n,r){try{return await e.downloadChunk(t,n,r),!0}catch(e){const t=Yr.getDeep(e,"status");if(404===t||500===t)return!1;throw e}}(e,t,o,i));return(await Promise.all(a)).every(e=>e)}function ac(e){if(!function(e){return!!Array.isArray(e)&&e.every(e=>"object"==typeof e&&e.path&&void 0!==e.size)}(e))throw new Fo("invalid collection",e)}function sc(e){if(e.webkitRelativePath&&""!==e.webkitRelativePath)return e.webkitRelativePath.replace(/.*?\//i,"");if(e.name)return e.name;throw new TypeError("file is not valid File object")}class cc{constructor(){this.pieces=[],this.currentFileSize=0}get output(){return this.pieces.reduce((e,t)=>{const n=new Uint8Array(e.length+t.length);return n.set(e),n.set(t,e.length),n})}beginFile(e,t){if(e.length>100)throw new Error(`File name too long: ${e}`);const n=function(e,t){const n=new TextEncoder;function r(e,t,r){const i=n.encode(e);o.set(i.slice(0,r),t)}const o=new Uint8Array(512);o.fill(0,0,512),r(e.slice(0,100).padEnd(100,"\0"),0,100),r("0000777\0",100,8),r("0001750\0",108,8),r("0001750\0",116,8),r(t.toString(8).padStart(11,"0")+"\0",124,12);r(Math.floor((new Date).getTime()/1e3).toString(8).padStart(11,"0")+"\0",136,12),r(" ",148,8),r("0",156,1),r("ustar\0\0",257,8);let i=0;for(let e=0;e<512;e++)i+=o[e];return r(i.toString(8).padStart(6,"0")+"\0 ",148,8),o}(e,t);this.pieces.push(n),this.currentFileSize=0}async appendFile(e){this.pieces.push(e),this.currentFileSize+=e.length}async endFile(){const e=this.currentFileSize%512==0?0:512-this.currentFileSize%512;e>0&&this.pieces.push(new Uint8Array(e))}async end(){this.pieces.push(new Uint8Array(1024))}}async function uc(e,t,n,r){const o=new cc;await async function(e,t){for(const n of e){if(!n.file)throw new Error("Invalid collection item");t.beginFile(n.path,n.file.size),await t.appendFile(new Uint8Array(await ri(n.file))),await t.endFile()}}(t,o),await o.end();return await zs(e,{method:"post",url:"bzz",data:o.output,responseType:"json",headers:{"content-type":"application/x-tar","swarm-collection":"true",...Ei(n,r)}})}const lc="bzz";async function fc(e,t,n,r,o){const i=await zs(e,{method:"post",url:lc,data:t,headers:Ei(n,o),params:{name:r},responseType:"json"}),a=to.asObject(i.data,{name:"response.data"});return{reference:new $o(to.asHexString(a.reference)),tagUid:i.headers["swarm-tag"]?fi(i.headers["swarm-tag"]):void 0,historyAddress:i.headers["swarm-act-history-address"]?no.of(new $o(i.headers["swarm-act-history-address"])):no.empty()}}async function hc(e,t,n,r){ac(t);const o=await uc(e,t,n,r),i=to.asObject(o.data,{name:"response.data"});return{reference:new $o(to.asHexString(i.reference)),tagUid:o.headers["swarm-tag"]?fi(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?no.of(new $o(o.headers["swarm-act-history-address"])):no.empty()}}const dc=go("bee-js:manifest"),pc=new TextEncoder,mc=new TextDecoder,gc=new Uint8Array([47]),yc=Wr.hexToUint8Array("5768b3b6a7db56d21d1abff40d41cebfc83448fed8d7e9b06ec0d3b073f28f7b");class bc{constructor(e,t){this.prefix=e,this.node=t}static split(e,t){const n=Wr.commonPrefix(e.prefix,t.prefix);if(n.length===e.prefix.length){const r=t.prefix.slice(n.length);return t.node.path=t.prefix.slice(n.length),t.prefix=t.prefix.slice(n.length),t.node.parent=e.node,e.node.forks.set(r[0],t),e}if(n.length===t.prefix.length){const r=e.prefix.slice(n.length);return e.node.path=e.prefix.slice(n.length),e.prefix=e.prefix.slice(n.length),e.node.parent=t.node,t.node.forks.set(r[0],e),t}const r=new wc({path:n}),o=new bc(e.prefix.slice(n.length),e.node),i=new bc(t.prefix.slice(n.length),t.node);return e.node.path=e.prefix.slice(n.length),t.node.path=t.prefix.slice(n.length),e.prefix=e.prefix.slice(n.length),t.prefix=t.prefix.slice(n.length),r.forks.set(o.prefix[0],o),r.forks.set(i.prefix[0],i),o.node.parent=r,i.node.parent=r,new bc(n,r)}marshal(){if(!this.node.selfAddress)throw Error("Fork#marshal node.selfAddress is not set");const e=[];if(e.push(new Uint8Array([this.node.determineType()])),e.push(Wr.numberToUint8(this.prefix.length)),e.push(this.prefix),this.prefix.length<30&&e.push(new Uint8Array(30-this.prefix.length)),e.push(this.node.selfAddress),dc("marshalling fork",{prefixLength:this.prefix.length,prefix:mc.decode(this.prefix),address:Wr.uint8ArrayToHex(this.node.selfAddress)}),this.node.metadata){const t=Wr.padEndToMultiple(new Uint8Array([0,0,...pc.encode(JSON.stringify(this.node.metadata))]),32,10),n=Wr.numberToUint16(t.length-2,"BE");t.set(n,0),e.push(t)}return Wr.concatBytes(...e)}static unmarshal(e,t){const n=Wr.uint8ToNumber(e.read(1)),r=Wr.uint8ToNumber(e.read(1)),o=e.read(r);r<30&&e.read(30-r);const i=e.read(t);let a;if(dc("unmarshalling fork",{type:n,prefixLength:r,prefix:mc.decode(o),addressLength:t,address:Wr.uint8ArrayToHex(i)}),function(e,t){return(e&t)===t}(n,16)){const t=Wr.uint16ToNumber(e.read(2),"BE");a=JSON.parse(mc.decode(e.read(t)))}return new bc(o,new wc({selfAddress:i,metadata:a,path:o}))}}class wc{constructor(e){this.obfuscationKey=new Uint8Array(32),this.selfAddress=null,this.targetAddress=new Uint8Array(32),this.metadata=null,this.path=new Uint8Array(0),this.forks=new Map,this.parent=null,e?.targetAddress&&(this.targetAddress=e.targetAddress),e?.selfAddress&&(this.selfAddress=e.selfAddress),e?.metadata&&(this.metadata=e.metadata),e?.obfuscationKey&&(this.obfuscationKey=e.obfuscationKey),e?.path&&(this.path=e.path),e?.parent&&(this.parent=e.parent)}get fullPath(){return Wr.concatBytes(this.parent?.fullPath??new Uint8Array(0),this.path)}get fullPathString(){return mc.decode(this.fullPath)}getRootMetadata(){const e=this.find("/");return e&&e.metadata?no.of(e.metadata):no.empty()}getDocsMetadata(){const e=this.find("/");return e&&e.metadata?{indexDocument:e.metadata["website-index-document"]??null,errorDocument:e.metadata["website-error-document"]??null}:{indexDocument:null,errorDocument:null}}async resolveFeed(e,t){const n=this.find("/");if(!n||!n.metadata)return no.empty();const r=n.metadata["swarm-feed-owner"],o=n.metadata["swarm-feed-topic"];return r&&o?no.of(await e.fetchLatestFeedUpdate(o,r,t)):no.empty()}async marshal(){for(const e of this.forks.values())e.node.selfAddress||(e.node.selfAddress=(await e.node.calculateSelfAddress()).toUint8Array());const e=new Uint8Array(32);e.set(yc,0),e.set(Wr.equals(this.targetAddress,$c)&&Wr.equals(this.path,new Uint8Array([47]))?Wr.numberToUint8(0):Wr.numberToUint8(this.targetAddress.length),31);const t=new Uint8Array(32);for(const e of this.forks.keys())Wr.setBit(t,e,1,"LE");const n=[];for(let e=0;e<256;e++)Wr.getBit(t,e,"LE")&&n.push(this.forks.get(e).marshal());const r=Wr.xorCypher(Wr.concatBytes(e,Wr.equals(this.targetAddress,$c)&&Wr.equals(this.path,new Uint8Array([47]))?new Uint8Array(0):this.targetAddress,t,...n),this.obfuscationKey);return Wr.concatBytes(this.obfuscationKey,r)}static async unmarshal(e,t,n,r){t=new $o(t);const o=(await e.downloadData(t,n,r)).toUint8Array();return this.unmarshalFromData(o,t.toUint8Array())}static unmarshalFromData(e,t){const n=e.subarray(0,32),r=Wr.xorCypher(e.subarray(32),n),o=new ao(r),i=o.read(31);if(!Wr.equals(i,yc.slice(0,31)))throw new Error("MantarayNode#unmarshal invalid version hash");const a=Wr.uint8ToNumber(o.read(1)),s=a?o.read(a):$c,c=new wc({selfAddress:t,targetAddress:s,obfuscationKey:n}),u=o.read(32);for(let e=0;e<256;e++)if(Wr.getBit(u,e,"LE")){const n=bc.unmarshal(o,t.length);c.forks.set(e,n),n.node.parent=c}return c}addFork(e,t,n){this.selfAddress=null,e=e instanceof Uint8Array?e:pc.encode(e),dc("adding fork",{path:mc.decode(e),reference:new $o(t).represent()});let r=this;for(;e.length;){const o=e.slice(0,30),i=0===(e=e.slice(30)).length,[a,s]=r.findClosest(o),c=o.slice(s.length);if(s.length&&(r=a),!c.length)continue;const u=new bc(c,new wc({targetAddress:i?new $o(t).toUint8Array():void 0,metadata:i?n:void 0,path:c})),l=a.forks.get(c[0]);if(l){const e=bc.split(u,l);r.forks.set(c[0],e),e.node.parent=r,r.selfAddress=null,r=u.node}else r.forks.set(c[0],u),u.node.parent=r,r.selfAddress=null,r=u.node}}removeFork(e){if(this.selfAddress=null,0===(e=e instanceof Uint8Array?e:pc.encode(e)).length)throw Error("MantarayNode#removeFork [path] parameter cannot be empty");const t=this.find(e);if(!t)throw Error("MantarayNode#removeFork fork not found");const[n,r]=this.findClosest(e.slice(0,e.length-1));n.forks.delete(e.slice(r.length)[0]);for(const e of t.forks.values())n.addFork(Wr.concatBytes(t.path,e.prefix),e.node.targetAddress,e.node.metadata)}async calculateSelfAddress(){return this.selfAddress?new $o(this.selfAddress):new $o((await ro.root(await this.marshal())).hash())}async saveRecursively(e,t,n,r){for(const o of this.forks.values())await o.node.saveRecursively(e,t,n,r);const o=await e.uploadData(t,await this.marshal(),n,r);return this.selfAddress=o.reference.toUint8Array(),o}async loadRecursively(e,t,n){for(const r of this.forks.values()){if(!r.node.selfAddress)throw Error("MantarayNode#loadRecursively fork.node.selfAddress is not set");const o=await wc.unmarshal(e,r.node.selfAddress,t,n);r.node.targetAddress=o.targetAddress,r.node.forks=o.forks,r.node.path=r.prefix,r.node.parent=this,await r.node.loadRecursively(e,t,n)}}find(e){const[t,n]=this.findClosest(e);return n.length===e.length?t:null}findClosest(e,t=new Uint8Array){if(0===(e=e instanceof Uint8Array?e:pc.encode(e)).length)return[this,t];const n=this.forks.get(e[0]);return n&&Wr.commonPrefix(n.prefix,e).length===n.prefix.length?n.node.findClosest(e.slice(n.prefix.length),Wr.concatBytes(t,n.prefix)):[this,t]}collect(e=[]){for(const t of this.forks.values())Wr.equals(t.node.targetAddress,$c)||e.push(t.node),t.node.collect(e);return e}collectAndMap(){const e=this.collect(),t={};for(const n of e)t[n.fullPathString]=new $o(n.targetAddress).toHex();return t}determineType(){let e=0;return Wr.equals(this.targetAddress,$c)&&!Wr.equals(this.path,gc)||(e|=2),this.forks.size>0&&(e|=4),-1===Wr.indexOf(this.path,gc)||Wr.equals(this.path,gc)||(e|=8),this.metadata&&(e|=16),e}}class vc{constructor(e,t,n){this.encryptionKey=e,this.keyLen=e.length,this.padding=t,this.initCtr=n,this.index=0}key(){return this.encryptionKey}encrypt(e){const t=e.length;let n=t;if(this.padding>0){if(t>this.padding)throw new Error(`data length ${t} longer than padding ${this.padding}`);n=this.padding}const r=new Uint8Array(n);return this.transform(e,r),r}decrypt(e){const t=e.length;if(this.padding>0&&t!==this.padding)throw new Error(`data length ${t} different than padding ${this.padding}`);const n=new Uint8Array(t);return this.transform(e,n),n}reset(){this.index=0}transform(e,t){const n=e.length;for(let r=0;r<n;r+=this.keyLen){const o=Math.min(this.keyLen,n-r);this.transcrypt(this.index,e.subarray(r,r+o),t.subarray(r,r+o)),this.index++}t.length>n&&Ec(t.subarray(n),this.encryptionKey,n)}transcrypt(e,t,n){const r=new Uint8Array(4);new DataView(r.buffer).setUint32(0,e+this.initCtr,!0);const o=new Uint8Array(this.encryptionKey.length+4);o.set(this.encryptionKey),o.set(r,this.encryptionKey.length);const i=Wr.keccak256(o),a=Wr.keccak256(i),s=t.length;for(let e=0;e<s;e++)n[e]=t[e]^a[e];n.length>s&&Ec(n.subarray(s),this.encryptionKey,e*this.keyLen+s)}}function Ec(e,t,n){if(0===e.length)return;let r=0,o=n;for(;r<e.length;){const n=new Uint8Array(4);new DataView(n.buffer).setUint32(0,o,!0);const i=new Uint8Array(t.length+n.length);i.set(t),i.set(n,t.length);const a=Wr.keccak256(i),s=Math.min(a.length,e.length-r);e.set(a.subarray(0,s),r),r+=s,o++}}function xc(e=32){const t=new Uint8Array(e);var n;return 0!==(n=t).length&&crypto.getRandomValues(n),t}function Bc(e){return new vc(e,0,Math.floor(128))}function Tc(e){return new vc(e,4096,0)}class Ac{encryptChunk(e,t){const n=t||xc(32);return{key:n,encryptedSpan:Bc(n).encrypt(e.subarray(0,8)),encryptedData:Tc(n).encrypt(e.subarray(8))}}}function Oc(){return new Ac}const Rc=new TextEncoder;function kc(e,t){if(e instanceof Uint8Array||(e=Rc.encode(e)),e.length<1||e.length>Go)throw new RangeError(`payload size ${e.length} exceeds limits [1, 4096]`);const n=Do.fromBigInt(BigInt(e.length)),r=Wr.concatBytes(n.toUint8Array(),e),o=Oc(),{key:i,encryptedSpan:a,encryptedData:s}=o.encryptChunk(r,t),c=Wr.concatBytes(a,s),u=Lo(c),l=new $o(Wr.concatBytes(u.toUint8Array(),i));return{data:c,encryptionKey:i,span:n,payload:new vo(c.slice(Do.LENGTH)),address:u,reference:l}}function Sc(e,t){return function(e,t){const n=Bc(e).decrypt(t.subarray(0,8)),r=Tc(e).decrypt(t.subarray(8)),o=new Uint8Array(8+r.length);return o.set(n),o.set(r,8),o}(t,e)}new Po("0000000000000000000000000000000000000000000000000000000000000000"),new No("0000000000000000000000000000000000000000000000000000000000000000");const $c=new Uint8Array(32);class zc{constructor(e,t,n={}){this.totalChunks=0,this.processedChunks=0,this.bee=e,this.rootReference=new $o(t),this.options=n,this.isEncrypted=64===this.rootReference.length,this.isEncrypted&&(this.rootEncryptionKey=function(e){const t=e.toUint8Array();if(64!==t.length)throw new Error(`Invalid encrypted reference length: ${t.length}, expected 64`);return t.slice(32,64)}(this.rootReference),this.rootReference=function(e){const t=e.toUint8Array();if(64!==t.length)throw new Error(`Invalid encrypted reference length: ${t.length}, expected 64`);return new $o(t.slice(0,32))}(this.rootReference))}async getSize(){return void 0!==this.fileSize||await this.fetchAndParseRoot(),this.fileSize}async fetchAndParseRoot(){if(void 0!==this.fileSize)return;const e=await this.downloadChunk(this.rootReference,this.rootEncryptionKey),t=Do.fromSlice(e,0);this.fileSize=t.toBigInt();const n=Math.ceil(Number(this.fileSize)/Go);this.totalChunks=n,this.updateProgress()}async downloadChunk(e,t){try{const n=await this.bee.downloadChunk(e,this.options.downloadOptions,this.options.requestOptions);return t?Sc(n,t):n}catch(t){if(t&&"object"==typeof t&&"status"in t){const n=t.status;if(404===n||500===n)throw new Error(`Failed to download chunk ${e.toHex()}: Chunk not found. Make sure the data exists on the Bee node.`)}throw t}}updateProgress(){this.options.onDownloadProgress&&this.options.onDownloadProgress({total:this.totalChunks,processed:this.processedChunks})}async readChunkRecursively(e,t){const n=await this.downloadChunk(e,t),r=Do.fromSlice(n,0).toBigInt(),o=n.slice(Do.LENGTH);if(r<=BigInt(Go))return this.processedChunks++,this.updateProgress(),o.slice(0,Number(r));const i=this.isEncrypted?64:32,a=[];for(let e=0;e<o.length;e+=i){const t=o.slice(e,e+i);if(t.length<i)break;const n=t.slice(0,32);Wr.equals(n,$c)||(this.isEncrypted?a.push({ref:new $o(n),key:t.slice(32,64)}):a.push({ref:new $o(n)}))}const s=this.options.concurrency??64,c=new Array(a.length);for(let e=0;e<a.length;e+=s){const t=a.slice(e,Math.min(e+s,a.length)).map(async({ref:t,key:n},r)=>{const o=e+r,i=await this.readChunkRecursively(t,n);c[o]=i});await Promise.all(t)}return Wr.concatBytes(...c)}async createReadableStream(){await this.fetchAndParseRoot();const e=this;let t=!1;return new ReadableStream({async start(n){try{t=!0;const r=await e.readChunkRecursively(e.rootReference,e.rootEncryptionKey);n.enqueue(r),n.close()}catch(e){n.error(e)}},cancel(){}})}async readAll(){return await this.fetchAndParseRoot(),this.readChunkRecursively(this.rootReference,this.rootEncryptionKey)}}const Dc="balances",Ic="consumed";const Pc="chequebook";async function Cc(e,t){const n=await zs(e,{url:Pc+`/cashout/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{peer:to.asString(r.peer,{name:"peer"}),uncashedAmount:ei.fromPLUR(oi(r.uncashedAmount,{name:"uncashedAmount"})),transactionHash:to.asNullableString(r.transactionHash),lastCashedCheque:to.asNullable(e=>Nc(e),r.lastCashedCheque),result:to.asNullable(e=>function(e){const t=to.asObject(e,{name:"cashout result"});return{recipient:to.asString(t.recipient,{name:"recipient"}),lastPayout:ei.fromPLUR(oi(t.lastPayout,{name:"lastPayout"})),bounced:to.asBoolean(t.bounced,{name:"bounced"})}}(e),r.result)}}function Nc(e){const t=to.asObject(e,{name:"cheque"});return{beneficiary:new ko(to.asString(t.beneficiary,{name:"beneficiary"})),chequebook:new ko(to.asString(t.chequebook,{name:"chequebook"})),payout:ei.fromPLUR(oi(t.payout,{name:"payout"}))}}function _c(e,t){const n=to.asObject(e,{name:t});return n.disconnectedPeers||(n.disconnectedPeers=[]),n.connectedPeers||(n.connectedPeers=[]),{population:to.asNumber(n.population,{name:"population"}),connected:to.asNumber(n.connected,{name:"connected"}),connectedPeers:to.asArray(n.connectedPeers,{name:"connectedPeers"}).map(e=>({address:to.asString(to.asObject(e,{name:"connectedPeer"}).address,{name:"address"})})),disconnectedPeers:to.asArray(n.disconnectedPeers,{name:"disconnectedPeers"}).map(e=>({address:to.asString(to.asObject(e,{name:"disconnectedPeer"}).address,{name:"address"})}))}}const Vc="settlements";const Uc="stake";class Fc{constructor(e){if(this.bytes=Math.ceil(e),e<0)throw Error("Size must be at least 0")}static fromBytes(e){return new Fc(e)}static fromKilobytes(e){return new Fc(1e3*e)}static fromMegabytes(e){return new Fc(1e3*e*1e3)}static fromGigabytes(e){return new Fc(1e3*e*1e3*1e3)}static parseFromString(e){return Fc.fromBytes(Xr.makeStorage(e,1e3))}toBytes(){return this.bytes}toGigabytes(){return this.bytes/1e3/1e3/1e3}toFormattedString(){return Xr.convertBytes(this.bytes,1e3)}represent(){return this.toFormattedString()}}function Mc(e){return Number.isInteger(e)?e<1?1:e>315569260?315569260:e:1}const jc="stamps";async function Lc(e){const t=await zs(e,{method:"get",url:"batches",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return to.asArray(n.batches,{name:"batches"}).map(e=>to.asObject(e,{name:"batch"})).map(e=>({batchID:new Po(to.asString(e.batchID,{name:"batchID"})),batchTTL:to.asNumber(e.batchTTL,{name:"batchTTL"}),bucketDepth:to.asNumber(e.bucketDepth,{name:"bucketDepth"}),depth:to.asNumber(e.depth,{name:"depth"}),immutable:to.asBoolean(e.immutable,{name:"immutable"}),owner:new ko(to.asString(e.owner,{name:"owner"})),start:to.asNumber(e.start,{name:"start"}),value:oi(e.value,{name:"value"})}))}async function Gc(e){const t=await zs(e,{method:"get",url:`${jc}`,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return to.asArray(n.stamps,{name:"stamps"}).map(e=>to.asObject(e,{name:"stamp"})).map(e=>{const t=to.asNumber(e.utilization,{name:"utilization"}),n=to.asNumber(e.depth,{name:"depth"}),r=to.asNumber(e.bucketDepth,{name:"bucketDepth"}),o=hi(t,n,r),i=Mc(to.asNumber(e.batchTTL,{name:"batchTTL"})),a=Qo.fromSeconds(i),s=mi(n);return{batchID:new Po(to.asString(e.batchID,{name:"batchID"})),utilization:t,usable:to.asBoolean(e.usable,{name:"usable"}),label:to.asEmptiableString(e.label,{name:"label"}),depth:n,amount:oi(e.amount,{name:"amount"}),bucketDepth:r,blockNumber:to.asNumber(e.blockNumber,{name:"blockNumber"}),immutableFlag:to.asBoolean(e.immutableFlag,{name:"immutableFlag"}),usage:o,usageText:`${Math.round(100*o)}%`,size:Fc.fromBytes(s),remainingSize:Fc.fromBytes(Math.ceil(s*(1-o))),theoreticalSize:Fc.fromBytes(di(n)),duration:a,calculateSize(e,t){const n=mi(this.depth,e,t);return Fc.fromBytes(n)},calculateRemainingSize(e,t){const n=mi(this.depth,e,t);return Fc.fromBytes(Math.ceil(n*(1-this.usage)))}}})}const qc="wallet";var Hc,Zc,Wc,Kc;function Jc(){if(Zc)return Hc;Zc=1;const e="object"==typeof process&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error("SEMVER",...e):()=>{};return Hc=e}function Xc(){if(Kc)return Wc;Kc=1;const e=Number.MAX_SAFE_INTEGER||9007199254740991;return Wc={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:e,RELEASE_TYPES:["major","premajor","minor","preminor","patch","prepatch","prerelease"],SEMVER_SPEC_VERSION:"2.0.0",FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}}var Yc,Qc,eu,tu,nu,ru,ou,iu,au,su={exports:{}};function cu(){return Yc||(Yc=1,function(e,t){const{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:o}=Xc(),i=Jc(),a=(t=e.exports={}).re=[],s=t.safeRe=[],c=t.src=[],u=t.safeSrc=[],l=t.t={};let f=0;const h="[a-zA-Z0-9-]",d=[["\\s",1],["\\d",o],[h,r]],p=(e,t,n)=>{const r=(e=>{for(const[t,n]of d)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e})(t),o=f++;i(e,o,t),l[e]=o,c[o]=t,u[o]=r,a[o]=new RegExp(t,n?"g":void 0),s[o]=new RegExp(r,n?"g":void 0)};p("NUMERICIDENTIFIER","0|[1-9]\\d*"),p("NUMERICIDENTIFIERLOOSE","\\d+"),p("NONNUMERICIDENTIFIER",`\\d*[a-zA-Z-]${h}*`),p("MAINVERSION",`(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})\\.(${c[l.NUMERICIDENTIFIER]})`),p("MAINVERSIONLOOSE",`(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})\\.(${c[l.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASEIDENTIFIER",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIER]})`),p("PRERELEASEIDENTIFIERLOOSE",`(?:${c[l.NONNUMERICIDENTIFIER]}|${c[l.NUMERICIDENTIFIERLOOSE]})`),p("PRERELEASE",`(?:-(${c[l.PRERELEASEIDENTIFIER]}(?:\\.${c[l.PRERELEASEIDENTIFIER]})*))`),p("PRERELEASELOOSE",`(?:-?(${c[l.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[l.PRERELEASEIDENTIFIERLOOSE]})*))`),p("BUILDIDENTIFIER",`${h}+`),p("BUILD",`(?:\\+(${c[l.BUILDIDENTIFIER]}(?:\\.${c[l.BUILDIDENTIFIER]})*))`),p("FULLPLAIN",`v?${c[l.MAINVERSION]}${c[l.PRERELEASE]}?${c[l.BUILD]}?`),p("FULL",`^${c[l.FULLPLAIN]}$`),p("LOOSEPLAIN",`[v=\\s]*${c[l.MAINVERSIONLOOSE]}${c[l.PRERELEASELOOSE]}?${c[l.BUILD]}?`),p("LOOSE",`^${c[l.LOOSEPLAIN]}$`),p("GTLT","((?:<|>)?=?)"),p("XRANGEIDENTIFIERLOOSE",`${c[l.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),p("XRANGEIDENTIFIER",`${c[l.NUMERICIDENTIFIER]}|x|X|\\*`),p("XRANGEPLAIN",`[v=\\s]*(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:\\.(${c[l.XRANGEIDENTIFIER]})(?:${c[l.PRERELEASE]})?${c[l.BUILD]}?)?)?`),p("XRANGEPLAINLOOSE",`[v=\\s]*(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[l.XRANGEIDENTIFIERLOOSE]})(?:${c[l.PRERELEASELOOSE]})?${c[l.BUILD]}?)?)?`),p("XRANGE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAIN]}$`),p("XRANGELOOSE",`^${c[l.GTLT]}\\s*${c[l.XRANGEPLAINLOOSE]}$`),p("COERCEPLAIN",`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),p("COERCE",`${c[l.COERCEPLAIN]}(?:$|[^\\d])`),p("COERCEFULL",c[l.COERCEPLAIN]+`(?:${c[l.PRERELEASE]})?`+`(?:${c[l.BUILD]})?(?:$|[^\\d])`),p("COERCERTL",c[l.COERCE],!0),p("COERCERTLFULL",c[l.COERCEFULL],!0),p("LONETILDE","(?:~>?)"),p("TILDETRIM",`(\\s*)${c[l.LONETILDE]}\\s+`,!0),t.tildeTrimReplace="$1~",p("TILDE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAIN]}$`),p("TILDELOOSE",`^${c[l.LONETILDE]}${c[l.XRANGEPLAINLOOSE]}$`),p("LONECARET","(?:\\^)"),p("CARETTRIM",`(\\s*)${c[l.LONECARET]}\\s+`,!0),t.caretTrimReplace="$1^",p("CARET",`^${c[l.LONECARET]}${c[l.XRANGEPLAIN]}$`),p("CARETLOOSE",`^${c[l.LONECARET]}${c[l.XRANGEPLAINLOOSE]}$`),p("COMPARATORLOOSE",`^${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]})$|^$`),p("COMPARATOR",`^${c[l.GTLT]}\\s*(${c[l.FULLPLAIN]})$|^$`),p("COMPARATORTRIM",`(\\s*)${c[l.GTLT]}\\s*(${c[l.LOOSEPLAIN]}|${c[l.XRANGEPLAIN]})`,!0),t.comparatorTrimReplace="$1$2$3",p("HYPHENRANGE",`^\\s*(${c[l.XRANGEPLAIN]})\\s+-\\s+(${c[l.XRANGEPLAIN]})\\s*$`),p("HYPHENRANGELOOSE",`^\\s*(${c[l.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[l.XRANGEPLAINLOOSE]})\\s*$`),p("STAR","(<|>)?=?\\s*\\*"),p("GTE0","^\\s*>=\\s*0\\.0\\.0\\s*$"),p("GTE0PRE","^\\s*>=\\s*0\\.0\\.0-0\\s*$")}(su,su.exports)),su.exports}function uu(){if(ou)return ru;ou=1;const e=Jc(),{MAX_LENGTH:t,MAX_SAFE_INTEGER:n}=Xc(),{safeRe:r,t:o}=cu(),i=function(){if(eu)return Qc;eu=1;const e=Object.freeze({loose:!0}),t=Object.freeze({});return Qc=n=>n?"object"!=typeof n?e:n:t}(),{compareIdentifiers:a}=function(){if(nu)return tu;nu=1;const e=/^[0-9]+$/,t=(t,n)=>{if("number"==typeof t&&"number"==typeof n)return t===n?0:t<n?-1:1;const r=e.test(t),o=e.test(n);return r&&o&&(t=+t,n=+n),t===n?0:r&&!o?-1:o&&!r?1:t<n?-1:1};return tu={compareIdentifiers:t,rcompareIdentifiers:(e,n)=>t(n,e)}}();class s{constructor(a,c){if(c=i(c),a instanceof s){if(a.loose===!!c.loose&&a.includePrerelease===!!c.includePrerelease)return a;a=a.version}else if("string"!=typeof a)throw new TypeError(`Invalid version. Must be a string. Got type "${typeof a}".`);if(a.length>t)throw new TypeError(`version is longer than ${t} characters`);e("SemVer",a,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;const u=a.trim().match(c.loose?r[o.LOOSE]:r[o.FULL]);if(!u)throw new TypeError(`Invalid Version: ${a}`);if(this.raw=a,this.major=+u[1],this.minor=+u[2],this.patch=+u[3],this.major>n||this.major<0)throw new TypeError("Invalid major version");if(this.minor>n||this.minor<0)throw new TypeError("Invalid minor version");if(this.patch>n||this.patch<0)throw new TypeError("Invalid patch version");u[4]?this.prerelease=u[4].split(".").map(e=>{if(/^[0-9]+$/.test(e)){const t=+e;if(t>=0&&t<n)return t}return e}):this.prerelease=[],this.build=u[5]?u[5].split("."):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(".")}`),this.version}toString(){return this.version}compare(t){if(e("SemVer.compare",this.version,this.options,t),!(t instanceof s)){if("string"==typeof t&&t===this.version)return 0;t=new s(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(e){return e instanceof s||(e=new s(e,this.options)),this.major<e.major?-1:this.major>e.major?1:this.minor<e.minor?-1:this.minor>e.minor?1:this.patch<e.patch?-1:this.patch>e.patch?1:0}comparePre(t){if(t instanceof s||(t=new s(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let n=0;do{const r=this.prerelease[n],o=t.prerelease[n];if(e("prerelease compare",n,r,o),void 0===r&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===r)return-1;if(r!==o)return a(r,o)}while(++n)}compareBuild(t){t instanceof s||(t=new s(t,this.options));let n=0;do{const r=this.build[n],o=t.build[n];if(e("build compare",n,r,o),void 0===r&&void 0===o)return 0;if(void 0===o)return 1;if(void 0===r)return-1;if(r!==o)return a(r,o)}while(++n)}inc(e,t,n){if(e.startsWith("pre")){if(!t&&!1===n)throw new Error("invalid increment argument: identifier is empty");if(t){const e=`-${t}`.match(this.options.loose?r[o.PRERELEASELOOSE]:r[o.PRERELEASE]);if(!e||e[1]!==t)throw new Error(`invalid identifier: ${t}`)}}switch(e){case"premajor":this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc("pre",t,n);break;case"preminor":this.prerelease.length=0,this.patch=0,this.minor++,this.inc("pre",t,n);break;case"prepatch":this.prerelease.length=0,this.inc("patch",t,n),this.inc("pre",t,n);break;case"prerelease":0===this.prerelease.length&&this.inc("patch",t,n),this.inc("pre",t,n);break;case"release":if(0===this.prerelease.length)throw new Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case"major":0===this.minor&&0===this.patch&&0!==this.prerelease.length||this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case"minor":0===this.patch&&0!==this.prerelease.length||this.minor++,this.patch=0,this.prerelease=[];break;case"patch":0===this.prerelease.length&&this.patch++,this.prerelease=[];break;case"pre":{const e=Number(n)?1:0;if(0===this.prerelease.length)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)"number"==typeof this.prerelease[r]&&(this.prerelease[r]++,r=-2);if(-1===r){if(t===this.prerelease.join(".")&&!1===n)throw new Error("invalid increment argument: identifier already exists");this.prerelease.push(e)}}if(t){let r=[t,e];!1===n&&(r=[t]),0===a(this.prerelease[0],t)?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw new Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(".")}`),this}}return ru=s}var lu=Lr(function(){if(au)return iu;au=1;const e=uu();return iu=(t,n)=>new e(t,n).major}());const fu="2.6.0-d0aa8b93";fu.split("-")[0];const hu="7.3.0";async function du(e){const t=await zs(e,{method:"get",url:"health",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{apiVersion:to.asString(n.apiVersion,{name:"apiVersion"}),version:to.asString(n.version,{name:"version"}),status:to.asString(n.status,{name:"status"})}}const pu="transactions";function mu(e){const t=to.asObject(e,{name:"transaction"});return{transactionHash:new zo(to.asString(t.transactionHash,{name:"transactionHash"})),to:to.asString(t.to,{name:"to"}),nonce:to.asNumber(t.nonce,{name:"nonce"}),gasPrice:oi(t.gasPrice,{name:"gasPrice"}),gasLimit:to.asNumber(t.gasLimit,{name:"gasLimit"}),data:to.asString(t.data,{name:"data"}),created:to.asString(t.created,{name:"created"}),description:to.asString(t.description,{name:"description"}),value:oi(t.value,{name:"value"})}}const gu="grantee";var yu,bu;var wu=Lr(function(){if(bu)return yu;bu=1;var e=null;return"undefined"!=typeof WebSocket?e=WebSocket:"undefined"!=typeof MozWebSocket?e=MozWebSocket:void 0!==jr?e=jr.WebSocket||jr.MozWebSocket:"undefined"!=typeof window?e=window.WebSocket||window.MozWebSocket:"undefined"!=typeof self&&(e=self.WebSocket||self.MozWebSocket),yu=e}());const vu="gsoc";const Eu="pins";const xu="pss";async function Bu(e,t,n,r,o,i){await zs(e,{method:"post",url:`${xu}/send/${t}/${n}`,data:r,responseType:"json",params:{recipient:i},headers:Ei(o)})}async function Tu(e){await zs(e,{url:""})}const Au="stewardship";const Ou="tags";function Ru(e){return function e(t){return t<=1?t:t+e(Math.ceil(t/128))}(Math.ceil(e/4096))}const ku={aac:"audio/aac",abw:"application/x-abiword",ai:"application/postscript",arc:"application/octet-stream",avi:"video/x-msvideo",azw:"application/vnd.amazon.ebook",bin:"application/octet-stream",bz:"application/x-bzip",bz2:"application/x-bzip2",csh:"application/x-csh",css:"text/css",csv:"text/csv",doc:"application/msword",dll:"application/octet-stream",dmg:"application/x-apple-diskimage",eot:"application/vnd.ms-fontobject",epub:"application/epub+zip",gif:"image/gif",htm:"text/html",html:"text/html",ico:"image/x-icon",ics:"text/calendar",jar:"application/java-archive",jpeg:"image/jpeg",jpg:"image/jpeg",js:"application/javascript",json:"application/json",mid:"audio/midi",midi:"audio/midi",mp2:"audio/mpeg",mp3:"audio/mpeg",mp4:"video/mp4",mpa:"video/mpeg",mpe:"video/mpeg",mpeg:"video/mpeg",mpkg:"application/vnd.apple.installer+xml",odp:"application/vnd.oasis.opendocument.presentation",ods:"application/vnd.oasis.opendocument.spreadsheet",odt:"application/vnd.oasis.opendocument.text",oga:"audio/ogg",ogv:"video/ogg",ogx:"application/ogg",otf:"font/otf",png:"image/png",pdf:"application/pdf",ppt:"application/vnd.ms-powerpoint",rar:"application/x-rar-compressed",rtf:"application/rtf",sh:"application/x-sh",svg:"image/svg+xml",swf:"application/x-shockwave-flash",tar:"application/x-tar",tif:"image/tiff",tiff:"image/tiff",ts:"application/typescript",ttf:"font/ttf",txt:"text/plain",vsd:"application/vnd.visio",wav:"audio/x-wav",weba:"audio/webm",webm:"video/webm",webp:"image/webp",woff:"font/woff",woff2:"font/woff2",xhtml:"application/xhtml+xml",xls:"application/vnd.ms-excel",xlsx:"application/vnd.ms-excel",xml:"application/xml",xul:"application/vnd.mozilla.xul+xml",zip:"application/zip","3gp":"video/3gpp","3gp2":"video/3gpp2","7z":"application/x-7z-compressed"};function Su(e){return["text/html","text/css"].includes(e)?`${e}; charset=utf-8`:e}async function $u(e){if("string"==typeof e)return(new TextEncoder).encode(e);if(e instanceof ArrayBuffer)return new Uint8Array(e);if(e instanceof Blob)return new Uint8Array(await new Response(e).arrayBuffer());throw new TypeError("unknown websocket data type")}function zu(e){if(!function(e){try{if("string"!=typeof e)return!1;const t=new URL(e);return"http:"===t.protocol||"https:"===t.protocol}catch(e){return!1}}(e))throw new Fo("URL is not valid!",e)}class Du{constructor(e,t){zu(e),this.url=function(e){return e.endsWith("/")?e.slice(0,-1):e}(e),t?.signer&&(this.signer=new Oo(t.signer)),this.network=t?.network??"gnosis",this.requestOptions={baseURL:this.url,timeout:t?.timeout??0,headers:t?.headers,onRequest:t?.onRequest,httpAgent:t?.httpAgent,httpsAgent:t?.httpsAgent}}async uploadData(e,t,n,r){return e=new Po(e),li(t),n&&(n=function(e,t="UploadOptions"){const n=ai(e,t),r=to.asObject(e,{name:t});return{...n,redundancyLevel:to.asOptional(e=>to.asInteger(e,{name:"redundancyLevel",min:0}),r.redundancyLevel)}}(n)),qs(this.getRequestOptionsForCall(r),t,e,n)}async probeData(e,t){return e=new $o(e),async function(e,t){t=new $o(t);const n=await zs(e,{url:`${Gs}/${t}`,method:"head",responseType:"json"});return{contentLength:parseInt(n.headers["content-length"])}}(this.getRequestOptionsForCall(t),e)}async downloadData(e,t,n){return t&&(t=ii(t)),Hs(this.getRequestOptionsForCall(n),new Js(e),t)}async downloadReadableData(e,t,n){return t&&(t=ii(t)),async function(e,t,n){return n&&(n=ii(n)),(await zs(e,{responseType:"stream",url:`${Gs}/${t}`,headers:Ei(null,n)})).data}(this.getRequestOptionsForCall(n),new Js(e),t)}async downloadDataStreaming(e,t,n){return t&&(t={...ii(t),...t}),async function(e,t,n,r){const o=new $o(t);return new zc(e,o,{onDownloadProgress:n?.onDownloadProgress,downloadOptions:n,requestOptions:r,concurrency:n?.concurrency}).createReadableStream()}(this,e,t,this.getRequestOptionsForCall(n))}async uploadChunk(e,t,n,r){if(t=t instanceof Uint8Array?t:t.data,n&&(n=ai(n)),t.length<Do.LENGTH)throw new Fo(`Chunk has to have size of at least ${Do.LENGTH}.`,t);if(t.length>4096+Do.LENGTH)throw new Fo(`Chunk has to have size of at most ${4096+Do.LENGTH}.`,t);return async function(e,t,n,r){const o=await zs(e,{method:"post",url:`${Is}`,data:t,headers:{"content-type":"application/octet-stream",...Ei(n,r)},responseType:"json"}),i=to.asObject(o.data,{name:"response.data"});return{reference:new $o(to.asString(i.reference,{name:"reference"})),tagUid:o.headers["swarm-tag"]?fi(o.headers["swarm-tag"]):void 0,historyAddress:o.headers["swarm-act-history-address"]?no.of(new $o(o.headers["swarm-act-history-address"])):no.empty()}}(this.getRequestOptionsForCall(r),t,e,n)}async downloadChunk(e,t,n){return e=new $o(e),t&&(t=ii(t)),Ps(this.getRequestOptionsForCall(n),e,t)}async createGrantees(e,t,n){return e=new Po(e),t=t.map(e=>new Ro(e)),async function(e,t,n){const r=await zs(e,{method:"post",url:gu,data:{grantees:n.map(e=>e.toCompressedHex())},headers:Ei(t),responseType:"json"}),o=to.asObject(r.data,{name:"response.data"});return{status:r.status,statusText:r.statusText,ref:new $o(to.asString(o.ref,{name:"ref"})),historyref:new $o(to.asString(o.historyref,{name:"historyref"}))}}(this.getRequestOptionsForCall(n),e,t)}async getGrantees(e,t){return async function(e,t){const n=await zs(t,{method:"get",url:`${gu}/${e}`,responseType:"json"}),r=to.asArray(n.data,{name:"response.data"}).map(e=>new Ro(to.asString(e,{name:"grantee"})));return{status:n.status,statusText:n.statusText,grantees:r}}(e=new $o(e),this.getRequestOptionsForCall(t))}async patchGrantees(e,t,n,r,o){return async function(e,t,n,r,o){const i=await zs(o,{method:"patch",url:`${gu}/${t}`,data:{add:r.add?.map(e=>e.toCompressedHex()),revoke:r.revoke?.map(e=>e.toCompressedHex())},headers:{...Ei(e),"swarm-act-history-address":n.toHex()},responseType:"json"}),a=to.asObject(i.data,{name:"response.data"});return{status:i.status,statusText:i.statusText,ref:new $o(to.asString(a.ref,{name:"ref"})),historyref:new $o(to.asString(a.historyref,{name:"historyref"}))}}(e=new Po(e),t=new $o(t),n=new $o(n),{add:r.add?.map(e=>new Ro(e))??[],revoke:r.revoke?.map(e=>new Ro(e))??[]},this.getRequestOptionsForCall(o))}async uploadFile(e,t,n,r,o){if(e=new Po(e),function(e){if(!("string"==typeof e||e instanceof Uint8Array||ni(e)))throw new TypeError("Data must be either string, Readable, Uint8Array or File!")}(t),r&&(r=function(e){const t=ai(e,"FileUploadOptions"),n=to.asObject(e,{name:"FileUploadOptions"});return{...t,size:to.asOptional(e=>to.asInteger(e,{name:"size",min:0}),n.size),contentType:to.asOptional(e=>to.asString(e,{name:"contentType"}),n.contentType),redundancyLevel:to.asOptional(e=>to.asInteger(e,{name:"redundancyLevel",min:0}),n.redundancyLevel)}}(r)),n&&"string"!=typeof n)throw new TypeError("name has to be string or undefined!");if(ni(t)){const i=await ri(t),a=n??t.name,s={contentType:t.type,...r};return fc(this.getRequestOptionsForCall(o),i,e,a,s)}return fc(this.getRequestOptionsForCall(o),t,e,n,r)}async downloadFile(e,t="",n,r){return n&&(n=ii(n)),async function(e,t,n="",r){const o=await zs(e,{method:"GET",responseType:"arraybuffer",url:`${lc}/${t}/${n}`,headers:Ei(null,r)});return{...vi(o.headers),data:new vo(o.data)}}(this.getRequestOptionsForCall(r),new Js(e),t,n)}async downloadReadableFile(e,t="",n,r){return e=new $o(e),n&&(n=ii(n)),async function(e,t,n="",r){t=new $o(t);const o=await zs(e,{method:"GET",responseType:"stream",url:`${lc}/${t}/${n}`,headers:Ei(null,r)});return{...vi(o.headers),data:o.data}}(this.getRequestOptionsForCall(r),e,t,n)}async downloadFileStreaming(e,t="",n,r){return n&&(n={...ii(n),...n}),async function(e,t,n="",r,o){const i=new $o(t),a=await wc.unmarshal(e,i,r,o);await a.loadRecursively(e,r,o);const s=n?a.find(n):a.find("/");if(!s)throw new Error(`Path not found in manifest: ${n}`);if(!s.targetAddress)throw new Error(`No file at path: ${n}`);const c=s.metadata||{},u=new $o(s.targetAddress),l=new zc(e,u,{onDownloadProgress:r?.onDownloadProgress,downloadOptions:r,requestOptions:o,concurrency:r?.concurrency}),f=await l.createReadableStream(),h={name:c.Filename||n.split("/").pop()||"",data:f};return c["Content-Type"]&&(h.contentType=c["Content-Type"]),h}(this,e,t,n,this.getRequestOptionsForCall(r))}async uploadFiles(e,t,n,r){e=new Po(e),n&&(n=si(n));const o=function(e){return Array.from(e).map(e=>({path:sc(e),size:e.size,file:e}))}(t);return hc(this.getRequestOptionsForCall(r),o,e,n)}async hashDirectory(e){return async function(){throw new Error("Hashing directories is not supported in browsers!")}()}async streamDirectory(e,t,n,r,o){return e=new Po(e),async function(){throw new Error("Streaming directories is not supported in browsers!")}(0,0,0,0,0,this.getRequestOptionsForCall(o))}async streamFiles(e,t,n,r,o){return async function(e,t,n,r,o,i){const a=new io(64,64);let s=0,c=0;for(const e of t)s+=Ru(e.size);async function u(t){await a.enqueue(async()=>{await e.uploadChunk(n,t.build(),o,i),r?.({total:s,processed:++c})})}n=new Po(n);const l=new wc;for(const e of t){const t=await new Promise((t,n)=>{const r=new ro(u);let o=0;const i=new FileReader;i.onerror=()=>{n(i.error)};const a=async()=>{if(o>=e.size){const e=await r.finalize();return void t(e)}const n=e.slice(o,o+4096);i.readAsArrayBuffer(n)};i.onload=async e=>{if(!e.target)return void n("No event target");const t=e.target.result;t&&(await r.append(new Uint8Array(t)),o+=4096),a()},a()});await a.drain();const{filename:n,extension:r}=Qr.parseFilename(e.name);l.addFork(sc(e),t.hash(),{"Content-Type":Su(ku[r.toLowerCase()]||"application/octet-stream"),Filename:n}),"index.html"===e.name&&l.addFork("/",$c,{"website-index-document":"index.html"})}return l.saveRecursively(e,n,o,i)}(this,t,e=new Po(e),n,r,this.getRequestOptionsForCall(o))}async uploadCollection(e,t,n,r){return e=new Po(e),ac(t),n&&(n=si(n)),hc(this.getRequestOptionsForCall(r),t,e,n)}async uploadFilesFromDirectory(e,t,n,r){e=new Po(e),n&&(n=si(n));const o=await async function(){throw new Error("Creating Collection from File System is not supported in browsers!")}();return hc(this.getRequestOptionsForCall(r),o,e,n)}async createTag(e){return async function(e){const t=await zs(e,{method:"post",url:Ou,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{address:to.asEmptiableString(n.address,{name:"address"}),seen:to.asNumber(n.seen,{name:"seen"}),sent:to.asNumber(n.sent,{name:"sent"}),split:to.asNumber(n.split,{name:"split"}),startedAt:to.asString(n.startedAt,{name:"startedAt"}),stored:to.asNumber(n.stored,{name:"stored"}),synced:to.asNumber(n.synced,{name:"synced"}),uid:to.asNumber(n.uid,{name:"uid"})}}(this.getRequestOptionsForCall(e))}async getAllTags(e,t){return e&&(e=function(e){const t=to.asObject(e,{name:"AllTagsOptions"});return{limit:to.asOptional(e=>to.asInteger(e,{name:"limit",min:1,max:1e3}),t.limit),offset:to.asOptional(e=>to.asInteger(e,{name:"offset",min:0}),t.offset)}}(e)),async function(e,t,n){const r=await zs(e,{url:Ou,params:{offset:t,limit:n},responseType:"json"}),o=to.asObject(r.data,{name:"response.data"});return to.asArray(o.tags,{name:"tags"}).map(e=>to.asObject(e,{name:"tag"})).map(e=>({address:to.asEmptiableString(e.address,{name:"address"}),seen:to.asNumber(e.seen,{name:"seen"}),sent:to.asNumber(e.sent,{name:"sent"}),split:to.asNumber(e.split,{name:"split"}),startedAt:to.asString(e.startedAt,{name:"startedAt"}),stored:to.asNumber(e.stored,{name:"stored"}),synced:to.asNumber(e.synced,{name:"synced"}),uid:to.asNumber(e.uid,{name:"uid"})}))}(this.getRequestOptionsForCall(t),e?.offset,e?.limit)}async retrieveTag(e,t){return e=fi(e),async function(e,t){const n=await zs(e,{url:`${Ou}/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{address:to.asEmptiableString(r.address,{name:"address"}),seen:to.asNumber(r.seen,{name:"seen"}),sent:to.asNumber(r.sent,{name:"sent"}),split:to.asNumber(r.split,{name:"split"}),startedAt:to.asString(r.startedAt,{name:"startedAt"}),stored:to.asNumber(r.stored,{name:"stored"}),synced:to.asNumber(r.synced,{name:"synced"}),uid:to.asNumber(r.uid,{name:"uid"})}}(this.getRequestOptionsForCall(t),e)}async deleteTag(e,t){return e=fi(e),async function(e,t){await zs(e,{method:"delete",url:`${Ou}/${t}`})}(this.getRequestOptionsForCall(t),e)}async updateTag(e,t,n){return t=new $o(t),e=fi(e),async function(e,t,n){await zs(e,{method:"patch",url:`${Ou}/${t}`,data:{reference:n}})}(this.getRequestOptionsForCall(n),e,t)}async pin(e,t){return e=new $o(e),async function(e,t){await zs(e,{method:"post",responseType:"json",url:`${Eu}/${t}`})}(this.getRequestOptionsForCall(t),e)}async unpin(e,t){return e=new $o(e),async function(e,t){await zs(e,{method:"delete",responseType:"json",url:`${Eu}/${t}`})}(this.getRequestOptionsForCall(t),e)}async getAllPins(e){return async function(e){const t=await zs(e,{method:"get",responseType:"json",url:`${Eu}`}),n=to.asObject(t.data,{name:"response.data"});return null===n.references?[]:to.asArray(n.references,{name:"references"}).map(e=>to.asString(e,{name:"reference"})).map(e=>new $o(e))}(this.getRequestOptionsForCall(e))}async getPin(e,t){return e=new $o(e),async function(e,t){const n=await zs(e,{method:"get",responseType:"json",url:`${Eu}/${t}`}),r=to.asObject(n.data,{name:"response.data"});return{reference:new $o(to.asString(r.reference,{name:"reference"}))}}(this.getRequestOptionsForCall(t),e)}async reuploadPinnedData(e,t,n){e=new Po(e),t=new $o(t),await async function(e,t,n){await zs(e,{method:"put",url:`${Au}/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}})}(this.getRequestOptionsForCall(n),e,t)}async isReferenceRetrievable(e,t){return e=new $o(e),async function(e,t){t=new $o(t);const n=await zs(e,{method:"get",responseType:"json",url:`${Au}/${t}`}),r=to.asObject(n.data,{name:"response.data"});return to.asBoolean(r.isRetrievable,{name:"isRetrievable"})}(this.getRequestOptionsForCall(t),e)}async isFeedRetrievable(e,t,n,r,o){if(e=new ko(e),t=new No(t),r&&(r=ii(r)),!n)try{return await this.makeFeedReader(t,e,o).download(),!0}catch(e){const t=Yr.getDeep(e,"status");if(404===t||500===t)return!1;throw e}return ic(this,e,t,n,r,this.getRequestOptionsForCall(o))}async pssSend(e,t,n,r,o,i){return e=new Po(e),li(r),o?(o=new Ro(o),Bu(this.getRequestOptionsForCall(i),t,n,r,e,o)):Bu(this.getRequestOptionsForCall(i),t,n,r,e)}pssSubscribe(e,t){t=function(e){const t=to.asObject(e,{name:"PssMessageHandler"});return{onMessage:to.asFunction(t.onMessage,{name:"onMessage"}),onError:to.asFunction(t.onError,{name:"onError"}),onClose:to.asFunction(t.onClose,{name:"onClose"})}}(t);const n=function(e,t,n){const r=e.replace(/^http/i,"ws");return"browser"===eo.whereAmI()?new wu(`${r}/${xu}/subscribe/${t.toHex()}`):new wu(`${r}/${xu}/subscribe/${t.toHex()}`,{headers:n})}(this.url,e,this.requestOptions.headers);let r=!1;const o={topic:e,cancel:()=>{r||(r=!0,n.terminate?n.terminate():n.close())}};return n.onmessage=async e=>{const n=await $u(e.data);n.length&&t.onMessage(new vo(n),o)},n.onerror=e=>{r||t.onError(new Uo(e.message),o)},n.onclose=()=>{t.onClose(o)},o}async pssReceive(e,t=0){if("number"!=typeof t)throw new TypeError("timeoutMsc parameter has to be a number!");return new Promise((n,r)=>{let o;const i=this.pssSubscribe(e,{onError:e=>{clearTimeout(o),i.cancel(),r(e.message)},onMessage:e=>{clearTimeout(o),i.cancel(),n(e)},onClose:()=>{clearTimeout(o),i.cancel()}});t>0&&(o=setTimeout(()=>{i.cancel(),r(new Uo("pssReceive timeout"))},t))})}gsocMine(e,t,n=12){e=new Io(e),t=new So(t);for(let r=0n;r<0xffffn;r++){const o=new Oo(Wr.numberToUint256(2867n+r,"BE")),i=Us(t,o.publicKey().address());if(256-Wr.proximity(i.toUint8Array(),e.toUint8Array())<=256-n)return o}throw Error("Could not mine a valid signer")}async gsocSend(e,t,n,r,o,i){e=new Po(e),t=new Oo(t),n=new So(n);const a=Fs(Ho(r),n,t);return async function(e,t,n,r){return Ms(e,t,n,r)}(this.getRequestOptionsForCall(i),a,e,o)}gsocSubscribe(e,t,n){e=new ko(e),t=new So(t),n=function(e){const t=to.asObject(e,{name:"GsocMessageHandler"});return{onMessage:to.asFunction(t.onMessage,{name:"onMessage"}),onError:to.asFunction(t.onError,{name:"onError"}),onClose:to.asFunction(t.onClose,{name:"onClose"})}}(n);const r=Us(t,e),o=function(e,t,n){const r=e.replace(/^http/i,"ws");return"browser"===eo.whereAmI()?new wu(`${r}/${vu}/subscribe/${t.toHex()}`):new wu(`${r}/${vu}/subscribe/${t.toHex()}`,{headers:n})}(this.url,r,this.requestOptions.headers);let i=!1;const a={address:e,cancel:()=>{i||(i=!0,o.terminate?o.terminate():o.close())}};return o.onmessage=async e=>{const t=await $u(e.data);t.length&&n.onMessage(new vo(t),a)},o.onerror=e=>{i||n.onError(new Uo(e.message),a)},o.onclose=()=>{n.onClose(a)},a}async createFeedManifest(e,t,n,r,o){return e=new Po(e),t=new No(t),n=new ko(n),r&&(r=ai(r)),async function(e,t,n,r,o){const i=await zs(e,{method:"post",responseType:"json",url:`${Zs}/${t}/${n}`,headers:Ei(r,o)}),a=to.asObject(i.data,{name:"response.data"});return new $o(to.asHexString(a.reference))}(this.getRequestOptionsForCall(o),n,t,e,r)}makeFeedReader(e,t,n){return e=new No(e),t=new ko(t),rc(this.getRequestOptionsForCall(n),e,t)}makeFeedWriter(e,t,n){if(e=new No(e),!(t=t?new Oo(t):this.signer))throw Error("No signer provided");return oc(this.getRequestOptionsForCall(n),e,t)}async fetchLatestFeedUpdate(e,t,n){return e=new No(e),t=new ko(t),Ks(this.getRequestOptionsForCall(n),t,e)}makeSOCReader(e,t){return{owner:e=new ko(e),download:Ls.bind(null,this.getRequestOptionsForCall(t),e)}}makeSOCWriter(e,t){if(!(e=e?new Oo(e):this.signer))throw Error("No signer provided");return{...this.makeSOCReader(e.publicKey().address(),t),upload:js.bind(null,this.getRequestOptionsForCall(t),e)}}async createEnvelope(e,t,n){return e=new Po(e),t=new $o(t),async function(e,t,n){const r=await zs(e,{method:"post",responseType:"json",url:`envelope/${n}`,headers:{"swarm-postage-batch-id":t.toHex()}}),o=to.asObject(r.data,{name:"response.data"});return{issuer:Wr.hexToUint8Array(to.asHexString(o.issuer,{name:"issuer",byteLength:20})),index:Wr.hexToUint8Array(to.asHexString(o.index,{name:"index",byteLength:8})),timestamp:Wr.hexToUint8Array(to.asHexString(o.timestamp,{name:"timestamp",byteLength:8})),signature:Wr.hexToUint8Array(to.asHexString(o.signature,{name:"signature",byteLength:65})),batchId:t}}(this.getRequestOptionsForCall(n),e,t)}async rchash(e,t,n,r){return async function(e,t,n,r){const o=await zs(e,{responseType:"json",url:`rchash/${t}/${n}/${r}`}),i=to.asObject(o.data,{name:"response.data"});return to.asNumber(i.durationSeconds,{name:"durationSeconds"})}(this.getRequestOptionsForCall(r),e,t,n)}async checkConnection(e){return Tu(this.getRequestOptionsForCall(e))}async isConnected(e){try{await Tu(this.getRequestOptionsForCall(e))}catch(e){return!1}return!0}async isGateway(e){return async function(e){try{const t=await zs(e,{url:"/gateway"}),n=to.asObject(t.data);return to.asBoolean(n.gateway)}catch(e){return!1}}(this.getRequestOptionsForCall(e))}async getNodeAddresses(e){return async function(e){const t=await zs(e,{url:"addresses",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{overlay:new Io(to.asString(n.overlay,{name:"overlay"})),underlay:to.asArray(n.underlay,{name:"underlay"}).map(e=>to.asString(e,{name:"underlay"})),ethereum:new ko(to.asString(n.ethereum,{name:"ethereum"})),publicKey:new Ro(to.asString(n.publicKey,{name:"publicKey"})),pssPublicKey:new Ro(to.asString(n.pssPublicKey,{name:"pssPublicKey"}))}}(this.getRequestOptionsForCall(e))}async getBlocklist(e){return async function(e){return(await zs(e,{url:"blocklist",responseType:"json"})).data.peers}(this.getRequestOptionsForCall(e))}async getPeers(e){return async function(e){const t=await zs(e,{url:"peers",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return to.asArray(n.peers,{name:"peers"}).map(e=>({address:to.asString(to.asObject(e,{name:"peer"}).address,{name:"address"}),fullNode:to.asBoolean(to.asObject(e,{name:"peer"}).fullNode,{name:"fullNode"})}))}(this.getRequestOptionsForCall(e))}async removePeer(e,t){return e=new Io(e),async function(e,t){return(await zs(e,{url:`peers/${t}`,responseType:"json",method:"DELETE"})).data}(this.getRequestOptionsForCall(t),e)}async getTopology(e){return async function(e){const t=await zs(e,{url:"topology",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"}),r=to.asObject(n.bins,{name:"bins"});return{baseAddr:to.asString(n.baseAddr,{name:"baseAddr"}),population:to.asNumber(n.population,{name:"population"}),connected:to.asNumber(n.connected,{name:"connected"}),timestamp:to.asString(n.timestamp,{name:"timestamp"}),nnLowWatermark:to.asNumber(n.nnLowWatermark,{name:"nnLowWatermark"}),depth:to.asNumber(n.depth,{name:"depth"}),reachability:to.asString(n.reachability,{name:"reachability"}),networkAvailability:to.asString(n.networkAvailability,{name:"networkAvailability"}),bins:{bin_0:_c(r.bin_0,"bin_0"),bin_1:_c(r.bin_1,"bin_1"),bin_2:_c(r.bin_2,"bin_2"),bin_3:_c(r.bin_3,"bin_3"),bin_4:_c(r.bin_4,"bin_4"),bin_5:_c(r.bin_5,"bin_5"),bin_6:_c(r.bin_6,"bin_6"),bin_7:_c(r.bin_7,"bin_7"),bin_8:_c(r.bin_8,"bin_8"),bin_9:_c(r.bin_9,"bin_9"),bin_10:_c(r.bin_10,"bin_10"),bin_11:_c(r.bin_11,"bin_11"),bin_12:_c(r.bin_12,"bin_12"),bin_13:_c(r.bin_13,"bin_13"),bin_14:_c(r.bin_14,"bin_14"),bin_15:_c(r.bin_15,"bin_15"),bin_16:_c(r.bin_16,"bin_16"),bin_17:_c(r.bin_17,"bin_17"),bin_18:_c(r.bin_18,"bin_18"),bin_19:_c(r.bin_19,"bin_19"),bin_20:_c(r.bin_20,"bin_20"),bin_21:_c(r.bin_21,"bin_21"),bin_22:_c(r.bin_22,"bin_22"),bin_23:_c(r.bin_23,"bin_23"),bin_24:_c(r.bin_24,"bin_24"),bin_25:_c(r.bin_25,"bin_25"),bin_26:_c(r.bin_26,"bin_26"),bin_27:_c(r.bin_27,"bin_27"),bin_28:_c(r.bin_28,"bin_28"),bin_29:_c(r.bin_29,"bin_29"),bin_30:_c(r.bin_30,"bin_30"),bin_31:_c(r.bin_31,"bin_31")}}}(this.getRequestOptionsForCall(e))}async pingPeer(e,t){return e=new Io(e),async function(e,t){return(await zs(e,{url:`pingpong/${t}`,responseType:"json",method:"POST"})).data}(this.getRequestOptionsForCall(t),e)}async getAllBalances(e){return async function(e){const t=await zs(e,{url:Dc,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{balances:to.asArray(n.balances,{name:"balances"}).map(e=>to.asObject(e,{name:"balance"})).map(e=>({peer:to.asString(e.peer,{name:"peer"}),balance:ei.fromPLUR(oi(e.balance,{name:"balance"}))}))}}(this.getRequestOptionsForCall(e))}async getPeerBalance(e,t){return e=new Io(e),async function(e,t){const n=await zs(e,{url:`${Dc}/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{peer:to.asString(r.peer,{name:"peer"}),balance:ei.fromPLUR(oi(r.balance,{name:"balance"}))}}(this.getRequestOptionsForCall(t),e)}async getPastDueConsumptionBalances(e){return async function(e){const t=await zs(e,{url:Ic,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{balances:to.asArray(n.balances,{name:"balances"}).map(e=>to.asObject(e,{name:"balance"})).map(e=>({peer:to.asString(e.peer,{name:"peer"}),balance:ei.fromPLUR(oi(e.balance,{name:"balance"}))}))}}(this.getRequestOptionsForCall(e))}async getPastDueConsumptionPeerBalance(e,t){return e=new Io(e),async function(e,t){const n=await zs(e,{url:`${Ic}/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{peer:to.asString(r.peer,{name:"peer"}),balance:ei.fromPLUR(oi(r.balance,{name:"balance"}))}}(this.getRequestOptionsForCall(t),e)}async getChequebookAddress(e){return async function(e){const t=await zs(e,{url:Pc+"/address",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{chequebookAddress:new ko(to.asString(n.chequebookAddress,{name:"chequebookAddress"}))}}(this.getRequestOptionsForCall(e))}async getChequebookBalance(e){return async function(e){const t=await zs(e,{url:Pc+"/balance",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{availableBalance:ei.fromPLUR(oi(n.availableBalance,{name:"availableBalance"})),totalBalance:ei.fromPLUR(oi(n.totalBalance,{name:"totalBalance"}))}}(this.getRequestOptionsForCall(e))}async getLastCheques(e){return async function(e){const t=await zs(e,{url:Pc+"/cheque",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{lastcheques:to.asArray(n.lastcheques,{name:"lastcheques"}).map(e=>to.asObject(e,{name:"lastcheque"})).map(e=>({peer:to.asString(e.peer,{name:"peer"}),lastreceived:to.asNullable(e=>Nc(e),e.lastreceived),lastsent:to.asNullable(e=>Nc(e),e.lastsent)}))}}(this.getRequestOptionsForCall(e))}async getLastChequesForPeer(e,t){return e=new Io(e),async function(e,t){const n=await zs(e,{url:Pc+`/cheque/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{peer:to.asString(r.peer,{name:"peer"}),lastreceived:to.asNullable(e=>Nc(e),r.lastreceived),lastsent:to.asNullable(e=>Nc(e),r.lastsent)}}(this.getRequestOptionsForCall(t),e)}async getLastCashoutAction(e,t){return e=new Io(e),Cc(this.getRequestOptionsForCall(t),e)}async cashoutLastCheque(e,t,n){return e=new Io(e),t&&ui(t),async function(e,t,n){const r=await zs(e,{method:"post",url:Pc+`/cashout/${t}`,responseType:"json",headers:Ei(null,n)}),o=to.asObject(r.data,{name:"response.data"});return new zo(to.asString(o.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(n),e,t)}async depositTokens(e,t,n){return this.depositBZZToChequebook(e,t,n)}async depositBZZToChequebook(e,t,n){const r=e instanceof ei?e.toPLURString():oi(e,{min:1n,name:"amount"});let o;return t&&(o=oi(e,{min:0n,name:"gasPrice"})),async function(e,t,n){const r={};n&&(r["gas-price"]=n.toString());const o=await zs(e,{method:"post",url:Pc+"/deposit",responseType:"json",params:{amount:t.toString(10)},headers:r}),i=to.asObject(o.data,{name:"response.data"});return new zo(to.asString(i.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(n),r,o)}async withdrawTokens(e,t,n){return this.withdrawBZZFromChequebook(e,t,n)}async withdrawBZZFromChequebook(e,t,n){const r=e instanceof ei?e.toPLURString():oi(e,{min:1n,name:"amount"});let o;return t&&(o=oi(e,{min:0n,name:"gasPrice"})),async function(e,t,n){const r={};n&&(r["gas-price"]=n.toString());const o=await zs(e,{method:"post",url:Pc+"/withdraw",responseType:"json",params:{amount:t.toString(10)},headers:r}),i=to.asObject(o.data,{name:"response.data"});return new zo(to.asString(i.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(n),r,o)}async withdrawBZZToExternalWallet(e,t,n){return e=e instanceof ei?e:ei.fromPLUR(e),t=new ko(t),async function(e,t,n){const r=await zs(e,{method:"post",url:`${qc}/withdraw/bzz`,responseType:"json",params:{amount:t.toPLURString(),address:n.toHex()}}),o=to.asObject(r.data,{name:"response.data"});return new zo(to.asString(o.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(n),e,t)}async withdrawDAIToExternalWallet(e,t,n){return e=e instanceof ti?e:ti.fromWei(e),t=new ko(t),async function(e,t,n){const r=await zs(e,{method:"post",url:`${qc}/withdraw/nativetoken`,responseType:"json",params:{amount:t.toWeiString(),address:n.toHex()}}),o=to.asObject(r.data,{name:"response.data"});return new zo(to.asString(o.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(n),e,t)}async getSettlements(e,t){return e=new Io(e),async function(e,t){const n=await zs(e,{url:`${Vc}/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{peer:to.asString(r.peer,{name:"peer"}),sent:ei.fromPLUR(oi(r.sent,{name:"sent"})),received:ei.fromPLUR(oi(r.received,{name:"received"}))}}(this.getRequestOptionsForCall(t),e)}async getAllSettlements(e){return async function(e){const t=await zs(e,{url:Vc,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{totalSent:ei.fromPLUR(oi(n.totalSent,{name:"totalSent"})),totalReceived:ei.fromPLUR(oi(n.totalReceived,{name:"totalReceived"})),settlements:to.asArray(n.settlements,{name:"settlements"}).map(e=>to.asObject(e,{name:"settlement"})).map(e=>({peer:to.asString(e.peer,{name:"peer"}),sent:ei.fromPLUR(oi(e.sent,{name:"sent"})),received:ei.fromPLUR(oi(e.received,{name:"received"}))}))}}(this.getRequestOptionsForCall(e))}async getStatus(e){return async function(e){const t=await zs(e,{method:"get",url:"status",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{overlay:to.asString(n.overlay,{name:"overlay"}),proximity:to.asNumber(n.proximity,{name:"proximity"}),beeMode:Ko(to.asString(n.beeMode,{name:"beeMode"})),reserveSize:to.asNumber(n.reserveSize,{name:"reserveSize"}),reserveSizeWithinRadius:to.asNumber(n.reserveSizeWithinRadius,{name:"reserveSizeWithinRadius"}),pullsyncRate:to.asNumber(n.pullsyncRate,{name:"pullsyncRate"}),storageRadius:to.asNumber(n.storageRadius,{name:"storageRadius"}),connectedPeers:to.asNumber(n.connectedPeers,{name:"connectedPeers"}),neighborhoodSize:to.asNumber(n.neighborhoodSize,{name:"neighborhoodSize"}),batchCommitment:to.asNumber(n.batchCommitment,{name:"batchCommitment"}),isReachable:to.asBoolean(n.isReachable,{name:"isReachable"}),lastSyncedBlock:to.asNumber(n.lastSyncedBlock,{name:"lastSyncedBlock"}),committedDepth:to.asNumber(n.committedDepth,{name:"committedDepth"}),isWarmingUp:to.asBoolean(n.isWarmingUp,{name:"isWarmingUp"})}}(this.getRequestOptionsForCall(e))}async getHealth(e){return du(this.getRequestOptionsForCall(e))}async getReadiness(e){return async function(e){const t=await zs(e,{method:"get",url:"readiness"}),n=to.asObject(t.data,{name:"response.data"});return{apiVersion:to.asString(n.apiVersion,{name:"apiVersion"}),version:to.asString(n.version,{name:"version"}),status:to.asString(n.status,{name:"status"})}}(this.getRequestOptionsForCall(e))}async getNodeInfo(e){return async function(e){const t=await zs(e,{method:"get",url:"node",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{beeMode:Ko(to.asString(n.beeMode,{name:"beeMode"})),chequebookEnabled:to.asBoolean(n.chequebookEnabled,{name:"chequebookEnabled"}),swapEnabled:to.asBoolean(n.swapEnabled,{name:"swapEnabled"})}}(this.getRequestOptionsForCall(e))}async isSupportedExactVersion(e){return async function(e){const{version:t}=await du(e);return t===fu}(this.getRequestOptionsForCall(e))}async isSupportedApiVersion(e){return async function(e){const{apiVersion:t}=await du(e);return lu(t)===lu(hu)}(this.getRequestOptionsForCall(e))}async getVersions(e){return async function(e){const{version:t,apiVersion:n}=await du(e);return{supportedBeeVersion:fu,supportedBeeApiVersion:hu,beeVersion:t,beeApiVersion:n}}(this.getRequestOptionsForCall(e))}async getReserveState(e){return async function(e){const t=await zs(e,{method:"get",url:"reservestate",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{commitment:to.asNumber(n.commitment,{name:"commitment"}),radius:to.asNumber(n.radius,{name:"radius"}),storageRadius:to.asNumber(n.storageRadius,{name:"storageRadius"})}}(this.getRequestOptionsForCall(e))}async getChainState(e){return async function(e){const t=await zs(e,{method:"get",url:"chainstate",responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{block:to.asNumber(n.block,{name:"block"}),chainTip:to.asNumber(n.chainTip,{name:"chainTip"}),totalAmount:oi(n.totalAmount,{name:"totalAmount"}),currentPrice:(r=to.asNumber(n.currentPrice,{name:"currentPrice"}),Number.isInteger(r)?r<24e3?24e3:r:24e3)};var r}(this.getRequestOptionsForCall(e))}async getWalletBalance(e){return async function(e){const t=await zs(e,{method:"get",url:`${qc}`,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return{bzzBalance:ei.fromPLUR(oi(n.bzzBalance,{name:"bzzBalance"})),nativeTokenBalance:ti.fromWei(oi(n.nativeTokenBalance,{name:"nativeTokenBalance"})),chainID:to.asNumber(n.chainID,{name:"chainID"}),chequebookContractAddress:to.asString(n.chequebookContractAddress,{name:"chequebookContractAddress"}),walletAddress:to.asString(n.walletAddress,{name:"walletAddress"})}}(this.getRequestOptionsForCall(e))}async createPostageBatch(e,t,n,r){const o=oi(e,{min:0n,name:"amount"});if(n&&(n=ci(n)),t<17||t>255)throw new Fo("Depth has to be between 17..255",t);const i=await this.getChainState(),a=17280n*BigInt(i.currentPrice)+1n;if(BigInt(o)<a)throw new Fo(`Amount has to be at least ${a} (1 day at current price ${i.currentPrice})`,o);const s=await async function(e,t,n,r){const o={};r?.gasPrice&&(o["gas-price"]=r.gasPrice.toString()),void 0!==r?.immutableFlag&&(o.immutable=String(r.immutableFlag));const i=await zs(e,{method:"post",url:`${jc}/${t}/${n}`,responseType:"json",params:{label:r?.label},headers:o}),a=to.asObject(i.data,{name:"response.data"});return new Po(to.asString(a.batchID,{name:"batchID"}))}(this.getRequestOptionsForCall(r),o,t,n);return!1!==n?.waitForUsable&&await this.waitForUsablePostageStamp(s,n?.waitForUsableTimeout),s}async buyStorage(e,t,n,r,o,i){const a=yi(t,(await this.getChainState(r)).currentPrice,"gnosis"===this.network?5:15),s=bi(e,o,i);return n&&(n=ci(n)),this.createPostageBatch(a,s,n,r)}async getStorageCost(e,t,n,r,o){const i=yi(t,(await this.getChainState(n)).currentPrice,"gnosis"===this.network?5:15);return gi(bi(e,r,o),i)}async extendStorage(e,t,n,r,o,i){const a=await this.getPostageBatch(e,r),s=bi(t,o,i),c=await this.getChainState(r),u=s-a.depth,l=u<=0?1n:2n**BigInt(u),f="gnosis"===this.network?5:15,h=yi(n,c.currentPrice,f),d=yi(a.duration,c.currentPrice,f),p=(n.isZero()?d*l:d+h*l)-d,m=await this.topUpBatch(a.batchID,p,r);return u>0?this.diluteBatch(a.batchID,s,r):m}async extendStorageSize(e,t,n,r,o){const i=await this.getChainState(n),a=await this.getPostageBatch(e,n),s=bi(t,r,o),c=s-a.depth;if(c<=0)throw new Fo("New depth has to be greater than the original depth",s);const u=yi(a.duration,i.currentPrice,"gnosis"===this.network?5:15);return await this.topUpBatch(a.batchID,u*(2n**BigInt(c)-1n)+1n,n),this.diluteBatch(a.batchID,s,n)}async extendStorageDuration(e,t,n){const r=await this.getPostageBatch(e,n),o=yi(t,(await this.getChainState(n)).currentPrice,"gnosis"===this.network?5:15);return this.topUpBatch(r.batchID,o,n)}async getExtensionCost(e,t,n,r,o,i){const a=await this.getPostageBatch(e,r),s=await this.getChainState(r),c="gnosis"===this.network?5:15,u=n.isZero()?0n:yi(n,s.currentPrice,c),l=bi(t,o,i),f=yi(a.duration,s.currentPrice,c),h=gi(a.depth,f);return gi(l,f+u).minus(h)}async getSizeExtensionCost(e,t,n,r,o){const i=await this.getPostageBatch(e,n),a=await this.getChainState(n),s=bi(t,r,o);if(s-i.depth<=0)throw new Fo("New depth has to be greater than the original depth",s);const c=yi(i.duration,a.currentPrice,"gnosis"===this.network?5:15),u=gi(i.depth,c);return gi(s,c).minus(u)}async getDurationExtensionCost(e,t,n){const r=await this.getPostageBatch(e,n),o=yi(t,(await this.getChainState(n)).currentPrice,"gnosis"===this.network?5:15);return gi(r.depth,o)}async topUpBatch(e,t,n){e=new Po(e);const r=oi(t,{min:1n,name:"amount"});return async function(e,t,n){const r=await zs(e,{method:"patch",url:`${jc}/topup/${t}/${n}`,responseType:"json"}),o=to.asObject(r.data,{name:"response.data"});return new Po(to.asString(o.batchID,{name:"batchID"}))}(this.getRequestOptionsForCall(n),e,r)}async diluteBatch(e,t,n){return e=new Po(e),t=to.asNumber(t,{name:"depth",min:18,max:255}),async function(e,t,n){const r=await zs(e,{method:"patch",url:`${jc}/dilute/${t}/${n}`,responseType:"json"}),o=to.asObject(r.data,{name:"response.data"});return new Po(to.asString(o.batchID,{name:"batchID"}))}(this.getRequestOptionsForCall(n),e,t)}async getPostageBatch(e,t,n,r){return e=new Po(e),async function(e,t,n,r){const o=await zs(e,{method:"get",url:`${jc}/${t}`,responseType:"json"}),i=to.asObject(o.data,{name:"response.data"}),a=to.asNumber(i.utilization,{name:"utilization"}),s=to.asNumber(i.depth,{name:"depth"}),c=to.asNumber(i.bucketDepth,{name:"bucketDepth"}),u=hi(a,s,c),l=Mc(to.asNumber(i.batchTTL,{name:"batchTTL"})),f=Qo.fromSeconds(l),h=mi(s,n,r);return{batchID:new Po(to.asString(i.batchID,{name:"batchID"})),utilization:a,usable:to.asBoolean(i.usable,{name:"usable"}),label:to.asEmptiableString(i.label,{name:"label"}),depth:s,amount:oi(i.amount,{name:"amount"}),bucketDepth:c,blockNumber:to.asNumber(i.blockNumber,{name:"blockNumber"}),immutableFlag:to.asBoolean(i.immutableFlag,{name:"immutableFlag"}),usage:u,usageText:`${Math.round(100*u)}%`,size:Fc.fromBytes(h),remainingSize:Fc.fromBytes(Math.ceil(h*(1-u))),theoreticalSize:Fc.fromBytes(di(s)),duration:f,calculateSize(e,t){const n=mi(s,e,t);return Fc.fromBytes(n)},calculateRemainingSize(e,t){const n=mi(s,e,t);return Fc.fromBytes(Math.ceil(n*(1-u)))}}}(this.getRequestOptionsForCall(t),e,n,r)}async getPostageBatchBuckets(e,t){return e=new Po(e),async function(e,t){const n=await zs(e,{method:"get",url:`${jc}/${t}/buckets`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return{depth:to.asNumber(r.depth,{name:"depth"}),bucketDepth:to.asNumber(r.bucketDepth,{name:"bucketDepth"}),bucketUpperBound:to.asNumber(r.bucketUpperBound,{name:"bucketUpperBound"}),buckets:to.asArray(r.buckets,{name:"buckets"}).map(e=>to.asObject(e,{name:"bucket"})).map(e=>({bucketID:to.asNumber(e.bucketID,{name:"bucketID"}),collisions:to.asNumber(e.collisions,{name:"collisions"})}))}}(this.getRequestOptionsForCall(t),e)}async getAllPostageBatch(e){return Gc(this.getRequestOptionsForCall(e))}async getAllGlobalPostageBatch(e){return Lc(this.getRequestOptionsForCall(e))}async getPostageBatches(e){return Gc(this.getRequestOptionsForCall(e))}async getGlobalPostageBatches(e){return Lc(this.getRequestOptionsForCall(e))}async getAllPendingTransactions(e){return async function(e){const t=await zs(e,{url:pu,responseType:"json"}),n=to.asObject(t.data,{name:"response.data"});return to.asArray(n.pendingTransactions,{name:"pendingTransactions"}).map(mu)}(this.getRequestOptionsForCall(e))}async getPendingTransaction(e,t){return e=new zo(e),async function(e,t){const n=await zs(e,{url:`${pu}/${t}`,responseType:"json"});return mu(to.asObject(n.data,{name:"response.data"}))}(this.getRequestOptionsForCall(t),e)}async rebroadcastPendingTransaction(e,t){return e=new zo(e),async function(e,t){const n=await zs(e,{method:"post",url:`${pu}/${t}`,responseType:"json"}),r=to.asObject(n.data,{name:"response.data"});return new zo(to.asString(r.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(t),e)}async cancelPendingTransaction(e,t,n){let r;return e=new zo(e),t&&(r=oi(t,{min:0n,name:"gasPrice"})),async function(e,t,n){const r={};n&&(r["gas-price"]=n.toString());const o=await zs(e,{method:"delete",headers:r,url:`${pu}/${t}`,responseType:"json"}),i=to.asObject(o.data,{name:"response.data"});return new zo(to.asString(i.transactionHash,{name:"transactionHash"}))}(this.getRequestOptionsForCall(n),e,r)}async getStake(e){return async function(e){const t=await zs(e,{method:"get",responseType:"json",url:`${Uc}`}),n=to.asObject(t.data,{name:"response.data"});return ei.fromPLUR(oi(n.stakedAmount,{name:"stakedAmount"}))}(this.getRequestOptionsForCall(e))}async getWithdrawableStake(e){return async function(e){const t=await zs(e,{method:"get",responseType:"json",url:`${Uc}/withdrawable`}),n=to.asObject(t.data,{name:"response.data"});return ei.fromPLUR(oi(n.withdrawableAmount,{name:"withdrawableAmount"}))}(this.getRequestOptionsForCall(e))}async withdrawSurplusStake(e){return async function(e){const t=await zs(e,{method:"delete",responseType:"json",url:`${Uc}/withdrawable`}),n=to.asObject(t.data,{name:"response.data"});return new zo(to.asHexString(n.txHash,{name:"txHash"}))}(this.getRequestOptionsForCall(e))}async migrateStake(e){return async function(e){const t=await zs(e,{method:"delete",responseType:"json",url:Uc}),n=to.asObject(t.data,{name:"response.data"});return new zo(to.asHexString(n.txHash,{name:"txHash"}))}(this.getRequestOptionsForCall(e))}async depositStake(e,t,n){const r=e instanceof ei?e.toPLURString():oi(e,{min:1n,name:"amount"});return t&&(t=ui(t)),async function(e,t,n){const r=await zs(e,{method:"post",responseType:"json",url:`${Uc}/${t}`,headers:Ei(null,n)}),o=to.asObject(r.data,{name:"response.data"});return new zo(to.asHexString(o.txHash,{name:"txHash"}))}(this.getRequestOptionsForCall(n),r,t)}async getRedistributionState(e){return async function(e){const t=await zs(e,{method:"get",responseType:"json",url:"redistributionstate"}),n=to.asObject(t.data,{name:"response.data"});return{minimumGasFunds:ti.fromWei(oi(n.minimumGasFunds,{name:"minimumGasFunds"})),hasSufficientFunds:to.asBoolean(n.hasSufficientFunds,{name:"hasSufficientFunds"}),isFrozen:to.asBoolean(n.isFrozen,{name:"isFrozen"}),isFullySynced:to.asBoolean(n.isFullySynced,{name:"isFullySynced"}),phase:to.asString(n.phase,{name:"phase"}),round:to.asNumber(n.round,{name:"round"}),lastWonRound:to.asNumber(n.lastWonRound,{name:"lastWonRound"}),lastPlayedRound:to.asNumber(n.lastPlayedRound,{name:"lastPlayedRound"}),lastFrozenRound:to.asNumber(n.lastFrozenRound,{name:"lastFrozenRound"}),lastSelectedRound:to.asNumber(n.lastSelectedRound,{name:"lastSelectedRound"}),lastSampleDurationSeconds:to.asNumber(n.lastSampleDurationSeconds,{name:"lastSampleDurationSeconds"}),block:to.asNumber(n.block,{name:"block"}),reward:ei.fromPLUR(oi(n.reward,{name:"reward"})),fees:ti.fromWei(oi(n.fees,{name:"fees"})),isHealthy:to.asBoolean(n.isHealthy,{name:"isHealthy"})}}(this.getRequestOptionsForCall(e))}async waitForUsablePostageStamp(e,t=24e4){for(let n=0;n<t;n+=3e3){try{if((await this.getPostageBatch(e)).usable)return}catch(e){}await eo.sleepMillis(3e3)}throw new Uo("Timeout on waiting for postage stamp to become usable")}getRequestOptionsForCall(e){return e&&(e=function(e){const t=to.asObject(e,{name:"BeeRequestOptions"});return{baseURL:to.asOptional(e=>to.asString(e,{name:"baseURL"}),t.baseURL),timeout:to.asOptional(e=>to.asInteger(e,{name:"timeout",min:0}),t.timeout),headers:to.asOptional(e=>to.asStringMap(e,{name:"headers"}),t.headers),onRequest:to.asOptional(e=>to.asFunction(e,{name:"onRequest"}),t.onRequest),httpAgent:t.httpAgent,httpsAgent:t.httpsAgent,endlesslyRetry:to.asOptional(e=>to.asBoolean(e,{name:"endlesslyRetry"}),t.endlesslyRetry)}}(e)),e?Yr.deepMerge2(this.requestOptions,e):this.requestOptions}}class Iu{constructor(e,t,n,r){this.signer=new Oo(e),this.batchId=new Po(t),this.buckets=n,this.depth=r,this.maxSlot=2**(this.depth-16)}static fromBlank(e,t,n){return new Iu(e,t,new Uint32Array(65536),n)}static fromState(e,t,n,r){return new Iu(e,t,n,r)}stamp(e){const t=e.hash(),n=Wr.uint16ToNumber(t,"BE"),r=this.buckets[n];if(r>=this.maxSlot)throw Error("Bucket is full");this.buckets[n]++;const o=Wr.concatBytes(Wr.numberToUint32(n,"BE"),Wr.numberToUint32(r,"BE")),i=Wr.numberToUint64(BigInt(Date.now()),"BE"),a=this.signer.sign(Wr.concatBytes(t,this.batchId.toUint8Array(),o,i));return{batchId:this.batchId,index:o,issuer:this.signer.publicKey().address().toUint8Array(),signature:a.toUint8Array(),timestamp:i}}getState(){return this.buckets}}Jo.MEDIUM,Jo.STRONG,Jo.INSANE,Jo.PARANOID;function Pu(e){const t=[];for(let n=0;n<e.length;n+=4096)t.push(e.slice(n,Math.min(n+4096,e.length)));return t}async function Cu(e,t){if(1===e.length)return new $o(e[0].address);const n=[];for(let r=0;r<e.length;r+=64){const o=e.slice(r,Math.min(r+64,e.length)),i=new Uint8Array(32*o.length);o.forEach((e,t)=>{i.set(e.address,32*t)});const a=Ho(i);n.push({address:a.address.toUint8Array()}),await t(a)}return n.length>1?Cu(n,t):new $o(n[0].address)}let Nu=class{constructor(e){this.cursor=0,this.buffer=e}write(e){throw new Error("SimpleUint8ArrayWriter.write() not implemented")}max(){return this.buffer.length}};class _u{constructor(e){this.chunk=e,this.span=e.span.toBigInt(),this.writer=new Nu(e.data)}hash(){return this.chunk.address.toUint8Array()}build(){return this.chunk.data}}async function Vu(e,t,n,r){const{bee:o,stamper:i,postageBatchId:a}=e;if(!i&&!a)throw new Error("No authentication method available");let s=n?.tag;if(!s){s=(await o.createTag()).uid}const c=Pu(t);let u=c.length,l=0;console.log(`[UploadData] Splitting ${t.length} bytes into ${u} chunks`);const f=()=>{r&&r({total:u,processed:l})},h=[],d={...n,tag:s};for(const e of c){const t=Ho(e);h.push({address:t.address.toUint8Array()}),await Uu(o,i,a,t,d),l++,f()}let p;return 1===h.length?(p=new $o(h[0].address),console.log("[UploadData] Single chunk upload, reference:",p.toHex())):(console.log("[UploadData] Building merkle tree for",h.length,"chunks"),p=await Cu(h,async e=>{await Uu(o,i,a,e,d),u++,l++,f()}),console.log("[UploadData] Merkle tree complete, root reference:",p.toHex())),{reference:p.toHex(),tagUid:s}}async function Uu(e,t,n,r,o){const i={...o,deferred:!0,pin:!1};if(console.log("[UploadData] uploadChunk options:",i),t){const n=new _u(r),o=t.stamp(n);await e.uploadChunk(o,r.data,i)}else{if(!n)throw new Error("No stamper or batch ID available");await e.uploadChunk(n,r.data,i)}}var Fu,Mu={};var ju=(Fu||(Fu=1,function(e){var t;async function n(e){return new Promise((t,n)=>e.then(n,t))}async function r(e){return new Promise(t=>setTimeout(()=>{t(!0)},e))}function o(e,t=Math.random){for(let n=e.length-1;n>0;n--){const r=Math.floor(t()*(n+1)),o=e[n];e[n]=e[r],e[r]=o}return e}function i(e,t,n=Math.random){return o(G(0,e.length-1),n).slice(0,t)}function a(e,t,n=Math.random){return Math.floor(n()*(t-e+1))+e}function s(e,t,n){return t>=e.x&&t<e.x+e.width&&n>=e.y&&n<e.y+e.height}function c(e,t=Math.random){return t()<e}function u(e,t=Math.random){return e[Math.floor(e.length*t())]}function l(e){if(!e.length)throw Error("Received empty array");return e[e.length-1]}function f(e,t,n){return n(t.reduce((e,t)=>t(e),e))}function h(e,t){if(null==e)return null;const n=t.split(".");let r=e;for(const e of n){if(null===r[e]||void 0===r[e])return null;r=r[e]}return r}function d(e,t,n){const r=t.split(/\.|\[/);let o=e;for(let e=0;e<r.length;e++){const t=r[e],i=e<r.length-1&&r[e+1].includes("]"),a=t.includes("]")?t.replace(/\[|\]/g,""):t;if(e===r.length-1)return o[a]=n,n;m(o[a])||(o[a]=i?[]:{}),o=o[a]}return n}function p(e,t){return Math.round(e/t)*t}function m(e,t=!0){return!(!e||t&&!b(e._readableState)||t&&e.constructor&&(e.constructor.isBuffer||"Uint8Array"==e.constructor.name||"ArrayBuffer"===e.constructor.name||"ReadableStream"===e.constructor.name))&&"object"==typeof e}function g(e){return m(e)&&!Array.isArray(e)}function y(e){return Array.isArray(e)&&0===e.length}function b(e){return void 0===e}function w(e){return"[object Function]"===Object.prototype.toString.call(e)||"[object AsyncFunction]"===Object.prototype.toString.call(e)}function v(e){return"[object String]"===Object.prototype.toString.call(e)}function E(e){return"number"==typeof e&&isFinite(e)}function x(e){return!0===e||!1===e}function B(e){return"[object Date]"===Object.prototype.toString.call(e)}function T(e){return!v(e)||0===e.trim().length}function A(e){return E(e)&&Number.isInteger(e)&&e>=1}function O(e){return v(e)&&null!==e.match(/^-?\d+$/)}function R(e){return v(e)&&null!==e.match(/^(0x)?[0-9a-f]+$/i)}Object.defineProperty(e,"__esModule",{value:!0}),e.Vector=e.Cache=e.Assertions=e.Strings=e.Types=e.Objects=e.Dates=e.Promises=e.Numbers=e.System=e.Arrays=e.Random=e.Elliptic=e.Binary=e.RollingValueProvider=e.TrieRouter=e.AsyncQueue=e.PubSubChannel=e.FixedPointNumber=e.MerkleTree=e.Chunk=e.Uint8ArrayWriter=e.Uint8ArrayReader=e.AsyncLazy=e.Lazy=e.Optional=void 0;const k="!@#$%^&*()_+-=[]{}|;:<>?,./".split(""),S="abcdefghijklmnopqrstuvwxyz",$=S+"ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890",z=$+"!@#$%^&*()_+-=[]{}|;:<>?,./",D=["—","\\","東","京","都","𝖆","𝖇","𝖈","👾","🙇","💁","🙅","ᚠ","ᛇ","ᚻ","ᛦ"],I="0123456789abcdef";function P(e,t){if(T(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);if(t&&(void 0!==t.min&&e.length<t.min||void 0!==t.max&&e.length>t.max))throw RangeError(`Expected string${t?.name?` for ${t.name}`:""} length in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e.length}`);return e}function C(e,t){if(void 0!==t.min&&e<t.min||void 0!==t.max&&e>t.max)throw RangeError(`Expected value${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: ${e}`)}function N(e,t){if(E(e))return t&&C(e,t),e;if(!v(e)||!e.match(/^-?\d+(\.\d+)?$/))throw new TypeError(`Expected number${t?.name?` for ${t.name}`:""}, got: `+e);const n=parseFloat(e);return t&&C(n,t),n}function _(e,t){return Math.trunc(N(e,t))}function V(e,t){if(!g(e))throw new TypeError(`Expected object${t?.name?` for ${t.name}`:""}, got: `+e);return e}function U(e){return v(e)&&null!==e.match(/^https?:\/\/.+/)}function F(e,t){for(const[n,r]of Object.entries(t))if(!r(e[n]))throw TypeError(`${n} in value does not exist or match shape`);for(const n of Object.keys(e))if(!t[n])throw TypeError(`${n} exists in value but not in shape`);return!0}function M(e,t){if(g(e)&&g(t))for(const n in t)g(t[n])?(e[n]||(e[n]={}),M(e[n],t[n])):Array.isArray(t[n])?e[n]=[...t[n]]:(null!==t[n]&&void 0!==t[n]||null===e[n]||void 0===e[n])&&(e[n]=t[n]);return e}function j(e,t){const n={};for(const r of e)for(const e of Object.keys(r))n[e]?n[e]=t(n[e],r[e]):n[e]=r[e];return n}function L(e,t){Array.prototype.push.apply(e,t)}function G(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function q(e,t=()=>!1){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").split("").map(e=>/[a-z0-9]/.test(e)||t(e)?e:"-").join("").replace(/-+/g,"-").replace(/^-|-$/g,"")}function H(e,t){if(0===t.length)return 0;const n=e.toLowerCase(),r=t.toLowerCase();return e===t?1e4:n.startsWith(r)?1e4-e.length:n.includes(r)?5e3-e.length:new RegExp(".*"+r.split("").join(".*")+".*").test(n)?1e3-e.length:0}const Z={"&amp;":"&","&quot;":'"',"&apos;":"'","&gt;":">","&lt;":"<"};function W(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(0,n)}function K(e,t){const n=e.indexOf(t);return-1===n?null:e.slice(n+t.length)}function J(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(0,n)}function X(e,t){const n=e.lastIndexOf(t);return-1===n?null:e.slice(n+t.length)}function Y(e,t,n=!1){const r=n?e.lastIndexOf(t):e.indexOf(t);return-1===r?n?[null,e]:[e,null]:[e.slice(0,r),e.slice(r+t.length)]}function Q(e,t){let n=[e];for(const e of t)n=n.flatMap(t=>t.split(e));return n.filter(e=>e)}function ee(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?"":t.slice(n+1)}function te(e){const t=l(e.split(/\\|\//g)),n=t.lastIndexOf(".",t.length-1);return n<=0?t:t.slice(0,n)}function ne(e){return e.split("\n").map(e=>e.trim().replace(/\s+/g," ")).filter(e=>e.length>0).join("\n")}function re(e){return e.charAt(0).toUpperCase()+e.slice(1)}function oe(e){return e.charAt(0).toLowerCase()+e.slice(1)}function ie(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function ae(e){if(!e)return!1;const t=e.charCodeAt(0);return t>=48&&t<=57}function se(e){return ie(e)||ae(e)}const ce=" \n\t\r.,?!:;\"'`(){}[]~@#$%^&*-+=|<>/\\".split("");function ue(e){return ce.includes(e)}function le(e,t,n=0){const r=t.exec(e.slice(n));return r?{index:r.index,match:r[0]}:null}function fe(e,t,n=!0){if(!n)return t.every(t=>t instanceof RegExp?t.test(e):-1!==e.indexOf(t,0));let r=0;for(const n of t)if(n instanceof RegExp){const t=le(e,n,r);if(!t)return!1;r=t.index+t.match.length}else{const t=e.indexOf(n,r);if(-1===t)return!1;r=t+n.length}return!0}function he(e,t,n=0){const r=[];let o=e.indexOf(t,n);for(;-1!==o;)r.push(o),o=e.indexOf(t,o+t.length);return r}function de(e,t,n=0){let r=-1;for(const o of t){const t=e.indexOf(o,n);-1!==t&&(-1===r||t<r)&&(r=t)}return r}function pe(e,t=0){for(let n=t;n<e.length;n++)if(ue(e[n]))return n;return-1}function me(e,t=0){for(let n=t;n<e.length;n++)if("#"===e[n]&&se(e[n+1]))return n;return-1}function ge(e,t,n=0){return e.slice(0,n).lastIndexOf(t)}function ye(e,t=0,n="{",r="}"){let o=1;for(let i=t;i<e.length;i++)if(e.slice(i,i+r.length)===r){if(0===--o)return i}else e.slice(i,i+n.length)===n&&o++;return-1}function be(e,t){const n=t.wordBoundary?de(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);if(-1===n)return null;const r=ye(e,n+t.opening.length,t.opening,t.closing);return-1===r?null:t.exclusive?e.slice(n+t.opening.length,r):e.slice(n,r+t.closing.length)}const we="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ve="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";function Ee(e,t){const n=t.length;let r=0,o=0;const i=[];for(let a=0;a<e.length;a++){const s=e[a];if("="===s)break;const c=t.indexOf(s);if(-1===c)throw new Error(`Invalid character: ${s}`);o=o<<Math.log2(n)|c,r+=Math.log2(n),r>=8&&(r-=8,i.push(o>>r&255))}return new Uint8Array(i)}function xe(e,t){const n=t.length;let r=0,o=0,i="";for(let a=0;a<e.length;a++)for(o=o<<8|e[a],r+=8;r>=Math.log2(n);)r-=Math.log2(n),i+=t[o>>r&n-1];return r>0&&(i+=t[o<<Math.log2(n)-r&n-1]),i.length%4!=0&&(i+="=".repeat(4-i.length%4)),i}function Be(e,t,n){const r=[];for(const o of n)o!==t&&r.push(e.replace(t,o));return r}function Te(e){const t=e.lastIndexOf(" ");return-1===t?{line:e,rest:""}:{line:e.slice(0,t),rest:e.slice(t+1)}}function Ae(e){const t=e.reduce((e,t)=>e.length<t.length?e:t);let n="";for(let r=0;r<t.length;r++){const o=t[r];if(!e.every(e=>e[r]===o))break;n+=o}return n}function Oe(e,t){return new RegExp(`\\b${t}\\b`).test(e)}function Re(e,t,n=[]){let r="";for(;t<e.length&&(se(e[t])||n.includes(e[t]));)r+=e[t++];return r}function ke(e,t,n,r="$",o=":"){if(""===n)return e;let i=e.indexOf(`${r}${t}`);for(;-1!==i;){if(e[i+t.length+1]===o)if(e[i+t.length+2]===o)e=e.replace(`${r}${t}${o}${o}`,n);else{const a=Re(e,i+t.length+2,["_"]);e=e.replace(`${r}${t}${o}${a}`,n)}else e=e.replace(`${r}${t}`,n);i=e.indexOf(`${r}${t}`,i+n.length)}return e}function Se(e,t="$",n=":"){let r=e.indexOf(t);for(;-1!==r;){const o=Re(e,r+1);if(e[r+o.length+1]===n)if(e[r+o.length+2]===n)e=e.replace(`${t}${o}${n}${n}`,"");else{const i=Re(e,r+o.length+2);e=e.replace(`${t}${o}${n}${i}`,i)}r=e.indexOf(t,r+1)}return e}function $e(e,t=!0){const n=Object.entries(e).filter(([e,t])=>null!=t).map(([e,t])=>`${e}=${encodeURIComponent(t)}`).join("&");return n?(t?"?":"")+n:""}function ze(e){return String(Math.floor(e)).padStart(2,"0")}function De(e){const t=Math.floor(e/36e5);e%=36e5;const n=Math.floor(e/6e4);e%=6e4;const r=Math.floor(e/1e3);return t?`${ze(t)}:${ze(n)}:${ze(r)}`:`${ze(n)}:${ze(r)}`}function Ie(e){return Math.floor((B(e)?e.getTime():e)/864e5)}const Pe={today:(e,t)=>ze(e)+":"+ze(t),yesterday:()=>"Yesterday",monday:()=>"Mon",tuesday:()=>"Tue",wednesday:()=>"Wed",thursday:()=>"Thu",friday:()=>"Fri",saturday:()=>"Sat",sunday:()=>"Sun",weeks:e=>`${e}w`},Ce={now:()=>"A few seconds",seconds:e=>`${e} seconds`,minutes:e=>`${e} minutes`,hours:e=>`${e} hours`,days:e=>`${e} days`,weeks:e=>`${e} weeks`};function Ne(t,n){const r=n?.now??Date.now(),o=n?.labels||Ce;let i=(r-(e.Types.isDate(t)?t.getTime():t))/1e3;return i<10?o.now():i<120?o.seconds(Math.floor(i)):(i/=60,i<120?o.minutes(Math.floor(i)):(i/=60,i<48?o.hours(Math.floor(i)):(i/=24,i<14?o.days(Math.floor(i)):(i/=7,o.weeks(Math.floor(i))))))}const _e={},Ve={s:1e3,m:6e4,h:36e5,d:864e5},Ue={0:"sunday",1:"monday",2:"tuesday",3:"wednesday",4:"thursday",5:"friday",6:"saturday"};function Fe(e){return{zeroBasedIndex:e,day:Ue[e]}}function Me(e){return Fe(e.getDay())}const je={ms:1,milli:1,millis:1,millisecond:1,milliseconds:1,s:1e3,sec:1e3,second:1e3,seconds:1e3,m:6e4,min:6e4,minute:6e4,minutes:6e4,h:36e5,hour:36e5,hours:36e5,d:864e5,day:864e5,days:864e5,w:6048e5,week:6048e5,weeks:6048e5,month:2592e6,months:2592e6,y:31536e6,year:31536e6,years:31536e6},Le={b:0,byte:0,bytes:0,kb:1,kilobyte:1,kilobytes:1,mb:2,megabyte:2,megabytes:2,gb:3,gigabyte:3,gigabytes:3,tb:4,terabyte:4,terabytes:4},Ge=new Map;function qe(e,t=!1){e=e.filter(e=>e),t&&v(e[1])&&(e[1]="../"+e[1]);let n="";v(e[0])&&e[0].includes("://")&&(n=W(e[0],"://")??"",e[0]=K(e[0],"://")??"");const r=e.map(e=>String(e)).flatMap(e=>e.split("/")),o=[];for(let e=0;e<r.length;e++)"."!==r[e]&&(".."===r[e]?(!n||o.length>1)&&o.pop():o.push(r[e]));return(n?n+"://":"")+o.join("/").replaceAll(/\/{2,}/g,"/")}function He(e){const t=Object.keys(e).sort((e,t)=>e.localeCompare(t)),n={};for(const r of t)n[r]=We(e[r]);return n}function Ze(e){const t=[];return e.sort((e,t)=>JSON.stringify(We(e)).localeCompare(JSON.stringify(We(t)))).forEach(e=>t.push(We(e))),t}function We(e){return Array.isArray(e)?Ze(e):m(e)?He(e):e}function Ke(e,t){return JSON.stringify(We(e))===JSON.stringify(We(t))}function Je(e){const t=Object.keys(e);return t[Math.floor(Math.random()*t.length)]}const Xe=[1e3,1e6,1e9,1e12,1e15,1e18,1e21,1e24,1e27,1e30,1e9,1e16,1e18,1e18,1e18,1e33],Ye=["thousand","million","billion","trillion","quadrillion","quintillion","sextillion","septillion","octillion","nonillion","gwei","bzz","btc","eth","dai","decillion"],Qe=["K","M","B","T","Qa","Qi","Sx","Sp","O","N","gwei","bzz","eth","btc","dai","D"];function et(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeNumber got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim(),r=Qe.findIndex(e=>e.toLowerCase()===n.toLowerCase());return-1===r?t:t*Xe[r]}function tt(e,t,n){return e<t?t:e>n?n:e}function nt(e,t,n){return e+(n?"["+t+"]":(e.length?".":"")+t)}function rt(e,t,n,r,o){if(!m(t))return t;for(const[i,a]of Object.entries(t)){const t=nt(n,i,r);Array.isArray(a)?o?rt(e,a,t,!0,o):e[t]=a.map(e=>rt(Array.isArray(e)?[]:{},e,"",!1,o)):m(a)?rt(e,a,t,!1,o):e[t]=a}return e}function ot(e,t){const n={};for(const r of e)n[t(r)]=r;return n}function it(e,t){const n=Math.ceil(e.length/t),r=[];for(let t=0;t<e.length;t+=n)r.push(e.slice(t,t+n));return r}function at(e,t){const n=[],r=Math.ceil(e.length/t);for(let o=0;o<r;o++)n.push(e.slice(o*t,o*t+t));return n}function st(e,t){return Object.fromEntries(Object.entries(e).sort(t))}function ct(e,t){const n=[];let r=[];return e.forEach((o,i)=>{(0===i||!t(o,e[i-1]))&&(r=[],n.push(r)),r.push(o)}),n}function ut(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.push(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}}class lt{constructor(e){this.value=e}static of(e){return new lt(e)}static empty(){return new lt(null)}map(e){return new lt(null!==this.value&&void 0!==this.value?e(this.value):null)}mapAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then(e=>lt.of(e)):Promise.resolve(lt.empty())}ifPresent(e){return null!==this.value&&void 0!==this.value&&e(this.value),this}ifPresentAsync(e){return null!==this.value&&void 0!==this.value?e(this.value).then(()=>this):Promise.resolve(this)}ifAbsent(e){return(null===this.value||void 0===this.value)&&e(),this}ifAbsentAsync(e){return null===this.value||void 0===this.value?e().then(()=>this):Promise.resolve(this)}getOrFallback(e){return this.value??e()}getOrFallbackAsync(e){return null!==this.value&&void 0!==this.value?Promise.resolve(this.value):e()}getOrThrow(){if(null===this.value||void 0===this.value)throw Error("Optional.value is empty");return this.value}}e.Optional=lt,e.Lazy=class{constructor(e){this.supplier=e,this.value=null}get(){return this.value||(this.value=this.supplier()),this.value}},e.AsyncLazy=class{constructor(e){this.supplier=e,this.value=null}async get(){return this.value||(this.value=await this.supplier()),this.value}};class ft{constructor(e){this.value=e,this.children=[]}}function ht(e,t){if(Math.log2(e.length)%1!=0)throw new Error("Array length must be a power of 2");let n=[...e];for(;n.length>1;){const e=[];for(let r=0;r<n.length;r+=2){const o=n[r+1];e.push(t(n[r],o))}n=e}return n[0]}function dt(...e){const t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t);let r=0;return e.forEach(e=>{n.set(e,r),r+=e.length}),n}function pt(e){return 137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]}function mt(e){return 255===e[0]&&216===e[1]}function gt(e){return 87===e[8]&&69===e[9]&&66===e[10]&&80===e[11]}function yt(e,t){const n=new ArrayBuffer(8);return new DataView(n).setBigUint64(0,BigInt(e),"LE"===t),new Uint8Array(n)}function bt(e,t){const n=new Uint8Array(32);let r=e;if("LE"===t){for(let e=0;e<32;e++)n[e]=Number(0xffn&r),r>>=8n;return n}for(let e=31;e>=0;e--)n[e]=Number(0xffn&r),r>>=8n;return n}function wt(e,t){let n=0n;if("LE"===t){for(let t=31;t>=0;t--)n=n<<8n|BigInt(e[t]);return n}for(let t=0;t<32;t++)n=n<<8n|BigInt(e[t]);return n}function vt(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.subarray(r,r+t));return n}const Et=[0,1,0,32898,2147483648,32906,2147483648,2147516416,0,32907,0,2147483649,2147483648,2147516545,2147483648,32777,0,138,0,136,0,2147516425,0,2147483658,0,2147516555,2147483648,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,0,32778,2147483648,2147483658,2147483648,2147516545,2147483648,32896,0,2147483649,2147483648,2147516424];function xt(e){for(let t=0;t<24;t++){const n=e[0]^e[10]^e[20]^e[30]^e[40],r=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],i=e[3]^e[13]^e[23]^e[33]^e[43],a=e[4]^e[14]^e[24]^e[34]^e[44],s=e[5]^e[15]^e[25]^e[35]^e[45],c=e[6]^e[16]^e[26]^e[36]^e[46],u=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],f=e[9]^e[19]^e[29]^e[39]^e[49],h=l^(o<<1|i>>>31),d=f^(i<<1|o>>>31),p=n^(a<<1|s>>>31),m=r^(s<<1|a>>>31),g=o^(c<<1|u>>>31),y=i^(u<<1|c>>>31),b=a^(l<<1|f>>>31),w=s^(f<<1|l>>>31),v=c^(n<<1|r>>>31),E=u^(r<<1|n>>>31);e[0]^=h,e[1]^=d,e[2]^=p,e[3]^=m,e[4]^=g,e[5]^=y,e[6]^=b,e[7]^=w,e[8]^=v,e[9]^=E,e[10]^=h,e[11]^=d,e[12]^=p,e[13]^=m,e[14]^=g,e[15]^=y,e[16]^=b,e[17]^=w,e[18]^=v,e[19]^=E,e[20]^=h,e[21]^=d,e[22]^=p,e[23]^=m,e[24]^=g,e[25]^=y,e[26]^=b,e[27]^=w,e[28]^=v,e[29]^=E,e[30]^=h,e[31]^=d,e[32]^=p,e[33]^=m,e[34]^=g,e[35]^=y,e[36]^=b,e[37]^=w,e[38]^=v,e[39]^=E,e[40]^=h,e[41]^=d,e[42]^=p,e[43]^=m,e[44]^=g,e[45]^=y,e[46]^=b,e[47]^=w,e[48]^=v,e[49]^=E;const x=e[0],B=e[1],T=e[2]<<1|e[3]>>>31,A=e[3]<<1|e[2]>>>31,O=e[5]<<30|e[4]>>>2,R=e[4]<<30|e[5]>>>2,k=e[6]<<28|e[7]>>>4,S=e[7]<<28|e[6]>>>4,$=e[8]<<27|e[9]>>>5,z=e[9]<<27|e[8]>>>5,D=e[11]<<4|e[10]>>>28,I=e[10]<<4|e[11]>>>28,P=e[13]<<12|e[12]>>>20,C=e[12]<<12|e[13]>>>20,N=e[14]<<6|e[15]>>>26,_=e[15]<<6|e[14]>>>26,V=e[17]<<23|e[16]>>>9,U=e[16]<<23|e[17]>>>9,F=e[18]<<20|e[19]>>>12,M=e[19]<<20|e[18]>>>12,j=e[20]<<3|e[21]>>>29,L=e[21]<<3|e[20]>>>29,G=e[22]<<10|e[23]>>>22,q=e[23]<<10|e[22]>>>22,H=e[25]<<11|e[24]>>>21,Z=e[24]<<11|e[25]>>>21,W=e[26]<<25|e[27]>>>7,K=e[27]<<25|e[26]>>>7,J=e[29]<<7|e[28]>>>25,X=e[28]<<7|e[29]>>>25,Y=e[31]<<9|e[30]>>>23,Q=e[30]<<9|e[31]>>>23,ee=e[33]<<13|e[32]>>>19,te=e[32]<<13|e[33]>>>19,ne=e[34]<<15|e[35]>>>17,re=e[35]<<15|e[34]>>>17,oe=e[36]<<21|e[37]>>>11,ie=e[37]<<21|e[36]>>>11,ae=e[38]<<8|e[39]>>>24,se=e[39]<<8|e[38]>>>24,ce=e[40]<<18|e[41]>>>14,ue=e[41]<<18|e[40]>>>14,le=e[42]<<2|e[43]>>>30,fe=e[43]<<2|e[42]>>>30,he=e[45]<<29|e[44]>>>3,de=e[44]<<29|e[45]>>>3,pe=e[47]<<24|e[46]>>>8,me=e[46]<<24|e[47]>>>8,ge=e[48]<<14|e[49]>>>18,ye=e[49]<<14|e[48]>>>18;e[0]=x^~P&H,e[1]=B^~C&Z,e[2]=P^~H&oe,e[3]=C^~Z&ie,e[4]=H^~oe&ge,e[5]=Z^~ie&ye,e[6]=oe^~ge&x,e[7]=ie^~ye&B,e[8]=ge^~x&P,e[9]=ye^~B&C,e[10]=k^~F&j,e[11]=S^~M&L,e[12]=F^~j&ee,e[13]=M^~L&te,e[14]=j^~ee&he,e[15]=L^~te&de,e[16]=ee^~he&k,e[17]=te^~de&S,e[18]=he^~k&F,e[19]=de^~S&M,e[20]=T^~N&W,e[21]=A^~_&K,e[22]=N^~W&ae,e[23]=_^~K&se,e[24]=W^~ae&ce,e[25]=K^~se&ue,e[26]=ae^~ce&T,e[27]=se^~ue&A,e[28]=ce^~T&N,e[29]=ue^~A&_,e[30]=$^~D&G,e[31]=z^~I&q,e[32]=D^~G&ne,e[33]=I^~q&re,e[34]=G^~ne&pe,e[35]=q^~re&me,e[36]=ne^~pe&$,e[37]=re^~me&z,e[38]=pe^~$&D,e[39]=me^~z&I,e[40]=O^~V&J,e[41]=R^~U&X,e[42]=V^~J&Y,e[43]=U^~X&Q,e[44]=J^~Y&le,e[45]=X^~Q&fe,e[46]=Y^~le&O,e[47]=Q^~fe&R,e[48]=le^~O&V,e[49]=fe^~R&U,e[0]^=Et[2*t],e[1]^=Et[2*t+1]}}function Bt(e){const t=[];for(let n=0;n<e.length;n+=4)t.push(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24);return t}function Tt(e,t){if(!e.length){const e=new Uint8Array(136);return e[0]=t,e[135]=128,[Bt(e)]}const n=vt(e,136),r=n[n.length-1];if(r.length<136){const e=new Uint8Array(136);e.set(r),e[r.length]=t,e[135]|=128,n[n.length-1]=e}if(136===r.length){const e=new Uint8Array(136);e[0]=t,e[135]=128,n.push(e)}return n.map(Bt)}function At(e,t){for(const n of t){for(let t=0;t<34;t+=2)e[t]^=n[t+1],e[t+1]^=n[t];xt(e)}return e}function Ot(e){return new Uint8Array([e[1],e[1]>>-24,e[1]>>-16,e[1]>>-8,e[0],e[0]>>8,e[0]>>16,e[0]>>24,e[3],e[3]>>-24,e[3]>>-16,e[3]>>-8,e[2],e[2]>>8,e[2]>>16,e[2]>>24,e[5],e[5]>>-24,e[5]>>-16,e[5]>>-8,e[4],e[4]>>8,e[4]>>16,e[4]>>24,e[7],e[7]>>-24,e[7]>>-16,e[7]>>-8,e[6],e[6]>>8,e[6]>>16,e[6]>>24])}function Rt(e){return Ot(At(new Array(50).fill(0),Tt(e,1)))}function kt(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,t-e.length),r}function St(e,t,n=0){if(e.length>=t)return e;const r=new Uint8Array(t);return r.fill(n),r.set(e,0),r}function $t(e,t){return(e%t+t)%t}function zt(e,t){e=$t(e,t);let[n,r]=[0n,1n],[o,i]=[t,e];for(;0n!==i;){const e=o/i;[n,r]=[r,n-e*r],[o,i]=[i,o-e*i]}if(o>1n)throw new Error("a is not invertible");return n<0n&&(n+=t),n}function Dt(e,t){return 0n===$t(e,t)?0n:t%4n==3n?function(e,t,n){let r=1n;for(e=$t(e,n);t>0;)t%2n==1n&&(r=$t(r*e,n)),e=$t(e*e,n),t/=2n;return r}(e,(t+1n)/4n,t):null}const It=0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn,Pt=0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141n,Ct=0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798n,Nt=0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8n;function _t(e,t,n){if(0n===t)return[0n,0n];const r=$t(3n*e*e*zt(2n*t,n),n),o=$t(r*r-2n*e,n);return[o,$t(r*(e-o)-t,n)]}function Vt(e,t,n,r,o){if(0n===e&&0n===t)return[n,r];if(0n===n&&0n===r)return[e,t];if(e===n&&t===$t(-r,o))return[0n,0n];if(e===n&&t===r)return _t(e,t,o);const i=$t((r-t)*zt(n-e,o),o),a=$t(i*i-e-n,o);return[a,$t(i*(e-a)-t,o)]}function Ut(e,t,n,r){let o=[0n,0n],i=[e,t];const a=n.toString(2);for(const e of a)"0"===e?(i=Vt(o[0],o[1],i[0],i[1],r),o=_t(o[0],o[1],r)):(o=Vt(o[0],o[1],i[0],i[1],r),i=_t(i[0],i[1],r));return o}function Ft(e,t,n){if(t<=0n||t>=Pt)throw new Error("Invalid private key");if(n||(n=$t(wt(Rt(dt(Rt(bt(t,"BE")),bt(e,"BE"))),"BE"),Pt)),n<=0n||n>=Pt)throw new Error("Invalid nonce");const r=$t(e,Pt),o=Ut(Ct,Nt,n,It),i=$t(o[0],Pt);let a=$t((r+$t(i,Pt)*t)*zt(n,Pt),Pt);if(0n===i||0n===a)throw new Error("Invalid r or s value");let s=o[1]%2n==0n?27n:28n;return a>Pt/2n&&(a=Pt-a,s=27n===s?28n:27n),[i,a,s]}class Mt{constructor(e){this.cursor=0,this.buffer=e}read(e){const t=this.buffer.subarray(this.cursor,this.cursor+e);return this.cursor+=e,t}max(){return this.buffer.length-this.cursor}}e.Uint8ArrayReader=Mt;class jt{constructor(e){this.buffer=e,this.cursor=0}write(e){const t=Math.min(this.max(),e.max());return this.buffer.set(e.read(t),this.cursor),this.cursor+=t,t}max(){return this.buffer.length-this.cursor}}e.Uint8ArrayWriter=jt;class Lt{constructor(e,t=0n){this.span=t,this.writer=new jt(new Uint8Array(e))}build(){return dt(yt(this.span,"LE"),this.writer.buffer)}hash(){const e=ht(vt(this.writer.buffer,32),(e,t)=>Lt.hashFunction(dt(e,t)));return Lt.hashFunction(dt(yt(this.span,"LE"),e))}}e.Chunk=Lt,Lt.hashFunction=Rt;class Gt{constructor(e,t=4096){this.counters=[1],this.capacity=t,this.chunks=[new Lt(t)],this.onChunk=e}static async root(e,n=4096){const r=new t(t.NOOP,n);return await r.append(e),r.finalize()}async append(e,t=0,n=0n){const r=new Mt(e);for(;r.max()>0;){0===this.chunks[t].writer.max()&&await this.elevate(t);const e=this.chunks[t].writer.write(r);n?this.chunks[t].span+=n:this.chunks[0].span+=BigInt(e)}}async elevate(e){this.counters[e]=++this.counters[e]%(this.capacity/32),this.chunks[e+1]||(this.chunks.push(new Lt(this.capacity)),this.counters.push(1)),await this.append(this.chunks[e].hash(),e+1,this.chunks[e].span),await this.onChunk(this.chunks[e]),this.chunks[e]=new Lt(this.capacity)}async finalize(e=0){return this.chunks[e+1]?1===this.counters[e]?(await this.elevate(e+1),this.chunks[e+1]=this.chunks[e],this.finalize(e+1)):(await this.elevate(e),this.finalize(e+1)):(await this.onChunk(this.chunks[e]),this.chunks[e])}}e.MerkleTree=Gt,t=Gt,Gt.NOOP=async e=>{};class qt{constructor(e,t){if(t<0)throw Error("Scale must be non-negative");this.value=BigInt(e),this.scale=t}static fromDecimalString(e,t){let[n,r]=e.split(".");return r=(r||"").padEnd(t,"0").slice(0,t),new qt(BigInt(n+r),t)}add(e){return this.assertSameScale(e),new qt(this.value+e.value,this.scale)}subtract(e){return this.assertSameScale(e),new qt(this.value-e.value,this.scale)}multiply(e){return new qt(this.value*e,this.scale)}divmod(e){if(0n===e)throw new Error("Division by zero is not allowed");const t=this.value/e,n=this.value%e;return[new qt(t,this.scale),new qt(n,this.scale)]}exchange(e,t,n){if("*"===e){const e=this.value*t.value/10n**BigInt(this.scale);return new qt(e,n)}this.assertSameScale(t);const r=this.value*10n**BigInt(n)/t.value;return new qt(r,n)}compare(e){return this.assertSameScale(e),this.value>e.value?1:this.value<e.value?-1:0}toDecimalString(){if(0===this.scale)return this.value.toString();const e=this.value.toString();return`${e.slice(0,-this.scale)||"0"}.${e.slice(-this.scale).padStart(this.scale,"0")}`}toString(){return this.value.toString()}toJSON(){return this.toString()}assertSameScale(e){if(this.scale!==e.scale)throw new Error(`Scale mismatch: expected ${this.scale}, but got ${e.scale}`)}}function Ht(e,t,n,r){const o=e.findIndex(e=>e===`--${t}`||e.startsWith(`--${t}=`)),i=e[o];if(!i)return(n||{})[r||t||""]||null;if(i.includes("="))return i.split("=")[1];const a=e[o+1];return a&&!a.startsWith("-")?a:(n||{})[r||t||""]||null}function Zt(e,t,n,r){const o=Ht(e,t,n,r);if(!o)throw new Error(`Missing argument ${t}`);return o}function Wt(e,t){const n=e[t];e.splice(t,1),e.unshift(n)}function Kt(e,t){return{x:e.x+t.x,y:e.y+t.y}}function Jt(e,t){return{x:e.x*t,y:e.y*t}}function Xt(e,t,n){return{x:e.x+Math.cos(t)*n,y:e.y+Math.sin(t)*n}}function Yt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Qt(e,t,n="row-first"){const r=[];if("column-first"===n)for(let n=0;n<e.length;n++)for(let o=0;o<e[0].length;o++)t(n,o)&&r.push({x:n,y:o});else for(let n=0;n<e[0].length;n++)for(let o=0;o<e.length;o++)t(o,n)&&r.push({x:o,y:n});return r}function en(e,t,n){return!e[t-1]?.[n]}function tn(e,t,n){return!e[t+1]?.[n]}function nn(e,t,n){return!e[t][n-1]}function rn(e,t,n){return!e[t][n+1]}function on(e,t,n){const r=[];return e[t][n]?function(e,t,n){return e[t+1]?.[n]&&e[t-1]?.[n]&&!e[t][n-1]&&!e[t][n+1]}(e,t,n)||function(e,t,n){return e[t][n+1]&&e[t][n-1]&&!e[t-1]?.[n]&&!e[t+1]?.[n]}(e,t,n)?[]:(!e[t-1]?.[n-1]&&en(e,t,n)&&nn(e,t,n)&&r.push({x:t,y:n}),!e[t+1]?.[n-1]&&tn(e,t,n)&&nn(e,t,n)&&r.push({x:t+1,y:n}),!e[t-1]?.[n+1]&&en(e,t,n)&&rn(e,t,n)&&r.push({x:t,y:n+1}),!e[t+1]?.[n+1]&&tn(e,t,n)&&rn(e,t,n)&&r.push({x:t+1,y:n+1}),r):(e[t-1]?.[n]&&e[t][n-1]&&r.push({x:t,y:n}),e[t+1]?.[n]&&e[t][n-1]&&r.push({x:t+1,y:n}),e[t-1]?.[n]&&e[t][n+1]&&r.push({x:t,y:n+1}),e[t+1]?.[n]&&e[t][n+1]&&r.push({x:t+1,y:n+1}),r)}function an(e,t){return t.map(t=>function(e,t){return Math.atan2(t.y-e.y,t.x-e.x)}(e,t)).sort((e,t)=>e-t)}function sn(e,t,n,r){const o=(r.y-n.y)*(t.x-e.x)-(r.x-n.x)*(t.y-e.y);if(0===o)return null;let i=e.y-n.y,a=e.x-n.x;const s=(r.x-n.x)*i-(r.y-n.y)*a,c=(t.x-e.x)*i-(t.y-e.y)*a;return i=s/o,a=c/o,i>0&&i<1&&a>0&&a<1?{x:e.x+i*(t.x-e.x),y:e.y+i*(t.y-e.y)}:null}function cn(e,t,n){const r=[],o=Xt(e,n,1e4);for(const n of t){const t=sn(e,o,n.start,n.end);t&&r.push(t)}return r.length?r.reduce((t,n)=>Yt(e,n)<Yt(e,t)?n:t):null}e.FixedPointNumber=qt;class un{constructor(){this.subscribers=[]}subscribe(e){return this.subscribers.push(e),()=>{this.subscribers=this.subscribers.filter(t=>t!==e)}}publish(e){this.subscribers.forEach(t=>t(e))}clear(){this.subscribers=[]}getSubscriberCount(){return this.subscribers.length}}e.PubSubChannel=un,e.AsyncQueue=class{constructor(e,t){this.queue=[],this.running=0,this.onProcessed=new un,this.onDrained=new un,this.concurrency=e,this.capacity=t}process(){if(this.running>=this.concurrency)return;const e=this.queue.shift();e&&(this.running++,e().finally(()=>{this.running--,this.process(),this.onProcessed.publish(),0===this.running&&this.onDrained.publish()}))}enqueue(e){if(this.queue.length<this.capacity)return this.queue.push(e),this.process(),Promise.resolve();if(this.onProcessed.getSubscriberCount())throw Error("Queue capacity is full");return new Promise(t=>{this.onProcessed.subscribe(()=>{this.queue.length<this.capacity&&(this.queue.push(e),this.process(),this.onProcessed.clear(),t())})})}drain(){if(0===this.running)return Promise.resolve();if(this.onDrained.getSubscriberCount())throw Error("Already draining");return new Promise(e=>{this.onDrained.subscribe(()=>{this.onDrained.clear(),e()})})}};class ln{constructor(){this.forks=new Map}insert(e,t){if(0===e.length)return void(this.handler=t);const n=e[0];let r,o=n;if(n.startsWith(":")&&(o=":",r=n.slice(1)),!this.forks.has(o)){const e=new ln;r&&(e.variableName=r),this.forks.set(o,e)}this.forks.get(o).insert(e.slice(1),t)}async handle(e,t,n,r){if(0===e.length)return!!this.handler&&(await this.handler(t,n,r),!0);const o=e[0],i=this.forks.get(o);if(i)return i.handle(e.slice(1),t,n,r);const a=this.forks.get(":");if(a)return a.variableName&&r.set(a.variableName,decodeURIComponent(o)),a.handle(e.slice(1),t,n,r);const s=this.forks.get("*");return!!s&&(r.set("wildcard",e.join("/")),!!s.handler&&(await s.handler(t,n,r),!0))}}e.TrieRouter=ln,e.RollingValueProvider=class{constructor(e){this.index=0,this.values=e}current(){return this.values[this.index]}next(){return this.index=(this.index+1)%this.values.length,this.values[this.index]}},e.Binary={hexToUint8Array:function(e){(e.startsWith("0x")||e.startsWith("0X"))&&(e=e.slice(2));const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(2*r,2*r+2),16);n[r]=t}return n},uint8ArrayToHex:function(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")},binaryToUint8Array:function(e){const t=Math.ceil(e.length/8),n=new Uint8Array(t);for(let r=0;r<t;r++){const t=parseInt(e.slice(8*r,8*r+8),2);n[r]=t}return n},uint8ArrayToBinary:function(e){return Array.from(e).map(e=>e.toString(2).padStart(8,"0")).join("")},base64ToUint8Array:function(e){return Ee(e,we)},uint8ArrayToBase64:function(e){return xe(e,we)},base32ToUint8Array:function(e){return Ee(e,ve)},uint8ArrayToBase32:function(e){return xe(e,ve)},log2Reduce:ht,partition:vt,concatBytes:dt,numberToUint8:function(e){return new Uint8Array([e])},uint8ToNumber:function(e){return e[0]},numberToUint16:function(e,t){const n=new ArrayBuffer(2);return new DataView(n).setUint16(0,e,"LE"===t),new Uint8Array(n)},uint16ToNumber:function(e,t){return new DataView(e.buffer).getUint16(e.byteOffset,"LE"===t)},numberToUint32:function(e,t){const n=new ArrayBuffer(4);return new DataView(n).setUint32(0,e,"LE"===t),new Uint8Array(n)},uint32ToNumber:function(e,t){return new DataView(e.buffer).getUint32(e.byteOffset,"LE"===t)},numberToUint64:yt,uint64ToNumber:function(e,t){return new DataView(e.buffer).getBigUint64(e.byteOffset,"LE"===t)},numberToUint256:bt,uint256ToNumber:wt,sliceBytes:function(e,t){const n=[];let r=0;for(const o of t)n.push(e.subarray(r,r+o)),r+=o;return n},keccak256:Rt,sha3_256:function(e){return Ot(At(new Array(50).fill(0),Tt(e,6)))},proximity:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++){const n=e[r]^t[r];for(let e=0;e<8;e++)if(n>>7-e&1)return 8*r+e}return 8*Math.min(e.length,t.length)},commonPrefix:function(e,t){const n=Math.min(e.length,t.length);for(let r=0;r<n;r++)if(e[r]!==t[r])return e.subarray(0,r);return e.subarray(0,n)},setBit:function(e,t,n,r){const o=Math.floor(t/8),i=t%8;1===n?e[o]|=1<<("BE"===r?7-i:i):e[o]&=~(1<<("BE"===r?7-i:i))},getBit:function(e,t,n){const r=t%8;return e[Math.floor(t/8)]>>("BE"===n?7-r:r)&1},indexOf:function(e,t,n=0){for(let r=n;r<e.length;r++)for(let n=0;n<t.length&&e[r+n]===t[n];n++)if(n===t.length-1)return r;return-1},equals:function(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},padStart:kt,padStartToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:kt(e,e.length+t-r,n)},padEnd:St,padEndToMultiple:function(e,t,n=0){const r=e.length%t;return 0===r?e:St(e,e.length+t-r,n)},xorCypher:function(e,t){const n=new Uint8Array(e.length);for(let r=0;r<e.length;r++)n[r]=e[r]^t[r%t.length];return n},isUtf8:function(e){for(let t=0;t<e.length;t++){const n=e[t];if(!(n<128))if(192==(224&n)){if(t+1>=e.length||128!=(192&e[t+1]))return!1;t+=1}else if(224==(240&n)){if(t+2>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2]))return!1;t+=2}else{if(240!=(248&n))return!1;if(t+3>=e.length||128!=(192&e[t+1])||128!=(192&e[t+2])||128!=(192&e[t+3]))return!1;t+=3}}return!0}},e.Elliptic={privateKeyToPublicKey:function(e){if(e<=0n||e>=Pt)throw new Error("Invalid private key");return Ut(Ct,Nt,e,It)},compressPublicKey:function(e){const t=e[1]%2n==0n?2:3;return new Uint8Array([t,...bt(e[0],"BE")])},publicKeyFromCompressed:function(e){if(33!==e.length||2!==e[0]&&3!==e[0])throw new Error("Invalid compressed public key");const t=wt(e.slice(1),"BE"),n=Dt($t(t**3n+7n,It),It);if(!n)throw Error("Invalid x: does not correspond to a valid curve point");const r=$t(-n,It),o=n%2n==0n;return[t,2===e[0]?o?n:r:o?r:n]},publicKeyToAddress:function(e){const t=new Uint8Array(20),n=Rt(dt(bt(e[0],"BE"),bt(e[1],"BE")));return t.set(n.subarray(12)),t},signMessage:function(e,t,n){return Ft(wt(Rt(e),"BE"),t,n)},signHash:Ft,verifySignature:function(e,t,n,r){const o=$t(wt(Rt(e),"BE"),Pt),i=zt(r,Pt),a=$t(o*i,Pt),s=$t(n*i,Pt),c=Ut(Ct,Nt,a,It),u=Ut(t[0],t[1],s,It);return n===$t(Vt(c[0],c[1],u[0],u[1],It)[0],Pt)},recoverPublicKey:function(e,t,n,r){const o=Dt($t(t**3n+7n,It),It);if(!o)throw new Error("Invalid r: does not correspond to a valid curve point");const i=o%2n==(27n===r?0n:1n)?o:It-o,a=$t(wt(Rt(e),"BE"),Pt),s=Ut(t,i,n,It),c=Ut(Ct,Nt,a,It),u=Vt(s[0],s[1],c[0],$t(-c[1],It),It);return Ut(u[0],u[1],zt(t,Pt),It)},checksumEncode:function(t){const n=e.Binary.uint8ArrayToHex(t),r=e.Binary.uint8ArrayToHex(e.Binary.keccak256(new Uint8Array([...n].map(e=>e.charCodeAt(0)))));let o="0x";for(let e=0;e<n.length;e++)parseInt(r[e],16)>7?o+=n[e].toUpperCase():o+=n[e];return o}},e.Random={intBetween:a,floatBetween:function(e,t,n=Math.random){return n()*(t-e)+e},chance:c,signed:function(){return 2*Math.random()-1},makeSeededRng:function(e){let t=e,n=3405648695,r=3735928559;return function(){return t+=n,n^=t<<7,t*=r,r^=t<<13,t^=n^r,(t>>>0)/4294967296}},point:function(e,t,n,r=Math.random){let o,i;do{o=a(0,e-1,r),i=a(0,t-1,r)}while(n&&s(n,o,i));return[o,i]},procs:function(e,t=Math.random){const n=Math.floor(e);return c(e-n,t)?n+1:n}},e.Arrays={countUnique:function(e,t,n,r,o){const i=t?e.map(t):e,a={};for(const e of i)a[e]=(a[e]||0)+1;const s=r?st(a,o?(e,t)=>e[1]-t[1]:(e,t)=>t[1]-e[1]):a;return n?Object.keys(s):s},makeUnique:function(e,t){return Object.values(ot(e,t))},splitBySize:function(e,t){const n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n},splitByCount:it,index:ot,indexCollection:function(e,t){const n={};for(const r of e){const e=t(r);n[e]||(n[e]=[]),n[e].push(r)}return n},onlyOrThrow:function(e){if(1===e.length)return e[0];throw Error(`Expected exactly one element, actual: ${e.length}`)},onlyOrNull:function(e){return 1===e.length?e[0]:null},firstOrThrow:function(e){if(!e.length)throw Error("Received empty array");return e[0]},firstOrNull:function(e){return e.length>0?e[0]:null},shuffle:o,initialize:function(e,t){const n=[];for(let r=0;r<e;r++)n.push(t(r));return n},initialize2D:function(e,t,n){const r=[];for(let o=0;o<e;o++){r.push([]);for(let e=0;e<t;e++)r[o].push(n)}return r},rotate2D:function(e){const t=[];for(let n=0;n<e[0].length;n++){t.push([]);for(let r=0;r<e.length;r++)t[n].push(e[r][n])}return t},containsShape:function(e,t,n,r){if(n<0||r<0||r+t[0].length>e[0].length||n+t.length>e.length)return!1;for(let o=0;o<t.length;o++)for(let i=0;i<t[o].length;i++)if(void 0!==t[o][i]&&e[n+o][r+i]!==t[o][i])return!1;return!0},glue:function(e,t){const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<e.length-1&&(w(t)?n.push(t()):n.push(t));return n},pluck:function(e,t){return e.map(e=>e[t])},pick:u,pickMany:function(e,t,n=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);return i(e,t,n).map(t=>e[t])},pickManyUnique:function(e,t,n,r=Math.random){if(t>e.length)throw new Error(`Count (${t}) is greater than array length (${e.length})`);const o=[];for(;o.length<t;){const t=u(e,r);o.some(e=>n(e,t))||o.push(t)}return o},pickWeighted:function(e,t,n){if(void 0===n&&(n=Math.random()),e.length!==t.length)throw new Error("Array length mismatch");let r=t.reduce((e,t)=>e+t,0);const o=n*r;for(let n=0;n<e.length-1;n++)if(r-=t[n],o>=r)return e[n];return l(e)},pickRandomIndices:i,pickGuaranteed:function(t,n,r,i,a,s=Math.random){const c=t.filter(e=>e!==n&&e!==r),u=[];for(null!==n&&u.push(n);c.length&&u.length<i;){const t=e.Random.intBetween(0,c.length-1,s);a(c[t],u)&&u.push(c[t]),c.splice(t,1)}return o(u,s),{values:u,indexOfGuaranteed:null!==n?u.indexOf(n):-1}},last:l,pipe:f,makePipe:function(e,t){return n=>f(n,e,t)},sortWeighted:function(e,t,n=Math.random){const r=t.map(e=>n()*e),o=[];for(let t=0;t<e.length;t++)o.push([e[t],r[t]]);return o.sort((e,t)=>t[1]-e[1]).map(e=>e[0])},pushAll:L,unshiftAll:function(e,t){Array.prototype.unshift.apply(e,t)},filterAndRemove:function(e,t){const n=[];for(let r=e.length-1;r>=0;r--)t(e[r])&&n.push(e.splice(r,1)[0]);return n},merge:function(e,t){const n=Object.keys(t);for(const r of n)Array.isArray(t[r])&&Array.isArray(e[r])&&L(e[r],t[r])},empty:function(e){return e.splice(0,e.length),e},pushToBucket:function(e,t,n){e[t]||(e[t]=[]),e[t].push(n)},unshiftAndLimit:function(e,t,n){for(e.unshift(t);e.length>n;)e.pop()},atRolling:function(e,t){let n=t%e.length;return n<0&&(n+=e.length),e[n]},group:ct,createOscillator:function(e){let t=0;return{next:()=>e[t++%e.length]}},organiseWithLimits:function(e,t,n,r,o){const i={};for(const e of Object.keys(t))i[e]=[];i[r]=[],o&&(e=e.sort(o));for(const o of e){const e=o[n],a=t[e]?e:r;i[a].length>=t[a]?i[r].push(o):i[a].push(o)}return i},tickPlaybook:function(e){if(0===e.length)return null;const t=e[0];return t.ttlMax?--t.ttl<=0&&e.shift():t.ttlMax=t.ttl,{progress:(t.ttlMax-t.ttl)/t.ttlMax,data:t.data}},getArgument:Ht,getBooleanArgument:function(e,t,n,r){const o=e.some(e=>e.endsWith("-"+t)),i=Ht(e,t,n,r);if(!i&&o)return!0;if(!i&&!o)return null;if(["true","1","yes","y","on"].includes(i.toLowerCase()))return!0;if(["false","0","no","n","off"].includes(i.toLowerCase()))return!1;throw Error(`Invalid boolean argument ${t}: ${i}`)},getNumberArgument:function(e,t,n,r){const o=Ht(e,t,n,r);if(!o)return null;try{return et(o)}catch{throw new Error(`Invalid number argument ${t}: ${o}`)}},requireStringArgument:Zt,requireNumberArgument:function(e,t,n,r){const o=Zt(e,t,n,r);try{return et(o)}catch{throw new Error(`Invalid argument ${t}: ${o}`)}},bringToFront:function(e,t){const n=[...e];return Wt(n,t),n},bringToFrontInPlace:Wt,findInstance:function(e,t){const n=e.find(e=>e instanceof t);return lt.of(n)},filterInstances:function(e,t){return e.filter(e=>e instanceof t)},interleave:function(e,t){const n=[],r=Math.max(e.length,t.length);for(let o=0;o<r;o++)e[o]&&n.push(e[o]),t[o]&&n.push(t[o]);return n},toggle:function(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]},createHierarchy:function(e,t,n,r,o=!1){const i=new Map,a=[];e.forEach(e=>{const n=new ft(e);i.set(e[t],n)}),e.forEach(e=>{const r=i.get(e[t]);if(!r)return;const o=e[n];if(o){const e=i.get(o);e&&e.children.push(r)}else a.push(r)});const s=e=>{e.children.sort((e,t)=>{const n=e.value[r],i=t.value[r];return o?i-n:n-i}),e.children.forEach(s)};return a.forEach(s),a},multicall:function(e){return()=>e.forEach(e=>e())},maxBy:function(e,t){return e.reduce((e,n)=>t(e)>t(n)?e:n)}},e.System={sleepMillis:r,forever:async function(e,t,n){for(;;){try{await e()}catch(e){n&&n("Error in forever",e)}await r(t)}},scheduleMany:function(e,t){for(let n=0;n<e.length;n++){const r=e[n],o=t[n],i=Math.max(0,o.getTime()-Date.now());setTimeout(r,i)}},waitFor:async function(e,t){let n=t.requiredConsecutivePasses||1,o=0;for(let i=0;i<t.attempts;i++){try{if(await e()){if(o++,o>=n)return}else o=0}catch{o=0}i<t.attempts-1&&await r(t.waitMillis)}throw Error("Timed out waiting for predicate")},expandError:function(e,t){if(v(e))return e;const n=Object.keys(e);e.message&&!n.includes("message")&&n.push("message");const r=n.map(t=>`${t}: ${e[t]}`).join("; ");return t&&e.stack?r+"\n"+e.stack:r},runAndSetInterval:function(e,t){e();const n=setInterval(()=>{e()},t);return()=>clearInterval(n)},whereAmI:function(){const e=globalThis.process;return e?!0===e.browser?"browser":"node":"browser"},withRetries:async function(e,t,n,o,i,a){let s=null;for(let c=0;c<=t;c++)try{return await e()}catch(e){if(s=e,c===t)break;const u=n+c/(t-1)*(o-n);i&&i("Error in withRetries, retrying",{attempt:c+1,allowedFailures:t,delayMillis:u,error:e}),a&&a(),await r(u)}throw s}},e.Numbers={make:et,sum:function(e){return e.reduce((e,t)=>e+t,0)},average:function(e){return e.reduce((e,t)=>e+t,0)/e.length},median:function(e){const t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==0?(t[n]+t[n-1])/2:t[n]},getDistanceFromMidpoint:function(e,t){return e-(t-1)/2},clamp:tt,range:G,interpolate:function(e,t,n){return e+(t-e)*n},createSequence:function(){let e=0;return{next:()=>e++}},increment:function(e,t,n){const r=e+t;return r>n?n:r},decrement:function(e,t,n){const r=e-t;return r<n?n:r},format:function(e,t){const n=t?.longForm??!1,r=t?.unit?` ${t.unit}`:"",o=n?Ye:Qe,i=t?.precision??1;if(e<Xe[0])return`${e}${r}`;for(let t=0;t<Xe.length-1;t++)if(e<Xe[t+1])return`${(e/Xe[t]).toFixed(i)}${n?" ":""}${o[t]}${r}`;return`${(e/Xe[Xe.length-1]).toFixed(i)}${n?" ":""}${o[Xe.length-1]}${r}`},fromDecimals:function(e,t,n){let r=e.length-t;if(r<=0)return"0."+"0".repeat(-r)+e+(n?" "+n:"");let o=e.substring(0,r);return""===o&&(o="0"),o+"."+e.substring(r)+(n?" "+n:"")},makeStorage:function(e,t=1024){const n=parseFloat(e);if(isNaN(n))throw Error("makeStorage got NaN for input");const r=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),o=""===r?0:Le[r];if(null==o)throw Error(`Unknown unit: "${r}"`);return Math.ceil(n*t**o)},asMegabytes:function(e){return e/1024/1024},convertBytes:function(e,t=1024){return e>=t*t*t*t?(e/t/t/t/t).toFixed(3)+" TB":e>=t*t*t?(e/t/t/t).toFixed(3)+" GB":e>=t*t?(e/t/t).toFixed(3)+" MB":e>=t?(e/t).toFixed(3)+" KB":e+" B"},hexToRgb:function(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e.toLowerCase());if(!t)throw new Error("Invalid hex color: "+e);return[parseInt(t[1],16),parseInt(t[2],16),parseInt(t[3],16)]},rgbToHex:function(e){return"#"+e.map(e=>e.toString(16).padStart(2,"0")).join("")},haversineDistanceToMeters:function(e,t,n,r){const o=e*Math.PI/180,i=n*Math.PI/180,a=(n-e)*Math.PI/180,s=(r-t)*Math.PI/180,c=Math.sin(a/2)*Math.sin(a/2)+Math.cos(o)*Math.cos(i)*Math.sin(s/2)*Math.sin(s/2);return 2*Math.atan2(Math.sqrt(c),Math.sqrt(1-c))*6371e3},roundToNearest:p,formatDistance:function(e){return e>1e3?(e/1e3).toFixed(0)+" km":e>=500?p(e,100)+" m":e>=100?p(e,50)+" m":p(e,10)+" m"},triangularNumber:function(e){return e*(e+1)/2},searchFloat:function(e){const t=e.match(/-?\d+(\.\d+)?/);if(!t)throw Error("No float found in "+e);return parseFloat(t[0])},binomialSample:function(e,t,n=Math.random){const r=e*t,o=Math.sqrt(e*t*(1-t)),i=(n()+n()+n()+n()+n()+n()-3)*Math.SQRT2,a=Math.round(r+o*i);return Math.max(0,Math.min(e,a))},toSignificantDigits:function(e,t){if(!e.includes("."))return e;if(0===parseFloat(e))return"0";const[n,r]=e.split("."),o=n.replace("-",""),i=o.length;if(i>=t)return n;if("0"!==o){const e=t-i,o=r.slice(0,e);return/[1-9]/.test(o)?`${n}.${o.replace(/0+$/,"")}`:n}const a=t+(r.match(/^0*/)?.[0].length??0);return`${n}.${r.slice(0,a)}`}},e.Promises={raceFulfilled:async function(e){return n(Promise.all(e.map(n)))},invert:n,runInParallelBatches:async function(e,t=1){const n=it(e,t),r=[],o=n.map(async e=>{for(const t of e)r.push(await t())});return await Promise.all(o),r}},e.Dates={getTimestamp:function(e,t){const n=new Date(t?.now||Date.now()),r=t?.labels||Pe,o=B(e)?e:new Date(e);if(Ie(n)===Ie(o))return r.today(o.getUTCHours(),o.getUTCMinutes(),o.getUTCHours()>12);if(Ie(n)-Ie(o)===1)return r.yesterday();const i=Me(o);return Ie(n)-Ie(o)<7?r[i.day]():r.weeks(Math.round((n.getTime()-o.getTime())/6048e5))},getTimeDelta:Ne,secondsToHumanTime:function(e,t=Ce){return Ne(0,{now:1e3*e,labels:t})},countCycles:function(e,t,n){const r=(n?.now??Date.now())-e;return{cycles:Math.floor(r/t),remaining:t/(n?.precision??1)-Math.ceil(r%t/(n?.precision??1))}},isoDate:function(e){return(e||new Date).toISOString().slice(0,10)},throttle:function(e,t){return(!_e[e]||Date.now()>_e[e])&&(_e[e]=Date.now()+t,!0)},timeSince:function(e,t,n){return t=B(t)?t.getTime():t,((n=n?B(n)?n.getTime():n:Date.now())-t)/Ve[e]},dateTimeSlug:function(e){return(e||new Date).toISOString().slice(0,19).replace(/T|:/g,"-")},unixTimestamp:function(e){return Math.ceil((e||Date.now())/1e3)},fromUtcString:function(e){const t=new Date(e);return new Date(t.getTime()-6e4*t.getTimezoneOffset())},fromMillis:function(e){return new Date(e)},getProgress:function(e,t,n,r){r||(r=Date.now());const o=r-e,i=o/t,a=i*n;return{deltaMs:o,progress:t/n,baseTimeMs:i,totalTimeMs:a,remainingTimeMs:a-o}},humanizeTime:De,humanizeProgress:function(e){return`[${Math.floor(100*e.progress)}%] ${De(e.deltaMs)} out of ${De(e.totalTimeMs)} (${De(e.remainingTimeMs)} left) [${Math.round(e.baseTimeMs)} ms each]`},createTimeDigits:ze,mapDayNumber:Fe,getDayInfoFromDate:Me,getDayInfoFromDateTimeString:function(e){return Me(new Date(e))},seconds:function(e){return 1e3*e},minutes:function(e){return 6e4*e},hours:function(e){return 36e5*e},days:function(e){return 864e5*e},make:function(e){const t=parseFloat(e);if(isNaN(t))throw Error("makeDate got NaN for input");const n=e.replace(/^-?[0-9.]+/,"").trim().toLowerCase(),r=""===n?1:je[n];if(!r)throw Error(`Unknown unit: "${n}"`);return Math.ceil(t*r)},normalizeTime:function(e){let[t,n]=e.split(":");E(parseInt(t,10))||(t="0"),E(parseInt(n,10))||(n="0");let r=tt(_(t),0,23),o=tt(_(n),0,59);return`${ze(r)}:${ze(o)}`},absoluteDays:Ie},e.Objects={safeParse:function(e){try{return JSON.parse(e)}catch{return null}},deleteDeep:function(e,t){const n=J(t,"."),r=X(t,".");if(!n||!r)return;const o=h(e,n);o&&delete o[r]},getDeep:h,setDeep:d,incrementDeep:function(e,t,n=1){const r=h(e,t)||0;return d(e,t,r+n),r},ensureDeep:function(e,t,n){return h(e,t)||d(e,t,n)},replaceDeep:function(e,t,n){const r=h(e,t);if(!r)throw new Error("Key '"+t+"' does not exist.");return d(e,t,n),r},getFirstDeep:function(e,t,n){for(const n of t){const t=h(e,n);if(t)return t}if(n){const t=Object.values(e);if(t.length)return t[0]}return null},deepMergeInPlace:M,deepMerge2:function(e,t){const n={};return M(n,e),M(n,t),n},deepMerge3:function(e,t,n){const r={};return M(r,e),M(r,t),M(r,n),r},mapAllAsync:async function(e,t){const n=[];for(const r of e)n.push(await t(r));return n},cloneWithJson:function(e){return JSON.parse(JSON.stringify(e))},sortObject:He,sortArray:Ze,sortAny:We,deepEquals:Ke,deepEqualsEvery:function(...e){for(let t=1;t<e.length;t++)if(!Ke(e[t-1],e[t]))return!1;return!0},runOn:function(e,t){return t(e),e},ifPresent:function(e,t){e&&t(e)},zip:j,zipSum:function(e){return j(e,(e,t)=>e+t)},removeEmptyArrays:function(e){for(const t of Object.keys(e))(y(e[t])||Array.isArray(e[t])&&e[t].every(e=>null==e))&&delete e[t];return e},removeEmptyValues:function(e){for(const t of Object.entries(e))(null===t[1]||void 0===t[1]||v(t[1])&&T(t[1]))&&delete e[t[0]];return e},flatten:function(e,t=!1,n){return rt({},e,n||"",!1,t)},unflatten:function e(t){if(!m(t))return t;const n=Array.isArray(t)?[]:{};for(const[r,o]of Object.entries(t))Array.isArray(o)?d(n,r,o.map(t=>e(t))):d(n,r,o);return n},match:function(e,t,n){return t[e]?t[e]:n},sort:st,map:function(e,t){const n={};for(const r of Object.entries(e))n[r[0]]=t(r[1]);return n},mapIterable:function(e,t){const n=[];let r=0;for(const o of e)n.push(t(o,r++));return n},filterKeys:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(r)&&(n[r]=o);return n},filterValues:function(e,t){const n={};for(const[r,o]of Object.entries(e))t(o)&&(n[r]=o);return n},rethrow:async function(e,t){try{return await e()}catch{throw t}},setSomeOnObject:function(e,t,n){null!=n&&(e[t]=n)},setSomeDeep:function(e,t,n,r){const o=h(n,r);null!=o&&d(e,t,o)},flip:function(e){const t={};for(const[n,r]of Object.entries(e))t[r]=n;return t},getAllPermutations:function(e){const t=Object.keys(e),n=t.map(t=>e[t].length),r=n.reduce((e,t)=>e*t);let o=1;const i=[1];for(let e=0;e<n.length-1;e++)o*=n[e],i.push(o);const a=[];for(let n=0;n<r;n++){const r={};for(let o=0;o<t.length;o++){const a=e[t[o]],s=Math.floor(n/i[o])%a.length;r[t[o]]=a[s]}a.push(r)}return a},countTruthyValues:function(e){return Object.values(e).filter(e=>e).length},transformToArray:function(e){const t=[],n=Object.keys(e),r=e[n[0]].length;for(let o=0;o<r;o++){const r={};for(const t of n)r[t]=e[t][o];t.push(r)}return t},setMulti:function(e,t,n){for(const r of e)r[t]=n},incrementMulti:function(e,t,n=1){for(const r of e)r[t]+=n},createBidirectionalMap:function(){return{map:new Map,keys:[]}},createTemporalBidirectionalMap:function(){return{map:new Map,keys:[]}},pushToBidirectionalMap:ut,unshiftToBidirectionalMap:function(e,t,n,r=100){if(e.map.has(t)){const n=e.keys.indexOf(t);e.keys.splice(n,1)}if(e.map.set(t,n),e.keys.unshift(t),e.keys.length>r){const t=e.keys.shift();t&&e.map.delete(t)}},addToTemporalBidirectionalMap:function(e,t,n,r,o=100){ut(e,t,{validUntil:Date.now()+r,data:n},o)},getFromTemporalBidirectionalMap:function(e,t){const n=e.map.get(t);return n&&n.validUntil>Date.now()?n.data:null},createStatefulToggle:function(e){let t;return n=>{const r=n===e&&t!==e;return t=n,r}},diffKeys:function(e,t){const n=Object.keys(e),r=Object.keys(t);return{uniqueToA:n.filter(e=>!r.includes(e)),uniqueToB:r.filter(e=>!n.includes(e))}},pickRandomKey:Je,mapRandomKey:function(e,t){const n=Je(e);return e[n]=t(e[n]),n},fromObjectString:function(e){return e=(e=(e=(e=(e=(e=(e=(e=(e=(e=(e=e.replace(/\r\n/g,"\n")).replace(/(\w+)\((.+)\)/g,(e,t,n)=>`${t}(${n.replaceAll(",","&comma;")})`)).replace(/(,)(\s+})/g,"$2")).replace(/\.\.\..+?,/g,"")).replace(/({\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/(,\s+)([a-zA-Z]\w+),/g,"$1$2: '$2',")).replace(/:(.+)\?(.+):/g,(e,t,n)=>`: (${t.trim()} && ${n.trim()}) ||`)).replace(/([a-zA-Z0-9]+)( ?: ?{)/g,'"$1"$2')).replace(/([a-zA-Z0-9]+) ?: ?(.+?)(,|\n|})/g,(e,t,n,r)=>`"${t}":"${n.trim()}"${r}`)).replace(/("'|'")/g,'"')).replaceAll("&comma;",","),JSON.parse(e)},toQueryString:$e,parseQueryString:function(e){const t={},n=e.split("&");for(const e of n){const[n,r]=e.split("=");n&&r&&(t[n]=decodeURIComponent(r))}return t},hasKey:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},selectMax:function(e,t){let n=null,r=-1/0;for(const[o,i]of Object.entries(e)){const e=t(i);e>r&&(r=e,n=o)}return n?[n,e[n]]:null},reposition:function(e,t,n,r){const o=e.find(e=>e[t]===n),i=e.find(e=>e[t]===n+r);o&&i?(o[t]=n+r,i[t]=n):o&&(o[t]=n+r),e.sort((e,n)=>N(e[t])-N(n[t])),e.forEach((e,n)=>e[t]=n+1)},unwrapSingleKey:function(e){const t=Object.keys(e);if(1===t.length)return e[t[0]];throw new Error("Expected object to have a single key")},parseKeyValues:function(e,t=":"){return Object.fromEntries(e.map(e=>Y(e,t)).map(e=>e[0]&&e[1]?[ne(e[0]),ne(e[1])]:null).filter(e=>e))},errorMatches:function(e,t){if(!e)return!1;const n=e.message;return"string"==typeof n&&n.includes(t)}},e.Types={isFunction:w,isObject:m,isStrictlyObject:g,isEmptyArray:y,isEmptyObject:function(e){return g(e)&&0===Object.keys(e).length},isUndefined:b,isString:v,isNumber:E,isBoolean:x,isDate:B,isBlank:T,isId:A,isIntegerString:O,isHexString:R,isUrl:U,isNullable:function(e,t){return null==t||e(t)},asString:P,asHexString:function(e,t){if(!R(e))throw new TypeError(`Expected hex string${t?.name?` for ${t.name}`:""}, got: `+e);if(t?.strictPrefix&&!e.startsWith("0x"))throw new TypeError(`Expected hex string with 0x prefix${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.replace(/^0x/,"");if(n.length%2!=0&&!t?.uneven)throw RangeError(`Expected even number of hex digits${t?.name?` for ${t.name}`:""}; got: `+e);if(t&&t.byteLength&&n.length!==2*t.byteLength)throw RangeError(`Expected hex string${t?.name?` for ${t.name}`:""} of byte length ${t.byteLength}; got: `+n);return`0x${n}`},asSafeString:function(e,t){if(!P(e,t).split("").every(e=>"_"===e||se(e)))throw new TypeError(`Expected safe string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asIntegerString:function(e,t){if(!O(e))throw new TypeError(`Expected integer string${t?.name?` for ${t.name}`:""}, got: `+e);const n=BigInt(e);if(t&&(t.min&&n<t.min||t.max&&n>t.max))throw RangeError(`Expected integer string${t?.name?` for ${t.name}`:""} in range: ${t.min??"-inf"}..${t.max??"inf"}; got: `+n);return e},asNumber:N,asFunction:function(e,t){if(!w(e))throw new TypeError(`Expected function${t?.name?` for ${t.name}`:""}, got: `+e);return e},asInteger:_,asBoolean:function(e,t){if("true"===e)return!0;if("false"===e)return!1;if(!x(e))throw new TypeError(`Expected boolean${t?.name?` for ${t.name}`:""}, got: `+e);return e},asDate:function(e,t){if(!B(e))throw new TypeError(`Expected date${t?.name?` for ${t.name}`:""}, got: `+e);return e},asNullableString:function(e){return T(e)?null:e},asEmptiableString:function(e,t){if(!v(e))throw new TypeError(`Expected string${t?.name?` for ${t.name}`:""}, got: `+e);return e},asId:function(e,t){if(A(e))return e;const n=parseInt(e,10);if(!A(n))throw new TypeError(`Expected id${t?.name?` for ${t.name}`:""}, got: `+e);return n},asTime:function(e,t){if(!v(e))throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const n=e.split(":");if(2!==n.length)throw new TypeError(`Expected time${t?.name?` for ${t.name}`:""}, got: `+e);const r=parseInt(n[0],10),o=parseInt(n[1],10);if(!E(r)||!E(o)||r<0||r>23||o<0||o>59)throw new TypeError(`Expected time, got${t?.name?` for ${t.name}`:""}: `+e);return`${String(r).padStart(2,"0")}:${String(o).padStart(2,"0")}`},asArray:function(e,t){if(!Array.isArray(e))throw new TypeError(`Expected array${t?.name?` for ${t.name}`:""}, got: `+e);return e},asObject:V,asNullableObject:function(e,t){return null===e?null:V(e,t)},asStringMap:function(e,t){const n=V(e,t);for(const r of Object.keys(n))if(!v(n[r]))throw new TypeError(`Expected string map${t?.name?` for ${t.name}`:""}, got: `+e);return n},asNumericDictionary:function(e,t){const n=V(e),r=Object.keys(n),o=Object.values(n);if(!r.every(v)||!o.every(E))throw new TypeError(`Expected numeric dictionary${t?.name?` for ${t.name}`:""}, got: `+e);return n},asUrl:function(e,t){if(!U(e))throw new TypeError(`Expected url${t?.name?` for ${t.name}`:""}, got: `+e);return e},asEmptiable:function(e,t){return""===t?void 0:e(t)},asNullable:function(e,t){return null==t?null:e(t)},asOptional:function(e,t){return null==t?void 0:e(t)},enforceObjectShape:F,enforceArrayShape:function(e,t){return e.every(e=>F(e,t))},isPng:pt,isJpg:mt,isWebp:gt,isImage:function(e){return pt(e)||mt(e)||gt(e)}},e.Strings={tokenizeByCount:function(e,t){return at(e,Math.ceil(e.length/t))},tokenizeByLength:at,searchHex:function(e,t){const n=new RegExp(`[0-9a-f]{${t}}`,"i"),r=e.match(n);return r?r[0]:null},searchSubstring:function(e,t,n=k){const r=Q(e,n);for(const e of r)if(t(e))return e;return null},randomHex:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=I[Math.floor(16*t())];return n},randomLetter:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=S[Math.floor(26*t())];return n},randomAlphanumeric:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=$[Math.floor(62*t())];return n},randomRichAscii:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=z[Math.floor(89*t())];return n},randomUnicode:function(e,t=Math.random){let n="";for(let r=0;r<e;r++)n+=D[Math.floor(t()*D.length)];return n},includesAny:function(e,t){return t.some(t=>e.includes(t))},slugify:q,normalForm:function(e){return q(e).replaceAll("-","")},enumify:function(e){return q(e).replace(/-/g,"_").toUpperCase()},escapeHtml:function(e){return e.replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},decodeHtmlEntities:function(e){let t=e.replace(/&#(\d+);/g,(e,t)=>String.fromCharCode(t)).replace(/&#x(\d+);/g,(e,t)=>String.fromCharCode(parseInt(t,16)));for(const[e,n]of Object.entries(Z))t=t.replaceAll(e,n);return t},after:K,afterLast:X,before:W,beforeLast:J,betweenWide:function(e,t,n){const r=J(e,n);return r?K(r,t):null},betweenNarrow:function(e,t,n){const r=K(e,t);return r?W(r,n):null},getPreLine:function(e){return e.replace(/ +/g," ").replace(/^ /gm,"")},containsWord:Oe,containsWords:function(e,t,n){return"any"===n?t.some(t=>Oe(e,t)):t.every(t=>Oe(e,t))},joinUrl:qe,getFuzzyMatchScore:H,sortByFuzzyScore:function(e,t){return e.filter(e=>H(e,t)).sort((e,n)=>H(n,t)-H(e,t))},splitOnce:Y,splitAll:Q,randomize:function(e,t=Math.random){return e.replace(/\{(.+?)\}/g,(e,n)=>u(n.split("|"),t))},expand:function e(t){const n=t.match(/\{(.+?)\}/);if(!n||!n.index)return[t];const r=n[1].split(","),o=t.slice(0,n.index),i=t.slice(n.index+n[0].length);let a=[];for(const t of r){const n=e(o+t+i);a=a.concat(n)}return a},shrinkTrim:ne,capitalize:re,decapitalize:oe,csvEscape:function(e){return e.match(/"|,/)?`"${e.replace(/"/g,'""')}"`:e},parseCsv:function(e,t=",",n='"'){const r=[];let o="",i=!1;const a=e.split("");for(const e of a)e!==t||i?e!==n||(o||i)&&!i?o+=e:i=!i:(r.push(o),o="");return r.push(o),r},surroundInOut:function(e,t){return t+e.split("").join(t)+t},getExtension:ee,getBasename:te,normalizeEmail:function(e){let[t,n]=e.split("@");t=ne(t.replaceAll(".","").toLowerCase()).replaceAll(" ","");const[r]=t.split("+");if(!r||!n||-1===n.indexOf(".")||n.indexOf(".")===n.length-1)throw new Error("Invalid email");return n=ne(n.toLowerCase()).replaceAll(" ",""),`${r}@${n}`},normalizeFilename:function(e){const t=te(e),n=ee(e);return n?`${t}.${n}`:t},parseFilename:function(e){const t=te(e),n=ee(e);return{basename:t,extension:n,filename:n?`${t}.${n}`:t}},camelToTitle:function(e){return re(e.replace(/([A-Z])/g," $1"))},slugToTitle:function(e){return e.split("-").map(re).join(" ")},slugToCamel:function(e){return oe(e.split("-").map(re).join(""))},joinHumanly:function(e,t=", ",n=" and "){return e&&e.length?1===e.length?e[0]:2===e.length?`${e[0]}${n}${e[1]}`:`${e.slice(0,e.length-1).join(t)}${n}${e[e.length-1]}`:""},findWeightedPair:ye,extractBlock:be,extractAllBlocks:function(e,t){const n=[];let r=t.wordBoundary?de(e,[`${t.opening} `,`${t.opening}\n`],t.start||0):e.indexOf(t.opening,t.start||0);for(;;){if(-1===r)return n;const o=be(e,{...t,start:r});if(!o)return n;n.push(o),r=t.wordBoundary?de(e,[`${t.opening} `,`${t.opening}\n`],r+o.length):e.indexOf(t.opening,r+o.length)}},replaceBlocks:function(t,n,r){let o=0;for(;;){const i=e.Strings.extractBlock(t,{...r,start:o});if(!i)return t;const a=n(i);o=t.indexOf(i,o)+a.length,t=t.replace(i,a)}},indexOfEarliest:de,lastIndexOfBefore:ge,parseHtmlAttributes:function(e){const t={},n=e.match(/([a-z\-]+)="([^"]+)"/g);if(n)for(const e of n){const[n,r]=Y(e,"=");t[n]=r.slice(1,r.length-1)}return t},readNextWord:Re,readWordsAfterAll:function(e,t,n=[]){const r=he(e,t),o=[];for(const i of r)o.push(Re(e,i+t.length,n));return o},resolveVariables:function(e,t,n="$",r=":"){for(const o in t)e=ke(e,o,t[o],n,r);return e=Se(e)},resolveVariableWithDefaultSyntax:ke,resolveRemainingVariablesWithDefaults:Se,isLetter:ie,isDigit:ae,isLetterOrDigit:se,isValidObjectPathCharacter:function(e){return se(e)||"."===e||"["===e||"]"===e||"_"===e},insert:function(e,t,n,r,o){return e.slice(0,t)+r+e.slice(t,t+n)+o+e.slice(t+n)},indexOfRegex:le,allIndexOf:he,lineMatches:fe,linesMatchInOrder:function(e,t,n=!0){let r=0;for(const o of t){let t=!1;for(;!t&&r<e.length;)fe(e[r],o,n)&&(t=!0),r++;if(!t)return!1}return!0},represent:function e(t,n="json",r=0){if(t&&w(t.represent)){const e=t.represent();if(v(e))return"json"===n&&0===r?JSON.stringify(e):e}if(m(t,!1)){if(r>1)return"[object Object]";if("json"===n){if(Array.isArray(t)){const n=t.map(t=>e(t,"json",r+1));return 0===r?JSON.stringify(n):n}const n={};t.message&&(n.message=e(t.message,"json",r+1));for(const[o,i]of Object.entries(t))n[o]=e(i,"json",r+1);return 0===r?JSON.stringify(n):n}if("key-value"===n){const n=Object.keys(t);return t.message&&!n.includes("message")&&n.unshift("message"),n.map(n=>`${n}=${JSON.stringify(e(t[n],"json",r+1))}`).join(" ")}}return b(t)&&(t="undefined"),0===r?JSON.stringify(t):t},resolveMarkdownLinks:function(e,t){let n=e.indexOf("](");for(;-1!==n;){const r=ge(e,"[",n),o=e.indexOf(")",n);if(-1!==r&&-1!==o){const[n,i]=e.slice(r+1,o).split("]("),a=t(n,i);e=e.slice(0,r)+a+e.slice(o+1)}n=e.indexOf("](",n+1)}return e},buildUrl:function(e,t,n){return qe([e,t])+$e(n||{})},isChinese:function(e){return/^[\u4E00-\u9FA5]+$/.test(e)},replaceBetweenStrings:function(e,t,n,r,o=!0){const i=e.indexOf(t),a=e.indexOf(n,i+t.length);if(-1===i||-1===a)throw Error("Start or end not found");return o?e.substring(0,i+t.length)+r+e.substring(a):e.substring(0,i)+r+e.substring(a+n.length)},describeMarkdown:function(e){let t="p";return e.startsWith("#")?(t="h1",e=e.slice(1).trim()):e.startsWith("-")&&(t="li",e=e.slice(1).trim()),{type:t,isCapitalized:e[0]===e[0].toUpperCase(),hasPunctuation:/[.?!]$/.test(e),endsWithColon:/:$/.test(e)}},isBalanced:function(e,t="(",n=")"){let r=0,o=0;for(;o<e.length;)if(e.startsWith(t,o)?(r++,o+=t.length):e.startsWith(n,o)?(r--,o+=n.length):o++,r<0)return!1;return t===n?r%2==0:0===r},textToFormat:function(e){let t=(e=e.normalize("NFD").replace(/[\u0300-\u036f]/g,"")).length;for(;(e=e.replace(/(\w+)[\s,']+\w+/g,"$1")).length!==t;)t=e.length;return e=(e=(e=e.replaceAll(/[A-Z][a-zA-Z0-9]*/g,"A")).replaceAll(/[a-z][a-zA-Z0-9]*/g,"a")).replaceAll(/[\u4E00-\u9FA5]+/g,"Z")},splitFormatting:function(e,t){const n=[];let r=0;for(;r<e.length;){const o=e.indexOf(t,r);if(-1===o){n.push({string:e.slice(r),symbol:null});break}const i=e.indexOf(t,o+t.length);if(o>r&&-1!==i&&n.push({string:e.slice(r,o),symbol:null}),-1===i){n.push({string:e.slice(r),symbol:null});break}n.push({string:e.slice(o+t.length,i),symbol:t}),r=i+t.length}return n},splitHashtags:function(e){const t=[];let n=0;for(;n<e.length;){const r=me(e,n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=pe(e,r+1);if(-1===o){t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1),symbol:"#"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r+1,o),symbol:"#"}),n=o}return t},splitUrls:function(e){const t=[];let n=0;for(;n<e.length;){const r=de(e,["http://","https://"],n);if(-1===r){t.push({string:e.slice(n),symbol:null});break}const o=de(e,[" ","\n"],r);if(-1===o){r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r),symbol:"http"});break}r>n&&t.push({string:e.slice(n,r),symbol:null}),t.push({string:e.slice(r,o),symbol:"http"}),n=o}return t},route:function(e,t){const n=e.split("/").filter(e=>e),r=t.split("/").filter(e=>e);if(n.length!==r.length)return null;const o={};for(let e=0;e<n.length;e++){const t=n[e];if(t.startsWith(":"))o[t.slice(1)]=r[e];else if(t!==r[e])return null}return o},explodeReplace:Be,generateVariants:function(t,n,r,o=Math.random){const i=e.Arrays.shuffle(n.map(t=>({variants:e.Arrays.shuffle(t.variants.map(e=>e),o),avoid:t.avoid})),o),a=[];for(const e of i){const n=e.variants.filter(t=>t!==e.avoid),o=n.find(e=>t.includes(e));if(o&&(L(a,Be(t,o,n)),a.length>=r))break}if(a.length<r)for(const e of i){const n=e.variants.find(e=>t.includes(e));if(n&&(L(a,Be(t,n,e.variants)),a.length>=r))break}return a.slice(0,r)},replaceWord:function(e,t,n,r=!1){const o=new RegExp(r?`(?<=\\s|^)${t}(?=\\s|$)`:`\\b${t}\\b`,"g");return e.replace(o,n)},replacePascalCaseWords:function(e,t){return e.replace(/\b[A-Z][a-zA-Z0-9]*\b/g,e=>e.toUpperCase()===e?e:t(e))},stripHtml:function(e){return e.replace(/<[^>]*>/g,"")},breakLine:Te,measureTextWidth:function(e,t={}){return[...e].reduce((e,n)=>e+(t[n]||1),0)},toLines:function(e,t,n={}){const r=[];let o="",i=0;for(let a=0;a<e.length;a++){const s=e[a];if(o+=s,i+=n[s]||1,i>t){const{line:e,rest:t}=Te(o);r.push(e),o=t,i=t.split("").map(e=>n[e]||1).reduce((e,t)=>e+t,0)}}return o&&r.push(o),r},levenshteinDistance:function(e,t){const n=[];for(let t=0;t<=e.length;t++)n[t]=[t];for(let e=0;e<=t.length;e++)n[0][e]=e;for(let r=1;r<=e.length;r++)for(let o=1;o<=t.length;o++){const i=e[r-1]===t[o-1]?0:1;n[r][o]=Math.min(n[r-1][o]+1,n[r][o-1]+1,n[r-1][o-1]+i)}return n[e.length][t.length]},findCommonPrefix:Ae,findCommonDirectory:function(e){const t=Ae(e),n=t.lastIndexOf("/");return-1===n?"":t.slice(0,n+1)}},e.Assertions={asEqual:function(e,t){if(e!==t)throw Error(`Expected [${e}] to equal [${t}]`);return[e,t]},asTrue:function(e){if(!0!==e)throw Error(`Expected [true], got: [${e}]`);return e},asTruthy:function(e){if(!e)throw Error(`Expected truthy value, got: [${e}]`);return e},asFalse:function(e){if(!1!==e)throw Error(`Expected [false], got: [${e}]`);return e},asFalsy:function(e){if(e)throw Error(`Expected falsy value, got: [${e}]`);return e},asEither:function(e,t){if(!t.includes(e))throw Error(`Expected any of [${t.join(", ")}], got: [${e}]`);return e}},e.Cache={get:async function(e,t,n){const r=Date.now(),o=Ge.get(e);if(o&&o.validUntil>r)return o.value;const i=await n(),a=r+t;return Ge.set(e,{value:i,validUntil:a}),i},delete:function(e){Ge.delete(e)},deleteExpired:function(){const e=Date.now();for(const[t,n]of Ge.entries())n.validUntil<=e&&Ge.delete(t)},size:function(){return Ge.size}},e.Vector={addPoint:Kt,subtractPoint:function(e,t){return{x:e.x-t.x,y:e.y-t.y}},multiplyPoint:Jt,normalizePoint:function(e){const t=Math.sqrt(e.x*e.x+e.y*e.y);return{x:e.x/t,y:e.y/t}},pushPoint:Xt,filterCoordinates:Qt,findCorners:function(e,t,n,r){const o=[{x:0,y:0},{x:n,y:0},{x:0,y:r},{x:n,y:r}];for(let t=0;t<e.length;t++)for(let n=0;n<e[0].length;n++){const r=on(e,t,n);for(const e of r)o.some(t=>t.x===e.x&&t.y===e.y)||o.push(e)}return o.map(e=>({x:e.x*t,y:e.y*t}))},findLines:function(e,t){const n=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t][n+1],"row-first").map(e=>({...e,dx:1,dy:0})),r=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t][n-1],"row-first").map(e=>({...e,dx:1,dy:0})),o=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t-1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1})),i=Qt(e,(t,n)=>0===e[t][n]&&0!==e[t+1]?.[n],"column-first").map(e=>({...e,dx:0,dy:1}));return n.forEach(e=>e.y++),i.forEach(e=>e.x++),[...ct([...o,...i],(e,t)=>e.x===t.x&&e.y-1===t.y),...ct([...r,...n],(e,t)=>e.y===t.y&&e.x-1===t.x)].map(e=>({start:e[0],end:l(e)})).map(e=>({start:Jt(e.start,t),end:Jt(Kt(e.end,{x:e.start.dx,y:e.start.dy}),t)}))},raycast:cn,raycastCircle:function(e,t,n){const r=an(e,n),o=[];for(const n of r){const r=cn(e,t,n-.001),i=cn(e,t,n+.001);r&&o.push(r),i&&o.push(i)}return o},getLineIntersectionPoint:sn}}(Mu)),Mu),Lu=Lr(ju);Lu.Arrays,Lu.Assertions;const Gu=Lu.Binary;Lu.Cache,Lu.Dates,Lu.Elliptic,Lu.Numbers,Lu.Objects,Lu.Pagination,Lu.Promises,Lu.Random,Lu.Strings,Lu.System,Lu.Types,Lu.Optional,Lu.Vector,Lu.PubSubChannel,Lu.Chunk,Lu.MerkleTree,Lu.FixedPointNumber,Lu.Lazy,Lu.AsyncLazy,Lu.AsyncQueue,Lu.Uint8ArrayReader,Lu.Uint8ArrayWriter,Lu.TrieRouter,Lu.RollingValueProvider;async function qu(e,t){if(1===e.length){const t=new Uint8Array(64);return t.set(e[0].address,0),t.set(e[0].key,32),new $o(t)}const n=[];for(let r=0;r<e.length;r+=64){const o=e.slice(r,Math.min(r+64,e.length)),i=o.reduce((e,t)=>e+t.span,0n);console.log(`[BuildEncryptedTree] Creating intermediate chunk for ${o.length} refs, totalSpan=${i}`);const a=new Uint8Array(4096);o.forEach((e,t)=>{a.set(e.address,64*t),a.set(e.key,64*t+32)}),console.log(`[BuildEncryptedTree] Payload size: ${a.length} bytes (${o.length} * 64 refs + zero padding)`);const s=Do.fromBigInt(i).toUint8Array(),c=Gu.concatBytes(s,a);console.log(`[BuildEncryptedTree] Chunk data size (before encryption): ${c.length} bytes (span=8 + payload=${a.length})`);const u=Oc(),{key:l,encryptedSpan:f,encryptedData:h}=u.encryptChunk(c),d=Gu.concatBytes(f,h);console.log(`[BuildEncryptedTree] Encrypted chunk data size: ${d.length} bytes (encryptedSpan=${f.length} + encryptedData=${h.length})`);const p=await Lo(d);console.log(`[BuildEncryptedTree] Intermediate chunk address: ${p.toHex()}, key: ${Array.from(l).map(e=>e.toString(16).padStart(2,"0")).join("")}`),await t(d),n.push({address:p.toUint8Array(),key:l,span:i})}if(n.length>1)return qu(n,t);const r=new Uint8Array(64);return r.set(n[0].address,0),r.set(n[0].key,32),new $o(r)}class Hu{constructor(e){this.cursor=0,this.buffer=e}write(e){throw new Error("SimpleUint8ArrayWriter.write() not implemented")}max(){return this.buffer.length}}class Zu{constructor(e){this.encryptedChunk=e,this.span=e.span.toBigInt(),this.writer=new Hu(e.data)}hash(){return this.encryptedChunk.address.toUint8Array()}build(){return this.encryptedChunk.data}}async function Wu(e,t,n,r){const{bee:o,stamper:i,postageBatchId:a}=e;if(!i&&!a)throw new Error("No authentication method available");let s=n?.tag;if(!s){s=(await o.createTag()).uid}const c=Pu(t);let u=c.length,l=0;console.log(`[UploadEncryptedData] Splitting ${t.length} bytes into ${u} chunks`);const f=()=>{r&&r({total:u,processed:l})},h=[],d={...n,tag:s};for(const e of c){const t=kc(e);console.log(`[UploadEncryptedData] Leaf chunk ${h.length}: address=${t.address.toHex()}, span=${e.length}, data size=${t.data.length}`),h.push({address:t.address.toUint8Array(),key:t.encryptionKey,span:BigInt(e.length)}),await Ku(o,i,a,t,d),l++,f()}let p;if(1===h.length){const e=new Uint8Array(64);e.set(h[0].address,0),e.set(h[0].key,32),p=new $o(e),console.log("[UploadEncryptedData] Single chunk upload, reference:",p.toHex())}else console.log("[UploadEncryptedData] Building encrypted merkle tree for",h.length,"chunks"),p=await qu(h,async e=>{if(console.log(`[UploadCallback] Received encrypted chunk data, size: ${e.length} bytes`),i){const t=await Lo(e);console.log(`[UploadCallback] Calculated address for upload: ${t.toHex()}`);const n=i.stamp({hash:()=>t.toUint8Array(),build:()=>e,span:0n,writer:void 0});console.log("[UploadCallback] Uploading intermediate chunk with client-side signing..."),await o.uploadChunk(n,e,d),console.log(`[UploadCallback] Upload complete for address: ${t.toHex()}`)}else console.log("[UploadCallback] Uploading intermediate chunk with node-side stamping..."),await o.uploadChunk(a,e,d),console.log("[UploadCallback] Upload complete");u++,l++,f()}),console.log("[UploadEncryptedData] Encrypted merkle tree complete, root reference:",p.toHex());return{reference:p.toHex(),tagUid:s}}async function Ku(e,t,n,r,o){const i={...o,deferred:!0,pin:!1};if(t){const n=new Zu(r),o=t.stamp(n);await e.uploadChunk(o,r.data,i)}else{if(!n)throw new Error("No stamper or batch ID available");await e.uploadChunk(n,r.data,i)}}class Ju{constructor(e){this.parentIdentified=!1,this.authenticated=!1,this.stamperDepth=23,this.popupMode="window",this.defaultBeeApiUrl=e.beeApiUrl,this.beeApiUrl=e.beeApiUrl,this.allowedOrigins=e.allowedOrigins||[],this.bee=new Du(this.beeApiUrl),this.setupMessageListener(),console.log("[Proxy] Proxy initialized with default Bee API:",this.defaultBeeApiUrl),this.announceReady()}announceReady(){window.parent&&window.parent!==window&&(console.log("[Proxy] Announcing readiness to parent window"),window.parent.postMessage({type:"proxyInitialized"},"*"))}getPostageBatchId(){return this.postageBatchId}getSignerKey(){return this.signerKey}initializeStamper(){if(this.signerKey&&this.postageBatchId)try{const e=this.loadStamperState();e?(this.stamper=Iu.fromState(this.signerKey,this.postageBatchId,e,this.stamperDepth),console.log("[Proxy] Stamper restored from saved state")):(this.stamper=Iu.fromBlank(this.signerKey,this.postageBatchId,this.stamperDepth),console.log("[Proxy] Stamper initialized fresh with depth:",this.stamperDepth))}catch(e){console.error("[Proxy] Failed to initialize stamper:",e),this.stamper=void 0}else console.warn("[Proxy] Cannot initialize stamper: missing signer key or batch ID")}saveStamperState(){if(this.stamper&&this.parentOrigin&&this.postageBatchId)try{const e=this.stamper.getState(),t=`swarm-stamper-${this.parentOrigin}-${this.postageBatchId}`,n=[];for(let t=0;t<e.length;t++)0!==e[t]&&n.push([t,e[t]]);localStorage.setItem(t,JSON.stringify(n))}catch(e){console.error("[Proxy] Failed to save stamper state:",e)}}loadStamperState(){if(this.parentOrigin&&this.postageBatchId)try{const e=`swarm-stamper-${this.parentOrigin}-${this.postageBatchId}`,t=localStorage.getItem(e);if(t){const e=JSON.parse(t),n=new Uint32Array(65536);for(const[t,r]of e)n[t]=r;return n}}catch(e){console.error("[Proxy] Failed to load stamper state:",e)}}setupMessageListener(){window.addEventListener("message",async e=>{console.log("[Proxy] Message received:",e.data.type,"from:",e.origin);const{type:t}=e.data;if("parentIdentify"===t)return void this.handleParentIdentify(e);if(!this.parentIdentified)return void console.warn("[Proxy] Ignoring message - parent not identified yet");const n=e.origin===window.location.origin,r=e.origin===this.parentOrigin;if("setButtonStyles"===t&&r)return this.currentStyles=e.data.styles,console.log("[Proxy] Button styles updated"),void(!this.authenticated&&this.authButtonContainer&&this.showAuthButton());if(n||r)try{if(r)try{const t=Ur.parse(e.data);return void await this.handleParentMessage(t,e)}catch(e){console.warn("[Proxy] Invalid parent message:",e)}if(n)try{const t=Mr.parse(e.data);return void await this.handlePopupMessage(t,e)}catch(e){console.warn("[Proxy] Invalid popup message:",e)}console.warn("[Proxy] Unknown message type:",t),this.sendErrorToParent(e,e.data.requestId,`Unknown message type: ${t}`)}catch(t){console.error("[Proxy] Error handling message:",t),this.sendErrorToParent(e,e.data.requestId,t instanceof Error?t.message:"Unknown error")}else console.warn("[Proxy] Rejected message from unauthorized origin:",e.origin)})}handleParentIdentify(e){if(this.parentIdentified)return void console.error("[Proxy] Parent already identified! Ignoring duplicate.");const t=e.data,n=t.beeApiUrl,r=t.popupMode;if(this.parentOrigin=e.origin,this.parentIdentified=!0,console.log("[Proxy] Parent identified via postMessage:",this.parentOrigin),console.log("[Proxy] Parent locked in - cannot be changed"),this.allowedOrigins.length>0&&!this.isAllowedOrigin(this.parentOrigin)){const t=`Origin validation failed! Expected one of: ${this.allowedOrigins.join(", ")}, but received: ${this.parentOrigin}`;return console.error("[Proxy]",t),void(e.source&&e.source.postMessage({type:"initError",error:t},{targetOrigin:e.origin}))}n?(this.beeApiUrl=n,this.bee=new Du(this.beeApiUrl),console.log("[Proxy] Using Bee API URL from parent:",this.beeApiUrl)):console.log("[Proxy] Using default Bee API URL:",this.beeApiUrl),r&&(this.popupMode=r,console.log("[Proxy] Using popup mode from parent:",this.popupMode)),this.loadAuthData(),e.source&&e.source.postMessage({type:"proxyReady",authenticated:this.authenticated,parentOrigin:this.parentOrigin},{targetOrigin:e.origin})}async handleParentMessage(e,t){switch(e.type){case"parentIdentify":break;case"checkAuth":this.handleCheckAuth(e,t);break;case"requestAuth":this.handleRequestAuth(e,t);break;case"uploadData":await this.handleUploadData(e,t);break;case"downloadData":await this.handleDownloadData(e,t);break;case"uploadFile":await this.handleUploadFile(e,t);break;case"downloadFile":await this.handleDownloadFile(e,t);break;case"uploadChunk":await this.handleUploadChunk(e,t);break;case"downloadChunk":await this.handleDownloadChunk(e,t);break;default:const n=e;console.warn("[Proxy] Unhandled message type:",n)}}async handlePopupMessage(e,t){if("setSecret"===e.type)await this.handleSetSecret(e,t)}isAllowedOrigin(e){return 0===this.allowedOrigins.length||this.allowedOrigins.includes(e)}loadAuthData(){if(!this.parentOrigin)return void console.log("[Proxy] No parent origin, cannot load auth data");const e=`swarm-secret-${this.parentOrigin}`,t=localStorage.getItem(e);if(t)try{const e=JSON.parse(t);console.log("[Proxy] Auth data loaded from localStorage for:",this.parentOrigin),this.appSecret=e.secret,this.postageBatchId=e.postageBatchId,this.signerKey=e.signerKey,this.authenticated=!0,this.hideAuthButton(),this.signerKey&&this.postageBatchId&&this.initializeStamper()}catch(e){console.error("[Proxy] Failed to parse auth data:",e),this.showAuthButton()}else console.log("[Proxy] No auth data found for:",this.parentOrigin),this.showAuthButton()}updateAuthStatus(e){this.authenticated=e,e?this.hideAuthButton():this.showAuthButton()}saveAuthData(e,t){const n=`swarm-secret-${e}`;localStorage.setItem(n,JSON.stringify(t)),console.log("[Proxy] Auth data saved to localStorage for:",e)}sendErrorToParent(e,t,n){e.source&&t&&e.source.postMessage({type:"error",requestId:t,error:n},{targetOrigin:e.origin})}sendToParent(e){this.parentOrigin&&window.parent&&window.parent!==window.self?window.parent.postMessage(e,this.parentOrigin):console.warn("[Proxy] Cannot send message to parent - no parent window")}handleCheckAuth(e,t){console.log("[Proxy] Checking authentication status..."),t.source&&t.source.postMessage({type:"authStatusResponse",requestId:e.requestId,authenticated:this.authenticated,origin:this.authenticated?this.parentOrigin:void 0},{targetOrigin:t.origin}),console.log("[Proxy] Authentication status:",this.authenticated)}handleRequestAuth(e,t){console.log("[Proxy] Request to show auth button for parent:",this.parentOrigin),this.currentStyles=e.styles,this.authButtonContainer&&this.showAuthButton()}showAuthButton(){if(!this.authButtonContainer)return void console.log("[Proxy] No auth button container set yet");this.authButtonContainer.innerHTML="";const e=document.createElement("button");e.textContent="🔐 Login with Swarm ID";const t=this.currentStyles||{};e.style.backgroundColor=t.backgroundColor||"#dd7200",e.style.color=t.color||"white",e.style.border=t.border||"none",e.style.borderRadius=t.borderRadius||"6px",e.style.padding=t.padding||"12px 24px",e.style.fontSize=t.fontSize||"14px",e.style.fontWeight=t.fontWeight||"600",e.style.cursor=t.cursor||"pointer",e.style.transition="all 0.2s",e.style.boxShadow="0 2px 8px rgba(221, 114, 0, 0.3)",e.addEventListener("mouseenter",()=>{e.style.transform="translateY(-1px)",e.style.boxShadow="0 4px 12px rgba(221, 114, 0, 0.5)"}),e.addEventListener("mouseleave",()=>{e.style.transform="translateY(0)",e.style.boxShadow="0 2px 8px rgba(221, 114, 0, 0.3)"}),e.addEventListener("click",()=>{if(!this.parentOrigin)return void console.error("[Proxy] Cannot open auth window - parent origin not set");if(console.log("[Proxy] Opening authentication window for parent:",this.parentOrigin),e.disabled=!0,e.innerHTML='<span style="display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.3); border-radius: 50%; border-top-color: white; animation: spin 1s linear infinite;"></span>',!document.getElementById("swarm-id-spinner-style")){const e=document.createElement("style");e.id="swarm-id-spinner-style",e.textContent="@keyframes spin { to { transform: rotate(360deg); } }",document.head.appendChild(e)}const t=`${window.location.origin}/connect?origin=${encodeURIComponent(this.parentOrigin)}`;"popup"===this.popupMode?window.open(t,"_blank","width=500,height=600"):window.open(t,"_blank")}),this.authButtonContainer.appendChild(e),console.log("[Proxy] Auth button shown")}hideAuthButton(){this.authButtonContainer&&(this.authButtonContainer.innerHTML="",console.log("[Proxy] Auth button hidden"))}setAuthButtonContainer(e){this.authButtonContainer=e,console.log("[Proxy] Auth button container set")}async handleSetSecret(e,t){const{appOrigin:n,data:r}=e;console.log("[Proxy] Received auth data for app:",n),n!==this.parentOrigin&&console.warn("[Proxy] App origin mismatch:",n,"vs",this.parentOrigin),this.saveAuthData(n,r),this.appSecret=r.secret,this.postageBatchId=r.postageBatchId,this.signerKey=r.signerKey,this.updateAuthStatus(!0),this.signerKey&&this.postageBatchId&&this.initializeStamper(),this.sendToParent({type:"authSuccess",origin:n}),console.log("[Proxy] Notified parent of successful authentication"),t.source&&!t.source.closed&&t.source.postMessage({type:"secretReceived",success:!0},{targetOrigin:t.origin})}async handleUploadData(e,t){const{requestId:n,data:r,options:o,enableProgress:i}=e;if(console.log("[Proxy] Upload data request, size:",r?r.length:0),!this.authenticated||!this.appSecret)throw new Error("Not authenticated. Please login first.");try{const e={bee:this.bee,stamper:this.stamper,postageBatchId:this.postageBatchId,signerKey:this.signerKey},a=i?e=>{t.source&&t.source.postMessage({type:"uploadProgress",requestId:n,total:e.total,processed:e.processed},{targetOrigin:t.origin})}:void 0;let s;if(this.signerKey)o?.encrypt?(console.log("[Proxy] Using client-side signing with encryption for uploadData"),s=await Wu(e,r,o,a)):(console.log("[Proxy] Using client-side signing for uploadData"),s=await Vu(e,r,o,a));else{if(!this.postageBatchId)throw new Error("No authentication method available");if(o?.encrypt){console.log("[Proxy] Using node-side stamping with encryption for uploadData");const e=await this.bee.uploadData(this.postageBatchId,r,o);s={reference:e.reference.toHex(),tagUid:e.tagUid}}else{console.log("[Proxy] Using node-side stamping for uploadData");const e=await this.bee.uploadData(this.postageBatchId,r,o);s={reference:e.reference.toHex(),tagUid:e.tagUid}}}this.signerKey&&this.stamper&&this.saveStamperState(),t.source&&t.source.postMessage({type:"uploadDataResponse",requestId:n,reference:s.reference,tagUid:s.tagUid},{targetOrigin:t.origin}),console.log("[Proxy] Data uploaded:",s.reference)}catch(e){this.sendErrorToParent(t,n,e instanceof Error?e.message:"Upload failed")}}async handleDownloadData(e,t){const{requestId:n,reference:r,options:o}=e;if(console.log("[Proxy] Download data request, reference:",r),!this.authenticated||!this.appSecret)throw new Error("Not authenticated. Please login first.");try{console.log("[Proxy] Downloading from Bee at:",this.beeApiUrl);const e=await async function(e,t,n){console.log(`[DownloadData] Downloading from reference: ${t} (${t.length} chars)`);const r=new $o(t),o=new zc(e,r,{downloadOptions:n,onDownloadProgress:void 0,concurrency:64}),i=await o.readAll();return console.log(`[DownloadData] Download complete, ${i.length} bytes`),i}(this.bee,r,o);console.log("[Proxy] Download successful, data size:",e.length),t.source&&t.source.postMessage({type:"downloadDataResponse",requestId:n,data:e},{targetOrigin:t.origin}),console.log("[Proxy] Data downloaded:",r)}catch(e){this.sendErrorToParent(t,n,e instanceof Error?e.message:"Download failed")}}async handleUploadFile(e,t){const{requestId:n,data:r,name:o,options:i}=e;if(console.log("[Proxy] Upload file request, name:",o,"size:",r?r.length:0),!this.authenticated||!this.appSecret)throw new Error("Not authenticated. Please login first.");if(!this.signerKey||this.postageBatchId){if(!this.postageBatchId)throw new Error("No postage batch ID available. Please authenticate with a valid batch ID.");try{console.log("[Proxy] Uploading file to Bee at:",this.beeApiUrl,"with batch:",this.postageBatchId);const e=await this.bee.uploadFile(this.postageBatchId,r,o,i);console.log("[Proxy] File upload successful, reference:",e.reference.toHex()),t.source&&t.source.postMessage({type:"uploadFileResponse",requestId:n,reference:e.reference.toHex(),tagUid:e.tagUid},{targetOrigin:t.origin}),console.log("[Proxy] File uploaded:",e.reference.toHex())}catch(e){this.sendErrorToParent(t,n,e instanceof Error?e.message:"Upload failed")}}else this.sendErrorToParent(t,n,"Signed uploads for files not yet implemented. Please use uploadChunk for signed uploads, or provide a postage batch ID for automatic chunking.")}async handleDownloadFile(e,t){const{requestId:n,reference:r,path:o,options:i}=e;if(console.log("[Proxy] Download file request, reference:",r,"path:",o),!this.authenticated||!this.appSecret)throw new Error("Not authenticated. Please login first.");try{console.log("[Proxy] Downloading file from Bee at:",this.beeApiUrl);const e=await this.bee.downloadFile(r,o,i);console.log("[Proxy] File download successful, data size:",e.data.toUint8Array().length);const a=e.data.toUint8Array();t.source&&t.source.postMessage({type:"downloadFileResponse",requestId:n,name:e.name||"file",data:a},{targetOrigin:t.origin}),console.log("[Proxy] File downloaded:",r)}catch(e){this.sendErrorToParent(t,n,e instanceof Error?e.message:"Download failed")}}async handleUploadChunk(e,t){const{requestId:n,data:r,options:o}=e;if(console.log("[Proxy] Upload chunk request, size:",r?r.length:0),!this.authenticated||!this.appSecret)throw new Error("Not authenticated. Please login first.");if(!this.signerKey&&!this.postageBatchId)throw new Error("No postage batch ID or signer key available. Please authenticate.");try{if(r.length<1||r.length>4096)throw new Error(`Invalid chunk size: ${r.length} bytes. Chunks must be between 1 and 4096 bytes.`);let e;if(this.signerKey){if(this.stamper||this.initializeStamper(),!this.stamper)throw new Error("Failed to initialize stamper for signing");console.log("[Proxy] Signing and uploading chunk with signer key");const t=Ho(r),n=this.stamper.stamp(t),i={...o,deferred:!0,pin:!1};e=await this.bee.uploadChunk(n,t.data,i)}else{if(!this.postageBatchId)throw new Error("No authentication method available");{console.log("[Proxy] Uploading chunk to Bee at:",this.beeApiUrl,"with batch:",this.postageBatchId);const t={...o,deferred:!0,pin:!1};e=await this.bee.uploadChunk(this.postageBatchId,r,t)}}console.log("[Proxy] Chunk upload successful, reference:",e.reference.toHex()),this.signerKey&&this.stamper&&this.saveStamperState(),t.source&&t.source.postMessage({type:"uploadChunkResponse",requestId:n,reference:e.reference.toHex()},{targetOrigin:t.origin}),console.log("[Proxy] Chunk uploaded:",e.reference.toHex())}catch(e){this.sendErrorToParent(t,n,e instanceof Error?e.message:"Upload failed")}}async handleDownloadChunk(e,t){const{requestId:n,reference:r,options:o}=e;if(console.log("[Proxy] Download chunk request, reference:",r),!this.authenticated||!this.appSecret)throw new Error("Not authenticated. Please login first.");try{console.log("[Proxy] Downloading chunk from Bee at:",this.beeApiUrl);const e=await this.bee.downloadChunk(r,o);console.log("[Proxy] Chunk download successful, data size:",e.length),t.source&&t.source.postMessage({type:"downloadChunkResponse",requestId:n,data:e},{targetOrigin:t.origin}),console.log("[Proxy] Chunk downloaded:",r)}catch(e){this.sendErrorToParent(t,n,e instanceof Error?e.message:"Download failed")}}}function Xu(e){return new Ju(e)}export{Ju as SwarmIdProxy,Xu as initProxy};
2
+ //# sourceMappingURL=swarm-id-proxy.js.map