@synnaxlabs/client 0.18.3 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (275) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/README.md +1 -1
  3. package/dist/auth/auth.d.ts +1 -0
  4. package/dist/auth/auth.d.ts.map +1 -0
  5. package/dist/auth/auth.spec.d.ts +1 -0
  6. package/dist/auth/auth.spec.d.ts.map +1 -0
  7. package/dist/auth/index.d.ts +1 -0
  8. package/dist/auth/index.d.ts.map +1 -0
  9. package/dist/channel/batchRetriever.spec.d.ts +1 -0
  10. package/dist/channel/batchRetriever.spec.d.ts.map +1 -0
  11. package/dist/channel/channel.spec.d.ts +1 -0
  12. package/dist/channel/channel.spec.d.ts.map +1 -0
  13. package/dist/channel/client.d.ts +9 -7
  14. package/dist/channel/client.d.ts.map +1 -0
  15. package/dist/channel/external.d.ts +2 -1
  16. package/dist/channel/external.d.ts.map +1 -0
  17. package/dist/channel/index.d.ts +1 -0
  18. package/dist/channel/index.d.ts.map +1 -0
  19. package/dist/channel/payload.d.ts +3 -3
  20. package/dist/channel/payload.d.ts.map +1 -0
  21. package/dist/channel/retriever.d.ts +1 -0
  22. package/dist/channel/retriever.d.ts.map +1 -0
  23. package/dist/channel/writer.d.ts +22 -0
  24. package/dist/channel/writer.d.ts.map +1 -0
  25. package/dist/client.cjs +18 -18
  26. package/dist/client.cjs.map +1 -1
  27. package/dist/client.d.ts +3 -3
  28. package/dist/client.d.ts.map +1 -0
  29. package/dist/client.js +8285 -8248
  30. package/dist/client.js.map +1 -1
  31. package/dist/connection/checker.d.ts +1 -0
  32. package/dist/connection/checker.d.ts.map +1 -0
  33. package/dist/connection/connection.spec.d.ts +1 -0
  34. package/dist/connection/connection.spec.d.ts.map +1 -0
  35. package/dist/connection/index.d.ts +1 -0
  36. package/dist/connection/index.d.ts.map +1 -0
  37. package/dist/control/authority.d.ts +1 -0
  38. package/dist/control/authority.d.ts.map +1 -0
  39. package/dist/control/external.d.ts +1 -0
  40. package/dist/control/external.d.ts.map +1 -0
  41. package/dist/control/index.d.ts +1 -0
  42. package/dist/control/index.d.ts.map +1 -0
  43. package/dist/control/state.d.ts +1 -0
  44. package/dist/control/state.d.ts.map +1 -0
  45. package/dist/control/state.spec.d.ts +1 -0
  46. package/dist/control/state.spec.d.ts.map +1 -0
  47. package/dist/errors.d.ts +3 -2
  48. package/dist/errors.d.ts.map +1 -0
  49. package/dist/framer/adapter.d.ts +1 -0
  50. package/dist/framer/adapter.d.ts.map +1 -0
  51. package/dist/framer/adapter.spec.d.ts +1 -0
  52. package/dist/framer/adapter.spec.d.ts.map +1 -0
  53. package/dist/framer/client.d.ts +9 -15
  54. package/dist/framer/client.d.ts.map +1 -0
  55. package/dist/framer/client.spec.d.ts +2 -0
  56. package/dist/framer/client.spec.d.ts.map +1 -0
  57. package/dist/framer/external.d.ts +1 -0
  58. package/dist/framer/external.d.ts.map +1 -0
  59. package/dist/framer/frame.d.ts +25 -24
  60. package/dist/framer/frame.d.ts.map +1 -0
  61. package/dist/framer/frame.spec.d.ts +1 -0
  62. package/dist/framer/frame.spec.d.ts.map +1 -0
  63. package/dist/framer/index.d.ts +1 -0
  64. package/dist/framer/index.d.ts.map +1 -0
  65. package/dist/framer/iterator.d.ts +3 -2
  66. package/dist/framer/iterator.d.ts.map +1 -0
  67. package/dist/framer/iterator.spec.d.ts +1 -0
  68. package/dist/framer/iterator.spec.d.ts.map +1 -0
  69. package/dist/framer/streamProxy.d.ts +1 -0
  70. package/dist/framer/streamProxy.d.ts.map +1 -0
  71. package/dist/framer/streamer.d.ts +1 -0
  72. package/dist/framer/streamer.d.ts.map +1 -0
  73. package/dist/framer/streamer.spec.d.ts +1 -0
  74. package/dist/framer/streamer.spec.d.ts.map +1 -0
  75. package/dist/framer/writer.d.ts +21 -19
  76. package/dist/framer/writer.d.ts.map +1 -0
  77. package/dist/framer/writer.spec.d.ts +1 -0
  78. package/dist/framer/writer.spec.d.ts.map +1 -0
  79. package/dist/hardware/client.d.ts +1 -0
  80. package/dist/hardware/client.d.ts.map +1 -0
  81. package/dist/hardware/device/client.d.ts +1 -0
  82. package/dist/hardware/device/client.d.ts.map +1 -0
  83. package/dist/hardware/device/device.spec.d.ts +1 -0
  84. package/dist/hardware/device/device.spec.d.ts.map +1 -0
  85. package/dist/hardware/device/external.d.ts +1 -0
  86. package/dist/hardware/device/external.d.ts.map +1 -0
  87. package/dist/hardware/device/index.d.ts +1 -0
  88. package/dist/hardware/device/index.d.ts.map +1 -0
  89. package/dist/hardware/device/payload.d.ts +1 -0
  90. package/dist/hardware/device/payload.d.ts.map +1 -0
  91. package/dist/hardware/device/retriever.d.ts +1 -0
  92. package/dist/hardware/device/retriever.d.ts.map +1 -0
  93. package/dist/hardware/device/writer.d.ts +1 -0
  94. package/dist/hardware/device/writer.d.ts.map +1 -0
  95. package/dist/hardware/external.d.ts +1 -0
  96. package/dist/hardware/external.d.ts.map +1 -0
  97. package/dist/hardware/index.d.ts +1 -0
  98. package/dist/hardware/index.d.ts.map +1 -0
  99. package/dist/hardware/rack/client.d.ts +1 -0
  100. package/dist/hardware/rack/client.d.ts.map +1 -0
  101. package/dist/hardware/rack/external.d.ts +1 -0
  102. package/dist/hardware/rack/external.d.ts.map +1 -0
  103. package/dist/hardware/rack/index.d.ts +1 -0
  104. package/dist/hardware/rack/index.d.ts.map +1 -0
  105. package/dist/hardware/rack/payload.d.ts +1 -0
  106. package/dist/hardware/rack/payload.d.ts.map +1 -0
  107. package/dist/hardware/rack/rack.spec.d.ts +1 -0
  108. package/dist/hardware/rack/rack.spec.d.ts.map +1 -0
  109. package/dist/hardware/rack/retriever.d.ts +1 -0
  110. package/dist/hardware/rack/retriever.d.ts.map +1 -0
  111. package/dist/hardware/rack/writer.d.ts +1 -0
  112. package/dist/hardware/rack/writer.d.ts.map +1 -0
  113. package/dist/hardware/task/client.d.ts +1 -0
  114. package/dist/hardware/task/client.d.ts.map +1 -0
  115. package/dist/hardware/task/external.d.ts +1 -0
  116. package/dist/hardware/task/external.d.ts.map +1 -0
  117. package/dist/hardware/task/index.d.ts +1 -0
  118. package/dist/hardware/task/index.d.ts.map +1 -0
  119. package/dist/hardware/task/payload.d.ts +1 -0
  120. package/dist/hardware/task/payload.d.ts.map +1 -0
  121. package/dist/hardware/task/retriever.d.ts +1 -0
  122. package/dist/hardware/task/retriever.d.ts.map +1 -0
  123. package/dist/hardware/task/task.spec.d.ts +1 -0
  124. package/dist/hardware/task/task.spec.d.ts.map +1 -0
  125. package/dist/hardware/task/writer.d.ts +1 -0
  126. package/dist/hardware/task/writer.d.ts.map +1 -0
  127. package/dist/index.d.ts +1 -0
  128. package/dist/index.d.ts.map +1 -0
  129. package/dist/label/client.d.ts +1 -0
  130. package/dist/label/client.d.ts.map +1 -0
  131. package/dist/label/external.d.ts +1 -0
  132. package/dist/label/external.d.ts.map +1 -0
  133. package/dist/label/index.d.ts +1 -0
  134. package/dist/label/index.d.ts.map +1 -0
  135. package/dist/label/label.spec.d.ts +1 -0
  136. package/dist/label/label.spec.d.ts.map +1 -0
  137. package/dist/label/payload.d.ts +1 -0
  138. package/dist/label/payload.d.ts.map +1 -0
  139. package/dist/label/retriever.d.ts +1 -0
  140. package/dist/label/retriever.d.ts.map +1 -0
  141. package/dist/label/writer.d.ts +1 -0
  142. package/dist/label/writer.d.ts.map +1 -0
  143. package/dist/ontology/client.d.ts +1 -0
  144. package/dist/ontology/client.d.ts.map +1 -0
  145. package/dist/ontology/external.d.ts +1 -0
  146. package/dist/ontology/external.d.ts.map +1 -0
  147. package/dist/ontology/group/client.d.ts +1 -0
  148. package/dist/ontology/group/client.d.ts.map +1 -0
  149. package/dist/ontology/group/external.d.ts +1 -0
  150. package/dist/ontology/group/external.d.ts.map +1 -0
  151. package/dist/ontology/group/group.d.ts +1 -0
  152. package/dist/ontology/group/group.d.ts.map +1 -0
  153. package/dist/ontology/group/group.spec.d.ts +1 -0
  154. package/dist/ontology/group/group.spec.d.ts.map +1 -0
  155. package/dist/ontology/group/index.d.ts +1 -0
  156. package/dist/ontology/group/index.d.ts.map +1 -0
  157. package/dist/ontology/group/payload.d.ts +1 -0
  158. package/dist/ontology/group/payload.d.ts.map +1 -0
  159. package/dist/ontology/group/writer.d.ts +1 -0
  160. package/dist/ontology/group/writer.d.ts.map +1 -0
  161. package/dist/ontology/index.d.ts +1 -0
  162. package/dist/ontology/index.d.ts.map +1 -0
  163. package/dist/ontology/ontology.spec.d.ts +1 -0
  164. package/dist/ontology/ontology.spec.d.ts.map +1 -0
  165. package/dist/ontology/payload.d.ts +1 -0
  166. package/dist/ontology/payload.d.ts.map +1 -0
  167. package/dist/ontology/retriever.d.ts +1 -0
  168. package/dist/ontology/retriever.d.ts.map +1 -0
  169. package/dist/ontology/signals.d.ts +1 -0
  170. package/dist/ontology/signals.d.ts.map +1 -0
  171. package/dist/ontology/writer.d.ts +1 -0
  172. package/dist/ontology/writer.d.ts.map +1 -0
  173. package/dist/ranger/active.d.ts +1 -0
  174. package/dist/ranger/active.d.ts.map +1 -0
  175. package/dist/ranger/alias.d.ts +1 -0
  176. package/dist/ranger/alias.d.ts.map +1 -0
  177. package/dist/ranger/client.d.ts +1 -0
  178. package/dist/ranger/client.d.ts.map +1 -0
  179. package/dist/ranger/external.d.ts +1 -0
  180. package/dist/ranger/external.d.ts.map +1 -0
  181. package/dist/ranger/index.d.ts +1 -0
  182. package/dist/ranger/index.d.ts.map +1 -0
  183. package/dist/ranger/kv.d.ts +1 -0
  184. package/dist/ranger/kv.d.ts.map +1 -0
  185. package/dist/ranger/payload.d.ts +29 -28
  186. package/dist/ranger/payload.d.ts.map +1 -0
  187. package/dist/ranger/range.d.ts +1 -0
  188. package/dist/ranger/range.d.ts.map +1 -0
  189. package/dist/ranger/ranger.spec.d.ts +1 -0
  190. package/dist/ranger/ranger.spec.d.ts.map +1 -0
  191. package/dist/ranger/retriever.d.ts +1 -0
  192. package/dist/ranger/retriever.d.ts.map +1 -0
  193. package/dist/ranger/writer.d.ts +1 -0
  194. package/dist/ranger/writer.d.ts.map +1 -0
  195. package/dist/setupspecs.d.ts +1 -0
  196. package/dist/setupspecs.d.ts.map +1 -0
  197. package/dist/signals/external.d.ts +1 -0
  198. package/dist/signals/external.d.ts.map +1 -0
  199. package/dist/signals/index.d.ts +1 -0
  200. package/dist/signals/index.d.ts.map +1 -0
  201. package/dist/signals/observable.d.ts +1 -0
  202. package/dist/signals/observable.d.ts.map +1 -0
  203. package/dist/transport.d.ts +1 -0
  204. package/dist/transport.d.ts.map +1 -0
  205. package/dist/user/index.d.ts +1 -0
  206. package/dist/user/index.d.ts.map +1 -0
  207. package/dist/user/payload.d.ts +1 -0
  208. package/dist/user/payload.d.ts.map +1 -0
  209. package/dist/util/telem.d.ts +1 -0
  210. package/dist/util/telem.d.ts.map +1 -0
  211. package/dist/workspace/client.d.ts +1 -0
  212. package/dist/workspace/client.d.ts.map +1 -0
  213. package/dist/workspace/external.d.ts +1 -0
  214. package/dist/workspace/external.d.ts.map +1 -0
  215. package/dist/workspace/index.d.ts +1 -0
  216. package/dist/workspace/index.d.ts.map +1 -0
  217. package/dist/workspace/lineplot/client.d.ts +1 -0
  218. package/dist/workspace/lineplot/client.d.ts.map +1 -0
  219. package/dist/workspace/lineplot/external.d.ts +1 -0
  220. package/dist/workspace/lineplot/external.d.ts.map +1 -0
  221. package/dist/workspace/lineplot/index.d.ts +1 -0
  222. package/dist/workspace/lineplot/index.d.ts.map +1 -0
  223. package/dist/workspace/lineplot/linePlot.spec.d.ts +1 -0
  224. package/dist/workspace/lineplot/linePlot.spec.d.ts.map +1 -0
  225. package/dist/workspace/lineplot/payload.d.ts +1 -0
  226. package/dist/workspace/lineplot/payload.d.ts.map +1 -0
  227. package/dist/workspace/lineplot/retriever.d.ts +1 -0
  228. package/dist/workspace/lineplot/retriever.d.ts.map +1 -0
  229. package/dist/workspace/lineplot/writer.d.ts +1 -0
  230. package/dist/workspace/lineplot/writer.d.ts.map +1 -0
  231. package/dist/workspace/payload.d.ts +1 -0
  232. package/dist/workspace/payload.d.ts.map +1 -0
  233. package/dist/workspace/pid/client.d.ts +1 -0
  234. package/dist/workspace/pid/client.d.ts.map +1 -0
  235. package/dist/workspace/pid/external.d.ts +1 -0
  236. package/dist/workspace/pid/external.d.ts.map +1 -0
  237. package/dist/workspace/pid/index.d.ts +1 -0
  238. package/dist/workspace/pid/index.d.ts.map +1 -0
  239. package/dist/workspace/pid/payload.d.ts +1 -0
  240. package/dist/workspace/pid/payload.d.ts.map +1 -0
  241. package/dist/workspace/pid/pid.spec.d.ts +1 -0
  242. package/dist/workspace/pid/pid.spec.d.ts.map +1 -0
  243. package/dist/workspace/pid/retriever.d.ts +1 -0
  244. package/dist/workspace/pid/retriever.d.ts.map +1 -0
  245. package/dist/workspace/pid/writer.d.ts +1 -0
  246. package/dist/workspace/pid/writer.d.ts.map +1 -0
  247. package/dist/workspace/retriever.d.ts +1 -0
  248. package/dist/workspace/retriever.d.ts.map +1 -0
  249. package/dist/workspace/workspace.spec.d.ts +1 -0
  250. package/dist/workspace/workspace.spec.d.ts.map +1 -0
  251. package/dist/workspace/writer.d.ts +1 -0
  252. package/dist/workspace/writer.d.ts.map +1 -0
  253. package/examples/node/liveStream.js +1 -1
  254. package/examples/node/package-lock.json +46 -47
  255. package/examples/node/package.json +2 -2
  256. package/examples/node/streamWrite.js +1 -1
  257. package/package.json +11 -11
  258. package/src/channel/channel.spec.ts +27 -0
  259. package/src/channel/client.ts +19 -13
  260. package/src/channel/external.ts +1 -1
  261. package/src/channel/payload.ts +1 -11
  262. package/src/channel/retriever.ts +1 -1
  263. package/src/channel/writer.ts +63 -0
  264. package/src/client.ts +24 -27
  265. package/src/control/state.spec.ts +2 -2
  266. package/src/errors.ts +2 -2
  267. package/src/framer/client.spec.ts +63 -0
  268. package/src/framer/client.ts +46 -14
  269. package/src/framer/iterator.spec.ts +2 -2
  270. package/src/framer/iterator.ts +7 -2
  271. package/src/framer/streamer.spec.ts +4 -4
  272. package/src/framer/writer.spec.ts +6 -6
  273. package/src/framer/writer.ts +6 -1
  274. package/dist/channel/creator.d.ts +0 -8
  275. package/src/channel/creator.ts +0 -44
package/dist/client.cjs CHANGED
@@ -1,37 +1,37 @@
1
- "use strict";var vl=Object.defineProperty;var wl=(r,e,t)=>e in r?vl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>(wl(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var _l=Object.defineProperty,bl=(r,e,t)=>e in r?_l(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>(bl(r,typeof e!="symbol"?e+"":e,t),t);let kl="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",Tl=(r=21)=>{let e="",t=r;for(;t--;)e+=kl[Math.random()*64|0];return e};const Ol=r=>r!=null&&typeof r=="object"&&"toString"in r,xl=(r,e=!1)=>{const t=Ol(r)?"stringer":typeof r;let s;switch(t){case"string":s=(n,a)=>n.localeCompare(a);break;case"stringer":s=(n,a)=>n.toString().localeCompare(a.toString());break;case"number":s=(n,a)=>n-a;break;case"bigint":s=(n,a)=>n-a>BigInt(0)?1:-1;break;case"boolean":s=(n,a)=>Number(n)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?Nl(s):s},Nl=r=>(e,t)=>r(t,e);var G;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(G||(G={}));var ja;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(ja||(ja={}));const T=G.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jt=r=>{switch(typeof r){case"undefined":return T.undefined;case"string":return T.string;case"number":return isNaN(r)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(r)?T.array:r===null?T.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?T.promise:typeof Map<"u"&&r instanceof Map?T.map:typeof Set<"u"&&r instanceof Set?T.set:typeof Date<"u"&&r instanceof Date?T.date:T.object;default:return T.unknown}},v=G.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Sl=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Ue=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,G.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};Ue.create=r=>new Ue(r);const Mr=(r,e)=>{let t;switch(r.code){case v.invalid_type:r.received===T.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case v.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,G.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:t=`Unrecognized key(s) in object: ${G.joinValues(r.keys,", ")}`;break;case v.invalid_union:t="Invalid input";break;case v.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${G.joinValues(r.options)}`;break;case v.invalid_enum_value:t=`Invalid enum value. Expected ${G.joinValues(r.options)}, received '${r.received}'`;break;case v.invalid_arguments:t="Invalid function arguments";break;case v.invalid_return_type:t="Invalid function return type";break;case v.invalid_date:t="Invalid date";break;case v.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:G.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case v.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case v.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case v.custom:t="Invalid input";break;case v.invalid_intersection_types:t="Intersection results could not be merged";break;case v.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case v.not_finite:t="Number must be finite";break;default:t=e.defaultError,G.assertNever(r)}return{message:t}};let Eo=Mr;function El(r){Eo=r}function cn(){return Eo}const un=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Zl=[];function N(r,e){const t=un({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,cn(),Mr].filter(s=>!!s)});r.common.issues.push(t)}class Oe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return M;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Oe.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return M;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const M=Object.freeze({status:"aborted"}),Zo=r=>({status:"dirty",value:r}),Ce=r=>({status:"valid",value:r}),Ra=r=>r.status==="aborted",za=r=>r.status==="dirty",Dr=r=>r.status==="valid",ln=r=>typeof Promise<"u"&&r instanceof Promise;var Z;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Z||(Z={}));class st{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Xi=(r,e)=>{if(Dr(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ue(r.common.issues);return this._error=t,this._error}}};function U(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}let V=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return jt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Oe,ctx:{common:e.parent.common,data:e.data,parsedType:jt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ln(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Xi(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:jt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ln(n)?n:Promise.resolve(n));return Xi(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:v.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Fe({schema:this,typeName:$.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xt.create(this,this._def)}nullable(){return er.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Qt.create(this,this._def)}promise(){return xr.create(this,this._def)}or(e){return Wr.create([this,e],this._def)}and(e){return Fr.create(this,e,this._def)}transform(e){return new Fe({...U(this._def),schema:this,typeName:$.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Hr({...U(this._def),innerType:this,defaultValue:t,typeName:$.ZodDefault})}brand(){return new Po({typeName:$.ZodBranded,type:this,...U(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new mn({...U(this._def),innerType:this,catchValue:t,typeName:$.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ni.create(this,e)}readonly(){return gn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Il=/^c[^\s-]{8,}$/i,Al=/^[a-z][a-z0-9]*$/,Cl=/^[0-9A-HJKMNP-TV-Z]{26}$/,$l=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,jl=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Rl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let pa;const zl=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Pl=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Ml=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Dl(r,e){return!!((e==="v4"||!e)&&zl.test(r)||(e==="v6"||!e)&&Pl.test(r))}let Tr=class Ar extends V{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T.string){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.string,received:n.parsedType}),M}const t=new Oe;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?N(s,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&N(s,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")jl.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")pa||(pa=new RegExp(Rl,"u")),pa.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")$l.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Il.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Al.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Cl.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:v.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:v.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Ml(n).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Dl(e.data,n.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:v.invalid_string,message:n.message}),t.dirty()):G.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:v.invalid_string,...Z.errToObj(s)})}_addCheck(e){return new Ar({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Z.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...Z.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Z.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Z.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Z.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Z.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Z.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Z.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Z.errToObj(t)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new Ar({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ar({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ar({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Tr.create=r=>{var e;return new Tr({checks:[],typeName:$.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...U(r)})};function Ll(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}let Lr=class Pa extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==T.number){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.number,received:n.parsedType}),M}let t;const s=new Oe;for(const n of this._def.checks)n.kind==="int"?G.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:v.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Ll(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_finite,message:n.message}),s.dirty()):G.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,s,n){return new Pa({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Z.toString(n)}]})}_addCheck(e){return new Pa({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&G.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Lr.create=r=>new Lr({checks:[],typeName:$.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...U(r)});let Ur=class Ma extends V{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==T.bigint){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.bigint,received:n.parsedType}),M}let t;const s=new Oe;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):G.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,s,n){return new Ma({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Z.toString(n)}]})}_addCheck(e){return new Ma({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Ur.create=r=>{var e;return new Ur({checks:[],typeName:$.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...U(r)})};let Br=class extends V{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T.boolean){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.boolean,received:t.parsedType}),M}return Ce(e.data)}};Br.create=r=>new Br({typeName:$.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...U(r)});let qr=class Io extends V{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T.date){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.date,received:n.parsedType}),M}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_date}),M}const t=new Oe;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):G.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Io({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Z.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Z.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};qr.create=r=>new qr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:$.ZodDate,...U(r)});let dn=class extends V{_parse(e){if(this._getType(e)!==T.symbol){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.symbol,received:t.parsedType}),M}return Ce(e.data)}};dn.create=r=>new dn({typeName:$.ZodSymbol,...U(r)});let Vr=class extends V{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.undefined,received:t.parsedType}),M}return Ce(e.data)}};Vr.create=r=>new Vr({typeName:$.ZodUndefined,...U(r)});let Kr=class extends V{_parse(e){if(this._getType(e)!==T.null){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.null,received:t.parsedType}),M}return Ce(e.data)}};Kr.create=r=>new Kr({typeName:$.ZodNull,...U(r)});let Or=class extends V{constructor(){super(...arguments),this._any=!0}_parse(e){return Ce(e.data)}};Or.create=r=>new Or({typeName:$.ZodAny,...U(r)});let Jt=class extends V{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ce(e.data)}};Jt.create=r=>new Jt({typeName:$.ZodUnknown,...U(r)});let Et=class extends V{_parse(e){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.never,received:t.parsedType}),M}};Et.create=r=>new Et({typeName:$.ZodNever,...U(r)});let hn=class extends V{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.void,received:t.parsedType}),M}return Ce(e.data)}};hn.create=r=>new hn({typeName:$.ZodVoid,...U(r)});let Qt=class Ds extends V{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==T.array)return N(t,{code:v.invalid_type,expected:T.array,received:t.parsedType}),M;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(N(t,{code:i?v.too_big:v.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(N(t,{code:v.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(N(t,{code:v.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new st(t,i,t.path,o)))).then(i=>Oe.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new st(t,i,t.path,o)));return Oe.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Ds({...this._def,minLength:{value:e,message:Z.toString(t)}})}max(e,t){return new Ds({...this._def,maxLength:{value:e,message:Z.toString(t)}})}length(e,t){return new Ds({...this._def,exactLength:{value:e,message:Z.toString(t)}})}nonempty(e){return this.min(1,e)}};Qt.create=(r,e)=>new Qt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:$.ZodArray,...U(e)});function pr(r){if(r instanceof ue){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=xt.create(pr(s))}return new ue({...r._def,shape:()=>e})}else return r instanceof Qt?new Qt({...r._def,type:pr(r.element)}):r instanceof xt?xt.create(pr(r.unwrap())):r instanceof er?er.create(pr(r.unwrap())):r instanceof Pt?Pt.create(r.items.map(e=>pr(e))):r}class ue extends V{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=G.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==T.object){const c=this._getOrReturnCtx(e);return N(c,{code:v.invalid_type,expected:T.object,received:c.parsedType}),M}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Et&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=n[c],h=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new st(s,h,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Et){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")i.length>0&&(N(s,{code:v.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new st(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>Oe.mergeObjectSync(t,c)):Oe.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Z.errToObj,new ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=Z.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new ue({...this._def,unknownKeys:"strip"})}passthrough(){return new ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:$.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ue({...this._def,catchall:e})}pick(e){const t={};return G.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new ue({...this._def,shape:()=>t})}omit(e){const t={};return G.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new ue({...this._def,shape:()=>t})}deepPartial(){return pr(this)}partial(e){const t={};return G.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new ue({...this._def,shape:()=>t})}required(e){const t={};return G.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof xt;)n=n._def.innerType;t[s]=n}}),new ue({...this._def,shape:()=>t})}keyof(){return zo(G.objectKeys(this.shape))}}ue.create=(r,e)=>new ue({shape:()=>r,unknownKeys:"strip",catchall:Et.create(),typeName:$.ZodObject,...U(e)});ue.strictCreate=(r,e)=>new ue({shape:()=>r,unknownKeys:"strict",catchall:Et.create(),typeName:$.ZodObject,...U(e)});ue.lazycreate=(r,e)=>new ue({shape:r,unknownKeys:"strip",catchall:Et.create(),typeName:$.ZodObject,...U(e)});let Wr=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Ue(o.ctx.common.issues));return N(t,{code:v.invalid_union,unionErrors:i}),M}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Ue(c));return N(t,{code:v.invalid_union,unionErrors:o}),M}}get options(){return this._def.options}};Wr.create=(r,e)=>new Wr({options:r,typeName:$.ZodUnion,...U(e)});const Ls=r=>r instanceof Yr?Ls(r.schema):r instanceof Fe?Ls(r.innerType()):r instanceof Jr?[r.value]:r instanceof Mt?r.options:r instanceof Gr?Object.keys(r.enum):r instanceof Hr?Ls(r._def.innerType):r instanceof Vr?[void 0]:r instanceof Kr?[null]:null;let Ao=class Co extends V{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.object)return N(t,{code:v.invalid_type,expected:T.object,received:t.parsedType}),M;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(N(t,{code:v.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),M)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Ls(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Co({typeName:$.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...U(s)})}};function Da(r,e){const t=jt(r),s=jt(e);if(r===e)return{valid:!0,data:r};if(t===T.object&&s===T.object){const n=G.objectKeys(e),a=G.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Da(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===T.array&&s===T.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Da(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===T.date&&s===T.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Fr=class extends V{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ra(a)||Ra(i))return M;const o=Da(a.value,i.value);return o.valid?((za(a)||za(i))&&t.dirty(),{status:t.value,value:o.data}):(N(s,{code:v.invalid_intersection_types}),M)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Fr.create=(r,e,t)=>new Fr({left:r,right:e,typeName:$.ZodIntersection,...U(t)});let Pt=class $o extends V{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.array)return N(s,{code:v.invalid_type,expected:T.array,received:s.parsedType}),M;if(s.data.length<this._def.items.length)return N(s,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),M;!this._def.rest&&s.data.length>this._def.items.length&&(N(s,{code:v.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new st(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>Oe.mergeArray(t,a)):Oe.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new $o({...this._def,rest:e})}};Pt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Pt({items:r,typeName:$.ZodTuple,rest:null,...U(e)})};let jo=class La extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.object)return N(s,{code:v.invalid_type,expected:T.object,received:s.parsedType}),M;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new st(s,o,s.path,o)),value:i._parse(new st(s,s.data[o],s.path,o))});return s.common.async?Oe.mergeObjectAsync(t,n):Oe.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof V?new La({keyType:e,valueType:t,typeName:$.ZodRecord,...U(s)}):new La({keyType:Tr.create(),valueType:e,typeName:$.ZodRecord,...U(t)})}},pn=class extends V{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.map)return N(s,{code:v.invalid_type,expected:T.map,received:s.parsedType}),M;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new st(s,o,s.path,[l,"key"])),value:a._parse(new st(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};pn.create=(r,e,t)=>new pn({valueType:e,keyType:r,typeName:$.ZodMap,...U(t)});let fn=class Ua extends V{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.set)return N(s,{code:v.invalid_type,expected:T.set,received:s.parsedType}),M;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(N(s,{code:v.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(N(s,{code:v.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return M;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new st(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Ua({...this._def,minSize:{value:e,message:Z.toString(t)}})}max(e,t){return new Ua({...this._def,maxSize:{value:e,message:Z.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};fn.create=(r,e)=>new fn({valueType:r,minSize:null,maxSize:null,typeName:$.ZodSet,...U(e)});let Ro=class Us extends V{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.function)return N(t,{code:v.invalid_type,expected:T.function,received:t.parsedType}),M;function s(o,c){return un({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cn(),Mr].filter(l=>!!l),issueData:{code:v.invalid_arguments,argumentsError:c}})}function n(o,c){return un({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cn(),Mr].filter(l=>!!l),issueData:{code:v.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof xr){const o=this;return Ce(async function(...c){const l=new Ue([]),h=await o._def.args.parseAsync(c,a).catch(oe=>{throw l.addIssue(s(c,oe)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(oe=>{throw l.addIssue(n(k,oe)),l})})}else{const o=this;return Ce(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Ue([s(c,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new Ue([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Us({...this._def,args:Pt.create(e).rest(Jt.create())})}returns(e){return new Us({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Us({args:e||Pt.create([]).rest(Jt.create()),returns:t||Jt.create(),typeName:$.ZodFunction,...U(s)})}},Yr=class extends V{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Yr.create=(r,e)=>new Yr({getter:r,typeName:$.ZodLazy,...U(e)});let Jr=class extends V{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:v.invalid_literal,expected:this._def.value}),M}return{status:"valid",value:e.data}}get value(){return this._def.value}};Jr.create=(r,e)=>new Jr({value:r,typeName:$.ZodLiteral,...U(e)});function zo(r,e){return new Mt({values:r,typeName:$.ZodEnum,...U(e)})}class Mt extends V{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return N(t,{expected:G.joinValues(s),received:t.parsedType,code:v.invalid_type}),M}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return N(t,{received:t.data,code:v.invalid_enum_value,options:s}),M}return Ce(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Mt.create(e)}exclude(e){return Mt.create(this.options.filter(t=>!e.includes(t)))}}Mt.create=zo;let Gr=class extends V{_parse(e){const t=G.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==T.string&&s.parsedType!==T.number){const n=G.objectValues(t);return N(s,{expected:G.joinValues(n),received:s.parsedType,code:v.invalid_type}),M}if(t.indexOf(e.data)===-1){const n=G.objectValues(t);return N(s,{received:s.data,code:v.invalid_enum_value,options:n}),M}return Ce(e.data)}get enum(){return this._def.values}};Gr.create=(r,e)=>new Gr({values:r,typeName:$.ZodNativeEnum,...U(e)});let xr=class extends V{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.promise&&t.common.async===!1)return N(t,{code:v.invalid_type,expected:T.promise,received:t.parsedType}),M;const s=t.parsedType===T.promise?t.data:Promise.resolve(t.data);return Ce(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};xr.create=(r,e)=>new xr({type:r,typeName:$.ZodPromise,...U(e)});let Fe=class extends V{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===$.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{N(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Dr(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>Dr(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);G.assertNever(n)}};Fe.create=(r,e,t)=>new Fe({schema:r,typeName:$.ZodEffects,effect:e,...U(t)});Fe.createWithPreprocess=(r,e,t)=>new Fe({schema:e,effect:{type:"preprocess",transform:r},typeName:$.ZodEffects,...U(t)});let xt=class extends V{_parse(e){return this._getType(e)===T.undefined?Ce(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};xt.create=(r,e)=>new xt({innerType:r,typeName:$.ZodOptional,...U(e)});let er=class extends V{_parse(e){return this._getType(e)===T.null?Ce(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};er.create=(r,e)=>new er({innerType:r,typeName:$.ZodNullable,...U(e)});let Hr=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===T.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Hr.create=(r,e)=>new Hr({innerType:r,typeName:$.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...U(e)});let mn=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ln(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ue(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ue(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};mn.create=(r,e)=>new mn({innerType:r,typeName:$.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...U(e)});let yn=class extends V{_parse(e){if(this._getType(e)!==T.nan){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.nan,received:t.parsedType}),M}return{status:"valid",value:e.data}}};yn.create=r=>new yn({typeName:$.ZodNaN,...U(r)});const Ul=Symbol("zod_brand");let Po=class extends V{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},ni=class Mo extends V{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?M:n.status==="dirty"?(t.dirty(),Zo(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?M:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Mo({in:e,out:t,typeName:$.ZodPipeline})}},gn=class extends V{_parse(e){const t=this._def.innerType._parse(e);return Dr(t)&&(t.value=Object.freeze(t.value)),t}};gn.create=(r,e)=>new gn({innerType:r,typeName:$.ZodReadonly,...U(e)});const Do=(r,e={},t)=>r?Or.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):Or.create(),Bl={object:ue.lazycreate};var $;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})($||($={}));const ql=(r,e={message:`Input not instance of ${r.name}`})=>Do(t=>t instanceof r,e),Lo=Tr.create,Uo=Lr.create,Vl=yn.create,Kl=Ur.create,Bo=Br.create,Wl=qr.create,Fl=dn.create,Yl=Vr.create,Jl=Kr.create,Gl=Or.create,Hl=Jt.create,Xl=Et.create,Ql=hn.create,ed=Qt.create,td=ue.create,rd=ue.strictCreate,sd=Wr.create,nd=Ao.create,ad=Fr.create,id=Pt.create,od=jo.create,cd=pn.create,ud=fn.create,ld=Ro.create,dd=Yr.create,hd=Jr.create,pd=Mt.create,fd=Gr.create,md=xr.create,Qi=Fe.create,yd=xt.create,gd=er.create,vd=Fe.createWithPreprocess,wd=ni.create,_d=()=>Lo().optional(),bd=()=>Uo().optional(),kd=()=>Bo().optional(),Td={string:r=>Tr.create({...r,coerce:!0}),number:r=>Lr.create({...r,coerce:!0}),boolean:r=>Br.create({...r,coerce:!0}),bigint:r=>Ur.create({...r,coerce:!0}),date:r=>qr.create({...r,coerce:!0})},Od=M;var f=Object.freeze({__proto__:null,defaultErrorMap:Mr,setErrorMap:El,getErrorMap:cn,makeIssue:un,EMPTY_PATH:Zl,addIssueToContext:N,ParseStatus:Oe,INVALID:M,DIRTY:Zo,OK:Ce,isAborted:Ra,isDirty:za,isValid:Dr,isAsync:ln,get util(){return G},get objectUtil(){return ja},ZodParsedType:T,getParsedType:jt,ZodType:V,ZodString:Tr,ZodNumber:Lr,ZodBigInt:Ur,ZodBoolean:Br,ZodDate:qr,ZodSymbol:dn,ZodUndefined:Vr,ZodNull:Kr,ZodAny:Or,ZodUnknown:Jt,ZodNever:Et,ZodVoid:hn,ZodArray:Qt,ZodObject:ue,ZodUnion:Wr,ZodDiscriminatedUnion:Ao,ZodIntersection:Fr,ZodTuple:Pt,ZodRecord:jo,ZodMap:pn,ZodSet:fn,ZodFunction:Ro,ZodLazy:Yr,ZodLiteral:Jr,ZodEnum:Mt,ZodNativeEnum:Gr,ZodPromise:xr,ZodEffects:Fe,ZodTransformer:Fe,ZodOptional:xt,ZodNullable:er,ZodDefault:Hr,ZodCatch:mn,ZodNaN:yn,BRAND:Ul,ZodBranded:Po,ZodPipeline:ni,ZodReadonly:gn,custom:Do,Schema:V,ZodSchema:V,late:Bl,get ZodFirstPartyTypeKind(){return $},coerce:Td,any:Gl,array:ed,bigint:Kl,boolean:Bo,date:Wl,discriminatedUnion:nd,effect:Qi,enum:pd,function:ld,instanceof:ql,intersection:ad,lazy:dd,literal:hd,map:cd,nan:Vl,nativeEnum:fd,never:Xl,null:Jl,nullable:gd,number:Uo,object:td,oboolean:kd,onumber:bd,optional:yd,ostring:_d,pipeline:wd,preprocess:vd,promise:md,record:od,set:ud,strictObject:rd,string:Lo,symbol:Fl,transformer:Qi,tuple:id,undefined:Yl,union:sd,unknown:Hl,void:Ql,NEVER:Od,ZodIssueCode:v,quotelessJson:Sl,ZodError:Ue});const ai=f.tuple([f.number(),f.number()]),qo=f.object({width:f.number(),height:f.number()}),xd=f.object({signedWidth:f.number(),signedHeight:f.number()}),Nd=["width","height"];f.enum(Nd);const Sd=["start","center","end"],Ed=["signedWidth","signedHeight"];f.enum(Ed);const vn=f.object({x:f.number(),y:f.number()}),Zd=f.object({clientX:f.number(),clientY:f.number()}),Id=["x","y"],Vo=f.enum(Id),Ko=["top","right","bottom","left"];f.enum(Ko);const Ad=["left","right"],Wo=f.enum(Ad),Cd=["top","bottom"],Fo=f.enum(Cd),Yo=["center"],eo=f.enum(Yo),$d=[...Ko,...Yo],Jo=f.enum($d);f.enum(Sd);const jd=["first","last"];f.enum(jd);const Rd=f.object({lower:f.number(),upper:f.number()});f.union([Rd,ai]);f.union([Vo,Jo]);f.union([Vo,Jo,f.instanceof(String)]);const zr=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),zd(t)},zd=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Pe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},Yn={};Object.defineProperty(Yn,"__esModule",{value:!0});function Pd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,s){return s.toUpperCase()}):""}Yn.default=Pd;var Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});function Md(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Jn.default=Md;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});function Dd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,s){return s.toUpperCase()}):""}Gn.default=Dd;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});function Ld(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}ii.default=Ld;var oi={};Object.defineProperty(oi,"__esModule",{value:!0});function Ud(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}oi.default=Ud;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});function Bd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}ci.default=Bd;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});function qd(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,s,n){return s+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}ui.default=qd;var li={};Object.defineProperty(li,"__esModule",{value:!0});function Vd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,s,n){return t+s.charAt(0).toUpperCase()+s.slice(1)+n}):""}li.default=Vd;var Hn={};Object.defineProperty(Hn,"__esModule",{value:!0});function Kd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Hn.default=Kd;var di={},ur={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(s){return e instanceof s})}})(ur);var Wd=Pe&&Pe.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(di,"__esModule",{value:!0});var ct=ur;function Bs(r,e){if(e===void 0&&(e=ct.DefaultOption),!ct.isValidObject(r))return null;e=ct.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toLowerCase();e.recursive&&(ct.isValidObject(n)?ct.belongToTypes(n,e.keepTypesOnRecursion)||(n=Bs(n,e)):e.recursiveInArray&&ct.isArrayObject(n)&&(n=Wd(n).map(function(i){var o=i;if(ct.isValidObject(i))ct.belongToTypes(o,e.keepTypesOnRecursion)||(o=Bs(i,e));else if(ct.isArrayObject(i)){var c=Bs({key:i},e);o=c.key}return o}))),t[a]=n}),t}di.default=Bs;var hi={},Fd=Pe&&Pe.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(hi,"__esModule",{value:!0});var ut=ur;function qs(r,e){if(e===void 0&&(e=ut.DefaultOption),!ut.isValidObject(r))return null;e=ut.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toUpperCase();e.recursive&&(ut.isValidObject(n)?ut.belongToTypes(n,e.keepTypesOnRecursion)||(n=qs(n,e)):e.recursiveInArray&&ut.isArrayObject(n)&&(n=Fd(n).map(function(i){var o=i;if(ut.isValidObject(i))ut.belongToTypes(o,e.keepTypesOnRecursion)||(o=qs(i,e));else if(ut.isArrayObject(i)){var c=qs({key:i},e);o=c.key}return o}))),t[a]=n}),t}hi.default=qs;var pi={},Yd=Pe&&Pe.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(pi,"__esModule",{value:!0});var lt=ur,Jd=Yn;function Vs(r,e){if(e===void 0&&(e=lt.DefaultOption),!lt.isValidObject(r))return null;e=lt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Jd.default(s);e.recursive&&(lt.isValidObject(n)?lt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Vs(n,e)):e.recursiveInArray&&lt.isArrayObject(n)&&(n=Yd(n).map(function(i){var o=i;if(lt.isValidObject(i))lt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Vs(i,e));else if(lt.isArrayObject(i)){var c=Vs({key:i},e);o=c.key}return o}))),t[a]=n}),t}pi.default=Vs;var fi={},Gd=Pe&&Pe.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(fi,"__esModule",{value:!0});var dt=ur,Hd=Jn;function Ks(r,e){if(e===void 0&&(e=dt.DefaultOption),!dt.isValidObject(r))return null;e=dt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Hd.default(s);e.recursive&&(dt.isValidObject(n)?dt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Ks(n,e)):e.recursiveInArray&&dt.isArrayObject(n)&&(n=Gd(n).map(function(i){var o=i;if(dt.isValidObject(i))dt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ks(i,e));else if(dt.isArrayObject(i)){var c=Ks({key:i},e);o=c.key}return o}))),t[a]=n}),t}fi.default=Ks;var mi={},Xd=Pe&&Pe.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(mi,"__esModule",{value:!0});var ht=ur,Qd=Gn;function Ws(r,e){if(e===void 0&&(e=ht.DefaultOption),!ht.isValidObject(r))return null;e=ht.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Qd.default(s);e.recursive&&(ht.isValidObject(n)?ht.belongToTypes(n,e.keepTypesOnRecursion)||(n=Ws(n,e)):e.recursiveInArray&&ht.isArrayObject(n)&&(n=Xd(n).map(function(i){var o=i;if(ht.isValidObject(i))ht.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ws(i,e));else if(ht.isArrayObject(i)){var c=Ws({key:i},e);o=c.key}return o}))),t[a]=n}),t}mi.default=Ws;var yi={},eh=Pe&&Pe.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(yi,"__esModule",{value:!0});var pt=ur,th=Hn;function Fs(r,e){if(e===void 0&&(e=pt.DefaultOption),!pt.isValidObject(r))return null;e=pt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=th.default(s);e.recursive&&(pt.isValidObject(n)?pt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Fs(n,e)):e.recursiveInArray&&pt.isArrayObject(n)&&(n=eh(n).map(function(i){var o=i;if(pt.isValidObject(i))pt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Fs(i,e));else if(pt.isArrayObject(i)){var c=Fs({key:i},e);o=c.key}return o}))),t[a]=n}),t}yi.default=Fs;Object.defineProperty(F,"__esModule",{value:!0});F.kebabKeys=F.pascalKeys=F.snakeKeys=F.camelKeys=F.upperKeys=F.lowerKeys=F.toLowerCase=F.toUpperCase=F.toKebabCase=F.toHeaderCase=F.toSentenceCase=F.toTextCase=F.toPathCase=F.toDotCase=F.toPascalCase=F.toSnakeCase=F.toCamelCase=void 0;var Go=Yn;F.toCamelCase=Go.default;var Ho=Jn;F.toSnakeCase=Ho.default;var Xo=Gn;F.toPascalCase=Xo.default;var Qo=ii;F.toDotCase=Qo.default;var ec=oi;F.toPathCase=ec.default;var tc=ci;F.toTextCase=tc.default;var rc=ui;F.toSentenceCase=rc.default;var sc=li;F.toHeaderCase=sc.default;var nc=Hn;F.toKebabCase=nc.default;var ac=di;F.lowerKeys=ac.default;var ic=hi;F.upperKeys=ic.default;var oc=pi;F.camelKeys=oc.default;var cc=fi;F.snakeKeys=cc.default;var uc=mi;F.pascalKeys=uc.default;var lc=yi;F.kebabKeys=lc.default;var dc=function(r){return String(r||"").toLowerCase()};F.toLowerCase=dc;var hc=function(r){return String(r||"").toUpperCase()};F.toUpperCase=hc;var rh={toCamelCase:Go.default,toSnakeCase:Ho.default,toPascalCase:Xo.default,toDotCase:Qo.default,toPathCase:ec.default,toTextCase:tc.default,toSentenceCase:rc.default,toHeaderCase:sc.default,toKebabCase:nc.default,toUpperCase:hc,toLowerCase:dc,lowerKeys:ac.default,upperKeys:ic.default,camelKeys:oc.default,snakeKeys:cc.default,pascalKeys:uc.default,kebabKeys:lc.default};F.default=rh;var pc=F;const fc={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},sh=r=>pc.snakeKeys(r,fc),nh=r=>pc.camelKeys(r,fc);var wn;(r=>{r.toSnake=sh,r.toCamel=nh,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(wn||(wn={}));f.object({x:Wo.or(eo),y:Fo.or(eo)});const ah=f.object({x:Wo,y:Fo}),ih=Object.freeze({x:"left",y:"top"}),oh=(r,e)=>r.x===e.x&&r.y===e.y,to=f.union([f.number(),vn,ai,qo,xd,Zd]),ch=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},ro={x:0,y:0},zs=f.union([f.number(),f.string()]);f.object({top:zs,left:zs,width:zs,height:zs});f.object({left:f.number(),top:f.number(),right:f.number(),bottom:f.number()});f.object({one:vn,two:vn,root:ah});const gi=(r,e,t=0,s=0,n)=>{const a={one:{...ro},two:{...ro},root:n??ih};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+s}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},fa=r=>{const e=gi(r);return{lower:e.one.x,upper:e.two.x}},ma=r=>{const e=gi(r);return{lower:e.one.y,upper:e.two.y}},uh=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,lh=f.object({signedWidth:f.number(),signedHeight:f.number()});f.union([qo,lh,vn,ai]);const dh=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);f.object({offset:to,scale:to});const hh=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],ph=r=>(e,t,s,n)=>[e,n?s/r:s*r],fh=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:i,upper:o}=r,c=a-n,l=o-i;if(t==="dimension")return[r,s*(l/c)];const h=(s-n)*(l/c)+i;return[r,h]},mh=r=>(e,t,s)=>[r,s],yh=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},gh=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=dh(s,n,a),[e,s]},Ba=class Cr{constructor(){p(this,"ops",[]),p(this,"currBounds",null),p(this,"currType",null),p(this,"reversed",!1),this.ops=[]}static translate(e){return new Cr().translate(e)}static magnify(e){return new Cr().magnify(e)}static scale(e,t){return new Cr().scale(e,t)}translate(e){const t=this.new(),s=hh(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=ph(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=zr(e,t),n=this.new(),a=fh(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=zr(e,t),n=this.new(),a=gh(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=zr(e,t),n=this.new(),a=mh(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=yh();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Cr;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([i,o])=>n>=i&&n<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}};p(Ba,"IDENTITY",new Ba);let so=Ba;const no=class _t{constructor(e=new so,t=new so,s=null){p(this,"x"),p(this,"y"),p(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new _t().translate(e,t)}static translateX(e){return new _t().translateX(e)}static translateY(e){return new _t().translateY(e)}static clamp(e){return new _t().clamp(e)}static magnify(e){return new _t().magnify(e)}static scale(e){return new _t().scale(e)}static reBound(e){return new _t().reBound(e)}translate(e,t){const s=ch(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(uh(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!oh(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(fa(e)),t.y=t.y.scale(ma(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(fa(e)),t.y=this.y.reBound(ma(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(fa(e)),t.y=this.y.clamp(ma(e)),t}copy(){const e=new _t;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return gi(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};p(no,"IDENTITY",new no);const mc=(r,e)=>{const t=new J(e);if(![ce.DAY,ce.HOUR,ce.MINUTE,ce.SECOND,ce.MILLISECOND,ce.MICROSECOND,ce.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof J?new J(s):new ce(s)},se=class z{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new z(BigInt(n.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=z.hours(parseInt(s??"00",10)).add(z.minutes(parseInt(n??"00",10))).add(z.seconds(parseInt(i??"00",10))).add(z.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(z.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new z(BigInt(s.getTime())*z.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(e="UTC"){const t=this.date(),s=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${s} ${n}`}static get utcOffset(){return new ce(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new ze(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return mc(this,e)}get isToday(){return this.truncate(ce.DAY).equals(z.now().truncate(ce.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let t=z.MIN;for(const s of e){const n=new z(s);n.after(t)&&(t=n)}return t}static min(...e){let t=z.MAX;for(const s of e){const n=new z(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};p(se,"NANOSECOND",se.nanoseconds(1)),p(se,"MICROSECOND",se.microseconds(1)),p(se,"MILLISECOND",se.milliseconds(1)),p(se,"SECOND",se.seconds(1)),p(se,"MINUTE",se.minutes(1)),p(se,"HOUR",se.hours(1)),p(se,"DAY",se.days(1)),p(se,"MAX",new se((1n<<63n)-1n)),p(se,"MIN",new se(0)),p(se,"ZERO",new se(0)),p(se,"z",f.union([f.object({value:f.bigint()}).transform(r=>new se(r.value)),f.string().transform(r=>new se(BigInt(r))),f.instanceof(Number).transform(r=>new se(r)),f.number().transform(r=>new se(r)),f.instanceof(se)]));let J=se;const ne=class Q{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new Q(e).valueOf()}greaterThan(e){return this.valueOf()>new Q(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new Q(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new Q(e).valueOf()}remainder(e){return mc(this,e)}truncate(e){return new Q(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(Q.DAY),t=this.truncate(Q.HOUR),s=this.truncate(Q.MINUTE),n=this.truncate(Q.SECOND),a=this.truncate(Q.MILLISECOND),i=this.truncate(Q.MICROSECOND),o=this.truncate(Q.NANOSECOND),c=e,l=t.sub(e),h=s.sub(t),k=n.sub(s),oe=a.sub(n),ge=i.sub(a),Re=o.sub(i);let he="";return c.isZero||(he+=`${c.days}d `),l.isZero||(he+=`${l.hours}h `),h.isZero||(he+=`${h.minutes}m `),k.isZero||(he+=`${k.seconds}s `),oe.isZero||(he+=`${oe.milliseconds}ms `),ge.isZero||(he+=`${ge.microseconds}µs `),Re.isZero||(he+=`${Re.nanoseconds}ns`),he.trim()}get days(){return Number(this.valueOf()/Q.DAY.valueOf())}get hours(){return Number(this.valueOf()/Q.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/Q.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/Q.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/Q.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/Q.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new Q(e).valueOf()}add(e){return new Q(this.valueOf()+new Q(e).valueOf())}sub(e){return new Q(this.valueOf()-new Q(e).valueOf())}static nanoseconds(e=1){return new Q(e)}static microseconds(e=1){return Q.nanoseconds(e*1e3)}static milliseconds(e=1){return Q.microseconds(e*1e3)}static seconds(e=1){return Q.milliseconds(e*1e3)}static minutes(e){return Q.seconds(e.valueOf()*60)}static hours(e){return Q.minutes(e*60)}static days(e){return Q.hours(e*24)}};p(ne,"NANOSECOND",ne.nanoseconds(1)),p(ne,"MICROSECOND",ne.microseconds(1)),p(ne,"MILLISECOND",ne.milliseconds(1)),p(ne,"SECOND",ne.seconds(1)),p(ne,"MINUTE",ne.minutes(1)),p(ne,"HOUR",ne.hours(1)),p(ne,"DAY",ne.days(1)),p(ne,"MAX",new ne((1n<<63n)-1n)),p(ne,"MIN",new ne(0)),p(ne,"ZERO",new ne(0)),p(ne,"z",f.union([f.object({value:f.bigint()}).transform(r=>new ne(r.value)),f.string().transform(r=>new ne(BigInt(r))),f.instanceof(Number).transform(r=>new ne(r)),f.number().transform(r=>new ne(r)),f.instanceof(ne)]));let ce=ne;const $r=class Ys extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ys(e).valueOf()}get period(){return ce.seconds(1/this.valueOf())}sampleCount(e){return new ce(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new Te(t).valueOf()}span(e){return ce.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ys(e)}static khz(e){return Ys.hz(e*1e3)}};p($r,"z",f.union([f.number().transform(r=>new $r(r)),f.instanceof(Number).transform(r=>new $r(r)),f.instanceof($r)]));let Xn=$r;const ve=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new _n(e*this.valueOf())}};p(ve,"UNKNOWN",new ve(0)),p(ve,"BIT128",new ve(16)),p(ve,"BIT64",new ve(8)),p(ve,"BIT32",new ve(4)),p(ve,"BIT16",new ve(2)),p(ve,"BIT8",new ve(1)),p(ve,"z",f.union([f.number().transform(r=>new ve(r)),f.instanceof(Number).transform(r=>new ve(r)),f.instanceof(ve)]));let Te=ve;const He=class Js{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new J(e.start),this.end=new J(e.end)):(this.start=new J(e),this.end=new J(t))}get span(){return new ce(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Js(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Js?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Js(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};p(He,"MAX",new He(J.MIN,J.MAX)),p(He,"MIN",new He(J.MAX,J.MIN)),p(He,"ZERO",new He(J.ZERO,J.ZERO)),p(He,"z",f.union([f.object({start:J.z,end:J.z}).transform(r=>new He(r.start,r.end)),f.instanceof(He)]));let ze=He;const y=class Xe extends String{constructor(e){if(e instanceof Xe||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=Xe.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(Xe.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=Xe.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(Xe.JSON)||this.equals(Xe.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(Xe.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=Xe.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return Xe.BIG_INT_TYPES.some(e=>e.equals(this))}};p(y,"UNKNOWN",new y("unknown")),p(y,"FLOAT64",new y("float64")),p(y,"FLOAT32",new y("float32")),p(y,"INT64",new y("int64")),p(y,"INT32",new y("int32")),p(y,"INT16",new y("int16")),p(y,"INT8",new y("int8")),p(y,"UINT64",new y("uint64")),p(y,"UINT32",new y("uint32")),p(y,"UINT16",new y("uint16")),p(y,"UINT8",new y("uint8")),p(y,"BOOLEAN",y.UINT8),p(y,"TIMESTAMP",new y("timestamp")),p(y,"UUID",new y("uuid")),p(y,"STRING",new y("string")),p(y,"JSON",new y("json")),p(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),p(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),p(y,"DENSITIES",new Map([[y.UINT8.toString(),Te.BIT8],[y.UINT16.toString(),Te.BIT16],[y.UINT32.toString(),Te.BIT32],[y.UINT64.toString(),Te.BIT64],[y.FLOAT32.toString(),Te.BIT32],[y.FLOAT64.toString(),Te.BIT64],[y.INT8.toString(),Te.BIT8],[y.INT16.toString(),Te.BIT16],[y.INT32.toString(),Te.BIT32],[y.INT64.toString(),Te.BIT64],[y.TIMESTAMP.toString(),Te.BIT64],[y.STRING.toString(),Te.UNKNOWN],[y.JSON.toString(),Te.UNKNOWN],[y.UUID.toString(),Te.BIT128]])),p(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),p(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),p(y,"z",f.union([f.string().transform(r=>new y(r)),f.instanceof(y)]));let te=y;const be=class pe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return pe.bytes(this.valueOf()+e.valueOf())}sub(e){return pe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new pe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return pe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/pe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/pe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/pe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/pe.TERABYTE.valueOf()}toString(){const e=this.truncate(pe.TERABYTE),t=this.truncate(pe.GIGABYTE),s=this.truncate(pe.MEGABYTE),n=this.truncate(pe.KILOBYTE),a=this.truncate(pe.BYTE),i=e,o=t.sub(e),c=s.sub(t),l=n.sub(s),h=a.sub(n);let k="";return i.isZero||(k+=`${i.terabytes}TB `),o.isZero||(k+=`${o.gigabytes}GB `),c.isZero||(k+=`${c.megabytes}MB `),l.isZero||(k+=`${l.kilobytes}KB `),(!h.isZero||k==="")&&(k+=`${h.valueOf()}B`),k.trim()}static bytes(e=1){return new pe(e)}static kilobytes(e=1){return pe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return pe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return pe.megabytes(e.valueOf()*1e3)}static terabytes(e){return pe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(be,"BYTE",new be(1)),p(be,"KILOBYTE",be.kilobytes(1)),p(be,"MEGABYTE",be.megabytes(1)),p(be,"GIGABYTE",be.gigabytes(1)),p(be,"TERABYTE",be.terabytes(1)),p(be,"ZERO",new be(0)),p(be,"z",f.union([f.number().transform(r=>new be(r)),f.instanceof(be)]));let _n=be;f.union([f.instanceof(Uint8Array),f.instanceof(Uint16Array),f.instanceof(Uint32Array),f.instanceof(BigUint64Array),f.instanceof(Float32Array),f.instanceof(Float64Array),f.instanceof(Int8Array),f.instanceof(Int16Array),f.instanceof(Int32Array),f.instanceof(BigInt64Array)]);const yc=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof J||r instanceof ce||r instanceof Date},vh=(r,e,t,s=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(s):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(s):jr(t,-s),wh=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof vr?!0:yc(r),Yt=-1;let vr=class bt{constructor(e){p(this,"key",""),p(this,"dataType"),p(this,"sampleOffset"),p(this,"gl"),p(this,"_data"),p(this,"_timeRange"),p(this,"alignment",0),p(this,"_cachedMin"),p(this,"_cachedMax"),p(this,"writePos",Yt),p(this,"_refCount",0),p(this,"_cachedLength"),wh(e)&&(e={data:e});const{dataType:t,timeRange:s,sampleOffset:n=0,glBufferUsage:a="static",alignment:i=0,key:o=Tl()}=e,{data:c}=e;if(c instanceof bt){this.key=c.key,this.dataType=c.dataType,this.sampleOffset=c.sampleOffset,this.gl=c.gl,this._data=c._data,this._timeRange=c._timeRange,this.alignment=c.alignment,this._cachedMin=c._cachedMin,this._cachedMax=c._cachedMax,this.writePos=c.writePos,this._refCount=c._refCount,this._cachedLength=c._cachedLength;return}const l=yc(c),h=Array.isArray(c);if(t!=null)this.dataType=new te(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(h||l){let k=c;if(!l){if(c.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");k=c[0]}if(typeof k=="string")this.dataType=te.STRING;else if(typeof k=="number")this.dataType=te.FLOAT64;else if(typeof k=="bigint")this.dataType=te.INT64;else if(typeof k=="boolean")this.dataType=te.BOOLEAN;else if(k instanceof J||k instanceof Date||k instanceof J)this.dataType=te.TIMESTAMP;else if(typeof k=="object")this.dataType=te.JSON;else throw new Error(`cannot infer data type of ${typeof k} when constructing a Series from a JS array`)}else this.dataType=new te(c)}if(!h&&!l)this._data=c;else{let k=l?[c]:c;const oe=k[0];(oe instanceof J||oe instanceof Date||oe instanceof ce)&&(k=k.map(ge=>new J(ge).valueOf())),this.dataType.equals(te.STRING)?(this._cachedLength=k.length,this._data=new TextEncoder().encode(k.join(`
1
+ "use strict";var Zl=Object.defineProperty;var Il=(r,e,t)=>e in r?Zl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var d=(r,e,t)=>(Il(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var Al=Object.defineProperty,$l=(r,e,t)=>e in r?Al(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,fe=(r,e,t)=>($l(r,typeof e!="symbol"?e+"":e,t),t),Cl=Object.defineProperty,jl=(r,e,t)=>e in r?Cl(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,b=(r,e,t)=>(jl(r,typeof e!="symbol"?e+"":e,t),t),J;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(J||(J={}));var Aa;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Aa||(Aa={}));const T=J.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zt=r=>{switch(typeof r){case"undefined":return T.undefined;case"string":return T.string;case"number":return isNaN(r)?T.nan:T.number;case"boolean":return T.boolean;case"function":return T.function;case"bigint":return T.bigint;case"symbol":return T.symbol;case"object":return Array.isArray(r)?T.array:r===null?T.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?T.promise:typeof Map<"u"&&r instanceof Map?T.map:typeof Set<"u"&&r instanceof Set?T.set:typeof Date<"u"&&r instanceof Date?T.date:T.object;default:return T.unknown}},v=J.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Rl=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let qe=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,J.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};qe.create=r=>new qe(r);const Cr=(r,e)=>{let t;switch(r.code){case v.invalid_type:r.received===T.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case v.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,J.jsonStringifyReplacer)}`;break;case v.unrecognized_keys:t=`Unrecognized key(s) in object: ${J.joinValues(r.keys,", ")}`;break;case v.invalid_union:t="Invalid input";break;case v.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${J.joinValues(r.options)}`;break;case v.invalid_enum_value:t=`Invalid enum value. Expected ${J.joinValues(r.options)}, received '${r.received}'`;break;case v.invalid_arguments:t="Invalid function arguments";break;case v.invalid_return_type:t="Invalid function return type";break;case v.invalid_date:t="Invalid date";break;case v.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:J.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case v.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case v.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case v.custom:t="Invalid input";break;case v.invalid_intersection_types:t="Intersection results could not be merged";break;case v.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case v.not_finite:t="Number must be finite";break;default:t=e.defaultError,J.assertNever(r)}return{message:t}};let Ao=Cr;function zl(r){Ao=r}function cn(){return Ao}const un=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Pl=[];function N(r,e){const t=un({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,cn(),Cr].filter(s=>!!s)});r.common.issues.push(t)}let Ce=class $o{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return M;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return $o.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return M;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}};const M=Object.freeze({status:"aborted"}),Co=r=>({status:"dirty",value:r}),Ie=r=>({status:"valid",value:r}),$a=r=>r.status==="aborted",Ca=r=>r.status==="dirty",jr=r=>r.status==="valid",ln=r=>typeof Promise<"u"&&r instanceof Promise;var Z;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Z||(Z={}));let at=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const to=(r,e)=>{if(jr(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new qe(r.common.issues);return this._error=t,this._error}}};function U(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}let q=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return zt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ce,ctx:{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ln(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return to(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(ln(n)?n:Promise.resolve(n));return to(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:v.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Ge({schema:this,typeName:C.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Nt.create(this,this._def)}nullable(){return Qt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Xt.create(this,this._def)}promise(){return _r.create(this,this._def)}or(e){return Ur.create([this,e],this._def)}and(e){return Br.create(this,e,this._def)}transform(e){return new Ge({...U(this._def),schema:this,typeName:C.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Wr({...U(this._def),innerType:this,defaultValue:t,typeName:C.ZodDefault})}brand(){return new Do({typeName:C.ZodBranded,type:this,...U(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new mn({...U(this._def),innerType:this,catchValue:t,typeName:C.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ni.create(this,e)}readonly(){return gn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Ml=/^c[^\s-]{8,}$/i,Dl=/^[a-z][a-z0-9]*$/,Ll=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ul=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Bl=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Vl="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let la;const ql=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Kl=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Wl=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Fl(r,e){return!!((e==="v4"||!e)&&ql.test(r)||(e==="v6"||!e)&&Kl.test(r))}class Ue extends q{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==T.string){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.string,received:n.parsedType}),M}const t=new Ce;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?N(s,{code:v.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&N(s,{code:v.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Bl.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"email",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")la||(la=new RegExp(Vl,"u")),la.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"emoji",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Ul.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"uuid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Ml.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Dl.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"cuid2",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Ll.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ulid",code:v.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),N(s,{validation:"url",code:v.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"regex",code:v.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Wl(n).test(e.data)||(s=this._getOrReturnCtx(e,s),N(s,{code:v.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Fl(e.data,n.version)||(s=this._getOrReturnCtx(e,s),N(s,{validation:"ip",code:v.invalid_string,message:n.message}),t.dirty()):J.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:v.invalid_string,...Z.errToObj(s)})}_addCheck(e){return new Ue({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Z.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Z.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Z.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Z.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Z.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Z.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Z.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Z.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...Z.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Z.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Z.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Z.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Z.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Z.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Z.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Z.errToObj(t)})}nonempty(e){return this.min(1,Z.errToObj(e))}trim(){return new Ue({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ue({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ue({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ue.create=r=>{var e;return new Ue({checks:[],typeName:C.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...U(r)})};function Yl(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}let Rr=class ja extends q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==T.number){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.number,received:n.parsedType}),M}let t;const s=new Ce;for(const n of this._def.checks)n.kind==="int"?J.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:v.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Yl(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_finite,message:n.message}),s.dirty()):J.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,s,n){return new ja({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Z.toString(n)}]})}_addCheck(e){return new ja({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Z.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Z.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Z.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Z.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&J.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}};Rr.create=r=>new Rr({checks:[],typeName:C.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...U(r)});let zr=class Ra extends q{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==T.bigint){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.bigint,received:n.parsedType}),M}let t;const s=new Ce;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),N(t,{code:v.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):J.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Z.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Z.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Z.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Z.toString(t))}setLimit(e,t,s,n){return new Ra({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:Z.toString(n)}]})}_addCheck(e){return new Ra({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Z.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Z.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Z.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};zr.create=r=>{var e;return new zr({checks:[],typeName:C.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...U(r)})};class Pr extends q{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==T.boolean){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.boolean,received:t.parsedType}),M}return Ie(e.data)}}Pr.create=r=>new Pr({typeName:C.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...U(r)});let Mr=class jo extends q{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==T.date){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_type,expected:T.date,received:n.parsedType}),M}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return N(n,{code:v.invalid_date}),M}const t=new Ce;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),N(s,{code:v.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):J.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new jo({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Z.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Z.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Mr.create=r=>new Mr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:C.ZodDate,...U(r)});let dn=class extends q{_parse(e){if(this._getType(e)!==T.symbol){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.symbol,received:t.parsedType}),M}return Ie(e.data)}};dn.create=r=>new dn({typeName:C.ZodSymbol,...U(r)});class Dr extends q{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.undefined,received:t.parsedType}),M}return Ie(e.data)}}Dr.create=r=>new Dr({typeName:C.ZodUndefined,...U(r)});class Lr extends q{_parse(e){if(this._getType(e)!==T.null){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.null,received:t.parsedType}),M}return Ie(e.data)}}Lr.create=r=>new Lr({typeName:C.ZodNull,...U(r)});let wr=class extends q{constructor(){super(...arguments),this._any=!0}_parse(e){return Ie(e.data)}};wr.create=r=>new wr({typeName:C.ZodAny,...U(r)});let Yt=class extends q{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ie(e.data)}};Yt.create=r=>new Yt({typeName:C.ZodUnknown,...U(r)});class Zt extends q{_parse(e){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.never,received:t.parsedType}),M}}Zt.create=r=>new Zt({typeName:C.ZodNever,...U(r)});class hn extends q{_parse(e){if(this._getType(e)!==T.undefined){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.void,received:t.parsedType}),M}return Ie(e.data)}}hn.create=r=>new hn({typeName:C.ZodVoid,...U(r)});let Xt=class Ps extends q{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==T.array)return N(t,{code:v.invalid_type,expected:T.array,received:t.parsedType}),M;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(N(t,{code:i?v.too_big:v.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(N(t,{code:v.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(N(t,{code:v.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new at(t,i,t.path,o)))).then(i=>Ce.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new at(t,i,t.path,o)));return Ce.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Ps({...this._def,minLength:{value:e,message:Z.toString(t)}})}max(e,t){return new Ps({...this._def,maxLength:{value:e,message:Z.toString(t)}})}length(e,t){return new Ps({...this._def,exactLength:{value:e,message:Z.toString(t)}})}nonempty(e){return this.min(1,e)}};Xt.create=(r,e)=>new Xt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:C.ZodArray,...U(e)});function dr(r){if(r instanceof Pe){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Nt.create(dr(s))}return new Pe({...r._def,shape:()=>e})}else return r instanceof Xt?new Xt({...r._def,type:dr(r.element)}):r instanceof Nt?Nt.create(dr(r.unwrap())):r instanceof Qt?Qt.create(dr(r.unwrap())):r instanceof Dt?Dt.create(r.items.map(e=>dr(e))):r}let Pe=class Le extends q{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=J.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==T.object){const c=this._getOrReturnCtx(e);return N(c,{code:v.invalid_type,expected:T.object,received:c.parsedType}),M}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Zt&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=n[c],h=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new at(s,h,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Zt){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")i.length>0&&(N(s,{code:v.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new at(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>Ce.mergeObjectSync(t,c)):Ce.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Z.errToObj,new Le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=Z.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Le({...this._def,unknownKeys:"strip"})}passthrough(){return new Le({...this._def,unknownKeys:"passthrough"})}extend(e){return new Le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:C.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Le({...this._def,catchall:e})}pick(e){const t={};return J.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new Le({...this._def,shape:()=>t})}omit(e){const t={};return J.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new Le({...this._def,shape:()=>t})}deepPartial(){return dr(this)}partial(e){const t={};return J.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new Le({...this._def,shape:()=>t})}required(e){const t={};return J.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Nt;)n=n._def.innerType;t[s]=n}}),new Le({...this._def,shape:()=>t})}keyof(){return Mo(J.objectKeys(this.shape))}};Pe.create=(r,e)=>new Pe({shape:()=>r,unknownKeys:"strip",catchall:Zt.create(),typeName:C.ZodObject,...U(e)});Pe.strictCreate=(r,e)=>new Pe({shape:()=>r,unknownKeys:"strict",catchall:Zt.create(),typeName:C.ZodObject,...U(e)});Pe.lazycreate=(r,e)=>new Pe({shape:r,unknownKeys:"strip",catchall:Zt.create(),typeName:C.ZodObject,...U(e)});class Ur extends q{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new qe(o.ctx.common.issues));return N(t,{code:v.invalid_union,unionErrors:i}),M}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new qe(c));return N(t,{code:v.invalid_union,unionErrors:o}),M}}get options(){return this._def.options}}Ur.create=(r,e)=>new Ur({options:r,typeName:C.ZodUnion,...U(e)});const Ms=r=>r instanceof Vr?Ms(r.schema):r instanceof Ge?Ms(r.innerType()):r instanceof qr?[r.value]:r instanceof xs?r.options:r instanceof Kr?Object.keys(r.enum):r instanceof Wr?Ms(r._def.innerType):r instanceof Dr?[void 0]:r instanceof Lr?[null]:null;class Wn extends q{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.object)return N(t,{code:v.invalid_type,expected:T.object,received:t.parsedType}),M;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(N(t,{code:v.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),M)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Ms(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Wn({typeName:C.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...U(s)})}}function za(r,e){const t=zt(r),s=zt(e);if(r===e)return{valid:!0,data:r};if(t===T.object&&s===T.object){const n=J.objectKeys(e),a=J.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=za(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===T.array&&s===T.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=za(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===T.date&&s===T.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let Br=class extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if($a(a)||$a(i))return M;const o=za(a.value,i.value);return o.valid?((Ca(a)||Ca(i))&&t.dirty(),{status:t.value,value:o.data}):(N(s,{code:v.invalid_intersection_types}),M)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};Br.create=(r,e,t)=>new Br({left:r,right:e,typeName:C.ZodIntersection,...U(t)});let Dt=class Ro extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.array)return N(s,{code:v.invalid_type,expected:T.array,received:s.parsedType}),M;if(s.data.length<this._def.items.length)return N(s,{code:v.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),M;!this._def.rest&&s.data.length>this._def.items.length&&(N(s,{code:v.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new at(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>Ce.mergeArray(t,a)):Ce.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new Ro({...this._def,rest:e})}};Dt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Dt({items:r,typeName:C.ZodTuple,rest:null,...U(e)})};let zo=class Pa extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.object)return N(s,{code:v.invalid_type,expected:T.object,received:s.parsedType}),M;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new at(s,o,s.path,o)),value:i._parse(new at(s,s.data[o],s.path,o))});return s.common.async?Ce.mergeObjectAsync(t,n):Ce.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof q?new Pa({keyType:e,valueType:t,typeName:C.ZodRecord,...U(s)}):new Pa({keyType:Ue.create(),valueType:e,typeName:C.ZodRecord,...U(t)})}},pn=class extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.map)return N(s,{code:v.invalid_type,expected:T.map,received:s.parsedType}),M;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new at(s,o,s.path,[l,"key"])),value:a._parse(new at(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return M;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};pn.create=(r,e,t)=>new pn({valueType:e,keyType:r,typeName:C.ZodMap,...U(t)});let fn=class Ma extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==T.set)return N(s,{code:v.invalid_type,expected:T.set,received:s.parsedType}),M;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(N(s,{code:v.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(N(s,{code:v.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return M;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new at(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Ma({...this._def,minSize:{value:e,message:Z.toString(t)}})}max(e,t){return new Ma({...this._def,maxSize:{value:e,message:Z.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};fn.create=(r,e)=>new fn({valueType:r,minSize:null,maxSize:null,typeName:C.ZodSet,...U(e)});let Po=class Ds extends q{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.function)return N(t,{code:v.invalid_type,expected:T.function,received:t.parsedType}),M;function s(o,c){return un({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cn(),Cr].filter(l=>!!l),issueData:{code:v.invalid_arguments,argumentsError:c}})}function n(o,c){return un({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,cn(),Cr].filter(l=>!!l),issueData:{code:v.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof _r){const o=this;return Ie(async function(...c){const l=new qe([]),h=await o._def.args.parseAsync(c,a).catch(se=>{throw l.addIssue(s(c,se)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(se=>{throw l.addIssue(n(k,se)),l})})}else{const o=this;return Ie(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new qe([s(c,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new qe([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Ds({...this._def,args:Dt.create(e).rest(Yt.create())})}returns(e){return new Ds({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Ds({args:e||Dt.create([]).rest(Yt.create()),returns:t||Yt.create(),typeName:C.ZodFunction,...U(s)})}},Vr=class extends q{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};Vr.create=(r,e)=>new Vr({getter:r,typeName:C.ZodLazy,...U(e)});class qr extends q{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return N(t,{received:t.data,code:v.invalid_literal,expected:this._def.value}),M}return{status:"valid",value:e.data}}get value(){return this._def.value}}qr.create=(r,e)=>new qr({value:r,typeName:C.ZodLiteral,...U(e)});function Mo(r,e){return new xs({values:r,typeName:C.ZodEnum,...U(e)})}let xs=class Da extends q{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return N(t,{expected:J.joinValues(s),received:t.parsedType,code:v.invalid_type}),M}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return N(t,{received:t.data,code:v.invalid_enum_value,options:s}),M}return Ie(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Da.create(e)}exclude(e){return Da.create(this.options.filter(t=>!e.includes(t)))}};xs.create=Mo;let Kr=class extends q{_parse(e){const t=J.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==T.string&&s.parsedType!==T.number){const n=J.objectValues(t);return N(s,{expected:J.joinValues(n),received:s.parsedType,code:v.invalid_type}),M}if(t.indexOf(e.data)===-1){const n=J.objectValues(t);return N(s,{received:s.data,code:v.invalid_enum_value,options:n}),M}return Ie(e.data)}get enum(){return this._def.values}};Kr.create=(r,e)=>new Kr({values:r,typeName:C.ZodNativeEnum,...U(e)});let _r=class extends q{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==T.promise&&t.common.async===!1)return N(t,{code:v.invalid_type,expected:T.promise,received:t.parsedType}),M;const s=t.parsedType===T.promise?t.data:Promise.resolve(t.data);return Ie(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};_r.create=(r,e)=>new _r({type:r,typeName:C.ZodPromise,...U(e)});let Ge=class extends q{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===C.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{N(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?M:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!jr(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>jr(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);J.assertNever(n)}};Ge.create=(r,e,t)=>new Ge({schema:r,typeName:C.ZodEffects,effect:e,...U(t)});Ge.createWithPreprocess=(r,e,t)=>new Ge({schema:e,effect:{type:"preprocess",transform:r},typeName:C.ZodEffects,...U(t)});let Nt=class extends q{_parse(e){return this._getType(e)===T.undefined?Ie(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Nt.create=(r,e)=>new Nt({innerType:r,typeName:C.ZodOptional,...U(e)});let Qt=class extends q{_parse(e){return this._getType(e)===T.null?Ie(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Qt.create=(r,e)=>new Qt({innerType:r,typeName:C.ZodNullable,...U(e)});let Wr=class extends q{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===T.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Wr.create=(r,e)=>new Wr({innerType:r,typeName:C.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...U(e)});let mn=class extends q{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return ln(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new qe(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new qe(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};mn.create=(r,e)=>new mn({innerType:r,typeName:C.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...U(e)});let yn=class extends q{_parse(e){if(this._getType(e)!==T.nan){const t=this._getOrReturnCtx(e);return N(t,{code:v.invalid_type,expected:T.nan,received:t.parsedType}),M}return{status:"valid",value:e.data}}};yn.create=r=>new yn({typeName:C.ZodNaN,...U(r)});const Gl=Symbol("zod_brand");let Do=class extends q{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}},ni=class Lo extends q{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?M:n.status==="dirty"?(t.dirty(),Co(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?M:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Lo({in:e,out:t,typeName:C.ZodPipeline})}};class gn extends q{_parse(e){const t=this._def.innerType._parse(e);return jr(t)&&(t.value=Object.freeze(t.value)),t}}gn.create=(r,e)=>new gn({innerType:r,typeName:C.ZodReadonly,...U(e)});const Uo=(r,e={},t)=>r?wr.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):wr.create(),Jl={object:Pe.lazycreate};var C;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(C||(C={}));const Hl=(r,e={message:`Input not instance of ${r.name}`})=>Uo(t=>t instanceof r,e),Bo=Ue.create,Vo=Rr.create,Xl=yn.create,Ql=zr.create,qo=Pr.create,ed=Mr.create,td=dn.create,rd=Dr.create,sd=Lr.create,nd=wr.create,ad=Yt.create,id=Zt.create,od=hn.create,cd=Xt.create,ud=Pe.create,ld=Pe.strictCreate,dd=Ur.create,hd=Wn.create,pd=Br.create,fd=Dt.create,md=zo.create,yd=pn.create,gd=fn.create,vd=Po.create,wd=Vr.create,_d=qr.create,bd=xs.create,kd=Kr.create,Td=_r.create,ro=Ge.create,Od=Nt.create,xd=Qt.create,Nd=Ge.createWithPreprocess,Sd=ni.create,Ed=()=>Bo().optional(),Zd=()=>Vo().optional(),Id=()=>qo().optional(),Ad={string:r=>Ue.create({...r,coerce:!0}),number:r=>Rr.create({...r,coerce:!0}),boolean:r=>Pr.create({...r,coerce:!0}),bigint:r=>zr.create({...r,coerce:!0}),date:r=>Mr.create({...r,coerce:!0})},$d=M;var f=Object.freeze({__proto__:null,defaultErrorMap:Cr,setErrorMap:zl,getErrorMap:cn,makeIssue:un,EMPTY_PATH:Pl,addIssueToContext:N,ParseStatus:Ce,INVALID:M,DIRTY:Co,OK:Ie,isAborted:$a,isDirty:Ca,isValid:jr,isAsync:ln,get util(){return J},get objectUtil(){return Aa},ZodParsedType:T,getParsedType:zt,ZodType:q,ZodString:Ue,ZodNumber:Rr,ZodBigInt:zr,ZodBoolean:Pr,ZodDate:Mr,ZodSymbol:dn,ZodUndefined:Dr,ZodNull:Lr,ZodAny:wr,ZodUnknown:Yt,ZodNever:Zt,ZodVoid:hn,ZodArray:Xt,ZodObject:Pe,ZodUnion:Ur,ZodDiscriminatedUnion:Wn,ZodIntersection:Br,ZodTuple:Dt,ZodRecord:zo,ZodMap:pn,ZodSet:fn,ZodFunction:Po,ZodLazy:Vr,ZodLiteral:qr,ZodEnum:xs,ZodNativeEnum:Kr,ZodPromise:_r,ZodEffects:Ge,ZodTransformer:Ge,ZodOptional:Nt,ZodNullable:Qt,ZodDefault:Wr,ZodCatch:mn,ZodNaN:yn,BRAND:Gl,ZodBranded:Do,ZodPipeline:ni,ZodReadonly:gn,custom:Uo,Schema:q,ZodSchema:q,late:Jl,get ZodFirstPartyTypeKind(){return C},coerce:Ad,any:nd,array:cd,bigint:Ql,boolean:qo,date:ed,discriminatedUnion:hd,effect:ro,enum:bd,function:vd,instanceof:Hl,intersection:pd,lazy:wd,literal:_d,map:yd,nan:Xl,nativeEnum:kd,never:id,null:sd,nullable:xd,number:Vo,object:ud,oboolean:Id,onumber:Zd,optional:Od,ostring:Ed,pipeline:Sd,preprocess:Nd,promise:Td,record:md,set:gd,strictObject:ld,string:Bo,symbol:td,transformer:ro,tuple:fd,undefined:rd,union:dd,unknown:ad,void:od,NEVER:$d,ZodIssueCode:v,quotelessJson:Rl,ZodError:qe});const ai=f.tuple([f.number(),f.number()]),Ko=f.object({width:f.number(),height:f.number()}),Cd=f.object({signedWidth:f.number(),signedHeight:f.number()}),jd=["width","height"];f.enum(jd);const Rd=["start","center","end"],zd=["signedWidth","signedHeight"];f.enum(zd);const vn=f.object({x:f.number(),y:f.number()}),Pd=f.object({clientX:f.number(),clientY:f.number()}),Md=["x","y"],Wo=f.enum(Md),Fo=["top","right","bottom","left"];f.enum(Fo);const Dd=["left","right"],Yo=f.enum(Dd),Ld=["top","bottom"],Go=f.enum(Ld),Jo=["center"],so=f.enum(Jo),Ud=[...Fo,...Jo],Ho=f.enum(Ud);f.enum(Rd);const Bd=["first","last"];f.enum(Bd);const Vd=f.object({lower:f.number(),upper:f.number()});f.union([Vd,ai]);f.union([Wo,Ho]);f.union([Wo,Ho,f.instanceof(String)]);const da=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),qd(t)},qd=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},F={},Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});function Kd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,s){return s.toUpperCase()}):""}Fn.default=Kd;var Yn={};Object.defineProperty(Yn,"__esModule",{value:!0});function Wd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Yn.default=Wd;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});function Fd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,s){return s.toUpperCase()}):""}Gn.default=Fd;var ii={};Object.defineProperty(ii,"__esModule",{value:!0});function Yd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}ii.default=Yd;var oi={};Object.defineProperty(oi,"__esModule",{value:!0});function Gd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}oi.default=Gd;var ci={};Object.defineProperty(ci,"__esModule",{value:!0});function Jd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}ci.default=Jd;var ui={};Object.defineProperty(ui,"__esModule",{value:!0});function Hd(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,s,n){return s+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}ui.default=Hd;var li={};Object.defineProperty(li,"__esModule",{value:!0});function Xd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,s,n){return t+s.charAt(0).toUpperCase()+s.slice(1)+n}):""}li.default=Xd;var Jn={};Object.defineProperty(Jn,"__esModule",{value:!0});function Qd(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Jn.default=Qd;var di={},or={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(s){return e instanceof s})}})(or);var eh=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(di,"__esModule",{value:!0});var lt=or;function Ls(r,e){if(e===void 0&&(e=lt.DefaultOption),!lt.isValidObject(r))return null;e=lt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toLowerCase();e.recursive&&(lt.isValidObject(n)?lt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Ls(n,e)):e.recursiveInArray&&lt.isArrayObject(n)&&(n=eh(n).map(function(i){var o=i;if(lt.isValidObject(i))lt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ls(i,e));else if(lt.isArrayObject(i)){var c=Ls({key:i},e);o=c.key}return o}))),t[a]=n}),t}di.default=Ls;var hi={},th=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(hi,"__esModule",{value:!0});var dt=or;function Us(r,e){if(e===void 0&&(e=dt.DefaultOption),!dt.isValidObject(r))return null;e=dt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toUpperCase();e.recursive&&(dt.isValidObject(n)?dt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Us(n,e)):e.recursiveInArray&&dt.isArrayObject(n)&&(n=th(n).map(function(i){var o=i;if(dt.isValidObject(i))dt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Us(i,e));else if(dt.isArrayObject(i)){var c=Us({key:i},e);o=c.key}return o}))),t[a]=n}),t}hi.default=Us;var pi={},rh=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(pi,"__esModule",{value:!0});var ht=or,sh=Fn;function Bs(r,e){if(e===void 0&&(e=ht.DefaultOption),!ht.isValidObject(r))return null;e=ht.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=sh.default(s);e.recursive&&(ht.isValidObject(n)?ht.belongToTypes(n,e.keepTypesOnRecursion)||(n=Bs(n,e)):e.recursiveInArray&&ht.isArrayObject(n)&&(n=rh(n).map(function(i){var o=i;if(ht.isValidObject(i))ht.belongToTypes(o,e.keepTypesOnRecursion)||(o=Bs(i,e));else if(ht.isArrayObject(i)){var c=Bs({key:i},e);o=c.key}return o}))),t[a]=n}),t}pi.default=Bs;var fi={},nh=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(fi,"__esModule",{value:!0});var pt=or,ah=Yn;function Vs(r,e){if(e===void 0&&(e=pt.DefaultOption),!pt.isValidObject(r))return null;e=pt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=ah.default(s);e.recursive&&(pt.isValidObject(n)?pt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Vs(n,e)):e.recursiveInArray&&pt.isArrayObject(n)&&(n=nh(n).map(function(i){var o=i;if(pt.isValidObject(i))pt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Vs(i,e));else if(pt.isArrayObject(i)){var c=Vs({key:i},e);o=c.key}return o}))),t[a]=n}),t}fi.default=Vs;var mi={},ih=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(mi,"__esModule",{value:!0});var ft=or,oh=Gn;function qs(r,e){if(e===void 0&&(e=ft.DefaultOption),!ft.isValidObject(r))return null;e=ft.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=oh.default(s);e.recursive&&(ft.isValidObject(n)?ft.belongToTypes(n,e.keepTypesOnRecursion)||(n=qs(n,e)):e.recursiveInArray&&ft.isArrayObject(n)&&(n=ih(n).map(function(i){var o=i;if(ft.isValidObject(i))ft.belongToTypes(o,e.keepTypesOnRecursion)||(o=qs(i,e));else if(ft.isArrayObject(i)){var c=qs({key:i},e);o=c.key}return o}))),t[a]=n}),t}mi.default=qs;var yi={},ch=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(yi,"__esModule",{value:!0});var mt=or,uh=Jn;function Ks(r,e){if(e===void 0&&(e=mt.DefaultOption),!mt.isValidObject(r))return null;e=mt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=uh.default(s);e.recursive&&(mt.isValidObject(n)?mt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Ks(n,e)):e.recursiveInArray&&mt.isArrayObject(n)&&(n=ch(n).map(function(i){var o=i;if(mt.isValidObject(i))mt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ks(i,e));else if(mt.isArrayObject(i)){var c=Ks({key:i},e);o=c.key}return o}))),t[a]=n}),t}yi.default=Ks;Object.defineProperty(F,"__esModule",{value:!0});F.kebabKeys=F.pascalKeys=F.snakeKeys=F.camelKeys=F.upperKeys=F.lowerKeys=F.toLowerCase=F.toUpperCase=F.toKebabCase=F.toHeaderCase=F.toSentenceCase=F.toTextCase=F.toPathCase=F.toDotCase=F.toPascalCase=F.toSnakeCase=F.toCamelCase=void 0;var Xo=Fn;F.toCamelCase=Xo.default;var Qo=Yn;F.toSnakeCase=Qo.default;var ec=Gn;F.toPascalCase=ec.default;var tc=ii;F.toDotCase=tc.default;var rc=oi;F.toPathCase=rc.default;var sc=ci;F.toTextCase=sc.default;var nc=ui;F.toSentenceCase=nc.default;var ac=li;F.toHeaderCase=ac.default;var ic=Jn;F.toKebabCase=ic.default;var oc=di;F.lowerKeys=oc.default;var cc=hi;F.upperKeys=cc.default;var uc=pi;F.camelKeys=uc.default;var lc=fi;F.snakeKeys=lc.default;var dc=mi;F.pascalKeys=dc.default;var hc=yi;F.kebabKeys=hc.default;var pc=function(r){return String(r||"").toLowerCase()};F.toLowerCase=pc;var fc=function(r){return String(r||"").toUpperCase()};F.toUpperCase=fc;var lh={toCamelCase:Xo.default,toSnakeCase:Qo.default,toPascalCase:ec.default,toDotCase:tc.default,toPathCase:rc.default,toTextCase:sc.default,toSentenceCase:nc.default,toHeaderCase:ac.default,toKebabCase:ic.default,toUpperCase:fc,toLowerCase:pc,lowerKeys:oc.default,upperKeys:cc.default,camelKeys:uc.default,snakeKeys:lc.default,pascalKeys:dc.default,kebabKeys:hc.default};F.default=lh;var mc=F;const yc={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},dh=r=>mc.snakeKeys(r,yc),hh=r=>mc.camelKeys(r,yc);var wn;(r=>{r.toSnake=dh,r.toCamel=hh,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(wn||(wn={}));f.object({x:Yo.or(so),y:Go.or(so)});const ph=f.object({x:Yo,y:Go}),fh=Object.freeze({x:"left",y:"top"}),mh=(r,e)=>r.x===e.x&&r.y===e.y,no=f.union([f.number(),vn,ai,Ko,Cd,Pd]),yh=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},ao={x:0,y:0},js=f.union([f.number(),f.string()]);f.object({top:js,left:js,width:js,height:js});f.object({left:f.number(),top:f.number(),right:f.number(),bottom:f.number()});f.object({one:vn,two:vn,root:ph});const gi=(r,e,t=0,s=0,n)=>{const a={one:{...ao},two:{...ao},root:n??fh};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+s}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},ha=r=>{const e=gi(r);return{lower:e.one.x,upper:e.two.x}},pa=r=>{const e=gi(r);return{lower:e.one.y,upper:e.two.y}},gh=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,vh=f.object({signedWidth:f.number(),signedHeight:f.number()});f.union([Ko,vh,vn,ai]);const wh=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);f.object({offset:no,scale:no});const _h=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],bh=r=>(e,t,s,n)=>[e,n?s/r:s*r],kh=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:i,upper:o}=r,c=a-n,l=o-i;if(t==="dimension")return[r,s*(l/c)];const h=(s-n)*(l/c)+i;return[r,h]},Th=r=>(e,t,s)=>[r,s],Oh=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},xh=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=wh(s,n,a),[e,s]},La=class Sr{constructor(){b(this,"ops",[]),b(this,"currBounds",null),b(this,"currType",null),b(this,"reversed",!1),this.ops=[]}static translate(e){return new Sr().translate(e)}static magnify(e){return new Sr().magnify(e)}static scale(e,t){return new Sr().scale(e,t)}translate(e){const t=this.new(),s=_h(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=bh(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=da(e,t),n=this.new(),a=kh(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=da(e,t),n=this.new(),a=xh(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=da(e,t),n=this.new(),a=Th(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=Oh();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Sr;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([i,o])=>n>=i&&n<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}};b(La,"IDENTITY",new La);let io=La;const oo=class kt{constructor(e=new io,t=new io,s=null){b(this,"x"),b(this,"y"),b(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new kt().translate(e,t)}static translateX(e){return new kt().translateX(e)}static translateY(e){return new kt().translateY(e)}static clamp(e){return new kt().clamp(e)}static magnify(e){return new kt().magnify(e)}static scale(e){return new kt().scale(e)}static reBound(e){return new kt().reBound(e)}translate(e,t){const s=yh(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(gh(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!mh(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(ha(e)),t.y=t.y.scale(pa(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(ha(e)),t.y=this.y.reBound(pa(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(ha(e)),t.y=this.y.clamp(pa(e)),t}copy(){const e=new kt;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return gi(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};b(oo,"IDENTITY",new oo);const gc=(r,e)=>{const t=new Ne(e);if(![Se.DAY,Se.HOUR,Se.MINUTE,Se.SECOND,Se.MILLISECOND,Se.MICROSECOND,Se.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof Ne?new Ne(s):new Se(s)},ne=class z{constructor(e,t="UTC"){if(b(this,"value"),b(this,"encodeValue",!0),e==null)this.value=z.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*z.MILLISECOND.valueOf();else if(typeof e=="string")this.value=z.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=z.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=z.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=z.MAX:e=z.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new z(BigInt(n.getTime())*z.MILLISECOND.valueOf()).truncate(z.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=z.hours(parseInt(s??"00",10)).add(z.minutes(parseInt(n??"00",10))).add(z.seconds(parseInt(i??"00",10))).add(z.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(z.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return z.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new z(BigInt(s.getTime())*z.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(z.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(e="UTC"){const t=this.date(),s=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${s} ${n}`}static get utcOffset(){return new Se(BigInt(new Date().getTimezoneOffset())*z.MINUTE.valueOf())}static since(e){return new z().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new z(e).valueOf()}span(e){return this.range(e).span}range(e){return new Nh(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new z(e).valueOf()}afterEq(e){return this.valueOf()>=new z(e).valueOf()}before(e){return this.valueOf()<new z(e).valueOf()}beforeEq(e){return this.valueOf()<=new z(e).valueOf()}add(e){return new z(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new z(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/z.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return gc(this,e)}get isToday(){return this.truncate(Se.DAY).equals(z.now().truncate(Se.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new z(new Date)}static max(...e){let t=z.MIN;for(const s of e){const n=new z(s);n.after(t)&&(t=n)}return t}static min(...e){let t=z.MAX;for(const s of e){const n=new z(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new z(e)}static microseconds(e){return z.nanoseconds(e*1e3)}static milliseconds(e){return z.microseconds(e*1e3)}static seconds(e){return z.milliseconds(e*1e3)}static minutes(e){return z.seconds(e*60)}static hours(e){return z.minutes(e*60)}static days(e){return z.hours(e*24)}};b(ne,"NANOSECOND",ne.nanoseconds(1)),b(ne,"MICROSECOND",ne.microseconds(1)),b(ne,"MILLISECOND",ne.milliseconds(1)),b(ne,"SECOND",ne.seconds(1)),b(ne,"MINUTE",ne.minutes(1)),b(ne,"HOUR",ne.hours(1)),b(ne,"DAY",ne.days(1)),b(ne,"MAX",new ne((1n<<63n)-1n)),b(ne,"MIN",new ne(0)),b(ne,"ZERO",new ne(0)),b(ne,"z",f.union([f.object({value:f.bigint()}).transform(r=>new ne(r.value)),f.string().transform(r=>new ne(BigInt(r))),f.instanceof(Number).transform(r=>new ne(r)),f.number().transform(r=>new ne(r)),f.instanceof(ne)]));let Ne=ne;const ae=class Q{constructor(e){b(this,"value"),b(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new Q(e).valueOf()}greaterThan(e){return this.valueOf()>new Q(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new Q(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new Q(e).valueOf()}remainder(e){return gc(this,e)}truncate(e){return new Q(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(Q.DAY),t=this.truncate(Q.HOUR),s=this.truncate(Q.MINUTE),n=this.truncate(Q.SECOND),a=this.truncate(Q.MILLISECOND),i=this.truncate(Q.MICROSECOND),o=this.truncate(Q.NANOSECOND),c=e,l=t.sub(e),h=s.sub(t),k=n.sub(s),se=a.sub(n),ye=i.sub(a),Re=o.sub(i);let de="";return c.isZero||(de+=`${c.days}d `),l.isZero||(de+=`${l.hours}h `),h.isZero||(de+=`${h.minutes}m `),k.isZero||(de+=`${k.seconds}s `),se.isZero||(de+=`${se.milliseconds}ms `),ye.isZero||(de+=`${ye.microseconds}µs `),Re.isZero||(de+=`${Re.nanoseconds}ns`),de.trim()}get days(){return Number(this.valueOf()/Q.DAY.valueOf())}get hours(){return Number(this.valueOf()/Q.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/Q.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/Q.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/Q.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/Q.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new Q(e).valueOf()}add(e){return new Q(this.valueOf()+new Q(e).valueOf())}sub(e){return new Q(this.valueOf()-new Q(e).valueOf())}static nanoseconds(e=1){return new Q(e)}static microseconds(e=1){return Q.nanoseconds(e*1e3)}static milliseconds(e=1){return Q.microseconds(e*1e3)}static seconds(e=1){return Q.milliseconds(e*1e3)}static minutes(e){return Q.seconds(e.valueOf()*60)}static hours(e){return Q.minutes(e*60)}static days(e){return Q.hours(e*24)}};b(ae,"NANOSECOND",ae.nanoseconds(1)),b(ae,"MICROSECOND",ae.microseconds(1)),b(ae,"MILLISECOND",ae.milliseconds(1)),b(ae,"SECOND",ae.seconds(1)),b(ae,"MINUTE",ae.minutes(1)),b(ae,"HOUR",ae.hours(1)),b(ae,"DAY",ae.days(1)),b(ae,"MAX",new ae((1n<<63n)-1n)),b(ae,"MIN",new ae(0)),b(ae,"ZERO",new ae(0)),b(ae,"z",f.union([f.object({value:f.bigint()}).transform(r=>new ae(r.value)),f.string().transform(r=>new ae(BigInt(r))),f.instanceof(Number).transform(r=>new ae(r)),f.number().transform(r=>new ae(r)),f.instanceof(ae)]));let Se=ae;const Rs=class Ws extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ws(e).valueOf()}get period(){return Se.seconds(1/this.valueOf())}sampleCount(e){return new Se(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new xe(t).valueOf()}span(e){return Se.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ws(e)}static khz(e){return Ws.hz(e*1e3)}};b(Rs,"z",f.union([f.number().transform(r=>new Rs(r)),f.instanceof(Number).transform(r=>new Rs(r)),f.instanceof(Rs)]));const ge=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Sh(e*this.valueOf())}};b(ge,"UNKNOWN",new ge(0)),b(ge,"BIT128",new ge(16)),b(ge,"BIT64",new ge(8)),b(ge,"BIT32",new ge(4)),b(ge,"BIT16",new ge(2)),b(ge,"BIT8",new ge(1)),b(ge,"z",f.union([f.number().transform(r=>new ge(r)),f.instanceof(Number).transform(r=>new ge(r)),f.instanceof(ge)]));let xe=ge;const Qe=class Fs{constructor(e,t){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new Ne(e.start),this.end=new Ne(e.end)):(this.start=new Ne(e),this.end=new Ne(t))}get span(){return new Se(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Fs(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Fs?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Fs(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};b(Qe,"MAX",new Qe(Ne.MIN,Ne.MAX)),b(Qe,"MIN",new Qe(Ne.MAX,Ne.MIN)),b(Qe,"ZERO",new Qe(Ne.ZERO,Ne.ZERO)),b(Qe,"z",f.union([f.object({start:Ne.z,end:Ne.z}).transform(r=>new Qe(r.start,r.end)),f.instanceof(Qe)]));let Nh=Qe;const g=class et extends String{constructor(e){if(e instanceof et||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=et.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(et.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=et.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(et.JSON)||this.equals(et.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(et.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=et.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return et.BIG_INT_TYPES.some(e=>e.equals(this))}};b(g,"UNKNOWN",new g("unknown")),b(g,"FLOAT64",new g("float64")),b(g,"FLOAT32",new g("float32")),b(g,"INT64",new g("int64")),b(g,"INT32",new g("int32")),b(g,"INT16",new g("int16")),b(g,"INT8",new g("int8")),b(g,"UINT64",new g("uint64")),b(g,"UINT32",new g("uint32")),b(g,"UINT16",new g("uint16")),b(g,"UINT8",new g("uint8")),b(g,"BOOLEAN",g.UINT8),b(g,"TIMESTAMP",new g("timestamp")),b(g,"UUID",new g("uuid")),b(g,"STRING",new g("string")),b(g,"JSON",new g("json")),b(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),b(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),b(g,"DENSITIES",new Map([[g.UINT8.toString(),xe.BIT8],[g.UINT16.toString(),xe.BIT16],[g.UINT32.toString(),xe.BIT32],[g.UINT64.toString(),xe.BIT64],[g.FLOAT32.toString(),xe.BIT32],[g.FLOAT64.toString(),xe.BIT64],[g.INT8.toString(),xe.BIT8],[g.INT16.toString(),xe.BIT16],[g.INT32.toString(),xe.BIT32],[g.INT64.toString(),xe.BIT64],[g.TIMESTAMP.toString(),xe.BIT64],[g.STRING.toString(),xe.UNKNOWN],[g.JSON.toString(),xe.UNKNOWN],[g.UUID.toString(),xe.BIT128]])),b(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),b(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),b(g,"z",f.union([f.string().transform(r=>new g(r)),f.instanceof(g)]));const _e=class he extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return he.bytes(this.valueOf()+e.valueOf())}sub(e){return he.bytes(this.valueOf()-e.valueOf())}truncate(e){return new he(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return he.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/he.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/he.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/he.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/he.TERABYTE.valueOf()}toString(){const e=this.truncate(he.TERABYTE),t=this.truncate(he.GIGABYTE),s=this.truncate(he.MEGABYTE),n=this.truncate(he.KILOBYTE),a=this.truncate(he.BYTE),i=e,o=t.sub(e),c=s.sub(t),l=n.sub(s),h=a.sub(n);let k="";return i.isZero||(k+=`${i.terabytes}TB `),o.isZero||(k+=`${o.gigabytes}GB `),c.isZero||(k+=`${c.megabytes}MB `),l.isZero||(k+=`${l.kilobytes}KB `),(!h.isZero||k==="")&&(k+=`${h.valueOf()}B`),k.trim()}static bytes(e=1){return new he(e)}static kilobytes(e=1){return he.bytes(e.valueOf()*1e3)}static megabytes(e=1){return he.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return he.megabytes(e.valueOf()*1e3)}static terabytes(e){return he.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(_e,"BYTE",new _e(1)),b(_e,"KILOBYTE",_e.kilobytes(1)),b(_e,"MEGABYTE",_e.megabytes(1)),b(_e,"GIGABYTE",_e.gigabytes(1)),b(_e,"TERABYTE",_e.terabytes(1)),b(_e,"ZERO",new _e(0)),b(_e,"z",f.union([f.number().transform(r=>new _e(r)),f.instanceof(_e)]));let Sh=_e;f.union([f.instanceof(Uint8Array),f.instanceof(Uint16Array),f.instanceof(Uint32Array),f.instanceof(BigUint64Array),f.instanceof(Float32Array),f.instanceof(Float64Array),f.instanceof(Int8Array),f.instanceof(Int16Array),f.instanceof(Int32Array),f.instanceof(BigInt64Array)]);f.record(f.union([f.number(),f.string(),f.symbol()]),f.unknown());const Eh=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),vc=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Zh=vc(),wc=["MacOS","Windows","Linux","Docker"],Ih=f.enum(wc);let fa;const Ah=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},$h=(r={})=>{const{force:e,default:t}=r;return e??fa??(fa=Ah(),fa??t)},_c=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:wc,RUNTIME:Zh,detect:vc,getOS:$h,osZ:Ih},Symbol.toStringTag,{value:"Module"})),Ch=(...r)=>r.map(bc).join(""),bc=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),jh=r=>r.endsWith("/")?r.slice(0,-1):r,Rh=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,s])=>`${e}${t}=${s}`).join("&");var ur;let zh=(ur=class{constructor({host:r,port:e,protocol:t="",pathPrefix:s=""}){b(this,"protocol"),b(this,"host"),b(this,"port"),b(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=bc(s)}replace(r){return new ur({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new ur({...this,pathPrefix:Ch(this.path,r)})}toString(){return jh(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},b(ur,"UNKNOWN",new ur({host:"unknown",port:0})),ur),Ph=class{constructor(){b(this,"contentType","application/json"),b(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(wn.toSnake(e),(s,n)=>ArrayBuffer.isView(n)?Array.from(n):Eh(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n);return new TextEncoder().encode(t)}decode(e,t){const s=wn.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(s):s}static registerCustomType(){}};new Ph;const Mh=f.string().regex(/^\d+\.\d+\.\d+$/);f.object({version:Mh});var H;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(H||(H={}));var Ua;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ua||(Ua={}));const O=H.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pt=r=>{switch(typeof r){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(r)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(r)?O.array:r===null?O.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?O.promise:typeof Map<"u"&&r instanceof Map?O.map:typeof Set<"u"&&r instanceof Set?O.set:typeof Date<"u"&&r instanceof Date?O.date:O.object;default:return O.unknown}},w=H.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Dh=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Ke=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,H.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}};Ke.create=r=>new Ke(r);const Fr=(r,e)=>{let t;switch(r.code){case w.invalid_type:r.received===O.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,H.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${H.joinValues(r.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${H.joinValues(r.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${H.joinValues(r.options)}, received '${r.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:H.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case w.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case w.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,H.assertNever(r)}return{message:t}};let kc=Fr;function Lh(r){kc=r}function _n(){return kc}const bn=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Uh=[];function S(r,e){const t=bn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,_n(),Fr].filter(s=>!!s)});r.common.issues.push(t)}let je=class Tc{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return D;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Tc.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return D;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}};const D=Object.freeze({status:"aborted"}),Oc=r=>({status:"dirty",value:r}),Ae=r=>({status:"valid",value:r}),Ba=r=>r.status==="aborted",Va=r=>r.status==="dirty",Yr=r=>r.status==="valid",kn=r=>typeof Promise<"u"&&r instanceof Promise;var I;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(I||(I={}));let it=class{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const co=(r,e)=>{if(Yr(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ke(r.common.issues);return this._error=t,this._error}}};function B(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}let K=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Pt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new je,ctx:{common:e.parent.common,data:e.data,parsedType:Pt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(kn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return co(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(kn(n)?n:Promise.resolve(n));return co(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:w.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Je({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return St.create(this,this._def)}nullable(){return tr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return er.create(this,this._def)}promise(){return kr.create(this,this._def)}or(e){return es.create([this,e],this._def)}and(e){return ts.create(this,e,this._def)}transform(e){return new Je({...B(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new is({...B(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new Ic({typeName:j.ZodBranded,type:this,...B(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Sn({...B(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return vi.create(this,e)}readonly(){return Zn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const Bh=/^c[^\s-]{8,}$/i,Vh=/^[a-z][a-z0-9]*$/,qh=/^[0-9A-HJKMNP-TV-Z]{26}$/,Kh=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Wh=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Fh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ma;const Yh=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Gh=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Jh=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Hh(r,e){return!!((e==="v4"||!e)&&Yh.test(r)||(e==="v6"||!e)&&Gh.test(r))}class Be extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.string,received:n.parsedType}),D}const t=new je;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?S(s,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&S(s,{code:w.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Wh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"email",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ma||(ma=new RegExp(Fh,"u")),ma.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"emoji",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Kh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"uuid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Bh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"cuid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Vh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"cuid2",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")qh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"ulid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),S(s,{validation:"url",code:w.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"regex",code:w.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?Jh(n).test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?Hh(e.data,n.version)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"ip",code:w.invalid_string,message:n.message}),t.dirty()):H.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:w.invalid_string,...I.errToObj(s)})}_addCheck(e){return new Be({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...I.errToObj(e)})}url(e){return this._addCheck({kind:"url",...I.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...I.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...I.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...I.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...I.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...I.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...I.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...I.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...I.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...I.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...I.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...I.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...I.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...I.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...I.errToObj(t)})}nonempty(e){return this.min(1,I.errToObj(e))}trim(){return new Be({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Be({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Be({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Be.create=r=>{var e;return new Be({checks:[],typeName:j.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};function Xh(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class Lt extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==O.number){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.number,received:n.parsedType}),D}let t;const s=new je;for(const n of this._def.checks)n.kind==="int"?H.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?Xh(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_finite,message:n.message}),s.dirty()):H.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,s,n){return new Lt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:I.toString(n)}]})}_addCheck(e){return new Lt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:I.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:I.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&H.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Lt.create=r=>new Lt({checks:[],typeName:j.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});let Gr=class qa extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==O.bigint){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.bigint,received:n.parsedType}),D}let t;const s=new je;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):H.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,s,n){return new qa({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:I.toString(n)}]})}_addCheck(e){return new qa({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};Gr.create=r=>{var e;return new Gr({checks:[],typeName:j.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};let Jr=class extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.boolean,received:t.parsedType}),D}return Ae(e.data)}};Jr.create=r=>new Jr({typeName:j.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});let Hr=class xc extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.date,received:n.parsedType}),D}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_date}),D}const t=new je;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):H.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new xc({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:I.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:I.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};Hr.create=r=>new Hr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:j.ZodDate,...B(r)});let Tn=class extends K{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.symbol,received:t.parsedType}),D}return Ae(e.data)}};Tn.create=r=>new Tn({typeName:j.ZodSymbol,...B(r)});let Xr=class extends K{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.undefined,received:t.parsedType}),D}return Ae(e.data)}};Xr.create=r=>new Xr({typeName:j.ZodUndefined,...B(r)});let Qr=class extends K{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.null,received:t.parsedType}),D}return Ae(e.data)}};Qr.create=r=>new Qr({typeName:j.ZodNull,...B(r)});let br=class extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return Ae(e.data)}};br.create=r=>new br({typeName:j.ZodAny,...B(r)});class Gt extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ae(e.data)}}Gt.create=r=>new Gt({typeName:j.ZodUnknown,...B(r)});let It=class extends K{_parse(e){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.never,received:t.parsedType}),D}};It.create=r=>new It({typeName:j.ZodNever,...B(r)});class On extends K{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.void,received:t.parsedType}),D}return Ae(e.data)}}On.create=r=>new On({typeName:j.ZodVoid,...B(r)});let er=class Ys extends K{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==O.array)return S(t,{code:w.invalid_type,expected:O.array,received:t.parsedType}),D;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(S(t,{code:i?w.too_big:w.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(S(t,{code:w.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(S(t,{code:w.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new it(t,i,t.path,o)))).then(i=>je.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new it(t,i,t.path,o)));return je.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Ys({...this._def,minLength:{value:e,message:I.toString(t)}})}max(e,t){return new Ys({...this._def,maxLength:{value:e,message:I.toString(t)}})}length(e,t){return new Ys({...this._def,exactLength:{value:e,message:I.toString(t)}})}nonempty(e){return this.min(1,e)}};er.create=(r,e)=>new er({type:r,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...B(e)});function hr(r){if(r instanceof ue){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=St.create(hr(s))}return new ue({...r._def,shape:()=>e})}else return r instanceof er?new er({...r._def,type:hr(r.element)}):r instanceof St?St.create(hr(r.unwrap())):r instanceof tr?tr.create(hr(r.unwrap())):r instanceof ot?ot.create(r.items.map(e=>hr(e))):r}class ue extends K{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=H.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const c=this._getOrReturnCtx(e);return S(c,{code:w.invalid_type,expected:O.object,received:c.parsedType}),D}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof It&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=n[c],h=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new it(s,h,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof It){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")i.length>0&&(S(s,{code:w.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new it(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>je.mergeObjectSync(t,c)):je.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return I.errToObj,new ue({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=I.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new ue({...this._def,unknownKeys:"strip"})}passthrough(){return new ue({...this._def,unknownKeys:"passthrough"})}extend(e){return new ue({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new ue({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new ue({...this._def,catchall:e})}pick(e){const t={};return H.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new ue({...this._def,shape:()=>t})}omit(e){const t={};return H.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new ue({...this._def,shape:()=>t})}deepPartial(){return hr(this)}partial(e){const t={};return H.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new ue({...this._def,shape:()=>t})}required(e){const t={};return H.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof St;)n=n._def.innerType;t[s]=n}}),new ue({...this._def,shape:()=>t})}keyof(){return Zc(H.objectKeys(this.shape))}}ue.create=(r,e)=>new ue({shape:()=>r,unknownKeys:"strip",catchall:It.create(),typeName:j.ZodObject,...B(e)});ue.strictCreate=(r,e)=>new ue({shape:()=>r,unknownKeys:"strict",catchall:It.create(),typeName:j.ZodObject,...B(e)});ue.lazycreate=(r,e)=>new ue({shape:r,unknownKeys:"strip",catchall:It.create(),typeName:j.ZodObject,...B(e)});let es=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Ke(o.ctx.common.issues));return S(t,{code:w.invalid_union,unionErrors:i}),D}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Ke(c));return S(t,{code:w.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}};es.create=(r,e)=>new es({options:r,typeName:j.ZodUnion,...B(e)});const Gs=r=>r instanceof ss?Gs(r.schema):r instanceof Je?Gs(r.innerType()):r instanceof ns?[r.value]:r instanceof Ut?r.options:r instanceof as?Object.keys(r.enum):r instanceof is?Gs(r._def.innerType):r instanceof Xr?[void 0]:r instanceof Qr?[null]:null;let Nc=class Sc extends K{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return S(t,{code:w.invalid_type,expected:O.object,received:t.parsedType}),D;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(S(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Gs(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Sc({typeName:j.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...B(s)})}};function Ka(r,e){const t=Pt(r),s=Pt(e);if(r===e)return{valid:!0,data:r};if(t===O.object&&s===O.object){const n=H.objectKeys(e),a=H.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Ka(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===O.array&&s===O.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Ka(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===O.date&&s===O.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let ts=class extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ba(a)||Ba(i))return D;const o=Ka(a.value,i.value);return o.valid?((Va(a)||Va(i))&&t.dirty(),{status:t.value,value:o.data}):(S(s,{code:w.invalid_intersection_types}),D)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}};ts.create=(r,e,t)=>new ts({left:r,right:e,typeName:j.ZodIntersection,...B(t)});class ot extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.array)return S(s,{code:w.invalid_type,expected:O.array,received:s.parsedType}),D;if(s.data.length<this._def.items.length)return S(s,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&s.data.length>this._def.items.length&&(S(s,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new it(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>je.mergeArray(t,a)):je.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ot({...this._def,rest:e})}}ot.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ot({items:r,typeName:j.ZodTuple,rest:null,...B(e)})};class rs extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.object)return S(s,{code:w.invalid_type,expected:O.object,received:s.parsedType}),D;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new it(s,o,s.path,o)),value:i._parse(new it(s,s.data[o],s.path,o))});return s.common.async?je.mergeObjectAsync(t,n):je.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof K?new rs({keyType:e,valueType:t,typeName:j.ZodRecord,...B(s)}):new rs({keyType:Be.create(),valueType:e,typeName:j.ZodRecord,...B(t)})}}let xn=class extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.map)return S(s,{code:w.invalid_type,expected:O.map,received:s.parsedType}),D;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new it(s,o,s.path,[l,"key"])),value:a._parse(new it(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}};xn.create=(r,e,t)=>new xn({valueType:e,keyType:r,typeName:j.ZodMap,...B(t)});let Nn=class Wa extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.set)return S(s,{code:w.invalid_type,expected:O.set,received:s.parsedType}),D;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(S(s,{code:w.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(S(s,{code:w.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return D;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new it(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new Wa({...this._def,minSize:{value:e,message:I.toString(t)}})}max(e,t){return new Wa({...this._def,maxSize:{value:e,message:I.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Nn.create=(r,e)=>new Nn({valueType:r,minSize:null,maxSize:null,typeName:j.ZodSet,...B(e)});let Ec=class Js extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return S(t,{code:w.invalid_type,expected:O.function,received:t.parsedType}),D;function s(o,c){return bn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_n(),Fr].filter(l=>!!l),issueData:{code:w.invalid_arguments,argumentsError:c}})}function n(o,c){return bn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,_n(),Fr].filter(l=>!!l),issueData:{code:w.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof kr){const o=this;return Ae(async function(...c){const l=new Ke([]),h=await o._def.args.parseAsync(c,a).catch(se=>{throw l.addIssue(s(c,se)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(se=>{throw l.addIssue(n(k,se)),l})})}else{const o=this;return Ae(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Ke([s(c,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new Ke([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Js({...this._def,args:ot.create(e).rest(Gt.create())})}returns(e){return new Js({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new Js({args:e||ot.create([]).rest(Gt.create()),returns:t||Gt.create(),typeName:j.ZodFunction,...B(s)})}};class ss extends K{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}ss.create=(r,e)=>new ss({getter:r,typeName:j.ZodLazy,...B(e)});class ns extends K{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return S(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}}ns.create=(r,e)=>new ns({value:r,typeName:j.ZodLiteral,...B(e)});function Zc(r,e){return new Ut({values:r,typeName:j.ZodEnum,...B(e)})}class Ut extends K{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return S(t,{expected:H.joinValues(s),received:t.parsedType,code:w.invalid_type}),D}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return S(t,{received:t.data,code:w.invalid_enum_value,options:s}),D}return Ae(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Ut.create(e)}exclude(e){return Ut.create(this.options.filter(t=>!e.includes(t)))}}Ut.create=Zc;let as=class extends K{_parse(e){const t=H.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==O.string&&s.parsedType!==O.number){const n=H.objectValues(t);return S(s,{expected:H.joinValues(n),received:s.parsedType,code:w.invalid_type}),D}if(t.indexOf(e.data)===-1){const n=H.objectValues(t);return S(s,{received:s.data,code:w.invalid_enum_value,options:n}),D}return Ae(e.data)}get enum(){return this._def.values}};as.create=(r,e)=>new as({values:r,typeName:j.ZodNativeEnum,...B(e)});let kr=class extends K{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return S(t,{code:w.invalid_type,expected:O.promise,received:t.parsedType}),D;const s=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return Ae(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}};kr.create=(r,e)=>new kr({type:r,typeName:j.ZodPromise,...B(e)});let Je=class extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{S(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Yr(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>Yr(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);H.assertNever(n)}};Je.create=(r,e,t)=>new Je({schema:r,typeName:j.ZodEffects,effect:e,...B(t)});Je.createWithPreprocess=(r,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:r},typeName:j.ZodEffects,...B(t)});class St extends K{_parse(e){return this._getType(e)===O.undefined?Ae(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}St.create=(r,e)=>new St({innerType:r,typeName:j.ZodOptional,...B(e)});let tr=class extends K{_parse(e){return this._getType(e)===O.null?Ae(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};tr.create=(r,e)=>new tr({innerType:r,typeName:j.ZodNullable,...B(e)});let is=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===O.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};is.create=(r,e)=>new is({innerType:r,typeName:j.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...B(e)});let Sn=class extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return kn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ke(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ke(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}};Sn.create=(r,e)=>new Sn({innerType:r,typeName:j.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...B(e)});let En=class extends K{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.nan,received:t.parsedType}),D}return{status:"valid",value:e.data}}};En.create=r=>new En({typeName:j.ZodNaN,...B(r)});const Qh=Symbol("zod_brand");class Ic extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}let vi=class Ac extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?D:n.status==="dirty"?(t.dirty(),Oc(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?D:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Ac({in:e,out:t,typeName:j.ZodPipeline})}};class Zn extends K{_parse(e){const t=this._def.innerType._parse(e);return Yr(t)&&(t.value=Object.freeze(t.value)),t}}Zn.create=(r,e)=>new Zn({innerType:r,typeName:j.ZodReadonly,...B(e)});const $c=(r,e={},t)=>r?br.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):br.create(),ep={object:ue.lazycreate};var j;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(j||(j={}));const tp=(r,e={message:`Input not instance of ${r.name}`})=>$c(t=>t instanceof r,e),Cc=Be.create,jc=Lt.create,rp=En.create,sp=Gr.create,Rc=Jr.create,np=Hr.create,ap=Tn.create,ip=Xr.create,op=Qr.create,cp=br.create,up=Gt.create,lp=It.create,dp=On.create,hp=er.create,pp=ue.create,fp=ue.strictCreate,mp=es.create,yp=Nc.create,gp=ts.create,vp=ot.create,wp=rs.create,_p=xn.create,bp=Nn.create,kp=Ec.create,Tp=ss.create,Op=ns.create,xp=Ut.create,Np=as.create,Sp=kr.create,uo=Je.create,Ep=St.create,Zp=tr.create,Ip=Je.createWithPreprocess,Ap=vi.create,$p=()=>Cc().optional(),Cp=()=>jc().optional(),jp=()=>Rc().optional(),Rp={string:r=>Be.create({...r,coerce:!0}),number:r=>Lt.create({...r,coerce:!0}),boolean:r=>Jr.create({...r,coerce:!0}),bigint:r=>Gr.create({...r,coerce:!0}),date:r=>Hr.create({...r,coerce:!0})},zp=D;var xt=Object.freeze({__proto__:null,defaultErrorMap:Fr,setErrorMap:Lh,getErrorMap:_n,makeIssue:bn,EMPTY_PATH:Uh,addIssueToContext:S,ParseStatus:je,INVALID:D,DIRTY:Oc,OK:Ae,isAborted:Ba,isDirty:Va,isValid:Yr,isAsync:kn,get util(){return H},get objectUtil(){return Ua},ZodParsedType:O,getParsedType:Pt,ZodType:K,ZodString:Be,ZodNumber:Lt,ZodBigInt:Gr,ZodBoolean:Jr,ZodDate:Hr,ZodSymbol:Tn,ZodUndefined:Xr,ZodNull:Qr,ZodAny:br,ZodUnknown:Gt,ZodNever:It,ZodVoid:On,ZodArray:er,ZodObject:ue,ZodUnion:es,ZodDiscriminatedUnion:Nc,ZodIntersection:ts,ZodTuple:ot,ZodRecord:rs,ZodMap:xn,ZodSet:Nn,ZodFunction:Ec,ZodLazy:ss,ZodLiteral:ns,ZodEnum:Ut,ZodNativeEnum:as,ZodPromise:kr,ZodEffects:Je,ZodTransformer:Je,ZodOptional:St,ZodNullable:tr,ZodDefault:is,ZodCatch:Sn,ZodNaN:En,BRAND:Qh,ZodBranded:Ic,ZodPipeline:vi,ZodReadonly:Zn,custom:$c,Schema:K,ZodSchema:K,late:ep,get ZodFirstPartyTypeKind(){return j},coerce:Rp,any:cp,array:hp,bigint:sp,boolean:Rc,date:np,discriminatedUnion:yp,effect:uo,enum:xp,function:kp,instanceof:tp,intersection:gp,lazy:Tp,literal:Op,map:_p,nan:rp,nativeEnum:Np,never:lp,null:op,nullable:Zp,number:jc,object:pp,oboolean:jp,onumber:Cp,optional:Ep,ostring:$p,pipeline:Ap,preprocess:Ip,promise:Sp,record:wp,set:bp,strictObject:fp,string:Cc,symbol:ap,transformer:uo,tuple:vp,undefined:ip,union:mp,unknown:up,void:dp,NEVER:zp,ZodIssueCode:w,quotelessJson:Dh,ZodError:Ke});let Ns=class extends Error{constructor(e,t){super(e),fe(this,"discriminator","FreighterError"),fe(this,"type"),this.type=t}};const Pp=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Fa="unknown",lo="nil",Hn="freighter",Ss=xt.object({type:xt.string(),data:xt.string()});class Mp{constructor(){fe(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:lo,data:""};if(Pp(e))for(const t of this.providers){const s=t.encode(e);if(s!=null)return s}return{type:Fa,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===lo)return null;if(e.type===Fa)return new ho(e.data);for(const t of this.providers){const s=t.decode(e);if(s!=null)return s}return new ho(e.data)}}const zc=new Mp,Pc=({encode:r,decode:e})=>zc.register({encode:r,decode:e}),wi=r=>zc.decode(r);let ho=class extends Ns{constructor(e){super(e,Fa)}},os=class extends Ns{constructor(){super("EOF",Hn)}},In=class extends Ns{constructor(){super("StreamClosed",Hn)}},cs=class extends Ns{constructor(e={}){const{message:t="Unreachable",url:s=zh.UNKNOWN}=e;super(t,Hn),fe(this,"url"),this.url=s}};const Hs="freighter",Dp=r=>{if(r.type!==Hn)return null;if(r instanceof os)return{type:Hs,data:"EOF"};if(r instanceof In)return{type:Hs,data:"StreamClosed"};if(r instanceof cs)return{type:Hs,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},Lp=r=>{if(r.type!==Hs)return null;switch(r.data){case"EOF":return new os;case"StreamClosed":return new In;case"Unreachable":return new cs;default:throw new Error(`Unknown error type: ${r.data}`)}};Pc({encode:Dp,decode:Lp});let Mc=class{constructor(){fe(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let s=0;const n=async a=>{if(s===this.middleware.length)return await t(a);const i=this.middleware[s];return s++,await i(a,n)};return await n(e)}};const Dc="Content-Type",po=r=>{if(_c.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),s=new t.Agent({rejectUnauthorized:!1});return async(n,a)=>await e(n,{...a,agent:s})};class Up extends Mc{constructor(e,t,s=!1){return super(),fe(this,"endpoint"),fe(this,"encoder"),fe(this,"fetch"),this.endpoint=e.replace({protocol:s?"https":"http"}),this.encoder=t,this.fetch=po(this.endpoint.protocol),new Proxy(this,{get:(n,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(n,a,i)})}get headers(){return{[Dc]:this.encoder.contentType}}async send(e,t,s,n){t=s==null?void 0:s.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,c]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const h={...l,params:{}};o.headers={...this.headers,...l.params};let k;try{k=await po(l.protocol)(l.target,o)}catch(ye){let Re=ye;return Re.message==="Load failed"&&(Re=new cs({url:i})),[h,Re]}const se=await k.arrayBuffer();if(k!=null&&k.ok)return n!=null&&(a=this.encoder.decode(se,n)),[h,null];try{if(k.status!==400)return[h,new Error(k.statusText)];const ye=this.encoder.decode(se,Ss),Re=wi(ye);return[h,Re]}catch(ye){return[h,new Error(`[freighter] - failed to decode error: ${k.statusText}: ${ye.message}`)]}});return[a,c]}}const $=async(r,e,t,s,n)=>{const[a,i]=await r.send(e,t,s,n);if(i!=null)throw i;return a},Bp=()=>_c.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),Vp=xt.object({type:xt.union([xt.literal("data"),xt.literal("close")]),payload:xt.unknown().optional(),error:xt.optional(Ss)});class qp{constructor(e,t,s,n){fe(this,"encoder"),fe(this,"reqSchema"),fe(this,"resSchema"),fe(this,"ws"),fe(this,"serverClosed"),fe(this,"sendClosed"),fe(this,"receiveDataQueue",[]),fe(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=s,this.resSchema=n,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new os;if(this.sendClosed)throw new In;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=wi(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,s)=>this.receiveCallbacksQueue.push({resolve:t,reject:s}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,Vp),s=this.receiveCallbacksQueue.shift();s!=null?s.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Gp(e)?new os:new In}}}const Kp="freighterctx",Wp=1e3,Fp=1001,Yp=[Wp,Fp],Gp=r=>Yp.includes(r.code),Lc=class Uc extends Mc{constructor(e,t,s=!1){super(),fe(this,"baseUrl"),fe(this,"encoder"),this.baseUrl=e.replace({protocol:s?"wss":"ws"}),this.encoder=t}async stream(e,t,s){const n=Bp();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=n(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=Uc.MESSAGE_TYPE;const h=await this.wrapSocket(c,t,s);return h instanceof Error?[l,h]:(a=h,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const s=Rh({[Dc]:this.encoder.contentType,...t.params},Kp);return this.baseUrl.child(e).toString()+s}async wrapSocket(e,t,s){return await new Promise(n=>{e.onopen=()=>{n(new qp(e,this.encoder,t,s))},e.onerror=a=>{const i=a;n(new Error(i.message))}})}};fe(Lc,"MESSAGE_TYPE","arraybuffer");let Jp=Lc;var Hp=Object.defineProperty,Xp=(r,e,t)=>e in r?Hp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,p=(r,e,t)=>(Xp(r,typeof e!="symbol"?e+"":e,t),t);let Qp="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",ef=(r=21)=>{let e="",t=r;for(;t--;)e+=Qp[Math.random()*64|0];return e};const tf=r=>r!=null&&typeof r=="object"&&"toString"in r,rf=(r,e=!1)=>{const t=tf(r)?"stringer":typeof r;let s;switch(t){case"string":s=(n,a)=>n.localeCompare(a);break;case"stringer":s=(n,a)=>n.toString().localeCompare(a.toString());break;case"number":s=(n,a)=>n-a;break;case"bigint":s=(n,a)=>n-a>BigInt(0)?1:-1;break;case"boolean":s=(n,a)=>Number(n)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?sf(s):s},sf=r=>(e,t)=>r(t,e);var X;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(X||(X={}));var Ya;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ya||(Ya={}));const x=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Mt=r=>{switch(typeof r){case"undefined":return x.undefined;case"string":return x.string;case"number":return isNaN(r)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(r)?x.array:r===null?x.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?x.promise:typeof Map<"u"&&r instanceof Map?x.map:typeof Set<"u"&&r instanceof Set?x.set:typeof Date<"u"&&r instanceof Date?x.date:x.object;default:return x.unknown}},_=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),nf=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class We extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}We.create=r=>new We(r);const us=(r,e)=>{let t;switch(r.code){case _.invalid_type:r.received===x.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,X.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${X.joinValues(r.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${X.joinValues(r.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${X.joinValues(r.options)}, received '${r.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:X.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case _.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case _.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,X.assertNever(r)}return{message:t}};let Bc=us;function af(r){Bc=r}function An(){return Bc}const $n=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},of=[];function E(r,e){const t=$n({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,An(),us].filter(s=>!!s)});r.common.issues.push(t)}class Te{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return L;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Te.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return L;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const L=Object.freeze({status:"aborted"}),Vc=r=>({status:"dirty",value:r}),$e=r=>({status:"valid",value:r}),Ga=r=>r.status==="aborted",Ja=r=>r.status==="dirty",ls=r=>r.status==="valid",Cn=r=>typeof Promise<"u"&&r instanceof Promise;var A;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(A||(A={}));class ct{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const fo=(r,e)=>{if(ls(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new We(r.common.issues);return this._error=t,this._error}}};function V(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}class W{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Mt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Mt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Te,ctx:{common:e.parent.common,data:e.data,parsedType:Mt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Cn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return fo(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Mt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(Cn(n)?n:Promise.resolve(n));return fo(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:_.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new He({schema:this,typeName:R.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Et.create(this,this._def)}nullable(){return nr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Fe.create(this,this._def)}promise(){return Or.create(this,this._def)}or(e){return fs.create([this,e],this._def)}and(e){return ms.create(this,e,this._def)}transform(e){return new He({...V(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new _s({...V(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new Kc({typeName:R.ZodBranded,type:this,...V(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Pn({...V(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Es.create(this,e)}readonly(){return Dn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const cf=/^c[^\s-]{8,}$/i,uf=/^[a-z][a-z0-9]*$/,lf=/^[0-9A-HJKMNP-TV-Z]{26}$/,df=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,hf=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pf="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ya;const ff=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,mf=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,yf=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function gf(r,e){return!!((e==="v4"||!e)&&ff.test(r)||(e==="v6"||!e)&&mf.test(r))}class Ve extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.string,received:n.parsedType}),L}const t=new Te;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?E(s,{code:_.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&E(s,{code:_.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")hf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"email",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ya||(ya=new RegExp(pf,"u")),ya.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"emoji",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")df.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"uuid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")cf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"cuid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")uf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"cuid2",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")lf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"ulid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),E(s,{validation:"url",code:_.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"regex",code:_.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?yf(n).test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?gf(e.data,n.version)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"ip",code:_.invalid_string,message:n.message}),t.dirty()):X.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:_.invalid_string,...A.errToObj(s)})}_addCheck(e){return new Ve({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...A.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...A.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ve({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ve.create=r=>{var e;return new Ve({checks:[],typeName:R.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...V(r)})};function vf(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class Bt extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==x.number){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.number,received:n.parsedType}),L}let t;const s=new Te;for(const n of this._def.checks)n.kind==="int"?X.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:_.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?vf(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_finite,message:n.message}),s.dirty()):X.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,s,n){return new Bt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:A.toString(n)}]})}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Bt.create=r=>new Bt({checks:[],typeName:R.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...V(r)});class Vt extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==x.bigint){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.bigint,received:n.parsedType}),L}let t;const s=new Te;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):X.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,s,n){return new Vt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:A.toString(n)}]})}_addCheck(e){return new Vt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Vt.create=r=>{var e;return new Vt({checks:[],typeName:R.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...V(r)})};class ds extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.boolean,received:t.parsedType}),L}return $e(e.data)}}ds.create=r=>new ds({typeName:R.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...V(r)});class rr extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.date,received:n.parsedType}),L}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_date}),L}const t=new Te;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):X.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new rr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}rr.create=r=>new rr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:R.ZodDate,...V(r)});class jn extends W{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.symbol,received:t.parsedType}),L}return $e(e.data)}}jn.create=r=>new jn({typeName:R.ZodSymbol,...V(r)});class hs extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.undefined,received:t.parsedType}),L}return $e(e.data)}}hs.create=r=>new hs({typeName:R.ZodUndefined,...V(r)});class ps extends W{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.null,received:t.parsedType}),L}return $e(e.data)}}ps.create=r=>new ps({typeName:R.ZodNull,...V(r)});class Tr extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return $e(e.data)}}Tr.create=r=>new Tr({typeName:R.ZodAny,...V(r)});class Jt extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $e(e.data)}}Jt.create=r=>new Jt({typeName:R.ZodUnknown,...V(r)});class At extends W{_parse(e){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.never,received:t.parsedType}),L}}At.create=r=>new At({typeName:R.ZodNever,...V(r)});class Rn extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.void,received:t.parsedType}),L}return $e(e.data)}}Rn.create=r=>new Rn({typeName:R.ZodVoid,...V(r)});class Fe extends W{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==x.array)return E(t,{code:_.invalid_type,expected:x.array,received:t.parsedType}),L;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(E(t,{code:i?_.too_big:_.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(E(t,{code:_.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(E(t,{code:_.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new ct(t,i,t.path,o)))).then(i=>Te.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new ct(t,i,t.path,o)));return Te.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Fe({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new Fe({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new Fe({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}}Fe.create=(r,e)=>new Fe({type:r,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...V(e)});function pr(r){if(r instanceof le){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Et.create(pr(s))}return new le({...r._def,shape:()=>e})}else return r instanceof Fe?new Fe({...r._def,type:pr(r.element)}):r instanceof Et?Et.create(pr(r.unwrap())):r instanceof nr?nr.create(pr(r.unwrap())):r instanceof ut?ut.create(r.items.map(e=>pr(e))):r}class le extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=X.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==x.object){const c=this._getOrReturnCtx(e);return E(c,{code:_.invalid_type,expected:x.object,received:c.parsedType}),L}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof At&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=n[c],h=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new ct(s,h,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof At){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")i.length>0&&(E(s,{code:_.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new ct(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>Te.mergeObjectSync(t,c)):Te.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=A.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new le({...this._def,unknownKeys:"strip"})}passthrough(){return new le({...this._def,unknownKeys:"passthrough"})}extend(e){return new le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new le({...this._def,catchall:e})}pick(e){const t={};return X.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new le({...this._def,shape:()=>t})}omit(e){const t={};return X.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new le({...this._def,shape:()=>t})}deepPartial(){return pr(this)}partial(e){const t={};return X.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new le({...this._def,shape:()=>t})}required(e){const t={};return X.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Et;)n=n._def.innerType;t[s]=n}}),new le({...this._def,shape:()=>t})}keyof(){return qc(X.objectKeys(this.shape))}}le.create=(r,e)=>new le({shape:()=>r,unknownKeys:"strip",catchall:At.create(),typeName:R.ZodObject,...V(e)});le.strictCreate=(r,e)=>new le({shape:()=>r,unknownKeys:"strict",catchall:At.create(),typeName:R.ZodObject,...V(e)});le.lazycreate=(r,e)=>new le({shape:r,unknownKeys:"strip",catchall:At.create(),typeName:R.ZodObject,...V(e)});class fs extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new We(o.ctx.common.issues));return E(t,{code:_.invalid_union,unionErrors:i}),L}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new We(c));return E(t,{code:_.invalid_union,unionErrors:o}),L}}get options(){return this._def.options}}fs.create=(r,e)=>new fs({options:r,typeName:R.ZodUnion,...V(e)});const Xs=r=>r instanceof gs?Xs(r.schema):r instanceof He?Xs(r.innerType()):r instanceof vs?[r.value]:r instanceof qt?r.options:r instanceof ws?Object.keys(r.enum):r instanceof _s?Xs(r._def.innerType):r instanceof hs?[void 0]:r instanceof ps?[null]:null;class Xn extends W{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return E(t,{code:_.invalid_type,expected:x.object,received:t.parsedType}),L;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(E(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Xs(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Xn({typeName:R.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...V(s)})}}function Ha(r,e){const t=Mt(r),s=Mt(e);if(r===e)return{valid:!0,data:r};if(t===x.object&&s===x.object){const n=X.objectKeys(e),a=X.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Ha(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===x.array&&s===x.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Ha(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===x.date&&s===x.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ms extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ga(a)||Ga(i))return L;const o=Ha(a.value,i.value);return o.valid?((Ja(a)||Ja(i))&&t.dirty(),{status:t.value,value:o.data}):(E(s,{code:_.invalid_intersection_types}),L)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ms.create=(r,e,t)=>new ms({left:r,right:e,typeName:R.ZodIntersection,...V(t)});class ut extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.array)return E(s,{code:_.invalid_type,expected:x.array,received:s.parsedType}),L;if(s.data.length<this._def.items.length)return E(s,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&s.data.length>this._def.items.length&&(E(s,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new ct(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>Te.mergeArray(t,a)):Te.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ut({...this._def,rest:e})}}ut.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ut({items:r,typeName:R.ZodTuple,rest:null,...V(e)})};class ys extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.object)return E(s,{code:_.invalid_type,expected:x.object,received:s.parsedType}),L;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new ct(s,o,s.path,o)),value:i._parse(new ct(s,s.data[o],s.path,o))});return s.common.async?Te.mergeObjectAsync(t,n):Te.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof W?new ys({keyType:e,valueType:t,typeName:R.ZodRecord,...V(s)}):new ys({keyType:Ve.create(),valueType:e,typeName:R.ZodRecord,...V(t)})}}class zn extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.map)return E(s,{code:_.invalid_type,expected:x.map,received:s.parsedType}),L;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new ct(s,o,s.path,[l,"key"])),value:a._parse(new ct(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}zn.create=(r,e,t)=>new zn({valueType:e,keyType:r,typeName:R.ZodMap,...V(t)});class sr extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.set)return E(s,{code:_.invalid_type,expected:x.set,received:s.parsedType}),L;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(E(s,{code:_.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(E(s,{code:_.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return L;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new ct(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new sr({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new sr({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}sr.create=(r,e)=>new sr({valueType:r,minSize:null,maxSize:null,typeName:R.ZodSet,...V(e)});class yr extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return E(t,{code:_.invalid_type,expected:x.function,received:t.parsedType}),L;function s(o,c){return $n({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,An(),us].filter(l=>!!l),issueData:{code:_.invalid_arguments,argumentsError:c}})}function n(o,c){return $n({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,An(),us].filter(l=>!!l),issueData:{code:_.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Or){const o=this;return $e(async function(...c){const l=new We([]),h=await o._def.args.parseAsync(c,a).catch(se=>{throw l.addIssue(s(c,se)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(se=>{throw l.addIssue(n(k,se)),l})})}else{const o=this;return $e(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new We([s(c,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new We([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new yr({...this._def,args:ut.create(e).rest(Jt.create())})}returns(e){return new yr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new yr({args:e||ut.create([]).rest(Jt.create()),returns:t||Jt.create(),typeName:R.ZodFunction,...V(s)})}}class gs extends W{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}gs.create=(r,e)=>new gs({getter:r,typeName:R.ZodLazy,...V(e)});class vs extends W{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return E(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}}vs.create=(r,e)=>new vs({value:r,typeName:R.ZodLiteral,...V(e)});function qc(r,e){return new qt({values:r,typeName:R.ZodEnum,...V(e)})}class qt extends W{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return E(t,{expected:X.joinValues(s),received:t.parsedType,code:_.invalid_type}),L}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return E(t,{received:t.data,code:_.invalid_enum_value,options:s}),L}return $e(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return qt.create(e)}exclude(e){return qt.create(this.options.filter(t=>!e.includes(t)))}}qt.create=qc;class ws extends W{_parse(e){const t=X.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==x.string&&s.parsedType!==x.number){const n=X.objectValues(t);return E(s,{expected:X.joinValues(n),received:s.parsedType,code:_.invalid_type}),L}if(t.indexOf(e.data)===-1){const n=X.objectValues(t);return E(s,{received:s.data,code:_.invalid_enum_value,options:n}),L}return $e(e.data)}get enum(){return this._def.values}}ws.create=(r,e)=>new ws({values:r,typeName:R.ZodNativeEnum,...V(e)});class Or extends W{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.promise&&t.common.async===!1)return E(t,{code:_.invalid_type,expected:x.promise,received:t.parsedType}),L;const s=t.parsedType===x.promise?t.data:Promise.resolve(t.data);return $e(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Or.create=(r,e)=>new Or({type:r,typeName:R.ZodPromise,...V(e)});class He extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{E(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ls(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>ls(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);X.assertNever(n)}}He.create=(r,e,t)=>new He({schema:r,typeName:R.ZodEffects,effect:e,...V(t)});He.createWithPreprocess=(r,e,t)=>new He({schema:e,effect:{type:"preprocess",transform:r},typeName:R.ZodEffects,...V(t)});class Et extends W{_parse(e){return this._getType(e)===x.undefined?$e(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Et.create=(r,e)=>new Et({innerType:r,typeName:R.ZodOptional,...V(e)});class nr extends W{_parse(e){return this._getType(e)===x.null?$e(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}nr.create=(r,e)=>new nr({innerType:r,typeName:R.ZodNullable,...V(e)});class _s extends W{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===x.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}_s.create=(r,e)=>new _s({innerType:r,typeName:R.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...V(e)});class Pn extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return Cn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new We(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new We(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Pn.create=(r,e)=>new Pn({innerType:r,typeName:R.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...V(e)});class Mn extends W{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.nan,received:t.parsedType}),L}return{status:"valid",value:e.data}}}Mn.create=r=>new Mn({typeName:R.ZodNaN,...V(r)});const wf=Symbol("zod_brand");class Kc extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Es extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?L:n.status==="dirty"?(t.dirty(),Vc(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?L:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Es({in:e,out:t,typeName:R.ZodPipeline})}}class Dn extends W{_parse(e){const t=this._def.innerType._parse(e);return ls(t)&&(t.value=Object.freeze(t.value)),t}}Dn.create=(r,e)=>new Dn({innerType:r,typeName:R.ZodReadonly,...V(e)});const Wc=(r,e={},t)=>r?Tr.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):Tr.create(),_f={object:le.lazycreate};var R;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(R||(R={}));const bf=(r,e={message:`Input not instance of ${r.name}`})=>Wc(t=>t instanceof r,e),Fc=Ve.create,Yc=Bt.create,kf=Mn.create,Tf=Vt.create,Gc=ds.create,Of=rr.create,xf=jn.create,Nf=hs.create,Sf=ps.create,Ef=Tr.create,Zf=Jt.create,If=At.create,Af=Rn.create,$f=Fe.create,Cf=le.create,jf=le.strictCreate,Rf=fs.create,zf=Xn.create,Pf=ms.create,Mf=ut.create,Df=ys.create,Lf=zn.create,Uf=sr.create,Bf=yr.create,Vf=gs.create,qf=vs.create,Kf=qt.create,Wf=ws.create,Ff=Or.create,mo=He.create,Yf=Et.create,Gf=nr.create,Jf=He.createWithPreprocess,Hf=Es.create,Xf=()=>Fc().optional(),Qf=()=>Yc().optional(),em=()=>Gc().optional(),tm={string:r=>Ve.create({...r,coerce:!0}),number:r=>Bt.create({...r,coerce:!0}),boolean:r=>ds.create({...r,coerce:!0}),bigint:r=>Vt.create({...r,coerce:!0}),date:r=>rr.create({...r,coerce:!0})},rm=L;var m=Object.freeze({__proto__:null,defaultErrorMap:us,setErrorMap:af,getErrorMap:An,makeIssue:$n,EMPTY_PATH:of,addIssueToContext:E,ParseStatus:Te,INVALID:L,DIRTY:Vc,OK:$e,isAborted:Ga,isDirty:Ja,isValid:ls,isAsync:Cn,get util(){return X},get objectUtil(){return Ya},ZodParsedType:x,getParsedType:Mt,ZodType:W,ZodString:Ve,ZodNumber:Bt,ZodBigInt:Vt,ZodBoolean:ds,ZodDate:rr,ZodSymbol:jn,ZodUndefined:hs,ZodNull:ps,ZodAny:Tr,ZodUnknown:Jt,ZodNever:At,ZodVoid:Rn,ZodArray:Fe,ZodObject:le,ZodUnion:fs,ZodDiscriminatedUnion:Xn,ZodIntersection:ms,ZodTuple:ut,ZodRecord:ys,ZodMap:zn,ZodSet:sr,ZodFunction:yr,ZodLazy:gs,ZodLiteral:vs,ZodEnum:qt,ZodNativeEnum:ws,ZodPromise:Or,ZodEffects:He,ZodTransformer:He,ZodOptional:Et,ZodNullable:nr,ZodDefault:_s,ZodCatch:Pn,ZodNaN:Mn,BRAND:wf,ZodBranded:Kc,ZodPipeline:Es,ZodReadonly:Dn,custom:Wc,Schema:W,ZodSchema:W,late:_f,get ZodFirstPartyTypeKind(){return R},coerce:tm,any:Ef,array:$f,bigint:Tf,boolean:Gc,date:Of,discriminatedUnion:zf,effect:mo,enum:Kf,function:Bf,instanceof:bf,intersection:Pf,lazy:Vf,literal:qf,map:Lf,nan:kf,nativeEnum:Wf,never:If,null:Sf,nullable:Gf,number:Yc,object:Cf,oboolean:em,onumber:Qf,optional:Yf,ostring:Xf,pipeline:Hf,preprocess:Jf,promise:Ff,record:Df,set:Uf,strictObject:jf,string:Fc,symbol:xf,transformer:mo,tuple:Mf,undefined:Nf,union:Rf,unknown:Zf,void:Af,NEVER:rm,ZodIssueCode:_,quotelessJson:nf,ZodError:We});const _i=m.tuple([m.number(),m.number()]),Jc=m.object({width:m.number(),height:m.number()}),sm=m.object({signedWidth:m.number(),signedHeight:m.number()}),nm=["width","height"];m.enum(nm);const am=["start","center","end"],im=["signedWidth","signedHeight"];m.enum(im);const Ln=m.object({x:m.number(),y:m.number()}),om=m.object({clientX:m.number(),clientY:m.number()}),cm=["x","y"],Hc=m.enum(cm),Xc=["top","right","bottom","left"];m.enum(Xc);const um=["left","right"],Qc=m.enum(um),lm=["top","bottom"],eu=m.enum(lm),tu=["center"],yo=m.enum(tu),dm=[...Xc,...tu],ru=m.enum(dm);m.enum(am);const hm=["first","last"];m.enum(hm);const pm=m.object({lower:m.number(),upper:m.number()});m.union([pm,_i]);m.union([Hc,ru]);m.union([Hc,ru,m.instanceof(String)]);const Ar=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),fm(t)},fm=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var De=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y={},Qn={};Object.defineProperty(Qn,"__esModule",{value:!0});function mm(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,s){return s.toUpperCase()}):""}Qn.default=mm;var ea={};Object.defineProperty(ea,"__esModule",{value:!0});function ym(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}ea.default=ym;var ta={};Object.defineProperty(ta,"__esModule",{value:!0});function gm(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,s){return s.toUpperCase()}):""}ta.default=gm;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});function vm(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}bi.default=vm;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});function wm(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}ki.default=wm;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});function _m(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ti.default=_m;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});function bm(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,s,n){return s+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Oi.default=bm;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});function km(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,s,n){return t+s.charAt(0).toUpperCase()+s.slice(1)+n}):""}xi.default=km;var ra={};Object.defineProperty(ra,"__esModule",{value:!0});function Tm(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}ra.default=Tm;var Ni={},cr={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(s){return e instanceof s})}})(cr);var Om=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ni,"__esModule",{value:!0});var yt=cr;function Qs(r,e){if(e===void 0&&(e=yt.DefaultOption),!yt.isValidObject(r))return null;e=yt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toLowerCase();e.recursive&&(yt.isValidObject(n)?yt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Qs(n,e)):e.recursiveInArray&&yt.isArrayObject(n)&&(n=Om(n).map(function(i){var o=i;if(yt.isValidObject(i))yt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Qs(i,e));else if(yt.isArrayObject(i)){var c=Qs({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ni.default=Qs;var Si={},xm=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Si,"__esModule",{value:!0});var gt=cr;function en(r,e){if(e===void 0&&(e=gt.DefaultOption),!gt.isValidObject(r))return null;e=gt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toUpperCase();e.recursive&&(gt.isValidObject(n)?gt.belongToTypes(n,e.keepTypesOnRecursion)||(n=en(n,e)):e.recursiveInArray&&gt.isArrayObject(n)&&(n=xm(n).map(function(i){var o=i;if(gt.isValidObject(i))gt.belongToTypes(o,e.keepTypesOnRecursion)||(o=en(i,e));else if(gt.isArrayObject(i)){var c=en({key:i},e);o=c.key}return o}))),t[a]=n}),t}Si.default=en;var Ei={},Nm=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ei,"__esModule",{value:!0});var vt=cr,Sm=Qn;function tn(r,e){if(e===void 0&&(e=vt.DefaultOption),!vt.isValidObject(r))return null;e=vt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Sm.default(s);e.recursive&&(vt.isValidObject(n)?vt.belongToTypes(n,e.keepTypesOnRecursion)||(n=tn(n,e)):e.recursiveInArray&&vt.isArrayObject(n)&&(n=Nm(n).map(function(i){var o=i;if(vt.isValidObject(i))vt.belongToTypes(o,e.keepTypesOnRecursion)||(o=tn(i,e));else if(vt.isArrayObject(i)){var c=tn({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ei.default=tn;var Zi={},Em=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Zi,"__esModule",{value:!0});var wt=cr,Zm=ea;function rn(r,e){if(e===void 0&&(e=wt.DefaultOption),!wt.isValidObject(r))return null;e=wt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Zm.default(s);e.recursive&&(wt.isValidObject(n)?wt.belongToTypes(n,e.keepTypesOnRecursion)||(n=rn(n,e)):e.recursiveInArray&&wt.isArrayObject(n)&&(n=Em(n).map(function(i){var o=i;if(wt.isValidObject(i))wt.belongToTypes(o,e.keepTypesOnRecursion)||(o=rn(i,e));else if(wt.isArrayObject(i)){var c=rn({key:i},e);o=c.key}return o}))),t[a]=n}),t}Zi.default=rn;var Ii={},Im=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ii,"__esModule",{value:!0});var _t=cr,Am=ta;function sn(r,e){if(e===void 0&&(e=_t.DefaultOption),!_t.isValidObject(r))return null;e=_t.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Am.default(s);e.recursive&&(_t.isValidObject(n)?_t.belongToTypes(n,e.keepTypesOnRecursion)||(n=sn(n,e)):e.recursiveInArray&&_t.isArrayObject(n)&&(n=Im(n).map(function(i){var o=i;if(_t.isValidObject(i))_t.belongToTypes(o,e.keepTypesOnRecursion)||(o=sn(i,e));else if(_t.isArrayObject(i)){var c=sn({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ii.default=sn;var Ai={},$m=De&&De.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ai,"__esModule",{value:!0});var bt=cr,Cm=ra;function nn(r,e){if(e===void 0&&(e=bt.DefaultOption),!bt.isValidObject(r))return null;e=bt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=Cm.default(s);e.recursive&&(bt.isValidObject(n)?bt.belongToTypes(n,e.keepTypesOnRecursion)||(n=nn(n,e)):e.recursiveInArray&&bt.isArrayObject(n)&&(n=$m(n).map(function(i){var o=i;if(bt.isValidObject(i))bt.belongToTypes(o,e.keepTypesOnRecursion)||(o=nn(i,e));else if(bt.isArrayObject(i)){var c=nn({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ai.default=nn;Object.defineProperty(Y,"__esModule",{value:!0});Y.kebabKeys=Y.pascalKeys=Y.snakeKeys=Y.camelKeys=Y.upperKeys=Y.lowerKeys=Y.toLowerCase=Y.toUpperCase=Y.toKebabCase=Y.toHeaderCase=Y.toSentenceCase=Y.toTextCase=Y.toPathCase=Y.toDotCase=Y.toPascalCase=Y.toSnakeCase=Y.toCamelCase=void 0;var su=Qn;Y.toCamelCase=su.default;var nu=ea;Y.toSnakeCase=nu.default;var au=ta;Y.toPascalCase=au.default;var iu=bi;Y.toDotCase=iu.default;var ou=ki;Y.toPathCase=ou.default;var cu=Ti;Y.toTextCase=cu.default;var uu=Oi;Y.toSentenceCase=uu.default;var lu=xi;Y.toHeaderCase=lu.default;var du=ra;Y.toKebabCase=du.default;var hu=Ni;Y.lowerKeys=hu.default;var pu=Si;Y.upperKeys=pu.default;var fu=Ei;Y.camelKeys=fu.default;var mu=Zi;Y.snakeKeys=mu.default;var yu=Ii;Y.pascalKeys=yu.default;var gu=Ai;Y.kebabKeys=gu.default;var vu=function(r){return String(r||"").toLowerCase()};Y.toLowerCase=vu;var wu=function(r){return String(r||"").toUpperCase()};Y.toUpperCase=wu;var jm={toCamelCase:su.default,toSnakeCase:nu.default,toPascalCase:au.default,toDotCase:iu.default,toPathCase:ou.default,toTextCase:cu.default,toSentenceCase:uu.default,toHeaderCase:lu.default,toKebabCase:du.default,toUpperCase:wu,toLowerCase:vu,lowerKeys:hu.default,upperKeys:pu.default,camelKeys:fu.default,snakeKeys:mu.default,pascalKeys:yu.default,kebabKeys:gu.default};Y.default=jm;var _u=Y;const bu={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Rm=r=>_u.snakeKeys(r,bu),zm=r=>_u.camelKeys(r,bu);var Un;(r=>{r.toSnake=Rm,r.toCamel=zm,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Un||(Un={}));m.object({x:Qc.or(yo),y:eu.or(yo)});const Pm=m.object({x:Qc,y:eu}),Mm=Object.freeze({x:"left",y:"top"}),Dm=(r,e)=>r.x===e.x&&r.y===e.y,go=m.union([m.number(),Ln,_i,Jc,sm,om]),Lm=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},vo={x:0,y:0},zs=m.union([m.number(),m.string()]);m.object({top:zs,left:zs,width:zs,height:zs});m.object({left:m.number(),top:m.number(),right:m.number(),bottom:m.number()});m.object({one:Ln,two:Ln,root:Pm});const $i=(r,e,t=0,s=0,n)=>{const a={one:{...vo},two:{...vo},root:n??Mm};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+s}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},ga=r=>{const e=$i(r);return{lower:e.one.x,upper:e.two.x}},va=r=>{const e=$i(r);return{lower:e.one.y,upper:e.two.y}},Um=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Bm=m.object({signedWidth:m.number(),signedHeight:m.number()});m.union([Jc,Bm,Ln,_i]);const Vm=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);m.object({offset:go,scale:go});const qm=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],Km=r=>(e,t,s,n)=>[e,n?s/r:s*r],Wm=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:i,upper:o}=r,c=a-n,l=o-i;if(t==="dimension")return[r,s*(l/c)];const h=(s-n)*(l/c)+i;return[r,h]},Fm=r=>(e,t,s)=>[r,s],Ym=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},Gm=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=Vm(s,n,a),[e,s]},Xa=class Er{constructor(){p(this,"ops",[]),p(this,"currBounds",null),p(this,"currType",null),p(this,"reversed",!1),this.ops=[]}static translate(e){return new Er().translate(e)}static magnify(e){return new Er().magnify(e)}static scale(e,t){return new Er().scale(e,t)}translate(e){const t=this.new(),s=qm(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=Km(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=Ar(e,t),n=this.new(),a=Wm(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=Ar(e,t),n=this.new(),a=Gm(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=Ar(e,t),n=this.new(),a=Fm(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=Ym();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Er;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([i,o])=>n>=i&&n<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}};p(Xa,"IDENTITY",new Xa);let wo=Xa;const _o=class Tt{constructor(e=new wo,t=new wo,s=null){p(this,"x"),p(this,"y"),p(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new Tt().translate(e,t)}static translateX(e){return new Tt().translateX(e)}static translateY(e){return new Tt().translateY(e)}static clamp(e){return new Tt().clamp(e)}static magnify(e){return new Tt().magnify(e)}static scale(e){return new Tt().scale(e)}static reBound(e){return new Tt().reBound(e)}translate(e,t){const s=Lm(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Um(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!Dm(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(ga(e)),t.y=t.y.scale(va(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(ga(e)),t.y=this.y.reBound(va(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(ga(e)),t.y=this.y.clamp(va(e)),t}copy(){const e=new Tt;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return $i(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};p(_o,"IDENTITY",new _o);const ku=(r,e)=>{const t=new G(e);if(![ce.DAY,ce.HOUR,ce.MINUTE,ce.SECOND,ce.MILLISECOND,ce.MICROSECOND,ce.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof G?new G(s):new ce(s)},ie=class P{constructor(e,t="UTC"){if(p(this,"value"),p(this,"encodeValue",!0),e==null)this.value=P.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*P.MILLISECOND.valueOf();else if(typeof e=="string")this.value=P.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=P.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=P.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=P.MAX:e=P.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new P(BigInt(n.getTime())*P.MILLISECOND.valueOf()).truncate(P.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=P.hours(parseInt(s??"00",10)).add(P.minutes(parseInt(n??"00",10))).add(P.seconds(parseInt(i??"00",10))).add(P.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(P.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return P.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new P(BigInt(s.getTime())*P.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(P.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(e="UTC"){const t=this.date(),s=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${s} ${n}`}static get utcOffset(){return new ce(BigInt(new Date().getTimezoneOffset())*P.MINUTE.valueOf())}static since(e){return new P().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new P(e).valueOf()}span(e){return this.range(e).span}range(e){return new ze(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new P(e).valueOf()}afterEq(e){return this.valueOf()>=new P(e).valueOf()}before(e){return this.valueOf()<new P(e).valueOf()}beforeEq(e){return this.valueOf()<=new P(e).valueOf()}add(e){return new P(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new P(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/P.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ku(this,e)}get isToday(){return this.truncate(ce.DAY).equals(P.now().truncate(ce.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new P(new Date)}static max(...e){let t=P.MIN;for(const s of e){const n=new P(s);n.after(t)&&(t=n)}return t}static min(...e){let t=P.MAX;for(const s of e){const n=new P(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new P(e)}static microseconds(e){return P.nanoseconds(e*1e3)}static milliseconds(e){return P.microseconds(e*1e3)}static seconds(e){return P.milliseconds(e*1e3)}static minutes(e){return P.seconds(e*60)}static hours(e){return P.minutes(e*60)}static days(e){return P.hours(e*24)}};p(ie,"NANOSECOND",ie.nanoseconds(1)),p(ie,"MICROSECOND",ie.microseconds(1)),p(ie,"MILLISECOND",ie.milliseconds(1)),p(ie,"SECOND",ie.seconds(1)),p(ie,"MINUTE",ie.minutes(1)),p(ie,"HOUR",ie.hours(1)),p(ie,"DAY",ie.days(1)),p(ie,"MAX",new ie((1n<<63n)-1n)),p(ie,"MIN",new ie(0)),p(ie,"ZERO",new ie(0)),p(ie,"z",m.union([m.object({value:m.bigint()}).transform(r=>new ie(r.value)),m.string().transform(r=>new ie(BigInt(r))),m.instanceof(Number).transform(r=>new ie(r)),m.number().transform(r=>new ie(r)),m.instanceof(ie)]));let G=ie;const oe=class ee{constructor(e){p(this,"value"),p(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new ee(e).valueOf()}greaterThan(e){return this.valueOf()>new ee(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new ee(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new ee(e).valueOf()}remainder(e){return ku(this,e)}truncate(e){return new ee(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(ee.DAY),t=this.truncate(ee.HOUR),s=this.truncate(ee.MINUTE),n=this.truncate(ee.SECOND),a=this.truncate(ee.MILLISECOND),i=this.truncate(ee.MICROSECOND),o=this.truncate(ee.NANOSECOND),c=e,l=t.sub(e),h=s.sub(t),k=n.sub(s),se=a.sub(n),ye=i.sub(a),Re=o.sub(i);let de="";return c.isZero||(de+=`${c.days}d `),l.isZero||(de+=`${l.hours}h `),h.isZero||(de+=`${h.minutes}m `),k.isZero||(de+=`${k.seconds}s `),se.isZero||(de+=`${se.milliseconds}ms `),ye.isZero||(de+=`${ye.microseconds}µs `),Re.isZero||(de+=`${Re.nanoseconds}ns`),de.trim()}get days(){return Number(this.valueOf()/ee.DAY.valueOf())}get hours(){return Number(this.valueOf()/ee.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/ee.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/ee.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/ee.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/ee.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new ee(e).valueOf()}add(e){return new ee(this.valueOf()+new ee(e).valueOf())}sub(e){return new ee(this.valueOf()-new ee(e).valueOf())}static nanoseconds(e=1){return new ee(e)}static microseconds(e=1){return ee.nanoseconds(e*1e3)}static milliseconds(e=1){return ee.microseconds(e*1e3)}static seconds(e=1){return ee.milliseconds(e*1e3)}static minutes(e){return ee.seconds(e.valueOf()*60)}static hours(e){return ee.minutes(e*60)}static days(e){return ee.hours(e*24)}};p(oe,"NANOSECOND",oe.nanoseconds(1)),p(oe,"MICROSECOND",oe.microseconds(1)),p(oe,"MILLISECOND",oe.milliseconds(1)),p(oe,"SECOND",oe.seconds(1)),p(oe,"MINUTE",oe.minutes(1)),p(oe,"HOUR",oe.hours(1)),p(oe,"DAY",oe.days(1)),p(oe,"MAX",new oe((1n<<63n)-1n)),p(oe,"MIN",new oe(0)),p(oe,"ZERO",new oe(0)),p(oe,"z",m.union([m.object({value:m.bigint()}).transform(r=>new oe(r.value)),m.string().transform(r=>new oe(BigInt(r))),m.instanceof(Number).transform(r=>new oe(r)),m.number().transform(r=>new oe(r)),m.instanceof(oe)]));let ce=oe;const Zr=class an extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new an(e).valueOf()}get period(){return ce.seconds(1/this.valueOf())}sampleCount(e){return new ce(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ke(t).valueOf()}span(e){return ce.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new an(e)}static khz(e){return an.hz(e*1e3)}};p(Zr,"z",m.union([m.number().transform(r=>new Zr(r)),m.instanceof(Number).transform(r=>new Zr(r)),m.instanceof(Zr)]));let sa=Zr;const ve=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new bs(e*this.valueOf())}};p(ve,"UNKNOWN",new ve(0)),p(ve,"BIT128",new ve(16)),p(ve,"BIT64",new ve(8)),p(ve,"BIT32",new ve(4)),p(ve,"BIT16",new ve(2)),p(ve,"BIT8",new ve(1)),p(ve,"z",m.union([m.number().transform(r=>new ve(r)),m.instanceof(Number).transform(r=>new ve(r)),m.instanceof(ve)]));let ke=ve;const tt=class on{constructor(e,t){p(this,"start"),p(this,"end"),typeof e=="object"&&"start"in e?(this.start=new G(e.start),this.end=new G(e.end)):(this.start=new G(e),this.end=new G(t))}get span(){return new ce(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new on(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof on?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new on(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};p(tt,"MAX",new tt(G.MIN,G.MAX)),p(tt,"MIN",new tt(G.MAX,G.MIN)),p(tt,"ZERO",new tt(G.ZERO,G.ZERO)),p(tt,"z",m.union([m.object({start:G.z,end:G.z}).transform(r=>new tt(r.start,r.end)),m.instanceof(tt)]));let ze=tt;const y=class rt extends String{constructor(e){if(e instanceof rt||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=rt.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(rt.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=rt.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(rt.JSON)||this.equals(rt.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(rt.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=rt.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return rt.BIG_INT_TYPES.some(e=>e.equals(this))}};p(y,"UNKNOWN",new y("unknown")),p(y,"FLOAT64",new y("float64")),p(y,"FLOAT32",new y("float32")),p(y,"INT64",new y("int64")),p(y,"INT32",new y("int32")),p(y,"INT16",new y("int16")),p(y,"INT8",new y("int8")),p(y,"UINT64",new y("uint64")),p(y,"UINT32",new y("uint32")),p(y,"UINT16",new y("uint16")),p(y,"UINT8",new y("uint8")),p(y,"BOOLEAN",y.UINT8),p(y,"TIMESTAMP",new y("timestamp")),p(y,"UUID",new y("uuid")),p(y,"STRING",new y("string")),p(y,"JSON",new y("json")),p(y,"ARRAY_CONSTRUCTORS",new Map([[y.UINT8.toString(),Uint8Array],[y.UINT16.toString(),Uint16Array],[y.UINT32.toString(),Uint32Array],[y.UINT64.toString(),BigUint64Array],[y.FLOAT32.toString(),Float32Array],[y.FLOAT64.toString(),Float64Array],[y.INT8.toString(),Int8Array],[y.INT16.toString(),Int16Array],[y.INT32.toString(),Int32Array],[y.INT64.toString(),BigInt64Array],[y.TIMESTAMP.toString(),BigInt64Array],[y.STRING.toString(),Uint8Array],[y.JSON.toString(),Uint8Array],[y.UUID.toString(),Uint8Array]])),p(y,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,y.UINT8],[Uint16Array.name,y.UINT16],[Uint32Array.name,y.UINT32],[BigUint64Array.name,y.UINT64],[Float32Array.name,y.FLOAT32],[Float64Array.name,y.FLOAT64],[Int8Array.name,y.INT8],[Int16Array.name,y.INT16],[Int32Array.name,y.INT32],[BigInt64Array.name,y.INT64]])),p(y,"DENSITIES",new Map([[y.UINT8.toString(),ke.BIT8],[y.UINT16.toString(),ke.BIT16],[y.UINT32.toString(),ke.BIT32],[y.UINT64.toString(),ke.BIT64],[y.FLOAT32.toString(),ke.BIT32],[y.FLOAT64.toString(),ke.BIT64],[y.INT8.toString(),ke.BIT8],[y.INT16.toString(),ke.BIT16],[y.INT32.toString(),ke.BIT32],[y.INT64.toString(),ke.BIT64],[y.TIMESTAMP.toString(),ke.BIT64],[y.STRING.toString(),ke.UNKNOWN],[y.JSON.toString(),ke.UNKNOWN],[y.UUID.toString(),ke.BIT128]])),p(y,"ALL",[y.UNKNOWN,y.FLOAT64,y.FLOAT32,y.INT64,y.INT32,y.INT16,y.INT8,y.UINT64,y.UINT32,y.UINT16,y.UINT8,y.TIMESTAMP,y.UUID,y.STRING,y.JSON]),p(y,"BIG_INT_TYPES",[y.INT64,y.UINT64,y.TIMESTAMP]),p(y,"z",m.union([m.string().transform(r=>new y(r)),m.instanceof(y)]));let te=y;const be=class pe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return pe.bytes(this.valueOf()+e.valueOf())}sub(e){return pe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new pe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return pe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/pe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/pe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/pe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/pe.TERABYTE.valueOf()}toString(){const e=this.truncate(pe.TERABYTE),t=this.truncate(pe.GIGABYTE),s=this.truncate(pe.MEGABYTE),n=this.truncate(pe.KILOBYTE),a=this.truncate(pe.BYTE),i=e,o=t.sub(e),c=s.sub(t),l=n.sub(s),h=a.sub(n);let k="";return i.isZero||(k+=`${i.terabytes}TB `),o.isZero||(k+=`${o.gigabytes}GB `),c.isZero||(k+=`${c.megabytes}MB `),l.isZero||(k+=`${l.kilobytes}KB `),(!h.isZero||k==="")&&(k+=`${h.valueOf()}B`),k.trim()}static bytes(e=1){return new pe(e)}static kilobytes(e=1){return pe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return pe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return pe.megabytes(e.valueOf()*1e3)}static terabytes(e){return pe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};p(be,"BYTE",new be(1)),p(be,"KILOBYTE",be.kilobytes(1)),p(be,"MEGABYTE",be.megabytes(1)),p(be,"GIGABYTE",be.gigabytes(1)),p(be,"TERABYTE",be.terabytes(1)),p(be,"ZERO",new be(0)),p(be,"z",m.union([m.number().transform(r=>new be(r)),m.instanceof(be)]));let bs=be;m.union([m.instanceof(Uint8Array),m.instanceof(Uint16Array),m.instanceof(Uint32Array),m.instanceof(BigUint64Array),m.instanceof(Float32Array),m.instanceof(Float64Array),m.instanceof(Int8Array),m.instanceof(Int16Array),m.instanceof(Int32Array),m.instanceof(BigInt64Array)]);const Tu=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof G||r instanceof ce||r instanceof Date},Jm=(r,e,t,s=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(s):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(s):Ir(t,-s),Hm=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof Ee?!0:Tu(r),Ft=-1;class Ee{constructor(e){p(this,"key",""),p(this,"dataType"),p(this,"sampleOffset"),p(this,"gl"),p(this,"_data"),p(this,"_timeRange"),p(this,"alignment",0),p(this,"_cachedMin"),p(this,"_cachedMax"),p(this,"writePos",Ft),p(this,"_refCount",0),p(this,"_cachedLength"),Hm(e)&&(e={data:e});const{dataType:t,timeRange:s,sampleOffset:n=0,glBufferUsage:a="static",alignment:i=0,key:o=ef()}=e,{data:c}=e;if(c instanceof Ee){this.key=c.key,this.dataType=c.dataType,this.sampleOffset=c.sampleOffset,this.gl=c.gl,this._data=c._data,this._timeRange=c._timeRange,this.alignment=c.alignment,this._cachedMin=c._cachedMin,this._cachedMax=c._cachedMax,this.writePos=c.writePos,this._refCount=c._refCount,this._cachedLength=c._cachedLength;return}const l=Tu(c),h=Array.isArray(c);if(t!=null)this.dataType=new te(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(h||l){let k=c;if(!l){if(c.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");k=c[0]}if(typeof k=="string")this.dataType=te.STRING;else if(typeof k=="number")this.dataType=te.FLOAT64;else if(typeof k=="bigint")this.dataType=te.INT64;else if(typeof k=="boolean")this.dataType=te.BOOLEAN;else if(k instanceof G||k instanceof Date||k instanceof G)this.dataType=te.TIMESTAMP;else if(typeof k=="object")this.dataType=te.JSON;else throw new Error(`cannot infer data type of ${typeof k} when constructing a Series from a JS array`)}else this.dataType=new te(c)}if(!h&&!l)this._data=c;else{let k=l?[c]:c;const se=k[0];(se instanceof G||se instanceof Date||se instanceof ce)&&(k=k.map(ye=>new G(ye).valueOf())),this.dataType.equals(te.STRING)?(this._cachedLength=k.length,this._data=new TextEncoder().encode(k.join(`
2
2
  `)+`
3
- `)):this.dataType.equals(te.JSON)?(this._cachedLength=k.length,this._data=new TextEncoder().encode(k.map(ge=>JSON.stringify(ge)).join(`
3
+ `)):this.dataType.equals(te.JSON)?(this._cachedLength=k.length,this._data=new TextEncoder().encode(k.map(ye=>JSON.stringify(ye)).join(`
4
4
  `)+`
5
- `)):this._data=new this.dataType.Array(k).buffer}this.key=o,this.alignment=i,this.sampleOffset=n??0,this._timeRange=s,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...s}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const n=new new te(t).Array(e),a=new bt({data:n.buffer,dataType:t,...s});return a.writePos=0,a}static generateTimestamps(e,t,s){const n=s.spanRange(t.span(e)),a=new BigInt64Array(e);for(let i=0;i<e;i++)a[i]=BigInt(s.add(t.span(i)).valueOf());return new bt({data:a,dataType:te.TIMESTAMP,timeRange:n})}get refCount(){return this._refCount}static fromStrings(e,t){const s=new TextEncoder().encode(e.join(`
5
+ `)):this._data=new this.dataType.Array(k).buffer}this.key=o,this.alignment=i,this.sampleOffset=n??0,this._timeRange=s,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...s}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const n=new new te(t).Array(e),a=new Ee({data:n.buffer,dataType:t,...s});return a.writePos=0,a}static generateTimestamps(e,t,s){const n=s.spanRange(t.span(e)),a=new BigInt64Array(e);for(let i=0;i<e;i++)a[i]=BigInt(s.add(t.span(i)).valueOf());return new Ee({data:a,dataType:te.TIMESTAMP,timeRange:n})}get refCount(){return this._refCount}static fromStrings(e,t){const s=new TextEncoder().encode(e.join(`
6
6
  `)+`
7
- `);return new bt({data:s,dataType:te.STRING,timeRange:t})}static fromJSON(e,t){const s=new TextEncoder().encode(e.map(n=>JSON.stringify(n)).join(`
7
+ `);return new Ee({data:s,dataType:te.STRING,timeRange:t})}static fromJSON(e,t){const s=new TextEncoder().encode(e.map(n=>JSON.stringify(n)).join(`
8
8
  `)+`
9
- `);return new bt({data:s,dataType:te.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Yt)return 0;const t=this.capacity-this.writePos,s=t<e.length?e.slice(0,t):e;return this.underlyingData.set(s.data,this.writePos),this.maybeRecomputeMinMax(s),this._cachedLength=void 0,this.writePos+=s.length,s.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Yt?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(te.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
9
+ `);return new Ee({data:s,dataType:te.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===Ft)return 0;const t=this.capacity-this.writePos,s=t<e.length?e.slice(0,t):e;return this.underlyingData.set(s.data,this.writePos),this.maybeRecomputeMinMax(s),this._cachedLength=void 0,this.writePos+=s.length,s.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===Ft?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(te.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
10
10
  `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(te.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=te.UUID.density.valueOf(),t=Array(this.length);for(let s=0;s<this.length;s++){const n=this.buffer.slice(s*e,(s+1)*e),a=Array.from(new Uint8Array(n),i=>i.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[s]=a}return t}parseJSON(e){if(!this.dataType.equals(te.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
11
- `).slice(0,-1).map(t=>e.parse(JSON.parse(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new _n(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Yt?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Yt?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const s=new e.Array(this.length);for(let n=0;n<this.length;n++)s[n]=vh(this.dataType,e,this.data[n],t);return new bt({data:s.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(te.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}else{const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),jr(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(te.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}else{const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),jr(this._cachedMin,this.sampleOffset))}get bounds(){return zr(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return jr(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const s=this.data[e];if(s==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return jr(s,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let s=0,n=0;for(let i=0;i<this.data.length;i++)if(this.data[i]===10){if(e===0){n=i;break}s=i+1,e--}if(n===0&&(n=this.data.length),s>=n||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(s,n);return this.dataType.equals(te.STRING)?new TextDecoder().decode(a):JSON.parse(new TextDecoder().decode(a))}binarySearch(e){let t=0,s=this.length-1;const n=xl(e);for(;t<=s;){const a=Math.floor((t+s)/2),i=n(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:s=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(te.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:s,prevBuffer:n}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==n)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Yt){n===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(n).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,s==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Yt}as(e){if(e==="string"){if(!this.dataType.equals(te.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(te.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return zr(this.alignment,this.alignment+this.length)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new _h(this);return this.dataType.equals(te.JSON)?new bh(e):e}return new kh(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const s=this.data.slice(e,t);return new bt({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new bt({data:this.buffer,dataType:this.dataType,timeRange:ze.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}},_h=class{constructor(e){if(p(this,"series"),p(this,"index"),p(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const s=this.index;return e===s?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,s))})}[Symbol.iterator](){return this}};var gc;let bh=class{constructor(e){p(this,"wrapped"),p(this,gc,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:JSON.parse(e.value)}}[Symbol.iterator](){return this}};gc=Symbol.toStringTag;var vc;let kh=class{constructor(e){p(this,"series"),p(this,"index"),p(this,vc,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}};vc=Symbol.toStringTag;const jr=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);class wc{constructor(e){if(p(this,"series"),e.length!==0){const t=e[0].dataType;for(let s=1;s<e.length;s++)if(!e[s].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new te(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?te.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?ze.ZERO:new ze(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const s of this.series){if(e<s.length)return s.at(e,t);e-=s.length}if(t)throw new Error(`[series] - no value at index ${e}`)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new Th(this.series)}}var _c;let Th=class{constructor(e){p(this,"series"),p(this,"seriesIndex"),p(this,"internal"),p(this,_c,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}};_c=Symbol.toStringTag;const vi=f.record(f.union([f.number(),f.string(),f.symbol()]),f.unknown()),bc=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Oh=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";Oh();const xh=["MacOS","Windows","Linux","Docker"];f.enum(xh);const Nh=(r,e)=>{let t=null;return e===0?r:(...s)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...s),e)}},ao=r=>[...new Set(r)],Sh=(...r)=>r.map(kc).join(""),kc=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Eh=r=>r.endsWith("/")?r.slice(0,-1):r;var dr;let Zh=(dr=class{constructor({host:r,port:e,protocol:t="",pathPrefix:s=""}){p(this,"protocol"),p(this,"host"),p(this,"port"),p(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=kc(s)}replace(r){return new dr({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new dr({...this,pathPrefix:Sh(this.path,r)})}toString(){return Eh(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},p(dr,"UNKNOWN",new dr({host:"unknown",port:0})),dr);const re=r=>Array.isArray(r)?r:[r];let Tc=class{constructor(){p(this,"contentType","application/json"),p(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(wn.toSnake(e),(s,n)=>ArrayBuffer.isView(n)?Array.from(n):bc(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n);return new TextEncoder().encode(t)}decode(e,t){const s=wn.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(s):s}static registerCustomType(){}};const Ih=[new Tc],Oc=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Ih,JSONEncoderDecoder:Tc},Symbol.toStringTag,{value:"Module"}));let Ah=class{constructor(e){p(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,s)=>s(e))}};const bn=Object.freeze(Object.defineProperty({__proto__:null,Observer:Ah},Symbol.toStringTag,{value:"Module"})),Ns=u.z.number(),Ss=u.z.object({name:u.z.string(),key:u.z.number(),rate:Xn.z,dataType:te.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),xc=Ss.extend({key:u.z.number().optional(),leaseholder:u.z.number().optional(),index:u.z.number().optional(),rate:Xn.z.optional(),isIndex:u.z.boolean().optional()}),Nc=r=>r.map(e=>({name:e.name,dataType:e.dataType,rate:e.rate??0,leaseholder:e.leaseholder,index:e.index,isIndex:e.isIndex})),Ch=u.z.object({channels:xc.array()}),$h=u.z.object({channels:Ss.array()}),Kn=class Kn{constructor(e){d(this,"client");this.client=e}async create(e){const t={channels:Nc(e)},[s,n]=await this.client.send(Kn.ENDPOINT,t,Ch,$h);if(n!=null)throw n;return s.channels}};d(Kn,"ENDPOINT","/channel/create");let kn=Kn;const jh=new Error("request for lock canceled");var Rh=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(s.next(h))}catch(k){i(k)}}function c(h){try{l(s.throw(h))}catch(k){i(k)}}function l(h){h.done?a(h.value):n(h.value).then(o,c)}l((s=s.apply(r,e||[])).next())})};class zh{constructor(e,t=jh){this._value=e,this._cancelError=t,this._weightedQueues=[],this._weightedWaiters=[]}acquire(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,s)=>{this._weightedQueues[e-1]||(this._weightedQueues[e-1]=[]),this._weightedQueues[e-1].push({resolve:t,reject:s}),this._dispatch()})}runExclusive(e,t=1){return Rh(this,void 0,void 0,function*(){const[s,n]=yield this.acquire(t);try{return yield e(s)}finally{n()}})}waitForUnlock(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),this._weightedWaiters[e-1].push(t),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatch()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatch()}cancel(){this._weightedQueues.forEach(e=>e.forEach(t=>t.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var e;for(let t=this._value;t>0;t--){const s=(e=this._weightedQueues[t-1])===null||e===void 0?void 0:e.shift();if(!s)continue;const n=this._value,a=t;this._value-=t,t=this._value+1,s.resolve([n,this._newReleaser(a)])}this._drainUnlockWaiters()}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){for(let e=this._value;e>0;e--)this._weightedWaiters[e-1]&&(this._weightedWaiters[e-1].forEach(t=>t()),this._weightedWaiters[e-1]=[])}}var Ph=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(s.next(h))}catch(k){i(k)}}function c(h){try{l(s.throw(h))}catch(k){i(k)}}function l(h){h.done?a(h.value):n(h.value).then(o,c)}l((s=s.apply(r,e||[])).next())})};class Mh{constructor(e){this._semaphore=new zh(1,e)}acquire(){return Ph(this,void 0,void 0,function*(){const[,e]=yield this._semaphore.acquire();return e})}runExclusive(e){return this._semaphore.runExclusive(()=>e())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var Dh=Object.defineProperty,Lh=(r,e,t)=>e in r?Dh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,me=(r,e,t)=>(Lh(r,typeof e!="symbol"?e+"":e,t),t),Uh=Object.defineProperty,Bh=(r,e,t)=>e in r?Uh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,b=(r,e,t)=>(Bh(r,typeof e!="symbol"?e+"":e,t),t),H;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(H||(H={}));var qa;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(qa||(qa={}));const O=H.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Rt=r=>{switch(typeof r){case"undefined":return O.undefined;case"string":return O.string;case"number":return isNaN(r)?O.nan:O.number;case"boolean":return O.boolean;case"function":return O.function;case"bigint":return O.bigint;case"symbol":return O.symbol;case"object":return Array.isArray(r)?O.array:r===null?O.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?O.promise:typeof Map<"u"&&r instanceof Map?O.map:typeof Set<"u"&&r instanceof Set?O.set:typeof Date<"u"&&r instanceof Date?O.date:O.object;default:return O.unknown}},w=H.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),qh=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Be extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,H.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Be.create=r=>new Be(r);const Xr=(r,e)=>{let t;switch(r.code){case w.invalid_type:r.received===O.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case w.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,H.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:t=`Unrecognized key(s) in object: ${H.joinValues(r.keys,", ")}`;break;case w.invalid_union:t="Invalid input";break;case w.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${H.joinValues(r.options)}`;break;case w.invalid_enum_value:t=`Invalid enum value. Expected ${H.joinValues(r.options)}, received '${r.received}'`;break;case w.invalid_arguments:t="Invalid function arguments";break;case w.invalid_return_type:t="Invalid function return type";break;case w.invalid_date:t="Invalid date";break;case w.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:H.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case w.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case w.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case w.custom:t="Invalid input";break;case w.invalid_intersection_types:t="Intersection results could not be merged";break;case w.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case w.not_finite:t="Number must be finite";break;default:t=e.defaultError,H.assertNever(r)}return{message:t}};let Sc=Xr;function Vh(r){Sc=r}function Tn(){return Sc}const On=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Kh=[];function S(r,e){const t=On({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Tn(),Xr].filter(s=>!!s)});r.common.issues.push(t)}class xe{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return D;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return xe.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return D;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const D=Object.freeze({status:"aborted"}),Ec=r=>({status:"dirty",value:r}),$e=r=>({status:"valid",value:r}),Va=r=>r.status==="aborted",Ka=r=>r.status==="dirty",Qr=r=>r.status==="valid",xn=r=>typeof Promise<"u"&&r instanceof Promise;var I;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(I||(I={}));class nt{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const io=(r,e)=>{if(Qr(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Be(r.common.issues);return this._error=t,this._error}}};function B(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}class K{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Rt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Rt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new xe,ctx:{common:e.parent.common,data:e.data,parsedType:Rt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(xn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Rt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return io(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Rt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(xn(n)?n:Promise.resolve(n));return io(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:w.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Ye({schema:this,typeName:j.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Nt.create(this,this._def)}nullable(){return sr.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return qe.create(this,this._def)}promise(){return Sr.create(this,this._def)}or(e){return ss.create([this,e],this._def)}and(e){return ns.create(this,e,this._def)}transform(e){return new Ye({...B(this._def),schema:this,typeName:j.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new us({...B(this._def),innerType:this,defaultValue:t,typeName:j.ZodDefault})}brand(){return new Ic({typeName:j.ZodBranded,type:this,...B(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Zn({...B(this._def),innerType:this,catchValue:t,typeName:j.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Es.create(this,e)}readonly(){return An.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Wh=/^c[^\s-]{8,}$/i,Fh=/^[a-z][a-z0-9]*$/,Yh=/^[0-9A-HJKMNP-TV-Z]{26}$/,Jh=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Gh=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Hh="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ya;const Xh=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Qh=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ep=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function tp(r,e){return!!((e==="v4"||!e)&&Xh.test(r)||(e==="v6"||!e)&&Qh.test(r))}class De extends K{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==O.string){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.string,received:n.parsedType}),D}const t=new xe;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?S(s,{code:w.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&S(s,{code:w.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")Gh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"email",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ya||(ya=new RegExp(Hh,"u")),ya.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"emoji",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Jh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"uuid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Wh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"cuid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Fh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"cuid2",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Yh.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"ulid",code:w.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),S(s,{validation:"url",code:w.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"regex",code:w.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?ep(n).test(e.data)||(s=this._getOrReturnCtx(e,s),S(s,{code:w.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?tp(e.data,n.version)||(s=this._getOrReturnCtx(e,s),S(s,{validation:"ip",code:w.invalid_string,message:n.message}),t.dirty()):H.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:w.invalid_string,...I.errToObj(s)})}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...I.errToObj(e)})}url(e){return this._addCheck({kind:"url",...I.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...I.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...I.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...I.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...I.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...I.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...I.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...I.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...I.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...I.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...I.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...I.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...I.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...I.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...I.errToObj(t)})}nonempty(e){return this.min(1,I.errToObj(e))}trim(){return new De({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new De({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new De({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}De.create=r=>{var e;return new De({checks:[],typeName:j.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};function rp(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class Dt extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==O.number){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.number,received:n.parsedType}),D}let t;const s=new xe;for(const n of this._def.checks)n.kind==="int"?H.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?rp(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_finite,message:n.message}),s.dirty()):H.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,s,n){return new Dt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:I.toString(n)}]})}_addCheck(e){return new Dt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:I.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:I.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:I.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:I.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&H.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Dt.create=r=>new Dt({checks:[],typeName:j.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});class Lt extends K{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==O.bigint){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.bigint,received:n.parsedType}),D}let t;const s=new xe;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),S(t,{code:w.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):H.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,I.toString(t))}gt(e,t){return this.setLimit("min",e,!1,I.toString(t))}lte(e,t){return this.setLimit("max",e,!0,I.toString(t))}lt(e,t){return this.setLimit("max",e,!1,I.toString(t))}setLimit(e,t,s,n){return new Lt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:I.toString(n)}]})}_addCheck(e){return new Lt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:I.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:I.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:I.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:I.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:I.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Lt.create=r=>{var e;return new Lt({checks:[],typeName:j.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...B(r)})};class es extends K{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==O.boolean){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.boolean,received:t.parsedType}),D}return $e(e.data)}}es.create=r=>new es({typeName:j.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...B(r)});class tr extends K{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==O.date){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_type,expected:O.date,received:n.parsedType}),D}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return S(n,{code:w.invalid_date}),D}const t=new xe;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),S(s,{code:w.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):H.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new tr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:I.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:I.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}tr.create=r=>new tr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:j.ZodDate,...B(r)});class Nn extends K{_parse(e){if(this._getType(e)!==O.symbol){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.symbol,received:t.parsedType}),D}return $e(e.data)}}Nn.create=r=>new Nn({typeName:j.ZodSymbol,...B(r)});class ts extends K{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.undefined,received:t.parsedType}),D}return $e(e.data)}}ts.create=r=>new ts({typeName:j.ZodUndefined,...B(r)});class rs extends K{_parse(e){if(this._getType(e)!==O.null){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.null,received:t.parsedType}),D}return $e(e.data)}}rs.create=r=>new rs({typeName:j.ZodNull,...B(r)});class Nr extends K{constructor(){super(...arguments),this._any=!0}_parse(e){return $e(e.data)}}Nr.create=r=>new Nr({typeName:j.ZodAny,...B(r)});class Gt extends K{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $e(e.data)}}Gt.create=r=>new Gt({typeName:j.ZodUnknown,...B(r)});class Zt extends K{_parse(e){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.never,received:t.parsedType}),D}}Zt.create=r=>new Zt({typeName:j.ZodNever,...B(r)});class Sn extends K{_parse(e){if(this._getType(e)!==O.undefined){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.void,received:t.parsedType}),D}return $e(e.data)}}Sn.create=r=>new Sn({typeName:j.ZodVoid,...B(r)});class qe extends K{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==O.array)return S(t,{code:w.invalid_type,expected:O.array,received:t.parsedType}),D;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(S(t,{code:i?w.too_big:w.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(S(t,{code:w.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(S(t,{code:w.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new nt(t,i,t.path,o)))).then(i=>xe.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new nt(t,i,t.path,o)));return xe.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new qe({...this._def,minLength:{value:e,message:I.toString(t)}})}max(e,t){return new qe({...this._def,maxLength:{value:e,message:I.toString(t)}})}length(e,t){return new qe({...this._def,exactLength:{value:e,message:I.toString(t)}})}nonempty(e){return this.min(1,e)}}qe.create=(r,e)=>new qe({type:r,minLength:null,maxLength:null,exactLength:null,typeName:j.ZodArray,...B(e)});function fr(r){if(r instanceof le){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=Nt.create(fr(s))}return new le({...r._def,shape:()=>e})}else return r instanceof qe?new qe({...r._def,type:fr(r.element)}):r instanceof Nt?Nt.create(fr(r.unwrap())):r instanceof sr?sr.create(fr(r.unwrap())):r instanceof at?at.create(r.items.map(e=>fr(e))):r}class le extends K{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=H.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==O.object){const c=this._getOrReturnCtx(e);return S(c,{code:w.invalid_type,expected:O.object,received:c.parsedType}),D}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Zt&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=n[c],h=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new nt(s,h,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof Zt){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")i.length>0&&(S(s,{code:w.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new nt(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>xe.mergeObjectSync(t,c)):xe.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return I.errToObj,new le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=I.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new le({...this._def,unknownKeys:"strip"})}passthrough(){return new le({...this._def,unknownKeys:"passthrough"})}extend(e){return new le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:j.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new le({...this._def,catchall:e})}pick(e){const t={};return H.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new le({...this._def,shape:()=>t})}omit(e){const t={};return H.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new le({...this._def,shape:()=>t})}deepPartial(){return fr(this)}partial(e){const t={};return H.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new le({...this._def,shape:()=>t})}required(e){const t={};return H.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof Nt;)n=n._def.innerType;t[s]=n}}),new le({...this._def,shape:()=>t})}keyof(){return Zc(H.objectKeys(this.shape))}}le.create=(r,e)=>new le({shape:()=>r,unknownKeys:"strip",catchall:Zt.create(),typeName:j.ZodObject,...B(e)});le.strictCreate=(r,e)=>new le({shape:()=>r,unknownKeys:"strict",catchall:Zt.create(),typeName:j.ZodObject,...B(e)});le.lazycreate=(r,e)=>new le({shape:r,unknownKeys:"strip",catchall:Zt.create(),typeName:j.ZodObject,...B(e)});class ss extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Be(o.ctx.common.issues));return S(t,{code:w.invalid_union,unionErrors:i}),D}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Be(c));return S(t,{code:w.invalid_union,unionErrors:o}),D}}get options(){return this._def.options}}ss.create=(r,e)=>new ss({options:r,typeName:j.ZodUnion,...B(e)});const Gs=r=>r instanceof is?Gs(r.schema):r instanceof Ye?Gs(r.innerType()):r instanceof os?[r.value]:r instanceof Ut?r.options:r instanceof cs?Object.keys(r.enum):r instanceof us?Gs(r._def.innerType):r instanceof ts?[void 0]:r instanceof rs?[null]:null;class Qn extends K{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.object)return S(t,{code:w.invalid_type,expected:O.object,received:t.parsedType}),D;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(S(t,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),D)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=Gs(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new Qn({typeName:j.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...B(s)})}}function Wa(r,e){const t=Rt(r),s=Rt(e);if(r===e)return{valid:!0,data:r};if(t===O.object&&s===O.object){const n=H.objectKeys(e),a=H.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Wa(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===O.array&&s===O.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Wa(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===O.date&&s===O.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ns extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Va(a)||Va(i))return D;const o=Wa(a.value,i.value);return o.valid?((Ka(a)||Ka(i))&&t.dirty(),{status:t.value,value:o.data}):(S(s,{code:w.invalid_intersection_types}),D)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ns.create=(r,e,t)=>new ns({left:r,right:e,typeName:j.ZodIntersection,...B(t)});class at extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.array)return S(s,{code:w.invalid_type,expected:O.array,received:s.parsedType}),D;if(s.data.length<this._def.items.length)return S(s,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),D;!this._def.rest&&s.data.length>this._def.items.length&&(S(s,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new nt(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>xe.mergeArray(t,a)):xe.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new at({...this._def,rest:e})}}at.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new at({items:r,typeName:j.ZodTuple,rest:null,...B(e)})};class as extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.object)return S(s,{code:w.invalid_type,expected:O.object,received:s.parsedType}),D;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new nt(s,o,s.path,o)),value:i._parse(new nt(s,s.data[o],s.path,o))});return s.common.async?xe.mergeObjectAsync(t,n):xe.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof K?new as({keyType:e,valueType:t,typeName:j.ZodRecord,...B(s)}):new as({keyType:De.create(),valueType:e,typeName:j.ZodRecord,...B(t)})}}class En extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.map)return S(s,{code:w.invalid_type,expected:O.map,received:s.parsedType}),D;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new nt(s,o,s.path,[l,"key"])),value:a._parse(new nt(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return D;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}En.create=(r,e,t)=>new En({valueType:e,keyType:r,typeName:j.ZodMap,...B(t)});class rr extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==O.set)return S(s,{code:w.invalid_type,expected:O.set,received:s.parsedType}),D;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(S(s,{code:w.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(S(s,{code:w.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return D;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new nt(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new rr({...this._def,minSize:{value:e,message:I.toString(t)}})}max(e,t){return new rr({...this._def,maxSize:{value:e,message:I.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}rr.create=(r,e)=>new rr({valueType:r,minSize:null,maxSize:null,typeName:j.ZodSet,...B(e)});class wr extends K{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.function)return S(t,{code:w.invalid_type,expected:O.function,received:t.parsedType}),D;function s(o,c){return On({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Tn(),Xr].filter(l=>!!l),issueData:{code:w.invalid_arguments,argumentsError:c}})}function n(o,c){return On({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Tn(),Xr].filter(l=>!!l),issueData:{code:w.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Sr){const o=this;return $e(async function(...c){const l=new Be([]),h=await o._def.args.parseAsync(c,a).catch(oe=>{throw l.addIssue(s(c,oe)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(oe=>{throw l.addIssue(n(k,oe)),l})})}else{const o=this;return $e(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Be([s(c,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new Be([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new wr({...this._def,args:at.create(e).rest(Gt.create())})}returns(e){return new wr({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new wr({args:e||at.create([]).rest(Gt.create()),returns:t||Gt.create(),typeName:j.ZodFunction,...B(s)})}}class is extends K{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}is.create=(r,e)=>new is({getter:r,typeName:j.ZodLazy,...B(e)});class os extends K{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return S(t,{received:t.data,code:w.invalid_literal,expected:this._def.value}),D}return{status:"valid",value:e.data}}get value(){return this._def.value}}os.create=(r,e)=>new os({value:r,typeName:j.ZodLiteral,...B(e)});function Zc(r,e){return new Ut({values:r,typeName:j.ZodEnum,...B(e)})}class Ut extends K{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return S(t,{expected:H.joinValues(s),received:t.parsedType,code:w.invalid_type}),D}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return S(t,{received:t.data,code:w.invalid_enum_value,options:s}),D}return $e(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Ut.create(e)}exclude(e){return Ut.create(this.options.filter(t=>!e.includes(t)))}}Ut.create=Zc;class cs extends K{_parse(e){const t=H.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==O.string&&s.parsedType!==O.number){const n=H.objectValues(t);return S(s,{expected:H.joinValues(n),received:s.parsedType,code:w.invalid_type}),D}if(t.indexOf(e.data)===-1){const n=H.objectValues(t);return S(s,{received:s.data,code:w.invalid_enum_value,options:n}),D}return $e(e.data)}get enum(){return this._def.values}}cs.create=(r,e)=>new cs({values:r,typeName:j.ZodNativeEnum,...B(e)});class Sr extends K{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==O.promise&&t.common.async===!1)return S(t,{code:w.invalid_type,expected:O.promise,received:t.parsedType}),D;const s=t.parsedType===O.promise?t.data:Promise.resolve(t.data);return $e(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Sr.create=(r,e)=>new Sr({type:r,typeName:j.ZodPromise,...B(e)});class Ye extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===j.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{S(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?D:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!Qr(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>Qr(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);H.assertNever(n)}}Ye.create=(r,e,t)=>new Ye({schema:r,typeName:j.ZodEffects,effect:e,...B(t)});Ye.createWithPreprocess=(r,e,t)=>new Ye({schema:e,effect:{type:"preprocess",transform:r},typeName:j.ZodEffects,...B(t)});class Nt extends K{_parse(e){return this._getType(e)===O.undefined?$e(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Nt.create=(r,e)=>new Nt({innerType:r,typeName:j.ZodOptional,...B(e)});class sr extends K{_parse(e){return this._getType(e)===O.null?$e(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}sr.create=(r,e)=>new sr({innerType:r,typeName:j.ZodNullable,...B(e)});class us extends K{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===O.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}us.create=(r,e)=>new us({innerType:r,typeName:j.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...B(e)});class Zn extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return xn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Be(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Be(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Zn.create=(r,e)=>new Zn({innerType:r,typeName:j.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...B(e)});class In extends K{_parse(e){if(this._getType(e)!==O.nan){const t=this._getOrReturnCtx(e);return S(t,{code:w.invalid_type,expected:O.nan,received:t.parsedType}),D}return{status:"valid",value:e.data}}}In.create=r=>new In({typeName:j.ZodNaN,...B(r)});const sp=Symbol("zod_brand");class Ic extends K{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Es extends K{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?D:n.status==="dirty"?(t.dirty(),Ec(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?D:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Es({in:e,out:t,typeName:j.ZodPipeline})}}class An extends K{_parse(e){const t=this._def.innerType._parse(e);return Qr(t)&&(t.value=Object.freeze(t.value)),t}}An.create=(r,e)=>new An({innerType:r,typeName:j.ZodReadonly,...B(e)});const Ac=(r,e={},t)=>r?Nr.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):Nr.create(),np={object:le.lazycreate};var j;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(j||(j={}));const ap=(r,e={message:`Input not instance of ${r.name}`})=>Ac(t=>t instanceof r,e),Cc=De.create,$c=Dt.create,ip=In.create,op=Lt.create,jc=es.create,cp=tr.create,up=Nn.create,lp=ts.create,dp=rs.create,hp=Nr.create,pp=Gt.create,fp=Zt.create,mp=Sn.create,yp=qe.create,gp=le.create,vp=le.strictCreate,wp=ss.create,_p=Qn.create,bp=ns.create,kp=at.create,Tp=as.create,Op=En.create,xp=rr.create,Np=wr.create,Sp=is.create,Ep=os.create,Zp=Ut.create,Ip=cs.create,Ap=Sr.create,oo=Ye.create,Cp=Nt.create,$p=sr.create,jp=Ye.createWithPreprocess,Rp=Es.create,zp=()=>Cc().optional(),Pp=()=>$c().optional(),Mp=()=>jc().optional(),Dp={string:r=>De.create({...r,coerce:!0}),number:r=>Dt.create({...r,coerce:!0}),boolean:r=>es.create({...r,coerce:!0}),bigint:r=>Lt.create({...r,coerce:!0}),date:r=>tr.create({...r,coerce:!0})},Lp=D;var m=Object.freeze({__proto__:null,defaultErrorMap:Xr,setErrorMap:Vh,getErrorMap:Tn,makeIssue:On,EMPTY_PATH:Kh,addIssueToContext:S,ParseStatus:xe,INVALID:D,DIRTY:Ec,OK:$e,isAborted:Va,isDirty:Ka,isValid:Qr,isAsync:xn,get util(){return H},get objectUtil(){return qa},ZodParsedType:O,getParsedType:Rt,ZodType:K,ZodString:De,ZodNumber:Dt,ZodBigInt:Lt,ZodBoolean:es,ZodDate:tr,ZodSymbol:Nn,ZodUndefined:ts,ZodNull:rs,ZodAny:Nr,ZodUnknown:Gt,ZodNever:Zt,ZodVoid:Sn,ZodArray:qe,ZodObject:le,ZodUnion:ss,ZodDiscriminatedUnion:Qn,ZodIntersection:ns,ZodTuple:at,ZodRecord:as,ZodMap:En,ZodSet:rr,ZodFunction:wr,ZodLazy:is,ZodLiteral:os,ZodEnum:Ut,ZodNativeEnum:cs,ZodPromise:Sr,ZodEffects:Ye,ZodTransformer:Ye,ZodOptional:Nt,ZodNullable:sr,ZodDefault:us,ZodCatch:Zn,ZodNaN:In,BRAND:sp,ZodBranded:Ic,ZodPipeline:Es,ZodReadonly:An,custom:Ac,Schema:K,ZodSchema:K,late:np,get ZodFirstPartyTypeKind(){return j},coerce:Dp,any:hp,array:yp,bigint:op,boolean:jc,date:cp,discriminatedUnion:_p,effect:oo,enum:Zp,function:Np,instanceof:ap,intersection:bp,lazy:Sp,literal:Ep,map:Op,nan:ip,nativeEnum:Ip,never:fp,null:dp,nullable:$p,number:$c,object:gp,oboolean:Mp,onumber:Pp,optional:Cp,ostring:zp,pipeline:Rp,preprocess:jp,promise:Ap,record:Tp,set:xp,strictObject:vp,string:Cc,symbol:up,transformer:oo,tuple:kp,undefined:lp,union:wp,unknown:pp,void:mp,NEVER:Lp,ZodIssueCode:w,quotelessJson:qh,ZodError:Be});const wi=m.tuple([m.number(),m.number()]),Rc=m.object({width:m.number(),height:m.number()}),Up=m.object({signedWidth:m.number(),signedHeight:m.number()}),Bp=["width","height"];m.enum(Bp);const qp=["start","center","end"],Vp=["signedWidth","signedHeight"];m.enum(Vp);const Cn=m.object({x:m.number(),y:m.number()}),Kp=m.object({clientX:m.number(),clientY:m.number()}),Wp=["x","y"],zc=m.enum(Wp),Pc=["top","right","bottom","left"];m.enum(Pc);const Fp=["left","right"],Mc=m.enum(Fp),Yp=["top","bottom"],Dc=m.enum(Yp),Lc=["center"],co=m.enum(Lc),Jp=[...Pc,...Lc],Uc=m.enum(Jp);m.enum(qp);const Gp=["first","last"];m.enum(Gp);const Hp=m.object({lower:m.number(),upper:m.number()});m.union([Hp,wi]);m.union([zc,Uc]);m.union([zc,Uc,m.instanceof(String)]);const ga=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),Xp(t)},Xp=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Me=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Y={},ea={};Object.defineProperty(ea,"__esModule",{value:!0});function Qp(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,s){return s.toUpperCase()}):""}ea.default=Qp;var ta={};Object.defineProperty(ta,"__esModule",{value:!0});function ef(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}ta.default=ef;var ra={};Object.defineProperty(ra,"__esModule",{value:!0});function tf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"$"+s}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,s){return s.toUpperCase()}):""}ra.default=tf;var _i={};Object.defineProperty(_i,"__esModule",{value:!0});function rf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}_i.default=rf;var bi={};Object.defineProperty(bi,"__esModule",{value:!0});function sf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}bi.default=sf;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});function nf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}ki.default=nf;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});function af(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,s,n){return s+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Ti.default=af;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});function of(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,s,n){return t+s.charAt(0).toUpperCase()+s.slice(1)+n}):""}Oi.default=of;var sa={};Object.defineProperty(sa,"__esModule",{value:!0});function cf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,s){return t+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}sa.default=cf;var xi={},lr={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(s){return e instanceof s})}})(lr);var uf=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(xi,"__esModule",{value:!0});var ft=lr;function Hs(r,e){if(e===void 0&&(e=ft.DefaultOption),!ft.isValidObject(r))return null;e=ft.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toLowerCase();e.recursive&&(ft.isValidObject(n)?ft.belongToTypes(n,e.keepTypesOnRecursion)||(n=Hs(n,e)):e.recursiveInArray&&ft.isArrayObject(n)&&(n=uf(n).map(function(i){var o=i;if(ft.isValidObject(i))ft.belongToTypes(o,e.keepTypesOnRecursion)||(o=Hs(i,e));else if(ft.isArrayObject(i)){var c=Hs({key:i},e);o=c.key}return o}))),t[a]=n}),t}xi.default=Hs;var Ni={},lf=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ni,"__esModule",{value:!0});var mt=lr;function Xs(r,e){if(e===void 0&&(e=mt.DefaultOption),!mt.isValidObject(r))return null;e=mt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=s.toUpperCase();e.recursive&&(mt.isValidObject(n)?mt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Xs(n,e)):e.recursiveInArray&&mt.isArrayObject(n)&&(n=lf(n).map(function(i){var o=i;if(mt.isValidObject(i))mt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Xs(i,e));else if(mt.isArrayObject(i)){var c=Xs({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ni.default=Xs;var Si={},df=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Si,"__esModule",{value:!0});var yt=lr,hf=ea;function Qs(r,e){if(e===void 0&&(e=yt.DefaultOption),!yt.isValidObject(r))return null;e=yt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=hf.default(s);e.recursive&&(yt.isValidObject(n)?yt.belongToTypes(n,e.keepTypesOnRecursion)||(n=Qs(n,e)):e.recursiveInArray&&yt.isArrayObject(n)&&(n=df(n).map(function(i){var o=i;if(yt.isValidObject(i))yt.belongToTypes(o,e.keepTypesOnRecursion)||(o=Qs(i,e));else if(yt.isArrayObject(i)){var c=Qs({key:i},e);o=c.key}return o}))),t[a]=n}),t}Si.default=Qs;var Ei={},pf=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ei,"__esModule",{value:!0});var gt=lr,ff=ta;function en(r,e){if(e===void 0&&(e=gt.DefaultOption),!gt.isValidObject(r))return null;e=gt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=ff.default(s);e.recursive&&(gt.isValidObject(n)?gt.belongToTypes(n,e.keepTypesOnRecursion)||(n=en(n,e)):e.recursiveInArray&&gt.isArrayObject(n)&&(n=pf(n).map(function(i){var o=i;if(gt.isValidObject(i))gt.belongToTypes(o,e.keepTypesOnRecursion)||(o=en(i,e));else if(gt.isArrayObject(i)){var c=en({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ei.default=en;var Zi={},mf=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Zi,"__esModule",{value:!0});var vt=lr,yf=ra;function tn(r,e){if(e===void 0&&(e=vt.DefaultOption),!vt.isValidObject(r))return null;e=vt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=yf.default(s);e.recursive&&(vt.isValidObject(n)?vt.belongToTypes(n,e.keepTypesOnRecursion)||(n=tn(n,e)):e.recursiveInArray&&vt.isArrayObject(n)&&(n=mf(n).map(function(i){var o=i;if(vt.isValidObject(i))vt.belongToTypes(o,e.keepTypesOnRecursion)||(o=tn(i,e));else if(vt.isArrayObject(i)){var c=tn({key:i},e);o=c.key}return o}))),t[a]=n}),t}Zi.default=tn;var Ii={},gf=Me&&Me.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var s=Array(r),n=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,n++)s[n]=a[i];return s};Object.defineProperty(Ii,"__esModule",{value:!0});var wt=lr,vf=sa;function rn(r,e){if(e===void 0&&(e=wt.DefaultOption),!wt.isValidObject(r))return null;e=wt.validateOptions(e);var t={};return Object.keys(r).forEach(function(s){var n=r[s],a=vf.default(s);e.recursive&&(wt.isValidObject(n)?wt.belongToTypes(n,e.keepTypesOnRecursion)||(n=rn(n,e)):e.recursiveInArray&&wt.isArrayObject(n)&&(n=gf(n).map(function(i){var o=i;if(wt.isValidObject(i))wt.belongToTypes(o,e.keepTypesOnRecursion)||(o=rn(i,e));else if(wt.isArrayObject(i)){var c=rn({key:i},e);o=c.key}return o}))),t[a]=n}),t}Ii.default=rn;Object.defineProperty(Y,"__esModule",{value:!0});Y.kebabKeys=Y.pascalKeys=Y.snakeKeys=Y.camelKeys=Y.upperKeys=Y.lowerKeys=Y.toLowerCase=Y.toUpperCase=Y.toKebabCase=Y.toHeaderCase=Y.toSentenceCase=Y.toTextCase=Y.toPathCase=Y.toDotCase=Y.toPascalCase=Y.toSnakeCase=Y.toCamelCase=void 0;var Bc=ea;Y.toCamelCase=Bc.default;var qc=ta;Y.toSnakeCase=qc.default;var Vc=ra;Y.toPascalCase=Vc.default;var Kc=_i;Y.toDotCase=Kc.default;var Wc=bi;Y.toPathCase=Wc.default;var Fc=ki;Y.toTextCase=Fc.default;var Yc=Ti;Y.toSentenceCase=Yc.default;var Jc=Oi;Y.toHeaderCase=Jc.default;var Gc=sa;Y.toKebabCase=Gc.default;var Hc=xi;Y.lowerKeys=Hc.default;var Xc=Ni;Y.upperKeys=Xc.default;var Qc=Si;Y.camelKeys=Qc.default;var eu=Ei;Y.snakeKeys=eu.default;var tu=Zi;Y.pascalKeys=tu.default;var ru=Ii;Y.kebabKeys=ru.default;var su=function(r){return String(r||"").toLowerCase()};Y.toLowerCase=su;var nu=function(r){return String(r||"").toUpperCase()};Y.toUpperCase=nu;var wf={toCamelCase:Bc.default,toSnakeCase:qc.default,toPascalCase:Vc.default,toDotCase:Kc.default,toPathCase:Wc.default,toTextCase:Fc.default,toSentenceCase:Yc.default,toHeaderCase:Jc.default,toKebabCase:Gc.default,toUpperCase:nu,toLowerCase:su,lowerKeys:Hc.default,upperKeys:Xc.default,camelKeys:Qc.default,snakeKeys:eu.default,pascalKeys:tu.default,kebabKeys:ru.default};Y.default=wf;var au=Y;const iu={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},_f=r=>au.snakeKeys(r,iu),bf=r=>au.camelKeys(r,iu);var $n;(r=>{r.toSnake=_f,r.toCamel=bf,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})($n||($n={}));m.object({x:Mc.or(co),y:Dc.or(co)});const kf=m.object({x:Mc,y:Dc}),Tf=Object.freeze({x:"left",y:"top"}),Of=(r,e)=>r.x===e.x&&r.y===e.y,uo=m.union([m.number(),Cn,wi,Rc,Up,Kp]),xf=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},lo={x:0,y:0},Ps=m.union([m.number(),m.string()]);m.object({top:Ps,left:Ps,width:Ps,height:Ps});m.object({left:m.number(),top:m.number(),right:m.number(),bottom:m.number()});m.object({one:Cn,two:Cn,root:kf});const Ai=(r,e,t=0,s=0,n)=>{const a={one:{...lo},two:{...lo},root:n??Tf};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+s},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:n??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+s}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},va=r=>{const e=Ai(r);return{lower:e.one.x,upper:e.two.x}},wa=r=>{const e=Ai(r);return{lower:e.one.y,upper:e.two.y}},Nf=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Sf=m.object({signedWidth:m.number(),signedHeight:m.number()});m.union([Rc,Sf,Cn,wi]);const Ef=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);m.object({offset:uo,scale:uo});const Zf=r=>(e,t,s,n)=>t==="dimension"?[e,s]:[e,n?s-r:s+r],If=r=>(e,t,s,n)=>[e,n?s/r:s*r],Af=r=>(e,t,s)=>{if(e===null)return[r,s];const{lower:n,upper:a}=e,{lower:i,upper:o}=r,c=a-n,l=o-i;if(t==="dimension")return[r,s*(l/c)];const h=(s-n)*(l/c)+i;return[r,h]},Cf=r=>(e,t,s)=>[r,s],$f=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:s,upper:n}=r;return[r,n-(t-s)]},jf=r=>(e,t,s)=>{const{lower:n,upper:a}=r;return s=Ef(s,n,a),[e,s]},Fa=class Rr{constructor(){b(this,"ops",[]),b(this,"currBounds",null),b(this,"currType",null),b(this,"reversed",!1),this.ops=[]}static translate(e){return new Rr().translate(e)}static magnify(e){return new Rr().magnify(e)}static scale(e,t){return new Rr().scale(e,t)}translate(e){const t=this.new(),s=Zf(e);return s.type="translate",t.ops.push(s),t}magnify(e){const t=this.new(),s=If(e);return s.type="magnify",t.ops.push(s),t}scale(e,t){const s=ga(e,t),n=this.new(),a=Af(s);return a.type="scale",n.ops.push(a),n}clamp(e,t){const s=ga(e,t),n=this.new(),a=jf(s);return a.type="clamp",n.ops.push(a),n}reBound(e,t){const s=ga(e,t),n=this.new(),a=Cf(s);return a.type="re-bound",n.ops.push(a),n}invert(){const e=$f();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new Rr;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([s,n],a)=>a(s,e,n,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((s,n)=>{if(s.type==="scale"||t.some(([i,o])=>n>=i&&n<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>n);a!==-1&&t.push([n,a])}),t.forEach(([s,n])=>{const a=e.ops.slice(s,n);a.unshift(e.ops[n]),e.ops.splice(s,n-s+1,...a)}),e.reversed=!e.reversed,e}};b(Fa,"IDENTITY",new Fa);let ho=Fa;const po=class kt{constructor(e=new ho,t=new ho,s=null){b(this,"x"),b(this,"y"),b(this,"currRoot"),this.x=e,this.y=t,this.currRoot=s}static translate(e,t){return new kt().translate(e,t)}static translateX(e){return new kt().translateX(e)}static translateY(e){return new kt().translateY(e)}static clamp(e){return new kt().clamp(e)}static magnify(e){return new kt().magnify(e)}static scale(e){return new kt().scale(e)}static reBound(e){return new kt().reBound(e)}translate(e,t){const s=xf(e,t),n=this.copy();return n.x=this.x.translate(s.x),n.y=this.y.translate(s.y),n}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Nf(e)){const s=this.currRoot;return t.currRoot=e.root,s!=null&&!Of(s,e.root)&&(s.x!==e.root.x&&(t.x=t.x.invert()),s.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(va(e)),t.y=t.y.scale(wa(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(va(e)),t.y=this.y.reBound(wa(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(va(e)),t.y=this.y.clamp(wa(e)),t}copy(){const e=new kt;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Ai(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};b(po,"IDENTITY",new po);const ou=(r,e)=>{const t=new Ze(e);if(![Ie.DAY,Ie.HOUR,Ie.MINUTE,Ie.SECOND,Ie.MILLISECOND,Ie.MICROSECOND,Ie.NANOSECOND].some(n=>n.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const s=r.valueOf()%t.valueOf();return r instanceof Ze?new Ze(s):new Ie(s)},ae=class P{constructor(e,t="UTC"){if(b(this,"value"),b(this,"encodeValue",!0),e==null)this.value=P.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*P.MILLISECOND.valueOf();else if(typeof e=="string")this.value=P.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=P.parseDate(e);else{let s=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(s=P.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=P.MAX:e=P.MIN)),this.value=BigInt(e.valueOf())+s}}static parseDate([e=1970,t=1,s=1]){const n=new Date(e,t-1,s,0,0,0,0);return new P(BigInt(n.getTime())*P.MILLISECOND.valueOf()).truncate(P.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[s,n,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=P.hours(parseInt(s??"00",10)).add(P.minutes(parseInt(n??"00",10))).add(P.seconds(parseInt(i??"00",10))).add(P.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(P.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return P.parseTimeString(e,t);const s=new Date(e);return e.includes(":")||s.setUTCHours(0,0,0,0),new P(BigInt(s.getTime())*P.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(P.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const s=this.toISOString(t);return e?s.slice(11,23):s.slice(11,19)}dateString(e="UTC"){const t=this.date(),s=t.toLocaleString("default",{month:"short"}),n=t.toLocaleString("default",{day:"numeric"});return`${s} ${n}`}static get utcOffset(){return new Ie(BigInt(new Date().getTimezoneOffset())*P.MINUTE.valueOf())}static since(e){return new P().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new P(e).valueOf()}span(e){return this.range(e).span}range(e){return new Rf(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new P(e).valueOf()}afterEq(e){return this.valueOf()>=new P(e).valueOf()}before(e){return this.valueOf()<new P(e).valueOf()}beforeEq(e){return this.valueOf()<=new P(e).valueOf()}add(e){return new P(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new P(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/P.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return ou(this,e)}get isToday(){return this.truncate(Ie.DAY).equals(P.now().truncate(Ie.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new P(new Date)}static max(...e){let t=P.MIN;for(const s of e){const n=new P(s);n.after(t)&&(t=n)}return t}static min(...e){let t=P.MAX;for(const s of e){const n=new P(s);n.before(t)&&(t=n)}return t}static nanoseconds(e){return new P(e)}static microseconds(e){return P.nanoseconds(e*1e3)}static milliseconds(e){return P.microseconds(e*1e3)}static seconds(e){return P.milliseconds(e*1e3)}static minutes(e){return P.seconds(e*60)}static hours(e){return P.minutes(e*60)}static days(e){return P.hours(e*24)}};b(ae,"NANOSECOND",ae.nanoseconds(1)),b(ae,"MICROSECOND",ae.microseconds(1)),b(ae,"MILLISECOND",ae.milliseconds(1)),b(ae,"SECOND",ae.seconds(1)),b(ae,"MINUTE",ae.minutes(1)),b(ae,"HOUR",ae.hours(1)),b(ae,"DAY",ae.days(1)),b(ae,"MAX",new ae((1n<<63n)-1n)),b(ae,"MIN",new ae(0)),b(ae,"ZERO",new ae(0)),b(ae,"z",m.union([m.object({value:m.bigint()}).transform(r=>new ae(r.value)),m.string().transform(r=>new ae(BigInt(r))),m.instanceof(Number).transform(r=>new ae(r)),m.number().transform(r=>new ae(r)),m.instanceof(ae)]));let Ze=ae;const ie=class ee{constructor(e){b(this,"value"),b(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new ee(e).valueOf()}greaterThan(e){return this.valueOf()>new ee(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new ee(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new ee(e).valueOf()}remainder(e){return ou(this,e)}truncate(e){return new ee(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(ee.DAY),t=this.truncate(ee.HOUR),s=this.truncate(ee.MINUTE),n=this.truncate(ee.SECOND),a=this.truncate(ee.MILLISECOND),i=this.truncate(ee.MICROSECOND),o=this.truncate(ee.NANOSECOND),c=e,l=t.sub(e),h=s.sub(t),k=n.sub(s),oe=a.sub(n),ge=i.sub(a),Re=o.sub(i);let he="";return c.isZero||(he+=`${c.days}d `),l.isZero||(he+=`${l.hours}h `),h.isZero||(he+=`${h.minutes}m `),k.isZero||(he+=`${k.seconds}s `),oe.isZero||(he+=`${oe.milliseconds}ms `),ge.isZero||(he+=`${ge.microseconds}µs `),Re.isZero||(he+=`${Re.nanoseconds}ns`),he.trim()}get days(){return Number(this.valueOf()/ee.DAY.valueOf())}get hours(){return Number(this.valueOf()/ee.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/ee.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/ee.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/ee.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/ee.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new ee(e).valueOf()}add(e){return new ee(this.valueOf()+new ee(e).valueOf())}sub(e){return new ee(this.valueOf()-new ee(e).valueOf())}static nanoseconds(e=1){return new ee(e)}static microseconds(e=1){return ee.nanoseconds(e*1e3)}static milliseconds(e=1){return ee.microseconds(e*1e3)}static seconds(e=1){return ee.milliseconds(e*1e3)}static minutes(e){return ee.seconds(e.valueOf()*60)}static hours(e){return ee.minutes(e*60)}static days(e){return ee.hours(e*24)}};b(ie,"NANOSECOND",ie.nanoseconds(1)),b(ie,"MICROSECOND",ie.microseconds(1)),b(ie,"MILLISECOND",ie.milliseconds(1)),b(ie,"SECOND",ie.seconds(1)),b(ie,"MINUTE",ie.minutes(1)),b(ie,"HOUR",ie.hours(1)),b(ie,"DAY",ie.days(1)),b(ie,"MAX",new ie((1n<<63n)-1n)),b(ie,"MIN",new ie(0)),b(ie,"ZERO",new ie(0)),b(ie,"z",m.union([m.object({value:m.bigint()}).transform(r=>new ie(r.value)),m.string().transform(r=>new ie(BigInt(r))),m.instanceof(Number).transform(r=>new ie(r)),m.number().transform(r=>new ie(r)),m.instanceof(ie)]));let Ie=ie;const Ms=class sn extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new sn(e).valueOf()}get period(){return Ie.seconds(1/this.valueOf())}sampleCount(e){return new Ie(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new Ee(t).valueOf()}span(e){return Ie.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new sn(e)}static khz(e){return sn.hz(e*1e3)}};b(Ms,"z",m.union([m.number().transform(r=>new Ms(r)),m.instanceof(Number).transform(r=>new Ms(r)),m.instanceof(Ms)]));const we=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new zf(r*this.valueOf())}};b(we,"UNKNOWN",new we(0)),b(we,"BIT128",new we(16)),b(we,"BIT64",new we(8)),b(we,"BIT32",new we(4)),b(we,"BIT16",new we(2)),b(we,"BIT8",new we(1)),b(we,"z",m.union([m.number().transform(r=>new we(r)),m.instanceof(Number).transform(r=>new we(r)),m.instanceof(we)]));let Ee=we;const Qe=class nn{constructor(e,t){b(this,"start"),b(this,"end"),typeof e=="object"&&"start"in e?(this.start=new Ze(e.start),this.end=new Ze(e.end)):(this.start=new Ze(e),this.end=new Ze(t))}get span(){return new Ie(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new nn(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof nn?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new nn(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};b(Qe,"MAX",new Qe(Ze.MIN,Ze.MAX)),b(Qe,"MIN",new Qe(Ze.MAX,Ze.MIN)),b(Qe,"ZERO",new Qe(Ze.ZERO,Ze.ZERO)),b(Qe,"z",m.union([m.object({start:Ze.z,end:Ze.z}).transform(r=>new Qe(r.start,r.end)),m.instanceof(Qe)]));let Rf=Qe;const g=class et extends String{constructor(e){if(e instanceof et||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=et.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(et.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=et.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(et.JSON)||this.equals(et.STRING)}get isNumeric(){return!this.isVariable&&!this.equals(et.UUID)}get isInteger(){return this.toString().startsWith("int")}get isFloat(){return this.toString().startsWith("float")}get density(){const e=et.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return et.BIG_INT_TYPES.some(e=>e.equals(this))}};b(g,"UNKNOWN",new g("unknown")),b(g,"FLOAT64",new g("float64")),b(g,"FLOAT32",new g("float32")),b(g,"INT64",new g("int64")),b(g,"INT32",new g("int32")),b(g,"INT16",new g("int16")),b(g,"INT8",new g("int8")),b(g,"UINT64",new g("uint64")),b(g,"UINT32",new g("uint32")),b(g,"UINT16",new g("uint16")),b(g,"UINT8",new g("uint8")),b(g,"BOOLEAN",g.UINT8),b(g,"TIMESTAMP",new g("timestamp")),b(g,"UUID",new g("uuid")),b(g,"STRING",new g("string")),b(g,"JSON",new g("json")),b(g,"ARRAY_CONSTRUCTORS",new Map([[g.UINT8.toString(),Uint8Array],[g.UINT16.toString(),Uint16Array],[g.UINT32.toString(),Uint32Array],[g.UINT64.toString(),BigUint64Array],[g.FLOAT32.toString(),Float32Array],[g.FLOAT64.toString(),Float64Array],[g.INT8.toString(),Int8Array],[g.INT16.toString(),Int16Array],[g.INT32.toString(),Int32Array],[g.INT64.toString(),BigInt64Array],[g.TIMESTAMP.toString(),BigInt64Array],[g.STRING.toString(),Uint8Array],[g.JSON.toString(),Uint8Array],[g.UUID.toString(),Uint8Array]])),b(g,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,g.UINT8],[Uint16Array.name,g.UINT16],[Uint32Array.name,g.UINT32],[BigUint64Array.name,g.UINT64],[Float32Array.name,g.FLOAT32],[Float64Array.name,g.FLOAT64],[Int8Array.name,g.INT8],[Int16Array.name,g.INT16],[Int32Array.name,g.INT32],[BigInt64Array.name,g.INT64]])),b(g,"DENSITIES",new Map([[g.UINT8.toString(),Ee.BIT8],[g.UINT16.toString(),Ee.BIT16],[g.UINT32.toString(),Ee.BIT32],[g.UINT64.toString(),Ee.BIT64],[g.FLOAT32.toString(),Ee.BIT32],[g.FLOAT64.toString(),Ee.BIT64],[g.INT8.toString(),Ee.BIT8],[g.INT16.toString(),Ee.BIT16],[g.INT32.toString(),Ee.BIT32],[g.INT64.toString(),Ee.BIT64],[g.TIMESTAMP.toString(),Ee.BIT64],[g.STRING.toString(),Ee.UNKNOWN],[g.JSON.toString(),Ee.UNKNOWN],[g.UUID.toString(),Ee.BIT128]])),b(g,"ALL",[g.UNKNOWN,g.FLOAT64,g.FLOAT32,g.INT64,g.INT32,g.INT16,g.INT8,g.UINT64,g.UINT32,g.UINT16,g.UINT8,g.TIMESTAMP,g.UUID,g.STRING,g.JSON]),b(g,"BIG_INT_TYPES",[g.INT64,g.UINT64,g.TIMESTAMP]),b(g,"z",m.union([m.string().transform(r=>new g(r)),m.instanceof(g)]));const ke=class fe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return fe.bytes(this.valueOf()+e.valueOf())}sub(e){return fe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new fe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return fe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/fe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/fe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/fe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/fe.TERABYTE.valueOf()}toString(){const e=this.truncate(fe.TERABYTE),t=this.truncate(fe.GIGABYTE),s=this.truncate(fe.MEGABYTE),n=this.truncate(fe.KILOBYTE),a=this.truncate(fe.BYTE),i=e,o=t.sub(e),c=s.sub(t),l=n.sub(s),h=a.sub(n);let k="";return i.isZero||(k+=`${i.terabytes}TB `),o.isZero||(k+=`${o.gigabytes}GB `),c.isZero||(k+=`${c.megabytes}MB `),l.isZero||(k+=`${l.kilobytes}KB `),(!h.isZero||k==="")&&(k+=`${h.valueOf()}B`),k.trim()}static bytes(e=1){return new fe(e)}static kilobytes(e=1){return fe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return fe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return fe.megabytes(e.valueOf()*1e3)}static terabytes(e){return fe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};b(ke,"BYTE",new ke(1)),b(ke,"KILOBYTE",ke.kilobytes(1)),b(ke,"MEGABYTE",ke.megabytes(1)),b(ke,"GIGABYTE",ke.gigabytes(1)),b(ke,"TERABYTE",ke.terabytes(1)),b(ke,"ZERO",new ke(0)),b(ke,"z",m.union([m.number().transform(r=>new ke(r)),m.instanceof(ke)]));let zf=ke;m.union([m.instanceof(Uint8Array),m.instanceof(Uint16Array),m.instanceof(Uint32Array),m.instanceof(BigUint64Array),m.instanceof(Float32Array),m.instanceof(Float64Array),m.instanceof(Int8Array),m.instanceof(Int16Array),m.instanceof(Int32Array),m.instanceof(BigInt64Array)]);m.record(m.union([m.number(),m.string(),m.symbol()]),m.unknown());const Pf=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),cu=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Mf=cu(),uu=["MacOS","Windows","Linux","Docker"],Df=m.enum(uu);let _a;const Lf=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Uf=(r={})=>{const{force:e,default:t}=r;return e??_a??(_a=Lf(),_a??t)},lu=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:uu,RUNTIME:Mf,detect:cu,getOS:Uf,osZ:Df},Symbol.toStringTag,{value:"Module"})),Bf=(...r)=>r.map(du).join(""),du=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),qf=r=>r.endsWith("/")?r.slice(0,-1):r,Vf=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,s])=>`${e}${t}=${s}`).join("&");var hr;let Kf=(hr=class{constructor({host:r,port:e,protocol:t="",pathPrefix:s=""}){b(this,"protocol"),b(this,"host"),b(this,"port"),b(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=du(s)}replace(r){return new hr({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new hr({...this,pathPrefix:Bf(this.path,r)})}toString(){return qf(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},b(hr,"UNKNOWN",new hr({host:"unknown",port:0})),hr);class Wf{constructor(){b(this,"contentType","application/json"),b(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify($n.toSnake(e),(s,n)=>ArrayBuffer.isView(n)?Array.from(n):Pf(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n);return new TextEncoder().encode(t)}decode(e,t){const s=$n.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(s):s}static registerCustomType(){}}new Wf;var X;(function(r){r.assertEqual=n=>n;function e(n){}r.assertIs=e;function t(n){throw new Error}r.assertNever=t,r.arrayToEnum=n=>{const a={};for(const i of n)a[i]=i;return a},r.getValidEnumValues=n=>{const a=r.objectKeys(n).filter(o=>typeof n[n[o]]!="number"),i={};for(const o of a)i[o]=n[o];return r.objectValues(i)},r.objectValues=n=>r.objectKeys(n).map(function(a){return n[a]}),r.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const a=[];for(const i in n)Object.prototype.hasOwnProperty.call(n,i)&&a.push(i);return a},r.find=(n,a)=>{for(const i of n)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&isFinite(n)&&Math.floor(n)===n;function s(n,a=" | "){return n.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=s,r.jsonStringifyReplacer=(n,a)=>typeof a=="bigint"?a.toString():a})(X||(X={}));var Ya;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ya||(Ya={}));const x=X.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zt=r=>{switch(typeof r){case"undefined":return x.undefined;case"string":return x.string;case"number":return isNaN(r)?x.nan:x.number;case"boolean":return x.boolean;case"function":return x.function;case"bigint":return x.bigint;case"symbol":return x.symbol;case"object":return Array.isArray(r)?x.array:r===null?x.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?x.promise:typeof Map<"u"&&r instanceof Map?x.map:typeof Set<"u"&&r instanceof Set?x.set:typeof Date<"u"&&r instanceof Date?x.date:x.object;default:return x.unknown}},_=X.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ff=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Ve extends Error{constructor(e){super(),this.issues=[],this.addIssue=s=>{this.issues=[...this.issues,s]},this.addIssues=(s=[])=>{this.issues=[...this.issues,...s]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},s={_errors:[]},n=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(n);else if(i.code==="invalid_return_type")n(i.returnTypeError);else if(i.code==="invalid_arguments")n(i.argumentsError);else if(i.path.length===0)s._errors.push(t(i));else{let o=s,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return n(this),s}toString(){return this.message}get message(){return JSON.stringify(this.issues,X.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},s=[];for(const n of this.issues)n.path.length>0?(t[n.path[0]]=t[n.path[0]]||[],t[n.path[0]].push(e(n))):s.push(e(n));return{formErrors:s,fieldErrors:t}}get formErrors(){return this.flatten()}}Ve.create=r=>new Ve(r);const ls=(r,e)=>{let t;switch(r.code){case _.invalid_type:r.received===x.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case _.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,X.jsonStringifyReplacer)}`;break;case _.unrecognized_keys:t=`Unrecognized key(s) in object: ${X.joinValues(r.keys,", ")}`;break;case _.invalid_union:t="Invalid input";break;case _.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${X.joinValues(r.options)}`;break;case _.invalid_enum_value:t=`Invalid enum value. Expected ${X.joinValues(r.options)}, received '${r.received}'`;break;case _.invalid_arguments:t="Invalid function arguments";break;case _.invalid_return_type:t="Invalid function return type";break;case _.invalid_date:t="Invalid date";break;case _.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:X.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case _.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case _.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case _.custom:t="Invalid input";break;case _.invalid_intersection_types:t="Intersection results could not be merged";break;case _.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case _.not_finite:t="Number must be finite";break;default:t=e.defaultError,X.assertNever(r)}return{message:t}};let hu=ls;function Yf(r){hu=r}function jn(){return hu}const Rn=r=>{const{data:e,path:t,errorMaps:s,issueData:n}=r,a=[...t,...n.path||[]],i={...n,path:a};let o="";const c=s.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...n,path:a,message:n.message||o}},Jf=[];function E(r,e){const t=Rn({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,jn(),ls].filter(s=>!!s)});r.common.issues.push(t)}class Ne{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const s=[];for(const n of t){if(n.status==="aborted")return L;n.status==="dirty"&&e.dirty(),s.push(n.value)}return{status:e.value,value:s}}static async mergeObjectAsync(e,t){const s=[];for(const n of t)s.push({key:await n.key,value:await n.value});return Ne.mergeObjectSync(e,s)}static mergeObjectSync(e,t){const s={};for(const n of t){const{key:a,value:i}=n;if(a.status==="aborted"||i.status==="aborted")return L;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||n.alwaysSet)&&(s[a.value]=i.value)}return{status:e.value,value:s}}}const L=Object.freeze({status:"aborted"}),pu=r=>({status:"dirty",value:r}),je=r=>({status:"valid",value:r}),Ja=r=>r.status==="aborted",Ga=r=>r.status==="dirty",ds=r=>r.status==="valid",zn=r=>typeof Promise<"u"&&r instanceof Promise;var A;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(A||(A={}));class it{constructor(e,t,s,n){this._cachedPath=[],this.parent=e,this.data=t,this._path=s,this._key=n}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const fo=(r,e)=>{if(ds(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Ve(r.common.issues);return this._error=t,this._error}}};function q(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:s,description:n}=r;if(e&&(t||s))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:n}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:s??i.defaultError}:{message:t??i.defaultError},description:n}}class W{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return zt(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Ne,ctx:{common:e.parent.common,data:e.data,parsedType:zt(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(zn(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const s=this.safeParse(e,t);if(s.success)return s.data;throw s.error}safeParse(e,t){var s;const n={common:{issues:[],async:(s=t==null?void 0:t.async)!==null&&s!==void 0?s:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},a=this._parseSync({data:e,path:n.path,parent:n});return fo(n,a)}async parseAsync(e,t){const s=await this.safeParseAsync(e,t);if(s.success)return s.data;throw s.error}async safeParseAsync(e,t){const s={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zt(e)},n=this._parse({data:e,path:s.path,parent:s}),a=await(zn(n)?n:Promise.resolve(n));return fo(s,a)}refine(e,t){const s=n=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(n):t;return this._refinement((n,a)=>{const i=e(n),o=()=>a.addIssue({code:_.custom,...s(n)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((s,n)=>e(s)?!0:(n.addIssue(typeof t=="function"?t(s,n):t),!1))}_refinement(e){return new Je({schema:this,typeName:R.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return St.create(this,this._def)}nullable(){return ir.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ke.create(this,this._def)}promise(){return Zr.create(this,this._def)}or(e){return ms.create([this,e],this._def)}and(e){return ys.create(this,e,this._def)}transform(e){return new Je({...q(this._def),schema:this,typeName:R.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new bs({...q(this._def),innerType:this,defaultValue:t,typeName:R.ZodDefault})}brand(){return new mu({typeName:R.ZodBranded,type:this,...q(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ln({...q(this._def),innerType:this,catchValue:t,typeName:R.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Zs.create(this,e)}readonly(){return Bn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Gf=/^c[^\s-]{8,}$/i,Hf=/^[a-z][a-z0-9]*$/,Xf=/^[0-9A-HJKMNP-TV-Z]{26}$/,Qf=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,em=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,tm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ba;const rm=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,sm=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,nm=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function am(r,e){return!!((e==="v4"||!e)&&rm.test(r)||(e==="v6"||!e)&&sm.test(r))}class Le extends W{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==x.string){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.string,received:n.parsedType}),L}const t=new Ne;let s;for(const n of this._def.checks)if(n.kind==="min")e.data.length<n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="max")e.data.length>n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!1,message:n.message}),t.dirty());else if(n.kind==="length"){const a=e.data.length>n.value,i=e.data.length<n.value;(a||i)&&(s=this._getOrReturnCtx(e,s),a?E(s,{code:_.too_big,maximum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}):i&&E(s,{code:_.too_small,minimum:n.value,type:"string",inclusive:!0,exact:!0,message:n.message}),t.dirty())}else if(n.kind==="email")em.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"email",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="emoji")ba||(ba=new RegExp(tm,"u")),ba.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"emoji",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="uuid")Qf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"uuid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid")Gf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"cuid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="cuid2")Hf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"cuid2",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="ulid")Xf.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"ulid",code:_.invalid_string,message:n.message}),t.dirty());else if(n.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),E(s,{validation:"url",code:_.invalid_string,message:n.message}),t.dirty()}else n.kind==="regex"?(n.regex.lastIndex=0,n.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"regex",code:_.invalid_string,message:n.message}),t.dirty())):n.kind==="trim"?e.data=e.data.trim():n.kind==="includes"?e.data.includes(n.value,n.position)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{includes:n.value,position:n.position},message:n.message}),t.dirty()):n.kind==="toLowerCase"?e.data=e.data.toLowerCase():n.kind==="toUpperCase"?e.data=e.data.toUpperCase():n.kind==="startsWith"?e.data.startsWith(n.value)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{startsWith:n.value},message:n.message}),t.dirty()):n.kind==="endsWith"?e.data.endsWith(n.value)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:{endsWith:n.value},message:n.message}),t.dirty()):n.kind==="datetime"?nm(n).test(e.data)||(s=this._getOrReturnCtx(e,s),E(s,{code:_.invalid_string,validation:"datetime",message:n.message}),t.dirty()):n.kind==="ip"?am(e.data,n.version)||(s=this._getOrReturnCtx(e,s),E(s,{validation:"ip",code:_.invalid_string,message:n.message}),t.dirty()):X.assertNever(n);return{status:t.value,value:e.data}}_regex(e,t,s){return this.refinement(n=>e.test(n),{validation:t,code:_.invalid_string,...A.errToObj(s)})}_addCheck(e){return new Le({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...A.errToObj(e)})}url(e){return this._addCheck({kind:"url",...A.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...A.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...A.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...A.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...A.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...A.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...A.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...A.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...A.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...A.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...A.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...A.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...A.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...A.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...A.errToObj(t)})}nonempty(e){return this.min(1,A.errToObj(e))}trim(){return new Le({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Le({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Le({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Le.create=r=>{var e;return new Le({checks:[],typeName:R.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...q(r)})};function im(r,e){const t=(r.toString().split(".")[1]||"").length,s=(e.toString().split(".")[1]||"").length,n=t>s?t:s,a=parseInt(r.toFixed(n).replace(".","")),i=parseInt(e.toFixed(n).replace(".",""));return a%i/Math.pow(10,n)}class Bt extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==x.number){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.number,received:n.parsedType}),L}let t;const s=new Ne;for(const n of this._def.checks)n.kind==="int"?X.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:_.invalid_type,expected:"integer",received:"float",message:n.message}),s.dirty()):n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_small,minimum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_big,maximum:n.value,type:"number",inclusive:n.inclusive,exact:!1,message:n.message}),s.dirty()):n.kind==="multipleOf"?im(e.data,n.value)!==0&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):n.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_finite,message:n.message}),s.dirty()):X.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,s,n){return new Bt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:A.toString(n)}]})}_addCheck(e){return new Bt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:A.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:A.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&X.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const s of this._def.checks){if(s.kind==="finite"||s.kind==="int"||s.kind==="multipleOf")return!0;s.kind==="min"?(t===null||s.value>t)&&(t=s.value):s.kind==="max"&&(e===null||s.value<e)&&(e=s.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Bt.create=r=>new Bt({checks:[],typeName:R.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...q(r)});class qt extends W{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==x.bigint){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.bigint,received:n.parsedType}),L}let t;const s=new Ne;for(const n of this._def.checks)n.kind==="min"?(n.inclusive?e.data<n.value:e.data<=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_small,type:"bigint",minimum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="max"?(n.inclusive?e.data>n.value:e.data>=n.value)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.too_big,type:"bigint",maximum:n.value,inclusive:n.inclusive,message:n.message}),s.dirty()):n.kind==="multipleOf"?e.data%n.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),E(t,{code:_.not_multiple_of,multipleOf:n.value,message:n.message}),s.dirty()):X.assertNever(n);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,A.toString(t))}gt(e,t){return this.setLimit("min",e,!1,A.toString(t))}lte(e,t){return this.setLimit("max",e,!0,A.toString(t))}lt(e,t){return this.setLimit("max",e,!1,A.toString(t))}setLimit(e,t,s,n){return new qt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:s,message:A.toString(n)}]})}_addCheck(e){return new qt({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:A.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}qt.create=r=>{var e;return new qt({checks:[],typeName:R.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...q(r)})};class hs extends W{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==x.boolean){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.boolean,received:t.parsedType}),L}return je(e.data)}}hs.create=r=>new hs({typeName:R.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...q(r)});class nr extends W{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==x.date){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_type,expected:x.date,received:n.parsedType}),L}if(isNaN(e.data.getTime())){const n=this._getOrReturnCtx(e);return E(n,{code:_.invalid_date}),L}const t=new Ne;let s;for(const n of this._def.checks)n.kind==="min"?e.data.getTime()<n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_small,message:n.message,inclusive:!0,exact:!1,minimum:n.value,type:"date"}),t.dirty()):n.kind==="max"?e.data.getTime()>n.value&&(s=this._getOrReturnCtx(e,s),E(s,{code:_.too_big,message:n.message,inclusive:!0,exact:!1,maximum:n.value,type:"date"}),t.dirty()):X.assertNever(n);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new nr({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:A.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:A.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}nr.create=r=>new nr({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:R.ZodDate,...q(r)});class Pn extends W{_parse(e){if(this._getType(e)!==x.symbol){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.symbol,received:t.parsedType}),L}return je(e.data)}}Pn.create=r=>new Pn({typeName:R.ZodSymbol,...q(r)});class ps extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.undefined,received:t.parsedType}),L}return je(e.data)}}ps.create=r=>new ps({typeName:R.ZodUndefined,...q(r)});class fs extends W{_parse(e){if(this._getType(e)!==x.null){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.null,received:t.parsedType}),L}return je(e.data)}}fs.create=r=>new fs({typeName:R.ZodNull,...q(r)});class Er extends W{constructor(){super(...arguments),this._any=!0}_parse(e){return je(e.data)}}Er.create=r=>new Er({typeName:R.ZodAny,...q(r)});class Ht extends W{constructor(){super(...arguments),this._unknown=!0}_parse(e){return je(e.data)}}Ht.create=r=>new Ht({typeName:R.ZodUnknown,...q(r)});class It extends W{_parse(e){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.never,received:t.parsedType}),L}}It.create=r=>new It({typeName:R.ZodNever,...q(r)});class Mn extends W{_parse(e){if(this._getType(e)!==x.undefined){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.void,received:t.parsedType}),L}return je(e.data)}}Mn.create=r=>new Mn({typeName:R.ZodVoid,...q(r)});class Ke extends W{_parse(e){const{ctx:t,status:s}=this._processInputParams(e),n=this._def;if(t.parsedType!==x.array)return E(t,{code:_.invalid_type,expected:x.array,received:t.parsedType}),L;if(n.exactLength!==null){const i=t.data.length>n.exactLength.value,o=t.data.length<n.exactLength.value;(i||o)&&(E(t,{code:i?_.too_big:_.too_small,minimum:o?n.exactLength.value:void 0,maximum:i?n.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:n.exactLength.message}),s.dirty())}if(n.minLength!==null&&t.data.length<n.minLength.value&&(E(t,{code:_.too_small,minimum:n.minLength.value,type:"array",inclusive:!0,exact:!1,message:n.minLength.message}),s.dirty()),n.maxLength!==null&&t.data.length>n.maxLength.value&&(E(t,{code:_.too_big,maximum:n.maxLength.value,type:"array",inclusive:!0,exact:!1,message:n.maxLength.message}),s.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>n.type._parseAsync(new it(t,i,t.path,o)))).then(i=>Ne.mergeArray(s,i));const a=[...t.data].map((i,o)=>n.type._parseSync(new it(t,i,t.path,o)));return Ne.mergeArray(s,a)}get element(){return this._def.type}min(e,t){return new Ke({...this._def,minLength:{value:e,message:A.toString(t)}})}max(e,t){return new Ke({...this._def,maxLength:{value:e,message:A.toString(t)}})}length(e,t){return new Ke({...this._def,exactLength:{value:e,message:A.toString(t)}})}nonempty(e){return this.min(1,e)}}Ke.create=(r,e)=>new Ke({type:r,minLength:null,maxLength:null,exactLength:null,typeName:R.ZodArray,...q(e)});function mr(r){if(r instanceof de){const e={};for(const t in r.shape){const s=r.shape[t];e[t]=St.create(mr(s))}return new de({...r._def,shape:()=>e})}else return r instanceof Ke?new Ke({...r._def,type:mr(r.element)}):r instanceof St?St.create(mr(r.unwrap())):r instanceof ir?ir.create(mr(r.unwrap())):r instanceof ot?ot.create(r.items.map(e=>mr(e))):r}class de extends W{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=X.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==x.object){const c=this._getOrReturnCtx(e);return E(c,{code:_.invalid_type,expected:x.object,received:c.parsedType}),L}const{status:t,ctx:s}=this._processInputParams(e),{shape:n,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof It&&this._def.unknownKeys==="strip"))for(const c in s.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=n[c],h=s.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new it(s,h,s.path,c)),alwaysSet:c in s.data})}if(this._def.catchall instanceof It){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:s.data[l]}});else if(c==="strict")i.length>0&&(E(s,{code:_.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const h=s.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new it(s,h,s.path,l)),alwaysSet:l in s.data})}}return s.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const h=await l.key;c.push({key:h,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>Ne.mergeObjectSync(t,c)):Ne.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return A.errToObj,new de({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,s)=>{var n,a,i,o;const c=(i=(a=(n=this._def).errorMap)===null||a===void 0?void 0:a.call(n,t,s).message)!==null&&i!==void 0?i:s.defaultError;return t.code==="unrecognized_keys"?{message:(o=A.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new de({...this._def,unknownKeys:"strip"})}passthrough(){return new de({...this._def,unknownKeys:"passthrough"})}extend(e){return new de({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new de({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:R.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new de({...this._def,catchall:e})}pick(e){const t={};return X.objectKeys(e).forEach(s=>{e[s]&&this.shape[s]&&(t[s]=this.shape[s])}),new de({...this._def,shape:()=>t})}omit(e){const t={};return X.objectKeys(this.shape).forEach(s=>{e[s]||(t[s]=this.shape[s])}),new de({...this._def,shape:()=>t})}deepPartial(){return mr(this)}partial(e){const t={};return X.objectKeys(this.shape).forEach(s=>{const n=this.shape[s];e&&!e[s]?t[s]=n:t[s]=n.optional()}),new de({...this._def,shape:()=>t})}required(e){const t={};return X.objectKeys(this.shape).forEach(s=>{if(e&&!e[s])t[s]=this.shape[s];else{let n=this.shape[s];for(;n instanceof St;)n=n._def.innerType;t[s]=n}}),new de({...this._def,shape:()=>t})}keyof(){return fu(X.objectKeys(this.shape))}}de.create=(r,e)=>new de({shape:()=>r,unknownKeys:"strip",catchall:It.create(),typeName:R.ZodObject,...q(e)});de.strictCreate=(r,e)=>new de({shape:()=>r,unknownKeys:"strict",catchall:It.create(),typeName:R.ZodObject,...q(e)});de.lazycreate=(r,e)=>new de({shape:r,unknownKeys:"strip",catchall:It.create(),typeName:R.ZodObject,...q(e)});class ms extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s=this._def.options;function n(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Ve(o.ctx.common.issues));return E(t,{code:_.invalid_union,unionErrors:i}),L}if(t.common.async)return Promise.all(s.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(n);{let a;const i=[];for(const c of s){const l={...t,common:{...t.common,issues:[]},parent:null},h=c._parseSync({data:t.data,path:t.path,parent:l});if(h.status==="valid")return h;h.status==="dirty"&&!a&&(a={result:h,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Ve(c));return E(t,{code:_.invalid_union,unionErrors:o}),L}}get options(){return this._def.options}}ms.create=(r,e)=>new ms({options:r,typeName:R.ZodUnion,...q(e)});const an=r=>r instanceof vs?an(r.schema):r instanceof Je?an(r.innerType()):r instanceof ws?[r.value]:r instanceof Vt?r.options:r instanceof _s?Object.keys(r.enum):r instanceof bs?an(r._def.innerType):r instanceof ps?[void 0]:r instanceof fs?[null]:null;class na extends W{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.object)return E(t,{code:_.invalid_type,expected:x.object,received:t.parsedType}),L;const s=this.discriminator,n=t.data[s],a=this.optionsMap.get(n);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(E(t,{code:_.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[s]}),L)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,s){const n=new Map;for(const a of t){const i=an(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(n.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);n.set(o,a)}}return new na({typeName:R.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:n,...q(s)})}}function Ha(r,e){const t=zt(r),s=zt(e);if(r===e)return{valid:!0,data:r};if(t===x.object&&s===x.object){const n=X.objectKeys(e),a=X.objectKeys(r).filter(o=>n.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Ha(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===x.array&&s===x.array){if(r.length!==e.length)return{valid:!1};const n=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Ha(i,o);if(!c.valid)return{valid:!1};n.push(c.data)}return{valid:!0,data:n}}else return t===x.date&&s===x.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ys extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=(a,i)=>{if(Ja(a)||Ja(i))return L;const o=Ha(a.value,i.value);return o.valid?((Ga(a)||Ga(i))&&t.dirty(),{status:t.value,value:o.data}):(E(s,{code:_.invalid_intersection_types}),L)};return s.common.async?Promise.all([this._def.left._parseAsync({data:s.data,path:s.path,parent:s}),this._def.right._parseAsync({data:s.data,path:s.path,parent:s})]).then(([a,i])=>n(a,i)):n(this._def.left._parseSync({data:s.data,path:s.path,parent:s}),this._def.right._parseSync({data:s.data,path:s.path,parent:s}))}}ys.create=(r,e,t)=>new ys({left:r,right:e,typeName:R.ZodIntersection,...q(t)});class ot extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.array)return E(s,{code:_.invalid_type,expected:x.array,received:s.parsedType}),L;if(s.data.length<this._def.items.length)return E(s,{code:_.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),L;!this._def.rest&&s.data.length>this._def.items.length&&(E(s,{code:_.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const n=[...s.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new it(s,a,s.path,i)):null}).filter(a=>!!a);return s.common.async?Promise.all(n).then(a=>Ne.mergeArray(t,a)):Ne.mergeArray(t,n)}get items(){return this._def.items}rest(e){return new ot({...this._def,rest:e})}}ot.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new ot({items:r,typeName:R.ZodTuple,rest:null,...q(e)})};class gs extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.object)return E(s,{code:_.invalid_type,expected:x.object,received:s.parsedType}),L;const n=[],a=this._def.keyType,i=this._def.valueType;for(const o in s.data)n.push({key:a._parse(new it(s,o,s.path,o)),value:i._parse(new it(s,s.data[o],s.path,o))});return s.common.async?Ne.mergeObjectAsync(t,n):Ne.mergeObjectSync(t,n)}get element(){return this._def.valueType}static create(e,t,s){return t instanceof W?new gs({keyType:e,valueType:t,typeName:R.ZodRecord,...q(s)}):new gs({keyType:Le.create(),valueType:e,typeName:R.ZodRecord,...q(t)})}}class Dn extends W{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.map)return E(s,{code:_.invalid_type,expected:x.map,received:s.parsedType}),L;const n=this._def.keyType,a=this._def.valueType,i=[...s.data.entries()].map(([o,c],l)=>({key:n._parse(new it(s,o,s.path,[l,"key"])),value:a._parse(new it(s,c,s.path,[l,"value"]))}));if(s.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,h=await c.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,h=c.value;if(l.status==="aborted"||h.status==="aborted")return L;(l.status==="dirty"||h.status==="dirty")&&t.dirty(),o.set(l.value,h.value)}return{status:t.value,value:o}}}}Dn.create=(r,e,t)=>new Dn({valueType:e,keyType:r,typeName:R.ZodMap,...q(t)});class ar extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.parsedType!==x.set)return E(s,{code:_.invalid_type,expected:x.set,received:s.parsedType}),L;const n=this._def;n.minSize!==null&&s.data.size<n.minSize.value&&(E(s,{code:_.too_small,minimum:n.minSize.value,type:"set",inclusive:!0,exact:!1,message:n.minSize.message}),t.dirty()),n.maxSize!==null&&s.data.size>n.maxSize.value&&(E(s,{code:_.too_big,maximum:n.maxSize.value,type:"set",inclusive:!0,exact:!1,message:n.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const h of c){if(h.status==="aborted")return L;h.status==="dirty"&&t.dirty(),l.add(h.value)}return{status:t.value,value:l}}const o=[...s.data.values()].map((c,l)=>a._parse(new it(s,c,s.path,l)));return s.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new ar({...this._def,minSize:{value:e,message:A.toString(t)}})}max(e,t){return new ar({...this._def,maxSize:{value:e,message:A.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ar.create=(r,e)=>new ar({valueType:r,minSize:null,maxSize:null,typeName:R.ZodSet,...q(e)});class _r extends W{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.function)return E(t,{code:_.invalid_type,expected:x.function,received:t.parsedType}),L;function s(o,c){return Rn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,jn(),ls].filter(l=>!!l),issueData:{code:_.invalid_arguments,argumentsError:c}})}function n(o,c){return Rn({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,jn(),ls].filter(l=>!!l),issueData:{code:_.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Zr){const o=this;return je(async function(...c){const l=new Ve([]),h=await o._def.args.parseAsync(c,a).catch(oe=>{throw l.addIssue(s(c,oe)),l}),k=await Reflect.apply(i,this,h);return await o._def.returns._def.type.parseAsync(k,a).catch(oe=>{throw l.addIssue(n(k,oe)),l})})}else{const o=this;return je(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Ve([s(c,l.error)]);const h=Reflect.apply(i,this,l.data),k=o._def.returns.safeParse(h,a);if(!k.success)throw new Ve([n(h,k.error)]);return k.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new _r({...this._def,args:ot.create(e).rest(Ht.create())})}returns(e){return new _r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,s){return new _r({args:e||ot.create([]).rest(Ht.create()),returns:t||Ht.create(),typeName:R.ZodFunction,...q(s)})}}class vs extends W{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}vs.create=(r,e)=>new vs({getter:r,typeName:R.ZodLazy,...q(e)});class ws extends W{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return E(t,{received:t.data,code:_.invalid_literal,expected:this._def.value}),L}return{status:"valid",value:e.data}}get value(){return this._def.value}}ws.create=(r,e)=>new ws({value:r,typeName:R.ZodLiteral,...q(e)});function fu(r,e){return new Vt({values:r,typeName:R.ZodEnum,...q(e)})}class Vt extends W{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),s=this._def.values;return E(t,{expected:X.joinValues(s),received:t.parsedType,code:_.invalid_type}),L}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),s=this._def.values;return E(t,{received:t.data,code:_.invalid_enum_value,options:s}),L}return je(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Vt.create(e)}exclude(e){return Vt.create(this.options.filter(t=>!e.includes(t)))}}Vt.create=fu;class _s extends W{_parse(e){const t=X.getValidEnumValues(this._def.values),s=this._getOrReturnCtx(e);if(s.parsedType!==x.string&&s.parsedType!==x.number){const n=X.objectValues(t);return E(s,{expected:X.joinValues(n),received:s.parsedType,code:_.invalid_type}),L}if(t.indexOf(e.data)===-1){const n=X.objectValues(t);return E(s,{received:s.data,code:_.invalid_enum_value,options:n}),L}return je(e.data)}get enum(){return this._def.values}}_s.create=(r,e)=>new _s({values:r,typeName:R.ZodNativeEnum,...q(e)});class Zr extends W{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==x.promise&&t.common.async===!1)return E(t,{code:_.invalid_type,expected:x.promise,received:t.parsedType}),L;const s=t.parsedType===x.promise?t.data:Promise.resolve(t.data);return je(s.then(n=>this._def.type.parseAsync(n,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Zr.create=(r,e)=>new Zr({type:r,typeName:R.ZodPromise,...q(e)});class Je extends W{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===R.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:s}=this._processInputParams(e),n=this._def.effect||null,a={addIssue:i=>{E(s,i),i.fatal?t.abort():t.dirty()},get path(){return s.path}};if(a.addIssue=a.addIssue.bind(a),n.type==="preprocess"){const i=n.transform(s.data,a);return s.common.issues.length?{status:"dirty",value:s.data}:s.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:s.path,parent:s})):this._def.schema._parseSync({data:i,path:s.path,parent:s})}if(n.type==="refinement"){const i=o=>{const c=n.refinement(o,a);if(s.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(s.common.async===!1){const o=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});return o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(o=>o.status==="aborted"?L:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(n.type==="transform")if(s.common.async===!1){const i=this._def.schema._parseSync({data:s.data,path:s.path,parent:s});if(!ds(i))return i;const o=n.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:s.data,path:s.path,parent:s}).then(i=>ds(i)?Promise.resolve(n.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);X.assertNever(n)}}Je.create=(r,e,t)=>new Je({schema:r,typeName:R.ZodEffects,effect:e,...q(t)});Je.createWithPreprocess=(r,e,t)=>new Je({schema:e,effect:{type:"preprocess",transform:r},typeName:R.ZodEffects,...q(t)});class St extends W{_parse(e){return this._getType(e)===x.undefined?je(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}St.create=(r,e)=>new St({innerType:r,typeName:R.ZodOptional,...q(e)});class ir extends W{_parse(e){return this._getType(e)===x.null?je(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ir.create=(r,e)=>new ir({innerType:r,typeName:R.ZodNullable,...q(e)});class bs extends W{_parse(e){const{ctx:t}=this._processInputParams(e);let s=t.data;return t.parsedType===x.undefined&&(s=this._def.defaultValue()),this._def.innerType._parse({data:s,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}bs.create=(r,e)=>new bs({innerType:r,typeName:R.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...q(e)});class Ln extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s={...t,common:{...t.common,issues:[]}},n=this._def.innerType._parse({data:s.data,path:s.path,parent:{...s}});return zn(n)?n.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Ve(s.common.issues)},input:s.data})})):{status:"valid",value:n.status==="valid"?n.value:this._def.catchValue({get error(){return new Ve(s.common.issues)},input:s.data})}}removeCatch(){return this._def.innerType}}Ln.create=(r,e)=>new Ln({innerType:r,typeName:R.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...q(e)});class Un extends W{_parse(e){if(this._getType(e)!==x.nan){const t=this._getOrReturnCtx(e);return E(t,{code:_.invalid_type,expected:x.nan,received:t.parsedType}),L}return{status:"valid",value:e.data}}}Un.create=r=>new Un({typeName:R.ZodNaN,...q(r)});const om=Symbol("zod_brand");class mu extends W{_parse(e){const{ctx:t}=this._processInputParams(e),s=t.data;return this._def.type._parse({data:s,path:t.path,parent:t})}unwrap(){return this._def.type}}class Zs extends W{_parse(e){const{status:t,ctx:s}=this._processInputParams(e);if(s.common.async)return(async()=>{const n=await this._def.in._parseAsync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?L:n.status==="dirty"?(t.dirty(),pu(n.value)):this._def.out._parseAsync({data:n.value,path:s.path,parent:s})})();{const n=this._def.in._parseSync({data:s.data,path:s.path,parent:s});return n.status==="aborted"?L:n.status==="dirty"?(t.dirty(),{status:"dirty",value:n.value}):this._def.out._parseSync({data:n.value,path:s.path,parent:s})}}static create(e,t){return new Zs({in:e,out:t,typeName:R.ZodPipeline})}}class Bn extends W{_parse(e){const t=this._def.innerType._parse(e);return ds(t)&&(t.value=Object.freeze(t.value)),t}}Bn.create=(r,e)=>new Bn({innerType:r,typeName:R.ZodReadonly,...q(e)});const yu=(r,e={},t)=>r?Er.create().superRefine((s,n)=>{var a,i;if(!r(s)){const o=typeof e=="function"?e(s):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;n.addIssue({code:"custom",...l,fatal:c})}}):Er.create(),cm={object:de.lazycreate};var R;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(R||(R={}));const um=(r,e={message:`Input not instance of ${r.name}`})=>yu(t=>t instanceof r,e),gu=Le.create,vu=Bt.create,lm=Un.create,dm=qt.create,wu=hs.create,hm=nr.create,pm=Pn.create,fm=ps.create,mm=fs.create,ym=Er.create,gm=Ht.create,vm=It.create,wm=Mn.create,_m=Ke.create,bm=de.create,km=de.strictCreate,Tm=ms.create,Om=na.create,xm=ys.create,Nm=ot.create,Sm=gs.create,Em=Dn.create,Zm=ar.create,Im=_r.create,Am=vs.create,Cm=ws.create,$m=Vt.create,jm=_s.create,Rm=Zr.create,mo=Je.create,zm=St.create,Pm=ir.create,Mm=Je.createWithPreprocess,Dm=Zs.create,Lm=()=>gu().optional(),Um=()=>vu().optional(),Bm=()=>wu().optional(),qm={string:r=>Le.create({...r,coerce:!0}),number:r=>Bt.create({...r,coerce:!0}),boolean:r=>hs.create({...r,coerce:!0}),bigint:r=>qt.create({...r,coerce:!0}),date:r=>nr.create({...r,coerce:!0})},Vm=L;var Ot=Object.freeze({__proto__:null,defaultErrorMap:ls,setErrorMap:Yf,getErrorMap:jn,makeIssue:Rn,EMPTY_PATH:Jf,addIssueToContext:E,ParseStatus:Ne,INVALID:L,DIRTY:pu,OK:je,isAborted:Ja,isDirty:Ga,isValid:ds,isAsync:zn,get util(){return X},get objectUtil(){return Ya},ZodParsedType:x,getParsedType:zt,ZodType:W,ZodString:Le,ZodNumber:Bt,ZodBigInt:qt,ZodBoolean:hs,ZodDate:nr,ZodSymbol:Pn,ZodUndefined:ps,ZodNull:fs,ZodAny:Er,ZodUnknown:Ht,ZodNever:It,ZodVoid:Mn,ZodArray:Ke,ZodObject:de,ZodUnion:ms,ZodDiscriminatedUnion:na,ZodIntersection:ys,ZodTuple:ot,ZodRecord:gs,ZodMap:Dn,ZodSet:ar,ZodFunction:_r,ZodLazy:vs,ZodLiteral:ws,ZodEnum:Vt,ZodNativeEnum:_s,ZodPromise:Zr,ZodEffects:Je,ZodTransformer:Je,ZodOptional:St,ZodNullable:ir,ZodDefault:bs,ZodCatch:Ln,ZodNaN:Un,BRAND:om,ZodBranded:mu,ZodPipeline:Zs,ZodReadonly:Bn,custom:yu,Schema:W,ZodSchema:W,late:cm,get ZodFirstPartyTypeKind(){return R},coerce:qm,any:ym,array:_m,bigint:dm,boolean:wu,date:hm,discriminatedUnion:Om,effect:mo,enum:$m,function:Im,instanceof:um,intersection:xm,lazy:Am,literal:Cm,map:Em,nan:lm,nativeEnum:jm,never:vm,null:mm,nullable:Pm,number:vu,object:bm,oboolean:Bm,onumber:Um,optional:zm,ostring:Lm,pipeline:Dm,preprocess:Mm,promise:Rm,record:Sm,set:Zm,strictObject:km,string:gu,symbol:pm,transformer:mo,tuple:Nm,undefined:fm,union:Tm,unknown:gm,void:wm,NEVER:Vm,ZodIssueCode:_,quotelessJson:Ff,ZodError:Ve});class Is extends Error{constructor(e,t){super(e),me(this,"discriminator","FreighterError"),me(this,"type"),this.type=t}}const Km=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Xa="unknown",yo="nil",aa="freighter",As=Ot.object({type:Ot.string(),data:Ot.string()});class Wm{constructor(){me(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:yo,data:""};if(Km(e))for(const t of this.providers){const s=t.encode(e);if(s!=null)return s}return{type:Xa,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===yo)return null;if(e.type===Xa)return new go(e.data);for(const t of this.providers){const s=t.decode(e);if(s!=null)return s}return new go(e.data)}}const _u=new Wm,bu=({encode:r,decode:e})=>_u.register({encode:r,decode:e}),Ci=r=>_u.decode(r);class go extends Is{constructor(e){super(e,Xa)}}class ks extends Is{constructor(){super("EOF",aa)}}class qn extends Is{constructor(){super("StreamClosed",aa)}}class Ts extends Is{constructor(e={}){const{message:t="Unreachable",url:s=Kf.UNKNOWN}=e;super(t,aa),me(this,"url"),this.url=s}}const on="freighter",Fm=r=>{if(r.type!==aa)return null;if(r instanceof ks)return{type:on,data:"EOF"};if(r instanceof qn)return{type:on,data:"StreamClosed"};if(r instanceof Ts)return{type:on,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},Ym=r=>{if(r.type!==on)return null;switch(r.data){case"EOF":return new ks;case"StreamClosed":return new qn;case"Unreachable":return new Ts;default:throw new Error(`Unknown error type: ${r.data}`)}};bu({encode:Fm,decode:Ym});class ku{constructor(){me(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let s=0;const n=async a=>{if(s===this.middleware.length)return await t(a);const i=this.middleware[s];return s++,await i(a,n)};return await n(e)}}const Tu="Content-Type",vo=r=>{if(lu.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),s=new t.Agent({rejectUnauthorized:!1});return async(n,a)=>await e(n,{...a,agent:s})};class Jm extends ku{constructor(e,t,s=!1){return super(),me(this,"endpoint"),me(this,"encoder"),me(this,"fetch"),this.endpoint=e.replace({protocol:s?"https":"http"}),this.encoder=t,this.fetch=vo(this.endpoint.protocol),new Proxy(this,{get:(n,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(n,a,i)})}get headers(){return{[Tu]:this.encoder.contentType}}async send(e,t,s,n){t=s==null?void 0:s.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,c]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const h={...l,params:{}};o.headers={...this.headers,...l.params};let k;try{k=await vo(l.protocol)(l.target,o)}catch(ge){let Re=ge;return Re.message==="Load failed"&&(Re=new Ts({url:i})),[h,Re]}const oe=await k.arrayBuffer();if(k!=null&&k.ok)return n!=null&&(a=this.encoder.decode(oe,n)),[h,null];try{if(k.status!==400)return[h,new Error(k.statusText)];const ge=this.encoder.decode(oe,As),Re=Ci(ge);return[h,Re]}catch(ge){return[h,new Error(`[freighter] - failed to decode error: ${k.statusText}: ${ge.message}`)]}});return[a,c]}}const C=async(r,e,t,s,n)=>{const[a,i]=await r.send(e,t,s,n);if(i!=null)throw i;return a},Gm=()=>lu.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),Hm=Ot.object({type:Ot.union([Ot.literal("data"),Ot.literal("close")]),payload:Ot.unknown().optional(),error:Ot.optional(As)});class Xm{constructor(e,t,s,n){me(this,"encoder"),me(this,"reqSchema"),me(this,"resSchema"),me(this,"ws"),me(this,"serverClosed"),me(this,"sendClosed"),me(this,"receiveDataQueue",[]),me(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=s,this.resSchema=n,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new ks;if(this.sendClosed)throw new qn;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Ci(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,s)=>this.receiveCallbacksQueue.push({resolve:t,reject:s}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,Hm),s=this.receiveCallbacksQueue.shift();s!=null?s.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=sy(e)?new ks:new qn}}}const Qm="freighterctx",ey=1e3,ty=1001,ry=[ey,ty],sy=r=>ry.includes(r.code),Ou=class xu extends ku{constructor(e,t,s=!1){super(),me(this,"baseUrl"),me(this,"encoder"),this.baseUrl=e.replace({protocol:s?"wss":"ws"}),this.encoder=t}async stream(e,t,s){const n=Gm();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=n(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=xu.MESSAGE_TYPE;const h=await this.wrapSocket(c,t,s);return h instanceof Error?[l,h]:(a=h,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const s=Vf({[Tu]:this.encoder.contentType,...t.params},Qm);return this.baseUrl.child(e).toString()+s}async wrapSocket(e,t,s){return await new Promise(n=>{e.onopen=()=>{n(new Xm(e,this.encoder,t,s))},e.onerror=a=>{const i=a;n(new Error(i.message))}})}};me(Ou,"MESSAGE_TYPE","arraybuffer");let ny=Ou;const Tt="sy.api.";var At=(r=>(r.General=Tt+"general",r.Parse=Tt+"parse",r.Auth=Tt+"auth",r.Unexpected=Tt+"unexpected",r.Validation=Tt+"validation",r.Query=Tt+"query",r.Route=Tt+"route",r))(At||{});class Kt extends Is{constructor(e){super(e,Tt)}}class Ae extends Kt{constructor(t){var e=(...D_)=>(super(...D_),d(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(s=>`${s.field}: ${s.message}`).join(`
12
- `)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class Nu extends Kt{}class Su extends Kt{}class $i extends Kt{}class or extends Kt{constructor(e){super(`
11
+ `).slice(0,-1).map(t=>e.parse(JSON.parse(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new bs(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===Ft?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===Ft?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const s=new e.Array(this.length);for(let n=0;n<this.length;n++)s[n]=Jm(this.dataType,e,this.data[n],t);return new Ee({data:s.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(te.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}else{const e=this.data;this._cachedMax=e.reduce((t,s)=>t>s?t:s)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),Ir(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(te.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}else{const e=this.data;this._cachedMin=e.reduce((t,s)=>t<s?t:s)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),Ir(this._cachedMin,this.sampleOffset))}get bounds(){return Ar(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return Ir(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const s=this.data[e];if(s==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return Ir(s,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let s=0,n=0;for(let i=0;i<this.data.length;i++)if(this.data[i]===10){if(e===0){n=i;break}s=i+1,e--}if(n===0&&(n=this.data.length),s>=n||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(s,n);return this.dataType.equals(te.STRING)?new TextDecoder().decode(a):JSON.parse(new TextDecoder().decode(a))}binarySearch(e){let t=0,s=this.length-1;const n=rf(e);for(;t<=s;){const a=Math.floor((t+s)/2),i=n(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:s=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(te.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:s,prevBuffer:n}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==n)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==Ft){n===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(n).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,s==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=Ft}as(e){if(e==="string"){if(!this.dataType.equals(te.STRING))throw new Error(`cannot convert series of type ${this.dataType.toString()} to string`);return this}if(e==="number"){if(!this.dataType.isNumeric)throw new Error(`cannot convert series of type ${this.dataType.toString()} to number`);return this}if(e==="bigint"){if(!this.dataType.equals(te.INT64))throw new Error(`cannot convert series of type ${this.dataType.toString()} to bigint`);return this}throw new Error(`cannot convert series to ${e}`)}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return Ar(this.alignment,this.alignment+this.length)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new Xm(this);return this.dataType.equals(te.JSON)?new Qm(e):e}return new ey(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const s=this.data.slice(e,t);return new Ee({data:s,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new Ee({data:this.buffer,dataType:this.dataType,timeRange:ze.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}}class Xm{constructor(e){if(p(this,"series"),p(this,"index"),p(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const s=this.index;return e===s?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,s))})}[Symbol.iterator](){return this}}var Ou;class Qm{constructor(e){p(this,"wrapped"),p(this,Ou,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:JSON.parse(e.value)}}[Symbol.iterator](){return this}}Ou=Symbol.toStringTag;var xu;class ey{constructor(e){p(this,"series"),p(this,"index"),p(this,xu,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}xu=Symbol.toStringTag;const Ir=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:e===0?r:r===0?e:Number(r)+Number(e);class Nu{constructor(e){if(p(this,"series"),e.length!==0){const t=e[0].dataType;for(let s=1;s<e.length;s++)if(!e[s].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new te(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?te.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?ze.ZERO:new ze(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const s of this.series){if(e<s.length)return s.at(e,t);e-=s.length}if(t)throw new Error(`[series] - no value at index ${e}`)}get byteLength(){return new bs(this.series.reduce((e,t)=>e+t.byteLength.valueOf(),0))}get data(){const e=new this.dataType.Array(this.length);let t=0;for(const s of this.series)e.set(s.data,t),t+=s.length;return new this.dataType.Array(e)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new ty(this.series)}}var Su;class ty{constructor(e){p(this,"series"),p(this,"seriesIndex"),p(this,"internal"),p(this,Su,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}Su=Symbol.toStringTag;const Ci=m.record(m.union([m.number(),m.string(),m.symbol()]),m.unknown()),Eu=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),ry=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";ry();const sy=["MacOS","Windows","Linux","Docker"];m.enum(sy);const ny=(r,e)=>{let t=null;return e===0?r:(...s)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...s),e)}},bo=r=>[...new Set(r)],ay=(...r)=>r.map(Zu).join(""),Zu=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),iy=r=>r.endsWith("/")?r.slice(0,-1):r;var lr;let oy=(lr=class{constructor({host:r,port:e,protocol:t="",pathPrefix:s=""}){p(this,"protocol"),p(this,"host"),p(this,"port"),p(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Zu(s)}replace(r){return new lr({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new lr({...this,pathPrefix:ay(this.path,r)})}toString(){return iy(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},p(lr,"UNKNOWN",new lr({host:"unknown",port:0})),lr);const re=r=>Array.isArray(r)?r:[r];class Iu{constructor(){p(this,"contentType","application/json"),p(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Un.toSnake(e),(s,n)=>ArrayBuffer.isView(n)?Array.from(n):Eu(n)&&"encode_value"in n?typeof n.value=="bigint"?n.value.toString():n.value:typeof n=="bigint"?n.toString():n);return new TextEncoder().encode(t)}decode(e,t){const s=Un.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(s):s}static registerCustomType(){}}const cy=[new Iu],Au=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:cy,JSONEncoderDecoder:Iu},Symbol.toStringTag,{value:"Module"}));class uy{constructor(e){p(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,s)=>s(e))}}const Bn=Object.freeze(Object.defineProperty({__proto__:null,Observer:uy},Symbol.toStringTag,{value:"Module"})),ly=m.string().regex(/^\d+\.\d+\.\d+$/);m.object({version:ly});const xr=u.z.number(),Zs=u.z.object({name:u.z.string(),key:u.z.number(),rate:sa.z,dataType:te.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),$u=Zs.extend({key:u.z.number().optional(),leaseholder:u.z.number().optional(),index:u.z.number().optional(),rate:sa.z.optional().default(0),isIndex:u.z.boolean().optional()}),dy=u.z.object({channels:$u.array()}),hy=u.z.object({channels:Zs.array()}),py=u.z.object({keys:xr.array().optional(),names:u.z.string().array().optional()}),fy=u.z.object({}),my="/channel/create",yy="/channel/delete";let Cu=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await $(this.client,my,{channels:e},dy,hy)).channels}async delete(e){await $(this.client,yy,e,py,fy)}};const gy=new Error("request for lock canceled");var vy=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(s.next(h))}catch(k){i(k)}}function c(h){try{l(s.throw(h))}catch(k){i(k)}}function l(h){h.done?a(h.value):n(h.value).then(o,c)}l((s=s.apply(r,e||[])).next())})};class wy{constructor(e,t=gy){this._value=e,this._cancelError=t,this._weightedQueues=[],this._weightedWaiters=[]}acquire(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,s)=>{this._weightedQueues[e-1]||(this._weightedQueues[e-1]=[]),this._weightedQueues[e-1].push({resolve:t,reject:s}),this._dispatch()})}runExclusive(e,t=1){return vy(this,void 0,void 0,function*(){const[s,n]=yield this.acquire(t);try{return yield e(s)}finally{n()}})}waitForUnlock(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),this._weightedWaiters[e-1].push(t),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatch()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatch()}cancel(){this._weightedQueues.forEach(e=>e.forEach(t=>t.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var e;for(let t=this._value;t>0;t--){const s=(e=this._weightedQueues[t-1])===null||e===void 0?void 0:e.shift();if(!s)continue;const n=this._value,a=t;this._value-=t,t=this._value+1,s.resolve([n,this._newReleaser(a)])}this._drainUnlockWaiters()}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){for(let e=this._value;e>0;e--)this._weightedWaiters[e-1]&&(this._weightedWaiters[e-1].forEach(t=>t()),this._weightedWaiters[e-1]=[])}}var _y=function(r,e,t,s){function n(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(h){try{l(s.next(h))}catch(k){i(k)}}function c(h){try{l(s.throw(h))}catch(k){i(k)}}function l(h){h.done?a(h.value):n(h.value).then(o,c)}l((s=s.apply(r,e||[])).next())})};class by{constructor(e){this._semaphore=new wy(1,e)}acquire(){return _y(this,void 0,void 0,function*(){const[,e]=yield this._semaphore.acquire();return e})}runExclusive(e){return this._semaphore.runExclusive(()=>e())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}const Ot="sy.api.";var Ct=(r=>(r.General=Ot+"general",r.Parse=Ot+"parse",r.Auth=Ot+"auth",r.Unexpected=Ot+"unexpected",r.Validation=Ot+"validation",r.Query=Ot+"query",r.Route=Ot+"route",r))(Ct||{});class Kt extends Ns{constructor(e){super(e,Ot)}}class Ze extends Kt{constructor(t){var e=(...yb)=>(super(...yb),d(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(s=>`${s.field}: ${s.message}`).join(`
12
+ `)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class ju extends Kt{}class Ru extends Kt{}class ji extends Kt{}class ar extends Kt{constructor(e){super(`
13
13
  Unexpected error encountered:
14
14
 
15
15
  ${e}
16
16
 
17
17
  Please report this to the Synnax team.
18
- `)}}class Ge extends Kt{}class ay extends Ge{}class iy extends Ge{}class Eu extends Kt{constructor(t,s){super(t);d(this,"path");this.path=s}}class oy extends Kt{}const cy=r=>{if(!r.type.startsWith(Tt))return null;switch(r.type){case At.General:return new Nu(r.data);case At.Parse:return new Su(r.data);case At.Auth:return new $i(r.data);case At.Unexpected:return new or(r.data);case At.Validation:return new Ae(r.data);case At.Query:return new Ge(r.data);case At.Route:return new Eu(r.data,r.data);default:return new or(r.data)}},uy=()=>{throw new Error("Not implemented")};bu({encode:uy,decode:cy});const ly=async(r,e)=>{const[t,s]=await e(r);return s==null?[t,s]:s instanceof Ts?[t,new Ts({message:`Cannot reach cluster at ${s.url.host}:${s.url.port}`,url:s.url})]:[t,s]},dy=u.z.object({leaseholder:u.z.number().optional(),keys:u.z.number().array().optional(),names:u.z.string().array().optional(),search:u.z.string().optional(),rangeKey:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional()}),hy=u.z.object({channels:Ss.array()}),Wn=class Wn{constructor(e){d(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,rangeKey:t})}async retrieve(e,t){const{variant:s,normalized:n}=Wt(e);return await this.execute({[s]:n,rangeKey:t})}async page(e,t,s){return await this.execute({offset:e,limit:t,rangeKey:s})}async execute(e){const[t,s]=await this.client.send(Wn.ENDPOINT,e,dy,hy);if(s!=null)throw s;return t.channels}};d(Wn,"ENDPOINT","/channel/retrieve");let Os=Wn;class ji{constructor(e){d(this,"cache");d(this,"namesToKeys");d(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t}=Wt(e),s=[],n=[];if(t.forEach(i=>{const o=this.getFromCache(i);o!=null?s.push(o):n.push(i)}),n.length===0)return s;const a=await this.wrapped.retrieve(n);return this.updateCache(a),s.concat(a)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}const Wt=r=>{let e=re(r).filter(s=>s!==0),t="keys";return typeof e[0]=="string"&&(isNaN(parseInt(e[0]))?t="names":e=e.map(s=>parseInt(s))),{single:!Array.isArray(r),variant:t,normalized:e,actual:r}};class Zu{constructor(e,t){d(this,"mu",new Mh);d(this,"requests",new Map);d(this,"wrapped");d(this,"debouncedRun");this.wrapped=e,this.debouncedRun=Nh(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t,variant:s}=Wt(e);return s==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,s)=>s.forEach(n=>e.add(n)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((s,n)=>s.resolve(t.filter(a=>n.includes(a.key))))}catch(t){this.requests.forEach(s=>s.reject(t))}finally{this.requests.clear()}})}}const Iu=async(r,e)=>{const{normalized:t}=Wt(e),s=await r.retrieve(t),n=[];if(t.forEach(a=>{s.find(i=>i.name===a||i.key===a)==null&&n.push(a)}),n.length>0)throw new Ge(`Could not find channels: ${JSON.stringify(n)}`);return s};class Ri{constructor({dataType:e,rate:t,name:s,leaseholder:n=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:c,alias:l}){d(this,"_frameClient");d(this,"key");d(this,"name");d(this,"rate");d(this,"dataType");d(this,"leaseholder");d(this,"index");d(this,"isIndex");d(this,"alias");this.key=a,this.name=s,this.rate=new Xn(t??0),this.dataType=new te(e),this.leaseholder=n,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new Ae("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Ss.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(this.key,e,t)}}let Au=class{constructor(e,t,s,n){d(this,"frameClient");d(this,"retriever");d(this,"creator");d(this,"client");this.frameClient=e,this.retriever=t,this.client=s,this.creator=n}async create(e,t={}){const{retrieveIfNameExists:s=!1}=t,n=!Array.isArray(e);let a=re(e),i=[];if(s){const o=await this.retriever.retrieve(a.map(l=>l.name)),c=new Set(o.map(l=>l.name));a=a.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.creator.create(a))),n?i[0]:i}async retrieve(e,t){const{single:s,actual:n,normalized:a}=Wt(e);if(a.length===0)return[];const i=this.sugar(await this.retriever.retrieve(e,t));if(!s)return i;if(i.length===0)throw new ay(`channel matching ${n} not found`);if(i.length>1)throw new iy(`multiple channels matching ${n} found`);return i[0]}async search(e,t){return this.sugar(await this.retriever.search(e,t))}newSearcherUnderRange(e){return new py(this,e)}async page(e,t,s){return this.sugar(await this.retriever.page(e,t,s))}createDebouncedBatchRetriever(e=10){return new ji(new Zu(new Os(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(s=>new Ri({...s,frameClient:t}))}};class py{constructor(e,t){d(this,"client");d(this,"rangeKey");this.client=e,this.rangeKey=t}async search(e){return await this.client.search(e,this.rangeKey)}async page(e,t){return await this.client.page(e,t,this.rangeKey)}async retrieve(e){return await this.client.retrieve(e,this.rangeKey)}}const fy=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:ji,Channel:Ri,Client:Au,ClusterRetriever:Os,Creator:kn,DebouncedBatchRetriever:Zu,analyzeParams:Wt,keyZ:Ns,newPayload:xc,parseChannels:Nc,payload:Ss,retrieveRequired:Iu},Symbol.toStringTag,{value:"Module"})),my=u.z.object({key:u.z.string(),username:u.z.string()}),yy=r=>async(e,t)=>{try{const s=await r();e.params.Authorization=`Bearer ${s}`}catch(s){return[e,s]}return await t(e)},gy=u.z.object({username:u.z.string(),password:u.z.string()}),vy=u.z.object({token:u.z.string(),user:my}),wy="/auth/login";let _y=class{constructor(e,t){d(this,"token");d(this,"client");d(this,"authenticating");d(this,"authenticated");d(this,"user");this.client=e,this.authenticated=!1,this.authenticate(t)}authenticate(e){this.authenticating=new Promise((t,s)=>{this.client.send(wy,e,gy,vy).then(([n,a])=>{if(a!=null)return s(a);this.token=n==null?void 0:n.token,this.user=n==null?void 0:n.user,this.authenticated=!0,t()}).catch(s)})}middleware(){return yy(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new $i("[auth] - attempting to authenticate without a token");return this.token})}};const by=["disconnected","connecting","connected","failed"],Cu=u.z.enum(by),$u=u.z.object({status:Cu,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),ky=u.z.object({clusterKey:u.z.string()}),wo={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},yr=class yr{constructor(e,t=ce.seconds(30),s){d(this,"_state");d(this,"pollFrequency",ce.seconds(30));d(this,"client");d(this,"name");d(this,"interval");d(this,"onChangeHandlers",[]);this._state={...wo},this.client=e,this.pollFrequency=t,this.name=s,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[s,n]=await this.client.send(yr.ENDPOINT,{},u.z.object({}),ky);if(n!=null)throw n;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=s.clusterKey}catch(s){this._state.status="failed",this._state.error=s,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(s=>s(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};d(yr,"ENDPOINT","/connectivity/check"),d(yr,"DEFAULT",wo),d(yr,"connectionStateZ",$u);let xs=yr;const Ty=Object.freeze(Object.defineProperty({__proto__:null,Checker:xs,state:$u,status:Cu},Symbol.toStringTag,{value:"Module"})),_o=r=>{const e=re(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},bo=(r,e)=>{const t=re(r);if(t.length===e.length)return;const s=_o(r);throw _o===null?new Ae("[Frame] - channel keys or names must be provided when constructing a frame."):new Ae(`[Frame] - ${s}s and arrays must be the same length.
19
- Got ${t.length} ${s}s and ${e.length} arrays.`)};class ye{constructor(e=[],t=[]){d(this,"columns",[]);d(this,"series",[]);if(e instanceof ye){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,a)=>this.push(a,...re(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e,a=n.series.map(i=>Ru(i));bo(n.keys,a),n.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([n,a])=>{const i=parseInt(n);if(isNaN(i))this.push(n,...re(a));else return this.push(i,...re(a))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=re(t),a=re(e);bo(a,n),n.forEach((i,o)=>this.push(a[o],i));return}throw new Ae(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
18
+ `)}}class Xe extends Kt{}class ky extends Xe{}class Ty extends Xe{}class zu extends Kt{constructor(t,s){super(t);d(this,"path");this.path=s}}class Oy extends Kt{}const xy=r=>{if(!r.type.startsWith(Ot))return null;switch(r.type){case Ct.General:return new ju(r.data);case Ct.Parse:return new Ru(r.data);case Ct.Auth:return new ji(r.data);case Ct.Unexpected:return new ar(r.data);case Ct.Validation:return new Ze(r.data);case Ct.Query:return new Xe(r.data);case Ct.Route:return new zu(r.data,r.data);default:return new ar(r.data)}},Ny=()=>{throw new Error("Not implemented")};Pc({encode:Ny,decode:xy});const Sy=async(r,e)=>{const[t,s]=await e(r);return s==null?[t,s]:s instanceof cs?[t,new cs({message:`Cannot reach cluster at ${s.url.host}:${s.url.port}`,url:s.url})]:[t,s]},Ey=u.z.object({leaseholder:u.z.number().optional(),keys:u.z.number().array().optional(),names:u.z.string().array().optional(),search:u.z.string().optional(),rangeKey:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional()}),Zy=u.z.object({channels:Zs.array()}),qn=class qn{constructor(e){d(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,rangeKey:t})}async retrieve(e,t){const{variant:s,normalized:n}=$t(e);return await this.execute({[s]:n,rangeKey:t})}async page(e,t,s){return await this.execute({offset:e,limit:t,rangeKey:s})}async execute(e){const[t,s]=await this.client.send(qn.ENDPOINT,e,Ey,Zy);if(s!=null)throw s;return t.channels}};d(qn,"ENDPOINT","/channel/retrieve");let ks=qn;class Ri{constructor(e){d(this,"cache");d(this,"namesToKeys");d(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t}=$t(e),s=[],n=[];if(t.forEach(i=>{const o=this.getFromCache(i);o!=null?s.push(o):n.push(i)}),n.length===0)return s;const a=await this.wrapped.retrieve(n);return this.updateCache(a),s.concat(a)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}const $t=r=>{let e=re(r).filter(s=>s!==0),t="keys";return typeof e[0]=="string"&&(isNaN(parseInt(e[0]))?t="names":e=e.map(s=>parseInt(s))),{single:!Array.isArray(r),variant:t,normalized:e,actual:r}};class Pu{constructor(e,t){d(this,"mu",new by);d(this,"requests",new Map);d(this,"wrapped");d(this,"debouncedRun");this.wrapped=e,this.debouncedRun=ny(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,s){return await this.wrapped.page(e,t,s)}async retrieve(e){const{normalized:t,variant:s}=$t(e);return s==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,s)=>s.forEach(n=>e.add(n)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((s,n)=>s.resolve(t.filter(a=>n.includes(a.key))))}catch(t){this.requests.forEach(s=>s.reject(t))}finally{this.requests.clear()}})}}const Mu=async(r,e)=>{const{normalized:t}=$t(e),s=await r.retrieve(t),n=[];if(t.forEach(a=>{s.find(i=>i.name===a||i.key===a)==null&&n.push(a)}),n.length>0)throw new Xe(`Could not find channels: ${JSON.stringify(n)}`);return s};class zi{constructor({dataType:e,rate:t,name:s,leaseholder:n=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:c,alias:l}){d(this,"_frameClient");d(this,"key");d(this,"name");d(this,"rate");d(this,"dataType");d(this,"leaseholder");d(this,"index");d(this,"isIndex");d(this,"alias");this.key=a,this.name=s,this.rate=new sa(t??0),this.dataType=new te(e),this.leaseholder=n,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new Ze("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Zs.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(e,this.key,t)}}let Du=class{constructor(e,t,s,n){d(this,"frameClient");d(this,"client");d(this,"retriever");d(this,"writer");this.frameClient=e,this.retriever=t,this.client=s,this.writer=n}async create(e,t={}){const{retrieveIfNameExists:s=!1}=t,n=!Array.isArray(e);let a=re(e),i=[];if(s){const o=await this.retriever.retrieve(a.map(l=>l.name)),c=new Set(o.map(l=>l.name));a=a.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.writer.create(a))),n?i[0]:i}async retrieve(e,t){const{single:s,actual:n,normalized:a}=$t(e);if(a.length===0)return[];const i=this.sugar(await this.retriever.retrieve(e,t));if(!s)return i;if(i.length===0)throw new ky(`channel matching ${n} not found`);if(i.length>1)throw new Ty(`multiple channels matching ${n} found`);return i[0]}async delete(e){const{normalized:t,variant:s}=$t(e);return s==="keys"?await this.writer.delete({keys:t}):await this.writer.delete({names:t})}async search(e,t){return this.sugar(await this.retriever.search(e,t))}newSearcherUnderRange(e){return new Iy(this,e)}async page(e,t,s){return this.sugar(await this.retriever.page(e,t,s))}createDebouncedBatchRetriever(e=10){return new Ri(new Pu(new ks(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(s=>new zi({...s,frameClient:t}))}};class Iy{constructor(e,t){d(this,"client");d(this,"rangeKey");this.client=e,this.rangeKey=t}async search(e){return await this.client.search(e,this.rangeKey)}async page(e,t){return await this.client.page(e,t,this.rangeKey)}async retrieve(e){return await this.client.retrieve(e,this.rangeKey)}}const Ay=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Ri,Channel:zi,Client:Du,ClusterRetriever:ks,DebouncedBatchRetriever:Pu,Writer:Cu,analyzeParams:$t,keyZ:xr,newPayload:$u,payload:Zs,retrieveRequired:Mu},Symbol.toStringTag,{value:"Module"})),$y=u.z.object({key:u.z.string(),username:u.z.string()}),Cy=r=>async(e,t)=>{try{const s=await r();e.params.Authorization=`Bearer ${s}`}catch(s){return[e,s]}return await t(e)},jy=u.z.object({username:u.z.string(),password:u.z.string()}),Ry=u.z.object({token:u.z.string(),user:$y}),zy="/auth/login";let Py=class{constructor(e,t){d(this,"token");d(this,"client");d(this,"authenticating");d(this,"authenticated");d(this,"user");this.client=e,this.authenticated=!1,this.authenticate(t)}authenticate(e){this.authenticating=new Promise((t,s)=>{this.client.send(zy,e,jy,Ry).then(([n,a])=>{if(a!=null)return s(a);this.token=n==null?void 0:n.token,this.user=n==null?void 0:n.user,this.authenticated=!0,t()}).catch(s)})}middleware(){return Cy(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new ji("[auth] - attempting to authenticate without a token");return this.token})}};const My=["disconnected","connecting","connected","failed"],Lu=u.z.enum(My),Uu=u.z.object({status:Lu,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),Dy=u.z.object({clusterKey:u.z.string()}),ko={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},fr=class fr{constructor(e,t=ce.seconds(30),s){d(this,"_state");d(this,"pollFrequency",ce.seconds(30));d(this,"client");d(this,"name");d(this,"interval");d(this,"onChangeHandlers",[]);this._state={...ko},this.client=e,this.pollFrequency=t,this.name=s,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[s,n]=await this.client.send(fr.ENDPOINT,{},u.z.object({}),Dy);if(n!=null)throw n;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=s.clusterKey}catch(s){this._state.status="failed",this._state.error=s,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(s=>s(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};d(fr,"ENDPOINT","/connectivity/check"),d(fr,"DEFAULT",ko),d(fr,"connectionStateZ",Uu);let Ts=fr;const Ly=Object.freeze(Object.defineProperty({__proto__:null,Checker:Ts,state:Uu,status:Lu},Symbol.toStringTag,{value:"Module"})),To=r=>{const e=re(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Oo=(r,e)=>{const t=re(r);if(t.length===e.length)return;const s=To(r);throw To===null?new Ze("[Frame] - channel keys or names must be provided when constructing a frame."):new Ze(`[Frame] - ${s}s and arrays must be the same length.
19
+ Got ${t.length} ${s}s and ${e.length} arrays.`)};class me{constructor(e=[],t=[]){d(this,"columns",[]);d(this,"series",[]);if(e instanceof me){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((n,a)=>this.push(a,...re(n)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const n=e,a=n.series.map(i=>Vu(i));Oo(n.keys,a),n.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([n,a])=>{const i=parseInt(n);if(isNaN(i))this.push(n,...re(a));else return this.push(i,...re(a))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const n=re(t),a=re(e);Oo(a,n),n.forEach((i,o)=>this.push(a[o],i));return}throw new Ze(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
20
20
  payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
21
- name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new or("colType is not key");return this.columns??[]}get uniqueKeys(){return ao(this.keys)}get names(){if(this.colType==="key")throw new or("colType is not name");return this.columns??[]}get uniqueNames(){return ao(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>zu(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return ze.ZERO;const s=J.min(...this.series.map(a=>a.timeRange.start)),n=J.max(...this.series.map(a=>a.timeRange.end));return new ze(s,n)}const t=this.get(e);return t==null?ze.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new wc(this.series.filter((t,s)=>this.columns[s]===e))}push(e,...t){if(e instanceof ye){if(this.colType!==null&&e.colType!==this.colType)throw new Ae("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new Ae("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new Ae("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new ye([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new ye;return this.forEach((s,n,a)=>t.push(...e(s,n,a))),t}forEach(e){this.columns.forEach((t,s)=>{const n=this.series[s];e(t,n,s)})}at(e,t=!1){const s={};return this.uniqueColumns.forEach(n=>{s[n]=this.get(n).at(e,t)}),s}filter(e){const t=new ye;return this.columns.forEach((s,n)=>{const a=this.series[n];e(s,a,n)&&t.push(s,a)}),t}get byteLength(){return new _n(this.series.reduce((e,t)=>e.add(t.byteLength),_n.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const ju=u.z.object({timeRange:ze.z.optional(),alignment:u.z.number().optional(),dataType:te.z,data:u.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),ia=u.z.object({keys:u.z.union([u.z.null().transform(()=>[]),u.z.number().array().optional().default([])]),series:u.z.union([u.z.null().transform(()=>[]),ju.array().optional().default([])])}),Ru=r=>{const{dataType:e,data:t,timeRange:s,alignment:n}=r;return new vr({data:t,dataType:e,timeRange:s,glBufferUsage:"static",alignment:n})},zu=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class oa{constructor(e){d(this,"adapter");d(this,"retriever");d(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const s=new oa(e);return await s.update(t),s}async update(e){const{variant:t,normalized:s}=Wt(e);if(t==="keys"){this.adapter=null,this.keys=s;return}const n=await this.retriever.retrieve(s),a=new Map;this.adapter=a,s.forEach(i=>{const o=n.find(c=>c.name===i);if(o==null)throw new Error(`Channel ${i} not found`);a.set(o.key,o.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((s,n)=>{if(typeof s=="number"){const a=t.get(s);if(a==null)throw new Error(`Channel ${s} not found`);return[a,n]}return[s,n]})}}class zi{constructor(e){d(this,"adapter");d(this,"retriever");d(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const s=new zi(e);return await s.update(t),s}async update(e){const t=await Iu(this.retriever,e);this.adapter=new Map(t.map(s=>[s.name,s.key])),this.keys=t.map(s=>s.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new Ae(`
21
+ name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new ar("colType is not key");return this.columns??[]}get uniqueKeys(){return bo(this.keys)}get names(){if(this.colType==="key")throw new ar("colType is not name");return this.columns??[]}get uniqueNames(){return bo(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>qu(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return ze.ZERO;const s=G.min(...this.series.map(a=>a.timeRange.start)),n=G.max(...this.series.map(a=>a.timeRange.end));return new ze(s,n)}const t=this.get(e);return t==null?ze.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Nu(this.series.filter((t,s)=>this.columns[s]===e))}push(e,...t){if(e instanceof me){if(this.colType!==null&&e.colType!==this.colType)throw new Ze("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new Ze("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new Ze("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new me([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new me;return this.forEach((s,n,a)=>t.push(...e(s,n,a))),t}forEach(e){this.columns.forEach((t,s)=>{const n=this.series[s];e(t,n,s)})}at(e,t=!1){const s={};return this.uniqueColumns.forEach(n=>{s[n]=this.get(n).at(e,t)}),s}filter(e){const t=new me;return this.columns.forEach((s,n)=>{const a=this.series[n];e(s,a,n)&&t.push(s,a)}),t}get byteLength(){return new bs(this.series.reduce((e,t)=>e.add(t.byteLength),bs.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const Bu=u.z.object({timeRange:ze.z.optional(),alignment:u.z.number().optional(),dataType:te.z,data:u.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),na=u.z.object({keys:u.z.union([u.z.null().transform(()=>[]),u.z.number().array().optional().default([])]),series:u.z.union([u.z.null().transform(()=>[]),Bu.array().optional().default([])])}),Vu=r=>{const{dataType:e,data:t,timeRange:s,alignment:n}=r;return new Ee({data:t,dataType:e,timeRange:s,glBufferUsage:"static",alignment:n})},qu=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class aa{constructor(e){d(this,"adapter");d(this,"retriever");d(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const s=new aa(e);return await s.update(t),s}async update(e){const{variant:t,normalized:s}=$t(e);if(t==="keys"){this.adapter=null,this.keys=s;return}const n=await this.retriever.retrieve(s),a=new Map;this.adapter=a,s.forEach(i=>{const o=n.find(c=>c.name===i);if(o==null)throw new Error(`Channel ${i} not found`);a.set(o.key,o.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((s,n)=>{if(typeof s=="number"){const a=t.get(s);if(a==null)throw new Error(`Channel ${s} not found`);return[a,n]}return[s,n]})}}class Pi{constructor(e){d(this,"adapter");d(this,"retriever");d(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const s=new Pi(e);return await s.update(t),s}async update(e){const t=await Mu(this.retriever,e);this.adapter=new Map(t.map(s=>[s.name,s.key])),this.keys=t.map(s=>s.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new Ze(`
22
22
  Received a single channel name or key but no series.
23
- `);if(Array.isArray(t)){if(t.length>1)throw new Ae(`
23
+ `);if(Array.isArray(t)){if(t.length>1)throw new Ze(`
24
24
  Received a single channel name or key but multiple series.
25
- `);t=t[0]}const i=await this.fetchChannel(e),o=new vr({data:t,dataType:i.dataType});return new ye(i.key,o)}if(Array.isArray(e)){if(t==null)throw new Ae(`
25
+ `);t=t[0]}const i=await this.fetchChannel(e),o=new Ee({data:t,dataType:i.dataType});return new me(i.key,o)}if(Array.isArray(e)){if(t==null)throw new Ze(`
26
26
  Received an array of channel names or keys but no series.
27
- `);if(!Array.isArray(t))throw new Ae(`
27
+ `);if(!Array.isArray(t))throw new Ze(`
28
28
  Received an array of channel names or keys but no array of series.
29
- `);const i=[],o=[];for(let c=0;c<e.length;c++){const l=await this.fetchChannel(e[c]);if(c>=t.length)throw new Ae(`
29
+ `);const i=[],o=[];for(let c=0;c<e.length;c++){const l=await this.fetchChannel(e[c]);if(c>=t.length)throw new Ze(`
30
30
  Received an array of channel names or keys but not enough series.
31
- `);const h=new vr({data:t[c],dataType:l.dataType});i.push(l.key),o.push(h)}return new ye(i,o)}if(e instanceof ye||e instanceof Map){const i=new ye(e);if(this.adapter==null)return i;let o=[];return o=i.columns.map(c=>{var h;const l=typeof c=="string"?(h=this.adapter)==null?void 0:h.get(c):c;if(l==null)throw new Ae(`
31
+ `);const h=new Ee({data:t[c],dataType:l.dataType});i.push(l.key),o.push(h)}return new me(i,o)}if(e instanceof me||e instanceof Map){const i=new me(e);if(this.adapter==null)return i;let o=[];return o=i.columns.map(c=>{var h;const l=typeof c=="string"?(h=this.adapter)==null?void 0:h.get(c):c;if(l==null)throw new Ze(`
32
32
  Channel ${c} was not provided in the list of channels when opening the writer
33
- `);return l}),new ye(o,i.series)}const s=[],n=[],a=Object.entries(e);for(let i=0;i<a.length;i++){const[o,c]=a[i],l=await this.fetchChannel(o),h=new vr({data:c,dataType:l.dataType});s.push(l.key),n.push(h)}return new ye(s,n)}}class Pi{constructor(e,t){d(this,"name");d(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){this.stream.closeSend();const[e,t]=await this.stream.receive();if(e!=null)throw new or(`${this.name} received unexpected response on closure.
34
- Please report this error to the Synnax team.`);if(t==null)throw new or(`${this.name} received unexpected null error on closure.
33
+ `);return l}),new me(o,i.series)}const s=[],n=[],a=Object.entries(e);for(let i=0;i<a.length;i++){const[o,c]=a[i],l=await this.fetchChannel(o),h=new Ee({data:c,dataType:l.dataType});s.push(l.key),n.push(h)}return new me(s,n)}}class Mi{constructor(e,t){d(this,"name");d(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){this.stream.closeSend();const[e,t]=await this.stream.receive();if(e!=null)throw new ar(`${this.name} received unexpected response on closure.
34
+ Please report this error to the Synnax team.`);if(t==null)throw new ar(`${this.name} received unexpected null error on closure.
35
35
  Please report this error to Synnax team.
36
- `);if(!(t instanceof ks))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Qa=new ce(-1);var Mi=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(Mi||{}),Pu=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(Pu||{});const Oy=u.z.object({command:u.z.nativeEnum(Mi),span:ce.z.optional(),bounds:ze.z.optional(),stamp:J.z.optional(),keys:u.z.number().array().optional()}),xy=u.z.object({variant:u.z.nativeEnum(Pu),ack:u.z.boolean(),command:u.z.nativeEnum(Mi),error:As.optional().nullable(),frame:ia.optional()}),Pr=class Pr{constructor(e,t){d(this,"stream");d(this,"adapter");d(this,"value");this.stream=new Pi("Iterator",e),this.value=new ye,this.adapter=t}static async _open(e,t,s,n){const a=await oa.open(s,t),i=await n.stream(Pr.ENDPOINT,Oy,xy),o=new Pr(i,a);return await o.execute({command:0,keys:a.keys,bounds:e}),o}async next(e=Qa){return await this.execute({command:1,span:new ce(e)})}async prev(e=Qa){return await this.execute({command:2,span:new ce(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new J(e)})}async seekGE(e){return await this.execute({command:6,stamp:new J(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Ny(this)}async execute(e){for(this.stream.send(e),this.value=new ye;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new ye(t.frame)))}}};d(Pr,"ENDPOINT","/frame/iterate");let Vn=Pr;class Ny{constructor(e){d(this,"iter");d(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Sy=u.z.object({start:J.z.optional(),keys:u.z.number().array()}),Ey=u.z.object({frame:ia,error:As.optional().nullable()}),Zy="/frame/stream";class ca{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new Pi("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:s,from:n}){const a=await oa.open(e,s),i=await t.stream(Zy,Sy,Ey),o=new ca(i,a);return i.send({start:new J(n),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new ye((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}const Ct=class Ct extends Number{};d(Ct,"Absolute",255),d(Ct,"Default",1),d(Ct,"z",u.z.union([u.z.instanceof(Ct),u.z.number().int().min(0).max(255).transform(e=>new Ct(e)),u.z.instanceof(Number).transform(e=>new Ct(e))]));let cr=Ct;const Di=u.z.object({name:u.z.string(),key:u.z.string()}),Iy=u.z.object({subject:Di,resource:u.z.number(),authority:cr.z}),Ay=(...r)=>e=>e.filter(t=>{let s=!1;return t.to!=null&&(s=r.includes(t.to.resource)),t.from!=null&&!s&&(s=r.includes(t.from.resource)),s}),Cy=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Li{constructor(e){d(this,"states");d(this,"streamer");d(this,"ecd");d(this,"observer");d(this,"closePromise");this.states=new Map,this.ecd=new Oc.JSONEncoderDecoder,this.observer=new bn.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.openStreamer("sy_node_1_control");return new Li(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var Ui=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r[r.SetMode=5]="SetMode",r))(Ui||{}),ua=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(ua||{});const $y=u.z.object({start:J.z.optional(),controlSubject:Di.optional(),keys:u.z.number().array().optional(),authorities:cr.z.array().optional(),mode:u.z.nativeEnum(ua).optional()}),jy=u.z.object({command:u.z.nativeEnum(Ui),config:$y.optional(),frame:ia.optional()}),Ry=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum(Ui),error:As.optional().nullable()});var Xt;let Mu=(Xt=class{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new Pi("Writer",e),this.adapter=t}static async _open(e,t,{channels:s,start:n=J.now(),authorities:a=cr.Absolute,controlSubject:i,mode:o=1}){const c=await zi.open(e,s),l=await t.stream(Xt.ENDPOINT,jy,Ry),h=new Xt(l,c);return await h.execute({command:0,config:{start:new J(n),keys:c.keys,controlSubject:i,authorities:re(a),mode:o}}),h}async write(e,t){const s=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:s.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(s=>Number(s)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?Ci(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},d(Xt,"ENDPOINT","/frame/write"),Xt),Du=class{constructor(e,t){d(this,"stream");d(this,"retriever");this.stream=e,this.retriever=t}async openIterator(e,t){return await Vn._open(e,t,this.retriever,this.stream)}async openWriter(e){return await Mu._open(this.retriever,this.stream,e)}async openStreamer(e){const t=typeof e=="object";return(Array.isArray(e)||!t)&&(e={channels:e}),await ca._open(this.retriever,this.stream,e)}async write(e,t,s){const n=await this.openWriter({start:t,channels:e,mode:ua.PersistOnly});try{await n.write(e,s),await n.commit()}finally{await n.close()}}async read(e,t){const{single:s}=Wt(t),n=await this.readFrame(e,t);return s?n.series[0]:n}async readFrame(e,t){const s=await this.openIterator(e,t),n=new ye;try{for await(const a of s)n.push(a)}finally{await s.close()}return n}};const zy=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Qa,Client:Du,Frame:ye,Iterator:Vn,Streamer:ca,Writer:Mu,WriterMode:ua,frameZ:ia,series:ju,seriesFromPayload:Ru,seriesToPayload:zu},Symbol.toStringTag,{value:"Module"}));let Lu=class{constructor(e,t,s){d(this,"tasks");d(this,"racks");d(this,"devices");this.tasks=e,this.racks=t,this.devices=s}};const Py=Object.freeze(Object.defineProperty({__proto__:null,Client:Lu},Symbol.toStringTag,{value:"Module"})),Cs=u.z.number(),Bi=u.z.object({key:Cs,name:u.z.string()}),My=Bi.partial({key:!0}),qi=u.z.string(),la=u.z.object({key:qi,rack:Cs,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class $s{constructor(e,t,s,n){d(this,"streamer");d(this,"decoder");d(this,"base");d(this,"closePromise");d(this,"deleteChannel");d(this,"setChannel");this.streamer=e,this.decoder=t,this.base=new bn.Observer,this.closePromise=this.stream(),this.deleteChannel=n,this.setChannel=s}onChange(e){return this.base.onChange(e)}async close(){return this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer){const t=[];if(this.deleteChannel!=null){const s=e.get(this.deleteChannel);t.push(...s.series.flatMap(n=>this.decoder("delete",n)))}if(this.setChannel!=null){const s=e.get(this.setChannel);t.push(...s.series.flatMap(n=>this.decoder("set",n)))}this.base.notify(t)}}static async open(e,t,s,n){const a=await e.openStreamer([t,s]);return new $s(a,n,t,s)}}const Dy="sy_device_set",Ly="sy_device_delete";let Uu=class{constructor(e,t,s){d(this,"retriever");d(this,"writer");d(this,"frameClient");this.retriever=e,this.writer=t,this.frameClient=s}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t=await this.retriever.retrieve(re(e));return Array.isArray(e)?t:t[0]}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async delete(e){await this.writer.delete(e)}async openDeviceTracker(){return await $s.open(this.frameClient,Dy,Ly,Uy)}};const Uy=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(la).map(t=>({variant:r,key:t.key,value:t})),ka="/hardware/device/retrieve",Ta=u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:qi.array().optional()}),Oa=u.z.object({devices:la.array()});let Bu=class{constructor(e){d(this,"client");this.client=e}async search(e){return(await C(this.client,ka,{keys:[e]},Ta,Oa)).devices}async page(e,t){return(await C(this.client,ka,{offset:e,limit:t},Ta,Oa)).devices}async retrieve(e){return(await C(this.client,ka,{keys:e},Ta,Oa)).devices}};const By="/hardware/device/create",qy="/hardware/device/delete",Vy=u.z.object({devices:la.array()}),Ky=u.z.object({devices:la.array()}),Wy=u.z.object({keys:qi.array()}),Fy=u.z.object({});let qu=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,By,{devices:e},Vy,Ky)).devices}async delete(e){await C(this.client,qy,{keys:e},Wy,Fy)}};const Yy=Object.freeze(Object.defineProperty({__proto__:null,Client:Uu,Retriever:Bu,Writer:qu},Symbol.toStringTag,{value:"Module"}));let Vu=class{constructor(e,t,s,n,a){d(this,"retriever");d(this,"writer");d(this,"frameClient");d(this,"taskWriter");d(this,"taskRetriever");this.retriever=e,this.writer=t,this.frameClient=s,this.taskWriter=n,this.taskRetriever=a}async create(e){const t=await this.writer.create([e]);return this.sugar(t)[0]}async search(e){const t=await this.retriever.search(e);return this.sugar(t)}async page(e,t){const s=await this.retriever.page(e,t);return this.sugar(s)}async retrieve(e){const t=await this.retriever.retrieve(re(e));return Array.isArray(e)?this.sugar(t):this.sugar(t)[0]}sugar(e){return e.map(t=>new Ku(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Ku{constructor(e,t,s,n){d(this,"key");d(this,"name");d(this,"writer");d(this,"tasks");this.key=e,this.name=t,this.writer=s,this.tasks=n}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async retrieveTasks(){return[]}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),(await this.writer.create([e]))[0]}async deleteTask(e){await this.writer.delete([e])}}const Jy="/hardware/rack/create",Gy="/hardware/rack/delete",Hy=u.z.object({racks:My.array()}),Xy=u.z.object({racks:Bi.array()}),Qy=u.z.object({keys:Cs.array()}),eg=u.z.object({});let Wu=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Jy,{racks:e},Hy,Xy)).racks}async delete(e){await C(this.client,Gy,{keys:e},Qy,eg)}};const xa="/hardware/rack/retrieve",Na=u.z.object({keys:Cs.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Sa=u.z.object({racks:Bi.array()});let Fu=class{constructor(e){d(this,"client");this.client=e}async page(e,t){return(await C(this.client,xa,{offset:e,limit:t},Na,Sa)).racks}async search(e){return(await C(this.client,xa,{search:e},Na,Sa)).racks}async retrieve(e){return(await C(this.client,xa,{keys:e},Na,Sa)).racks}};const tg=Object.freeze(Object.defineProperty({__proto__:null,Client:Vu,Rack:Ku,Retriever:Fu,Writer:Wu},Symbol.toStringTag,{value:"Module"}));let Yu=class{constructor(e,t){d(this,"retriever");d(this,"writer");this.retriever=e,this.writer=t}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t={};let s=!0;typeof e=="number"?t.rack=e:typeof e=="string"?(s=!1,t.keys=[e]):t.keys=re(e);const n=await this.retriever.retrieve(t);return s?n:n[0]}};const Vi=u.z.union([u.z.string(),u.z.bigint().transform(r=>r.toString()),u.z.number().transform(r=>r.toString())]),Ki=u.z.object({key:Vi,name:u.z.string(),type:u.z.string(),config:u.z.record(u.z.unknown()).or(u.z.string().transform(r=>JSON.parse(r)))}),rg=Ki.omit({key:!0}).extend({key:Vi.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))}),Ea=u.z.object({rack:Cs.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Za=u.z.object({tasks:u.z.union([Ki.array(),u.z.null().transform(()=>[])])}),Ia="/hardware/task/retrieve";let Ju=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){return(await C(this.client,Ia,e,Ea,Za)).tasks}async search(e){return(await C(this.client,Ia,{keys:[e]},Ea,Za)).tasks}async page(e,t){return(await C(this.client,Ia,{offset:e,limit:t},Ea,Za)).tasks}};const sg="/hardware/task/create",ng="/hardware/task/delete",ag=u.z.object({tasks:rg.array()}),ig=u.z.object({tasks:Ki.array()}),og=u.z.object({keys:Vi.array()}),cg=u.z.object({});let Gu=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,sg,{tasks:e},ag,ig)).tasks}async delete(e){await C(this.client,ng,{keys:e},og,cg)}};const ug=Object.freeze(Object.defineProperty({__proto__:null,Client:Yu,Retriever:Ju,Writer:Gu},Symbol.toStringTag,{value:"Module"}));class lg{constructor(e,t){d(this,"key");d(this,"name");this.key=t,this.name=e}get ontologyID(){return new _e({type:"group",key:this.key})}}const dg=u.z.string().uuid(),hg=u.z.object({key:dg,name:u.z.string()}),Hu=u.z.union([u.z.literal("label"),u.z.literal("builtin"),u.z.literal("cluster"),u.z.literal("channel"),u.z.literal("node"),u.z.literal("group"),u.z.literal("range"),u.z.literal("range-alias"),u.z.literal("user"),u.z.literal("workspace"),u.z.literal("pid"),u.z.literal("lineplot"),u.z.literal("rack")]),We=u.z.object({type:Hu,key:u.z.string()}),Xu=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),Qu=u.z.union([Xu,We]),gr=class gr{constructor(e){d(this,"type");d(this,"key");if(e instanceof gr)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,s]=e.split(":");this.type=t,this.key=s}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};d(gr,"z",u.z.union([Qu,u.z.instanceof(gr)]).transform(e=>new gr(e)));let _e=gr;const pg=new _e({type:"builtin",key:"root"}),el=u.z.object({type:u.z.number()}),tl=u.z.object({type:Hu,fields:u.z.record(el)}),rl=u.z.object({id:_e.z,name:u.z.string(),schema:tl.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),fg=u.z.object({from:_e.z,type:u.z.string(),to:_e.z}),ei=r=>{const[e,t,s]=r.split("->");return{from:new _e(e),type:t,to:new _e(s)}},mg=u.z.object({group:hg}),yg=u.z.object({parent:We,name:u.z.string()}),gg=u.z.object({key:u.z.string(),name:u.z.string()}),vg=u.z.object({keys:u.z.array(u.z.string())});var rt;let wg=(rt=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const[s,n]=await this.client.send(rt.ENDPOINT,{parent:e,name:t},yg,mg);if(n!=null)throw n;return s.group}async rename(e,t){const s={key:e,name:t},[,n]=await this.client.send(rt.ENDPOINT_RENAME,s,gg,u.z.object({}));if(n!=null)throw n}async delete(e){const t={keys:e},[,s]=await this.client.send(rt.ENDPOINT_DELETE,t,vg,u.z.object({}));if(s!=null)throw s}},d(rt,"ENDPOINT","/ontology/create-group"),d(rt,"ENDPOINT_RENAME","/ontology/rename-group"),d(rt,"ENDPOINT_DELETE","/ontology/delete-group"),rt),_g=class{constructor(e){d(this,"creator");this.creator=new wg(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new lg(e.name,e.key)}};const bg=u.z.object({ids:We.array().optional(),children:u.z.boolean().optional(),parents:u.z.boolean().optional(),includeSchema:u.z.boolean().optional(),includeFieldData:u.z.boolean().optional(),term:u.z.string().optional()}),kg=u.z.object({resources:rl.array()});var br;let Tg=(br=class{constructor(e){d(this,"client");this.client=e}async search(e){return await this.execute({term:e})}async retrieve(e,t=!0,s=!0){return await this.execute({ids:re(e).map(n=>new _e(n).payload),includeFieldData:s,includeSchema:t})}async retrieveChildren(e,t=!0,s=!0){return await this.execute({ids:re(e).map(n=>new _e(n).payload),children:!0,includeSchema:t,includeFieldData:s})}async retrieveParents(e,t=!0,s=!0){return await this.execute({ids:re(e).map(n=>new _e(n).payload),parents:!0,includeSchema:t,includeFieldData:s})}async execute(e){return(await C(this.client,br.ENDPOINT,e,bg,kg)).resources}},d(br,"ENDPOINT","/ontology/retrieve"),br);const Aa={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},ko=u.z.object({id:We,children:We.array()}),Og=u.z.object({from:We,to:We,children:We.array()});let xg=class{constructor(e){d(this,"client");this.client=e}async addChildren(e,...t){await C(this.client,Aa.ADD_CHILDREN,{id:e,children:t},ko,u.z.object({}))}async removeChildren(e,...t){await C(this.client,Aa.REMOVE_CHILDREN,{id:e,children:t},ko,u.z.object({}))}async moveChildren(e,t,...s){const n={from:e,to:t,children:s};await C(this.client,Aa.MOVE_CHILDREN,n,Og,u.z.object({}))}};const To="sy_ontology_resource_set",Oo="sy_ontology_resource_delete",xo="sy_ontology_relationship_set",No="sy_ontology_relationship_delete";class da{constructor(e,t){d(this,"resourceObs");d(this,"relationshipObs");d(this,"relationships");d(this,"resources");d(this,"streamer");d(this,"retriever");d(this,"closePromise");this.relationshipObs=new bn.Observer,this.relationships=this.relationshipObs,this.resourceObs=new bn.Observer,this.resources=this.resourceObs,this.retriever=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),s=this.parseResourceDeletes(e);t.concat(s).length>0&&this.resourceObs.notify(t.concat(s));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(xo);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"set",key:ei(s),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(No);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:ei(s)}))}async parseResourceSets(e){const t=e.get(To);if(t.length===0)return[];const s=Array.from(t.as("string")).map(n=>new _e(n));try{return(await this.retriever.retrieve(s)).map(a=>({variant:"set",key:a.id,value:a}))}catch(n){if(n instanceof Ge)return console.warn(n),[];throw n}}parseResourceDeletes(e){const t=e.get(Oo);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:new _e(s)}))}static async open(e,t){const s=await e.openStreamer([To,Oo,xo,No]);return new da(s,t)}}let sl=class{constructor(e,t){d(this,"groups");d(this,"retriever");d(this,"writer");d(this,"framer");this.retriever=new Tg(e),this.writer=new xg(e),this.groups=new _g(e),this.framer=t}async search(e){return await this.retriever.search(e)}async retrieve(e,t,s){const n=await this.retriever.retrieve(e,t,s);if(Array.isArray(e))return n;if(n.length===0)throw new Ge(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t){return[]}async retrieveChildren(e,t,s){return await this.retriever.retrieveChildren(e,t,s)}async retrieveParents(e,t,s){return await this.retriever.retrieveParents(e,t,s)}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...s){return await this.writer.moveChildren(e,t,...s)}async openChangeTracker(){return await da.open(this.framer,this.retriever)}};const Ng=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:da,Client:sl,ID:_e,Root:pg,crudeIDZ:Qu,idZ:We,parseRelationship:ei,relationshipSchemaZ:fg,resourceSchemaZ:rl,schemaFieldZ:el,schemaZ:tl,stringIDZ:Xu},Symbol.toStringTag,{value:"Module"})),Ir=u.z.string().uuid(),js=u.z.object({key:Ir,name:u.z.string().min(1),color:u.z.string()}),Sg=r=>new _e({type:"label",key:r}),Eg=u.z.object({keys:Ir.array().optional(),for:We.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Zg=u.z.object({labels:js.array().optional().default([])});var kr;let nl=(kr=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=re(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,s]=await this.client.send(kr.ENDPOINT,e,Eg,Zg);if(s!=null)throw s;return t.labels}},d(kr,"ENDPOINT","/label/retrieve"),kr);const al=js.extend({key:Ir.optional()}),Ig=u.z.object({labels:al.array()}),Ag=u.z.object({labels:js.array()}),Cg=u.z.object({keys:Ir.array()}),il=u.z.object({id:We,labels:Ir.array()}),$g=il,Ca=u.z.object({}),jg="/label/create",Rg="/label/delete",zg="/label/set",Pg="/label/remove";let ol=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,jg,{labels:re(e)},Ig,Ag)).labels}async delete(e){await C(this.client,Rg,{keys:re(e)},Cg,Ca)}async set(e,t){await C(this.client,zg,{id:e,labels:t},il,Ca)}async remove(e,t){await C(this.client,Pg,{id:e,labels:t},$g,Ca)}};const Mg="sy_label_set",Dg="sy_label_delete";let cl=class{constructor(e,t){d(this,"retriever");d(this,"writer");d(this,"frameClient");this.writer=new ol(e),this.retriever=new nl(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),s=await this.writer.create(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await $s.open(this.frameClient,Mg,Dg,Lg)}};const Lg=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(js).map(t=>({variant:r,key:t.key,value:t})),Ug=Object.freeze(Object.defineProperty({__proto__:null,Client:cl,Retriever:nl,Writer:ol,keyZ:Ir,labelZ:js,newLabelPayloadZ:al,ontologyID:Sg},Symbol.toStringTag,{value:"Module"})),Se=u.z.string().uuid(),Rs=u.z.object({key:Se,name:u.z.string().min(1),timeRange:ze.z}),ul=Rs.extend({key:u.z.string().uuid().optional()}),Wi=r=>{const e=re(r);if(e.length===0)throw new Error("Range params must not be empty");const t=Se.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},Bg=u.z.object({}),qg=u.z.object({range:Rs}),Vg=u.z.object({range:Se}),Kg=u.z.object({range:Se}),Wg=u.z.object({}),Fg="/range/set-active",Yg="/range/retrieve-active",Jg="/range/clear-active";class Gg{constructor(e){d(this,"client");this.client=e}async setActive(e){await C(this.client,Fg,{range:e},Vg,Bg)}async retrieveActive(){const[e,t]=await this.client.send(Yg,{},u.z.object({}),qg);if(t instanceof Ge)return null;if(t!=null)throw t;return e.range}async clearActive(e){await C(this.client,Jg,{range:e},Kg,Wg)}}const Hg="sy_range_alias_set",Xg="sy_range_alias_delete",Qg=u.z.object({range:Se,aliases:u.z.string().array()}),ev=u.z.object({aliases:u.z.record(u.z.string(),Ns)}),tv=u.z.object({range:Se,aliases:u.z.record(Ns.or(u.z.string()),u.z.string())}),rv=u.z.unknown(),sv=u.z.object({range:Se,channels:Ns.array()}),nv=u.z.unknown(),av=u.z.object({range:Se}),iv=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),tt=class tt{constructor(e,t,s){d(this,"frameClient");d(this,"cache",new Map);d(this,"client");d(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=s,this.frameClient=t}async resolve(e){const t=[],s=typeof e=="string",n={};if(s){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?n[i]=o:t.push(i)});if(t.length===0)return n;const a=await C(this.client,tt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},Qg,ev);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),s?a.aliases[t[0]]:{...n,...a.aliases}}async set(e){await C(this.client,tt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},tv,rv)}async list(){return(await C(this.client,tt.LIST_ENDPOINT,{range:this.rangeKey},av,iv)).aliases}async delete(e){await C(this.client,tt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},sv,nv)}async openChangeTracker(){return await $s.open(this.frameClient,Hg,Xg,uv(this.rangeKey))}};d(tt,"SET_ENDPOINT","/range/alias/set"),d(tt,"RESOLVE_ENDPOINT","/range/alias/resolve"),d(tt,"LIST_ENDPOINT","/range/alias/list"),d(tt,"DELETE_ENDPOINT","/range/alias/delete");let ti=tt;const ov=u.z.object({range:Se,channel:Ns,alias:u.z.string()}),cv="---",uv=r=>(e,t)=>e==="delete"?t.toStrings().filter(s=>s.split(cv)[0]===r).map(s=>({variant:e,key:s,value:void 0})):t.parseJSON(ov).map(s=>({variant:e,key:s.alias,value:s})),lv=u.z.object({range:Se,keys:u.z.string().array()}),dv=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())}),hv=u.z.object({range:Se,pairs:u.z.record(u.z.string(),u.z.string())}),pv=u.z.object({range:Se,keys:u.z.string().array()}),$t=class $t{constructor(e,t){d(this,"rangeKey");d(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,s]=await this.client.send($t.GET_ENDPOINT,{range:this.rangeKey,keys:re(e)},lv,dv);if(s!=null)throw s;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await C(this.client,$t.SET_ENDPOINT,{range:this.rangeKey,pairs:bc(e)?e:{[e]:t}},hv,u.z.unknown())}async delete(e){await C(this.client,$t.DELETE_ENDPOINT,{range:this.rangeKey,keys:re(e)},pv,u.z.unknown())}};d($t,"GET_ENDPOINT","/range/kv/get"),d($t,"SET_ENDPOINT","/range/kv/set"),d($t,"DELETE_ENDPOINT","/range/kv/delete");let ri=$t;const $a=r=>new _e({type:"range",key:r});class ll{constructor(e,t=ze.ZERO,s,n,a,i,o,c){d(this,"key");d(this,"name");d(this,"kv");d(this,"timeRange");d(this,"channels");d(this,"aliaser");d(this,"frameClient");d(this,"labelClient");this.key=s,this.name=e,this.timeRange=t,this.frameClient=n,this.kv=a,this.aliaser=i,this.channels=o,this.labelClient=c}async setAlias(e,t){const s=await this.channels.retrieve(e);if(s.length===0)throw new Ge(`Channel ${e} does not exist`);await this.aliaser.set({[s[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor($a(this.key))}async addLabel(...e){await this.labelClient.label($a(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels($a(this.key),e)}}let dl=class{constructor(e,t,s,n,a,i){d(this,"frameClient");d(this,"retriever");d(this,"writer");d(this,"unaryClient");d(this,"channels");d(this,"active");d(this,"labelClient");this.frameClient=e,this.retriever=t,this.writer=s,this.unaryClient=n,this.channels=a,this.active=new Gg(n),this.labelClient=i}async create(e){const t=!Array.isArray(e),s=this.sugar(await this.writer.create(re(e)));return t?s[0]:s}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(re(e))}async search(e){return this.sugar(await this.retriever.search(e))}async page(e,t){return[]}async retrieve(e){const{single:t,actual:s}=Wi(e),n=this.sugar(await this.retriever.retrieve(e));if(!t)return n;if(n.length===0)throw new Ge(`range matching ${s} not found`);if(n.length>1)throw new Ge(`multiple ranges matching ${s} found`);return n[0]}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new ll(t.name,t.timeRange,t.key,this.frameClient,new ri(t.key,this.unaryClient),new ti(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const fv=u.z.object({ranges:Rs.array()}),mv=u.z.object({ranges:ul.array()}),yv=u.z.object({keys:Se.array()}),gv=u.z.object({}),vv=u.z.object({key:Se,name:u.z.string()}),wv=u.z.object({}),_v="/range/create",bv="/range/delete",kv="/range/rename";let hl=class{constructor(e){d(this,"client");this.client=e}async rename(e,t){await C(this.client,kv,{key:e,name:t},vv,wv)}async create(e){return(await C(this.client,_v,{ranges:e},mv,fv)).ranges}async delete(e){await C(this.client,bv,{keys:e},yv,gv)}};const Tv=u.z.object({keys:Se.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()}),Ov=u.z.object({ranges:u.z.array(Rs)});let pl=class{constructor(e){d(this,"ENDPOINT","/range/retrieve");d(this,"client");this.client=e}async retrieve(e){const{normalized:t,variant:s}=Wi(e);return await this.execute({[s]:t})}async search(e){return await this.execute({term:e})}async execute(e){const[t,s]=await this.client.send(this.ENDPOINT,e,Tv,Ov);if(s!=null)throw s;return t.ranges}};const xv=Object.freeze(Object.defineProperty({__proto__:null,Client:dl,Range:ll,Retriever:pl,Writer:hl,analyzeParams:Wi,keyZ:Se,newPayloadZ:ul,payloadZ:Rs},Symbol.toStringTag,{value:"Module"})),Nv="/api/v1/";class Sv{constructor(e,t=!1){d(this,"url");d(this,"unary");d(this,"stream");d(this,"secure");this.secure=t,this.url=e.child(Nv);const s=new Oc.JSONEncoderDecoder;this.unary=new Jm(this.url,s,this.secure),this.stream=new ny(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Ft=u.z.string().uuid(),Fi=u.z.object({name:u.z.string(),key:Ft,layout:vi.or(u.z.string().transform(r=>JSON.parse(r)))}),Yi=Fi.omit({layout:!0}).extend({layout:u.z.string().transform(r=>JSON.parse(r))}),Ji=u.z.string().uuid(),Gi=u.z.object({key:u.z.string(),name:u.z.string(),data:vi.or(u.z.string().transform(r=>JSON.parse(r)))}),Ev=u.z.object({keys:u.z.string().array()}),Zv=u.z.object({linePlots:Gi.array()});let Iv=class{constructor(e){d(this,"ENDPOINT","/workspace/lineplot/retrieve");d(this,"client");this.client=e}async retrieve(e){const t=re(e);return(await C(this.client,this.ENDPOINT,{keys:t},Ev,Zv)).linePlots}};const Av=Gi.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Cv=u.z.object({workspace:Ft,linePlots:Av.array()}),$v=u.z.object({linePlots:Gi.array()}),jv=u.z.object({keys:Ji.array()}),Rv=u.z.object({}),zv=u.z.object({key:Ji,name:u.z.string()}),Pv=u.z.object({}),Mv=u.z.object({key:Ji,data:u.z.string()}),Dv=u.z.object({}),Lv="/workspace/lineplot/create",Uv="/workspace/lineplot/delete",Bv="/workspace/lineplot/rename",qv="/workspace/lineplot/set-data";let Vv=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const s={...t,data:JSON.stringify(t.data)};return(await C(this.client,Lv,{workspace:e,linePlots:[s]},Cv,$v)).linePlots[0]}async delete(e){const t=re(e);await C(this.client,Uv,{keys:t},jv,Rv)}async rename(e,t){await C(this.client,Bv,{key:e,name:t},zv,Pv)}async setData(e,t){await C(this.client,qv,{key:e,data:JSON.stringify(t)},Mv,Dv)}},Kv=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new Vv(e),this.retriever=new Iv(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}};const ha=u.z.string().uuid(),Wv=u.z.object({key:u.z.string(),name:u.z.string(),data:vi.or(u.z.string().transform(r=>JSON.parse(r))),snapshot:u.z.boolean()}),Hi=u.z.object({key:u.z.string(),name:u.z.string(),snapshot:u.z.boolean(),data:u.z.string().transform(r=>JSON.parse(r))}),Fv=u.z.object({keys:u.z.string().array()}),Yv=u.z.object({pids:Hi.array()});let Jv=class{constructor(e){d(this,"ENDPOINT","/workspace/pid/retrieve");d(this,"client");this.client=e}async retrieve(e){return(await C(this.client,this.ENDPOINT,{keys:re(e)},Fv,Yv)).pids}};const Gv=Wv.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Hv=u.z.object({workspace:Ft,pids:Gv.array()}),Xv=u.z.object({pids:Hi.array()}),Qv=u.z.object({keys:ha.array()}),ew=u.z.object({}),tw=u.z.object({key:ha,name:u.z.string()}),So=u.z.object({}),rw=u.z.object({key:ha,data:u.z.string()});u.z.object({});const sw=u.z.object({key:ha,name:u.z.string(),snapshot:u.z.boolean()}),nw=u.z.object({pid:Hi}),aw="/workspace/pid/create",iw="/workspace/pid/delete",ow="/workspace/pid/rename",cw="/workspace/pid/set-data",uw="/workspace/pid/copy";let lw=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const s={...t,data:JSON.stringify(t.data)};return(await C(this.client,aw,{workspace:e,pids:[s]},Hv,Xv)).pids[0]}async copy(e,t,s){return(await C(this.client,uw,{key:e,name:t,snapshot:s},sw,nw)).pid}async delete(e){const t=re(e);await C(this.client,iw,{keys:t},Qv,ew)}async rename(e,t){await C(this.client,ow,{key:e,name:t},tw,So)}async setData(e,t){await C(this.client,cw,{key:e,data:JSON.stringify(t)},rw,So)}},dw=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new lw(e),this.retriever=new Jv(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,s){return await this.writer.copy(e,t,s)}};const hw=u.z.object({keys:Ft.array().optional(),search:u.z.string().optional(),author:u.z.string().uuid().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),pw=u.z.object({workspaces:Yi.array()}),Fn=class Fn{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=re(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await C(this.client,Fn.ENDPOINT,e,hw,pw)).workspaces}};d(Fn,"ENDPOINT","/workspace/retrieve");let si=Fn;const fw=Fi.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),mw=u.z.object({workspaces:fw.array()}),yw=u.z.object({workspaces:Yi.array()}),gw=u.z.object({keys:Ft.array()}),vw=u.z.object({}),ww=u.z.object({key:Ft,name:u.z.string()}),_w=u.z.object({}),bw=u.z.object({key:Ft,layout:u.z.string()}),kw=u.z.object({}),Tw="/workspace/create",Ow="/workspace/delete",xw="/workspace/rename",Nw="/workspace/set-layout";class Sw{constructor(e){d(this,"client");this.client=e}async create(e){return(await C(this.client,Tw,{workspaces:re(e)},mw,yw)).workspaces}async delete(e){await C(this.client,Ow,{keys:re(e)},gw,vw)}async rename(e,t){await C(this.client,xw,{key:e,name:t},ww,_w)}async setLayout(e,t){await C(this.client,Nw,{key:e,layout:JSON.stringify(t)},bw,kw)}}class fl{constructor(e){d(this,"pid");d(this,"linePlot");d(this,"retriever");d(this,"writer");this.pid=new dw(e),this.linePlot=new Kv(e),this.retriever=new si(e),this.writer=new Sw(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),s=await this.writer.create(e);return t?s:s[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const Ew=Object.freeze(Object.defineProperty({__proto__:null,Client:fl,keyZ:Ft,workspaceRemoteZ:Yi,workspaceZ:Fi},Symbol.toStringTag,{value:"Module"})),ml=u.z.object({host:u.z.string().min(1),port:u.z.number().or(u.z.string()),username:u.z.string().optional(),password:u.z.string().optional(),connectivityPollFrequency:ce.z.default(ce.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class yl{constructor(e){d(this,"createdAt");d(this,"props");d(this,"telem");d(this,"ranges");d(this,"channels");d(this,"auth");d(this,"connectivity");d(this,"ontology");d(this,"workspaces");d(this,"labels");d(this,"hardware");d(this,"transport");this.createdAt=J.now(),this.props=ml.parse(e);const{host:t,port:s,username:n,password:a,connectivityPollFrequency:i,secure:o}=this.props;this.transport=new Sv(new Zh({host:t,port:Number(s)}),o),this.transport.use(ly),n!=null&&a!=null&&(this.auth=new _y(this.transport.unary,{username:n,password:a}),this.transport.use(this.auth.middleware()));const c=new ji(new Os(this.transport.unary)),l=new kn(this.transport.unary);this.telem=new Du(this.transport.stream,c),this.channels=new Au(this.telem,c,this.transport.unary,l),this.connectivity=new xs(this.transport.unary,i,e.name),this.ontology=new sl(this.transport.unary,this.telem);const h=new pl(this.transport.unary),k=new hl(this.transport.unary);this.labels=new cl(this.transport.unary,this.telem),this.ranges=new dl(this.telem,h,k,this.transport.unary,c,this.labels),this.workspaces=new fl(this.transport.unary);const oe=new Uu(new Bu(this.transport.unary),new qu(this.transport.unary),this.telem),ge=new Ju(this.transport.unary),Re=new Gu(this.transport.unary),he=new Yu(ge,Re),gl=new Vu(new Fu(this.transport.unary),new Wu(this.transport.unary),this.telem,Re,ge);this.hardware=new Lu(he,gl,oe)}close(){this.connectivity.stopChecking()}}d(yl,"connectivity",xs);const Zw=Object.freeze(Object.defineProperty({__proto__:null,Authority:cr,StateTracker:Li,filterTransfersByChannelKey:Ay,stateZ:Iy,subjectZ:Di,transferString:Cy},Symbol.toStringTag,{value:"Module"}));exports.AuthError=$i;exports.Authority=cr;exports.Channel=Ri;exports.ContiguityError=oy;exports.DataType=te;exports.Density=Te;exports.Frame=ye;exports.GeneralError=Nu;exports.MultiSeries=wc;exports.ParseError=Su;exports.QueryError=Ge;exports.Rate=Xn;exports.RouteError=Eu;exports.Series=vr;exports.Synnax=yl;exports.TimeRange=ze;exports.TimeSpan=ce;exports.TimeStamp=J;exports.UnexpectedError=or;exports.ValidationError=Ae;exports.channel=fy;exports.connection=Ty;exports.control=Zw;exports.device=Yy;exports.framer=zy;exports.hardware=Py;exports.label=Ug;exports.ontology=Ng;exports.rack=tg;exports.ranger=xv;exports.synnaxPropsZ=ml;exports.task=ug;exports.workspace=Ew;
36
+ `);if(!(t instanceof os))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Qa=new ce(-1);var Di=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(Di||{}),Ku=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(Ku||{});const Uy=u.z.object({command:u.z.nativeEnum(Di),span:ce.z.optional(),bounds:ze.z.optional(),stamp:G.z.optional(),keys:u.z.number().array().optional()}),By=u.z.object({variant:u.z.nativeEnum(Ku),ack:u.z.boolean(),command:u.z.nativeEnum(Di),error:Ss.optional().nullable(),frame:na.optional()}),$r=class $r{constructor(e,t){d(this,"stream");d(this,"adapter");d(this,"value");this.stream=new Mi("Iterator",e),this.value=new me,this.adapter=t}static async _open(e,t,s,n){const a=await aa.open(s,t),i=await n.stream($r.ENDPOINT,Uy,By),o=new $r(i,a);return await o.execute({command:0,keys:a.keys,bounds:new ze(e)}),o}async next(e=Qa){return await this.execute({command:1,span:new ce(e)})}async prev(e=Qa){return await this.execute({command:2,span:new ce(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new G(e)})}async seekGE(e){return await this.execute({command:6,stamp:new G(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Vy(this)}async execute(e){for(this.stream.send(e),this.value=new me;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new me(t.frame)))}}};d($r,"ENDPOINT","/frame/iterate");let Vn=$r;class Vy{constructor(e){d(this,"iter");d(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const qy=u.z.object({start:G.z.optional(),keys:u.z.number().array()}),Ky=u.z.object({frame:na,error:Ss.optional().nullable()}),Wy="/frame/stream";class ia{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new Mi("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:s,from:n}){const a=await aa.open(e,s),i=await t.stream(Wy,qy,Ky),o=new ia(i,a);return i.send({start:new G(n),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new me((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}const jt=class jt extends Number{};d(jt,"Absolute",255),d(jt,"Default",1),d(jt,"z",u.z.union([u.z.instanceof(jt),u.z.number().int().min(0).max(255).transform(e=>new jt(e)),u.z.instanceof(Number).transform(e=>new jt(e))]));let ir=jt;const Li=u.z.object({name:u.z.string(),key:u.z.string()}),Fy=u.z.object({subject:Li,resource:u.z.number(),authority:ir.z}),Yy=(...r)=>e=>e.filter(t=>{let s=!1;return t.to!=null&&(s=r.includes(t.to.resource)),t.from!=null&&!s&&(s=r.includes(t.from.resource)),s}),Gy=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Ui{constructor(e){d(this,"states");d(this,"streamer");d(this,"ecd");d(this,"observer");d(this,"closePromise");this.states=new Map,this.ecd=new Au.JSONEncoderDecoder,this.observer=new Bn.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.openStreamer("sy_node_1_control");return new Ui(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var Bi=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r[r.SetMode=5]="SetMode",r))(Bi||{}),Os=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Os||{});const Jy=u.z.object({start:G.z.optional(),controlSubject:Li.optional(),keys:u.z.number().array().optional(),authorities:ir.z.array().optional(),mode:u.z.nativeEnum(Os).optional()}),Hy=u.z.object({command:u.z.nativeEnum(Bi),config:Jy.optional(),frame:na.optional()}),Xy=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum(Bi),error:Ss.optional().nullable()});var Ht;let Wu=(Ht=class{constructor(e,t){d(this,"stream");d(this,"adapter");this.stream=new Mi("Writer",e),this.adapter=t}static async _open(e,t,{channels:s,start:n=G.now(),authorities:a=ir.Absolute,controlSubject:i,mode:o=1}){const c=await Pi.open(e,s),l=await t.stream(Ht.ENDPOINT,Hy,Xy),h=new Ht(l,c);return await h.execute({command:0,config:{start:new G(n),keys:c.keys,controlSubject:i,authorities:re(a),mode:o}}),h}async write(e,t){const s=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:s.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(s=>Number(s)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?wi(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},d(Ht,"ENDPOINT","/frame/write"),Ht),Fu=class{constructor(e,t){d(this,"stream");d(this,"retriever");this.stream=e,this.retriever=t}async openIterator(e,t){return await Vn._open(e,t,this.retriever,this.stream)}async openWriter(e){return await Wu._open(this.retriever,this.stream,e)}async openStreamer(e){const t=typeof e=="object";return(Array.isArray(e)||!t)&&(e={channels:e}),await ia._open(this.retriever,this.stream,e)}async write(e,t,s){if(s==null){const a=t,i=await this.openWriter({start:e,channels:Object.keys(a),mode:Os.PersistOnly});try{await i.write(a),await i.commit()}finally{await i.close()}return}const n=await this.openWriter({start:e,channels:t,mode:Os.PersistOnly});try{await n.write(t,s),await n.commit()}finally{await n.close()}}async read(e,t){const{single:s}=$t(t),n=await this.readFrame(e,t);return s?n.get(t):n}async readFrame(e,t){const s=await this.openIterator(e,t),n=new me;try{for await(const a of s)n.push(a)}finally{await s.close()}return n}};const Qy=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Qa,Client:Fu,Frame:me,Iterator:Vn,Streamer:ia,Writer:Wu,WriterMode:Os,frameZ:na,series:Bu,seriesFromPayload:Vu,seriesToPayload:qu},Symbol.toStringTag,{value:"Module"}));let Yu=class{constructor(e,t,s){d(this,"tasks");d(this,"racks");d(this,"devices");this.tasks=e,this.racks=t,this.devices=s}};const eg=Object.freeze(Object.defineProperty({__proto__:null,Client:Yu},Symbol.toStringTag,{value:"Module"})),Is=u.z.number(),Vi=u.z.object({key:Is,name:u.z.string()}),tg=Vi.partial({key:!0}),qi=u.z.string(),oa=u.z.object({key:qi,rack:Is,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class As{constructor(e,t,s,n){d(this,"streamer");d(this,"decoder");d(this,"base");d(this,"closePromise");d(this,"deleteChannel");d(this,"setChannel");this.streamer=e,this.decoder=t,this.base=new Bn.Observer,this.closePromise=this.stream(),this.deleteChannel=n,this.setChannel=s}onChange(e){return this.base.onChange(e)}async close(){return this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer){const t=[];if(this.deleteChannel!=null){const s=e.get(this.deleteChannel);t.push(...s.series.flatMap(n=>this.decoder("delete",n)))}if(this.setChannel!=null){const s=e.get(this.setChannel);t.push(...s.series.flatMap(n=>this.decoder("set",n)))}this.base.notify(t)}}static async open(e,t,s,n){const a=await e.openStreamer([t,s]);return new As(a,n,t,s)}}const rg="sy_device_set",sg="sy_device_delete";let Gu=class{constructor(e,t,s){d(this,"retriever");d(this,"writer");d(this,"frameClient");this.retriever=e,this.writer=t,this.frameClient=s}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t=await this.retriever.retrieve(re(e));return Array.isArray(e)?t:t[0]}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async delete(e){await this.writer.delete(e)}async openDeviceTracker(){return await As.open(this.frameClient,rg,sg,ng)}};const ng=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(oa).map(t=>({variant:r,key:t.key,value:t})),wa="/hardware/device/retrieve",_a=u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:qi.array().optional()}),ba=u.z.object({devices:oa.array()});let Ju=class{constructor(e){d(this,"client");this.client=e}async search(e){return(await $(this.client,wa,{keys:[e]},_a,ba)).devices}async page(e,t){return(await $(this.client,wa,{offset:e,limit:t},_a,ba)).devices}async retrieve(e){return(await $(this.client,wa,{keys:e},_a,ba)).devices}};const ag="/hardware/device/create",ig="/hardware/device/delete",og=u.z.object({devices:oa.array()}),cg=u.z.object({devices:oa.array()}),ug=u.z.object({keys:qi.array()}),lg=u.z.object({});let Hu=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await $(this.client,ag,{devices:e},og,cg)).devices}async delete(e){await $(this.client,ig,{keys:e},ug,lg)}};const dg=Object.freeze(Object.defineProperty({__proto__:null,Client:Gu,Retriever:Ju,Writer:Hu},Symbol.toStringTag,{value:"Module"}));let Xu=class{constructor(e,t,s,n,a){d(this,"retriever");d(this,"writer");d(this,"frameClient");d(this,"taskWriter");d(this,"taskRetriever");this.retriever=e,this.writer=t,this.frameClient=s,this.taskWriter=n,this.taskRetriever=a}async create(e){const t=await this.writer.create([e]);return this.sugar(t)[0]}async search(e){const t=await this.retriever.search(e);return this.sugar(t)}async page(e,t){const s=await this.retriever.page(e,t);return this.sugar(s)}async retrieve(e){const t=await this.retriever.retrieve(re(e));return Array.isArray(e)?this.sugar(t):this.sugar(t)[0]}sugar(e){return e.map(t=>new Qu(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Qu{constructor(e,t,s,n){d(this,"key");d(this,"name");d(this,"writer");d(this,"tasks");this.key=e,this.name=t,this.writer=s,this.tasks=n}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async retrieveTasks(){return[]}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),(await this.writer.create([e]))[0]}async deleteTask(e){await this.writer.delete([e])}}const hg="/hardware/rack/create",pg="/hardware/rack/delete",fg=u.z.object({racks:tg.array()}),mg=u.z.object({racks:Vi.array()}),yg=u.z.object({keys:Is.array()}),gg=u.z.object({});let el=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await $(this.client,hg,{racks:e},fg,mg)).racks}async delete(e){await $(this.client,pg,{keys:e},yg,gg)}};const ka="/hardware/rack/retrieve",Ta=u.z.object({keys:Is.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Oa=u.z.object({racks:Vi.array()});let tl=class{constructor(e){d(this,"client");this.client=e}async page(e,t){return(await $(this.client,ka,{offset:e,limit:t},Ta,Oa)).racks}async search(e){return(await $(this.client,ka,{search:e},Ta,Oa)).racks}async retrieve(e){return(await $(this.client,ka,{keys:e},Ta,Oa)).racks}};const vg=Object.freeze(Object.defineProperty({__proto__:null,Client:Xu,Rack:Qu,Retriever:tl,Writer:el},Symbol.toStringTag,{value:"Module"}));let rl=class{constructor(e,t){d(this,"retriever");d(this,"writer");this.retriever=e,this.writer=t}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t={};let s=!0;typeof e=="number"?t.rack=e:typeof e=="string"?(s=!1,t.keys=[e]):t.keys=re(e);const n=await this.retriever.retrieve(t);return s?n:n[0]}};const Ki=u.z.union([u.z.string(),u.z.bigint().transform(r=>r.toString()),u.z.number().transform(r=>r.toString())]),Wi=u.z.object({key:Ki,name:u.z.string(),type:u.z.string(),config:u.z.record(u.z.unknown()).or(u.z.string().transform(r=>JSON.parse(r)))}),wg=Wi.omit({key:!0}).extend({key:Ki.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))}),xa=u.z.object({rack:Is.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Na=u.z.object({tasks:u.z.union([Wi.array(),u.z.null().transform(()=>[])])}),Sa="/hardware/task/retrieve";let sl=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){return(await $(this.client,Sa,e,xa,Na)).tasks}async search(e){return(await $(this.client,Sa,{keys:[e]},xa,Na)).tasks}async page(e,t){return(await $(this.client,Sa,{offset:e,limit:t},xa,Na)).tasks}};const _g="/hardware/task/create",bg="/hardware/task/delete",kg=u.z.object({tasks:wg.array()}),Tg=u.z.object({tasks:Wi.array()}),Og=u.z.object({keys:Ki.array()}),xg=u.z.object({});let nl=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await $(this.client,_g,{tasks:e},kg,Tg)).tasks}async delete(e){await $(this.client,bg,{keys:e},Og,xg)}};const Ng=Object.freeze(Object.defineProperty({__proto__:null,Client:rl,Retriever:sl,Writer:nl},Symbol.toStringTag,{value:"Module"}));class Sg{constructor(e,t){d(this,"key");d(this,"name");this.key=t,this.name=e}get ontologyID(){return new we({type:"group",key:this.key})}}const Eg=u.z.string().uuid(),Zg=u.z.object({key:Eg,name:u.z.string()}),al=u.z.union([u.z.literal("label"),u.z.literal("builtin"),u.z.literal("cluster"),u.z.literal("channel"),u.z.literal("node"),u.z.literal("group"),u.z.literal("range"),u.z.literal("range-alias"),u.z.literal("user"),u.z.literal("workspace"),u.z.literal("pid"),u.z.literal("lineplot"),u.z.literal("rack")]),Ye=u.z.object({type:al,key:u.z.string()}),il=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),ol=u.z.union([il,Ye]),mr=class mr{constructor(e){d(this,"type");d(this,"key");if(e instanceof mr)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,s]=e.split(":");this.type=t,this.key=s}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};d(mr,"z",u.z.union([ol,u.z.instanceof(mr)]).transform(e=>new mr(e)));let we=mr;const Ig=new we({type:"builtin",key:"root"}),cl=u.z.object({type:u.z.number()}),ul=u.z.object({type:al,fields:u.z.record(cl)}),ll=u.z.object({id:we.z,name:u.z.string(),schema:ul.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),Ag=u.z.object({from:we.z,type:u.z.string(),to:we.z}),ei=r=>{const[e,t,s]=r.split("->");return{from:new we(e),type:t,to:new we(s)}},$g=u.z.object({group:Zg}),Cg=u.z.object({parent:Ye,name:u.z.string()}),jg=u.z.object({key:u.z.string(),name:u.z.string()}),Rg=u.z.object({keys:u.z.array(u.z.string())});var nt;let zg=(nt=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const[s,n]=await this.client.send(nt.ENDPOINT,{parent:e,name:t},Cg,$g);if(n!=null)throw n;return s.group}async rename(e,t){const s={key:e,name:t},[,n]=await this.client.send(nt.ENDPOINT_RENAME,s,jg,u.z.object({}));if(n!=null)throw n}async delete(e){const t={keys:e},[,s]=await this.client.send(nt.ENDPOINT_DELETE,t,Rg,u.z.object({}));if(s!=null)throw s}},d(nt,"ENDPOINT","/ontology/create-group"),d(nt,"ENDPOINT_RENAME","/ontology/rename-group"),d(nt,"ENDPOINT_DELETE","/ontology/delete-group"),nt),Pg=class{constructor(e){d(this,"creator");this.creator=new zg(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new Sg(e.name,e.key)}};const Mg=u.z.object({ids:Ye.array().optional(),children:u.z.boolean().optional(),parents:u.z.boolean().optional(),includeSchema:u.z.boolean().optional(),includeFieldData:u.z.boolean().optional(),term:u.z.string().optional()}),Dg=u.z.object({resources:ll.array()});var gr;let Lg=(gr=class{constructor(e){d(this,"client");this.client=e}async search(e){return await this.execute({term:e})}async retrieve(e,t=!0,s=!0){return await this.execute({ids:re(e).map(n=>new we(n).payload),includeFieldData:s,includeSchema:t})}async retrieveChildren(e,t=!0,s=!0){return await this.execute({ids:re(e).map(n=>new we(n).payload),children:!0,includeSchema:t,includeFieldData:s})}async retrieveParents(e,t=!0,s=!0){return await this.execute({ids:re(e).map(n=>new we(n).payload),parents:!0,includeSchema:t,includeFieldData:s})}async execute(e){return(await $(this.client,gr.ENDPOINT,e,Mg,Dg)).resources}},d(gr,"ENDPOINT","/ontology/retrieve"),gr);const Ea={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},xo=u.z.object({id:Ye,children:Ye.array()}),Ug=u.z.object({from:Ye,to:Ye,children:Ye.array()});let Bg=class{constructor(e){d(this,"client");this.client=e}async addChildren(e,...t){await $(this.client,Ea.ADD_CHILDREN,{id:e,children:t},xo,u.z.object({}))}async removeChildren(e,...t){await $(this.client,Ea.REMOVE_CHILDREN,{id:e,children:t},xo,u.z.object({}))}async moveChildren(e,t,...s){const n={from:e,to:t,children:s};await $(this.client,Ea.MOVE_CHILDREN,n,Ug,u.z.object({}))}};const No="sy_ontology_resource_set",So="sy_ontology_resource_delete",Eo="sy_ontology_relationship_set",Zo="sy_ontology_relationship_delete";class ca{constructor(e,t){d(this,"resourceObs");d(this,"relationshipObs");d(this,"relationships");d(this,"resources");d(this,"streamer");d(this,"retriever");d(this,"closePromise");this.relationshipObs=new Bn.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Bn.Observer,this.resources=this.resourceObs,this.retriever=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),s=this.parseResourceDeletes(e);t.concat(s).length>0&&this.resourceObs.notify(t.concat(s));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(Eo);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"set",key:ei(s),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Zo);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:ei(s)}))}async parseResourceSets(e){const t=e.get(No);if(t.length===0)return[];const s=Array.from(t.as("string")).map(n=>new we(n));try{return(await this.retriever.retrieve(s)).map(a=>({variant:"set",key:a.id,value:a}))}catch(n){if(n instanceof Xe)return console.warn(n),[];throw n}}parseResourceDeletes(e){const t=e.get(So);return t.length===0?[]:Array.from(t.as("string")).map(s=>({variant:"delete",key:new we(s)}))}static async open(e,t){const s=await e.openStreamer([No,So,Eo,Zo]);return new ca(s,t)}}let dl=class{constructor(e,t){d(this,"groups");d(this,"retriever");d(this,"writer");d(this,"framer");this.retriever=new Lg(e),this.writer=new Bg(e),this.groups=new Pg(e),this.framer=t}async search(e){return await this.retriever.search(e)}async retrieve(e,t,s){const n=await this.retriever.retrieve(e,t,s);if(Array.isArray(e))return n;if(n.length===0)throw new Xe(`No resource found with ID ${e.toString()}`);return n[0]}async page(e,t){return[]}async retrieveChildren(e,t,s){return await this.retriever.retrieveChildren(e,t,s)}async retrieveParents(e,t,s){return await this.retriever.retrieveParents(e,t,s)}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...s){return await this.writer.moveChildren(e,t,...s)}async openChangeTracker(){return await ca.open(this.framer,this.retriever)}};const Vg=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:ca,Client:dl,ID:we,Root:Ig,crudeIDZ:ol,idZ:Ye,parseRelationship:ei,relationshipSchemaZ:Ag,resourceSchemaZ:ll,schemaFieldZ:cl,schemaZ:ul,stringIDZ:il},Symbol.toStringTag,{value:"Module"})),Nr=u.z.string().uuid(),$s=u.z.object({key:Nr,name:u.z.string().min(1),color:u.z.string()}),qg=r=>new we({type:"label",key:r}),Kg=u.z.object({keys:Nr.array().optional(),for:Ye.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Wg=u.z.object({labels:$s.array().optional().default([])});var vr;let hl=(vr=class{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=re(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,s]=await this.client.send(vr.ENDPOINT,e,Kg,Wg);if(s!=null)throw s;return t.labels}},d(vr,"ENDPOINT","/label/retrieve"),vr);const pl=$s.extend({key:Nr.optional()}),Fg=u.z.object({labels:pl.array()}),Yg=u.z.object({labels:$s.array()}),Gg=u.z.object({keys:Nr.array()}),fl=u.z.object({id:Ye,labels:Nr.array()}),Jg=fl,Za=u.z.object({}),Hg="/label/create",Xg="/label/delete",Qg="/label/set",ev="/label/remove";let ml=class{constructor(e){d(this,"client");this.client=e}async create(e){return(await $(this.client,Hg,{labels:re(e)},Fg,Yg)).labels}async delete(e){await $(this.client,Xg,{keys:re(e)},Gg,Za)}async set(e,t){await $(this.client,Qg,{id:e,labels:t},fl,Za)}async remove(e,t){await $(this.client,ev,{id:e,labels:t},Jg,Za)}};const tv="sy_label_set",rv="sy_label_delete";let yl=class{constructor(e,t){d(this,"retriever");d(this,"writer");d(this,"frameClient");this.writer=new ml(e),this.retriever=new hl(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),s=await this.writer.create(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await As.open(this.frameClient,tv,rv,sv)}};const sv=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON($s).map(t=>({variant:r,key:t.key,value:t})),nv=Object.freeze(Object.defineProperty({__proto__:null,Client:yl,Retriever:hl,Writer:ml,keyZ:Nr,labelZ:$s,newLabelPayloadZ:pl,ontologyID:qg},Symbol.toStringTag,{value:"Module"})),Oe=u.z.string().uuid(),Cs=u.z.object({key:Oe,name:u.z.string().min(1),timeRange:ze.z}),gl=Cs.extend({key:u.z.string().uuid().optional()}),Fi=r=>{const e=re(r);if(e.length===0)throw new Error("Range params must not be empty");const t=Oe.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},av=u.z.object({}),iv=u.z.object({range:Cs}),ov=u.z.object({range:Oe}),cv=u.z.object({range:Oe}),uv=u.z.object({}),lv="/range/set-active",dv="/range/retrieve-active",hv="/range/clear-active";class pv{constructor(e){d(this,"client");this.client=e}async setActive(e){await $(this.client,lv,{range:e},ov,av)}async retrieveActive(){const[e,t]=await this.client.send(dv,{},u.z.object({}),iv);if(t instanceof Xe)return null;if(t!=null)throw t;return e.range}async clearActive(e){await $(this.client,hv,{range:e},cv,uv)}}const fv="sy_range_alias_set",mv="sy_range_alias_delete",yv=u.z.object({range:Oe,aliases:u.z.string().array()}),gv=u.z.object({aliases:u.z.record(u.z.string(),xr)}),vv=u.z.object({range:Oe,aliases:u.z.record(xr.or(u.z.string()),u.z.string())}),wv=u.z.unknown(),_v=u.z.object({range:Oe,channels:xr.array()}),bv=u.z.unknown(),kv=u.z.object({range:Oe}),Tv=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),st=class st{constructor(e,t,s){d(this,"frameClient");d(this,"cache",new Map);d(this,"client");d(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=s,this.frameClient=t}async resolve(e){const t=[],s=typeof e=="string",n={};if(s){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?n[i]=o:t.push(i)});if(t.length===0)return n;const a=await $(this.client,st.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},yv,gv);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),s?a.aliases[t[0]]:{...n,...a.aliases}}async set(e){await $(this.client,st.SET_ENDPOINT,{range:this.rangeKey,aliases:e},vv,wv)}async list(){return(await $(this.client,st.LIST_ENDPOINT,{range:this.rangeKey},kv,Tv)).aliases}async delete(e){await $(this.client,st.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},_v,bv)}async openChangeTracker(){return await As.open(this.frameClient,fv,mv,Nv(this.rangeKey))}};d(st,"SET_ENDPOINT","/range/alias/set"),d(st,"RESOLVE_ENDPOINT","/range/alias/resolve"),d(st,"LIST_ENDPOINT","/range/alias/list"),d(st,"DELETE_ENDPOINT","/range/alias/delete");let ti=st;const Ov=u.z.object({range:Oe,channel:xr,alias:u.z.string()}),xv="---",Nv=r=>(e,t)=>e==="delete"?t.toStrings().filter(s=>s.split(xv)[0]===r).map(s=>({variant:e,key:s,value:void 0})):t.parseJSON(Ov).map(s=>({variant:e,key:s.alias,value:s})),Sv=u.z.object({range:Oe,keys:u.z.string().array()}),Ev=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())}),Zv=u.z.object({range:Oe,pairs:u.z.record(u.z.string(),u.z.string())}),Iv=u.z.object({range:Oe,keys:u.z.string().array()}),Rt=class Rt{constructor(e,t){d(this,"rangeKey");d(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,s]=await this.client.send(Rt.GET_ENDPOINT,{range:this.rangeKey,keys:re(e)},Sv,Ev);if(s!=null)throw s;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await $(this.client,Rt.SET_ENDPOINT,{range:this.rangeKey,pairs:Eu(e)?e:{[e]:t}},Zv,u.z.unknown())}async delete(e){await $(this.client,Rt.DELETE_ENDPOINT,{range:this.rangeKey,keys:re(e)},Iv,u.z.unknown())}};d(Rt,"GET_ENDPOINT","/range/kv/get"),d(Rt,"SET_ENDPOINT","/range/kv/set"),d(Rt,"DELETE_ENDPOINT","/range/kv/delete");let ri=Rt;const Ia=r=>new we({type:"range",key:r});class vl{constructor(e,t=ze.ZERO,s,n,a,i,o,c){d(this,"key");d(this,"name");d(this,"kv");d(this,"timeRange");d(this,"channels");d(this,"aliaser");d(this,"frameClient");d(this,"labelClient");this.key=s,this.name=e,this.timeRange=t,this.frameClient=n,this.kv=a,this.aliaser=i,this.channels=o,this.labelClient=c}async setAlias(e,t){const s=await this.channels.retrieve(e);if(s.length===0)throw new Xe(`Channel ${e} does not exist`);await this.aliaser.set({[s[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(Ia(this.key))}async addLabel(...e){await this.labelClient.label(Ia(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(Ia(this.key),e)}}let wl=class{constructor(e,t,s,n,a,i){d(this,"frameClient");d(this,"retriever");d(this,"writer");d(this,"unaryClient");d(this,"channels");d(this,"active");d(this,"labelClient");this.frameClient=e,this.retriever=t,this.writer=s,this.unaryClient=n,this.channels=a,this.active=new pv(n),this.labelClient=i}async create(e){const t=!Array.isArray(e),s=this.sugar(await this.writer.create(re(e)));return t?s[0]:s}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(re(e))}async search(e){return this.sugar(await this.retriever.search(e))}async page(e,t){return[]}async retrieve(e){const{single:t,actual:s}=Fi(e),n=this.sugar(await this.retriever.retrieve(e));if(!t)return n;if(n.length===0)throw new Xe(`range matching ${s} not found`);if(n.length>1)throw new Xe(`multiple ranges matching ${s} found`);return n[0]}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new vl(t.name,t.timeRange,t.key,this.frameClient,new ri(t.key,this.unaryClient),new ti(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const Av=u.z.object({ranges:Cs.array()}),$v=u.z.object({ranges:gl.array()}),Cv=u.z.object({keys:Oe.array()}),jv=u.z.object({}),Rv=u.z.object({key:Oe,name:u.z.string()}),zv=u.z.object({}),Pv="/range/create",Mv="/range/delete",Dv="/range/rename";let _l=class{constructor(e){d(this,"client");this.client=e}async rename(e,t){await $(this.client,Dv,{key:e,name:t},Rv,zv)}async create(e){return(await $(this.client,Pv,{ranges:e},$v,Av)).ranges}async delete(e){await $(this.client,Mv,{keys:e},Cv,jv)}};const Lv=u.z.object({keys:Oe.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()}),Uv=u.z.object({ranges:u.z.array(Cs)});let bl=class{constructor(e){d(this,"ENDPOINT","/range/retrieve");d(this,"client");this.client=e}async retrieve(e){const{normalized:t,variant:s}=Fi(e);return await this.execute({[s]:t})}async search(e){return await this.execute({term:e})}async execute(e){const[t,s]=await this.client.send(this.ENDPOINT,e,Lv,Uv);if(s!=null)throw s;return t.ranges}};const Bv=Object.freeze(Object.defineProperty({__proto__:null,Client:wl,Range:vl,Retriever:bl,Writer:_l,analyzeParams:Fi,keyZ:Oe,newPayloadZ:gl,payloadZ:Cs},Symbol.toStringTag,{value:"Module"})),Vv="/api/v1/";class qv{constructor(e,t=!1){d(this,"url");d(this,"unary");d(this,"stream");d(this,"secure");this.secure=t,this.url=e.child(Vv);const s=new Au.JSONEncoderDecoder;this.unary=new Up(this.url,s,this.secure),this.stream=new Jp(this.url,s,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Wt=u.z.string().uuid(),Yi=u.z.object({name:u.z.string(),key:Wt,layout:Ci.or(u.z.string().transform(r=>JSON.parse(r)))}),Gi=Yi.omit({layout:!0}).extend({layout:u.z.string().transform(r=>JSON.parse(r))}),Ji=u.z.string().uuid(),Hi=u.z.object({key:u.z.string(),name:u.z.string(),data:Ci.or(u.z.string().transform(r=>JSON.parse(r)))}),Kv=u.z.object({keys:u.z.string().array()}),Wv=u.z.object({linePlots:Hi.array()});let Fv=class{constructor(e){d(this,"ENDPOINT","/workspace/lineplot/retrieve");d(this,"client");this.client=e}async retrieve(e){const t=re(e);return(await $(this.client,this.ENDPOINT,{keys:t},Kv,Wv)).linePlots}};const Yv=Hi.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Gv=u.z.object({workspace:Wt,linePlots:Yv.array()}),Jv=u.z.object({linePlots:Hi.array()}),Hv=u.z.object({keys:Ji.array()}),Xv=u.z.object({}),Qv=u.z.object({key:Ji,name:u.z.string()}),ew=u.z.object({}),tw=u.z.object({key:Ji,data:u.z.string()}),rw=u.z.object({}),sw="/workspace/lineplot/create",nw="/workspace/lineplot/delete",aw="/workspace/lineplot/rename",iw="/workspace/lineplot/set-data";let ow=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const s={...t,data:JSON.stringify(t.data)};return(await $(this.client,sw,{workspace:e,linePlots:[s]},Gv,Jv)).linePlots[0]}async delete(e){const t=re(e);await $(this.client,nw,{keys:t},Hv,Xv)}async rename(e,t){await $(this.client,aw,{key:e,name:t},Qv,ew)}async setData(e,t){await $(this.client,iw,{key:e,data:JSON.stringify(t)},tw,rw)}},cw=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new ow(e),this.retriever=new Fv(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}};const ua=u.z.string().uuid(),uw=u.z.object({key:u.z.string(),name:u.z.string(),data:Ci.or(u.z.string().transform(r=>JSON.parse(r))),snapshot:u.z.boolean()}),Xi=u.z.object({key:u.z.string(),name:u.z.string(),snapshot:u.z.boolean(),data:u.z.string().transform(r=>JSON.parse(r))}),lw=u.z.object({keys:u.z.string().array()}),dw=u.z.object({pids:Xi.array()});let hw=class{constructor(e){d(this,"ENDPOINT","/workspace/pid/retrieve");d(this,"client");this.client=e}async retrieve(e){return(await $(this.client,this.ENDPOINT,{keys:re(e)},lw,dw)).pids}};const pw=uw.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),fw=u.z.object({workspace:Wt,pids:pw.array()}),mw=u.z.object({pids:Xi.array()}),yw=u.z.object({keys:ua.array()}),gw=u.z.object({}),vw=u.z.object({key:ua,name:u.z.string()}),Io=u.z.object({}),ww=u.z.object({key:ua,data:u.z.string()});u.z.object({});const _w=u.z.object({key:ua,name:u.z.string(),snapshot:u.z.boolean()}),bw=u.z.object({pid:Xi}),kw="/workspace/pid/create",Tw="/workspace/pid/delete",Ow="/workspace/pid/rename",xw="/workspace/pid/set-data",Nw="/workspace/pid/copy";let Sw=class{constructor(e){d(this,"client");this.client=e}async create(e,t){const s={...t,data:JSON.stringify(t.data)};return(await $(this.client,kw,{workspace:e,pids:[s]},fw,mw)).pids[0]}async copy(e,t,s){return(await $(this.client,Nw,{key:e,name:t,snapshot:s},_w,bw)).pid}async delete(e){const t=re(e);await $(this.client,Tw,{keys:t},yw,gw)}async rename(e,t){await $(this.client,Ow,{key:e,name:t},vw,Io)}async setData(e,t){await $(this.client,xw,{key:e,data:JSON.stringify(t)},ww,Io)}},Ew=class{constructor(e){d(this,"writer");d(this,"retriever");this.writer=new Sw(e),this.retriever=new hw(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,s){return await this.writer.copy(e,t,s)}};const Zw=u.z.object({keys:Wt.array().optional(),search:u.z.string().optional(),author:u.z.string().uuid().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Iw=u.z.object({workspaces:Gi.array()}),Kn=class Kn{constructor(e){d(this,"client");this.client=e}async retrieve(e){const t=re(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await $(this.client,Kn.ENDPOINT,e,Zw,Iw)).workspaces}};d(Kn,"ENDPOINT","/workspace/retrieve");let si=Kn;const Aw=Yi.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),$w=u.z.object({workspaces:Aw.array()}),Cw=u.z.object({workspaces:Gi.array()}),jw=u.z.object({keys:Wt.array()}),Rw=u.z.object({}),zw=u.z.object({key:Wt,name:u.z.string()}),Pw=u.z.object({}),Mw=u.z.object({key:Wt,layout:u.z.string()}),Dw=u.z.object({}),Lw="/workspace/create",Uw="/workspace/delete",Bw="/workspace/rename",Vw="/workspace/set-layout";class qw{constructor(e){d(this,"client");this.client=e}async create(e){return(await $(this.client,Lw,{workspaces:re(e)},$w,Cw)).workspaces}async delete(e){await $(this.client,Uw,{keys:re(e)},jw,Rw)}async rename(e,t){await $(this.client,Bw,{key:e,name:t},zw,Pw)}async setLayout(e,t){await $(this.client,Vw,{key:e,layout:JSON.stringify(t)},Mw,Dw)}}class kl{constructor(e){d(this,"pid");d(this,"linePlot");d(this,"retriever");d(this,"writer");this.pid=new Ew(e),this.linePlot=new cw(e),this.retriever=new si(e),this.writer=new qw(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),s=await this.retriever.retrieve(e);return t?s:s[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),s=await this.writer.create(e);return t?s:s[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const Kw=Object.freeze(Object.defineProperty({__proto__:null,Client:kl,keyZ:Wt,workspaceRemoteZ:Gi,workspaceZ:Yi},Symbol.toStringTag,{value:"Module"})),Tl=u.z.object({host:u.z.string().min(1),port:u.z.number().or(u.z.string()),username:u.z.string().optional(),password:u.z.string().optional(),connectivityPollFrequency:ce.z.default(ce.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class Ol extends Fu{constructor(t){const s=Tl.parse(t),{host:n,port:a,username:i,password:o,connectivityPollFrequency:c,secure:l}=s,h=new qv(new oy({host:n,port:Number(a)}),l);h.use(Sy);let k;if(i!=null&&o!=null){const El=new Py(h.unary,{username:i,password:o});h.use(El.middleware())}const se=new Ri(new ks(h.unary)),ye=new Cu(h.unary);super(h.stream,se);d(this,"createdAt");d(this,"props");d(this,"ranges");d(this,"channels");d(this,"auth");d(this,"connectivity");d(this,"ontology");d(this,"workspaces");d(this,"labels");d(this,"hardware");d(this,"transport");this.createdAt=G.now(),this.props=s,this.auth=k,this.transport=h,this.channels=new Du(this,se,h.unary,ye),this.connectivity=new Ts(h.unary,c,s.name),this.ontology=new dl(h.unary,this);const Re=new bl(h.unary),de=new _l(this.transport.unary);this.labels=new yl(this.transport.unary,this),this.ranges=new wl(this,Re,de,this.transport.unary,se,this.labels),this.workspaces=new kl(this.transport.unary);const xl=new Gu(new Ju(this.transport.unary),new Hu(this.transport.unary),this),Qi=new sl(this.transport.unary),eo=new nl(this.transport.unary),Nl=new rl(Qi,eo),Sl=new Xu(new tl(this.transport.unary),new el(this.transport.unary),this,eo,Qi);this.hardware=new Yu(Nl,Sl,xl)}close(){this.connectivity.stopChecking()}}d(Ol,"connectivity",Ts);const Ww=Object.freeze(Object.defineProperty({__proto__:null,Authority:ir,StateTracker:Ui,filterTransfersByChannelKey:Yy,stateZ:Fy,subjectZ:Li,transferString:Gy},Symbol.toStringTag,{value:"Module"}));exports.AuthError=ji;exports.Authority=ir;exports.Channel=zi;exports.ContiguityError=Oy;exports.DataType=te;exports.Density=ke;exports.Frame=me;exports.GeneralError=ju;exports.MultiSeries=Nu;exports.ParseError=Ru;exports.QueryError=Xe;exports.Rate=sa;exports.RouteError=zu;exports.Series=Ee;exports.Synnax=Ol;exports.TimeRange=ze;exports.TimeSpan=ce;exports.TimeStamp=G;exports.UnexpectedError=ar;exports.ValidationError=Ze;exports.channel=Ay;exports.connection=Ly;exports.control=Ww;exports.device=dg;exports.framer=Qy;exports.hardware=eg;exports.label=nv;exports.ontology=Vg;exports.rack=vg;exports.ranger=Bv;exports.synnaxPropsZ=Tl;exports.task=Ng;exports.workspace=Kw;
37
37
  //# sourceMappingURL=client.cjs.map