@apiboost/omnispec 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (347) hide show
  1. package/LICENSE.md +202 -0
  2. package/README.md +166 -0
  3. package/core/package.json +5 -0
  4. package/dist/cjs/asyncapi/index.js +17 -0
  5. package/dist/cjs/asyncapi/index.js.map +1 -0
  6. package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js +819 -0
  7. package/dist/cjs/chunks/AsyncApiSpec-TBlyRxTP.js.map +1 -0
  8. package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js +7527 -0
  9. package/dist/cjs/chunks/Collapsible-BHAHk_Ep.js.map +1 -0
  10. package/dist/cjs/chunks/ErrorBoundary-c1piU8da.js +36 -0
  11. package/dist/cjs/chunks/ErrorBoundary-c1piU8da.js.map +1 -0
  12. package/dist/cjs/chunks/OmniSpecRenderer-CE4wxVTL.js +104 -0
  13. package/dist/cjs/chunks/OmniSpecRenderer-CE4wxVTL.js.map +1 -0
  14. package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js +3157 -0
  15. package/dist/cjs/chunks/OpenApiSpec-D0JtmOVQ.js.map +1 -0
  16. package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js +2416 -0
  17. package/dist/cjs/chunks/OpenIdConnectManual-oEnN0QJ-.js.map +1 -0
  18. package/dist/cjs/chunks/RendererRegistry-DQ7JBLMT.js +24 -0
  19. package/dist/cjs/chunks/RendererRegistry-DQ7JBLMT.js.map +1 -0
  20. package/dist/cjs/chunks/binary-response-CSrPCI-1.js +77 -0
  21. package/dist/cjs/chunks/binary-response-CSrPCI-1.js.map +1 -0
  22. package/dist/cjs/chunks/ref-resolver-DWu6Q6E5.js +7108 -0
  23. package/dist/cjs/chunks/ref-resolver-DWu6Q6E5.js.map +1 -0
  24. package/dist/cjs/chunks/ssrf-guard-B6T2A7Ho.js +25 -0
  25. package/dist/cjs/chunks/ssrf-guard-B6T2A7Ho.js.map +1 -0
  26. package/dist/cjs/chunks/useSpecDetector-A4OwYrmY.js +252 -0
  27. package/dist/cjs/chunks/useSpecDetector-A4OwYrmY.js.map +1 -0
  28. package/dist/cjs/chunks/useSpecFetcher-BKz1jHTV.js +13669 -0
  29. package/dist/cjs/chunks/useSpecFetcher-BKz1jHTV.js.map +1 -0
  30. package/dist/cjs/core/public.js +198 -0
  31. package/dist/cjs/core/public.js.map +1 -0
  32. package/dist/cjs/index.js +36 -0
  33. package/dist/cjs/index.js.map +1 -0
  34. package/dist/cjs/openapi/index.js +19 -0
  35. package/dist/cjs/openapi/index.js.map +1 -0
  36. package/dist/cjs/server/index.js +154 -0
  37. package/dist/cjs/server/index.js.map +1 -0
  38. package/dist/cjs/wc/index.js +428 -0
  39. package/dist/cjs/wc/index.js.map +1 -0
  40. package/dist/esm/asyncapi/index.js +11 -0
  41. package/dist/esm/asyncapi/index.js.map +1 -0
  42. package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js +817 -0
  43. package/dist/esm/chunks/AsyncApiSpec-C3lsUpZk.js.map +1 -0
  44. package/dist/esm/chunks/Collapsible-DA6-nS46.js +7482 -0
  45. package/dist/esm/chunks/Collapsible-DA6-nS46.js.map +1 -0
  46. package/dist/esm/chunks/ErrorBoundary-posRNrbt.js +34 -0
  47. package/dist/esm/chunks/ErrorBoundary-posRNrbt.js.map +1 -0
  48. package/dist/esm/chunks/OmniSpecRenderer-MqsQFXro.js +102 -0
  49. package/dist/esm/chunks/OmniSpecRenderer-MqsQFXro.js.map +1 -0
  50. package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js +3153 -0
  51. package/dist/esm/chunks/OpenApiSpec-Cy-oW6jA.js.map +1 -0
  52. package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js +2393 -0
  53. package/dist/esm/chunks/OpenIdConnectManual-COfITasf.js.map +1 -0
  54. package/dist/esm/chunks/RendererRegistry-zlh-WYbU.js +21 -0
  55. package/dist/esm/chunks/RendererRegistry-zlh-WYbU.js.map +1 -0
  56. package/dist/esm/chunks/binary-response-Cre_H-Rt.js +72 -0
  57. package/dist/esm/chunks/binary-response-Cre_H-Rt.js.map +1 -0
  58. package/dist/esm/chunks/ref-resolver-BIrHJOjz.js +7105 -0
  59. package/dist/esm/chunks/ref-resolver-BIrHJOjz.js.map +1 -0
  60. package/dist/esm/chunks/ssrf-guard-CsZoYdEq.js +23 -0
  61. package/dist/esm/chunks/ssrf-guard-CsZoYdEq.js.map +1 -0
  62. package/dist/esm/chunks/useSpecDetector-5SGcKnJx.js +248 -0
  63. package/dist/esm/chunks/useSpecDetector-5SGcKnJx.js.map +1 -0
  64. package/dist/esm/chunks/useSpecFetcher-CZvAnU7Z.js +13625 -0
  65. package/dist/esm/chunks/useSpecFetcher-CZvAnU7Z.js.map +1 -0
  66. package/dist/esm/core/public.js +102 -0
  67. package/dist/esm/core/public.js.map +1 -0
  68. package/dist/esm/index.js +17 -0
  69. package/dist/esm/index.js.map +1 -0
  70. package/dist/esm/openapi/index.js +13 -0
  71. package/dist/esm/openapi/index.js.map +1 -0
  72. package/dist/esm/server/index.js +152 -0
  73. package/dist/esm/server/index.js.map +1 -0
  74. package/dist/esm/wc/index.js +403 -0
  75. package/dist/esm/wc/index.js.map +1 -0
  76. package/dist/types/asyncapi/AsyncApiSpec.d.ts +12 -0
  77. package/dist/types/asyncapi/AsyncApiSpec.d.ts.map +1 -0
  78. package/dist/types/asyncapi/components/AsyncOverview.d.ts +16 -0
  79. package/dist/types/asyncapi/components/AsyncOverview.d.ts.map +1 -0
  80. package/dist/types/asyncapi/components/ChannelDetail.d.ts +19 -0
  81. package/dist/types/asyncapi/components/ChannelDetail.d.ts.map +1 -0
  82. package/dist/types/asyncapi/components/ComponentsSection.d.ts +16 -0
  83. package/dist/types/asyncapi/components/ComponentsSection.d.ts.map +1 -0
  84. package/dist/types/asyncapi/components/ProtocolBadge.d.ts +16 -0
  85. package/dist/types/asyncapi/components/ProtocolBadge.d.ts.map +1 -0
  86. package/dist/types/asyncapi/components/ServerList.d.ts +16 -0
  87. package/dist/types/asyncapi/components/ServerList.d.ts.map +1 -0
  88. package/dist/types/asyncapi/hooks/useAsyncApiSpec.d.ts +12 -0
  89. package/dist/types/asyncapi/hooks/useAsyncApiSpec.d.ts.map +1 -0
  90. package/dist/types/asyncapi/index.d.ts +11 -0
  91. package/dist/types/asyncapi/index.d.ts.map +1 -0
  92. package/dist/types/asyncapi/parser/asyncapi-parser.d.ts +12 -0
  93. package/dist/types/asyncapi/parser/asyncapi-parser.d.ts.map +1 -0
  94. package/dist/types/asyncapi/types/asyncapi.types.d.ts +125 -0
  95. package/dist/types/asyncapi/types/asyncapi.types.d.ts.map +1 -0
  96. package/dist/types/core/components/Auth/ApiKeyAuth.d.ts +30 -0
  97. package/dist/types/core/components/Auth/ApiKeyAuth.d.ts.map +1 -0
  98. package/dist/types/core/components/Auth/AuthPanel.d.ts +18 -0
  99. package/dist/types/core/components/Auth/AuthPanel.d.ts.map +1 -0
  100. package/dist/types/core/components/Auth/AuthPanelModal.d.ts +24 -0
  101. package/dist/types/core/components/Auth/AuthPanelModal.d.ts.map +1 -0
  102. package/dist/types/core/components/Auth/BasicAuth.d.ts +20 -0
  103. package/dist/types/core/components/Auth/BasicAuth.d.ts.map +1 -0
  104. package/dist/types/core/components/Auth/BearerAuth.d.ts +20 -0
  105. package/dist/types/core/components/Auth/BearerAuth.d.ts.map +1 -0
  106. package/dist/types/core/components/Auth/OAuth2AuthManual.d.ts +37 -0
  107. package/dist/types/core/components/Auth/OAuth2AuthManual.d.ts.map +1 -0
  108. package/dist/types/core/components/Auth/OpenIdConnectManual.d.ts +33 -0
  109. package/dist/types/core/components/Auth/OpenIdConnectManual.d.ts.map +1 -0
  110. package/dist/types/core/components/Auth/SecretInput.d.ts +27 -0
  111. package/dist/types/core/components/Auth/SecretInput.d.ts.map +1 -0
  112. package/dist/types/core/components/Auth/index.d.ts +16 -0
  113. package/dist/types/core/components/Auth/index.d.ts.map +1 -0
  114. package/dist/types/core/components/CodeBlock/CodeBlock.d.ts +32 -0
  115. package/dist/types/core/components/CodeBlock/CodeBlock.d.ts.map +1 -0
  116. package/dist/types/core/components/CodeBlock/index.d.ts +12 -0
  117. package/dist/types/core/components/CodeBlock/index.d.ts.map +1 -0
  118. package/dist/types/core/components/Layout/DocLayout.d.ts +24 -0
  119. package/dist/types/core/components/Layout/DocLayout.d.ts.map +1 -0
  120. package/dist/types/core/components/Layout/MobileDrawerDismissContext.d.ts +20 -0
  121. package/dist/types/core/components/Layout/MobileDrawerDismissContext.d.ts.map +1 -0
  122. package/dist/types/core/components/Layout/SpecStatusScreen.d.ts +38 -0
  123. package/dist/types/core/components/Layout/SpecStatusScreen.d.ts.map +1 -0
  124. package/dist/types/core/components/Layout/index.d.ts +11 -0
  125. package/dist/types/core/components/Layout/index.d.ts.map +1 -0
  126. package/dist/types/core/components/MarkdownRenderer/MarkdownRenderer.d.ts +16 -0
  127. package/dist/types/core/components/MarkdownRenderer/MarkdownRenderer.d.ts.map +1 -0
  128. package/dist/types/core/components/MarkdownRenderer/index.d.ts +11 -0
  129. package/dist/types/core/components/MarkdownRenderer/index.d.ts.map +1 -0
  130. package/dist/types/core/components/Navigation/CustomNavSection.d.ts +16 -0
  131. package/dist/types/core/components/Navigation/CustomNavSection.d.ts.map +1 -0
  132. package/dist/types/core/components/Navigation/NavTree.d.ts +32 -0
  133. package/dist/types/core/components/Navigation/NavTree.d.ts.map +1 -0
  134. package/dist/types/core/components/Navigation/SearchBar.d.ts +16 -0
  135. package/dist/types/core/components/Navigation/SearchBar.d.ts.map +1 -0
  136. package/dist/types/core/components/Navigation/buildSidebar.d.ts +13 -0
  137. package/dist/types/core/components/Navigation/buildSidebar.d.ts.map +1 -0
  138. package/dist/types/core/components/Navigation/index.d.ts +13 -0
  139. package/dist/types/core/components/Navigation/index.d.ts.map +1 -0
  140. package/dist/types/core/components/Reference/ReferenceLayout.d.ts +19 -0
  141. package/dist/types/core/components/Reference/ReferenceLayout.d.ts.map +1 -0
  142. package/dist/types/core/components/Reference/ReferenceOperationDetail.d.ts +42 -0
  143. package/dist/types/core/components/Reference/ReferenceOperationDetail.d.ts.map +1 -0
  144. package/dist/types/core/components/Reference/SamplesPanel.d.ts +33 -0
  145. package/dist/types/core/components/Reference/SamplesPanel.d.ts.map +1 -0
  146. package/dist/types/core/components/SchemaViewer/SchemaPresentation.d.ts +147 -0
  147. package/dist/types/core/components/SchemaViewer/SchemaPresentation.d.ts.map +1 -0
  148. package/dist/types/core/components/SchemaViewer/SchemaPrimitives.d.ts +66 -0
  149. package/dist/types/core/components/SchemaViewer/SchemaPrimitives.d.ts.map +1 -0
  150. package/dist/types/core/components/SchemaViewer/SchemaTable.d.ts +16 -0
  151. package/dist/types/core/components/SchemaViewer/SchemaTable.d.ts.map +1 -0
  152. package/dist/types/core/components/SchemaViewer/SchemaTree.d.ts +26 -0
  153. package/dist/types/core/components/SchemaViewer/SchemaTree.d.ts.map +1 -0
  154. package/dist/types/core/components/SchemaViewer/index.d.ts +16 -0
  155. package/dist/types/core/components/SchemaViewer/index.d.ts.map +1 -0
  156. package/dist/types/core/components/SchemaViewer/schema-style.d.ts +45 -0
  157. package/dist/types/core/components/SchemaViewer/schema-style.d.ts.map +1 -0
  158. package/dist/types/core/components/SchemaViewer/schema-utils.d.ts +83 -0
  159. package/dist/types/core/components/SchemaViewer/schema-utils.d.ts.map +1 -0
  160. package/dist/types/core/components/TryIt/CodeSamples.d.ts +26 -0
  161. package/dist/types/core/components/TryIt/CodeSamples.d.ts.map +1 -0
  162. package/dist/types/core/components/TryIt/CustomHeaders.d.ts +24 -0
  163. package/dist/types/core/components/TryIt/CustomHeaders.d.ts.map +1 -0
  164. package/dist/types/core/components/TryIt/InlineTryIt.d.ts +26 -0
  165. package/dist/types/core/components/TryIt/InlineTryIt.d.ts.map +1 -0
  166. package/dist/types/core/components/TryIt/ParameterForm.d.ts +34 -0
  167. package/dist/types/core/components/TryIt/ParameterForm.d.ts.map +1 -0
  168. package/dist/types/core/components/TryIt/RequestBodyEditor.d.ts +34 -0
  169. package/dist/types/core/components/TryIt/RequestBodyEditor.d.ts.map +1 -0
  170. package/dist/types/core/components/TryIt/ResponseViewer.d.ts +18 -0
  171. package/dist/types/core/components/TryIt/ResponseViewer.d.ts.map +1 -0
  172. package/dist/types/core/components/TryIt/TryItPanel.d.ts +38 -0
  173. package/dist/types/core/components/TryIt/TryItPanel.d.ts.map +1 -0
  174. package/dist/types/core/components/TryIt/code-generators.d.ts +23 -0
  175. package/dist/types/core/components/TryIt/code-generators.d.ts.map +1 -0
  176. package/dist/types/core/components/TryIt/curl-generator.d.ts +12 -0
  177. package/dist/types/core/components/TryIt/curl-generator.d.ts.map +1 -0
  178. package/dist/types/core/components/TryIt/index.d.ts +16 -0
  179. package/dist/types/core/components/TryIt/index.d.ts.map +1 -0
  180. package/dist/types/core/components/common/Badge.d.ts +19 -0
  181. package/dist/types/core/components/common/Badge.d.ts.map +1 -0
  182. package/dist/types/core/components/common/Button.d.ts +44 -0
  183. package/dist/types/core/components/common/Button.d.ts.map +1 -0
  184. package/dist/types/core/components/common/Collapsible.d.ts +23 -0
  185. package/dist/types/core/components/common/Collapsible.d.ts.map +1 -0
  186. package/dist/types/core/components/common/CopyButton.d.ts +16 -0
  187. package/dist/types/core/components/common/CopyButton.d.ts.map +1 -0
  188. package/dist/types/core/components/common/ErrorBoundary.d.ts +40 -0
  189. package/dist/types/core/components/common/ErrorBoundary.d.ts.map +1 -0
  190. package/dist/types/core/components/common/ErrorMessage.d.ts +16 -0
  191. package/dist/types/core/components/common/ErrorMessage.d.ts.map +1 -0
  192. package/dist/types/core/components/common/ExampleSelector.d.ts +29 -0
  193. package/dist/types/core/components/common/ExampleSelector.d.ts.map +1 -0
  194. package/dist/types/core/components/common/ExpandableCard.d.ts +27 -0
  195. package/dist/types/core/components/common/ExpandableCard.d.ts.map +1 -0
  196. package/dist/types/core/components/common/Icon.d.ts +53 -0
  197. package/dist/types/core/components/common/Icon.d.ts.map +1 -0
  198. package/dist/types/core/components/common/LinkableHeading.d.ts +19 -0
  199. package/dist/types/core/components/common/LinkableHeading.d.ts.map +1 -0
  200. package/dist/types/core/components/common/LoadingScreen.d.ts +13 -0
  201. package/dist/types/core/components/common/LoadingScreen.d.ts.map +1 -0
  202. package/dist/types/core/components/common/MethodBar.d.ts +18 -0
  203. package/dist/types/core/components/common/MethodBar.d.ts.map +1 -0
  204. package/dist/types/core/components/common/Modal.d.ts +19 -0
  205. package/dist/types/core/components/common/Modal.d.ts.map +1 -0
  206. package/dist/types/core/components/common/ResponsiveColumns.d.ts +17 -0
  207. package/dist/types/core/components/common/ResponsiveColumns.d.ts.map +1 -0
  208. package/dist/types/core/components/common/SpecToolbar.d.ts +27 -0
  209. package/dist/types/core/components/common/SpecToolbar.d.ts.map +1 -0
  210. package/dist/types/core/components/common/Tabs.d.ts +29 -0
  211. package/dist/types/core/components/common/Tabs.d.ts.map +1 -0
  212. package/dist/types/core/components/common/Tooltip.d.ts +17 -0
  213. package/dist/types/core/components/common/Tooltip.d.ts.map +1 -0
  214. package/dist/types/core/components/common/UpgradePrompt.d.ts +18 -0
  215. package/dist/types/core/components/common/UpgradePrompt.d.ts.map +1 -0
  216. package/dist/types/core/components/common/index.d.ts +18 -0
  217. package/dist/types/core/components/common/index.d.ts.map +1 -0
  218. package/dist/types/core/context/AuthContext.d.ts +35 -0
  219. package/dist/types/core/context/AuthContext.d.ts.map +1 -0
  220. package/dist/types/core/context/ConfigContext.d.ts +55 -0
  221. package/dist/types/core/context/ConfigContext.d.ts.map +1 -0
  222. package/dist/types/core/context/ExpandContext.d.ts +33 -0
  223. package/dist/types/core/context/ExpandContext.d.ts.map +1 -0
  224. package/dist/types/core/context/RendererRegistry.d.ts +24 -0
  225. package/dist/types/core/context/RendererRegistry.d.ts.map +1 -0
  226. package/dist/types/core/context/index.d.ts +14 -0
  227. package/dist/types/core/context/index.d.ts.map +1 -0
  228. package/dist/types/core/hooks/index.d.ts +12 -0
  229. package/dist/types/core/hooks/index.d.ts.map +1 -0
  230. package/dist/types/core/hooks/useHashScroll.d.ts +15 -0
  231. package/dist/types/core/hooks/useHashScroll.d.ts.map +1 -0
  232. package/dist/types/core/hooks/useScrollSpy.d.ts +33 -0
  233. package/dist/types/core/hooks/useScrollSpy.d.ts.map +1 -0
  234. package/dist/types/core/hooks/useSegmentedRouter.d.ts +19 -0
  235. package/dist/types/core/hooks/useSegmentedRouter.d.ts.map +1 -0
  236. package/dist/types/core/hooks/useSpecDetector.d.ts +13 -0
  237. package/dist/types/core/hooks/useSpecDetector.d.ts.map +1 -0
  238. package/dist/types/core/hooks/useSpecFetcher.d.ts +17 -0
  239. package/dist/types/core/hooks/useSpecFetcher.d.ts.map +1 -0
  240. package/dist/types/core/public.d.ts +86 -0
  241. package/dist/types/core/public.d.ts.map +1 -0
  242. package/dist/types/core/styles/breakpoints.d.ts +33 -0
  243. package/dist/types/core/styles/breakpoints.d.ts.map +1 -0
  244. package/dist/types/core/styles/css.d.ts +17 -0
  245. package/dist/types/core/styles/css.d.ts.map +1 -0
  246. package/dist/types/core/styles/styled.d.ts +25 -0
  247. package/dist/types/core/styles/styled.d.ts.map +1 -0
  248. package/dist/types/core/themes/ThemeProvider.d.ts +25 -0
  249. package/dist/types/core/themes/ThemeProvider.d.ts.map +1 -0
  250. package/dist/types/core/themes/index.d.ts +12 -0
  251. package/dist/types/core/themes/index.d.ts.map +1 -0
  252. package/dist/types/core/themes/tokens.d.ts +13 -0
  253. package/dist/types/core/themes/tokens.d.ts.map +1 -0
  254. package/dist/types/core/types/auth.types.d.ts +83 -0
  255. package/dist/types/core/types/auth.types.d.ts.map +1 -0
  256. package/dist/types/core/types/common.types.d.ts +141 -0
  257. package/dist/types/core/types/common.types.d.ts.map +1 -0
  258. package/dist/types/core/types/index.d.ts +16 -0
  259. package/dist/types/core/types/index.d.ts.map +1 -0
  260. package/dist/types/core/types/interactive-auth.types.d.ts +37 -0
  261. package/dist/types/core/types/interactive-auth.types.d.ts.map +1 -0
  262. package/dist/types/core/types/sidebar-nav.types.d.ts +41 -0
  263. package/dist/types/core/types/sidebar-nav.types.d.ts.map +1 -0
  264. package/dist/types/core/types/spec-detection.types.d.ts +26 -0
  265. package/dist/types/core/types/spec-detection.types.d.ts.map +1 -0
  266. package/dist/types/core/types/theme.types.d.ts +119 -0
  267. package/dist/types/core/types/theme.types.d.ts.map +1 -0
  268. package/dist/types/core/types/try-it.types.d.ts +50 -0
  269. package/dist/types/core/types/try-it.types.d.ts.map +1 -0
  270. package/dist/types/core/utils/binary-response.d.ts +24 -0
  271. package/dist/types/core/utils/binary-response.d.ts.map +1 -0
  272. package/dist/types/core/utils/detect-spec.d.ts +12 -0
  273. package/dist/types/core/utils/detect-spec.d.ts.map +1 -0
  274. package/dist/types/core/utils/direct-client.d.ts +20 -0
  275. package/dist/types/core/utils/direct-client.d.ts.map +1 -0
  276. package/dist/types/core/utils/fetch-spec.d.ts +15 -0
  277. package/dist/types/core/utils/fetch-spec.d.ts.map +1 -0
  278. package/dist/types/core/utils/index.d.ts +14 -0
  279. package/dist/types/core/utils/index.d.ts.map +1 -0
  280. package/dist/types/core/utils/proxy-client.d.ts +19 -0
  281. package/dist/types/core/utils/proxy-client.d.ts.map +1 -0
  282. package/dist/types/core/utils/ref-security.d.ts +78 -0
  283. package/dist/types/core/utils/ref-security.d.ts.map +1 -0
  284. package/dist/types/core/utils/resolve-download-link.d.ts +23 -0
  285. package/dist/types/core/utils/resolve-download-link.d.ts.map +1 -0
  286. package/dist/types/core/utils/sanitize-html.d.ts +16 -0
  287. package/dist/types/core/utils/sanitize-html.d.ts.map +1 -0
  288. package/dist/types/core/utils/tryit-storage.d.ts +45 -0
  289. package/dist/types/core/utils/tryit-storage.d.ts.map +1 -0
  290. package/dist/types/index.d.ts +29 -0
  291. package/dist/types/index.d.ts.map +1 -0
  292. package/dist/types/openapi/OpenApiSpec.d.ts +12 -0
  293. package/dist/types/openapi/OpenApiSpec.d.ts.map +1 -0
  294. package/dist/types/openapi/components/ApiOverview.d.ts +19 -0
  295. package/dist/types/openapi/components/ApiOverview.d.ts.map +1 -0
  296. package/dist/types/openapi/components/CallbacksSection.d.ts +19 -0
  297. package/dist/types/openapi/components/CallbacksSection.d.ts.map +1 -0
  298. package/dist/types/openapi/components/ComponentsSection.d.ts +19 -0
  299. package/dist/types/openapi/components/ComponentsSection.d.ts.map +1 -0
  300. package/dist/types/openapi/components/EndpointCard.d.ts +20 -0
  301. package/dist/types/openapi/components/EndpointCard.d.ts.map +1 -0
  302. package/dist/types/openapi/components/OperationDetail.d.ts +28 -0
  303. package/dist/types/openapi/components/OperationDetail.d.ts.map +1 -0
  304. package/dist/types/openapi/components/OperationView.d.ts +19 -0
  305. package/dist/types/openapi/components/OperationView.d.ts.map +1 -0
  306. package/dist/types/openapi/components/SegmentedContent.d.ts +22 -0
  307. package/dist/types/openapi/components/SegmentedContent.d.ts.map +1 -0
  308. package/dist/types/openapi/components/ServerSelector.d.ts +18 -0
  309. package/dist/types/openapi/components/ServerSelector.d.ts.map +1 -0
  310. package/dist/types/openapi/components/TagGroup.d.ts +19 -0
  311. package/dist/types/openapi/components/TagGroup.d.ts.map +1 -0
  312. package/dist/types/openapi/hooks/useOpenApiSpec.d.ts +13 -0
  313. package/dist/types/openapi/hooks/useOpenApiSpec.d.ts.map +1 -0
  314. package/dist/types/openapi/index.d.ts +11 -0
  315. package/dist/types/openapi/index.d.ts.map +1 -0
  316. package/dist/types/openapi/parser/openapi-parser.d.ts +13 -0
  317. package/dist/types/openapi/parser/openapi-parser.d.ts.map +1 -0
  318. package/dist/types/openapi/parser/ref-resolver.d.ts +18 -0
  319. package/dist/types/openapi/parser/ref-resolver.d.ts.map +1 -0
  320. package/dist/types/openapi/search.d.ts +16 -0
  321. package/dist/types/openapi/search.d.ts.map +1 -0
  322. package/dist/types/openapi/types/openapi.types.d.ts +139 -0
  323. package/dist/types/openapi/types/openapi.types.d.ts.map +1 -0
  324. package/dist/types/server/index.d.ts +12 -0
  325. package/dist/types/server/index.d.ts.map +1 -0
  326. package/dist/types/server/proxy-router.d.ts +44 -0
  327. package/dist/types/server/proxy-router.d.ts.map +1 -0
  328. package/dist/types/server/ssrf-guard.d.ts +20 -0
  329. package/dist/types/server/ssrf-guard.d.ts.map +1 -0
  330. package/dist/types/test-setup.d.ts +11 -0
  331. package/dist/types/test-setup.d.ts.map +1 -0
  332. package/dist/types/unified/OmniSpecRenderer.d.ts +18 -0
  333. package/dist/types/unified/OmniSpecRenderer.d.ts.map +1 -0
  334. package/dist/types/unified/index.d.ts +12 -0
  335. package/dist/types/unified/index.d.ts.map +1 -0
  336. package/dist/types/wc/OmniSpecRendererElement.d.ts +48 -0
  337. package/dist/types/wc/OmniSpecRendererElement.d.ts.map +1 -0
  338. package/dist/types/wc/attribute-bridge.d.ts +96 -0
  339. package/dist/types/wc/attribute-bridge.d.ts.map +1 -0
  340. package/dist/types/wc/index.d.ts +42 -0
  341. package/dist/types/wc/index.d.ts.map +1 -0
  342. package/dist/types/wc/style-injection.d.ts +24 -0
  343. package/dist/types/wc/style-injection.d.ts.map +1 -0
  344. package/dist/wc/standalone.js +3 -0
  345. package/dist/wc/standalone.js.LICENSE.txt +65 -0
  346. package/dist/wc/standalone.js.map +1 -0
  347. package/package.json +167 -0
