@makaio/framework 1.0.0-dev-1781081952714 → 1.0.0-dev-1781260968078

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 (194) hide show
  1. package/README.md +29 -0
  2. package/dist/.makaio-build.json +2 -2
  3. package/dist/adapters/acp-client/index.d.mts +4 -4
  4. package/dist/adapters/config/index.d.mts +1 -1
  5. package/dist/adapters/config/index.mjs +1 -1
  6. package/dist/adapters/index.d.mts +1 -1
  7. package/dist/adapters/index.mjs +1 -1
  8. package/dist/adapters/node.mjs +1 -1
  9. package/dist/ajv-BA2z5ztb.mjs +8 -0
  10. package/dist/bus/index.d.mts +19 -19
  11. package/dist/bus/index.mjs +1 -1
  12. package/dist/client-BJVDImPV.d.mts +175 -0
  13. package/dist/clients/index.d.mts +105 -2
  14. package/dist/clients/index.mjs +2 -2
  15. package/dist/contracts/adapter/index.d.mts +2 -2
  16. package/dist/contracts/adapter/schemas/session-lineage.d.mts +1 -1
  17. package/dist/contracts/artifact/index.d.mts +1 -1
  18. package/dist/contracts/client/index.d.mts +1 -1
  19. package/dist/contracts/extension/index.d.mts +3 -3
  20. package/dist/contracts/extension/index.mjs +1 -1
  21. package/dist/contracts/facet/index.d.mts +1 -1
  22. package/dist/contracts/index.d.mts +741 -228
  23. package/dist/contracts/index.mjs +1 -1
  24. package/dist/contracts/materialization/index.d.mts +3 -3
  25. package/dist/contracts/session/index.d.mts +2 -2
  26. package/dist/{cursor-storage-C_WTAESV.mjs → cursor-storage-CmKjSvKY.mjs} +1 -1
  27. package/dist/{definition-DqJOg6Lv.d.mts → definition-SiimP25_.d.mts} +1 -1
  28. package/dist/{detached-extension-handle-CxEBQnSa.mjs → detached-extension-handle-Diiwgm13.mjs} +1 -1
  29. package/dist/drizzle/0001_messages_content_tsv.na.md +18 -0
  30. package/dist/drizzle/0012_legal_kate_bishop.sql +3 -0
  31. package/dist/drizzle/0013_eager_rhodey.sql +56 -0
  32. package/dist/drizzle/0014_fancy_ultimo.sql +1 -0
  33. package/dist/drizzle/meta/0012_snapshot.json +2934 -0
  34. package/dist/drizzle/meta/0013_snapshot.json +2954 -0
  35. package/dist/drizzle/meta/0014_snapshot.json +2959 -0
  36. package/dist/drizzle/meta/_journal.json +21 -0
  37. package/dist/drizzle-wjquQK2m.mjs +1 -0
  38. package/dist/esm-CQVFKEW5.mjs +1 -0
  39. package/dist/expression/index.d.mts +11 -2
  40. package/dist/expression/index.mjs +4 -4
  41. package/dist/extension-DfNcE0zm.mjs +1 -0
  42. package/dist/extension-ZBN4BGre.mjs +1 -0
  43. package/dist/{filesystem-service-DH9zlxyd.mjs → filesystem-service-BjfrUmGS.mjs} +1 -1
  44. package/dist/git/index.mjs +14 -14
  45. package/dist/{globby-4SrlyIlj.mjs → globby-BIH65cbN.mjs} +1 -1
  46. package/dist/handler-DSfSAlxx.mjs +1 -0
  47. package/dist/handlers-C8EtpSqK.mjs +41 -0
  48. package/dist/{index-BCKRUuI2.d.mts → index-B2xbnMZe.d.mts} +1 -1
  49. package/dist/{index-YDfOv0GT.d.mts → index-BDRKAxIV.d.mts} +160 -7
  50. package/dist/{index-CwKzQuIX.d.mts → index-BQiHs8EF.d.mts} +12 -12
  51. package/dist/{index-BheaEhyI.d.mts → index-BtztOqaF.d.mts} +6 -6
  52. package/dist/{index-BmV60tMf.d.mts → index-BvSyOgTY.d.mts} +1298 -30
  53. package/dist/{index-D6bw4qJp.d.mts → index-CARxIllg.d.mts} +98 -98
  54. package/dist/{index-Bibt5jAX.d.mts → index-CZ_TcT6J.d.mts} +8 -8
  55. package/dist/{index-CNOTkyGw.d.mts → index-Cb64d5c5.d.mts} +307 -383
  56. package/dist/{index-DETxgKS2.d.mts → index-CgjslA5-.d.mts} +88 -15
  57. package/dist/{index-C3zfJg6s.d.mts → index-D5CI1V5d.d.mts} +16 -16
  58. package/dist/{index-jlQ4IhR5.d.mts → index-DDQkhhRo.d.mts} +281 -273
  59. package/dist/{index-Db0uJ_Cg2.d.mts → index-DTdqGAfH2.d.mts} +18 -8
  60. package/dist/{index-Clut1ljB.d.mts → index-Drz_a7kW.d.mts} +1 -1
  61. package/dist/kernel/extension/index.d.mts +1 -1
  62. package/dist/kernel/extension/index.mjs +1 -1
  63. package/dist/kernel/index.d.mts +2 -2
  64. package/dist/kernel/index.mjs +1 -1
  65. package/dist/kernel/observability/index.d.mts +1 -1
  66. package/dist/{lib-B9kVK_1_.mjs → lib-CNOQJtgs.mjs} +1 -1
  67. package/dist/{lib-DPruLs5D.mjs → lib-Cq5R6Tx9.mjs} +19 -22
  68. package/dist/lib-nlcl5kRW.mjs +2 -0
  69. package/dist/{load-extensions-C-TqCwzL.mjs → load-extensions-wELQ4BBN.mjs} +1 -1
  70. package/dist/mcp-http-server/index.mjs +1 -1
  71. package/dist/{namespace-ByyuIFpL.d.mts → namespace-7tsuJhQ9.d.mts} +28 -28
  72. package/dist/{namespace-BlS_i9KT.d.mts → namespace-B73Sxj5L.d.mts} +1 -1
  73. package/dist/{namespace-aBIAWxY3.d.mts → namespace-Ba4bxtHQ.d.mts} +12 -12
  74. package/dist/{namespace-DBKWNrk7.d.mts → namespace-DDCjoQUj.d.mts} +3 -3
  75. package/dist/{namespace-Ds6HkJEU.d.mts → namespace-DRFJN-_z.d.mts} +134 -134
  76. package/dist/namespace-DwE2g8Wm.mjs +1 -0
  77. package/dist/{orchestrator-shared-FnWrPS09.mjs → orchestrator-shared-Dt4WDse7.mjs} +1 -1
  78. package/dist/{out-CvZYgczi.mjs → out-C1JFb2Bp.mjs} +1 -1
  79. package/dist/package-Be2Ez4vv.mjs +1 -0
  80. package/dist/package.json +1 -1
  81. package/dist/primitive-runtime-Xrc9xh6p.mjs +1 -0
  82. package/dist/registry-RG-bkw3c.mjs +146 -0
  83. package/dist/rules/index.mjs +1 -1
  84. package/dist/runtime-bun/index.mjs +1 -1
  85. package/dist/runtime-node/extension-validation.mjs +1 -1
  86. package/dist/runtime-node/index.d.mts +57 -36
  87. package/dist/runtime-node/index.mjs +26 -53
  88. package/dist/runtime-node/makaio-config.mjs +1 -1
  89. package/dist/runtime-node/workflow-worker/index.d.mts +1 -1
  90. package/dist/runtime-node/workflow-worker/index.mjs +1 -1
  91. package/dist/{schema-CDL_pyyM.d.mts → schema-BNrM9LWb.d.mts} +216 -10
  92. package/dist/schema-BerZmr2q.mjs +1 -0
  93. package/dist/schema-BrnYlDwZ.mjs +1 -0
  94. package/dist/{schemas-t1VR6_b_.d.mts → schemas-CkOSG2eJ.d.mts} +3 -3
  95. package/dist/{schemas-Exixg77V2.d.mts → schemas-DAFYpgHk2.d.mts} +12 -12
  96. package/dist/{schemas-on3_N5HP.d.mts → schemas-Dv5FxHDT.d.mts} +134 -134
  97. package/dist/services/agent-runtime/index.d.mts +2 -2
  98. package/dist/services/agent-runtime/namespace.d.mts +1 -1
  99. package/dist/services/agent-runtime/schemas.d.mts +1 -1
  100. package/dist/services/filesystem/index.mjs +1 -1
  101. package/dist/services/filesystem/namespace.d.mts +6 -6
  102. package/dist/services/filesystem/schemas.d.mts +3 -3
  103. package/dist/services/git/namespace.d.mts +2 -2
  104. package/dist/services/git/schemas.d.mts +2 -2
  105. package/dist/services/harness/index.d.mts +29 -17
  106. package/dist/services/harness/index.mjs +1 -1
  107. package/dist/services/harness/storage/schema.d.mts +60 -16
  108. package/dist/services/harness/storage/schema.mjs +1 -1
  109. package/dist/services/index.d.mts +103 -103
  110. package/dist/services/index.mjs +1 -1
  111. package/dist/services/log-import/browser.d.mts +2 -2
  112. package/dist/services/log-import/index.d.mts +7 -12
  113. package/dist/services/log-import/index.mjs +2 -2
  114. package/dist/services/log-import/log-import.d.mts +1 -1
  115. package/dist/services/log-import/namespace.d.mts +2 -2
  116. package/dist/services/log-import/schemas.d.mts +1 -1
  117. package/dist/services/session/handlers/index.mjs +1 -1
  118. package/dist/services/session/index.d.mts +7 -7
  119. package/dist/services/session/index.mjs +1 -1
  120. package/dist/services/session/messages/namespace.d.mts +1 -1
  121. package/dist/services/session/messages/namespace.mjs +1 -1
  122. package/dist/services/session/orchestrator-testing/index.mjs +1 -1
  123. package/dist/services/session/session-events/namespace.d.mts +1 -1
  124. package/dist/services/session/session-events/namespace.mjs +1 -1
  125. package/dist/services/session/storage/namespace.d.mts +1 -1
  126. package/dist/services/session/storage/schema.d.mts +2 -2
  127. package/dist/services/session/storage/schema.mjs +1 -1
  128. package/dist/services/session/testing/index.d.mts +18 -2
  129. package/dist/services/session/testing/index.mjs +52 -3
  130. package/dist/services/session/testing/orchestrator-shared.mjs +1 -1
  131. package/dist/services/session/turns/namespace.d.mts +1 -1
  132. package/dist/services/session/turns/namespace.mjs +1 -1
  133. package/dist/services/settings/namespace.d.mts +12 -12
  134. package/dist/services/subagent-template/index.d.mts +1 -1
  135. package/dist/services/subagent-template/schemas.d.mts +1 -1
  136. package/dist/services/tool-approval/index.mjs +1 -1
  137. package/dist/services/tools/index.mjs +1 -1
  138. package/dist/session-KnewDVxt.mjs +39 -0
  139. package/dist/{session-lineage-CKg6mErA.d.mts → session-lineage-CXzV_hAP.d.mts} +1 -1
  140. package/dist/{src-Dvp41Cg2.mjs → src-CBG3IHUl.mjs} +1 -1
  141. package/dist/storage/drizzle/client.d.mts +2 -78
  142. package/dist/storage/drizzle/client.mjs +1 -1
  143. package/dist/storage/drizzle/columns/postgres.d.mts +88 -0
  144. package/dist/storage/drizzle/columns/postgres.mjs +1 -0
  145. package/dist/storage/drizzle/columns/sqlite.d.mts +81 -0
  146. package/dist/storage/drizzle/columns/sqlite.mjs +1 -0
  147. package/dist/storage/drizzle/index.d.mts +976 -23
  148. package/dist/storage/drizzle/index.mjs +1 -1
  149. package/dist/storage/handlers/drizzle/index.d.mts +1 -1
  150. package/dist/storage/handlers/drizzle/index.mjs +1 -1
  151. package/dist/storage/handlers/index.d.mts +1 -1
  152. package/dist/storage/handlers/index.mjs +1 -1
  153. package/dist/style.css +540 -540
  154. package/dist/testing/drizzle-harness.d.mts +52 -6
  155. package/dist/testing/drizzle-harness.mjs +1 -1
  156. package/dist/testing/index.d.mts +34 -2
  157. package/dist/testing/index.mjs +1 -1
  158. package/dist/{tool-approval-service-BgNcJvKx.mjs → tool-approval-service-Cb2F1yT6.mjs} +1 -1
  159. package/dist/tools-D5DVHC-R.mjs +1 -0
  160. package/dist/{types-CmMesAgR.d.mts → types-BMpIa4fx.d.mts} +1 -1
  161. package/dist/{types-D0fPFh-D.d.mts → types-D5IMwOkJ.d.mts} +1 -1
  162. package/dist/{types-DiGqpZOD.d.mts → types-DLVitCZP.d.mts} +195 -195
  163. package/dist/ui-components/index.d.mts +1 -1
  164. package/dist/ui-components/index.mjs +2 -2
  165. package/dist/ui-hooks/index.d.mts +6 -6
  166. package/dist/ui-views/index.mjs +2 -2
  167. package/dist/workflow-engine/index.d.mts +492 -96
  168. package/dist/workflow-engine/index.mjs +1 -1
  169. package/dist/workflow-engine/package.mjs +1 -1
  170. package/dist/workflow-engine/workflow-orchestrator.mjs +1 -1
  171. package/dist/workflow-worker-CK9Sqj7D.mjs +1 -0
  172. package/package.json +40 -1
  173. package/dist/ajv-BJsabpMb.mjs +0 -8
  174. package/dist/drizzle-DpjZFY_j.mjs +0 -1
  175. package/dist/esm-BdLRFEUy.mjs +0 -3
  176. package/dist/extension--5Q190u_.mjs +0 -1
  177. package/dist/extension-DFIZ3FCJ.mjs +0 -1
  178. package/dist/fast-uri-BF2Xuiop.mjs +0 -1
  179. package/dist/handlers-Bev7-xjL.mjs +0 -41
  180. package/dist/lib-aRogYLqg.mjs +0 -5
  181. package/dist/namespace-CDiM5Bcr.mjs +0 -1
  182. package/dist/namespace-h0HIuqx0.mjs +0 -1
  183. package/dist/package-1DS4bXg5.mjs +0 -1
  184. package/dist/primitive-runtime-DcYYWy_6.mjs +0 -8
  185. package/dist/schema-DCJyzRHe.mjs +0 -1
  186. package/dist/schema-DOnJmAPw.mjs +0 -1
  187. package/dist/session-BnfsJoZi.mjs +0 -134
  188. package/dist/tools-DC4KrqI1.mjs +0 -1
  189. package/dist/types-BhXRffJ_.d.mts +0 -31
  190. package/dist/workflow-worker-DvP753UN.mjs +0 -1
  191. /package/dist/{cleanEnvForAdapter-BlpmyXYk.mjs → cleanEnvForAdapter-vZfPGi0X.mjs} +0 -0
  192. /package/dist/{create-static-mount-CFGo91CI.mjs → create-static-mount-BB1MIQ9J.mjs} +0 -0
  193. /package/dist/{jsonl-transport-BxNXizIm.mjs → jsonl-transport-C21tpVfe.mjs} +0 -0
  194. /package/dist/{src-Z3vAZJfw.mjs → src-DedDL9iv.mjs} +0 -0
package/README.md CHANGED
@@ -67,6 +67,35 @@ Switch `adapterName` and the same code runs against any supported provider.
67
67
  | `@makaio/framework/tools` | Tool contract, defineTool(), defineToolset() |
68
68
  | `@makaio/framework/testing` | Test helpers, bus fixtures, SQLite harness |
69
69
 
70
+ ## PostgreSQL Backend
71
+
72
+ SQLite is the default backend and needs no configuration. To run against PostgreSQL instead, install the `@makaio/storage-pg` engine package in your application and point the runtime at your server:
73
+
74
+ ```bash
75
+ npm install @makaio/storage-pg
76
+ export MAKAIO_DATABASE_URL=postgres://user:password@host:5432/makaio
77
+ ```
78
+
79
+ The node-postgres driver (`pg` ^8.x) is a regular dependency of `@makaio/storage-pg` — neither is listed in this package's dependencies or peer dependencies, so selecting SQLite never pulls in a Postgres driver and SQLite-only installs add nothing extra. The driver is pure JavaScript and runs under both Node.js and Bun.
80
+
81
+ **Selecting the backend.** The connection target resolves in this order (empty and whitespace-only values count as unset):
82
+
83
+ 1. The `database.url` boot option
84
+ 2. The `MAKAIO_DATABASE_URL` environment variable
85
+ 3. The `dbPath` option of direct `initializeNodeDatabase` callers (SQLite file path)
86
+ 4. The `MAKAIO_DATABASE_PATH` environment variable (SQLite file path)
87
+ 5. `<makaioHome>/makaio.db` (SQLite default)
88
+
89
+ A `postgres://` or `postgresql://` URL from the first two sources selects PostgreSQL — Node and Bun runtime hosts recognize the scheme and auto-register the installed `@makaio/storage-pg` engine before any database client is created (the `database.engines` boot option stays the explicit registration path). Any other URL scheme there is rejected with an error rather than falling through to SQLite. The connection pool defaults to 4 connections; tune it with the `database.poolMax` boot option.
90
+
91
+ **Migrations.** The package bundles only the SQLite migration chain (`dist/drizzle/`); the Postgres chain ships inside `@makaio/storage-pg` and is resolved through its storage engine. Boot applies the chain matching the selected backend automatically. Concurrent boots against the same Postgres database are safe — migration runs are serialized with a transaction-scoped advisory lock.
92
+
93
+ **Full-text search** works on both backends through the same contracts: FTS5 on SQLite, `tsvector` on Postgres (web-search query syntax via `websearch_to_tsquery`). Relevance scores are positive on both backends but not comparable across them.
94
+
95
+ **Supported version.** CI runs the storage conformance suite against PostgreSQL 18 (`postgres:18-alpine`); use 18 or newer.
96
+
97
+ **Switching an existing SQLite install.** Install `@makaio/storage-pg` and set `MAKAIO_DATABASE_URL`; delete any custom `dbPath` wiring (a URL outranks it, so leftover path configuration is inert). Data is not migrated across backends — the Postgres database starts empty.
98
+
70
99
  ## Documentation
71
100
 
72
101
  - [Getting Started](https://github.com/makaio-ai/makaio-framework/blob/main/docs/getting-started.md)
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "version": 1,
3
- "fingerprint": "9419aa75e4fbc1b2062dec7da5532282732f5d590f8f7c7fbe3557937c1b0e64",
4
- "builtAt": "2026-06-10T08:59:39.232Z"
3
+ "fingerprint": "daeb2026022263a120ed5df0788c9fc1202e6569ad39f3545c9c02e3b3f4e246",
4
+ "builtAt": "2026-06-12T10:44:03.243Z"
5
5
  }
@@ -1,4 +1,4 @@
1
- //#region ../node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.d.ts
1
+ //#region node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.d.ts
2
2
  /**
3
3
  * Notification sent when a suggestion is accepted.
4
4
  */
@@ -5118,7 +5118,7 @@ type WriteTextFileResponse = {
5118
5118
  } | null;
5119
5119
  };
5120
5120
  //#endregion
5121
- //#region ../node_modules/@agentclientprotocol/sdk/dist/jsonrpc.d.ts
5121
+ //#region node_modules/@agentclientprotocol/sdk/dist/jsonrpc.d.ts
5122
5122
  /**
5123
5123
  * JSON-RPC 2.0 type definitions for internal use.
5124
5124
  */
@@ -5149,7 +5149,7 @@ type ErrorResponse = {
5149
5149
  data?: unknown;
5150
5150
  };
5151
5151
  //#endregion
