@sixb/app 0.1.10 → 0.1.11

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.
@@ -0,0 +1,70 @@
1
+ // @bun
2
+ // src/locale-messages.ts
3
+ var en = {
4
+ goHome: "Go home",
5
+ reload: "Reload",
6
+ retry: "Retry",
7
+ notFound: {
8
+ title: "Not found",
9
+ detail: "The page or resource you requested does not exist."
10
+ },
11
+ accessDenied: {
12
+ title: "Access required",
13
+ detail: "Your account is signed in, but it does not have permission to access this app.",
14
+ signOut: "Sign out",
15
+ signingOut: "Signing out\u2026"
16
+ },
17
+ error: {
18
+ title: "Something went wrong",
19
+ sharedDetail: "This shared page could not be displayed."
20
+ },
21
+ apiUnavailable: {
22
+ title: "Can't reach the Sixb API",
23
+ detail: (apiBaseUrl) => `This app could not load your session from ${apiBaseUrl}. Check that the API is running and allows this origin, then retry.`
24
+ },
25
+ shared: {
26
+ opening: "Opening shared access\u2026",
27
+ verifying: "Please wait while this link is verified.",
28
+ retryableTitle: "Unable to open this link",
29
+ retryableDetail: "A temporary problem occurred. Please try again.",
30
+ unavailableTitle: "Link unavailable",
31
+ unavailableDetail: "This shared link is invalid, expired, or no longer available.",
32
+ tryAgain: "Try again"
33
+ }
34
+ };
35
+ var fr = {
36
+ goHome: "Retour \xE0 l\u2019accueil",
37
+ reload: "Recharger",
38
+ retry: "R\xE9essayer",
39
+ notFound: {
40
+ title: "Page introuvable",
41
+ detail: "La page ou la ressource demand\xE9e n\u2019existe pas."
42
+ },
43
+ accessDenied: {
44
+ title: "Acc\xE8s requis",
45
+ detail: "Ce compte est connect\xE9, mais n\u2019a pas l\u2019autorisation d\u2019acc\xE9der \xE0 cette application.",
46
+ signOut: "Se d\xE9connecter",
47
+ signingOut: "D\xE9connexion\u2026"
48
+ },
49
+ error: {
50
+ title: "Une erreur est survenue",
51
+ sharedDetail: "Cette page partag\xE9e n\u2019a pas pu \xEAtre affich\xE9e."
52
+ },
53
+ apiUnavailable: {
54
+ title: "Impossible de joindre l\u2019API Sixb",
55
+ detail: (apiBaseUrl) => `L\u2019application n\u2019a pas pu charger la session depuis ${apiBaseUrl}. V\xE9rifiez que l\u2019API est d\xE9marr\xE9e et autorise cette origine, puis r\xE9essayez.`
56
+ },
57
+ shared: {
58
+ opening: "Ouverture de l\u2019acc\xE8s partag\xE9\u2026",
59
+ verifying: "V\xE9rification du lien en cours.",
60
+ retryableTitle: "Impossible d\u2019ouvrir ce lien",
61
+ retryableDetail: "Un probl\xE8me temporaire est survenu. R\xE9essayez.",
62
+ unavailableTitle: "Lien indisponible",
63
+ unavailableDetail: "Ce lien de partage est invalide, a expir\xE9 ou n\u2019est plus disponible.",
64
+ tryAgain: "R\xE9essayer"
65
+ }
66
+ };
67
+
68
+ export { en, fr };
69
+
70
+ //# debugId=352DF601DDD4B18B64756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/locale-messages.ts"],
4
+ "sourcesContent": [
5
+ "import type { MessageTree, Translation } from \"@sixb/ui/lib/i18n\"\n\n/** Source catalog of the screens Sixb generates around a custom app. */\nexport const en = {\n goHome: \"Go home\",\n reload: \"Reload\",\n retry: \"Retry\",\n notFound: {\n title: \"Not found\",\n detail: \"The page or resource you requested does not exist.\",\n },\n accessDenied: {\n title: \"Access required\",\n detail: \"Your account is signed in, but it does not have permission to access this app.\",\n signOut: \"Sign out\",\n signingOut: \"Signing out…\",\n },\n error: {\n title: \"Something went wrong\",\n sharedDetail: \"This shared page could not be displayed.\",\n },\n apiUnavailable: {\n title: \"Can't reach the Sixb API\",\n detail: (apiBaseUrl: string) =>\n `This app could not load your session from ${apiBaseUrl}. Check that the API is running and allows this origin, then retry.`,\n },\n shared: {\n opening: \"Opening shared access…\",\n verifying: \"Please wait while this link is verified.\",\n retryableTitle: \"Unable to open this link\",\n retryableDetail: \"A temporary problem occurred. Please try again.\",\n unavailableTitle: \"Link unavailable\",\n unavailableDetail: \"This shared link is invalid, expired, or no longer available.\",\n tryAgain: \"Try again\",\n },\n} satisfies MessageTree\n\nexport type AppMessages = typeof en\n\nexport const fr: Translation<AppMessages> = {\n goHome: \"Retour à l’accueil\",\n reload: \"Recharger\",\n retry: \"Réessayer\",\n notFound: {\n title: \"Page introuvable\",\n detail: \"La page ou la ressource demandée n’existe pas.\",\n },\n accessDenied: {\n title: \"Accès requis\",\n detail: \"Ce compte est connecté, mais n’a pas l’autorisation d’accéder à cette application.\",\n signOut: \"Se déconnecter\",\n signingOut: \"Déconnexion…\",\n },\n error: {\n title: \"Une erreur est survenue\",\n sharedDetail: \"Cette page partagée n’a pas pu être affichée.\",\n },\n apiUnavailable: {\n title: \"Impossible de joindre l’API Sixb\",\n detail: (apiBaseUrl) =>\n `L’application n’a pas pu charger la session depuis ${apiBaseUrl}. Vérifiez que l’API est démarrée et autorise cette origine, puis réessayez.`,\n },\n shared: {\n opening: \"Ouverture de l’accès partagé…\",\n verifying: \"Vérification du lien en cours.\",\n retryableTitle: \"Impossible d’ouvrir ce lien\",\n retryableDetail: \"Un problème temporaire est survenu. Réessayez.\",\n unavailableTitle: \"Lien indisponible\",\n unavailableDetail: \"Ce lien de partage est invalide, a expiré ou n’est plus disponible.\",\n tryAgain: \"Réessayer\",\n },\n}\n"
6
+ ],
7
+ "mappings": ";;AAGO,IAAM,KAAK;AAAA,EAChB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,EACd;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EAChB;AAAA,EACA,gBAAgB;AAAA,IACd,OAAO;AAAA,IACP,QAAQ,CAAC,eACP,6CAA6C;AAAA,EACjD;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,UAAU;AAAA,EACZ;AACF;AAIO,IAAM,KAA+B;AAAA,EAC1C,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,UAAU;AAAA,IACR,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,cAAc;AAAA,IACZ,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,EACd;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,cAAc;AAAA,EAChB;AAAA,EACA,gBAAgB;AAAA,IACd,OAAO;AAAA,IACP,QAAQ,CAAC,eACP,gEAAsD;AAAA,EAC1D;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,WAAW;AAAA,IACX,gBAAgB;AAAA,IAChB,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,mBAAmB;AAAA,IACnB,UAAU;AAAA,EACZ;AACF;",
8
+ "debugId": "352DF601DDD4B18B64756E2164756E21",
9
+ "names": []
10
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"codegen.d.ts","sourceRoot":"","sources":["../src/codegen.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAIrD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAmB,MAAM,WAAW,CAAA;AAEhF,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;IAChC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC7B;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,aAAa,CAAC,EAAE,SAAS,yBAAyB,EAAE,CAAA;IAC7D,QAAQ,CAAC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AAED;;;;;;;;GAQG;AACH,wBAAsB,gBAAgB,CACpC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE;IACP,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,sEAAsE;IACtE,wBAAwB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CACxC,GACL,OAAO,CAAC;IACT,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,MAAM,CAAA;IAChB,YAAY,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAC,CAm8BD"}
package/dist/index.js CHANGED
@@ -2,6 +2,10 @@
2
2
  import {
3
3
  publicEnv2
4
4
  } from "./chunk-e1gj8c1a.js";
