@redocly/openapi-docs 3.24.1 → 3.25.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (283) hide show
  1. package/dist/{redocly-openapi-docs.min.AiChatProvider-j-VDfFJ9.js → redocly-openapi-docs.min.AiChatProvider-CDMc3dS6.js} +1 -1
  2. package/dist/{redocly-openapi-docs.min.AiChatSqliteDBStorage-BBRBmffc.js → redocly-openapi-docs.min.AiChatSqliteDBStorage-BopXqcPv.js} +1 -1
  3. package/dist/{redocly-openapi-docs.min.AiPanel-DTzHqAiI.js → redocly-openapi-docs.min.AiPanel-DkXOeLs5.js} +1 -1
  4. package/dist/redocly-openapi-docs.min.FileWatcher-DMjNW66W.js +1 -0
  5. package/dist/{redocly-openapi-docs.min.SemanticSearchService-DNFOPBZK.js → redocly-openapi-docs.min.SemanticSearchService-DbpnWseN.js} +1 -1
  6. package/dist/{redocly-openapi-docs.min.SqliteDBStorage-Dy40Vq04.js → redocly-openapi-docs.min.SqliteDBStorage-ak3Zqgtw.js} +1 -1
  7. package/dist/{redocly-openapi-docs.min.TauriFileSystemAdapter-CpViFqJQ.js → redocly-openapi-docs.min.TauriFileSystemAdapter-Dl2fY3am.js} +1 -1
  8. package/dist/{redocly-openapi-docs.min.TauriRootStorage-TCUrp2uB.js → redocly-openapi-docs.min.TauriRootStorage-m4plsfqx.js} +1 -1
  9. package/dist/{redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js → redocly-openapi-docs.min.ai-chat-mappers-Dg8U8w8r.js} +1 -1
  10. package/dist/{redocly-openapi-docs.min.external-resolver-BkceRyB4.js → redocly-openapi-docs.min.external-resolver-Db7hewsm.js} +1 -1
  11. package/dist/{redocly-openapi-docs.min.index-BCcol5vU.js → redocly-openapi-docs.min.index-B5-R6EGY.js} +1 -1
  12. package/dist/{redocly-openapi-docs.min.index-CmXZfuiZ.js → redocly-openapi-docs.min.index-D9U4Tk7n.js} +1320 -1213
  13. package/dist/{redocly-openapi-docs.min.index-DVWw0ICA.js → redocly-openapi-docs.min.index-DeHk4n2z.js} +1 -1
  14. package/dist/{redocly-openapi-docs.min.index-C6uU_v-b.js → redocly-openapi-docs.min.index-EVRmC_IQ.js} +1 -1
  15. package/dist/redocly-openapi-docs.min.js +1 -1
  16. package/dist/{redocly-openapi-docs.min.lint-2YpbCz3r.js → redocly-openapi-docs.min.lint-PvmGrAK3.js} +2 -2
  17. package/dist/{redocly-openapi-docs.min.lint-graphql-Bgfcu2tP.js → redocly-openapi-docs.min.lint-graphql-CMMhYVr_.js} +1 -1
  18. package/dist/{redocly-openapi-docs.min.respect-run-Ct8taisL.js → redocly-openapi-docs.min.respect-run-DgsYdmxw.js} +1 -1
  19. package/dist/{redocly-openapi-docs.min.standalone-BPCdJgtH.js → redocly-openapi-docs.min.standalone-D9becCWS.js} +708 -673
  20. package/dist/redocly-openapi-docs.min.tauri-path-Bv9A5DVf.js +1 -0
  21. package/dist/{redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js → redocly-openapi-docs.min.useAiChatQueries-Cb-1pa0w.js} +2 -2
  22. package/lib/telemetry/RedocTelemetry.js +1 -31
  23. package/package.json +5 -5
  24. package/dist/redocly-openapi-docs.min.FileWatcher-DDoyaS7A.js +0 -1
  25. package/dist/redocly-openapi-docs.min.tauri-path-CmqBCxGb.js +0 -1
  26. package/lib/components/ApiInfo/__tests__/ApiInfo.test.d.ts +0 -1
  27. package/lib/components/ApiInfo/__tests__/ApiInfo.test.js +0 -46
  28. package/lib/components/Callbacks/__tests__/Callbacks.test.d.ts +0 -1
  29. package/lib/components/Callbacks/__tests__/Callbacks.test.js +0 -46
  30. package/lib/components/Content/__tests__/useAutoScroll.test.d.ts +0 -1
  31. package/lib/components/Content/__tests__/useAutoScroll.test.js +0 -88
  32. package/lib/components/ContentItem/__tests__/useIsExpanded.test.d.ts +0 -1
  33. package/lib/components/ContentItem/__tests__/useIsExpanded.test.js +0 -123
  34. package/lib/components/ContentItems/__tests__/Items.test.d.ts +0 -1
  35. package/lib/components/ContentItems/__tests__/Items.test.js +0 -66
  36. package/lib/components/ContentItems/__tests__/VirtualList.test.d.ts +0 -1
  37. package/lib/components/ContentItems/__tests__/VirtualList.test.js +0 -135
  38. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.d.ts +0 -1
  39. package/lib/components/Discriminator/__tests__/DiscriminatorDropdown.test.js +0 -63
  40. package/lib/components/Download/__tests__/DownloadSpecification.test.d.ts +0 -1
  41. package/lib/components/Download/__tests__/DownloadSpecification.test.js +0 -52
  42. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.d.ts +0 -1
  43. package/lib/components/ExpandAllButton/__tests__/ExpandAllButton.test.js +0 -60
  44. package/lib/components/ExpandAllButton/__tests__/helpers.test.d.ts +0 -1
  45. package/lib/components/ExpandAllButton/__tests__/helpers.test.js +0 -133
  46. package/lib/components/Language/__tests__/LanguageDropdown.test.d.ts +0 -1
  47. package/lib/components/Language/__tests__/LanguageDropdown.test.js +0 -23
  48. package/lib/components/Markdown/__tests__/Markdown.test.d.ts +0 -1
  49. package/lib/components/Markdown/__tests__/Markdown.test.js +0 -34
  50. package/lib/components/McpOverview/__tests__/McpOverview.test.d.ts +0 -1
  51. package/lib/components/McpOverview/__tests__/McpOverview.test.js +0 -66
  52. package/lib/components/McpTool/__tests__/McpPrompt.test.d.ts +0 -1
  53. package/lib/components/McpTool/__tests__/McpPrompt.test.js +0 -57
  54. package/lib/components/McpTool/__tests__/McpResource.test.d.ts +0 -1
  55. package/lib/components/McpTool/__tests__/McpResource.test.js +0 -81
  56. package/lib/components/McpTool/__tests__/McpTool.test.d.ts +0 -1
  57. package/lib/components/McpTool/__tests__/McpTool.test.js +0 -82
  58. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.d.ts +0 -1
  59. package/lib/components/MediaTypeSwitch/__tests__/MediaTypesSwitch.test.js +0 -79
  60. package/lib/components/OperationItem/__tests__/OperationItem.test.d.ts +0 -1
  61. package/lib/components/OperationItem/__tests__/OperationItem.test.js +0 -70
  62. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.d.ts +0 -16
  63. package/lib/components/OperationItem/__tests__/__mocks__/mock-intersection-observer.js +0 -42
  64. package/lib/components/Overview/__tests__/Overview.test.d.ts +0 -1
  65. package/lib/components/Overview/__tests__/Overview.test.js +0 -59
  66. package/lib/components/PayloadSamples/__tests__/Example.test.d.ts +0 -1
  67. package/lib/components/PayloadSamples/__tests__/Example.test.js +0 -36
  68. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.d.ts +0 -1
  69. package/lib/components/PayloadSamples/__tests__/ExampleValue.test.js +0 -197
  70. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.d.ts +0 -1
  71. package/lib/components/PayloadSamples/__tests__/PayloadSamples.test.js +0 -38
  72. package/lib/components/PropertyDetails/__tests__/Extensions.test.d.ts +0 -1
  73. package/lib/components/PropertyDetails/__tests__/Extensions.test.js +0 -21
  74. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.d.ts +0 -1
  75. package/lib/components/PropertyDetails/__tests__/FieldDetail.test.js +0 -52
  76. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.d.ts +0 -1
  77. package/lib/components/PropertyDetails/__tests__/FieldDetails.test.js +0 -191
  78. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.d.ts +0 -1
  79. package/lib/components/PropertyDetails/__tests__/PropertyDetails.test.js +0 -365
  80. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.d.ts +0 -1
  81. package/lib/components/PropertyDetails/__tests__/cycleColorsByLevel.test.js +0 -23
  82. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.d.ts +0 -1
  83. package/lib/components/RedoclyOpenAPIDocs/__tests__/AppProvider.test.js +0 -16
  84. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.d.ts +0 -1
  85. package/lib/components/RedoclyOpenAPIDocs/__tests__/RedoclyOpenAPIDocs.test.js +0 -104
  86. package/lib/components/RenderHook/__tests__/RenderHook.test.d.ts +0 -1
  87. package/lib/components/RenderHook/__tests__/RenderHook.test.js +0 -15
  88. package/lib/components/Replay/__tests__/utils.test.d.ts +0 -1
  89. package/lib/components/Replay/__tests__/utils.test.js +0 -526
  90. package/lib/components/Request/__tests__/RequestDetails.test.d.ts +0 -1
  91. package/lib/components/Request/__tests__/RequestDetails.test.js +0 -98
  92. package/lib/components/RequestSamples/__tests__/Example.test.d.ts +0 -1
  93. package/lib/components/RequestSamples/__tests__/Example.test.js +0 -384
  94. package/lib/components/RequestSamples/__tests__/RequestSamples.test.d.ts +0 -1
  95. package/lib/components/RequestSamples/__tests__/RequestSamples.test.js +0 -226
  96. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.d.ts +0 -1
  97. package/lib/components/RequestSamples/__tests__/useCodeSamples.test.js +0 -64
  98. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.d.ts +0 -1
  99. package/lib/components/ResponseSamples/__tests__/ResponseSamples.test.js +0 -29
  100. package/lib/components/Responses/__tests__/OperationResponseList.test.d.ts +0 -1
  101. package/lib/components/Responses/__tests__/OperationResponseList.test.js +0 -89
  102. package/lib/components/Responses/__tests__/ResponseDetails.test.d.ts +0 -1
  103. package/lib/components/Responses/__tests__/ResponseDetails.test.js +0 -111
  104. package/lib/components/Responses/__tests__/ResponsesHeaders.test.d.ts +0 -1
  105. package/lib/components/Responses/__tests__/ResponsesHeaders.test.js +0 -26
  106. package/lib/components/Schema/__tests__/ArraySchema.test.d.ts +0 -1
  107. package/lib/components/Schema/__tests__/ArraySchema.test.js +0 -93
  108. package/lib/components/Schema/__tests__/ObjectSchema.test.d.ts +0 -1
  109. package/lib/components/Schema/__tests__/ObjectSchema.test.js +0 -115
  110. package/lib/components/Schema/__tests__/OneOfSchema.test.d.ts +0 -1
  111. package/lib/components/Schema/__tests__/OneOfSchema.test.js +0 -33
  112. package/lib/components/Schema/__tests__/Schema.test.d.ts +0 -1
  113. package/lib/components/Schema/__tests__/Schema.test.js +0 -67
  114. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.d.ts +0 -1
  115. package/lib/components/Schema/__tests__/useOneOfLocationIdx.test.js +0 -22
  116. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.d.ts +0 -1
  117. package/lib/components/SchemaCatalogLink/__tests__/SchemaCatalogLink.test.js +0 -95
  118. package/lib/components/Security/__tests__/Security.test.d.ts +0 -1
  119. package/lib/components/Security/__tests__/Security.test.js +0 -38
  120. package/lib/components/Security/__tests__/SecurityButton.test.d.ts +0 -1
  121. package/lib/components/Security/__tests__/SecurityButton.test.js +0 -92
  122. package/lib/components/Security/__tests__/SecurityModal.test.d.ts +0 -1
  123. package/lib/components/Security/__tests__/SecurityModal.test.js +0 -172
  124. package/lib/components/ServerList/__tests__/ServerList.test.d.ts +0 -1
  125. package/lib/components/ServerList/__tests__/ServerList.test.js +0 -83
  126. package/lib/components/Tabs/__tests__/Tabs.test.d.ts +0 -1
  127. package/lib/components/Tabs/__tests__/Tabs.test.js +0 -27
  128. package/lib/components/ViewNested/__tests__/ViewNested.test.d.ts +0 -1
  129. package/lib/components/ViewNested/__tests__/ViewNested.test.js +0 -42
  130. package/lib/components/__tests__/Samples/ExampleSwitch.test.d.ts +0 -1
  131. package/lib/components/__tests__/Samples/ExampleSwitch.test.js +0 -45
  132. package/lib/components/__tests__/Samples/use-example-key.test.d.ts +0 -1
  133. package/lib/components/__tests__/Samples/use-example-key.test.js +0 -28
  134. package/lib/components/__tests__/common/ClearButton.test.d.ts +0 -1
  135. package/lib/components/__tests__/common/ClearButton.test.js +0 -18
  136. package/lib/components/__tests__/common/Dropdown.test.d.ts +0 -1
  137. package/lib/components/__tests__/common/Dropdown.test.js +0 -52
  138. package/lib/components/__tests__/mocks/examples.d.ts +0 -4
  139. package/lib/components/__tests__/mocks/examples.js +0 -115
  140. package/lib/components/common/__tests__/Dropdown.test.d.ts +0 -1
  141. package/lib/components/common/__tests__/Dropdown.test.js +0 -129
  142. package/lib/components/common/__tests__/LinkToField.test.d.ts +0 -1
  143. package/lib/components/common/__tests__/LinkToField.test.js +0 -39
  144. package/lib/jotai/__tests__/app.test.d.ts +0 -1
  145. package/lib/jotai/__tests__/app.test.js +0 -53
  146. package/lib/models/__tests__/Callback.test.d.ts +0 -1
  147. package/lib/models/__tests__/Callback.test.js +0 -15
  148. package/lib/models/__tests__/FieldModel.test.d.ts +0 -1
  149. package/lib/models/__tests__/FieldModel.test.js +0 -117
  150. package/lib/models/__tests__/MediaContent.test.d.ts +0 -1
  151. package/lib/models/__tests__/MediaContent.test.js +0 -105
  152. package/lib/models/__tests__/Operation.test.d.ts +0 -1
  153. package/lib/models/__tests__/Operation.test.js +0 -459
  154. package/lib/models/__tests__/Response.test.d.ts +0 -1
  155. package/lib/models/__tests__/Response.test.js +0 -221
  156. package/lib/models/__tests__/Schema.circular.test.d.ts +0 -1
  157. package/lib/models/__tests__/Schema.circular.test.js +0 -694
  158. package/lib/models/__tests__/Schema.test.d.ts +0 -1
  159. package/lib/models/__tests__/Schema.test.js +0 -1395
  160. package/lib/models/__tests__/example.test.d.ts +0 -1
  161. package/lib/models/__tests__/example.test.js +0 -90
  162. package/lib/models/__tests__/group.test.d.ts +0 -1
  163. package/lib/models/__tests__/group.test.js +0 -52
  164. package/lib/models/__tests__/helpers.d.ts +0 -5
  165. package/lib/models/__tests__/helpers.js +0 -62
  166. package/lib/models/__tests__/request.test.d.ts +0 -1
  167. package/lib/models/__tests__/request.test.js +0 -119
  168. package/lib/services/__tests__/OpenAPIParser.test.d.ts +0 -1
  169. package/lib/services/__tests__/OpenAPIParser.test.js +0 -80
  170. package/lib/services/__tests__/check.test.d.ts +0 -1
  171. package/lib/services/__tests__/check.test.js +0 -22
  172. package/lib/services/__tests__/utils.test.d.ts +0 -1
  173. package/lib/services/__tests__/utils.test.js +0 -42
  174. package/lib/services/code-samples/__tests__/apply-environments.test.d.ts +0 -1
  175. package/lib/services/code-samples/__tests__/apply-environments.test.js +0 -64
  176. package/lib/services/code-samples/__tests__/build-code-samples.test.d.ts +0 -1
  177. package/lib/services/code-samples/__tests__/build-code-samples.test.js +0 -70
  178. package/lib/services/code-samples/__tests__/convertSampleToString.test.d.ts +0 -1
  179. package/lib/services/code-samples/__tests__/convertSampleToString.test.js +0 -116
  180. package/lib/services/code-samples/__tests__/generator-data-value.test.d.ts +0 -1
  181. package/lib/services/code-samples/__tests__/generator-data-value.test.js +0 -277
  182. package/lib/services/code-samples/__tests__/generator-serialized-value.test.d.ts +0 -1
  183. package/lib/services/code-samples/__tests__/generator-serialized-value.test.js +0 -258
  184. package/lib/services/code-samples/__tests__/generator-value.test.d.ts +0 -1
  185. package/lib/services/code-samples/__tests__/generator-value.test.js +0 -273
  186. package/lib/services/code-samples/__tests__/generator.test.d.ts +0 -249
  187. package/lib/services/code-samples/__tests__/generator.test.js +0 -1201
  188. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.d.ts +0 -1
  189. package/lib/services/code-samples/__tests__/get-example-value-by-mime-type.test.js +0 -31
  190. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.d.ts +0 -1
  191. package/lib/services/code-samples/httpsnippet/__tests__/device-authorization.test.js +0 -222
  192. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.d.ts +0 -1
  193. package/lib/services/code-samples/httpsnippet/helpers/__tests__/code-helpers.test.js +0 -129
  194. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.d.ts +0 -1
  195. package/lib/services/code-samples/httpsnippet/helpers/__tests__/string-utility.test.js +0 -49
  196. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.d.ts +0 -1
  197. package/lib/services/code-samples/httpsnippet/targets/csharp/__tests__/httpclient.test.js +0 -172
  198. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.d.ts +0 -1
  199. package/lib/services/code-samples/httpsnippet/targets/csharpNewtonsoft/__tests__/httpclient.test.js +0 -172
  200. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.d.ts +0 -1
  201. package/lib/services/code-samples/httpsnippet/targets/go/__tests__/native.test.js +0 -130
  202. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.d.ts +0 -1
  203. package/lib/services/code-samples/httpsnippet/targets/java/__tests__/httpclient.test.js +0 -191
  204. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.d.ts +0 -1
  205. package/lib/services/code-samples/httpsnippet/targets/java8/__tests__/apachehttp.test.js +0 -172
  206. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.d.ts +0 -1
  207. package/lib/services/code-samples/httpsnippet/targets/javascript/__tests__/fetch.test.js +0 -85
  208. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.d.ts +0 -1
  209. package/lib/services/code-samples/httpsnippet/targets/node/__tests__/fetch.test.js +0 -85
  210. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.d.ts +0 -1
  211. package/lib/services/code-samples/httpsnippet/targets/php/__tests__/curl.test.js +0 -126
  212. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.d.ts +0 -1
  213. package/lib/services/code-samples/httpsnippet/targets/python/__tests__/requests.test.js +0 -105
  214. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.d.ts +0 -1
  215. package/lib/services/code-samples/httpsnippet/targets/r/__tests__/httr.test.js +0 -126
  216. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.d.ts +0 -1
  217. package/lib/services/code-samples/httpsnippet/targets/ruby/__tests__/native.test.js +0 -129
  218. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.d.ts +0 -1
  219. package/lib/services/code-samples/httpsnippet/targets/shell/__tests__/curl.test.js +0 -129
  220. package/lib/services/config-options/__tests__/helpers.test.d.ts +0 -1
  221. package/lib/services/config-options/__tests__/helpers.test.js +0 -234
  222. package/lib/services/history/__tests__/helpers.test.d.ts +0 -1
  223. package/lib/services/history/__tests__/helpers.test.js +0 -19
  224. package/lib/services/menu/__tests__/buildNestedTagsItems.test.d.ts +0 -1
  225. package/lib/services/menu/__tests__/buildNestedTagsItems.test.js +0 -109
  226. package/lib/services/menu/__tests__/builder.test.d.ts +0 -1
  227. package/lib/services/menu/__tests__/builder.test.js +0 -307
  228. package/lib/services/menu/__tests__/operation.test.d.ts +0 -1
  229. package/lib/services/menu/__tests__/operation.test.js +0 -240
  230. package/lib/services/menu/__tests__/tags.test.d.ts +0 -1
  231. package/lib/services/menu/__tests__/tags.test.js +0 -71
  232. package/lib/telemetry/__tests__/RedocTelemetry.test.d.ts +0 -1
  233. package/lib/telemetry/__tests__/RedocTelemetry.test.js +0 -107
  234. package/lib/testProviders.d.ts +0 -6
  235. package/lib/testProviders.js +0 -14
  236. package/lib/utils/__tests__/areArraysEqual.test.d.ts +0 -1
  237. package/lib/utils/__tests__/areArraysEqual.test.js +0 -33
  238. package/lib/utils/__tests__/argValuesHelpers.d.ts +0 -1
  239. package/lib/utils/__tests__/argValuesHelpers.js +0 -56
  240. package/lib/utils/__tests__/calculateMaxLength.test.d.ts +0 -1
  241. package/lib/utils/__tests__/calculateMaxLength.test.js +0 -119
  242. package/lib/utils/__tests__/configure-helpers.test.d.ts +0 -1
  243. package/lib/utils/__tests__/configure-helpers.test.js +0 -356
  244. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.d.ts +0 -1
  245. package/lib/utils/__tests__/convertSwagger2OpenAPI.test.js +0 -392
  246. package/lib/utils/__tests__/debounce.test.d.ts +0 -1
  247. package/lib/utils/__tests__/debounce.test.js +0 -54
  248. package/lib/utils/__tests__/debug.test.d.ts +0 -1
  249. package/lib/utils/__tests__/debug.test.js +0 -23
  250. package/lib/utils/__tests__/dom.test.d.ts +0 -1
  251. package/lib/utils/__tests__/dom.test.js +0 -108
  252. package/lib/utils/__tests__/getBreadcrumbs.test.d.ts +0 -1
  253. package/lib/utils/__tests__/getBreadcrumbs.test.js +0 -98
  254. package/lib/utils/__tests__/hasNestedFields.test.d.ts +0 -1
  255. package/lib/utils/__tests__/hasNestedFields.test.js +0 -147
  256. package/lib/utils/__tests__/helpers.test.d.ts +0 -1
  257. package/lib/utils/__tests__/helpers.test.js +0 -174
  258. package/lib/utils/__tests__/isMobile.test.d.ts +0 -1
  259. package/lib/utils/__tests__/isMobile.test.js +0 -28
  260. package/lib/utils/__tests__/loadAndBundleSpec.test.d.ts +0 -1
  261. package/lib/utils/__tests__/loadAndBundleSpec.test.js +0 -22
  262. package/lib/utils/__tests__/local-storage.test.d.ts +0 -1
  263. package/lib/utils/__tests__/local-storage.test.js +0 -48
  264. package/lib/utils/__tests__/object.test.d.ts +0 -1
  265. package/lib/utils/__tests__/object.test.js +0 -45
  266. package/lib/utils/__tests__/openapi.test.d.ts +0 -1
  267. package/lib/utils/__tests__/openapi.test.js +0 -1378
  268. package/lib/utils/__tests__/path.test.d.ts +0 -1
  269. package/lib/utils/__tests__/path.test.js +0 -16
  270. package/lib/utils/__tests__/queryString.test.d.ts +0 -1
  271. package/lib/utils/__tests__/queryString.test.js +0 -60
  272. package/lib/utils/__tests__/replaceVariables.test.d.ts +0 -1
  273. package/lib/utils/__tests__/replaceVariables.test.js +0 -46
  274. package/lib/utils/__tests__/simplifyAstStructure.test.d.ts +0 -1
  275. package/lib/utils/__tests__/simplifyAstStructure.test.js +0 -26
  276. package/lib/utils/__tests__/sort.test.d.ts +0 -1
  277. package/lib/utils/__tests__/sort.test.js +0 -16
  278. package/lib/utils/__tests__/string.test.d.ts +0 -1
  279. package/lib/utils/__tests__/string.test.js +0 -16
  280. package/lib/utils/__tests__/theme-helpers.test.d.ts +0 -1
  281. package/lib/utils/__tests__/theme-helpers.test.js +0 -24
  282. package/lib/utils/__tests__/url.test.d.ts +0 -1
  283. package/lib/utils/__tests__/url.test.js +0 -134
