@krak-stack/registry 0.1.31 → 0.1.33
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.
- package/README.md +21 -0
- package/dist/components/ui/code-block.d.ts +8 -6
- package/dist/components/ui/code-block.js +40 -19
- package/dist/components/ui/copy-button.d.ts +9 -6
- package/dist/components/ui/copy-button.js +15 -8
- package/dist/components/ui/data-table.d.ts +9 -5
- package/dist/components/ui/data-table.js +74 -479
- package/dist/components/ui/editing-locale-switcher.d.ts +8 -4
- package/dist/components/ui/editing-locale-switcher.js +20 -448
- package/dist/components/ui/effect-form.d.ts +39 -10
- package/dist/components/ui/effect-form.js +141 -527
- package/dist/components/ui/error-component.d.ts +4 -2
- package/dist/components/ui/error-component.js +24 -450
- package/dist/components/ui/file-picker.d.ts +4 -2
- package/dist/components/ui/file-picker.js +25 -452
- package/dist/components/ui/form.d.ts +123 -71
- package/dist/components/ui/form.js +81 -474
- package/dist/components/ui/google-map.d.ts +2 -1
- package/dist/components/ui/google-map.js +4 -439
- package/dist/components/ui/icon-input.d.ts +50 -1
- package/dist/components/ui/icon-input.js +30 -446
- package/dist/components/ui/loading.d.ts +7 -1
- package/dist/components/ui/loading.js +4 -438
- package/dist/components/ui/locale-switcher.d.ts +8 -4
- package/dist/components/ui/locale-switcher.js +29 -453
- package/dist/components/ui/pagination.d.ts +5 -3
- package/dist/components/ui/pagination.js +5 -439
- package/dist/components/ui/search-menu.d.ts +4 -2
- package/dist/components/ui/search-menu.js +6 -440
- package/dist/components/ui/theme-switcher.d.ts +5 -3
- package/dist/components/ui/theme-switcher.js +6 -440
- package/dist/components/ui/virtualized-combobox.d.ts +4 -2
- package/dist/components/ui/virtualized-combobox.js +11 -443
- package/dist/lib/docs.d.ts +2 -0
- package/dist/lib/docs.js +86 -481
- package/dist/lib/docs.server.js +0 -21
- package/dist/lib/documentation-toolkit.js +0 -21
- package/dist/lib/markdown/content.d.ts +4 -5
- package/dist/services/agent/client/index.js +75 -463
- package/dist/services/agent/client/widget.d.ts +6 -3
- package/dist/services/notification/client/index.js +8 -440
- package/dist/services/notification/client/notification-menu.d.ts +6 -3
- package/dist/services/notification/public.js +8 -440
- package/dist/services/opentelemetry/api.d.ts +5 -0
- package/dist/services/opentelemetry/api.js +44 -0
- package/dist/services/opentelemetry/browser.d.ts +10 -0
- package/dist/services/opentelemetry/browser.js +59 -0
- package/package.json +9 -1
- package/dist/paraglide/runtime.d.ts +0 -978
|
@@ -212,11 +212,21 @@ function Button({
|
|
|
212
212
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
213
213
|
import { useEffect, useRef, useState } from "react";
|
|
214
214
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
215
|
+
var messages = {
|
|
216
|
+
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
217
|
+
fr: { copy: "Copier", copied: "Copié", copyFailed: "Échec de la copie" }
|
|
218
|
+
};
|
|
219
|
+
var copyButtonMessages = (locale = "en", translations) => ({
|
|
220
|
+
...locale.startsWith("fr") ? messages.fr : messages.en,
|
|
221
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
222
|
+
...translations?.[locale]
|
|
223
|
+
});
|
|
215
224
|
function CopyButton({
|
|
216
225
|
value,
|
|
217
226
|
valueDescription,
|
|
218
227
|
copyVariant = "default",
|
|
219
|
-
|
|
228
|
+
locale = "en",
|
|
229
|
+
messages: messages2,
|
|
220
230
|
onCopied,
|
|
221
231
|
onCopyError,
|
|
222
232
|
resetDelay = 1500,
|
|
@@ -227,11 +237,7 @@ function CopyButton({
|
|
|
227
237
|
}) {
|
|
228
238
|
const [copyState, setCopyState] = useState("idle");
|
|
229
239
|
const copyTimeout = useRef(undefined);
|
|
230
|
-
const labels =
|
|
231
|
-
copy: messages?.copy ?? "Copy",
|
|
232
|
-
copied: messages?.copied ?? "Copied",
|
|
233
|
-
copyFailed: messages?.copyFailed ?? "Copy failed"
|
|
234
|
-
};
|
|
240
|
+
const labels = copyButtonMessages(locale, messages2);
|
|
235
241
|
const accessibleLabel = ariaLabel ?? (valueDescription ? `${labels.copy} ${valueDescription}` : labels.copy);
|
|
236
242
|
const isLarge = copyVariant === "large";
|
|
237
243
|
const defaultSize = copyVariant === "sm" ? "icon-xs" : isLarge ? "sm" : "icon-sm";
|
|
@@ -253,7 +259,7 @@ function CopyButton({
|
|
|
253
259
|
onCopied?.();
|
|
254
260
|
} catch (error) {
|
|
255
261
|
setCopyState("failed");
|
|
256
|
-
onCopyError?.(error instanceof Error ? error : new Error(
|
|
262
|
+
onCopyError?.(error instanceof Error ? error : new Error(labels.copyFailed, { cause: error }));
|
|
257
263
|
}
|
|
258
264
|
resetCopyState();
|
|
259
265
|
};
|
|
@@ -309,21 +315,34 @@ var themeCss = `${createThemeCss({
|
|
|
309
315
|
color: inherit;
|
|
310
316
|
}
|
|
311
317
|
[data-code-theme] pre.th-code code { font: inherit; }`;
|
|
318
|
+
var messages2 = {
|
|
319
|
+
en: {
|
|
320
|
+
codeDescription: (language) => `${language} code`,
|
|
321
|
+
copy: "Copy",
|
|
322
|
+
copied: "Copied",
|
|
323
|
+
copyFailed: "Copy failed"
|
|
324
|
+
},
|
|
325
|
+
fr: {
|
|
326
|
+
codeDescription: (language) => `code ${language}`,
|
|
327
|
+
copy: "Copier",
|
|
328
|
+
copied: "Copié",
|
|
329
|
+
copyFailed: "Échec de la copie"
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
var codeBlockMessages = (locale = "en", translations) => ({
|
|
333
|
+
...locale.startsWith("fr") ? messages2.fr : messages2.en,
|
|
334
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
335
|
+
...translations?.[locale]
|
|
336
|
+
});
|
|
312
337
|
function CodeBlock({
|
|
313
338
|
code,
|
|
314
339
|
language = "text",
|
|
315
|
-
|
|
340
|
+
locale = "en",
|
|
341
|
+
messages: messages3
|
|
316
342
|
}) {
|
|
317
343
|
const normalizedLanguage = language.toLowerCase() || "text";
|
|
318
344
|
const highlighted = highlight(code, { lang: normalizedLanguage });
|
|
319
|
-
const
|
|
320
|
-
if (messages?.copy !== undefined)
|
|
321
|
-
copyMessages.copy = messages.copy;
|
|
322
|
-
if (messages?.copied !== undefined)
|
|
323
|
-
copyMessages.copied = messages.copied;
|
|
324
|
-
if (messages?.copyFailed !== undefined) {
|
|
325
|
-
copyMessages.copyFailed = messages.copyFailed;
|
|
326
|
-
}
|
|
345
|
+
const labels = codeBlockMessages(locale, messages3);
|
|
327
346
|
return /* @__PURE__ */ jsxs2("div", {
|
|
328
347
|
className: "not-prose bg-muted overflow-hidden rounded-md border text-[var(--th-token)]",
|
|
329
348
|
"data-code-theme": true,
|
|
@@ -340,9 +359,10 @@ function CodeBlock({
|
|
|
340
359
|
}),
|
|
341
360
|
/* @__PURE__ */ jsx3(CopyButton, {
|
|
342
361
|
value: code,
|
|
343
|
-
valueDescription:
|
|
362
|
+
valueDescription: labels.codeDescription(highlighted.lang),
|
|
344
363
|
variant: "secondary",
|
|
345
|
-
|
|
364
|
+
locale,
|
|
365
|
+
messages: { [locale]: labels }
|
|
346
366
|
})
|
|
347
367
|
]
|
|
348
368
|
}),
|
|
@@ -360,7 +380,8 @@ var MarkdownContent = ({
|
|
|
360
380
|
className,
|
|
361
381
|
codeBlocks,
|
|
362
382
|
html,
|
|
363
|
-
|
|
383
|
+
locale = "en",
|
|
384
|
+
messages: messages3
|
|
364
385
|
}) => {
|
|
365
386
|
const content = [];
|
|
366
387
|
let remainingHtml = html;
|
|
@@ -378,7 +399,8 @@ var MarkdownContent = ({
|
|
|
378
399
|
children: /* @__PURE__ */ jsx4(CodeBlock, {
|
|
379
400
|
code: block.code,
|
|
380
401
|
language: block.language,
|
|
381
|
-
|
|
402
|
+
locale,
|
|
403
|
+
messages: messages3
|
|
382
404
|
})
|
|
383
405
|
}, `code-${index}`));
|
|
384
406
|
remainingHtml = remainingHtml.slice(markerIndex + marker.length);
|
|
@@ -1102,442 +1124,6 @@ function TooltipContent({
|
|
|
1102
1124
|
});
|
|
1103
1125
|
}
|
|
1104
1126
|
|
|
1105
|
-
// ../../src/paraglide/runtime.js
|
|
1106
|
-
import"@inlang/paraglide-js/urlpattern-polyfill";
|
|
1107
|
-
var baseLocale = "en";
|
|
1108
|
-
var locales = ["en", "fr"];
|
|
1109
|
-
var cookieName = "locale";
|
|
1110
|
-
var cookieMaxAge = 34560000;
|
|
1111
|
-
var cookieDomain = "";
|
|
1112
|
-
var localStorageKey = "PARAGLIDE_LOCALE";
|
|
1113
|
-
var strategy = [
|
|
1114
|
-
"url",
|
|
1115
|
-
"cookie",
|
|
1116
|
-
"preferredLanguage",
|
|
1117
|
-
"baseLocale"
|
|
1118
|
-
];
|
|
1119
|
-
var routeStrategies = [
|
|
1120
|
-
{
|
|
1121
|
-
match: "/api/:path(.*)?",
|
|
1122
|
-
exclude: true
|
|
1123
|
-
},
|
|
1124
|
-
{
|
|
1125
|
-
match: "/sitemap.xml",
|
|
1126
|
-
exclude: true
|
|
1127
|
-
},
|
|
1128
|
-
{
|
|
1129
|
-
match: "/llms.txt",
|
|
1130
|
-
exclude: true
|
|
1131
|
-
}
|
|
1132
|
-
];
|
|
1133
|
-
var urlPatterns = [
|
|
1134
|
-
{
|
|
1135
|
-
pattern: "/:path(.*)?",
|
|
1136
|
-
localized: [
|
|
1137
|
-
[
|
|
1138
|
-
"en",
|
|
1139
|
-
"/en/:path(.*)?"
|
|
1140
|
-
],
|
|
1141
|
-
[
|
|
1142
|
-
"fr",
|
|
1143
|
-
"/fr/:path(.*)?"
|
|
1144
|
-
]
|
|
1145
|
-
]
|
|
1146
|
-
}
|
|
1147
|
-
];
|
|
1148
|
-
var cachedRouteStrategyUrl;
|
|
1149
|
-
var cachedRouteStrategy;
|
|
1150
|
-
function findMatchingRouteStrategy(url) {
|
|
1151
|
-
if (routeStrategies.length === 0) {
|
|
1152
|
-
return;
|
|
1153
|
-
}
|
|
1154
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
1155
|
-
if (cachedRouteStrategyUrl === urlString) {
|
|
1156
|
-
return cachedRouteStrategy;
|
|
1157
|
-
}
|
|
1158
|
-
const urlObject = new URL(urlString, "http://dummy.com");
|
|
1159
|
-
let match;
|
|
1160
|
-
for (const routeStrategy of routeStrategies) {
|
|
1161
|
-
const pattern = new URLPattern(routeStrategy.match, urlObject.href);
|
|
1162
|
-
if (pattern.exec(urlObject.href)) {
|
|
1163
|
-
match = routeStrategy;
|
|
1164
|
-
break;
|
|
1165
|
-
}
|
|
1166
|
-
}
|
|
1167
|
-
cachedRouteStrategyUrl = urlString;
|
|
1168
|
-
cachedRouteStrategy = match;
|
|
1169
|
-
return match;
|
|
1170
|
-
}
|
|
1171
|
-
function getStrategyForUrl(url) {
|
|
1172
|
-
const routeStrategy = findMatchingRouteStrategy(url);
|
|
1173
|
-
if (routeStrategy && routeStrategy.exclude !== true && Array.isArray(routeStrategy.strategy)) {
|
|
1174
|
-
return routeStrategy.strategy;
|
|
1175
|
-
}
|
|
1176
|
-
return strategy;
|
|
1177
|
-
}
|
|
1178
|
-
var serverAsyncLocalStorage = undefined;
|
|
1179
|
-
var isServer = import.meta.env?.SSR ?? typeof window === "undefined";
|
|
1180
|
-
var experimentalStaticLocale = undefined;
|
|
1181
|
-
var TREE_SHAKE_COOKIE_STRATEGY_USED = true;
|
|
1182
|
-
var TREE_SHAKE_URL_STRATEGY_USED = true;
|
|
1183
|
-
var TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED = false;
|
|
1184
|
-
var TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED = true;
|
|
1185
|
-
var TREE_SHAKE_DEFAULT_URL_PATTERN_USED = false;
|
|
1186
|
-
var TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED = false;
|
|
1187
|
-
globalThis.__paraglide = globalThis.__paraglide ?? {};
|
|
1188
|
-
globalThis.__paraglide.ssr = globalThis.__paraglide.ssr ?? {};
|
|
1189
|
-
var _locale;
|
|
1190
|
-
var localeInitiallySet = false;
|
|
1191
|
-
var getLocale = () => {
|
|
1192
|
-
if (experimentalStaticLocale !== undefined) {
|
|
1193
|
-
return experimentalStaticLocale;
|
|
1194
|
-
}
|
|
1195
|
-
if (serverAsyncLocalStorage) {
|
|
1196
|
-
const locale = serverAsyncLocalStorage?.getStore()?.locale;
|
|
1197
|
-
if (locale) {
|
|
1198
|
-
return locale;
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
let strategyToUse = strategy;
|
|
1202
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
1203
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
1204
|
-
}
|
|
1205
|
-
const resolved = resolveLocaleWithStrategies(strategyToUse, typeof window !== "undefined" ? window.location?.href : undefined);
|
|
1206
|
-
if (resolved) {
|
|
1207
|
-
if (!localeInitiallySet) {
|
|
1208
|
-
_locale = resolved;
|
|
1209
|
-
localeInitiallySet = true;
|
|
1210
|
-
setLocale(resolved, { reload: false });
|
|
1211
|
-
}
|
|
1212
|
-
return resolved;
|
|
1213
|
-
}
|
|
1214
|
-
throw new Error("No locale found. Read the docs https://paraglidejs.com/errors#no-locale-found");
|
|
1215
|
-
};
|
|
1216
|
-
function resolveLocaleWithStrategies(strategyToUse, urlForUrlStrategy) {
|
|
1217
|
-
let locale;
|
|
1218
|
-
for (const strat of strategyToUse) {
|
|
1219
|
-
if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
1220
|
-
locale = extractLocaleFromCookie();
|
|
1221
|
-
} else if (strat === "baseLocale") {
|
|
1222
|
-
locale = baseLocale;
|
|
1223
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && !isServer && typeof urlForUrlStrategy === "string") {
|
|
1224
|
-
locale = extractLocaleFromUrl(urlForUrlStrategy);
|
|
1225
|
-
} else if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable" && _locale !== undefined) {
|
|
1226
|
-
locale = _locale;
|
|
1227
|
-
} else if (TREE_SHAKE_PREFERRED_LANGUAGE_STRATEGY_USED && strat === "preferredLanguage" && !isServer) {
|
|
1228
|
-
locale = extractLocaleFromNavigator();
|
|
1229
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && !isServer) {
|
|
1230
|
-
locale = localStorage.getItem(localStorageKey) ?? undefined;
|
|
1231
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
1232
|
-
const handler = customClientStrategies.get(strat);
|
|
1233
|
-
if (handler) {
|
|
1234
|
-
const result = handler.getLocale();
|
|
1235
|
-
if (result instanceof Promise) {
|
|
1236
|
-
continue;
|
|
1237
|
-
}
|
|
1238
|
-
if (result !== undefined) {
|
|
1239
|
-
return assertIsLocale(result);
|
|
1240
|
-
}
|
|
1241
|
-
}
|
|
1242
|
-
}
|
|
1243
|
-
const matchedLocale = toLocale(locale);
|
|
1244
|
-
if (matchedLocale) {
|
|
1245
|
-
return matchedLocale;
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
return;
|
|
1249
|
-
}
|
|
1250
|
-
var rtlLanguages = new Set([
|
|
1251
|
-
"ar",
|
|
1252
|
-
"dv",
|
|
1253
|
-
"fa",
|
|
1254
|
-
"he",
|
|
1255
|
-
"ks",
|
|
1256
|
-
"ku",
|
|
1257
|
-
"ps",
|
|
1258
|
-
"sd",
|
|
1259
|
-
"ug",
|
|
1260
|
-
"ur",
|
|
1261
|
-
"yi"
|
|
1262
|
-
]);
|
|
1263
|
-
var navigateOrReload = (newLocation) => {
|
|
1264
|
-
if (newLocation) {
|
|
1265
|
-
window.location.href = newLocation;
|
|
1266
|
-
} else {
|
|
1267
|
-
window.location.reload();
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
var setLocale = (newLocale, options) => {
|
|
1271
|
-
const optionsWithDefaults = {
|
|
1272
|
-
reload: true,
|
|
1273
|
-
...options
|
|
1274
|
-
};
|
|
1275
|
-
let currentLocale;
|
|
1276
|
-
try {
|
|
1277
|
-
currentLocale = getLocale();
|
|
1278
|
-
} catch {}
|
|
1279
|
-
const customSetLocalePromises = [];
|
|
1280
|
-
let newLocation = undefined;
|
|
1281
|
-
let strategyToUse = strategy;
|
|
1282
|
-
if (!isServer && typeof window !== "undefined" && window.location?.href) {
|
|
1283
|
-
strategyToUse = getStrategyForUrl(window.location.href);
|
|
1284
|
-
}
|
|
1285
|
-
for (const strat of strategyToUse) {
|
|
1286
|
-
if (TREE_SHAKE_GLOBAL_VARIABLE_STRATEGY_USED && strat === "globalVariable") {
|
|
1287
|
-
_locale = newLocale;
|
|
1288
|
-
} else if (TREE_SHAKE_COOKIE_STRATEGY_USED && strat === "cookie") {
|
|
1289
|
-
if (isServer || typeof document === "undefined" || typeof window === "undefined") {
|
|
1290
|
-
continue;
|
|
1291
|
-
}
|
|
1292
|
-
const cookieString = `${cookieName}=${newLocale}; path=/; max-age=${cookieMaxAge}`;
|
|
1293
|
-
document.cookie = cookieDomain ? `${cookieString}; domain=${cookieDomain}` : cookieString;
|
|
1294
|
-
} else if (strat === "baseLocale") {
|
|
1295
|
-
continue;
|
|
1296
|
-
} else if (TREE_SHAKE_URL_STRATEGY_USED && strat === "url" && typeof window !== "undefined") {
|
|
1297
|
-
newLocation = localizeUrl(window.location.href, {
|
|
1298
|
-
locale: newLocale
|
|
1299
|
-
}).href;
|
|
1300
|
-
} else if (TREE_SHAKE_LOCAL_STORAGE_STRATEGY_USED && strat === "localStorage" && typeof window !== "undefined") {
|
|
1301
|
-
localStorage.setItem(localStorageKey, newLocale);
|
|
1302
|
-
} else if (isCustomStrategy(strat) && customClientStrategies.has(strat)) {
|
|
1303
|
-
const handler = customClientStrategies.get(strat);
|
|
1304
|
-
if (handler) {
|
|
1305
|
-
let result = handler.setLocale(newLocale);
|
|
1306
|
-
if (result instanceof Promise) {
|
|
1307
|
-
result = result.catch((error) => {
|
|
1308
|
-
throw new Error(`Custom strategy "${strat}" setLocale failed.`, {
|
|
1309
|
-
cause: error
|
|
1310
|
-
});
|
|
1311
|
-
});
|
|
1312
|
-
customSetLocalePromises.push(result);
|
|
1313
|
-
}
|
|
1314
|
-
}
|
|
1315
|
-
}
|
|
1316
|
-
}
|
|
1317
|
-
const runReload = () => {
|
|
1318
|
-
if (!isServer && optionsWithDefaults.reload && window.location && newLocale !== currentLocale) {
|
|
1319
|
-
navigateOrReload(newLocation);
|
|
1320
|
-
}
|
|
1321
|
-
};
|
|
1322
|
-
if (customSetLocalePromises.length) {
|
|
1323
|
-
return Promise.all(customSetLocalePromises).then(() => {
|
|
1324
|
-
runReload();
|
|
1325
|
-
});
|
|
1326
|
-
}
|
|
1327
|
-
runReload();
|
|
1328
|
-
return;
|
|
1329
|
-
};
|
|
1330
|
-
var getUrlOrigin = () => {
|
|
1331
|
-
if (serverAsyncLocalStorage) {
|
|
1332
|
-
return serverAsyncLocalStorage.getStore()?.origin ?? "http://fallback.com";
|
|
1333
|
-
} else if (typeof window !== "undefined") {
|
|
1334
|
-
return window.location.origin;
|
|
1335
|
-
}
|
|
1336
|
-
return "http://fallback.com";
|
|
1337
|
-
};
|
|
1338
|
-
function toLocale(value) {
|
|
1339
|
-
if (typeof value !== "string") {
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
const lowerValue = value.toLowerCase();
|
|
1343
|
-
for (const locale of locales) {
|
|
1344
|
-
if (locale.toLowerCase() === lowerValue) {
|
|
1345
|
-
return locale;
|
|
1346
|
-
}
|
|
1347
|
-
}
|
|
1348
|
-
return;
|
|
1349
|
-
}
|
|
1350
|
-
function assertIsLocale(input) {
|
|
1351
|
-
const locale = toLocale(input);
|
|
1352
|
-
if (locale)
|
|
1353
|
-
return locale;
|
|
1354
|
-
throw new Error(`Invalid locale: ${input}. Expected one of: ${locales.join(", ")}`);
|
|
1355
|
-
}
|
|
1356
|
-
function extractLocaleFromCookie() {
|
|
1357
|
-
if (typeof document === "undefined" || !document.cookie) {
|
|
1358
|
-
return;
|
|
1359
|
-
}
|
|
1360
|
-
const match = document.cookie.match(new RegExp(`(^| )${cookieName}=([^;]+)`));
|
|
1361
|
-
const locale = match?.[2];
|
|
1362
|
-
return toLocale(locale);
|
|
1363
|
-
}
|
|
1364
|
-
function extractLocaleFromNavigator() {
|
|
1365
|
-
if (!navigator?.languages?.length) {
|
|
1366
|
-
return;
|
|
1367
|
-
}
|
|
1368
|
-
const languages = navigator.languages.map((lang) => ({
|
|
1369
|
-
fullTag: lang,
|
|
1370
|
-
baseTag: lang.split("-")[0]
|
|
1371
|
-
}));
|
|
1372
|
-
for (const lang of languages) {
|
|
1373
|
-
const fullLocale = toLocale(lang.fullTag);
|
|
1374
|
-
if (fullLocale) {
|
|
1375
|
-
return fullLocale;
|
|
1376
|
-
}
|
|
1377
|
-
const baseLocale2 = toLocale(lang.baseTag);
|
|
1378
|
-
if (baseLocale2) {
|
|
1379
|
-
return baseLocale2;
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
return;
|
|
1383
|
-
}
|
|
1384
|
-
var cachedUrl;
|
|
1385
|
-
var cachedLocale;
|
|
1386
|
-
function extractLocaleFromUrl(url) {
|
|
1387
|
-
const urlString = typeof url === "string" ? url : url.href;
|
|
1388
|
-
if (cachedUrl === urlString) {
|
|
1389
|
-
return cachedLocale;
|
|
1390
|
-
}
|
|
1391
|
-
let result;
|
|
1392
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
1393
|
-
result = defaultUrlPatternExtractLocale(url);
|
|
1394
|
-
} else {
|
|
1395
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
1396
|
-
for (const element of urlPatterns) {
|
|
1397
|
-
for (const [locale, localizedPattern] of element.localized) {
|
|
1398
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
1399
|
-
if (match) {
|
|
1400
|
-
result = locale;
|
|
1401
|
-
break;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
if (result)
|
|
1405
|
-
break;
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
cachedUrl = urlString;
|
|
1409
|
-
cachedLocale = result;
|
|
1410
|
-
return result;
|
|
1411
|
-
}
|
|
1412
|
-
function defaultUrlPatternExtractLocale(url) {
|
|
1413
|
-
const urlObj = new URL(url, "http://dummy.com");
|
|
1414
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
1415
|
-
return toLocale(pathSegments[0]) || baseLocale;
|
|
1416
|
-
}
|
|
1417
|
-
function localizeUrl(url, options) {
|
|
1418
|
-
const targetLocale = options?.locale ? assertIsLocale(options?.locale) : getLocale();
|
|
1419
|
-
if (TREE_SHAKE_DEFAULT_URL_PATTERN_USED) {
|
|
1420
|
-
return localizeUrlDefaultPattern(url, targetLocale);
|
|
1421
|
-
}
|
|
1422
|
-
const urlObj = typeof url === "string" ? new URL(url) : url;
|
|
1423
|
-
for (const element of urlPatterns) {
|
|
1424
|
-
for (const [, localizedPattern] of element.localized) {
|
|
1425
|
-
const match = new URLPattern(localizedPattern, urlObj.href).exec(urlObj.href);
|
|
1426
|
-
if (!match) {
|
|
1427
|
-
continue;
|
|
1428
|
-
}
|
|
1429
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
1430
|
-
if (!targetPattern) {
|
|
1431
|
-
continue;
|
|
1432
|
-
}
|
|
1433
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(match), urlObj.origin);
|
|
1434
|
-
return fillMissingUrlParts(localizedUrl, match);
|
|
1435
|
-
}
|
|
1436
|
-
const unlocalizedMatch = new URLPattern(element.pattern, urlObj.href).exec(urlObj.href);
|
|
1437
|
-
if (unlocalizedMatch) {
|
|
1438
|
-
const targetPattern = element.localized.find(([locale]) => locale === targetLocale)?.[1];
|
|
1439
|
-
if (targetPattern) {
|
|
1440
|
-
const localizedUrl = fillPattern(targetPattern, aggregateGroups(unlocalizedMatch), urlObj.origin);
|
|
1441
|
-
return fillMissingUrlParts(localizedUrl, unlocalizedMatch);
|
|
1442
|
-
}
|
|
1443
|
-
}
|
|
1444
|
-
}
|
|
1445
|
-
return urlObj;
|
|
1446
|
-
}
|
|
1447
|
-
function localizeUrlDefaultPattern(url, locale) {
|
|
1448
|
-
const urlObj = typeof url === "string" ? new URL(url, getUrlOrigin()) : new URL(url);
|
|
1449
|
-
const currentLocale = extractLocaleFromUrl(urlObj);
|
|
1450
|
-
if (currentLocale === locale) {
|
|
1451
|
-
return urlObj;
|
|
1452
|
-
}
|
|
1453
|
-
const pathSegments = urlObj.pathname.split("/").filter(Boolean);
|
|
1454
|
-
if (pathSegments.length > 0 && toLocale(pathSegments[0])) {
|
|
1455
|
-
pathSegments.shift();
|
|
1456
|
-
}
|
|
1457
|
-
if (locale === baseLocale) {
|
|
1458
|
-
urlObj.pathname = "/" + pathSegments.join("/");
|
|
1459
|
-
} else {
|
|
1460
|
-
urlObj.pathname = "/" + locale + "/" + pathSegments.join("/");
|
|
1461
|
-
}
|
|
1462
|
-
return urlObj;
|
|
1463
|
-
}
|
|
1464
|
-
function fillMissingUrlParts(url, match) {
|
|
1465
|
-
if (match.protocol.groups["0"]) {
|
|
1466
|
-
url.protocol = match.protocol.groups["0"] ?? "";
|
|
1467
|
-
}
|
|
1468
|
-
if (match.hostname.groups["0"]) {
|
|
1469
|
-
url.hostname = match.hostname.groups["0"] ?? "";
|
|
1470
|
-
}
|
|
1471
|
-
if (match.username.groups["0"]) {
|
|
1472
|
-
url.username = match.username.groups["0"] ?? "";
|
|
1473
|
-
}
|
|
1474
|
-
if (match.password.groups["0"]) {
|
|
1475
|
-
url.password = match.password.groups["0"] ?? "";
|
|
1476
|
-
}
|
|
1477
|
-
if (match.port.groups["0"]) {
|
|
1478
|
-
url.port = match.port.groups["0"] ?? "";
|
|
1479
|
-
}
|
|
1480
|
-
if (match.pathname.groups["0"]) {
|
|
1481
|
-
url.pathname = match.pathname.groups["0"] ?? "";
|
|
1482
|
-
}
|
|
1483
|
-
if (match.search.groups["0"]) {
|
|
1484
|
-
url.search = match.search.groups["0"] ?? "";
|
|
1485
|
-
}
|
|
1486
|
-
if (match.hash.groups["0"]) {
|
|
1487
|
-
url.hash = match.hash.groups["0"] ?? "";
|
|
1488
|
-
}
|
|
1489
|
-
return url;
|
|
1490
|
-
}
|
|
1491
|
-
function fillPattern(pattern, values, origin) {
|
|
1492
|
-
let processedPattern = pattern.replace(/(https?:\/\/[^:/]+):(\d+)(\/|$)/g, (_, protocol, port, slash) => {
|
|
1493
|
-
return `${protocol}#PORT-${port}#${slash}`;
|
|
1494
|
-
});
|
|
1495
|
-
let processedGroupDelimiters = processedPattern.replace(/\{([^{}]*)\}([?+*]?)/g, (_, content, modifier) => {
|
|
1496
|
-
if (modifier === "?") {
|
|
1497
|
-
return content;
|
|
1498
|
-
}
|
|
1499
|
-
return content;
|
|
1500
|
-
});
|
|
1501
|
-
let filled = processedGroupDelimiters.replace(/(\/?):([a-zA-Z0-9_]+)(\([^)]*\))?([?+*]?)/g, (_, slash, name, __, modifier) => {
|
|
1502
|
-
const value = values[name];
|
|
1503
|
-
if (value === null) {
|
|
1504
|
-
return "";
|
|
1505
|
-
}
|
|
1506
|
-
if (modifier === "?") {
|
|
1507
|
-
return value !== undefined ? `${slash}${value}` : "";
|
|
1508
|
-
}
|
|
1509
|
-
if (modifier === "+" || modifier === "*") {
|
|
1510
|
-
if (value === undefined && modifier === "+") {
|
|
1511
|
-
throw new Error(`Missing value for "${name}" (one or more required)`);
|
|
1512
|
-
}
|
|
1513
|
-
return value ? `${slash}${value}` : "";
|
|
1514
|
-
}
|
|
1515
|
-
if (value === undefined) {
|
|
1516
|
-
throw new Error(`Missing value for "${name}"`);
|
|
1517
|
-
}
|
|
1518
|
-
return `${slash}${value}`;
|
|
1519
|
-
});
|
|
1520
|
-
filled = filled.replace(/#PORT-(\d+)#/g, ":$1");
|
|
1521
|
-
return new URL(filled, origin);
|
|
1522
|
-
}
|
|
1523
|
-
function aggregateGroups(match) {
|
|
1524
|
-
return {
|
|
1525
|
-
...match.hash.groups,
|
|
1526
|
-
...match.hostname.groups,
|
|
1527
|
-
...match.password.groups,
|
|
1528
|
-
...match.pathname.groups,
|
|
1529
|
-
...match.port.groups,
|
|
1530
|
-
...match.protocol.groups,
|
|
1531
|
-
...match.search.groups,
|
|
1532
|
-
...match.username.groups
|
|
1533
|
-
};
|
|
1534
|
-
}
|
|
1535
|
-
var customServerStrategies = new Map;
|
|
1536
|
-
var customClientStrategies = new Map;
|
|
1537
|
-
function isCustomStrategy(strategy2) {
|
|
1538
|
-
return typeof strategy2 === "string" && /^custom-[A-Za-z0-9_-]+$/.test(strategy2);
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
1127
|
// ../../src/services/agent/schema.ts
|
|
1542
1128
|
import { Schema as Schema2 } from "effect";
|
|
1543
1129
|
import {
|
|
@@ -1623,7 +1209,7 @@ var AgentStreamError = Schema2.Struct({
|
|
|
1623
1209
|
|
|
1624
1210
|
// ../../src/services/agent/client/widget.tsx
|
|
1625
1211
|
import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1626
|
-
var
|
|
1212
|
+
var messages3 = {
|
|
1627
1213
|
en: {
|
|
1628
1214
|
approve: "Approve",
|
|
1629
1215
|
approvalDestructive: "This may permanently remove data. Check the action before continuing.",
|
|
@@ -1631,6 +1217,7 @@ var messages = {
|
|
|
1631
1217
|
approvalRequired: "The assistant needs your confirmation before making this change.",
|
|
1632
1218
|
cancel: "Cancel",
|
|
1633
1219
|
close: "Close",
|
|
1220
|
+
codeDescription: (language) => `${language} code`,
|
|
1634
1221
|
copied: "Copied",
|
|
1635
1222
|
copy: "Copy",
|
|
1636
1223
|
description: "Ask questions and use available tools to get things done.",
|
|
@@ -1664,6 +1251,7 @@ var messages = {
|
|
|
1664
1251
|
approvalRequired: "L'assistant a besoin de votre confirmation avant d'effectuer cette modification.",
|
|
1665
1252
|
cancel: "Annuler",
|
|
1666
1253
|
close: "Fermer",
|
|
1254
|
+
codeDescription: (language) => `code ${language}`,
|
|
1667
1255
|
copied: "Copié",
|
|
1668
1256
|
copy: "Copier",
|
|
1669
1257
|
description: "Posez des questions et utilisez les outils disponibles pour accomplir vos tâches.",
|
|
@@ -1691,9 +1279,10 @@ var messages = {
|
|
|
1691
1279
|
welcome: "Comment puis-je vous aider?"
|
|
1692
1280
|
}
|
|
1693
1281
|
};
|
|
1694
|
-
var agentWidgetMessages = (locale =
|
|
1695
|
-
...locale.startsWith("fr") ?
|
|
1696
|
-
...
|
|
1282
|
+
var agentWidgetMessages = (locale = "en", translations) => ({
|
|
1283
|
+
...locale.startsWith("fr") ? messages3.fr : messages3.en,
|
|
1284
|
+
...translations?.[locale.split("-")[0] ?? locale],
|
|
1285
|
+
...translations?.[locale]
|
|
1697
1286
|
});
|
|
1698
1287
|
var errorMessage = (code, labels) => {
|
|
1699
1288
|
switch (code) {
|
|
@@ -1769,6 +1358,7 @@ var ToolLabel = ({
|
|
|
1769
1358
|
function ToolActivityCard({
|
|
1770
1359
|
disabled,
|
|
1771
1360
|
labels,
|
|
1361
|
+
locale,
|
|
1772
1362
|
onApproval,
|
|
1773
1363
|
tool
|
|
1774
1364
|
}) {
|
|
@@ -1828,7 +1418,14 @@ function ToolActivityCard({
|
|
|
1828
1418
|
children: /* @__PURE__ */ jsx19(CodeBlock, {
|
|
1829
1419
|
code: inputCode(tool.input),
|
|
1830
1420
|
language: "json",
|
|
1831
|
-
|
|
1421
|
+
locale,
|
|
1422
|
+
messages: {
|
|
1423
|
+
[locale]: {
|
|
1424
|
+
codeDescription: labels.codeDescription,
|
|
1425
|
+
copied: labels.copied,
|
|
1426
|
+
copy: labels.copy
|
|
1427
|
+
}
|
|
1428
|
+
}
|
|
1832
1429
|
})
|
|
1833
1430
|
})
|
|
1834
1431
|
}),
|
|
@@ -1872,6 +1469,7 @@ function ToolActivityCard({
|
|
|
1872
1469
|
function ToolActivityLog({
|
|
1873
1470
|
disabled,
|
|
1874
1471
|
labels,
|
|
1472
|
+
locale,
|
|
1875
1473
|
onApproval,
|
|
1876
1474
|
pending,
|
|
1877
1475
|
tools,
|
|
@@ -1920,6 +1518,7 @@ function ToolActivityLog({
|
|
|
1920
1518
|
children: loggedTools.map((tool) => /* @__PURE__ */ jsx19(ToolActivityCard, {
|
|
1921
1519
|
disabled,
|
|
1922
1520
|
labels,
|
|
1521
|
+
locale,
|
|
1923
1522
|
onApproval,
|
|
1924
1523
|
tool
|
|
1925
1524
|
}, tool.toolCallId))
|
|
@@ -1929,6 +1528,7 @@ function ToolActivityLog({
|
|
|
1929
1528
|
/* @__PURE__ */ jsx19(ToolActivityCard, {
|
|
1930
1529
|
disabled,
|
|
1931
1530
|
labels,
|
|
1531
|
+
locale,
|
|
1932
1532
|
onApproval,
|
|
1933
1533
|
tool: currentTool
|
|
1934
1534
|
})
|
|
@@ -1978,6 +1578,7 @@ function ToolActivityLog({
|
|
|
1978
1578
|
loggedTools.map((tool) => /* @__PURE__ */ jsx19(ToolActivityCard, {
|
|
1979
1579
|
disabled,
|
|
1980
1580
|
labels,
|
|
1581
|
+
locale,
|
|
1981
1582
|
onApproval,
|
|
1982
1583
|
tool
|
|
1983
1584
|
}, tool.toolCallId))
|
|
@@ -1989,6 +1590,7 @@ function ToolActivityLog({
|
|
|
1989
1590
|
function AgentMessageRow({
|
|
1990
1591
|
disabled,
|
|
1991
1592
|
labels,
|
|
1593
|
+
locale,
|
|
1992
1594
|
message,
|
|
1993
1595
|
onApproval,
|
|
1994
1596
|
pending
|
|
@@ -2030,6 +1632,7 @@ function AgentMessageRow({
|
|
|
2030
1632
|
!isUser && (message.tools.length > 0 || pending && !message.text) ? /* @__PURE__ */ jsx19(ToolActivityLog, {
|
|
2031
1633
|
disabled,
|
|
2032
1634
|
labels,
|
|
1635
|
+
locale,
|
|
2033
1636
|
onApproval,
|
|
2034
1637
|
pending,
|
|
2035
1638
|
tools: message.tools,
|
|
@@ -2045,7 +1648,14 @@ function AgentMessageRow({
|
|
|
2045
1648
|
className: "w-full",
|
|
2046
1649
|
codeBlocks: message.markdown.codeBlocks,
|
|
2047
1650
|
html: message.markdown.html,
|
|
2048
|
-
messages: {
|
|
1651
|
+
messages: {
|
|
1652
|
+
[locale]: {
|
|
1653
|
+
codeDescription: labels.codeDescription,
|
|
1654
|
+
copied: labels.copied,
|
|
1655
|
+
copy: labels.copy
|
|
1656
|
+
}
|
|
1657
|
+
},
|
|
1658
|
+
locale
|
|
2049
1659
|
}) : /* @__PURE__ */ jsx19("div", {
|
|
2050
1660
|
className: "w-full whitespace-pre-wrap",
|
|
2051
1661
|
children: message.text
|
|
@@ -2057,6 +1667,7 @@ function AgentMessageRow({
|
|
|
2057
1667
|
function AgentWidget({
|
|
2058
1668
|
availableReferences = [],
|
|
2059
1669
|
context,
|
|
1670
|
+
locale = "en",
|
|
2060
1671
|
messages: messageOverrides,
|
|
2061
1672
|
onInterrupt,
|
|
2062
1673
|
onRemoveContext,
|
|
@@ -2064,7 +1675,7 @@ function AgentWidget({
|
|
|
2064
1675
|
onSubmit,
|
|
2065
1676
|
state
|
|
2066
1677
|
}) {
|
|
2067
|
-
const labels = agentWidgetMessages(
|
|
1678
|
+
const labels = agentWidgetMessages(locale, messageOverrides);
|
|
2068
1679
|
const referenceInputId = useId();
|
|
2069
1680
|
const referenceListId = `${referenceInputId}-list`;
|
|
2070
1681
|
const [open, setOpen] = useState2(false);
|
|
@@ -2250,6 +1861,7 @@ function AgentWidget({
|
|
|
2250
1861
|
children: /* @__PURE__ */ jsx19(AgentMessageRow, {
|
|
2251
1862
|
disabled: state.pending,
|
|
2252
1863
|
labels,
|
|
1864
|
+
locale,
|
|
2253
1865
|
message,
|
|
2254
1866
|
onApproval: respondToApproval,
|
|
2255
1867
|
pending: state.pending && index === state.messages.length - 1
|