@amboras-dev/storefront-core 2026.11.10 → 2026.11.11-rc.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 (57) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/README.md +29 -3
  3. package/bin/amboras-check.mjs +2 -1
  4. package/bin/checks/check-market-routes.mjs +184 -0
  5. package/bin/checks/check-redirect-boundaries.mjs +10 -2
  6. package/core-manifest.json +6 -1
  7. package/dist/edge/hosted-checkout.d.ts +5 -2
  8. package/dist/edge/hosted-checkout.d.ts.map +1 -1
  9. package/dist/edge/hosted-checkout.js +8 -6
  10. package/dist/edge/hosted-checkout.js.map +1 -1
  11. package/dist/edge/market.d.ts +45 -0
  12. package/dist/edge/market.d.ts.map +1 -0
  13. package/dist/edge/market.js +74 -0
  14. package/dist/edge/market.js.map +1 -0
  15. package/dist/edge/proxy.d.ts +27 -2
  16. package/dist/edge/proxy.d.ts.map +1 -1
  17. package/dist/edge/proxy.js +204 -56
  18. package/dist/edge/proxy.js.map +1 -1
  19. package/dist/edge/url-map.d.ts +57 -0
  20. package/dist/edge/url-map.d.ts.map +1 -0
  21. package/dist/edge/url-map.js +140 -0
  22. package/dist/edge/url-map.js.map +1 -0
  23. package/dist/hooks/use-auth.d.ts.map +1 -1
  24. package/dist/hooks/use-auth.js +5 -2
  25. package/dist/hooks/use-auth.js.map +1 -1
  26. package/dist/lib/market.d.ts +176 -0
  27. package/dist/lib/market.d.ts.map +1 -0
  28. package/dist/lib/market.js +228 -0
  29. package/dist/lib/market.js.map +1 -0
  30. package/dist/lib/medusa-client.d.ts.map +1 -1
  31. package/dist/lib/medusa-client.js +30 -1
  32. package/dist/lib/medusa-client.js.map +1 -1
  33. package/dist/lib/redirects.d.ts +13 -5
  34. package/dist/lib/redirects.d.ts.map +1 -1
  35. package/dist/lib/redirects.js +68 -9
  36. package/dist/lib/redirects.js.map +1 -1
  37. package/dist/lib/seo.d.ts +20 -7
  38. package/dist/lib/seo.d.ts.map +1 -1
  39. package/dist/lib/seo.js +157 -29
  40. package/dist/lib/seo.js.map +1 -1
  41. package/dist/lib/site-url.d.ts +8 -0
  42. package/dist/lib/site-url.d.ts.map +1 -1
  43. package/dist/lib/site-url.js +18 -0
  44. package/dist/lib/site-url.js.map +1 -1
  45. package/dist/lib/visitor-free-routes.d.ts +17 -0
  46. package/dist/lib/visitor-free-routes.d.ts.map +1 -0
  47. package/dist/lib/visitor-free-routes.js +31 -0
  48. package/dist/lib/visitor-free-routes.js.map +1 -0
  49. package/dist/next-config/index.d.ts +31 -0
  50. package/dist/next-config/index.d.ts.map +1 -1
  51. package/dist/next-config/index.js +32 -1
  52. package/dist/next-config/index.js.map +1 -1
  53. package/dist/shell/market-link.d.ts +18 -0
  54. package/dist/shell/market-link.d.ts.map +1 -0
  55. package/dist/shell/market-link.js +39 -0
  56. package/dist/shell/market-link.js.map +1 -0
  57. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,113 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 2026.11.11
