@clarify-labs/renderer 0.9.4 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/output/{ClarifyShell-D2P0iZ_m.js → ClarifyShell-1LuBliwt.js} +124 -40
  2. package/output/ClarifyShell-1LuBliwt.js.map +1 -0
  3. package/output/{ClarifyShell-7r92MZg9.cjs → ClarifyShell-C6li72Ce.cjs} +138 -54
  4. package/output/ClarifyShell-C6li72Ce.cjs.map +1 -0
  5. package/output/MermaidViewer-B6-BMCJG.cjs +101 -0
  6. package/output/MermaidViewer-B6-BMCJG.cjs.map +1 -0
  7. package/output/MermaidViewer-dXsomvM7.js +98 -0
  8. package/output/MermaidViewer-dXsomvM7.js.map +1 -0
  9. package/output/{OpenApiOperation-Dhlz3JSx.js → OpenApiOperation-CqNM-no4.js} +274 -206
  10. package/output/OpenApiOperation-CqNM-no4.js.map +1 -0
  11. package/output/{OpenApiOperation-CyyPlZL6.cjs → OpenApiOperation-DK46w2dq.cjs} +305 -225
  12. package/output/OpenApiOperation-DK46w2dq.cjs.map +1 -0
  13. package/output/{PageActions-CTn2XkPg.cjs → PageActions-BjB6PYmL.cjs} +76 -735
  14. package/output/PageActions-BjB6PYmL.cjs.map +1 -0
  15. package/output/{PageActions-D0PA8Zv5.js → PageActions-D7K9LDGf.js} +67 -678
  16. package/output/PageActions-D7K9LDGf.js.map +1 -0
  17. package/output/SearchDialog-CIPvXMT3.cjs +414 -0
  18. package/output/SearchDialog-CIPvXMT3.cjs.map +1 -0
  19. package/output/SearchDialog-CxYLjRi5.js +411 -0
  20. package/output/SearchDialog-CxYLjRi5.js.map +1 -0
  21. package/output/app/AppShell.d.ts +2 -2
  22. package/output/app/SectionHashSync.d.ts +6 -0
  23. package/output/client.cjs +3 -3
  24. package/output/client.js +3 -3
  25. package/output/components/MermaidViewer.d.ts +7 -0
  26. package/output/context.d.ts +1 -1
  27. package/output/core/context.d.ts +3 -4
  28. package/output/core/i18n.d.ts +1 -1
  29. package/output/core/index.d.ts +1 -1
  30. package/output/core/types.d.ts +36 -19
  31. package/output/i18n-DnqZHFT7.js +247 -0
  32. package/output/i18n-DnqZHFT7.js.map +1 -0
  33. package/output/i18n-b4iTLeia.cjs +294 -0
  34. package/output/i18n-b4iTLeia.cjs.map +1 -0
  35. package/output/index.cjs +91 -94
  36. package/output/index.cjs.map +1 -1
  37. package/output/index.d.ts +5 -5
  38. package/output/index.js +83 -86
  39. package/output/index.js.map +1 -1
  40. package/output/markdown.cjs +1 -1
  41. package/output/openapi/components/EndpointSections.d.ts +3 -1
  42. package/output/openapi/components/ExamplePanels.d.ts +3 -1
  43. package/output/openapi/components/OpenApiOperation.d.ts +3 -1
  44. package/output/openapi/components/OpenApiOperation.state.d.ts +3 -3
  45. package/output/openapi/components/SchemaProperties.d.ts +1 -0
  46. package/output/openapi/components/helpers.d.ts +2 -2
  47. package/output/openapi/entry.d.ts +0 -1
  48. package/output/openapi/lib/helpers.d.ts +5 -3
  49. package/output/openapi/lib/request-code.d.ts +2 -1
  50. package/output/openapi/lib/spec-path.d.ts +6 -1
  51. package/output/openapi/lib/utils.d.ts +10 -4
  52. package/output/preview.cjs +7 -5
  53. package/output/preview.cjs.map +1 -1
  54. package/output/preview.js +5 -3
  55. package/output/preview.js.map +1 -1
  56. package/output/remark-Dd2WU50s.js.map +1 -1
  57. package/output/{remark-Dv3owbSH.cjs → remark-zSQT0MBv.cjs} +3 -3
  58. package/output/{remark-Dv3owbSH.cjs.map → remark-zSQT0MBv.cjs.map} +1 -1
  59. package/output/{render-CwSsfrs7.js → render-DKj24Jqw.js} +15 -8
  60. package/output/render-DKj24Jqw.js.map +1 -0
  61. package/output/{render-DXDSIfZ8.cjs → render-Di5B6Zc0.cjs} +15 -8
  62. package/output/render-Di5B6Zc0.cjs.map +1 -0
  63. package/output/renderer.css +55 -1
  64. package/output/runtime/ClarifyShell.d.ts +5 -6
  65. package/output/server.cjs +4 -4
  66. package/output/server.cjs.map +1 -1
  67. package/output/server.js +4 -4
  68. package/output/server.js.map +1 -1
  69. package/output/shell/Navigation.d.ts +1 -0
  70. package/output/shell/search/SearchDialog.d.ts +1 -1
  71. package/output/slots/RuntimeSlot.d.ts +7 -7
  72. package/output/slots/context.d.ts +5 -5
  73. package/output/slots/index.d.ts +2 -2
  74. package/output/slots/types.d.ts +1 -1
  75. package/output/utils/path.d.ts +1 -1
  76. package/package.json +10 -10
  77. package/output/ClarifyShell-7r92MZg9.cjs.map +0 -1
  78. package/output/ClarifyShell-D2P0iZ_m.js.map +0 -1
  79. package/output/OpenApiOperation-CyyPlZL6.cjs.map +0 -1
  80. package/output/OpenApiOperation-Dhlz3JSx.js.map +0 -1
  81. package/output/PageActions-CTn2XkPg.cjs.map +0 -1
  82. package/output/PageActions-D0PA8Zv5.js.map +0 -1
  83. package/output/render-CwSsfrs7.js.map +0 -1
  84. package/output/render-DXDSIfZ8.cjs.map +0 -1
  85. /package/output/{chunk-DakpK96I.cjs → rolldown-runtime-DakpK96I.cjs} +0 -0
@@ -1,247 +1,13 @@
1
+ import { t as useBuiltInText } from "./i18n-DnqZHFT7.js";
1
2
  import clsx from "clsx";