@@ -0,0 +1,2393 @@
1
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
+ import { createContext, useContext, useState, useEffect, useCallback, useMemo, useRef } from 'react';
3
+ import { j as useConfig, m as mq, I as Icon, B as Button } from './useSpecFetcher-CZvAnU7Z.js';
4
+ import { css, cx } from '@emotion/css';
5
+ import { M as MarkdownRenderer, t as SchemaTree, A as schemaToNodes, I as useExpandAll, x as generateExample, C as CodeBlock, T as Tabs } from './Collapsible-DA6-nS46.js';
6
+ import { i as isBinaryContentType, b as bytesToBase64, a as base64ToBlob, f as filenameForResponse } from './binary-response-Cre_H-Rt.js';
7
+
8
+ const AUTH_KEY_PREFIX = "omnispec:auth";
9
+ function getStorage$1() {
10
+ try {
11
+ if (typeof window === "undefined" || !window.localStorage) return null;
12
+ if (typeof window.localStorage.setItem !== "function" || typeof window.localStorage.getItem !== "function") {
13
+ return null;
14
+ }
15
+ return window.localStorage;
16
+ } catch {
17
+ return null;
18
+ }
19
+ }
20
+ function persistEnabled(ttlSeconds) {
21
+ return typeof ttlSeconds === "number" && Number.isFinite(ttlSeconds) && ttlSeconds > 0;
22
+ }
23
+ function authStorageKey(specKey) {
24
+ return `${AUTH_KEY_PREFIX}:${specKey}`;
25
+ }
26
+ function loadPersistedAuth(specKey, ttlSeconds) {
27
+ if (!specKey || !persistEnabled(ttlSeconds)) return /* @__PURE__ */ new Map();
28
+ const storage = getStorage$1();
29
+ if (!storage) return /* @__PURE__ */ new Map();
30
+ const key = authStorageKey(specKey);
31
+ try {
32
+ const raw = storage.getItem(key);
33
+ if (!raw) return /* @__PURE__ */ new Map();
34
+ const parsed = JSON.parse(raw);
35
+ if (!parsed || typeof parsed.savedAt !== "number" || !Array.isArray(parsed.values)) {
36
+ storage.removeItem(key);
37
+ return /* @__PURE__ */ new Map();
38
+ }
39
+ if (Date.now() - parsed.savedAt > ttlSeconds * 1e3) {
40
+ storage.removeItem(key);
41
+ return /* @__PURE__ */ new Map();
42
+ }
43
+ return new Map(parsed.values.filter((v) => v && v.schemeId).map((v) => [v.schemeId, v]));
44
+ } catch {
45
+ return /* @__PURE__ */ new Map();
46
+ }
47
+ }
48
+ function persistAuth(auth, specKey, ttlSeconds) {
49
+ if (!specKey) return;
50
+ const storage = getStorage$1();
51
+ if (!storage) return;
52
+ const key = authStorageKey(specKey);
53
+ try {
54
+ if (!persistEnabled(ttlSeconds) || auth.size === 0) {
55
+ storage.removeItem(key);
56
+ return;
57
+ }
58
+ const envelope = { savedAt: Date.now(), values: Array.from(auth.values()) };
59
+ storage.setItem(key, JSON.stringify(envelope));
60
+ } catch {
61
+ }
62
+ }
63
+ const AuthContext = createContext({
64
+ appliedAuth: /* @__PURE__ */ new Map(),
65
+ applyAuth: () => {
66
+ },
67
+ removeAuth: () => {
68
+ },
69
+ clearAuth: () => {
70
+ },
71
+ getAuthHeaders: () => ({}),
72
+ schemes: [],
73
+ hasAuth: false,
74
+ authPanelOpen: false,
75
+ openAuthPanel: () => {
76
+ },
77
+ closeAuthPanel: () => {
78
+ }
79
+ });
80
+ function useAuth() {
81
+ return useContext(AuthContext);
82
+ }
83
+ function AuthProvider({ children, schemes = [] }) {
84
+ const { specKey, tryItPersistTtl } = useConfig();
85
+ const [appliedAuth, setAppliedAuth] = useState(
86
+ () => loadPersistedAuth(specKey, tryItPersistTtl)
87
+ );
88
+ const [authPanelOpen, setAuthPanelOpen] = useState(false);
89
+ useEffect(() => {
90
+ persistAuth(appliedAuth, specKey, tryItPersistTtl);
91
+ }, [appliedAuth, specKey, tryItPersistTtl]);
92
+ const applyAuth = useCallback((value2) => {
93
+ setAppliedAuth((prev) => {
94
+ const next = new Map(prev);
95
+ next.set(value2.schemeId, value2);
96
+ return next;
97
+ });
98
+ }, []);
99
+ const removeAuth = useCallback((schemeId) => {
100
+ setAppliedAuth((prev) => {
101
+ const next = new Map(prev);
102
+ next.delete(schemeId);
103
+ return next;
104
+ });
105
+ }, []);
106
+ const clearAuth = useCallback(() => {
107
+ setAppliedAuth(/* @__PURE__ */ new Map());
108
+ }, []);
109
+ const getAuthHeaders = useCallback(() => {
110
+ const headers = {};
111
+ for (const auth of appliedAuth.values()) {
112
+ headers[auth.headerName] = auth.headerValue;
113
+ }
114
+ return headers;
115
+ }, [appliedAuth]);
116
+ const openAuthPanel = useCallback(() => setAuthPanelOpen(true), []);
117
+ const closeAuthPanel = useCallback(() => setAuthPanelOpen(false), []);
118
+ const value = useMemo(() => ({
119
+ appliedAuth,
120
+ applyAuth,
121
+ removeAuth,
122
+ clearAuth,
123
+ getAuthHeaders,
124
+ schemes,
125
+ hasAuth: schemes.length > 0,
126
+ authPanelOpen,
127
+ openAuthPanel,
128
+ closeAuthPanel
129
+ }), [appliedAuth, applyAuth, removeAuth, clearAuth, getAuthHeaders, schemes, authPanelOpen, openAuthPanel, closeAuthPanel]);
130
+ return /* @__PURE__ */ jsx(AuthContext.Provider, { value, children });
131
+ }
132
+
133
+ const MOBILE_TABS = [
134
+ { id: "schema", label: "Schema" },
135
+ { id: "samples", label: "Samples" },
136
+ { id: "try-it", label: "Try It" }
137
+ ];
138
+ const RIGHT_TABS = [
139
+ { id: "samples", label: "Samples" },
140
+ { id: "try-it", label: "Try It" }
141
+ ];
142
+ function ReferenceLayout({ schema, samples, tryIt, operationId }) {
143
+ const [rightTab, setRightTab] = useState("samples");
144
+ const [mobileTab, setMobileTab] = useState("schema");
145
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
146
+ /* @__PURE__ */ jsxs("div", { className: mobileWrapperStyle, children: [
147
+ /* @__PURE__ */ jsx("div", { className: mobileTabBarStyle, role: "tablist", children: MOBILE_TABS.map((tab) => /* @__PURE__ */ jsx(
148
+ "button",
149
+ {
150
+ type: "button",
151
+ role: "tab",
152
+ "aria-selected": mobileTab === tab.id,
153
+ "aria-controls": `mobile-panel-${operationId}-${tab.id}`,
154
+ onClick: () => setMobileTab(tab.id),
155
+ className: cx(mobileTabStyle, mobileTab === tab.id ? mobileTabActiveStyle : void 0),
156
+ children: tab.label
157
+ },
158
+ tab.id
159
+ )) }),
160
+ /* @__PURE__ */ jsxs(
161
+ "div",
162
+ {
163
+ id: `mobile-panel-${operationId}-${mobileTab}`,
164
+ className: mobileContentStyle,
165
+ role: "tabpanel",
166
+ children: [
167
+ mobileTab === "schema" && schema,
168
+ mobileTab === "samples" && samples,
169
+ mobileTab === "try-it" && tryIt
170
+ ]
171
+ }
172
+ )
173
+ ] }, `mobile-${operationId}`),
174
+ /* @__PURE__ */ jsxs("div", { className: desktopWrapperStyle, children: [
175
+ /* @__PURE__ */ jsx("div", { className: leftColumnStyle$1, children: schema }),
176
+ /* @__PURE__ */ jsxs("div", { className: rightColumnStyle$1, children: [
177
+ /* @__PURE__ */ jsx("div", { className: rightTabBarStyle, role: "tablist", children: RIGHT_TABS.map((tab) => /* @__PURE__ */ jsx(
178
+ "button",
179
+ {
180
+ type: "button",
181
+ role: "tab",
182
+ "aria-selected": rightTab === tab.id,
183
+ "aria-controls": `right-panel-${operationId}-${tab.id}`,
184
+ onClick: () => setRightTab(tab.id),
185
+ className: cx(rightTabStyle, rightTab === tab.id ? rightTabActiveStyle : void 0),
186
+ children: tab.label
187
+ },
188
+ tab.id
189
+ )) }),
190
+ /* @__PURE__ */ jsxs(
191
+ "div",
192
+ {
193
+ id: `right-panel-${operationId}-${rightTab}`,
194
+ className: rightContentStyle,
195
+ role: "tabpanel",
196
+ children: [
197
+ rightTab === "samples" && samples,
198
+ rightTab === "try-it" && tryIt
199
+ ]
200
+ }
201
+ )
202
+ ] })
203
+ ] }, `desktop-${operationId}`)
204
+ ] });
205
+ }
206
+ const mobileWrapperStyle = css({
207
+ display: "block",
208
+ [mq.desktop]: {
209
+ display: "none"
210
+ }
211
+ });
212
+ const mobileTabBarStyle = css({
213
+ display: "flex",
214
+ borderBottom: "1px solid var(--omnispec-border-color)"
215
+ });
216
+ const mobileTabStyle = css({
217
+ flex: 1,
218
+ textAlign: "center",
219
+ padding: "0.625rem 0.5rem",
220
+ background: "none",
221
+ border: "none",
222
+ borderBottom: "0.125rem solid transparent",
223
+ cursor: "pointer",
224
+ fontSize: "var(--omnispec-font-size-xs)",
225
+ fontWeight: 600,
226
+ letterSpacing: "0.04em",
227
+ textTransform: "uppercase",
228
+ color: "var(--omnispec-fg-secondary)",
229
+ "&:hover": {
230
+ color: "var(--omnispec-fg-primary)"
231
+ }
232
+ });
233
+ const mobileTabActiveStyle = css({
234
+ borderBottom: "0.125rem solid var(--omnispec-color-primary)",
235
+ color: "var(--omnispec-color-primary)"
236
+ });
237
+ const mobileContentStyle = css({
238
+ padding: "1rem 0"
239
+ });
240
+ const desktopWrapperStyle = css({
241
+ display: "none",
242
+ [mq.desktop]: {
243
+ display: "flex",
244
+ alignItems: "flex-start"
245
+ }
246
+ });
247
+ const leftColumnStyle$1 = css({
248
+ flex: 1,
249
+ minWidth: 0,
250
+ padding: "1rem 1.5rem"
251
+ });
252
+ const rightColumnStyle$1 = css({
253
+ width: "26rem",
254
+ flexShrink: 0,
255
+ borderLeft: "1px solid var(--omnispec-border-color)",
256
+ position: "sticky",
257
+ top: "calc(var(--omnispec-offset-top, 0px) + 1rem)",
258
+ alignSelf: "flex-start",
259
+ maxHeight: "calc(100vh - var(--omnispec-offset-top, 0px) - 2rem)",
260
+ overflowY: "auto"
261
+ });
262
+ const rightTabBarStyle = css({
263
+ display: "flex",
264
+ borderBottom: "1px solid var(--omnispec-border-color)"
265
+ });
266
+ const rightTabStyle = css({
267
+ flex: 1,
268
+ textAlign: "center",
269
+ padding: "0.625rem 0.5rem",
270
+ background: "none",
271
+ border: "none",
272
+ borderBottom: "0.125rem solid transparent",
273
+ cursor: "pointer",
274
+ fontSize: "var(--omnispec-font-size-xs)",
275
+ fontWeight: 600,
276
+ letterSpacing: "0.04em",
277
+ textTransform: "uppercase",
278
+ color: "var(--omnispec-fg-secondary)",
279
+ "&:hover": {
280
+ color: "var(--omnispec-fg-primary)"
281
+ }
282
+ });
283
+ const rightTabActiveStyle = css({
284
+ borderBottom: "0.125rem solid var(--omnispec-color-primary)",
285
+ color: "var(--omnispec-color-primary)"
286
+ });
287
+ const rightContentStyle = css({
288
+ padding: "1rem"
289
+ });
290
+
291
+ function buildParamSchemaNodes(parameters) {
292
+ return parameters.map((p) => ({
293
+ name: p.name,
294
+ type: p.schema?.type ?? "any",
295
+ format: p.schema?.format,
296
+ description: p.description,
297
+ required: p.required,
298
+ enum: p.schema?.enum,
299
+ default: p.schema?.default,
300
+ constraints: []
301
+ }));
302
+ }
303
+ function getStatusColor$2(code) {
304
+ const num = parseInt(code, 10);
305
+ if (num >= 200 && num < 300) return "var(--omnispec-color-success)";
306
+ if (num >= 400 && num < 500) return "var(--omnispec-color-warning)";
307
+ if (num >= 500) return "var(--omnispec-color-error)";
308
+ return "var(--omnispec-fg-primary)";
309
+ }
310
+ function getStatusBg$1(code) {
311
+ const num = parseInt(code, 10);
312
+ if (num >= 200 && num < 300) return "rgba(26, 127, 55, 0.08)";
313
+ if (num >= 400 && num < 500) return "rgba(191, 135, 0, 0.08)";
314
+ if (num >= 500) return "rgba(207, 34, 46, 0.08)";
315
+ return "var(--omnispec-bg-tertiary)";
316
+ }
317
+ function ResponseCard({ response }) {
318
+ const [expanded, setExpanded] = useState(false);
319
+ const { expandAll, expandGeneration } = useExpandAll();
320
+ useEffect(() => {
321
+ if (expandGeneration > 0) {
322
+ setExpanded(!!expandAll);
323
+ }
324
+ }, [expandAll, expandGeneration]);
325
+ const statusColor = getStatusColor$2(response.statusCode);
326
+ const statusBg = getStatusBg$1(response.statusCode);
327
+ const hasContent = response.content && Object.keys(response.content).length > 0;
328
+ const header = /* @__PURE__ */ jsxs(Fragment, { children: [
329
+ /* @__PURE__ */ jsx(
330
+ "span",
331
+ {
332
+ className: cx(
333
+ statusPillStyle,
334
+ css({ color: statusColor, backgroundColor: "transparent" })
335
+ ),
336
+ children: response.statusCode
337
+ }
338
+ ),
339
+ /* @__PURE__ */ jsx("span", { className: responseDescStyle, children: response.description })
340
+ ] });
341
+ return /* @__PURE__ */ jsxs(
342
+ "div",
343
+ {
344
+ className: cx(
345
+ responseCardStyle,
346
+ css({
347
+ borderLeft: `0.1875rem solid ${statusColor}`,
348
+ backgroundColor: statusBg
349
+ })
350
+ ),
351
+ children: [
352
+ hasContent ? /* @__PURE__ */ jsxs(
353
+ "button",
354
+ {
355
+ type: "button",
356
+ className: responseCardHeaderStyle,
357
+ onClick: () => setExpanded((prev) => !prev),
358
+ "aria-expanded": expanded,
359
+ children: [
360
+ /* @__PURE__ */ jsx(
361
+ "span",
362
+ {
363
+ className: cx(
364
+ chevronStyle,
365
+ css({ transform: expanded ? "rotate(90deg)" : "rotate(0deg)" })
366
+ ),
367
+ children: /* @__PURE__ */ jsx(Icon, { name: "chevron-right", size: "0.875rem" })
368
+ }
369
+ ),
370
+ header
371
+ ]
372
+ }
373
+ ) : (
374
+ // No response schema — render a static, non-interactive row. The left
375
+ // inset keeps the status pill aligned with the expandable rows' pills.
376
+ /* @__PURE__ */ jsx("div", { className: responseCardStaticHeaderStyle, children: header })
377
+ ),
378
+ expanded && hasContent && /* @__PURE__ */ jsx("div", { className: responseBodyStyle, children: Object.entries(response.content).map(([contentType, media]) => /* @__PURE__ */ jsxs("div", { children: [
379
+ /* @__PURE__ */ jsxs("div", { className: schemaHeaderRowStyle, children: [
380
+ /* @__PURE__ */ jsx("span", { className: sectionLabelStyle, children: "Response Schema" }),
381
+ /* @__PURE__ */ jsx("code", { className: contentTypeBadgeStyle$1, children: contentType })
382
+ ] }),
383
+ media.schema && /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(media.schema), context: "response" })
384
+ ] }, contentType)) })
385
+ ]
386
+ }
387
+ );
388
+ }
389
+ function ParamSection({ title, params }) {
390
+ if (params.length === 0) return null;
391
+ const nodes = buildParamSchemaNodes(params);
392
+ return /* @__PURE__ */ jsxs("div", { className: sectionStyle$1, children: [
393
+ /* @__PURE__ */ jsx("h4", { className: sectionTitleStyle$1, children: title }),
394
+ /* @__PURE__ */ jsx(SchemaTree, { nodes })
395
+ ] });
396
+ }
397
+ function ReferenceOperationDetail({
398
+ description,
399
+ parameters,
400
+ requestBody,
401
+ responses,
402
+ security
403
+ }) {
404
+ const pathParams = parameters.filter((p) => p.in === "path");
405
+ const queryParams = parameters.filter((p) => p.in === "query");
406
+ const headerParams = parameters.filter((p) => p.in === "header");
407
+ return /* @__PURE__ */ jsxs("div", { className: containerStyle$4, children: [
408
+ description && /* @__PURE__ */ jsx("div", { className: sectionStyle$1, children: /* @__PURE__ */ jsx(MarkdownRenderer, { content: description }) }),
409
+ security && security.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle$1, children: [
410
+ /* @__PURE__ */ jsx("h4", { className: sectionTitleStyle$1, children: "Security" }),
411
+ /* @__PURE__ */ jsx("div", { className: securityListStyle, children: security.map((schemes, idx) => /* @__PURE__ */ jsx("div", { className: securityRowStyle, children: schemes.map((scheme) => /* @__PURE__ */ jsxs("span", { className: securityBadgeStyle, children: [
412
+ /* @__PURE__ */ jsx(Icon, { name: "lock", size: "0.625rem", strokeWidth: 2.5 }),
413
+ scheme
414
+ ] }, scheme)) }, idx)) })
415
+ ] }),
416
+ /* @__PURE__ */ jsx(ParamSection, { title: "Path Parameters", params: pathParams }),
417
+ /* @__PURE__ */ jsx(ParamSection, { title: "Query Parameters", params: queryParams }),
418
+ /* @__PURE__ */ jsx(ParamSection, { title: "Header Parameters", params: headerParams }),
419
+ requestBody && /* @__PURE__ */ jsxs("div", { className: sectionStyle$1, children: [
420
+ /* @__PURE__ */ jsxs("div", { className: schemaHeaderRowStyle, children: [
421
+ /* @__PURE__ */ jsx("h4", { className: sectionTitleStyle$1, children: "Request Body" }),
422
+ requestBody.required && /* @__PURE__ */ jsx("span", { className: requiredTagStyle, children: "Required" })
423
+ ] }),
424
+ Object.entries(requestBody.content).map(([contentType, media]) => /* @__PURE__ */ jsxs("div", { children: [
425
+ /* @__PURE__ */ jsx("code", { className: contentTypeBadgeStyle$1, children: contentType }),
426
+ media.schema && /* @__PURE__ */ jsx(SchemaTree, { nodes: schemaToNodes(media.schema), context: "request" })
427
+ ] }, contentType))
428
+ ] }),
429
+ responses.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle$1, children: [
430
+ /* @__PURE__ */ jsxs("div", { className: responsesHeaderRowStyle, children: [
431
+ /* @__PURE__ */ jsx("h4", { className: sectionTitleStyle$1, children: "Responses" }),
432
+ /* @__PURE__ */ jsx("div", { className: statusPillsRowStyle, children: responses.map((r) => /* @__PURE__ */ jsx(
433
+ "span",
434
+ {
435
+ className: cx(
436
+ statusPillStyle,
437
+ css({
438
+ color: getStatusColor$2(r.statusCode),
439
+ backgroundColor: getStatusBg$1(r.statusCode)
440
+ })
441
+ ),
442
+ children: r.statusCode
443
+ },
444
+ r.statusCode
445
+ )) })
446
+ ] }),
447
+ /* @__PURE__ */ jsx("div", { className: responseListStyle, children: responses.map((r) => /* @__PURE__ */ jsx(ResponseCard, { response: r }, r.statusCode)) })
448
+ ] })
449
+ ] });
450
+ }
451
+ const containerStyle$4 = css({
452
+ display: "flex",
453
+ flexDirection: "column"
454
+ });
455
+ const sectionStyle$1 = css({
456
+ marginBottom: "1.5rem"
457
+ });
458
+ const sectionTitleStyle$1 = css({
459
+ margin: "0 0 0.75rem",
460
+ fontSize: "var(--omnispec-font-size-xs)",
461
+ fontWeight: 700,
462
+ letterSpacing: "0.06em",
463
+ textTransform: "uppercase",
464
+ color: "var(--omnispec-fg-muted)"
465
+ });
466
+ const sectionLabelStyle = css({
467
+ fontSize: "var(--omnispec-font-size-xs)",
468
+ fontWeight: 700,
469
+ letterSpacing: "0.06em",
470
+ textTransform: "uppercase",
471
+ color: "var(--omnispec-fg-muted)"
472
+ });
473
+ const securityListStyle = css({
474
+ display: "flex",
475
+ flexDirection: "column",
476
+ gap: "0.375rem"
477
+ });
478
+ const securityRowStyle = css({
479
+ display: "flex",
480
+ alignItems: "center",
481
+ gap: "0.375rem",
482
+ flexWrap: "wrap"
483
+ });
484
+ const securityBadgeStyle = css({
485
+ display: "inline-flex",
486
+ alignItems: "center",
487
+ gap: "0.3125rem",
488
+ fontSize: "var(--omnispec-font-size-xs)",
489
+ fontFamily: "var(--omnispec-font-mono)",
490
+ color: "var(--omnispec-fg-primary)",
491
+ backgroundColor: "var(--omnispec-bg-tertiary)",
492
+ padding: "0.1875rem 0.625rem",
493
+ borderRadius: "0.25rem",
494
+ fontWeight: 500
495
+ });
496
+ const schemaHeaderRowStyle = css({
497
+ display: "flex",
498
+ alignItems: "center",
499
+ gap: "0.5rem",
500
+ marginBottom: "0.5rem",
501
+ flexWrap: "wrap"
502
+ });
503
+ const contentTypeBadgeStyle$1 = css({
504
+ display: "inline-block",
505
+ fontFamily: "var(--omnispec-font-mono)",
506
+ fontSize: "var(--omnispec-font-size-xs)",
507
+ color: "var(--omnispec-fg-muted)",
508
+ backgroundColor: "var(--omnispec-bg-tertiary)",
509
+ padding: "0.125rem 0.5rem",
510
+ borderRadius: "0.25rem"
511
+ });
512
+ const requiredTagStyle = css({
513
+ fontSize: "var(--omnispec-font-size-xxs)",
514
+ fontWeight: 600,
515
+ color: "var(--omnispec-color-error)",
516
+ textTransform: "uppercase",
517
+ letterSpacing: "0.05em"
518
+ });
519
+ const responsesHeaderRowStyle = css({
520
+ display: "flex",
521
+ alignItems: "center",
522
+ gap: "0.75rem",
523
+ marginBottom: "0.75rem",
524
+ flexWrap: "wrap"
525
+ });
526
+ const statusPillsRowStyle = css({
527
+ display: "flex",
528
+ gap: "0.375rem",
529
+ flexWrap: "wrap"
530
+ });
531
+ const statusPillStyle = css({
532
+ display: "inline-block",
533
+ fontFamily: "var(--omnispec-font-mono)",
534
+ fontWeight: 700,
535
+ fontSize: "var(--omnispec-font-size-xs)",
536
+ padding: "0.125rem 0.5rem",
537
+ borderRadius: "0.25rem"
538
+ });
539
+ const responseListStyle = css({
540
+ display: "flex",
541
+ flexDirection: "column",
542
+ gap: "0.5rem"
543
+ });
544
+ const responseCardStyle = css({
545
+ borderRadius: "var(--omnispec-border-radius)",
546
+ overflow: "hidden"
547
+ });
548
+ const responseCardHeaderStyle = css({
549
+ display: "flex",
550
+ alignItems: "center",
551
+ gap: "0.5rem",
552
+ width: "100%",
553
+ padding: "0.625rem 0.75rem",
554
+ background: "none",
555
+ border: "none",
556
+ cursor: "pointer",
557
+ textAlign: "left",
558
+ color: "inherit"
559
+ });
560
+ const responseCardStaticHeaderStyle = css({
561
+ display: "flex",
562
+ alignItems: "center",
563
+ gap: "0.5rem",
564
+ width: "100%",
565
+ padding: "0.625rem 0.75rem 0.625rem 2.125rem",
566
+ color: "inherit"
567
+ });
568
+ const chevronStyle = css({
569
+ display: "inline-flex",
570
+ alignItems: "center",
571
+ flexShrink: 0,
572
+ transition: "transform 0.15s ease",
573
+ color: "var(--omnispec-fg-muted)"
574
+ });
575
+ const responseDescStyle = css({
576
+ fontSize: "var(--omnispec-font-size-sm)",
577
+ color: "var(--omnispec-fg-secondary)",
578
+ flex: 1
579
+ });
580
+ const responseBodyStyle = css({
581
+ padding: "0 0.75rem 0.75rem"
582
+ });
583
+
584
+ function generateCurl(request, serverUrl) {
585
+ const parts = ["curl"];
586
+ if (request.method.toUpperCase() !== "GET") {
587
+ parts.push(`-X ${request.method.toUpperCase()}`);
588
+ }
589
+ let url = serverUrl + request.url;
590
+ for (const [key, value] of Object.entries(request.pathParams)) {
591
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
592
+ }
593
+ const queryEntries = Object.entries(request.queryParams);
594
+ if (queryEntries.length > 0) {
595
+ const params = new URLSearchParams();
596
+ for (const [key, value] of queryEntries) {
597
+ if (Array.isArray(value)) {
598
+ for (const v of value) params.append(key, v);
599
+ } else {
600
+ params.set(key, value);
601
+ }
602
+ }
603
+ url += `?${params.toString()}`;
604
+ }
605
+ parts.push(`'${url}'`);
606
+ for (const [key, value] of Object.entries(request.headers)) {
607
+ parts.push(`-H '${key}: ${value}'`);
608
+ }
609
+ if (request.body && typeof request.body !== "string") {
610
+ request.body.forEach((value, key) => {
611
+ if (typeof value === "string") {
612
+ parts.push(`-F '${key}=${value.replace(/'/g, "'\\''")}'`);
613
+ } else {
614
+ parts.push(`-F '${key}=@${value.name || "file"}'`);
615
+ }
616
+ });
617
+ return parts.join(" \\\n ");
618
+ }
619
+ if (request.body && typeof request.body === "string") {
620
+ if (request.bodyType === "application/x-www-form-urlencoded") {
621
+ try {
622
+ const parsed = JSON.parse(request.body);
623
+ for (const [key, value] of Object.entries(parsed)) {
624
+ parts.push(`--data-urlencode '${key}=${String(value)}'`);
625
+ }
626
+ } catch {
627
+ const escaped = request.body.replace(/'/g, "'\\''");
628
+ parts.push(`-d '${escaped}'`);
629
+ }
630
+ } else {
631
+ const escaped = request.body.replace(/'/g, "'\\''");
632
+ parts.push(`-d '${escaped}'`);
633
+ }
634
+ }
635
+ return parts.join(" \\\n ");
636
+ }
637
+
638
+ function buildUrl(request, serverUrl) {
639
+ let url = serverUrl + request.url;
640
+ for (const [key, value] of Object.entries(request.pathParams)) {
641
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
642
+ }
643
+ const queryEntries = Object.entries(request.queryParams);
644
+ if (queryEntries.length > 0) {
645
+ const params = new URLSearchParams();
646
+ for (const [key, value] of queryEntries) {
647
+ if (Array.isArray(value)) {
648
+ for (const v of value) params.append(key, v);
649
+ } else {
650
+ params.set(key, value);
651
+ }
652
+ }
653
+ url += `?${params.toString()}`;
654
+ }
655
+ return url;
656
+ }
657
+ function generateJavaScript(request, serverUrl) {
658
+ const url = buildUrl(request, serverUrl);
659
+ const method = request.method.toUpperCase();
660
+ const headers = Object.entries(request.headers);
661
+ const hasBody = request.body && typeof request.body === "string";
662
+ const lines = [];
663
+ lines.push(`const response = await fetch('${url}', {`);
664
+ lines.push(` method: '${method}',`);
665
+ if (headers.length > 0) {
666
+ lines.push(" headers: {");
667
+ for (const [key, value] of headers) {
668
+ lines.push(` '${key}': '${value}',`);
669
+ }
670
+ lines.push(" },");
671
+ }
672
+ if (hasBody) {
673
+ lines.push(` body: JSON.stringify(${request.body}),`);
674
+ }
675
+ lines.push("})");
676
+ lines.push("");
677
+ lines.push("const data = await response.json()");
678
+ lines.push("console.log(data)");
679
+ return lines.join("\n");
680
+ }
681
+ function generatePython(request, serverUrl) {
682
+ const url = buildUrl(request, serverUrl);
683
+ const method = request.method.toLowerCase();
684
+ const headers = Object.entries(request.headers);
685
+ const hasBody = request.body && typeof request.body === "string";
686
+ const lines = [];
687
+ lines.push("import requests");
688
+ lines.push("");
689
+ if (headers.length > 0) {
690
+ lines.push("headers = {");
691
+ for (const [key, value] of headers) {
692
+ lines.push(` '${key}': '${value}',`);
693
+ }
694
+ lines.push("}");
695
+ lines.push("");
696
+ }
697
+ if (hasBody) {
698
+ lines.push(`payload = ${request.body}`);
699
+ lines.push("");
700
+ }
701
+ const args = [`'${url}'`];
702
+ if (headers.length > 0) args.push("headers=headers");
703
+ if (hasBody) args.push("json=payload");
704
+ lines.push(`response = requests.${method}(${args.join(", ")})`);
705
+ lines.push("print(response.json())");
706
+ return lines.join("\n");
707
+ }
708
+ function generateGo(request, serverUrl) {
709
+ const url = buildUrl(request, serverUrl);
710
+ const method = request.method.toUpperCase();
711
+ const headers = Object.entries(request.headers);
712
+ const hasBody = request.body && typeof request.body === "string";
713
+ const lines = [];
714
+ lines.push("package main");
715
+ lines.push("");
716
+ lines.push("import (");
717
+ lines.push(' "fmt"');
718
+ lines.push(' "io"');
719
+ lines.push(' "net/http"');
720
+ if (hasBody) lines.push(' "strings"');
721
+ lines.push(")");
722
+ lines.push("");
723
+ lines.push("func main() {");
724
+ if (hasBody) {
725
+ lines.push(` body := strings.NewReader(\`${request.body}\`)`);
726
+ lines.push(` req, err := http.NewRequest("${method}", "${url}", body)`);
727
+ } else {
728
+ lines.push(` req, err := http.NewRequest("${method}", "${url}", nil)`);
729
+ }
730
+ lines.push(" if err != nil {");
731
+ lines.push(" panic(err)");
732
+ lines.push(" }");
733
+ for (const [key, value] of headers) {
734
+ lines.push(` req.Header.Set("${key}", "${value}")`);
735
+ }
736
+ lines.push("");
737
+ lines.push(" resp, err := http.DefaultClient.Do(req)");
738
+ lines.push(" if err != nil {");
739
+ lines.push(" panic(err)");
740
+ lines.push(" }");
741
+ lines.push(" defer resp.Body.Close()");
742
+ lines.push("");
743
+ lines.push(" resBody, _ := io.ReadAll(resp.Body)");
744
+ lines.push(" fmt.Println(string(resBody))");
745
+ lines.push("}");
746
+ return lines.join("\n");
747
+ }
748
+ function generateJava(request, serverUrl) {
749
+ const url = buildUrl(request, serverUrl);
750
+ const method = request.method.toUpperCase();
751
+ const headers = Object.entries(request.headers);
752
+ const hasBody = request.body && typeof request.body === "string";
753
+ const lines = [];
754
+ lines.push("import java.net.URI;");
755
+ lines.push("import java.net.http.HttpClient;");
756
+ lines.push("import java.net.http.HttpRequest;");
757
+ lines.push("import java.net.http.HttpResponse;");
758
+ lines.push("");
759
+ lines.push("HttpClient client = HttpClient.newHttpClient();");
760
+ if (hasBody) {
761
+ lines.push("");
762
+ lines.push('String body = """');
763
+ lines.push(` ${request.body}""";`);
764
+ }
765
+ lines.push("");
766
+ lines.push("HttpRequest request = HttpRequest.newBuilder()");
767
+ lines.push(` .uri(URI.create("${url}"))`);
768
+ if (hasBody) {
769
+ lines.push(` .method("${method}", HttpRequest.BodyPublishers.ofString(body))`);
770
+ } else if (method !== "GET") {
771
+ lines.push(` .method("${method}", HttpRequest.BodyPublishers.noBody())`);
772
+ }
773
+ for (const [key, value] of headers) {
774
+ lines.push(` .header("${key}", "${value}")`);
775
+ }
776
+ lines.push(" .build();");
777
+ lines.push("");
778
+ lines.push("HttpResponse<String> response = client.send(");
779
+ lines.push(" request, HttpResponse.BodyHandlers.ofString());");
780
+ lines.push("System.out.println(response.body());");
781
+ return lines.join("\n");
782
+ }
783
+ function generateCSharp(request, serverUrl) {
784
+ const url = buildUrl(request, serverUrl);
785
+ const method = request.method.toUpperCase();
786
+ const headers = Object.entries(request.headers);
787
+ const hasBody = request.body && typeof request.body === "string";
788
+ const contentType = request.headers["Content-Type"] ?? "application/json";
789
+ const lines = [];
790
+ lines.push("using var client = new HttpClient();");
791
+ lines.push("");
792
+ if (hasBody) {
793
+ lines.push("var content = new StringContent(");
794
+ lines.push(` @"${request.body.replace(/"/g, '""')}",`);
795
+ lines.push(" System.Text.Encoding.UTF8,");
796
+ lines.push(` "${contentType}");`);
797
+ lines.push("");
798
+ }
799
+ const nonContentHeaders = headers.filter(([k]) => k !== "Content-Type");
800
+ for (const [key, value] of nonContentHeaders) {
801
+ lines.push(`client.DefaultRequestHeaders.Add("${key}", "${value}");`);
802
+ }
803
+ if (nonContentHeaders.length > 0) lines.push("");
804
+ const methodMap = {
805
+ GET: "GetAsync",
806
+ POST: "PostAsync",
807
+ PUT: "PutAsync",
808
+ DELETE: "DeleteAsync",
809
+ PATCH: "PatchAsync"
810
+ };
811
+ const asyncMethod = methodMap[method] ?? "SendAsync";
812
+ if (hasBody && (method === "POST" || method === "PUT" || method === "PATCH")) {
813
+ lines.push(`var response = await client.${asyncMethod}("${url}", content);`);
814
+ } else if (method === "GET" || method === "DELETE") {
815
+ lines.push(`var response = await client.${asyncMethod}("${url}");`);
816
+ } else {
817
+ lines.push(`var request = new HttpRequestMessage(HttpMethod.${method.charAt(0) + method.slice(1).toLowerCase()}, "${url}");`);
818
+ if (hasBody) lines.push("request.Content = content;");
819
+ lines.push("var response = await client.SendAsync(request);");
820
+ }
821
+ lines.push("var body = await response.Content.ReadAsStringAsync();");
822
+ lines.push("Console.WriteLine(body);");
823
+ return lines.join("\n");
824
+ }
825
+ const CODE_LANGUAGES = [
826
+ { id: "curl", label: "cURL", prismLanguage: "bash" },
827
+ { id: "javascript", label: "JavaScript", prismLanguage: "javascript" },
828
+ { id: "python", label: "Python", prismLanguage: "python" },
829
+ { id: "go", label: "Go", prismLanguage: "go" },
830
+ { id: "java", label: "Java", prismLanguage: "java" },
831
+ { id: "csharp", label: "C#", prismLanguage: "csharp" }
832
+ ];
833
+
834
+ function ExampleSelector({
835
+ examples,
836
+ selectedName,
837
+ onSelect
838
+ }) {
839
+ if (examples.length <= 1) {
840
+ return null;
841
+ }
842
+ return /* @__PURE__ */ jsxs("div", { className: containerStyle$3, children: [
843
+ /* @__PURE__ */ jsx("label", { htmlFor: "example-selector", className: labelStyle, children: "Example:" }),
844
+ /* @__PURE__ */ jsx(
845
+ "select",
846
+ {
847
+ id: "example-selector",
848
+ value: selectedName,
849
+ onChange: (e) => onSelect(e.target.value),
850
+ className: selectStyle,
851
+ children: examples.map((example) => /* @__PURE__ */ jsx("option", { value: example.name, children: example.summary ? `${example.name} - ${example.summary}` : example.name }, example.name))
852
+ }
853
+ )
854
+ ] });
855
+ }
856
+ function getNamedExamples(media) {
857
+ if (media.example !== void 0) {
858
+ return [{ name: "default", value: media.example }];
859
+ }
860
+ if (media.examples && typeof media.examples === "object") {
861
+ return Object.entries(media.examples).map(([name, example]) => ({
862
+ name,
863
+ summary: example.summary,
864
+ value: example.value
865
+ }));
866
+ }
867
+ return [];
868
+ }
869
+ const containerStyle$3 = css({
870
+ display: "flex",
871
+ alignItems: "center",
872
+ gap: "0.5rem",
873
+ marginBottom: "0.75rem"
874
+ });
875
+ const labelStyle = css({
876
+ fontSize: "var(--omnispec-font-size-xs)",
877
+ fontWeight: 600,
878
+ color: "var(--omnispec-fg-muted)",
879
+ textTransform: "uppercase",
880
+ letterSpacing: "0.5px",
881
+ whiteSpace: "nowrap"
882
+ });
883
+ const selectStyle = css({
884
+ padding: "0.375rem 0.625rem",
885
+ border: "1px solid var(--omnispec-input-border)",
886
+ borderRadius: "var(--omnispec-border-radius)",
887
+ backgroundColor: "var(--omnispec-input-bg)",
888
+ color: "var(--omnispec-fg-primary)",
889
+ fontSize: "var(--omnispec-font-size-sm)",
890
+ fontFamily: "var(--omnispec-font-mono)"
891
+ });
892
+
893
+ const generators$1 = {
894
+ curl: generateCurl,
895
+ javascript: generateJavaScript,
896
+ python: generatePython,
897
+ go: generateGo,
898
+ java: generateJava,
899
+ csharp: generateCSharp
900
+ };
901
+ function getStatusColor$1(statusCode) {
902
+ const code = parseInt(statusCode, 10);
903
+ if (code >= 200 && code < 300) return "var(--omnispec-color-success)";
904
+ if (code >= 400 && code < 500) return "var(--omnispec-color-warning)";
905
+ if (code >= 500) return "var(--omnispec-color-error)";
906
+ return "var(--omnispec-fg-muted)";
907
+ }
908
+ function getStatusBg(statusCode) {
909
+ const code = parseInt(statusCode, 10);
910
+ if (code >= 200 && code < 300) return "rgba(26, 127, 55, 0.15)";
911
+ if (code >= 400 && code < 500) return "rgba(191, 135, 0, 0.15)";
912
+ if (code >= 500) return "rgba(207, 34, 46, 0.15)";
913
+ return "var(--omnispec-bg-secondary)";
914
+ }
915
+ function SamplesPanel({
916
+ method,
917
+ path,
918
+ serverUrl,
919
+ requestBodySchema,
920
+ requestBodyContentType = "application/json",
921
+ responses
922
+ }) {
923
+ const [selectedLang, setSelectedLang] = useState("curl");
924
+ const [selectedResponseIndex, setSelectedResponseIndex] = useState(0);
925
+ const [selectedExampleName, setSelectedExampleName] = useState("");
926
+ const request = useMemo(() => {
927
+ const headers = {};
928
+ const hasBody = requestBodySchema && ["post", "put", "patch", "delete"].includes(method.toLowerCase());
929
+ if (hasBody) {
930
+ headers["Content-Type"] = requestBodyContentType;
931
+ }
932
+ const body = hasBody ? JSON.stringify(generateExample(requestBodySchema), null, 2) : void 0;
933
+ return {
934
+ url: path,
935
+ method: method.toUpperCase(),
936
+ headers,
937
+ queryParams: {},
938
+ pathParams: {},
939
+ body
940
+ };
941
+ }, [method, path, requestBodySchema, requestBodyContentType]);
942
+ const requestCode = useMemo(() => {
943
+ const generator = generators$1[selectedLang];
944
+ return generator ? generator(request, serverUrl) : "";
945
+ }, [request, serverUrl, selectedLang]);
946
+ const langOption = CODE_LANGUAGES.find((l) => l.id === selectedLang);
947
+ const prismLang = langOption?.prismLanguage ?? "text";
948
+ const activeResponse = responses[selectedResponseIndex] ?? null;
949
+ const { namedExamples, responseContentType } = useMemo(() => {
950
+ if (!activeResponse?.content) return { namedExamples: [], responseContentType: null };
951
+ const firstContentType = Object.keys(activeResponse.content)[0];
952
+ const firstMedia = activeResponse.content[firstContentType];
953
+ if (!firstMedia) return { namedExamples: [], responseContentType: firstContentType };
954
+ const examples = getNamedExamples(firstMedia);
955
+ if (examples.length === 0 && firstMedia.schema) {
956
+ return {
957
+ namedExamples: [{ name: "generated", value: generateExample(firstMedia.schema) }],
958
+ responseContentType: firstContentType
959
+ };
960
+ }
961
+ return { namedExamples: examples, responseContentType: firstContentType };
962
+ }, [activeResponse]);
963
+ const responseExampleCode = useMemo(() => {
964
+ if (namedExamples.length === 0) return null;
965
+ const target = selectedExampleName ? namedExamples.find((ex) => ex.name === selectedExampleName) : namedExamples[0];
966
+ const value = target?.value ?? namedExamples[0]?.value ?? null;
967
+ if (value === null) return null;
968
+ return typeof value === "string" ? value : JSON.stringify(value, null, 2);
969
+ }, [namedExamples, selectedExampleName]);
970
+ const languageTabs = /* @__PURE__ */ jsx("div", { className: languageBarStyle$1, children: CODE_LANGUAGES.map((lang) => /* @__PURE__ */ jsx(
971
+ "button",
972
+ {
973
+ type: "button",
974
+ onClick: () => setSelectedLang(lang.id),
975
+ className: cx(langBtnStyle$1, selectedLang === lang.id && langBtnActiveStyle$1),
976
+ children: lang.label
977
+ },
978
+ lang.id
979
+ )) });
980
+ return /* @__PURE__ */ jsxs("div", { className: panelStyle, children: [
981
+ /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
982
+ /* @__PURE__ */ jsxs("div", { className: sectionHeaderStyle, children: [
983
+ /* @__PURE__ */ jsx("span", { className: sectionTitleStyle, children: "Request samples" }),
984
+ requestBodyContentType && /* @__PURE__ */ jsx("code", { className: contentTypeBadgeStyle, children: requestBodyContentType })
985
+ ] }),
986
+ /* @__PURE__ */ jsx(
987
+ CodeBlock,
988
+ {
989
+ code: requestCode,
990
+ language: prismLang,
991
+ showCopy: true,
992
+ headerLeft: languageTabs
993
+ }
994
+ )
995
+ ] }),
996
+ responses.length > 0 && /* @__PURE__ */ jsxs("div", { className: sectionStyle, children: [
997
+ /* @__PURE__ */ jsx("div", { className: sectionHeaderStyle, children: /* @__PURE__ */ jsx("span", { className: sectionTitleStyle, children: "Response samples" }) }),
998
+ /* @__PURE__ */ jsx("div", { className: statusTabsStyle, children: responses.map((res, idx) => {
999
+ const color = getStatusColor$1(res.statusCode);
1000
+ const bg = getStatusBg(res.statusCode);
1001
+ const isActive = idx === selectedResponseIndex;
1002
+ return /* @__PURE__ */ jsx(
1003
+ "button",
1004
+ {
1005
+ type: "button",
1006
+ onClick: () => {
1007
+ setSelectedResponseIndex(idx);
1008
+ setSelectedExampleName("");
1009
+ },
1010
+ className: cx(statusTabStyle, isActive && statusTabActiveStyle),
1011
+ style: {
1012
+ "--status-color": color,
1013
+ "--status-bg": bg
1014
+ },
1015
+ title: res.description,
1016
+ children: res.statusCode
1017
+ },
1018
+ res.statusCode
1019
+ );
1020
+ }) }),
1021
+ responseExampleCode !== null ? /* @__PURE__ */ jsxs("div", { children: [
1022
+ /* @__PURE__ */ jsx("div", { className: contentTypeLabelStyle, children: /* @__PURE__ */ jsx("code", { className: contentTypeBadgeStyle, children: responseContentType }) }),
1023
+ namedExamples.length > 1 && /* @__PURE__ */ jsx(
1024
+ ExampleSelector,
1025
+ {
1026
+ examples: namedExamples,
1027
+ selectedName: selectedExampleName || namedExamples[0]?.name,
1028
+ onSelect: setSelectedExampleName
1029
+ }
1030
+ ),
1031
+ /* @__PURE__ */ jsx(
1032
+ CodeBlock,
1033
+ {
1034
+ code: responseExampleCode,
1035
+ language: "json",
1036
+ showCopy: true
1037
+ }
1038
+ )
1039
+ ] }) : /* @__PURE__ */ jsx("div", { className: emptyStateStyle, children: "No response sample available." })
1040
+ ] })
1041
+ ] });
1042
+ }
1043
+ const panelStyle = css({
1044
+ display: "flex",
1045
+ flexDirection: "column",
1046
+ gap: "1.5rem"
1047
+ });
1048
+ const sectionStyle = css({
1049
+ display: "flex",
1050
+ flexDirection: "column",
1051
+ gap: "0.5rem"
1052
+ });
1053
+ const sectionHeaderStyle = css({
1054
+ display: "flex",
1055
+ alignItems: "center",
1056
+ gap: "0.5rem",
1057
+ flexWrap: "wrap"
1058
+ });
1059
+ const sectionTitleStyle = css({
1060
+ fontSize: "var(--omnispec-font-size-sm)",
1061
+ fontWeight: 600,
1062
+ color: "var(--omnispec-fg-primary)",
1063
+ [mq.desktop]: {
1064
+ fontSize: "var(--omnispec-font-size-base)"
1065
+ }
1066
+ });
1067
+ const contentTypeBadgeStyle = css({
1068
+ fontSize: "var(--omnispec-font-size-xs)",
1069
+ fontFamily: "var(--omnispec-font-mono)",
1070
+ color: "var(--omnispec-fg-muted)",
1071
+ backgroundColor: "var(--omnispec-bg-secondary)",
1072
+ padding: "0.125rem 0.375rem",
1073
+ borderRadius: "var(--omnispec-border-radius)"
1074
+ });
1075
+ const languageBarStyle$1 = css({
1076
+ display: "flex",
1077
+ gap: "0.125rem",
1078
+ overflowX: "auto",
1079
+ scrollbarWidth: "none",
1080
+ "&::-webkit-scrollbar": {
1081
+ display: "none"
1082
+ }
1083
+ });
1084
+ const langBtnStyle$1 = css({
1085
+ padding: "0.25rem 0.5rem",
1086
+ background: "none",
1087
+ border: "none",
1088
+ cursor: "pointer",
1089
+ fontSize: "var(--omnispec-font-size-xs)",
1090
+ fontWeight: 500,
1091
+ color: "var(--omnispec-fg-muted)",
1092
+ whiteSpace: "nowrap",
1093
+ borderRadius: "var(--omnispec-border-radius)",
1094
+ "&:hover": {
1095
+ color: "var(--omnispec-fg-primary)",
1096
+ backgroundColor: "var(--omnispec-bg-secondary)"
1097
+ }
1098
+ });
1099
+ const langBtnActiveStyle$1 = css({
1100
+ color: "var(--omnispec-color-primary)",
1101
+ backgroundColor: "var(--omnispec-bg-secondary)",
1102
+ fontWeight: 600
1103
+ });
1104
+ const statusTabsStyle = css({
1105
+ display: "flex",
1106
+ flexWrap: "wrap",
1107
+ gap: "0.375rem"
1108
+ });
1109
+ const statusTabStyle = css({
1110
+ padding: "0.25rem 0.625rem",
1111
+ border: "none",
1112
+ borderRadius: "var(--omnispec-border-radius)",
1113
+ cursor: "pointer",
1114
+ fontSize: "var(--omnispec-font-size-xs)",
1115
+ fontWeight: 600,
1116
+ fontFamily: "var(--omnispec-font-mono)",
1117
+ opacity: 0.65,
1118
+ backgroundColor: "var(--status-bg)",
1119
+ color: "var(--status-color)",
1120
+ transition: "opacity 0.15s, box-shadow 0.15s",
1121
+ "&:hover": {
1122
+ opacity: 0.85
1123
+ }
1124
+ });
1125
+ const statusTabActiveStyle = css({
1126
+ opacity: 1,
1127
+ boxShadow: "0 0 0 1px var(--status-color)"
1128
+ });
1129
+ const contentTypeLabelStyle = css({
1130
+ marginBottom: "0.25rem"
1131
+ });
1132
+ const emptyStateStyle = css({
1133
+ fontSize: "var(--omnispec-font-size-sm)",
1134
+ color: "var(--omnispec-fg-muted)",
1135
+ padding: "0.75rem 0"
1136
+ });
1137
+
1138
+ function LinkableHeading({ id, as: Tag = "h3", className, children }) {
1139
+ const [copied, setCopied] = useState(false);
1140
+ const handleCopy = useCallback((e) => {
1141
+ e.preventDefault();
1142
+ const url = `${window.location.origin}${window.location.pathname}#${id}`;
1143
+ navigator.clipboard.writeText(url).then(() => {
1144
+ setCopied(true);
1145
+ setTimeout(() => setCopied(false), 1500);
1146
+ });
1147
+ }, [id]);
1148
+ return /* @__PURE__ */ jsxs(Tag, { id, className: `${containerStyle$2} ${className ?? ""}`, children: [
1149
+ children,
1150
+ /* @__PURE__ */ jsx(
1151
+ "a",
1152
+ {
1153
+ href: `#${id}`,
1154
+ onClick: handleCopy,
1155
+ className: linkIconStyle,
1156
+ "aria-label": "Copy link to section",
1157
+ title: copied ? "Copied!" : "Copy link",
1158
+ children: /* @__PURE__ */ jsx(Icon, { name: "link", size: "0.75em" })
1159
+ }
1160
+ )
1161
+ ] });
1162
+ }
1163
+ const containerStyle$2 = css({
1164
+ position: "relative",
1165
+ display: "flex",
1166
+ alignItems: "center",
1167
+ gap: "0.5rem",
1168
+ "&:hover a": {
1169
+ opacity: 1
1170
+ }
1171
+ });
1172
+ const linkIconStyle = css({
1173
+ opacity: 0,
1174
+ color: "var(--omnispec-fg-muted)",
1175
+ transition: "opacity 0.15s",
1176
+ flexShrink: 0,
1177
+ lineHeight: 1,
1178
+ textDecoration: "none",
1179
+ "&:hover": {
1180
+ color: "var(--omnispec-color-primary)"
1181
+ }
1182
+ });
1183
+
1184
+ function Modal({ open, onClose, title, children }) {
1185
+ useEffect(() => {
1186
+ if (!open) return void 0;
1187
+ const handleKey = (e) => {
1188
+ if (e.key === "Escape") onClose();
1189
+ };
1190
+ document.addEventListener("keydown", handleKey);
1191
+ document.body.style.overflow = "hidden";
1192
+ return () => {
1193
+ document.removeEventListener("keydown", handleKey);
1194
+ document.body.style.overflow = "";
1195
+ };
1196
+ }, [open, onClose]);
1197
+ if (!open) return null;
1198
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
1199
+ /* @__PURE__ */ jsx(
1200
+ "div",
1201
+ {
1202
+ className: backdropStyle,
1203
+ onClick: onClose,
1204
+ "aria-hidden": "true"
1205
+ }
1206
+ ),
1207
+ /* @__PURE__ */ jsxs(
1208
+ "div",
1209
+ {
1210
+ className: dialogStyle,
1211
+ role: "dialog",
1212
+ "aria-modal": "true",
1213
+ "aria-label": title,
1214
+ children: [
1215
+ /* @__PURE__ */ jsxs("div", { className: headerStyle, children: [
1216
+ title && /* @__PURE__ */ jsx("h3", { className: titleStyle, children: title }),
1217
+ /* @__PURE__ */ jsx(
1218
+ "button",
1219
+ {
1220
+ type: "button",
1221
+ onClick: onClose,
1222
+ className: closeBtnStyle,
1223
+ "aria-label": "Close",
1224
+ children: "\xD7"
1225
+ }
1226
+ )
1227
+ ] }),
1228
+ /* @__PURE__ */ jsx("div", { className: bodyStyle, children })
1229
+ ]
1230
+ }
1231
+ )
1232
+ ] });
1233
+ }
1234
+ const backdropStyle = css({
1235
+ position: "fixed",
1236
+ inset: 0,
1237
+ backgroundColor: "rgba(0, 0, 0, 0.5)",
1238
+ zIndex: 1100
1239
+ });
1240
+ const dialogStyle = css({
1241
+ position: "fixed",
1242
+ top: "50%",
1243
+ left: "50%",
1244
+ transform: "translate(-50%, -50%)",
1245
+ width: "90%",
1246
+ maxWidth: "768px",
1247
+ maxHeight: "85vh",
1248
+ backgroundColor: "var(--omnispec-bg-primary)",
1249
+ borderRadius: "12px",
1250
+ boxShadow: "0 20px 60px rgba(0, 0, 0, 0.2)",
1251
+ zIndex: 1101,
1252
+ display: "flex",
1253
+ flexDirection: "column",
1254
+ overflow: "hidden"
1255
+ });
1256
+ const headerStyle = css({
1257
+ display: "flex",
1258
+ alignItems: "center",
1259
+ justifyContent: "space-between",
1260
+ padding: "16px 20px",
1261
+ borderBottom: "1px solid var(--omnispec-border-color)"
1262
+ });
1263
+ const titleStyle = css({
1264
+ margin: 0,
1265
+ fontSize: "var(--omnispec-h3-font-size)",
1266
+ fontWeight: 600,
1267
+ color: "var(--omnispec-color-primary)"
1268
+ });
1269
+ const closeBtnStyle = css({
1270
+ background: "none",
1271
+ border: "none",
1272
+ cursor: "pointer",
1273
+ fontSize: "24px",
1274
+ lineHeight: 1,
1275
+ color: "var(--omnispec-fg-muted)",
1276
+ padding: "4px 8px",
1277
+ borderRadius: "4px",
1278
+ "&:hover": {
1279
+ color: "var(--omnispec-fg-primary)",
1280
+ backgroundColor: "var(--omnispec-bg-secondary)"
1281
+ }
1282
+ });
1283
+ const bodyStyle = css({
1284
+ padding: "20px",
1285
+ overflowY: "auto",
1286
+ flex: 1
1287
+ });
1288
+
1289
+ const PREFIX = "omnispec:tryit";
1290
+ function storageKey(specKey, operationKey) {
1291
+ return `${PREFIX}:${specKey}:${operationKey}`;
1292
+ }
1293
+ function isEnvelope(value) {
1294
+ return typeof value === "object" && value !== null && typeof value.savedAt === "number" && typeof value.state === "object" && value.state !== null;
1295
+ }
1296
+ function getStorage() {
1297
+ try {
1298
+ if (typeof window === "undefined" || !window.localStorage) return null;
1299
+ if (typeof window.localStorage.setItem !== "function" || typeof window.localStorage.getItem !== "function") {
1300
+ return null;
1301
+ }
1302
+ return window.localStorage;
1303
+ } catch {
1304
+ return null;
1305
+ }
1306
+ }
1307
+ function loadTryItState(specKey, operationKey, ttlSeconds) {
1308
+ if (!specKey) return null;
1309
+ if (ttlSeconds === 0) return null;
1310
+ const storage = getStorage();
1311
+ if (!storage) return null;
1312
+ const key = storageKey(specKey, operationKey);
1313
+ try {
1314
+ const raw = storage.getItem(key);
1315
+ if (!raw) return null;
1316
+ const parsed = JSON.parse(raw);
1317
+ if (isEnvelope(parsed)) {
1318
+ if (ttlSeconds !== void 0 && Date.now() - parsed.savedAt > ttlSeconds * 1e3) {
1319
+ storage.removeItem(key);
1320
+ return null;
1321
+ }
1322
+ return parsed.state;
1323
+ }
1324
+ if (parsed && typeof parsed === "object") {
1325
+ if (ttlSeconds !== void 0) {
1326
+ storage.removeItem(key);
1327
+ return null;
1328
+ }
1329
+ return parsed;
1330
+ }
1331
+ return null;
1332
+ } catch {
1333
+ return null;
1334
+ }
1335
+ }
1336
+ function saveTryItState(specKey, operationKey, state) {
1337
+ if (!specKey) return;
1338
+ const storage = getStorage();
1339
+ if (!storage) return;
1340
+ try {
1341
+ const envelope = { savedAt: Date.now(), state };
1342
+ storage.setItem(storageKey(specKey, operationKey), JSON.stringify(envelope));
1343
+ } catch {
1344
+ }
1345
+ }
1346
+ const PANEL_WIDTH_KEY = `${PREFIX}:panel-width`;
1347
+ function loadPanelWidth() {
1348
+ const storage = getStorage();
1349
+ if (!storage) return null;
1350
+ try {
1351
+ const raw = storage.getItem(PANEL_WIDTH_KEY);
1352
+ if (!raw) return null;
1353
+ const value = Number(raw);
1354
+ return Number.isFinite(value) && value > 0 ? value : null;
1355
+ } catch {
1356
+ return null;
1357
+ }
1358
+ }
1359
+ function savePanelWidth(width) {
1360
+ const storage = getStorage();
1361
+ if (!storage) return;
1362
+ try {
1363
+ storage.setItem(PANEL_WIDTH_KEY, String(Math.round(width)));
1364
+ } catch {
1365
+ }
1366
+ }
1367
+ function clearTryItState(specKey, operationKey) {
1368
+ if (!specKey) return;
1369
+ const storage = getStorage();
1370
+ if (!storage) return;
1371
+ try {
1372
+ storage.removeItem(storageKey(specKey, operationKey));
1373
+ } catch {
1374
+ }
1375
+ }
1376
+
1377
+ const MIN_RIGHT_WIDTH = 320;
1378
+ const MAX_RIGHT_FRACTION = 0.65;
1379
+ const singleColumnStyle = css({
1380
+ padding: "0.75rem 0",
1381
+ minWidth: 0,
1382
+ [mq.desktop]: {
1383
+ padding: "1rem 1.25rem"
1384
+ }
1385
+ });
1386
+ const gridStyle = css({
1387
+ maxWidth: "100%",
1388
+ [mq.desktop]: {
1389
+ display: "grid",
1390
+ // The custom property is set inline while a user-chosen width is active;
1391
+ // it falls back to a 65/35 split (content-heavy left, Try-It on the right).
1392
+ gridTemplateColumns: "1fr 0.375rem var(--omnispec-tryit-col, calc(35% - 0.375rem))"
1393
+ }
1394
+ });
1395
+ const leftColumnStyle = css({
1396
+ padding: "0.75rem 0",
1397
+ minWidth: 0,
1398
+ [mq.desktop]: {
1399
+ padding: "1rem 1.25rem"
1400
+ }
1401
+ });
1402
+ const toggleButtonStyle = css({
1403
+ display: "block",
1404
+ width: "100%",
1405
+ padding: "10px 16px",
1406
+ marginTop: "12px",
1407
+ borderRadius: "var(--omnispec-border-radius)",
1408
+ background: "var(--omnispec-color-primary, #1a1a2e)",
1409
+ color: "#fff",
1410
+ border: "none",
1411
+ cursor: "pointer",
1412
+ fontSize: "var(--omnispec-font-size-base)",
1413
+ fontWeight: 500,
1414
+ textAlign: "center",
1415
+ [mq.desktop]: {
1416
+ display: "none"
1417
+ }
1418
+ });
1419
+ const rightColumnStyle = css({
1420
+ padding: "0.75rem 0",
1421
+ background: "var(--omnispec-bg-secondary)",
1422
+ minWidth: 0,
1423
+ display: "none",
1424
+ "&[data-mobile-visible]": {
1425
+ display: "block",
1426
+ borderTop: "1px solid var(--omnispec-border-color)"
1427
+ },
1428
+ [mq.desktop]: {
1429
+ display: "block",
1430
+ padding: "1rem 1.25rem",
1431
+ borderTop: "none"
1432
+ }
1433
+ });
1434
+ const resizeHandleStyle = css({
1435
+ display: "none",
1436
+ [mq.desktop]: {
1437
+ display: "block",
1438
+ cursor: "col-resize",
1439
+ backgroundColor: "var(--omnispec-border-color)",
1440
+ borderRadius: "0.1875rem",
1441
+ transition: "background-color 0.15s ease",
1442
+ marginTop: "1rem",
1443
+ marginBottom: "1rem",
1444
+ "&:hover, &[data-dragging]": {
1445
+ backgroundColor: "var(--omnispec-color-primary)"
1446
+ }
1447
+ }
1448
+ });
1449
+ const draggingContainerStyle = css({
1450
+ userSelect: "none"
1451
+ });
1452
+ function ResponsiveColumns({ left, right, rightLabel = "Try It" }) {
1453
+ const [showRight, setShowRight] = useState(false);
1454
+ const [rightWidth, setRightWidth] = useState(() => loadPanelWidth());
1455
+ const [dragging, setDragging] = useState(false);
1456
+ const containerRef = useRef(null);
1457
+ const startDrag = (e) => {
1458
+ e.preventDefault();
1459
+ setDragging(true);
1460
+ const onMove = (ev) => {
1461
+ const rect = containerRef.current?.getBoundingClientRect();
1462
+ if (!rect) return;
1463
+ const raw = rect.right - ev.clientX;
1464
+ const max = rect.width * MAX_RIGHT_FRACTION;
1465
+ setRightWidth(Math.min(max, Math.max(MIN_RIGHT_WIDTH, raw)));
1466
+ };
1467
+ const onUp = () => {
1468
+ window.removeEventListener("pointermove", onMove);
1469
+ window.removeEventListener("pointerup", onUp);
1470
+ setDragging(false);
1471
+ setRightWidth((width) => {
1472
+ if (width !== null) savePanelWidth(width);
1473
+ return width;
1474
+ });
1475
+ };
1476
+ window.addEventListener("pointermove", onMove);
1477
+ window.addEventListener("pointerup", onUp);
1478
+ };
1479
+ if (!right) {
1480
+ return /* @__PURE__ */ jsx("div", { className: singleColumnStyle, children: left });
1481
+ }
1482
+ const containerStyle = rightWidth !== null ? { "--omnispec-tryit-col": `${rightWidth}px` } : void 0;
1483
+ return /* @__PURE__ */ jsxs(
1484
+ "div",
1485
+ {
1486
+ ref: containerRef,
1487
+ className: `${gridStyle} ${dragging ? draggingContainerStyle : ""}`,
1488
+ style: containerStyle,
1489
+ children: [
1490
+ /* @__PURE__ */ jsxs("div", { className: leftColumnStyle, children: [
1491
+ left,
1492
+ /* @__PURE__ */ jsx(
1493
+ "button",
1494
+ {
1495
+ type: "button",
1496
+ className: toggleButtonStyle,
1497
+ onClick: () => setShowRight((prev) => !prev),
1498
+ children: showRight ? "Hide" : rightLabel
1499
+ }
1500
+ )
1501
+ ] }),
1502
+ /* @__PURE__ */ jsx(
1503
+ "div",
1504
+ {
1505
+ className: resizeHandleStyle,
1506
+ role: "separator",
1507
+ "aria-orientation": "vertical",
1508
+ "aria-label": `Resize ${rightLabel} panel`,
1509
+ onPointerDown: startDrag,
1510
+ ...dragging ? { "data-dragging": "" } : {}
1511
+ }
1512
+ ),
1513
+ /* @__PURE__ */ jsx(
1514
+ "div",
1515
+ {
1516
+ className: rightColumnStyle,
1517
+ ...showRight ? { "data-mobile-visible": "" } : {},
1518
+ children: right
1519
+ }
1520
+ )
1521
+ ]
1522
+ }
1523
+ );
1524
+ }
1525
+
1526
+ async function sendProxiedRequest(proxyUrl, request, proxyHeaders) {
1527
+ const targetUrl = buildTargetUrl$1(request);
1528
+ const proxyPayload = {
1529
+ url: targetUrl,
1530
+ method: request.method,
1531
+ headers: request.headers,
1532
+ timeout: 3e4
1533
+ };
1534
+ if (request.body) {
1535
+ if (typeof request.body === "string") {
1536
+ proxyPayload.body = request.body;
1537
+ proxyPayload.bodyEncoding = "utf-8";
1538
+ } else {
1539
+ const { body, contentType } = await encodeMultipartBody(request.body);
1540
+ proxyPayload.body = body;
1541
+ proxyPayload.bodyEncoding = "base64";
1542
+ proxyPayload.headers = { ...proxyPayload.headers, "Content-Type": contentType };
1543
+ }
1544
+ }
1545
+ const startTime = performance.now();
1546
+ const response = await fetch(proxyUrl, {
1547
+ method: "POST",
1548
+ headers: { "Content-Type": "application/json", ...proxyHeaders },
1549
+ body: JSON.stringify(proxyPayload)
1550
+ });
1551
+ if (!response.ok) {
1552
+ throw new Error(`Proxy request failed: ${response.status} ${response.statusText}`);
1553
+ }
1554
+ const proxyResponse = await response.json();
1555
+ const duration = performance.now() - startTime;
1556
+ return {
1557
+ status: proxyResponse.status,
1558
+ statusText: proxyResponse.statusText,
1559
+ headers: proxyResponse.headers,
1560
+ body: proxyResponse.body,
1561
+ bodyEncoding: proxyResponse.bodyEncoding ?? "utf-8",
1562
+ contentType: proxyResponse.headers["content-type"] ?? "text/plain",
1563
+ duration: proxyResponse.duration ?? duration
1564
+ };
1565
+ }
1566
+ async function blobToBytes(value) {
1567
+ if (typeof value.arrayBuffer === "function") {
1568
+ return new Uint8Array(await value.arrayBuffer());
1569
+ }
1570
+ return new Promise((resolve, reject) => {
1571
+ const reader = new FileReader();
1572
+ reader.onload = () => resolve(new Uint8Array(reader.result));
1573
+ reader.onerror = () => reject(reader.error);
1574
+ reader.readAsArrayBuffer(value);
1575
+ });
1576
+ }
1577
+ async function encodeMultipartBody(formData) {
1578
+ const boundary = `----omnispec${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`;
1579
+ const encoder = new TextEncoder();
1580
+ const chunks = [];
1581
+ const push = (s) => chunks.push(encoder.encode(s));
1582
+ const entries = [];
1583
+ formData.forEach((value, key) => entries.push([key, value]));
1584
+ for (const [key, value] of entries) {
1585
+ push(`--${boundary}\r
1586
+ `);
1587
+ if (typeof value === "string") {
1588
+ push(`Content-Disposition: form-data; name="${key}"\r
1589
+ \r
1590
+ `);
1591
+ push(`${value}\r
1592
+ `);
1593
+ } else {
1594
+ const filename = value.name || "file";
1595
+ const fileType = value.type || "application/octet-stream";
1596
+ push(`Content-Disposition: form-data; name="${key}"; filename="${filename}"\r
1597
+ `);
1598
+ push(`Content-Type: ${fileType}\r
1599
+ \r
1600
+ `);
1601
+ chunks.push(await blobToBytes(value));
1602
+ push("\r\n");
1603
+ }
1604
+ }
1605
+ push(`--${boundary}--\r
1606
+ `);
1607
+ const total = chunks.reduce((n, c) => n + c.length, 0);
1608
+ const bytes = new Uint8Array(total);
1609
+ let offset = 0;
1610
+ for (const c of chunks) {
1611
+ bytes.set(c, offset);
1612
+ offset += c.length;
1613
+ }
1614
+ let binary = "";
1615
+ const CHUNK = 32768;
1616
+ for (let i = 0; i < bytes.length; i += CHUNK) {
1617
+ binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
1618
+ }
1619
+ return { body: btoa(binary), contentType: `multipart/form-data; boundary=${boundary}` };
1620
+ }
1621
+ function buildTargetUrl$1(request) {
1622
+ let url = request.url;
1623
+ for (const [key, value] of Object.entries(request.pathParams)) {
1624
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
1625
+ }
1626
+ const queryEntries = Object.entries(request.queryParams);
1627
+ if (queryEntries.length > 0) {
1628
+ const params = new URLSearchParams();
1629
+ for (const [key, value] of queryEntries) {
1630
+ if (Array.isArray(value)) {
1631
+ for (const v of value) {
1632
+ params.append(key, v);
1633
+ }
1634
+ } else {
1635
+ params.set(key, value);
1636
+ }
1637
+ }
1638
+ const separator = url.includes("?") ? "&" : "?";
1639
+ url = `${url}${separator}${params.toString()}`;
1640
+ }
1641
+ return url;
1642
+ }
1643
+
1644
+ async function sendDirectRequest(request) {
1645
+ const url = upgradeMixedContent(buildTargetUrl(request));
1646
+ const init = {
1647
+ method: request.method,
1648
+ headers: request.headers
1649
+ };
1650
+ if (request.body) {
1651
+ init.body = typeof request.body === "string" ? request.body : request.body;
1652
+ }
1653
+ const startTime = performance.now();
1654
+ const response = await fetch(url, init);
1655
+ const duration = performance.now() - startTime;
1656
+ const contentType = response.headers.get("content-type") ?? "text/plain";
1657
+ let body;
1658
+ let bodyEncoding = "utf-8";
1659
+ if (isBinaryContentType(contentType)) {
1660
+ body = bytesToBase64(new Uint8Array(await response.arrayBuffer()));
1661
+ bodyEncoding = "base64";
1662
+ } else {
1663
+ body = await response.text();
1664
+ }
1665
+ const headers = {};
1666
+ response.headers.forEach((value, key) => {
1667
+ headers[key] = value;
1668
+ });
1669
+ return {
1670
+ status: response.status,
1671
+ statusText: response.statusText,
1672
+ headers,
1673
+ body,
1674
+ bodyEncoding,
1675
+ contentType,
1676
+ duration
1677
+ };
1678
+ }
1679
+ function upgradeMixedContent(url) {
1680
+ if (typeof window !== "undefined" && window.location?.protocol === "https:" && url.startsWith("http://")) {
1681
+ return `https://${url.slice("http://".length)}`;
1682
+ }
1683
+ return url;
1684
+ }
1685
+ function buildTargetUrl(request) {
1686
+ let url = request.url;
1687
+ for (const [key, value] of Object.entries(request.pathParams)) {
1688
+ url = url.replace(`{${key}}`, encodeURIComponent(value));
1689
+ }
1690
+ const queryEntries = Object.entries(request.queryParams);
1691
+ if (queryEntries.length > 0) {
1692
+ const params = new URLSearchParams();
1693
+ for (const [key, value] of queryEntries) {
1694
+ if (Array.isArray(value)) {
1695
+ for (const v of value) {
1696
+ params.append(key, v);
1697
+ }
1698
+ } else {
1699
+ params.set(key, value);
1700
+ }
1701
+ }
1702
+ const separator = url.includes("?") ? "&" : "?";
1703
+ url = `${url}${separator}${params.toString()}`;
1704
+ }
1705
+ return url;
1706
+ }
1707
+
1708
+ const generators = {
1709
+ curl: generateCurl,
1710
+ javascript: generateJavaScript,
1711
+ python: generatePython,
1712
+ go: generateGo,
1713
+ java: generateJava,
1714
+ csharp: generateCSharp
1715
+ };
1716
+ function CodeSamples({
1717
+ request,
1718
+ serverUrl,
1719
+ selectedLanguage,
1720
+ onLanguageChange,
1721
+ xCodeSamples
1722
+ }) {
1723
+ const code = useMemo(() => {
1724
+ if (xCodeSamples) {
1725
+ const custom = xCodeSamples.find(
1726
+ (s) => s.lang.toLowerCase() === selectedLanguage || s.label?.toLowerCase() === selectedLanguage
1727
+ );
1728
+ if (custom) return custom.source;
1729
+ }
1730
+ const generator = generators[selectedLanguage];
1731
+ return generator ? generator(request, serverUrl) : "";
1732
+ }, [request, serverUrl, selectedLanguage, xCodeSamples]);
1733
+ const langOption = CODE_LANGUAGES.find((l) => l.id === selectedLanguage);
1734
+ const prismLang = langOption?.prismLanguage ?? "text";
1735
+ const languageTabs = /* @__PURE__ */ jsx("div", { className: languageBarStyle, children: CODE_LANGUAGES.map((lang) => /* @__PURE__ */ jsx(
1736
+ "button",
1737
+ {
1738
+ type: "button",
1739
+ onClick: () => onLanguageChange(lang.id),
1740
+ className: cx(langBtnStyle, selectedLanguage === lang.id && langBtnActiveStyle),
1741
+ children: lang.label
1742
+ },
1743
+ lang.id
1744
+ )) });
1745
+ return /* @__PURE__ */ jsx("div", { className: containerStyle$1, children: /* @__PURE__ */ jsx(
1746
+ CodeBlock,
1747
+ {
1748
+ code,
1749
+ language: prismLang,
1750
+ showCopy: true,
1751
+ headerLeft: languageTabs
1752
+ }
1753
+ ) });
1754
+ }
1755
+ const containerStyle$1 = css({
1756
+ marginTop: "0.75rem"
1757
+ });
1758
+ const languageBarStyle = css({
1759
+ display: "flex",
1760
+ gap: "0.125rem",
1761
+ overflowX: "auto",
1762
+ scrollbarWidth: "none",
1763
+ "&::-webkit-scrollbar": {
1764
+ display: "none"
1765
+ }
1766
+ });
1767
+ const langBtnStyle = css({
1768
+ padding: "0.25rem 0.5rem",
1769
+ background: "none",
1770
+ border: "none",
1771
+ cursor: "pointer",
1772
+ fontSize: "var(--omnispec-font-size-xs)",
1773
+ fontWeight: 500,
1774
+ color: "var(--omnispec-fg-muted)",
1775
+ whiteSpace: "nowrap",
1776
+ borderRadius: "var(--omnispec-border-radius)",
1777
+ "&:hover": {
1778
+ color: "var(--omnispec-fg-primary)",
1779
+ backgroundColor: "var(--omnispec-bg-secondary)"
1780
+ }
1781
+ });
1782
+ const langBtnActiveStyle = css({
1783
+ color: "var(--omnispec-color-primary)",
1784
+ backgroundColor: "var(--omnispec-bg-secondary)",
1785
+ fontWeight: 600
1786
+ });
1787
+
1788
+ const containerStyle = css({
1789
+ marginTop: "12px",
1790
+ border: "1px solid var(--omnispec-border-color)",
1791
+ borderRadius: "var(--omnispec-border-radius)",
1792
+ padding: "12px",
1793
+ backgroundColor: "var(--omnispec-bg-secondary)"
1794
+ });
1795
+ const statusBarStyle = css({
1796
+ display: "flex",
1797
+ justifyContent: "space-between",
1798
+ alignItems: "center",
1799
+ marginBottom: "12px"
1800
+ });
1801
+ const statusCodeBaseStyle = css({
1802
+ fontFamily: "var(--omnispec-font-mono)",
1803
+ fontWeight: 700,
1804
+ fontSize: "var(--omnispec-font-size-base)"
1805
+ });
1806
+ const durationStyle = css({
1807
+ color: "var(--omnispec-fg-muted)",
1808
+ fontSize: "var(--omnispec-font-size-xs)"
1809
+ });
1810
+ const loadingStyle = css({
1811
+ color: "var(--omnispec-fg-muted)",
1812
+ textAlign: "center",
1813
+ padding: "24px"
1814
+ });
1815
+ const errorStyle$1 = css({
1816
+ color: "var(--omnispec-color-error)",
1817
+ padding: "12px"
1818
+ });
1819
+ const headersStyle = css({
1820
+ fontFamily: "var(--omnispec-font-mono)",
1821
+ fontSize: "var(--omnispec-font-size-xs)"
1822
+ });
1823
+ const headerRowStyle = css({
1824
+ display: "flex",
1825
+ gap: "8px",
1826
+ padding: "2px 0"
1827
+ });
1828
+ const headerKeyStyle = css({
1829
+ color: "var(--omnispec-fg-secondary)",
1830
+ fontWeight: 600
1831
+ });
1832
+ const headerValueStyle = css({
1833
+ color: "var(--omnispec-fg-primary)",
1834
+ wordBreak: "break-all"
1835
+ });
1836
+ function ResponseViewer({ response, loading, error }) {
1837
+ if (loading) {
1838
+ return /* @__PURE__ */ jsx("div", { className: containerStyle, children: /* @__PURE__ */ jsx("div", { className: loadingStyle, children: "Sending request..." }) });
1839
+ }
1840
+ if (error) {
1841
+ return /* @__PURE__ */ jsx("div", { className: containerStyle, children: /* @__PURE__ */ jsx("div", { className: errorStyle$1, children: error }) });
1842
+ }
1843
+ if (!response) return null;
1844
+ const statusColor = getStatusColor(response.status);
1845
+ const isBinary = response.bodyEncoding === "base64";
1846
+ const bodyLanguage = detectLanguage(response.contentType);
1847
+ const formattedBody = isBinary ? "" : formatBody(response.body, bodyLanguage);
1848
+ const handleDownload = () => {
1849
+ const blob = base64ToBlob(response.body, response.contentType);
1850
+ const url = URL.createObjectURL(blob);
1851
+ const anchor = document.createElement("a");
1852
+ anchor.href = url;
1853
+ anchor.download = filenameForResponse(response.headers, response.contentType);
1854
+ document.body.appendChild(anchor);
1855
+ anchor.click();
1856
+ anchor.remove();
1857
+ URL.revokeObjectURL(url);
1858
+ };
1859
+ const binarySize = isBinary ? Math.floor(response.body.length * 3 / 4) : 0;
1860
+ return /* @__PURE__ */ jsxs("div", { className: `adr-response ${containerStyle}`, children: [
1861
+ /* @__PURE__ */ jsxs("div", { className: statusBarStyle, children: [
1862
+ /* @__PURE__ */ jsxs("span", { className: css(statusCodeBaseStyle, { color: statusColor }), children: [
1863
+ response.status,
1864
+ " ",
1865
+ response.statusText
1866
+ ] }),
1867
+ /* @__PURE__ */ jsxs("span", { className: durationStyle, children: [
1868
+ response.duration.toFixed(0),
1869
+ "ms"
1870
+ ] })
1871
+ ] }),
1872
+ /* @__PURE__ */ jsx(
1873
+ Tabs,
1874
+ {
1875
+ tabs: [
1876
+ {
1877
+ id: "body",
1878
+ label: "Response Body",
1879
+ content: isBinary ? /* @__PURE__ */ jsxs("div", { className: binaryPanelStyle, children: [
1880
+ /* @__PURE__ */ jsxs("span", { className: binaryInfoStyle, children: [
1881
+ "Binary response \u2014 ",
1882
+ response.contentType.split(";")[0],
1883
+ " (",
1884
+ formatSize(binarySize),
1885
+ ")"
1886
+ ] }),
1887
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: handleDownload, children: "Download" })
1888
+ ] }) : /* @__PURE__ */ jsx(
1889
+ CodeBlock,
1890
+ {
1891
+ code: formattedBody,
1892
+ language: bodyLanguage,
1893
+ title: response.contentType,
1894
+ maxHeight: "300px"
1895
+ }
1896
+ )
1897
+ },
1898
+ {
1899
+ id: "headers",
1900
+ label: "Headers",
1901
+ content: /* @__PURE__ */ jsx("div", { className: headersStyle, children: Object.entries(response.headers).map(([key, value]) => /* @__PURE__ */ jsxs("div", { className: headerRowStyle, children: [
1902
+ /* @__PURE__ */ jsxs("span", { className: headerKeyStyle, children: [
1903
+ key,
1904
+ ":"
1905
+ ] }),
1906
+ /* @__PURE__ */ jsx("span", { className: headerValueStyle, children: value })
1907
+ ] }, key)) })
1908
+ }
1909
+ ]
1910
+ }
1911
+ )
1912
+ ] });
1913
+ }
1914
+ const binaryPanelStyle = css({
1915
+ display: "flex",
1916
+ flexDirection: "column",
1917
+ alignItems: "flex-start",
1918
+ gap: "0.75rem",
1919
+ padding: "1rem"
1920
+ });
1921
+ const binaryInfoStyle = css({
1922
+ fontSize: "var(--omnispec-font-size-sm)",
1923
+ color: "var(--omnispec-fg-secondary)",
1924
+ fontFamily: "var(--omnispec-font-mono)",
1925
+ wordBreak: "break-all"
1926
+ });
1927
+ function formatSize(bytes) {
1928
+ if (bytes < 1024) return `${bytes} B`;
1929
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
1930
+ return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
1931
+ }
1932
+ function getStatusColor(status) {
1933
+ if (status >= 200 && status < 300) return "var(--omnispec-color-success)";
1934
+ if (status >= 300 && status < 400) return "var(--omnispec-color-info)";
1935
+ if (status >= 400 && status < 500) return "var(--omnispec-color-warning)";
1936
+ return "var(--omnispec-color-error)";
1937
+ }
1938
+ function detectLanguage(contentType) {
1939
+ if (contentType.includes("json")) return "json";
1940
+ if (contentType.includes("xml") || contentType.includes("html")) return "xml";
1941
+ if (contentType.includes("yaml") || contentType.includes("yml")) return "yaml";
1942
+ return "text";
1943
+ }
1944
+ function formatBody(body, language) {
1945
+ if (language === "json") {
1946
+ try {
1947
+ return JSON.stringify(JSON.parse(body), null, 2);
1948
+ } catch {
1949
+ return body;
1950
+ }
1951
+ }
1952
+ return body;
1953
+ }
1954
+
1955
+ function SecretInput({
1956
+ value,
1957
+ onChange,
1958
+ placeholder,
1959
+ className,
1960
+ autoComplete,
1961
+ "aria-label": ariaLabel
1962
+ }) {
1963
+ const [revealed, setRevealed] = useState(false);
1964
+ return /* @__PURE__ */ jsxs("div", { className: wrapStyle, children: [
1965
+ /* @__PURE__ */ jsx(
1966
+ "input",
1967
+ {
1968
+ type: revealed ? "text" : "password",
1969
+ value,
1970
+ onChange: (e) => onChange(e.target.value),
1971
+ placeholder,
1972
+ className,
1973
+ autoComplete,
1974
+ "aria-label": ariaLabel,
1975
+ style: { width: "100%", paddingRight: "2.25rem" }
1976
+ }
1977
+ ),
1978
+ /* @__PURE__ */ jsx(
1979
+ "button",
1980
+ {
1981
+ type: "button",
1982
+ onClick: () => setRevealed((v) => !v),
1983
+ className: toggleStyle,
1984
+ "aria-label": revealed ? "Hide value" : "Show value",
1985
+ "aria-pressed": revealed,
1986
+ title: revealed ? "Hide" : "Show",
1987
+ children: /* @__PURE__ */ jsx(Icon, { name: revealed ? "eye-off" : "eye", size: "1rem" })
1988
+ }
1989
+ )
1990
+ ] });
1991
+ }
1992
+ const wrapStyle = css({
1993
+ position: "relative",
1994
+ flex: 1,
1995
+ display: "flex",
1996
+ alignItems: "stretch"
1997
+ });
1998
+ const toggleStyle = css({
1999
+ position: "absolute",
2000
+ right: "4px",
2001
+ top: "50%",
2002
+ transform: "translateY(-50%)",
2003
+ display: "inline-flex",
2004
+ alignItems: "center",
2005
+ justifyContent: "center",
2006
+ width: "1.75rem",
2007
+ height: "1.75rem",
2008
+ padding: 0,
2009
+ border: "none",
2010
+ background: "transparent",
2011
+ cursor: "pointer",
2012
+ color: "var(--omnispec-fg-muted)",
2013
+ borderRadius: "var(--omnispec-border-radius)",
2014
+ "&:hover": {
2015
+ color: "var(--omnispec-fg-primary)"
2016
+ },
2017
+ "&:focus-visible": {
2018
+ outline: "2px solid var(--omnispec-color-primary)",
2019
+ outlineOffset: "1px"
2020
+ }
2021
+ });
2022
+
2023
+ const authStyles = {
2024
+ section: css({
2025
+ padding: "0.75rem 0",
2026
+ borderBottom: "1px solid var(--omnispec-border-color)",
2027
+ "&:last-child": {
2028
+ borderBottom: "none"
2029
+ }
2030
+ }),
2031
+ label: css({
2032
+ fontWeight: 600,
2033
+ fontSize: "var(--omnispec-font-size-sm)",
2034
+ color: "var(--omnispec-fg-primary)",
2035
+ marginBottom: "4px",
2036
+ display: "flex",
2037
+ alignItems: "center",
2038
+ gap: "8px"
2039
+ }),
2040
+ hint: css({
2041
+ fontWeight: 400,
2042
+ fontSize: "var(--omnispec-font-size-xs)",
2043
+ color: "var(--omnispec-fg-muted)"
2044
+ }),
2045
+ description: css({
2046
+ fontSize: "var(--omnispec-font-size-xs)",
2047
+ color: "var(--omnispec-fg-secondary)",
2048
+ margin: "4px 0 8px"
2049
+ }),
2050
+ inputRow: css({
2051
+ display: "flex",
2052
+ gap: "8px",
2053
+ alignItems: "center"
2054
+ }),
2055
+ input: css({
2056
+ flex: 1,
2057
+ padding: "6px 10px",
2058
+ border: "1px solid var(--omnispec-input-border)",
2059
+ borderRadius: "var(--omnispec-border-radius)",
2060
+ backgroundColor: "var(--omnispec-input-bg)",
2061
+ color: "var(--omnispec-fg-primary)",
2062
+ fontSize: "var(--omnispec-font-size-sm)",
2063
+ fontFamily: "var(--omnispec-font-mono)",
2064
+ "&:focus": {
2065
+ borderColor: "var(--omnispec-color-primary)",
2066
+ outline: "none"
2067
+ },
2068
+ "&:hover": {
2069
+ borderColor: "var(--omnispec-color-primary)"
2070
+ }
2071
+ }),
2072
+ applyBtn: css({
2073
+ padding: "6px 16px",
2074
+ backgroundColor: "var(--omnispec-color-primary)",
2075
+ color: "var(--omnispec-color-primary-text)",
2076
+ border: "none",
2077
+ borderRadius: "var(--omnispec-border-radius)",
2078
+ cursor: "pointer",
2079
+ fontSize: "var(--omnispec-font-size-sm)",
2080
+ fontWeight: 500,
2081
+ "&:hover": {
2082
+ opacity: 0.85
2083
+ }
2084
+ }),
2085
+ removeBtn: css({
2086
+ padding: "6px 16px",
2087
+ backgroundColor: "var(--omnispec-color-error)",
2088
+ color: "#fff",
2089
+ border: "none",
2090
+ borderRadius: "var(--omnispec-border-radius)",
2091
+ cursor: "pointer",
2092
+ fontSize: "var(--omnispec-font-size-sm)",
2093
+ fontWeight: 500,
2094
+ "&:hover": {
2095
+ opacity: 0.85
2096
+ }
2097
+ })
2098
+ };
2099
+ function ApiKeyAuth({ scheme, onApply, onRemove, applied, appliedValue }) {
2100
+ const [value, setValue] = useState(appliedValue?.input?.value ?? "");
2101
+ const handleApply = () => {
2102
+ if (!value.trim()) return;
2103
+ const headerName = scheme.in === "query" ? scheme.name ?? "api_key" : scheme.name ?? "X-API-Key";
2104
+ onApply({
2105
+ schemeId: scheme.id,
2106
+ headerName,
2107
+ headerValue: value,
2108
+ input: { value }
2109
+ });
2110
+ };
2111
+ const handleRemove = () => {
2112
+ setValue("");
2113
+ onRemove(scheme.id);
2114
+ };
2115
+ return /* @__PURE__ */ jsxs("div", { className: authStyles.section, children: [
2116
+ /* @__PURE__ */ jsxs("div", { className: authStyles.label, children: [
2117
+ scheme.displayName,
2118
+ /* @__PURE__ */ jsxs("span", { className: authStyles.hint, children: [
2119
+ "(",
2120
+ scheme.in,
2121
+ ": ",
2122
+ scheme.name,
2123
+ ")"
2124
+ ] })
2125
+ ] }),
2126
+ scheme.description && /* @__PURE__ */ jsx(MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
2127
+ /* @__PURE__ */ jsxs("div", { className: authStyles.inputRow, children: [
2128
+ /* @__PURE__ */ jsx(
2129
+ SecretInput,
2130
+ {
2131
+ value,
2132
+ onChange: setValue,
2133
+ placeholder: "Enter API key",
2134
+ className: authStyles.input,
2135
+ "aria-label": `${scheme.displayName} value`
2136
+ }
2137
+ ),
2138
+ applied ? /* @__PURE__ */ jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleApply, className: authStyles.applyBtn, children: "Apply" })
2139
+ ] })
2140
+ ] });
2141
+ }
2142
+
2143
+ const flowLabels = {
2144
+ authorizationCode: "Authorization Code",
2145
+ implicit: "Implicit",
2146
+ clientCredentials: "Client Credentials",
2147
+ password: "Resource Owner Password"
2148
+ };
2149
+ const flowSelectorStyle = css({
2150
+ display: "flex",
2151
+ gap: "4px",
2152
+ marginBottom: ".5rem"
2153
+ });
2154
+ const flowTabStyle = css({
2155
+ padding: "4px 10px",
2156
+ background: "var(--omnispec-bg-tertiary)",
2157
+ border: "1px solid var(--omnispec-border-color)",
2158
+ borderRadius: "var(--omnispec-border-radius)",
2159
+ cursor: "pointer",
2160
+ fontSize: "var(--omnispec-font-size-xs)",
2161
+ color: "var(--omnispec-fg-secondary)",
2162
+ "&:hover": {
2163
+ borderColor: "var(--omnispec-color-primary)"
2164
+ }
2165
+ });
2166
+ const activeFlowTabStyle = css({
2167
+ backgroundColor: "var(--omnispec-color-primary)",
2168
+ color: "var(--omnispec-color-primary-text)",
2169
+ borderColor: "var(--omnispec-color-primary)"
2170
+ });
2171
+ const flowDetailsStyle = css({
2172
+ marginBottom: "0.5rem"
2173
+ });
2174
+ const urlRowStyle$1 = css({
2175
+ display: "flex",
2176
+ gap: "0.5rem",
2177
+ fontSize: "var(--omnispec-font-size-sm)",
2178
+ marginBottom: "0.25rem"
2179
+ });
2180
+ const urlLabelStyle = css({
2181
+ color: "var(--omnispec-fg-muted)",
2182
+ fontWeight: 600,
2183
+ whiteSpace: "nowrap",
2184
+ marginBottom: ".5rem",
2185
+ display: "inline-block"
2186
+ });
2187
+ const urlValueStyle = css({
2188
+ color: "var(--omnispec-fg-secondary)",
2189
+ fontFamily: "var(--omnispec-font-mono)",
2190
+ fontSize: "var(--omnispec-font-size-sm)",
2191
+ wordBreak: "break-all"
2192
+ });
2193
+ const scopesStyle = css({
2194
+ marginTop: "0.5rem",
2195
+ fontSize: "var(--omnispec-font-size-sm)"
2196
+ });
2197
+ const scopeListStyle = css({
2198
+ marginTop: "0.25rem",
2199
+ display: "flex",
2200
+ flexDirection: "column",
2201
+ gap: "0.125rem"
2202
+ });
2203
+ const scopeItemStyle = css({
2204
+ fontSize: "var(--omnispec-font-size-sm)"
2205
+ });
2206
+ const scopeNameStyle = css({
2207
+ fontFamily: "var(--omnispec-font-mono)",
2208
+ color: "var(--omnispec-fg-secondary)"
2209
+ });
2210
+ const scopeDescStyle = css({
2211
+ color: "var(--omnispec-fg-muted)"
2212
+ });
2213
+ const tokenSectionStyle = css({
2214
+ marginTop: "8px"
2215
+ });
2216
+ const flowErrorStyle = css({
2217
+ marginTop: "8px",
2218
+ fontSize: "var(--omnispec-font-size-xs)",
2219
+ color: "var(--omnispec-color-error)"
2220
+ });
2221
+ function OAuth2AuthManual({ scheme, onApply, onRemove, applied, appliedValue }) {
2222
+ const flows = scheme.flows;
2223
+ const availableFlows = flows ? Object.entries(flows).filter(([, v]) => v) : [];
2224
+ const [activeFlow, setActiveFlow] = useState(availableFlows[0]?.[0] ?? "authorizationCode");
2225
+ const [token, setToken] = useState(appliedValue?.input?.token ?? "");
2226
+ const [applyError, setApplyError] = useState(void 0);
2227
+ const currentFlow = flows?.[activeFlow];
2228
+ const handleTokenChange = (value) => {
2229
+ setToken(value);
2230
+ if (applyError) setApplyError(void 0);
2231
+ };
2232
+ const handleApplyToken = () => {
2233
+ if (!token.trim()) {
2234
+ setApplyError("Enter an access token to apply.");
2235
+ return;
2236
+ }
2237
+ setApplyError(void 0);
2238
+ onApply({
2239
+ schemeId: scheme.id,
2240
+ headerName: "Authorization",
2241
+ headerValue: `Bearer ${token}`,
2242
+ input: { token }
2243
+ });
2244
+ };
2245
+ const handleRemove = () => {
2246
+ setToken("");
2247
+ setApplyError(void 0);
2248
+ onRemove(scheme.id);
2249
+ };
2250
+ return /* @__PURE__ */ jsxs("div", { className: authStyles.section, children: [
2251
+ /* @__PURE__ */ jsxs("div", { className: authStyles.label, children: [
2252
+ scheme.displayName,
2253
+ /* @__PURE__ */ jsx("span", { className: authStyles.hint, children: "(OAuth 2.0)" })
2254
+ ] }),
2255
+ scheme.description && /* @__PURE__ */ jsx(MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
2256
+ availableFlows.length > 1 && /* @__PURE__ */ jsx("div", { className: flowSelectorStyle, children: availableFlows.map(([key]) => /* @__PURE__ */ jsx(
2257
+ "button",
2258
+ {
2259
+ type: "button",
2260
+ onClick: () => setActiveFlow(key),
2261
+ className: cx(flowTabStyle, key === activeFlow && activeFlowTabStyle),
2262
+ children: flowLabels[key]
2263
+ },
2264
+ key
2265
+ )) }),
2266
+ currentFlow && /* @__PURE__ */ jsxs("div", { className: flowDetailsStyle, children: [
2267
+ currentFlow.authorizationUrl && /* @__PURE__ */ jsxs("div", { className: urlRowStyle$1, children: [
2268
+ /* @__PURE__ */ jsx("span", { className: urlLabelStyle, children: "Auth URL:" }),
2269
+ /* @__PURE__ */ jsx("code", { className: urlValueStyle, children: currentFlow.authorizationUrl })
2270
+ ] }),
2271
+ currentFlow.tokenUrl && /* @__PURE__ */ jsxs("div", { className: urlRowStyle$1, children: [
2272
+ /* @__PURE__ */ jsx("span", { className: urlLabelStyle, children: "Token URL:" }),
2273
+ /* @__PURE__ */ jsx("code", { className: urlValueStyle, children: currentFlow.tokenUrl })
2274
+ ] }),
2275
+ currentFlow.refreshUrl && /* @__PURE__ */ jsxs("div", { className: urlRowStyle$1, children: [
2276
+ /* @__PURE__ */ jsx("span", { className: urlLabelStyle, children: "Refresh URL:" }),
2277
+ /* @__PURE__ */ jsx("code", { className: urlValueStyle, children: currentFlow.refreshUrl })
2278
+ ] }),
2279
+ currentFlow.scopes && Object.keys(currentFlow.scopes).length > 0 && /* @__PURE__ */ jsxs("div", { className: scopesStyle, children: [
2280
+ /* @__PURE__ */ jsx("span", { className: urlLabelStyle, children: "Scopes:" }),
2281
+ /* @__PURE__ */ jsx("div", { className: scopeListStyle, children: Object.entries(currentFlow.scopes).map(([scope, desc]) => /* @__PURE__ */ jsxs("div", { className: scopeItemStyle, children: [
2282
+ /* @__PURE__ */ jsx("code", { className: scopeNameStyle, children: scope }),
2283
+ desc && /* @__PURE__ */ jsxs("span", { className: scopeDescStyle, children: [
2284
+ " \u2014 ",
2285
+ desc
2286
+ ] })
2287
+ ] }, scope)) })
2288
+ ] })
2289
+ ] }),
2290
+ /* @__PURE__ */ jsxs("div", { className: tokenSectionStyle, children: [
2291
+ /* @__PURE__ */ jsx("div", { className: authStyles.label, children: /* @__PURE__ */ jsx("span", { className: authStyles.hint, children: "Enter access token:" }) }),
2292
+ /* @__PURE__ */ jsxs("div", { className: authStyles.inputRow, children: [
2293
+ /* @__PURE__ */ jsx(
2294
+ SecretInput,
2295
+ {
2296
+ value: token,
2297
+ onChange: handleTokenChange,
2298
+ placeholder: "Access token",
2299
+ className: authStyles.input,
2300
+ "aria-label": `${scheme.displayName} access token`
2301
+ }
2302
+ ),
2303
+ applied ? /* @__PURE__ */ jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleApplyToken, className: authStyles.applyBtn, children: "Apply" })
2304
+ ] }),
2305
+ applyError && /* @__PURE__ */ jsx("p", { role: "alert", className: flowErrorStyle, children: applyError })
2306
+ ] })
2307
+ ] });
2308
+ }
2309
+
2310
+ const errorStyle = css({
2311
+ fontSize: "var(--omnispec-font-size-xs)",
2312
+ color: "var(--omnispec-color-error)",
2313
+ margin: "4px 0 8px"
2314
+ });
2315
+ const urlRowStyle = css({
2316
+ fontSize: "var(--omnispec-font-size-xs)",
2317
+ color: "var(--omnispec-fg-secondary)",
2318
+ margin: "4px 0 8px",
2319
+ wordBreak: "break-all"
2320
+ });
2321
+ const urlLinkStyle = css({
2322
+ color: "var(--omnispec-color-primary)"
2323
+ });
2324
+ function OpenIdConnectManual({
2325
+ scheme,
2326
+ onApply,
2327
+ onRemove,
2328
+ applied,
2329
+ appliedValue
2330
+ }) {
2331
+ const [token, setToken] = useState(appliedValue?.input?.token ?? "");
2332
+ const [error, setError] = useState(void 0);
2333
+ const handleApply = () => {
2334
+ if (!token.trim()) {
2335
+ setError("Enter an access token to apply.");
2336
+ return;
2337
+ }
2338
+ setError(void 0);
2339
+ onApply({
2340
+ schemeId: scheme.id,
2341
+ headerName: "Authorization",
2342
+ headerValue: `Bearer ${token}`,
2343
+ input: { token }
2344
+ });
2345
+ };
2346
+ const handleRemove = () => {
2347
+ setToken("");
2348
+ setError(void 0);
2349
+ onRemove(scheme.id);
2350
+ };
2351
+ return /* @__PURE__ */ jsxs("div", { className: authStyles.section, children: [
2352
+ /* @__PURE__ */ jsxs("div", { className: authStyles.label, children: [
2353
+ scheme.displayName,
2354
+ /* @__PURE__ */ jsx("span", { className: authStyles.hint, children: "(OpenID Connect)" })
2355
+ ] }),
2356
+ scheme.description && /* @__PURE__ */ jsx(MarkdownRenderer, { content: scheme.description, className: authStyles.description }),
2357
+ scheme.openIdConnectUrl && /* @__PURE__ */ jsxs("p", { className: urlRowStyle, children: [
2358
+ "Discovery URL:",
2359
+ " ",
2360
+ /* @__PURE__ */ jsx(
2361
+ "a",
2362
+ {
2363
+ className: urlLinkStyle,
2364
+ href: scheme.openIdConnectUrl,
2365
+ target: "_blank",
2366
+ rel: "noreferrer noopener",
2367
+ children: scheme.openIdConnectUrl
2368
+ }
2369
+ )
2370
+ ] }),
2371
+ /* @__PURE__ */ jsx("div", { className: authStyles.label, children: /* @__PURE__ */ jsx("span", { className: authStyles.hint, children: "Enter access token directly:" }) }),
2372
+ /* @__PURE__ */ jsxs("div", { className: authStyles.inputRow, children: [
2373
+ /* @__PURE__ */ jsx(
2374
+ SecretInput,
2375
+ {
2376
+ value: token,
2377
+ onChange: (value) => {
2378
+ setToken(value);
2379
+ if (error) setError(void 0);
2380
+ },
2381
+ placeholder: "Access token",
2382
+ className: authStyles.input,
2383
+ "aria-label": `${scheme.displayName} access token`
2384
+ }
2385
+ ),
2386
+ applied ? /* @__PURE__ */ jsx("button", { type: "button", onClick: handleRemove, className: authStyles.removeBtn, children: "Remove" }) : /* @__PURE__ */ jsx("button", { type: "button", onClick: handleApply, className: authStyles.applyBtn, children: "Apply" })
2387
+ ] }),
2388
+ error && /* @__PURE__ */ jsx("p", { role: "alert", className: errorStyle, children: error })
2389
+ ] });
2390
+ }
2391
+
2392
+ export { AuthProvider as A, CodeSamples as C, ExampleSelector as E, LinkableHeading as L, Modal as M, OAuth2AuthManual as O, ReferenceLayout as R, SamplesPanel as S, OpenIdConnectManual as a, ReferenceOperationDetail as b, ResponseViewer as c, ResponsiveColumns as d, SecretInput as e, authStyles as f, sendProxiedRequest as g, ApiKeyAuth as h, saveTryItState as i, clearTryItState as j, getNamedExamples as k, loadTryItState as l, sendDirectRequest as s, useAuth as u };
2393
+ //# sourceMappingURL=OpenIdConnectManual-COfITasf.js.map