6
+
7
+ ### Added
8
+
9
+ - Market URLs (AMB-2174, Shopify's market web presences): a market can have a subfolder (`store.com/en-ca`), a subdomain
10
+ (`ca.store.com`) or its own domain (`store.ca`). Medusa owns the link and serves it as `GET /store/url-map`.
11
+ - `/edge`: `marketProxy`, for a store whose routes live under `app/[m]/`. It resolves the market from the host or the
12
+ first path segment and rewrites every page to `/{key}{path}` (`_` root, `en-ca` subfolder, `_<marketId>` host).
13
+ A previous path (the map's `previousPaths`) and a former default language's path (`languagePaths`: `/de-ca`, and
14
+ `/en-can` after en→de and can→ca, each computed by Medusa) 301 to the current URL only while that URL is
15
+ announced (active and turned on); to a pending host, an inactive market or a passive URL they 302 to the root
16
+ instead (`unserved`), so no indexed link is moved for good to a URL that does not serve. A language that is only
17
+ enabled is never a redirect (`/fr-ca` is the root's), and an older map without `languagePaths` has none. An
18
+ inactive presence 302s to the root when Medusa
19
+ says so in `inactiveRedirect` (`temporary`: a draft market, market URLs off, a market now the primary; null or an
20
+ unknown value: no redirect); `/en-ca/checkout*` 302s to the root checkout. Every market redirect is `no-store`. A
21
+ copy of the map older than 10 minutes routes but never redirects, except to the root checkout.
22
+ - Paths in `OUTSIDE_MARKET_TREE` are never rewritten: files (`public/`, `/llms.txt`, `/pinterest/feed.xml`, robots,
23
+ sitemaps, the manifest), `/api`, `.well-known` and the root metadata images. A file path that no file or route
24
+ answers goes to `/_/<path>` through `marketFallbackRewrites()` (`/next-config`, a store's `afterFiles` rewrites,
25
+ one rule), so the catch-all answers the merchant's redirect for it, as on the old tree. A subfolder's file keeps
26
+ its market: `marketProxy` names the market key in `x-amb-market-key` (`MARKET_KEY_HEADER`), and the catch-all's
27
+ lookup accepts a subfolder key that the URL map holds as an active market and that is the path's own prefix, so
28
+ `/en-ca/catalog.pdf` inherits the root's `/catalog.pdf` redirect, prefixed (308 `/en-ca/new`). Any other key is
29
+ the root's lookup. The key comes from a copy of the map younger than 10 minutes only; on a cold instance the read
30
+ starts in the background, so a later request has it. A file never waits for the map, never 503s, never redirects
31
+ and sends no beacon. A real file in `public/` is served first. A dotted path on a market host
32
+ (`ca.store.com/products/a.b`) is the root's: Medusa's product handles carry no `.`.
33
+ - Market URLs exist only on a build that opted in (`marketTreeEnv()`, `isMarketTreeBuild()`): without it neither
34
+ `proxy` nor `marketProxy` reads the URL map, and `proxy` (a store on the old route tree) sets no `x-amb-market`,
35
+ sends no market redirect and adds no market canonical, exactly as before. Both delete client copies of
36
+ `x-amb-market`, `x-amb-market-hop` and `x-amb-market-key`. With the opt-in, `marketProxy` sets `x-amb-market` to the
37
+ resolved market (none on the root); `proxy` never rewrites a path.
38
+ - A/B on the `app/[m]/` tree: the control signs the internal path it resolved into `x-amb-market-hop`
39
+ (`MARKET_HOP_HEADER`, the `amb_theme` HMAC, valid 60 s), and the variant's `marketProxy` serves that path as it is.
40
+ A variant that cannot verify it (no secret yet, an old one) still serves an internal key the map holds (`/_/x`, a
41
+ market host's `/_<marketId>/x`) as it is on a host that is not the store's, without a market header, and counts
42
+ `hop_unverified` (as for any hop header that fails verification). On such a host a subfolder resolves as on the primary (draft 302, previous-suffix 301 included),
43
+ so subfolder pages keep rendering there with or without a verified hop.
44
+ - The edge keeps the map in memory: refreshed every 30 s with `If-None-Match`, in the background once a copy exists,
45
+ one fetch in flight, a 1.5 s timeout, the last good copy when Medusa fails. A 404 or 410 before any good copy (an
46
+ older Medusa) means no map: the root everywhere, retried in 30 s; any other 4xx, or a 4xx after a good copy, keeps
47
+ the copy, marked stale. A cold instance (its first page request) waits for that read, up to 1.5 s, even on a store
48
+ with no market URL: the map is how it knows there is none. One that cannot read it tries
49
+ again after 5 s and, on the primary host, answers a first segment that starts like a market URL (a language subtag
50
+ and a hyphen, `en-ca`; not a template page such as `/kit-gallery`) with a 503 (`Retry-After: 5`, `no-store`) that
51
+ crawlers retry, where a 404 would drop the page; every other path is the
52
+ root's; after 10 minutes without a map (a revoked key, a WAF block) it stops answering 503 and serves the root,
53
+ still retrying. A change to a market URL reaches the edge within about 90 s (Medusa's 30 s memo, 30 s at
54
+ CloudFront, the copy's 30 s refresh) and a page's canonical and the sitemaps 30 s after that (the data cache). Market redirects run only on the store's own hosts: a preview or variant deployment keeps its
55
+ password gate first and never sends a visitor to the live checkout. It counts `map_stale`, `map_unavailable`, `inactive_redirect` and `hop_unverified` through
56
+ `POST /store/market-signals` (kind only), at most once a minute per kind.
57
+ - `lib/market` (new shim `lib/market.ts`): `StoreUrlMap`, `parseStoreUrlMap` (a presence of an unknown kind or status
58
+ is left out, not the whole map), `MARKET_HEADER`, `OUTSIDE_MARKET_TREE`, `isOutsideMarketTree`, `prefixOfKey`,
59
+ `isMarketKey` (an internal key, or one safe lowercase segment the proxy rewrites; a segment of
60
+ `OUTSIDE_MARKET_TREE` such as `api` is not one), `assertMarketKey(m, notFound)` (the `[m]` layout's guard),
61
+ `marketHref`, `getStoreUrlMap` (null only on a 404 or 410, a store API without the map; any other answer that is
62
+ not a map throws `StoreUrlMapUnavailableError`, as the edge copy reads it). The `m` param is request input: a key or
63
+ prefix that is not one safe lowercase segment (`isMarketPrefix`: no slash, backslash, `_` or `.`) prefixes nothing,
64
+ and a redirect lookup given one answers none. Core never re-checks the market URL rule itself (language and
65
+ suffix): that is Medusa's alone, and the map carries only what it allowed.
66
+ - `/visitor-free-routes`: `VISITOR_FREE_ROUTES`, the store routes whose GET/HEAD answer never depends on the visitor
67
+ (`/store/content/blogs/:blog/articles`, …). The server fetch shim reads it, and Medusa's mirror spec imports it, so
68
+ the list has one owner.
69
+ - `shell/market-link`: `useMarketHref`, `MarketLink`, `useMarketPathname` (the public path on the server and in the
70
+ browser alike). `useAuth().logout` goes to the market's home.
71
+ - `lib/site-url`: `marketMetadataBase(key, map)`, the `metadataBase` of an `app/[m]/` page (`https://store.com/en-ca`,
72
+ `https://store.ca`); the root origin for a passive (backfilled, not turned on) presence.
73
+ - `lib/seo`: the sitemap index lists the root plus each announced subfolder on the primary host, and a market's own
74
+ host lists its market; child ids are `slot * 100000 + page`, the slot being Medusa's stable presence `ordinal`
75
+ (the root's slot is 0, so its ids are unchanged). Every URL carries hreflang alternates (`en-CA`, …, `x-default`) when the store's
76
+ hreflang setting is on and a market URL is announced. A market's sitemap (a subfolder's slot, or its own host's)
77
+ lists what its region sells (`/store/products?region_id=`, the map's `regionId`; a market without one lists no
78
+ product), and a product URL names as alternates only the markets that sell it (read in at most one
79
+ `region_id` + `id` lookup per market per 100 products of the child, cached like it). The sitemap is the only place
80
+ hreflang is written: no page `<head>` carries it, so the two can never disagree. `robots.txt` names a market host's own sitemap there and
81
+ disallows the private pages under each announced subfolder too. All of it only on the `app/[m]/` tree
82
+ (`marketTreeEnv()`, `isMarketTreeBuild()`): a store on the old route tree never reads the map there and gets
83
+ byte-for-byte today's sitemaps and robots, as does a store with no announced market URL.
84
+ - `lib/redirects`: `resolveRedirect`, `resolveHandleRedirect` and `resolveUnmatchedPathRedirect` take a
85
+ `marketPrefix` (`prefixOfKey(params.m)`). Under a prefix the full path is tried first (`/en-ca/old-page`), then
86
+ the inner path, whose relative target stays in the market. With no prefix, on the `app/[m]/` tree,
87
+ `resolveUnmatchedPathRedirect` takes a market file path's prefix from `x-amb-market-key` as above (it reads
88
+ `headers()`; a map that cannot be read is the root's lookup, never a 500, logged as `redirect_lookup_failed`).
89
+ - `amboras-check market-routes`: on a store with `app/[m]/` or a `marketProxy` export, fails a route file on the wrong
90
+ side of `OUTSIDE_MARKET_TREE` (and a metadata image anywhere but the app root) with the move to make, an
91
+ `app/[m]/layout` without `assertMarketKey`, and a `next.config` that does not spread `marketTreeEnv()` into its
92
+ `env` or return `marketFallbackRewrites()` in its `rewrites()` `afterFiles` (alone, or spread anywhere in an array).
93
+ `amboras-check redirect-boundaries` guards the same folders under
94
+ `app/[m]/`, and `app/[m]/loading.*`.
95
+
96
+ ### Fixed
97
+
98
+ - Static rendering, on a store that opts in (`env: { ...marketTreeEnv() }` in next.config, `/next-config`: the
99
+ `app/[m]/` template): the server fetch shim (`lib/medusa-client`) read `cookies()` / `headers()` for every request to
100
+ Medusa, so a statically rendered page (`/about`, `/checkout`, `/account`) threw "static to dynamic" on every
101
+ revalidation and stayed stale, and an `app/[m]/` page's first render under a market key answered 500. With the
102
+ opt-in it skips that read for a GET of the exact store routes core calls that Medusa answers the same for every
103
+ visitor: `/store/url-map`, `/store/url-redirects`, `/store/content/blogs`, `/store/content/blogs/:blog/articles`,
104
+ `/store/content/blogs/:blog/articles/:handle`, `/store/content/blogs/:blog/articles/:handle/comments`,
105
+ `/store/metaobjects/:type`, `/store/metaobjects/:type/:handle`, `/store/config`, `/store/brand`,
106
+ `/store/integrations/active`, `/store/policies`, `/store/checkout-settings` (matched on the normalised path).
107
+ Every other route keeps the visitor's `x-amb-vid` / `x-amb-country`, and a store without the opt-in (every store on
108
+ the old tree) is exactly as before.
109
+ - `edge/proxy.ts` no longer claims to be generated from the orchestrator's `middleware-template.ts`: core stores run
110
+ this file, legacy stores run the template.
111
+
5
112
  ## 2026.11.10
6
113
 
7
114
  ### Fixed
package/README.md CHANGED
@@ -57,7 +57,7 @@ from it and its version-floor check makes sure each shim exists.
57
57
  | `types/index.ts` | `@amboras-dev/storefront-core/types` |
58
58
  | `components/ClientPluginSlot.tsx` | `@amboras-dev/storefront-core/shell/client-plugin-slot` |
59
59
  | `components/PluginSlot.tsx` | `createPluginSlot` from `@amboras-dev/storefront-core/server/plugin-slot` |
60
- | `proxy.ts` | `proxy` from `@amboras-dev/storefront-core/edge` |
60
+ | `proxy.ts` | `proxy` (or `marketProxy`) from `@amboras-dev/storefront-core/edge` |
61
61
 
62
62
  ### 3. The registry and payment UI are injected
63
63
 
@@ -184,6 +184,31 @@ export const config = {
184
184
 
185
185
  `amboras-check proxy-matcher` fails when the copy differs from the installed core's matcher.
186
186
 
187
+ **Market URLs (AMB-2174).** A store whose routes live under `app/[m]/` exports `marketProxy as proxy` instead. It
188
+ reads the store's URL map (`GET /store/url-map`), resolves the market from the host (`ca.store.com`, `store.ca`) or the
189
+ first path segment (`/en-ca`), rewrites every page to `/{market key}{path}` and sets the `x-amb-market` request header
190
+ (any client copy is deleted first). A store on the old tree keeps `proxy`, which reads no URL map and never rewrites
191
+ a path, so it is unchanged by a core bump. Links go through `MarketLink` / `useMarketHref` (`/shell/market-link`) or
192
+ `marketHref` (`/lib/market`); the current path through `useMarketPathname` (never `usePathname`, which differs between
193
+ the server and the browser on a rewritten page). The `[m]` layout guards its key with `assertMarketKey(m, notFound)`
194
+ and sets `metadataBase` with `marketMetadataBase(m, map)`. `next.config` (both from `/next-config`) spreads
195
+ `...marketTreeEnv()` into its `env`, the opt-in that lets the visitor-independent store reads skip the visitor
196
+ cookies so static pages stay static (without it the store is an old tree: no market URL anywhere), and returns
197
+ `afterFiles: marketFallbackRewrites()` from `rewrites()`: a file path no file or route answered goes to `/_/<path>`,
198
+ where the catch-all answers the merchant's redirect, as on the old tree (`/en-ca/old.pdf` in the `en-ca` market, from
199
+ the key `marketProxy` names in `x-amb-market-key`). `OUTSIDE_MARKET_TREE`
200
+ (`/lib/market`, `/edge`) is the one list of paths served outside `app/[m]/`: files, `/api`, `.well-known`, the sitemaps
201
+ and the root metadata images. `amboras-check market-routes` fails a route file on the wrong side of it, a layout
202
+ without `assertMarketKey` and a `next.config` without either of the two.
203
+
204
+ What a market URL is (its language and suffix) is Medusa's rule alone: the map holds only what it allowed, with each
205
+ moved URL's old paths (`previousPaths`, and `languagePaths` for a former default language). An old path 301s only to
206
+ an announced URL; to one that is not serving yet it 302s to the root. The edge keeps the map in memory, so a page
207
+ request makes no Medusa call except on a cold instance's first request, which waits up to 1.5 s for it (even on a
208
+ store without market URLs). With no map at all, a path that starts like a market URL (`/en-ca`) answers 503 for up
209
+ to 10 minutes, which crawlers retry. A change reaches the edge within about 90 s and a page's canonical and the
210
+ sitemaps about 30 s after that.
211
+
187
212
  ### 6. Feature switches: unknown is not off
188
213
 
189
214
  `useStoreConfig()` (client) and `getStoreConfig()` (server) read Medusa's `GET /store/config`. Each
@@ -197,7 +222,7 @@ then falls back to `/store/checkout-settings`.
197
222
  ### 7. Build gates
198
223
 
199
224
  ```bash
200
- npx amboras-check # plugin slots, store quirks, redirect boundaries, consent scroll, proxy matcher
225
+ npx amboras-check # plugin slots, store quirks, redirect boundaries, consent scroll, proxy matcher, market routes
201
226
  npx amboras-check slots # one gate
202
227
  ```
203
228
 
@@ -209,7 +234,8 @@ npx amboras-check slots # one gate
209
234
  | `/client/<hook>` | one hook file, same exports as the template's | per file |
210
235
  | `/server` | `createPluginSlot`, `PluginSlot`, `getPluginConfigs`, `medusaFetch`, `getStoreConfig`, config | no |
211
236
  | `/lib/<path>` | logic modules (checkout, cart, payment providers, analytics, consent…) | per file |
212
- | `/edge` | `proxy`, `proxyConfig` | no |
237
+ | `/edge` | `proxy`, `marketProxy`, `proxyConfig`, `OUTSIDE_MARKET_TREE`, `MARKET_HOP_HEADER` | no |
238
+ | `/visitor-free-routes` | `VISITOR_FREE_ROUTES`, the store routes that never vary by visitor (Medusa's spec imports it) | no |
213
239
  | `/next-config` | `withAmborasCore`, `resolveAmborasImageHosts` | no |
214
240
  | `/config` | `configureCore`, `getCoreConfig` | no |
215
241
  | `/types`, `/types/plugins` | shared types, slot types | no |
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // amboras-check [gate…] [--root <dir>]
5
5
  //
6
- // Gates: slots, quirks, redirect-boundaries, consent-scroll, proxy-matcher (default: all).
6
+ // Gates: slots, quirks, redirect-boundaries, consent-scroll, proxy-matcher, market-routes (default: all).
7
7
  // The store root defaults to the current directory. Each gate is a separate
8
8
  // node process, so a failing gate's exit code and output are its own.
9
9
  import { spawnSync } from 'node:child_process'
@@ -17,6 +17,7 @@ const GATES = {
17
17
  'redirect-boundaries': 'check-redirect-boundaries.mjs',
18
18
  'consent-scroll': 'check-consent-scroll.mjs',
19
19
  'proxy-matcher': 'check-proxy-matcher.mjs',
20
+ 'market-routes': 'check-market-routes.mjs',
20
21
  }
21
22
 
22
23
  const args = process.argv.slice(2)
@@ -0,0 +1,184 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Guard: on a store with the `app/[m]/` tree (AMB-2174), every route file sits where `marketProxy` serves it.
4
+ *
5
+ * WHY. `marketProxy` rewrites every page request to `/{market key}{path}` (`/products/x` → `/_/products/x`), so a
6
+ * page, route handler or metadata route anywhere else under `app/` is never reached: it 404s at the root and under
7
+ * every market prefix. The other way round, a URL in core's `OUTSIDE_MARKET_TREE` (the API, `.well-known`, a file
8
+ * such as `/llms.txt` or `/pinterest/feed.xml`, robots, sitemaps, the manifest) is never rewritten, so its route file
9
+ * must stay at the top of `app/`. Metadata images (`icon`, `apple-icon`, `opengraph-image`, `twitter-image`) live at the
10
+ * app root only. The rule is core's own `isOutsideMarketTree`, loaded from the installed `dist/lib/market.js`, so the
11
+ * gate and the proxy cannot drift.
12
+ *
13
+ * Active when the store has an `app/[m]/` folder or its proxy file exports `marketProxy`; then `app/[m]/layout.*`
14
+ * must exist and guard its key with `assertMarketKey`, and `next.config.*` must spread `marketTreeEnv()` into its
15
+ * `env` and return `marketFallbackRewrites()` in its `rewrites()` `afterFiles`, alone or spread anywhere in an array
16
+ * (else a missing file path, `/old.pdf`, 404s instead of answering its merchant redirect; a config writer such as the
17
+ * Shopify cloner can drop them). A store on the old tree runs `proxy` and passes untouched.
18
+ *
19
+ * Usage: `node check-market-routes.mjs` from the store root (or AMBORAS_STORE_ROOT). One FAIL line per problem with
20
+ * the move to make, exit 1; `[check-market-routes] EXIT_OK` as the last line otherwise.
21
+ */
22
+ import { existsSync, readdirSync, readFileSync, realpathSync } from 'node:fs'
23
+ import { dirname, join, relative, sep } from 'node:path'
24
+ import { fileURLToPath, pathToFileURL } from 'node:url'
25
+
26
+ const TAG = '[check-market-routes]'
27
+ const SCRIPT_EXT = '(?:tsx?|jsx?)'
28
+ const PAGE_RE = new RegExp(`^(?:page|route)\\.${SCRIPT_EXT}$`)
29
+ /** Metadata images: served from the app root only on the market tree (nested under `[m]` their URL doubles the prefix). */
30
+ const METADATA_IMAGE_RE = /^(?:icon|apple-icon|opengraph-image|twitter-image)\d*\..+$/
31
+ /** The other metadata routes and the URL Next serves each at. */
32
+ const METADATA_URL = { robots: 'robots.txt', manifest: 'manifest.webmanifest', sitemap: 'sitemap.xml' }
33
+ const METADATA_RE = /^(robots|manifest|sitemap)\..+$/
34
+ const LAYOUT_RE = new RegExp(`^layout\\.${SCRIPT_EXT}$`)
35
+ const PROXY_FILES = ['proxy.ts', 'proxy.js', 'src/proxy.ts']
36
+
37
+ /** True when the store is on the `app/[m]/` tree: the folder exists, or its proxy file exports `marketProxy`. */
38
+ export function isMarketTree(root) {
39
+ if (existsSync(join(root, 'app', '[m]'))) return true
40
+ return PROXY_FILES.some((file) => {
41
+ try {
42
+ return /\bmarketProxy\b/.test(readFileSync(join(root, file), 'utf8'))
43
+ } catch {
44
+ return false
45
+ }
46
+ })
47
+ }
48
+
49
+ /** What is wrong with `app/[m]/layout.*`, or null: it must exist and call `assertMarketKey`. */
50
+ export function layoutProblem(root) {
51
+ const dir = join(root, 'app', '[m]')
52
+ const layout = existsSync(dir) ? readdirSync(dir).find((name) => LAYOUT_RE.test(name)) : undefined
53
+ if (!layout) return 'app/[m]/layout.tsx is missing: it sets the market metadataBase and answers a bad key with assertMarketKey.'
54
+ if (!readFileSync(join(dir, layout), 'utf8').includes('assertMarketKey')) {
55
+ return `app/[m]/${layout} does not call assertMarketKey(m, notFound): a path no rewrite reaches (/api/missing.json) would render a page under any first segment.`
56
+ }
57
+ return null
58
+ }
59
+
60
+ const NEXT_CONFIGS = ['next.config.mjs', 'next.config.js', 'next.config.ts', 'next.config.mts', 'next.config.cjs']
61
+
62
+ /**
63
+ * The source of the `{ … }` (or the `[ … ]` with `open` `[`) that starts at or after `from`, by bracket count (strings
64
+ * and comments are not special).
65
+ */
66
+ function blockFrom(src, from, open = '{') {
67
+ const close = open === '[' ? ']' : '}'
68
+ const start = src.indexOf(open, from)
69
+ if (start < 0) return ''
70
+ let depth = 0
71
+ for (let i = start; i < src.length; i++) {
72
+ if (src[i] === open) depth++
73
+ if (src[i] === close && --depth === 0) return src.slice(start, i + 1)
74
+ }
75
+ return src.slice(start)
76
+ }
77
+
78
+ /** Whether the `afterFiles` of a `rewrites()` body is `marketFallbackRewrites()` or an array that spreads it anywhere. */
79
+ function afterFilesHasFallback(body) {
80
+ const afterFiles = /\bafterFiles\s*:\s*/.exec(body)
81
+ if (!afterFiles) return false
82
+ const value = body.slice(afterFiles.index + afterFiles[0].length)
83
+ if (/^marketFallbackRewrites\s*\(/.test(value)) return true
84
+ return value.startsWith('[') && /\.\.\.\s*marketFallbackRewrites\s*\(/.test(blockFrom(value, 0, '['))
85
+ }
86
+
87
+ /** The first match of `re` (global) that is not on a `//` comment line, or null. */
88
+ function declaration(src, re) {
89
+ for (const match of src.matchAll(re)) {
90
+ const lineStart = src.lastIndexOf('\n', match.index) + 1
91
+ if (!src.slice(lineStart, match.index).includes('//')) return match
92
+ }
93
+ return null
94
+ }
95
+
96
+ /**
97
+ * What is wrong with the store's next.config, or null: its `env` must spread `marketTreeEnv()` (the opt-in of the
98
+ * market tree), its `rewrites()` must return `marketFallbackRewrites()` in `afterFiles` (after the public files and
99
+ * static routes, before `app/[m]`; alone or spread anywhere in an array).
100
+ */
101
+ export function nextConfigProblem(root) {
102
+ const file = NEXT_CONFIGS.find((name) => existsSync(join(root, name)))
103
+ if (!file) return `no next.config (${NEXT_CONFIGS.join(', ')}): it must set env: { ...marketTreeEnv() } and rewrites() afterFiles: marketFallbackRewrites().`
104
+ const src = readFileSync(join(root, file), 'utf8')
105
+ // The declarations themselves (`env: {`, `rewrites() {`, `rewrites: async () =>`), never a comment that names them.
106
+ const env = declaration(src, /\benv\s*:\s*\{/g)
107
+ if (!env || !/\.\.\.\s*marketTreeEnv\s*\(\s*\)/.test(blockFrom(src, env.index))) {
108
+ return `${file} does not spread marketTreeEnv() into its env: the market tree's static pages would read cookies on every store read and render per request.`
109
+ }
110
+ const rewrites = declaration(src, /\brewrites\s*(?:\(\s*\)\s*\{|:\s*(?:async\s*)?(?:\(\s*\)\s*=>|function\s*\())/g)
111
+ if (!rewrites || !afterFilesHasFallback(blockFrom(src, rewrites.index))) {
112
+ return `${file} does not return marketFallbackRewrites() in its rewrites() afterFiles: a missing file path (/old.pdf) would 404 instead of answering its merchant redirect.`
113
+ }
114
+ return null
115
+ }
116
+
117
+ function walk(dir) {
118
+ return readdirSync(dir, { withFileTypes: true }).flatMap((d) => (d.isDirectory() ? walk(join(dir, d.name)) : [join(dir, d.name)]))
119
+ }
120
+
121
+ /** The URL a route file serves, from its segments under `app/` (groups and `[m]` already dropped). */
122
+ function urlOf(dirs, name) {
123
+ const metadata = METADATA_RE.exec(name)?.[1]
124
+ return `/${[...dirs, ...(metadata ? [METADATA_URL[metadata]] : [])].join('/')}`
125
+ }
126
+
127
+ /**
128
+ * Misplaced route files of `root` as `{ file, move, reason }` (store-relative, `/`-separated). `isOutside` is core's
129
+ * `isOutsideMarketTree`. Files in private folders (`_x`) are not routes; route groups (`(x)`) are not in the URL.
130
+ */
131
+ export function findMarketRouteViolations(root, isOutside) {
132
+ const appDir = join(root, 'app')
133
+ if (!existsSync(appDir)) return []
134
+ const found = []
135
+ for (const file of walk(appDir).map((f) => relative(root, f).split(sep).join('/')).sort()) {
136
+ const segments = file.split('/').slice(1)
137
+ const name = segments.pop()
138
+ if (segments.some((s) => s.startsWith('_'))) continue
139
+ const isImage = METADATA_IMAGE_RE.test(name)
140
+ if (!isImage && !PAGE_RE.test(name) && !METADATA_RE.test(name)) continue
141
+ const dirs = segments.filter((s) => !/^\(.*\)$/.test(s))
142
+ const inTree = dirs[0] === '[m]'
143
+ const urlDirs = inTree ? dirs.slice(1) : dirs
144
+ const raw = segments.filter((s) => s !== '[m]')
145
+ const top = `app/${[...raw, name].join('/')}`
146
+ if (isImage) {
147
+ if (dirs.length) found.push({ file, move: `app/${name}`, reason: 'a metadata image is served from the app root only' })
148
+ continue
149
+ }
150
+ const outside = isOutside(PAGE_RE.test(name) ? `/${urlDirs.join('/')}` : urlOf(urlDirs, name))
151
+ if (outside && inTree) found.push({ file, move: top, reason: 'its URL is outside app/[m]/ (OUTSIDE_MARKET_TREE), marketProxy never rewrites it' })
152
+ if (!outside && !inTree) found.push({ file, move: `app/[m]/${[...raw, name].join('/')}`, reason: 'a route outside app/[m]/ is never served by marketProxy' })
153
+ }
154
+ return found
155
+ }
156
+
157
+ async function main() {
158
+ const root = process.env.AMBORAS_STORE_ROOT ?? process.cwd()
159
+ if (!isMarketTree(root)) {
160
+ console.log(`${TAG} OK: no app/[m]/ and no marketProxy, the store is on the old route tree (proxy), nothing to check.`)
161
+ console.log(`${TAG} EXIT_OK`)
162
+ return
163
+ }
164
+ // core's own rule, from the installed build (the same code the proxy runs).
165
+ const coreMarket = pathToFileURL(join(dirname(fileURLToPath(import.meta.url)), '..', '..', 'dist', 'lib', 'market.js')).href
166
+ const { isOutsideMarketTree } = await import(coreMarket)
167
+ const problems = [
168
+ ...[layoutProblem(root), nextConfigProblem(root)].filter(Boolean),
169
+ ...findMarketRouteViolations(root, isOutsideMarketTree).map(({ file, move, reason }) => `${file} → ${move} (${reason})`),
170
+ ]
171
+ if (problems.length) {
172
+ for (const problem of problems) console.error(`${TAG} FAIL: ${problem}`)
173
+ process.exit(1)
174
+ }
175
+ console.log(`${TAG} OK: every route file is where marketProxy serves it, and app/[m]/layout guards its key.`)
176
+ console.log(`${TAG} EXIT_OK`)
177
+ }
178
+
179
+ if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) {
180
+ main().catch((err) => {
181
+ console.error(`${TAG} FAIL: check crashed — ${err?.message ?? err}`)
182
+ process.exit(1)
183
+ })
184
+ }
@@ -19,12 +19,16 @@
19
19
  * The same holds for the catch-all `app/[...slug]/page.tsx` (a merchant URL redirect for any path):
20
20
  * a `loading.tsx` next to it would turn its 308 into a 200 with a client redirect.
21
21
  *
22
+ * On the `app/[m]/` tree (AMB-2174) the same folders sit under `app/[m]/`, and a `loading.tsx` in `app/[m]/` itself
23
+ * wraps every one of them, so it fails too.
24
+ *
22
25
  * Usage: `node scripts/check-redirect-boundaries.mjs [storefrontRoot]`.
23
26
  * Exit 1 with the offending paths, exit 0 otherwise.
24
27
  */
25
28
  import { existsSync, readFileSync } from 'node:fs'
26
29
  import { join, resolve } from 'node:path'
27
30
  import { fileURLToPath } from 'node:url'
31
+ import { isMarketTree } from './check-market-routes.mjs'
28
32
 
29
33
  // app/pages: a metaobject entry's web page (app/pages/[handle]/[entry]) 308s to a merchant URL redirect when
30
34
  // the entry is gone, so a loading.tsx in either parent would turn that into a 200 (content module).
@@ -36,10 +40,13 @@ export const CORE_BLOG_DIRS = ['app/blogs', 'app/blogs/[blog]']
36
40
  const CORE_BLOG_MARKER = '@/lib/store-blog'
37
41
  const LOADING_FILES = ['loading.tsx', 'loading.ts', 'loading.jsx', 'loading.js']
38
42
 
43
+ /** `app/x` → `app/[m]/x` on the market tree. */
44
+ const inTree = (root, dir) => (isMarketTree(root) ? dir.replace(/^app\//, 'app/[m]/') : dir)
45
+
39
46
  function hasCoreBlogPages(root) {
40
47
  return ['app/blogs/[blog]/page.tsx', 'app/blogs/[blog]/[article]/page.tsx'].some((file) => {
41
48
  try {
42
- return readFileSync(join(root, file), 'utf8').includes(CORE_BLOG_MARKER)
49
+ return readFileSync(join(root, inTree(root, file)), 'utf8').includes(CORE_BLOG_MARKER)
43
50
  } catch {
44
51
  return false
45
52
  }
@@ -49,7 +56,8 @@ function hasCoreBlogPages(root) {
49
56
  /** Offending files (relative paths) under `root`. */
50
57
  export function findRedirectBoundaryViolations(root) {
51
58
  const found = []
52
- for (const dir of hasCoreBlogPages(root) ? [...GUARDED_DIRS, ...CORE_BLOG_DIRS] : GUARDED_DIRS) {
59
+ const dirs = (hasCoreBlogPages(root) ? [...GUARDED_DIRS, ...CORE_BLOG_DIRS] : GUARDED_DIRS).map((dir) => inTree(root, dir))
60
+ for (const dir of isMarketTree(root) ? ['app/[m]', ...dirs] : dirs) {
53
61
  for (const file of LOADING_FILES) {
54
62
  if (existsSync(join(root, dir, file))) found.push(`${dir}/${file}`)
55
63
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$comment": "Generated by scripts/build-manifest.mjs. Paths are relative to the storefront app root.",
3
3
  "package": "@amboras-dev/storefront-core",
4
- "version": "2026.11.10",
4
+ "version": "2026.11.11-rc.1",
5
5
  "shims": [
6
6
  {
7
7
  "path": "hooks/use-auth.ts",
@@ -383,6 +383,11 @@
383
383
  "import": "@amboras-dev/storefront-core/lib/logger",
384
384
  "kind": "reexport"
385
385
  },
386
+ {
387
+ "path": "lib/market.ts",
388
+ "import": "@amboras-dev/storefront-core/lib/market",
389
+ "kind": "reexport"
390
+ },
386
391
  {
387
392
  "path": "lib/medusa-client.ts",
388
393
  "import": "@amboras-dev/storefront-core/lib/medusa-client",
@@ -50,8 +50,11 @@ export interface HostedCheckoutEnv {
50
50
  preview?: boolean;
51
51
  }
52
52
  export declare function hostedCheckoutEnv(): HostedCheckoutEnv;
53
- /** The rewrite to the hosted checkout, or null to let the store serve /checkout itself. */
54
- export declare function hostedCheckout(req: NextRequest, env?: HostedCheckoutEnv, now?: number): Promise<NextResponse | null>;
53
+ /**
54
+ * The rewrite to the hosted checkout, or null to let the store serve /checkout itself. `requestHeaders` are the
55
+ * headers forwarded to the checkout app (the proxy's, with the client's `x-amb-market` already replaced).
56
+ */
57
+ export declare function hostedCheckout(req: NextRequest, env?: HostedCheckoutEnv, now?: number, requestHeaders?: Headers): Promise<NextResponse | null>;
55
58
  /** True for a rewrite to the hosted app: its own security headers must reach the browser untouched. */
56
59
  export declare function isHostedCheckoutResponse(res: Response): boolean;
57
60
  /** Test seam: forget the cached health document. */
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-checkout.d.ts","sourceRoot":"","sources":["../../src/edge/hosted-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAA;AAE5D;;;;;;;;;GASG;AAEH,eAAO,MAAM,kBAAkB,oBAAoB,CAAA;AAEnD,MAAM,WAAW,iBAAiB;IAChC,CAAC,EAAE,CAAC,CAAA;IACJ,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,CAAC,EAAE,CAAC,CAAA;IACL,CAAC,EAAE,MAAM,CAAA;IACT,6FAA6F;IAC7F,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,CAAC,CAAC,EAAE,MAAM,CAAA;IACV,gGAAgG;IAChG,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAkBD,wGAAwG;AACxG,wBAAsB,cAAc,CA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AE,MAAM,CAAA;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,iBAAiB,IAAI,iBAAiB,CAarD;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,GAAG,EAAE,WAAW,EAChB,GAAG,GAAE,iBAAuC,EAC5C,GAAG,GAAE,MAAmB,EACxB,cAAc,GAAE,OAAqB,GACpC,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAoC9B;AAID,uGAAuG;AACvG,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAE/D;AAED,oDAAoD;AACpD,wBAAgB,yBAAyB,SAExC"}
@@ -1,4 +1,5 @@
1
1
  import { NextResponse } from 'next/server';
2
+ import { edgeStoreEnv } from './url-map.js';
2
3
  /**
3
4
  * Hosted checkout: /checkout on the store's own domain is served by the platform's checkout app
4
5
  * (amboras-checkout) through a rewrite, so the shopper never leaves the store's origin.
@@ -69,9 +70,7 @@ export function hostedCheckoutEnv() {
69
70
  checkoutKey: process.env.AMBORAS_CHECKOUT_KEY,
70
71
  checkoutKeyId: process.env.AMBORAS_CHECKOUT_KEY_ID,
71
72
  healthUrl: process.env.AMBORAS_CHECKOUT_HEALTH_URL,
72
- storeId: process.env.NEXT_PUBLIC_STORE_ID,
73
- medusaUrl: process.env.NEXT_PUBLIC_MEDUSA_BACKEND_URL,
74
- publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PUBLISHABLE_KEY,
73
+ ...edgeStoreEnv(),
75
74
  analyticsEndpoint: process.env.NEXT_PUBLIC_ANALYTICS_ENDPOINT,
76
75
  analyticsIngestUrl: process.env.NEXT_PUBLIC_ANALYTICS_INGEST_URL,
77
76
  analyticsKey: process.env.NEXT_PUBLIC_ANALYTICS_KEY,
@@ -79,8 +78,11 @@ export function hostedCheckoutEnv() {
79
78
  preview: process.env.VERCEL_ENV !== undefined && process.env.VERCEL_ENV !== 'production',
80
79
  };
81
80
  }
82
- /** The rewrite to the hosted checkout, or null to let the store serve /checkout itself. */
83
- export async function hostedCheckout(req, env = hostedCheckoutEnv(), now = Date.now()) {
81
+ /**
82
+ * The rewrite to the hosted checkout, or null to let the store serve /checkout itself. `requestHeaders` are the
83
+ * headers forwarded to the checkout app (the proxy's, with the client's `x-amb-market` already replaced).
84
+ */
85
+ export async function hostedCheckout(req, env = hostedCheckoutEnv(), now = Date.now(), requestHeaders = req.headers) {
84
86
  const { pathname: requested, search } = req.nextUrl;
85
87
  const pathname = requested === STORE_PAYMENT_RELAY_PATH ? HOSTED_PAYMENT_RELAY_PATH : requested;
86
88
  if (!isCheckoutPath(pathname))
@@ -112,7 +114,7 @@ export async function hostedCheckout(req, env = hostedCheckoutEnv(), now = Date.
112
114
  ...(env.analyticsKey ? { ak: env.analyticsKey } : {}),
113
115
  ...(env.googleMapsApiKey ? { g: env.googleMapsApiKey } : {}),
114
116
  };
115
- const headers = new Headers(req.headers);
117
+ const headers = new Headers(requestHeaders);
116
118
  headers.set(STORE_TOKEN_HEADER, await signStoreToken(checkoutKey, payload));
117
119
  const target = new URL(`${pathname}${search}`, checkoutUrl);
118
120
  const res = NextResponse.rewrite(target, { request: { headers } });
@@ -1 +1 @@
1
- {"version":3,"file":"hosted-checkout.js","sourceRoot":"","sources":["../../src/edge/hosted-checkout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAoB,MAAM,aAAa,CAAA;AAE5D;;;;;;;;;GASG;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,iBAAiB,CAAA;AAoBnD,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAA;AAE7B,SAAS,MAAM,CAAC,KAAiB;IAC/B,IAAI,CAAC,GAAG,EAAE,CAAA;IACV,KAAK,MAAM,CA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AAC,CAAA;IAC3D,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,EAAE,CAAC,CAAA;IAClE,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACxB,OAAO,GAAG,CAAA;AACZ,CAAC;AAED,MAAM,eAAe,GAAG,IAAI,OAAO,EAAY,CAAA;AAE/C,uGAAuG;AACvG,MAAM,UAAU,wBAAwB,CAAC,GAAa;IACpD,OAAO,eAAe,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACjC,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,yBAAyB;IACvC,WAAW,GAAG,IAAI,CAAA;AACpB,CAAC"}
@@ -0,0 +1,45 @@
1
+ import type { UrlMapCopy } from './url-map.js';
2
+ /**
3
+ * Which market a request URL names (AMB-2174). Pure: no I/O, the same answer for a crawler and a human.
4
+ *
5
+ * First match wins:
6
+ * 1. the host is a subdomain or domain presence: active → that market; inactive → its `inactiveRedirect` to the
7
+ * primary, else the root; pending → the root (`domain_pending`);
8
+ * 2. on the primary host, the first path segment is a subfolder presence's `path`: active → that market (a
9
+ * `/checkout*` inner path → 302 to the root checkout); inactive → its `inactiveRedirect` to the root, else the root;
10
+ * 2a. a previous path (`previousPaths`) → 301 to the current URL; 2b. a former default language's path
11
+ * (`languagePaths`) → 301 to the current URL; either only while that URL is announced (active and turned on),
12
+ * else a 302 to the root (`unserved`: a pending host, an inactive market or a passive URL is no place to move
13
+ * an indexed link to for good);
14
+ * 3. anything else → the root, today's behaviour.
15
+ *
16
+ * An inactive presence redirects as Medusa says (`inactiveRedirect`: `temporary` 302, null none; it can always come
17
+ * back), a moved URL 301s; the proxy sends
18
+ * every one with `no-store`, so a browser never replays an old one after a suffix is reverted. Redirect targets are
19
+ * built on a map origin (a presence host or the primary), never resolved against the request, so none can become an
20
+ * open redirect.
21
+ */
22
+ export interface MarketResolution {
23
+ source: 'host' | 'subfolder' | 'root';
24
+ /** null on the root. */
25
+ marketId: string | null;
26
+ /** '/en-ca' on a subfolder, '' otherwise. */
27
+ publicPrefix: string;
28
+ /** The `[m]` segment: '_' root, 'en-ca' subfolder, '_<marketId>' subdomain or domain. */
29
+ internalKey: string;
30
+ /** The path without publicPrefix. */
31
+ innerPath: string;
32
+ redirect?: {
33
+ location: URL;
34
+ status: 301 | 302;
35
+ kind: 'previous_path' | 'language' | 'unserved' | 'inactive' | 'root_checkout';
36
+ };
37
+ fallback?: 'map_stale' | 'map_unavailable' | 'domain_pending';
38
+ }
39
+ /** The root: today's behaviour, no market. */
40
+ export declare function rootResolution(url: URL): MarketResolution;
41
+ /** `options.subfolders: false` resolves hosts only (the `proxy` export, for a store tree without `app/[m]/`). */
42
+ export declare function resolveMarket(url: URL, host: string, map: UrlMapCopy | null, primaryHost: string | null, { subfolders: withSubfolders }?: {
43
+ subfolders?: boolean;
44
+ }): MarketResolution;
45
+ //# sourceMappingURL=market.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"market.d.ts","sourceRoot":"","sources":["../../src/edge/market.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAE9C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAAA;IACrC,wBAAwB;IACxB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,6CAA6C;IAC7C,YAAY,EAAE,MAAM,CAAA;IACpB,yFAAyF;IACzF,WAAW,EAAE,MAAM,CAAA;IACnB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE;QAAE,QAAQ,EAAE,GAAG,CAAC;QAAC,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC;QAAC,IAAI,EAAE,eAAe,GAAG,UAAU,GAAG,UAAU,GAAG,UAAU,GAAG,eAAe,CAAA;KAAE,CAAA;IAC/H,QAAQ,CAAC,EAAE,WAAW,GAAG,iBAAiB,GAAG,gBAAgB,CAAA;CAC9D;AAgBD,8CAA8C;AAC9C,wBAAgB,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,gBAAgB,CAEzD;AAED,iHAAiH;AACjH,wBAAgB,aAAa,CAC3B,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,UAAU,GAAG,IAAI,EACtB,WAAW,EAAE,MAAM,GAAG,IAAI,EAC1B,EAAE,UAAU,EAAE,cAAqB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,GACnE,gBAAgB,CAkDlB"}