5
+ import {
6
+ en,
7
+ fr
8
+ } from "./chunk-cftmy40z.js";
5
9
 
6
10
  // src/createCustomApp.ts
7
11
  import { randomBytes } from "crypto";
@@ -574,6 +578,9 @@ function isNotFoundError(error) {
574
578
  }
575
579
 
576
580
  // src/codegen.ts
581
+ function sharedUnavailableTranslations() {
582
+ return { en: en.shared.unavailableDetail, fr: fr.shared.unavailableDetail };
583
+ }
577
584
  var AUTH_EXPERIENCE_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__";
578
585
  function assertNoReservedSharedRoutes(routes) {
579
586
  const reservedRoute = routes.find((route) => route.path === "/shared" || route.path.startsWith("/shared/"));
@@ -899,8 +906,10 @@ import {
899
906
  useNavigate,
900
907
  useRoutes,
901
908
  } from "react-router-dom"
902
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
909
+ import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query"
903
910
  import { isSixbApiError } from "@sixb/client/browser"
911
+ import { getProjectInfoOptions } from "@sixb/client/hooks"
912
+ import { LocaleProvider, useAppMessages } from "@sixb/app/locale"
904
913
  import { routePaths, routes } from "./routes"
905
914
  ${globalsCssImport}
906
915
  ${layoutImport}
@@ -1090,6 +1099,7 @@ function AppFallback({
1090
1099
  showReload?: boolean
1091
1100
  action?: React.ReactNode
1092
1101
  }) {
1102
+ const messages = useAppMessages()
1093
1103
  return (
1094
1104
  <div
1095
1105
  role="alert"
@@ -1125,7 +1135,7 @@ function AppFallback({
1125
1135
  textDecoration: "none",
1126
1136
  }}
1127
1137
  >
1128
- Go home
1138
+ {messages.goHome}
1129
1139
  </a>
1130
1140
  {showReload ? (
1131
1141
  <button
@@ -1140,7 +1150,7 @@ function AppFallback({
1140
1150
  cursor: "pointer",
1141
1151
  }}
1142
1152
  >
1143
- Reload
1153
+ {messages.reload}
1144
1154
  </button>
1145
1155
  ) : null}
1146
1156
  </>
@@ -1151,6 +1161,7 @@ function AppFallback({
1151
1161
  }
1152
1162
 
1153
1163
  function AccessDeniedView() {
1164
+ const messages = useAppMessages().accessDenied
1154
1165
  const [isSigningOut, setIsSigningOut] = React.useState(false)
1155
1166
 
1156
1167
  async function handleSignOut() {
@@ -1165,8 +1176,8 @@ function AccessDeniedView() {
1165
1176
 
1166
1177
  return (
1167
1178
  <AppFallback
1168
- title="Access required"
1169
- detail="Your account is signed in, but it does not have permission to access this app."
1179
+ title={messages.title}
1180
+ detail={messages.detail}
1170
1181
  showReload={false}
1171
1182
  action={
1172
1183
  <button
@@ -1182,7 +1193,7 @@ function AccessDeniedView() {
1182
1193
  cursor: isSigningOut ? "default" : "pointer",
1183
1194
  }}
1184
1195
  >
1185
- {isSigningOut ? "Signing out\u2026" : "Sign out"}
1196
+ {isSigningOut ? messages.signingOut : messages.signOut}
1186
1197
  </button>
1187
1198
  }
1188
1199
  />
@@ -1193,10 +1204,11 @@ function AccessDeniedView() {
1193
1204
  // route below) and for an expected 404 surfaced through a query. Apps will be
1194
1205
  // able to override this via app/not-found.tsx.
1195
1206
  function NotFoundView() {
1207
+ const messages = useAppMessages().notFound
1196
1208
  return (
1197
1209
  <AppFallback
1198
- title="Not found"
1199
- detail="The page or resource you requested does not exist."
1210
+ title={messages.title}
1211
+ detail={messages.detail}
1200
1212
  showReload={false}
1201
1213
  />
1202
1214
  )
@@ -1214,15 +1226,16 @@ function AppErrorFallback({
1214
1226
  error: unknown
1215
1227
  hideErrorDetails: boolean
1216
1228
  }) {
1229
+ const messages = useAppMessages().error
1217
1230
  if (isSixbApiError(error) && error.status === 404) {
1218
1231
  return <NotFoundView />
1219
1232
  }
1220
1233
  return (
1221
1234
  <AppFallback
1222
- title="Something went wrong"
1235
+ title={messages.title}
1223
1236
  detail={
1224
1237
  hideErrorDetails
1225
- ? "This shared page could not be displayed."
1238
+ ? messages.sharedDetail
1226
1239
  : error instanceof Error
1227
1240
  ? error.message
1228
1241
  : String(error)
@@ -1304,30 +1317,105 @@ function RoutedApp({ hideErrorDetails }: { readonly hideErrorDetails: boolean })
1304
1317
  )
1305
1318
  }
1306
1319
 
1320
+ // Project settings do not change while the app runs: never refetch or collect them. Built on use:
1321
+ // the query key captures the API base URL, which the bootstrap configures after this module loads.
1322
+ function projectInfoQuery() {
1323
+ return {
1324
+ ...getProjectInfoOptions(),
1325
+ staleTime: Number.POSITIVE_INFINITY,
1326
+ gcTime: Number.POSITIVE_INFINITY,
1327
+ retry: false,
1328
+ }
1329
+ }
1330
+
1331
+ // Framework text follows the reader's browser languages and falls back to the project's. A shared
1332
+ // link's grant cannot read project settings, so it keeps the browser's languages alone.
1333
+ function ProjectLocale({
1334
+ shared,
1335
+ children,
1336
+ }: {
1337
+ readonly shared: boolean
1338
+ readonly children: React.ReactNode
1339
+ }) {
1340
+ const { data: project } = useQuery({ ...projectInfoQuery(), enabled: !shared })
1341
+ return <LocaleProvider fallbackLocale={project?.locale}>{children}</LocaleProvider>
1342
+ }
1343
+
1307
1344
  function App({ basename }: StartAppOptions) {
1308
1345
  return (
1309
1346
  <QueryClientProvider client={queryClient}>
1310
- <BrowserRouter basename={basename}>
1311
- <SharedDocumentLinkInterceptor basename={basename} />
1312
- <InternalLinkInterceptor basename={basename} />
1313
- {basename ? (
1314
- <RoutedApp hideErrorDetails />
1315
- ) : (
1316
- <SharedDocumentBoundary>
1317
- <RoutedApp hideErrorDetails={false} />
1318
- </SharedDocumentBoundary>
1319
- )}
1320
- </BrowserRouter>
1347
+ <ProjectLocale shared={Boolean(basename)}>
1348
+ <BrowserRouter basename={basename}>
1349
+ <SharedDocumentLinkInterceptor basename={basename} />
1350
+ <InternalLinkInterceptor basename={basename} />
1351
+ {basename ? (
1352
+ <RoutedApp hideErrorDetails />
1353
+ ) : (
1354
+ <SharedDocumentBoundary>
1355
+ <RoutedApp hideErrorDetails={false} />
1356
+ </SharedDocumentBoundary>
1357
+ )}
1358
+ </BrowserRouter>
1359
+ </ProjectLocale>
1321
1360
  </QueryClientProvider>
1322
1361
  )
1323
1362
  }
1324
1363
 
1325
1364
  export function startApp(options: StartAppOptions = {}) {
1365
+ // The HTML is built without loading the project: declare the project's language on the document
1366
+ // as soon as the API answers, without waiting for the page tree to render.
1367
+ if (!options.basename) {
1368
+ void queryClient.fetchQuery(projectInfoQuery()).then(
1369
+ (project) => {
1370
+ document.documentElement.lang = project.locale
1371
+ },
1372
+ () => undefined
1373
+ )
1374
+ }
1326
1375
  getRoot().render(<App basename={options.basename} />)
1327
1376
  }
1328
1377
 
1378
+ // Without a session the project's locale is unknown: these speak the browser's language.
1329
1379
  export function renderAccessDenied() {
1330
- getRoot().render(<AccessDeniedView />)
1380
+ getRoot().render(
1381
+ <LocaleProvider>
1382
+ <AccessDeniedView />
1383
+ </LocaleProvider>
1384
+ )
1385
+ }
1386
+
1387
+ export function renderApiUnavailable(apiBaseUrl: string) {
1388
+ getRoot().render(
1389
+ <LocaleProvider>
1390
+ <ApiUnavailableView apiBaseUrl={apiBaseUrl} />
1391
+ </LocaleProvider>
1392
+ )
1393
+ }
1394
+
1395
+ function ApiUnavailableView({ apiBaseUrl }: { readonly apiBaseUrl: string }) {
1396
+ const messages = useAppMessages()
1397
+ return (
1398
+ <AppFallback
1399
+ title={messages.apiUnavailable.title}
1400
+ detail={messages.apiUnavailable.detail(apiBaseUrl)}
1401
+ action={
1402
+ <button
1403
+ type="button"
1404
+ onClick={() => window.location.reload()}
1405
+ style={{
1406
+ padding: "0.5rem 1rem",
1407
+ borderRadius: "var(--radius, 0.5rem)",
1408
+ border: "1px solid var(--border, #cbd2d9)",
1409
+ background: "transparent",
1410
+ color: "inherit",
1411
+ cursor: "pointer",
1412
+ }}
1413
+ >
1414
+ {messages.retry}
1415
+ </button>
1416
+ }
1417
+ />
1418
+ )
1331
1419
  }
1332
1420
  `;
1333
1421
  const runtimePath = join4(generatedDir, "app-runtime.tsx");
@@ -1337,7 +1425,7 @@ export function renderAccessDenied() {
1337
1425
  readSixbBrowserRuntimeConfig,
1338
1426
  requireSixbBrowserAuthSession,
1339
1427
  } from "@sixb/client/browser"
1340
- import { renderAccessDenied, startApp } from "./app-runtime"
1428
+ import { renderAccessDenied, renderApiUnavailable, startApp } from "./app-runtime"
1341
1429
 
1342
1430
  const runtimeConfig = readSixbBrowserRuntimeConfig({ audience: "app" })
1343
1431
  const browserClient = configureSixbBrowserClient(runtimeConfig)
@@ -1347,24 +1435,30 @@ if (import.meta.hot) {
1347
1435
  import.meta.hot.dispose(() => browserClient.dispose())
1348
1436
  }
1349
1437
 
1438
+ // Without the API's answer the app can neither render nor send the user to sign in.
1350
1439
  const authSession = runtimeConfig.auth.enabled
1351
- ? await requireSixbBrowserAuthSession(runtimeConfig, browserClient)
1440
+ ? await requireSixbBrowserAuthSession(runtimeConfig, browserClient).catch((error: unknown) => {
1441
+ console.error("[SixbCustomApp] Could not load the session from the API:", error)
1442
+ return "unavailable" as const
1443
+ })
1352
1444
  : null
1353
- const applicationAccessDenied =
1354
- authSession?.authenticated === true && !authSession.applicationAccess.allowed
1355
- const canRenderApp =
1445
+
1446
+ if (authSession === "unavailable") {
1447
+ renderApiUnavailable(runtimeConfig.api.baseUrl)
1448
+ } else if (
1356
1449
  !runtimeConfig.auth.enabled ||
1450
+ (authSession?.authenticated === false && authSession.authEnabled === false) ||
1357
1451
  (authSession?.authenticated === true && authSession.applicationAccess.allowed)
1358
-
1359
- if (canRenderApp) {
1452
+ ) {
1360
1453
  startApp()
1361
- } else if (applicationAccessDenied) {
1454
+ } else if (authSession?.authenticated === true && !authSession.applicationAccess.allowed) {
1362
1455
  renderAccessDenied()
1363
1456
  }
1364
1457
  `;
1365
1458
  const mainPath = join4(generatedDir, "main.tsx");
1366
1459
  await writeFileIfChanged(mainPath, mainContent);
1367
- const sharedMainContent = `import {
1460
+ const sharedMainContent = `import { browserAppLocale, browserAppMessages } from "@sixb/app/locale"
1461
+ import {
1368
1462
  configureSixbSharedBrowserClient,
1369
1463
  isSixbApiError,
1370
1464
  readSixbBrowserRuntimeConfig,
@@ -1396,6 +1490,8 @@ export function startSharedApp(
1396
1490
  bootstrap: SharedAppBootstrap,
1397
1491
  options: SharedAppStartOptions = {}
1398
1492
  ): void {
1493
+ // A shared link speaks the reader's language: the grant cannot read the project's.
1494
+ document.documentElement.lang = browserAppLocale()
1399
1495
  if (!isValidBootstrap(bootstrap)) {
1400
1496
  renderSharedFallback("unavailable")
1401
1497
  return
@@ -1524,28 +1620,29 @@ function renderSharedFallback(
1524
1620
  "justify-content:center;gap:.75rem;padding:2rem;text-align:center;" +
1525
1621
  "font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"
1526
1622
 
1623
+ const messages = browserAppMessages().shared
1527
1624
  const title = document.createElement("h1")
1528
1625
  title.style.cssText = "margin:0;font-size:1.5rem"
1529
1626
  title.textContent =
1530
1627
  state === "loading"
1531
- ? "Opening shared access\u2026"
1628
+ ? messages.opening
1532
1629
  : state === "retryable"
1533
- ? "Unable to open this link"
1534
- : "Link unavailable"
1630
+ ? messages.retryableTitle
1631
+ : messages.unavailableTitle
1535
1632
  const detail = document.createElement("p")
1536
1633
  detail.style.cssText = "margin:0;max-width:32rem"
1537
1634
  detail.textContent =
1538
1635
  state === "loading"
1539
- ? "Please wait while this link is verified."
1636
+ ? messages.verifying
1540
1637
  : state === "retryable"
1541
- ? "A temporary problem occurred. Please try again."
1542
- : "This shared link is invalid, expired, or no longer available."
1638
+ ? messages.retryableDetail
1639
+ : messages.unavailableDetail
1543
1640
  main.append(title, detail)
1544
1641
 
1545
1642
  if (retry) {
1546
1643
  const button = document.createElement("button")
1547
1644
  button.type = "button"
1548
- button.textContent = "Try again"
1645
+ button.textContent = messages.tryAgain
1549
1646
  button.style.cssText =
1550
1647
  "margin-top:.25rem;padding:.625rem 1rem;border:1px solid currentColor;" +
1551
1648
  "border-radius:.375rem;background:transparent;color:inherit;cursor:pointer;font:inherit"
@@ -1628,7 +1725,13 @@ ${renderSharedMetadataHead(metadata)}
1628
1725
  "min-height:100dvh;display:grid;place-items:center;padding:2rem;text-align:center;" +
1629
1726
  "font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"
1630
1727
  const message = document.createElement("p")
1631
- message.textContent = "This shared link is invalid, expired, or no longer available."
1728
+ // Inline and dependency-free: the translations travel with the page.
1729
+ const translations = ${JSON.stringify(sharedUnavailableTranslations())}
1730
+ const language = (navigator.languages || [navigator.language])
1731
+ .map((tag) => String(tag).split("-")[0].toLowerCase())
1732
+ .find((tag) => tag in translations)
1733
+ document.documentElement.lang = language || "en"
1734
+ message.textContent = translations[language || "en"]
1632
1735
  main.append(message)
1633
1736
  root.replaceChildren(main)
1634
1737
  }
@@ -2834,4 +2937,4 @@ export {
2834
2937
  publicEnv2 as publicEnv
2835
2938
  };
2836
2939
 
2837
- //# debugId=8CE68A1AF0B49C0864756E2164756E21
2940
+ //# debugId=0F17895FA991402664756E2164756E21