@@ -1,4 +1,4 @@
1
- import{D as v,F as T,ay as x,w as _t,d as Qt,r as l,j as at}from"./redocly-openapi-docs.min.standalone-BPCdJgtH.js";import{T as Gt,c as rt,D as Ht,a as Vt,u as mt,b as gt,d as A,A as ft,I as Yt,e as E,f as Xt,g as Zt,h as te,i as wt,j as ee,k as ne,l as oe,m as ae,n as Tt,o as st,p as ht,q as At,r as re,s as se,t as Mt,R as it,v as ie,w as yt,x as le,y as ue}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{c as St,p as pe,g as ce,T as de,i as me,a as ge,s as fe,A as he,b as ye,r as Se,d as ve,e as be,o as Ie,f as ke,w as Ce,m as xe,h as _e,u as we,j as Te,k as Ae,l as Me,n as Oe,D as Ee,q as Re,t as je,v as qe,x as Ne,y as $e,z as Pe}from"./redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js";import{b as Ot,g as Et}from"./redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js";function R(t){const e=t.toLowerCase(),n=[["google.vertex","gcp.vertex_ai"],["google.generative-ai","gcp.gemini"],["google-vertex","gcp.vertex_ai"],["amazon-bedrock","aws.bedrock"],["azure-openai","azure.ai.openai"],["anthropic","anthropic"],["openai","openai"],["azure","azure.ai.inference"],["google","gcp.gemini"],["mistral","mistral_ai"],["cohere","cohere"],["bedrock","aws.bedrock"],["groq","groq"],["deepseek","deepseek"],["perplexity","perplexity"],["xai","x_ai"]];for(const[o,r]of n)if(e===o||e.startsWith(o+".")||e.startsWith(o+"-"))return r;return t}function Rt(t){var e;return(e={"ai.generateText":"invoke_agent","ai.streamText":"invoke_agent","ai.generateObject":"invoke_agent","ai.streamObject":"invoke_agent","ai.embed":"embeddings","ai.embedMany":"embeddings","ai.rerank":"rerank"}[t])!=null?e:t}function jt(t){return typeof t=="string"?[{type:"text",content:t}]:Array.isArray(t)?t.map(e=>({type:"text",content:e.content})):[{type:"text",content:t.content}]}function De(t){var e,n,o,r,a;switch(t.type){case"text":return{type:"text",content:t.text};case"reasoning":return{type:"reasoning",content:t.text};case"tool-call":return{type:"tool_call",id:(e=t.toolCallId)!=null?e:null,name:t.toolName,arguments:t.input};case"tool-result":{const s=t.output;let i;return s&&(s.type==="text"||s.type==="error-text"||s.type==="json"||s.type==="error-json"?i=s.value:s.type==="execution-denied"?i={denied:!0,reason:s.reason}:i=s),{type:"tool_call_response",id:(n=t.toolCallId)!=null?n:null,response:i}}case"file":{const s=t.data,i=(()=>{if(typeof s=="object"&&s!==null&&!(s instanceof URL)&&!(s instanceof Uint8Array)&&!(s instanceof ArrayBuffer)&&"type"in s)switch(s.type){case"data":return s.data;case"url":return s.url;case"text":return s.text;default:return""}return s})();let u;if(i instanceof Uint8Array)u=St(i);else if(typeof i=="string"){if(i.startsWith("http://")||i.startsWith("https://"))return{type:"uri",modality:j(t.mediaType),mime_type:(o=t.mediaType)!=null?o:null,uri:i};u=i}else{if(i instanceof URL)return{type:"uri",modality:j(t.mediaType),mime_type:(r=t.mediaType)!=null?r:null,uri:i.toString()};u=String(i)}return{type:"blob",modality:j(t.mediaType),mime_type:(a=t.mediaType)!=null?a:null,content:u}}case"tool-approval-response":return{type:"tool_approval_response",approval_id:t.approvalId,approved:t.approved,reason:t.reason};case"custom":return{type:"custom",kind:t.kind};case"reasoning-file":return{type:String(t.type)};default:return{type:String(t.type)}}}function j(t){return!t||t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"image"}function We(t){return t.filter(e=>e.role!=="system").map(e=>{if(e.role==="system")return{role:"system",parts:[{type:"text",content:e.content}]};const n=e.content.map(De);return{role:e.role,parts:n}})}function vt({prompt:t,messages:e}){const n=[];if(typeof t=="string")n.push({role:"user",parts:[{type:"text",content:t}]});else if(Array.isArray(t))for(const o of t){const r=qt(o);r&&n.push(r)}if(e)for(const o of e){const r=qt(o);r&&n.push(r)}return n}function qt(t){if(t.role!=="system"){if(t.role==="user")return typeof t.content=="string"?{role:"user",parts:[{type:"text",content:t.content}]}:{role:"user",parts:t.content.map(e=>{var n,o,r,a,s,i,u,d;switch(e.type){case"text":return{type:"text",content:e.text};case"image":{const p=e.image;return p instanceof URL?{type:"uri",modality:"image",mime_type:(n=e.mediaType)!=null?n:null,uri:p.toString()}:typeof p=="string"?p.startsWith("http://")||p.startsWith("https://")?{type:"uri",modality:"image",mime_type:(o=e.mediaType)!=null?o:null,uri:p}:{type:"blob",modality:"image",mime_type:(r=e.mediaType)!=null?r:null,content:p}:{type:"blob",modality:"image",mime_type:(a=e.mediaType)!=null?a:null,content:St(p)}}case"file":{const p=e.data,c=(()=>{if(typeof p=="object"&&p!==null&&!(p instanceof URL)&&!(p instanceof Uint8Array)&&!(p instanceof ArrayBuffer)&&"type"in p)switch(p.type){case"data":return p.data;case"url":return p.url;case"text":return p.text;default:return""}return p})();return c instanceof URL?{type:"uri",modality:j(e.mediaType),mime_type:(s=e.mediaType)!=null?s:null,uri:c.toString()}:typeof c=="string"?c.startsWith("http://")||c.startsWith("https://")?{type:"uri",modality:j(e.mediaType),mime_type:(i=e.mediaType)!=null?i:null,uri:c}:{type:"blob",modality:j(e.mediaType),mime_type:(u=e.mediaType)!=null?u:null,content:c}:{type:"blob",modality:j(e.mediaType),mime_type:(d=e.mediaType)!=null?d:null,content:St(c)}}default:return{type:String(e.type)}}})};if(t.role==="assistant")return typeof t.content=="string"?{role:"assistant",parts:[{type:"text",content:t.content}]}:{role:"assistant",parts:t.content.map(e=>{var n,o;switch(e.type){case"text":return{type:"text",content:e.text};case"reasoning":return{type:"reasoning",content:e.text};case"tool-call":return{type:"tool_call",id:(n=e.toolCallId)!=null?n:null,name:e.toolName,arguments:e.input};case"tool-result":{const r=e.output;let a;return r&&(r.type==="text"||r.type==="error-text"||r.type==="json"||r.type==="error-json"?a=r.value:r.type==="execution-denied"?a={denied:!0,reason:r.reason}:a=r),{type:"tool_call_response",id:(o=e.toolCallId)!=null?o:null,response:a}}default:return{type:String(e.type)}}})};if(t.role==="tool")return{role:"tool",parts:t.content.map(e=>{var n;if(e.type==="tool-result"){const o=e.output;let r;return o&&(o.type==="text"||o.type==="error-text"||o.type==="json"||o.type==="error-json"?r=o.value:o.type==="execution-denied"?r={denied:!0,reason:o.reason}:r=o),{type:"tool_call_response",id:(n=e.toolCallId)!=null?n:null,response:r}}return{type:String(e.type)}})}}}function Nt({text:t,reasoning:e,toolCalls:n,files:o,finishReason:r}){const a=[];if(e)for(const s of e)"text"in s&&s.text&&a.push({type:"reasoning",content:s.text});if(t!=null&&t.length>0&&a.push({type:"text",content:t}),n)for(const s of n)a.push({type:"tool_call",id:s.toolCallId,name:s.toolName,arguments:s.input});if(o)for(const s of o)a.push({type:"blob",modality:j(s.mediaType),mime_type:s.mediaType,content:s.base64});return[{role:"assistant",parts:a,finish_reason:Pt(r)}]}function $t({objectText:t,finishReason:e}){return[{role:"assistant",parts:[{type:"text",content:t}],finish_reason:Pt(e)}]}function Pt(t){var e;return(e={stop:"stop",length:"length","content-filter":"content_filter","tool-calls":"tool_call",error:"error",other:"stop",unknown:"stop"}[t])!=null?e:t}function L(t,e){e instanceof Error?(t.recordException({name:e.name,message:e.message,stack:e.stack}),t.setStatus({code:_t.ERROR,message:e.message})):t.setStatus({code:_t.ERROR})}function Je(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function lt(t){if(!Array.isArray(t))return t;const e=new Set(t.filter(Je).map(o=>typeof o));if(e.size!==1)return;const[n]=e;return n==="string"?t.filter(o=>typeof o=="string"):n==="number"?t.filter(o=>typeof o=="number"):t.filter(o=>typeof o=="boolean")}function Fe(t){const e={};for(const[n,o]of Object.entries(t??{})){if(o==null)continue;const r=lt(o);r!=null&&(e[n]=r)}return e}function Le(t){return t?.isEnabled!==!1}function h(t,e){if(!Le(t))return{};const n={};for(const[o,r]of Object.entries(e)){if(r==null)continue;if(typeof r=="object"&&"input"in r&&typeof r.input=="function"){if(t?.recordInputs===!1)continue;const s=r.input();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}if(typeof r=="object"&&"output"in r&&typeof r.output=="function"){if(t?.recordOutputs===!1)continue;const s=r.output();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}const a=lt(r);a!=null&&(n[o]=a)}return n}var Ue={usage:!1,providerMetadata:!1,embedding:!1,reranking:!1,runtimeContext:!1,headers:!1,toolChoice:!1,schema:!1};function Ke(t){var e,n,o,r,a,s,i,u;return{...Ue,usage:(e=t.usage)!=null?e:!1,providerMetadata:(n=t.providerMetadata)!=null?n:!1,embedding:(o=t.embedding)!=null?o:!1,reranking:(r=t.reranking)!=null?r:!1,runtimeContext:(a=t.runtimeContext)!=null?a:!1,headers:(s=t.headers)!=null?s:!1,toolChoice:(i=t.toolChoice)!=null?i:!1,schema:(u=t.schema)!=null?u:!1}}function Be(t){const e={};for(const[n,o]of Object.entries(t??{}))Dt(e,`ai.settings.context.${n}`,o);return e}function Dt(t,e,n){if(n!=null){if(Array.isArray(n)||typeof n!="object"){t[e]=n;return}for(const[o,r]of Object.entries(n))Dt(t,`${e}.${o}`,r)}}function ut(t){return Object.fromEntries(Object.entries(t??{}).filter(([,e])=>e!=null).map(([e,n])=>[`ai.request.headers.${e}`,n]))}function V(t){var e,n,o;return{"ai.usage.inputTokenDetails.noCacheTokens":(e=t.inputTokenDetails)==null?void 0:e.noCacheTokens,"ai.usage.outputTokenDetails.textTokens":(n=t.outputTokenDetails)==null?void 0:n.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(o=t.outputTokenDetails)==null?void 0:o.reasoningTokens}}function S(t,e,n){const o={};for(const[r,a]of Object.entries(n))!e[r]||a==null||Object.assign(o,h(t,a));return o}function pt(t){return t==null?void 0:t/1e3}function ze(t){var e;return{"gen_ai.client.operation.duration":pt(t.responseTimeMs),"gen_ai.client.operation.time_to_first_chunk":pt(t.timeToFirstOutputMs),"gen_ai.client.operation.time_per_output_chunk":pt((e=t.timeBetweenOutputChunksMs)==null?void 0:e.avg)}}var Qe=class{constructor(t={}){this.callStates=new Map;var e;this.tracer=(e=t.tracer)!=null?e:v.getTracer("gen_ai"),this.supplementalAttributes=Ke(t),this.enrichSpan=t.enrichSpan}getCallState(t){return this.callStates.get(t)}cleanupCallState(t){this.callStates.delete(t)}getSpanAttributes({attributes:t,spanType:e,operationId:n,callId:o,runtimeContext:r}){var a;let s;try{s=(a=this.enrichSpan)==null?void 0:a.call(this,{spanType:e,operationId:n,callId:o,runtimeContext:r})}catch{s=void 0}return{...Fe(s),...t}}executeTool({callId:t,toolCallId:e,execute:n}){var o;const r=(o=this.getCallState(t))==null?void 0:o.toolSpans.get(e);return r==null?n():T.with(r.context,n)}executeLanguageModelCall({callId:t,execute:e}){var n;const o=this.getCallState(t),r=(n=o?.inferenceContext)!=null?n:o?.stepContext;return r==null?e():T.with(r,e)}onStart(t){if(t.operationId==="ai.embed"||t.operationId==="ai.embedMany"){this.onEmbedOperationStart(t);return}if(t.operationId==="ai.rerank"){this.onRerankOperationStart(t);return}if(t.operationId==="ai.generateObject"||t.operationId==="ai.streamObject"){this.onObjectOperationStart(t);return}this.onGenerateStart(t)}onGenerateStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,stopSequences:t.stopSequences,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=t.runtimeContext,i=S(n,this.supplementalAttributes,{runtimeContext:Be(s),headers:ut(t.headers)}),u=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.stop_sequences":t.stopSequences,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.instructions?{input:()=>JSON.stringify(jt(t.instructions))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:void 0,messages:t.messages}))},...i}),d=`${a} ${t.modelId}`,p=this.tracer.startSpan(d,{attributes:this.getSpanAttributes({attributes:u,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:s}),kind:x.INTERNAL}),c=v.setSpan(T.active(),p);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:p,rootContext:c,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:s,baseSupplementalAttributes:i})}onObjectOperationStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=S(n,this.supplementalAttributes,{headers:ut(t.headers)}),i=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.system?{input:()=>JSON.stringify(jt(t.system))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:t.prompt,messages:t.messages}))},...s,...S(n,this.supplementalAttributes,{schema:{"ai.schema":t.schema?{input:()=>JSON.stringify(t.schema)}:void 0,"ai.schema.name":t.schemaName,"ai.schema.description":t.schemaDescription,"ai.settings.output":t.output}})}),u=`${a} ${t.modelId}`,d=this.tracer.startSpan(u,{attributes:this.getSpanAttributes({attributes:i,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.INTERNAL}),p=v.setSpan(T.active(),d);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:d,rootContext:p,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:s})}onObjectStepStart(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan||!n.rootContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>t.promptMessages?JSON.stringify(We(t.promptMessages)):void 0},...n.baseSupplementalAttributes}),s=`chat ${t.modelId}`;n.inferenceSpan=this.tracer.startSpan(s,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.rootContext),n.inferenceContext=v.setSpan(n.rootContext,n.inferenceSpan)}onObjectStepEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.inferenceSpan)return;const{telemetry:o}=n;n.inferenceSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.response.id,"gen_ai.response.model":t.response.modelId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>{try{return JSON.stringify($t({objectText:t.objectText,finishReason:t.finishReason}))}catch{return t.objectText}}},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.inferenceSpan.end(),n.inferenceSpan=void 0,n.inferenceContext=void 0}onEmbedOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=t.value,a=t.operationId==="ai.embedMany",s=h(e,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{embedding:a?{"ai.values":{input:()=>r.map(p=>JSON.stringify(p))}}:{"ai.value":{input:()=>JSON.stringify(r)}}})}),i=`embeddings ${t.modelId}`,u=this.tracer.startSpan(i,{attributes:this.getSpanAttributes({attributes:s,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),d=v.setSpan(T.active(),u);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:u,rootContext:d,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onStepStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e;e.runtimeContext=t.runtimeContext;const o=h(n,{"gen_ai.operation.name":"agent_step",...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{toolChoice:{"ai.prompt.toolChoice":{input:()=>t.stepToolChoice!=null?JSON.stringify(t.stepToolChoice):void 0}}})});e.stepSpan=this.tracer.startSpan(`step ${t.steps.length+1}`,{attributes:this.getSpanAttributes({attributes:o,spanType:"step",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.rootContext),e.stepContext=v.setSpan(e.rootContext,e.stepSpan)}onLanguageModelCallStart(t){var e;const n=this.getCallState(t.callId);if(!n?.stepContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.stop_sequences":n.settings.stopSequences,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>{const s=vt({prompt:void 0,messages:t.messages});return s.length>0?JSON.stringify(s):void 0}},"gen_ai.tool.definitions":{input:()=>t.tools?JSON.stringify(t.tools):void 0}});n.inferenceSpan=this.tracer.startSpan(`chat ${t.modelId}`,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.stepContext),n.inferenceContext=v.setSpan(n.stepContext,n.inferenceSpan)}onLanguageModelCallEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.inferenceSpan)return;const{telemetry:r}=o;o.inferenceSpan.setAttributes(h(r,{...ze(t.performance),"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.responseId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>JSON.stringify(Nt({text:t.content.filter(a=>a.type==="text").map(a=>a.text).join("")||void 0,reasoning:t.content.filter(a=>a.type==="reasoning"),toolCalls:t.content.filter(a=>a.type==="tool-call"),files:t.content.filter(a=>a.type==="file").map(a=>a.file),finishReason:t.finishReason}))},...S(r,this.supplementalAttributes,{usage:V(t.usage)})})),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0}onToolExecutionStart(t){const e=this.getCallState(t.callId);if(!e?.stepContext)return;const{telemetry:n}=e,{toolCall:o}=t,r=h(n,{"gen_ai.operation.name":"execute_tool","gen_ai.tool.name":o.toolName,"gen_ai.tool.call.id":o.toolCallId,"gen_ai.tool.type":"function","gen_ai.tool.call.arguments":{input:()=>JSON.stringify(o.input)}}),a=`execute_tool ${o.toolName}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"tool",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.stepContext),i=v.setSpan(e.stepContext,s);e.toolSpans.set(o.toolCallId,{span:s,context:i})}onToolExecutionEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.toolSpans.get(t.toolCall.toolCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e,{toolOutput:a}=t;if(o.setAttributes(h(r,{"gen_ai.execute_tool.duration":pt(t.toolExecutionMs)})),a.type==="tool-result")try{o.setAttributes(h(r,{"gen_ai.tool.call.result":{output:()=>JSON.stringify(a.output)}}))}catch{}else L(o,a.error);o.end(),e.toolSpans.delete(t.toolCall.toolCallId)}onStepEnd(t){const e=this.getCallState(t.callId);if(!e?.stepSpan)return;const{telemetry:n}=e;e.stepSpan.setAttributes(S(n,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})),e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0}onStepFinish(t){this.onStepEnd(t)}onEnd(t){const e=this.getCallState(t.callId);if(e?.rootSpan){if(e.operationId==="ai.embed"||e.operationId==="ai.embedMany"){this.onEmbedOperationEnd(t);return}if(e.operationId==="ai.rerank"){this.onRerankOperationEnd(t);return}if(e.operationId==="ai.generateObject"||e.operationId==="ai.streamObject"){this.onObjectOperationEnd(t);return}this.onGenerateEnd(t)}}onGenerateEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.rootSpan)return;const{telemetry:r}=o;o.rootSpan.setAttributes(h(r,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>{var a;return JSON.stringify(Nt({text:(a=t.text)!=null?a:void 0,reasoning:t.finalStep.reasoning,toolCalls:t.toolCalls,files:t.files,finishReason:t.finishReason}))}},...S(r,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.finalStep.providerMetadata?JSON.stringify(t.finalStep.providerMetadata):void 0},usage:V(t.usage)})})),o.rootSpan.end(),this.cleanupCallState(t.callId)}onObjectOperationEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan)return;const{telemetry:o}=n;n.rootSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>t.object!=null?JSON.stringify($t({objectText:JSON.stringify(t.object),finishReason:t.finishReason})):void 0},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedOperationEnd(t){const e=this.getCallState(t.callId);if(!e?.rootSpan)return;const{telemetry:n}=e,o=e.operationId==="ai.embedMany";e.rootSpan.setAttributes(h(n,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(n,this.supplementalAttributes,{embedding:o?{"ai.embeddings":{output:()=>t.embedding.map(r=>JSON.stringify(r))}}:{"ai.embedding":{output:()=>JSON.stringify(t.embedding)}}})})),e.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{embedding:{"ai.values":{input:()=>t.values.map(u=>JSON.stringify(u))}}})}),a=`embeddings ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"embedding",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.embedSpans.set(t.embedCallId,{span:s,context:i})}onEmbedEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.embedSpans.get(t.embedCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e;o.setAttributes(h(r,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(r,this.supplementalAttributes,{embedding:{"ai.embeddings":{output:()=>t.embeddings.map(a=>JSON.stringify(a))}}})})),o.end(),e.embedSpans.delete(t.embedCallId)}onRerankOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=h(e,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${t.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),i=v.setSpan(T.active(),s);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:s,rootContext:i,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onRerankOperationEnd(t){const e=this.getCallState(t.callId);e?.rootSpan&&(e.rootSpan.end(),this.cleanupCallState(t.callId))}onRerankStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"reranking",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.rerankSpan={span:s,context:i}}onRerankEnd(t){const e=this.getCallState(t.callId);if(!e?.rerankSpan)return;const{span:n}=e.rerankSpan,{telemetry:o}=e;n.setAttributes(S(o,this.supplementalAttributes,{reranking:{"ai.ranking.type":t.documentsType,"ai.ranking":{output:()=>t.ranking.map(r=>JSON.stringify(r))}}})),n.end(),e.rerankSpan=void 0}onAbort(t){const e=this.getCallState(t.callId);if(e?.rootSpan){for(const{span:n}of e.toolSpans.values())n.end();e.toolSpans.clear(),e.inferenceSpan&&(e.inferenceSpan.end(),e.inferenceSpan=void 0,e.inferenceContext=void 0),e.stepSpan&&(e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0);for(const{span:n}of e.embedSpans.values())n.end();e.embedSpans.clear(),e.rerankSpan&&(e.rerankSpan.span.end(),e.rerankSpan=void 0),e.rootSpan.end(),this.cleanupCallState(t.callId)}}onError(t){var e;const n=t;if(!n?.callId)return;const o=this.getCallState(n.callId);if(!o?.rootSpan)return;const r=(e=n.error)!=null?e:t;for(const{span:a}of o.toolSpans.values())L(a,r),a.end();o.toolSpans.clear(),o.inferenceSpan&&(L(o.inferenceSpan,r),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0),o.stepSpan&&(L(o.stepSpan,r),o.stepSpan.end(),o.stepSpan=void 0,o.stepContext=void 0);for(const{span:a}of o.embedSpans.values())L(a,r),a.end();o.embedSpans.clear(),o.rerankSpan&&(L(o.rerankSpan.span,r),o.rerankSpan.span.end(),o.rerankSpan=void 0),L(o.rootSpan,r),o.rootSpan.end(),this.cleanupCallState(n.callId)}};function Ge(t){return pe({messages:t,emptyMessages:"remove",reasoning:"none",toolCalls:`before-last-${Gt}-messages`})}function He(t){return typeof t=="object"&&t!==null&&"role"in t&&"content"in t}function Ve(t){return Array.isArray(t)&&t.every(He)}function Ye(t,{conversationId:e,getModel:n}){let o=0;const r=()=>{const a=n?.();return a?{model_provider:a.provider,model_id:a.modelId}:{}};return{onStepStart:()=>{o+=1},onToolExecutionStart:a=>{t("com.redocly.aiChat.toolCallStarted",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,...r()}])},onToolExecutionEnd:a=>{const s=a.toolOutput.type==="tool-error";t("com.redocly.aiChat.toolCallFinished",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,success:!s,duration_ms:a.toolExecutionMs,...r(),...s&&{error:a.toolOutput.error instanceof Error?a.toolOutput.error.message:String(a.toolOutput.error)}}])},onStart:a=>{o=0,t("com.redocly.aiChat.conversationStarted",[{...rt("conversation",e,"ai"),model_provider:"provider"in a?a.provider:"unknown",model_id:"modelId"in a?a.modelId:"unknown"}])},onEnd:a=>{if(!("steps"in a))return;const s=a.usage;t("com.redocly.aiChat.conversationFinished",[{...rt("conversation",e,"ai"),model_provider:a.model.provider,model_id:a.model.modelId,success:!0,step_count:a.steps.length,finish_reason:a.finishReason,input_tokens:s.inputTokens,output_tokens:s.outputTokens,total_tokens:s.totalTokens}])}}}function Xe(t,e){const n=()=>v.getSpan(T.active())?T.active():e;return{startSpan:(o,r,a)=>t.startSpan(o,r,a??e),startActiveSpan:((o,r,a,s)=>{if(typeof r=="function")return t.startActiveSpan(o,{},n(),r);if(typeof a=="function")return t.startActiveSpan(o,r,n(),a);if(s)return t.startActiveSpan(o,r,a,s);throw new Error("withParentContext: invalid startActiveSpan invocation")})}}const Ze=`You are a helpful assistant that can generate titles for conversations.
1
+ import{D as v,F as T,ay as x,w as _t,d as Qt,r as l,j as at}from"./redocly-openapi-docs.min.standalone-D9becCWS.js";import{T as Gt,c as rt,D as Ht,a as Vt,u as mt,b as gt,d as A,A as ft,I as Yt,e as E,f as Xt,g as Zt,h as te,i as wt,j as ee,k as ne,l as oe,m as ae,n as Tt,o as st,p as ht,q as At,r as re,s as se,t as Mt,R as it,v as ie,w as yt,x as le,y as ue}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{c as St,p as pe,g as ce,T as de,i as me,a as ge,s as fe,A as he,b as ye,r as Se,d as ve,e as be,o as Ie,f as ke,w as Ce,m as xe,h as _e,u as we,j as Te,k as Ae,l as Me,n as Oe,D as Ee,q as Re,t as je,v as qe,x as Ne,y as $e,z as Pe}from"./redocly-openapi-docs.min.useAiChatQueries-Cb-1pa0w.js";import{b as Ot,g as Et}from"./redocly-openapi-docs.min.ai-chat-mappers-Dg8U8w8r.js";function R(t){const e=t.toLowerCase(),n=[["google.vertex","gcp.vertex_ai"],["google.generative-ai","gcp.gemini"],["google-vertex","gcp.vertex_ai"],["amazon-bedrock","aws.bedrock"],["azure-openai","azure.ai.openai"],["anthropic","anthropic"],["openai","openai"],["azure","azure.ai.inference"],["google","gcp.gemini"],["mistral","mistral_ai"],["cohere","cohere"],["bedrock","aws.bedrock"],["groq","groq"],["deepseek","deepseek"],["perplexity","perplexity"],["xai","x_ai"]];for(const[o,r]of n)if(e===o||e.startsWith(o+".")||e.startsWith(o+"-"))return r;return t}function Rt(t){var e;return(e={"ai.generateText":"invoke_agent","ai.streamText":"invoke_agent","ai.generateObject":"invoke_agent","ai.streamObject":"invoke_agent","ai.embed":"embeddings","ai.embedMany":"embeddings","ai.rerank":"rerank"}[t])!=null?e:t}function jt(t){return typeof t=="string"?[{type:"text",content:t}]:Array.isArray(t)?t.map(e=>({type:"text",content:e.content})):[{type:"text",content:t.content}]}function De(t){var e,n,o,r,a;switch(t.type){case"text":return{type:"text",content:t.text};case"reasoning":return{type:"reasoning",content:t.text};case"tool-call":return{type:"tool_call",id:(e=t.toolCallId)!=null?e:null,name:t.toolName,arguments:t.input};case"tool-result":{const s=t.output;let i;return s&&(s.type==="text"||s.type==="error-text"||s.type==="json"||s.type==="error-json"?i=s.value:s.type==="execution-denied"?i={denied:!0,reason:s.reason}:i=s),{type:"tool_call_response",id:(n=t.toolCallId)!=null?n:null,response:i}}case"file":{const s=t.data,i=(()=>{if(typeof s=="object"&&s!==null&&!(s instanceof URL)&&!(s instanceof Uint8Array)&&!(s instanceof ArrayBuffer)&&"type"in s)switch(s.type){case"data":return s.data;case"url":return s.url;case"text":return s.text;default:return""}return s})();let u;if(i instanceof Uint8Array)u=St(i);else if(typeof i=="string"){if(i.startsWith("http://")||i.startsWith("https://"))return{type:"uri",modality:j(t.mediaType),mime_type:(o=t.mediaType)!=null?o:null,uri:i};u=i}else{if(i instanceof URL)return{type:"uri",modality:j(t.mediaType),mime_type:(r=t.mediaType)!=null?r:null,uri:i.toString()};u=String(i)}return{type:"blob",modality:j(t.mediaType),mime_type:(a=t.mediaType)!=null?a:null,content:u}}case"tool-approval-response":return{type:"tool_approval_response",approval_id:t.approvalId,approved:t.approved,reason:t.reason};case"custom":return{type:"custom",kind:t.kind};case"reasoning-file":return{type:String(t.type)};default:return{type:String(t.type)}}}function j(t){return!t||t.startsWith("image/")?"image":t.startsWith("video/")?"video":t.startsWith("audio/")?"audio":"image"}function We(t){return t.filter(e=>e.role!=="system").map(e=>{if(e.role==="system")return{role:"system",parts:[{type:"text",content:e.content}]};const n=e.content.map(De);return{role:e.role,parts:n}})}function vt({prompt:t,messages:e}){const n=[];if(typeof t=="string")n.push({role:"user",parts:[{type:"text",content:t}]});else if(Array.isArray(t))for(const o of t){const r=qt(o);r&&n.push(r)}if(e)for(const o of e){const r=qt(o);r&&n.push(r)}return n}function qt(t){if(t.role!=="system"){if(t.role==="user")return typeof t.content=="string"?{role:"user",parts:[{type:"text",content:t.content}]}:{role:"user",parts:t.content.map(e=>{var n,o,r,a,s,i,u,d;switch(e.type){case"text":return{type:"text",content:e.text};case"image":{const p=e.image;return p instanceof URL?{type:"uri",modality:"image",mime_type:(n=e.mediaType)!=null?n:null,uri:p.toString()}:typeof p=="string"?p.startsWith("http://")||p.startsWith("https://")?{type:"uri",modality:"image",mime_type:(o=e.mediaType)!=null?o:null,uri:p}:{type:"blob",modality:"image",mime_type:(r=e.mediaType)!=null?r:null,content:p}:{type:"blob",modality:"image",mime_type:(a=e.mediaType)!=null?a:null,content:St(p)}}case"file":{const p=e.data,c=(()=>{if(typeof p=="object"&&p!==null&&!(p instanceof URL)&&!(p instanceof Uint8Array)&&!(p instanceof ArrayBuffer)&&"type"in p)switch(p.type){case"data":return p.data;case"url":return p.url;case"text":return p.text;default:return""}return p})();return c instanceof URL?{type:"uri",modality:j(e.mediaType),mime_type:(s=e.mediaType)!=null?s:null,uri:c.toString()}:typeof c=="string"?c.startsWith("http://")||c.startsWith("https://")?{type:"uri",modality:j(e.mediaType),mime_type:(i=e.mediaType)!=null?i:null,uri:c}:{type:"blob",modality:j(e.mediaType),mime_type:(u=e.mediaType)!=null?u:null,content:c}:{type:"blob",modality:j(e.mediaType),mime_type:(d=e.mediaType)!=null?d:null,content:St(c)}}default:return{type:String(e.type)}}})};if(t.role==="assistant")return typeof t.content=="string"?{role:"assistant",parts:[{type:"text",content:t.content}]}:{role:"assistant",parts:t.content.map(e=>{var n,o;switch(e.type){case"text":return{type:"text",content:e.text};case"reasoning":return{type:"reasoning",content:e.text};case"tool-call":return{type:"tool_call",id:(n=e.toolCallId)!=null?n:null,name:e.toolName,arguments:e.input};case"tool-result":{const r=e.output;let a;return r&&(r.type==="text"||r.type==="error-text"||r.type==="json"||r.type==="error-json"?a=r.value:r.type==="execution-denied"?a={denied:!0,reason:r.reason}:a=r),{type:"tool_call_response",id:(o=e.toolCallId)!=null?o:null,response:a}}default:return{type:String(e.type)}}})};if(t.role==="tool")return{role:"tool",parts:t.content.map(e=>{var n;if(e.type==="tool-result"){const o=e.output;let r;return o&&(o.type==="text"||o.type==="error-text"||o.type==="json"||o.type==="error-json"?r=o.value:o.type==="execution-denied"?r={denied:!0,reason:o.reason}:r=o),{type:"tool_call_response",id:(n=e.toolCallId)!=null?n:null,response:r}}return{type:String(e.type)}})}}}function Nt({text:t,reasoning:e,toolCalls:n,files:o,finishReason:r}){const a=[];if(e)for(const s of e)"text"in s&&s.text&&a.push({type:"reasoning",content:s.text});if(t!=null&&t.length>0&&a.push({type:"text",content:t}),n)for(const s of n)a.push({type:"tool_call",id:s.toolCallId,name:s.toolName,arguments:s.input});if(o)for(const s of o)a.push({type:"blob",modality:j(s.mediaType),mime_type:s.mediaType,content:s.base64});return[{role:"assistant",parts:a,finish_reason:Pt(r)}]}function $t({objectText:t,finishReason:e}){return[{role:"assistant",parts:[{type:"text",content:t}],finish_reason:Pt(e)}]}function Pt(t){var e;return(e={stop:"stop",length:"length","content-filter":"content_filter","tool-calls":"tool_call",error:"error",other:"stop",unknown:"stop"}[t])!=null?e:t}function L(t,e){e instanceof Error?(t.recordException({name:e.name,message:e.message,stack:e.stack}),t.setStatus({code:_t.ERROR,message:e.message})):t.setStatus({code:_t.ERROR})}function Je(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function lt(t){if(!Array.isArray(t))return t;const e=new Set(t.filter(Je).map(o=>typeof o));if(e.size!==1)return;const[n]=e;return n==="string"?t.filter(o=>typeof o=="string"):n==="number"?t.filter(o=>typeof o=="number"):t.filter(o=>typeof o=="boolean")}function Fe(t){const e={};for(const[n,o]of Object.entries(t??{})){if(o==null)continue;const r=lt(o);r!=null&&(e[n]=r)}return e}function Le(t){return t?.isEnabled!==!1}function h(t,e){if(!Le(t))return{};const n={};for(const[o,r]of Object.entries(e)){if(r==null)continue;if(typeof r=="object"&&"input"in r&&typeof r.input=="function"){if(t?.recordInputs===!1)continue;const s=r.input();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}if(typeof r=="object"&&"output"in r&&typeof r.output=="function"){if(t?.recordOutputs===!1)continue;const s=r.output();if(s!=null){const i=lt(s);i!=null&&(n[o]=i)}continue}const a=lt(r);a!=null&&(n[o]=a)}return n}var Ue={usage:!1,providerMetadata:!1,embedding:!1,reranking:!1,runtimeContext:!1,headers:!1,toolChoice:!1,schema:!1};function Ke(t){var e,n,o,r,a,s,i,u;return{...Ue,usage:(e=t.usage)!=null?e:!1,providerMetadata:(n=t.providerMetadata)!=null?n:!1,embedding:(o=t.embedding)!=null?o:!1,reranking:(r=t.reranking)!=null?r:!1,runtimeContext:(a=t.runtimeContext)!=null?a:!1,headers:(s=t.headers)!=null?s:!1,toolChoice:(i=t.toolChoice)!=null?i:!1,schema:(u=t.schema)!=null?u:!1}}function Be(t){const e={};for(const[n,o]of Object.entries(t??{}))Dt(e,`ai.settings.context.${n}`,o);return e}function Dt(t,e,n){if(n!=null){if(Array.isArray(n)||typeof n!="object"){t[e]=n;return}for(const[o,r]of Object.entries(n))Dt(t,`${e}.${o}`,r)}}function ut(t){return Object.fromEntries(Object.entries(t??{}).filter(([,e])=>e!=null).map(([e,n])=>[`ai.request.headers.${e}`,n]))}function V(t){var e,n,o;return{"ai.usage.inputTokenDetails.noCacheTokens":(e=t.inputTokenDetails)==null?void 0:e.noCacheTokens,"ai.usage.outputTokenDetails.textTokens":(n=t.outputTokenDetails)==null?void 0:n.textTokens,"ai.usage.outputTokenDetails.reasoningTokens":(o=t.outputTokenDetails)==null?void 0:o.reasoningTokens}}function S(t,e,n){const o={};for(const[r,a]of Object.entries(n))!e[r]||a==null||Object.assign(o,h(t,a));return o}function pt(t){return t==null?void 0:t/1e3}function ze(t){var e;return{"gen_ai.client.operation.duration":pt(t.responseTimeMs),"gen_ai.client.operation.time_to_first_chunk":pt(t.timeToFirstOutputMs),"gen_ai.client.operation.time_per_output_chunk":pt((e=t.timeBetweenOutputChunksMs)==null?void 0:e.avg)}}var Qe=class{constructor(t={}){this.callStates=new Map;var e;this.tracer=(e=t.tracer)!=null?e:v.getTracer("gen_ai"),this.supplementalAttributes=Ke(t),this.enrichSpan=t.enrichSpan}getCallState(t){return this.callStates.get(t)}cleanupCallState(t){this.callStates.delete(t)}getSpanAttributes({attributes:t,spanType:e,operationId:n,callId:o,runtimeContext:r}){var a;let s;try{s=(a=this.enrichSpan)==null?void 0:a.call(this,{spanType:e,operationId:n,callId:o,runtimeContext:r})}catch{s=void 0}return{...Fe(s),...t}}executeTool({callId:t,toolCallId:e,execute:n}){var o;const r=(o=this.getCallState(t))==null?void 0:o.toolSpans.get(e);return r==null?n():T.with(r.context,n)}executeLanguageModelCall({callId:t,execute:e}){var n;const o=this.getCallState(t),r=(n=o?.inferenceContext)!=null?n:o?.stepContext;return r==null?e():T.with(r,e)}onStart(t){if(t.operationId==="ai.embed"||t.operationId==="ai.embedMany"){this.onEmbedOperationStart(t);return}if(t.operationId==="ai.rerank"){this.onRerankOperationStart(t);return}if(t.operationId==="ai.generateObject"||t.operationId==="ai.streamObject"){this.onObjectOperationStart(t);return}this.onGenerateStart(t)}onGenerateStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,stopSequences:t.stopSequences,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=t.runtimeContext,i=S(n,this.supplementalAttributes,{runtimeContext:Be(s),headers:ut(t.headers)}),u=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.stop_sequences":t.stopSequences,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.instructions?{input:()=>JSON.stringify(jt(t.instructions))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:void 0,messages:t.messages}))},...i}),d=`${a} ${t.modelId}`,p=this.tracer.startSpan(d,{attributes:this.getSpanAttributes({attributes:u,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:s}),kind:x.INTERNAL}),c=v.setSpan(T.active(),p);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:p,rootContext:c,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:s,baseSupplementalAttributes:i})}onObjectOperationStart(t){var e;const n={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},o={maxOutputTokens:t.maxOutputTokens,temperature:t.temperature,topP:t.topP,topK:t.topK,presencePenalty:t.presencePenalty,frequencyPenalty:t.frequencyPenalty,seed:t.seed,maxRetries:t.maxRetries},r=R(t.provider),a=Rt(t.operationId),s=S(n,this.supplementalAttributes,{headers:ut(t.headers)}),i=h(n,{"gen_ai.operation.name":a,"gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.agent.name":n.functionId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":t.frequencyPenalty,"gen_ai.request.max_tokens":t.maxOutputTokens,"gen_ai.request.presence_penalty":t.presencePenalty,"gen_ai.request.temperature":(e=t.temperature)!=null?e:void 0,"gen_ai.request.top_k":t.topK,"gen_ai.request.top_p":t.topP,"gen_ai.request.seed":t.seed,"gen_ai.system_instructions":t.system?{input:()=>JSON.stringify(jt(t.system))}:void 0,"gen_ai.input.messages":{input:()=>JSON.stringify(vt({prompt:t.prompt,messages:t.messages}))},...s,...S(n,this.supplementalAttributes,{schema:{"ai.schema":t.schema?{input:()=>JSON.stringify(t.schema)}:void 0,"ai.schema.name":t.schemaName,"ai.schema.description":t.schemaDescription,"ai.settings.output":t.output}})}),u=`${a} ${t.modelId}`,d=this.tracer.startSpan(u,{attributes:this.getSpanAttributes({attributes:i,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.INTERNAL}),p=v.setSpan(T.active(),d);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:n,rootSpan:d,rootContext:p,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:o,provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:s})}onObjectStepStart(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan||!n.rootContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.output.type":"json","gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>t.promptMessages?JSON.stringify(We(t.promptMessages)):void 0},...n.baseSupplementalAttributes}),s=`chat ${t.modelId}`;n.inferenceSpan=this.tracer.startSpan(s,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.rootContext),n.inferenceContext=v.setSpan(n.rootContext,n.inferenceSpan)}onObjectStepEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.inferenceSpan)return;const{telemetry:o}=n;n.inferenceSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.response.id,"gen_ai.response.model":t.response.modelId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>{try{return JSON.stringify($t({objectText:t.objectText,finishReason:t.finishReason}))}catch{return t.objectText}}},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.inferenceSpan.end(),n.inferenceSpan=void 0,n.inferenceContext=void 0}onEmbedOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=t.value,a=t.operationId==="ai.embedMany",s=h(e,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{embedding:a?{"ai.values":{input:()=>r.map(p=>JSON.stringify(p))}}:{"ai.value":{input:()=>JSON.stringify(r)}}})}),i=`embeddings ${t.modelId}`,u=this.tracer.startSpan(i,{attributes:this.getSpanAttributes({attributes:s,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),d=v.setSpan(T.active(),u);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:u,rootContext:d,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onStepStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e;e.runtimeContext=t.runtimeContext;const o=h(n,{"gen_ai.operation.name":"agent_step",...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{toolChoice:{"ai.prompt.toolChoice":{input:()=>t.stepToolChoice!=null?JSON.stringify(t.stepToolChoice):void 0}}})});e.stepSpan=this.tracer.startSpan(`step ${t.steps.length+1}`,{attributes:this.getSpanAttributes({attributes:o,spanType:"step",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.rootContext),e.stepContext=v.setSpan(e.rootContext,e.stepSpan)}onLanguageModelCallStart(t){var e;const n=this.getCallState(t.callId);if(!n?.stepContext)return;const{telemetry:o}=n,r=R(t.provider),a=h(o,{"gen_ai.operation.name":"chat","gen_ai.provider.name":r,"gen_ai.request.model":t.modelId,"gen_ai.request.frequency_penalty":n.settings.frequencyPenalty,"gen_ai.request.max_tokens":n.settings.maxOutputTokens,"gen_ai.request.presence_penalty":n.settings.presencePenalty,"gen_ai.request.stop_sequences":n.settings.stopSequences,"gen_ai.request.temperature":(e=n.settings.temperature)!=null?e:void 0,"gen_ai.request.top_k":n.settings.topK,"gen_ai.request.top_p":n.settings.topP,"gen_ai.input.messages":{input:()=>{const s=vt({prompt:void 0,messages:t.messages});return s.length>0?JSON.stringify(s):void 0}},"gen_ai.tool.definitions":{input:()=>t.tools?JSON.stringify(t.tools):void 0}});n.inferenceSpan=this.tracer.startSpan(`chat ${t.modelId}`,{attributes:this.getSpanAttributes({attributes:a,spanType:"languageModel",operationId:n.operationId,callId:t.callId,runtimeContext:n.runtimeContext}),kind:x.CLIENT},n.stepContext),n.inferenceContext=v.setSpan(n.stepContext,n.inferenceSpan)}onLanguageModelCallEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.inferenceSpan)return;const{telemetry:r}=o;o.inferenceSpan.setAttributes(h(r,{...ze(t.performance),"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.response.id":t.responseId,"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>JSON.stringify(Nt({text:t.content.filter(a=>a.type==="text").map(a=>a.text).join("")||void 0,reasoning:t.content.filter(a=>a.type==="reasoning"),toolCalls:t.content.filter(a=>a.type==="tool-call"),files:t.content.filter(a=>a.type==="file").map(a=>a.file),finishReason:t.finishReason}))},...S(r,this.supplementalAttributes,{usage:V(t.usage)})})),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0}onToolExecutionStart(t){const e=this.getCallState(t.callId);if(!e?.stepContext)return;const{telemetry:n}=e,{toolCall:o}=t,r=h(n,{"gen_ai.operation.name":"execute_tool","gen_ai.tool.name":o.toolName,"gen_ai.tool.call.id":o.toolCallId,"gen_ai.tool.type":"function","gen_ai.tool.call.arguments":{input:()=>JSON.stringify(o.input)}}),a=`execute_tool ${o.toolName}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"tool",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.INTERNAL},e.stepContext),i=v.setSpan(e.stepContext,s);e.toolSpans.set(o.toolCallId,{span:s,context:i})}onToolExecutionEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.toolSpans.get(t.toolCall.toolCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e,{toolOutput:a}=t;if(o.setAttributes(h(r,{"gen_ai.execute_tool.duration":pt(t.toolExecutionMs)})),a.type==="tool-result")try{o.setAttributes(h(r,{"gen_ai.tool.call.result":{output:()=>JSON.stringify(a.output)}}))}catch{}else L(o,a.error);o.end(),e.toolSpans.delete(t.toolCall.toolCallId)}onStepEnd(t){const e=this.getCallState(t.callId);if(!e?.stepSpan)return;const{telemetry:n}=e;e.stepSpan.setAttributes(S(n,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})),e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0}onStepFinish(t){this.onStepEnd(t)}onEnd(t){const e=this.getCallState(t.callId);if(e?.rootSpan){if(e.operationId==="ai.embed"||e.operationId==="ai.embedMany"){this.onEmbedOperationEnd(t);return}if(e.operationId==="ai.rerank"){this.onRerankOperationEnd(t);return}if(e.operationId==="ai.generateObject"||e.operationId==="ai.streamObject"){this.onObjectOperationEnd(t);return}this.onGenerateEnd(t)}}onGenerateEnd(t){var e,n;const o=this.getCallState(t.callId);if(!o?.rootSpan)return;const{telemetry:r}=o;o.rootSpan.setAttributes(h(r,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.usage.cache_creation.input_tokens":(n=t.usage.inputTokenDetails)==null?void 0:n.cacheWriteTokens,"gen_ai.output.messages":{output:()=>{var a;return JSON.stringify(Nt({text:(a=t.text)!=null?a:void 0,reasoning:t.finalStep.reasoning,toolCalls:t.toolCalls,files:t.files,finishReason:t.finishReason}))}},...S(r,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.finalStep.providerMetadata?JSON.stringify(t.finalStep.providerMetadata):void 0},usage:V(t.usage)})})),o.rootSpan.end(),this.cleanupCallState(t.callId)}onObjectOperationEnd(t){var e;const n=this.getCallState(t.callId);if(!n?.rootSpan)return;const{telemetry:o}=n;n.rootSpan.setAttributes(h(o,{"gen_ai.response.finish_reasons":[t.finishReason],"gen_ai.usage.input_tokens":t.usage.inputTokens,"gen_ai.usage.output_tokens":t.usage.outputTokens,"gen_ai.usage.cache_read.input_tokens":(e=t.usage.inputTokenDetails)==null?void 0:e.cacheReadTokens,"gen_ai.output.messages":{output:()=>t.object!=null?JSON.stringify($t({objectText:JSON.stringify(t.object),finishReason:t.finishReason})):void 0},...S(o,this.supplementalAttributes,{providerMetadata:{"ai.response.providerMetadata":t.providerMetadata?JSON.stringify(t.providerMetadata):void 0},usage:V(t.usage)})})),n.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedOperationEnd(t){const e=this.getCallState(t.callId);if(!e?.rootSpan)return;const{telemetry:n}=e,o=e.operationId==="ai.embedMany";e.rootSpan.setAttributes(h(n,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(n,this.supplementalAttributes,{embedding:o?{"ai.embeddings":{output:()=>t.embedding.map(r=>JSON.stringify(r))}}:{"ai.embedding":{output:()=>JSON.stringify(t.embedding)}}})})),e.rootSpan.end(),this.cleanupCallState(t.callId)}onEmbedStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"embeddings","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{embedding:{"ai.values":{input:()=>t.values.map(u=>JSON.stringify(u))}}})}),a=`embeddings ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"embedding",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.embedSpans.set(t.embedCallId,{span:s,context:i})}onEmbedEnd(t){const e=this.getCallState(t.callId);if(!e)return;const n=e.embedSpans.get(t.embedCallId);if(!n)return;const{span:o}=n,{telemetry:r}=e;o.setAttributes(h(r,{"gen_ai.usage.input_tokens":t.usage.tokens,...S(r,this.supplementalAttributes,{embedding:{"ai.embeddings":{output:()=>t.embeddings.map(a=>JSON.stringify(a))}}})})),o.end(),e.embedSpans.delete(t.embedCallId)}onRerankOperationStart(t){const e={recordInputs:t.recordInputs,recordOutputs:t.recordOutputs,functionId:t.functionId},n=R(t.provider),o=S(e,this.supplementalAttributes,{headers:ut(t.headers)}),r=h(e,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":n,"gen_ai.request.model":t.modelId,...o,...S(e,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${t.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"operation",operationId:t.operationId,callId:t.callId,runtimeContext:void 0}),kind:x.CLIENT}),i=v.setSpan(T.active(),s);this.callStates.set(t.callId,{operationId:t.operationId,telemetry:e,rootSpan:s,rootContext:i,stepSpan:void 0,stepContext:void 0,inferenceSpan:void 0,inferenceContext:void 0,embedSpans:new Map,rerankSpan:void 0,toolSpans:new Map,settings:{maxRetries:t.maxRetries},provider:t.provider,modelId:t.modelId,runtimeContext:void 0,baseSupplementalAttributes:o})}onRerankOperationEnd(t){const e=this.getCallState(t.callId);e?.rootSpan&&(e.rootSpan.end(),this.cleanupCallState(t.callId))}onRerankStart(t){const e=this.getCallState(t.callId);if(!e?.rootSpan||!e.rootContext)return;const{telemetry:n}=e,o=R(e.provider),r=h(n,{"gen_ai.operation.name":"rerank","gen_ai.provider.name":o,"gen_ai.request.model":e.modelId,...e.baseSupplementalAttributes,...S(n,this.supplementalAttributes,{reranking:{"ai.documents":{input:()=>t.documents.map(u=>JSON.stringify(u))}}})}),a=`rerank ${e.modelId}`,s=this.tracer.startSpan(a,{attributes:this.getSpanAttributes({attributes:r,spanType:"reranking",operationId:e.operationId,callId:t.callId,runtimeContext:e.runtimeContext}),kind:x.CLIENT},e.rootContext),i=v.setSpan(e.rootContext,s);e.rerankSpan={span:s,context:i}}onRerankEnd(t){const e=this.getCallState(t.callId);if(!e?.rerankSpan)return;const{span:n}=e.rerankSpan,{telemetry:o}=e;n.setAttributes(S(o,this.supplementalAttributes,{reranking:{"ai.ranking.type":t.documentsType,"ai.ranking":{output:()=>t.ranking.map(r=>JSON.stringify(r))}}})),n.end(),e.rerankSpan=void 0}onAbort(t){const e=this.getCallState(t.callId);if(e?.rootSpan){for(const{span:n}of e.toolSpans.values())n.end();e.toolSpans.clear(),e.inferenceSpan&&(e.inferenceSpan.end(),e.inferenceSpan=void 0,e.inferenceContext=void 0),e.stepSpan&&(e.stepSpan.end(),e.stepSpan=void 0,e.stepContext=void 0);for(const{span:n}of e.embedSpans.values())n.end();e.embedSpans.clear(),e.rerankSpan&&(e.rerankSpan.span.end(),e.rerankSpan=void 0),e.rootSpan.end(),this.cleanupCallState(t.callId)}}onError(t){var e;const n=t;if(!n?.callId)return;const o=this.getCallState(n.callId);if(!o?.rootSpan)return;const r=(e=n.error)!=null?e:t;for(const{span:a}of o.toolSpans.values())L(a,r),a.end();o.toolSpans.clear(),o.inferenceSpan&&(L(o.inferenceSpan,r),o.inferenceSpan.end(),o.inferenceSpan=void 0,o.inferenceContext=void 0),o.stepSpan&&(L(o.stepSpan,r),o.stepSpan.end(),o.stepSpan=void 0,o.stepContext=void 0);for(const{span:a}of o.embedSpans.values())L(a,r),a.end();o.embedSpans.clear(),o.rerankSpan&&(L(o.rerankSpan.span,r),o.rerankSpan.span.end(),o.rerankSpan=void 0),L(o.rootSpan,r),o.rootSpan.end(),this.cleanupCallState(n.callId)}};function Ge(t){return pe({messages:t,emptyMessages:"remove",reasoning:"none",toolCalls:`before-last-${Gt}-messages`})}function He(t){return typeof t=="object"&&t!==null&&"role"in t&&"content"in t}function Ve(t){return Array.isArray(t)&&t.every(He)}function Ye(t,{conversationId:e,getModel:n}){let o=0;const r=()=>{const a=n?.();return a?{model_provider:a.provider,model_id:a.modelId}:{}};return{onStepStart:()=>{o+=1},onToolExecutionStart:a=>{t("com.redocly.aiChat.toolCallStarted",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,...r()}])},onToolExecutionEnd:a=>{const s=a.toolOutput.type==="tool-error";t("com.redocly.aiChat.toolCallFinished",[{conversation_id:e,...rt("toolCall",a.toolCall.toolCallId,"ai"),tool_name:a.toolCall.toolName,input:a.toolCall.input,step_number:o,success:!s,duration_ms:a.toolExecutionMs,...r(),...s&&{error:a.toolOutput.error instanceof Error?a.toolOutput.error.message:String(a.toolOutput.error)}}])},onStart:a=>{o=0,t("com.redocly.aiChat.conversationStarted",[{...rt("conversation",e,"ai"),model_provider:"provider"in a?a.provider:"unknown",model_id:"modelId"in a?a.modelId:"unknown"}])},onEnd:a=>{if(!("steps"in a))return;const s=a.usage;t("com.redocly.aiChat.conversationFinished",[{...rt("conversation",e,"ai"),model_provider:a.model.provider,model_id:a.model.modelId,success:!0,step_count:a.steps.length,finish_reason:a.finishReason,input_tokens:s.inputTokens,output_tokens:s.outputTokens,total_tokens:s.totalTokens}])}}}function Xe(t,e){const n=()=>v.getSpan(T.active())?T.active():e;return{startSpan:(o,r,a)=>t.startSpan(o,r,a??e),startActiveSpan:((o,r,a,s)=>{if(typeof r=="function")return t.startActiveSpan(o,{},n(),r);if(typeof a=="function")return t.startActiveSpan(o,r,n(),a);if(s)return t.startActiveSpan(o,r,a,s);throw new Error("withParentContext: invalid startActiveSpan invocation")})}}const Ze=`You are a helpful assistant that can generate titles for conversations.
2
2
 
3
3
  ## Rules
4
4
  - Titles should be at most 30 characters.
@@ -1 +1 @@
1
- import{c as o,a as m,d as y}from"./redocly-openapi-docs.min.ai-chat-mappers-CmX-8902.js";import{a as h,b as r,c as d}from"./redocly-openapi-docs.min.ai-message-parts.schema-C7fjQhYX.js";import{a as c,e as a,b as g}from"./redocly-openapi-docs.min.indexes-Bp4ld5gB.js";const u={orderBy:[c(r.createdAt),c(r.indexWithinInsertBatch)],with:{parts:{orderBy:[c(h.index)]}}};class b{constructor(t){this.sqliteDB=t}sqliteDB;async findAll(){return await this.initialize(),(await this.db.query.aiChats.findMany({with:{messages:u}})).map(o)}async findRecentChatsPage(t){await this.initialize();const i=t.limit+1,s=await this.db.query.aiChats.findMany({orderBy:(l,{desc:w})=>w(l.updatedAt),limit:i,offset:t.offset}),e=s.slice(0,t.limit),n=s.length>t.limit,f=t.offset+e.length;return{items:e.map(l=>{const w={...l,messages:[]};return o(w)}),hasMore:n,nextOffset:f}}async findOne(t){await this.initialize();const i=await this.db.query.aiChats.findFirst({where:a(d.id,t),with:{messages:u}});return i&&o(i)}async upsert(t){await this.initialize();const i=m(t);await this.db.query.aiChats.findFirst({where:a(d.id,i.id),columns:{id:!0}})?await this.db.update(d).set(i).where(a(d.id,i.id)):await this.db.insert(d).values(i);for(let s=0;s<t.messages.length;s++)await this.upsertMessageRowAndParts(t.id,s,t.messages[s])}async remove(t){await this.initialize(),await this.db.delete(d).where(a(d.id,t))}async upsertMessageRowAndParts(t,i,s){const e=await this.db.query.aiMessages.findFirst({where:g(a(r.aiChatId,t),a(r.uiId,s.id))}),n=y(t,i,s,e?.id);e?await this.db.update(r).set({...n,indexWithinInsertBatch:e.indexWithinInsertBatch}).where(a(r.id,e.id)):await this.db.insert(r).values(n),await this.db.delete(h).where(a(h.aiMessageId,n.id)),n.parts.length>0&&await this.db.insert(h).values(n.parts)}get db(){return this.sqliteDB.db}async initialize(){await this.sqliteDB.initialize()}}export{b as AiChatSqliteDBStorage};
1
+ import{c as o,a as m,d as y}from"./redocly-openapi-docs.min.ai-chat-mappers-Dg8U8w8r.js";import{a as h,b as r,c as d}from"./redocly-openapi-docs.min.ai-message-parts.schema-C7fjQhYX.js";import{a as c,e as a,b as g}from"./redocly-openapi-docs.min.indexes-Bp4ld5gB.js";const u={orderBy:[c(r.createdAt),c(r.indexWithinInsertBatch)],with:{parts:{orderBy:[c(h.index)]}}};class b{constructor(t){this.sqliteDB=t}sqliteDB;async findAll(){return await this.initialize(),(await this.db.query.aiChats.findMany({with:{messages:u}})).map(o)}async findRecentChatsPage(t){await this.initialize();const i=t.limit+1,s=await this.db.query.aiChats.findMany({orderBy:(l,{desc:w})=>w(l.updatedAt),limit:i,offset:t.offset}),e=s.slice(0,t.limit),n=s.length>t.limit,f=t.offset+e.length;return{items:e.map(l=>{const w={...l,messages:[]};return o(w)}),hasMore:n,nextOffset:f}}async findOne(t){await this.initialize();const i=await this.db.query.aiChats.findFirst({where:a(d.id,t),with:{messages:u}});return i&&o(i)}async upsert(t){await this.initialize();const i=m(t);await this.db.query.aiChats.findFirst({where:a(d.id,i.id),columns:{id:!0}})?await this.db.update(d).set(i).where(a(d.id,i.id)):await this.db.insert(d).values(i);for(let s=0;s<t.messages.length;s++)await this.upsertMessageRowAndParts(t.id,s,t.messages[s])}async remove(t){await this.initialize(),await this.db.delete(d).where(a(d.id,t))}async upsertMessageRowAndParts(t,i,s){const e=await this.db.query.aiMessages.findFirst({where:g(a(r.aiChatId,t),a(r.uiId,s.id))}),n=y(t,i,s,e?.id);e?await this.db.update(r).set({...n,indexWithinInsertBatch:e.indexWithinInsertBatch}).where(a(r.id,e.id)):await this.db.insert(r).values(n),await this.db.delete(h).where(a(h.aiMessageId,n.id)),n.parts.length>0&&await this.db.insert(h).values(n.parts)}get db(){return this.sqliteDB.db}async initialize(){await this.sqliteDB.initialize()}}export{b as AiChatSqliteDBStorage};
@@ -1,4 +1,4 @@
1
- import{g as q,a as l,j as r,h as ae,B as _,r as h,f as ct,z as dt,ad as ut,Z as pt,$ as ft,a0 as ye,x as ht,az as xt,aA as gt,ac as E,a8 as U,e as mt}from"./redocly-openapi-docs.min.standalone-BPCdJgtH.js";import{f as J,M as we,N as vt,e as yt,q as je,m as wt,n as jt,O as bt,Q as Ct,U as se,V as le,W as kt,X as It,Y as F,Z as ce,_ as Tt,$ as _t,a0 as be,a1 as St,a2 as At,R as de,a3 as Ot,a4 as ue,a5 as Ce,t as ke,a6 as pe,a7 as L,a8 as Bt,a9 as Vt,aa as zt,ab as Mt,ac as $t}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{B as Ft,C as Rt,E as Et,F as Lt,G as Nt,H as Dt,I as Pt,J as Ie,K as k,L as Te,M as Ut,N as Ht,O as H,P as Gt,Q as Kt,R as Wt,S as V,U as Zt,V as N}from"./redocly-openapi-docs.min.useAiChatQueries-t8oy8jik.js";import{g as _e}from"./redocly-openapi-docs.min.SemanticSearchService-DNFOPBZK.js";function Q(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Yt=45e3,qt=e=>r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M12 7.5H4V8.5H12V7.5Z"})}),Jt=l(qt).attrs({"data-component-name":"icons/SubtractIcon/SubtractIcon"})`
1
+ import{g as q,a as l,j as r,h as ae,B as _,r as h,f as ct,z as dt,ad as ut,Z as pt,$ as ft,a0 as ye,x as ht,az as xt,aA as gt,ac as E,a8 as U,e as mt}from"./redocly-openapi-docs.min.standalone-D9becCWS.js";import{f as J,O as we,Q as vt,e as yt,q as je,m as wt,n as jt,U as bt,E as Ct,V as se,W as le,X as kt,Y as It,Z as F,_ as ce,$ as Tt,a0 as _t,a1 as be,a2 as St,a3 as At,R as de,a4 as Ot,a5 as ue,a6 as Ce,t as ke,a7 as pe,a8 as L,a9 as Bt,aa as Vt,ab as zt,ac as Mt,ad as $t}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{B as Ft,C as Rt,E as Et,F as Lt,G as Nt,H as Dt,I as Pt,J as Ie,K as k,L as Te,M as Ut,N as Ht,O as H,P as Gt,Q as Kt,R as Wt,S as V,U as Zt,V as N}from"./redocly-openapi-docs.min.useAiChatQueries-Cb-1pa0w.js";import{g as _e}from"./redocly-openapi-docs.min.SemanticSearchService-DbpnWseN.js";function Q(e){return e.charAt(0).toUpperCase()+e.slice(1)}const Yt=45e3,qt=e=>r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e,children:r.jsx("path",{d:"M12 7.5H4V8.5H12V7.5Z"})}),Jt=l(qt).attrs({"data-component-name":"icons/SubtractIcon/SubtractIcon"})`
2
2
  path {
3
3
  fill: ${({color:e})=>q(e)};
4
4
  }
@@ -0,0 +1 @@
1
+ import{z as v,B as y,P as m,C as f,E as x,F}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{g as E}from"./redocly-openapi-docs.min.SemanticSearchService-DbpnWseN.js";var w;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(w||(w={}));async function _(r,t){await v("plugin:event|unlisten",{event:r,eventId:t})}async function C(r,t,i){var e;const a=(e=void 0)!==null&&e!==void 0?e:{kind:"Any"};return v("plugin:event|listen",{event:r,target:a,handler:y(t)}).then(s=>async()=>_(r,s))}const c="replay-environments.yaml";class A{constructor(t,i,e,a){this.storage=t,this.state=i,this.projectDir=e,this.aiEnabled=a}storage;state;projectDir;aiEnabled;watchPath=null;unlistenEvent=null;get tauriStorage(){return this.storage}indexApis(t){!this.aiEnabled||t.length===0||E().indexApis(t).catch(i=>console.error("Semantic index (apis):",i))}indexCollections(t){!this.aiEnabled||t.length===0||E().indexCollections(t).catch(i=>console.error("Semantic index (collections):",i))}removeApis(t){if(!this.aiEnabled||t.length===0)return;const i=E();Promise.all(t.map(e=>i.removeApi(e))).catch(e=>console.error("Semantic remove (apis):",e))}removeCollections(t){if(!this.aiEnabled||t.length===0)return;const i=E();Promise.all(t.map(e=>i.removeCollection(e))).catch(e=>console.error("Semantic remove (collections):",e))}async start(){if(this.watchPath){console.warn("Watcher already started for:",this.watchPath);return}try{this.unlistenEvent=await C("fs-watch-event",async t=>{const i=t.payload;try{await this.handleEvent(i)}catch(e){console.error("Error handling file change:",e)}}),await v("fs_watch",{path:this.projectDir,options:{recursive:!0,delayMs:500}}),this.watchPath=this.projectDir}catch(t){throw console.error("Failed to start file watcher:",t),this.unlistenEvent&&(this.unlistenEvent(),this.unlistenEvent=null),t}}async stop(){if(this.watchPath)try{await v("fs_unwatch",{path:this.watchPath})}catch(t){console.error("Error stopping file watcher:",t)}finally{this.unlistenEvent&&(this.unlistenEvent(),this.unlistenEvent=null),this.watchPath=null}}async handleEvent(t){const{changeType:i,paths:e,pathTypes:a,type:s}=t;if(await this.isProjectFolderRemoved(e,i)){await this.handleProjectFolderRemoval();return}const o=this.filterSpecFiles(e,a);if(o.paths.length===0)return;const n=await this.toFileEntries(o.paths,o.pathTypes);switch(i){case"changed":(s.includes("Data")||s.includes("Name"))&&await this.handleModify(n);break;case"added":await this.handleCreate(n);break;case"deleted":await this.handleDelete(n);break;case"renamed":await this.handleRename(n);break;default:console.log("Unhandled change type:",i)}}filterSpecFiles(t,i){const e=[],a=[];for(let s=0;s<t.length;s++){const o=t[s],n=o.split(".").pop()?.toLowerCase();n&&["yaml","yml","json"].includes(n)&&(e.push(o),a.push(i[s]||"unknown"))}return{paths:e,pathTypes:a}}async toFileEntries(t,i){return Promise.all(t.map(async(e,a)=>({relative_path:await m.relative(this.projectDir,e),absolute_path:e,type:i[a]||"unknown"})))}hasEnvironmentsFileChange(t){return!this.storage.isWatchExcluded(c)&&t.some(i=>i.relative_path===c)}withoutEnvironmentsFile(t){return t.filter(i=>i.relative_path!==c)}consolidateFileEntries(t){const i=[],e=new Set;for(const a of t)e.has(a.relative_path)||(e.add(a.relative_path),this.storage.isWatchExcluded(a.relative_path)||i.push(a));return i}async handleModify(t){const i=this.hasEnvironmentsFileChange(t),e=this.withoutEnvironmentsFile(t),{newApiFiles:a,existingApiFiles:s}=this.categorizeApisFromFiles(e),{newCollectionFiles:o,existingCollectionFiles:n}=this.categorizeCollectionsFromFiles(e),d=await this.findApisToReload(t),h=await this.findCollectionsToReload(t),p=[...a,...o];p.length>0&&await this.handleCreate(p),i&&await this.reloadEnvironments();const u=this.consolidateFileEntries([...s,...d]),g=this.consolidateFileEntries([...n,...h]);await this.reloadApis(u),await this.reloadCollections(g)}async handleCreate(t){this.hasEnvironmentsFileChange(t)&&await this.reloadEnvironments();const i=this.withoutEnvironmentsFile(t),e=i.filter(h=>h.type==="api"),a=i.filter(h=>h.type==="collection"),{newApiFiles:s,existingApiFiles:o}=this.categorizeApisFromFiles(e),{newCollectionFiles:n,existingCollectionFiles:d}=this.categorizeCollectionsFromFiles(a);if(s.length>0||n.length>0){s.forEach(l=>this.storage.addPersistExcludedId(l.relative_path)),n.forEach(l=>this.storage.addPersistExcludedId(l.relative_path));const h=s.length>0?await this.tauriStorage.loadAndParseApis(s,void 0,!0):[],p=n.length>0?await this.tauriStorage.loadAndParseCollections(n,void 0):[],u=h.filter(l=>l!==null),g=p.filter(l=>l!==null);this.state.apis.merge(u),this.state.collections.merge(g),this.indexApis(u),this.indexCollections(g),setTimeout(()=>{s.forEach(l=>this.storage.removePersistExcludedId(l.relative_path)),n.forEach(l=>this.storage.removePersistExcludedId(l.relative_path))},500)}o.length>0&&await this.reloadApis(o),d.length>0&&await this.reloadCollections(d)}categorizeApisFromFiles(t){const i=new Set,e=[],a=[];for(const s of t)i.has(s.relative_path)||(i.add(s.relative_path),this.state.apis.get({noproxy:!0}).some(o=>o.id===s.relative_path)?a.push(s):s.type==="api"&&e.push(s));return{newApiFiles:e,existingApiFiles:a}}categorizeCollectionsFromFiles(t){const i=new Set,e=[],a=[];for(const s of t)i.has(s.relative_path)||(i.add(s.relative_path),this.state.collections.get({noproxy:!0}).some(o=>o.id===s.relative_path)?a.push(s):s.type==="collection"&&e.push(s));return{newCollectionFiles:e,existingCollectionFiles:a}}async handleDelete(t){this.hasEnvironmentsFileChange(t)&&await this.reloadEnvironments();const i=[],e=[];for(const a of this.withoutEnvironmentsFile(t)){this.storage.addPersistExcludedId(a.relative_path);const s=this.state.apis.get({noproxy:!0}).findIndex(n=>n.id===a.relative_path);s>=0&&(this.state.apis[s].set(f),this.tauriStorage.deleteApiFromCache(a.relative_path),i.push(a.relative_path));const o=this.state.collections.get({noproxy:!0}).findIndex(n=>n.id===a.relative_path);o>=0&&(this.state.collections[o].set(f),e.push(a.relative_path)),setTimeout(()=>{this.storage.removePersistExcludedId(a.relative_path)},500)}this.removeApis(i),this.removeCollections(e)}async handleRename(t){if(t.length>=2){const[i,e]=t;await this.handleDelete([i]),await this.handleCreate([e])}else await this.handleCreate(t)}async isProjectFolderRemoved(t,i){if(t.length===0)return!1;if(i==="deleted"||i==="renamed"){for(const e of t)if(e===this.projectDir)return!0}return t.filter(e=>!e.startsWith(this.projectDir+"/")&&e!==this.projectDir).length>0&&i==="renamed"}async handleProjectFolderRemoval(){const t=this.state.apis.get({noproxy:!0}),i=t.map(s=>s.id);t.forEach(s=>{this.storage.addPersistExcludedId(s.id),this.tauriStorage.deleteApiFromCache(s.id)}),this.state.apis.set([]);const e=this.state.collections.get({noproxy:!0}),a=e.map(s=>s.id);e.forEach(s=>{this.storage.addPersistExcludedId(s.id)}),this.state.collections.set([]),setTimeout(()=>{t.forEach(s=>this.storage.removePersistExcludedId(s.id)),e.forEach(s=>this.storage.removePersistExcludedId(s.id))},500),this.removeApis(i),this.removeCollections(a),await this.stop()}async findApisToReload(t){const i=[];return await Promise.all(this.state.apis.map(async e=>{const a=e.fileDependencies?.get({noproxy:!0})??new Set,s=e.get({noproxy:!0}).id,o=t.find(n=>a.has(n.absolute_path));if(!this.storage.isWatchExcluded(s)&&o){const n=await m.join(this.projectDir,s);i.push({relative_path:s,absolute_path:n,type:"api"})}})),i}async findCollectionsToReload(t){const i=[];return await Promise.all(this.state.collections.map(async e=>{const a=e.fileDependencies?.get({noproxy:!0})??new Set,s=e.get({noproxy:!0}).id,o=t.find(n=>a.has(n.absolute_path));if(!this.storage.isWatchExcluded(s)&&o){const n=await m.join(this.projectDir,s);i.push({relative_path:s,absolute_path:n,type:"collection"})}})),i}async reloadEnvironments(){const t=await this.tauriStorage.readEnviroments();this.storage.addPersistExcludedId(c),this.state.environments.set(t.length>0?t:x(F)),this.state.configFileError.set(this.storage.getEnvironmentsConfigError()),setTimeout(()=>{this.storage.removePersistExcludedId(c)},500)}async reloadApis(t){if(t.length===0)return;const i=await this.tauriStorage.loadAndParseApis(t,void 0,!0),e=[];await Promise.all(i.map(async(a,s)=>{if(!a){await this.handleDelete([t[s]]);return}const o=this.state.apis.get({noproxy:!0}).findIndex(n=>n.id===a.id);o>=0?(this.storage.addPersistExcludedId(a.id),this.state.apis[o].set(a),e.push(a),setTimeout(()=>this.storage.removePersistExcludedId(a.id),500)):console.warn("API not found in state after reload:",a.id)})),e.length>0&&this.indexApis(e)}async reloadCollections(t){if(t.length===0)return;const i=await this.tauriStorage.loadAndParseCollections(t,void 0),e=[];await Promise.all(i.map(async(a,s)=>{if(!a){await this.handleDelete([t[s]]);return}const o=this.state.collections.get({noproxy:!0}).findIndex(n=>n.id===a.id);o>=0?(this.storage.addPersistExcludedId(a.id),this.state.collections[o].set(a),e.push(a),setTimeout(()=>this.storage.removePersistExcludedId(a.id),500)):console.warn("Collection not found in state after reload:",a.id)})),e.length>0&&this.indexCollections(e)}}export{A as FileWatcher};
@@ -1 +1 @@
1
- import{z as h,aO as te,aP as ne,aQ as y}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{O as H}from"./redocly-openapi-docs.min.Observable-D6wKbFwB.js";import{p as ie}from"./redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js";function x(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&"raw"in t&&typeof t.raw=="string"?t.raw:String(t)}function w(t){return t.replace(/\s+/g," ").trim()}function b(t){return typeof t=="object"&&t!==null&&"$ref"in t}function _(t){return b(t)?null:t}function N(t){try{return JSON.stringify(t)}catch{return String(t)}}function U(t){let e=`${t.name} (${t.in}`;return t.required&&(e+=", required"),t.type&&(e+=`, ${t.type}`),t.format&&(e+=`, format: ${t.format}`),t.enum&&(e+=`, enum: [${t.enum.join(",")}]`),t.pattern&&(e+=`, pattern: ${t.pattern}`),e+=")",e}function M(t){return t.type?Array.isArray(t.type)?t.type.join("|"):t.type:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":"object"}function oe(t){return t==="querystring"?"query":t==="query"||t==="header"||t==="path"||t==="cookie"?t:"query"}function se(t){const e=t.schema&&!b(t.schema)?t.schema:null,n={name:t.name,in:oe(t.in),required:t.required??!1};return e&&(n.type=M(e),e.format&&(n.format=e.format),e.enum&&(n.enum=e.enum.map(String)),e.pattern&&(n.pattern=e.pattern),e.example!==void 0&&(n.example=String(e.example))),t.description&&(n.description=x(t.description)),t.example!==void 0&&!n.example&&(n.example=String(t.example)),n}function ae(t,e){const n=new Set,o=[],s=i=>{for(const a of i){const r=_(a);if(!r||!r.name)continue;const c=`${r.in}:${r.name}`;n.has(c)||(n.add(c),o.push(se(r)))}};return t.parameters&&s(t.parameters),e.parameters&&s(e.parameters),o}function F(t,e=2,n=0){if(n>=e||!t.properties)return[];const o=new Set(t.required??[]);return Object.entries(t.properties).map(([s,i])=>({name:s,type:M(i),required:o.has(s),readOnly:i.readOnly}))}function E(t){const e=t.components?.securitySchemes;if(!e)return[];const n=[];for(const[o,s]of Object.entries(e)){const i=_(s);i&&n.push(re(o,i))}return n}function re(t,e){const n={schemeName:t,type:e.type};if(e.in&&(n.in=e.in),e.name&&(n.name=e.name),e.scheme&&(n.scheme=e.scheme),e.bearerFormat&&(n.bearerFormat=e.bearerFormat),e.flows){const o=Object.keys(e.flows).filter(i=>e.flows[i]);o.length>0&&(n.flows=o.join(", "));const s=new Set;for(const i of o){const a=e.flows[i];a?.scopes&&Object.keys(a.scopes).forEach(r=>s.add(r))}s.size>0&&(n.scopes=[...s].join(", "))}return n}function ce(t,e,n){const o=t??e;if(!o||n.length===0)return[];const s=new Set;for(const i of o)for(const a of Object.keys(i))s.add(a);return n.filter(i=>s.has(i.schemeName))}function le(t){return t.length===0?"":`Security: ${t.map(e=>{let n=`${e.schemeName} (${e.type}`;return e.scheme&&(n+=`, ${e.scheme}`),e.in&&e.name&&(n+=`, ${e.name} in ${e.in}`),n+=")",n}).join("; ")}.`}const de=["get","put","post","delete","options","head","patch","trace"],ue=["query","x-query"];function pe(t,e){const n=[],o=Object.keys(t.content??{});if(o.length===0)return{textPart:"",schemaJson:"{}",examples:n};const s=o.find(l=>l.includes("json"))??o[0],i=t.content?.[s],a=i?.schema&&!b(i.schema)?i.schema:null,r=(a?F(a):[]).filter(l=>!e.hideReadOnly||!l.readOnly),c=t.required?"required":"optional";let d=`Request body (${s}, ${c})`;if(r.length>0){const l=r.map(u=>`${u.name}: ${u.type}${u.required?" required":""}${u.readOnly?" readOnly":""}`);d+=`: {${l.join(", ")}}`}return i?.example!==void 0&&n.push(N(i.example)),{textPart:d,schemaJson:JSON.stringify(r),examples:n}}function he(t){const e=[],n=[];for(const[o,s]of Object.entries(t)){if(b(s))continue;const i=x(s.description??"");e.push(`${o} ${i}`.trim());const a={statusCode:o};i&&(a.description=i);const r=s.content;if(r){const c=Object.keys(r).find(l=>l.includes("json"))??Object.keys(r)[0],d=r[c]?.schema;if(d&&!b(d)){const l=F(d);l.length>0&&(a.schemaProperties=JSON.stringify(l))}}n.push(a)}return{textParts:e,summaries:n}}function q(t){const{apiId:e,apiTitle:n,path:o,method:s,op:i,pathItem:a,globalSchemes:r,apiSecurity:c}=t,d=i.summary??"",l=x(i.description??""),u=i.operationId??"",p=i.tags??[],g=s.toUpperCase(),m=ae(i,a),f=ce(i.security,c,r),Z=f.length>0?f.map(v=>`api_sec:${e}:${v.schemeName}`):void 0,I=[n,`${g} ${o}`,d,l];u&&I.push(`operationId: ${u}`),p.length>0&&I.push(`Tags: ${p.join(", ")}`),i.deprecated&&I.push("DEPRECATED"),m.length>0&&I.push(`Parameters: ${m.map(U).join(". ")}.`);let z;const S=[],J=i.requestBody;if(J){const v=_(J);if(v){const j=pe(v,{hideReadOnly:g==="POST"||g==="PUT"||g==="PATCH"});j.textPart&&I.push(j.textPart),z=j.schemaJson,S.push(...j.examples)}}const{textParts:C,summaries:T}=he(i.responses??{});C.length>0&&I.push(`Responses: ${C.join(", ")}.`);const D=le(f);D&&I.push(D);const R=`api_op:${e}:${o}:${s}:${u||`${o}-${s}`}`,ee={type:"api_operation",id:R,contentHash:"",title:d||`${g} ${o}`,description:l||void 0,apiId:e,path:o,method:g,operationId:u||void 0,tags:p.length>0?p:void 0,deprecated:i.deprecated||void 0,parameterDetails:m.length>0?m:void 0,requestBodySchema:z,responseSchemas:T.length>0?T:void 0,securitySchemeRefs:Z,examples:S.length>0?S:void 0};return{id:R,text:w(I.filter(Boolean).join(" ")),payload:ee}}function Q(t){const e=t.info?.title??"Untitled API",n=x(t.info?.description??t.info?.summary??""),o=t.id;return{id:`api:${o}`,text:w([e,n].filter(Boolean).join(" ")),payload:{type:"api",id:`api:${o}`,contentHash:"",title:e,description:n||void 0,apiId:o}}}function O(t){const e=[];for(const n of t){e.push(Q(n));const o=n.info?.title??"Untitled API",s=n.id,i=E(n);for(const r of i){const c=`api_sec:${s}:${r.schemeName}`,d=[`${r.schemeName}: type=${r.type}`,r.scheme?`scheme=${r.scheme}`:"",r.in&&r.name?`${r.name} in ${r.in}`:"",r.bearerFormat?`format=${r.bearerFormat}`:"",r.flows?`flows=[${r.flows}]`:"",r.scopes?`scopes=[${r.scopes}]`:""].filter(Boolean).join(" ");e.push({id:c,text:w(`${o} Authentication. ${r.schemeName}. ${d}.`),payload:{type:"api_security",id:c,contentHash:"",title:`${o} \u2014 ${r.schemeName}`,apiId:s,securityScheme:r}})}const a=n.paths??{};for(const[r,c]of Object.entries(a)){if(!c||typeof c!="object")continue;const d=[...de.filter(u=>u in c),...ue.filter(u=>u in c)];for(const u of d){const p=c[u];!p||typeof p!="object"||e.push(q({apiId:s,apiTitle:o,path:r,method:u,op:p,pathItem:c,globalSchemes:i,apiSecurity:n.security}))}const l=c.additionalOperations;if(l&&typeof l=="object")for(const[u,p]of Object.entries(l))!p||typeof p!="object"||e.push(q({apiId:s,apiTitle:o,path:r,method:u,op:p,pathItem:c,globalSchemes:i,apiSecurity:n.security}))}}return e}function me(t){const e=[],n=[{list:t.queryParameters,loc:"query"},{list:t.headers,loc:"header"},{list:t.cookies,loc:"cookie"},{list:t.pathParameters,loc:"path"}];for(const{list:o,loc:s}of n)for(const i of o)if("key"in i){const a=i;e.push({name:a.key,in:s,required:!1})}return e}function L(t){const e=t.id,n=t.info?.title??"Untitled Collection",o=x(t.info?.description??t.info?.summary??"");return{id:`collection:${e}`,text:w([n,o].filter(Boolean).join(" ")),payload:{type:"collection",id:`collection:${e}`,contentHash:"",title:n,description:o||void 0,collectionId:e}}}function W(t){const{collectionId:e,collectionTitle:n,workflow:o}=t,s=o.workflowId??"",i=o.summary??s,a=x(o.description??""),r=[n,i,a];if(o.inputs&&r.push(`Inputs schema: ${N(o.inputs)}`),o.outputs?.length){const c=o.outputs.map(d=>d.key).filter(Boolean);c.length&&r.push(`Outputs: ${c.join(", ")}`)}return o.dependsOn?.length&&r.push(`Depends on: ${o.dependsOn.join(", ")}`),{id:`workflow:${e}:${s}`,text:w(r.filter(Boolean).join(" ")),payload:{type:"workflow",id:`workflow:${e}:${s}`,contentHash:"",title:i,description:a||void 0,collectionId:e,workflowId:s}}}function K(t){const{collectionId:e,collectionTitle:n,workflowId:o,workflowTitle:s,step:i}=t,a=i.stepId??"",r=x(i.description??""),c=i.operation,d=i.xOperation,l=[n,s,`step: ${a}`];r&&l.push(r),c?(l.push(`${c.method?.toUpperCase()} ${c.path}`),c.apiId&&l.push(`API: ${c.apiId}`),c.operationId&&l.push(`operationId: ${c.operationId}`)):d&&l.push(`${d.method?.toUpperCase()} ${d.url}`);const u=i.parameters?me(i.parameters):[];u.length>0&&l.push(`Parameters: ${u.map(U).join(". ")}.`),i.requestBody?.type&&l.push(`Request body type: ${i.requestBody.type}`);const p=(i.successCriteria??[]).map(m=>{let f=m.condition;return m.context&&(f+=` context: ${m.context}`),m.type&&(f+=` (${m.type})`),f});if(p.length>0&&l.push(`Success criteria: ${p.join("; ")}`),i.outputs?.length){const m=i.outputs.map(f=>`${f.key}=${f.value}`).filter(Boolean);m.length&&l.push(`Outputs: ${m.join(", ")}`)}const g=`step:${e}:${o}:${a}`;return{id:g,text:w(l.filter(Boolean).join(" ")),payload:{type:"step",id:g,contentHash:"",title:a,description:r||void 0,collectionId:e,workflowId:o,stepId:a,path:c?.path??d?.url,method:(c?.method??d?.method)?.toUpperCase(),apiId:c?.apiId,operationId:c?.operationId,parameterDetails:u.length>0?u:void 0,successCriteria:p.length>0?p:void 0,requestBodySchema:i.requestBody?.type?N(i.requestBody):void 0}}}function P(t){const e=[];for(const n of t){const o=n.id,s=n.info?.title??"Untitled Collection";e.push(L(n));for(const i of n.workflows??[]){e.push(W({collectionId:o,collectionTitle:s,workflow:i}));const a=i.workflowId??"",r=i.summary??a;for(const c of i.steps??[])e.push(K({collectionId:o,collectionTitle:s,workflowId:a,workflowTitle:r,step:c}))}}return e}function G(t,e){return[...O(t),...P(e)]}const k=10,fe=4;function V(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e>>>0}function ye(t){return te(ne(t))}const ge={};class Ie extends H{constructor(e){super(),this.collectionName=e}collectionName;activeIndexJobs=0;getIndexingActivityState(){return{inProgress:this.activeIndexJobs>0}}beginIndexJob(){this.activeIndexJobs++,this.activeIndexJobs===1&&this.emit("indexing-activity",{inProgress:!0})}endIndexJob(){this.activeIndexJobs=Math.max(0,this.activeIndexJobs-1),this.activeIndexJobs===0&&this.emit("indexing-activity",{inProgress:!1})}async getIdsByPayload(e,n){return h("semantic_search_get_ids_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getAllIds(){return h("semantic_search_get_all_ids",{collectionName:this.collectionName})}async getScopeHashes(e){const n=e.apiIds??[],o=e.collectionIds??[];let s;if(n.length===0&&o.length===0)s=await this.getAllIds();else{const a=[];for(const r of n)a.push(this.getIdsByPayload("apiId",r));for(const r of o)a.push(this.getIdsByPayload("collectionId",r));s=(await Promise.all(a)).flat()}const i=new Map;for(const a of s)i.set(a.id,a.contentHash);return i}async indexDocuments(e,n){if(e.length===0&&!n)return{added:0,updated:0,removed:0,unchanged:0};const o=await this.getScopeHashes(n??{}),s=[],i=new Set;let a=0,r=0;for(const l of e){const u=ye(l.text);l.payload.contentHash=u,i.add(l.id);const p=o.get(l.id);p===u?r++:(p||a++,s.push(l))}const c=s.length-a,d=[];for(const l of o.keys())i.has(l)||d.push(l);if(d.length>0||s.length>0){this.beginIndexJob();try{d.length>0&&await this.deletePoints(d.map(V)),s.length>0&&await this.embedAndUpsert(s),await this.flush()}finally{this.endIndexJob()}}return{added:a,updated:c,removed:d.length,unchanged:r}}async removeByPayloadFilter(e,n){return h("semantic_search_delete_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getStoredDocumentCount(){try{return(await h("plugin:velesdb|list_collections"))?.find(e=>e.name===this.collectionName)?.count??0}catch{return 0}}async getDocumentsByIds(e){if(e.length===0)return new Map;const n=e.map(V),o=await h("plugin:velesdb|get_points",{request:{collection:this.collectionName,ids:n}}),s=new Map;for(const i of o??[])if(i?.payload){const a=i.payload;a.id&&s.set(a.id,a)}return s}async embedAndUpsert(e){const n=[],o=e.length;for(let s=0;s<o;s+=k)n.push({docs:e.slice(s,s+k),index:Math.floor(s/k)});await ie(n,fe,async s=>{const i=s.docs.map(a=>({id:a.id,text:a.text||a.payload.title,payload:a.payload}));await h("semantic_search_embed_and_upsert",{collectionName:this.collectionName,documents:i})})}async deletePoints(e){e.length!==0&&await h("plugin:velesdb|delete_points",{request:{collection:this.collectionName,ids:e}})}async flush(){await h("plugin:velesdb|flush",{name:this.collectionName}),await h("semantic_search_write_hnsw_marker",{collectionName:this.collectionName}).catch(()=>{})}}const X="replay_search",xe=384,$={added:0,updated:0,removed:0,unchanged:0};function B(t){return t.added+t.updated>0}class Y extends H{initialized=!1;projectId=null;indexer=null;indexQueue=Promise.resolve();get collectionName(){return this.projectId?`${X}_${this.projectId}`:X}createIndexer(){const e=new Ie(this.collectionName);return e.subscribe("indexing-activity",n=>{this.emit("indexing-activity",n)}),e}getIndexer(){return this.indexer||(this.indexer=this.createIndexer()),this.indexer}getIndexingActivityState(){return this.getIndexer().getIndexingActivityState()}async ensureInitialized(){this.initialized||await this.init()}enqueueIndex(e,n){const o=this.indexQueue.then(()=>e()).then(async s=>(n(s)&&await this.unloadModel(),s)).catch(async s=>{throw console.error("Semantic index:",s),await this.unloadModel(),s});return this.indexQueue=o.catch(()=>{}),o}async unloadModel(){try{await h("semantic_search_unload_model")}catch{}}setProject(e){this.projectId!==e&&(this.projectId=e,this.initialized=!1,this.indexer=this.createIndexer())}async init(){if(y()&&!this.initialized){try{if((await h("plugin:velesdb|list_collections"))?.some(e=>e.name===this.collectionName)){this.initialized=!0;return}}catch{}await h("plugin:velesdb|create_collection",{request:{name:this.collectionName,dimension:xe,metric:"cosine",storage_mode:"full"}}),this.initialized=!0}}async indexApis(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer(),s=O(e),i={apiIds:e.map(a=>a.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?$:o.indexDocuments(s,i),B)}async indexCollections(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer(),s=P(e),i={collectionIds:e.map(a=>a.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?$:o.indexDocuments(s,i),B)}async removeApi(e){if(!y())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("apiId",e),()=>!1)}async removeCollection(e){if(!y())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("collectionId",e),()=>!1)}async reindex(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer();return await this.ensureInitialized(),this.enqueueIndex(async()=>{if(this.collectionName!==n)return $;const{apis:s,collections:i}=e(),a=G(s,i);return o.indexDocuments(a,ge)},B)}async search(e,n=10,o){if(!y())return[];try{await this.ensureInitialized();const s=o&&Object.keys(o).length>0?{type:o.type,apiId:o.apiId,collectionId:o.collectionId,path:o.path,method:o.method,operationId:o.operationId,workflowId:o.workflowId,stepId:o.stepId}:void 0,i=((await h("semantic_search_text",{collection:this.collectionName,query:e,topK:n,filters:s})).results??[]).map(a=>({...a.payload,score:a.score??0}));return await this.enrichWithRelatedSecurity(i),i}catch{return[]}}async enrichWithRelatedSecurity(e){const n=e.filter(i=>i.type==="api_operation"&&i.securitySchemeRefs?.length);if(n.length===0)return;const o=[...new Set(n.flatMap(i=>i.securitySchemeRefs??[]))],s=await this.getIndexer().getDocumentsByIds(o);for(const i of n){const a=[];for(const r of i.securitySchemeRefs??[]){const c=s.get(r);c?.securityScheme&&a.push(c.securityScheme)}a.length>0&&(i.relatedSecuritySchemes=a)}}async status(){if(!y())return{indexed:0,modelLoaded:!1};const e=await this.getIndexer().getStoredDocumentCount();let n=!1;try{n=(await h("semantic_search_model_status")).loaded}catch{}return{indexed:e,modelLoaded:n}}async clear(){if(!(!y()||!this.initialized))try{await h("plugin:velesdb|delete_collection",{name:this.collectionName}),this.initialized=!1}catch{}}async preloadModel(){if(y())try{await h("semantic_search_preload_model")}catch{}}}let A=null;function we(){return A||(A=new Y),A}export{Y as S,O as a,P as b,Q as c,q as d,G as e,E as f,we as g,L as h,K as i,W as j};
1
+ import{z as h,aP as te,aQ as ne,aR as y}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{O as H}from"./redocly-openapi-docs.min.Observable-D6wKbFwB.js";import{p as ie}from"./redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js";function x(t){return t==null?"":typeof t=="string"?t:typeof t=="object"&&"raw"in t&&typeof t.raw=="string"?t.raw:String(t)}function w(t){return t.replace(/\s+/g," ").trim()}function b(t){return typeof t=="object"&&t!==null&&"$ref"in t}function _(t){return b(t)?null:t}function N(t){try{return JSON.stringify(t)}catch{return String(t)}}function U(t){let e=`${t.name} (${t.in}`;return t.required&&(e+=", required"),t.type&&(e+=`, ${t.type}`),t.format&&(e+=`, format: ${t.format}`),t.enum&&(e+=`, enum: [${t.enum.join(",")}]`),t.pattern&&(e+=`, pattern: ${t.pattern}`),e+=")",e}function M(t){return t.type?Array.isArray(t.type)?t.type.join("|"):t.type:t.oneOf?"oneOf":t.anyOf?"anyOf":t.allOf?"allOf":"object"}function oe(t){return t==="querystring"?"query":t==="query"||t==="header"||t==="path"||t==="cookie"?t:"query"}function se(t){const e=t.schema&&!b(t.schema)?t.schema:null,n={name:t.name,in:oe(t.in),required:t.required??!1};return e&&(n.type=M(e),e.format&&(n.format=e.format),e.enum&&(n.enum=e.enum.map(String)),e.pattern&&(n.pattern=e.pattern),e.example!==void 0&&(n.example=String(e.example))),t.description&&(n.description=x(t.description)),t.example!==void 0&&!n.example&&(n.example=String(t.example)),n}function ae(t,e){const n=new Set,o=[],s=i=>{for(const a of i){const r=_(a);if(!r||!r.name)continue;const c=`${r.in}:${r.name}`;n.has(c)||(n.add(c),o.push(se(r)))}};return t.parameters&&s(t.parameters),e.parameters&&s(e.parameters),o}function F(t,e=2,n=0){if(n>=e||!t.properties)return[];const o=new Set(t.required??[]);return Object.entries(t.properties).map(([s,i])=>({name:s,type:M(i),required:o.has(s),readOnly:i.readOnly}))}function E(t){const e=t.components?.securitySchemes;if(!e)return[];const n=[];for(const[o,s]of Object.entries(e)){const i=_(s);i&&n.push(re(o,i))}return n}function re(t,e){const n={schemeName:t,type:e.type};if(e.in&&(n.in=e.in),e.name&&(n.name=e.name),e.scheme&&(n.scheme=e.scheme),e.bearerFormat&&(n.bearerFormat=e.bearerFormat),e.flows){const o=Object.keys(e.flows).filter(i=>e.flows[i]);o.length>0&&(n.flows=o.join(", "));const s=new Set;for(const i of o){const a=e.flows[i];a?.scopes&&Object.keys(a.scopes).forEach(r=>s.add(r))}s.size>0&&(n.scopes=[...s].join(", "))}return n}function ce(t,e,n){const o=t??e;if(!o||n.length===0)return[];const s=new Set;for(const i of o)for(const a of Object.keys(i))s.add(a);return n.filter(i=>s.has(i.schemeName))}function le(t){return t.length===0?"":`Security: ${t.map(e=>{let n=`${e.schemeName} (${e.type}`;return e.scheme&&(n+=`, ${e.scheme}`),e.in&&e.name&&(n+=`, ${e.name} in ${e.in}`),n+=")",n}).join("; ")}.`}const de=["get","put","post","delete","options","head","patch","trace"],ue=["query","x-query"];function pe(t,e){const n=[],o=Object.keys(t.content??{});if(o.length===0)return{textPart:"",schemaJson:"{}",examples:n};const s=o.find(l=>l.includes("json"))??o[0],i=t.content?.[s],a=i?.schema&&!b(i.schema)?i.schema:null,r=(a?F(a):[]).filter(l=>!e.hideReadOnly||!l.readOnly),c=t.required?"required":"optional";let d=`Request body (${s}, ${c})`;if(r.length>0){const l=r.map(u=>`${u.name}: ${u.type}${u.required?" required":""}${u.readOnly?" readOnly":""}`);d+=`: {${l.join(", ")}}`}return i?.example!==void 0&&n.push(N(i.example)),{textPart:d,schemaJson:JSON.stringify(r),examples:n}}function he(t){const e=[],n=[];for(const[o,s]of Object.entries(t)){if(b(s))continue;const i=x(s.description??"");e.push(`${o} ${i}`.trim());const a={statusCode:o};i&&(a.description=i);const r=s.content;if(r){const c=Object.keys(r).find(l=>l.includes("json"))??Object.keys(r)[0],d=r[c]?.schema;if(d&&!b(d)){const l=F(d);l.length>0&&(a.schemaProperties=JSON.stringify(l))}}n.push(a)}return{textParts:e,summaries:n}}function q(t){const{apiId:e,apiTitle:n,path:o,method:s,op:i,pathItem:a,globalSchemes:r,apiSecurity:c}=t,d=i.summary??"",l=x(i.description??""),u=i.operationId??"",p=i.tags??[],g=s.toUpperCase(),m=ae(i,a),f=ce(i.security,c,r),Z=f.length>0?f.map(v=>`api_sec:${e}:${v.schemeName}`):void 0,I=[n,`${g} ${o}`,d,l];u&&I.push(`operationId: ${u}`),p.length>0&&I.push(`Tags: ${p.join(", ")}`),i.deprecated&&I.push("DEPRECATED"),m.length>0&&I.push(`Parameters: ${m.map(U).join(". ")}.`);let z;const S=[],J=i.requestBody;if(J){const v=_(J);if(v){const j=pe(v,{hideReadOnly:g==="POST"||g==="PUT"||g==="PATCH"});j.textPart&&I.push(j.textPart),z=j.schemaJson,S.push(...j.examples)}}const{textParts:C,summaries:T}=he(i.responses??{});C.length>0&&I.push(`Responses: ${C.join(", ")}.`);const D=le(f);D&&I.push(D);const R=`api_op:${e}:${o}:${s}:${u||`${o}-${s}`}`,ee={type:"api_operation",id:R,contentHash:"",title:d||`${g} ${o}`,description:l||void 0,apiId:e,path:o,method:g,operationId:u||void 0,tags:p.length>0?p:void 0,deprecated:i.deprecated||void 0,parameterDetails:m.length>0?m:void 0,requestBodySchema:z,responseSchemas:T.length>0?T:void 0,securitySchemeRefs:Z,examples:S.length>0?S:void 0};return{id:R,text:w(I.filter(Boolean).join(" ")),payload:ee}}function Q(t){const e=t.info?.title??"Untitled API",n=x(t.info?.description??t.info?.summary??""),o=t.id;return{id:`api:${o}`,text:w([e,n].filter(Boolean).join(" ")),payload:{type:"api",id:`api:${o}`,contentHash:"",title:e,description:n||void 0,apiId:o}}}function O(t){const e=[];for(const n of t){e.push(Q(n));const o=n.info?.title??"Untitled API",s=n.id,i=E(n);for(const r of i){const c=`api_sec:${s}:${r.schemeName}`,d=[`${r.schemeName}: type=${r.type}`,r.scheme?`scheme=${r.scheme}`:"",r.in&&r.name?`${r.name} in ${r.in}`:"",r.bearerFormat?`format=${r.bearerFormat}`:"",r.flows?`flows=[${r.flows}]`:"",r.scopes?`scopes=[${r.scopes}]`:""].filter(Boolean).join(" ");e.push({id:c,text:w(`${o} Authentication. ${r.schemeName}. ${d}.`),payload:{type:"api_security",id:c,contentHash:"",title:`${o} \u2014 ${r.schemeName}`,apiId:s,securityScheme:r}})}const a=n.paths??{};for(const[r,c]of Object.entries(a)){if(!c||typeof c!="object")continue;const d=[...de.filter(u=>u in c),...ue.filter(u=>u in c)];for(const u of d){const p=c[u];!p||typeof p!="object"||e.push(q({apiId:s,apiTitle:o,path:r,method:u,op:p,pathItem:c,globalSchemes:i,apiSecurity:n.security}))}const l=c.additionalOperations;if(l&&typeof l=="object")for(const[u,p]of Object.entries(l))!p||typeof p!="object"||e.push(q({apiId:s,apiTitle:o,path:r,method:u,op:p,pathItem:c,globalSchemes:i,apiSecurity:n.security}))}}return e}function me(t){const e=[],n=[{list:t.queryParameters,loc:"query"},{list:t.headers,loc:"header"},{list:t.cookies,loc:"cookie"},{list:t.pathParameters,loc:"path"}];for(const{list:o,loc:s}of n)for(const i of o)if("key"in i){const a=i;e.push({name:a.key,in:s,required:!1})}return e}function L(t){const e=t.id,n=t.info?.title??"Untitled Collection",o=x(t.info?.description??t.info?.summary??"");return{id:`collection:${e}`,text:w([n,o].filter(Boolean).join(" ")),payload:{type:"collection",id:`collection:${e}`,contentHash:"",title:n,description:o||void 0,collectionId:e}}}function W(t){const{collectionId:e,collectionTitle:n,workflow:o}=t,s=o.workflowId??"",i=o.summary??s,a=x(o.description??""),r=[n,i,a];if(o.inputs&&r.push(`Inputs schema: ${N(o.inputs)}`),o.outputs?.length){const c=o.outputs.map(d=>d.key).filter(Boolean);c.length&&r.push(`Outputs: ${c.join(", ")}`)}return o.dependsOn?.length&&r.push(`Depends on: ${o.dependsOn.join(", ")}`),{id:`workflow:${e}:${s}`,text:w(r.filter(Boolean).join(" ")),payload:{type:"workflow",id:`workflow:${e}:${s}`,contentHash:"",title:i,description:a||void 0,collectionId:e,workflowId:s}}}function K(t){const{collectionId:e,collectionTitle:n,workflowId:o,workflowTitle:s,step:i}=t,a=i.stepId??"",r=x(i.description??""),c=i.operation,d=i.xOperation,l=[n,s,`step: ${a}`];r&&l.push(r),c?(l.push(`${c.method?.toUpperCase()} ${c.path}`),c.apiId&&l.push(`API: ${c.apiId}`),c.operationId&&l.push(`operationId: ${c.operationId}`)):d&&l.push(`${d.method?.toUpperCase()} ${d.url}`);const u=i.parameters?me(i.parameters):[];u.length>0&&l.push(`Parameters: ${u.map(U).join(". ")}.`),i.requestBody?.type&&l.push(`Request body type: ${i.requestBody.type}`);const p=(i.successCriteria??[]).map(m=>{let f=m.condition;return m.context&&(f+=` context: ${m.context}`),m.type&&(f+=` (${m.type})`),f});if(p.length>0&&l.push(`Success criteria: ${p.join("; ")}`),i.outputs?.length){const m=i.outputs.map(f=>`${f.key}=${f.value}`).filter(Boolean);m.length&&l.push(`Outputs: ${m.join(", ")}`)}const g=`step:${e}:${o}:${a}`;return{id:g,text:w(l.filter(Boolean).join(" ")),payload:{type:"step",id:g,contentHash:"",title:a,description:r||void 0,collectionId:e,workflowId:o,stepId:a,path:c?.path??d?.url,method:(c?.method??d?.method)?.toUpperCase(),apiId:c?.apiId,operationId:c?.operationId,parameterDetails:u.length>0?u:void 0,successCriteria:p.length>0?p:void 0,requestBodySchema:i.requestBody?.type?N(i.requestBody):void 0}}}function P(t){const e=[];for(const n of t){const o=n.id,s=n.info?.title??"Untitled Collection";e.push(L(n));for(const i of n.workflows??[]){e.push(W({collectionId:o,collectionTitle:s,workflow:i}));const a=i.workflowId??"",r=i.summary??a;for(const c of i.steps??[])e.push(K({collectionId:o,collectionTitle:s,workflowId:a,workflowTitle:r,step:c}))}}return e}function G(t,e){return[...O(t),...P(e)]}const k=10,fe=4;function V(t){let e=0;for(let n=0;n<t.length;n++)e=(e<<5)-e+t.charCodeAt(n)|0;return e>>>0}function ye(t){return te(ne(t))}const ge={};class Ie extends H{constructor(e){super(),this.collectionName=e}collectionName;activeIndexJobs=0;getIndexingActivityState(){return{inProgress:this.activeIndexJobs>0}}beginIndexJob(){this.activeIndexJobs++,this.activeIndexJobs===1&&this.emit("indexing-activity",{inProgress:!0})}endIndexJob(){this.activeIndexJobs=Math.max(0,this.activeIndexJobs-1),this.activeIndexJobs===0&&this.emit("indexing-activity",{inProgress:!1})}async getIdsByPayload(e,n){return h("semantic_search_get_ids_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getAllIds(){return h("semantic_search_get_all_ids",{collectionName:this.collectionName})}async getScopeHashes(e){const n=e.apiIds??[],o=e.collectionIds??[];let s;if(n.length===0&&o.length===0)s=await this.getAllIds();else{const a=[];for(const r of n)a.push(this.getIdsByPayload("apiId",r));for(const r of o)a.push(this.getIdsByPayload("collectionId",r));s=(await Promise.all(a)).flat()}const i=new Map;for(const a of s)i.set(a.id,a.contentHash);return i}async indexDocuments(e,n){if(e.length===0&&!n)return{added:0,updated:0,removed:0,unchanged:0};const o=await this.getScopeHashes(n??{}),s=[],i=new Set;let a=0,r=0;for(const l of e){const u=ye(l.text);l.payload.contentHash=u,i.add(l.id);const p=o.get(l.id);p===u?r++:(p||a++,s.push(l))}const c=s.length-a,d=[];for(const l of o.keys())i.has(l)||d.push(l);if(d.length>0||s.length>0){this.beginIndexJob();try{d.length>0&&await this.deletePoints(d.map(V)),s.length>0&&await this.embedAndUpsert(s),await this.flush()}finally{this.endIndexJob()}}return{added:a,updated:c,removed:d.length,unchanged:r}}async removeByPayloadFilter(e,n){return h("semantic_search_delete_by_payload",{collectionName:this.collectionName,field:e,value:n})}async getStoredDocumentCount(){try{return(await h("plugin:velesdb|list_collections"))?.find(e=>e.name===this.collectionName)?.count??0}catch{return 0}}async getDocumentsByIds(e){if(e.length===0)return new Map;const n=e.map(V),o=await h("plugin:velesdb|get_points",{request:{collection:this.collectionName,ids:n}}),s=new Map;for(const i of o??[])if(i?.payload){const a=i.payload;a.id&&s.set(a.id,a)}return s}async embedAndUpsert(e){const n=[],o=e.length;for(let s=0;s<o;s+=k)n.push({docs:e.slice(s,s+k),index:Math.floor(s/k)});await ie(n,fe,async s=>{const i=s.docs.map(a=>({id:a.id,text:a.text||a.payload.title,payload:a.payload}));await h("semantic_search_embed_and_upsert",{collectionName:this.collectionName,documents:i})})}async deletePoints(e){e.length!==0&&await h("plugin:velesdb|delete_points",{request:{collection:this.collectionName,ids:e}})}async flush(){await h("plugin:velesdb|flush",{name:this.collectionName}),await h("semantic_search_write_hnsw_marker",{collectionName:this.collectionName}).catch(()=>{})}}const X="replay_search",xe=384,$={added:0,updated:0,removed:0,unchanged:0};function B(t){return t.added+t.updated>0}class Y extends H{initialized=!1;projectId=null;indexer=null;indexQueue=Promise.resolve();get collectionName(){return this.projectId?`${X}_${this.projectId}`:X}createIndexer(){const e=new Ie(this.collectionName);return e.subscribe("indexing-activity",n=>{this.emit("indexing-activity",n)}),e}getIndexer(){return this.indexer||(this.indexer=this.createIndexer()),this.indexer}getIndexingActivityState(){return this.getIndexer().getIndexingActivityState()}async ensureInitialized(){this.initialized||await this.init()}enqueueIndex(e,n){const o=this.indexQueue.then(()=>e()).then(async s=>(n(s)&&await this.unloadModel(),s)).catch(async s=>{throw console.error("Semantic index:",s),await this.unloadModel(),s});return this.indexQueue=o.catch(()=>{}),o}async unloadModel(){try{await h("semantic_search_unload_model")}catch{}}setProject(e){this.projectId!==e&&(this.projectId=e,this.initialized=!1,this.indexer=this.createIndexer())}async init(){if(y()&&!this.initialized){try{if((await h("plugin:velesdb|list_collections"))?.some(e=>e.name===this.collectionName)){this.initialized=!0;return}}catch{}await h("plugin:velesdb|create_collection",{request:{name:this.collectionName,dimension:xe,metric:"cosine",storage_mode:"full"}}),this.initialized=!0}}async indexApis(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer(),s=O(e),i={apiIds:e.map(a=>a.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?$:o.indexDocuments(s,i),B)}async indexCollections(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer(),s=P(e),i={collectionIds:e.map(a=>a.id)};return await this.ensureInitialized(),this.enqueueIndex(async()=>this.collectionName!==n?$:o.indexDocuments(s,i),B)}async removeApi(e){if(!y())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("apiId",e),()=>!1)}async removeCollection(e){if(!y())return;const n=this.getIndexer();await this.ensureInitialized(),await this.enqueueIndex(()=>n.removeByPayloadFilter("collectionId",e),()=>!1)}async reindex(e){if(!y())return $;const n=this.collectionName,o=this.getIndexer();return await this.ensureInitialized(),this.enqueueIndex(async()=>{if(this.collectionName!==n)return $;const{apis:s,collections:i}=e(),a=G(s,i);return o.indexDocuments(a,ge)},B)}async search(e,n=10,o){if(!y())return[];try{await this.ensureInitialized();const s=o&&Object.keys(o).length>0?{type:o.type,apiId:o.apiId,collectionId:o.collectionId,path:o.path,method:o.method,operationId:o.operationId,workflowId:o.workflowId,stepId:o.stepId}:void 0,i=((await h("semantic_search_text",{collection:this.collectionName,query:e,topK:n,filters:s})).results??[]).map(a=>({...a.payload,score:a.score??0}));return await this.enrichWithRelatedSecurity(i),i}catch{return[]}}async enrichWithRelatedSecurity(e){const n=e.filter(i=>i.type==="api_operation"&&i.securitySchemeRefs?.length);if(n.length===0)return;const o=[...new Set(n.flatMap(i=>i.securitySchemeRefs??[]))],s=await this.getIndexer().getDocumentsByIds(o);for(const i of n){const a=[];for(const r of i.securitySchemeRefs??[]){const c=s.get(r);c?.securityScheme&&a.push(c.securityScheme)}a.length>0&&(i.relatedSecuritySchemes=a)}}async status(){if(!y())return{indexed:0,modelLoaded:!1};const e=await this.getIndexer().getStoredDocumentCount();let n=!1;try{n=(await h("semantic_search_model_status")).loaded}catch{}return{indexed:e,modelLoaded:n}}async clear(){if(!(!y()||!this.initialized))try{await h("plugin:velesdb|delete_collection",{name:this.collectionName}),this.initialized=!1}catch{}}async preloadModel(){if(y())try{await h("semantic_search_preload_model")}catch{}}}let A=null;function we(){return A||(A=new Y),A}export{Y as S,O as a,P as b,Q as c,q as d,G as e,E as f,we as g,L as h,K as i,W as j};
@@ -1,4 +1,4 @@
1
- import{z as ve}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{h as We}from"./redocly-openapi-docs.min.history.schema-DzAAX18S.js";import{s as Ve}from"./redocly-openapi-docs.min.step-context.schema-DEgzIgw0.js";import{b as z,c as G,a as H}from"./redocly-openapi-docs.min.ai-message-parts.schema-C7fjQhYX.js";import{c as f,T as m,i as h,g as W,s as n,o as Ue,n as Ye,f as Ge,h as He,j as Ze,k as Xe,m as et,p as tt,q as st,l as it,r as rt,t as nt,u as at,v as ot,w as lt,x as ct,y as ht,z as ut,e as qe,A as dt,b as ce,d as ft,a as mt,C as O,S as y,V as A,B as E,D as he,E as R,F as V,G as Z,H as ue,P as Ce,I as pt,J as de,K as fe,L as gt,W as Ne,M as Qe,N as yt,O as X,Q as Te}from"./redocly-openapi-docs.min.indexes-Bp4ld5gB.js";class bt{static[f]="ConsoleLogWriter";write(e){console.log(e)}}class wt{static[f]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new bt}logQuery(e,t){const s=t.map(r=>{try{return JSON.stringify(r)}catch{return String(r)}}),i=s.length?` -- params: [${s.join(", ")}]`:"";this.writer.write(`Query: ${e}${i}`)}}class St{static[f]="NoopLogger";logQuery(){}}const Le=Symbol.for("drizzle:PgInlineForeignKeys"),xe=Symbol.for("drizzle:EnableRLS");class $t extends m{static[f]="PgTable";static Symbol=Object.assign({},m.Symbol,{InlineForeignKeys:Le,EnableRLS:xe});[Le]=[];[xe]=!1;[m.Symbol.ExtraConfigBuilder]=void 0;[m.Symbol.ExtraConfigColumns]={}}class vt{static[f]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new qt(e,this.columns,this.name)}}class qt{constructor(e,t,s){this.table=e,this.columns=t,this.name=s}static[f]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[$t.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}class Oe{constructor(e,t,s){this.sourceTable=e,this.referencedTable=t,this.relationName=s,this.referencedTableName=t[m.Symbol.Name]}static[f]="Relation";referencedTableName;fieldName}class Be{constructor(e,t){this.table=e,this.config=t}static[f]="Relations"}class D extends Oe{constructor(e,t,s,i){super(e,t,s?.relationName),this.config=s,this.isNullable=i}static[f]="One";withFieldName(e){const t=new D(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class ne extends Oe{constructor(e,t,s){super(e,t,s?.relationName),this.config=s}static[f]="Many";withFieldName(e){const t=new ne(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function Ct(){return{and:ce,between:dt,eq:qe,exists:ut,gt:ht,gte:ct,ilike:lt,inArray:ot,isNull:at,isNotNull:nt,like:rt,lt:it,lte:st,ne:tt,not:et,notBetween:Xe,notExists:Ze,notLike:He,notIlike:Ge,notInArray:Ye,or:Ue,sql:n}}function Nt(){return{sql:n,asc:mt,desc:ft}}function Qt(l,e){Object.keys(l).length===1&&"default"in l&&!h(l.default,m)&&(l=l.default);const t={},s={},i={};for(const[r,a]of Object.entries(l))if(h(a,m)){const o=W(a),c=s[o];t[o]=r,i[r]={tsName:r,dbName:a[m.Symbol.Name],schema:a[m.Symbol.Schema],columns:a[m.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(const d of Object.values(a[m.Symbol.Columns]))d.primary&&i[r].primaryKey.push(d);const u=a[m.Symbol.ExtraConfigBuilder]?.(a[m.Symbol.ExtraConfigColumns]);if(u)for(const d of Object.values(u))h(d,vt)&&i[r].primaryKey.push(...d.columns)}else if(h(a,Be)){const o=W(a.table),c=t[o],u=a.config(e(a.table));let d;for(const[g,N]of Object.entries(u))if(c){const Q=i[c];Q.relations[g]=N}else o in s||(s[o]={relations:{},primaryKey:d}),s[o].relations[g]=N}return{tables:i,tableNamesMap:t}}function me(l,e){return new Be(l,t=>Object.fromEntries(Object.entries(e(t)).map(([s,i])=>[s,i.withFieldName(s)])))}function Tt(l){return function(e,t){return new D(l,e,t,t?.fields.reduce((s,i)=>s&&i.notNull,!0)??!1)}}function Lt(l){return function(e,t){return new ne(l,e,t)}}function xt(l,e,t){if(h(t,D)&&t.config)return{fields:t.config.fields,references:t.config.references};const s=e[W(t.referencedTable)];if(!s)throw new Error(`Table "${t.referencedTable[m.Symbol.Name]}" not found in schema`);const i=l[s];if(!i)throw new Error(`Table "${s}" not found in schema`);const r=t.sourceTable,a=e[W(r)];if(!a)throw new Error(`Table "${r[m.Symbol.Name]}" not found in schema`);const o=[];for(const c of Object.values(i.relations))(t.relationName&&t!==c&&c.relationName===t.relationName||!t.relationName&&c.referencedTable===t.sourceTable)&&o.push(c);if(o.length>1)throw t.relationName?new Error(`There are multiple relations with name "${t.relationName}" in table "${s}"`):new Error(`There are multiple relations between "${s}" and "${t.sourceTable[m.Symbol.Name]}". Please specify relation name`);if(o[0]&&h(o[0],D)&&o[0].config)return{fields:o[0].config.references,references:o[0].config.fields};throw new Error(`There is not enough information to infer relation "${a}.${t.fieldName}"`)}function Ot(l){return{one:Tt(l),many:Lt(l)}}function pe(l,e,t,s,i=r=>r){const r={};for(const[a,o]of s.entries())if(o.isJson){const c=e.relations[o.tsKey],u=t[a],d=typeof u=="string"?JSON.parse(u):u;r[o.tsKey]=h(c,D)?d&&pe(l,l[o.relationTableTsKey],d,o.selection,i):d.map(g=>pe(l,l[o.relationTableTsKey],g,o.selection,i))}else{const c=i(t[a]),u=o.field;let d;h(u,O)?d=u:h(u,y)?d=u.decoder:d=u.sql.decoder,r[o.tsKey]=c===null?null:d.mapFromDriverValue(c)}return r}class ee{constructor(e){this.table=e}static[f]="ColumnAliasProxyHandler";get(e,t){return t==="table"?this.table:e[t]}}class ge{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[f]="TableAliasProxyHandler";get(e,t){if(t===m.Symbol.IsAlias)return!0;if(t===m.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===m.Symbol.OriginalName)return this.alias;if(t===A)return{...e[A],name:this.alias,isAlias:!0};if(t===m.Symbol.Columns){const i=e[m.Symbol.Columns];if(!i)return i;const r={};return Object.keys(i).map(a=>{r[a]=new Proxy(i[a],new ee(new Proxy(e,this)))}),r}const s=e[t];return h(s,O)?new Proxy(s,new ee(new Proxy(e,this))):s}}function ye(l,e){return new Proxy(l,new ge(e,!1))}function P(l,e){return new Proxy(l,new ee(new Proxy(l.table,new ge(e,!1))))}function je(l,e){return new y.Aliased(te(l.sql,e),l.fieldAlias)}function te(l,e){return n.join(l.queryChunks.map(t=>h(t,O)?P(t,e):h(t,y)?te(t,e):h(t,y.Aliased)?je(t,e):t))}class T{static[f]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===A)return{...e[A],selectedFields:new Proxy(e[A].selectedFields,this)};if(typeof t=="symbol")return e[t];const s=(h(e,E)?e._.selectedFields:h(e,he)?e[A].selectedFields:e)[t];if(h(s,y.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!s.isSelectionField)return s.sql;const i=s.clone();return i.isSelectionField=!0,i}if(h(s,y)){if(this.config.sqlBehavior==="sql")return s;throw new Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return h(s,O)?this.config.alias?new Proxy(s,new ee(new Proxy(s.table,new ge(this.config.alias,this.config.replaceOriginalName??!1)))):s:typeof s!="object"||s===null?s:new Proxy(s,new T(this.config))}}class K{static[f]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}function k(l){return h(l,R)?[`${l[m.Symbol.BaseName]}`]:h(l,E)?l._.usedTables??[]:h(l,y)?l.usedTables??[]:[]}class Ae extends K{constructor(e,t,s,i){super(),this.table=e,this.session=t,this.dialect=s,this.config={table:e,withList:i}}static[f]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){const t=e[0](new Proxy(this.config.table[m.Symbol.Columns],new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),s=Array.isArray(t)?t:[t];this.config.orderBy=s}else{const t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[R.Symbol.Columns]){return this.config.returning=V(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:k(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}function Bt(l){return(l.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function jt(l){return(l.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,s)=>{const i=s===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`;return e+i},"")}function At(l){return l}class Rt{static[f]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Bt:e==="camelCase"?jt:At}getColumnCasing(e){if(!e.keyAsName)return e.name;const t=e.table[m.Symbol.Schema]??"public",s=e.table[m.Symbol.OriginalName],i=`${t}.${s}.${e.name}`;return this.cache[i]||this.cacheTable(e.table),this.cache[i]}cacheTable(e){const t=e[m.Symbol.Schema]??"public",s=e[m.Symbol.OriginalName],i=`${t}.${s}`;if(!this.cachedTables[i]){for(const r of Object.values(e[m.Symbol.Columns])){const a=`${i}.${r.name}`;this.cache[a]=this.convert(r.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class be extends Error{static[f]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class I extends Error{constructor(e,t,s){super(`Failed query: ${e}
1
+ import{z as ve}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{h as We}from"./redocly-openapi-docs.min.history.schema-DzAAX18S.js";import{s as Ve}from"./redocly-openapi-docs.min.step-context.schema-DEgzIgw0.js";import{b as z,c as G,a as H}from"./redocly-openapi-docs.min.ai-message-parts.schema-C7fjQhYX.js";import{c as f,T as m,i as h,g as W,s as n,o as Ue,n as Ye,f as Ge,h as He,j as Ze,k as Xe,m as et,p as tt,q as st,l as it,r as rt,t as nt,u as at,v as ot,w as lt,x as ct,y as ht,z as ut,e as qe,A as dt,b as ce,d as ft,a as mt,C as O,S as y,V as A,B as E,D as he,E as R,F as V,G as Z,H as ue,P as Ce,I as pt,J as de,K as fe,L as gt,W as Ne,M as Qe,N as yt,O as X,Q as Te}from"./redocly-openapi-docs.min.indexes-Bp4ld5gB.js";class bt{static[f]="ConsoleLogWriter";write(e){console.log(e)}}class wt{static[f]="DefaultLogger";writer;constructor(e){this.writer=e?.writer??new bt}logQuery(e,t){const s=t.map(r=>{try{return JSON.stringify(r)}catch{return String(r)}}),i=s.length?` -- params: [${s.join(", ")}]`:"";this.writer.write(`Query: ${e}${i}`)}}class St{static[f]="NoopLogger";logQuery(){}}const Le=Symbol.for("drizzle:PgInlineForeignKeys"),xe=Symbol.for("drizzle:EnableRLS");class $t extends m{static[f]="PgTable";static Symbol=Object.assign({},m.Symbol,{InlineForeignKeys:Le,EnableRLS:xe});[Le]=[];[xe]=!1;[m.Symbol.ExtraConfigBuilder]=void 0;[m.Symbol.ExtraConfigColumns]={}}class vt{static[f]="PgPrimaryKeyBuilder";columns;name;constructor(e,t){this.columns=e,this.name=t}build(e){return new qt(e,this.columns,this.name)}}class qt{constructor(e,t,s){this.table=e,this.columns=t,this.name=s}static[f]="PgPrimaryKey";columns;name;getName(){return this.name??`${this.table[$t.Symbol.Name]}_${this.columns.map(e=>e.name).join("_")}_pk`}}class Oe{constructor(e,t,s){this.sourceTable=e,this.referencedTable=t,this.relationName=s,this.referencedTableName=t[m.Symbol.Name]}static[f]="Relation";referencedTableName;fieldName}class Be{constructor(e,t){this.table=e,this.config=t}static[f]="Relations"}class D extends Oe{constructor(e,t,s,i){super(e,t,s?.relationName),this.config=s,this.isNullable=i}static[f]="One";withFieldName(e){const t=new D(this.sourceTable,this.referencedTable,this.config,this.isNullable);return t.fieldName=e,t}}class ne extends Oe{constructor(e,t,s){super(e,t,s?.relationName),this.config=s}static[f]="Many";withFieldName(e){const t=new ne(this.sourceTable,this.referencedTable,this.config);return t.fieldName=e,t}}function Ct(){return{and:ce,between:dt,eq:qe,exists:ut,gt:ht,gte:ct,ilike:lt,inArray:ot,isNull:at,isNotNull:nt,like:rt,lt:it,lte:st,ne:tt,not:et,notBetween:Xe,notExists:Ze,notLike:He,notIlike:Ge,notInArray:Ye,or:Ue,sql:n}}function Nt(){return{sql:n,asc:mt,desc:ft}}function Qt(l,e){Object.keys(l).length===1&&"default"in l&&!h(l.default,m)&&(l=l.default);const t={},s={},i={};for(const[r,a]of Object.entries(l))if(h(a,m)){const o=W(a),c=s[o];t[o]=r,i[r]={tsName:r,dbName:a[m.Symbol.Name],schema:a[m.Symbol.Schema],columns:a[m.Symbol.Columns],relations:c?.relations??{},primaryKey:c?.primaryKey??[]};for(const d of Object.values(a[m.Symbol.Columns]))d.primary&&i[r].primaryKey.push(d);const u=a[m.Symbol.ExtraConfigBuilder]?.(a[m.Symbol.ExtraConfigColumns]);if(u)for(const d of Object.values(u))h(d,vt)&&i[r].primaryKey.push(...d.columns)}else if(h(a,Be)){const o=W(a.table),c=t[o],u=a.config(e(a.table));let d;for(const[g,N]of Object.entries(u))if(c){const Q=i[c];Q.relations[g]=N}else o in s||(s[o]={relations:{},primaryKey:d}),s[o].relations[g]=N}return{tables:i,tableNamesMap:t}}function me(l,e){return new Be(l,t=>Object.fromEntries(Object.entries(e(t)).map(([s,i])=>[s,i.withFieldName(s)])))}function Tt(l){return function(e,t){return new D(l,e,t,t?.fields.reduce((s,i)=>s&&i.notNull,!0)??!1)}}function Lt(l){return function(e,t){return new ne(l,e,t)}}function xt(l,e,t){if(h(t,D)&&t.config)return{fields:t.config.fields,references:t.config.references};const s=e[W(t.referencedTable)];if(!s)throw new Error(`Table "${t.referencedTable[m.Symbol.Name]}" not found in schema`);const i=l[s];if(!i)throw new Error(`Table "${s}" not found in schema`);const r=t.sourceTable,a=e[W(r)];if(!a)throw new Error(`Table "${r[m.Symbol.Name]}" not found in schema`);const o=[];for(const c of Object.values(i.relations))(t.relationName&&t!==c&&c.relationName===t.relationName||!t.relationName&&c.referencedTable===t.sourceTable)&&o.push(c);if(o.length>1)throw t.relationName?new Error(`There are multiple relations with name "${t.relationName}" in table "${s}"`):new Error(`There are multiple relations between "${s}" and "${t.sourceTable[m.Symbol.Name]}". Please specify relation name`);if(o[0]&&h(o[0],D)&&o[0].config)return{fields:o[0].config.references,references:o[0].config.fields};throw new Error(`There is not enough information to infer relation "${a}.${t.fieldName}"`)}function Ot(l){return{one:Tt(l),many:Lt(l)}}function pe(l,e,t,s,i=r=>r){const r={};for(const[a,o]of s.entries())if(o.isJson){const c=e.relations[o.tsKey],u=t[a],d=typeof u=="string"?JSON.parse(u):u;r[o.tsKey]=h(c,D)?d&&pe(l,l[o.relationTableTsKey],d,o.selection,i):d.map(g=>pe(l,l[o.relationTableTsKey],g,o.selection,i))}else{const c=i(t[a]),u=o.field;let d;h(u,O)?d=u:h(u,y)?d=u.decoder:d=u.sql.decoder,r[o.tsKey]=c===null?null:d.mapFromDriverValue(c)}return r}class ee{constructor(e){this.table=e}static[f]="ColumnAliasProxyHandler";get(e,t){return t==="table"?this.table:e[t]}}class ge{constructor(e,t){this.alias=e,this.replaceOriginalName=t}static[f]="TableAliasProxyHandler";get(e,t){if(t===m.Symbol.IsAlias)return!0;if(t===m.Symbol.Name)return this.alias;if(this.replaceOriginalName&&t===m.Symbol.OriginalName)return this.alias;if(t===A)return{...e[A],name:this.alias,isAlias:!0};if(t===m.Symbol.Columns){const i=e[m.Symbol.Columns];if(!i)return i;const r={};return Object.keys(i).map(a=>{r[a]=new Proxy(i[a],new ee(new Proxy(e,this)))}),r}const s=e[t];return h(s,O)?new Proxy(s,new ee(new Proxy(e,this))):s}}function ye(l,e){return new Proxy(l,new ge(e,!1))}function P(l,e){return new Proxy(l,new ee(new Proxy(l.table,new ge(e,!1))))}function je(l,e){return new y.Aliased(te(l.sql,e),l.fieldAlias)}function te(l,e){return n.join(l.queryChunks.map(t=>h(t,O)?P(t,e):h(t,y)?te(t,e):h(t,y.Aliased)?je(t,e):t))}class T{static[f]="SelectionProxyHandler";config;constructor(e){this.config={...e}}get(e,t){if(t==="_")return{...e._,selectedFields:new Proxy(e._.selectedFields,this)};if(t===A)return{...e[A],selectedFields:new Proxy(e[A].selectedFields,this)};if(typeof t=="symbol")return e[t];const s=(h(e,E)?e._.selectedFields:h(e,he)?e[A].selectedFields:e)[t];if(h(s,y.Aliased)){if(this.config.sqlAliasedBehavior==="sql"&&!s.isSelectionField)return s.sql;const i=s.clone();return i.isSelectionField=!0,i}if(h(s,y)){if(this.config.sqlBehavior==="sql")return s;throw new Error(`You tried to reference "${t}" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`)}return h(s,O)?this.config.alias?new Proxy(s,new ee(new Proxy(s.table,new ge(this.config.alias,this.config.replaceOriginalName??!1)))):s:typeof s!="object"||s===null?s:new Proxy(s,new T(this.config))}}class K{static[f]="QueryPromise";[Symbol.toStringTag]="QueryPromise";catch(e){return this.then(void 0,e)}finally(e){return this.then(t=>(e?.(),t),t=>{throw e?.(),t})}then(e,t){return this.execute().then(e,t)}}function k(l){return h(l,R)?[`${l[m.Symbol.BaseName]}`]:h(l,E)?l._.usedTables??[]:h(l,y)?l.usedTables??[]:[]}class Ae extends K{constructor(e,t,s,i){super(),this.table=e,this.session=t,this.dialect=s,this.config={table:e,withList:i}}static[f]="SQLiteDelete";config;where(e){return this.config.where=e,this}orderBy(...e){if(typeof e[0]=="function"){const t=e[0](new Proxy(this.config.table[m.Symbol.Columns],new T({sqlAliasedBehavior:"alias",sqlBehavior:"sql"}))),s=Array.isArray(t)?t:[t];this.config.orderBy=s}else{const t=e;this.config.orderBy=t}return this}limit(e){return this.config.limit=e,this}returning(e=this.table[R.Symbol.Columns]){return this.config.returning=V(e),this}getSQL(){return this.dialect.buildDeleteQuery(this.config)}toSQL(){const{typings:e,...t}=this.dialect.sqlToQuery(this.getSQL());return t}_prepare(e=!0){return this.session[e?"prepareOneTimeQuery":"prepareQuery"](this.dialect.sqlToQuery(this.getSQL()),this.config.returning,this.config.returning?"all":"run",!0,void 0,{type:"delete",tables:k(this.config.table)})}prepare(){return this._prepare(!1)}run=e=>this._prepare().run(e);all=e=>this._prepare().all(e);get=e=>this._prepare().get(e);values=e=>this._prepare().values(e);async execute(e){return this._prepare().execute(e)}$dynamic(){return this}}function Bt(l){return(l.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).map(e=>e.toLowerCase()).join("_")}function jt(l){return(l.replace(/['\u2019]/g,"").match(/[\da-z]+|[A-Z]+(?![a-z])|[A-Z][\da-z]+/g)??[]).reduce((e,t,s)=>{const i=s===0?t.toLowerCase():`${t[0].toUpperCase()}${t.slice(1)}`;return e+i},"")}function At(l){return l}class Rt{static[f]="CasingCache";cache={};cachedTables={};convert;constructor(e){this.convert=e==="snake_case"?Bt:e==="camelCase"?jt:At}getColumnCasing(e){if(!e.keyAsName)return e.name;const t=e.table[m.Symbol.Schema]??"public",s=e.table[m.Symbol.OriginalName],i=`${t}.${s}.${e.name}`;return this.cache[i]||this.cacheTable(e.table),this.cache[i]}cacheTable(e){const t=e[m.Symbol.Schema]??"public",s=e[m.Symbol.OriginalName],i=`${t}.${s}`;if(!this.cachedTables[i]){for(const r of Object.values(e[m.Symbol.Columns])){const a=`${i}.${r.name}`;this.cache[a]=this.convert(r.name)}this.cachedTables[i]=!0}}clearCache(){this.cache={},this.cachedTables={}}}class be extends Error{static[f]="DrizzleError";constructor({message:e,cause:t}){super(e),this.name="DrizzleError",this.cause=t}}class I extends Error{constructor(e,t,s){super(`Failed query: ${e}
2
2
  params: ${t}`),this.query=e,this.params=t,this.cause=s,Error.captureStackTrace(this,I),s&&(this.cause=s)}}class Mt extends be{static[f]="TransactionRollbackError";constructor(){super({message:"Rollback"})}}class we extends he{static[f]="SQLiteViewBase"}class se{static[f]="SQLiteDialect";casing;constructor(e){this.casing=new Rt(e?.casing)}escapeName(e){return`"${e.replace(/"/g,'""')}"`}escapeParam(e){return"?"}escapeString(e){return`'${e.replace(/'/g,"''")}'`}buildWithCTE(e){if(!e?.length)return;const t=[n`with `];for(const[s,i]of e.entries())t.push(n`${n.identifier(i._.alias)} as (${i._.sql})`),s<e.length-1&&t.push(n`, `);return t.push(n` `),n.join(t)}buildDeleteQuery({table:e,where:t,returning:s,withList:i,limit:r,orderBy:a}){const o=this.buildWithCTE(i),c=s?n` returning ${this.buildSelection(s,{isSingleTable:!0})}`:void 0,u=t?n` where ${t}`:void 0,d=this.buildOrderBy(a),g=this.buildLimit(r);return n`${o}delete from ${e}${u}${c}${d}${g}`}buildUpdateSet(e,t){const s=e[m.Symbol.Columns],i=Object.keys(s).filter(a=>t[a]!==void 0||s[a]?.onUpdateFn!==void 0),r=i.length;return n.join(i.flatMap((a,o)=>{const c=s[a],u=c.onUpdateFn?.(),d=t[a]??(h(u,y)?u:n.param(u,c)),g=n`${n.identifier(this.casing.getColumnCasing(c))} = ${d}`;return o<r-1?[g,n.raw(", ")]:[g]}))}buildUpdateQuery({table:e,set:t,where:s,returning:i,withList:r,joins:a,from:o,limit:c,orderBy:u}){const d=this.buildWithCTE(r),g=this.buildUpdateSet(e,t),N=o&&n.join([n.raw(" from "),this.buildFromTable(o)]),Q=this.buildJoins(a),q=i?n` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,w=s?n` where ${s}`:void 0,$=this.buildOrderBy(u),S=this.buildLimit(c);return n`${d}update ${e} set ${g}${N}${Q}${w}${q}${$}${S}`}buildSelection(e,{isSingleTable:t=!1}={}){const s=e.length,i=e.flatMap(({field:r},a)=>{const o=[];if(h(r,y.Aliased)&&r.isSelectionField)o.push(n.identifier(r.fieldAlias));else if(h(r,y.Aliased)||h(r,y)){const c=h(r,y.Aliased)?r.sql:r;t?o.push(new y(c.queryChunks.map(u=>h(u,O)?n.identifier(this.casing.getColumnCasing(u)):u))):o.push(c),h(r,y.Aliased)&&o.push(n` as ${n.identifier(r.fieldAlias)}`)}else if(h(r,O)){const c=r.table[m.Symbol.Name];r.columnType==="SQLiteNumericBigInt"?t?o.push(n`cast(${n.identifier(this.casing.getColumnCasing(r))} as text)`):o.push(n`cast(${n.identifier(c)}.${n.identifier(this.casing.getColumnCasing(r))} as text)`):t?o.push(n.identifier(this.casing.getColumnCasing(r))):o.push(n`${n.identifier(c)}.${n.identifier(this.casing.getColumnCasing(r))}`)}else if(h(r,E)){const c=Object.entries(r._.selectedFields);if(c.length===1){const u=c[0][1],d=h(u,y)?u.decoder:h(u,O)?{mapFromDriverValue:g=>u.mapFromDriverValue(g)}:u.sql.decoder;d&&(r._.sql.decoder=d)}o.push(r)}return a<s-1&&o.push(n`, `),o});return n.join(i)}buildJoins(e){if(!e||e.length===0)return;const t=[];if(e)for(const[s,i]of e.entries()){s===0&&t.push(n` `);const r=i.table,a=i.on?n` on ${i.on}`:void 0;if(h(r,R)){const o=r[R.Symbol.Name],c=r[R.Symbol.Schema],u=r[R.Symbol.OriginalName],d=o===u?void 0:i.alias;t.push(n`${n.raw(i.joinType)} join ${c?n`${n.identifier(c)}.`:void 0}${n.identifier(u)}${d&&n` ${n.identifier(d)}`}${a}`)}else t.push(n`${n.raw(i.joinType)} join ${r}${a}`);s<e.length-1&&t.push(n` `)}return n.join(t)}buildLimit(e){return typeof e=="object"||typeof e=="number"&&e>=0?n` limit ${e}`:void 0}buildOrderBy(e){const t=[];if(e)for(const[s,i]of e.entries())t.push(i),s<e.length-1&&t.push(n`, `);return t.length>0?n` order by ${n.join(t)}`:void 0}buildFromTable(e){return h(e,m)&&e[m.Symbol.IsAlias]?n`${n`${n.identifier(e[m.Symbol.Schema]??"")}.`.if(e[m.Symbol.Schema])}${n.identifier(e[m.Symbol.OriginalName])} ${n.identifier(e[m.Symbol.Name])}`:e}buildSelectQuery({withList:e,fields:t,fieldsFlat:s,where:i,having:r,table:a,joins:o,orderBy:c,groupBy:u,limit:d,offset:g,distinct:N,setOperators:Q}){const q=s??V(t);for(const B of q)if(h(B.field,O)&&Z(B.field.table)!==(h(a,E)?a._.alias:h(a,we)?a[A].name:h(a,y)?void 0:Z(a))&&!(j=>o?.some(({alias:Y})=>Y===(j[m.Symbol.IsAlias]?Z(j):j[m.Symbol.BaseName])))(B.field.table)){const j=Z(B.field.table);throw new Error(`Your "${B.path.join("->")}" field references a column "${j}"."${B.field.name}", but the table "${j}" is not part of the query! Did you forget to join it?`)}const w=!o||o.length===0,$=this.buildWithCTE(e),S=N?n` distinct`:void 0,L=this.buildSelection(q,{isSingleTable:w}),v=this.buildFromTable(a),C=this.buildJoins(o),M=i?n` where ${i}`:void 0,x=r?n` having ${r}`:void 0,p=[];if(u)for(const[B,j]of u.entries())p.push(j),B<u.length-1&&p.push(n`, `);const b=p.length>0?n` group by ${n.join(p)}`:void 0,_=this.buildOrderBy(c),U=this.buildLimit(d),le=g?n` offset ${g}`:void 0,J=n`${$}select${S} ${L} from ${v}${C}${M}${b}${x}${_}${U}${le}`;return Q.length>0?this.buildSetOperations(J,Q):J}buildSetOperations(e,t){const[s,...i]=t;if(!s)throw new Error("Cannot pass undefined values to any set operator");return i.length===0?this.buildSetOperationQuery({leftSelect:e,setOperator:s}):this.buildSetOperations(this.buildSetOperationQuery({leftSelect:e,setOperator:s}),i)}buildSetOperationQuery({leftSelect:e,setOperator:{type:t,isAll:s,rightSelect:i,limit:r,orderBy:a,offset:o}}){const c=n`${e.getSQL()} `,u=n`${i.getSQL()}`;let d;if(a&&a.length>0){const q=[];for(const w of a)if(h(w,ue))q.push(n.identifier(w.name));else if(h(w,y)){for(let $=0;$<w.queryChunks.length;$++){const S=w.queryChunks[$];h(S,ue)&&(w.queryChunks[$]=n.identifier(this.casing.getColumnCasing(S)))}q.push(n`${w}`)}else q.push(n`${w}`);d=n` order by ${n.join(q,n`, `)}`}const g=typeof r=="object"||typeof r=="number"&&r>=0?n` limit ${r}`:void 0,N=n.raw(`${t} ${s?"all ":""}`),Q=o?n` offset ${o}`:void 0;return n`${c}${N}${u}${d}${g}${Q}`}buildInsertQuery({table:e,values:t,onConflict:s,returning:i,withList:r,select:a}){const o=[],c=e[m.Symbol.Columns],u=Object.entries(c).filter(([w,$])=>!$.shouldDisableInsert()),d=u.map(([,w])=>n.identifier(this.casing.getColumnCasing(w)));if(a){const w=t;h(w,y)?o.push(w):o.push(w.getSQL())}else{const w=t;o.push(n.raw("values "));for(const[$,S]of w.entries()){const L=[];for(const[v,C]of u){const M=S[v];if(M===void 0||h(M,Ce)&&M.value===void 0){let x;if(C.default!==null&&C.default!==void 0)x=h(C.default,y)?C.default:n.param(C.default,C);else if(C.defaultFn!==void 0){const p=C.defaultFn();x=h(p,y)?p:n.param(p,C)}else if(!C.default&&C.onUpdateFn!==void 0){const p=C.onUpdateFn();x=h(p,y)?p:n.param(p,C)}else x=n`null`;L.push(x)}else L.push(M)}o.push(L),$<w.length-1&&o.push(n`, `)}}const g=this.buildWithCTE(r),N=n.join(o),Q=i?n` returning ${this.buildSelection(i,{isSingleTable:!0})}`:void 0,q=s?.length?n.join(s):void 0;return n`${g}insert into ${e} ${d} ${N}${q}${Q}`}sqlToQuery(e,t){return e.toQuery({casing:this.casing,escapeName:this.escapeName,escapeParam:this.escapeParam,escapeString:this.escapeString,invokeSource:t})}buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:s,table:i,tableConfig:r,queryConfig:a,tableAlias:o,nestedQueryRelation:c,joinOn:u}){let d=[],g,N,Q=[],q;const w=[];if(a===!0)d=Object.entries(r.columns).map(([S,L])=>({dbKey:L.name,tsKey:S,field:P(L,o),relationTableTsKey:void 0,isJson:!1,selection:[]}));else{const S=Object.fromEntries(Object.entries(r.columns).map(([p,b])=>[p,P(b,o)]));if(a.where){const p=typeof a.where=="function"?a.where(S,Ct()):a.where;q=p&&te(p,o)}const L=[];let v=[];if(a.columns){let p=!1;for(const[b,_]of Object.entries(a.columns))_!==void 0&&b in r.columns&&(!p&&_===!0&&(p=!0),v.push(b));v.length>0&&(v=p?v.filter(b=>a.columns?.[b]===!0):Object.keys(r.columns).filter(b=>!v.includes(b)))}else v=Object.keys(r.columns);for(const p of v){const b=r.columns[p];L.push({tsKey:p,value:b})}let C=[];a.with&&(C=Object.entries(a.with).filter(p=>!!p[1]).map(([p,b])=>({tsKey:p,queryConfig:b,relation:r.relations[p]})));let M;if(a.extras){M=typeof a.extras=="function"?a.extras(S,{sql:n}):a.extras;for(const[p,b]of Object.entries(M))L.push({tsKey:p,value:je(b,o)})}for(const{tsKey:p,value:b}of L)d.push({dbKey:h(b,y.Aliased)?b.fieldAlias:r.columns[p].name,tsKey:p,field:h(b,O)?P(b,o):b,relationTableTsKey:void 0,isJson:!1,selection:[]});let x=typeof a.orderBy=="function"?a.orderBy(S,Nt()):a.orderBy??[];Array.isArray(x)||(x=[x]),Q=x.map(p=>h(p,O)?P(p,o):te(p,o)),g=a.limit,N=a.offset;for(const{tsKey:p,queryConfig:b,relation:_}of C){const U=xt(t,s,_),le=W(_.referencedTable),J=s[le],B=`${o}_${p}`,j=ce(...U.fields.map((Je,ze)=>qe(P(U.references[ze],B),P(Je,o)))),Y=this.buildRelationalQuery({fullSchema:e,schema:t,tableNamesMap:s,table:e[J],tableConfig:t[J],queryConfig:h(_,D)?b===!0?{limit:1}:{...b,limit:1}:b,tableAlias:B,joinOn:j,nestedQueryRelation:_}),De=n`(${Y.sql})`.as(p);d.push({dbKey:p,tsKey:p,field:De,relationTableTsKey:J,isJson:!0,selection:Y.selection})}}if(d.length===0)throw new be({message:`No fields selected for table "${r.tsName}" ("${o}"). You need to have at least one item in "columns", "with" or "extras". If you need to select all columns, omit the "columns" key or set it to undefined.`});let $;if(q=ce(u,q),c){let S=n`json_array(${n.join(d.map(({field:v})=>h(v,ue)?n.identifier(this.casing.getColumnCasing(v)):h(v,y.Aliased)?v.sql:v),n`, `)})`;h(c,ne)&&(S=n`coalesce(json_group_array(${S}), json_array())`);const L=[{dbKey:"data",tsKey:"data",field:S.as("data"),isJson:!0,relationTableTsKey:r.tsName,selection:d}];g!==void 0||N!==void 0||Q.length>0?($=this.buildSelectQuery({table:ye(i,o),fields:{},fieldsFlat:[{path:[],field:n.raw("*")}],where:q,limit:g,offset:N,orderBy:Q,setOperators:[]}),q=void 0,g=void 0,N=void 0,Q=void 0):$=ye(i,o),$=this.buildSelectQuery({table:h($,R)?$:new E($,{},o),fields:{},fieldsFlat:L.map(({field:v})=>({path:[],field:h(v,O)?P(v,o):v})),joins:w,where:q,limit:g,offset:N,orderBy:Q,setOperators:[]})}else $=this.buildSelectQuery({table:ye(i,o),fields:{},fieldsFlat:d.map(({field:S})=>({path:[],field:h(S,O)?P(S,o):S})),joins:w,where:q,limit:g,offset:N,orderBy:Q,setOperators:[]});return{tableTsKey:r.tsName,sql:$,selection:d}}}class _t extends se{static[f]="SQLiteSyncDialect";migrate(e,t,s){const i=s===void 0||typeof s=="string"?"__drizzle_migrations":s.migrationsTable??"__drizzle_migrations",r=n`
3
3
  CREATE TABLE IF NOT EXISTS ${n.identifier(i)} (
4
4
  id SERIAL PRIMARY KEY,
@@ -1 +1 @@
1
- import{aR as c,aS as l,aT as n,P as o,aU as h,aV as u,aW as d,aX as w,aY as y,aZ as m}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{O as f}from"./redocly-openapi-docs.min.Observable-D6wKbFwB.js";const E=new Set(["node_modules"]);class g extends f{constructor(e){super(),this.baseDir=e,this.initializeDirectory(e)}baseDir;writeExcludedKeys=new Set;writeEndTimers=new Map;async initializeDirectory(e){await c(e,{recursive:!0})}setWriteExcludedKeys(e){this.writeExcludedKeys=e}async ls(e){const t=await this.getFullPath(e);return this.getDirEntryFilesRecursively(t)}async getDirEntryFilesRecursively(e){try{const t=[],i=await l(e);for(const s of i)if(s.isDirectory){if(E.has(s.name))continue;const a=await n(e,s.name),r=await this.getDirEntryFilesRecursively(a);t.push(...r)}else{const a=await n(e,s.name),r=await o.relative(this.baseDir,a);t.push(r)}return t}catch(t){return t.includes("forbidden path")||console.error(t),[]}}async get(e){const t=await this.getFullPath(e);try{return await h(t)}catch(i){return!i.includes("No such file or directory")&&!i.includes("forbidden path")&&console.error(i),null}}async has(e){const t=await this.getFullPath(e);return await u(t)}async set(e,t){if(!this.writeExcludedKeys.has(e)){this.emit("write-start",e);try{const i=await this.getFullPath(e),s=m(),a=i.split(s).slice(0,-1).join(s);await c(a,{recursive:!0}),await d(i,t)}finally{const i=this.writeEndTimers.get(e);i&&clearTimeout(i);const s=setTimeout(()=>{this.emit("write-end",e),this.writeEndTimers.delete(e)},1e3);this.writeEndTimers.set(e,s)}}}async remove(e){if(!this.writeExcludedKeys.has(e)){this.emit("write-start",e);try{const t=await this.getFullPath(e);await w(t)}catch(t){!t.includes("No such file or directory")&&!t.includes("forbidden path")&&console.error(t)}finally{const t=this.writeEndTimers.get(e);t&&clearTimeout(t);const i=setTimeout(()=>{this.emit("write-end",e),this.writeEndTimers.delete(e)},1e3);this.writeEndTimers.set(e,i)}}}async rename(e,t){const i=await this.getFullPath(e),s=await this.getFullPath(t);await y(i,s)}async getFullPath(e){return await n(this.baseDir,e??"")}}export{g as TauriFileSystemAdapter};
1
+ import{aS as c,aT as l,aU as n,P as o,aV as h,aW as u,aX as d,aY as w,aZ as y,a_ as m}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{O as f}from"./redocly-openapi-docs.min.Observable-D6wKbFwB.js";const E=new Set(["node_modules"]);class g extends f{constructor(e){super(),this.baseDir=e,this.initializeDirectory(e)}baseDir;writeExcludedKeys=new Set;writeEndTimers=new Map;async initializeDirectory(e){await c(e,{recursive:!0})}setWriteExcludedKeys(e){this.writeExcludedKeys=e}async ls(e){const t=await this.getFullPath(e);return this.getDirEntryFilesRecursively(t)}async getDirEntryFilesRecursively(e){try{const t=[],i=await l(e);for(const s of i)if(s.isDirectory){if(E.has(s.name))continue;const a=await n(e,s.name),r=await this.getDirEntryFilesRecursively(a);t.push(...r)}else{const a=await n(e,s.name),r=await o.relative(this.baseDir,a);t.push(r)}return t}catch(t){return t.includes("forbidden path")||console.error(t),[]}}async get(e){const t=await this.getFullPath(e);try{return await h(t)}catch(i){return!i.includes("No such file or directory")&&!i.includes("forbidden path")&&console.error(i),null}}async has(e){const t=await this.getFullPath(e);return await u(t)}async set(e,t){if(!this.writeExcludedKeys.has(e)){this.emit("write-start",e);try{const i=await this.getFullPath(e),s=m(),a=i.split(s).slice(0,-1).join(s);await c(a,{recursive:!0}),await d(i,t)}finally{const i=this.writeEndTimers.get(e);i&&clearTimeout(i);const s=setTimeout(()=>{this.emit("write-end",e),this.writeEndTimers.delete(e)},1e3);this.writeEndTimers.set(e,s)}}}async remove(e){if(!this.writeExcludedKeys.has(e)){this.emit("write-start",e);try{const t=await this.getFullPath(e);await w(t)}catch(t){!t.includes("No such file or directory")&&!t.includes("forbidden path")&&console.error(t)}finally{const t=this.writeEndTimers.get(e);t&&clearTimeout(t);const i=setTimeout(()=>{this.emit("write-end",e),this.writeEndTimers.delete(e)},1e3);this.writeEndTimers.set(e,i)}}}async rename(e,t){const i=await this.getFullPath(e),s=await this.getFullPath(t);await y(i,s)}async getFullPath(e){return await n(this.baseDir,e??"")}}export{g as TauriFileSystemAdapter};
@@ -1 +1 @@
1
- import{E as ht,S as N,F as ut,G as O,H as B,J as ft,c as F,z as pt,K as dt,L as mt,P as vt}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{p as G}from"./redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js";import{TauriFileSystemAdapter as H}from"./redocly-openapi-docs.min.TauriFileSystemAdapter-CpViFqJQ.js";import{d as wt,w as k}from"./redocly-openapi-docs.min.standalone-BPCdJgtH.js";var R={exports:{}},X;function yt(){return X||(X=1,(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function c(s,o,l){this.fn=s,this.context=o,this.once=l||!1}function a(s,o,l,y,g){if(typeof l!="function")throw new TypeError("The listener must be a function");var m=new c(l,y||s,g),w=e?e+o:o;return s._events[w]?s._events[w].fn?s._events[w]=[s._events[w],m]:s._events[w].push(m):(s._events[w]=m,s._eventsCount++),s}function f(s,o){--s._eventsCount===0?s._events=new i:delete s._events[o]}function h(){this._events=new i,this._eventsCount=0}h.prototype.eventNames=function(){var s=[],o,l;if(this._eventsCount===0)return s;for(l in o=this._events)t.call(o,l)&&s.push(e?l.slice(1):l);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(o)):s},h.prototype.listeners=function(s){var o=e?e+s:s,l=this._events[o];if(!l)return[];if(l.fn)return[l.fn];for(var y=0,g=l.length,m=new Array(g);y<g;y++)m[y]=l[y].fn;return m},h.prototype.listenerCount=function(s){var o=e?e+s:s,l=this._events[o];return l?l.fn?1:l.length:0},h.prototype.emit=function(s,o,l,y,g,m){var w=e?e+s:s;if(!this._events[w])return!1;var u=this._events[w],_=arguments.length,P,v;if(u.fn){switch(u.once&&this.removeListener(s,u.fn,void 0,!0),_){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,o),!0;case 3:return u.fn.call(u.context,o,l),!0;case 4:return u.fn.call(u.context,o,l,y),!0;case 5:return u.fn.call(u.context,o,l,y,g),!0;case 6:return u.fn.call(u.context,o,l,y,g,m),!0}for(v=1,P=new Array(_-1);v<_;v++)P[v-1]=arguments[v];u.fn.apply(u.context,P)}else{var lt=u.length,I;for(v=0;v<lt;v++)switch(u[v].once&&this.removeListener(s,u[v].fn,void 0,!0),_){case 1:u[v].fn.call(u[v].context);break;case 2:u[v].fn.call(u[v].context,o);break;case 3:u[v].fn.call(u[v].context,o,l);break;case 4:u[v].fn.call(u[v].context,o,l,y);break;default:if(!P)for(I=1,P=new Array(_-1);I<_;I++)P[I-1]=arguments[I];u[v].fn.apply(u[v].context,P)}}return!0},h.prototype.on=function(s,o,l){return a(this,s,o,l,!1)},h.prototype.once=function(s,o,l){return a(this,s,o,l,!0)},h.prototype.removeListener=function(s,o,l,y){var g=e?e+s:s;if(!this._events[g])return this;if(!o)return f(this,g),this;var m=this._events[g];if(m.fn)m.fn===o&&(!y||m.once)&&(!l||m.context===l)&&f(this,g);else{for(var w=0,u=[],_=m.length;w<_;w++)(m[w].fn!==o||y&&!m[w].once||l&&m[w].context!==l)&&u.push(m[w]);u.length?this._events[g]=u.length===1?u[0]:u:f(this,g)}return this},h.prototype.removeAllListeners=function(s){var o;return s?(o=e?e+s:s,this._events[o]&&f(this,o)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=e,h.EventEmitter=h,n.exports=h})(R)),R.exports}var gt=yt();const bt=wt(gt);class Z extends Error{constructor(t){super(t),this.name="TimeoutError"}}let St=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n}};const tt=n=>globalThis.DOMException===void 0?new St(n):new DOMException(n),et=n=>{const t=n.reason===void 0?tt("This operation was aborted."):n.reason;return t instanceof Error?t:tt(t)};function _t(n,t,e,i){let c;const a=new Promise((f,h)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t===Number.POSITIVE_INFINITY){f(n);return}if(i={customTimers:{setTimeout,clearTimeout},...i},i.signal){const{signal:s}=i;s.aborted&&h(et(s)),s.addEventListener("abort",()=>{h(et(s))})}c=i.customTimers.setTimeout.call(void 0,()=>{const s=`Promise timed out after ${t} milliseconds`,o=e instanceof Error?e:new Z(s);typeof n.cancel=="function"&&n.cancel(),h(o)},t),(async()=>{try{f(await n)}catch(s){h(s)}finally{i.customTimers.clearTimeout.call(void 0,c)}})()});return a.clear=()=>{clearTimeout(c),c=void 0},a}function Et(n,t,e){let i=0,c=n.length;for(;c>0;){const a=Math.trunc(c/2);let f=i+a;e(n[f],t)<=0?(i=++f,c-=a+1):c=a}return i}var x=function(n,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(n):i?i.value:t.get(n)},C;class Ct{constructor(){C.set(this,[])}enqueue(t,e){e={priority:0,...e};const i={priority:e.priority,run:t};if(this.size&&x(this,C,"f")[this.size-1].priority>=e.priority){x(this,C,"f").push(i);return}const c=Et(x(this,C,"f"),i,(a,f)=>f.priority-a.priority);x(this,C,"f").splice(c,0,i)}dequeue(){return x(this,C,"f").shift()?.run}filter(t){return x(this,C,"f").filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return x(this,C,"f").length}}C=new WeakMap;var p=function(n,t,e,i,c){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!c:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?c.call(n,e):c?c.value=e:t.set(n,e),e},r=function(n,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(n):i?i.value:t.get(n)},d,L,W,T,D,M,$,E,z,b,q,S,j,A,K,it,st,rt,nt,at,Y,Q,J,U,ot,V;class ct extends Error{}class Tt extends bt{constructor(t){var e,i,c,a;if(super(),d.add(this),L.set(this,void 0),W.set(this,void 0),T.set(this,0),D.set(this,void 0),M.set(this,void 0),$.set(this,0),E.set(this,void 0),z.set(this,void 0),b.set(this,void 0),q.set(this,void 0),S.set(this,0),j.set(this,void 0),A.set(this,void 0),K.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Ct,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(e=t.intervalCap)===null||e===void 0?void 0:e.toString())!==null&&i!==void 0?i:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(c=t.interval)===null||c===void 0?void 0:c.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);p(this,L,t.carryoverConcurrencyCount,"f"),p(this,W,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,"f"),p(this,D,t.intervalCap,"f"),p(this,M,t.interval,"f"),p(this,b,new t.queueClass,"f"),p(this,q,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,p(this,K,t.throwOnTimeout===!0,"f"),p(this,A,t.autoStart===!1,"f")}get concurrency(){return r(this,j,"f")}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);p(this,j,t,"f"),r(this,d,"m",U).call(this)}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:r(this,K,"f"),...e},new Promise((i,c)=>{r(this,b,"f").enqueue(async()=>{var a,f,h;p(this,S,(f=r(this,S,"f"),f++,f),"f"),p(this,T,(h=r(this,T,"f"),h++,h),"f");try{if(!((a=e.signal)===null||a===void 0)&&a.aborted)throw new ct("The task was aborted.");let s=t({signal:e.signal});e.timeout&&(s=_t(Promise.resolve(s),e.timeout)),e.signal&&(s=Promise.race([s,r(this,d,"m",ot).call(this,e.signal)]));const o=await s;i(o),this.emit("completed",o)}catch(s){if(s instanceof Z&&!e.throwOnTimeout){i();return}c(s),this.emit("error",s)}finally{r(this,d,"m",rt).call(this)}},e),this.emit("add"),r(this,d,"m",Y).call(this)})}async addAll(t,e){return Promise.all(t.map(async i=>this.add(i,e)))}start(){return r(this,A,"f")?(p(this,A,!1,"f"),r(this,d,"m",U).call(this),this):this}pause(){p(this,A,!0,"f")}clear(){p(this,b,new(r(this,q,"f")),"f")}async onEmpty(){r(this,b,"f").size!==0&&await r(this,d,"m",V).call(this,"empty")}async onSizeLessThan(t){r(this,b,"f").size<t||await r(this,d,"m",V).call(this,"next",()=>r(this,b,"f").size<t)}async onIdle(){r(this,S,"f")===0&&r(this,b,"f").size===0||await r(this,d,"m",V).call(this,"idle")}get size(){return r(this,b,"f").size}sizeBy(t){return r(this,b,"f").filter(t).length}get pending(){return r(this,S,"f")}get isPaused(){return r(this,A,"f")}}L=new WeakMap,W=new WeakMap,T=new WeakMap,D=new WeakMap,M=new WeakMap,$=new WeakMap,E=new WeakMap,z=new WeakMap,b=new WeakMap,q=new WeakMap,S=new WeakMap,j=new WeakMap,A=new WeakMap,K=new WeakMap,d=new WeakSet,it=function(){return r(this,W,"f")||r(this,T,"f")<r(this,D,"f")},st=function(){return r(this,S,"f")<r(this,j,"f")},rt=function(){var n;p(this,S,(n=r(this,S,"f"),n--,n),"f"),r(this,d,"m",Y).call(this),this.emit("next")},nt=function(){r(this,d,"m",J).call(this),r(this,d,"m",Q).call(this),p(this,z,void 0,"f")},at=function(){const n=Date.now();if(r(this,E,"f")===void 0){const t=r(this,$,"f")-n;if(t<0)p(this,T,r(this,L,"f")?r(this,S,"f"):0,"f");else return r(this,z,"f")===void 0&&p(this,z,setTimeout(()=>{r(this,d,"m",nt).call(this)},t),"f"),!0}return!1},Y=function(){if(r(this,b,"f").size===0)return r(this,E,"f")&&clearInterval(r(this,E,"f")),p(this,E,void 0,"f"),this.emit("empty"),r(this,S,"f")===0&&this.emit("idle"),!1;if(!r(this,A,"f")){const n=!r(this,d,"a",at);if(r(this,d,"a",it)&&r(this,d,"a",st)){const t=r(this,b,"f").dequeue();return t?(this.emit("active"),t(),n&&r(this,d,"m",Q).call(this),!0):!1}}return!1},Q=function(){r(this,W,"f")||r(this,E,"f")!==void 0||(p(this,E,setInterval(()=>{r(this,d,"m",J).call(this)},r(this,M,"f")),"f"),p(this,$,Date.now()+r(this,M,"f"),"f"))},J=function(){r(this,T,"f")===0&&r(this,S,"f")===0&&r(this,E,"f")&&(clearInterval(r(this,E,"f")),p(this,E,void 0,"f")),p(this,T,r(this,L,"f")?r(this,S,"f"):0,"f"),r(this,d,"m",U).call(this)},U=function(){for(;r(this,d,"m",Y).call(this););},ot=async function(n){return new Promise((t,e)=>{n.addEventListener("abort",()=>{e(new ct("The task was aborted."))},{once:!0})})},V=async function(n,t){return new Promise(e=>{const i=()=>{t&&!t()||(this.off(n,i),e())};this.on(n,i)})};class At{constructor(t){this.apisStorage=t}apisStorage;data=new Map;loading=new Set;pQueue=new Tt({concurrency:20});async get(t){return this.data.has(t)?this.data.get(t)??null:(await this.loadAndParse(t),this.data.get(t)??null)}async load(t,e=!1){this.data.has(t)&&!e||await this.loadAndParse(t,e)}async loadAndParse(t,e=!1){if(this.loading.has(t)){await this.pQueue.add(()=>this.get(t));return}e&&this.data.delete(t),this.loading.add(t),await this.pQueue.add(async()=>{const i=ht(t)?N.WEB:N.FS,c=i===N.WEB?t:await this.apisStorage.getAbsolutePath(t);try{const{definition:a,fileDependencies:f}=await ut(c);if(!a){this.data.set(t,null),await O(t);return}const h=this.apisStorage.parse({uri:t,type:i,content:a});this.data.set(t,{...h,fileDependencies:f}),await O(t)}catch(a){if(this.data.set(t,null),a instanceof Error&&(a.message.includes("Unsupported specification")||a.message.includes("File not found"))){await O(t);return}console.info("Error loading api "+t,a),await B(t,a);return}}),this.loading.delete(t)}get size(){return this.data.size}delete(t){this.data.delete(t)}getAll(){return Array.from(this.data.values()).filter(t=>t!==null)}clear(){this.data.clear(),this.loading.clear()}}class Pt extends ft{apiLoader;constructor(t,e,i){const c=new H(t.systemFilesDir),a=new H(t.userFilesDir);super(c,a,t,!0,e,i),this.apiLoader=new At(this.apisStorage),this.setupWriteListeners(a)}setupWriteListeners(t){t.on("write-start",e=>{this.addWatchExcludedId(e)}),t.on("write-end",e=>{this.removeWatchExcludedId(e)})}async read(){const t=this.telemetry?.startSpan("com.redocly.storage.read",[F("storageOperation","read","storage")],void 0),e=this.telemetry?.startSpan("com.redocly.storage.loadUserState",[F("storageOperation","loadUserState","storage")],t?.parentCtx),[i,c,a]=await Promise.all([this.activeEnvironmentIdStorage.read(),this.tabsStateStorage.read(),this.environmentsStorage.read()]);e?.setAttribute("status","completed"),e?.setAttribute("environmentCount",a.length),e?.setStatus(k.OK),e?.end();const{apiFiles:f,collectionFiles:h}=await this.detectProjectFiles(t);await this.loadAndParseApis(f,t);const s=(await this.loadAndParseCollections(h,t)).filter(l=>l!==null);this.collectionsStorage.setItemIds(s.map(l=>l.id));const o=this.apiLoader.getAll();return this.apisStorage.setItemIds(o.map(l=>l.id)),t?.setAttribute("status","completed"),t?.setStatus(k.OK),t?.end(),{project:this.project,activeEnvironmentId:i,tabsState:c,environments:a,apis:o,collections:s}}async detectProjectFiles(t){const e=this.telemetry?.startSpan("com.redocly.storage.detectFiles",[F("storageOperation","detectFiles","storage")],t?.parentCtx),{api_files:i,collection_files:c}=await pt("fs_scan",{dir:this.project.userFilesDir});return e?.setAttribute("status","completed"),e?.setAttribute("filesCount",i.length+c.length),e?.setAttribute("apiFilesCount",i.length),e?.setAttribute("collectionFilesCount",c.length),e?.setStatus(k.OK),e?.end(),{apiFiles:i,collectionFiles:c}}readEnviroments(){return this.environmentsStorage.read()}deleteApiFromCache(t){this.apiLoader.delete(t)}async loadAndParseApis(t,e,i=!1){const c=this.telemetry?.startSpan("com.redocly.storage.parseApis",[{...F("storageOperation","parseApis","storage"),apisCount:t.length}],e?.parentCtx),a=await G(t,20,async f=>{try{return await this.apiLoader.load(f.relative_path,i),this.apiLoader.get(f.relative_path)}catch(h){return console.info(`Error parsing YAML/JSON file ${f.absolute_path}:`,h),await B(f.relative_path,h),null}});return c?.setAttribute("status","completed"),c?.setAttribute("parsedApisCount",this.apiLoader.size),c?.setStatus(k.OK),c?.end(),a}async loadAndParseCollections(t,e){const i=this.telemetry?.startSpan("com.redocly.storage.parseCollections",[{...F("storageOperation","parseCollections","storage"),collectionsCount:t.length}],e?.parentCtx),c=await G(t,20,async a=>{try{const f=await this.userFilesStorage.get(a.relative_path);if(!f)return null;const h=dt.load(f);if(typeof h!="object"||h===null||typeof h.arazzo!="string")return await O(a.relative_path),null;const s=[];await Promise.all(h.sourceDescriptions?.map(async y=>{const g=y.type,m=y.url,w=!g||g==="openapi",u=await mt({projectPath:this.project.userFilesDir,apiUrl:m,collectionId:a.relative_path});if(w){const _=await this.apiLoader.get(u);_&&s.push(_)}}));const o=await vt.join(this.project.userFilesDir,a.relative_path),l=await this.collectionsStorage.parse({uri:a.relative_path,type:N.FS,content:h,fileDependencies:new Set([o])},s);return await O(a.relative_path),l}catch(f){return console.info(`Error parsing Arazzo file ${a.relative_path}:`,f),await B(a.relative_path,f),null}});return i?.setAttribute("status","completed"),i?.setAttribute("parsedCollectionsCount",c.length),i?.setStatus(k.OK),i?.end(),c}}export{Pt as TauriRootStorage};
1
+ import{G as ht,S as N,H as ut,J as O,K as B,L as ft,c as F,z as pt,M as dt,N as mt,P as vt}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{p as G}from"./redocly-openapi-docs.min.promise-map-limit-Db_42GvV.js";import{TauriFileSystemAdapter as H}from"./redocly-openapi-docs.min.TauriFileSystemAdapter-Dl2fY3am.js";import{d as wt,w as k}from"./redocly-openapi-docs.min.standalone-D9becCWS.js";var R={exports:{}},X;function yt(){return X||(X=1,(function(n){var t=Object.prototype.hasOwnProperty,e="~";function i(){}Object.create&&(i.prototype=Object.create(null),new i().__proto__||(e=!1));function c(s,o,l){this.fn=s,this.context=o,this.once=l||!1}function a(s,o,l,y,g){if(typeof l!="function")throw new TypeError("The listener must be a function");var m=new c(l,y||s,g),w=e?e+o:o;return s._events[w]?s._events[w].fn?s._events[w]=[s._events[w],m]:s._events[w].push(m):(s._events[w]=m,s._eventsCount++),s}function f(s,o){--s._eventsCount===0?s._events=new i:delete s._events[o]}function h(){this._events=new i,this._eventsCount=0}h.prototype.eventNames=function(){var s=[],o,l;if(this._eventsCount===0)return s;for(l in o=this._events)t.call(o,l)&&s.push(e?l.slice(1):l);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(o)):s},h.prototype.listeners=function(s){var o=e?e+s:s,l=this._events[o];if(!l)return[];if(l.fn)return[l.fn];for(var y=0,g=l.length,m=new Array(g);y<g;y++)m[y]=l[y].fn;return m},h.prototype.listenerCount=function(s){var o=e?e+s:s,l=this._events[o];return l?l.fn?1:l.length:0},h.prototype.emit=function(s,o,l,y,g,m){var w=e?e+s:s;if(!this._events[w])return!1;var u=this._events[w],S=arguments.length,P,v;if(u.fn){switch(u.once&&this.removeListener(s,u.fn,void 0,!0),S){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,o),!0;case 3:return u.fn.call(u.context,o,l),!0;case 4:return u.fn.call(u.context,o,l,y),!0;case 5:return u.fn.call(u.context,o,l,y,g),!0;case 6:return u.fn.call(u.context,o,l,y,g,m),!0}for(v=1,P=new Array(S-1);v<S;v++)P[v-1]=arguments[v];u.fn.apply(u.context,P)}else{var lt=u.length,I;for(v=0;v<lt;v++)switch(u[v].once&&this.removeListener(s,u[v].fn,void 0,!0),S){case 1:u[v].fn.call(u[v].context);break;case 2:u[v].fn.call(u[v].context,o);break;case 3:u[v].fn.call(u[v].context,o,l);break;case 4:u[v].fn.call(u[v].context,o,l,y);break;default:if(!P)for(I=1,P=new Array(S-1);I<S;I++)P[I-1]=arguments[I];u[v].fn.apply(u[v].context,P)}}return!0},h.prototype.on=function(s,o,l){return a(this,s,o,l,!1)},h.prototype.once=function(s,o,l){return a(this,s,o,l,!0)},h.prototype.removeListener=function(s,o,l,y){var g=e?e+s:s;if(!this._events[g])return this;if(!o)return f(this,g),this;var m=this._events[g];if(m.fn)m.fn===o&&(!y||m.once)&&(!l||m.context===l)&&f(this,g);else{for(var w=0,u=[],S=m.length;w<S;w++)(m[w].fn!==o||y&&!m[w].once||l&&m[w].context!==l)&&u.push(m[w]);u.length?this._events[g]=u.length===1?u[0]:u:f(this,g)}return this},h.prototype.removeAllListeners=function(s){var o;return s?(o=e?e+s:s,this._events[o]&&f(this,o)):(this._events=new i,this._eventsCount=0),this},h.prototype.off=h.prototype.removeListener,h.prototype.addListener=h.prototype.on,h.prefixed=e,h.EventEmitter=h,n.exports=h})(R)),R.exports}var gt=yt();const bt=wt(gt);class Z extends Error{constructor(t){super(t),this.name="TimeoutError"}}let Et=class extends Error{constructor(n){super(),this.name="AbortError",this.message=n}};const tt=n=>globalThis.DOMException===void 0?new Et(n):new DOMException(n),et=n=>{const t=n.reason===void 0?tt("This operation was aborted."):n.reason;return t instanceof Error?t:tt(t)};function St(n,t,e,i){let c;const a=new Promise((f,h)=>{if(typeof t!="number"||Math.sign(t)!==1)throw new TypeError(`Expected \`milliseconds\` to be a positive number, got \`${t}\``);if(t===Number.POSITIVE_INFINITY){f(n);return}if(i={customTimers:{setTimeout,clearTimeout},...i},i.signal){const{signal:s}=i;s.aborted&&h(et(s)),s.addEventListener("abort",()=>{h(et(s))})}c=i.customTimers.setTimeout.call(void 0,()=>{const s=`Promise timed out after ${t} milliseconds`,o=e instanceof Error?e:new Z(s);typeof n.cancel=="function"&&n.cancel(),h(o)},t),(async()=>{try{f(await n)}catch(s){h(s)}finally{i.customTimers.clearTimeout.call(void 0,c)}})()});return a.clear=()=>{clearTimeout(c),c=void 0},a}function _t(n,t,e){let i=0,c=n.length;for(;c>0;){const a=Math.trunc(c/2);let f=i+a;e(n[f],t)<=0?(i=++f,c-=a+1):c=a}return i}var x=function(n,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(n):i?i.value:t.get(n)},C;class Ct{constructor(){C.set(this,[])}enqueue(t,e){e={priority:0,...e};const i={priority:e.priority,run:t};if(this.size&&x(this,C,"f")[this.size-1].priority>=e.priority){x(this,C,"f").push(i);return}const c=_t(x(this,C,"f"),i,(a,f)=>f.priority-a.priority);x(this,C,"f").splice(c,0,i)}dequeue(){return x(this,C,"f").shift()?.run}filter(t){return x(this,C,"f").filter(e=>e.priority===t.priority).map(e=>e.run)}get size(){return x(this,C,"f").length}}C=new WeakMap;var p=function(n,t,e,i,c){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!c)throw new TypeError("Private accessor was defined without a setter");if(typeof t=="function"?n!==t||!c:!t.has(n))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?c.call(n,e):c?c.value=e:t.set(n,e),e},r=function(n,t,e,i){if(e==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof t=="function"?n!==t||!i:!t.has(n))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?i:e==="a"?i.call(n):i?i.value:t.get(n)},d,L,M,T,D,W,$,_,z,b,q,E,j,A,K,it,st,rt,nt,at,Y,Q,J,U,ot,V;class ct extends Error{}class Tt extends bt{constructor(t){var e,i,c,a;if(super(),d.add(this),L.set(this,void 0),M.set(this,void 0),T.set(this,0),D.set(this,void 0),W.set(this,void 0),$.set(this,0),_.set(this,void 0),z.set(this,void 0),b.set(this,void 0),q.set(this,void 0),E.set(this,0),j.set(this,void 0),A.set(this,void 0),K.set(this,void 0),Object.defineProperty(this,"timeout",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),t={carryoverConcurrencyCount:!1,intervalCap:Number.POSITIVE_INFINITY,interval:0,concurrency:Number.POSITIVE_INFINITY,autoStart:!0,queueClass:Ct,...t},!(typeof t.intervalCap=="number"&&t.intervalCap>=1))throw new TypeError(`Expected \`intervalCap\` to be a number from 1 and up, got \`${(i=(e=t.intervalCap)===null||e===void 0?void 0:e.toString())!==null&&i!==void 0?i:""}\` (${typeof t.intervalCap})`);if(t.interval===void 0||!(Number.isFinite(t.interval)&&t.interval>=0))throw new TypeError(`Expected \`interval\` to be a finite number >= 0, got \`${(a=(c=t.interval)===null||c===void 0?void 0:c.toString())!==null&&a!==void 0?a:""}\` (${typeof t.interval})`);p(this,L,t.carryoverConcurrencyCount,"f"),p(this,M,t.intervalCap===Number.POSITIVE_INFINITY||t.interval===0,"f"),p(this,D,t.intervalCap,"f"),p(this,W,t.interval,"f"),p(this,b,new t.queueClass,"f"),p(this,q,t.queueClass,"f"),this.concurrency=t.concurrency,this.timeout=t.timeout,p(this,K,t.throwOnTimeout===!0,"f"),p(this,A,t.autoStart===!1,"f")}get concurrency(){return r(this,j,"f")}set concurrency(t){if(!(typeof t=="number"&&t>=1))throw new TypeError(`Expected \`concurrency\` to be a number from 1 and up, got \`${t}\` (${typeof t})`);p(this,j,t,"f"),r(this,d,"m",U).call(this)}async add(t,e={}){return e={timeout:this.timeout,throwOnTimeout:r(this,K,"f"),...e},new Promise((i,c)=>{r(this,b,"f").enqueue(async()=>{var a,f,h;p(this,E,(f=r(this,E,"f"),f++,f),"f"),p(this,T,(h=r(this,T,"f"),h++,h),"f");try{if(!((a=e.signal)===null||a===void 0)&&a.aborted)throw new ct("The task was aborted.");let s=t({signal:e.signal});e.timeout&&(s=St(Promise.resolve(s),e.timeout)),e.signal&&(s=Promise.race([s,r(this,d,"m",ot).call(this,e.signal)]));const o=await s;i(o),this.emit("completed",o)}catch(s){if(s instanceof Z&&!e.throwOnTimeout){i();return}c(s),this.emit("error",s)}finally{r(this,d,"m",rt).call(this)}},e),this.emit("add"),r(this,d,"m",Y).call(this)})}async addAll(t,e){return Promise.all(t.map(async i=>this.add(i,e)))}start(){return r(this,A,"f")?(p(this,A,!1,"f"),r(this,d,"m",U).call(this),this):this}pause(){p(this,A,!0,"f")}clear(){p(this,b,new(r(this,q,"f")),"f")}async onEmpty(){r(this,b,"f").size!==0&&await r(this,d,"m",V).call(this,"empty")}async onSizeLessThan(t){r(this,b,"f").size<t||await r(this,d,"m",V).call(this,"next",()=>r(this,b,"f").size<t)}async onIdle(){r(this,E,"f")===0&&r(this,b,"f").size===0||await r(this,d,"m",V).call(this,"idle")}get size(){return r(this,b,"f").size}sizeBy(t){return r(this,b,"f").filter(t).length}get pending(){return r(this,E,"f")}get isPaused(){return r(this,A,"f")}}L=new WeakMap,M=new WeakMap,T=new WeakMap,D=new WeakMap,W=new WeakMap,$=new WeakMap,_=new WeakMap,z=new WeakMap,b=new WeakMap,q=new WeakMap,E=new WeakMap,j=new WeakMap,A=new WeakMap,K=new WeakMap,d=new WeakSet,it=function(){return r(this,M,"f")||r(this,T,"f")<r(this,D,"f")},st=function(){return r(this,E,"f")<r(this,j,"f")},rt=function(){var n;p(this,E,(n=r(this,E,"f"),n--,n),"f"),r(this,d,"m",Y).call(this),this.emit("next")},nt=function(){r(this,d,"m",J).call(this),r(this,d,"m",Q).call(this),p(this,z,void 0,"f")},at=function(){const n=Date.now();if(r(this,_,"f")===void 0){const t=r(this,$,"f")-n;if(t<0)p(this,T,r(this,L,"f")?r(this,E,"f"):0,"f");else return r(this,z,"f")===void 0&&p(this,z,setTimeout(()=>{r(this,d,"m",nt).call(this)},t),"f"),!0}return!1},Y=function(){if(r(this,b,"f").size===0)return r(this,_,"f")&&clearInterval(r(this,_,"f")),p(this,_,void 0,"f"),this.emit("empty"),r(this,E,"f")===0&&this.emit("idle"),!1;if(!r(this,A,"f")){const n=!r(this,d,"a",at);if(r(this,d,"a",it)&&r(this,d,"a",st)){const t=r(this,b,"f").dequeue();return t?(this.emit("active"),t(),n&&r(this,d,"m",Q).call(this),!0):!1}}return!1},Q=function(){r(this,M,"f")||r(this,_,"f")!==void 0||(p(this,_,setInterval(()=>{r(this,d,"m",J).call(this)},r(this,W,"f")),"f"),p(this,$,Date.now()+r(this,W,"f"),"f"))},J=function(){r(this,T,"f")===0&&r(this,E,"f")===0&&r(this,_,"f")&&(clearInterval(r(this,_,"f")),p(this,_,void 0,"f")),p(this,T,r(this,L,"f")?r(this,E,"f"):0,"f"),r(this,d,"m",U).call(this)},U=function(){for(;r(this,d,"m",Y).call(this););},ot=async function(n){return new Promise((t,e)=>{n.addEventListener("abort",()=>{e(new ct("The task was aborted."))},{once:!0})})},V=async function(n,t){return new Promise(e=>{const i=()=>{t&&!t()||(this.off(n,i),e())};this.on(n,i)})};class At{constructor(t){this.apisStorage=t}apisStorage;data=new Map;loading=new Set;pQueue=new Tt({concurrency:20});async get(t){return this.data.has(t)?this.data.get(t)??null:(await this.loadAndParse(t),this.data.get(t)??null)}async load(t,e=!1){this.data.has(t)&&!e||await this.loadAndParse(t,e)}async loadAndParse(t,e=!1){if(this.loading.has(t)){await this.pQueue.add(()=>this.get(t));return}e&&this.data.delete(t),this.loading.add(t),await this.pQueue.add(async()=>{const i=ht(t)?N.WEB:N.FS,c=i===N.WEB?t:await this.apisStorage.getAbsolutePath(t);try{const{definition:a,fileDependencies:f}=await ut(c);if(!a){this.data.set(t,null),await O(t);return}const h=this.apisStorage.parse({uri:t,type:i,content:a});this.data.set(t,{...h,fileDependencies:f}),await O(t)}catch(a){if(this.data.set(t,null),a instanceof Error&&(a.message.includes("Unsupported specification")||a.message.includes("File not found"))){await O(t);return}console.info("Error loading api "+t,a),await B(t,a);return}}),this.loading.delete(t)}get size(){return this.data.size}delete(t){this.data.delete(t)}getAll(){return Array.from(this.data.values()).filter(t=>t!==null)}clear(){this.data.clear(),this.loading.clear()}}class Pt extends ft{apiLoader;constructor(t,e,i){const c=new H(t.systemFilesDir),a=new H(t.userFilesDir);super(c,a,t,!0,!1,e,i),this.apiLoader=new At(this.apisStorage),this.setupWriteListeners(a)}setupWriteListeners(t){t.on("write-start",e=>{this.addWatchExcludedId(e)}),t.on("write-end",e=>{this.removeWatchExcludedId(e)})}async read(){const t=this.telemetry?.startSpan("com.redocly.storage.read",[F("storageOperation","read","storage")],void 0),e=this.telemetry?.startSpan("com.redocly.storage.loadUserState",[F("storageOperation","loadUserState","storage")],t?.parentCtx),[i,c,a]=await Promise.all([this.activeEnvironmentIdStorage.read(),this.tabsStateStorage.read(),this.environmentsStorage.read()]);e?.setAttribute("status","completed"),e?.setAttribute("environmentCount",a.length),e?.setStatus(k.OK),e?.end();const{apiFiles:f,collectionFiles:h}=await this.detectProjectFiles(t);await this.loadAndParseApis(f,t);const s=(await this.loadAndParseCollections(h,t)).filter(l=>l!==null);this.collectionsStorage.setItemIds(s.map(l=>l.id));const o=this.apiLoader.getAll();return this.apisStorage.setItemIds(o.map(l=>l.id)),t?.setAttribute("status","completed"),t?.setStatus(k.OK),t?.end(),{project:this.project,activeEnvironmentId:i,tabsState:c,environments:a,apis:o,collections:s,configFileError:this.getEnvironmentsConfigError()}}async detectProjectFiles(t){const e=this.telemetry?.startSpan("com.redocly.storage.detectFiles",[F("storageOperation","detectFiles","storage")],t?.parentCtx),{api_files:i,collection_files:c}=await pt("fs_scan",{dir:this.project.userFilesDir});return e?.setAttribute("status","completed"),e?.setAttribute("filesCount",i.length+c.length),e?.setAttribute("apiFilesCount",i.length),e?.setAttribute("collectionFilesCount",c.length),e?.setStatus(k.OK),e?.end(),{apiFiles:i,collectionFiles:c}}readEnviroments(){return this.environmentsStorage.read()}deleteApiFromCache(t){this.apiLoader.delete(t)}async loadAndParseApis(t,e,i=!1){const c=this.telemetry?.startSpan("com.redocly.storage.parseApis",[{...F("storageOperation","parseApis","storage"),apisCount:t.length}],e?.parentCtx),a=await G(t,20,async f=>{try{return await this.apiLoader.load(f.relative_path,i),this.apiLoader.get(f.relative_path)}catch(h){return console.info(`Error parsing YAML/JSON file ${f.absolute_path}:`,h),await B(f.relative_path,h),null}});return c?.setAttribute("status","completed"),c?.setAttribute("parsedApisCount",this.apiLoader.size),c?.setStatus(k.OK),c?.end(),a}async loadAndParseCollections(t,e){const i=this.telemetry?.startSpan("com.redocly.storage.parseCollections",[{...F("storageOperation","parseCollections","storage"),collectionsCount:t.length}],e?.parentCtx),c=await G(t,20,async a=>{try{const f=await this.userFilesStorage.get(a.relative_path);if(!f)return null;const h=dt.load(f);if(typeof h!="object"||h===null||typeof h.arazzo!="string")return await O(a.relative_path),null;const s=[];await Promise.all(h.sourceDescriptions?.map(async y=>{const g=y.type,m=y.url,w=!g||g==="openapi",u=await mt({projectPath:this.project.userFilesDir,apiUrl:m,collectionId:a.relative_path});if(w){const S=await this.apiLoader.get(u);S&&s.push(S)}}));const o=await vt.join(this.project.userFilesDir,a.relative_path),l=await this.collectionsStorage.parse({uri:a.relative_path,type:N.FS,content:h,fileDependencies:new Set([o])},s);return await O(a.relative_path),l}catch(f){return console.info(`Error parsing Arazzo file ${a.relative_path}:`,f),await B(a.relative_path,f),null}});return i?.setAttribute("status","completed"),i?.setAttribute("parsedCollectionsCount",c.length),i?.setStatus(k.OK),i?.end(),c}}export{Pt as TauriRootStorage};
@@ -1 +1 @@
1
- import{A as i}from"./redocly-openapi-docs.min.standalone-BPCdJgtH.js";import{R as u,a4 as n}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";function m(){return`aichat_${i()}`}function l(){return`aimsg_${i()}`}function c(){return`aimpt_${i()}`}function f(t){return{id:t.id,title:t.title??void 0,modelConfig:t.modelConfig,messages:t.messages.map(p),createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}}function p(t){return{id:t.uiId,role:t.role,metadata:t.metadata,parts:t.parts.map(g)}}function g(t){return t.self}function I(t){const a=t.id;return{id:a,title:t.title,modelConfig:t.modelConfig,messages:t.messages.map((e,r)=>d(a,r,e))}}function d(t,a,e,r=l()){return{id:r,uiId:e.id,role:e.role,metadata:e.metadata,aiChatId:t,indexWithinInsertBatch:a,parts:e.parts.map((o,s)=>C(r,s,o))}}function C(t,a,e){return{id:c(),text:e.type==="text"?e.text:null,index:a,self:e,aiMessageId:t}}function h(t){return{id:t.id,title:t.title,modelConfig:v(t.model),messages:t.messages.map(A)}}function v(t){switch(t.provider){case n.OPENAI:case n.ANTHROPIC:case n.GEMINI:return{provider:t.provider,modelId:t.modelId};case u:return{provider:t.provider,baseUrl:t.baseUrl};default:throw new Error("Cannot create model config")}}function A(t){return{...t,parts:t.parts.filter(a=>a.type!=="file")}}export{I as a,h as b,f as c,d,m as g};
1
+ import{A as i}from"./redocly-openapi-docs.min.standalone-D9becCWS.js";import{R as u,a5 as n}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";function m(){return`aichat_${i()}`}function l(){return`aimsg_${i()}`}function c(){return`aimpt_${i()}`}function f(t){return{id:t.id,title:t.title??void 0,modelConfig:t.modelConfig,messages:t.messages.map(p),createdAt:new Date(t.createdAt),updatedAt:new Date(t.updatedAt)}}function p(t){return{id:t.uiId,role:t.role,metadata:t.metadata,parts:t.parts.map(g)}}function g(t){return t.self}function I(t){const a=t.id;return{id:a,title:t.title,modelConfig:t.modelConfig,messages:t.messages.map((e,r)=>d(a,r,e))}}function d(t,a,e,r=l()){return{id:r,uiId:e.id,role:e.role,metadata:e.metadata,aiChatId:t,indexWithinInsertBatch:a,parts:e.parts.map((o,s)=>C(r,s,o))}}function C(t,a,e){return{id:c(),text:e.type==="text"?e.text:null,index:a,self:e,aiMessageId:t}}function h(t){return{id:t.id,title:t.title,modelConfig:v(t.model),messages:t.messages.map(A)}}function v(t){switch(t.provider){case n.OPENAI:case n.ANTHROPIC:case n.GEMINI:return{provider:t.provider,modelId:t.modelId};case u:return{provider:t.provider,baseUrl:t.baseUrl};default:throw new Error("Cannot create model config")}}function A(t){return{...t,parts:t.parts.filter(a=>a.type!=="file")}}export{I as a,h as b,f as c,d,m as g};
@@ -1,2 +1,2 @@
1
- import{a_ as o,ai as n,aV as i,aS as c,aU as l}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";import{aG as f,ao as r,bj as d,b1 as s}from"./redocly-openapi-docs.min.standalone-BPCdJgtH.js";class w extends f{constructor(){super()}resolveExternalRef(e,a){return o(a)?a:e&&o(e)?new URL(a,e).href:e?r.resolve(r.dirname(e),a):a}async loadExternalRef(e){if(o(e)){const{body:a,mimeType:t}=await d(e,{...this.config.http,customFetch:n});return new s(e,a,t)}else{if(!await i(e))throw new Error(`File not found at ${e}.`);try{throw await c(e),new Error(`Expected a file but received a folder at ${e}.`)}catch(t){if(t instanceof Error&&t.message.includes("Expected a file but received a folder"))throw t}const a=await l(e);return new s(e,a.replace(/\r\n/g,`
1
+ import{b3 as o,aj as n,aW as i,aT as c,aV as l}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";import{aG as f,ao as r,bj as d,b1 as s}from"./redocly-openapi-docs.min.standalone-D9becCWS.js";class w extends f{constructor(){super()}resolveExternalRef(e,a){return o(a)?a:e&&o(e)?new URL(a,e).href:e?r.resolve(r.dirname(e),a):a}async loadExternalRef(e){if(o(e)){const{body:a,mimeType:t}=await d(e,{...this.config.http,customFetch:n});return new s(e,a,t)}else{if(!await i(e))throw new Error(`File not found at ${e}.`);try{throw await c(e),new Error(`Expected a file but received a folder at ${e}.`)}catch(t){if(t instanceof Error&&t.message.includes("Expected a file but received a folder"))throw t}const a=await l(e);return new s(e,a.replace(/\r\n/g,`
2
2
  `))}}}export{w as ExternalResolver};
@@ -1 +1 @@
1
- import{z as n}from"./redocly-openapi-docs.min.index-CmXZfuiZ.js";async function t(o={}){return typeof o=="object"&&Object.freeze(o),await n("plugin:dialog|open",{options:o})}export{t as open};
1
+ import{z as n}from"./redocly-openapi-docs.min.index-D9U4Tk7n.js";async function t(o={}){return typeof o=="object"&&Object.freeze(o),await n("plugin:dialog|open",{options:o})}export{t as open};