5152
- //#region ../node_modules/@agentclientprotocol/sdk/dist/stream.d.ts
5152
+ //#region node_modules/@agentclientprotocol/sdk/dist/stream.d.ts
5153
5153
  /**
5154
5154
  * Stream interface for ACP connections.
5155
5155
  *
@@ -5163,7 +5163,7 @@ type Stream = {
5163
5163
  readable: ReadableStream<AnyMessage>;
5164
5164
  };
5165
5165
  //#endregion
5166
- //#region ../node_modules/@agentclientprotocol/sdk/dist/acp.d.ts
5166
+ //#region node_modules/@agentclientprotocol/sdk/dist/acp.d.ts
5167
5167
  /**
5168
5168
  * A client-side connection to an agent.
5169
5169
  *
@@ -1,4 +1,4 @@
1
- import { g as BaseAgentConnectorConfig } from "../../types-CmMesAgR.mjs";
1
+ import { g as BaseAgentConnectorConfig } from "../../types-BMpIa4fx.mjs";
2
2
  import { z } from "zod";
3
3
  import { IMakaioBus, MakaioBusContext } from "@makaio/framework/bus";
4
4
  import { AIModelSchema, ProtocolId, ProviderContext } from "@makaio/framework/contracts";
@@ -1 +1 @@
1
- import{t as e}from"../../cleanEnvForAdapter-BlpmyXYk.mjs";import{z as t}from"zod";import n from"node:fs/promises";import{createBusInstance as r,openChannel as i}from"@makaio/framework/bus";import{AIModelSchema as a,CredentialSubjects as o}from"@makaio/framework/contracts";import{BaseAdapterConfigSchema as s,ProviderConfigSchema as c,ProviderDefaultsSchema as l}from"@makaio/framework/contracts/config";import{ProviderStorageSubjects as u}from"@makaio/framework/services/settings/storage";import{resolveTimeouts as d}from"@makaio/framework/utils";import{AdapterSubsystemSubjects as f}from"@makaio/framework/services/adapter-subsystem";import{resolveClientBinary as p}from"@makaio/framework/clients";async function m(e,t={}){if(e.startsWith(`env:`)){let n=e.slice(4);if(!n)throw Error(`Credential reference is missing environment variable name`);return(t.readEnv??(e=>process.env[e]))(n)||null}if(e.startsWith(`file:`)){let r=e.slice(5);if(!r)throw Error(`Credential reference is missing file path`);return(await(t.readFile??(async e=>await n.readFile(e,`utf-8`)))(r)).trim()||null}if(e.startsWith(`keychain:`)){let[n,...r]=e.slice(9).split(`:`);if(!n||r.length===0)throw Error(`Credential reference is missing keychain service or account`);if(!t.resolveKeychain)throw Error(`Keychain credential resolution is not configured`);return t.resolveKeychain(n,r.join(`:`))}return e||null}function h(e,t){let n=e.find(e=>e.id===t);if(!n)throw Error(`Provider definition not found: '${t}'`);if(!g(n))throw Error(`Provider definition '${t}' is missing a defaultModel`);return n}function g(e){return typeof e.defaultModel==`string`&&e.defaultModel.length>0}const _=t.record(t.string(),t.unknown());function v(e){return{getDefaults:()=>e().adapterDefaults,getConfig:async t=>{let{adapterName:n,adapterDefaults:r,adapterDefinition:i,protocol:a}=e(),{providerContext:o}=t,s=o.endpointOverrides?.[a]??null,c=d([{layer:`adapter`,source:n,config:i.defaultTimeouts},{layer:`runtime`,source:`config.ts`,config:t.runtimeTimeouts}]),l={...r.providerConfig,...t.providerConfig,baseUrl:s??t.providerConfig?.baseUrl??r.providerConfig?.baseUrl},u=t.model??r.model;if(!u)throw Error(`No model resolved for adapter "${n}" (agentId: ${t.agentId}). Provide a model explicitly or configure adapterDefaults.model.`);return{...r,...t,adapterName:t.adapterName,model:u,cwd:t.cwd??r.cwd??process.cwd(),timeouts:c,providerConfig:l}}}}async function y(e,t){let n=Object.entries(t);if(n.length===0)return{};let a={},s=e.getContext(),{token:c}=await r({context:s}).request(o.getChannelToken,{}),l=await i(s,`credentials`,{token:c,transports:[]});try{let e=await Promise.allSettled(n.map(([,e])=>l.request(o.resolve,{ref:e})));for(let t=0;t<n.length;t++){let[r,i]=n[t],o=e[t];if(o.status===`fulfilled`)if(o.value.value!==null)a[r]=o.value.value;else if(o.value.error){let e=JSON.stringify(i);console.warn(`[resolveConnectorCredentials] Failed to resolve field '${r}' (ref ${e}):`,o.value.error)}else{let e=JSON.stringify(i);console.info(`[resolveConnectorCredentials] Credential unavailable for field '${r}' (ref ${e}); omitting it from the resolved connector credentials.`)}else{let e=JSON.stringify(i);console.warn(`[resolveConnectorCredentials] Failed to resolve field '${r}' (ref ${e}):`,o.reason)}}}finally{l.close()}return a}async function b(e,t,n){let{config:r}=await e.request(f.getProviderConfig,{id:t});if(!r)throw Error(`ProviderConfig '${t}' not found`);let{context:i}=await e.request(f.buildProviderContext,{providerConfigId:t});if(!i)throw Error(`ProviderConfig '${t}' not found`);if(i.definitionId!==r.definitionId)throw Error(`ProviderConfig '${t}' changed during resolution; retry`);let{provider:a}=await e.request(u.get,{id:i.definitionId});if(!a)throw Error(`ProviderDefinition '${r.definitionId}' not found for config '${t}'`);return{config:r,definition:a,baseUrl:i.endpointOverrides?.[n]??a.endpoints?.[n]??null,credentials:await y(e,i.credentialRefs)}}async function x(e,t,n){let{baseUrl:r,credentials:i}=await b(e,t,n);if(!r)throw Error(`Could not resolve baseUrl for ProviderConfig '${t}' with protocol '${n}'. Ensure the provider definition or config override declares an endpoint for this protocol.`);let a=i.apiKey;if(!a)throw Error(`Could not resolve apiKey for ProviderConfig '${t}'. Store credentials via settings before using this provider.`);return{baseUrl:r,apiKey:a}}function S(e,t){if(!t)return{};let n={};for(let[r,i]of Object.entries(t)){let t=e[r];t!==void 0&&(n[i]=t)}return n}async function C(t){let{bus:n,providerContext:r,clientId:i,baseEnv:a={}}=t,o=await y(n,r?.credentialRefs??{}),s=S(o,r?.credentialEnvVars),c=await p(i);return{credentials:o,credEnv:s,resolvedBinary:c,spawnEnv:{...e(a,{omitEnvVars:r?.ambientCredentialEnvVars}),...s,...c?.env??{}}}}export{a as AIModelSchema,s as BaseAdapterConfigSchema,_ as BaseProviderConfigSchema,c as ProviderConfigSchema,l as ProviderDefaultsSchema,S as buildCredentialEnv,v as createAdapterConfigFactory,h as getDefinitionOrThrow,y as resolveConnectorCredentials,m as resolveCredentialRef,x as resolveProviderEndpoint,b as resolveProviderResolution,C as resolveSessionEnvironment};
1
+ import{t as e}from"../../cleanEnvForAdapter-vZfPGi0X.mjs";import{z as t}from"zod";import n from"node:fs/promises";import{createBusInstance as r,openChannel as i}from"@makaio/framework/bus";import{AIModelSchema as a,CredentialSubjects as o}from"@makaio/framework/contracts";import{BaseAdapterConfigSchema as s,ProviderConfigSchema as c,ProviderDefaultsSchema as l}from"@makaio/framework/contracts/config";import{ProviderStorageSubjects as u}from"@makaio/framework/services/settings/storage";import{resolveTimeouts as d}from"@makaio/framework/utils";import{AdapterSubsystemSubjects as f}from"@makaio/framework/services/adapter-subsystem";import{resolveClientBinary as p}from"@makaio/framework/clients";async function m(e,t={}){if(e.startsWith(`env:`)){let n=e.slice(4);if(!n)throw Error(`Credential reference is missing environment variable name`);return(t.readEnv??(e=>process.env[e]))(n)||null}if(e.startsWith(`file:`)){let r=e.slice(5);if(!r)throw Error(`Credential reference is missing file path`);return(await(t.readFile??(async e=>await n.readFile(e,`utf-8`)))(r)).trim()||null}if(e.startsWith(`keychain:`)){let[n,...r]=e.slice(9).split(`:`);if(!n||r.length===0)throw Error(`Credential reference is missing keychain service or account`);if(!t.resolveKeychain)throw Error(`Keychain credential resolution is not configured`);return t.resolveKeychain(n,r.join(`:`))}return e||null}function h(e,t){let n=e.find(e=>e.id===t);if(!n)throw Error(`Provider definition not found: '${t}'`);if(!g(n))throw Error(`Provider definition '${t}' is missing a defaultModel`);return n}function g(e){return typeof e.defaultModel==`string`&&e.defaultModel.length>0}const _=t.record(t.string(),t.unknown());function v(e){return{getDefaults:()=>e().adapterDefaults,getConfig:async t=>{let{adapterName:n,adapterDefaults:r,adapterDefinition:i,protocol:a}=e(),{providerContext:o}=t,s=o.endpointOverrides?.[a]??null,c=d([{layer:`adapter`,source:n,config:i.defaultTimeouts},{layer:`runtime`,source:`config.ts`,config:t.runtimeTimeouts}]),l={...r.providerConfig,...t.providerConfig,baseUrl:s??t.providerConfig?.baseUrl??r.providerConfig?.baseUrl},u=t.model??r.model;if(!u)throw Error(`No model resolved for adapter "${n}" (agentId: ${t.agentId}). Provide a model explicitly or configure adapterDefaults.model.`);return{...r,...t,adapterName:t.adapterName,model:u,cwd:t.cwd??r.cwd??process.cwd(),timeouts:c,providerConfig:l}}}}async function y(e,t){let n=Object.entries(t);if(n.length===0)return{};let a={},s=e.getContext(),{token:c}=await r({context:s}).request(o.getChannelToken,{}),l=await i(s,`credentials`,{token:c,transports:[]});try{let e=await Promise.allSettled(n.map(([,e])=>l.request(o.resolve,{ref:e})));for(let t=0;t<n.length;t++){let[r,i]=n[t],o=e[t];if(o.status===`fulfilled`)if(o.value.value!==null)a[r]=o.value.value;else if(o.value.error){let e=JSON.stringify(i);console.warn(`[resolveConnectorCredentials] Failed to resolve field '${r}' (ref ${e}):`,o.value.error)}else{let e=JSON.stringify(i);console.info(`[resolveConnectorCredentials] Credential unavailable for field '${r}' (ref ${e}); omitting it from the resolved connector credentials.`)}else{let e=JSON.stringify(i);console.warn(`[resolveConnectorCredentials] Failed to resolve field '${r}' (ref ${e}):`,o.reason)}}}finally{l.close()}return a}async function b(e,t,n){let{config:r}=await e.request(f.getProviderConfig,{id:t});if(!r)throw Error(`ProviderConfig '${t}' not found`);let{context:i}=await e.request(f.buildProviderContext,{providerConfigId:t});if(!i)throw Error(`ProviderConfig '${t}' not found`);if(i.definitionId!==r.definitionId)throw Error(`ProviderConfig '${t}' changed during resolution; retry`);let{provider:a}=await e.request(u.get,{id:i.definitionId});if(!a)throw Error(`ProviderDefinition '${r.definitionId}' not found for config '${t}'`);return{config:r,definition:a,baseUrl:i.endpointOverrides?.[n]??a.endpoints?.[n]??null,credentials:await y(e,i.credentialRefs)}}async function x(e,t,n){let{baseUrl:r,credentials:i}=await b(e,t,n);if(!r)throw Error(`Could not resolve baseUrl for ProviderConfig '${t}' with protocol '${n}'. Ensure the provider definition or config override declares an endpoint for this protocol.`);let a=i.apiKey;if(!a)throw Error(`Could not resolve apiKey for ProviderConfig '${t}'. Store credentials via settings before using this provider.`);return{baseUrl:r,apiKey:a}}function S(e,t){if(!t)return{};let n={};for(let[r,i]of Object.entries(t)){let t=e[r];t!==void 0&&(n[i]=t)}return n}async function C(t){let{bus:n,providerContext:r,clientId:i,baseEnv:a={}}=t,o=await y(n,r?.credentialRefs??{}),s=S(o,r?.credentialEnvVars),c=await p(i);return{credentials:o,credEnv:s,resolvedBinary:c,spawnEnv:{...e(a,{omitEnvVars:r?.ambientCredentialEnvVars}),...s,...c?.env??{}}}}export{a as AIModelSchema,s as BaseAdapterConfigSchema,_ as BaseProviderConfigSchema,c as ProviderConfigSchema,l as ProviderDefaultsSchema,S as buildCredentialEnv,v as createAdapterConfigFactory,h as getDefinitionOrThrow,y as resolveConnectorCredentials,m as resolveCredentialRef,x as resolveProviderEndpoint,b as resolveProviderResolution,C as resolveSessionEnvironment};
@@ -1,4 +1,4 @@
1
- import { A as MessageHandle, B as ReasoningLevelMap, C as SendMessageRequestPayload, D as IAdapterConfigFactory, E as ConfigFactoryInput, F as MessageState, H as LedgerSessionContext, I as ProcessingState, L as SendMessageOptions, M as NormalizedMessageInput, N as normalizeMessageInput, O as AIAgentConnector, P as MessageResult, R as AIModel, S as NormalizedCallUsage, T as StartAgentOptions, U as SessionToolLedger, V as ISessionToolLedger, W as ToolLedgerEntry, _ as ConnectorSendMessageOptions, a as AgentCwdChangeRequestPayload, b as ExecutionContext, c as AgentInterruptRequestPayload, d as AgentMcpServersSetResponsePayload, f as AgentModelChangeRequestPayload, g as BaseAgentConnectorConfig, h as AgentStartResult, i as AgentCredentialChangeResponsePayload, j as markCompletedWithFinalResult, k as MessageDeliveryMode, l as AgentInterruptResponsePayload, m as AgentSendMessageOptions, n as AgentContext, o as AgentCwdChangeResponsePayload, p as AgentModelChangeResponsePayload, r as AgentCredentialChangeRequestPayload, s as AgentIdentity, t as AIAgentConfig, u as AgentMcpServersSetRequestPayload, v as ConnectorStartOptions, w as SendMessageResponsePayload, x as GetCapabilitiesResponsePayload, y as ContextWindowInput, z as AIReasoningLevel } from "../types-CmMesAgR.mjs";
1
+ import { A as MessageHandle, B as ReasoningLevelMap, C as SendMessageRequestPayload, D as IAdapterConfigFactory, E as ConfigFactoryInput, F as MessageState, H as LedgerSessionContext, I as ProcessingState, L as SendMessageOptions, M as NormalizedMessageInput, N as normalizeMessageInput, O as AIAgentConnector, P as MessageResult, R as AIModel, S as NormalizedCallUsage, T as StartAgentOptions, U as SessionToolLedger, V as ISessionToolLedger, W as ToolLedgerEntry, _ as ConnectorSendMessageOptions, a as AgentCwdChangeRequestPayload, b as ExecutionContext, c as AgentInterruptRequestPayload, d as AgentMcpServersSetResponsePayload, f as AgentModelChangeRequestPayload, g as BaseAgentConnectorConfig, h as AgentStartResult, i as AgentCredentialChangeResponsePayload, j as markCompletedWithFinalResult, k as MessageDeliveryMode, l as AgentInterruptResponsePayload, m as AgentSendMessageOptions, n as AgentContext, o as AgentCwdChangeResponsePayload, p as AgentModelChangeResponsePayload, r as AgentCredentialChangeRequestPayload, s as AgentIdentity, t as AIAgentConfig, u as AgentMcpServersSetRequestPayload, v as ConnectorStartOptions, w as SendMessageResponsePayload, x as GetCapabilitiesResponsePayload, y as ContextWindowInput, z as AIReasoningLevel } from "../types-BMpIa4fx.mjs";
2
2
  import { _ as LogImporterConfig, a as CompactionMetadata, b as StorageMessagePayload, c as ExternalToolIdentifiers, d as ImportMetadata, f as ImportSegment, g as LogImporter, h as LogImportTestConfig, l as ExternalToolMeta, m as LogImportSessionContext, n as LogOrchestratorConfig, o as DiscoveryMetadata, p as ImportSegmentLineage, r as ParseFileResult, s as ExternalToolIdentifier, u as ImportCursorPosition, v as NormalizedEvent, x as toImportSegment, y as ProcessLogFileResult } from "../base-orchestrator-M5mAB5-w.mjs";
3
3
  import { z } from "zod";
4
4
  import * as _$_makaio_core0 from "@makaio/framework/core";
@@ -1,4 +1,4 @@
1
- import{o as e,t}from"../chunk-DTipWd-i.mjs";import{t as n}from"../cleanEnvForAdapter-BlpmyXYk.mjs";import{i as r,n as i,r as a,t as o}from"../cursor-storage-C_WTAESV.mjs";import{_ as s,a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as ee,s as b,t as te,u as x,v as S}from"../ajv-BJsabpMb.mjs";import{z as C}from"zod";import*as ne from"node:fs";import{AuthenticationError as re,DirectoryNotFoundError as ie,ModelUnavailableError as ae,QuotaExceededError as oe,RateLimitError as se,createBusNamespace as ce}from"@makaio/framework/core";import{MakaioBus as w,NoHandlerError as le,RequestError as ue}from"@makaio/framework/bus";import{AdapterSubjects as T,AgentSubjects as E,AgentToolApproveSchema as D,HarnessSubjects as O,MCP_CALL_TOOL_NAME as de,McpSubjects as k,SessionContextSchema as A,SessionSubjects as j}from"@makaio/framework/contracts";import{TurnStorageSubjects as fe}from"@makaio/framework/services/turn";import{CredentialRefSchema as pe}from"@makaio/framework/contracts/config";import{runPostUserMessageHooks as me,runPreUserMessageHooks as he}from"@makaio/framework/hooks";import{activateProviderContextStrict as ge,buildProviderContext as _e}from"@makaio/framework/services/provider-context";import ve from"node:os";import{AgentStorageSubjects as M}from"@makaio/framework/services/session";import{DeferredPromise as N,resolveTimeouts as ye}from"@makaio/framework/utils";import*as be from"node:process";function xe(e,t,n){return w.registerNamespace(ce(e,t,n))}function P(e){let t=[];try{return JSON.stringify(e,function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n},2)??`[Non-serializable value]`}catch{try{return String(e)}catch{return`[Non-serializable value]`}}}function Se(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`'`,`&apos;`)}function Ce(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);return t.length===0?`context`:/^[A-Za-z_]/.test(t)?t:`context_${t}`}function we(e,t){let n=Ce(e);return`<${n}>\n${Se(t)}\n</${n}>`}function Te(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`&&typeof t.description==`string`&&(t.compatibility===void 0||typeof t.compatibility==`string`)}function Ee(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.metadata,r=n;return typeof t.name==`string`&&typeof t.content==`string`&&(t.license===void 0||typeof t.license==`string`)&&(t.compatibility===void 0||typeof t.compatibility==`string`)&&(t.allowedTools===void 0||typeof t.allowedTools==`string`)&&(n===void 0||typeof n==`object`&&!!n&&Object.values(r??{}).every(e=>typeof e==`string`))}function De(e){if(!Array.isArray(e))return;let t=e.filter(Te).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.compatibility?`- ${e.name}: ${e.description} Compatibility: ${e.compatibility}`:`- ${e.name}: ${e.description}`);return t.length>0?t.join(`
1
+ import{o as e,t}from"../chunk-DTipWd-i.mjs";import{t as n}from"../cleanEnvForAdapter-vZfPGi0X.mjs";import{i as r,n as i,r as a,t as o}from"../cursor-storage-CmKjSvKY.mjs";import{_ as s,a as c,c as l,d as u,f as d,g as f,h as p,i as m,l as h,m as g,n as _,o as v,p as y,r as ee,s as b,t as te,u as x,v as S}from"../ajv-BA2z5ztb.mjs";import{z as C}from"zod";import*as ne from"node:fs";import{AuthenticationError as re,DirectoryNotFoundError as ie,ModelUnavailableError as ae,QuotaExceededError as oe,RateLimitError as se,createBusNamespace as ce}from"@makaio/framework/core";import{MakaioBus as w,NoHandlerError as le,RequestError as ue}from"@makaio/framework/bus";import{AdapterSubjects as T,AgentSubjects as E,AgentToolApproveSchema as D,HarnessSubjects as O,MCP_CALL_TOOL_NAME as de,McpSubjects as k,SessionContextSchema as A,SessionSubjects as j}from"@makaio/framework/contracts";import{TurnStorageSubjects as fe}from"@makaio/framework/services/turn";import{CredentialRefSchema as pe}from"@makaio/framework/contracts/config";import{runPostUserMessageHooks as me,runPreUserMessageHooks as he}from"@makaio/framework/hooks";import{activateProviderContextStrict as ge,buildProviderContext as _e}from"@makaio/framework/services/provider-context";import ve from"node:os";import{AgentStorageSubjects as M}from"@makaio/framework/services/session";import{DeferredPromise as N,resolveTimeouts as ye}from"@makaio/framework/utils";import*as be from"node:process";function xe(e,t,n){return w.registerNamespace(ce(e,t,n))}function P(e){let t=[];try{return JSON.stringify(e,function(e,n){if(typeof n==`bigint`)return n.toString();if(typeof n==`object`&&n){for(;t.length>0&&t[t.length-1]!==this;)t.pop();if(t.includes(n))return`[Circular]`;t.push(n)}return n},2)??`[Non-serializable value]`}catch{try{return String(e)}catch{return`[Non-serializable value]`}}}function Se(e){return e.replaceAll(`&`,`&amp;`).replaceAll(`<`,`&lt;`).replaceAll(`>`,`&gt;`).replaceAll(`'`,`&apos;`)}function Ce(e){let t=e.replace(/[^a-zA-Z0-9_-]/g,`_`);return t.length===0?`context`:/^[A-Za-z_]/.test(t)?t:`context_${t}`}function we(e,t){let n=Ce(e);return`<${n}>\n${Se(t)}\n</${n}>`}function Te(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.name==`string`&&typeof t.description==`string`&&(t.compatibility===void 0||typeof t.compatibility==`string`)}function Ee(e){if(typeof e!=`object`||!e)return!1;let t=e,n=t.metadata,r=n;return typeof t.name==`string`&&typeof t.content==`string`&&(t.license===void 0||typeof t.license==`string`)&&(t.compatibility===void 0||typeof t.compatibility==`string`)&&(t.allowedTools===void 0||typeof t.allowedTools==`string`)&&(n===void 0||typeof n==`object`&&!!n&&Object.values(r??{}).every(e=>typeof e==`string`))}function De(e){if(!Array.isArray(e))return;let t=e.filter(Te).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>e.compatibility?`- ${e.name}: ${e.description} Compatibility: ${e.compatibility}`:`- ${e.name}: ${e.description}`);return t.length>0?t.join(`
2
2
  `):void 0}function Oe(e){if(!Array.isArray(e))return;let t=e.filter(Ee).sort((e,t)=>e.name.localeCompare(t.name)).map(e=>{let t=[`## ${e.name}`];return e.compatibility&&t.push(`Compatibility: ${e.compatibility}`),t.push(e.content),t.join(`
3
3
  `)});return t.length>0?t.join(`
4
4
 
@@ -1,4 +1,4 @@
1
- import{o as e,t}from"../chunk-DTipWd-i.mjs";import{i as n,r}from"../cursor-storage-C_WTAESV.mjs";import{t as i}from"../globby-4SrlyIlj.mjs";import*as a from"node:fs/promises";import*as o from"node:path";import{MakaioBus as s}from"@makaio/framework/bus";import{AdapterSubjects as c,SessionStorageSubjects as l,SessionSubjects as u}from"@makaio/framework/contracts";const d=65536;async function f(e){let{filePath:t,startOffset:n=0}=e,r=[],i=[],o=n,s;try{s=await a.open(t,`r`);let e=await s.stat();if(n>=e.size)return{records:r,bytesRead:n,errors:i};let c=Buffer.alloc(d),l=``,u=n,f=0;for(n>0&&(f=await _(s,n));u<e.size;){let{bytesRead:e}=await s.read(c,0,d,u);if(e===0)break;l+=c.toString(`utf8`,0,e),u+=e;let t=l.split(`
1
+ import{o as e,t}from"../chunk-DTipWd-i.mjs";import{i as n,r}from"../cursor-storage-CmKjSvKY.mjs";import{t as i}from"../globby-BIH65cbN.mjs";import*as a from"node:fs/promises";import*as o from"node:path";import{MakaioBus as s}from"@makaio/framework/bus";import{AdapterSubjects as c,SessionStorageSubjects as l,SessionSubjects as u}from"@makaio/framework/contracts";const d=65536;async function f(e){let{filePath:t,startOffset:n=0}=e,r=[],i=[],o=n,s;try{s=await a.open(t,`r`);let e=await s.stat();if(n>=e.size)return{records:r,bytesRead:n,errors:i};let c=Buffer.alloc(d),l=``,u=n,f=0;for(n>0&&(f=await _(s,n));u<e.size;){let{bytesRead:e}=await s.read(c,0,d,u);if(e===0)break;l+=c.toString(`utf8`,0,e),u+=e;let t=l.split(`
2
2
  `),n=t.pop();for(let e of t){if(f++,e.trim()===``){o+=Buffer.byteLength(e,`utf8`)+1;continue}let t=h(e,f);t.success?r.push(t.record):i.push(t.error),o+=Buffer.byteLength(e,`utf8`)+1}l=n??``}return{records:r,bytesRead:o,errors:i}}finally{s&&await s.close()}}async function p(e,t){let n=[],r;try{r=await a.open(e,`r`);let i=Buffer.alloc(d),o=``,s=0;for(;n.length<t;){let{bytesRead:e}=await r.read(i,0,d,s);if(e===0)break;o+=i.toString(`utf8`,0,e),s+=e;let a=o.split(`
3
3
  `);o=a.pop()??``;for(let e of a){if(n.length>=t)break;let r=e.trim();if(r!==``)try{n.push(JSON.parse(r))}catch{}}}return n}finally{r&&await r.close()}}async function m(e,t){let n;try{n=await a.open(e,`r`);let r=Buffer.alloc(d),i=``,o=0;for(;;){let{bytesRead:e}=await n.read(r,0,d,o);if(e===0)break;i+=r.toString(`utf8`,0,e),o+=e;let a=i.split(`
4
4
  `);i=a.pop()??``;for(let e of a){let n=e.trim();if(n!==``)try{if(t(JSON.parse(n)))return!0}catch{}}}return!1}finally{n&&await n.close()}}function h(e,t){try{return{success:!0,record:JSON.parse(e)}}catch(n){return{success:!1,error:{line:t,error:n instanceof Error?n.message:String(n),content:g(e)}}}}function g(e){return e.length<=200?e:e.slice(0,200)+`...`}async function _(e,t){let n=0,r=Buffer.alloc(d),i=0;for(;i<t;){let a=Math.min(d,t-i),{bytesRead:o}=await e.read(r,0,a,i);if(o===0)break;for(let e=0;e<o;e++)r[e]===10&&n++;i+=o}return n}var v=e(t(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=`~`;function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(r=!1));function a(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,n,i,o){if(typeof n!=`function`)throw TypeError(`The listener must be a function`);var s=new a(n,i||e,o),c=r?r+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],s]:e._events[c].push(s):(e._events[c]=s,e._eventsCount++),e}function s(e,t){--e._eventsCount===0?e._events=new i:delete e._events[t]}function c(){this._events=new i,this._eventsCount=0}c.prototype.eventNames=function(){var e=[],t,i;if(this._eventsCount===0)return e;for(i in t=this._events)n.call(t,i)&&e.push(r?i.slice(1):i);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},c.prototype.listeners=function(e){var t=r?r+e:e,n=this._events[t];if(!n)return[];if(n.fn)return[n.fn];for(var i=0,a=n.length,o=Array(a);i<a;i++)o[i]=n[i].fn;return o},c.prototype.listenerCount=function(e){var t=r?r+e:e,n=this._events[t];return n?n.fn?1:n.length:0},c.prototype.emit=function(e,t,n,i,a,o){var s=r?r+e:e;if(!this._events[s])return!1;var c=this._events[s],l=arguments.length,u,d;if(c.fn){switch(c.once&&this.removeListener(e,c.fn,void 0,!0),l){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,t),!0;case 3:return c.fn.call(c.context,t,n),!0;case 4:return c.fn.call(c.context,t,n,i),!0;case 5:return c.fn.call(c.context,t,n,i,a),!0;case 6:return c.fn.call(c.context,t,n,i,a,o),!0}for(d=1,u=Array(l-1);d<l;d++)u[d-1]=arguments[d];c.fn.apply(c.context,u)}else{var f=c.length,p;for(d=0;d<f;d++)switch(c[d].once&&this.removeListener(e,c[d].fn,void 0,!0),l){case 1:c[d].fn.call(c[d].context);break;case 2:c[d].fn.call(c[d].context,t);break;case 3:c[d].fn.call(c[d].context,t,n);break;case 4:c[d].fn.call(c[d].context,t,n,i);break;default:if(!u)for(p=1,u=Array(l-1);p<l;p++)u[p-1]=arguments[p];c[d].fn.apply(c[d].context,u)}}return!0},c.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},c.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},c.prototype.removeListener=function(e,t,n,i){var a=r?r+e:e;if(!this._events[a])return this;if(!t)return s(this,a),this;var o=this._events[a];if(o.fn)o.fn===t&&(!i||o.once)&&(!n||o.context===n)&&s(this,a);else{for(var c=0,l=[],u=o.length;c<u;c++)(o[c].fn!==t||i&&!o[c].once||n&&o[c].context!==n)&&l.push(o[c]);l.length?this._events[a]=l.length===1?l[0]:l:s(this,a)}return this},c.prototype.removeAllListeners=function(e){var t;return e?(t=r?r+e:e,this._events[t]&&s(this,t)):(this._events=new i,this._eventsCount=0),this},c.prototype.off=c.prototype.removeListener,c.prototype.addListener=c.prototype.on,c.prefixed=r,c.EventEmitter=c,t!==void 0&&(t.exports=c)}))(),1),y=class e extends Error{name=`TimeoutError`;constructor(t,n){super(t,n),Error.captureStackTrace?.(this,e)}};const b=e=>e.reason??new DOMException(`This operation was aborted.`,`AbortError`);function x(e,t){let{milliseconds:n,fallback:r,message:i,customTimers:a={setTimeout,clearTimeout},signal:o}=t,s,c,l=new Promise((t,l)=>{if(typeof n!=`number`||Math.sign(n)!==1)throw TypeError(`Expected \`milliseconds\` to be a positive number, got \`${n}\``);if(o?.aborted){l(b(o));return}if(o&&(c=()=>{l(b(o))},o.addEventListener(`abort`,c,{once:!0})),e.then(t,l),n===1/0)return;let u=new y;s=a.setTimeout.call(void 0,()=>{if(r){try{t(r())}catch(e){l(e)}return}typeof e.cancel==`function`&&e.cancel(),i===!1?t():i instanceof Error?l(i):(u.message=i??`Promise timed out after ${n} milliseconds`,l(u))},n)}).finally(()=>{l.clear(),c&&o&&o.removeEventListener(`abort`,c)});return l.clear=()=>{a.clearTimeout.call(void 0,s),s=void 0},l}function S(e,t,n){let r=0,i=e.length;for(;i>0;){let a=Math.trunc(i/2),o=r+a;n(e[o],t)<=0?(r=++o,i-=a+1):i=a}return r}var C=class{#e=[];#t=0;enqueue(e,t){let{priority:n=0,id:r}=t??{},{size:i}=this,a={priority:n,id:r,run:e};if(i===0){this.#e.length=0,this.#t=0,this.#e.push(a);return}if(this.#e.at(-1).priority>=n){this.#e.push(a);return}this.#n();let o=S(this.#e,a,(e,t)=>t.priority-e.priority);this.#e.splice(o,0,a)}setPriority(e,t){let n=this.#e.findIndex((t,n)=>n>=this.#t&&t.id===e);if(n===-1)throw ReferenceError(`No promise function with the id "${e}" exists in the queue.`);let[r]=this.#e.splice(n,1);this.enqueue(r.run,{priority:t,id:e})}remove(e){let t=this.#e.findIndex((t,n)=>n<this.#t?!1:typeof e==`string`?t.id===e:t.run===e);t!==-1&&this.#e.splice(t,1)}dequeue(){if(this.#t===this.#e.length)return;let e=this.#e[this.#t];return this.#t++,this.#t===this.#e.length?(this.#e.length=0,this.#t=0):this.#t>100&&this.#t>this.#e.length/2&&this.#n(),e?.run}filter(e){let t=[];for(let n=this.#t;n<this.#e.length;n++){let r=this.#e[n];r.priority===e.priority&&t.push(r.run)}return t}get size(){return this.#e.length-this.#t}#n(){this.#t!==0&&(this.#e.splice(0,this.#t),this.#t=0)}},w=class extends v.default{#e;#t;#n=0;#r;#i=!1;#a=!1;#o;#s=0;#c=0;#l;#u;#d;#f=[];#p=0;#m;#h;#g=0;#_;#v;#y=1n;#b=new Map;#x=new Set;timeout;constructor(e){if(super(),e={carryoverIntervalCount:!1,intervalCap:1/0,interval:0,concurrency:1/0,autoStart:!0,queueClass:C,strict:!1,...e},!(typeof e.intervalCap==`number`&&e.intervalCap>=1))throw TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${e.intervalCap?.toString()??``}\` (${typeof e.intervalCap})`);if(e.interval===void 0||!(Number.isFinite(e.interval)&&e.interval>=0))throw TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${e.interval?.toString()??``}\` (${typeof e.interval})`);if(e.strict&&e.interval===0)throw TypeError("The `strict` option requires a non-zero `interval`");if(e.strict&&e.intervalCap===1/0)throw TypeError("The `strict` option requires a finite `intervalCap`");if(this.#e=e.carryoverIntervalCount??e.carryoverConcurrencyCount??!1,this.#t=e.intervalCap===1/0||e.interval===0,this.#r=e.intervalCap,this.#o=e.interval,this.#d=e.strict,this.#m=new e.queueClass,this.#h=e.queueClass,this.concurrency=e.concurrency,e.timeout!==void 0&&!(Number.isFinite(e.timeout)&&e.timeout>0))throw TypeError(`Expected \`timeout\` to be a positive finite number, got \`${e.timeout}\` (${typeof e.timeout})`);this.timeout=e.timeout,this.#v=e.autoStart===!1,this.#z()}#S(e){for(;this.#p<this.#f.length;){let t=this.#f[this.#p];if(t!==void 0&&e-t>=this.#o)this.#p++;else break}(this.#p>100&&this.#p>this.#f.length/2||this.#p===this.#f.length)&&(this.#f=this.#f.slice(this.#p),this.#p=0)}#C(e){this.#d?this.#f.push(e):this.#n++}#w(){this.#d?this.#f.length>this.#p&&this.#f.pop():this.#n>0&&this.#n--}#T(){return this.#f.length-this.#p}get#E(){return this.#t?!0:this.#d?this.#T()<this.#r:this.#n<this.#r}get#D(){return this.#g<this.#_}#O(){this.#g--,this.#g===0&&this.emit(`pendingZero`),this.#P(),this.emit(`next`)}#k(){this.#u=void 0,this.#I(),this.#F()}#A(e){if(this.#d){if(this.#S(e),this.#T()>=this.#r){let t=this.#f[this.#p],n=this.#o-(e-t);return this.#j(n),!0}return!1}if(this.#l===void 0){let t=this.#s-e;if(t<0){if(this.#c>0){let t=e-this.#c;if(t<this.#o)return this.#j(this.#o-t),!0}this.#n=this.#e?this.#g:0}else return this.#j(t),!0}return!1}#j(e){this.#u===void 0&&(this.#u=setTimeout(()=>{this.#k()},e))}#M(){this.#l&&=(clearInterval(this.#l),void 0)}#N(){this.#u&&=(clearTimeout(this.#u),void 0)}#P(){if(this.#m.size===0){if(this.#M(),this.emit(`empty`),this.#g===0){if(this.#N(),this.#d&&this.#p>0){let e=Date.now();this.#S(e)}this.emit(`idle`)}return!1}let e=!1;if(!this.#v){let t=Date.now(),n=!this.#A(t);if(this.#E&&this.#D){let r=this.#m.dequeue();this.#t||(this.#C(t),this.#B()),this.emit(`active`),r(),n&&this.#F(),e=!0}}return e}#F(){this.#t||this.#l!==void 0||this.#d||(this.#l=setInterval(()=>{this.#I()},this.#o),this.#s=Date.now()+this.#o)}#I(){this.#d||(this.#n===0&&this.#g===0&&this.#l&&this.#M(),this.#n=this.#e?this.#g:0),this.#L(),this.#B()}#L(){for(;this.#P(););}get concurrency(){return this.#_}set concurrency(e){if(!(typeof e==`number`&&e>=1))throw TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${e}\` (${typeof e})`);this.#_=e,this.#L()}setPriority(e,t){if(typeof t!=`number`||!Number.isFinite(t))throw TypeError(`Expected \`priority\` to be a finite number, got \`${t}\` (${typeof t})`);this.#m.setPriority(e,t)}async add(e,t={}){return t={timeout:this.timeout,...t,id:t.id??(this.#y++).toString()},new Promise((n,r)=>{let i=Symbol(`task-${t.id}`),a=()=>void 0,o=async()=>{a(),this.#g++,this.#b.set(i,{id:t.id,priority:t.priority??0,startTime:Date.now(),timeout:t.timeout});let o;try{try{t.signal?.throwIfAborted()}catch(e){throw this.#V(),this.#b.delete(i),e}this.#c=Date.now();let r=e({signal:t.signal});if(t.timeout&&(r=x(Promise.resolve(r),{milliseconds:t.timeout,message:`Task timed out after ${t.timeout}ms (queue has ${this.#g} running, ${this.#m.size} waiting)`})),t.signal){let{signal:e}=t;r=Promise.race([r,new Promise((t,n)=>{o=()=>{n(e.reason)},e.addEventListener(`abort`,o,{once:!0})})])}let a=await r;n(a),this.emit(`completed`,a)}catch(e){r(e),this.emit(`error`,e)}finally{o&&t.signal?.removeEventListener(`abort`,o),this.#b.delete(i),queueMicrotask(()=>{this.#O()})}};this.#m.enqueue(o,t);let s=()=>{if(this.#m instanceof C){this.#m.remove(o);return}this.#m.remove?.(t.id)};if(t.signal){let{signal:e}=t,n=()=>{a(),s(),r(e.reason),this.#P(),this.emit(`next`)};if(a=()=>{e.removeEventListener(`abort`,n),this.#x.delete(a)},e.aborted){n();return}e.addEventListener(`abort`,n,{once:!0}),this.#x.add(a)}this.emit(`add`),this.#P()})}async addAll(e,t){return Promise.all(e.map(async e=>this.add(e,t)))}start(){return this.#v?(this.#v=!1,this.#L(),this):this}pause(){this.#v=!0}clear(){for(let e of this.#x)e();this.#m=new this.#h,this.#M(),this.#H(),this.emit(`empty`),this.#g===0&&(this.#N(),this.emit(`idle`)),this.emit(`next`)}async onEmpty(){this.#m.size!==0&&await this.#R(`empty`)}async onSizeLessThan(e){this.#m.size<e||await this.#R(`next`,()=>this.#m.size<e)}async onIdle(){this.#g===0&&this.#m.size===0||await this.#R(`idle`)}async onPendingZero(){this.#g!==0&&await this.#R(`pendingZero`)}async onRateLimit(){this.isRateLimited||await this.#R(`rateLimit`)}async onRateLimitCleared(){this.isRateLimited&&await this.#R(`rateLimitCleared`)}onError(){return new Promise((e,t)=>{let n=e=>{this.off(`error`,n),t(e)};this.on(`error`,n)})}async#R(e,t){return new Promise(n=>{let r=()=>{t&&!t()||(this.off(e,r),n())};this.on(e,r)})}get size(){return this.#m.size}sizeBy(e){return this.#m.filter(e).length}get pending(){return this.#g}get isPaused(){return this.#v}#z(){this.#t||(this.on(`add`,()=>{this.#m.size>0&&this.#B()}),this.on(`next`,()=>{this.#B()}))}#B(){this.#t||this.#a||(this.#a=!0,queueMicrotask(()=>{this.#a=!1,this.#H()}))}#V(){this.#t||(this.#w(),this.#B())}#H(){let e=this.#i;if(this.#t||this.#m.size===0){e&&(this.#i=!1,this.emit(`rateLimitCleared`));return}let t;if(this.#d){let e=Date.now();this.#S(e),t=this.#T()}else t=this.#n;let n=t>=this.#r;n!==e&&(this.#i=n,this.emit(n?`rateLimit`:`rateLimitCleared`))}get isRateLimited(){return this.#i}get isSaturated(){return this.#g===this.#_&&this.#m.size>0||this.isRateLimited&&this.#m.size>0}get runningTasks(){return[...this.#b.values()].map(e=>({...e,timeoutRemaining:e.timeout?Math.max(0,e.startTime+e.timeout-Date.now()):void 0}))}},T=class{eventQueue;cursorQueue;onEventEmitted;constructor(e){this.onEventEmitted=e.onEventEmitted,this.eventQueue=new w({concurrency:1,interval:1e3,intervalCap:e.eventsPerSecond}),this.cursorQueue=new w({concurrency:1})}queueEvent(e){return this.eventQueue.add(async()=>{await s.emit(e.subject,e.payload),this.onEventEmitted()})}queueAfterEvents(e,t=[]){let n=Promise.all(t);return n.catch(()=>void 0),this.cursorQueue.add(async()=>{await n,await e()})}async drain(){await Promise.all([this.eventQueue.onIdle(),this.cursorQueue.onIdle()])}async onIdle(){await this.drain()}},E=class{options;emittery=new n;trackedFiles=new Map;pollTimer;isPolling=!1;isDisposed=!1;inFlightChecks=new Map;constructor(e){if(!o.isAbsolute(e.directory))throw Error(`Directory must be an absolute path: ${e.directory}`);this.options={directory:e.directory,pattern:e.pattern,pollIntervalMs:e.pollIntervalMs??1e4}}on(e,t){return this.emittery.on(e,t)}once(e,t){return this.emittery.once(e,t)}async start(){this.isDisposed||this.pollTimer===void 0&&(await this.poll(),this.pollTimer=setInterval(()=>{this.poll()},this.options.pollIntervalMs))}stop(){this.pollTimer!==void 0&&(clearInterval(this.pollTimer),this.pollTimer=void 0)}dispose(){this.isDisposed=!0,this.stop(),this.emittery.clearListeners(),this.trackedFiles.clear(),this.inFlightChecks.clear()}isRunning(){return this.pollTimer!==void 0}getTrackedFiles(){return this.trackedFiles}seedFromCursors(e){for(let t of e)this.trackedFiles.set(t.filePath,{size:t.bytesRead,mtimeMs:new Date(t.lastModified).getTime()})}async poll(){if(!this.isDisposed&&!this.isPolling){this.isPolling=!0;try{let e=await this.discoverFiles(),t=new Set(e);for(let e of this.trackedFiles.keys())if(!t.has(e)){if(this.isDisposed)return;this.trackedFiles.delete(e),await this.emittery.emit(`deleted`,{filePath:e})}for(let t of e)try{await this.runFileCheck(t)}catch(e){await this.emitWatcherError(e,t)}if(this.isDisposed)return;await this.emittery.emit(`polled`,{trackedFilePaths:new Set(this.trackedFiles.keys())})}catch(e){await this.emitWatcherError(e)}finally{this.isPolling=!1}}}async discoverFiles(){return i(this.options.pattern,{cwd:this.options.directory,absolute:!0,onlyFiles:!0})}async checkFile(e){if(this.isDisposed)return;let t=await a.stat(e);if(this.isDisposed)return;let n={size:t.size,mtimeMs:t.mtimeMs},r=this.trackedFiles.get(e);if(!r){if(this.trackedFiles.set(e,n),this.isDisposed){this.trackedFiles.delete(e);return}await this.emittery.emit(`change`,{filePath:e,stat:{size:t.size,mtime:t.mtime},changeType:`created`});return}if(n.mtimeMs!==r.mtimeMs){let i=n.size<r.size?`rotated`:`modified`;if(this.trackedFiles.set(e,n),this.isDisposed)return;await this.emittery.emit(`change`,{filePath:e,stat:{size:t.size,mtime:t.mtime},changeType:i})}}clearTrackedFile(e){return this.trackedFiles.delete(e)}clearAllTrackedFiles(){this.trackedFiles.clear()}triggerImmediatePoll(e){this.runFileCheck(e).catch(t=>{this.emitWatcherError(t,e)})}async runFileCheck(e){if(this.isDisposed)return;let t=this.inFlightChecks.get(e);if(t){await t;return}let n=(async()=>{try{await this.checkFile(e)}finally{this.inFlightChecks.delete(e)}})();this.inFlightChecks.set(e,n),await n}async emitWatcherError(e,t){let n=e instanceof Error?e:Error(String(e));try{await this.emittery.emit(`error`,{error:n,filePath:t})}catch(e){console.error(`[LogFileWatcher] Error listener failed:`,e instanceof Error?e.message:String(e))}}},D=class{watcher;constructor(e){this.watcher=new E(e)}isRunning(){return this.watcher.isRunning()}async start(){await this.watcher.start()}stop(){this.watcher.stop()}dispose(){this.watcher.dispose()}onChange(e){return this.watcher.on(`change`,e)}onError(e){return this.watcher.on(`error`,e)}onDeleted(e){return this.watcher.on(`deleted`,e)}onPolled(e){return this.watcher.on(`polled`,({trackedFilePaths:t})=>e(t))}getTrackedFileMtimeMs(e){return this.watcher.getTrackedFiles().get(e)?.mtimeMs}triggerImmediatePoll(e){this.watcher.triggerImmediatePoll(e)}seedFromCursors(e){this.watcher.seedFromCursors(e)}},O=class{filesProcessed=0;eventsEmitted=0;sessionsImported=new Set;sessionsSkipped=new Set;lastLoggedEventCount=0;lastLoggedSnapshot=``;reset(){this.filesProcessed=0,this.eventsEmitted=0,this.sessionsImported.clear(),this.sessionsSkipped.clear(),this.lastLoggedEventCount=0,this.lastLoggedSnapshot=``}recordFileProcessed(){this.filesProcessed++}recordEventEmitted(e){this.eventsEmitted++,!(this.eventsEmitted-this.lastLoggedEventCount<1e3)&&(console.info(`${e} Imported ${this.eventsEmitted} events (${this.sessionsImported.size} sessions)...`),this.lastLoggedEventCount=this.eventsEmitted)}recordSessionImported(e){this.sessionsImported.add(e)}recordSessionSkipped(e){this.sessionsSkipped.add(e)}hasActivity(){return this.eventsEmitted>0||this.filesProcessed>0}stoppedMessage(e){return`${e} Stopped - ${this.eventsEmitted} events from ${this.sessionsImported.size} sessions (${this.sessionsSkipped.size} skipped)`}logProgress(e){if(!this.hasActivity())return;let t=JSON.stringify({eventsEmitted:this.eventsEmitted,filesProcessed:this.filesProcessed,sessionsImported:this.sessionsImported.size,sessionsSkipped:this.sessionsSkipped.size});t!==this.lastLoggedSnapshot&&(this.lastLoggedSnapshot=t,console.info(`${e} Progress: ${this.eventsEmitted} events, ${this.sessionsImported.size} sessions, ${this.filesProcessed} files, ${this.sessionsSkipped.size} skipped`))}};function k(){return async e=>{try{let t=await s.request(u.getByAdapterSessionId,{adapterSessionId:e});return t.session!==null&&!t.session.isImported}catch{return!1}}}var A=class{checkedSessions=new Map;inFlight=new Map;async isSkipped(e,t,n){let r=this.checkedSessions.get(e);if(r!==void 0)return r;let i=this.inFlight.get(e);return i||(i=t(e).then(t=>(this.checkedSessions.set(e,t),t&&n(e),t)).finally(()=>{this.inFlight.delete(e)}),this.inFlight.set(e,i)),i}clear(){this.checkedSessions.clear(),this.inFlight.clear()}};function j(e,t,n,r){return!n||!e||r===`rotated`?!1:new Date(e)>=t}function M(e,t,n){for(let r of n??[]){let n=r.line===void 0?``:` at line ${r.line}`;console.warn(`${e} Parse error in ${t}${n}: ${r.error}`)}}async function N(e,t,n,i){let{cursor:a}=await s.request(r.get,{filePath:e});return a&&a.bytesRead>0&&!a.sessionContext&&!t?(await s.request(r.delete,{filePath:e}).catch(()=>{}),i(n),`retry`):a}async function P(e,t,n,r,i,a){let o=await a.parseFile(e,0);M(i,e,o.errors);let s=a.validateRecords(o.records);s.length>0&&await a.handleFirstRead(e,s,o.bytesRead??0,t,n,0,r)}function F(e,t,n,r,i){let a=[];n&&(a.push(i(t.sessionEvent)),a.push(i(t.startedEvent)));let o=r(e,t);for(let e of o)a.push(i(e));return a}function I(e,t){let n=[];for(let r of e)n.push(t(r));return n}function L(e){return typeof e==`object`&&!!e&&`compactionDetected`in e&&e.compactionDetected===!0}function R(e,t,n){return{...e,state:n(t)}}var z=class{tasks=new Set;track(e){this.tasks.add(e),e.finally(()=>{this.tasks.delete(e)})}async drain(){for(;this.tasks.size>0;)await Promise.allSettled([...this.tasks])}},B=class{config;watcher;eventQueue;importer;managedSessionCache=new A;unsubscribeChange;unsubscribeError;unsubscribeDeleted;stats=new O;watcherTasks=new z;progressTimer;constructor(e,t){this.importer=t;let n=e.directory??t.getLogDirectory();this.config={enabled:e.enabled,directory:e.directory,pollIntervalMs:e.pollIntervalMs??1e4,eventsPerSecond:e.eventsPerSecond??100,adapterId:e.adapterId,adapterName:e.adapterName,checkMakaioManaged:e.checkMakaioManaged},this.watcher=new D({directory:n,pattern:this.getLogFilePattern(),pollIntervalMs:this.config.pollIntervalMs}),this.eventQueue=new T({eventsPerSecond:this.config.eventsPerSecond,onEventEmitted:()=>{this.stats.recordEventEmitted(this.logPrefix)}})}shouldSkipFile(e){return!1}validateRecords(e){return e}getMaxRecords(){}buildCursorSessionContext(e){let{adapterSessionId:t,sessionEvent:n,startedEvent:r,state:i,...a}=e;return{...a,adapterSessionId:t,sessionEvent:n,startedEvent:r,state:this.importer.serializeState(i)}}usesJsonFormat(){let e=this.getLogFilePattern();return e.includes(`.json`)&&!e.includes(`.jsonl`)}isEnabled(){return this.config.enabled}isRunning(){return this.watcher.isRunning()}async start(){if(!this.config.enabled||this.isRunning())return;let e=this.config.directory??this.importer.getLogDirectory();console.info(`${this.logPrefix} Starting - watching ${e}`),this.stats.reset(),this.managedSessionCache.clear(),this.progressTimer=setInterval(()=>this.stats.logProgress(this.logPrefix),1e4),this.unsubscribeChange=this.watcher.onChange(e=>{this.trackFileChange(e)}),this.unsubscribeError=this.watcher.onError(({error:e,filePath:t})=>{console.warn(`${this.logPrefix} Error${t?` for ${t}`:``}: ${e.message}`)}),this.unsubscribeDeleted=this.watcher.onDeleted(({filePath:e})=>{this.watcherTasks.track(s.request(r.delete,{filePath:e}).then(()=>void 0).catch(()=>{}))}),await this.watcher.start()}async stop(){this.progressTimer&&=(clearInterval(this.progressTimer),void 0),this.unsubscribeChange?.(),this.unsubscribeError?.(),this.unsubscribeDeleted?.(),this.unsubscribeChange=void 0,this.unsubscribeError=void 0,this.unsubscribeDeleted=void 0,this.watcher.stop(),await this.watcherTasks.drain(),await this.eventQueue.drain(),this.stats.hasActivity()&&console.info(this.stats.stoppedMessage(this.logPrefix))}async dispose(){await this.stop(),this.watcher.dispose(),this.managedSessionCache.clear()}static createDefaultCheckMakaioManaged(){return k()}async updateCursor(e,t,n,i){await s.request(r.set,{filePath:e,bytesRead:t,lastModified:n.toISOString(),sessionContext:i})}async handleFileChange(e){let{filePath:t,changeType:n,stat:i}=e;if(this.shouldSkipFile(t))return;let a=this.usesJsonFormat();n===`rotated`&&await s.request(r.delete,{filePath:t}).catch(()=>{});let o=await N(t,a,e,e=>this.trackFileChange(e));if(o===`retry`)return;let c=o?.sessionContext!==void 0,l=c?o?.bytesRead??0:0;if(j(o?.lastModified,i.mtime,a,n))return;let u=await this.parseFile(t,a?0:l,this.getMaxRecords());M(this.logPrefix,t,u.errors),this.stats.recordFileProcessed();let d=this.validateRecords(u.records),f=u.bytesRead??0;if(d.length===0){await this.maybeUpdateCursor(t,f,l,i.mtime,a,o?.sessionContext);return}c&&o?.sessionContext?await this.handleIncrementalRead(t,d,o.sessionContext,f,i.mtime,a,l):await this.handleFirstRead(t,d,f,i.mtime,a,l)}trackFileChange(e){let t=this.handleFileChange(e).catch(e=>{console.error(`${this.logPrefix} Error handling file change:`,e instanceof Error?e.message:String(e))});this.watcherTasks.track(t)}async handleFirstRead(e,t,n,r,i,a,o=!0){let s=this.importer.extractSessionContext(t);if(await this.isSessionSkipped(s.adapterSessionId)){await this.maybeUpdateCursor(e,n,a,r,i,this.buildCursorSessionContext(s));return}let c=F(t,s,o,(e,t)=>this.importer.processRecords(e,t),e=>this.queueEvent(e));this.trackImportedSession(s.adapterSessionId),await this.queueCursorUpdate(e,n,a,r,i,this.buildCursorSessionContext(s),c)}trackImportedSession(e){this.stats.recordSessionImported(e)}async handleIncrementalRead(e,t,n,i,a,o,c){if(await this.isSessionSkipped(n.adapterSessionId)){await this.maybeUpdateCursor(e,i,c,a,o,n);return}let l;try{l=this.importer.deserializeState(n.state)}catch(t){console.warn(`${this.logPrefix} Corrupted cursor state for ${e}, deleting cursor and re-importing.`,t instanceof Error?t.message:String(t)),await s.request(r.delete,{filePath:e}).catch(t=>{console.warn(`${this.logPrefix} Failed to delete corrupted cursor for ${e}.`,t instanceof Error?t.message:String(t))}),await P(e,a,o,!0,this.logPrefix,{parseFile:(e,t)=>this.parseFile(e,t),validateRecords:e=>this.validateRecords(e),handleFirstRead:(e,t,n,r,i,a,o)=>this.handleFirstRead(e,t,n,r,i,a,o)});return}let u={adapterSessionId:n.adapterSessionId,model:n.model,cwd:n.cwd,sessionEvent:n.sessionEvent,startedEvent:n.startedEvent,state:l},d=this.importer.processRecords(t,u);if(L(u.state)){await P(e,a,o,!1,this.logPrefix,{parseFile:(e,t)=>this.parseFile(e,t),validateRecords:e=>this.validateRecords(e),handleFirstRead:(e,t,n,r,i,a,o)=>this.handleFirstRead(e,t,n,r,i,a,o)});return}let f=I(d,e=>this.queueEvent(e)),p=R(n,u.state,e=>this.importer.serializeState(e));await this.queueCursorUpdate(e,i,c,a,o,p,f)}async maybeUpdateCursor(e,t,n,r,i,a){(t>n||i)&&await this.updateCursor(e,t,r,a)}async isSessionSkipped(e){return this.managedSessionCache.isSkipped(e,e=>this.importer.isMakaioManaged(e),e=>this.stats.recordSessionSkipped(e))}queueEvent(e){return this.eventQueue.queueEvent(e)}queueCursorUpdate(e,t,n,r,i,a,o=[]){return this.eventQueue.queueAfterEvents(()=>this.maybeUpdateCursor(e,t,n,r,i,a),o)}},V=class extends B{trackingFilePaths=new Set;trackingInactiveCount=new Map;lastSeenMtimeMs=new Map;unsubscribePolled;constructor(e,t){super(e,t)}clearTrackingState(e){this.trackingFilePaths.delete(e),this.trackingInactiveCount.delete(e),this.lastSeenMtimeMs.delete(e)}async persistImportedStatus(e){let{session:t}=await s.request(l.getByLogFilePath,{logFilePath:e});return!t||t.importStatus!==`tracking`||(await s.request(l.updateImportStatus,{sessionId:t.sessionId,importStatus:`imported`})).success?!0:(console.warn(`${this.logPrefix} Failed to persist imported status for ${e}`),!1)}async start(){!this.isEnabled()||this.isRunning()||(await super.start(),this.unsubscribePolled=this.watcher.onPolled(e=>{this.onPollCycle(e).catch(e=>{console.error(`${this.logPrefix} Error handling poll cycle:`,e instanceof Error?e.message:String(e))})}),await this.restorePersistedTrackingState())}async stop(){this.unsubscribePolled?.(),this.unsubscribePolled=void 0,await super.stop()}async dispose(){this.trackingFilePaths.clear(),this.trackingInactiveCount.clear(),this.lastSeenMtimeMs.clear(),await super.dispose()}async handleFileChange(e){let{filePath:t,changeType:n,stat:i}=e;if(this.shouldSkipFile(t))return;let{cursor:a}=await s.request(r.get,{filePath:t});if(!a){await this.discoverNewFile(e);return}n===`modified`&&await this.handleModifiedImportedFile(t,e,i.mtime)}async restorePersistedTrackingState(){this.trackingFilePaths.clear(),this.trackingInactiveCount.clear(),this.lastSeenMtimeMs.clear();try{let{sessions:e}=await s.request(l.listImported,{source:this.config.adapterName,importStatus:`tracking`});for(let t of e){if(t.source!==this.config.adapterName)continue;if(!t.logFilePath){(await s.request(l.updateImportStatus,{sessionId:t.sessionId,importStatus:`imported`})).success||console.warn(`${this.logPrefix} Failed to reset tracking status for session ${t.sessionId}`);continue}let e=this.watcher.getTrackedFileMtimeMs(t.logFilePath);if(e===void 0){(await s.request(l.updateImportStatus,{sessionId:t.sessionId,importStatus:`imported`})).success||console.warn(`${this.logPrefix} Failed to reset tracking status for ${t.logFilePath}`);continue}this.trackingFilePaths.add(t.logFilePath),this.trackingInactiveCount.set(t.logFilePath,0),this.lastSeenMtimeMs.set(t.logFilePath,e)}}catch(e){console.warn(`[DiscoveryOrchestrator] Failed to restore persisted tracking state:`,e instanceof Error?e.message:String(e))}}async discoverNewFile(e){let{filePath:t,stat:n}=e,r=await this.importer.extractDiscoveryMetadata(t);if(!(r.hasMessages??!1)){await this.updateCursor(t,0,n.mtime);return}if(await this.isSessionSkipped(r.adapterSessionId)){await this.updateCursor(t,0,n.mtime);return}let i=this.queueEvent({subject:c.session.discovered,payload:{adapterId:this.config.adapterId,adapterName:this.config.adapterName,adapterSessionId:r.adapterSessionId,model:r.model??null,cwd:r.cwd??null,title:r.title,parentAdapterSessionId:r.parentAdapterSessionId??null,forkPointMessageId:r.forkPointMessageId??null,kind:r.kind??`root`,startedAt:r.startedAt,logFilePath:t}});await this.eventQueue.queueAfterEvents(()=>this.updateCursor(t,0,n.mtime),[i])}async handleModifiedImportedFile(e,t,n){let{session:r}=await s.request(l.getByLogFilePath,{logFilePath:e});if(!r){await this.discoverNewFile(t);return}if(r.source===this.config.adapterName&&!(r.importStatus!==`imported`&&r.importStatus!==`tracking`)){if(await super.handleFileChange(t),r.importStatus===`imported`&&!(await s.request(l.updateImportStatus,{sessionId:r.sessionId,importStatus:`tracking`})).success){console.warn(`${this.logPrefix} Failed to persist tracking status for ${e}`);return}this.trackingFilePaths.add(e),this.lastSeenMtimeMs.set(e,n.getTime()),this.trackingInactiveCount.delete(e),this.watcher.triggerImmediatePoll(e)}}async onPollCycle(e){for(let t of[...this.trackingFilePaths]){if(!e.has(t)){await this.persistImportedStatus(t)&&this.clearTrackingState(t);continue}let n=this.watcher.getTrackedFileMtimeMs(t),r=this.lastSeenMtimeMs.get(t);if(!(n===void 0||r===void 0))try{if(n===r){let e=(this.trackingInactiveCount.get(t)??0)+1;e>=3?await this.persistImportedStatus(t)&&this.clearTrackingState(t):this.trackingInactiveCount.set(t,e)}else this.lastSeenMtimeMs.set(t,n),this.trackingInactiveCount.delete(t)}catch(e){console.warn(`${this.logPrefix} Failed to process tracked file ${t}:`,e instanceof Error?e.message:String(e))}}}};export{B as BaseLogOrchestrator,V as DiscoveryOrchestrator,f as parseJsonlFile,p as readFirstJsonlRecords,m as someJsonlRecord};
@@ -0,0 +1,8 @@
1
+ import{t as e}from"./chunk-DTipWd-i.mjs";var t=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;var t=class{};e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;var n=class extends t{constructor(t){if(super(),!e.IDENTIFIER.test(t))throw Error(`CodeGen: name must be a valid identifier`);this.str=t}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}};e.Name=n;var r=class extends t{constructor(e){super(),this._items=typeof e==`string`?[e]:e}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;let e=this._items[0];return e===``||e===`""`}get str(){return this._str??=this._items.reduce((e,t)=>`${e}${t}`,``)}get names(){return this._names??=this._items.reduce((e,t)=>(t instanceof n&&(e[t.str]=(e[t.str]||0)+1),e),{})}};e._Code=r,e.nil=new r(``);function i(e,...t){let n=[e[0]],i=0;for(;i<t.length;)s(n,t[i]),n.push(e[++i]);return new r(n)}e._=i;let a=new r(`+`);function o(e,...t){let n=[p(e[0])],i=0;for(;i<t.length;)n.push(a),s(n,t[i]),n.push(a,p(e[++i]));return c(n),new r(n)}e.str=o;function s(e,t){t instanceof r?e.push(...t._items):t instanceof n?e.push(t):e.push(d(t))}e.addCodeArg=s;function c(e){let t=1;for(;t<e.length-1;){if(e[t]===a){let n=l(e[t-1],e[t+1]);if(n!==void 0){e.splice(t-1,3,n);continue}e[t++]=`+`}t++}}function l(e,t){if(t===`""`)return e;if(e===`""`)return t;if(typeof e==`string`)return t instanceof n||e[e.length-1]!==`"`?void 0:typeof t==`string`?t[0]===`"`?e.slice(0,-1)+t.slice(1):void 0:`${e.slice(0,-1)}${t}"`;if(typeof t==`string`&&t[0]===`"`&&!(e instanceof n))return`"${e}${t.slice(1)}`}function u(e,t){return t.emptyStr()?e:e.emptyStr()?t:o`${e}${t}`}e.strConcat=u;function d(e){return typeof e==`number`||typeof e==`boolean`||e===null?e:p(Array.isArray(e)?e.join(`,`):e)}function f(e){return new r(p(e))}e.stringify=f;function p(e){return JSON.stringify(e).replace(/\u2028/g,`\\u2028`).replace(/\u2029/g,`\\u2029`)}e.safeStringify=p;function m(t){return typeof t==`string`&&e.IDENTIFIER.test(t)?new r(`.${t}`):i`[${t}]`}e.getProperty=m;function h(t){if(typeof t==`string`&&e.IDENTIFIER.test(t))return new r(`${t}`);throw Error(`CodeGen: invalid export name: ${t}, use explicit $id name mapping`)}e.getEsmExportName=h;function g(e){return new r(e.toString())}e.regexpCode=g})),n=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;let n=t();var r=class extends Error{constructor(e){super(`CodeGen: "code" for ${e} not defined`),this.value=e.value}},i;(function(e){e[e.Started=0]=`Started`,e[e.Completed=1]=`Completed`})(i||(e.UsedValueState=i={})),e.varKinds={const:new n.Name(`const`),let:new n.Name(`let`),var:new n.Name(`var`)};var a=class{constructor({prefixes:e,parent:t}={}){this._names={},this._prefixes=e,this._parent=t}toName(e){return e instanceof n.Name?e:this.name(e)}name(e){return new n.Name(this._newName(e))}_newName(e){let t=this._names[e]||this._nameGroup(e);return`${e}${t.index++}`}_nameGroup(e){if((this._parent?._prefixes)?.has(e)||this._prefixes&&!this._prefixes.has(e))throw Error(`CodeGen: prefix "${e}" is not allowed in this scope`);return this._names[e]={prefix:e,index:0}}};e.Scope=a;var o=class extends n.Name{constructor(e,t){super(t),this.prefix=e}setValue(e,{property:t,itemIndex:r}){this.value=e,this.scopePath=(0,n._)`.${new n.Name(t)}[${r}]`}};e.ValueScopeName=o;let s=(0,n._)`\n`;e.ValueScope=class extends a{constructor(e){super(e),this._values={},this._scope=e.scope,this.opts={...e,_n:e.lines?s:n.nil}}get(){return this._scope}name(e){return new o(e,this._newName(e))}value(e,t){if(t.ref===void 0)throw Error(`CodeGen: ref must be passed in value`);let n=this.toName(e),{prefix:r}=n,i=t.key??t.ref,a=this._values[r];if(a){let e=a.get(i);if(e)return e}else a=this._values[r]=new Map;a.set(i,n);let o=this._scope[r]||(this._scope[r]=[]),s=o.length;return o[s]=t.ref,n.setValue(t,{property:r,itemIndex:s}),n}getValue(e,t){let n=this._values[e];if(n)return n.get(t)}scopeRefs(e,t=this._values){return this._reduceValues(t,t=>{if(t.scopePath===void 0)throw Error(`CodeGen: name "${t}" has no value`);return(0,n._)`${e}${t.scopePath}`})}scopeCode(e=this._values,t,n){return this._reduceValues(e,e=>{if(e.value===void 0)throw Error(`CodeGen: name "${e}" has no value`);return e.value.code},t,n)}_reduceValues(t,a,o={},s){let c=n.nil;for(let l in t){let u=t[l];if(!u)continue;let d=o[l]=o[l]||new Map;u.forEach(t=>{if(d.has(t))return;d.set(t,i.Started);let o=a(t);if(o){let r=this.opts.es5?e.varKinds.var:e.varKinds.const;c=(0,n._)`${c}${r} ${t} = ${o};${this.opts._n}`}else if(o=s?.(t))c=(0,n._)`${c}${o}${this.opts._n}`;else throw new r(t);d.set(t,i.Completed)})}return c}}})),r=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;let r=t(),i=n();var a=t();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return a._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return a.str}}),Object.defineProperty(e,`strConcat`,{enumerable:!0,get:function(){return a.strConcat}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return a.nil}}),Object.defineProperty(e,`getProperty`,{enumerable:!0,get:function(){return a.getProperty}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return a.stringify}}),Object.defineProperty(e,`regexpCode`,{enumerable:!0,get:function(){return a.regexpCode}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return a.Name}});var o=n();Object.defineProperty(e,`Scope`,{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,`ValueScope`,{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,`ValueScopeName`,{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,`varKinds`,{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new r._Code(`>`),GTE:new r._Code(`>=`),LT:new r._Code(`<`),LTE:new r._Code(`<=`),EQ:new r._Code(`===`),NEQ:new r._Code(`!==`),NOT:new r._Code(`!`),OR:new r._Code(`||`),AND:new r._Code(`&&`),ADD:new r._Code(`+`)};var s=class{optimizeNodes(){return this}optimizeNames(e,t){return this}},c=class extends s{constructor(e,t,n){super(),this.varKind=e,this.name=t,this.rhs=n}render({es5:e,_n:t}){let n=e?i.varKinds.var:this.varKind,r=this.rhs===void 0?``:` = ${this.rhs}`;return`${n} ${this.name}${r};`+t}optimizeNames(e,t){if(e[this.name.str])return this.rhs&&=j(this.rhs,e,t),this}get names(){return this.rhs instanceof r._CodeOrName?this.rhs.names:{}}},l=class extends s{constructor(e,t,n){super(),this.lhs=e,this.rhs=t,this.sideEffects=n}render({_n:e}){return`${this.lhs} = ${this.rhs};`+e}optimizeNames(e,t){if(!(this.lhs instanceof r.Name&&!e[this.lhs.str]&&!this.sideEffects))return this.rhs=j(this.rhs,e,t),this}get names(){return A(this.lhs instanceof r.Name?{}:{...this.lhs.names},this.rhs)}},u=class extends l{constructor(e,t,n,r){super(e,n,r),this.op=t}render({_n:e}){return`${this.lhs} ${this.op}= ${this.rhs};`+e}},d=class extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`${this.label}:`+e}},f=class extends s{constructor(e){super(),this.label=e,this.names={}}render({_n:e}){return`break${this.label?` ${this.label}`:``};`+e}},p=class extends s{constructor(e){super(),this.error=e}render({_n:e}){return`throw ${this.error};`+e}get names(){return this.error.names}},m=class extends s{constructor(e){super(),this.code=e}render({_n:e}){return`${this.code};`+e}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(e,t){return this.code=j(this.code,e,t),this}get names(){return this.code instanceof r._CodeOrName?this.code.names:{}}},h=class extends s{constructor(e=[]){super(),this.nodes=e}render(e){return this.nodes.reduce((t,n)=>t+n.render(e),``)}optimizeNodes(){let{nodes:e}=this,t=e.length;for(;t--;){let n=e[t].optimizeNodes();Array.isArray(n)?e.splice(t,1,...n):n?e[t]=n:e.splice(t,1)}return e.length>0?this:void 0}optimizeNames(e,t){let{nodes:n}=this,r=n.length;for(;r--;){let i=n[r];i.optimizeNames(e,t)||(M(e,i.names),n.splice(r,1))}return n.length>0?this:void 0}get names(){return this.nodes.reduce((e,t)=>k(e,t.names),{})}},g=class extends h{render(e){return`{`+e._n+super.render(e)+`}`+e._n}},_=class extends h{},v=class extends g{};v.kind=`else`;var y=class e extends g{constructor(e,t){super(t),this.condition=e}render(e){let t=`if(${this.condition})`+super.render(e);return this.else&&(t+=`else `+this.else.render(e)),t}optimizeNodes(){super.optimizeNodes();let t=this.condition;if(t===!0)return this.nodes;let n=this.else;if(n){let e=n.optimizeNodes();n=this.else=Array.isArray(e)?new v(e):e}if(n)return t===!1?n instanceof e?n:n.nodes:this.nodes.length?this:new e(N(t),n instanceof e?[n]:n.nodes);if(!(t===!1||!this.nodes.length))return this}optimizeNames(e,t){if(this.else=this.else?.optimizeNames(e,t),super.optimizeNames(e,t)||this.else)return this.condition=j(this.condition,e,t),this}get names(){let e=super.names;return A(e,this.condition),this.else&&k(e,this.else.names),e}};y.kind=`if`;var b=class extends g{};b.kind=`for`;var x=class extends b{constructor(e){super(),this.iteration=e}render(e){return`for(${this.iteration})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iteration=j(this.iteration,e,t),this}get names(){return k(super.names,this.iteration.names)}},S=class extends b{constructor(e,t,n,r){super(),this.varKind=e,this.name=t,this.from=n,this.to=r}render(e){let t=e.es5?i.varKinds.var:this.varKind,{name:n,from:r,to:a}=this;return`for(${t} ${n}=${r}; ${n}<${a}; ${n}++)`+super.render(e)}get names(){return A(A(super.names,this.from),this.to)}},C=class extends b{constructor(e,t,n,r){super(),this.loop=e,this.varKind=t,this.name=n,this.iterable=r}render(e){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(e)}optimizeNames(e,t){if(super.optimizeNames(e,t))return this.iterable=j(this.iterable,e,t),this}get names(){return k(super.names,this.iterable.names)}},w=class extends g{constructor(e,t,n){super(),this.name=e,this.args=t,this.async=n}render(e){return`${this.async?`async `:``}function ${this.name}(${this.args})`+super.render(e)}};w.kind=`func`;var T=class extends h{render(e){return`return `+super.render(e)}};T.kind=`return`;var E=class extends g{render(e){let t=`try`+super.render(e);return this.catch&&(t+=this.catch.render(e)),this.finally&&(t+=this.finally.render(e)),t}optimizeNodes(){var e,t;return super.optimizeNodes(),(e=this.catch)==null||e.optimizeNodes(),(t=this.finally)==null||t.optimizeNodes(),this}optimizeNames(e,t){var n,r;return super.optimizeNames(e,t),(n=this.catch)==null||n.optimizeNames(e,t),(r=this.finally)==null||r.optimizeNames(e,t),this}get names(){let e=super.names;return this.catch&&k(e,this.catch.names),this.finally&&k(e,this.finally.names),e}},D=class extends g{constructor(e){super(),this.error=e}render(e){return`catch(${this.error})`+super.render(e)}};D.kind=`catch`;var O=class extends g{render(e){return`finally`+super.render(e)}};O.kind=`finally`,e.CodeGen=class{constructor(e,t={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...t,_n:t.lines?`
2
+ `:``},this._extScope=e,this._scope=new i.Scope({parent:e}),this._nodes=[new _]}toString(){return this._root.render(this.opts)}name(e){return this._scope.name(e)}scopeName(e){return this._extScope.name(e)}scopeValue(e,t){let n=this._extScope.value(e,t);return(this._values[n.prefix]||(this._values[n.prefix]=new Set)).add(n),n}getScopeValue(e,t){return this._extScope.getValue(e,t)}scopeRefs(e){return this._extScope.scopeRefs(e,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(e,t,n,r){let i=this._scope.toName(t);return n!==void 0&&r&&(this._constants[i.str]=n),this._leafNode(new c(e,i,n)),i}const(e,t,n){return this._def(i.varKinds.const,e,t,n)}let(e,t,n){return this._def(i.varKinds.let,e,t,n)}var(e,t,n){return this._def(i.varKinds.var,e,t,n)}assign(e,t,n){return this._leafNode(new l(e,t,n))}add(t,n){return this._leafNode(new u(t,e.operators.ADD,n))}code(e){return typeof e==`function`?e():e!==r.nil&&this._leafNode(new m(e)),this}object(...e){let t=[`{`];for(let[n,i]of e)t.length>1&&t.push(`,`),t.push(n),(n!==i||this.opts.es5)&&(t.push(`:`),(0,r.addCodeArg)(t,i));return t.push(`}`),new r._Code(t)}if(e,t,n){if(this._blockNode(new y(e)),t&&n)this.code(t).else().code(n).endIf();else if(t)this.code(t).endIf();else if(n)throw Error(`CodeGen: "else" body without "then" body`);return this}elseIf(e){return this._elseNode(new y(e))}else(){return this._elseNode(new v)}endIf(){return this._endBlockNode(y,v)}_for(e,t){return this._blockNode(e),t&&this.code(t).endFor(),this}for(e,t){return this._for(new x(e),t)}forRange(e,t,n,r,a=this.opts.es5?i.varKinds.var:i.varKinds.let){let o=this._scope.toName(e);return this._for(new S(a,o,t,n),()=>r(o))}forOf(e,t,n,a=i.varKinds.const){let o=this._scope.toName(e);if(this.opts.es5){let e=t instanceof r.Name?t:this.var(`_arr`,t);return this.forRange(`_i`,0,(0,r._)`${e}.length`,t=>{this.var(o,(0,r._)`${e}[${t}]`),n(o)})}return this._for(new C(`of`,a,o,t),()=>n(o))}forIn(e,t,n,a=this.opts.es5?i.varKinds.var:i.varKinds.const){if(this.opts.ownProperties)return this.forOf(e,(0,r._)`Object.keys(${t})`,n);let o=this._scope.toName(e);return this._for(new C(`in`,a,o,t),()=>n(o))}endFor(){return this._endBlockNode(b)}label(e){return this._leafNode(new d(e))}break(e){return this._leafNode(new f(e))}return(e){let t=new T;if(this._blockNode(t),this.code(e),t.nodes.length!==1)throw Error(`CodeGen: "return" should have one node`);return this._endBlockNode(T)}try(e,t,n){if(!t&&!n)throw Error(`CodeGen: "try" without "catch" and "finally"`);let r=new E;if(this._blockNode(r),this.code(e),t){let e=this.name(`e`);this._currNode=r.catch=new D(e),t(e)}return n&&(this._currNode=r.finally=new O,this.code(n)),this._endBlockNode(D,O)}throw(e){return this._leafNode(new p(e))}block(e,t){return this._blockStarts.push(this._nodes.length),e&&this.code(e).endBlock(t),this}endBlock(e){let t=this._blockStarts.pop();if(t===void 0)throw Error(`CodeGen: not in self-balancing block`);let n=this._nodes.length-t;if(n<0||e!==void 0&&n!==e)throw Error(`CodeGen: wrong number of nodes: ${n} vs ${e} expected`);return this._nodes.length=t,this}func(e,t=r.nil,n,i){return this._blockNode(new w(e,t,n)),i&&this.code(i).endFunc(),this}endFunc(){return this._endBlockNode(w)}optimize(e=1){for(;e-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(e){return this._currNode.nodes.push(e),this}_blockNode(e){this._currNode.nodes.push(e),this._nodes.push(e)}_endBlockNode(e,t){let n=this._currNode;if(n instanceof e||t&&n instanceof t)return this._nodes.pop(),this;throw Error(`CodeGen: not in block "${t?`${e.kind}/${t.kind}`:e.kind}"`)}_elseNode(e){let t=this._currNode;if(!(t instanceof y))throw Error(`CodeGen: "else" without "if"`);return this._currNode=t.else=e,this}get _root(){return this._nodes[0]}get _currNode(){let e=this._nodes;return e[e.length-1]}set _currNode(e){let t=this._nodes;t[t.length-1]=e}};function k(e,t){for(let n in t)e[n]=(e[n]||0)+(t[n]||0);return e}function A(e,t){return t instanceof r._CodeOrName?k(e,t.names):e}function j(e,t,n){if(e instanceof r.Name)return i(e);if(!a(e))return e;return new r._Code(e._items.reduce((e,t)=>(t instanceof r.Name&&(t=i(t)),t instanceof r._Code?e.push(...t._items):e.push(t),e),[]));function i(e){let r=n[e.str];return r===void 0||t[e.str]!==1?e:(delete t[e.str],r)}function a(e){return e instanceof r._Code&&e._items.some(e=>e instanceof r.Name&&t[e.str]===1&&n[e.str]!==void 0)}}function M(e,t){for(let n in t)e[n]=(e[n]||0)-(t[n]||0)}function N(e){return typeof e==`boolean`||typeof e==`number`||e===null?!e:(0,r._)`!${z(e)}`}e.not=N;let P=R(e.operators.AND);function F(...e){return e.reduce(P)}e.and=F;let I=R(e.operators.OR);function L(...e){return e.reduce(I)}e.or=L;function R(e){return(t,n)=>t===r.nil?n:n===r.nil?t:(0,r._)`${z(t)} ${e} ${z(n)}`}function z(e){return e instanceof r.Name?e:(0,r._)`(${e})`}})),i=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.checkStrictMode=e.getErrorPath=e.Type=e.useFunc=e.setEvaluated=e.evaluatedPropsToName=e.mergeEvaluated=e.eachItem=e.unescapeJsonPointer=e.escapeJsonPointer=e.escapeFragment=e.unescapeFragment=e.schemaRefOrVal=e.schemaHasRulesButRef=e.schemaHasRules=e.checkUnknownRules=e.alwaysValidSchema=e.toHash=void 0;let n=r(),i=t();function a(e){let t={};for(let n of e)t[n]=!0;return t}e.toHash=a;function o(e,t){return typeof t==`boolean`?t:Object.keys(t).length===0?!0:(s(e,t),!c(t,e.self.RULES.all))}e.alwaysValidSchema=o;function s(e,t=e.schema){let{opts:n,self:r}=e;if(!n.strictSchema||typeof t==`boolean`)return;let i=r.RULES.keywords;for(let n in t)i[n]||C(e,`unknown keyword: "${n}"`)}e.checkUnknownRules=s;function c(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(t[n])return!0;return!1}e.schemaHasRules=c;function l(e,t){if(typeof e==`boolean`)return!e;for(let n in e)if(n!==`$ref`&&t.all[n])return!0;return!1}e.schemaHasRulesButRef=l;function u({topSchemaRef:e,schemaPath:t},r,i,a){if(!a){if(typeof r==`number`||typeof r==`boolean`)return r;if(typeof r==`string`)return(0,n._)`${r}`}return(0,n._)`${e}${t}${(0,n.getProperty)(i)}`}e.schemaRefOrVal=u;function d(e){return m(decodeURIComponent(e))}e.unescapeFragment=d;function f(e){return encodeURIComponent(p(e))}e.escapeFragment=f;function p(e){return typeof e==`number`?`${e}`:e.replace(/~/g,`~0`).replace(/\//g,`~1`)}e.escapeJsonPointer=p;function m(e){return e.replace(/~1/g,`/`).replace(/~0/g,`~`)}e.unescapeJsonPointer=m;function h(e,t){if(Array.isArray(e))for(let n of e)t(n);else t(e)}e.eachItem=h;function g({mergeNames:e,mergeToName:t,mergeValues:r,resultToName:i}){return(a,o,s,c)=>{let l=s===void 0?o:s instanceof n.Name?(o instanceof n.Name?e(a,o,s):t(a,o,s),s):o instanceof n.Name?(t(a,s,o),o):r(o,s);return c===n.Name&&!(l instanceof n.Name)?i(a,l):l}}e.mergeEvaluated={props:g({mergeNames:(e,t,r)=>e.if((0,n._)`${r} !== true && ${t} !== undefined`,()=>{e.if((0,n._)`${t} === true`,()=>e.assign(r,!0),()=>e.assign(r,(0,n._)`${r} || {}`).code((0,n._)`Object.assign(${r}, ${t})`))}),mergeToName:(e,t,r)=>e.if((0,n._)`${r} !== true`,()=>{t===!0?e.assign(r,!0):(e.assign(r,(0,n._)`${r} || {}`),v(e,r,t))}),mergeValues:(e,t)=>e===!0?!0:{...e,...t},resultToName:_}),items:g({mergeNames:(e,t,r)=>e.if((0,n._)`${r} !== true && ${t} !== undefined`,()=>e.assign(r,(0,n._)`${t} === true ? true : ${r} > ${t} ? ${r} : ${t}`)),mergeToName:(e,t,r)=>e.if((0,n._)`${r} !== true`,()=>e.assign(r,t===!0?!0:(0,n._)`${r} > ${t} ? ${r} : ${t}`)),mergeValues:(e,t)=>e===!0?!0:Math.max(e,t),resultToName:(e,t)=>e.var(`items`,t)})};function _(e,t){if(t===!0)return e.var(`props`,!0);let r=e.var(`props`,(0,n._)`{}`);return t!==void 0&&v(e,r,t),r}e.evaluatedPropsToName=_;function v(e,t,r){Object.keys(r).forEach(r=>e.assign((0,n._)`${t}${(0,n.getProperty)(r)}`,!0))}e.setEvaluated=v;let y={};function b(e,t){return e.scopeValue(`func`,{ref:t,code:y[t.code]||(y[t.code]=new i._Code(t.code))})}e.useFunc=b;var x;(function(e){e[e.Num=0]=`Num`,e[e.Str=1]=`Str`})(x||(e.Type=x={}));function S(e,t,r){if(e instanceof n.Name){let i=t===x.Num;return r?i?(0,n._)`"[" + ${e} + "]"`:(0,n._)`"['" + ${e} + "']"`:i?(0,n._)`"/" + ${e}`:(0,n._)`"/" + ${e}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return r?(0,n.getProperty)(e).toString():`/`+p(e)}e.getErrorPath=S;function C(e,t,n=e.opts.strictSchema){if(n){if(t=`strict mode: ${t}`,n===!0)throw Error(t);e.self.logger.warn(t)}}e.checkStrictMode=C})),a=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r();e.default={data:new t.Name(`data`),valCxt:new t.Name(`valCxt`),instancePath:new t.Name(`instancePath`),parentData:new t.Name(`parentData`),parentDataProperty:new t.Name(`parentDataProperty`),rootData:new t.Name(`rootData`),dynamicAnchors:new t.Name(`dynamicAnchors`),vErrors:new t.Name(`vErrors`),errors:new t.Name(`errors`),this:new t.Name(`this`),self:new t.Name(`self`),scope:new t.Name(`scope`),json:new t.Name(`json`),jsonPos:new t.Name(`jsonPos`),jsonLen:new t.Name(`jsonLen`),jsonPart:new t.Name(`jsonPart`)}})),o=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;let t=r(),n=i(),o=a();e.keywordError={message:({keyword:e})=>(0,t.str)`must pass "${e}" keyword validation`},e.keyword$DataError={message:({keyword:e,schemaType:n})=>n?(0,t.str)`"${e}" keyword must be ${n} ($data)`:(0,t.str)`"${e}" keyword is invalid ($data)`};function s(n,r=e.keywordError,i,a){let{it:o}=n,{gen:s,compositeRule:c,allErrors:l}=o,u=m(n,r,i);a??(c||l)?d(s,u):f(o,(0,t._)`[${u}]`)}e.reportError=s;function c(t,n=e.keywordError,r){let{it:i}=t,{gen:a,compositeRule:s,allErrors:c}=i;d(a,m(t,n,r)),s||c||f(i,o.default.vErrors)}e.reportExtraError=c;function l(e,n){e.assign(o.default.errors,n),e.if((0,t._)`${o.default.vErrors} !== null`,()=>e.if(n,()=>e.assign((0,t._)`${o.default.vErrors}.length`,n),()=>e.assign(o.default.vErrors,null)))}e.resetErrorsCount=l;function u({gen:e,keyword:n,schemaValue:r,data:i,errsCount:a,it:s}){if(a===void 0)throw Error(`ajv implementation error`);let c=e.name(`err`);e.forRange(`i`,a,o.default.errors,a=>{e.const(c,(0,t._)`${o.default.vErrors}[${a}]`),e.if((0,t._)`${c}.instancePath === undefined`,()=>e.assign((0,t._)`${c}.instancePath`,(0,t.strConcat)(o.default.instancePath,s.errorPath))),e.assign((0,t._)`${c}.schemaPath`,(0,t.str)`${s.errSchemaPath}/${n}`),s.opts.verbose&&(e.assign((0,t._)`${c}.schema`,r),e.assign((0,t._)`${c}.data`,i))})}e.extendErrors=u;function d(e,n){let r=e.const(`err`,n);e.if((0,t._)`${o.default.vErrors} === null`,()=>e.assign(o.default.vErrors,(0,t._)`[${r}]`),(0,t._)`${o.default.vErrors}.push(${r})`),e.code((0,t._)`${o.default.errors}++`)}function f(e,n){let{gen:r,validateName:i,schemaEnv:a}=e;a.$async?r.throw((0,t._)`new ${e.ValidationError}(${n})`):(r.assign((0,t._)`${i}.errors`,n),r.return(!1))}let p={keyword:new t.Name(`keyword`),schemaPath:new t.Name(`schemaPath`),params:new t.Name(`params`),propertyName:new t.Name(`propertyName`),message:new t.Name(`message`),schema:new t.Name(`schema`),parentSchema:new t.Name(`parentSchema`)};function m(e,n,r){let{createErrors:i}=e.it;return i===!1?(0,t._)`{}`:h(e,n,r)}function h(e,t,n={}){let{gen:r,it:i}=e,a=[g(i,n),_(e,n)];return v(e,t,a),r.object(...a)}function g({errorPath:e},{instancePath:r}){let i=r?(0,t.str)`${e}${(0,n.getErrorPath)(r,n.Type.Str)}`:e;return[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,i)]}function _({keyword:e,it:{errSchemaPath:r}},{schemaPath:i,parentSchema:a}){let o=a?r:(0,t.str)`${r}/${e}`;return i&&(o=(0,t.str)`${o}${(0,n.getErrorPath)(i,n.Type.Str)}`),[p.schemaPath,o]}function v(e,{params:n,message:r},i){let{keyword:a,data:s,schemaValue:c,it:l}=e,{opts:u,propertyName:d,topSchemaRef:f,schemaPath:m}=l;i.push([p.keyword,a],[p.params,typeof n==`function`?n(e):n||(0,t._)`{}`]),u.messages&&i.push([p.message,typeof r==`function`?r(e):r]),u.verbose&&i.push([p.schema,c],[p.parentSchema,(0,t._)`${f}${m}`],[o.default.data,s]),d&&i.push([p.propertyName,d])}})),s=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.boolOrEmptySchema=e.topBoolOrEmptySchema=void 0;let t=o(),n=r(),i=a(),s={message:`boolean schema is false`};function c(e){let{gen:t,schema:r,validateName:a}=e;r===!1?u(e,!1):typeof r==`object`&&r.$async===!0?t.return(i.default.data):(t.assign((0,n._)`${a}.errors`,null),t.return(!0))}e.topBoolOrEmptySchema=c;function l(e,t){let{gen:n,schema:r}=e;r===!1?(n.var(t,!1),u(e)):n.var(t,!0)}e.boolOrEmptySchema=l;function u(e,n){let{gen:r,data:i}=e,a={gen:r,keyword:`false schema`,data:i,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:e};(0,t.reportError)(a,s,void 0,n)}})),c=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getRules=e.isJSONType=void 0;let t=new Set([`string`,`number`,`integer`,`boolean`,`null`,`object`,`array`]);function n(e){return typeof e==`string`&&t.has(e)}e.isJSONType=n;function r(){let e={number:{type:`number`,rules:[]},string:{type:`string`,rules:[]},array:{type:`array`,rules:[]},object:{type:`object`,rules:[]}};return{types:{...e,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},e.number,e.string,e.array,e.object],post:{rules:[]},all:{},keywords:{}}}e.getRules=r})),l=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.shouldUseRule=e.shouldUseGroup=e.schemaHasRulesForType=void 0;function t({schema:e,self:t},r){let i=t.RULES.types[r];return i&&i!==!0&&n(e,i)}e.schemaHasRulesForType=t;function n(e,t){return t.rules.some(t=>r(e,t))}e.shouldUseGroup=n;function r(e,t){return e[t.keyword]!==void 0||t.definition.implements?.some(t=>e[t]!==void 0)}e.shouldUseRule=r})),u=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reportTypeError=e.checkDataTypes=e.checkDataType=e.coerceAndCheckDataType=e.getJSONTypes=e.getSchemaTypes=e.DataType=void 0;let t=c(),n=l(),a=o(),s=r(),u=i();var d;(function(e){e[e.Correct=0]=`Correct`,e[e.Wrong=1]=`Wrong`})(d||(e.DataType=d={}));function f(e){let t=p(e.type);if(t.includes(`null`)){if(e.nullable===!1)throw Error(`type: null contradicts nullable: false`)}else{if(!t.length&&e.nullable!==void 0)throw Error(`"nullable" cannot be used without "type"`);e.nullable===!0&&t.push(`null`)}return t}e.getSchemaTypes=f;function p(e){let n=Array.isArray(e)?e:e?[e]:[];if(n.every(t.isJSONType))return n;throw Error(`type must be JSONType or JSONType[]: `+n.join(`,`))}e.getJSONTypes=p;function m(e,t){let{gen:r,data:i,opts:a}=e,o=g(t,a.coerceTypes),s=t.length>0&&!(o.length===0&&t.length===1&&(0,n.schemaHasRulesForType)(e,t[0]));if(s){let n=b(t,i,a.strictNumbers,d.Wrong);r.if(n,()=>{o.length?_(e,t,o):S(e)})}return s}e.coerceAndCheckDataType=m;let h=new Set([`string`,`number`,`integer`,`boolean`,`null`]);function g(e,t){return t?e.filter(e=>h.has(e)||t===`array`&&e===`array`):[]}function _(e,t,n){let{gen:r,data:i,opts:a}=e,o=r.let(`dataType`,(0,s._)`typeof ${i}`),c=r.let(`coerced`,(0,s._)`undefined`);a.coerceTypes===`array`&&r.if((0,s._)`${o} == 'object' && Array.isArray(${i}) && ${i}.length == 1`,()=>r.assign(i,(0,s._)`${i}[0]`).assign(o,(0,s._)`typeof ${i}`).if(b(t,i,a.strictNumbers),()=>r.assign(c,i))),r.if((0,s._)`${c} !== undefined`);for(let e of n)(h.has(e)||e===`array`&&a.coerceTypes===`array`)&&l(e);r.else(),S(e),r.endIf(),r.if((0,s._)`${c} !== undefined`,()=>{r.assign(i,c),v(e,c)});function l(e){switch(e){case`string`:r.elseIf((0,s._)`${o} == "number" || ${o} == "boolean"`).assign(c,(0,s._)`"" + ${i}`).elseIf((0,s._)`${i} === null`).assign(c,(0,s._)`""`);return;case`number`:r.elseIf((0,s._)`${o} == "boolean" || ${i} === null
3
+ || (${o} == "string" && ${i} && ${i} == +${i})`).assign(c,(0,s._)`+${i}`);return;case`integer`:r.elseIf((0,s._)`${o} === "boolean" || ${i} === null
4
+ || (${o} === "string" && ${i} && ${i} == +${i} && !(${i} % 1))`).assign(c,(0,s._)`+${i}`);return;case`boolean`:r.elseIf((0,s._)`${i} === "false" || ${i} === 0 || ${i} === null`).assign(c,!1).elseIf((0,s._)`${i} === "true" || ${i} === 1`).assign(c,!0);return;case`null`:r.elseIf((0,s._)`${i} === "" || ${i} === 0 || ${i} === false`),r.assign(c,null);return;case`array`:r.elseIf((0,s._)`${o} === "string" || ${o} === "number"
5
+ || ${o} === "boolean" || ${i} === null`).assign(c,(0,s._)`[${i}]`)}}}function v({gen:e,parentData:t,parentDataProperty:n},r){e.if((0,s._)`${t} !== undefined`,()=>e.assign((0,s._)`${t}[${n}]`,r))}function y(e,t,n,r=d.Correct){let i=r===d.Correct?s.operators.EQ:s.operators.NEQ,a;switch(e){case`null`:return(0,s._)`${t} ${i} null`;case`array`:a=(0,s._)`Array.isArray(${t})`;break;case`object`:a=(0,s._)`${t} && typeof ${t} == "object" && !Array.isArray(${t})`;break;case`integer`:a=o((0,s._)`!(${t} % 1) && !isNaN(${t})`);break;case`number`:a=o();break;default:return(0,s._)`typeof ${t} ${i} ${e}`}return r===d.Correct?a:(0,s.not)(a);function o(e=s.nil){return(0,s.and)((0,s._)`typeof ${t} == "number"`,e,n?(0,s._)`isFinite(${t})`:s.nil)}}e.checkDataType=y;function b(e,t,n,r){if(e.length===1)return y(e[0],t,n,r);let i,a=(0,u.toHash)(e);if(a.array&&a.object){let e=(0,s._)`typeof ${t} != "object"`;i=a.null?e:(0,s._)`!${t} || ${e}`,delete a.null,delete a.array,delete a.object}else i=s.nil;a.number&&delete a.integer;for(let e in a)i=(0,s.and)(i,y(e,t,n,r));return i}e.checkDataTypes=b;let x={message:({schema:e})=>`must be ${e}`,params:({schema:e,schemaValue:t})=>typeof e==`string`?(0,s._)`{type: ${e}}`:(0,s._)`{type: ${t}}`};function S(e){let t=C(e);(0,a.reportError)(t,x)}e.reportTypeError=S;function C(e){let{gen:t,data:n,schema:r}=e,i=(0,u.schemaRefOrVal)(e,r,`type`);return{gen:t,keyword:`type`,data:n,schema:r.type,schemaCode:i,schemaValue:i,parentSchema:r,params:{},it:e}}})),d=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.assignDefaults=void 0;let t=r(),n=i();function a(e,t){let{properties:n,items:r}=e.schema;if(t===`object`&&n)for(let t in n)o(e,t,n[t].default);else t===`array`&&Array.isArray(r)&&r.forEach((t,n)=>o(e,n,t.default))}e.assignDefaults=a;function o(e,r,i){let{gen:a,compositeRule:o,data:s,opts:c}=e;if(i===void 0)return;let l=(0,t._)`${s}${(0,t.getProperty)(r)}`;if(o){(0,n.checkStrictMode)(e,`default is ignored for: ${l}`);return}let u=(0,t._)`${l} === undefined`;c.useDefaults===`empty`&&(u=(0,t._)`${u} || ${l} === null || ${l} === ""`),a.if(u,(0,t._)`${l} = ${(0,t.stringify)(i)}`)}})),f=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateUnion=e.validateArray=e.usePattern=e.callValidateCode=e.schemaProperties=e.allSchemaProperties=e.noPropertyInData=e.propertyInData=e.isOwnProperty=e.hasPropFunc=e.reportMissingProp=e.checkMissingProp=e.checkReportMissingProp=void 0;let t=r(),n=i(),o=a(),s=i();function c(e,n){let{gen:r,data:i,it:a}=e;r.if(m(r,i,n,a.opts.ownProperties),()=>{e.setParams({missingProperty:(0,t._)`${n}`},!0),e.error()})}e.checkReportMissingProp=c;function l({gen:e,data:n,it:{opts:r}},i,a){return(0,t.or)(...i.map(i=>(0,t.and)(m(e,n,i,r.ownProperties),(0,t._)`${a} = ${i}`)))}e.checkMissingProp=l;function u(e,t){e.setParams({missingProperty:t},!0),e.error()}e.reportMissingProp=u;function d(e){return e.scopeValue(`func`,{ref:Object.prototype.hasOwnProperty,code:(0,t._)`Object.prototype.hasOwnProperty`})}e.hasPropFunc=d;function f(e,n,r){return(0,t._)`${d(e)}.call(${n}, ${r})`}e.isOwnProperty=f;function p(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} !== undefined`;return i?(0,t._)`${a} && ${f(e,n,r)}`:a}e.propertyInData=p;function m(e,n,r,i){let a=(0,t._)`${n}${(0,t.getProperty)(r)} === undefined`;return i?(0,t.or)(a,(0,t.not)(f(e,n,r))):a}e.noPropertyInData=m;function h(e){return e?Object.keys(e).filter(e=>e!==`__proto__`):[]}e.allSchemaProperties=h;function g(e,t){return h(t).filter(r=>!(0,n.alwaysValidSchema)(e,t[r]))}e.schemaProperties=g;function _({schemaCode:e,data:n,it:{gen:r,topSchemaRef:i,schemaPath:a,errorPath:s},it:c},l,u,d){let f=d?(0,t._)`${e}, ${n}, ${i}${a}`:n,p=[[o.default.instancePath,(0,t.strConcat)(o.default.instancePath,s)],[o.default.parentData,c.parentData],[o.default.parentDataProperty,c.parentDataProperty],[o.default.rootData,o.default.rootData]];c.opts.dynamicRef&&p.push([o.default.dynamicAnchors,o.default.dynamicAnchors]);let m=(0,t._)`${f}, ${r.object(...p)}`;return u===t.nil?(0,t._)`${l}(${m})`:(0,t._)`${l}.call(${u}, ${m})`}e.callValidateCode=_;let v=(0,t._)`new RegExp`;function y({gen:e,it:{opts:n}},r){let i=n.unicodeRegExp?`u`:``,{regExp:a}=n.code,o=a(r,i);return e.scopeValue(`pattern`,{key:o.toString(),ref:o,code:(0,t._)`${a.code===`new RegExp`?v:(0,s.useFunc)(e,a)}(${r}, ${i})`})}e.usePattern=y;function b(e){let{gen:r,data:i,keyword:a,it:o}=e,s=r.name(`valid`);if(o.allErrors){let e=r.let(`valid`,!0);return c(()=>r.assign(e,!1)),e}return r.var(s,!0),c(()=>r.break()),s;function c(o){let c=r.const(`len`,(0,t._)`${i}.length`);r.forRange(`i`,0,c,i=>{e.subschema({keyword:a,dataProp:i,dataPropType:n.Type.Num},s),r.if((0,t.not)(s),o)})}}e.validateArray=b;function x(e){let{gen:r,schema:i,keyword:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(i.some(e=>(0,n.alwaysValidSchema)(o,e))&&!o.opts.unevaluated)return;let s=r.let(`valid`,!1),c=r.name(`_valid`);r.block(()=>i.forEach((n,i)=>{let o=e.subschema({keyword:a,schemaProp:i,compositeRule:!0},c);r.assign(s,(0,t._)`${s} || ${c}`),e.mergeValidEvaluated(o,c)||r.if((0,t.not)(s))})),e.result(s,()=>e.reset(),()=>e.error(!0))}e.validateUnion=x})),p=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateKeywordUsage=e.validSchemaType=e.funcKeywordCode=e.macroKeywordCode=void 0;let t=r(),n=a(),i=f(),s=o();function c(e,n){let{gen:r,keyword:i,schema:a,parentSchema:o,it:s}=e,c=n.macro.call(s.self,a,o,s),l=m(r,i,c);s.opts.validateSchema!==!1&&s.self.validateSchema(c,!0);let u=r.name(`valid`);e.subschema({schema:c,schemaPath:t.nil,errSchemaPath:`${s.errSchemaPath}/${i}`,topSchemaRef:l,compositeRule:!0},u),e.pass(u,()=>e.error(!0))}e.macroKeywordCode=c;function l(e,r){let{gen:a,keyword:o,schema:s,parentSchema:c,$data:l,it:f}=e;p(f,r);let h=m(a,o,!l&&r.compile?r.compile.call(f.self,s,c,f):r.validate),g=a.let(`valid`);e.block$data(g,_),e.ok(r.valid??g);function _(){if(r.errors===!1)b(),r.modifying&&u(e),x(()=>e.error());else{let t=r.async?v():y();r.modifying&&u(e),x(()=>d(e,t))}}function v(){let e=a.let(`ruleErrs`,null);return a.try(()=>b((0,t._)`await `),n=>a.assign(g,!1).if((0,t._)`${n} instanceof ${f.ValidationError}`,()=>a.assign(e,(0,t._)`${n}.errors`),()=>a.throw(n))),e}function y(){let e=(0,t._)`${h}.errors`;return a.assign(e,null),b(t.nil),e}function b(o=r.async?(0,t._)`await `:t.nil){let s=f.opts.passContext?n.default.this:n.default.self,c=!(`compile`in r&&!l||r.schema===!1);a.assign(g,(0,t._)`${o}${(0,i.callValidateCode)(e,h,s,c)}`,r.modifying)}function x(e){a.if((0,t.not)(r.valid??g),e)}}e.funcKeywordCode=l;function u(e){let{gen:n,data:r,it:i}=e;n.if(i.parentData,()=>n.assign(r,(0,t._)`${i.parentData}[${i.parentDataProperty}]`))}function d(e,r){let{gen:i}=e;i.if((0,t._)`Array.isArray(${r})`,()=>{i.assign(n.default.vErrors,(0,t._)`${n.default.vErrors} === null ? ${r} : ${n.default.vErrors}.concat(${r})`).assign(n.default.errors,(0,t._)`${n.default.vErrors}.length`),(0,s.extendErrors)(e)},()=>e.error())}function p({schemaEnv:e},t){if(t.async&&!e.$async)throw Error(`async keyword in sync schema`)}function m(e,n,r){if(r===void 0)throw Error(`keyword "${n}" failed to compile`);return e.scopeValue(`keyword`,typeof r==`function`?{ref:r}:{ref:r,code:(0,t.stringify)(r)})}function h(e,t,n=!1){return!t.length||t.some(t=>t===`array`?Array.isArray(e):t===`object`?e&&typeof e==`object`&&!Array.isArray(e):typeof e==t||n&&e===void 0)}e.validSchemaType=h;function g({schema:e,opts:t,self:n,errSchemaPath:r},i,a){if(Array.isArray(i.keyword)?!i.keyword.includes(a):i.keyword!==a)throw Error(`ajv implementation error`);let o=i.dependencies;if(o?.some(t=>!Object.prototype.hasOwnProperty.call(e,t)))throw Error(`parent schema must have dependencies of ${a}: ${o.join(`,`)}`);if(i.validateSchema&&!i.validateSchema(e[a])){let e=`keyword "${a}" value is invalid at path "${r}": `+n.errorsText(i.validateSchema.errors);if(t.validateSchema===`log`)n.logger.error(e);else throw Error(e)}}e.validateKeywordUsage=g})),m=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.extendSubschemaMode=e.extendSubschemaData=e.getSubschema=void 0;let t=r(),n=i();function a(e,{keyword:r,schemaProp:i,schema:a,schemaPath:o,errSchemaPath:s,topSchemaRef:c}){if(r!==void 0&&a!==void 0)throw Error(`both "keyword" and "schema" passed, only one allowed`);if(r!==void 0){let a=e.schema[r];return i===void 0?{schema:a,schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}`,errSchemaPath:`${e.errSchemaPath}/${r}`}:{schema:a[i],schemaPath:(0,t._)`${e.schemaPath}${(0,t.getProperty)(r)}${(0,t.getProperty)(i)}`,errSchemaPath:`${e.errSchemaPath}/${r}/${(0,n.escapeFragment)(i)}`}}if(a!==void 0){if(o===void 0||s===void 0||c===void 0)throw Error(`"schemaPath", "errSchemaPath" and "topSchemaRef" are required with "schema"`);return{schema:a,schemaPath:o,topSchemaRef:c,errSchemaPath:s}}throw Error(`either "keyword" or "schema" must be passed`)}e.getSubschema=a;function o(e,r,{dataProp:i,dataPropType:a,data:o,dataTypes:s,propertyName:c}){if(o!==void 0&&i!==void 0)throw Error(`both "data" and "dataProp" passed, only one allowed`);let{gen:l}=r;if(i!==void 0){let{errorPath:o,dataPathArr:s,opts:c}=r;u(l.let(`data`,(0,t._)`${r.data}${(0,t.getProperty)(i)}`,!0)),e.errorPath=(0,t.str)`${o}${(0,n.getErrorPath)(i,a,c.jsPropertySyntax)}`,e.parentDataProperty=(0,t._)`${i}`,e.dataPathArr=[...s,e.parentDataProperty]}o!==void 0&&(u(o instanceof t.Name?o:l.let(`data`,o,!0)),c!==void 0&&(e.propertyName=c)),s&&(e.dataTypes=s);function u(t){e.data=t,e.dataLevel=r.dataLevel+1,e.dataTypes=[],r.definedProperties=new Set,e.parentData=r.data,e.dataNames=[...r.dataNames,t]}}e.extendSubschemaData=o;function s(e,{jtdDiscriminator:t,jtdMetadata:n,compositeRule:r,createErrors:i,allErrors:a}){r!==void 0&&(e.compositeRule=r),i!==void 0&&(e.createErrors=i),a!==void 0&&(e.allErrors=a),e.jtdDiscriminator=t,e.jtdMetadata=n}e.extendSubschemaMode=s})),h=e(((e,t)=>{t.exports=function e(t,n){if(t===n)return!0;if(t&&n&&typeof t==`object`&&typeof n==`object`){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if(r=t.length,r!=n.length)return!1;for(i=r;i--!==0;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if(a=Object.keys(t),r=a.length,r!==Object.keys(n).length)return!1;for(i=r;i--!==0;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;i--!==0;){var o=a[i];if(!e(t[o],n[o]))return!1}return!0}return t!==t&&n!==n}})),g=e(((e,t)=>{var n=t.exports=function(e,t,n){typeof t==`function`&&(n=t,t={}),n=t.cb||n;var i=typeof n==`function`?n:n.pre||function(){},a=n.post||function(){};r(t,i,a,e,``,e)};n.keywords={additionalItems:!0,items:!0,contains:!0,additionalProperties:!0,propertyNames:!0,not:!0,if:!0,then:!0,else:!0},n.arrayKeywords={items:!0,allOf:!0,anyOf:!0,oneOf:!0},n.propsKeywords={$defs:!0,definitions:!0,properties:!0,patternProperties:!0,dependencies:!0},n.skipKeywords={default:!0,enum:!0,const:!0,required:!0,maximum:!0,minimum:!0,exclusiveMaximum:!0,exclusiveMinimum:!0,multipleOf:!0,maxLength:!0,minLength:!0,pattern:!0,format:!0,maxItems:!0,minItems:!0,uniqueItems:!0,maxProperties:!0,minProperties:!0};function r(e,t,a,o,s,c,l,u,d,f){if(o&&typeof o==`object`&&!Array.isArray(o)){for(var p in t(o,s,c,l,u,d,f),o){var m=o[p];if(Array.isArray(m)){if(p in n.arrayKeywords)for(var h=0;h<m.length;h++)r(e,t,a,m[h],s+`/`+p+`/`+h,c,s,p,o,h)}else if(p in n.propsKeywords){if(m&&typeof m==`object`)for(var g in m)r(e,t,a,m[g],s+`/`+p+`/`+i(g),c,s,p,o,g)}else (p in n.keywords||e.allKeys&&!(p in n.skipKeywords))&&r(e,t,a,m,s+`/`+p,c,s,p,o)}a(o,s,c,l,u,d,f)}}function i(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}})),_=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getSchemaRefs=e.resolveUrl=e.normalizeId=e._getFullPath=e.getFullPath=e.inlineRef=void 0;let t=i(),n=h(),r=g(),a=new Set([`type`,`format`,`pattern`,`maxLength`,`minLength`,`maxProperties`,`minProperties`,`maxItems`,`minItems`,`maximum`,`minimum`,`uniqueItems`,`multipleOf`,`required`,`enum`,`const`]);function o(e,t=!0){return typeof e==`boolean`?!0:t===!0?!c(e):t?l(e)<=t:!1}e.inlineRef=o;let s=new Set([`$ref`,`$recursiveRef`,`$recursiveAnchor`,`$dynamicRef`,`$dynamicAnchor`]);function c(e){for(let t in e){if(s.has(t))return!0;let n=e[t];if(Array.isArray(n)&&n.some(c)||typeof n==`object`&&c(n))return!0}return!1}function l(e){let n=0;for(let r in e)if(r===`$ref`||(n++,!a.has(r)&&(typeof e[r]==`object`&&(0,t.eachItem)(e[r],e=>n+=l(e)),n===1/0)))return 1/0;return n}function u(e,t=``,n){return n!==!1&&(t=p(t)),d(e,e.parse(t))}e.getFullPath=u;function d(e,t){return e.serialize(t).split(`#`)[0]+`#`}e._getFullPath=d;let f=/#\/?$/;function p(e){return e?e.replace(f,``):``}e.normalizeId=p;function m(e,t,n){return n=p(n),e.resolve(t,n)}e.resolveUrl=m;let _=/^[a-z_][-a-z0-9._]*$/i;function v(e,t){if(typeof e==`boolean`)return{};let{schemaId:i,uriResolver:a}=this.opts,o=p(e[i]||t),s={"":o},c=u(a,o,!1),l={},d=new Set;return r(e,{allKeys:!0},(e,t,n,r)=>{if(r===void 0)return;let a=c+t,o=s[r];typeof e[i]==`string`&&(o=u.call(this,e[i])),h.call(this,e.$anchor),h.call(this,e.$dynamicAnchor),s[t]=o;function u(t){let n=this.opts.uriResolver.resolve;if(t=p(o?n(o,t):t),d.has(t))throw m(t);d.add(t);let r=this.refs[t];return typeof r==`string`&&(r=this.refs[r]),typeof r==`object`?f(e,r.schema,t):t!==p(a)&&(t[0]===`#`?(f(e,l[t],t),l[t]=e):this.refs[t]=a),t}function h(e){if(typeof e==`string`){if(!_.test(e))throw Error(`invalid anchor "${e}"`);u.call(this,`#${e}`)}}}),l;function f(e,t,r){if(t!==void 0&&!n(e,t))throw m(r)}function m(e){return Error(`reference "${e}" resolves to more than one schema`)}}e.getSchemaRefs=v})),v=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.getData=e.KeywordCxt=e.validateFunctionCode=void 0;let t=s(),n=u(),c=l(),f=u(),h=d(),g=p(),v=m(),y=r(),b=a(),x=_(),S=i(),C=o();function w(e){if(N(e)&&(F(e),M(e))){O(e);return}T(e,()=>(0,t.topBoolOrEmptySchema)(e))}e.validateFunctionCode=w;function T({gen:e,validateName:t,schema:n,schemaEnv:r,opts:i},a){i.code.es5?e.func(t,(0,y._)`${b.default.data}, ${b.default.valCxt}`,r.$async,()=>{e.code((0,y._)`"use strict"; ${A(n,i)}`),D(e,i),e.code(a)}):e.func(t,(0,y._)`${b.default.data}, ${E(i)}`,r.$async,()=>e.code(A(n,i)).code(a))}function E(e){return(0,y._)`{${b.default.instancePath}="", ${b.default.parentData}, ${b.default.parentDataProperty}, ${b.default.rootData}=${b.default.data}${e.dynamicRef?(0,y._)`, ${b.default.dynamicAnchors}={}`:y.nil}}={}`}function D(e,t){e.if(b.default.valCxt,()=>{e.var(b.default.instancePath,(0,y._)`${b.default.valCxt}.${b.default.instancePath}`),e.var(b.default.parentData,(0,y._)`${b.default.valCxt}.${b.default.parentData}`),e.var(b.default.parentDataProperty,(0,y._)`${b.default.valCxt}.${b.default.parentDataProperty}`),e.var(b.default.rootData,(0,y._)`${b.default.valCxt}.${b.default.rootData}`),t.dynamicRef&&e.var(b.default.dynamicAnchors,(0,y._)`${b.default.valCxt}.${b.default.dynamicAnchors}`)},()=>{e.var(b.default.instancePath,(0,y._)`""`),e.var(b.default.parentData,(0,y._)`undefined`),e.var(b.default.parentDataProperty,(0,y._)`undefined`),e.var(b.default.rootData,b.default.data),t.dynamicRef&&e.var(b.default.dynamicAnchors,(0,y._)`{}`)})}function O(e){let{schema:t,opts:n,gen:r}=e;T(e,()=>{n.$comment&&t.$comment&&V(e),R(e),r.let(b.default.vErrors,null),r.let(b.default.errors,0),n.unevaluated&&k(e),I(e),H(e)})}function k(e){let{gen:t,validateName:n}=e;e.evaluated=t.const(`evaluated`,(0,y._)`${n}.evaluated`),t.if((0,y._)`${e.evaluated}.dynamicProps`,()=>t.assign((0,y._)`${e.evaluated}.props`,(0,y._)`undefined`)),t.if((0,y._)`${e.evaluated}.dynamicItems`,()=>t.assign((0,y._)`${e.evaluated}.items`,(0,y._)`undefined`))}function A(e,t){let n=typeof e==`object`&&e[t.schemaId];return n&&(t.code.source||t.code.process)?(0,y._)`/*# sourceURL=${n} */`:y.nil}function j(e,n){if(N(e)&&(F(e),M(e))){P(e,n);return}(0,t.boolOrEmptySchema)(e,n)}function M({schema:e,self:t}){if(typeof e==`boolean`)return!e;for(let n in e)if(t.RULES.all[n])return!0;return!1}function N(e){return typeof e.schema!=`boolean`}function P(e,t){let{schema:n,gen:r,opts:i}=e;i.$comment&&n.$comment&&V(e),z(e),B(e);let a=r.const(`_errs`,b.default.errors);I(e,a),r.var(t,(0,y._)`${a} === ${b.default.errors}`)}function F(e){(0,S.checkUnknownRules)(e),L(e)}function I(e,t){if(e.opts.jtd)return W(e,[],!1,t);let r=(0,n.getSchemaTypes)(e.schema);W(e,r,!(0,n.coerceAndCheckDataType)(e,r),t)}function L(e){let{schema:t,errSchemaPath:n,opts:r,self:i}=e;t.$ref&&r.ignoreKeywordsWithRef&&(0,S.schemaHasRulesButRef)(t,i.RULES)&&i.logger.warn(`$ref: keywords ignored in schema at path "${n}"`)}function R(e){let{schema:t,opts:n}=e;t.default!==void 0&&n.useDefaults&&n.strictSchema&&(0,S.checkStrictMode)(e,`default is ignored in the schema root`)}function z(e){let t=e.schema[e.opts.schemaId];t&&(e.baseId=(0,x.resolveUrl)(e.opts.uriResolver,e.baseId,t))}function B(e){if(e.schema.$async&&!e.schemaEnv.$async)throw Error(`async schema in sync schema`)}function V({gen:e,schemaEnv:t,schema:n,errSchemaPath:r,opts:i}){let a=n.$comment;if(i.$comment===!0)e.code((0,y._)`${b.default.self}.logger.log(${a})`);else if(typeof i.$comment==`function`){let n=(0,y.str)`${r}/$comment`,i=e.scopeValue(`root`,{ref:t.root});e.code((0,y._)`${b.default.self}.opts.$comment(${a}, ${n}, ${i}.schema)`)}}function H(e){let{gen:t,schemaEnv:n,validateName:r,ValidationError:i,opts:a}=e;n.$async?t.if((0,y._)`${b.default.errors} === 0`,()=>t.return(b.default.data),()=>t.throw((0,y._)`new ${i}(${b.default.vErrors})`)):(t.assign((0,y._)`${r}.errors`,b.default.vErrors),a.unevaluated&&U(e),t.return((0,y._)`${b.default.errors} === 0`))}function U({gen:e,evaluated:t,props:n,items:r}){n instanceof y.Name&&e.assign((0,y._)`${t}.props`,n),r instanceof y.Name&&e.assign((0,y._)`${t}.items`,r)}function W(e,t,n,r){let{gen:i,schema:a,data:o,allErrors:s,opts:l,self:u}=e,{RULES:d}=u;if(a.$ref&&(l.ignoreKeywordsWithRef||!(0,S.schemaHasRulesButRef)(a,d))){i.block(()=>Q(e,`$ref`,d.all.$ref.definition));return}l.jtd||K(e,t),i.block(()=>{for(let e of d.rules)p(e);p(d.post)});function p(u){(0,c.shouldUseGroup)(a,u)&&(u.type?(i.if((0,f.checkDataType)(u.type,o,l.strictNumbers)),G(e,u),t.length===1&&t[0]===u.type&&n&&(i.else(),(0,f.reportTypeError)(e)),i.endIf()):G(e,u),s||i.if((0,y._)`${b.default.errors} === ${r||0}`))}}function G(e,t){let{gen:n,schema:r,opts:{useDefaults:i}}=e;i&&(0,h.assignDefaults)(e,t.type),n.block(()=>{for(let n of t.rules)(0,c.shouldUseRule)(r,n)&&Q(e,n.keyword,n.definition,t.type)})}function K(e,t){e.schemaEnv.meta||!e.opts.strictTypes||(q(e,t),e.opts.allowUnionTypes||ee(e,t),J(e,e.dataTypes))}function q(e,t){if(t.length){if(!e.dataTypes.length){e.dataTypes=t;return}t.forEach(t=>{Y(e.dataTypes,t)||X(e,`type "${t}" not allowed by context "${e.dataTypes.join(`,`)}"`)}),ne(e,t)}}function ee(e,t){t.length>1&&!(t.length===2&&t.includes(`null`))&&X(e,`use allowUnionTypes to allow union type keyword`)}function J(e,t){let n=e.self.RULES.all;for(let r in n){let i=n[r];if(typeof i==`object`&&(0,c.shouldUseRule)(e.schema,i)){let{type:n}=i.definition;n.length&&!n.some(e=>te(t,e))&&X(e,`missing type "${n.join(`,`)}" for keyword "${r}"`)}}}function te(e,t){return e.includes(t)||t===`number`&&e.includes(`integer`)}function Y(e,t){return e.includes(t)||t===`integer`&&e.includes(`number`)}function ne(e,t){let n=[];for(let r of e.dataTypes)Y(t,r)?n.push(r):t.includes(`integer`)&&r===`number`&&n.push(`integer`);e.dataTypes=n}function X(e,t){let n=e.schemaEnv.baseId+e.errSchemaPath;t+=` at "${n}" (strictTypes)`,(0,S.checkStrictMode)(e,t,e.opts.strictTypes)}var Z=class{constructor(e,t,n){if((0,g.validateKeywordUsage)(e,t,n),this.gen=e.gen,this.allErrors=e.allErrors,this.keyword=n,this.data=e.data,this.schema=e.schema[n],this.$data=t.$data&&e.opts.$data&&this.schema&&this.schema.$data,this.schemaValue=(0,S.schemaRefOrVal)(e,this.schema,n,this.$data),this.schemaType=t.schemaType,this.parentSchema=e.schema,this.params={},this.it=e,this.def=t,this.$data)this.schemaCode=e.gen.const(`vSchema`,$(this.$data,e));else if(this.schemaCode=this.schemaValue,!(0,g.validSchemaType)(this.schema,t.schemaType,t.allowUndefined))throw Error(`${n} value must be ${JSON.stringify(t.schemaType)}`);(`code`in t?t.trackErrors:t.errors!==!1)&&(this.errsCount=e.gen.const(`_errs`,b.default.errors))}result(e,t,n){this.failResult((0,y.not)(e),t,n)}failResult(e,t,n){this.gen.if(e),n?n():this.error(),t?(this.gen.else(),t(),this.allErrors&&this.gen.endIf()):this.allErrors?this.gen.endIf():this.gen.else()}pass(e,t){this.failResult((0,y.not)(e),void 0,t)}fail(e){if(e===void 0){this.error(),this.allErrors||this.gen.if(!1);return}this.gen.if(e),this.error(),this.allErrors?this.gen.endIf():this.gen.else()}fail$data(e){if(!this.$data)return this.fail(e);let{schemaCode:t}=this;this.fail((0,y._)`${t} !== undefined && (${(0,y.or)(this.invalid$data(),e)})`)}error(e,t,n){if(t){this.setParams(t),this._error(e,n),this.setParams({});return}this._error(e,n)}_error(e,t){(e?C.reportExtraError:C.reportError)(this,this.def.error,t)}$dataError(){(0,C.reportError)(this,this.def.$dataError||C.keyword$DataError)}reset(){if(this.errsCount===void 0)throw Error(`add "trackErrors" to keyword definition`);(0,C.resetErrorsCount)(this.gen,this.errsCount)}ok(e){this.allErrors||this.gen.if(e)}setParams(e,t){t?Object.assign(this.params,e):this.params=e}block$data(e,t,n=y.nil){this.gen.block(()=>{this.check$data(e,n),t()})}check$data(e=y.nil,t=y.nil){if(!this.$data)return;let{gen:n,schemaCode:r,schemaType:i,def:a}=this;n.if((0,y.or)((0,y._)`${r} === undefined`,t)),e!==y.nil&&n.assign(e,!0),(i.length||a.validateSchema)&&(n.elseIf(this.invalid$data()),this.$dataError(),e!==y.nil&&n.assign(e,!1)),n.else()}invalid$data(){let{gen:e,schemaCode:t,schemaType:n,def:r,it:i}=this;return(0,y.or)(a(),o());function a(){if(n.length){if(!(t instanceof y.Name))throw Error(`ajv implementation error`);let e=Array.isArray(n)?n:[n];return(0,y._)`${(0,f.checkDataTypes)(e,t,i.opts.strictNumbers,f.DataType.Wrong)}`}return y.nil}function o(){if(r.validateSchema){let n=e.scopeValue(`validate$data`,{ref:r.validateSchema});return(0,y._)`!${n}(${t})`}return y.nil}}subschema(e,t){let n=(0,v.getSubschema)(this.it,e);(0,v.extendSubschemaData)(n,this.it,e),(0,v.extendSubschemaMode)(n,e);let r={...this.it,...n,items:void 0,props:void 0};return j(r,t),r}mergeEvaluated(e,t){let{it:n,gen:r}=this;n.opts.unevaluated&&(n.props!==!0&&e.props!==void 0&&(n.props=S.mergeEvaluated.props(r,e.props,n.props,t)),n.items!==!0&&e.items!==void 0&&(n.items=S.mergeEvaluated.items(r,e.items,n.items,t)))}mergeValidEvaluated(e,t){let{it:n,gen:r}=this;if(n.opts.unevaluated&&(n.props!==!0||n.items!==!0))return r.if(t,()=>this.mergeEvaluated(e,y.Name)),!0}};e.KeywordCxt=Z;function Q(e,t,n,r){let i=new Z(e,n,t);`code`in n?n.code(i,r):i.$data&&n.validate?(0,g.funcKeywordCode)(i,n):`macro`in n?(0,g.macroKeywordCode)(i,n):(n.compile||n.validate)&&(0,g.funcKeywordCode)(i,n)}let re=/^\/(?:[^~]|~0|~1)*$/,ie=/^([0-9]+)(#|\/(?:[^~]|~0|~1)*)?$/;function $(e,{dataLevel:t,dataNames:n,dataPathArr:r}){let i,a;if(e===``)return b.default.rootData;if(e[0]===`/`){if(!re.test(e))throw Error(`Invalid JSON-pointer: ${e}`);i=e,a=b.default.rootData}else{let o=ie.exec(e);if(!o)throw Error(`Invalid JSON-pointer: ${e}`);let s=+o[1];if(i=o[2],i===`#`){if(s>=t)throw Error(c(`property/index`,s));return r[t-s]}if(s>t)throw Error(c(`data`,s));if(a=n[t-s],!i)return a}let o=a,s=i.split(`/`);for(let e of s)e&&(a=(0,y._)`${a}${(0,y.getProperty)((0,S.unescapeJsonPointer)(e))}`,o=(0,y._)`${o} && ${a}`);return o;function c(e,n){return`Cannot access ${e} ${n} levels up, current level is ${t}`}}e.getData=$})),y=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=class extends Error{constructor(e){super(`validation failed`),this.errors=e,this.ajv=this.validation=!0}}})),b=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=_();e.default=class extends Error{constructor(e,n,r,i){super(i||`can't resolve reference ${r} from id ${n}`),this.missingRef=(0,t.resolveUrl)(e,n,r),this.missingSchema=(0,t.normalizeId)((0,t.getFullPath)(e,this.missingRef))}}})),x=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.resolveSchema=e.getCompilingSchema=e.resolveRef=e.compileSchema=e.SchemaEnv=void 0;let t=r(),n=y(),o=a(),s=_(),c=i(),l=v();var u=class{constructor(e){this.refs={},this.dynamicAnchors={};let t;typeof e.schema==`object`&&(t=e.schema),this.schema=e.schema,this.schemaId=e.schemaId,this.root=e.root||this,this.baseId=e.baseId??(0,s.normalizeId)(t?.[e.schemaId||`$id`]),this.schemaPath=e.schemaPath,this.localRefs=e.localRefs,this.meta=e.meta,this.$async=t?.$async,this.refs={}}};e.SchemaEnv=u;function d(e){let r=m.call(this,e);if(r)return r;let i=(0,s.getFullPath)(this.opts.uriResolver,e.root.baseId),{es5:a,lines:c}=this.opts.code,{ownProperties:u}=this.opts,d=new t.CodeGen(this.scope,{es5:a,lines:c,ownProperties:u}),f;e.$async&&(f=d.scopeValue(`Error`,{ref:n.default,code:(0,t._)`require("ajv/dist/runtime/validation_error").default`}));let p=d.scopeName(`validate`);e.validateName=p;let h={gen:d,allErrors:this.opts.allErrors,data:o.default.data,parentData:o.default.parentData,parentDataProperty:o.default.parentDataProperty,dataNames:[o.default.data],dataPathArr:[t.nil],dataLevel:0,dataTypes:[],definedProperties:new Set,topSchemaRef:d.scopeValue(`schema`,this.opts.code.source===!0?{ref:e.schema,code:(0,t.stringify)(e.schema)}:{ref:e.schema}),validateName:p,ValidationError:f,schema:e.schema,schemaEnv:e,rootId:i,baseId:e.baseId||i,schemaPath:t.nil,errSchemaPath:e.schemaPath||(this.opts.jtd?``:`#`),errorPath:(0,t._)`""`,opts:this.opts,self:this},g;try{this._compilations.add(e),(0,l.validateFunctionCode)(h),d.optimize(this.opts.code.optimize);let n=d.toString();g=`${d.scopeRefs(o.default.scope)}return ${n}`,this.opts.code.process&&(g=this.opts.code.process(g,e));let r=Function(`${o.default.self}`,`${o.default.scope}`,g)(this,this.scope.get());if(this.scope.value(p,{ref:r}),r.errors=null,r.schema=e.schema,r.schemaEnv=e,e.$async&&(r.$async=!0),this.opts.code.source===!0&&(r.source={validateName:p,validateCode:n,scopeValues:d._values}),this.opts.unevaluated){let{props:e,items:n}=h;r.evaluated={props:e instanceof t.Name?void 0:e,items:n instanceof t.Name?void 0:n,dynamicProps:e instanceof t.Name,dynamicItems:n instanceof t.Name},r.source&&(r.source.evaluated=(0,t.stringify)(r.evaluated))}return e.validate=r,e}catch(t){throw delete e.validate,delete e.validateName,g&&this.logger.error(`Error compiling schema, function code:`,g),t}finally{this._compilations.delete(e)}}e.compileSchema=d;function f(e,t,n){n=(0,s.resolveUrl)(this.opts.uriResolver,t,n);let r=e.refs[n];if(r)return r;let i=g.call(this,e,n);if(i===void 0){let r=e.localRefs?.[n],{schemaId:a}=this.opts;r&&(i=new u({schema:r,schemaId:a,root:e,baseId:t}))}if(i!==void 0)return e.refs[n]=p.call(this,i)}e.resolveRef=f;function p(e){return(0,s.inlineRef)(e.schema,this.opts.inlineRefs)?e.schema:e.validate?e:d.call(this,e)}function m(e){for(let t of this._compilations)if(h(t,e))return t}e.getCompilingSchema=m;function h(e,t){return e.schema===t.schema&&e.root===t.root&&e.baseId===t.baseId}function g(e,t){let n;for(;typeof(n=this.refs[t])==`string`;)t=n;return n||this.schemas[t]||b.call(this,e,t)}function b(e,t){let n=this.opts.uriResolver.parse(t),r=(0,s._getFullPath)(this.opts.uriResolver,n),i=(0,s.getFullPath)(this.opts.uriResolver,e.baseId,void 0);if(Object.keys(e.schema).length>0&&r===i)return S.call(this,n,e);let a=(0,s.normalizeId)(r),o=this.refs[a]||this.schemas[a];if(typeof o==`string`){let t=b.call(this,e,o);return typeof t?.schema==`object`?S.call(this,n,t):void 0}if(typeof o?.schema==`object`){if(o.validate||d.call(this,o),a===(0,s.normalizeId)(t)){let{schema:t}=o,{schemaId:n}=this.opts,r=t[n];return r&&(i=(0,s.resolveUrl)(this.opts.uriResolver,i,r)),new u({schema:t,schemaId:n,root:e,baseId:i})}return S.call(this,n,o)}}e.resolveSchema=b;let x=new Set([`properties`,`patternProperties`,`enum`,`dependencies`,`definitions`]);function S(e,{baseId:t,schema:n,root:r}){if(e.fragment?.[0]!==`/`)return;for(let r of e.fragment.slice(1).split(`/`)){if(typeof n==`boolean`)return;let e=n[(0,c.unescapeFragment)(r)];if(e===void 0)return;n=e;let i=typeof n==`object`&&n[this.opts.schemaId];!x.has(r)&&i&&(t=(0,s.resolveUrl)(this.opts.uriResolver,t,i))}let i;if(typeof n!=`boolean`&&n.$ref&&!(0,c.schemaHasRulesButRef)(n,this.RULES)){let e=(0,s.resolveUrl)(this.opts.uriResolver,t,n.$ref);i=b.call(this,r,e)}let{schemaId:a}=this.opts;if(i||=new u({schema:n,schemaId:a,root:r,baseId:t}),i.schema!==i.root.schema)return i}})),S=e(((e,t)=>{t.exports={$id:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`,description:`Meta-schema for $data reference (JSON AnySchema extension proposal)`,type:`object`,required:[`$data`],properties:{$data:{type:`string`,anyOf:[{format:`relative-json-pointer`},{format:`json-pointer`}]}},additionalProperties:!1}})),C=e(((e,t)=>{let n=RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu),r=RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u),i=RegExp.prototype.test.bind(/^[\da-f]{2}$/iu),a=RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu),o=RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);function s(e){let t=``,n=0,r=0;for(r=0;r<e.length;r++)if(n=e[r].charCodeAt(0),n!==48){if(!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r];break}for(r+=1;r<e.length;r++){if(n=e[r].charCodeAt(0),!(n>=48&&n<=57||n>=65&&n<=70||n>=97&&n<=102))return``;t+=e[r]}return t}let c=RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);function l(e){return e.length=0,!0}function u(e,t,n){if(e.length){let r=s(e);if(r!==``)t.push(r);else return n.error=!0,!1;e.length=0}return!0}function d(e){let t=0,n={error:!1,address:``,zone:``},r=[],i=[],a=!1,o=!1,c=u;for(let s=0;s<e.length;s++){let u=e[s];if(!(u===`[`||u===`]`))if(u===`:`){if(a===!0&&(o=!0),!c(i,r,n))break;if(++t>7){n.error=!0;break}s>0&&e[s-1]===`:`&&(a=!0),r.push(`:`);continue}else if(u===`%`){if(!c(i,r,n))break;c=l}else{i.push(u);continue}}return i.length&&(c===l?n.zone=i.join(``):o?r.push(i.join(``)):r.push(s(i))),n.address=r.join(``),n}function f(e){if(p(e,`:`)<2)return{host:e,isIPV6:!1};let t=d(e);if(t.error)return{host:e,isIPV6:!1};{let e=t.address,n=t.address;return t.zone&&(e+=`%`+t.zone,n+=`%25`+t.zone),{host:e,isIPV6:!0,escapedHost:n}}}function p(e,t){let n=0;for(let r=0;r<e.length;r++)e[r]===t&&n++;return n}function m(e){let t=e,n=[],r=-1,i=0;for(;i=t.length;){if(i===1){if(t===`.`)break;if(t===`/`){n.push(`/`);break}else{n.push(t);break}}else if(i===2){if(t[0]===`.`){if(t[1]===`.`)break;if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&(t[1]===`.`||t[1]===`/`)){n.push(`/`);break}}else if(i===3&&t===`/..`){n.length!==0&&n.pop(),n.push(`/`);break}if(t[0]===`.`){if(t[1]===`.`){if(t[2]===`/`){t=t.slice(3);continue}}else if(t[1]===`/`){t=t.slice(2);continue}}else if(t[0]===`/`&&t[1]===`.`){if(t[2]===`/`){t=t.slice(2);continue}else if(t[2]===`.`&&t[3]===`/`){t=t.slice(3),n.length!==0&&n.pop();continue}}if((r=t.indexOf(`/`,1))===-1){n.push(t);break}else n.push(t.slice(0,r)),t=t.slice(r)}return n.join(``)}let h={"@":`%40`,"/":`%2F`,"?":`%3F`,"#":`%23`,":":`%3A`},g=/[@/?#:]/g,_=/[@/?#]/g;function v(e,t){let n=t?_:g;return n.lastIndex=0,e.replace(n,e=>h[e])}function y(e,t=!1){if(e.indexOf(`%`)===-1)return e;let n=``;for(let r=0;r<e.length;r++){if(e[r]===`%`&&r+2<e.length){let o=e.slice(r+1,r+3);if(i(o)){let e=o.toUpperCase(),i=String.fromCharCode(parseInt(e,16));t&&a(i)?n+=i:n+=`%`+e,r+=2;continue}}n+=e[r]}return n}function b(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){let e=r.toUpperCase(),i=String.fromCharCode(parseInt(e,16));i!==`.`&&a(i)?t+=i:t+=`%`+e,n+=2;continue}}o(e[n])?t+=e[n]:t+=escape(e[n])}return t}function x(e){let t=``;for(let n=0;n<e.length;n++){if(e[n]===`%`&&n+2<e.length){let r=e.slice(n+1,n+3);if(i(r)){t+=`%`+r.toUpperCase(),n+=2;continue}}t+=escape(e[n])}return t}function S(e){let t=[];if(e.userinfo!==void 0&&(t.push(e.userinfo),t.push(`@`)),e.host!==void 0){let n=unescape(e.host);if(!r(n)){let e=f(n);n=e.isIPV6===!0?`[${e.escapedHost}]`:v(n,!1)}t.push(n)}return(typeof e.port==`number`||typeof e.port==`string`)&&(t.push(`:`),t.push(String(e.port))),t.length?t.join(``):void 0}t.exports={nonSimpleDomain:c,recomposeAuthority:S,reescapeHostDelimiters:v,normalizePercentEncoding:y,normalizePathEncoding:b,escapePreservingEscapes:x,removeDotSegments:m,isIPv4:r,isUUID:n,normalizeIPv6:f,stringArrayToHexStripped:s}})),w=e(((e,t)=>{let{isUUID:n}=C(),r=/([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu,i=[`http`,`https`,`ws`,`wss`,`urn`,`urn:uuid`];function a(e){return i.indexOf(e)!==-1}function o(e){return e.secure===!0?!0:e.secure===!1?!1:e.scheme?e.scheme.length===3&&(e.scheme[0]===`w`||e.scheme[0]===`W`)&&(e.scheme[1]===`s`||e.scheme[1]===`S`)&&(e.scheme[2]===`s`||e.scheme[2]===`S`):!1}function s(e){return e.host||(e.error=e.error||`HTTP URIs must have a host.`),e}function c(e){let t=String(e.scheme).toLowerCase()===`https`;return(e.port===(t?443:80)||e.port===``)&&(e.port=void 0),e.path||=`/`,e}function l(e){return e.secure=o(e),e.resourceName=(e.path||`/`)+(e.query?`?`+e.query:``),e.path=void 0,e.query=void 0,e}function u(e){if((e.port===(o(e)?443:80)||e.port===``)&&(e.port=void 0),typeof e.secure==`boolean`&&(e.scheme=e.secure?`wss`:`ws`,e.secure=void 0),e.resourceName){let[t,n]=e.resourceName.split(`?`);e.path=t&&t!==`/`?t:void 0,e.query=n,e.resourceName=void 0}return e.fragment=void 0,e}function d(e,t){if(!e.path)return e.error=`URN can not be parsed`,e;let n=e.path.match(r);if(n){let r=t.scheme||e.scheme||`urn`;e.nid=n[1].toLowerCase(),e.nss=n[2];let i=y(`${r}:${t.nid||e.nid}`);e.path=void 0,i&&(e=i.parse(e,t))}else e.error=e.error||`URN can not be parsed.`;return e}function f(e,t){if(e.nid===void 0)throw Error(`URN without nid cannot be serialized`);let n=t.scheme||e.scheme||`urn`,r=e.nid.toLowerCase(),i=y(`${n}:${t.nid||r}`);i&&(e=i.serialize(e,t));let a=e,o=e.nss;return a.path=`${r||t.nid}:${o}`,t.skipEscape=!0,a}function p(e,t){let r=e;return r.uuid=r.nss,r.nss=void 0,!t.tolerant&&(!r.uuid||!n(r.uuid))&&(r.error=r.error||`UUID is not valid.`),r}function m(e){let t=e;return t.nss=(e.uuid||``).toLowerCase(),t}let h={scheme:`http`,domainHost:!0,parse:s,serialize:c},g={scheme:`https`,domainHost:h.domainHost,parse:s,serialize:c},_={scheme:`ws`,domainHost:!0,parse:l,serialize:u},v={http:h,https:g,ws:_,wss:{scheme:`wss`,domainHost:_.domainHost,parse:_.parse,serialize:_.serialize},urn:{scheme:`urn`,parse:d,serialize:f,skipNormalize:!0},"urn:uuid":{scheme:`urn:uuid`,parse:p,serialize:m,skipNormalize:!0}};Object.setPrototypeOf(v,null);function y(e){return e&&(v[e]||v[e.toLowerCase()])||void 0}t.exports={wsIsSecure:o,SCHEMES:v,isValidSchemeName:a,getSchemeHandler:y}})),T=e(((e,t)=>{let{normalizeIPv6:n,removeDotSegments:r,recomposeAuthority:i,normalizePercentEncoding:a,normalizePathEncoding:o,escapePreservingEscapes:s,reescapeHostDelimiters:c,isIPv4:l,nonSimpleDomain:u}=C(),{SCHEMES:d,getSchemeHandler:f}=w();function p(e,t){return typeof e==`string`?e=S(e,t):typeof e==`object`&&(e=x(_(e,t),t)),e}function m(e,t,n){let r=n?Object.assign({scheme:`null`},n):{scheme:`null`},i=h(x(e,r),x(t,r),r,!0);return r.skipEscape=!0,_(i,r)}function h(e,t,n,i){let a={};return i||(e=x(_(e,n),n),t=x(_(t,n),n)),n||={},!n.tolerant&&t.scheme?(a.scheme=t.scheme,a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.userinfo!==void 0||t.host!==void 0||t.port!==void 0?(a.userinfo=t.userinfo,a.host=t.host,a.port=t.port,a.path=r(t.path||``),a.query=t.query):(t.path?(t.path[0]===`/`?a.path=r(t.path):((e.userinfo!==void 0||e.host!==void 0||e.port!==void 0)&&!e.path?a.path=`/`+t.path:e.path?a.path=e.path.slice(0,e.path.lastIndexOf(`/`)+1)+t.path:a.path=t.path,a.path=r(a.path)),a.query=t.query):(a.path=e.path,t.query===void 0?a.query=e.query:a.query=t.query),a.userinfo=e.userinfo,a.host=e.host,a.port=e.port),a.scheme=e.scheme),a.fragment=t.fragment,a}function g(e,t,n){let r=E(e,n),i=E(t,n);return r!==void 0&&i!==void 0&&r.toLowerCase()===i.toLowerCase()}function _(e,t){let n={host:e.host,scheme:e.scheme,userinfo:e.userinfo,port:e.port,path:e.path,query:e.query,nid:e.nid,nss:e.nss,uuid:e.uuid,fragment:e.fragment,reference:e.reference,resourceName:e.resourceName,secure:e.secure,error:``},o=Object.assign({},t),c=[],l=f(o.scheme||n.scheme);l&&l.serialize&&l.serialize(n,o),n.path!==void 0&&(o.skipEscape?n.path=a(n.path):(n.path=s(n.path),n.scheme!==void 0&&(n.path=n.path.split(`%3A`).join(`:`)))),o.reference!==`suffix`&&n.scheme&&c.push(n.scheme,`:`);let u=i(n);if(u!==void 0&&(o.reference!==`suffix`&&c.push(`//`),c.push(u),n.path&&n.path[0]!==`/`&&c.push(`/`)),n.path!==void 0){let e=n.path;!o.absolutePath&&(!l||!l.absolutePath)&&(e=r(e)),u===void 0&&e[0]===`/`&&e[1]===`/`&&(e=`/%2F`+e.slice(2)),c.push(e)}return n.query!==void 0&&c.push(`?`,n.query),n.fragment!==void 0&&c.push(`#`,n.fragment),c.join(``)}let v=/^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;function y(e,t){if(t[2]!==void 0&&e.path&&e.path[0]!==`/`)return`URI path must start with "/" when authority is present.`;if(typeof e.port==`number`&&(e.port<0||e.port>65535))return`URI port is malformed.`}function b(e,t){let r=Object.assign({},t),i={scheme:void 0,userinfo:void 0,host:``,port:void 0,path:``,query:void 0,fragment:void 0},a=!1,s=!1;r.reference===`suffix`&&(e=r.scheme?r.scheme+`:`+e:`//`+e);let d=e.match(v);if(d){i.scheme=d[1],i.userinfo=d[3],i.host=d[4],i.port=parseInt(d[5],10),i.path=d[6]||``,i.query=d[7],i.fragment=d[8],isNaN(i.port)&&(i.port=d[5]);let t=y(i,d);if(t!==void 0&&(i.error=i.error||t,a=!0),i.host)if(l(i.host)===!1){let e=n(i.host);i.host=e.host.toLowerCase(),s=e.isIPV6}else s=!0;i.scheme===void 0&&i.userinfo===void 0&&i.host===void 0&&i.port===void 0&&i.query===void 0&&!i.path?i.reference=`same-document`:i.scheme===void 0?i.reference=`relative`:i.fragment===void 0?i.reference=`absolute`:i.reference=`uri`,r.reference&&r.reference!==`suffix`&&r.reference!==i.reference&&(i.error=i.error||`URI is not a `+r.reference+` reference.`);let p=f(r.scheme||i.scheme);if(!r.unicodeSupport&&(!p||!p.unicodeSupport)&&i.host&&(r.domainHost||p&&p.domainHost)&&s===!1&&u(i.host))try{i.host=URL.domainToASCII(i.host.toLowerCase())}catch(e){i.error=i.error||`Host's domain name can not be converted to ASCII: `+e}if((!p||p&&!p.skipNormalize)&&(e.indexOf(`%`)!==-1&&(i.scheme!==void 0&&(i.scheme=unescape(i.scheme)),i.host!==void 0&&(i.host=c(unescape(i.host),s))),i.path&&=o(i.path),i.fragment))try{i.fragment=encodeURI(decodeURIComponent(i.fragment))}catch{i.error=i.error||`URI malformed`}p&&p.parse&&p.parse(i,r)}else i.error=i.error||`URI can not be parsed.`;return{parsed:i,malformedAuthorityOrPort:a}}function x(e,t){return b(e,t).parsed}function S(e,t){return T(e,t).normalized}function T(e,t){let{parsed:n,malformedAuthorityOrPort:r}=b(e,t);return{normalized:r?e:_(n,t),malformedAuthorityOrPort:r}}function E(e,t){if(typeof e==`string`){let{normalized:n,malformedAuthorityOrPort:r}=T(e,t);return r?void 0:n}if(typeof e==`object`)return _(e,t)}let D={SCHEMES:d,normalize:p,resolve:m,resolveComponent:h,equal:g,serialize:_,parse:x};t.exports=D,t.exports.default=D,t.exports.fastUri=D})),E=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=T();t.code=`require("ajv/dist/runtime/uri").default`,e.default=t})),D=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=void 0;var t=v();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return t.KeywordCxt}});var n=r();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return n.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return n.CodeGen}});let a=y(),o=b(),s=c(),l=x(),d=r(),f=_(),p=u(),m=i(),h=S(),g=E(),C=(e,t)=>new RegExp(e,t);C.code=`new RegExp`;let w=[`removeAdditional`,`useDefaults`,`coerceTypes`],T=new Set([`validate`,`serialize`,`parse`,`wrapper`,`root`,`schema`,`keyword`,`pattern`,`formats`,`validate$data`,`func`,`obj`,`Error`]),D={errorDataPath:``,format:"`validateFormats: false` can be used instead.",nullable:`"nullable" keyword is supported by default.`,jsonPointers:`Deprecated jsPropertySyntax can be used instead.`,extendRefs:`Deprecated ignoreKeywordsWithRef can be used instead.`,missingRefs:`Pass empty schema with $id that should be ignored to ajv.addSchema.`,processCode:"Use option `code: {process: (code, schemaEnv: object) => string}`",sourceCode:"Use option `code: {source: true}`",strictDefaults:"It is default now, see option `strict`.",strictKeywords:"It is default now, see option `strict`.",uniqueItems:`"uniqueItems" keyword is always validated.`,unknownFormats:"Disable strict mode or pass `true` to `ajv.addFormat` (or `formats` option).",cache:`Map is used as cache, schema object as key.`,serialize:`Map is used as cache, schema object as key.`,ajvErrors:`It is default now.`},O={ignoreKeywordsWithRef:``,jsPropertySyntax:``,unicode:`"minLength"/"maxLength" account for unicode characters by default.`};function k(e){let t=e.strict,n=e.code?.optimize,r=n===!0||n===void 0?1:n||0,i=e.code?.regExp??C,a=e.uriResolver??g.default;return{strictSchema:e.strictSchema??t??!0,strictNumbers:e.strictNumbers??t??!0,strictTypes:e.strictTypes??t??`log`,strictTuples:e.strictTuples??t??`log`,strictRequired:e.strictRequired??t??!1,code:e.code?{...e.code,optimize:r,regExp:i}:{optimize:r,regExp:i},loopRequired:e.loopRequired??200,loopEnum:e.loopEnum??200,meta:e.meta??!0,messages:e.messages??!0,inlineRefs:e.inlineRefs??!0,schemaId:e.schemaId??`$id`,addUsedSchema:e.addUsedSchema??!0,validateSchema:e.validateSchema??!0,validateFormats:e.validateFormats??!0,unicodeRegExp:e.unicodeRegExp??!0,int32range:e.int32range??!0,uriResolver:a}}var A=class{constructor(e={}){this.schemas={},this.refs={},this.formats=Object.create(null),this._compilations=new Set,this._loading={},this._cache=new Map,e=this.opts={...e,...k(e)};let{es5:t,lines:n}=this.opts.code;this.scope=new d.ValueScope({scope:{},prefixes:T,es5:t,lines:n}),this.logger=R(e.logger);let r=e.validateFormats;e.validateFormats=!1,this.RULES=(0,s.getRules)(),j.call(this,D,e,`NOT SUPPORTED`),j.call(this,O,e,`DEPRECATED`,`warn`),this._metaOpts=I.call(this),e.formats&&P.call(this),this._addVocabularies(),this._addDefaultMetaSchema(),e.keywords&&F.call(this,e.keywords),typeof e.meta==`object`&&this.addMetaSchema(e.meta),N.call(this),e.validateFormats=r}_addVocabularies(){this.addKeyword(`$async`)}_addDefaultMetaSchema(){let{$data:e,meta:t,schemaId:n}=this.opts,r=h;n===`id`&&(r={...h},r.id=r.$id,delete r.$id),t&&e&&this.addMetaSchema(r,r[n],!1)}defaultMeta(){let{meta:e,schemaId:t}=this.opts;return this.opts.defaultMeta=typeof e==`object`?e[t]||e:void 0}validate(e,t){let n;if(typeof e==`string`){if(n=this.getSchema(e),!n)throw Error(`no schema with key or ref "${e}"`)}else n=this.compile(e);let r=n(t);return`$async`in n||(this.errors=n.errors),r}compile(e,t){let n=this._addSchema(e,t);return n.validate||this._compileSchemaEnv(n)}compileAsync(e,t){if(typeof this.opts.loadSchema!=`function`)throw Error(`options.loadSchema should be a function`);let{loadSchema:n}=this.opts;return r.call(this,e,t);async function r(e,t){await i.call(this,e.$schema);let n=this._addSchema(e,t);return n.validate||a.call(this,n)}async function i(e){e&&!this.getSchema(e)&&await r.call(this,{$ref:e},!0)}async function a(e){try{return this._compileSchemaEnv(e)}catch(t){if(!(t instanceof o.default))throw t;return s.call(this,t),await c.call(this,t.missingSchema),a.call(this,e)}}function s({missingSchema:e,missingRef:t}){if(this.refs[e])throw Error(`AnySchema ${e} is loaded but ${t} cannot be resolved`)}async function c(e){let n=await l.call(this,e);this.refs[e]||await i.call(this,n.$schema),this.refs[e]||this.addSchema(n,e,t)}async function l(e){let t=this._loading[e];if(t)return t;try{return await(this._loading[e]=n(e))}finally{delete this._loading[e]}}}addSchema(e,t,n,r=this.opts.validateSchema){if(Array.isArray(e)){for(let t of e)this.addSchema(t,void 0,n,r);return this}let i;if(typeof e==`object`){let{schemaId:t}=this.opts;if(i=e[t],i!==void 0&&typeof i!=`string`)throw Error(`schema ${t} must be string`)}return t=(0,f.normalizeId)(t||i),this._checkUnique(t),this.schemas[t]=this._addSchema(e,n,t,r,!0),this}addMetaSchema(e,t,n=this.opts.validateSchema){return this.addSchema(e,t,!0,n),this}validateSchema(e,t){if(typeof e==`boolean`)return!0;let n;if(n=e.$schema,n!==void 0&&typeof n!=`string`)throw Error(`$schema must be a string`);if(n=n||this.opts.defaultMeta||this.defaultMeta(),!n)return this.logger.warn(`meta-schema not available`),this.errors=null,!0;let r=this.validate(n,e);if(!r&&t){let e=`schema is invalid: `+this.errorsText();if(this.opts.validateSchema===`log`)this.logger.error(e);else throw Error(e)}return r}getSchema(e){let t;for(;typeof(t=M.call(this,e))==`string`;)e=t;if(t===void 0){let{schemaId:n}=this.opts,r=new l.SchemaEnv({schema:{},schemaId:n});if(t=l.resolveSchema.call(this,r,e),!t)return;this.refs[e]=t}return t.validate||this._compileSchemaEnv(t)}removeSchema(e){if(e instanceof RegExp)return this._removeAllSchemas(this.schemas,e),this._removeAllSchemas(this.refs,e),this;switch(typeof e){case`undefined`:return this._removeAllSchemas(this.schemas),this._removeAllSchemas(this.refs),this._cache.clear(),this;case`string`:{let t=M.call(this,e);return typeof t==`object`&&this._cache.delete(t.schema),delete this.schemas[e],delete this.refs[e],this}case`object`:{let t=e;this._cache.delete(t);let n=e[this.opts.schemaId];return n&&(n=(0,f.normalizeId)(n),delete this.schemas[n],delete this.refs[n]),this}default:throw Error(`ajv.removeSchema: invalid parameter`)}}addVocabulary(e){for(let t of e)this.addKeyword(t);return this}addKeyword(e,t){let n;if(typeof e==`string`)n=e,typeof t==`object`&&(this.logger.warn(`these parameters are deprecated, see docs for addKeyword`),t.keyword=n);else if(typeof e==`object`&&t===void 0){if(t=e,n=t.keyword,Array.isArray(n)&&!n.length)throw Error(`addKeywords: keyword must be string or non-empty array`)}else throw Error(`invalid addKeywords parameters`);if(B.call(this,n,t),!t)return(0,m.eachItem)(n,e=>V.call(this,e)),this;U.call(this,t);let r={...t,type:(0,p.getJSONTypes)(t.type),schemaType:(0,p.getJSONTypes)(t.schemaType)};return(0,m.eachItem)(n,r.type.length===0?e=>V.call(this,e,r):e=>r.type.forEach(t=>V.call(this,e,r,t))),this}getKeyword(e){let t=this.RULES.all[e];return typeof t==`object`?t.definition:!!t}removeKeyword(e){let{RULES:t}=this;delete t.keywords[e],delete t.all[e];for(let n of t.rules){let t=n.rules.findIndex(t=>t.keyword===e);t>=0&&n.rules.splice(t,1)}return this}addFormat(e,t){return typeof t==`string`&&(t=new RegExp(t)),this.formats[e]=t,this}errorsText(e=this.errors,{separator:t=`, `,dataVar:n=`data`}={}){return!e||e.length===0?`No errors`:e.map(e=>`${n}${e.instancePath} ${e.message}`).reduce((e,n)=>e+t+n)}$dataMetaSchema(e,t){let n=this.RULES.all;e=JSON.parse(JSON.stringify(e));for(let r of t){let t=r.split(`/`).slice(1),i=e;for(let e of t)i=i[e];for(let e in n){let t=n[e];if(typeof t!=`object`)continue;let{$data:r}=t.definition,a=i[e];r&&a&&(i[e]=G(a))}}return e}_removeAllSchemas(e,t){for(let n in e){let r=e[n];(!t||t.test(n))&&(typeof r==`string`?delete e[n]:r&&!r.meta&&(this._cache.delete(r.schema),delete e[n]))}}_addSchema(e,t,n,r=this.opts.validateSchema,i=this.opts.addUsedSchema){let a,{schemaId:o}=this.opts;if(typeof e==`object`)a=e[o];else if(this.opts.jtd)throw Error(`schema must be object`);else if(typeof e!=`boolean`)throw Error(`schema must be object or boolean`);let s=this._cache.get(e);if(s!==void 0)return s;n=(0,f.normalizeId)(a||n);let c=f.getSchemaRefs.call(this,e,n);return s=new l.SchemaEnv({schema:e,schemaId:o,meta:t,baseId:n,localRefs:c}),this._cache.set(s.schema,s),i&&!n.startsWith(`#`)&&(n&&this._checkUnique(n),this.refs[n]=s),r&&this.validateSchema(e,!0),s}_checkUnique(e){if(this.schemas[e]||this.refs[e])throw Error(`schema with key or id "${e}" already exists`)}_compileSchemaEnv(e){if(e.meta?this._compileMetaSchema(e):l.compileSchema.call(this,e),!e.validate)throw Error(`ajv implementation error`);return e.validate}_compileMetaSchema(e){let t=this.opts;this.opts=this._metaOpts;try{l.compileSchema.call(this,e)}finally{this.opts=t}}};A.ValidationError=a.default,A.MissingRefError=o.default,e.default=A;function j(e,t,n,r=`error`){for(let i in e){let a=i;a in t&&this.logger[r](`${n}: option ${i}. ${e[a]}`)}}function M(e){return e=(0,f.normalizeId)(e),this.schemas[e]||this.refs[e]}function N(){let e=this.opts.schemas;if(e)if(Array.isArray(e))this.addSchema(e);else for(let t in e)this.addSchema(e[t],t)}function P(){for(let e in this.opts.formats){let t=this.opts.formats[e];t&&this.addFormat(e,t)}}function F(e){if(Array.isArray(e)){this.addVocabulary(e);return}this.logger.warn(`keywords option as map is deprecated, pass array`);for(let t in e){let n=e[t];n.keyword||=t,this.addKeyword(n)}}function I(){let e={...this.opts};for(let t of w)delete e[t];return e}let L={log(){},warn(){},error(){}};function R(e){if(e===!1)return L;if(e===void 0)return console;if(e.log&&e.warn&&e.error)return e;throw Error(`logger must implement log, warn and error methods`)}let z=/^[a-z_$][a-z0-9_$:-]*$/i;function B(e,t){let{RULES:n}=this;if((0,m.eachItem)(e,e=>{if(n.keywords[e])throw Error(`Keyword ${e} is already defined`);if(!z.test(e))throw Error(`Keyword ${e} has invalid name`)}),t&&t.$data&&!(`code`in t||`validate`in t))throw Error(`$data keyword must have "code" or "validate" function`)}function V(e,t,n){var r;let i=t?.post;if(n&&i)throw Error(`keyword with "post" flag cannot have "type"`);let{RULES:a}=this,o=i?a.post:a.rules.find(({type:e})=>e===n);if(o||(o={type:n,rules:[]},a.rules.push(o)),a.keywords[e]=!0,!t)return;let s={keyword:e,definition:{...t,type:(0,p.getJSONTypes)(t.type),schemaType:(0,p.getJSONTypes)(t.schemaType)}};t.before?H.call(this,o,s,t.before):o.rules.push(s),a.all[e]=s,(r=t.implements)==null||r.forEach(e=>this.addKeyword(e))}function H(e,t,n){let r=e.rules.findIndex(e=>e.keyword===n);r>=0?e.rules.splice(r,0,t):(e.rules.push(t),this.logger.warn(`rule ${n} is not defined`))}function U(e){let{metaSchema:t}=e;t!==void 0&&(e.$data&&this.opts.$data&&(t=G(t)),e.validateSchema=this.compile(t,!0))}let W={$ref:`https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#`};function G(e){return{anyOf:[e,W]}}})),O=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`id`,code(){throw Error(`NOT SUPPORTED: keyword "id", use "$id" for schema ID`)}}})),k=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.callRef=e.getValidate=void 0;let t=b(),n=f(),o=r(),s=a(),c=x(),l=i(),u={keyword:`$ref`,schemaType:`string`,code(e){let{gen:n,schema:r,it:i}=e,{baseId:a,schemaEnv:s,validateName:l,opts:u,self:f}=i,{root:m}=s;if((r===`#`||r===`#/`)&&a===m.baseId)return g();let h=c.resolveRef.call(f,m,a,r);if(h===void 0)throw new t.default(i.opts.uriResolver,a,r);if(h instanceof c.SchemaEnv)return _(h);return v(h);function g(){if(s===m)return p(e,l,s,s.$async);let t=n.scopeValue(`root`,{ref:m});return p(e,(0,o._)`${t}.validate`,m,m.$async)}function _(t){p(e,d(e,t),t,t.$async)}function v(t){let i=n.scopeValue(`schema`,u.code.source===!0?{ref:t,code:(0,o.stringify)(t)}:{ref:t}),a=n.name(`valid`),s=e.subschema({schema:t,dataTypes:[],schemaPath:o.nil,topSchemaRef:i,errSchemaPath:r},a);e.mergeEvaluated(s),e.ok(a)}}};function d(e,t){let{gen:n}=e;return t.validate?n.scopeValue(`validate`,{ref:t.validate}):(0,o._)`${n.scopeValue(`wrapper`,{ref:t})}.validate`}e.getValidate=d;function p(e,t,r,i){let{gen:a,it:c}=e,{allErrors:u,schemaEnv:d,opts:f}=c,p=f.passContext?s.default.this:o.nil;i?m():h();function m(){if(!d.$async)throw Error(`async schema referenced by sync schema`);let r=a.let(`valid`);a.try(()=>{a.code((0,o._)`await ${(0,n.callValidateCode)(e,t,p)}`),_(t),u||a.assign(r,!0)},e=>{a.if((0,o._)`!(${e} instanceof ${c.ValidationError})`,()=>a.throw(e)),g(e),u||a.assign(r,!1)}),e.ok(r)}function h(){e.result((0,n.callValidateCode)(e,t,p),()=>_(t),()=>g(t))}function g(e){let t=(0,o._)`${e}.errors`;a.assign(s.default.vErrors,(0,o._)`${s.default.vErrors} === null ? ${t} : ${s.default.vErrors}.concat(${t})`),a.assign(s.default.errors,(0,o._)`${s.default.vErrors}.length`)}function _(e){if(!c.opts.unevaluated)return;let t=r?.validate?.evaluated;if(c.props!==!0)if(t&&!t.dynamicProps)t.props!==void 0&&(c.props=l.mergeEvaluated.props(a,t.props,c.props));else{let t=a.var(`props`,(0,o._)`${e}.evaluated.props`);c.props=l.mergeEvaluated.props(a,t,c.props,o.Name)}if(c.items!==!0)if(t&&!t.dynamicItems)t.items!==void 0&&(c.items=l.mergeEvaluated.items(a,t.items,c.items));else{let t=a.var(`items`,(0,o._)`${e}.evaluated.items`);c.items=l.mergeEvaluated.items(a,t,c.items,o.Name)}}}e.callRef=p,e.default=u})),A=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=O(),n=k();e.default=[`$schema`,`$id`,`$defs`,`$vocabulary`,{keyword:`$comment`},`definitions`,t.default,n.default]})),j=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=t.operators,i={maximum:{okStr:`<=`,ok:n.LTE,fail:n.GT},minimum:{okStr:`>=`,ok:n.GTE,fail:n.LT},exclusiveMaximum:{okStr:`<`,ok:n.LT,fail:n.GTE},exclusiveMinimum:{okStr:`>`,ok:n.GT,fail:n.LTE}};e.default={keyword:Object.keys(i),type:`number`,schemaType:`number`,$data:!0,error:{message:({keyword:e,schemaCode:n})=>(0,t.str)`must be ${i[e].okStr} ${n}`,params:({keyword:e,schemaCode:n})=>(0,t._)`{comparison: ${i[e].okStr}, limit: ${n}}`},code(e){let{keyword:n,data:r,schemaCode:a}=e;e.fail$data((0,t._)`${r} ${i[n].fail} ${a} || isNaN(${r})`)}}})),M=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r();e.default={keyword:`multipleOf`,type:`number`,schemaType:`number`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must be multiple of ${e}`,params:({schemaCode:e})=>(0,t._)`{multipleOf: ${e}}`},code(e){let{gen:n,data:r,schemaCode:i,it:a}=e,o=a.opts.multipleOfPrecision,s=n.let(`res`),c=o?(0,t._)`Math.abs(Math.round(${s}) - ${s}) > 1e-${o}`:(0,t._)`${s} !== parseInt(${s})`;e.fail$data((0,t._)`(${i} === 0 || (${s} = ${r}/${i}, ${c}))`)}}})),N=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});function t(e){let t=e.length,n=0,r=0,i;for(;r<t;)n++,i=e.charCodeAt(r++),i>=55296&&i<=56319&&r<t&&(i=e.charCodeAt(r),(i&64512)==56320&&r++);return n}e.default=t,t.code=`require("ajv/dist/runtime/ucs2length").default`})),P=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i(),a=N();e.default={keyword:[`maxLength`,`minLength`],type:`string`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxLength`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} characters`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:r,data:i,schemaCode:o,it:s}=e,c=r===`maxLength`?t.operators.GT:t.operators.LT,l=s.opts.unicode===!1?(0,t._)`${i}.length`:(0,t._)`${(0,n.useFunc)(e.gen,a.default)}(${i})`;e.fail$data((0,t._)`${l} ${c} ${o}`)}}})),F=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=f(),n=i(),a=r();e.default={keyword:`pattern`,type:`string`,schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,a.str)`must match pattern "${e}"`,params:({schemaCode:e})=>(0,a._)`{pattern: ${e}}`},code(e){let{gen:r,data:i,$data:o,schema:s,schemaCode:c,it:l}=e,u=l.opts.unicodeRegExp?`u`:``;if(o){let{regExp:t}=l.opts.code,o=t.code===`new RegExp`?(0,a._)`new RegExp`:(0,n.useFunc)(r,t),s=r.let(`valid`);r.try(()=>r.assign(s,(0,a._)`${o}(${c}, ${u}).test(${i})`),()=>r.assign(s,!1)),e.fail$data((0,a._)`!${s}`)}else{let n=(0,t.usePattern)(e,s);e.fail$data((0,a._)`!${n}.test(${i})`)}}}})),I=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r();e.default={keyword:[`maxProperties`,`minProperties`],type:`object`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxProperties`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} properties`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxProperties`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`Object.keys(${r}).length ${a} ${i}`)}}})),L=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=f(),n=r(),a=i();e.default={keyword:`required`,type:`object`,schemaType:`array`,$data:!0,error:{message:({params:{missingProperty:e}})=>(0,n.str)`must have required property '${e}'`,params:({params:{missingProperty:e}})=>(0,n._)`{missingProperty: ${e}}`},code(e){let{gen:r,schema:i,schemaCode:o,data:s,$data:c,it:l}=e,{opts:u}=l;if(!c&&i.length===0)return;let d=i.length>=u.loopRequired;if(l.allErrors?f():p(),u.strictRequired){let t=e.parentSchema.properties,{definedProperties:n}=e.it;for(let e of i)if(t?.[e]===void 0&&!n.has(e)){let t=`required property "${e}" is not defined at "${l.schemaEnv.baseId+l.errSchemaPath}" (strictRequired)`;(0,a.checkStrictMode)(l,t,l.opts.strictRequired)}}function f(){if(d||c)e.block$data(n.nil,m);else for(let n of i)(0,t.checkReportMissingProp)(e,n)}function p(){let n=r.let(`missing`);if(d||c){let t=r.let(`valid`,!0);e.block$data(t,()=>h(n,t)),e.ok(t)}else r.if((0,t.checkMissingProp)(e,i,n)),(0,t.reportMissingProp)(e,n),r.else()}function m(){r.forOf(`prop`,o,n=>{e.setParams({missingProperty:n}),r.if((0,t.noPropertyInData)(r,s,n,u.ownProperties),()=>e.error())})}function h(i,a){e.setParams({missingProperty:i}),r.forOf(i,o,()=>{r.assign(a,(0,t.propertyInData)(r,s,i,u.ownProperties)),r.if((0,n.not)(a),()=>{e.error(),r.break()})},n.nil)}}}})),R=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r();e.default={keyword:[`maxItems`,`minItems`],type:`array`,schemaType:`number`,$data:!0,error:{message({keyword:e,schemaCode:n}){let r=e===`maxItems`?`more`:`fewer`;return(0,t.str)`must NOT have ${r} than ${n} items`},params:({schemaCode:e})=>(0,t._)`{limit: ${e}}`},code(e){let{keyword:n,data:r,schemaCode:i}=e,a=n===`maxItems`?t.operators.GT:t.operators.LT;e.fail$data((0,t._)`${r}.length ${a} ${i}`)}}})),z=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=h();t.code=`require("ajv/dist/runtime/equal").default`,e.default=t})),B=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=u(),n=r(),a=i(),o=z();e.default={keyword:`uniqueItems`,type:`array`,schemaType:`boolean`,$data:!0,error:{message:({params:{i:e,j:t}})=>(0,n.str)`must NOT have duplicate items (items ## ${t} and ${e} are identical)`,params:({params:{i:e,j:t}})=>(0,n._)`{i: ${e}, j: ${t}}`},code(e){let{gen:r,data:i,$data:s,schema:c,parentSchema:l,schemaCode:u,it:d}=e;if(!s&&!c)return;let f=r.let(`valid`),p=l.items?(0,t.getSchemaTypes)(l.items):[];e.block$data(f,m,(0,n._)`${u} === false`),e.ok(f);function m(){let t=r.let(`i`,(0,n._)`${i}.length`),a=r.let(`j`);e.setParams({i:t,j:a}),r.assign(f,!0),r.if((0,n._)`${t} > 1`,()=>(h()?g:_)(t,a))}function h(){return p.length>0&&!p.some(e=>e===`object`||e===`array`)}function g(a,o){let s=r.name(`item`),c=(0,t.checkDataTypes)(p,s,d.opts.strictNumbers,t.DataType.Wrong),l=r.const(`indices`,(0,n._)`{}`);r.for((0,n._)`;${a}--;`,()=>{r.let(s,(0,n._)`${i}[${a}]`),r.if(c,(0,n._)`continue`),p.length>1&&r.if((0,n._)`typeof ${s} == "string"`,(0,n._)`${s} += "_"`),r.if((0,n._)`typeof ${l}[${s}] == "number"`,()=>{r.assign(o,(0,n._)`${l}[${s}]`),e.error(),r.assign(f,!1).break()}).code((0,n._)`${l}[${s}] = ${a}`)})}function _(t,s){let c=(0,a.useFunc)(r,o.default),l=r.name(`outer`);r.label(l).for((0,n._)`;${t}--;`,()=>r.for((0,n._)`${s} = ${t}; ${s}--;`,()=>r.if((0,n._)`${c}(${i}[${t}], ${i}[${s}])`,()=>{e.error(),r.assign(f,!1).break(l)})))}}}})),V=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i(),a=z();e.default={keyword:`const`,$data:!0,error:{message:`must be equal to constant`,params:({schemaCode:e})=>(0,t._)`{allowedValue: ${e}}`},code(e){let{gen:r,data:i,$data:o,schemaCode:s,schema:c}=e;o||c&&typeof c==`object`?e.fail$data((0,t._)`!${(0,n.useFunc)(r,a.default)}(${i}, ${s})`):e.fail((0,t._)`${c} !== ${i}`)}}})),H=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i(),a=z();e.default={keyword:`enum`,schemaType:`array`,$data:!0,error:{message:`must be equal to one of the allowed values`,params:({schemaCode:e})=>(0,t._)`{allowedValues: ${e}}`},code(e){let{gen:r,data:i,$data:o,schema:s,schemaCode:c,it:l}=e;if(!o&&s.length===0)throw Error(`enum must have non-empty array`);let u=s.length>=l.opts.loopEnum,d,f=()=>d??=(0,n.useFunc)(r,a.default),p;if(u||o)p=r.let(`valid`),e.block$data(p,m);else{if(!Array.isArray(s))throw Error(`ajv implementation error`);let e=r.const(`vSchema`,c);p=(0,t.or)(...s.map((t,n)=>h(e,n)))}e.pass(p);function m(){r.assign(p,!1),r.forOf(`v`,c,e=>r.if((0,t._)`${f()}(${i}, ${e})`,()=>r.assign(p,!0).break()))}function h(e,n){let r=s[n];return typeof r==`object`&&r?(0,t._)`${f()}(${i}, ${e}[${n}])`:(0,t._)`${i} === ${r}`}}}})),U=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=j(),n=M(),r=P(),i=F(),a=I(),o=L(),s=R(),c=B(),l=V(),u=H();e.default=[t.default,n.default,r.default,i.default,a.default,o.default,s.default,c.default,{keyword:`type`,schemaType:[`string`,`array`]},{keyword:`nullable`,schemaType:`boolean`},l.default,u.default]})),W=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateAdditionalItems=void 0;let t=r(),n=i(),a={keyword:`additionalItems`,type:`array`,schemaType:[`boolean`,`object`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{parentSchema:t,it:r}=e,{items:i}=t;if(!Array.isArray(i)){(0,n.checkStrictMode)(r,`"additionalItems" is ignored when "items" is not an array of schemas`);return}o(e,i)}};function o(e,r){let{gen:i,schema:a,data:o,keyword:s,it:c}=e;c.items=!0;let l=i.const(`len`,(0,t._)`${o}.length`);if(a===!1)e.setParams({len:r.length}),e.pass((0,t._)`${l} <= ${r.length}`);else if(typeof a==`object`&&!(0,n.alwaysValidSchema)(c,a)){let n=i.var(`valid`,(0,t._)`${l} <= ${r.length}`);i.if((0,t.not)(n),()=>u(n)),e.ok(n)}function u(a){i.forRange(`i`,r.length,l,r=>{e.subschema({keyword:s,dataProp:r,dataPropType:n.Type.Num},a),c.allErrors||i.if((0,t.not)(a),()=>i.break())})}}e.validateAdditionalItems=o,e.default=a})),G=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateTuple=void 0;let t=r(),n=i(),a=f(),o={keyword:`items`,type:`array`,schemaType:[`object`,`array`,`boolean`],before:`uniqueItems`,code(e){let{schema:t,it:r}=e;if(Array.isArray(t))return s(e,`additionalItems`,t);r.items=!0,!(0,n.alwaysValidSchema)(r,t)&&e.ok((0,a.validateArray)(e))}};function s(e,r,i=e.schema){let{gen:a,parentSchema:o,data:s,keyword:c,it:l}=e;f(o),l.opts.unevaluated&&i.length&&l.items!==!0&&(l.items=n.mergeEvaluated.items(a,i.length,l.items));let u=a.name(`valid`),d=a.const(`len`,(0,t._)`${s}.length`);i.forEach((r,i)=>{(0,n.alwaysValidSchema)(l,r)||(a.if((0,t._)`${d} > ${i}`,()=>e.subschema({keyword:c,schemaProp:i,dataProp:i},u)),e.ok(u))});function f(e){let{opts:t,errSchemaPath:a}=l,o=i.length,s=o===e.minItems&&(o===e.maxItems||e[r]===!1);if(t.strictTuples&&!s){let e=`"${c}" is ${o}-tuple, but minItems or maxItems/${r} are not specified or different at path "${a}"`;(0,n.checkStrictMode)(l,e,t.strictTuples)}}}e.validateTuple=s,e.default=o})),K=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=G();e.default={keyword:`prefixItems`,type:`array`,schemaType:[`array`],before:`uniqueItems`,code:e=>(0,t.validateTuple)(e,`items`)}})),q=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i(),a=f(),o=W();e.default={keyword:`items`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,error:{message:({params:{len:e}})=>(0,t.str)`must NOT have more than ${e} items`,params:({params:{len:e}})=>(0,t._)`{limit: ${e}}`},code(e){let{schema:t,parentSchema:r,it:i}=e,{prefixItems:s}=r;i.items=!0,!(0,n.alwaysValidSchema)(i,t)&&(s?(0,o.validateAdditionalItems)(e,s):e.ok((0,a.validateArray)(e)))}}})),ee=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i();e.default={keyword:`contains`,type:`array`,schemaType:[`object`,`boolean`],before:`uniqueItems`,trackErrors:!0,error:{message:({params:{min:e,max:n}})=>n===void 0?(0,t.str)`must contain at least ${e} valid item(s)`:(0,t.str)`must contain at least ${e} and no more than ${n} valid item(s)`,params:({params:{min:e,max:n}})=>n===void 0?(0,t._)`{minContains: ${e}}`:(0,t._)`{minContains: ${e}, maxContains: ${n}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:o,it:s}=e,c,l,{minContains:u,maxContains:d}=a;s.opts.next?(c=u===void 0?1:u,l=d):c=1;let f=r.const(`len`,(0,t._)`${o}.length`);if(e.setParams({min:c,max:l}),l===void 0&&c===0){(0,n.checkStrictMode)(s,`"minContains" == 0 without "maxContains": "contains" keyword ignored`);return}if(l!==void 0&&c>l){(0,n.checkStrictMode)(s,`"minContains" > "maxContains" is always invalid`),e.fail();return}if((0,n.alwaysValidSchema)(s,i)){let n=(0,t._)`${f} >= ${c}`;l!==void 0&&(n=(0,t._)`${n} && ${f} <= ${l}`),e.pass(n);return}s.items=!0;let p=r.name(`valid`);l===void 0&&c===1?h(p,()=>r.if(p,()=>r.break())):c===0?(r.let(p,!0),l!==void 0&&r.if((0,t._)`${o}.length > 0`,m)):(r.let(p,!1),m()),e.result(p,()=>e.reset());function m(){let e=r.name(`_valid`),t=r.let(`count`,0);h(e,()=>r.if(e,()=>g(t)))}function h(t,i){r.forRange(`i`,0,f,r=>{e.subschema({keyword:`contains`,dataProp:r,dataPropType:n.Type.Num,compositeRule:!0},t),i()})}function g(e){r.code((0,t._)`${e}++`),l===void 0?r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0).break()):(r.if((0,t._)`${e} > ${l}`,()=>r.assign(p,!1).break()),c===1?r.assign(p,!0):r.if((0,t._)`${e} >= ${c}`,()=>r.assign(p,!0)))}}}})),J=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.validateSchemaDeps=e.validatePropertyDeps=e.error=void 0;let t=r(),n=i(),a=f();e.error={message:({params:{property:e,depsCount:n,deps:r}})=>{let i=n===1?`property`:`properties`;return(0,t.str)`must have ${i} ${r} when property ${e} is present`},params:({params:{property:e,depsCount:n,deps:r,missingProperty:i}})=>(0,t._)`{property: ${e},
6
+ missingProperty: ${i},
7
+ depsCount: ${n},
8
+ deps: ${r}}`};let o={keyword:`dependencies`,type:`object`,schemaType:`object`,error:e.error,code(e){let[t,n]=s(e);c(e,t),l(e,n)}};function s({schema:e}){let t={},n={};for(let r in e){if(r===`__proto__`)continue;let i=Array.isArray(e[r])?t:n;i[r]=e[r]}return[t,n]}function c(e,n=e.schema){let{gen:r,data:i,it:o}=e;if(Object.keys(n).length===0)return;let s=r.let(`missing`);for(let c in n){let l=n[c];if(l.length===0)continue;let u=(0,a.propertyInData)(r,i,c,o.opts.ownProperties);e.setParams({property:c,depsCount:l.length,deps:l.join(`, `)}),o.allErrors?r.if(u,()=>{for(let t of l)(0,a.checkReportMissingProp)(e,t)}):(r.if((0,t._)`${u} && (${(0,a.checkMissingProp)(e,l,s)})`),(0,a.reportMissingProp)(e,s),r.else())}}e.validatePropertyDeps=c;function l(e,t=e.schema){let{gen:r,data:i,keyword:o,it:s}=e,c=r.name(`valid`);for(let l in t)(0,n.alwaysValidSchema)(s,t[l])||(r.if((0,a.propertyInData)(r,i,l,s.opts.ownProperties),()=>{let t=e.subschema({keyword:o,schemaProp:l},c);e.mergeValidEvaluated(t,c)},()=>r.var(c,!0)),e.ok(c))}e.validateSchemaDeps=l,e.default=o})),te=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i();e.default={keyword:`propertyNames`,type:`object`,schemaType:[`object`,`boolean`],error:{message:`property name must be valid`,params:({params:e})=>(0,t._)`{propertyName: ${e.propertyName}}`},code(e){let{gen:r,schema:i,data:a,it:o}=e;if((0,n.alwaysValidSchema)(o,i))return;let s=r.name(`valid`);r.forIn(`key`,a,n=>{e.setParams({propertyName:n}),e.subschema({keyword:`propertyNames`,data:n,dataTypes:[`string`],propertyName:n,compositeRule:!0},s),r.if((0,t.not)(s),()=>{e.error(!0),o.allErrors||r.break()})}),e.ok(s)}}})),Y=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=f(),n=r(),o=a(),s=i();e.default={keyword:`additionalProperties`,type:[`object`],schemaType:[`boolean`,`object`],allowUndefined:!0,trackErrors:!0,error:{message:`must NOT have additional properties`,params:({params:e})=>(0,n._)`{additionalProperty: ${e.additionalProperty}}`},code(e){let{gen:r,schema:i,parentSchema:a,data:c,errsCount:l,it:u}=e;if(!l)throw Error(`ajv implementation error`);let{allErrors:d,opts:f}=u;if(u.props=!0,f.removeAdditional!==`all`&&(0,s.alwaysValidSchema)(u,i))return;let p=(0,t.allSchemaProperties)(a.properties),m=(0,t.allSchemaProperties)(a.patternProperties);h(),e.ok((0,n._)`${l} === ${o.default.errors}`);function h(){r.forIn(`key`,c,e=>{!p.length&&!m.length?v(e):r.if(g(e),()=>v(e))})}function g(i){let o;if(p.length>8){let e=(0,s.schemaRefOrVal)(u,a.properties,`properties`);o=(0,t.isOwnProperty)(r,e,i)}else o=p.length?(0,n.or)(...p.map(e=>(0,n._)`${i} === ${e}`)):n.nil;return m.length&&(o=(0,n.or)(o,...m.map(r=>(0,n._)`${(0,t.usePattern)(e,r)}.test(${i})`))),(0,n.not)(o)}function _(e){r.code((0,n._)`delete ${c}[${e}]`)}function v(t){if(f.removeAdditional===`all`||f.removeAdditional&&i===!1){_(t);return}if(i===!1){e.setParams({additionalProperty:t}),e.error(),d||r.break();return}if(typeof i==`object`&&!(0,s.alwaysValidSchema)(u,i)){let i=r.name(`valid`);f.removeAdditional===`failing`?(y(t,i,!1),r.if((0,n.not)(i),()=>{e.reset(),_(t)})):(y(t,i),d||r.if((0,n.not)(i),()=>r.break()))}}function y(t,n,r){let i={keyword:`additionalProperties`,dataProp:t,dataPropType:s.Type.Str};r===!1&&Object.assign(i,{compositeRule:!0,createErrors:!1,allErrors:!1}),e.subschema(i,n)}}}})),ne=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=v(),n=f(),r=i(),a=Y();e.default={keyword:`properties`,type:`object`,schemaType:`object`,code(e){let{gen:i,schema:o,parentSchema:s,data:c,it:l}=e;l.opts.removeAdditional===`all`&&s.additionalProperties===void 0&&a.default.code(new t.KeywordCxt(l,a.default,`additionalProperties`));let u=(0,n.allSchemaProperties)(o);for(let e of u)l.definedProperties.add(e);l.opts.unevaluated&&u.length&&l.props!==!0&&(l.props=r.mergeEvaluated.props(i,(0,r.toHash)(u),l.props));let d=u.filter(e=>!(0,r.alwaysValidSchema)(l,o[e]));if(d.length===0)return;let f=i.name(`valid`);for(let t of d)p(t)?m(t):(i.if((0,n.propertyInData)(i,c,t,l.opts.ownProperties)),m(t),l.allErrors||i.else().var(f,!0),i.endIf()),e.it.definedProperties.add(t),e.ok(f);function p(e){return l.opts.useDefaults&&!l.compositeRule&&o[e].default!==void 0}function m(t){e.subschema({keyword:`properties`,schemaProp:t,dataProp:t},f)}}}})),X=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=f(),n=r(),a=i(),o=i();e.default={keyword:`patternProperties`,type:`object`,schemaType:`object`,code(e){let{gen:r,schema:i,data:s,parentSchema:c,it:l}=e,{opts:u}=l,d=(0,t.allSchemaProperties)(i),f=d.filter(e=>(0,a.alwaysValidSchema)(l,i[e]));if(d.length===0||f.length===d.length&&(!l.opts.unevaluated||l.props===!0))return;let p=u.strictSchema&&!u.allowMatchingProperties&&c.properties,m=r.name(`valid`);l.props!==!0&&!(l.props instanceof n.Name)&&(l.props=(0,o.evaluatedPropsToName)(r,l.props));let{props:h}=l;g();function g(){for(let e of d)p&&_(e),l.allErrors?v(e):(r.var(m,!0),v(e),r.if(m))}function _(e){for(let t in p)new RegExp(e).test(t)&&(0,a.checkStrictMode)(l,`property ${t} matches pattern ${e} (use allowMatchingProperties)`)}function v(i){r.forIn(`key`,s,a=>{r.if((0,n._)`${(0,t.usePattern)(e,i)}.test(${a})`,()=>{let t=f.includes(i);t||e.subschema({keyword:`patternProperties`,schemaProp:i,dataProp:a,dataPropType:o.Type.Str},m),l.opts.unevaluated&&h!==!0?r.assign((0,n._)`${h}[${a}]`,!0):!t&&!l.allErrors&&r.if((0,n.not)(m),()=>r.break())})})}}}})),Z=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=i();e.default={keyword:`not`,schemaType:[`object`,`boolean`],trackErrors:!0,code(e){let{gen:n,schema:r,it:i}=e;if((0,t.alwaysValidSchema)(i,r)){e.fail();return}let a=n.name(`valid`);e.subschema({keyword:`not`,compositeRule:!0,createErrors:!1,allErrors:!1},a),e.failResult(a,()=>e.reset(),()=>e.error())},error:{message:`must NOT be valid`}}})),Q=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default={keyword:`anyOf`,schemaType:`array`,trackErrors:!0,code:f().validateUnion,error:{message:`must match a schema in anyOf`}}})),re=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i();e.default={keyword:`oneOf`,schemaType:`array`,trackErrors:!0,error:{message:`must match exactly one schema in oneOf`,params:({params:e})=>(0,t._)`{passingSchemas: ${e.passing}}`},code(e){let{gen:r,schema:i,parentSchema:a,it:o}=e;if(!Array.isArray(i))throw Error(`ajv implementation error`);if(o.opts.discriminator&&a.discriminator)return;let s=i,c=r.let(`valid`,!1),l=r.let(`passing`,null),u=r.name(`_valid`);e.setParams({passing:l}),r.block(d),e.result(c,()=>e.reset(),()=>e.error(!0));function d(){s.forEach((i,a)=>{let s;(0,n.alwaysValidSchema)(o,i)?r.var(u,!0):s=e.subschema({keyword:`oneOf`,schemaProp:a,compositeRule:!0},u),a>0&&r.if((0,t._)`${u} && ${c}`).assign(c,!1).assign(l,(0,t._)`[${l}, ${a}]`).else(),r.if(u,()=>{r.assign(c,!0),r.assign(l,a),s&&e.mergeEvaluated(s,t.Name)})})}}}})),ie=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=i();e.default={keyword:`allOf`,schemaType:`array`,code(e){let{gen:n,schema:r,it:i}=e;if(!Array.isArray(r))throw Error(`ajv implementation error`);let a=n.name(`valid`);r.forEach((n,r)=>{if((0,t.alwaysValidSchema)(i,n))return;let o=e.subschema({keyword:`allOf`,schemaProp:r},a);e.ok(a),e.mergeEvaluated(o)})}}})),$=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=i(),a={keyword:`if`,schemaType:[`object`,`boolean`],trackErrors:!0,error:{message:({params:e})=>(0,t.str)`must match "${e.ifClause}" schema`,params:({params:e})=>(0,t._)`{failingKeyword: ${e.ifClause}}`},code(e){let{gen:r,parentSchema:i,it:a}=e;i.then===void 0&&i.else===void 0&&(0,n.checkStrictMode)(a,`"if" without "then" and "else" is ignored`);let s=o(a,`then`),c=o(a,`else`);if(!s&&!c)return;let l=r.let(`valid`,!0),u=r.name(`_valid`);if(d(),e.reset(),s&&c){let t=r.let(`ifClause`);e.setParams({ifClause:t}),r.if(u,f(`then`,t),f(`else`,t))}else s?r.if(u,f(`then`)):r.if((0,t.not)(u),f(`else`));e.pass(l,()=>e.error(!0));function d(){let t=e.subschema({keyword:`if`,compositeRule:!0,createErrors:!1,allErrors:!1},u);e.mergeEvaluated(t)}function f(n,i){return()=>{let a=e.subschema({keyword:n},u);r.assign(l,u),e.mergeValidEvaluated(a,l),i?r.assign(i,(0,t._)`${n}`):e.setParams({ifClause:n})}}}};function o(e,t){let r=e.schema[t];return r!==void 0&&!(0,n.alwaysValidSchema)(e,r)}e.default=a})),ae=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=i();e.default={keyword:[`then`,`else`],schemaType:[`object`,`boolean`],code({keyword:e,parentSchema:n,it:r}){n.if===void 0&&(0,t.checkStrictMode)(r,`"${e}" without "if" is ignored`)}}})),oe=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=W(),n=K(),r=G(),i=q(),a=ee(),o=J(),s=te(),c=Y(),l=ne(),u=X(),d=Z(),f=Q(),p=re(),m=ie(),h=$(),g=ae();function _(e=!1){let _=[d.default,f.default,p.default,m.default,h.default,g.default,s.default,c.default,o.default,l.default,u.default];return e?_.push(n.default,i.default):_.push(t.default,r.default),_.push(a.default),_}e.default=_})),se=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r();e.default={keyword:`format`,type:[`number`,`string`],schemaType:`string`,$data:!0,error:{message:({schemaCode:e})=>(0,t.str)`must match format "${e}"`,params:({schemaCode:e})=>(0,t._)`{format: ${e}}`},code(e,n){let{gen:r,data:i,$data:a,schema:o,schemaCode:s,it:c}=e,{opts:l,errSchemaPath:u,schemaEnv:d,self:f}=c;if(!l.validateFormats)return;a?p():m();function p(){let a=r.scopeValue(`formats`,{ref:f.formats,code:l.code.formats}),o=r.const(`fDef`,(0,t._)`${a}[${s}]`),c=r.let(`fType`),u=r.let(`format`);r.if((0,t._)`typeof ${o} == "object" && !(${o} instanceof RegExp)`,()=>r.assign(c,(0,t._)`${o}.type || "string"`).assign(u,(0,t._)`${o}.validate`),()=>r.assign(c,(0,t._)`"string"`).assign(u,o)),e.fail$data((0,t.or)(p(),m()));function p(){return l.strictSchema===!1?t.nil:(0,t._)`${s} && !${u}`}function m(){let e=d.$async?(0,t._)`(${o}.async ? await ${u}(${i}) : ${u}(${i}))`:(0,t._)`${u}(${i})`,r=(0,t._)`(typeof ${u} == "function" ? ${e} : ${u}.test(${i}))`;return(0,t._)`${u} && ${u} !== true && ${c} === ${n} && !${r}`}}function m(){let a=f.formats[o];if(!a){m();return}if(a===!0)return;let[s,c,p]=h(a);s===n&&e.pass(g());function m(){if(l.strictSchema===!1){f.logger.warn(e());return}throw Error(e());function e(){return`unknown format "${o}" ignored in schema at path "${u}"`}}function h(e){let n=e instanceof RegExp?(0,t.regexpCode)(e):l.code.formats?(0,t._)`${l.code.formats}${(0,t.getProperty)(o)}`:void 0,i=r.scopeValue(`formats`,{key:o,ref:e,code:n});return typeof e==`object`&&!(e instanceof RegExp)?[e.type||`string`,e.validate,(0,t._)`${i}.validate`]:[`string`,e,i]}function g(){if(typeof a==`object`&&!(a instanceof RegExp)&&a.async){if(!d.$async)throw Error(`async format in sync schema`);return(0,t._)`await ${p}(${i})`}return typeof c==`function`?(0,t._)`${p}(${i})`:(0,t._)`${p}.test(${i})`}}}}})),ce=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.default=[se().default]})),le=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.contentVocabulary=e.metadataVocabulary=void 0,e.metadataVocabulary=[`title`,`description`,`default`,`deprecated`,`readOnly`,`writeOnly`,`examples`],e.contentVocabulary=[`contentMediaType`,`contentEncoding`,`contentSchema`]})),ue=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=A(),n=U(),r=oe(),i=ce(),a=le();e.default=[t.default,n.default,(0,r.default)(),i.default,a.metadataVocabulary,a.contentVocabulary]})),de=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.DiscrError=void 0;var t;(function(e){e.Tag=`tag`,e.Mapping=`mapping`})(t||(e.DiscrError=t={}))})),fe=e((e=>{Object.defineProperty(e,`__esModule`,{value:!0});let t=r(),n=de(),a=x(),o=b(),s=i();e.default={keyword:`discriminator`,type:`object`,schemaType:`object`,error:{message:({params:{discrError:e,tagName:t}})=>e===n.DiscrError.Tag?`tag "${t}" must be string`:`value of tag "${t}" must be in oneOf`,params:({params:{discrError:e,tag:n,tagName:r}})=>(0,t._)`{error: ${e}, tag: ${r}, tagValue: ${n}}`},code(e){let{gen:r,data:i,schema:c,parentSchema:l,it:u}=e,{oneOf:d}=l;if(!u.opts.discriminator)throw Error(`discriminator: requires discriminator option`);let f=c.propertyName;if(typeof f!=`string`)throw Error(`discriminator: requires propertyName`);if(c.mapping)throw Error(`discriminator: mapping is not supported`);if(!d)throw Error(`discriminator: requires oneOf keyword`);let p=r.let(`valid`,!1),m=r.const(`tag`,(0,t._)`${i}${(0,t.getProperty)(f)}`);r.if((0,t._)`typeof ${m} == "string"`,()=>h(),()=>e.error(!1,{discrError:n.DiscrError.Tag,tag:m,tagName:f})),e.ok(p);function h(){let i=_();r.if(!1);for(let e in i)r.elseIf((0,t._)`${m} === ${e}`),r.assign(p,g(i[e]));r.else(),e.error(!1,{discrError:n.DiscrError.Mapping,tag:m,tagName:f}),r.endIf()}function g(n){let i=r.name(`valid`),a=e.subschema({keyword:`oneOf`,schemaProp:n},i);return e.mergeEvaluated(a,t.Name),i}function _(){let e={},t=r(l),n=!0;for(let e=0;e<d.length;e++){let c=d[e];if(c?.$ref&&!(0,s.schemaHasRulesButRef)(c,u.self.RULES)){let e=c.$ref;if(c=a.resolveRef.call(u.self,u.schemaEnv.root,u.baseId,e),c instanceof a.SchemaEnv&&(c=c.schema),c===void 0)throw new o.default(u.opts.uriResolver,u.baseId,e)}let l=c?.properties?.[f];if(typeof l!=`object`)throw Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${f}"`);n&&=t||r(c),i(l,e)}if(!n)throw Error(`discriminator: "${f}" must be required`);return e;function r({required:e}){return Array.isArray(e)&&e.includes(f)}function i(e,t){if(e.const)c(e.const,t);else if(e.enum)for(let n of e.enum)c(n,t);else throw Error(`discriminator: "properties/${f}" must have "const" or "enum"`)}function c(t,n){if(typeof t!=`string`||t in e)throw Error(`discriminator: "${f}" values must be unique strings`);e[t]=n}}}}})),pe=e(((e,t)=>{t.exports={$schema:`http://json-schema.org/draft-07/schema#`,$id:`http://json-schema.org/draft-07/schema#`,title:`Core schema meta-schema`,definitions:{schemaArray:{type:`array`,minItems:1,items:{$ref:`#`}},nonNegativeInteger:{type:`integer`,minimum:0},nonNegativeIntegerDefault0:{allOf:[{$ref:`#/definitions/nonNegativeInteger`},{default:0}]},simpleTypes:{enum:[`array`,`boolean`,`integer`,`null`,`number`,`object`,`string`]},stringArray:{type:`array`,items:{type:`string`},uniqueItems:!0,default:[]}},type:[`object`,`boolean`],properties:{$id:{type:`string`,format:`uri-reference`},$schema:{type:`string`,format:`uri`},$ref:{type:`string`,format:`uri-reference`},$comment:{type:`string`},title:{type:`string`},description:{type:`string`},default:!0,readOnly:{type:`boolean`,default:!1},examples:{type:`array`,items:!0},multipleOf:{type:`number`,exclusiveMinimum:0},maximum:{type:`number`},exclusiveMaximum:{type:`number`},minimum:{type:`number`},exclusiveMinimum:{type:`number`},maxLength:{$ref:`#/definitions/nonNegativeInteger`},minLength:{$ref:`#/definitions/nonNegativeIntegerDefault0`},pattern:{type:`string`,format:`regex`},additionalItems:{$ref:`#`},items:{anyOf:[{$ref:`#`},{$ref:`#/definitions/schemaArray`}],default:!0},maxItems:{$ref:`#/definitions/nonNegativeInteger`},minItems:{$ref:`#/definitions/nonNegativeIntegerDefault0`},uniqueItems:{type:`boolean`,default:!1},contains:{$ref:`#`},maxProperties:{$ref:`#/definitions/nonNegativeInteger`},minProperties:{$ref:`#/definitions/nonNegativeIntegerDefault0`},required:{$ref:`#/definitions/stringArray`},additionalProperties:{$ref:`#`},definitions:{type:`object`,additionalProperties:{$ref:`#`},default:{}},properties:{type:`object`,additionalProperties:{$ref:`#`},default:{}},patternProperties:{type:`object`,additionalProperties:{$ref:`#`},propertyNames:{format:`regex`},default:{}},dependencies:{type:`object`,additionalProperties:{anyOf:[{$ref:`#`},{$ref:`#/definitions/stringArray`}]}},propertyNames:{$ref:`#`},const:!0,enum:{type:`array`,items:!0,minItems:1,uniqueItems:!0},type:{anyOf:[{$ref:`#/definitions/simpleTypes`},{type:`array`,items:{$ref:`#/definitions/simpleTypes`},minItems:1,uniqueItems:!0}]},format:{type:`string`},contentMediaType:{type:`string`},contentEncoding:{type:`string`},if:{$ref:`#`},then:{$ref:`#`},else:{$ref:`#`},allOf:{$ref:`#/definitions/schemaArray`},anyOf:{$ref:`#/definitions/schemaArray`},oneOf:{$ref:`#/definitions/schemaArray`},not:{$ref:`#`}},default:!0}})),me=e(((e,t)=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MissingRefError=e.ValidationError=e.CodeGen=e.Name=e.nil=e.stringify=e.str=e._=e.KeywordCxt=e.Ajv=void 0;let n=D(),i=ue(),a=fe(),o=pe(),s=[`/properties`],c=`http://json-schema.org/draft-07/schema`;var l=class extends n.default{_addVocabularies(){super._addVocabularies(),i.default.forEach(e=>this.addVocabulary(e)),this.opts.discriminator&&this.addKeyword(a.default)}_addDefaultMetaSchema(){if(super._addDefaultMetaSchema(),!this.opts.meta)return;let e=this.opts.$data?this.$dataMetaSchema(o,s):o;this.addMetaSchema(e,c,!1),this.refs[`http://json-schema.org/schema`]=c}defaultMeta(){return this.opts.defaultMeta=super.defaultMeta()||(this.getSchema(c)?c:void 0)}};e.Ajv=l,t.exports=e=l,t.exports.Ajv=l,Object.defineProperty(e,`__esModule`,{value:!0}),e.default=l;var u=v();Object.defineProperty(e,`KeywordCxt`,{enumerable:!0,get:function(){return u.KeywordCxt}});var d=r();Object.defineProperty(e,`_`,{enumerable:!0,get:function(){return d._}}),Object.defineProperty(e,`str`,{enumerable:!0,get:function(){return d.str}}),Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return d.stringify}}),Object.defineProperty(e,`nil`,{enumerable:!0,get:function(){return d.nil}}),Object.defineProperty(e,`Name`,{enumerable:!0,get:function(){return d.Name}}),Object.defineProperty(e,`CodeGen`,{enumerable:!0,get:function(){return d.CodeGen}});var f=y();Object.defineProperty(e,`ValidationError`,{enumerable:!0,get:function(){return f.default}});var p=b();Object.defineProperty(e,`MissingRefError`,{enumerable:!0,get:function(){return p.default}})}));export{i as _,ce as a,U as c,D as d,x as f,a as g,v as h,le as i,A as l,y as m,fe as n,oe as o,b as p,ue as r,J as s,me as t,k as u,r as v};
@@ -3598,25 +3598,6 @@ declare const CanonicalModelSelectionSchema: z.ZodObject<{
3598
3598
  env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
3599
3599
  mcpSessionContext: z.ZodOptional<z.ZodObject<{
3600
3600
  sessionId: z.ZodString;
3601
- directTools: z.ZodArray<z.ZodObject<{
3602
- fullName: z.ZodString;
3603
- originalName: z.ZodString;
3604
- serverName: z.ZodString;
3605
- description: z.ZodOptional<z.ZodString>;
3606
- inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3607
- exposureMode: z.ZodEnum<{
3608
- direct: "direct";
3609
- discovery: "discovery";
3610
- hidden: "hidden";
3611
- }>;
3612
- enabled: z.ZodBoolean;
3613
- enabledBy: z.ZodOptional<z.ZodEnum<{
3614
- discovery: "discovery";
3615
- toolset: "toolset";
3616
- }>>;
3617
- enabledAt: z.ZodOptional<z.ZodNumber>;
3618
- exposed: z.ZodBoolean;
3619
- }, z.core.$strip>>;
3620
3601
  servers: z.ZodArray<z.ZodObject<{
3621
3602
  name: z.ZodString;
3622
3603
  transport: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -3657,6 +3638,25 @@ declare const CanonicalModelSelectionSchema: z.ZodObject<{
3657
3638
  discovery: "discovery";
3658
3639
  }>;
3659
3640
  }, z.core.$strip>>;
3641
+ directTools: z.ZodArray<z.ZodObject<{
3642
+ fullName: z.ZodString;
3643
+ originalName: z.ZodString;
3644
+ serverName: z.ZodString;
3645
+ description: z.ZodOptional<z.ZodString>;
3646
+ inputSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
3647
+ exposureMode: z.ZodEnum<{
3648
+ direct: "direct";
3649
+ discovery: "discovery";
3650
+ hidden: "hidden";
3651
+ }>;
3652
+ enabled: z.ZodBoolean;
3653
+ enabledBy: z.ZodOptional<z.ZodEnum<{
3654
+ discovery: "discovery";
3655
+ toolset: "toolset";
3656
+ }>>;
3657
+ enabledAt: z.ZodOptional<z.ZodNumber>;
3658
+ exposed: z.ZodBoolean;
3659
+ }, z.core.$strip>>;
3660
3660
  discoverableTools: z.ZodArray<z.ZodObject<{
3661
3661
  fullName: z.ZodString;
3662
3662
  originalName: z.ZodString;