2
- import { Fragment, Suspense, createContext, forwardRef, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
3
- import { Link, useLocation, useNavigate } from "react-router-dom";
3
+ import { Suspense, createContext, forwardRef, lazy, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
4
+ import { Link, useLocation } from "react-router-dom";
4
5
  import { CloseButton, Dialog, DialogBackdrop, DialogPanel, Menu, MenuButton, MenuItem, MenuItems, TransitionChild } from "@headlessui/react";
5
6
  import * as LucideIcons from "lucide-react";
6
- import { Check, ChevronDown, Copy, ExternalLink, FileText, Globe2, Link2, LoaderCircle, Menu as Menu$1, Monitor, Moon, MoreHorizontal, PencilLine, Search, SearchX, Sun, X } from "lucide-react";
7
+ import { Check, ChevronDown, Copy, ExternalLink, FileText, Globe2, Link2, Menu as Menu$1, Monitor, Moon, MoreHorizontal, PencilLine, Search, Sun, X } from "lucide-react";
7
8
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
9
  import { AnimatePresence, motion, useIsPresent, useScroll, useTransform } from "framer-motion";
9
10
  import { create, createStore, useStore } from "zustand";
10
- //#region source/core/context.tsx
11
- var ConfigContext = createContext(null);
12
- var LocaleContext = createContext(void 0);
13
- var OpenApisContext = createContext({});
14
- function useConfig() {
15
- const config = useContext(ConfigContext);
16
- if (!config) throw new Error("[clarify] useConfig must be used within a ConfigContext.Provider");
17
- return config;
18
- }
19
- function useConfigOptional() {
20
- return useContext(ConfigContext);
21
- }
22
- function useLocale() {
23
- return useContext(LocaleContext);
24
- }
25
- function useOpenApis() {
26
- return useContext(OpenApisContext);
27
- }
28
- //#endregion
29
- //#region source/core/i18n.ts
30
- var builtInText = {
31
- en: {
32
- "actions.code": "Code",
33
- "actions.copy": "Copy",
34
- "actions.copied": "Copied!",
35
- "builtWith.label": "Built with Clarify",
36
- "builtWith.prefix": "Built with",
37
- "callout.danger": "Danger",
38
- "callout.info": "Info",
39
- "callout.note": "Note",
40
- "callout.success": "Success",
41
- "callout.tip": "Tip",
42
- "callout.warning": "Warning",
43
- "contentActions.copyContent": "Copy page",
44
- "contentActions.copyContentDescription": "Copy this page as {contentType} for LLMs",
45
- "contentActions.copyLink": "Copy {contentType} link",
46
- "contentActions.copyLinkDescription": "Copy the raw {contentType} content link for this page",
47
- "contentActions.copyLlms": "Copy llms.txt",
48
- "contentActions.copyLlmsDescription": "Copy the llms.txt link for this site",
49
- "contentActions.copiedLlms": "Copied llms.txt",
50
- "contentActions.editPage": "Edit this page",
51
- "contentActions.editPageDescription": "Open the source file for this page",
52
- "contentActions.copyOptions": "Choose copy option",
53
- "contentActions.copiedContent": "Copied page",
54
- "contentActions.copiedLink": "Copied link",
55
- "contentActions.viewMarkdown": "View as Markdown",
56
- "contentActions.viewMarkdownDescription": "View this page as plain text",
57
- "contentActions.viewOpenApi": "View raw OpenAPI",
58
- "contentActions.viewOpenApiDescription": "Open the API description file in a new tab",
59
- "feedback.no": "No",
60
- "feedback.prompt": "Was this page helpful?",
61
- "feedback.thanks": "Thanks for your feedback!",
62
- "feedback.yes": "Yes",
63
- "navigation.documentation": "Documentation",
64
- "navigation.next": "Next",
65
- "navigation.previous": "Previous",
66
- "navigation.previousNext": "Previous and next pages",
67
- "navigation.toggle": "Toggle navigation",
68
- "navbar.home": "Home",
69
- "navbar.openLinks": "Open navigation links",
70
- "navbar.sections": "Documentation sections",
71
- "notFound.description": "The page may have moved, been renamed, or never existed. Check the address or return to the homepage.",
72
- "notFound.home": "Back to homepage",
73
- "notFound.label": "404",
74
- "notFound.title": "Page not found",
75
- "openapi.apiDocumentation": "API Documentation",
76
- "openapi.bodyProperties": "Body properties",
77
- "openapi.collapse": "Collapse",
78
- "openapi.endpointNotFound": "Endpoint not found: {endpoint}",
79
- "openapi.example": "Example",
80
- "openapi.expand": "Expand",
81
- "openapi.headers": "Headers",
82
- "openapi.language": "Language",
83
- "openapi.client": "Client",
84
- "openapi.mediaType": "Media type",
85
- "openapi.none": "None",
86
- "openapi.openApiReference": "OpenAPI Reference",
87
- "openapi.operationParameter": "Operation parameter.",
88
- "openapi.optional": "Optional.",
89
- "openapi.parameter": "parameter",
90
- "openapi.pathParameters": "Path parameters",
91
- "openapi.queryParameters": "Query parameters",
92
- "openapi.request": "Request",
93
- "openapi.requestBody": "Request body",
94
- "openapi.responseBodyProperties": "Response body properties",
95
- "openapi.required": "Required.",
96
- "openapi.requiredBadge": "required",
97
- "openapi.response": "Response",
98
- "openapi.responses": "Responses",
99
- "openapi.schemaExample": "Schema example",
100
- "openapi.scrollExamplesLeft": "Scroll examples left",
101
- "openapi.scrollExamplesRight": "Scroll examples right",
102
- "openapi.specNotFound": "OpenAPI spec not found: {specPath}",
103
- "openapi.specPathMissing": "spec or specPath was not provided",
104
- "openapi.status": "Status",
105
- "openapi.version": "Version {version}",
106
- "search.button": "Search...",
107
- "search.noResults": "Nothing found for {query}.",
108
- "search.placeholder": "Find something...",
109
- "search.shortcutCtrl": "Ctrl ",
110
- "renderError.componentStack": "React component stack",
111
- "renderError.description": "Clarify stopped rendering this route to keep the rest of the shell responsive. Review the diagnostics below, fix the page source, then reload the route.",
112
- "renderError.details": "Runtime diagnostics",
113
- "renderError.message": "Message",
114
- "renderError.path": "Route",
115
- "renderError.reload": "Reload route",
116
- "renderError.stack": "JavaScript stack trace",
117
- "renderError.title": "Route render failed",
118
- "renderError.type": "Error type",
119
- "renderError.version": "Clarify version",
120
- "theme.switchToDark": "Switch to dark theme",
121
- "theme.switchToLight": "Switch to light theme",
122
- "theme.switchToSystem": "Follow system theme",
123
- "language.switch": "Switch language",
124
- "mermaid.zoomIn": "Zoom in",
125
- "mermaid.zoomOut": "Zoom out",
126
- "mermaid.resetZoom": "Reset zoom",
127
- "mermaid.renderError": "Mermaid render error",
128
- "mermaid.scrollHint": "Click the diagram to enable scroll-to-zoom"
129
- },
130
- "zh-CN": {
131
- "actions.code": "代码",
132
- "actions.copy": "复制",
133
- "actions.copied": "已复制!",
134
- "builtWith.label": "由 Clarify 构建",
135
- "builtWith.prefix": "构建来自",
136
- "callout.danger": "危险",
137
- "callout.info": "信息",
138
- "callout.note": "注意",
139
- "callout.success": "成功",
140
- "callout.tip": "提示",
141
- "callout.warning": "警告",
142
- "contentActions.copyContent": "复制页面",
143
- "contentActions.copyContentDescription": "将页面以 {contentType} 格式复制给 LLMs",
144
- "contentActions.copyLink": "复制 {contentType} 链接",
145
- "contentActions.copyLinkDescription": "复制当前页面的 {contentType} 原始内容链接",
146
- "contentActions.copyLlms": "复制 llms.txt",
147
- "contentActions.copyLlmsDescription": "复制此站点的 llms.txt 链接",
148
- "contentActions.copiedLlms": "已复制 llms.txt",
149
- "contentActions.editPage": "编辑此页面",
150
- "contentActions.editPageDescription": "打开当前页面的源文件",
151
- "contentActions.copyOptions": "选择复制选项",
152
- "contentActions.copiedContent": "已复制页面",
153
- "contentActions.copiedLink": "已复制链接",
154
- "contentActions.viewMarkdown": "以 Markdown 格式查看",
155
- "contentActions.viewMarkdownDescription": "以纯文本查看此页面",
156
- "contentActions.viewOpenApi": "查看 OpenAPI 原始内容",
157
- "contentActions.viewOpenApiDescription": "在新标签页打开 API 描述文件",
158
- "feedback.no": "否",
159
- "feedback.prompt": "这个页面有帮助吗?",
160
- "feedback.thanks": "感谢你的反馈!",
161
- "feedback.yes": "是",
162
- "navigation.documentation": "文档",
163
- "navigation.next": "下一页",
164
- "navigation.previous": "上一页",
165
- "navigation.previousNext": "上一页和下一页",
166
- "navigation.toggle": "切换导航",
167
- "navbar.home": "首页",
168
- "navbar.openLinks": "打开导航链接",
169
- "navbar.sections": "文档栏目",
170
- "notFound.description": "页面可能已移动、重命名或不存在。请检查地址,或返回首页继续浏览。",
171
- "notFound.home": "返回首页",
172
- "notFound.label": "404",
173
- "notFound.title": "页面未找到",
174
- "openapi.apiDocumentation": "API 文档",
175
- "openapi.bodyProperties": "请求体属性",
176
- "openapi.collapse": "收起",
177
- "openapi.endpointNotFound": "未找到端点:{endpoint}",
178
- "openapi.example": "示例",
179
- "openapi.expand": "展开",
180
- "openapi.headers": "请求头",
181
- "openapi.language": "语言",
182
- "openapi.client": "客户端",
183
- "openapi.mediaType": "媒体类型",
184
- "openapi.none": "无",
185
- "openapi.openApiReference": "OpenAPI 参考",
186
- "openapi.operationParameter": "操作参数。",
187
- "openapi.optional": "可选。",
188
- "openapi.parameter": "参数",
189
- "openapi.pathParameters": "路径参数",
190
- "openapi.queryParameters": "查询参数",
191
- "openapi.request": "请求",
192
- "openapi.requestBody": "请求体",
193
- "openapi.responseBodyProperties": "响应体属性",
194
- "openapi.required": "必填。",
195
- "openapi.requiredBadge": "必填",
196
- "openapi.response": "响应",
197
- "openapi.responses": "响应",
198
- "openapi.schemaExample": "Schema 示例",
199
- "openapi.scrollExamplesLeft": "向左滚动示例",
200
- "openapi.scrollExamplesRight": "向右滚动示例",
201
- "openapi.specNotFound": "未找到 OpenAPI 描述文件:{specPath}",
202
- "openapi.specPathMissing": "未提供 spec 或 specPath",
203
- "openapi.status": "状态",
204
- "openapi.version": "版本 {version}",
205
- "search.button": "搜索...",
206
- "search.noResults": "没有找到与 {query} 相关的结果。",
207
- "search.placeholder": "搜索内容...",
208
- "search.shortcutCtrl": "Ctrl ",
209
- "renderError.componentStack": "React 组件栈",
210
- "renderError.description": "Clarify 已停止渲染此路由,以保证文档 Shell 仍可响应。请查看下方诊断信息,修复页面源码后重新加载路由。",
211
- "renderError.details": "运行时诊断",
212
- "renderError.message": "错误消息",
213
- "renderError.path": "路由",
214
- "renderError.reload": "重新加载路由",
215
- "renderError.stack": "JavaScript 堆栈",
216
- "renderError.title": "路由渲染失败",
217
- "renderError.type": "错误类型",
218
- "renderError.version": "Clarify 版本",
219
- "theme.switchToDark": "切换到深色主题",
220
- "theme.switchToLight": "切换到浅色主题",
221
- "theme.switchToSystem": "跟随系统主题",
222
- "language.switch": "切换语言",
223
- "mermaid.zoomIn": "放大",
224
- "mermaid.zoomOut": "缩小",
225
- "mermaid.resetZoom": "重置缩放",
226
- "mermaid.renderError": "Mermaid 渲染错误",
227
- "mermaid.scrollHint": "点击图表后即可滚轮缩放"
228
- }
229
- };
230
- function resolveBuiltInLocale(locale) {
231
- return locale === "zh-CN" || locale?.toLowerCase().startsWith("zh") ? "zh-CN" : "en";
232
- }
233
- function translateBuiltInText(locale, key, replacements = {}) {
234
- let value = builtInText[resolveBuiltInLocale(locale)]?.[key] ?? builtInText.en[key];
235
- for (const [name, replacement] of Object.entries(replacements)) value = value.replaceAll(`{${name}}`, replacement);
236
- return value;
237
- }
238
- function useBuiltInText(locale) {
239
- const config = useContext(ConfigContext);
240
- const currentLocale = useContext(LocaleContext);
241
- const resolvedLocale = locale ?? currentLocale ?? config?.i18n?.defaultLocale;
242
- return (key, replacements) => translateBuiltInText(resolvedLocale, key, replacements);
243
- }
244
- //#endregion
245
11
  //#region source/utils/clipboard.ts
246
12
  async function copyTextToClipboard(text) {
247
13
  if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) try {
@@ -303,7 +69,7 @@ function ContentActions(arg0) {
303
69
  const { route, routePrefix } = arg0;
304
70
  const t = useBuiltInText();
305
71
  const [copied, setCopied] = useState("idle");
306
- if (!route?.contentArtifactUrl && !route?.sourceUrl) return null;
72
+ if (!route?.contentArtifactUrl && !route?.sourceEditUrl) return null;
307
73
  const contentArtifactUrl = route.contentArtifactUrl ? resolveContentArtifactUrl(route.contentArtifactUrl, routePrefix) : void 0;
308
74
  const isOpenApi = route.kind === "openapi";
309
75
  const replacements = { contentType: isOpenApi ? "OpenAPI" : "Markdown" };
@@ -311,7 +77,7 @@ function ContentActions(arg0) {
311
77
  const viewDescription = isOpenApi ? t("contentActions.viewOpenApiDescription") : t("contentActions.viewMarkdownDescription");
312
78
  function markCopied(state) {
313
79
  setCopied(state);
314
- window.setTimeout(() => setCopied("idle"), 1600);
80
+ setTimeout(() => setCopied("idle"), 1600);
315
81
  }
316
82
  async function handleCopyContent() {
317
83
  if (!contentArtifactUrl) return;
@@ -366,7 +132,7 @@ function ContentActions(arg0) {
366
132
  children: copied === primaryAction.key ? t("actions.copied") : primaryAction.label
367
133
  })]
368
134
  }) : /* @__PURE__ */ jsxs("a", {
369
- href: route.sourceUrl,
135
+ href: route.sourceEditUrl,
370
136
  target: "_blank",
371
137
  rel: "noreferrer",
372
138
  className: "clarify-content-actions-primary clarify-ui-control inline-flex h-8 min-w-0 items-center gap-1.5 px-2.5 no-underline transition sm:px-3",
@@ -384,8 +150,8 @@ function ContentActions(arg0) {
384
150
  anchor: "bottom end",
385
151
  className: "clarify-content-actions-list clarify-ui-menu z-30 mt-2 w-(--clarify-ui-action-menu-width) origin-top-right rounded-(--clarify-theme-tokens-radius-xl) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1.5 shadow-xl shadow-zinc-900/5 transition [--anchor-gap:--spacing(2)] focus:outline-none data-closed:scale-95 data-closed:opacity-0",
386
152
  children: [
387
- route.sourceUrl ? /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsxs("a", {
388
- href: route.sourceUrl,
153
+ route.sourceEditUrl ? /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsxs("a", {
154
+ href: route.sourceEditUrl,
389
155
  target: "_blank",
390
156
  rel: "noreferrer",
391
157
  className: "clarify-content-actions-item clarify-ui-menu-item group flex w-full items-center gap-2 rounded-(--clarify-theme-tokens-radius-lg) px-1.5 py-1.5 text-left no-underline transition",
@@ -710,9 +476,19 @@ function normalizeRoutePath(path) {
710
476
  const [pathname, suffix = ""] = path.split(/([?#].*)/, 2);
711
477
  return `${pathname.replace(/^\/+/, "/").replace(/\/+$/, "") || "/"}${suffix}`;
712
478
  }
713
- function isSameRoutePath(a, b) {
479
+ function stripLocalePathPrefix(path, locale) {
480
+ if (!locale) return normalizeRoutePath(path);
481
+ const [pathname, suffix = ""] = normalizeRoutePath(path).split(/([?#].*)/, 2);
482
+ const localePrefix = `/${locale}`;
483
+ if (pathname === localePrefix) return `/${suffix}`.replace(/^\/$/, "/");
484
+ if (!pathname.startsWith(`${localePrefix}/`)) return `${pathname}${suffix}`;
485
+ return `${pathname.slice(localePrefix.length) || "/"}${suffix}`;
486
+ }
487
+ function isSameRoutePath(a, b, locale) {
714
488
  if (!a || !b) return false;
715
- return normalizeRoutePath(a) === normalizeRoutePath(b);
489
+ const normalizedA = normalizeRoutePath(a);
490
+ const normalizedB = normalizeRoutePath(b);
491
+ return normalizedA === normalizedB || stripLocalePathPrefix(normalizedA, locale) === normalizedB || normalizedA === stripLocalePathPrefix(normalizedB, locale);
716
492
  }
717
493
  //#endregion
718
494
  //#region source/utils/lucide.ts
@@ -797,7 +573,7 @@ function computeVisibleSections(sections, scrollY, viewportTop, viewportBottom)
797
573
  }
798
574
  return visibleSections;
799
575
  }
800
- function useSectionVisibilityDebug(headerTopAreaRef) {
576
+ function useSectionVisibilityDebug(_headerTopAreaRef) {
801
577
  const lastDebugSignatureRef = useRef("");
802
578
  return (snapshot) => {
803
579
  const { scrollY, innerHeight, blockedTop, visibleSections } = snapshot;
@@ -809,14 +585,11 @@ function useSectionVisibilityDebug(headerTopAreaRef) {
809
585
  ].join("|");
810
586
  if (lastDebugSignatureRef.current === debugSignature) return;
811
587
  lastDebugSignatureRef.current = debugSignature;
812
- console.info("[clarify][section-visibility]", {
813
- ...snapshot,
814
- topAreaHeight: headerTopAreaRef?.current?.offsetHeight ?? 0
815
- });
816
588
  };
817
589
  }
818
590
  function useSectionVisibilityObserver(checkVisibleSections, headerTopAreaRef) {
819
591
  useEffect(() => {
592
+ if (typeof window === "undefined") return void 0;
820
593
  const raf = window.requestAnimationFrame(() => checkVisibleSections());
821
594
  window.addEventListener("scroll", checkVisibleSections, { passive: true });
822
595
  window.addEventListener("resize", checkVisibleSections);
@@ -837,6 +610,7 @@ function useVisibleSections(sectionStore, headerTopAreaRef) {
837
610
  const sections = useStore(sectionStore, (state) => state.sections);
838
611
  const emitVisibilityDebug = useSectionVisibilityDebug(headerTopAreaRef);
839
612
  useSectionVisibilityObserver(useCallback(() => {
613
+ if (typeof window === "undefined") return;
840
614
  const { innerHeight, scrollY } = window;
841
615
  const viewportTop = getVisibleViewportTop(scrollY, innerHeight, headerTopAreaRef);
842
616
  const viewportBottom = getVisibleViewportBottom(scrollY, innerHeight, headerTopAreaRef);
@@ -921,7 +695,8 @@ var sectionBadgeColorStyles = {
921
695
  DELETE: "text-red-500 dark:text-rose-500",
922
696
  OPTIONS: "text-violet-500 dark:text-violet-400",
923
697
  HEAD: "text-zinc-500 dark:text-zinc-400",
924
- TRACE: "text-fuchsia-500 dark:text-fuchsia-400"
698
+ TRACE: "text-fuchsia-500 dark:text-fuchsia-400",
699
+ WEBHOOK: "text-violet-500 dark:text-violet-400"
925
700
  };
926
701
  function SectionBadge(arg0) {
927
702
  const { children } = arg0;
@@ -955,13 +730,13 @@ function NavLink(arg0) {
955
730
  });
956
731
  }
957
732
  function VisibleSectionHighlight(arg0) {
958
- const { group, pathname } = arg0;
733
+ const { group, pathname, currentLocale } = arg0;
959
734
  const [sections, visibleSections] = useInitialValue([useSectionStore((s) => s.sections), useSectionStore((s) => s.visibleSections)], useIsInsideMobileNavigation());
960
735
  const isPresent = useIsPresent();
961
736
  const firstVisibleSectionIndex = Math.max(0, [{ id: "_top" }, ...sections].findIndex((section) => section.id === visibleSections[0]));
962
737
  const itemHeight = remToPx(2);
963
738
  const height = isPresent ? Math.max(1, visibleSections.length) * itemHeight : itemHeight;
964
- const top = group.links.findIndex((link) => isSameRoutePath(link.href, pathname)) * itemHeight + firstVisibleSectionIndex * itemHeight;
739
+ const top = group.links.findIndex((link) => isSameRoutePath(link.href, pathname, currentLocale)) * itemHeight + firstVisibleSectionIndex * itemHeight;
965
740
  return /* @__PURE__ */ jsx(motion.div, {
966
741
  initial: {
967
742
  opacity: 0,
@@ -993,9 +768,9 @@ function VisibleSectionHighlight(arg0) {
993
768
  });
994
769
  }
995
770
  function ActivePageMarker(arg0) {
996
- const { group, pathname } = arg0;
771
+ const { group, pathname, currentLocale } = arg0;
997
772
  const itemHeight = remToPx(2);
998
- const top = remToPx(.25) + group.links.findIndex((link) => isSameRoutePath(link.href, pathname)) * itemHeight;
773
+ const top = remToPx(.25) + group.links.findIndex((link) => isSameRoutePath(link.href, pathname, currentLocale)) * itemHeight;
999
774
  return /* @__PURE__ */ jsx(motion.div, {
1000
775
  className: "absolute left-2 h-6 w-px bg-(--clarify-theme-tokens-colors-primary)",
1001
776
  initial: {
@@ -1021,10 +796,10 @@ function ActivePageMarker(arg0) {
1021
796
  });
1022
797
  }
1023
798
  function NavigationGroup(arg0) {
1024
- const { group, className } = arg0;
799
+ const { group, className, currentLocale } = arg0;
1025
800
  const isInsideMobileNavigation = useIsInsideMobileNavigation();
1026
801
  const [pathname, sections] = useInitialValue([normalizeRoutePath(useLocation().pathname), useSectionStore((s) => s.sections)], isInsideMobileNavigation);
1027
- const isActiveGroup = group.links.findIndex((link) => isSameRoutePath(link.href, pathname)) !== -1;
802
+ const isActiveGroup = group.links.findIndex((link) => isSameRoutePath(link.href, pathname, currentLocale)) !== -1;
1028
803
  return /* @__PURE__ */ jsxs("li", {
1029
804
  className: clsx("clarify-navigation-group relative mb-6", className),
1030
805
  children: [/* @__PURE__ */ jsxs("h2", {
@@ -1040,7 +815,8 @@ function NavigationGroup(arg0) {
1040
815
  initial: !isInsideMobileNavigation,
1041
816
  children: isActiveGroup ? /* @__PURE__ */ jsx(VisibleSectionHighlight, {
1042
817
  group,
1043
- pathname
818
+ pathname,
819
+ currentLocale
1044
820
  }) : null
1045
821
  }),
1046
822
  /* @__PURE__ */ jsx("div", { className: "absolute inset-y-0 left-2 w-px bg-(--clarify-theme-tokens-colors-border) dark:bg-white/5" }),
@@ -1048,14 +824,15 @@ function NavigationGroup(arg0) {
1048
824
  initial: false,
1049
825
  children: isActiveGroup ? /* @__PURE__ */ jsx(ActivePageMarker, {
1050
826
  group,
1051
- pathname
827
+ pathname,
828
+ currentLocale
1052
829
  }) : null
1053
830
  }),
1054
831
  /* @__PURE__ */ jsx("ul", {
1055
832
  role: "list",
1056
833
  className: "border-l border-transparent",
1057
834
  children: group.links.map((link) => {
1058
- const active = isSameRoutePath(link.href, pathname);
835
+ const active = isSameRoutePath(link.href, pathname, currentLocale);
1059
836
  return /* @__PURE__ */ jsxs("li", {
1060
837
  className: "relative",
1061
838
  children: [/* @__PURE__ */ jsx(NavLink, {
@@ -1094,7 +871,7 @@ function NavigationGroup(arg0) {
1094
871
  });
1095
872
  }
1096
873
  function Navigation(arg0) {
1097
- const { navigation, className } = arg0;
874
+ const { navigation, className, currentLocale } = arg0;
1098
875
  const groups = navigationToGroups(navigation, useBuiltInText()("navigation.documentation"));
1099
876
  return /* @__PURE__ */ jsx("nav", {
1100
877
  className: clsx("clarify-navigation", className),
@@ -1103,7 +880,8 @@ function Navigation(arg0) {
1103
880
  className: "clarify-navigation-list",
1104
881
  children: groups.map((group, groupIndex) => /* @__PURE__ */ jsx(NavigationGroup, {
1105
882
  group,
1106
- className: groupIndex === 0 ? "mt-0" : ""
883
+ className: groupIndex === 0 ? "mt-0" : "",
884
+ currentLocale
1107
885
  }, group.title))
1108
886
  })
1109
887
  });
@@ -1111,17 +889,17 @@ function Navigation(arg0) {
1111
889
  //#endregion
1112
890
  //#region source/shell/mobile.tsx
1113
891
  var IsInsideMobileNavigationContext = createContext(false);
1114
- function hasPath$1(nodes, pathname) {
1115
- return nodes.some((node) => isSameRoutePath(node.path, pathname) || hasPath$1(node.children ?? [], pathname));
892
+ function hasPath$1(nodes, pathname, currentLocale) {
893
+ return nodes.some((node) => isSameRoutePath(node.path, pathname, currentLocale) || hasPath$1(node.children ?? [], pathname, currentLocale));
1116
894
  }
1117
- function isActiveTab$1(tab, pathname) {
1118
- return isSameRoutePath(tab.path, pathname) || hasPath$1(tab.children, pathname);
895
+ function isActiveTab$1(tab, pathname, currentLocale) {
896
+ return isSameRoutePath(tab.path, pathname, currentLocale) || hasPath$1(tab.children, pathname, currentLocale);
1119
897
  }
1120
898
  function MobileTabsSelect(arg0) {
1121
- const { tabs } = arg0;
899
+ const { tabs, currentLocale } = arg0;
1122
900
  const pathname = normalizeRoutePath(useLocation().pathname);
1123
901
  if (!tabs?.length) return null;
1124
- const activeTab = tabs.find((tab) => isActiveTab$1(tab, pathname)) ?? tabs[0];
902
+ const activeTab = tabs.find((tab) => isActiveTab$1(tab, pathname, currentLocale)) ?? tabs[0];
1125
903
  return /* @__PURE__ */ jsxs(Menu, {
1126
904
  as: "div",
1127
905
  className: "clarify-mobile-tabs-select mb-6",
@@ -1140,7 +918,7 @@ function MobileTabsSelect(arg0) {
1140
918
  }), /* @__PURE__ */ jsx(MenuItems, {
1141
919
  className: "clarify-mobile-tabs-select-list clarify-ui-menu mt-2 flex flex-col gap-1 rounded-(--clarify-theme-tokens-radius-xl) border border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-surface) p-1 shadow-lg shadow-zinc-900/5 focus:outline-none dark:border-white/10 dark:bg-zinc-900 dark:shadow-none",
1142
920
  children: tabs.map((tab) => {
1143
- const active = isActiveTab$1(tab, pathname);
921
+ const active = isActiveTab$1(tab, pathname, currentLocale);
1144
922
  return /* @__PURE__ */ jsx(MenuItem, { children: /* @__PURE__ */ jsxs(Link, {
1145
923
  to: tab.path,
1146
924
  className: clsx("clarify-mobile-tabs-select-item clarify-ui-menu-item flex items-center justify-between gap-3 rounded-(--clarify-theme-tokens-radius-lg) px-3 py-2.5 no-underline transition", active && "clarify-ui-menu-item-active"),
@@ -1181,7 +959,13 @@ function MobileNavigationDialog(arg0) {
1181
959
  }) }), /* @__PURE__ */ jsx(TransitionChild, { children: /* @__PURE__ */ jsxs(motion.div, {
1182
960
  layoutScroll: true,
1183
961
  className: "clarify-mobile-navigation-panel fixed top-14 bottom-0 left-0 w-full max-w-sm overflow-y-auto bg-(--clarify-theme-tokens-colors-background) px-4 pt-6 pb-4 shadow-lg ring-1 shadow-zinc-900/10 ring-(--clarify-theme-tokens-colors-border) duration-500 ease-in-out data-closed:-translate-x-full sm:px-6 sm:pb-10 dark:bg-zinc-950 dark:ring-zinc-800",
1184
- children: [/* @__PURE__ */ jsx(MobileTabsSelect, { tabs }), /* @__PURE__ */ jsx(Navigation, { navigation })]
962
+ children: [/* @__PURE__ */ jsx(MobileTabsSelect, {
963
+ tabs,
964
+ currentLocale
965
+ }), /* @__PURE__ */ jsx(Navigation, {
966
+ navigation,
967
+ currentLocale
968
+ })]
1185
969
  }) })] })]
1186
970
  });
1187
971
  }
@@ -1224,405 +1008,6 @@ function MobileNavigation(arg0) {
1224
1008
  });
1225
1009
  }
1226
1010
  //#endregion
1227
- //#region source/shell/search/items.ts
1228
- function routeGroupTitles(navigation) {
1229
- const titles = /* @__PURE__ */ new Map();
1230
- for (const node of navigation) if (node.children?.length) for (const child of node.children) titles.set(child.path, node.title);
1231
- else titles.set(node.path, node.title);
1232
- return titles;
1233
- }
1234
- function buildSearchItems(routes, navigation) {
1235
- const groupTitles = routeGroupTitles(navigation);
1236
- return routes.flatMap((route) => {
1237
- if (route.isBareAlias) return [];
1238
- const groupTitle = groupTitles.get(route.path);
1239
- return [{
1240
- title: route.title,
1241
- pageTitle: route.title,
1242
- sectionTitle: groupTitle,
1243
- url: route.path,
1244
- keywords: [
1245
- groupTitle,
1246
- route.title,
1247
- route.path,
1248
- route.kind
1249
- ].filter(Boolean).join(" ").toLowerCase()
1250
- }, ...route.sections?.map((section) => ({
1251
- title: section.title,
1252
- pageTitle: route.title,
1253
- sectionTitle: groupTitle,
1254
- url: `${route.path}#${section.id}`,
1255
- keywords: [
1256
- groupTitle,
1257
- route.title,
1258
- section.title,
1259
- route.path,
1260
- section.id
1261
- ].filter(Boolean).join(" ").toLowerCase()
1262
- })) ?? []];
1263
- });
1264
- }
1265
- //#endregion
1266
- //#region source/shell/search/pagefind.ts
1267
- var pagefindPromises = /* @__PURE__ */ new Map();
1268
- function pagefindCacheKey(routePrefix, locale) {
1269
- return `${routePrefix || "/"}:${locale || "default"}`;
1270
- }
1271
- function loadPagefind(routePrefix, locale) {
1272
- if (typeof window === "undefined") return Promise.resolve(null);
1273
- const language = locale ?? document.documentElement.lang;
1274
- const cacheKey = pagefindCacheKey(routePrefix, language);
1275
- const cachedPagefind = pagefindPromises.get(cacheKey);
1276
- if (cachedPagefind) return cachedPagefind;
1277
- const pagefindPromise = import(
1278
- /* @vite-ignore */
1279
- prefixHref("/pagefind/pagefind.js", routePrefix)
1280
- ).then(async (module) => {
1281
- const previousLanguage = document.documentElement.lang;
1282
- if (language) document.documentElement.lang = language;
1283
- const pagefind = module.createInstance();
1284
- if (previousLanguage && previousLanguage !== language) document.documentElement.lang = previousLanguage;
1285
- await pagefind.init?.();
1286
- return pagefind;
1287
- }).catch((error) => {
1288
- pagefindPromises.delete(cacheKey);
1289
- console.warn("[clarify:search] Pagefind instance failed", {
1290
- cacheKey,
1291
- language,
1292
- error
1293
- });
1294
- return null;
1295
- });
1296
- pagefindPromises.set(cacheKey, pagefindPromise);
1297
- return pagefindPromise;
1298
- }
1299
- function normalizePagefindUrl(url, routePrefix) {
1300
- const parsedUrl = new URL(url, window.location.origin);
1301
- let pathname = parsedUrl.pathname;
1302
- const prefix = routePrefix && routePrefix !== "/" ? `/${routePrefix.replace(/^\/+|\/+$/g, "")}` : "";
1303
- if (prefix && (pathname === prefix || pathname.startsWith(`${prefix}/`))) pathname = pathname.slice(prefix.length) || "/";
1304
- return `${pathname}${parsedUrl.search}${parsedUrl.hash}`;
1305
- }
1306
- //#endregion
1307
- //#region source/shell/search/SearchInput.tsx
1308
- var SearchInput = forwardRef(function SearchInput(arg0, inputRef) {
1309
- const { query, setQuery, onClose, onSubmit, activeDescendantId, loading = false } = arg0;
1310
- const t = useBuiltInText();
1311
- return /* @__PURE__ */ jsxs("div", {
1312
- className: "clarify-search-input group relative flex h-12",
1313
- children: [/* @__PURE__ */ jsx(loading ? LoaderCircle : Search, {
1314
- "aria-hidden": "true",
1315
- className: clsx("pointer-events-none absolute top-0 left-3 h-full w-5 stroke-(--clarify-theme-tokens-colors-muted)", loading && "animate-spin")
1316
- }), /* @__PURE__ */ jsx("input", {
1317
- ref: inputRef,
1318
- "data-autofocus": true,
1319
- role: "combobox",
1320
- "aria-expanded": query !== "",
1321
- "aria-controls": "clarify-search-results",
1322
- "aria-activedescendant": activeDescendantId,
1323
- value: query,
1324
- onChange: (event) => setQuery(event.currentTarget.value),
1325
- onKeyDown: (event) => {
1326
- if (event.key === "Escape") if (query) setQuery("");
1327
- else onClose();
1328
- if (event.key === "Enter") {
1329
- event.preventDefault();
1330
- onSubmit();
1331
- }
1332
- },
1333
- placeholder: t("search.placeholder"),
1334
- className: "clarify-search-field flex-auto appearance-none bg-transparent pr-4 pl-10 outline-hidden focus:w-full focus:flex-none [&::-webkit-search-cancel-button]:hidden [&::-webkit-search-decoration]:hidden [&::-webkit-search-results-button]:hidden [&::-webkit-search-results-decoration]:hidden"
1335
- })]
1336
- });
1337
- });
1338
- //#endregion
1339
- //#region source/shell/search/Highlight.tsx
1340
- function stripHtml(value) {
1341
- if (typeof document === "undefined") return value.replace(/<[^>]*>/g, "");
1342
- const template = document.createElement("template");
1343
- template.innerHTML = value;
1344
- return template.content.textContent ?? "";
1345
- }
1346
- function escapeRegExp(value) {
1347
- return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1348
- }
1349
- function HighlightQuery(arg0) {
1350
- const { text, query } = arg0;
1351
- if (!query) return text;
1352
- return /* @__PURE__ */ jsx(Fragment$1, { children: text.split(new RegExp(`(${escapeRegExp(query)})`, "ig")).map((part, index) => part.toLowerCase() === query.toLowerCase() ? /* @__PURE__ */ jsx("mark", {
1353
- className: "bg-transparent text-(--clarify-theme-tokens-colors-primary) underline",
1354
- children: part
1355
- }, index) : /* @__PURE__ */ jsx(Fragment, { children: part }, index)) });
1356
- }
1357
- function renderExcerptNode(node, key) {
1358
- if (node.nodeType === Node.TEXT_NODE) return node.textContent;
1359
- if (node.nodeType !== Node.ELEMENT_NODE) return null;
1360
- const element = node;
1361
- const children = Array.from(element.childNodes).map((child, index) => renderExcerptNode(child, `${key}-${index}`));
1362
- if (element.tagName.toLowerCase() === "mark") return /* @__PURE__ */ jsx("mark", {
1363
- className: "bg-transparent text-(--clarify-theme-tokens-colors-primary) underline",
1364
- children
1365
- }, key);
1366
- return /* @__PURE__ */ jsx(Fragment, { children }, key);
1367
- }
1368
- function HighlightExcerpt(arg0) {
1369
- const { excerpt, query } = arg0;
1370
- if (typeof document === "undefined" || !excerpt.includes("<mark")) return /* @__PURE__ */ jsx(HighlightQuery, {
1371
- text: stripHtml(excerpt),
1372
- query
1373
- });
1374
- const template = document.createElement("template");
1375
- template.innerHTML = excerpt;
1376
- return /* @__PURE__ */ jsx(Fragment$1, { children: Array.from(template.content.childNodes).map((node, index) => renderExcerptNode(node, String(index))) });
1377
- }
1378
- //#endregion
1379
- //#region source/shell/search/SearchResult.tsx
1380
- function SearchResult(arg0) {
1381
- const { result, query, active, onActive, onSelect } = arg0;
1382
- const id = useId();
1383
- const hierarchy = result.type === "quick" ? [result.sectionTitle, result.pageTitle].filter((value) => typeof value === "string") : [];
1384
- return /* @__PURE__ */ jsxs("li", {
1385
- id,
1386
- className: clsx("clarify-search-result group block cursor-pointer px-4 py-3", active && "clarify-search-result-active"),
1387
- "aria-selected": active,
1388
- onMouseEnter: onActive,
1389
- onMouseMove: onActive,
1390
- onMouseDown: (event) => {
1391
- event.preventDefault();
1392
- onSelect();
1393
- },
1394
- children: [
1395
- /* @__PURE__ */ jsx("div", {
1396
- className: "clarify-search-result-title",
1397
- children: /* @__PURE__ */ jsx(HighlightQuery, {
1398
- text: result.title,
1399
- query
1400
- })
1401
- }),
1402
- hierarchy.length > 0 ? /* @__PURE__ */ jsx("div", {
1403
- className: "clarify-search-result-hierarchy mt-1 truncate whitespace-nowrap",
1404
- children: hierarchy.map((item, itemIndex, items) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(HighlightQuery, {
1405
- text: item,
1406
- query
1407
- }), /* @__PURE__ */ jsx("span", {
1408
- className: itemIndex === items.length - 1 ? "sr-only" : "clarify-search-result-separator mx-2",
1409
- children: "/"
1410
- })] }, `${item}-${itemIndex}`))
1411
- }) : null,
1412
- result.type === "full-text" && result.excerpt ? /* @__PURE__ */ jsx("p", {
1413
- className: "clarify-search-result-excerpt mt-1 line-clamp-2 text-xs leading-5 text-(--clarify-theme-tokens-colors-muted)",
1414
- children: /* @__PURE__ */ jsx(HighlightExcerpt, {
1415
- excerpt: result.excerpt,
1416
- query
1417
- })
1418
- }) : null
1419
- ]
1420
- });
1421
- }
1422
- //#endregion
1423
- //#region source/shell/search/SearchDialog.tsx
1424
- function useSearchDialogLifecycle(arg0) {
1425
- const { open, setOpen } = arg0;
1426
- const location = useLocation();
1427
- useEffect(() => {
1428
- setOpen(false);
1429
- }, [
1430
- location.pathname,
1431
- location.search,
1432
- location.hash,
1433
- setOpen
1434
- ]);
1435
- useEffect(() => {
1436
- if (open) return void 0;
1437
- function onKeyDown(event) {
1438
- if (event.key === "k" && (event.metaKey || event.ctrlKey)) {
1439
- event.preventDefault();
1440
- setOpen(true);
1441
- }
1442
- }
1443
- window.addEventListener("keydown", onKeyDown);
1444
- return () => window.removeEventListener("keydown", onKeyDown);
1445
- }, [open, setOpen]);
1446
- }
1447
- function useSearchData(arg0) {
1448
- const { query, searchItems, routePrefix, currentLocale } = arg0;
1449
- const [fullTextState, setFullTextState] = useState(null);
1450
- const [pagefindState, setPagefindState] = useState(null);
1451
- const quickResults = useMemo(() => {
1452
- const normalizedQuery = query.trim().toLowerCase();
1453
- if (!normalizedQuery) return [];
1454
- return searchItems.filter((item) => item.keywords.includes(normalizedQuery)).slice(0, 8).map((item) => ({
1455
- ...item,
1456
- type: "quick"
1457
- }));
1458
- }, [query, searchItems]);
1459
- const pagefindKey = pagefindCacheKey(routePrefix, currentLocale);
1460
- const activePagefindState = pagefindState?.key === pagefindKey ? pagefindState : null;
1461
- const pagefind = activePagefindState?.pagefind ?? null;
1462
- const pagefindAvailable = activePagefindState?.available ?? null;
1463
- const trimmedQuery = query.trim();
1464
- const fullTextKey = `${pagefindKey}:${trimmedQuery}`;
1465
- const results = (fullTextState?.key === fullTextKey ? fullTextState.results : null) ?? quickResults;
1466
- const searchInputLoading = pagefindAvailable === null || Boolean(trimmedQuery && pagefind && fullTextState?.key !== fullTextKey);
1467
- const showNoResults = Boolean(query.trim()) && results.length === 0 && pagefindAvailable !== null;
1468
- useEffect(() => {
1469
- let cancelled = false;
1470
- loadPagefind(routePrefix, currentLocale).then((loadedPagefind) => {
1471
- if (cancelled) return;
1472
- setPagefindState({
1473
- key: pagefindKey,
1474
- pagefind: loadedPagefind,
1475
- available: Boolean(loadedPagefind)
1476
- });
1477
- });
1478
- return () => {
1479
- cancelled = true;
1480
- };
1481
- }, [
1482
- currentLocale,
1483
- pagefindKey,
1484
- routePrefix
1485
- ]);
1486
- useEffect(() => {
1487
- let cancelled = false;
1488
- if (!trimmedQuery || !pagefind) return void 0;
1489
- Promise.resolve().then(async () => {
1490
- if (cancelled) return;
1491
- try {
1492
- const search = await pagefind.search(trimmedQuery, { limit: 8 });
1493
- const data = await Promise.all(search.results.map(async (result) => ({
1494
- id: result.id,
1495
- data: await result.data()
1496
- })));
1497
- if (cancelled) return;
1498
- setFullTextState({
1499
- key: fullTextKey,
1500
- results: data.map(({ id, data }) => ({
1501
- type: "full-text",
1502
- id,
1503
- title: data.meta.title || data.url,
1504
- url: normalizePagefindUrl(data.url, routePrefix),
1505
- excerpt: data.excerpt
1506
- }))
1507
- });
1508
- } catch (error) {
1509
- console.warn("[clarify:search] Pagefind search failed", {
1510
- currentLocale,
1511
- query: trimmedQuery,
1512
- error
1513
- });
1514
- if (!cancelled) setFullTextState({
1515
- key: fullTextKey,
1516
- results: null
1517
- });
1518
- }
1519
- });
1520
- return () => {
1521
- cancelled = true;
1522
- };
1523
- }, [
1524
- currentLocale,
1525
- fullTextKey,
1526
- pagefind,
1527
- routePrefix,
1528
- trimmedQuery
1529
- ]);
1530
- return {
1531
- results,
1532
- searchInputLoading,
1533
- showNoResults
1534
- };
1535
- }
1536
- function SearchDialog(arg0) {
1537
- const { open, setOpen, routes, navigation, routePrefix = "/", currentLocale, className, onNavigate = () => {} } = arg0;
1538
- const t = useBuiltInText();
1539
- const navigate = useNavigate();
1540
- const inputRef = useRef(null);
1541
- const [query, setQuery] = useState("");
1542
- const [activeIndex, setActiveIndex] = useState(0);
1543
- const searchItems = useMemo(() => buildSearchItems(routes, navigation), [navigation, routes]);
1544
- useSearchDialogLifecycle({
1545
- open,
1546
- setOpen
1547
- });
1548
- const { results, searchInputLoading, showNoResults } = useSearchData({
1549
- query,
1550
- searchItems,
1551
- routePrefix,
1552
- currentLocale
1553
- });
1554
- const updateQuery = (value) => {
1555
- setQuery(value);
1556
- setActiveIndex(0);
1557
- };
1558
- function closeDialog() {
1559
- updateQuery("");
1560
- setOpen(false);
1561
- }
1562
- function selectResult(result = results[activeIndex]) {
1563
- if (!result) return;
1564
- navigate(result.url);
1565
- onNavigate();
1566
- closeDialog();
1567
- }
1568
- function renderResultsPanel() {
1569
- return /* @__PURE__ */ jsxs("div", {
1570
- className: "border-t border-(--clarify-theme-tokens-colors-border) bg-(--clarify-theme-tokens-colors-background) empty:hidden dark:border-zinc-100/5 dark:bg-white/2.5",
1571
- children: [showNoResults ? /* @__PURE__ */ jsxs("div", {
1572
- className: "p-6 text-center",
1573
- children: [/* @__PURE__ */ jsx(SearchX, { className: "mx-auto h-5 w-5 stroke-(--clarify-theme-tokens-colors-foreground) dark:stroke-zinc-600" }), /* @__PURE__ */ jsx("p", {
1574
- className: "mt-2 text-xs text-(--clarify-theme-tokens-colors-muted) dark:text-zinc-400",
1575
- children: t("search.noResults", { query })
1576
- })]
1577
- }) : null, results.length ? /* @__PURE__ */ jsx("ul", {
1578
- id: "clarify-search-results",
1579
- className: "clarify-search-results",
1580
- role: "listbox",
1581
- children: results.map((result, resultIndex) => /* @__PURE__ */ jsx(SearchResult, {
1582
- result,
1583
- query,
1584
- active: resultIndex === activeIndex,
1585
- onActive: () => setActiveIndex(resultIndex),
1586
- onSelect: () => selectResult(result)
1587
- }, result.type === "full-text" ? result.id : result.url))
1588
- }) : null]
1589
- });
1590
- }
1591
- return /* @__PURE__ */ jsxs(Dialog, {
1592
- open,
1593
- onClose: closeDialog,
1594
- className: clsx("clarify-search-dialog fixed inset-0 z-50", className),
1595
- children: [/* @__PURE__ */ jsx(DialogBackdrop, {
1596
- transition: true,
1597
- className: "clarify-search-backdrop clarify-ui-backdrop fixed inset-0 backdrop-blur-xs data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in"
1598
- }), /* @__PURE__ */ jsx("div", {
1599
- className: "fixed inset-0 overflow-y-auto px-4 py-4 sm:px-6 sm:py-20 md:py-32 lg:px-8 lg:py-(--clarify-search-dialog-padding-block-lg)",
1600
- children: /* @__PURE__ */ jsxs(DialogPanel, {
1601
- transition: true,
1602
- className: "clarify-search-panel mx-auto transform-gpu overflow-hidden rounded-(--clarify-theme-tokens-radius-lg) bg-(--clarify-theme-tokens-colors-surface) shadow-xl ring-1 ring-(--clarify-theme-tokens-colors-border) data-closed:scale-95 data-closed:opacity-0 data-enter:duration-300 data-enter:ease-out data-leave:duration-200 data-leave:ease-in sm:max-w-xl dark:bg-zinc-900 dark:ring-zinc-800",
1603
- onKeyDown: (event) => {
1604
- if (event.key === "ArrowDown") {
1605
- event.preventDefault();
1606
- setActiveIndex((index) => results.length ? (index + 1) % results.length : 0);
1607
- }
1608
- if (event.key === "ArrowUp") {
1609
- event.preventDefault();
1610
- setActiveIndex((index) => results.length ? (index - 1 + results.length) % results.length : 0);
1611
- }
1612
- },
1613
- children: [/* @__PURE__ */ jsx(SearchInput, {
1614
- ref: inputRef,
1615
- query,
1616
- setQuery: updateQuery,
1617
- onClose: closeDialog,
1618
- onSubmit: () => selectResult(),
1619
- loading: searchInputLoading
1620
- }), renderResultsPanel()]
1621
- })
1622
- })]
1623
- });
1624
- }
1625
- //#endregion
1626
1011
  //#region source/shell/search/useSearchProps.ts
1627
1012
  function useSearchProps() {
1628
1013
  const buttonRef = useRef(null);
@@ -1642,6 +1027,7 @@ function useSearchProps() {
1642
1027
  }
1643
1028
  //#endregion
1644
1029
  //#region source/shell/Search.tsx
1030
+ var SearchDialog = lazy(() => import("./SearchDialog-CxYLjRi5.js"));
1645
1031
  function getModifierKey() {
1646
1032
  if (typeof navigator === "undefined") return "Ctrl ";
1647
1033
  return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform) ? "⌘" : "Ctrl ";
@@ -1848,14 +1234,14 @@ function MobileNavbarMenu(arg0) {
1848
1234
  })]
1849
1235
  });
1850
1236
  }
1851
- function hasPath(nodes, pathname) {
1852
- return nodes.some((node) => isSameRoutePath(node.path, pathname) || hasPath(node.children ?? [], pathname));
1237
+ function hasPath(nodes, pathname, currentLocale) {
1238
+ return nodes.some((node) => isSameRoutePath(node.path, pathname, currentLocale) || hasPath(node.children ?? [], pathname, currentLocale));
1853
1239
  }
1854
- function isActiveTab(tab, pathname) {
1855
- return isSameRoutePath(tab.path, pathname) || hasPath(tab.children, pathname);
1240
+ function isActiveTab(tab, pathname, currentLocale) {
1241
+ return isSameRoutePath(tab.path, pathname, currentLocale) || hasPath(tab.children, pathname, currentLocale);
1856
1242
  }
1857
1243
  function ProductTabs(arg0) {
1858
- const { tabs } = arg0;
1244
+ const { tabs, currentLocale } = arg0;
1859
1245
  const t = useBuiltInText();
1860
1246
  const pathname = normalizeRoutePath(useLocation().pathname);
1861
1247
  if (!tabs?.length) return null;
@@ -1866,7 +1252,7 @@ function ProductTabs(arg0) {
1866
1252
  className: "clarify-product-tabs-nav mx-auto flex h-full w-full max-w-(--clarify-theme-layout-max-width) items-stretch gap-6 overflow-x-auto px-5",
1867
1253
  "aria-label": t("navbar.sections"),
1868
1254
  children: tabs.map((tab) => {
1869
- const active = isActiveTab(tab, pathname);
1255
+ const active = isActiveTab(tab, pathname, currentLocale);
1870
1256
  return /* @__PURE__ */ jsxs(Link, {
1871
1257
  to: tab.path,
1872
1258
  "aria-current": active ? "page" : void 0,
@@ -2012,7 +1398,10 @@ var Header = forwardRef(function Header(arg0, ref) {
2012
1398
  "data-clarify-header-banner": true,
2013
1399
  children: banner
2014
1400
  }),
2015
- /* @__PURE__ */ jsx(ProductTabs, { tabs })
1401
+ /* @__PURE__ */ jsx(ProductTabs, {
1402
+ tabs,
1403
+ currentLocale
1404
+ })
2016
1405
  ]
2017
1406
  });
2018
1407
  }
@@ -2049,6 +1438,6 @@ function PageTitleActions() {
2049
1438
  });
2050
1439
  }
2051
1440
  //#endregion
2052
- export { OpenApisContext as A, isExternalHref as C, useBuiltInText as D, copyTextToClipboard as E, useConfigOptional as M, useLocale as N, ConfigContext as O, useOpenApis as P, themeCookieName as S, prefixHref as T, getStoredThemePreference as _, SectionProvider as a, storeLocalePreference as b, lucideIconRegistry as c, normalizeRoutePath as d, resolveLocalizedText as f, getStoredLocalePreference as g, useTheme as h, Navigation as i, useConfig as j, LocaleContext as k, resolveLucideIconName as l, ThemeProvider as m, PageTitleActions as n, useSectionStore as o, ThemeToggle as p, Header as r, remToPx as s, PageActionsProvider as t, isSameRoutePath as u, localeCookieName as v, localizeHref as w, storeThemePreference as x, readLocaleCookie as y };
1441
+ export { isExternalHref as C, copyTextToClipboard as E, themeCookieName as S, prefixHref as T, getStoredThemePreference as _, SectionProvider as a, storeLocalePreference as b, lucideIconRegistry as c, normalizeRoutePath as d, resolveLocalizedText as f, getStoredLocalePreference as g, useTheme as h, Navigation as i, resolveLucideIconName as l, ThemeProvider as m, PageTitleActions as n, useSectionStore as o, ThemeToggle as p, Header as r, remToPx as s, PageActionsProvider as t, isSameRoutePath as u, localeCookieName as v, localizeHref as w, storeThemePreference as x, readLocaleCookie as y };
2053
1442
 
2054
- //# sourceMappingURL=PageActions-D0PA8Zv5.js.map
1443
+ //# sourceMappingURL=PageActions-D7K9LDGf.js.map