@misiki/gocommerce-connector 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/services/base.ts","../src/services/static-store.ts","../src/services/money.ts","../src/services/mappers.ts","../src/services/checkout-details.ts","../src/services/address-book.ts","../src/services/catalog.ts","../src/services/cart.ts","../src/services/checkout.ts","../src/services/orders.ts","../src/services/store.ts","../src/services/unsupported.ts"],"names":["storage","products","meta","res","CART_ID_KEY","readStoredCartId","window"],"mappings":";AAgBO,IAAM,gBAAA,GAAmB;AAYzB,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EAC1C,IAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EAEA,YAAY,OAAA,EAAiB,IAAA,GAAO,gBAAA,EAAkB,MAAA,GAAS,GAAG,OAAA,EAAmB;AACpF,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EAChB;AACD;AAEO,IAAM,WAAA,GAAN,MAAM,YAAA,CAAY;AAAA,EAChB,MAAA;AAAA,EACR,OAAe,eAA4B,EAAC;AAAA,EAC5C,OAAe,aAAA;AAAA,EAEf,YAAY,OAAA,EAAwB;AAEnC,IAAA,IAAA,CAAK,SAAS,OAAA,KAAY,CAAA,GAAI,SAAmC,UAAA,CAAW,KAAA,CAAM,GAAG,IAAI,CAAA,CAAA;AAAA,EAC1F;AAAA,EAEA,SAAS,OAAA,EAA6B;AACrC,IAAA,IAAA,CAAK,MAAA,GAAS,OAAA;AACd,IAAA,OAAO,IAAA;AAAA,EACR;AAAA,EAEA,QAAA,GAAyB;AACxB,IAA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AAY;AAAA,EAC1D,OAAO,WAAA,GAAc,SAAA,CAAU,0BAAyB,CAAA;AAAA,EAExD,MAAM,wBAAwB,KAAA,EAAgB;AAC7C,IAAA,OAAO,EAAE,IAAA,EAAM,EAAC,EAAG,KAAA,EAAO,CAAA,EAAG,QAAA,EAAU,SAAA,EAAW,QAAA,EAAU,CAAA,EAAG,IAAA,EAAM,CAAA,EAAE;AAAA,EACxE;AAAA,EAEA,MAAM,sBAAsB,UAAA,EAAoC;AAC/D,IAAA,MAAM,YAAY,qBAAqB,CAAA;AAAA,EACxC;AAAA,EAEA,MAAM,4BAAA,CAA6B,OAAA,EAAiB,OAAA,EAAiB,QAAA,EAAkC;AACtG,IAAA,MAAM,YAAY,qBAAqB,CAAA;AAAA,EACxC;AACD;AAEO,IAAM,yBAAA,GAA4B,0BAA0B,WAAA","file":"index.js","sourcesContent":["// The transport every GoCommerce service shares.\n//\n// Two request paths live here and the difference matters. `api()` builds an ABSOLUTE url against\n// PUBLIC_GOCOMMERCE_API_URL and is what the services actually call. `get/post/put/patch/delete`\n// keep the raw-url signature the storefront's Litekart-era call sites use\n// (`storeService.get('/api/stores/public-details')`) and are left relative on purpose: rest-guard.ts\n// wraps exactly those and answers them from local data. GoCommerce's own paths also start with\n// `/api/`, so routing service calls through `api()` is what keeps the guard from swallowing them.\n\nimport type { ListMeta } from './types'\n\n/**\n * The storefront route that forwards to the GoCommerce server, and the only path the browser is\n * ever pointed at. It must not start with `/api/`: rest-guard.ts intercepts that prefix as a\n * Litekart REST path and would answer these calls itself.\n */\nexport const API_PROXY_PREFIX = '/proxy/gocommerce'\n\nexport type Credentials = {\n\t/** Base url of the GoCommerce server, e.g. `http://127.0.0.1:8080`. */\n\tapiUrl?: string\n\t[key: string]: string | undefined\n}\n\n/** `{ data, meta }` — the envelope every GoCommerce endpoint answers with. */\nexport type Envelope<T> = { data: T; meta?: ListMeta }\n\n/** What the storefront shows when a request fails: GoCommerce's own message, not a status code. */\nexport class GoCommerceError extends Error {\n\tcode: string\n\tdetails: unknown\n\tstatus: number\n\n\tconstructor(message: string, code = 'internal_error', status = 0, details?: unknown) {\n\t\tsuper(message)\n\t\tthis.name = 'GoCommerceError'\n\t\tthis.code = code\n\t\tthis.status = status\n\t\tthis.details = details\n\t}\n}\n\nexport class BaseService {\n\tprivate _fetch: typeof fetch\n\tprivate static _credentials: Credentials = {}\n\tprivate static _languageCode?: string\n\n\tconstructor(fetchFn?: typeof fetch) {\n\t\t// Bound to globalThis: an unbound `fetch` throws \"Illegal invocation\" in the browser.\n\t\tthis._fetch = fetchFn || ((...args: Parameters<typeof fetch>) => globalThis.fetch(...args))\n\t}\n\n\tsetFetch(fetchFn: typeof fetch): this {\n\t\tthis._fetch = fetchFn\n\t\treturn this\n\t}\n\n\tgetFetch(): typeof fetch {\n\t\treturn this._fetch\n\t}\n\n\t/**\n\t * The fetch a GoCommerce call actually goes out on.\n\t *\n\t * In the browser it is whatever was handed in, against this storefront's own origin. On the\n\t * server it is deliberately the platform's, not SvelteKit's: a universal `+page.ts` load is\n\t * given a `fetch` that simulates a browser's CORS check, and GoCommerce sends no\n\t * `Access-Control-Allow-Origin`, so the same product page that renders from a `+page.server.ts`\n\t * would throw from a `+page.ts`. Nothing is lost by stepping around it — SvelteKit's fetch adds\n\t * cookie forwarding and internal routing, and both are about this storefront's own origin, not\n\t * a separate API host.\n\t */\n\tprivate transport(): typeof fetch {\n\t\treturn BaseService.isBrowser() ? this._fetch : (...args: Parameters<typeof fetch>) => globalThis.fetch(...args)\n\t}\n\n\t/**\n\t * The hook the storefront's `src/lib/core/connectors/init.ts` calls with `PUBLIC_GOCOMMERCE_*`. Merges, so a\n\t * later call with a subset never erases the base url an earlier one established.\n\t */\n\tstatic setCredentials(creds: Credentials) {\n\t\tBaseService._credentials = { ...BaseService._credentials, ...creds }\n\t}\n\n\tstatic getCredentials(): Credentials {\n\t\treturn BaseService._credentials\n\t}\n\n\tstatic setBaseUrl(url?: string) {\n\t\tif (url) BaseService._credentials.apiUrl = url\n\t}\n\n\t/** Trailing slashes stripped so `${base}/api/products` never doubles up. */\n\tstatic getBaseUrl(): string {\n\t\treturn (BaseService._credentials.apiUrl || '').replace(/\\/+$/, '')\n\t}\n\n\tstatic setLanguageCode(code?: string) {\n\t\tBaseService._languageCode = code\n\t}\n\n\tstatic getLanguageCode(): string | undefined {\n\t\treturn BaseService._languageCode\n\t}\n\n\tsetBaseUrl(url?: string): this {\n\t\tBaseService.setBaseUrl(url)\n\t\treturn this\n\t}\n\n\tgetBaseUrl(): string {\n\t\treturn BaseService.getBaseUrl()\n\t}\n\n\t/**\n\t * Where a request for `path` actually goes.\n\t *\n\t * GoCommerce sends no CORS headers and answers a preflight with 405, so a browser cannot reach\n\t * it cross-origin at all — and neither can a universal `+page.ts` load, because SvelteKit\n\t * simulates the same CORS check server-side for consistency. So anything the browser issues goes\n\t * through this storefront's own origin (`src/routes/proxy/gocommerce/[...path]`), which is\n\t * same-origin and needs no headers from the API.\n\t *\n\t * On the server there is no such rule, and the extra hop through the storefront's own handler\n\t * would be a request the process makes to itself, so it calls the API directly.\n\t */\n\tstatic apiUrl(path: string): string {\n\t\tif (/^https?:\\/\\//i.test(path)) return path\n\t\tconst suffix = path.startsWith('/') ? path : `/${path}`\n\t\tif (BaseService.isBrowser()) return `${API_PROXY_PREFIX}${suffix}`\n\t\tconst base = BaseService.getBaseUrl()\n\t\tif (!base) {\n\t\t\tthrow new GoCommerceError('PUBLIC_GOCOMMERCE_API_URL is not configured — add it to .env (see docs/GOCOMMERCE.md).', 'not_ready')\n\t\t}\n\t\treturn `${base}${suffix}`\n\t}\n\n\t/**\n\t * Where an `<img>` points.\n\t *\n\t * Media urls come back site-relative for files this store holds (`/media/42.jpg`). Unlike an API\n\t * call, the consumer is always the browser — a server-rendered `<img src>` is still fetched by\n\t * it — so this always resolves through the proxy, and the picture loads wherever the API happens\n\t * to be reachable from. A url that is already absolute belongs to someone else's host and is\n\t * left exactly as it is.\n\t */\n\tstatic mediaUrl(path: string): string {\n\t\tif (/^https?:\\/\\//i.test(path)) return path\n\t\treturn `${API_PROXY_PREFIX}${path.startsWith('/') ? path : `/${path}`}`\n\t}\n\n\tstatic isBrowser(): boolean {\n\t\treturn typeof window !== 'undefined' && typeof window.document !== 'undefined'\n\t}\n\n\t/**\n\t * One request against the GoCommerce API.\n\t *\n\t * Unwraps `{ data, meta }` and turns `{ error: { code, message } }` into a thrown\n\t * GoCommerceError carrying the server's own wording — a 409 at checkout says which line went\n\t * stale, and that sentence is what the shopper needs to see.\n\t */\n\tprotected async api<T>(\n\t\tmethod: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE',\n\t\tpath: string,\n\t\tbody?: unknown,\n\t\theaders: Record<string, string> = {}\n\t): Promise<Envelope<T>> {\n\t\tconst url = BaseService.apiUrl(path)\n\t\tconst lang = BaseService.getLanguageCode()\n\n\t\tlet res: Response\n\t\ttry {\n\t\t\tres = await this.transport()(url, {\n\t\t\t\tmethod,\n\t\t\t\theaders: {\n\t\t\t\t\tAccept: 'application/json',\n\t\t\t\t\t...(body === undefined ? {} : { 'Content-Type': 'application/json' }),\n\t\t\t\t\t...(lang ? { 'Accept-Language': lang } : {}),\n\t\t\t\t\t...headers\n\t\t\t\t},\n\t\t\t\t...(body === undefined ? {} : { body: JSON.stringify(body) })\n\t\t\t})\n\t\t} catch (cause) {\n\t\t\t// The server-side path talks to the API directly, so a stopped backend surfaces here as\n\t\t\t// Node's bare \"fetch failed\" with nothing naming what it tried to reach. Say it, the way\n\t\t\t// the proxy does for the browser's half.\n\t\t\tconst reason = (cause as { cause?: { code?: string } })?.cause?.code ?? (cause as Error)?.message ?? 'unknown error'\n\t\t\tthrow new GoCommerceError(\n\t\t\t\t`Could not reach the GoCommerce server at ${BaseService.getBaseUrl() || url} — ${reason}. Is it running?`,\n\t\t\t\t'not_ready',\n\t\t\t\t0,\n\t\t\t\tcause\n\t\t\t)\n\t\t}\n\n\t\t// 204 and friends carry no envelope; a DELETE that removed the last line is one.\n\t\tconst text = await res.text()\n\t\tlet parsed: unknown = undefined\n\t\tif (text) {\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(text)\n\t\t\t} catch {\n\t\t\t\tthrow new GoCommerceError(`GoCommerce returned a non-JSON response for ${method} ${path} (${res.status}).`, 'internal_error', res.status)\n\t\t\t}\n\t\t}\n\n\t\tconst envelope = (parsed ?? {}) as {\n\t\t\tdata?: T\n\t\t\tmeta?: ListMeta\n\t\t\terror?: { code?: string; message?: string; details?: unknown }\n\t\t\t/** Not GoCommerce's shape — what something between here and it answered with. */\n\t\t\tmessage?: string\n\t\t}\n\n\t\tif (!res.ok || envelope.error) {\n\t\t\tconst error = envelope.error\n\t\t\t// A failure need not come from GoCommerce: the proxy in front of it answers with\n\t\t\t// SvelteKit's `{ message }` when the server cannot be reached at all. Preferring the\n\t\t\t// generic sentence over that message is how a stopped backend reads as an unexplained\n\t\t\t// 502 rather than \"could not reach the GoCommerce server at …\".\n\t\t\tthrow new GoCommerceError(\n\t\t\t\terror?.message || envelope.message || `GoCommerce request failed: ${method} ${path} (${res.status}).`,\n\t\t\t\terror?.code || 'internal_error',\n\t\t\t\tres.status,\n\t\t\t\terror?.details\n\t\t\t)\n\t\t}\n\n\t\treturn { data: envelope.data as T, meta: envelope.meta }\n\t}\n\n\t/**\n\t * Litekart-era raw-url reads. Deliberately not routed to GoCommerce: a bare `/api/...` here means\n\t * a path from the storefront's own REST API, which rest-guard.ts answers from local data or\n\t * reports. Absolute urls pass straight through.\n\t */\n\tasync get<T>(url: string): Promise<T> {\n\t\tconst res = await this._fetch(url, { headers: { Accept: 'application/json' } })\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync post<T>(url: string, data: unknown): Promise<T> {\n\t\tconst res = await this._fetch(url, {\n\t\t\tmethod: 'POST',\n\t\t\theaders: { 'Content-Type': 'application/json', Accept: 'application/json' },\n\t\t\tbody: JSON.stringify(data)\n\t\t})\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync put<T>(url: string, data: unknown): Promise<T> {\n\t\tconst res = await this._fetch(url, {\n\t\t\tmethod: 'PUT',\n\t\t\theaders: { 'Content-Type': 'application/json', Accept: 'application/json' },\n\t\t\tbody: JSON.stringify(data)\n\t\t})\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync patch<T>(url: string, data: unknown): Promise<T> {\n\t\tconst res = await this._fetch(url, {\n\t\t\tmethod: 'PATCH',\n\t\t\theaders: { 'Content-Type': 'application/json', Accept: 'application/json' },\n\t\t\tbody: JSON.stringify(data)\n\t\t})\n\t\treturn (await res.json()) as T\n\t}\n\n\tasync delete<T>(url: string): Promise<T> {\n\t\tconst res = await this._fetch(url, { method: 'DELETE', headers: { Accept: 'application/json' } })\n\t\treturn (await res.json()) as T\n\t}\n}\n","// Store identity — name, logo, favicon, currency, menus, plugin toggles, theme variables — has no\n// GoCommerce equivalent: the API is a commerce engine, not a CMS. The storefront registers its own\n// provider at module load (the storefront's connectors/gocommerce.ts module) and every service that needs the store record\n// reads it from here.\n\nexport type StaticStoreProvider = () => Promise<Record<string, unknown>> | Record<string, unknown>\n\nlet provider: StaticStoreProvider | undefined\n\nexport const setStaticStore = (fn: StaticStoreProvider) => {\n\tprovider = fn\n}\n\nexport const hasStaticStore = () => Boolean(provider)\n\n/**\n * Features this backend cannot perform, whatever the store record says.\n *\n * The storefront shows or hides a feature from `plugins.*.active` — it is how the search icon and\n * the wishlist button already hide themselves. GoCommerce has no accounts, no discount engine, no\n * wishlist, no reviews and one vendor, so offering any of them produces a control whose only\n * possible answer is \"not available on this store\": the shopper types a promo code, or opens a\n * sign-in, and is refused. Not offering it is the better answer.\n *\n * `accounts` is the storefront's own toggle, read by src/lib/components/auth/auth-button.svelte — every\n * login, signup and password-reset entry point renders through that component.\n */\nconst IMPOSSIBLE_FEATURES = {\n\taccounts: { active: false },\n\tisDiscountCoupons: { active: false },\n\tisWishlist: { active: false },\n\tisProductReviewsAndRatings: { active: false },\n\tisMultiVendor: { active: false }\n} as const\n\n/**\n * Applied on read rather than by wrapping the registered provider, because the provider is not ours\n * to keep: the storefront's `src/lib/core/connectors/init.ts` calls `setStaticStore(staticStoreConfig)` for whatever\n * connector is active, at boot, which lands after this module has loaded and replaces anything\n * registered here. Forcing at the point of use is immune to who registered last.\n */\nexport const readStaticStore = async (): Promise<Record<string, any> | undefined> => {\n\tif (!provider) return undefined\n\tconst store = (await provider()) as Record<string, any>\n\tif (!store) return store\n\treturn {\n\t\t...store,\n\t\tplugins: { ...(store.plugins ?? {}), ...IMPOSSIBLE_FEATURES }\n\t}\n}\n\nexport const readStaticStoreDetails = readStaticStore\n","// GoCommerce sends money as an integer count of the currency's minor unit plus its code, because\r\n// binary floating point cannot represent 0.10 and the number of decimals belongs to the currency\r\n// (USD has 2, JPY has 0, KWD has 3). The storefront's components take a plain number in major\r\n// units, so the conversion happens once, here, against the currency the amount arrived with.\r\n\r\nimport type { Money } from './types'\r\n\r\nconst DEFAULT_FRACTION_DIGITS = 2\r\nconst fractionDigitsCache = new Map<string, number>()\r\n\r\nexport const currencyFractionDigits = (currencyCode?: string): number => {\r\n\tif (!currencyCode) return DEFAULT_FRACTION_DIGITS\r\n\tconst code = currencyCode.toUpperCase()\r\n\tconst cached = fractionDigitsCache.get(code)\r\n\tif (cached !== undefined) return cached\r\n\r\n\tlet digits = DEFAULT_FRACTION_DIGITS\r\n\ttry {\r\n\t\tconst resolved = new Intl.NumberFormat('en', { style: 'currency', currency: code }).resolvedOptions().maximumFractionDigits\r\n\t\tif (typeof resolved === 'number') digits = resolved\r\n\t} catch {\r\n\t\t// An unknown code keeps the two-decimal default rather than failing the render.\r\n\t}\r\n\tfractionDigitsCache.set(code, digits)\r\n\treturn digits\r\n}\r\n\r\n/** `{ amount_minor: 2500, currency: 'USD' }` -> `25`. */\r\nexport const fromMoney = (money?: Money | null): number => {\r\n\tif (!money || typeof money.amount_minor !== 'number' || !Number.isFinite(money.amount_minor)) return 0\r\n\tconst digits = currencyFractionDigits(money.currency)\r\n\treturn digits === 0 ? money.amount_minor : money.amount_minor / 10 ** digits\r\n}\r\n","// GoCommerce's wire shapes translated into the ones this storefront's components read. The target\n// shape is Litekart's — every @misiki/*-connector maps onto it, which is what lets the same\n// components render on any backend. Fields GoCommerce has no notion of are filled with the neutral\n// value the component expects rather than left undefined, because `undefined` is what makes a card\n// render a blank price or a broken image.\n\nimport { BaseService } from './base'\nimport { currencyFractionDigits, fromMoney } from './money'\nimport type { GcAddress, GcCart, GcCartLine, GcCategory, GcCollection, GcOrder, GcProduct, GcVariant, ListMeta } from './types'\n\n/** The page size this storefront's grids and lists are built around. */\nexport const PAGE_SIZE = 20\n\n/** The API's maximum `limit`. Also the ceiling on what one request can be filtered or sorted over. */\nexport const MAX_LIMIT = 200\n\n/** A variant that does not track inventory is always buyable; the number just has to be positive. */\nconst UNTRACKED_STOCK = 999\n\nexport type Paginated<T> = {\n\tdata: T[]\n\tcount: number\n\tpageSize: number\n\tnoOfPage: number\n\tpage: number\n}\n\nexport const paginated = <T>(data: T[], count: number, page = 1, pageSize = PAGE_SIZE): Paginated<T> => ({\n\tdata,\n\tcount,\n\tpageSize,\n\tnoOfPage: Math.ceil(count / pageSize) || (count ? 1 : 0),\n\tpage\n})\n\nexport const emptyPage = <T>(page = 1, pageSize = PAGE_SIZE): Paginated<T> => ({\n\tdata: [],\n\tcount: 0,\n\tpageSize,\n\tnoOfPage: 0,\n\tpage\n})\n\n/** Meta the API returns for a window, translated into the page numbers the storefront prints. */\nexport const fromListMeta = <T>(data: T[], meta?: ListMeta, fallbackPage = 1): Paginated<T> => {\n\tconst count = meta?.total ?? data.length\n\tconst pageSize = meta?.limit || data.length || PAGE_SIZE\n\treturn {\n\t\tdata,\n\t\tcount,\n\t\tpageSize,\n\t\tnoOfPage: meta?.total_pages ?? (Math.ceil(count / pageSize) || (count ? 1 : 0)),\n\t\tpage: meta?.page ?? fallbackPage\n\t}\n}\n\n/** Media urls arrive site-relative for files the store holds; see `BaseService.mediaUrl`. */\nexport const absoluteMedia = (url?: string | null): string | null => (url ? BaseService.mediaUrl(url) : null)\n\nconst activeVariants = (product?: GcProduct | null): GcVariant[] => (product?.variants || []).filter((v) => v?.active !== false)\n\n/** The variant a card prices and a PDP opens on: the first active one, in the operator's order. */\nconst primaryVariant = (product?: GcProduct | null): GcVariant | undefined => activeVariants(product)[0] || (product?.variants || [])[0]\n\nconst variantStock = (variant?: GcVariant | null): number => {\n\tif (!variant) return 0\n\tif (variant.track_inventory === false) return UNTRACKED_STOCK\n\tconst available = Math.max(0, variant.available ?? 0)\n\t// `continue_selling` takes the order after the count runs out, so the item is still buyable.\n\treturn available === 0 && variant.continue_selling ? UNTRACKED_STOCK : available\n}\n\n/**\n * Every image the storefront can show for a product.\n *\n * Two sources, in the order a gallery should show them: the product's own `image_url` first, then\n * whatever image each variant nominates — what a storefront swaps to when a shopper picks a colour.\n * De-duplicated, because a variant may nominate the picture the product already leads with.\n *\n * Both are read defensively. `image_url` is undocumented in `/doc` yet is the only image this\n * catalogue actually has, while `Variant.image` is the documented field and is empty here; a server\n * on either side of that change has to render. A product with neither has no image, and the\n * components fall back to their own placeholder.\n */\nexport const productImages = (product?: GcProduct | null): string[] => {\n\tconst seen = new Set<string>()\n\tconst featured = absoluteMedia(product?.image_url)\n\tif (featured) seen.add(featured)\n\tfor (const variant of product?.variants || []) {\n\t\tconst url = absoluteMedia(variant?.image?.url)\n\t\tif (url) seen.add(url)\n\t}\n\treturn [...seen]\n}\n\n/**\n * Product metadata, flattened for display.\n *\n * GoCommerce namespaces it by whichever module wrote it — `{ category: { material: ['Cork'] } }` —\n * while the storefront's spec block prints each entry's value straight into the page, so a nested\n * object arrives as the literal text \"[object Object]\". Only the leaves say anything to a shopper,\n * so those are lifted out under their own names, and a name claimed twice keeps its namespace to\n * stay distinguishable.\n */\nexport const flattenMetadata = (metadata?: Record<string, unknown> | null): Record<string, string> | null => {\n\tif (!metadata || typeof metadata !== 'object') return null\n\tconst out: Record<string, string> = {}\n\n\tconst printable = (value: unknown): string | undefined => {\n\t\tif (value === null || value === undefined || value === '') return undefined\n\t\tif (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value)\n\t\tif (Array.isArray(value)) {\n\t\t\tconst items = value.map(printable).filter(Boolean)\n\t\t\treturn items.length ? items.join(', ') : undefined\n\t\t}\n\t\treturn undefined\n\t}\n\n\tconst walk = (node: Record<string, unknown>, namespace = '') => {\n\t\tfor (const [key, value] of Object.entries(node)) {\n\t\t\tconst text = printable(value)\n\t\t\tif (text !== undefined) {\n\t\t\t\tout[key in out && namespace ? `${namespace} ${key}` : key] = text\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif (value && typeof value === 'object' && !Array.isArray(value)) walk(value as Record<string, unknown>, key)\n\t\t}\n\t}\n\n\twalk(metadata)\n\treturn Object.keys(out).length ? out : null\n}\n\nconst optionValueId = (product: GcProduct | undefined, optionIndex: number, value: string) =>\n\tproduct?.options?.[optionIndex]?.values?.find((v) => v.value === value)?.id ?? `${optionIndex}-${value}`\n\nconst mapVariant = (product: GcProduct, variant: GcVariant) => {\n\tconst price = fromMoney(variant.price)\n\tconst compareAt = fromMoney(variant.compare_at_price)\n\t// A variant that nominates no image of its own is shown under the product's picture rather than\n\t// none — which is every variant on a catalogue that only sets `image_url`.\n\tconst image = absoluteMedia(variant.image?.url) || absoluteMedia(product.image_url)\n\treturn {\n\t\tid: variant.id,\n\t\t// The PDP prints this as the heading whenever it is not 'default'. GoCommerce labels a variant\n\t\t// by its options (\"M / Black\") and leaves that empty for a product that has none — where the\n\t\t// product's own title is the right heading, and the SKU would be a code shown to a shopper.\n\t\ttitle: variant.label || (variant.options || []).join(' / ') || product.title || 'default',\n\t\tproductId: product.id,\n\t\tsku: variant.sku || null,\n\t\tbarcode: variant.barcode || null,\n\t\tbatchNo: null,\n\t\tstock: variantStock(variant),\n\t\tallowBackorder: Boolean(variant.continue_selling),\n\t\tmanageInventory: variant.track_inventory !== false,\n\t\thsCode: variant.hs_code || null,\n\t\toriginCountry: variant.origin_country || null,\n\t\tmidCode: null,\n\t\tmaterial: null,\n\t\tweight: variant.weight ?? null,\n\t\tlength: null,\n\t\theight: null,\n\t\twidth: null,\n\t\tprice,\n\t\tcostPerItem: 0,\n\t\tmfgDate: null,\n\t\texpiryDate: null,\n\t\treturnAllowed: false,\n\t\treplaceAllowed: false,\n\t\t// No compare-at price recorded means nothing is on sale; mrp equals price so the components\n\t\t// print one number instead of a struck-through duplicate.\n\t\tmrp: compareAt > price ? compareAt : price,\n\t\timg: image,\n\t\tdescription: null,\n\t\tstoreId: null,\n\t\tlen: null,\n\t\trank: variant.position ?? 0,\n\t\tshippingWeight: null,\n\t\tshippingHeight: null,\n\t\tshippingLen: null,\n\t\tshippingWidth: null,\n\t\tshippingCost: null,\n\t\tmetadata: variant.metadata ?? null,\n\t\tvariantRank: variant.position ?? 0,\n\t\t// A variant's `options` are the VALUES, positionally aligned with the product's option list.\n\t\toptions: (variant.options || []).map((value, index) => ({\n\t\t\tid: optionValueId(product, index, value),\n\t\t\toptionId: product.options?.[index]?.id ?? index,\n\t\t\tvalue,\n\t\t\tvariantId: variant.id\n\t\t}))\n\t}\n}\n\nexport const mapProduct = (product?: GcProduct | null) => {\n\tif (!product) return null\n\n\tconst variants = activeVariants(product)\n\tconst priced = variants.length ? variants : product.variants || []\n\tconst prices = priced.map((v) => fromMoney(v.price)).filter((n) => Number.isFinite(n))\n\tconst price = prices.length ? Math.min(...prices) : 0\n\tconst compareAtPrices = priced.map((v) => fromMoney(v.compare_at_price)).filter((n) => n > 0)\n\tconst mrp = compareAtPrices.length ? Math.max(...compareAtPrices) : price\n\n\tconst images = productImages(product)\n\tconst featured = images[0] || null\n\tconst first = primaryVariant(product)\n\n\treturn {\n\t\tid: product.id,\n\t\ttitle: product.title,\n\t\tslug: product.slug,\n\t\tdescription: product.description || '',\n\t\tprice,\n\t\tmrp,\n\t\tfeaturedImage: featured,\n\t\tactive: product.status === 'active',\n\t\tstatus: product.status === 'active' ? 'published' : product.status || 'draft',\n\t\ttype: 'physical',\n\t\tvendorId: product.vendor || '',\n\t\tcategoryId: product.category?.id ?? null,\n\t\tcurrency: product.currency || null,\n\t\tinstructions: null,\n\t\thsnCode: first?.hs_code || null,\n\t\t// The components read this as a comma-joined list, the way Litekart serves it.\n\t\timages: images.join(','),\n\t\tthumbnail: featured,\n\t\tkeywords: (product.tags || []).join(',') || null,\n\t\tlink: null,\n\t\tmetaTitle: product.seo_title || null,\n\t\tmetaDescription: product.seo_description || null,\n\t\tsubtitle: product.product_type || null,\n\t\tpopularity: 0,\n\t\trank: 0,\n\t\texpiryDate: null,\n\t\tweight: first?.weight ?? null,\n\t\tmfgDate: null,\n\t\tcostPerItem: 0,\n\t\tsku: first?.sku || null,\n\t\tstock: priced.reduce((sum, v) => sum + variantStock(v), 0),\n\t\tallowBackorder: Boolean(first?.continue_selling),\n\t\tmanageInventory: first?.track_inventory !== false,\n\t\tshippingWeight: null,\n\t\tshippingHeight: null,\n\t\tshippingLen: null,\n\t\tshippingWidth: null,\n\t\theight: null,\n\t\twidth: null,\n\t\tlen: null,\n\t\tbarcode: first?.barcode || null,\n\t\tshippingCost: null,\n\t\treturnAllowed: false,\n\t\treplaceAllowed: false,\n\t\toriginCountry: first?.origin_country || null,\n\t\tweightUnit: first?.weight_unit || 'g',\n\t\tdimensionUnit: 'cm',\n\t\tmetadata: flattenMetadata(product.metadata),\n\t\tcollectionId: product.collections?.[0]?.id ?? null,\n\t\ttags: product.tags || [],\n\t\tvendor: product.vendor || null,\n\t\tcategories: product.category ? [{ category: { id: product.category.id, name: product.category.title, slug: product.category.slug } }] : [],\n\t\tcreatedAt: product.created_at || null,\n\t\tupdatedAt: product.updated_at || null,\n\t\toptions: (product.options || []).map((option) => ({\n\t\t\tid: option.id,\n\t\t\ttitle: option.name,\n\t\t\ttype: 'radio',\n\t\t\tvalues: (option.values || []).map((v) => ({ id: v.id, value: v.value }))\n\t\t})),\n\t\tvariants: priced.map((variant) => mapVariant(product, variant))\n\t}\n}\n\nexport const mapCategory = (category?: GcCategory | null) => {\n\tif (!category) return null\n\treturn {\n\t\tid: category.id,\n\t\tisActive: true,\n\t\tisInternal: false,\n\t\tisMegamenu: false,\n\t\tthumbnail: null,\n\t\tpath: category.full_name || null,\n\t\tlevel: category.depth ?? 0,\n\t\tdescription: null,\n\t\tisFeatured: false,\n\t\tkeywords: null,\n\t\trank: category.position ?? 0,\n\t\tlink: null,\n\t\tmetaDescription: null,\n\t\tmetaKeywords: null,\n\t\tmetaTitle: null,\n\t\tname: category.title,\n\t\t// The storefront's filter composable rebuilds the tree from this field.\n\t\tparentCategoryId: category.parent_id ?? null,\n\t\tstore: null,\n\t\tslug: category.slug,\n\t\tuserId: '',\n\t\tactiveProducts: 0,\n\t\tinactiveProducts: 0,\n\t\tcreatedAt: category.created_at || null,\n\t\tupdatedAt: category.updated_at || null\n\t}\n}\n\n/**\n * `collectionvalues[].products` is the shape the collection components read — Litekart's, where each\n * value points at one product.\n */\nexport const mapCollection = (collection?: (GcCollection & { products?: GcProduct[] }) | null) => {\n\tif (!collection) return null\n\tconst products = collection.products || []\n\treturn {\n\t\tid: collection.id,\n\t\tname: collection.title,\n\t\tslug: collection.slug,\n\t\tdescription: collection.description || null,\n\t\tisActive: true,\n\t\tisFeatured: false,\n\t\tuserId: '',\n\t\tthumbnail: productImages(products[0])[0] || null,\n\t\tmetaTitle: null,\n\t\tmetaDescription: null,\n\t\trank: collection.position ?? 0,\n\t\tcollectionvalues: products.map((product) => {\n\t\t\tconst mapped = mapProduct(product)\n\t\t\treturn {\n\t\t\t\tproducts: {\n\t\t\t\t\tid: product.id,\n\t\t\t\t\tname: product.title,\n\t\t\t\t\ttitle: product.title,\n\t\t\t\t\tslug: product.slug,\n\t\t\t\t\tthumbnail: mapped?.thumbnail || null,\n\t\t\t\t\tprice: mapped?.price ?? 0,\n\t\t\t\t\tmrp: mapped?.mrp ?? 0\n\t\t\t\t}\n\t\t\t}\n\t\t}),\n\t\tproductCount: products.length,\n\t\tcreatedAt: collection.created_at || null,\n\t\tupdatedAt: collection.updated_at || null\n\t}\n}\n\n/** Whatever the storefront collected at the address step; GoCommerce has no cart field to hold it. */\nexport type CheckoutDetails = {\n\temail?: string\n\tphone?: string\n\tname?: string\n\tshippingAddress?: Record<string, any> | null\n\tbillingAddress?: Record<string, any> | null\n}\n\n/** A product lookup used to fill in what a cart or order line does not carry: slug and image. */\nexport type ProductIndex = Map<number, GcProduct>\n\nconst lineProduct = (index: ProductIndex | undefined, productId?: number | null) => (productId == null ? undefined : index?.get(productId))\n\nconst mapCartLine = (line: GcCartLine, index?: ProductIndex) => {\n\tconst product = lineProduct(index, line.product_id)\n\tconst mapped = product ? mapProduct(product) : null\n\tconst variant = product?.variants?.find((v) => v.id === line.variant_id)\n\tconst price = fromMoney(line.unit_price)\n\tconst compareAt = fromMoney(variant?.compare_at_price)\n\tconst thumbnail = absoluteMedia(variant?.image?.url) || mapped?.thumbnail || null\n\n\treturn {\n\t\tid: line.id,\n\t\tproductId: line.product_id,\n\t\tvariantId: line.variant_id,\n\t\tqty: line.quantity,\n\t\tsubtotal: fromMoney(line.total),\n\t\tdiscount: 0,\n\t\ttax: 0,\n\t\tshippingCharges: 0,\n\t\ttotal: fromMoney(line.total),\n\t\tprice,\n\t\tmrp: compareAt > price ? compareAt : price,\n\t\ttitle: line.title || mapped?.title || '',\n\t\tslug: mapped?.slug || '',\n\t\tsku: line.sku || '',\n\t\tdescription: null,\n\t\tthumbnail,\n\t\tmetadata: null,\n\t\tvendorId: null,\n\t\tweight: null,\n\t\tdimensionUnit: 'cm',\n\t\theight: null,\n\t\twidth: null,\n\t\tlen: null,\n\t\tshippingWeight: null,\n\t\tshippingHeight: null,\n\t\tshippingLen: null,\n\t\tshippingWidth: null,\n\t\tisSelectedForCheckout: true,\n\t\t// Surfaced so the cart can warn, instead of letting checkout refuse the whole order later.\n\t\tpriceChanged: Boolean(line.price_changed),\n\t\tinStock: line.in_stock !== false,\n\t\tcreatedAt: null,\n\t\tproduct: {\n\t\t\tid: line.product_id,\n\t\t\ttitle: line.title || mapped?.title || '',\n\t\t\tthumbnail,\n\t\t\tslug: mapped?.slug || '',\n\t\t\tsku: line.sku || '',\n\t\t\tcategories: mapped?.categories || []\n\t\t},\n\t\tvariant: {\n\t\t\tid: line.variant_id,\n\t\t\tprice,\n\t\t\tmrp: compareAt > price ? compareAt : price,\n\t\t\tweight: null,\n\t\t\theight: null,\n\t\t\twidth: null,\n\t\t\tlen: null,\n\t\t\tshippingWeight: null,\n\t\t\tshippingHeight: null,\n\t\t\tshippingLen: null,\n\t\t\tshippingWidth: null,\n\t\t\tsku: line.sku || '',\n\t\t\ttitle: line.variant_label || variant?.label || 'default',\n\t\t\toptions: variant && product ? mapVariant(product, variant).options : []\n\t\t}\n\t}\n}\n\nexport const mapCart = (cart: GcCart | null | undefined, details: CheckoutDetails = {}, index?: ProductIndex, store?: Record<string, any>) => {\n\tif (!cart) return {}\n\tconst currency = cart.currency || store?.currency?.code || 'USD'\n\tconst lines = cart.line_items || []\n\tconst subtotal = fromMoney(cart.subtotal)\n\tconst shippingAddress = details.shippingAddress || null\n\tconst billingAddress = details.billingAddress || shippingAddress\n\n\treturn {\n\t\tid: cart.id,\n\t\temail: cart.email || details.email || null,\n\t\tphone: details.phone || shippingAddress?.phone || null,\n\t\tname: details.name || null,\n\t\t// The payment step gates on an id as well as the address itself. There is no address record\n\t\t// in GoCommerce to have an id of its own, so the cart it belongs to names it.\n\t\tbillingAddressId: billingAddress ? `${cart.id}-billing` : null,\n\t\tshippingAddressId: shippingAddress ? `${cart.id}-shipping` : null,\n\t\tregionId: null,\n\t\tuserId: null,\n\t\tcouponCode: null,\n\t\tdiscountAmount: 0,\n\t\tcouponAppliedDate: null,\n\t\tneedAddress: !shippingAddress,\n\t\tisCodAvailable: true,\n\t\tpaymentId: null,\n\t\ttype: null,\n\t\tcompletedAt: cart.status === 'converted' ? cart.updated_at || null : null,\n\t\tpaymentAuthorizedAt: null,\n\t\tidempotencyKey: null,\n\t\tsalesChannelId: null,\n\t\tqty: cart.item_count ?? lines.reduce((sum, l) => sum + (l.quantity || 0), 0),\n\t\t// GoCommerce prices shipping at checkout, not on the cart, so there is nothing honest to put\n\t\t// here yet — and a fabricated number is the one the shopper would check the total against.\n\t\tshippingCharges: 0,\n\t\tpaymentMethod: null,\n\t\tshippingMethod: null,\n\t\tsubtotal,\n\t\tcodCharges: 0,\n\t\ttax: 0,\n\t\ttotal: subtotal,\n\t\tsavingAmount: 0,\n\t\tuserAuthToken: null,\n\t\tcurrencyCode: currency,\n\t\tcurrencySymbol: store?.currency?.symbol || '',\n\t\tshippingRateId: null,\n\t\tcurrencyDecimalDigits: currencyFractionDigits(currency),\n\t\tstoreId: store?.id ?? null,\n\t\tstatus: cart.status || 'open',\n\t\tcreatedAt: cart.created_at || null,\n\t\tupdatedAt: cart.updated_at || null,\n\t\tdeletedAt: null,\n\t\tlineItems: lines.map((line) => mapCartLine(line, index)),\n\t\tshippingAddress,\n\t\tbillingAddress\n\t}\n}\n\nconst splitName = (name?: string) => {\n\tconst parts = (name || '').trim().split(/\\s+/).filter(Boolean)\n\treturn { firstName: parts[0] || '', lastName: parts.slice(1).join(' ') }\n}\n\n/** GoCommerce's address shape -> the one the address form and order pages read. */\nexport const toStorefrontAddress = (address?: GcAddress | null, email?: string, phone?: string) => {\n\tif (!address) return null\n\tconst { firstName, lastName } = splitName(address.name)\n\treturn {\n\t\tid: null,\n\t\tfirstName,\n\t\tlastName,\n\t\temail: email || null,\n\t\tphone: address.phone || phone || '',\n\t\taddress_1: address.line1 || '',\n\t\taddress_2: address.line2 || '',\n\t\tcity: address.city || '',\n\t\tstate: address.state || '',\n\t\tzip: address.postal_code || '',\n\t\tcountry: address.country || '',\n\t\tcountryCode: address.country || '',\n\t\tisPrimary: false,\n\t\tisResidential: true,\n\t\tdeliveryInstructions: null\n\t}\n}\n\n/** The storefront's address form -> GoCommerce's `Address`, which checkout requires. */\nexport const toGoCommerceAddress = (address?: Record<string, any> | null, fallbackPhone?: string): GcAddress | null => {\n\tif (!address) return null\n\tconst name = [address.firstName, address.lastName].filter(Boolean).join(' ').trim() || address.name || ''\n\tconst line1 = address.address_1 || address.line1 || ''\n\tconst city = address.city || ''\n\tconst postal = address.zip || address.postal_code || ''\n\tconst country = address.countryCode || address.country_code || address.country || ''\n\tif (!line1 || !city || !postal || !country) return null\n\treturn {\n\t\tname,\n\t\tphone: address.phone || fallbackPhone || '',\n\t\tline1,\n\t\tline2: address.address_2 || address.line2 || '',\n\t\tcity,\n\t\tstate: address.state || '',\n\t\tpostal_code: postal,\n\t\t// GoCommerce wants ISO 3166-1 alpha-2; the form may hold a full country name alongside it.\n\t\tcountry: String(country).length === 2 ? String(country).toUpperCase() : String(country)\n\t}\n}\n\nexport const mapOrder = (order?: GcOrder | null, index?: ProductIndex) => {\n\tif (!order) return null\n\tconst shippingAddress = toStorefrontAddress(order.address, order.email, order.phone)\n\n\treturn {\n\t\tid: order.id,\n\t\torderNo: order.number,\n\t\torder_no: order.number,\n\t\t// The orders list links a detail page by parentOrderNo; the number is the handle here.\n\t\tparentOrderNo: order.number,\n\t\tstatus: order.status || 'pending',\n\t\tpaymentStatus: order.payment_status || 'pending',\n\t\tpaymentMethod: order.payment_provider || null,\n\t\tcreatedAt: order.created_at || null,\n\t\tupdatedAt: order.updated_at || null,\n\t\tuserEmail: order.email || '',\n\t\tphone: order.phone || '',\n\t\tsubtotal: fromMoney(order.subtotal),\n\t\tshippingCharges: fromMoney(order.shipping),\n\t\tdiscount: fromMoney(order.discount),\n\t\ttotal: fromMoney(order.total),\n\t\tcurrencyCode: order.currency,\n\t\tcurrencyDecimalDigits: currencyFractionDigits(order.currency),\n\t\tshippingRate: null,\n\t\tfulfillments: (order.fulfillments || []).map((f) => ({\n\t\t\tid: f.id,\n\t\t\tstatus: f.status || '',\n\t\t\tprovider: f.provider || '',\n\t\t\ttrackingNumber: f.tracking || '',\n\t\t\tlabelUrl: f.label_url || '',\n\t\t\tcreatedAt: f.created_at || null\n\t\t})),\n\t\tshippingAddress,\n\t\tbillingAddress: shippingAddress,\n\t\tlineItems: (order.line_items || []).map((line) => {\n\t\t\tconst product = lineProduct(index, line.product_id)\n\t\t\tconst mapped = product ? mapProduct(product) : null\n\t\t\tconst variant = product?.variants?.find((v) => v.id === line.variant_id)\n\t\t\treturn {\n\t\t\t\tid: line.id,\n\t\t\t\tproductId: line.product_id,\n\t\t\t\tvariantId: line.variant_id,\n\t\t\t\ttitle: line.title || mapped?.title || '',\n\t\t\t\tvariantTitle: line.variant_label || line.sku || '',\n\t\t\t\tslug: mapped?.slug || '',\n\t\t\t\tsku: line.sku || '',\n\t\t\t\tthumbnail: absoluteMedia(variant?.image?.url) || mapped?.thumbnail || null,\n\t\t\t\tqty: line.quantity,\n\t\t\t\tprice: fromMoney(line.unit_price),\n\t\t\t\t// The orders list prints `total`; the confirmation page prints `subtotal`.\n\t\t\t\tsubtotal: fromMoney(line.total),\n\t\t\t\ttotal: fromMoney(line.total)\n\t\t\t}\n\t\t})\n\t}\n}\n","// What the checkout needs but a GoCommerce cart cannot hold.\r\n//\r\n// A GoCommerce cart is a token, a currency, an email and its lines. There is no endpoint to change\r\n// it after it is opened and no address on it at all: the shopper's name, phone and delivery address\r\n// are arguments to `POST /api/checkout/{code}`, and they exist nowhere before that call. The\r\n// storefront collects them a step earlier, so they are held here — in this browser, against this\r\n// cart id — and handed over when the order is actually placed.\r\n//\r\n// Order access tokens live here too. Guest checkout is permanent in GoCommerce, so the token\r\n// returned once at checkout is the only credential that reads the order back; losing it means the\r\n// shopper cannot see what they just bought.\r\n\r\nimport type { CheckoutDetails } from './mappers'\r\n\r\nconst DETAILS_PREFIX = 'gocommerce_checkout_'\r\nconst ORDER_TOKENS_KEY = 'gocommerce_order_tokens'\r\n\r\n/** Server-side rendering has no localStorage, and no shopper to have typed anything into it. */\r\nconst storage = (): Storage | undefined => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' && window.localStorage ? window.localStorage : undefined\r\n\t} catch {\r\n\t\t// Blocked site data (private windows, strict browser settings) throws on access, not on read.\r\n\t\treturn undefined\r\n\t}\r\n}\r\n\r\nconst readJson = <T>(key: string): T | undefined => {\r\n\tconst store = storage()\r\n\tif (!store) return undefined\r\n\ttry {\r\n\t\tconst raw = store.getItem(key)\r\n\t\treturn raw ? (JSON.parse(raw) as T) : undefined\r\n\t} catch {\r\n\t\treturn undefined\r\n\t}\r\n}\r\n\r\nconst writeJson = (key: string, value: unknown) => {\r\n\tconst store = storage()\r\n\tif (!store) return\r\n\ttry {\r\n\t\tstore.setItem(key, JSON.stringify(value))\r\n\t} catch {\r\n\t\t// A full or unavailable quota must not break the checkout step that triggered the write.\r\n\t}\r\n}\r\n\r\nexport const readCheckoutDetails = (cartId?: string | null): CheckoutDetails => {\r\n\tif (!cartId) return {}\r\n\treturn readJson<CheckoutDetails>(`${DETAILS_PREFIX}${cartId}`) ?? {}\r\n}\r\n\r\n/** Merges, so setting an address later never erases the email collected before it. */\r\nexport const writeCheckoutDetails = (cartId: string | null | undefined, patch: CheckoutDetails): CheckoutDetails => {\r\n\tif (!cartId) return patch\r\n\tconst merged = { ...readCheckoutDetails(cartId), ...patch }\r\n\twriteJson(`${DETAILS_PREFIX}${cartId}`, merged)\r\n\treturn merged\r\n}\r\n\r\nexport const clearCheckoutDetails = (cartId?: string | null) => {\r\n\tconst store = storage()\r\n\tif (!store || !cartId) return\r\n\ttry {\r\n\t\tstore.removeItem(`${DETAILS_PREFIX}${cartId}`)\r\n\t} catch {\r\n\t\t// Nothing to recover from: the entry expires with the cart either way.\r\n\t}\r\n}\r\n\r\ntype OrderTokens = Record<string, string>\r\n\r\n/** The credential a guest reads their own order back with. Returned once, at checkout. */\r\nexport const rememberOrderToken = (orderNumber?: string, token?: string) => {\r\n\tif (!orderNumber || !token) return\r\n\tconst tokens = readJson<OrderTokens>(ORDER_TOKENS_KEY) ?? {}\r\n\ttokens[orderNumber] = token\r\n\twriteJson(ORDER_TOKENS_KEY, tokens)\r\n}\r\n\r\nexport const readOrderToken = (orderNumber?: string | null): string | undefined => {\r\n\tif (!orderNumber) return undefined\r\n\treturn (readJson<OrderTokens>(ORDER_TOKENS_KEY) ?? {})[orderNumber]\r\n}\r\n\r\n/** Every order this browser has placed, newest last — the shopper's own order history. */\r\nexport const readOrderNumbers = (): string[] => Object.keys(readJson<OrderTokens>(ORDER_TOKENS_KEY) ?? {})\r\n","// The address book.\r\n//\r\n// GoCommerce has no such thing — there are no accounts to hang addresses off, and a delivery address\r\n// exists only as an argument to `POST /api/checkout/{code}`. But the storefront's checkout needs one:\r\n// when it believes a shopper is signed in it saves the address to the book, lists it, and only then\r\n// copies the selection onto the cart. Refusing that write does not degrade gracefully, it dead-ends\r\n// checkout with \"Saved addresses is not available on this store\".\r\n//\r\n// So the book is real, and local to this browser: the same place the checkout details already live\r\n// (checkout-details.ts), under the same rule — the shopper's own data, on the shopper's own device,\r\n// sent to GoCommerce only when the order is placed. Nothing here reaches the server, and clearing\r\n// site data clears it.\r\n\r\nconst ADDRESSES_KEY = 'gocommerce_addresses'\r\n\r\nexport type StoredAddress = Record<string, unknown> & { id: string }\r\n\r\nconst storage = (): Storage | undefined => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' && window.localStorage ? window.localStorage : undefined\r\n\t} catch {\r\n\t\t// Blocked site data (private windows, strict browser settings) throws on access.\r\n\t\treturn undefined\r\n\t}\r\n}\r\n\r\nconst readAll = (): StoredAddress[] => {\r\n\tconst store = storage()\r\n\tif (!store) return []\r\n\ttry {\r\n\t\tconst raw = store.getItem(ADDRESSES_KEY)\r\n\t\tconst parsed = raw ? JSON.parse(raw) : []\r\n\t\treturn Array.isArray(parsed) ? parsed : []\r\n\t} catch {\r\n\t\treturn []\r\n\t}\r\n}\r\n\r\nconst writeAll = (addresses: StoredAddress[]) => {\r\n\tconst store = storage()\r\n\tif (!store) return\r\n\ttry {\r\n\t\tstore.setItem(ADDRESSES_KEY, JSON.stringify(addresses))\r\n\t} catch {\r\n\t\t// A full or unavailable quota must not fail the checkout step that triggered the write.\r\n\t}\r\n}\r\n\r\n/** `'new'` is the placeholder the form opens with, so it never identifies a saved record. */\r\nconst isSavedId = (id: unknown): id is string => typeof id === 'string' && id.length > 0 && id !== 'new'\r\n\r\nconst newId = () => `addr_${Math.random().toString(36).slice(2, 10)}${Date.now().toString(36)}`\r\n\r\nexport const listAddresses = (): StoredAddress[] => readAll()\r\n\r\nexport const findAddress = (id: string): StoredAddress | undefined => readAll().find((a) => a.id === id)\r\n\r\n/**\r\n * Adds an address, or replaces the one it already names.\r\n *\r\n * The form hands back the record it was opened with, so an edit arrives carrying its own id while a\r\n * new address arrives with the `'new'` placeholder.\r\n */\r\nexport const putAddress = (address: Record<string, unknown>): StoredAddress => {\r\n\tconst addresses = readAll()\r\n\tconst id = isSavedId(address.id) ? address.id : newId()\r\n\tconst saved: StoredAddress = { ...address, id }\r\n\tconst index = addresses.findIndex((a) => a.id === id)\r\n\tif (index >= 0) addresses[index] = saved\r\n\telse addresses.push(saved)\r\n\twriteAll(addresses)\r\n\treturn saved\r\n}\r\n\r\nexport const patchAddress = (id: string, patch: Record<string, unknown>): StoredAddress | undefined => {\r\n\tconst existing = findAddress(id)\r\n\tif (!existing) return undefined\r\n\treturn putAddress({ ...existing, ...patch, id })\r\n}\r\n\r\nexport const removeAddress = (id: string) => {\r\n\twriteAll(readAll().filter((a) => a.id !== id))\r\n}\r\n\r\n/**\r\n * Cookies naming a signed-in shopper, which on GoCommerce can only be leftovers.\r\n *\r\n * `connect.sid` and `me` are how the shared user store decides who is signed in — it reads them from\r\n * `document.cookie` directly. GoCommerce has no accounts and sets neither, so a pair sitting in the\r\n * browser came from running this storefront against a different backend. Left alone they make the\r\n * storefront believe a guest is signed in, which routes checkout down the saved-address path and, on\r\n * a store with no address book, dead-ends it.\r\n */\r\nconst SESSION_COOKIES = ['connect.sid', 'me']\r\n\r\nexport const clearPhantomSession = () => {\r\n\tif (typeof document === 'undefined') return\r\n\tfor (const name of SESSION_COOKIES) {\r\n\t\t// Expire on the current path and on the root, since we did not set them and cannot know which.\r\n\t\tdocument.cookie = `${name}=; Max-Age=0; path=/`\r\n\t\tdocument.cookie = `${name}=; Max-Age=0`\r\n\t}\r\n}\r\n\r\n/** True when this browser is carrying a session from some other backend. */\r\nexport const hasPhantomSession = () =>\r\n\ttypeof document !== 'undefined' && SESSION_COOKIES.some((name) => new RegExp(`(^|;\\\\s*)${name.replace('.', '\\\\.')}=`).test(document.cookie))\r\n","// Catalogue: products, categories, collections, and the listing search built on them.\r\n//\r\n// GoCommerce's shopper-facing catalogue is deliberately small — `q`, `limit`, `page`, and a category\r\n// or collection slug. It has no sort parameter, no tag filter and no price range, so the listing\r\n// page's sort control and facet filters are applied here, over one window of the catalogue\r\n// (`MAX_LIMIT` products, the API's own ceiling). That is exact for a catalogue up to that size and\r\n// is the honest limit of what one request can answer; see docs/GOCOMMERCE.md.\r\n\r\nimport { BaseService, type GoCommerceError } from './base'\r\nimport { currencyFractionDigits as currencyDigits } from './money'\r\nimport { MAX_LIMIT, PAGE_SIZE, emptyPage, fromListMeta, mapCategory, mapCollection, mapProduct, paginated } from './mappers'\r\nimport type { ProductIndex } from './mappers'\r\nimport type { GcCategory, GcCategoryPage, GcCollection, GcCollectionPage, GcProduct, GcVariant, ListMeta } from './types'\r\n\r\n/**\r\n * Products this connector has already read, so a cart or order line can show a slug and an image\r\n * without a request per line. Bounded: a storefront session touches a handful of products, and the\r\n * entries are refreshed whenever a listing reads them again.\r\n */\r\nconst productCache = new Map<number, GcProduct>()\r\n\r\n/** `listRelatedProducts` is handed a category id, but the API is keyed on slug. */\r\nconst categorySlugById = new Map<number, string>()\r\n\r\nconst remember = (products: GcProduct[]) => {\r\n\tfor (const product of products) {\r\n\t\tif (product?.id != null) productCache.set(product.id, product)\r\n\t\tif (product?.category?.id != null && product.category.slug) categorySlugById.set(product.category.id, product.category.slug)\r\n\t}\r\n\treturn products\r\n}\r\n\r\nconst rememberCategories = (categories: GcCategory[]) => {\r\n\tfor (const category of categories) {\r\n\t\tif (category?.id != null && category.slug) categorySlugById.set(category.id, category.slug)\r\n\t\tif (category?.children?.length) rememberCategories(category.children)\r\n\t}\r\n\treturn categories\r\n}\r\n\r\nconst query = (params: Record<string, string | number | undefined>) => {\r\n\tconst search = new URLSearchParams()\r\n\tfor (const [key, value] of Object.entries(params)) {\r\n\t\tif (value === undefined || value === '') continue\r\n\t\tsearch.set(key, String(value))\r\n\t}\r\n\tconst qs = search.toString()\r\n\treturn qs ? `?${qs}` : ''\r\n}\r\n\r\nexport class ProductService extends BaseService {\r\n\tprivate static instance: ProductService\r\n\r\n\tstatic getInstance(): ProductService {\r\n\t\tif (!ProductService.instance) ProductService.instance = new ProductService()\r\n\t\treturn ProductService.instance\r\n\t}\r\n\r\n\t/** One window of the catalogue, raw. Everything else in this file is built on it. */\r\n\tasync fetchProducts({ q, page = 1, limit = PAGE_SIZE }: { q?: string; page?: number; limit?: number } = {}) {\r\n\t\tconst res = await this.api<GcProduct[]>('GET', `/api/products${query({ q, page, limit })}`)\r\n\t\treturn { products: remember(res.data || []), meta: res.meta }\r\n\t}\r\n\r\n\t/** A product by its numeric id — how a cart line names what is in it. */\r\n\tasync fetchProductById(id: number): Promise<GcProduct | null> {\r\n\t\tconst cached = productCache.get(id)\r\n\t\tif (cached) return cached\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcProduct>('GET', `/api/products/${id}`)\r\n\t\t\tif (res.data) remember([res.data])\r\n\t\t\treturn res.data ?? null\r\n\t\t} catch {\r\n\t\t\t// A line whose product went inactive still has to render; it just renders without a slug.\r\n\t\t\treturn null\r\n\t\t}\r\n\t}\r\n\r\n\tasync fetchProductBySlug(slug: string): Promise<GcProduct | null> {\r\n\t\tconst res = await this.api<GcProduct>('GET', `/api/products/slug/${encodeURIComponent(slug)}`)\r\n\t\tif (res.data) remember([res.data])\r\n\t\treturn res.data ?? null\r\n\t}\r\n\r\n\tasync list({ page = 1, search = '', sort = '' }: { page?: number; search?: string; sort?: string } = {}) {\r\n\t\tif (sortNeedsWholeCatalogue(sort)) {\r\n\t\t\tconst { products, meta } = await this.fetchProducts({ q: search, page: 1, limit: MAX_LIMIT })\r\n\t\t\tconst sorted = sortProducts(products, sort)\r\n\t\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\t\treturn paginated(sorted.slice(start, start + PAGE_SIZE).map(mapProduct), meta?.total ?? sorted.length, page)\r\n\t\t}\r\n\t\tconst { products, meta } = await this.fetchProducts({ q: search, page, limit: PAGE_SIZE })\r\n\t\treturn fromListMeta(products.map(mapProduct), meta, page)\r\n\t}\r\n\r\n\t// GoCommerce records no \"featured\" or \"trending\" flag, and inventing one would rank the catalogue\r\n\t// by nothing. Newest first is the honest reading of both, and it is what the homepage asks for.\r\n\tasync listFeaturedProducts({ page = 1, sort = '-createdAt' }: { page?: number; sort?: string } = {}) {\r\n\t\treturn this.list({ page, sort })\r\n\t}\r\n\r\n\tasync listTrendingProducts({ page = 1, search = '', sort = '-createdAt' }: { page?: number; search?: string; sort?: string } = {}) {\r\n\t\treturn this.list({ page, search, sort })\r\n\t}\r\n\r\n\t/** The \"you may also like\" rail: the rest of the product's own category. */\r\n\tasync listRelatedProducts({ page = 1, categoryId = '' }: { page?: number; categoryId?: string | number; sort?: string } = {}) {\r\n\t\tconst slug = await resolveCategorySlug(categoryId)\r\n\t\tif (!slug) return emptyPage(page)\r\n\t\tconst { products, meta } = await categoryService.fetchCategoryPage(slug, { limit: MAX_LIMIT })\r\n\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\treturn paginated(products.slice(start, start + PAGE_SIZE).map(mapProduct), meta?.total ?? products.length, page)\r\n\t}\r\n\r\n\tasync getOne(slug: string) {\r\n\t\treturn mapProduct(await this.fetchProductBySlug(slug))\r\n\t}\r\n\r\n\t/** A product's variants, for a PDP that wants them without re-reading the product. */\r\n\tasync listVariants(productId: number | string) {\r\n\t\tconst res = await this.api<GcVariant[]>('GET', `/api/variants${query({ product_id: productId, limit: MAX_LIMIT })}`)\r\n\t\treturn fromListMeta(res.data || [], res.meta)\r\n\t}\r\n\r\n\t// GoCommerce ships no review API, and a silent success would tell the shopper their review was\r\n\t// saved when nothing left the browser.\r\n\tasync addReview(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Product reviews are not available on this store.')\r\n\t}\r\n\r\n\tasync fetchReels() {\r\n\t\treturn { data: [], count: 0 }\r\n\t}\r\n}\r\n\r\nexport const productService = ProductService.getInstance()\r\n\r\nexport class CategoryService extends BaseService {\r\n\tprivate static instance: CategoryService\r\n\r\n\tstatic getInstance(): CategoryService {\r\n\t\tif (!CategoryService.instance) CategoryService.instance = new CategoryService()\r\n\t\treturn CategoryService.instance\r\n\t}\r\n\r\n\t/**\r\n\t * `use-category-filters` in @misiki/kitcommerce-core fetches the tree by raw Litekart REST path\r\n\t * rather than a typed method. On a GoCommerce store that url resolves against the storefront's\r\n\t * own origin, so route that one path to the real tree; `fetchAllCategories` already returns the\r\n\t * `{ data }` shape it reads.\r\n\t */\r\n\tasync get<T>(url: string): Promise<T> {\r\n\t\tif (typeof url === 'string' && url.startsWith('/api/categories/all')) {\r\n\t\t\treturn (await this.fetchAllCategories()) as T\r\n\t\t}\r\n\t\treturn super.get<T>(url)\r\n\t}\r\n\r\n\t/**\r\n\t * The taxonomy, flattened.\r\n\t *\r\n\t * `GET /api/categories` answers with one fixed window and ignores `limit`/`page`, so this is\r\n\t * every category the storefront can see — roots plus what fits beneath them. A store that has\r\n\t * imported a full retail taxonomy has far more nodes than that; the ones a shopper reaches are\r\n\t * still reachable, because a listing page looks its category up by slug directly.\r\n\t */\r\n\tasync fetchAllCategories() {\r\n\t\tconst res = await this.api<GcCategory[]>('GET', `/api/categories${query({ flat: 'true' })}`)\r\n\t\tconst categories = rememberCategories(res.data || [])\r\n\t\treturn paginated(categories.map(mapCategory), categories.length, 1, categories.length || PAGE_SIZE)\r\n\t}\r\n\r\n\t/** A category and the active products filed under it or anything beneath it. */\r\n\tasync fetchCategoryPage(slug: string, { limit = MAX_LIMIT, offset = 0 }: { limit?: number; offset?: number } = {}) {\r\n\t\tconst res = await this.api<GcCategoryPage>('GET', `/api/categories/${encodeURIComponent(slug)}${query({ limit, offset })}`)\r\n\t\tconst category = res.data\r\n\t\tif (category) rememberCategories([category])\r\n\t\tconst products = remember(category?.products || [])\r\n\t\treturn { category, products, meta: res.meta }\r\n\t}\r\n\r\n\tasync fetchCategory(slugOrId: string) {\r\n\t\tconst { category } = await this.fetchCategoryPage(String(slugOrId), { limit: 1 })\r\n\t\treturn mapCategory(category)\r\n\t}\r\n\r\n\tasync fetchFooterCategories({ page = 1, q = '' }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst all = await this.fetchAllCategories()\r\n\t\tconst filtered = q ? all.data.filter((c) => c?.name?.toLowerCase().includes(q.toLowerCase())) : all.data\r\n\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\treturn paginated(filtered.slice(start, start + PAGE_SIZE), filtered.length, page)\r\n\t}\r\n\r\n\t/** The homepage grid: the roots of the taxonomy, which is what a shopper navigates from. */\r\n\tasync fetchFeaturedCategories({ limit = 18 }: { limit?: number } = {}) {\r\n\t\tconst all = await this.fetchAllCategories()\r\n\t\tconst roots = all.data.filter((c) => c && c.parentCategoryId == null)\r\n\t\tconst picked = (roots.length ? roots : all.data).slice(0, limit)\r\n\t\treturn paginated(picked, picked.length, 1, limit)\r\n\t}\r\n\r\n\tasync fetchAllProductsOfCategories(slugOrId: string) {\r\n\t\tconst slug = (await resolveCategorySlug(slugOrId)) || String(slugOrId)\r\n\t\tconst { products, meta } = await this.fetchCategoryPage(slug)\r\n\t\treturn fromListMeta(products.map(mapProduct), meta)\r\n\t}\r\n\r\n\tasync getMegamenu() {\r\n\t\treturn this.fetchFeaturedCategories({ limit: 50 })\r\n\t}\r\n}\r\n\r\nexport const categoryService = CategoryService.getInstance()\r\n\r\n/** Turns the numeric category id carried on a product into the slug the API is keyed on. */\r\nconst resolveCategorySlug = async (categoryId: string | number | undefined | null): Promise<string | undefined> => {\r\n\tif (categoryId === undefined || categoryId === null || categoryId === '') return undefined\r\n\tconst asNumber = Number(categoryId)\r\n\tif (!Number.isFinite(asNumber)) return String(categoryId)\r\n\tconst known = categorySlugById.get(asNumber)\r\n\tif (known) return known\r\n\tawait categoryService.fetchAllCategories()\r\n\treturn categorySlugById.get(asNumber)\r\n}\r\n\r\nexport class CollectionService extends BaseService {\r\n\tprivate static instance: CollectionService\r\n\r\n\tstatic getInstance(): CollectionService {\r\n\t\tif (!CollectionService.instance) CollectionService.instance = new CollectionService()\r\n\t\treturn CollectionService.instance\r\n\t}\r\n\r\n\tasync list({ page = 1, q = '' }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst res = await this.api<GcCollection[]>('GET', `/api/collections${query({ page, limit: PAGE_SIZE })}`)\r\n\t\tconst items = res.data || []\r\n\t\tconst filtered = q ? items.filter((c) => c.title?.toLowerCase().includes(q.toLowerCase())) : items\r\n\t\treturn fromListMeta(\r\n\t\t\tfiltered.map((c) => mapCollection(c)),\r\n\t\t\tres.meta,\r\n\t\t\tpage\r\n\t\t)\r\n\t}\r\n\r\n\t/**\r\n\t * A collection with its products. GoCommerce is keyed on slug; the storefront sometimes has only\r\n\t * an id, and there is no id lookup, so that case reads the list and matches there.\r\n\t */\r\n\tasync getOne(idOrSlug: string) {\r\n\t\tconst looksLikeId = /^[0-9]+$/.test(String(idOrSlug))\r\n\t\tlet slug = String(idOrSlug)\r\n\t\tif (looksLikeId) {\r\n\t\t\tconst res = await this.api<GcCollection[]>('GET', `/api/collections${query({ limit: MAX_LIMIT })}`)\r\n\t\t\tconst match = (res.data || []).find((c) => String(c.id) === String(idOrSlug))\r\n\t\t\tif (!match) throw new Error(`Collection ${idOrSlug} not found`)\r\n\t\t\tslug = match.slug\r\n\t\t}\r\n\t\tconst res = await this.api<GcCollectionPage>('GET', `/api/collections/${encodeURIComponent(slug)}${query({ limit: MAX_LIMIT })}`)\r\n\t\tif (!res.data) throw new Error(`Collection ${idOrSlug} not found`)\r\n\t\tremember(res.data.products || [])\r\n\t\treturn mapCollection(res.data)\r\n\t}\r\n\r\n\t// GoCommerce records no ratings, so there is no \"all ratings\" collection to serve.\r\n\tasync getAllRatings() {\r\n\t\treturn {\r\n\t\t\tid: null,\r\n\t\t\tname: 'All Ratings',\r\n\t\t\tslug: 'all-ratings',\r\n\t\t\tdescription: null,\r\n\t\t\tisActive: true,\r\n\t\t\tisFeatured: false,\r\n\t\t\tuserId: '',\r\n\t\t\tproductCount: 0,\r\n\t\t\tthumbnail: null,\r\n\t\t\tmetaTitle: null,\r\n\t\t\tmetaDescription: null,\r\n\t\t\tcollectionvalues: [],\r\n\t\t\tcreatedAt: null,\r\n\t\t\tupdatedAt: null\r\n\t\t}\r\n\t}\r\n}\r\n\r\nexport const collectionService = CollectionService.getInstance()\r\n\r\n// ---------------------------------------------------------------------------------------------\r\n// Listing search\r\n// ---------------------------------------------------------------------------------------------\r\n\r\nexport type ProductSearchResult = {\r\n\tdata: unknown[]\r\n\tcount: number\r\n\ttotalPages: number\r\n\tcategoryHierarchy: { name: string; slug?: string }[]\r\n\tfacets: {\r\n\t\tpriceStat: { min?: number; max?: number }\r\n\t\tcategories: { name: string; slug?: string; count: number }[]\r\n\t\ttags: { name: string; slug?: string; count: number }[]\r\n\t\tallFilters: Record<string, unknown>\r\n\t}\r\n}\r\n\r\n/** `popularity` has no GoCommerce equivalent, so it means \"the operator's own order\" — no re-sort. */\r\nconst sortNeedsWholeCatalogue = (sort?: string) => {\r\n\tif (!sort) return false\r\n\tconst key = sort.replace(/^-/, '').split(':')[0]\r\n\treturn key === 'price' || key === 'updatedAt' || key === 'createdAt'\r\n}\r\n\r\nconst sortProducts = (products: GcProduct[], sort?: string): GcProduct[] => {\r\n\tif (!sortNeedsWholeCatalogue(sort)) return products\r\n\t// Both spellings reach here: `price:asc` from the sort control, `-createdAt` from the homepage.\r\n\tconst leadingMinus = sort!.startsWith('-')\r\n\tconst [rawKey, rawDirection] = sort!.replace(/^-/, '').split(':')\r\n\tconst descending = leadingMinus || rawDirection === 'desc'\r\n\r\n\tconst value = (product: GcProduct) => {\r\n\t\tif (rawKey === 'price') {\r\n\t\t\tconst prices = (product.variants || []).filter((v) => v.active !== false).map((v) => v.price?.amount_minor ?? 0)\r\n\t\t\treturn prices.length ? Math.min(...prices) : 0\r\n\t\t}\r\n\t\tconst stamp = rawKey === 'createdAt' ? product.created_at : product.updated_at\r\n\t\treturn stamp ? Date.parse(stamp) : 0\r\n\t}\r\n\r\n\treturn [...products].sort((a, b) => (descending ? value(b) - value(a) : value(a) - value(b)))\r\n}\r\n\r\nconst productPrice = (product: GcProduct) => {\r\n\tconst prices = (product.variants || []).filter((v) => v.active !== false).map((v) => v.price?.amount_minor ?? 0)\r\n\treturn prices.length ? Math.min(...prices) : 0\r\n}\r\n\r\nconst countBy = <T>(items: T[], key: (item: T) => { name: string; slug?: string } | undefined) => {\r\n\tconst counts = new Map<string, { name: string; slug?: string; count: number }>()\r\n\tfor (const item of items) {\r\n\t\tconst entry = key(item)\r\n\t\tif (!entry?.name) continue\r\n\t\tconst id = entry.slug || entry.name\r\n\t\tconst existing = counts.get(id)\r\n\t\tif (existing) existing.count += 1\r\n\t\telse counts.set(id, { ...entry, count: 1 })\r\n\t}\r\n\treturn [...counts.values()].sort((a, b) => b.count - a.count)\r\n}\r\n\r\nexport class SearchService extends BaseService {\r\n\tprivate static instance: SearchService\r\n\r\n\tstatic getInstance(): SearchService {\r\n\t\tif (!SearchService.instance) SearchService.instance = new SearchService()\r\n\t\treturn SearchService.instance\r\n\t}\r\n\r\n\temptyResult(): ProductSearchResult {\r\n\t\treturn {\r\n\t\t\tdata: [],\r\n\t\t\tcount: 0,\r\n\t\t\ttotalPages: 0,\r\n\t\t\tcategoryHierarchy: [],\r\n\t\t\tfacets: { priceStat: { min: undefined, max: undefined }, categories: [], tags: [], allFilters: {} }\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The listing page: `/products`, `/[slug]` for a category, and every filter the sidebar sets.\r\n\t *\r\n\t * Term and category are pushed to the API. Tags, the price range and the sort control are\r\n\t * applied here, because GoCommerce has no parameter for them — so when any of those is active\r\n\t * the request asks for the whole window rather than one page, and the result is paged locally.\r\n\t */\r\n\tasync searchWithUrl(url: URL, slug?: string): Promise<ProductSearchResult> {\r\n\t\ttry {\r\n\t\t\tconst params = new URLSearchParams(url.search)\r\n\t\t\tconst term = params.get('search') || params.get('q') || ''\r\n\t\t\tconst page = Math.max(1, Number(params.get('page') || 1) || 1)\r\n\t\t\tconst sort = params.get('sort') || ''\r\n\t\t\tconst tags = (params.get('tags') || '')\r\n\t\t\t\t.split(',')\r\n\t\t\t\t.map((t) => decodeURIComponent(t).trim().toLowerCase())\r\n\t\t\t\t.filter(Boolean)\r\n\t\t\tconst priceFrom = params.get('priceFrom') ? Number(params.get('priceFrom')) : undefined\r\n\t\t\tconst priceTo = params.get('priceTo') ? Number(params.get('priceTo')) : undefined\r\n\r\n\t\t\t// `/products` is the catalogue root, not a category; anything else in that slot is one.\r\n\t\t\tconst categorySlug = slug && slug !== 'products' ? slug : params.get('categories') || undefined\r\n\r\n\t\t\tconst localFilters = tags.length > 0 || priceFrom !== undefined || priceTo !== undefined\r\n\t\t\tconst needsWholeWindow = localFilters || sortNeedsWholeCatalogue(sort) || Boolean(categorySlug)\r\n\r\n\t\t\tlet products: GcProduct[] = []\r\n\t\t\tlet meta: ListMeta | undefined\r\n\t\t\tlet category: GcCategory | undefined\r\n\r\n\t\t\tif (categorySlug) {\r\n\t\t\t\tconst res = await categoryService.fetchCategoryPage(categorySlug, { limit: MAX_LIMIT })\r\n\t\t\t\tproducts = res.products\r\n\t\t\t\tmeta = res.meta\r\n\t\t\t\tcategory = res.category\r\n\t\t\t\tif (term) {\r\n\t\t\t\t\tconst needle = term.toLowerCase()\r\n\t\t\t\t\tproducts = products.filter((p) => `${p.title} ${p.description || ''}`.toLowerCase().includes(needle))\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tconst res = await productService.fetchProducts({\r\n\t\t\t\t\tq: term,\r\n\t\t\t\t\tpage: needsWholeWindow ? 1 : page,\r\n\t\t\t\t\tlimit: needsWholeWindow ? MAX_LIMIT : PAGE_SIZE\r\n\t\t\t\t})\r\n\t\t\t\tproducts = res.products\r\n\t\t\t\tmeta = res.meta\r\n\t\t\t}\r\n\r\n\t\t\t// Facets describe what came back, so they are computed before the local filters narrow it.\r\n\t\t\tconst facetSource = products\r\n\t\t\tconst priceMinor = facetSource.map(productPrice).filter((n) => Number.isFinite(n))\r\n\t\t\tconst currency = facetSource[0]?.variants?.[0]?.price?.currency || facetSource[0]?.currency\r\n\t\t\tconst digits = currency ? 10 ** currencyDigits(currency) : 100\r\n\r\n\t\t\tlet filtered = products\r\n\t\t\tif (tags.length) {\r\n\t\t\t\tfiltered = filtered.filter((p) => (p.tags || []).some((tag) => tags.includes(tag.toLowerCase())))\r\n\t\t\t}\r\n\t\t\tif (priceFrom !== undefined) filtered = filtered.filter((p) => productPrice(p) / digits >= priceFrom)\r\n\t\t\tif (priceTo !== undefined) filtered = filtered.filter((p) => productPrice(p) / digits <= priceTo)\r\n\r\n\t\t\tfiltered = sortProducts(filtered, sort)\r\n\r\n\t\t\t// One page of the API's own window is already the page; anything narrowed here is not.\r\n\t\t\tconst paged = needsWholeWindow ? filtered.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE) : filtered\r\n\t\t\tconst count = needsWholeWindow ? filtered.length : (meta?.total ?? filtered.length)\r\n\r\n\t\t\treturn {\r\n\t\t\t\tdata: paged.map(mapProduct),\r\n\t\t\t\tcount,\r\n\t\t\t\ttotalPages: Math.ceil(count / PAGE_SIZE) || (count ? 1 : 0),\r\n\t\t\t\t// Only the category itself: its ancestors are named in `full_name` but their slugs are\r\n\t\t\t\t// not served to a storefront, and a breadcrumb link with no destination is worse than\r\n\t\t\t\t// no crumb.\r\n\t\t\t\tcategoryHierarchy: category ? [{ name: category.title, slug: category.slug }] : [],\r\n\t\t\t\tfacets: {\r\n\t\t\t\t\tpriceStat: priceMinor.length\r\n\t\t\t\t\t\t? { min: Math.min(...priceMinor) / digits, max: Math.max(...priceMinor) / digits }\r\n\t\t\t\t\t\t: { min: undefined, max: undefined },\r\n\t\t\t\t\tcategories: countBy(facetSource, (p) => (p.category ? { name: p.category.title, slug: p.category.slug } : undefined)),\r\n\t\t\t\t\ttags: countBy(\r\n\t\t\t\t\t\tfacetSource.flatMap((p) => (p.tags || []).map((tag) => ({ tag }))),\r\n\t\t\t\t\t\t({ tag }) => ({ name: tag, slug: tag })\r\n\t\t\t\t\t),\r\n\t\t\t\t\tallFilters: {}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t} catch (error) {\r\n\t\t\t// `(www)/[slug]` is the storefront's catch-all, so every unmatched path arrives here as a\r\n\t\t\t// category lookup. A slug that names no category is that route doing its job, not a\r\n\t\t\t// failure worth a stack trace — anything else is.\r\n\t\t\tif ((error as GoCommerceError)?.code !== 'not_found') console.error('[gocommerce] search failed', error)\r\n\t\t\treturn this.emptyResult()\r\n\t\t}\r\n\t}\r\n\r\n\tasync searchWithQuery(queryString: string): Promise<ProductSearchResult> {\r\n\t\tconst url = new URL('https://storefront.local/products')\r\n\t\tif (queryString) url.searchParams.set('search', queryString)\r\n\t\treturn this.searchWithUrl(url)\r\n\t}\r\n}\r\n\r\nexport const searchService = SearchService.getInstance()\r\n\r\n/**\r\n * The site-wide search box. Litekart backs this with Meilisearch; GoCommerce answers the same\r\n * question with `?q=` on the catalogue, so the shape is translated rather than the engine replaced.\r\n */\r\nexport class MeilisearchService extends BaseService {\r\n\tprivate static instance: MeilisearchService\r\n\r\n\tstatic getInstance(): MeilisearchService {\r\n\t\tif (!MeilisearchService.instance) MeilisearchService.instance = new MeilisearchService()\r\n\t\treturn MeilisearchService.instance\r\n\t}\r\n\r\n\tasync search(params: { q?: string; page?: number; limit?: number } = {}) {\r\n\t\tconst page = Math.max(1, Number(params.page || 1) || 1)\r\n\t\tconst { products, meta } = await productService.fetchProducts({\r\n\t\t\tq: params.q || '',\r\n\t\t\tpage,\r\n\t\t\tlimit: params.limit || PAGE_SIZE\r\n\t\t})\r\n\t\tconst hits = products.map(mapProduct)\r\n\t\treturn {\r\n\t\t\thits,\r\n\t\t\tdata: hits,\r\n\t\t\testimatedTotalHits: meta?.total ?? hits.length,\r\n\t\t\tcount: meta?.total ?? hits.length,\r\n\t\t\tpage,\r\n\t\t\ttotalPages: meta?.total_pages ?? 1,\r\n\t\t\thitsPerPage: meta?.limit ?? PAGE_SIZE,\r\n\t\t\tfacetDistribution: {},\r\n\t\t\tprocessingTimeMs: 0,\r\n\t\t\tquery: params.q || ''\r\n\t\t}\r\n\t}\r\n\r\n\tasync searchAutoComplete(params: { q?: string; limit?: number } = {}) {\r\n\t\tconst { products } = await productService.fetchProducts({ q: params.q || '', page: 1, limit: params.limit || 8 })\r\n\t\tconst hits = products.map((product) => ({\r\n\t\t\tid: product.id,\r\n\t\t\tname: product.title,\r\n\t\t\ttitle: product.title,\r\n\t\t\tslug: product.slug,\r\n\t\t\tthumbnail: mapProduct(product)?.thumbnail || null\r\n\t\t}))\r\n\t\treturn { hits, data: hits, count: hits.length, query: params.q || '' }\r\n\t}\r\n}\r\n\r\nexport const meilisearchService = MeilisearchService.getInstance()\r\n\r\nexport class AutocompleteService extends BaseService {\r\n\tprivate static instance: AutocompleteService\r\n\r\n\tstatic getInstance(): AutocompleteService {\r\n\t\tif (!AutocompleteService.instance) AutocompleteService.instance = new AutocompleteService()\r\n\t\treturn AutocompleteService.instance\r\n\t}\r\n\r\n\tasync list({ page = 1, q = '' }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst { products, meta } = await productService.fetchProducts({ q, page, limit: 10 })\r\n\t\treturn fromListMeta(\r\n\t\t\tproducts.map((product) => ({ id: product.id, name: product.title, slug: product.slug })),\r\n\t\t\tmeta,\r\n\t\t\tpage\r\n\t\t)\r\n\t}\r\n}\r\n\r\nexport const autocompleteService = AutocompleteService.getInstance()\r\n\r\n/**\r\n * A product index for the ids a cart or order line names, so those lines can show a slug and an\r\n * image. Everything already read is served from the cache; the rest is fetched once, in parallel.\r\n */\r\nexport const resolveProductIndex = async (ids: (number | null | undefined)[], fetchFn?: typeof fetch): Promise<ProductIndex> => {\r\n\tconst wanted = [...new Set(ids.filter((id): id is number => typeof id === 'number'))]\r\n\tconst service = fetchFn ? new ProductService(fetchFn) : productService\r\n\tawait Promise.all(wanted.filter((id) => !productCache.has(id)).map((id) => service.fetchProductById(id)))\r\n\tconst index: ProductIndex = new Map()\r\n\tfor (const id of wanted) {\r\n\t\tconst product = productCache.get(id)\r\n\t\tif (product) index.set(id, product)\r\n\t}\r\n\treturn index\r\n}\r\n","// The cart.\r\n//\r\n// A GoCommerce cart is an opaque token and possessing it is the whole authorisation — there is no\r\n// account, and there never has to be. So the token is what this storefront persists as `cart_id`,\r\n// exactly where the shared cart store already looks for it.\r\n\r\nimport { BaseService } from './base'\r\nimport { resolveProductIndex } from './catalog'\r\nimport { readCheckoutDetails, writeCheckoutDetails } from './checkout-details'\r\nimport { mapCart } from './mappers'\r\nimport { readStaticStore } from './static-store'\r\nimport type { GcCart } from './types'\r\n\r\n/** The shared cart store's \"remove this line\" signal, sent as a quantity. */\r\nconst REMOVE_LINE = -9999999\r\n\r\nconst CART_ID_KEY = 'cart_id'\r\n\r\nconst readStoredCartId = (): string | null => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' ? window.localStorage?.getItem(CART_ID_KEY) || null : null\r\n\t} catch {\r\n\t\treturn null\r\n\t}\r\n}\r\n\r\nconst storeCartId = (cartId?: string | null) => {\r\n\tif (!cartId) return\r\n\ttry {\r\n\t\twindow?.localStorage?.setItem(CART_ID_KEY, cartId)\r\n\t} catch {\r\n\t\t// Without storage the cart lives for one page view; the checkout still works within it.\r\n\t}\r\n}\r\n\r\nconst forgetCartId = () => {\r\n\ttry {\r\n\t\twindow?.localStorage?.removeItem(CART_ID_KEY)\r\n\t} catch {\r\n\t\t// Nothing to clean up if storage is unavailable — there was no id to remember either.\r\n\t}\r\n}\r\n\r\n/** `'undefined'` reaches here as a string from call sites that interpolate a missing id. */\r\nconst usableId = (cartId?: string | null) => (cartId && cartId !== 'undefined' && cartId !== 'null' ? cartId : null)\r\n\r\nexport class CartService extends BaseService {\r\n\tprivate static instance: CartService\r\n\r\n\tstatic getInstance(): CartService {\r\n\t\tif (!CartService.instance) CartService.instance = new CartService()\r\n\t\treturn CartService.instance\r\n\t}\r\n\r\n\t/** Turns a GoCommerce cart into the shape the storefront's cart, drawer and checkout read. */\r\n\tprivate async present(cart: GcCart | null | undefined) {\r\n\t\tif (!cart) return {}\r\n\t\tstoreCartId(cart.id)\r\n\t\tconst [index, store] = await Promise.all([\r\n\t\t\t// Cart lines name a product by id only, so slug and image are filled in from the catalogue.\r\n\t\t\tresolveProductIndex(\r\n\t\t\t\t(cart.line_items || []).map((line) => line.product_id),\r\n\t\t\t\tthis.getFetch()\r\n\t\t\t),\r\n\t\t\treadStaticStore()\r\n\t\t])\r\n\t\treturn mapCart(cart, readCheckoutDetails(cart.id), index, store)\r\n\t}\r\n\r\n\t/** Opens a cart. The email is optional here and is the only field `POST /api/carts` accepts. */\r\n\tprivate async openCart(email?: string): Promise<GcCart> {\r\n\t\tconst res = await this.api<GcCart>('POST', '/api/carts', email ? { email } : {})\r\n\t\tstoreCartId(res.data?.id)\r\n\t\treturn res.data\r\n\t}\r\n\r\n\tprivate async readCart(cartId: string): Promise<GcCart | null> {\r\n\t\tlet cart: GcCart | null = null\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcCart>('GET', `/api/carts/${encodeURIComponent(cartId)}`)\r\n\t\t\tcart = res.data ?? null\r\n\t\t} catch {\r\n\t\t\t// An expired or unknown token is not an error the shopper can act on — it is an empty bag.\r\n\t\t\treturn null\r\n\t\t}\r\n\r\n\t\t// A checked-out cart keeps its lines forever — that is what makes it readable as a receipt on\r\n\t\t// the confirmation page. It is no longer a bag, though, so forget the token here: otherwise\r\n\t\t// the shopper lands back on the store with the thing they just bought still sitting in it, and\r\n\t\t// every attempt to change it is refused by the API.\r\n\t\tif (cart && cart.status && cart.status !== 'open') {\r\n\t\t\tforgetCartId()\r\n\t\t\treturn null\r\n\t\t}\r\n\t\treturn cart\r\n\t}\r\n\r\n\t/**\r\n\t * Is the cart behind this token gone for good — expired, unknown, or already checked out?\r\n\t *\r\n\t * Asked by re-reading the cart rather than by matching the failure's wording, because the API\r\n\t * reports several unrelated things the same way: a dead cart and an unknown payment code are both\r\n\t * `404 not_found`. The status is the fact; the message is prose.\r\n\t */\r\n\tasync cartIsSpent(cartId: string): Promise<boolean> {\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcCart>('GET', `/api/carts/${encodeURIComponent(cartId)}`)\r\n\t\t\treturn !res.data || (Boolean(res.data.status) && res.data.status !== 'open')\r\n\t\t} catch {\r\n\t\t\t// The token names nothing.\r\n\t\t\treturn true\r\n\t\t}\r\n\t}\r\n\r\n\t/** One line-item write against a cart that exists. Returns the cart the write left behind. */\r\n\tprivate async writeLine(\r\n\t\tcartId: string,\r\n\t\t{ variantId, qty, lineId, removing }: { variantId?: string | number; qty: number; lineId?: string | number | null; removing: boolean }\r\n\t): Promise<GcCart | null> {\r\n\t\tconst cart = encodeURIComponent(cartId)\r\n\r\n\t\tif (lineId) {\r\n\t\t\tconst line = encodeURIComponent(String(lineId))\r\n\t\t\tconst res = removing\r\n\t\t\t\t? await this.api<GcCart>('DELETE', `/api/carts/${cart}/line-items/${line}`)\r\n\t\t\t\t: await this.api<GcCart>('PATCH', `/api/carts/${cart}/line-items/${line}`, { quantity: qty })\r\n\t\t\treturn res.data ?? null\r\n\t\t}\r\n\r\n\t\t// Nothing was named to remove, so leave the cart exactly as it is.\r\n\t\tif (removing) return this.readCart(cartId)\r\n\r\n\t\tconst res = await this.api<GcCart>('POST', `/api/carts/${cart}/line-items`, {\r\n\t\t\tvariant_id: Number(variantId),\r\n\t\t\tquantity: qty\r\n\t\t})\r\n\t\treturn res.data ?? null\r\n\t}\r\n\r\n\tasync getCartByCartId(cartId: string) {\r\n\t\tconst id = usableId(cartId) || readStoredCartId()\r\n\t\tif (!id) return {}\r\n\t\treturn this.present(await this.readCart(id))\r\n\t}\r\n\r\n\tasync fetchCartData() {\r\n\t\tconst id = readStoredCartId()\r\n\t\tif (!id) return {}\r\n\t\treturn this.present(await this.readCart(id))\r\n\t}\r\n\r\n\tasync refereshCart() {\r\n\t\treturn this.fetchCartData()\r\n\t}\r\n\r\n\t/**\r\n\t * Add, change or remove a line.\r\n\t *\r\n\t * `qty` is the line's new quantity, not a delta — which is how the shared cart store calls it\r\n\t * (its stepper sends `qty ± 1`), and what `PATCH .../line-items/{lineId}` takes. A quantity of\r\n\t * zero removes the line, and so does the store's `REMOVE_LINE` sentinel.\r\n\t *\r\n\t * A cart token in this browser can be dead — expired, wiped server-side, or already checked out —\r\n\t * and the API then answers \"cart not found\", which is what the shopper was shown when they\r\n\t * clicked Add to bag. That is a token this storefront is holding, not anything they did, so a\r\n\t * dead one is dropped and the item is added to a fresh cart instead of reporting it.\r\n\t */\r\n\tasync addToCart({\r\n\t\tvariantId,\r\n\t\tqty,\r\n\t\tcartId,\r\n\t\tlineId\r\n\t}: {\r\n\t\tproductId?: string | number\r\n\t\tvariantId?: string | number\r\n\t\tqty: number\r\n\t\tcartId?: string | null\r\n\t\tlineId?: string | number | null\r\n\t}) {\r\n\t\tconst removing = qty === REMOVE_LINE || qty <= 0\r\n\t\tif (!removing && !variantId) throw new Error('A variant is required to add an item to the cart.')\r\n\r\n\t\tlet id = usableId(cartId) || readStoredCartId()\r\n\r\n\t\tif (id) {\r\n\t\t\tlet cart: GcCart | null = null\r\n\t\t\tlet spent = false\r\n\t\t\ttry {\r\n\t\t\t\tcart = await this.writeLine(id, { variantId, qty, lineId, removing })\r\n\t\t\t} catch (error) {\r\n\t\t\t\t// Only a dead cart is recovered from. A refusal the cart is alive for — a price that\r\n\t\t\t\t// moved, stock that ran out — is the shopper's to see, and must not be swallowed by\r\n\t\t\t\t// silently starting a new bag.\r\n\t\t\t\tif (!(await this.cartIsSpent(id))) throw error\r\n\t\t\t\tspent = true\r\n\t\t\t}\r\n\t\t\tif (!spent) return this.present(cart)\r\n\t\t\tforgetCartId()\r\n\t\t\tid = null\r\n\t\t}\r\n\r\n\t\t// No cart, or the one this browser held is gone. Removing a line from a cart that no longer\r\n\t\t// exists has already happened, as far as the shopper is concerned.\r\n\t\tif (removing) return {}\r\n\r\n\t\tconst opened = await this.openCart(readCheckoutDetails(null).email)\r\n\t\tif (!opened?.id) throw new Error('Could not open a cart on this store.')\r\n\t\t// `lineId` named a line in the cart that just died, so this is a plain add.\r\n\t\treturn this.present(await this.writeLine(opened.id, { variantId, qty, lineId: null, removing: false }))\r\n\t}\r\n\r\n\tasync updateCart({\r\n\t\tqty,\r\n\t\tcartId,\r\n\t\tlineId = null,\r\n\t\tproductId,\r\n\t\tvariantId\r\n\t}: {\r\n\t\tqty: number\r\n\t\tcartId?: string | null\r\n\t\tlineId?: string | number | null\r\n\t\tproductId?: string | number\r\n\t\tvariantId?: string | number\r\n\t\tisSelectedForCheckout?: boolean\r\n\t}) {\r\n\t\treturn this.addToCart({ productId, variantId, qty, cartId, lineId })\r\n\t}\r\n\r\n\tasync removeCart({ cartId, lineId = null }: { cartId?: string | null; lineId?: string | number | null }) {\r\n\t\treturn this.addToCart({ qty: REMOVE_LINE, cartId, lineId })\r\n\t}\r\n\r\n\t/**\r\n\t * The address step's write.\r\n\t *\r\n\t * GoCommerce has no endpoint that changes a cart after it is opened, and no address on it: these\r\n\t * fields are arguments to checkout. They are kept against this cart id in the browser and sent\r\n\t * when the order is placed — see checkout-details.ts. The email additionally seeds a cart that\r\n\t * has not been opened yet, which is the one moment GoCommerce does accept it.\r\n\t */\r\n\tasync updateCart2({\r\n\t\tcartId,\r\n\t\temail,\r\n\t\tphone,\r\n\t\tbillingAddress,\r\n\t\tshippingAddress,\r\n\t\tisBillingAddressSameAsShipping\r\n\t}: {\r\n\t\tstoreId?: string\r\n\t\tcartId?: string | null\r\n\t\temail?: string\r\n\t\tphone?: string\r\n\t\tcustomer_id?: string\r\n\t\tbillingAddress?: Record<string, any> | null\r\n\t\tshippingAddress?: Record<string, any> | null\r\n\t\tisBillingAddressSameAsShipping?: boolean\r\n\t}) {\r\n\t\t// Read before writing: a token that has expired or already checked out must not be the one the\r\n\t\t// address is filed under, or checkout would refuse it and send the shopper back to a step they\r\n\t\t// had already finished.\r\n\t\tlet id = usableId(cartId) || readStoredCartId()\r\n\t\tlet cart = id ? await this.readCart(id) : null\r\n\t\tif (!cart) {\r\n\t\t\tcart = await this.openCart(email)\r\n\t\t\tid = cart?.id ?? null\r\n\t\t}\r\n\t\tif (!id) throw new Error('Could not open a cart on this store.')\r\n\r\n\t\tconst name =\r\n\t\t\t[shippingAddress?.firstName, shippingAddress?.lastName].filter(Boolean).join(' ').trim() ||\r\n\t\t\t[billingAddress?.firstName, billingAddress?.lastName].filter(Boolean).join(' ').trim() ||\r\n\t\t\tundefined\r\n\r\n\t\twriteCheckoutDetails(id, {\r\n\t\t\t...(email ? { email } : {}),\r\n\t\t\t...(phone || shippingAddress?.phone ? { phone: phone || shippingAddress?.phone } : {}),\r\n\t\t\t...(name ? { name } : {}),\r\n\t\t\t...(shippingAddress ? { shippingAddress } : {}),\r\n\t\t\t...(billingAddress && !isBillingAddressSameAsShipping ? { billingAddress } : shippingAddress ? { billingAddress: shippingAddress } : {})\r\n\t\t})\r\n\r\n\t\treturn this.present(cart)\r\n\t}\r\n\r\n\t/** Nothing to reserve ahead of payment: `POST /api/checkout/{code}` is one transaction. */\r\n\tasync completeCart(cartId: string) {\r\n\t\treturn this.getCartByCartId(cartId)\r\n\t}\r\n\r\n\t/** Remembered so the payment step can re-select it; GoCommerce takes the code at checkout. */\r\n\tasync updateCartPaymentMethod({ cartId, paymentMethod }: { cartId?: string | null; paymentMethod?: string }) {\r\n\t\tconst id = usableId(cartId) || readStoredCartId()\r\n\t\tif (!id) return {}\r\n\t\tconst cart = await this.readCart(id)\r\n\t\tconst presented = (await this.present(cart)) as Record<string, unknown>\r\n\t\tif (presented && paymentMethod) presented.paymentMethod = paymentMethod\r\n\t\treturn presented\r\n\t}\r\n\r\n\t// GoCommerce has no discount engine, so there is no code to accept. Saying so beats a silent\r\n\t// no-op that leaves the shopper waiting for a discount that is never coming.\r\n\tasync applyCoupon(_params: { cartId?: string | null; couponCode?: string }): Promise<never> {\r\n\t\tthrow new Error('Discount codes are not available on this store.')\r\n\t}\r\n\r\n\tasync removeCoupon() {\r\n\t\treturn this.fetchCartData()\r\n\t}\r\n\r\n\t/** Shipping is priced by the store at checkout; there are no rates for a shopper to choose. */\r\n\tasync updateShippingRate({ cartId }: { cartId?: string | null; shippingRateId?: string }) {\r\n\t\treturn this.getCartByCartId(cartId || '')\r\n\t}\r\n}\r\n\r\nexport const cartService = CartService.getInstance()\r\n","// Checkout and payment methods.\r\n//\r\n// `POST /api/checkout/{code}` is the whole thing: it validates the cart, reserves inventory and\r\n// creates the order in one transaction, then starts payment outside it. There is no multi-step\r\n// checkout object to build up first — which is why the address step's answers are carried in\r\n// checkout-details.ts and spent here.\r\n\r\nimport { BaseService } from './base'\r\nimport { cartService } from './cart'\r\nimport { clearCheckoutDetails, readCheckoutDetails, rememberOrderToken } from './checkout-details'\r\nimport { mapOrder, toGoCommerceAddress } from './mappers'\r\nimport { resolveProductIndex } from './catalog'\r\nimport type { GcCheckoutMethods, GcCheckoutResult } from './types'\r\n\r\nconst CART_ID_KEY = 'cart_id'\r\n\r\nconst readStoredCartId = (): string | null => {\r\n\ttry {\r\n\t\treturn typeof window !== 'undefined' ? window.localStorage?.getItem(CART_ID_KEY) || null : null\r\n\t} catch {\r\n\t\treturn null\r\n\t}\r\n}\r\n\r\n/** A shopper-readable name for a payment code the store installed. */\r\nconst METHOD_NAMES: Record<string, string> = {\r\n\tcod: 'Cash on delivery',\r\n\tstripe: 'Card',\r\n\trazorpay: 'Razorpay',\r\n\tcashfree: 'Cashfree',\r\n\tpaypal: 'PayPal',\r\n\tphonepe: 'PhonePe',\r\n\tmanual: 'Manual payment'\r\n}\r\n\r\n/** The codes GoCommerce reported, so a checkout call can send back the exact spelling. */\r\nlet installedCodes: string[] = []\r\n\r\nconst goCommerceCode = (storefrontCode: string): string => {\r\n\tconst match = installedCodes.find((code) => code.toLowerCase() === storefrontCode.toLowerCase())\r\n\treturn match || storefrontCode.toLowerCase()\r\n}\r\n\r\nconst titleCase = (code: string) => code.charAt(0).toUpperCase() + code.slice(1)\r\n\r\nexport class PaymentMethodService extends BaseService {\r\n\tprivate static instance: PaymentMethodService\r\n\r\n\tstatic getInstance(): PaymentMethodService {\r\n\t\tif (!PaymentMethodService.instance) PaymentMethodService.instance = new PaymentMethodService()\r\n\t\treturn PaymentMethodService.instance\r\n\t}\r\n\r\n\t/**\r\n\t * What this store accepts, from `GET /api/checkout`.\r\n\t *\r\n\t * The storefront branches on an uppercase code (`COD`, `STRIPE`, …) while GoCommerce installs\r\n\t * them lowercase, so the code is uppercased for the UI and the original kept for the API call.\r\n\t */\r\n\tasync list(_params: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst res = await this.api<GcCheckoutMethods>('GET', '/api/checkout')\r\n\t\tconst codes = res.data?.payment_methods || []\r\n\t\tinstalledCodes = codes\r\n\t\tconst data = codes.map((code, index) => ({\r\n\t\t\tid: code,\r\n\t\t\tcode: code.toUpperCase(),\r\n\t\t\tname: METHOD_NAMES[code.toLowerCase()] || titleCase(code),\r\n\t\t\tdescription: '',\r\n\t\t\tactive: true,\r\n\t\t\tisTest: false,\r\n\t\t\timg: null,\r\n\t\t\trank: index,\r\n\t\t\tcurrency: res.data?.currency || null\r\n\t\t}))\r\n\t\treturn { data, count: data.length, pageSize: data.length, noOfPage: data.length ? 1 : 0, page: 1 }\r\n\t}\r\n}\r\n\r\nexport const paymentMethodService = PaymentMethodService.getInstance()\r\n\r\nexport class CheckoutService extends BaseService {\r\n\tprivate static instance: CheckoutService\r\n\r\n\tstatic getInstance(): CheckoutService {\r\n\t\tif (!CheckoutService.instance) CheckoutService.instance = new CheckoutService()\r\n\t\treturn CheckoutService.instance\r\n\t}\r\n\r\n\t/**\r\n\t * Places the order.\r\n\t *\r\n\t * Everything the API requires and the cart cannot hold — email, name, phone, delivery address —\r\n\t * comes from what the address step recorded against this cart. Missing pieces are named in the\r\n\t * error rather than sent as blanks, because GoCommerce's own validation message (\"address.line1\r\n\t * is required\") does not tell a shopper which screen to go back to.\r\n\t */\r\n\tprivate async place(storefrontCode: string, { cartId, origin, returnUrl }: { cartId?: string | null; origin?: string; returnUrl?: string }) {\r\n\t\tconst id = cartId && cartId !== 'undefined' ? cartId : readStoredCartId()\r\n\t\tif (!id) throw new Error('There is no cart to check out.')\r\n\r\n\t\tconst details = readCheckoutDetails(id)\r\n\t\tconst address = toGoCommerceAddress(details.shippingAddress, details.phone)\r\n\r\n\t\tif (!details.email) throw new Error('An email address is required to place this order — add one at the address step.')\r\n\t\tif (!address) throw new Error('A complete delivery address is required to place this order — add one at the address step.')\r\n\r\n\t\tconst code = goCommerceCode(storefrontCode)\r\n\t\tlet res\r\n\t\ttry {\r\n\t\t\tres = await this.api<GcCheckoutResult>(\r\n\t\t\t\t'POST',\r\n\t\t\t\t`/api/checkout/${encodeURIComponent(code)}`,\r\n\t\t\t\t{\r\n\t\t\t\t\tcart_id: id,\r\n\t\t\t\t\temail: details.email,\r\n\t\t\t\t\t...(details.name ? { name: details.name } : {}),\r\n\t\t\t\t\t...(details.phone ? { phone: details.phone } : {}),\r\n\t\t\t\t\taddress,\r\n\t\t\t\t\t...(returnUrl || origin ? { return_url: returnUrl || `${origin}/checkout/process` } : {})\r\n\t\t\t\t},\r\n\t\t\t\t// A double-submitted Place Order must not become two orders and two inventory holds.\r\n\t\t\t\t{ 'Idempotency-Key': `${id}:${code}` }\r\n\t\t\t)\r\n\t\t} catch (error) {\r\n\t\t\t// A dead cart and an unknown payment code are both reported as `404 not_found` here, so the\r\n\t\t\t// cart is re-read rather than the message matched. \"cart not found\" at the last step tells a\r\n\t\t\t// shopper nothing they can act on; naming the expiry, and what to do about it, does.\r\n\t\t\tif (await cartService.cartIsSpent(id)) {\r\n\t\t\t\tthrow new Error('This cart is no longer available — it has expired or was already checked out. Add the items to a new bag and try again.')\r\n\t\t\t}\r\n\t\t\tthrow error\r\n\t\t}\r\n\r\n\t\tconst order = res.data?.order\r\n\t\tconst payment = res.data?.payment\r\n\t\trememberOrderToken(order?.number, order?.access_token)\r\n\t\t// The cart is converted now; its address is spent and must not seed the next one.\r\n\t\tclearCheckoutDetails(id)\r\n\r\n\t\tconst index = await resolveProductIndex(\r\n\t\t\t(order?.line_items || []).map((line) => line.product_id),\r\n\t\t\tthis.getFetch()\r\n\t\t)\r\n\r\n\t\treturn {\r\n\t\t\t...(mapOrder(order, index) ?? {}),\r\n\t\t\t// The order number, under every name the storefront's payment step reads it by.\r\n\t\t\torder_no: order?.number,\r\n\t\t\torderNo: order?.number,\r\n\t\t\tcode: order?.number,\r\n\t\t\tpayment: payment ?? null,\r\n\t\t\tpaymentKind: payment?.kind ?? 'none',\r\n\t\t\t// A gateway's own fields (a Razorpay order id, a Stripe client secret, a redirect url)\r\n\t\t\t// ride on `client_data`; spreading them is what lets the storefront's per-gateway\r\n\t\t\t// branches find what they look for without this connector naming each gateway.\r\n\t\t\t...(payment?.client_data ?? {})\r\n\t\t}\r\n\t}\r\n\r\n\tasync checkoutCOD({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('cod', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutPOS({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('pos', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutRazorpay({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('razorpay', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutStripe({ cartId, origin }: { cartId?: string | null; origin?: string }) {\r\n\t\treturn this.place('stripe', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutCashfree({ cartId, origin }: { cartId?: string | null; email?: string; origin?: string }) {\r\n\t\treturn this.place('cashfree', { cartId, origin })\r\n\t}\r\n\r\n\tasync checkoutPaypal({ cartId, origin, return_url }: { cartId?: string | null; origin?: string; return_url?: string }) {\r\n\t\treturn this.place('paypal', { cartId, origin, returnUrl: return_url })\r\n\t}\r\n\r\n\tasync checkoutPhonepe({ cartId, origin }: { cartId?: string | null; email?: string; phone?: string; origin?: string }) {\r\n\t\treturn this.place('phonepe', { cartId, origin })\r\n\t}\r\n\r\n\tasync createAffirmPayOrder({\r\n\t\tcartId,\r\n\t\torigin\r\n\t}: {\r\n\t\tcartId?: string | null\r\n\t\torigin?: string\r\n\t\taddressId?: string\r\n\t\tstoreId?: string\r\n\t\tpaymentMethodId?: string\r\n\t}) {\r\n\t\treturn this.place('affirm', { cartId, origin })\r\n\t}\r\n\r\n\t// GoCommerce reconciles a payment through `POST /api/checkout/{code}/webhook`, which the gateway\r\n\t// calls server to server. There is nothing for the browser to capture afterwards, so these keep\r\n\t// the storefront's redirect moving with the order number it already has rather than pretending\r\n\t// to perform a capture that this API does not offer.\r\n\tprivate settled(orderNo?: string) {\r\n\t\treturn { order_no: orderNo || '', orderNo: orderNo || '', captured: false }\r\n\t}\r\n\r\n\tasync captureRazorpayPayment({ razorpay_order_id }: { razorpay_order_id?: string; razorpay_payment_id?: string }) {\r\n\t\treturn this.settled(razorpay_order_id)\r\n\t}\r\n\r\n\tasync capturePhonepePayment({ phonepe_order_id }: { phonepe_order_id?: string; phonepe_payment_id?: string }) {\r\n\t\treturn this.settled(phonepe_order_id)\r\n\t}\r\n\r\n\tasync captureCashfreePayment({ order_no }: { order_no?: string }) {\r\n\t\treturn this.settled(order_no)\r\n\t}\r\n\r\n\tasync checkoutStripeCapture({ order_no }: { order_no?: string; pg?: string; payment_session_id?: string; storeId?: string }) {\r\n\t\treturn this.settled(order_no)\r\n\t}\r\n\r\n\tasync confirmAffirmOrder({ orderId }: { affirmToken?: string; orderId?: string; storeId?: string; origin?: string }) {\r\n\t\treturn this.settled(orderId)\r\n\t}\r\n\r\n\tasync cancelAffirmOrder({ orderId }: { orderId?: string; storeId?: string; origin?: string }): Promise<never> {\r\n\t\tthrow new Error(`Cancelling order ${orderId || ''} is not available on this store.`)\r\n\t}\r\n\r\n\t/**\r\n\t * GoCommerce prices shipping when it creates the order — there is no rate list for a shopper to\r\n\t * choose from. An empty list is the accurate answer, and the payment step renders no rate picker\r\n\t * for it rather than an empty one.\r\n\t */\r\n\tasync getShippingRates(_params: { cartId?: string | null }) {\r\n\t\treturn { message: 'This store does not offer selectable shipping rates', success: true, error: null, data: [] }\r\n\t}\r\n}\r\n\r\nexport const checkoutService = CheckoutService.getInstance()\r\n","// Orders.\r\n//\r\n// Guest checkout is permanent in GoCommerce: there is no account, and the order's access token —\r\n// returned once at checkout — is the credential that reads it back. This browser holds those\r\n// tokens (checkout-details.ts), which is what makes \"my orders\" work at all here.\r\n//\r\n// The confirmation page is the exception, because it renders on the server, where no token exists.\r\n// It arrives with `cart_id` in the url, and a converted cart stays readable by its own token, so\r\n// the order is reconstructed from the cart that became it. The number comes from the url; the items\r\n// and totals come from the cart — all of it the shopper's own data, reached with the shopper's own\r\n// credential.\r\n\r\nimport { BaseService } from './base'\r\nimport { resolveProductIndex } from './catalog'\r\nimport { readOrderNumbers, readOrderToken } from './checkout-details'\r\nimport { PAGE_SIZE, absoluteMedia, emptyPage, mapOrder, mapProduct, paginated } from './mappers'\r\nimport { fromMoney } from './money'\r\nimport type { GcCart, GcOrder } from './types'\r\n\r\nconst usable = (value?: string | null) => (value && value !== 'undefined' && value !== 'null' ? value : null)\r\n\r\nexport class OrderService extends BaseService {\r\n\tprivate static instance: OrderService\r\n\r\n\tstatic getInstance(): OrderService {\r\n\t\tif (!OrderService.instance) OrderService.instance = new OrderService()\r\n\t\treturn OrderService.instance\r\n\t}\r\n\r\n\tprivate async readOrder(orderNumber: string, token: string): Promise<GcOrder | null> {\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcOrder>('GET', `/api/orders/${encodeURIComponent(orderNumber)}?token=${encodeURIComponent(token)}`)\r\n\t\t\treturn res.data ?? null\r\n\t\t} catch {\r\n\t\t\t// A wrong or missing token is reported as not found, so this cannot be used to discover\r\n\t\t\t// which order numbers exist. Nothing to show is the correct outcome either way.\r\n\t\t\treturn null\r\n\t\t}\r\n\t}\r\n\r\n\tprivate async present(order: GcOrder | null) {\r\n\t\tif (!order) return null\r\n\t\tconst index = await resolveProductIndex(\r\n\t\t\t(order.line_items || []).map((line) => line.product_id),\r\n\t\t\tthis.getFetch()\r\n\t\t)\r\n\t\treturn mapOrder(order, index)\r\n\t}\r\n\r\n\t/**\r\n\t * The confirmation view, rebuilt from the cart that became the order.\r\n\t *\r\n\t * Everything a receipt needs is on the converted cart except the address, which was never stored\r\n\t * on it — so that block is simply absent rather than invented.\r\n\t */\r\n\tprivate async orderFromCart(cartId: string, orderNumber: string) {\r\n\t\tlet cart: GcCart | null = null\r\n\t\ttry {\r\n\t\t\tconst res = await this.api<GcCart>('GET', `/api/carts/${encodeURIComponent(cartId)}`)\r\n\t\t\tcart = res.data ?? null\r\n\t\t} catch {\r\n\t\t\treturn null\r\n\t\t}\r\n\t\tif (!cart) return null\r\n\r\n\t\tconst lines = cart.line_items || []\r\n\t\tconst index = await resolveProductIndex(\r\n\t\t\tlines.map((line) => line.product_id),\r\n\t\t\tthis.getFetch()\r\n\t\t)\r\n\t\tconst subtotal = fromMoney(cart.subtotal)\r\n\r\n\t\treturn {\r\n\t\t\tid: null,\r\n\t\t\torderNo: orderNumber,\r\n\t\t\torder_no: orderNumber,\r\n\t\t\tparentOrderNo: orderNumber,\r\n\t\t\tstatus: cart.status === 'converted' ? 'confirmed' : 'pending',\r\n\t\t\tpaymentStatus: 'pending',\r\n\t\t\tpaymentMethod: null,\r\n\t\t\tcreatedAt: cart.updated_at || cart.created_at || null,\r\n\t\t\tupdatedAt: cart.updated_at || null,\r\n\t\t\tuserEmail: cart.email || '',\r\n\t\t\tphone: '',\r\n\t\t\tsubtotal,\r\n\t\t\tshippingCharges: 0,\r\n\t\t\tdiscount: 0,\r\n\t\t\ttotal: subtotal,\r\n\t\t\tcurrencyCode: cart.currency,\r\n\t\t\tshippingRate: null,\r\n\t\t\tfulfillments: [],\r\n\t\t\tshippingAddress: null,\r\n\t\t\tbillingAddress: null,\r\n\t\t\tlineItems: lines.map((line) => {\r\n\t\t\t\tconst product = line.product_id == null ? undefined : index.get(line.product_id)\r\n\t\t\t\tconst mapped = product ? mapProduct(product) : null\r\n\t\t\t\tconst variant = product?.variants?.find((v) => v.id === line.variant_id)\r\n\t\t\t\treturn {\r\n\t\t\t\t\tid: line.id,\r\n\t\t\t\t\tproductId: line.product_id,\r\n\t\t\t\t\tvariantId: line.variant_id,\r\n\t\t\t\t\ttitle: line.title || mapped?.title || '',\r\n\t\t\t\t\tvariantTitle: line.variant_label || line.sku || '',\r\n\t\t\t\t\tslug: mapped?.slug || '',\r\n\t\t\t\t\tsku: line.sku || '',\r\n\t\t\t\t\tthumbnail: absoluteMedia(variant?.image?.url) || mapped?.thumbnail || null,\r\n\t\t\t\t\tqty: line.quantity,\r\n\t\t\t\t\tprice: fromMoney(line.unit_price),\r\n\t\t\t\t\tsubtotal: fromMoney(line.total),\r\n\t\t\t\t\ttotal: fromMoney(line.total)\r\n\t\t\t\t}\r\n\t\t\t})\r\n\t\t}\r\n\t}\r\n\r\n\t/**\r\n\t * The shopper's orders. Without an account there is no server-side list to ask for, so this is\r\n\t * every order placed from this browser, newest first — which is exactly what it can know.\r\n\t */\r\n\tasync list({ page = 1 }: { page?: number; q?: string; sort?: string } = {}) {\r\n\t\tconst numbers = readOrderNumbers().reverse()\r\n\t\tif (!numbers.length) return emptyPage(page)\r\n\t\tconst start = (page - 1) * PAGE_SIZE\r\n\t\tconst window = numbers.slice(start, start + PAGE_SIZE)\r\n\t\tconst orders = await Promise.all(\r\n\t\t\twindow.map(async (number) => {\r\n\t\t\t\tconst token = readOrderToken(number)\r\n\t\t\t\treturn token ? this.present(await this.readOrder(number, token)) : null\r\n\t\t\t})\r\n\t\t)\r\n\t\treturn paginated(orders.filter(Boolean), numbers.length, page)\r\n\t}\r\n\r\n\t/** What the confirmation page loads with, server-side, straight after checkout. */\r\n\tasync listOrdersByParent({ orderNo, cartId }: { orderNo?: string | null; cartId?: string | null }) {\r\n\t\tconst number = usable(orderNo)\r\n\t\tif (!number) return emptyPage()\r\n\r\n\t\tconst token = readOrderToken(number)\r\n\t\tif (token) {\r\n\t\t\tconst order = await this.present(await this.readOrder(number, token))\r\n\t\t\tif (order) return paginated([order], 1, 1, 1)\r\n\t\t}\r\n\r\n\t\tconst cart = usable(cartId)\r\n\t\tif (cart) {\r\n\t\t\tconst reconstructed = await this.orderFromCart(cart, number)\r\n\t\t\tif (reconstructed) return paginated([reconstructed], 1, 1, 1)\r\n\t\t}\r\n\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\tasync getOrder(orderNo: string) {\r\n\t\tconst number = usable(orderNo)\r\n\t\tif (!number) return {}\r\n\t\tconst token = readOrderToken(number)\r\n\t\tif (!token) return {}\r\n\t\treturn (await this.present(await this.readOrder(number, token))) ?? {}\r\n\t}\r\n\r\n\tasync fetchOrder(id: string) {\r\n\t\treturn this.getOrder(id)\r\n\t}\r\n\r\n\tasync fetchTrackOrder(id: string) {\r\n\t\treturn this.listOrdersByParent({ orderNo: id, cartId: null })\r\n\t}\r\n\r\n\tasync paySuccessPageHit(orderId: string) {\r\n\t\treturn this.getOrder(orderId)\r\n\t}\r\n\r\n\t// GoCommerce has no email+OTP lookup: an order is reached by its number and access token.\r\n\tasync getOrderByEmailAndOTP(_params: { email?: string; otp?: string }) {\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\t// No server-side order feed exists to reorder from; `list()` is the shopper's own history.\r\n\tasync buyAgain() {\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\tasync listPublic() {\r\n\t\treturn emptyPage()\r\n\t}\r\n\r\n\tasync submitReview(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Product reviews are not available on this store.')\r\n\t}\r\n\r\n\t// Checkout runs through CheckoutService here; these Litekart-era entry points have no equivalent\r\n\t// and must not fall back to an API a GoCommerce store does not run.\r\n\tasync codCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutCOD() on GoCommerce.')\r\n\t}\r\n\r\n\tasync razorpayCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutRazorpay() on GoCommerce.')\r\n\t}\r\n\r\n\tasync stripeCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutStripe() on GoCommerce.')\r\n\t}\r\n\r\n\tasync cashfreeCheckout(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.checkoutCashfree() on GoCommerce.')\r\n\t}\r\n\r\n\tasync razorCapture(_params: unknown): Promise<never> {\r\n\t\tthrow new Error('Use checkoutService.captureRazorpayPayment() on GoCommerce.')\r\n\t}\r\n}\r\n\r\nexport const orderService = OrderService.getInstance()\r\n","// Store identity and the settings that hang off it.\n//\n// GoCommerce is a commerce engine, not a CMS: it has no store record, no menus, no country list and\n// no plugin toggles. All of that is the storefront's own configuration, registered through\n// static-store.ts (default-store.json merged under the kitcommerce.config.ts default export), and\n// these services read it from there rather than asking an API that has no such endpoint.\n\nimport { BaseService } from './base'\nimport { PAGE_SIZE, paginated } from './mappers'\nimport { readStaticStore, readStaticStoreDetails } from './static-store'\n\nconst listOf = <T>(items: T[]) => paginated(items, items.length, 1, items.length || PAGE_SIZE)\n\nexport class StoreService extends BaseService {\n\tprivate static instance: StoreService\n\n\tstatic getInstance(): StoreService {\n\t\tif (!StoreService.instance) StoreService.instance = new StoreService()\n\t\treturn StoreService.instance\n\t}\n\n\tasync getStoreByIdOrDomain(_params: { storeId?: string; domain?: string } = {}) {\n\t\tconst store = await readStaticStoreDetails()\n\t\tif (!store) {\n\t\t\tthrow new Error('No store configuration is registered — check kitcommerce.config.ts (see docs/GOCOMMERCE.md).')\n\t\t}\n\t\treturn store\n\t}\n\n\t/** The settings store asks for the record by id; there is only ever the configured one. */\n\tasync getStore(_storeId?: string) {\n\t\treturn this.getStoreByIdOrDomain({})\n\t}\n}\n\nexport const storeService = StoreService.getInstance()\n\nexport class MenuService extends BaseService {\n\tprivate static instance: MenuService\n\n\tstatic getInstance(): MenuService {\n\t\tif (!MenuService.instance) MenuService.instance = new MenuService()\n\t\treturn MenuService.instance\n\t}\n\n\t/** The nav reads `response.data` and filters it on `menuId`, the way the Litekart API served it. */\n\tasync list() {\n\t\tconst store = await readStaticStore()\n\t\treturn { data: (store?.menu ?? []) as unknown[] }\n\t}\n}\n\nexport const menuService = MenuService.getInstance()\n\nexport class CountryService extends BaseService {\n\tprivate static instance: CountryService\n\n\tstatic getInstance(): CountryService {\n\t\tif (!CountryService.instance) CountryService.instance = new CountryService()\n\t\treturn CountryService.instance\n\t}\n\n\t/** The address form's country dropdown. Empty here means a shopper cannot enter an address. */\n\tasync list() {\n\t\tconst store = await readStaticStore()\n\t\treturn listOf((store?.countries ?? []) as unknown[])\n\t}\n}\n\nexport const countryService = CountryService.getInstance()\n\nexport class StateService extends BaseService {\n\tprivate static instance: StateService\n\n\tstatic getInstance(): StateService {\n\t\tif (!StateService.instance) StateService.instance = new StateService()\n\t\treturn StateService.instance\n\t}\n\n\t// No state list ships with the store record, and GoCommerce takes the state as free text.\n\tasync list() {\n\t\treturn listOf([])\n\t}\n}\n\nexport const stateService = StateService.getInstance()\n\nexport class CurrencyService extends BaseService {\n\tprivate static instance: CurrencyService\n\n\tstatic getInstance(): CurrencyService {\n\t\tif (!CurrencyService.instance) CurrencyService.instance = new CurrencyService()\n\t\treturn CurrencyService.instance\n\t}\n\n\t/** One currency: GoCommerce prices a store in the currency its catalogue is recorded in. */\n\tasync listCurrencies() {\n\t\tconst store = await readStaticStore()\n\t\treturn listOf(store?.currency ? [store.currency] : [])\n\t}\n}\n\nexport const currencyService = CurrencyService.getInstance()\n\nexport class RegionService extends BaseService {\n\tprivate static instance: RegionService\n\n\tstatic getInstance(): RegionService {\n\t\tif (!RegionService.instance) RegionService.instance = new RegionService()\n\t\treturn RegionService.instance\n\t}\n\n\t// GoCommerce has no regions; one store, one currency, one price list.\n\tasync getRegionByRegionId(_id: string) {\n\t\treturn {}\n\t}\n}\n\nexport const regionService = RegionService.getInstance()\n\nexport class PluginService extends BaseService {\n\tprivate static instance: PluginService\n\n\tstatic getInstance(): PluginService {\n\t\tif (!PluginService.instance) PluginService.instance = new PluginService()\n\t\treturn PluginService.instance\n\t}\n\n\tasync list(_params: { page?: number; q?: string; sort?: string } = {}) {\n\t\tconst store = await readStaticStore()\n\t\treturn listOf((store?.plugins ?? []) as unknown[])\n\t}\n}\n\nexport const pluginService = PluginService.getInstance()\nexport const pluginsService = pluginService\n\nexport class SettingService extends BaseService {\n\tprivate static instance: SettingService\n\n\tstatic getInstance(): SettingService {\n\t\tif (!SettingService.instance) SettingService.instance = new SettingService()\n\t\treturn SettingService.instance\n\t}\n\n\tasync fetchSetting() {\n\t\tconst store = await readStaticStore()\n\t\treturn store ? [store] : []\n\t}\n\n\t// Settings are the storefront's own configuration; a storefront must not write them back.\n\tasync saveSettings(_setting: unknown): Promise<never> {\n\t\tthrow new Error('Store settings are configured in kitcommerce.config.ts, not from the storefront.')\n\t}\n\n\tasync updateSettings(_id: string, _setting: unknown): Promise<never> {\n\t\tthrow new Error('Store settings are configured in kitcommerce.config.ts, not from the storefront.')\n\t}\n}\n\nexport const settingService = SettingService.getInstance()\nexport const settingsService = settingService\n\nexport class InitService extends BaseService {\n\tprivate static instance: InitService\n\n\tstatic getInstance(): InitService {\n\t\tif (!InitService.instance) InitService.instance = new InitService()\n\t\treturn InitService.instance\n\t}\n\n\tasync fetchInit() {\n\t\tconst store = await readStaticStore()\n\t\treturn store ? [store] : []\n\t}\n}\n\nexport const initService = InitService.getInstance()\n\nexport class HomeService extends BaseService {\n\tprivate static instance: HomeService\n\n\tstatic getInstance(): HomeService {\n\t\tif (!HomeService.instance) HomeService.instance = new HomeService()\n\t\treturn HomeService.instance\n\t}\n\n\t// The homepage is composed from the storefront's own blocks; GoCommerce stores no page layouts.\n\tasync getHome() {\n\t\treturn [] as unknown[]\n\t}\n}\n\nexport const homeService = HomeService.getInstance()\n\nexport class PopularSearchService extends BaseService {\n\tprivate static instance: PopularSearchService\n\n\tstatic getInstance(): PopularSearchService {\n\t\tif (!PopularSearchService.instance) PopularSearchService.instance = new PopularSearchService()\n\t\treturn PopularSearchService.instance\n\t}\n\n\t// GoCommerce records no search analytics, so there are no popular searches to report.\n\tasync listPopularSearch(_params: { page?: number; q?: string; sort?: string } = {}) {\n\t\treturn listOf([])\n\t}\n}\n\nexport const popularSearchService = PopularSearchService.getInstance()\n\nexport class PopularityService extends BaseService {\n\tprivate static instance: PopularityService\n\n\tstatic getInstance(): PopularityService {\n\t\tif (!PopularityService.instance) PopularityService.instance = new PopularityService()\n\t\treturn PopularityService.instance\n\t}\n\n\t/** Nothing to record against: a view counter is not part of this API. Accepted and dropped. */\n\tasync updatePopularity(_params: { product_id?: string; sid?: string } = {}) {\n\t\treturn { success: true }\n\t}\n}\n\nexport const popularityService = PopularityService.getInstance()\n","// What GoCommerce deliberately does not have.\n//\n// It is a commerce engine: catalogue, cart, checkout, orders. There are no shopper accounts (guest\n// checkout is permanent by design), no CMS, no reviews, no wishlist, no marketplace vendors.\n//\n// The rule these follow is the one rest-guard.ts states: a collection resolves empty, because an\n// empty list is a legitimate state a page can render; a single record and every write throw, because\n// a blank detail page reads as broken and a silent success would tell the shopper their review,\n// enquiry or upload was saved when nothing left the browser.\n\nimport { BaseService } from './base'\nimport { PAGE_SIZE, emptyPage, paginated } from './mappers'\nimport { clearPhantomSession, findAddress, listAddresses, patchAddress, putAddress, removeAddress } from './address-book'\n\nconst unavailable = (what: string) => new Error(`${what} is not available on this store.`)\n\nconst singleton = <T>(Ctor: new () => T) => {\n\tlet instance: T | undefined\n\treturn () => (instance ??= new Ctor())\n}\n\n// --- Accounts -----------------------------------------------------------------------------------\n// Guest checkout is permanent in GoCommerce: a shopper needs a cart token and an email, never an\n// account. The API's only credentials are the admin ones, which a storefront must never hold.\n\nconst NO_ACCOUNTS = 'Accounts are not available on this store — checkout does not need one'\n\nexport class UserService extends BaseService {\n\tstatic getInstance = singleton(UserService)\n\n\t/** No session to report. `null` is what the header and guards check for. */\n\tasync getMe() {\n\t\treturn null\n\t}\n\n\tasync getUser(_id: string) {\n\t\treturn null\n\t}\n\n\tasync login(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync signup(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync joinAsVendor(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Vendor signup')\n\t}\n\n\tasync forgotPassword(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync resetPassword(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync changePassword(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync getOtp(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync verifyOtp(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync updateProfile(_params: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\tasync checkEmail(_email: string) {\n\t\t// Nothing to collide with, so every address is free to use at checkout.\n\t\treturn { exists: false }\n\t}\n\n\tasync deleteUser(_id: string): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n\n\t/**\n\t * Clears the session this storefront thinks it has.\n\t *\n\t * There is no session on GoCommerce to end, so it would be easy to make this a no-op — and that\n\t * is a trap. The shared user store decides who is signed in by reading the `connect.sid` and `me`\n\t * cookies straight from `document.cookie`, not by asking a service. A pair left behind by running\n\t * this storefront against a backend that does have accounts therefore makes GoCommerce look\n\t * signed-in, which sends the checkout down the saved-address path instead of the guest one. The\n\t * checkout page already knows to call `logout()` and retry when that happens — so this has to\n\t * actually clear them, or that recovery does nothing.\n\t */\n\tasync logout() {\n\t\tclearPhantomSession()\n\t\treturn { success: true }\n\t}\n}\n\nexport const userService = UserService.getInstance()\n\nexport class AuthService extends UserService {\n\tstatic getInstance = singleton(AuthService)\n\n\tasync verifyEmail(_email: string, _token: string): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}, so there is no address to verify.`)\n\t}\n\n\tasync joinAsAdmin(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Admin signup')\n\t}\n}\n\nexport const authService = AuthService.getInstance()\n\nexport class ProfileService extends BaseService {\n\tstatic getInstance = singleton(ProfileService)\n\n\tasync getOne() {\n\t\treturn null\n\t}\n\n\tasync save(_profile: unknown): Promise<never> {\n\t\tthrow new Error(`${NO_ACCOUNTS}.`)\n\t}\n}\n\nexport const profileService = ProfileService.getInstance()\n\n/**\n * The saved-address book. GoCommerce has none, so it is kept in this browser — see\n * ./address-book.ts for why refusing the write is not an option.\n */\nexport class AddressService extends BaseService {\n\tstatic getInstance = singleton(AddressService)\n\n\tasync list(params: { page?: number } = {}) {\n\t\tconst addresses = listAddresses()\n\t\tconst page = Math.max(1, Number(params.page || 1) || 1)\n\t\tconst start = (page - 1) * PAGE_SIZE\n\t\treturn paginated(addresses.slice(start, start + PAGE_SIZE), addresses.length, page)\n\t}\n\n\tasync fetchAddress(id: string) {\n\t\tconst address = findAddress(id)\n\t\tif (!address) throw new Error('That address is no longer saved on this device.')\n\t\treturn address\n\t}\n\n\tasync saveAddress(address: Record<string, unknown>) {\n\t\treturn putAddress(address)\n\t}\n\n\tasync editAddress(id: string, address: Record<string, unknown>) {\n\t\tconst saved = patchAddress(id, address)\n\t\tif (!saved) throw new Error('That address is no longer saved on this device.')\n\t\treturn saved\n\t}\n\n\tasync deleteAddress(id: string) {\n\t\tremoveAddress(id)\n\t}\n}\n\nexport const addressService = AddressService.getInstance()\n\n// --- Merchandising extras -----------------------------------------------------------------------\n\nexport class WishlistService extends BaseService {\n\tstatic getInstance = singleton(WishlistService)\n\n\tasync fetchWishlist(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync checkWishlist(_params: unknown = {}) {\n\t\treturn { data: false }\n\t}\n\n\t/** The product grid asks about many ids at once; nothing is on a list that cannot exist. */\n\tasync checkWishlistInBulk(_ids: unknown) {\n\t\treturn { data: [] }\n\t}\n\n\tasync toggleWishlist(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Wishlists')\n\t}\n}\n\nexport const wishlistService = WishlistService.getInstance()\n\nexport class CouponService extends BaseService {\n\tstatic getInstance = singleton(CouponService)\n\n\t// No discount engine, so the payment step renders no coupon box rather than an empty one.\n\tasync listCoupons(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync searchCoupons(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getCoupon(_id: string): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n\n\tasync createCoupon(_coupon: unknown): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n\n\tasync patchCoupon(_id: string, _coupon: unknown): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n\n\tasync deleteCoupon(_id: string): Promise<never> {\n\t\tthrow unavailable('Discount codes')\n\t}\n}\n\nexport const couponService = CouponService.getInstance()\n\nexport class DealService extends BaseService {\n\tstatic getInstance = singleton(DealService)\n\n\tasync fetchDeals() {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const dealService = DealService.getInstance()\n\nexport class ReviewService extends BaseService {\n\tstatic getInstance = singleton(ReviewService)\n\n\tasync fetchReviews(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync allReviews(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync fetchProducrReviews(_productId: string) {\n\t\treturn emptyPage()\n\t}\n\n\tasync saveReview(_review: unknown): Promise<never> {\n\t\tthrow unavailable('Product reviews')\n\t}\n}\n\nexport const reviewService = ReviewService.getInstance()\n\n// --- Content ------------------------------------------------------------------------------------\n// GoCommerce stores no pages, posts, banners or galleries. This storefront's own content lives in\n// the repo; anything asked for by slug here genuinely does not exist.\n\nexport class PageService extends BaseService {\n\tstatic getInstance = singleton(PageService)\n\n\tasync list(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync listLatestPages(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\t/**\n\t * Every caller asks for a fixed, optional slug — `products`, `about-us`, `privacy-policy` — to\n\t * dress a page the storefront already renders. So an absent page is the normal state, not a dead\n\t * link: answer empty and let the route show its own content, rather than log a failure on every\n\t * request for something that was never required.\n\t */\n\tasync getOne(_id: string) {\n\t\treturn {}\n\t}\n}\n\nexport const pageService = PageService.getInstance()\n\nexport class BlogService extends BaseService {\n\tstatic getInstance = singleton(BlogService)\n\n\tasync list(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getOne(id: string): Promise<never> {\n\t\tthrow new Error(`The post \"${id}\" does not exist on this store.`)\n\t}\n}\n\nexport const blogService = BlogService.getInstance()\n\nexport class BannerService extends BaseService {\n\tstatic getInstance = singleton(BannerService)\n\n\tasync list() {\n\t\treturn emptyPage()\n\t}\n\n\tasync fetchBannersGroup() {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const bannerService = BannerService.getInstance()\n\nexport class GalleryService extends BaseService {\n\tstatic getInstance = singleton(GalleryService)\n\n\tasync fetchGallery() {\n\t\treturn [] as unknown[]\n\t}\n}\n\nexport const galleryService = GalleryService.getInstance()\n\nexport class ReelsService extends BaseService {\n\tstatic getInstance = singleton(ReelsService)\n\n\tasync list() {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const reelsService = ReelsService.getInstance()\n\nexport class FaqService extends BaseService {\n\tstatic getInstance = singleton(FaqService)\n\n\tasync listFaqs(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const faqService = FaqService.getInstance()\n\nexport class FeedbackService extends BaseService {\n\tstatic getInstance = singleton(FeedbackService)\n\n\tasync listFeedbacks(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const feedbackService = FeedbackService.getInstance()\n\n// --- Inbound messages ---------------------------------------------------------------------------\n// Each of these hands the shopper's words to a backend that has no inbox for them. A resolved\n// promise would render \"thanks, we'll be in touch\" over a message nobody will ever read.\n\nexport class ContactService extends BaseService {\n\tstatic getInstance = singleton(ContactService)\n\n\tasync submitContactUsForm(_params: unknown): Promise<never> {\n\t\tthrow unavailable('The contact form')\n\t}\n}\n\nexport const contactService = ContactService.getInstance()\n\nexport class EnquiryService extends BaseService {\n\tstatic getInstance = singleton(EnquiryService)\n\n\tasync create(_params: unknown): Promise<never> {\n\t\tthrow unavailable('Product enquiries')\n\t}\n}\n\nexport const enquiryService = EnquiryService.getInstance()\n\nexport class ChatService extends BaseService {\n\tstatic getInstance = singleton(ChatService)\n\n\tasync list() {\n\t\treturn [] as Record<string, unknown>[]\n\t}\n\n\tasync chats() {\n\t\treturn [] as Record<string, unknown>[]\n\t}\n\n\tasync save(_message: unknown): Promise<never> {\n\t\tthrow unavailable('Messaging')\n\t}\n}\n\nexport const chatService = ChatService.getInstance()\n\nexport class UploadService extends BaseService {\n\tstatic getInstance = singleton(UploadService)\n\n\t// Media in GoCommerce is an operator's, uploaded through the admin API. A storefront holds no\n\t// admin credential and must not act as though it does.\n\tasync uploadToS3(_params: unknown): Promise<never> {\n\t\tthrow unavailable('File uploads')\n\t}\n\n\tasync uploadMultipleToS3(_params: unknown): Promise<never> {\n\t\tthrow unavailable('File uploads')\n\t}\n\n\tasync deleteFromS3(_params: unknown): Promise<never> {\n\t\tthrow unavailable('File uploads')\n\t}\n}\n\nexport const uploadService = UploadService.getInstance()\n\n// --- Marketplace --------------------------------------------------------------------------------\n// GoCommerce is single-vendor: one operator, one catalogue.\n\nexport class VendorService extends BaseService {\n\tstatic getInstance = singleton(VendorService)\n\n\tasync list(_params: unknown = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getVendor(_id: string): Promise<never> {\n\t\tthrow unavailable('Vendor pages')\n\t}\n\n\tasync fetchMyVendorDetails(): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n\n\tasync fetchDashboard(): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n\n\tasync fetchProductsOfVendor(_vendorId: string) {\n\t\treturn [] as unknown[]\n\t}\n\n\tasync getAllVendorRatings(_vendorId: string) {\n\t\treturn [] as unknown[]\n\t}\n\n\tasync save(_data: unknown): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n\n\tasync update(_data: unknown): Promise<never> {\n\t\tthrow unavailable('Vendor accounts')\n\t}\n}\n\nexport const vendorService = VendorService.getInstance()\n\n// --- Storefront-specific add-ons ----------------------------------------------------------------\n// Custom-design ordering is a Litekart-side feature with its own backend; there is no GoCommerce\n// counterpart to route it to.\n\nexport class VarniCustomDesignService extends BaseService {\n\tstatic getInstance = singleton(VarniCustomDesignService)\n\n\tasync submitForm(_formDetails: unknown): Promise<never> {\n\t\tthrow unavailable('Custom design requests')\n\t}\n}\n\nexport const varniCustomDesignService = VarniCustomDesignService.getInstance()\n\nexport class VarniCustomProductService extends BaseService {\n\tstatic getInstance = singleton(VarniCustomProductService)\n\n\tasync checkForCombinationWith(_args: unknown) {\n\t\treturn { data: [], count: 0, pageSize: PAGE_SIZE, noOfPage: 0, page: 1 }\n\t}\n\n\tasync createCustomOrderChat(_productId: string): Promise<never> {\n\t\tthrow unavailable('Custom product chat')\n\t}\n\n\tasync sendMessageToCustomOrderChat(_chatId: string, _vendor: string, _message: string): Promise<never> {\n\t\tthrow unavailable('Custom product chat')\n\t}\n}\n\nexport const varniCustomProductService = VarniCustomProductService.getInstance()\n"]}
1
+ {"version":3,"sources":["../src/errors.ts","../src/money.ts","../src/static-store.ts","../src/rest-guard.ts","../src/cache.ts","../src/map.ts","../src/browser.ts","../src/services/base.service.ts","../src/services/facts.ts","../src/services/catalog.ts","../src/services/product-service.ts","../src/services/search-service.ts","../src/services/meilisearch-service.ts","../src/services/category-service.ts","../src/services/collection-service.ts","../src/services/cart-service.ts","../src/services/checkout-service.ts","../src/services/payment-method-service.ts","../src/services/coupon-service.ts","../src/services/order-service.ts","../src/services/user-service.ts","../src/services/address-service.ts","../src/services/wishlist-service.ts","../src/services/review-service.ts","../src/services/menu-service.ts","../src/services/store-service.ts","../src/services/page-service.ts","../src/services/vendor-service.ts","../src/services/misc-services.ts"],"names":["c","env","quote","reported","clean","enc"],"mappings":";AAeO,IAAM,eAAA,GAAN,cAA8B,KAAA,CAAM;AAAA,EACjC,MAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,MAAA,EAAgB,IAAA,EAAe,OAAA,EAAmB;AAC9E,IAAA,KAAA,CAAM,OAAO,CAAA;AACb,IAAA,IAAA,CAAK,IAAA,GAAO,iBAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AACd,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AACZ,IAAA,IAAA,CAAK,OAAA,GAAU,OAAA;AAAA,EAChB;AACD;AAWO,IAAM,iBAAA,GAAN,cAAgC,KAAA,CAAM;AAAA,EACnC,OAAA;AAAA,EACA,MAAA;AAAA,EAET,WAAA,CAAY,OAAA,EAAiB,MAAA,EAAgB,MAAA,EAAiB;AAC7D,IAAA,KAAA,CAAM,CAAA,EAAG,OAAO,CAAA,CAAA,EAAI,MAAM,CAAA,iCAAA,EAAoC,SAAS,CAAA,EAAA,EAAK,MAAM,CAAA,CAAA,GAAK,GAAG,CAAA,CAAE,CAAA;AAC5F,IAAA,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A;AAChC,IAAM,oBAAA,GAAuB,IAAI,oBAAA;AACjC,IAAM,iBAAA,GAAoB,IAAI,iBAAA;AAC9B,IAAM,WAAA,GAAc,IAAI,WAAA;AACxB,IAAM,aAAA,GAAgB,IAAI,aAAA;AAC1B,IAAM,YAAA,GAAe,IAAI,YAAA;AACzB,IAAM,WAAA,GAAc,IAAI,WAAA;AACxB,IAAM,cAAA,GAAiB,IAAI,cAAA;AAC3B,IAAM,WAAA,GAAc,IAAI,WAAA;AACxB,IAAM,eAAA,GAAkB,IAAI,eAAA;AAC5B,IAAM,kBAAA,GAAqB,IAAI,kBAAA;AAC/B,IAAM,aAAA,GAAgB,IAAI,aAAA;AAC1B,IAAM,eAAA,GAAkB,IAAI,eAAA;AAC5B,IAAM,wBAAA,GAA2B,IAAI,wBAAA;AACrC,IAAM,yBAAA,GAA4B,IAAI,yBAAA;AAItC,IAAM,cAAA,GAAiB;AACvB,IAAM,eAAA,GAAkB","file":"index.js","sourcesContent":["/**\n * The two ways a call through this connector fails.\n *\n * Both carry `message`, because the storefront shows `err.message` in a toast\n * and has no other field it reliably reads.\n */\n\n/**\n * What the engine refused, in a shape the storefront can show a shopper.\n *\n * `status` travels because the difference between 404 and 409 is the\n * difference between \"that product is gone\" and \"somebody just bought the last\n * one\", and a storefront renders those differently. `code` is the engine's own\n * taxonomy (`not_found`, `validation`, `conflict`, `unauthorized`, …).\n */\nexport class GoCommerceError extends Error {\n\treadonly status: number\n\treadonly code: string | undefined\n\treadonly details: unknown\n\n\tconstructor(message: string, status: number, code?: string, details?: unknown) {\n\t\tsuper(message)\n\t\tthis.name = 'GoCommerceError'\n\t\tthis.status = status\n\t\tthis.code = code\n\t\tthis.details = details\n\t}\n}\n\n/**\n * A storefront feature this engine has no model for — reels, chat, a vendor's\n * commission statement — or one that lives in a module this particular build\n * did not compile in.\n *\n * The name is the one every connector in the family throws, so a storefront\n * that branches on `err.name === 'NotSupportedError'` treats GoCommerce the same\n * as the rest.\n */\nexport class NotSupportedError extends Error {\n\treadonly service: string\n\treadonly method: string\n\n\tconstructor(service: string, method: string, detail?: string) {\n\t\tsuper(`${service}.${method}() is not supported by GoCommerce${detail ? `: ${detail}` : '.'}`)\n\t\tthis.name = 'NotSupportedError'\n\t\tthis.service = service\n\t\tthis.method = method\n\t}\n}\n","/**\n * Money, across the one boundary in this connector where it changes shape.\n *\n * The engine speaks minor units and a currency code, always, and never sends a\n * formatted string (AGENTS.md rule 6). Svelte Commerce's types say `price:\n * number`, and every backend it already talks to means \"19.99\" by that. So the\n * conversion happens here, once, in the only file allowed to divide money.\n *\n * The exponent is per currency, not a constant 100: the yen writes no decimals\n * and the dinar writes three. Dividing 2500 JPY by 100 would price a ¥2,500\n * item at ¥25. The table mirrors `currencyExponent` in core/transfer_shopify.go\n * — the same list, because a second opinion about the yen is a bug.\n */\n\nconst ZERO_DECIMAL = new Set([\n\t'BIF',\n\t'CLP',\n\t'DJF',\n\t'GNF',\n\t'ISK',\n\t'JPY',\n\t'KMF',\n\t'KRW',\n\t'PYG',\n\t'RWF',\n\t'UGX',\n\t'VND',\n\t'VUV',\n\t'XAF',\n\t'XOF',\n\t'XPF',\n])\n\nconst THREE_DECIMAL = new Set(['BHD', 'IQD', 'JOD', 'KWD', 'LYD', 'OMR', 'TND'])\n\nexport function currencyExponent(code: string | null | undefined): number {\n\tconst c = (code ?? '').toUpperCase()\n\tif (ZERO_DECIMAL.has(c)) return 0\n\tif (THREE_DECIMAL.has(c)) return 3\n\treturn 2\n}\n\n/** The engine's money object. */\nexport type Money = { amount_minor: number; currency: string }\n\n/**\n * Minor units to the major-unit number the storefront renders.\n *\n * Rounded to the currency's own precision rather than left as raw float\n * division: 1999/100 is 19.99 exactly, but 1 / 1000 for a three-decimal\n * currency is not, and a price that renders as 0.0010000000000000002 is the\n * kind of thing nobody notices until a customer screenshots it.\n */\nexport function toMajor(money: Money | null | undefined): number {\n\tif (!money) return 0\n\treturn minorToMajor(money.amount_minor, money.currency)\n}\n\n/** The same, for the routes that send a bare `*_minor` integer beside a currency. */\nexport function minorToMajor(minor: number | null | undefined, currency: string | null | undefined): number {\n\tif (minor === null || minor === undefined || !Number.isFinite(minor)) return 0\n\tconst exp = currencyExponent(currency)\n\tif (exp === 0) return minor\n\treturn Number((minor / 10 ** exp).toFixed(exp))\n}\n\n/**\n * Back the other way, for the few places the storefront hands us a number —\n * a price filter, mostly.\n *\n * Rounded, not truncated: 19.99 * 100 is 1998.9999999999998 in binary floating\n * point, and truncating that filters out the item priced exactly 19.99.\n */\nexport function toMinor(amount: number, currency: string | null | undefined): number {\n\tconst exp = currencyExponent(currency)\n\treturn Math.round(amount * 10 ** exp)\n}\n","/**\n * Store identity — name, logo, favicon, menus, theme variables.\n *\n * Some of that the engine has (the settlement currency, the payment methods,\n * the switched-on plugins) and most of it it does not: a logo and a hero banner\n * are the storefront's own business. The storefront registers its static store\n * record here at boot — `default-store.json` merged under the project's\n * `kitcommerce.config.ts` — and `storeService` lays the engine's live facts\n * over it, so the engine wins wherever it has an opinion.\n */\nexport type StaticStoreProvider = () => Promise<Record<string, any>> | Record<string, any>\n\nlet provider: StaticStoreProvider | undefined\n\nexport const setStaticStore = (fn: StaticStoreProvider) => {\n\tprovider = fn\n}\n\nexport const hasStaticStore = () => Boolean(provider)\n\nexport const readStaticStore = async (): Promise<Record<string, any>> => {\n\tif (!provider) return {}\n\treturn (await provider()) ?? {}\n}\n\n/** The marker the storefront reads to tell which backend is active. */\nexport const connectorName = 'gocommerce'\n","/**\n * Litekart REST paths, intercepted.\n *\n * Every connector in the family exposes `get/post/put/patch/delete(path)` on\n * its BaseService because Litekart's does, and a little storefront code still\n * calls them with a Litekart path — `storeService.post('/api/…')`. Those paths\n * are relative, so they would land on the storefront's own origin, where\n * nothing answers.\n *\n * GoCommerce's own routes also start with `/api/`, which is why this connector\n * never sends an engine request through those verbs: every engine call goes\n * through `BaseService.engine()` with an absolute URL, and the storefront's own\n * guard (which patches the same verbs) cannot reach it either. What arrives\n * here is only ever an inherited Litekart path.\n *\n * Reads for a collection resolve empty (a store legitimately has none); reads\n * for one record and every write throw, because a blank detail page reads as\n * broken and a silent success would tell a shopper their enquiry was saved when\n * nothing left the browser. Each distinct path is reported once.\n */\n\nconst COLLECTION_SEGMENTS = new Set([\n\t'all',\n\t'list',\n\t'list-by-parent',\n\t'list-public',\n\t'latest',\n\t'search',\n\t'public',\n\t'public-details',\n\t'me',\n\t'multiple',\n])\n\nconst emptyResult = () => ({ data: [], count: 0, pageSize: 0, noOfPage: 0, page: 1 })\n\nconst addressesOneRecord = (url: string) => {\n\tconst segments = url.split('?')[0].split('/').filter(Boolean)\n\tif (segments.length < 3) return false\n\treturn !COLLECTION_SEGMENTS.has(segments[segments.length - 1].toLowerCase())\n}\n\nconst reported = new Set<string>()\n\nconst report = (method: string, url: string) => {\n\tconst key = `${method} ${url.split('?')[0]}`\n\tif (reported.has(key)) return\n\treported.add(key)\n\tconsole.warn(\n\t\t`[gocommerce] no native implementation for \\`${key}\\` — that is a Litekart REST path, and it was not called.`,\n\t)\n}\n\n/**\n * Answers a Litekart REST path from data the storefront holds (menus,\n * countries, plugin toggles…). Return `undefined` to fall through.\n */\nexport type RestResolver = (url: string) => Promise<unknown> | unknown | undefined\n\nlet localResolver: RestResolver | undefined\n\nexport const serveRestLocally = (resolver: RestResolver) => {\n\tlocalResolver = resolver\n}\n\nexport const resolveRestLocally = async (method: string, url: string) => {\n\tif (method === 'get') {\n\t\tconst local = await localResolver?.(url)\n\t\tif (local !== undefined) return local\n\t}\n\treport(method, url)\n\tif (method !== 'get' || addressesOneRecord(url)) {\n\t\tthrow new Error(`This feature is not available on this store (gocommerce).`)\n\t}\n\treturn emptyResult()\n}\n","/**\n * A short memory for store-level facts: which plugins are on, the settlement\n * currency, the category tree.\n *\n * The storefront asks for the store record on every server request, and a\n * category page needs the whole tree to draw one breadcrumb. Asking the engine\n * each time would multiply its load by the page count for answers that change\n * when a merchant edits something, not when a shopper clicks.\n *\n * Only facts that are the same for every shopper may go in here — this module\n * is shared by every request a server process handles. Keyed by engine URL, so\n * a platform storefront talking to several stores keeps them apart.\n */\nconst TTL_MS = 60_000\n\ntype Entry = { at: number; value: Promise<unknown> }\n\nconst entries = new Map<string, Entry>()\n\nexport function remember<T>(key: string, load: () => Promise<T>, ttl = TTL_MS): Promise<T> {\n\tconst hit = entries.get(key)\n\tif (hit && Date.now() - hit.at < ttl) return hit.value as Promise<T>\n\tconst value = load()\n\tentries.set(key, { at: Date.now(), value })\n\t// A failure is not remembered: the next caller tries again.\n\tvalue.catch(() => {\n\t\tif (entries.get(key)?.value === value) entries.delete(key)\n\t})\n\treturn value\n}\n\n/** For tests, and for a storefront that has just changed something itself. */\nexport function forgetAll(): void {\n\tentries.clear()\n}\n","/**\n * Engine shapes to storefront shapes.\n *\n * Svelte Commerce's types were drawn around Litekart's API, so every connector\n * is a translation and this file is most of ours. Four rules run through it:\n *\n * 1. Ids cross as strings. The storefront matches variants and cart lines\n * with `===` against ids it read from a URL.\n * 2. Money crosses as a major-unit number, through money.ts and nowhere else.\n * 3. A field the engine does not have is empty, never invented. There is no\n * popularity score, so none is made up; there is no compare-at price, so\n * `mrp` equals the price rather than 0, which would render as a 100%\n * discount on everything in the shop.\n * 4. Lists are always arrays. Product cards read `variants[0]` unguarded.\n */\nimport type {\n\tAddress,\n\tCart,\n\tCartLine,\n\tCategory,\n\tCmsPage,\n\tCollection,\n\tCustomer,\n\tIdentityAddress,\n\tOrder,\n\tOrderLine,\n\tProduct,\n\tReview,\n\tSearchDoc,\n\tVariant,\n\tVendor,\n} from './engine'\nimport { minorToMajor, toMajor, type Money } from './money'\nimport type { CartExtras, StorefrontAddress } from './browser'\n\nconst str = (v: number | string | null | undefined): string => (v === null || v === undefined ? '' : String(v))\n\nconst arr = <T>(v: T[] | null | undefined): T[] => v ?? []\n\n// ---------------------------------------------------------------- products\n\n/** Variants a shopper can see: inactive ones are the merchant's business. */\nconst liveVariants = (p: Product): Variant[] => arr(p.variants).filter((v) => v.active)\n\nfunction variantImages(v: Variant): string[] {\n\tconst out: string[] = []\n\tfor (const img of [v.image, ...arr(v.images)]) {\n\t\tif (img?.url && (img.kind ?? 'image') === 'image' && !out.includes(img.url)) out.push(img.url)\n\t}\n\treturn out\n}\n\n/**\n * Every picture the public API offers for a product: the lead image, then each\n * variant's. The engine keeps the full gallery on admin routes only, so this\n * is the honest union rather than the whole media library.\n */\nexport function productImages(p: Product): string[] {\n\tconst out: string[] = []\n\tconst push = (url?: string) => {\n\t\tif (url && !out.includes(url)) out.push(url)\n\t}\n\tpush(p.image_url)\n\tfor (const v of arr(p.variants)) for (const url of variantImages(v)) push(url)\n\treturn out\n}\n\nexport function toVariant(v: Variant, p: Product, optionless: boolean) {\n\tconst images = variantImages(v)\n\tconst options = arr(p.options)\n\treturn {\n\t\tid: str(v.id),\n\t\tproductId: str(v.product_id),\n\t\t// The storefront picks the default variant of an optionless product by\n\t\t// this exact title, and hides the variant name when it sees it.\n\t\ttitle: optionless ? 'default' : v.label || v.sku,\n\t\tsku: v.sku,\n\t\tbarcode: v.barcode ?? null,\n\t\tprice: toMajor(v.price),\n\t\tmrp: toMajor(v.compare_at_price ?? v.price),\n\t\t// The engine's own vocabulary, unchanged: `available` is on hand minus\n\t\t// reserved; an untracked variant is never managed, so its count is moot.\n\t\tstock: v.active ? v.available : 0,\n\t\tmanageInventory: v.active ? v.track_inventory : true,\n\t\tallowBackorder: v.active && v.continue_selling,\n\t\tactive: v.active,\n\t\tweight: v.weight_grams ?? null,\n\t\tlength: v.dimensions?.length_mm ?? null,\n\t\twidth: v.dimensions?.width_mm ?? null,\n\t\theight: v.dimensions?.height_mm ?? null,\n\t\timages: images.join(','),\n\t\timg: images[0] ?? null,\n\t\timage: images[0] ?? null,\n\t\tthumbnail: images[0] ?? null,\n\t\t// Values in option order — `options[i]` answers `p.options[i]`.\n\t\toptions: arr(v.options).map((value, i) => ({ optionId: str(options[i]?.id), value })),\n\t\tmetadata: v.metadata ?? null,\n\t}\n}\n\nexport type StorefrontProduct = ReturnType<typeof toProduct>\n\nexport function toProduct(p: Product, extra: { categoryHierarchy?: { name: string; slug: string }[] } = {}) {\n\tconst live = liveVariants(p)\n\tconst lead = live[0] ?? arr(p.variants)[0]\n\tconst optionless = arr(p.options).length === 0\n\tconst images = productImages(p)\n\tconst prices = live.map((v) => toMajor(v.price))\n\tconst tracked = live.filter((v) => v.track_inventory)\n\tconst category = p.category\n\tconst tags = arr(p.tags)\n\n\treturn {\n\t\tid: str(p.id),\n\t\tslug: p.slug,\n\t\ttitle: p.title,\n\t\tname: p.title,\n\t\tsubtitle: null,\n\t\tdescription: p.description ?? '',\n\t\tstatus: p.status === 'active' ? 'published' : p.status,\n\t\tactive: p.status === 'active',\n\t\ttype: p.product_type ?? '',\n\t\tcurrency: p.currency,\n\t\tcurrencyCode: p.currency,\n\t\tprice: lead ? toMajor(lead.price) : 0,\n\t\tmrp: lead ? toMajor(lead.compare_at_price ?? lead.price) : 0,\n\t\tminPrice: prices.length ? Math.min(...prices) : 0,\n\t\tmaxPrice: prices.length ? Math.max(...prices) : 0,\n\t\tsku: lead?.sku ?? null,\n\t\tbarcode: lead?.barcode ?? null,\n\t\tweight: lead?.weight_grams ?? null,\n\t\toriginCountry: lead?.origin_country ?? null,\n\t\tthumbnail: images[0] ?? null,\n\t\timage_url: images[0] ?? null,\n\t\timages: images.join(','),\n\t\timageList: images,\n\t\t// Product-level stock is what a card shows before a variant is picked:\n\t\t// buyable when any live variant is, counted only where counting means\n\t\t// something.\n\t\tmanageInventory: live.length > 0 && tracked.length === live.length,\n\t\tallowBackorder: live.some((v) => v.continue_selling),\n\t\tstock: tracked.reduce((n, v) => n + Math.max(0, v.available), 0),\n\t\thasStock: live.some((v) => !v.track_inventory || v.continue_selling || v.available > 0),\n\t\tcategoryId: category ? str(category.id) : null,\n\t\tcategory: category ? { id: str(category.id), name: category.title, slug: category.slug } : null,\n\t\tcategories: category ? [{ category: { id: str(category.id), name: category.title, slug: category.slug } }] : [],\n\t\tcategoryHierarchy: extra.categoryHierarchy ?? (category ? [{ name: category.title, slug: category.slug }] : []),\n\t\tcollections: arr(p.collections).map((c) => ({ id: str(c.id), name: c.title, slug: c.slug })),\n\t\t// Free text on the engine's product, not a vendor record.\n\t\tvendor: p.vendor ? { businessName: p.vendor } : null,\n\t\tproductTags: tags.join(','),\n\t\tkeywords: tags.join(','),\n\t\tmetaTitle: p.seo_title || p.title,\n\t\tmetaDescription: p.seo_description || null,\n\t\tlink: `/products/${p.slug}`,\n\t\toptions: arr(p.options).map((o) => ({\n\t\t\tid: str(o.id),\n\t\t\ttitle: o.name,\n\t\t\tname: o.name,\n\t\t\ttype: 'text',\n\t\t\tvalues: arr(o.values).map((val) => ({ id: str(val.id), value: val.value })),\n\t\t})),\n\t\tvariants: live.map((v) => toVariant(v, p, optionless)),\n\t\t// Filled by the product page from ext/reviews when it is installed.\n\t\tratings: [] as ReturnType<typeof toRating>[],\n\t\trating: null as number | null,\n\t\tratingCount: 0,\n\t\treviewCount: 0,\n\t\tattributes: [] as { name: string; value: string }[],\n\t\tmetadata: p.metadata ?? null,\n\t\tcreatedAt: p.created_at,\n\t\tupdatedAt: p.updated_at,\n\t}\n}\n\n/** A Meilisearch hit — the search index's document, which is thinner than a product. */\nexport function fromSearchDoc(d: SearchDoc) {\n\tconst price = minorToMajor(d.price_minor, d.currency)\n\treturn {\n\t\tid: str(d.id),\n\t\tslug: d.slug,\n\t\ttitle: d.title,\n\t\tname: d.title,\n\t\tdescription: d.description,\n\t\tcurrency: d.currency,\n\t\tprice,\n\t\tmrp: price,\n\t\tminPrice: price,\n\t\tmaxPrice: minorToMajor(d.price_max_minor, d.currency),\n\t\tthumbnail: d.image ?? null,\n\t\timage_url: d.image ?? null,\n\t\timages: d.image ?? '',\n\t\tstock: d.in_stock ? 1 : 0,\n\t\thasStock: d.in_stock,\n\t\t// The index cannot say how much is left, only whether any is; a card\n\t\t// built from it must not claim to count.\n\t\tmanageInventory: false,\n\t\tallowBackorder: false,\n\t\tproductTags: arr(d.tags).join(','),\n\t\tcategory: d.category ? { name: d.category.split(' / ').pop() ?? d.category, slug: '' } : null,\n\t\tvendor: d.vendor ? { businessName: d.vendor } : null,\n\t\tvariants: [] as ReturnType<typeof toVariant>[],\n\t\toptions: [],\n\t\tratings: [],\n\t\tlink: `/products/${d.slug}`,\n\t\tupdatedAt: new Date(d.updated_at * 1000).toISOString(),\n\t}\n}\n\n// ---------------------------------------------------------------- taxonomy\n\nexport type StorefrontCategory = {\n\tid: string\n\tname: string\n\ttitle: string\n\tslug: string\n\tlink: string\n\tparentCategoryId: string | null\n\tpath: string\n\tlevel: number\n\trank: number\n\tchildCount: number\n\tthumbnail: string | null\n\tdescription: string | null\n\tisActive: boolean\n\tisFeatured: boolean\n\tisMegamenu: boolean\n\tmetaTitle: string\n\tchildren: StorefrontCategory[]\n\tcreatedAt: string\n\tupdatedAt: string\n}\n\nexport function toCategory(c: Category): StorefrontCategory {\n\treturn {\n\t\tid: str(c.id),\n\t\tname: c.title,\n\t\ttitle: c.title,\n\t\tslug: c.slug,\n\t\tlink: `/${c.slug}`,\n\t\tparentCategoryId: c.parent_id === null || c.parent_id === undefined ? null : str(c.parent_id),\n\t\tpath: c.full_name,\n\t\tlevel: c.depth,\n\t\trank: c.position,\n\t\tchildCount: c.child_count,\n\t\tthumbnail: (c.metadata?.image as string | undefined) ?? null,\n\t\tdescription: (c.metadata?.description as string | undefined) ?? null,\n\t\tisActive: true,\n\t\tisFeatured: false,\n\t\tisMegamenu: false,\n\t\tmetaTitle: c.title,\n\t\tchildren: arr(c.children).map(toCategory),\n\t\tcreatedAt: c.created_at,\n\t\tupdatedAt: c.updated_at,\n\t}\n}\n\nexport function toCollection(c: Collection) {\n\treturn {\n\t\tid: str(c.id),\n\t\tname: c.title,\n\t\ttitle: c.title,\n\t\tslug: c.slug,\n\t\tdescription: c.description || null,\n\t\tsubTitle: null,\n\t\trank: str(c.position),\n\t\tthumbnail: (c.metadata?.image as string | undefined) ?? null,\n\t\tisActive: true,\n\t\tmetaTitle: c.title,\n\t\tmetaDescription: c.description || null,\n\t\tcreatedAt: c.created_at,\n\t\tupdatedAt: c.updated_at,\n\t}\n}\n\n// ---------------------------------------------------------------- addresses\n\n/** The engine's address — on a checkout or an order — to the storefront's form shape. */\nexport function fromEngineAddress(a: Address | undefined, email?: string) {\n\tif (!a) return null\n\tconst [firstName, ...rest] = (a.name ?? '').trim().split(/\\s+/)\n\treturn {\n\t\tfirstName: firstName || '',\n\t\tlastName: rest.join(' '),\n\t\temail: email ?? null,\n\t\tphone: a.phone ?? null,\n\t\taddress_1: a.line1,\n\t\taddress_2: a.line2 ?? '',\n\t\tcity: a.city,\n\t\tstate: a.state ?? '',\n\t\tzip: a.postal_code,\n\t\tcountry: a.country,\n\t\tcountryCode: a.country,\n\t}\n}\n\n/** The storefront's form shape to the engine's checkout address. */\nexport function toEngineAddress(a: StorefrontAddress): Address {\n\tconst name = [a.firstName, a.lastName].filter(Boolean).join(' ').trim()\n\treturn {\n\t\t...(name ? { name } : {}),\n\t\t...(a.phone ? { phone: String(a.phone) } : {}),\n\t\tline1: String(a.address_1 ?? '').trim(),\n\t\t...(a.address_2 || a.locality ? { line2: [a.address_2, a.locality].filter(Boolean).join(', ') } : {}),\n\t\tcity: String(a.city ?? '').trim(),\n\t\t...(a.state ? { state: String(a.state) } : {}),\n\t\tpostal_code: String(a.zip ?? '').trim(),\n\t\tcountry: String(a.countryCode || a.country || '')\n\t\t\t.trim()\n\t\t\t.toUpperCase(),\n\t}\n}\n\n/** An address-book entry (ext/identity) to the storefront's Address. */\nexport function fromIdentityAddress(a: IdentityAddress, email?: string) {\n\tconst [firstName, ...rest] = (a.name ?? '').trim().split(/\\s+/)\n\treturn {\n\t\tid: str(a.id),\n\t\tfirstName: firstName || '',\n\t\tlastName: rest.join(' '),\n\t\temail: email ?? null,\n\t\tphone: a.phone || null,\n\t\taddress_1: a.line1,\n\t\taddress_2: a.line2,\n\t\tcity: a.city,\n\t\tstate: a.state,\n\t\tzip: a.postal_code,\n\t\tcountry: a.country,\n\t\tcountryCode: a.country,\n\t\tlabel: a.label,\n\t\tisPrimary: a.is_default,\n\t\tcreatedAt: a.created_at,\n\t\tupdatedAt: a.updated_at,\n\t}\n}\n\n/** The storefront's Address to ext/identity's AddressInput. Only declared fields: the engine refuses others. */\nexport function toIdentityAddress(a: StorefrontAddress & { isPrimary?: boolean; label?: string }) {\n\tconst e = toEngineAddress(a)\n\treturn {\n\t\tname: e.name ?? '',\n\t\tphone: e.phone ?? '',\n\t\tline1: e.line1,\n\t\tline2: e.line2 ?? '',\n\t\tcity: e.city,\n\t\tstate: e.state ?? '',\n\t\tpostal_code: e.postal_code,\n\t\tcountry: e.country,\n\t\t...(a.label ? { label: String(a.label) } : {}),\n\t\t...(a.isPrimary ? { is_default: true } : {}),\n\t}\n}\n\n// ---------------------------------------------------------------- cart\n\nexport function toCartLine(l: CartLine, extra: { slug?: string; thumbnail?: string | null } = {}) {\n\treturn {\n\t\tid: str(l.id),\n\t\tproductId: str(l.product_id),\n\t\tvariantId: str(l.variant_id),\n\t\tsku: l.sku,\n\t\ttitle: l.title,\n\t\tname: l.title,\n\t\tslug: extra.slug ?? '',\n\t\tthumbnail: extra.thumbnail ?? null,\n\t\tvariantTitle: l.variant_label ?? '',\n\t\tqty: l.quantity,\n\t\tprice: toMajor(l.unit_price),\n\t\tmrp: toMajor(l.unit_price),\n\t\tsubtotal: toMajor(l.total),\n\t\ttotal: toMajor(l.total),\n\t\tinStock: l.in_stock,\n\t\tpriceChanged: l.price_changed,\n\t\tcurrentPrice: toMajor(l.current_price),\n\t\t// The storefront's review step lists only lines marked for checkout. The\n\t\t// engine checks a cart out whole, so every line is.\n\t\tisSelectedForCheckout: true,\n\t\tvariant: {\n\t\t\tid: str(l.variant_id),\n\t\t\toptions: l.variant_label ? l.variant_label.split(' / ').map((value) => ({ option: { title: '' }, value })) : [],\n\t\t},\n\t\tproduct: { id: str(l.product_id), categories: [] as unknown[] },\n\t}\n}\n\n/**\n * A cart, with what the engine does not keep laid over it: the coupon and its\n * previewed saving, the delivery choice and the addresses. Totals here are an\n * estimate the engine settles at checkout — tax in particular exists only on\n * the order — and the storefront is told so by `taxIncluded: false`.\n */\nexport function toCart(\n\tc: Cart,\n\textras: CartExtras = {},\n\tlineExtra: (l: CartLine) => { slug?: string; thumbnail?: string | null } = () => ({}),\n) {\n\tconst lines = c.status === 'converted' ? [] : arr(c.line_items)\n\tconst currency = c.currency\n\tconst subtotalMinor = lines.reduce((n, l) => n + l.total.amount_minor, 0)\n\tconst discountMinor = extras.discount && !extras.discount.free_shipping ? extras.discount.amount_minor : 0\n\tconst shippingMinor = extras.discount?.free_shipping ? 0 : (extras.shippingRate?.minor ?? 0)\n\tconst totalMinor = Math.max(0, subtotalMinor - discountMinor) + shippingMinor\n\tconst money = (minor: number) => minorToMajor(minor, currency)\n\tconst ship = extras.shippingAddress ?? null\n\n\treturn {\n\t\tid: c.id,\n\t\tstatus: c.status,\n\t\temail: c.email ?? ship?.email ?? null,\n\t\tphone: extras.phone ?? ship?.phone ?? null,\n\t\tname: ship ? [ship.firstName, ship.lastName].filter(Boolean).join(' ') : null,\n\t\tlineItems: lines.map((l) => toCartLine(l, lineExtra(l))),\n\t\tqty: lines.reduce((n, l) => n + l.quantity, 0),\n\t\tcurrencyCode: currency,\n\t\tcurrency,\n\t\tsubtotal: money(subtotalMinor),\n\t\tdiscountAmount: money(discountMinor),\n\t\tsavingAmount: money(discountMinor),\n\t\tcouponCode: extras.discount?.code ?? null,\n\t\tdiscount: extras.discount ?? null,\n\t\tshippingCharges: money(shippingMinor),\n\t\tshippingRateId: extras.shippingRateId ?? null,\n\t\tshippingMethod: extras.shippingRate?.name ?? null,\n\t\ttax: 0,\n\t\ttaxIncluded: false,\n\t\tcodCharges: 0,\n\t\ttotal: money(totalMinor),\n\t\tshippingAddress: ship,\n\t\tshippingAddressId: ship ? (ship.id && ship.id !== 'new' ? String(ship.id) : 'cart') : null,\n\t\tbillingAddress: extras.billingAddress ?? ship,\n\t\tbillingAddressId: extras.billingAddress\n\t\t\t? extras.billingAddress.id && extras.billingAddress.id !== 'new'\n\t\t\t\t? String(extras.billingAddress.id)\n\t\t\t\t: 'cart-billing'\n\t\t\t: ship\n\t\t\t\t? ship.id && ship.id !== 'new'\n\t\t\t\t\t? String(ship.id)\n\t\t\t\t\t: 'cart'\n\t\t\t\t: null,\n\t\tpaymentMethod: null,\n\t\tneedAddress: lines.length > 0,\n\t\tcompletedAt: c.status === 'converted' ? c.updated_at : null,\n\t\tcreatedAt: c.created_at,\n\t\tupdatedAt: c.updated_at,\n\t\texpiresAt: c.expires_at,\n\t}\n}\n\n/** What the storefront shows for \"no bag yet\": its own initial cart, field for field. */\nexport function emptyCart(currency = 'USD') {\n\treturn {\n\t\tid: '',\n\t\tstatus: 'open',\n\t\temail: null,\n\t\tphone: null,\n\t\tlineItems: [] as ReturnType<typeof toCartLine>[],\n\t\tqty: 0,\n\t\tcurrencyCode: currency,\n\t\tsubtotal: 0,\n\t\tdiscountAmount: 0,\n\t\tsavingAmount: 0,\n\t\tcouponCode: null,\n\t\tshippingCharges: 0,\n\t\ttax: 0,\n\t\ttotal: 0,\n\t\tshippingAddress: null,\n\t\tshippingAddressId: null,\n\t\tbillingAddress: null,\n\t\tbillingAddressId: null,\n\t}\n}\n\n// ---------------------------------------------------------------- orders\n\nconst STATUS: Record<string, string> = {\n\tpending: 'Pending',\n\tconfirmed: 'Confirmed',\n\tpartial: 'Partially shipped',\n\tshipped: 'Shipped',\n\tdelivered: 'Delivered',\n\tcancelled: 'Cancelled',\n}\n\nconst PAYMENT_STATUS: Record<string, string> = {\n\tpending: 'Pending',\n\tpaid: 'Paid',\n\tfailed: 'Failed',\n\trefunded: 'Refunded',\n}\n\nfunction toOrderLine(l: OrderLine, currency: string) {\n\treturn {\n\t\tid: str(l.id),\n\t\tproductId: str(l.product_id),\n\t\tvariantId: str(l.variant_id),\n\t\tsku: l.sku,\n\t\ttitle: l.title,\n\t\tname: l.title,\n\t\tslug: '',\n\t\tthumbnail: l.image_url ?? null,\n\t\timg: l.image_url ?? null,\n\t\tvariantTitle: l.variant_label ?? '',\n\t\tqty: l.quantity,\n\t\tshippedQty: l.shipped_quantity,\n\t\tprice: toMajor(l.unit_price),\n\t\tmrp: toMajor(l.unit_price),\n\t\tsubtotal: toMajor(l.total),\n\t\ttotal: toMajor(l.total),\n\t\tcurrencyCode: currency,\n\t\tstatus: l.shipped_quantity >= l.quantity ? 'Shipped' : 'Pending',\n\t\tfiles: [],\n\t\tusedOptions: [],\n\t}\n}\n\nexport type StorefrontOrder = ReturnType<typeof toOrder>\n\nexport function toOrder(o: Order) {\n\tconst address = fromEngineAddress(o.address, o.email)\n\tconst code = (o.discounts ?? []).find((d) => d.code)?.code\n\treturn {\n\t\tid: str(o.id),\n\t\torderNo: o.number,\n\t\torderNumber: o.number,\n\t\tnumber: o.number,\n\t\t// The storefront links an order by this; the engine has no sub-orders,\n\t\t// so an order is its own parent.\n\t\tparentOrderNo: o.number,\n\t\tstatus: STATUS[o.status] ?? o.status,\n\t\tengineStatus: o.status,\n\t\tpaymentStatus: PAYMENT_STATUS[o.payment_status] ?? o.payment_status,\n\t\tpaymentMethod: o.payment_provider.toUpperCase(),\n\t\tcurrencyCode: o.currency,\n\t\tsubtotal: toMajor(o.subtotal),\n\t\tshippingCharges: toMajor(o.shipping),\n\t\tdiscount: toMajor(o.discount),\n\t\ttax: toMajor(o.tax),\n\t\ttaxIncluded: o.tax_inclusive,\n\t\ttotal: toMajor(o.total),\n\t\trefunded: toMajor(o.refunded),\n\t\tcodCharges: 0,\n\t\tcoupon: code ? { code } : null,\n\t\tuserEmail: o.email,\n\t\temail: o.email,\n\t\tphone: o.phone ?? null,\n\t\tshippingAddress: address,\n\t\tbillingAddress: address,\n\t\tshippingMethod: o.shipping_method ?? null,\n\t\tshippingRate: o.shipping_method ? { name: o.shipping_method } : null,\n\t\tlineItems: arr(o.line_items).map((l) => toOrderLine(l, o.currency)),\n\t\tfulfillments: arr(o.fulfillments).map((f) => ({\n\t\t\tid: str(f.id),\n\t\t\tstatus: f.status,\n\t\t\tcarrier: f.carrier_name || f.carrier || f.provider,\n\t\t\ttrackingNumber: f.tracking ?? null,\n\t\t\ttrackingUrl: f.tracking_url ?? null,\n\t\t\tlineItems: arr(f.lines).map((l) => ({ id: str(l.order_line_id), title: l.title, qty: l.quantity })),\n\t\t\tcreatedAt: f.created_at,\n\t\t})),\n\t\ttracking: [],\n\t\torderHistory: [],\n\t\tisReplaceOrReturn: false,\n\t\tcreatedAt: o.created_at,\n\t\tupdatedAt: o.updated_at,\n\t}\n}\n\n// ---------------------------------------------------------------- the rest\n\nexport function toRating(r: Review) {\n\treturn {\n\t\tid: str(r.id),\n\t\trating: r.rating,\n\t\tname: r.name,\n\t\ttitle: r.title ?? '',\n\t\treview: r.body,\n\t\tmessage: r.body,\n\t\treply: r.reply ?? null,\n\t\tverified: r.verified,\n\t\timg: '',\n\t\tcreatedAt: r.created_at,\n\t}\n}\n\nexport function toCmsPage(p: CmsPage) {\n\treturn {\n\t\tid: str(p.id),\n\t\tslug: p.slug,\n\t\tname: p.title,\n\t\ttitle: p.title,\n\t\tcontent: p.body,\n\t\texcerpt: p.excerpt ?? null,\n\t\tlayouts: [],\n\t\tlanguage: p.language,\n\t\tmetaTitle: p.seo?.title || p.title,\n\t\tmetaDescription: p.seo?.description || p.excerpt || null,\n\t\tmetaKeywords: p.seo?.keywords || null,\n\t\tpublishedAt: p.published_at ?? null,\n\t\tcreatedAt: p.created_at,\n\t\tupdatedAt: p.updated_at,\n\t}\n}\n\nexport function toVendor(v: Vendor) {\n\treturn {\n\t\tid: str(v.id),\n\t\tslug: v.slug,\n\t\tname: v.name,\n\t\tbusinessName: v.name,\n\t\tabout: v.about,\n\t\tdescription: v.about,\n\t\twebsite: v.website,\n\t\taddress: v.address,\n\t\tbanners: [],\n\t\trating: null,\n\t}\n}\n\nexport function toUser(c: Customer) {\n\tconst [firstName, ...rest] = (c.name ?? '').trim().split(/\\s+/)\n\treturn {\n\t\tid: str(c.id),\n\t\tuserId: str(c.id),\n\t\temail: c.email,\n\t\temailVerified: c.email_verified,\n\t\tphone: c.phone || null,\n\t\tfirstName: firstName || '',\n\t\tlastName: rest.join(' '),\n\t\tname: c.name,\n\t\tfullName: c.name,\n\t\tavatar: null,\n\t\trole: 'USER',\n\t\tcreatedAt: c.created_at,\n\t\tupdatedAt: c.updated_at,\n\t}\n}\n\nexport const priceOf = (m: Money | undefined) => (m ? toMajor(m) : 0)\n","/**\n * The state this connector keeps in the shopper's browser, and only there.\n *\n * The storefront renders some services from a server singleton shared by every\n * shopper, so nothing about one shopper may live in module scope: a token held\n * in a static field would be served to the next request. Everything here is\n * read from `localStorage` or `document.cookie` at the moment it is needed, and\n * on the server every reader answers \"nothing\".\n *\n * What lives here, and why the engine does not hold it:\n *\n * - the account session token — ext/identity is bearer-only and sets no cookie;\n * - the `me` and `connect.sid` cookies — the storefront's own idea of who is\n * signed in, which every connector in the family writes itself;\n * - `cart_id` — the storefront reads it, the connector writes it;\n * - per-cart checkout details — the engine's cart holds lines and an email, and\n * takes the address, phone and delivery choice only in the checkout request,\n * so they are kept here until then;\n * - order access tokens — returned once, at checkout, and the only way a guest\n * can read an order back;\n * - the wishlist token — ext/wishlist keys a list by its own token.\n */\nimport type { AppliedDiscount, AuthResponse, Customer } from './engine'\n\nexport const inBrowser = (): boolean => typeof window !== 'undefined' && typeof document !== 'undefined'\n\nexport function readLocal(key: string): string | null {\n\tif (!inBrowser()) return null\n\ttry {\n\t\treturn window.localStorage.getItem(key)\n\t} catch {\n\t\treturn null\n\t}\n}\n\nexport function writeLocal(key: string, value: string): void {\n\tif (!inBrowser()) return\n\ttry {\n\t\twindow.localStorage.setItem(key, value)\n\t} catch {\n\t\t// Private mode or a full quota. The call it belongs to still succeeds;\n\t\t// only the memory of it is lost.\n\t}\n}\n\nexport function removeLocal(key: string): void {\n\tif (!inBrowser()) return\n\ttry {\n\t\twindow.localStorage.removeItem(key)\n\t} catch {\n\t\t// see writeLocal\n\t}\n}\n\nfunction readJSON<T>(key: string): T | null {\n\tconst raw = readLocal(key)\n\tif (!raw) return null\n\ttry {\n\t\treturn JSON.parse(raw) as T\n\t} catch {\n\t\treturn null\n\t}\n}\n\nconst YEAR = 60 * 60 * 24 * 365\n\nfunction setCookie(name: string, value: string, maxAge = YEAR): void {\n\tif (!inBrowser()) return\n\tdocument.cookie = `${name}=${value}; path=/; max-age=${maxAge}; samesite=lax`\n}\n\nfunction clearCookie(name: string): void {\n\tif (!inBrowser()) return\n\tdocument.cookie = `${name}=; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT`\n}\n\nexport function readCookie(name: string): string | null {\n\tif (!inBrowser()) return null\n\tfor (const pair of document.cookie.split(';')) {\n\t\tconst at = pair.indexOf('=')\n\t\tif (at < 0) continue\n\t\tif (pair.slice(0, at).trim() === name) return pair.slice(at + 1).trim()\n\t}\n\treturn null\n}\n\n// ---------------------------------------------------------------- session\n\nconst TOKEN = 'gocommerce_token'\n\n/** The ext/identity bearer token, when a shopper is signed in in this browser. */\nexport const sessionToken = (): string | null => readLocal(TOKEN)\n\n/**\n * The user object the storefront keeps in its `me` cookie. `userId` is its\n * signed-in test and `role: 'USER'` its shopper test; the rest fills forms.\n */\nexport function toMe(c: Customer) {\n\tconst [firstName, ...rest] = (c.name ?? '').trim().split(/\\s+/)\n\treturn {\n\t\tid: String(c.id),\n\t\tuserId: String(c.id),\n\t\temail: c.email,\n\t\tphone: c.phone || null,\n\t\tfirstName: firstName || '',\n\t\tlastName: rest.join(' '),\n\t\tname: c.name ?? '',\n\t\tfullName: c.name ?? '',\n\t\tavatar: null,\n\t\trole: 'USER',\n\t\temailVerified: c.email_verified,\n\t\tstoreId: null,\n\t}\n}\n\nexport type Me = ReturnType<typeof toMe>\n\n/**\n * Signs this browser in: the token for the engine, the two cookies for the\n * storefront. `connect.sid` carries no secret — the storefront's server only\n * checks that it exists — so it holds a marker rather than the token, which\n * would otherwise ride along on every request to the storefront's origin.\n */\nexport function startSession(auth: AuthResponse): Me {\n\twriteLocal(TOKEN, auth.token)\n\tconst me = toMe(auth.record)\n\tconst expires = Math.max(60, Math.floor((Date.parse(auth.expires_at) - Date.now()) / 1000)) || YEAR\n\tsetCookie('me', encodeURIComponent(JSON.stringify(me)), expires)\n\tsetCookie('connect.sid', 'gocommerce', expires)\n\treturn me\n}\n\n/** Refreshes the `me` cookie after a profile change, keeping the session. */\nexport function updateMe(c: Customer): Me {\n\tconst me = toMe(c)\n\tsetCookie('me', encodeURIComponent(JSON.stringify(me)))\n\treturn me\n}\n\nexport function endSession(): void {\n\tremoveLocal(TOKEN)\n\tclearCookie('me')\n\tclearCookie('connect.sid')\n}\n\n/** The `me` cookie, decoded — the name and email a review is signed with. */\nexport function currentMe(): Partial<Me> | null {\n\tconst raw = readCookie('me')\n\tif (!raw) return null\n\ttry {\n\t\treturn JSON.parse(decodeURIComponent(raw))\n\t} catch {\n\t\treturn null\n\t}\n}\n\n// ---------------------------------------------------------------- cart\n\n/** `localStorage.cart_id`, the storefront's own key, with its stale spellings refused. */\nexport function storedCartId(): string | null {\n\tconst v = readLocal('cart_id')\n\tif (!v || v === 'undefined' || v === 'null') return null\n\treturn v\n}\n\nexport const rememberCartId = (id: string): void => writeLocal('cart_id', id)\n\n/** The storefront's address shape, as its checkout form builds it. */\nexport type StorefrontAddress = {\n\tid?: string\n\tfirstName?: string\n\tlastName?: string\n\temail?: string\n\tphone?: string\n\taddress_1?: string\n\taddress_2?: string\n\tlocality?: string\n\tcity?: string\n\tstate?: string\n\tzip?: string\n\tcountry?: string\n\tcountryCode?: string\n\t[key: string]: unknown\n}\n\nexport type CartExtras = {\n\tphone?: string\n\tshippingAddress?: StorefrontAddress | null\n\tbillingAddress?: StorefrontAddress | null\n\tshippingRateId?: string | null\n\tshippingRate?: { id: string; name: string; minor: number; currency: string } | null\n\tdiscount?: AppliedDiscount | null\n\t/** The Idempotency-Key of the last checkout attempt, and the body it was sent with. */\n\tattempt?: { key: string; body: string } | null\n}\n\nconst extrasKey = (cartId: string) => `gocommerce_cart_${cartId}`\n\nexport const cartExtras = (cartId: string): CartExtras => readJSON<CartExtras>(extrasKey(cartId)) ?? {}\n\nexport function saveCartExtras(cartId: string, patch: CartExtras): CartExtras {\n\tconst next = { ...cartExtras(cartId), ...patch }\n\twriteLocal(extrasKey(cartId), JSON.stringify(next))\n\treturn next\n}\n\nexport const forgetCartExtras = (cartId: string): void => removeLocal(extrasKey(cartId))\n\n// ---------------------------------------------------------------- orders\n\ntype PlacedOrder = { number: string; token: string; cartId: string; reference?: string }\n\nconst ORDERS = 'gocommerce_orders'\n\nconst placedOrders = (): PlacedOrder[] => readJSON<PlacedOrder[]>(ORDERS) ?? []\n\n/**\n * Keeps an order's access token. The engine returns it exactly once — a\n * replayed checkout leaves it out — and without it a guest cannot read the\n * order back, so losing it here loses the order.\n */\nexport function rememberOrder(o: PlacedOrder): void {\n\tconst kept = placedOrders().filter((p) => p.number !== o.number)\n\t// Bounded: a shared computer should not accumulate a history forever.\n\twriteLocal(ORDERS, JSON.stringify([o, ...kept].slice(0, 50)))\n}\n\nexport const placedOrder = (number: string): PlacedOrder | undefined => placedOrders().find((p) => p.number === number)\n\nexport const placedOrderForCart = (cartId: string): PlacedOrder | undefined =>\n\tplacedOrders().find((p) => p.cartId === cartId)\n\nexport const placedOrderByReference = (reference: string): PlacedOrder | undefined =>\n\tplacedOrders().find((p) => p.reference === reference)\n\n// ---------------------------------------------------------------- wishlist\n\nconst WISHLIST = 'gocommerce_wishlist'\nexport const wishlistToken = (): string | null => readLocal(WISHLIST)\nexport const rememberWishlistToken = (token: string): void => writeLocal(WISHLIST, token)\nexport const forgetWishlistToken = (): void => removeLocal(WISHLIST)\n","import type { Credentials } from '../config'\nimport type { Envelope } from '../engine'\nimport { GoCommerceError } from '../errors'\nimport { resolveRestLocally } from '../rest-guard'\nimport { sessionToken } from '../browser'\n\ntype Query = Record<string, string | number | boolean | null | undefined | (string | number)[]>\n\nexport type EngineRequest = {\n\tmethod?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n\tquery?: Query\n\tbody?: unknown\n\theaders?: Record<string, string>\n\t/** Send the signed-in shopper's bearer token. Only ext/identity reads it. */\n\tauth?: boolean\n}\n\n/**\n * BaseService — the one place this connector talks to the engine.\n *\n * - Credentials arrive through the static `setCredentials` (both hooks), never\n * a constructor, and merge: the storefront drops unset variables rather than\n * sending `undefined`, so a second call must not erase the first.\n * - Server-side, a service is built with SvelteKit's `fetch`; client-side, the\n * prebuilt singletons use the global one. Either way it is called with the\n * global object as receiver, because the browser's native fetch throws\n * \"Illegal invocation\" when called as a method of anything else.\n * - Every engine call goes through `engine()`, with an absolute URL. The\n * engine's own routes start with `/api/`, and the storefront patches this\n * class's `get/post/put/patch/delete` to swallow any relative `/api/` path\n * (see rest-guard.ts), so those verbs are kept for the Litekart paths the\n * storefront still sends and never used for the engine.\n * - Failures throw a `GoCommerceError`: an `Error` with the engine's message,\n * status and code, which is what the storefront toasts.\n */\nexport class BaseService {\n\tprivate static _credentials: Credentials = { apiUrl: '' }\n\tprotected _fetch: typeof fetch\n\n\tconstructor(fetchFn?: typeof fetch) {\n\t\tthis._fetch = fetchFn ?? ((input, init) => globalThis.fetch(input, init))\n\t}\n\n\tstatic setCredentials(creds: Partial<Credentials>): void {\n\t\tBaseService._credentials = { ...BaseService._credentials, ...creds }\n\t}\n\n\tstatic getCredentials(): Credentials {\n\t\treturn BaseService._credentials\n\t}\n\n\tprotected get creds(): Credentials {\n\t\treturn BaseService._credentials\n\t}\n\n\t/**\n\t * The engine's base URL from wherever this code runs. In the browser a\n\t * configured proxy path wins, because the engine answers no CORS preflight.\n\t */\n\tprotected engineBase(): string {\n\t\tconst { apiUrl, proxyPath } = this.creds\n\t\tif (proxyPath && typeof window !== 'undefined' && window.location) {\n\t\t\treturn new URL(proxyPath, window.location.origin).href.replace(/\\/+$/, '')\n\t\t}\n\t\tconst url = (apiUrl ?? '').trim()\n\t\tif (!url) {\n\t\t\tthrow new GoCommerceError(\n\t\t\t\t'PUBLIC_GOCOMMERCE_API_URL is not set, so this storefront does not know where its commerce ' +\n\t\t\t\t\t'engine is. Point it at a running GoCommerce, e.g. http://127.0.0.1:8080.',\n\t\t\t\t0,\n\t\t\t)\n\t\t}\n\t\treturn url.replace(/\\/+$/, '')\n\t}\n\n\t/** An absolute engine URL for a path and query, without sending anything. */\n\tprotected engineURL(path: string, query?: Query): string {\n\t\treturn this.engineBase() + path + qs(query)\n\t}\n\n\t/**\n\t * One request to the engine, envelope and all.\n\t *\n\t * The body is read as text first, so a proxy's HTML error page is reported\n\t * as what it is rather than as a JSON parse error three frames away.\n\t */\n\tprotected async engine<T>(path: string, req: EngineRequest = {}): Promise<Envelope<T>> {\n\t\tconst url = this.engineURL(path, req.query)\n\t\tconst headers: Record<string, string> = { Accept: 'application/json', ...req.headers }\n\t\tif (req.body !== undefined) headers['Content-Type'] = 'application/json'\n\t\tif (this.creds.store) headers['X-Store'] = this.creds.store\n\t\tif (req.auth) {\n\t\t\tconst token = sessionToken()\n\t\t\tif (!token) throw new GoCommerceError('Please sign in to continue.', 401, 'unauthorized')\n\t\t\theaders.Authorization = `Bearer ${token}`\n\t\t}\n\n\t\tconst init: RequestInit = {\n\t\t\tmethod: req.method ?? 'GET',\n\t\t\theaders,\n\t\t\tbody: req.body === undefined ? undefined : JSON.stringify(req.body),\n\t\t}\n\t\tlet res: Response\n\t\ttry {\n\t\t\tres = await this._fetch.call(globalThis, url, init)\n\t\t} catch (cause) {\n\t\t\t// SvelteKit's server-side fetch applies the browser's CORS rule to a\n\t\t\t// universal load, and the engine sends no CORS headers. On the server\n\t\t\t// there is no browser to protect, so ask again with Node's own fetch;\n\t\t\t// in the browser the same call goes through PUBLIC_GOCOMMERCE_PROXY_PATH.\n\t\t\tif (typeof window === 'undefined' && /CORS/i.test(String((cause as Error)?.message))) {\n\t\t\t\ttry {\n\t\t\t\t\tres = await globalThis.fetch(url, init)\n\t\t\t\t} catch (again) {\n\t\t\t\t\tthrow unreachable(this.engineBase(), again)\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthrow unreachable(this.engineBase(), cause)\n\t\t\t}\n\t\t}\n\t\treturn this.unwrap<T>(res)\n\t}\n\n\t/** The envelope opened: the payload, or the engine's error as a GoCommerceError. */\n\tprivate async unwrap<T>(res: Response): Promise<Envelope<T>> {\n\t\tconst text = await res.text()\n\t\tlet parsed: any = null\n\t\tif (text) {\n\t\t\ttry {\n\t\t\t\tparsed = JSON.parse(text)\n\t\t\t} catch {\n\t\t\t\tthrow new GoCommerceError(\n\t\t\t\t\t`The commerce engine answered ${res.status} with something that is not JSON: ${text.slice(0, 120)}`,\n\t\t\t\t\tres.status,\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t\tif (!res.ok) {\n\t\t\tconst err = parsed?.error ?? {}\n\t\t\tthrow new GoCommerceError(\n\t\t\t\terr.message ?? `The commerce engine answered ${res.status}.`,\n\t\t\t\tres.status,\n\t\t\t\terr.code,\n\t\t\t\terr.details,\n\t\t\t)\n\t\t}\n\t\t// 204 is a success with nothing to say; the caller decides what that means.\n\t\treturn (parsed ?? { data: null }) as Envelope<T>\n\t}\n\n\t/** The bare payload, for the many callers that never look at `meta`. */\n\tprotected async data<T>(path: string, req: EngineRequest = {}): Promise<T> {\n\t\treturn (await this.engine<T>(path, req)).data\n\t}\n\n\t/**\n\t * Prices a cart at the signed-in shopper's customer-group prices. The\n\t * engine does this only for an account whose email is confirmed (403\n\t * otherwise), and the cart stays the shopper's either way — so a refusal\n\t * is not an error, and neither is a build without ext/identity.\n\t */\n\tprotected async claimCartForAccount(cartId: string): Promise<void> {\n\t\ttry {\n\t\t\tawait this.engine('/x/identity/me/carts', { method: 'POST', body: { cart_id: cartId }, auth: true })\n\t\t} catch {\n\t\t\t// Unconfirmed email, no identity module, or a cart already checked out.\n\t\t}\n\t}\n\n\t// ------------------------------------------------------------ Litekart verbs\n\n\t/**\n\t * The family's path-addressed verbs. An absolute URL is fetched as-is; a\n\t * relative one is a Litekart REST path, answered from the storefront's own\n\t * data where it has some and refused otherwise (rest-guard.ts).\n\t */\n\tget<T = any>(path: string): Promise<T> {\n\t\treturn this.raw<T>('get', path)\n\t}\n\tpost<T = any>(path: string, data?: unknown): Promise<T> {\n\t\treturn this.raw<T>('post', path, data)\n\t}\n\tput<T = any>(path: string, data?: unknown): Promise<T> {\n\t\treturn this.raw<T>('put', path, data)\n\t}\n\tpatch<T = any>(path: string, data?: unknown): Promise<T> {\n\t\treturn this.raw<T>('patch', path, data)\n\t}\n\tdelete<T = any>(path: string): Promise<T> {\n\t\treturn this.raw<T>('delete', path)\n\t}\n\n\tprivate async raw<T>(method: string, path: string, data?: unknown): Promise<T> {\n\t\tif (!/^https?:\\/\\//i.test(path)) return (await resolveRestLocally(method, path)) as T\n\t\tconst res = await this._fetch.call(globalThis, path, {\n\t\t\tmethod: method.toUpperCase(),\n\t\t\theaders: { Accept: 'application/json', ...(data === undefined ? {} : { 'Content-Type': 'application/json' }) },\n\t\t\tbody: data === undefined ? undefined : JSON.stringify(data),\n\t\t})\n\t\tconst body = await res.json().catch(() => ({}))\n\t\tif (!res.ok)\n\t\t\tthrow new GoCommerceError(body?.error?.message ?? `Request failed with status ${res.status}`, res.status)\n\t\treturn body as T\n\t}\n}\n\n/** A refused connection is the commonest failure in development; it says which address did not answer. */\nconst unreachable = (base: string, cause: unknown) =>\n\tnew GoCommerceError(`Could not reach the commerce engine at ${base}: ${(cause as Error)?.message ?? cause}`, 0)\n\n/** `?a=1&b=2`, dropping what was not asked for. Arrays repeat the key. */\nexport function qs(query?: Query): string {\n\tif (!query) return ''\n\tconst sp = new URLSearchParams()\n\tfor (const [key, value] of Object.entries(query)) {\n\t\t// Undefined, null and '' are \"did not ask\", not \"asked for nothing\":\n\t\t// `?q=` would filter to the empty string.\n\t\tif (value === undefined || value === null || value === '') continue\n\t\tif (Array.isArray(value)) for (const v of value) sp.append(key, String(v))\n\t\telse sp.append(key, String(value))\n\t}\n\tconst s = sp.toString()\n\treturn s ? `?${s}` : ''\n}\n\n/** The family's list shape, from the engine's `{data, meta}`. Totals are the engine's, never invented. */\nexport function toPage<T, U>(env: Envelope<T[] | null>, map: (row: T) => U) {\n\tconst rows = env.data ?? []\n\tconst meta = env.meta\n\treturn {\n\t\tdata: rows.map(map),\n\t\tcount: meta?.total ?? rows.length,\n\t\tpageSize: meta?.limit ?? rows.length,\n\t\tnoOfPage: meta?.total_pages ?? 1,\n\t\tpage: meta?.page ?? 1,\n\t}\n}\n\nexport const emptyPage = <T = never>() => ({ data: [] as T[], count: 0, pageSize: 0, noOfPage: 0, page: 1 })\n","import { remember } from '../cache'\nimport type { Category, CheckoutOptions, Plugin } from '../engine'\nimport { BaseService } from './base.service'\n\n/**\n * Store-level questions several services ask, answered once a minute.\n *\n * Not exported from the package: it is plumbing the other services share.\n */\nexport class StoreFacts extends BaseService {\n\tprivate key(name: string) {\n\t\treturn `${this.engineBase()}|${this.creds.store ?? ''}|${name}`\n\t}\n\n\t/** Enabled plugins by key. A module that is not installed has no key here. */\n\tplugins(): Promise<Map<string, Plugin>> {\n\t\treturn remember(this.key('plugins'), async () => {\n\t\t\tconst list = (await this.data<Plugin[] | null>('/api/plugins')) ?? []\n\t\t\treturn new Map(list.map((p) => [p.key, p]))\n\t\t})\n\t}\n\n\tasync pluginOn(key: string): Promise<boolean> {\n\t\ttry {\n\t\t\treturn (await this.plugins()).has(key)\n\t\t} catch {\n\t\t\treturn false\n\t\t}\n\t}\n\n\t/** The store's settlement currency and default language. */\n\tready(): Promise<{ currency: string; language: string; version: string }> {\n\t\treturn remember(this.key('ready'), () => this.data('/health/ready'))\n\t}\n\n\tcheckoutOptions(): Promise<CheckoutOptions> {\n\t\treturn remember(this.key('checkout'), () => this.data<CheckoutOptions>('/api/checkout'))\n\t}\n\n\t/**\n\t * The whole tree, flat and depth-first. Past 500 categories the engine\n\t * answers a truncated list; the tree then serves what it has, and a\n\t * breadcrumb for a category outside it falls back to the category alone.\n\t */\n\tcategories(): Promise<Category[]> {\n\t\treturn remember(\n\t\t\tthis.key('categories'),\n\t\t\tasync () => (await this.data<Category[] | null>('/api/categories', { query: { flat: 1 } })) ?? [],\n\t\t)\n\t}\n\n\t/** Root → `slug`, by walking parents in the flat tree. */\n\tasync hierarchy(slug: string): Promise<{ name: string; slug: string }[]> {\n\t\tconst all = await this.categories().catch(() => [] as Category[])\n\t\tconst byId = new Map(all.map((c) => [c.id, c]))\n\t\tconst out: { name: string; slug: string }[] = []\n\t\tlet c = all.find((x) => x.slug === slug)\n\t\twhile (c) {\n\t\t\tout.unshift({ name: c.title, slug: c.slug })\n\t\t\tc = c.parent_id === null ? undefined : byId.get(c.parent_id)\n\t\t}\n\t\treturn out\n\t}\n\n\t/** `slug` and every category under it — what a category page sells. */\n\tasync subtree(slug: string): Promise<Category[]> {\n\t\tconst all = await this.categories()\n\t\tconst root = all.find((c) => c.slug === slug)\n\t\tif (!root) return []\n\t\tconst ids = new Set([root.id])\n\t\tconst out = [root]\n\t\t// Depth-first and flat, so a parent always precedes its children.\n\t\tfor (const c of all) {\n\t\t\tif (c.parent_id !== null && ids.has(c.parent_id) && !ids.has(c.id)) {\n\t\t\t\tids.add(c.id)\n\t\t\t\tout.push(c)\n\t\t\t}\n\t\t}\n\t\treturn out\n\t}\n}\n","import type { Category, Product, SearchResult } from '../engine'\nimport { fromSearchDoc, toProduct } from '../map'\nimport { toMinor } from '../money'\nimport { BaseService, toPage } from './base.service'\nimport { StoreFacts } from './facts'\n\nexport const PAGE_SIZE = 24\n\nexport type CatalogQuery = {\n\tpage?: number\n\tlimit?: number\n\tsearch?: string\n\t/** The family's sort spellings: `-createdAt`, `price`, `price:asc`, `updatedAt:desc`, `-popularity`… */\n\tsort?: string\n\t/** A category slug: the page sells it and everything under it. */\n\tcategory?: string\n\tpriceFrom?: number\n\tpriceTo?: number\n}\n\nexport type CatalogPage = {\n\tdata: ReturnType<typeof toProduct>[] | ReturnType<typeof fromSearchDoc>[]\n\tcount: number\n\tpageSize: number\n\tnoOfPage: number\n\tpage: number\n\tcategoryHierarchy: { name: string; slug: string }[]\n\t/** Whether the answer honoured `sort` and the price range, or had to drop them. */\n\tsorted: boolean\n}\n\n/**\n * The family's sort names, in the search index's terms. The engine's own\n * listing has one order — newest first — so anything else needs the index.\n * Popularity has no answer anywhere: the engine keeps no such score, and\n * inventing one would sort the shop into a plausible-looking lie.\n */\nfunction indexSort(sort?: string): string | undefined {\n\tif (!sort) return undefined\n\tconst s = sort.trim()\n\tconst [field, dir] = s.startsWith('-') ? [s.slice(1), 'desc'] : s.includes(':') ? s.split(':') : [s, 'asc']\n\tconst d = dir === 'desc' ? 'desc' : 'asc'\n\tswitch (field) {\n\t\tcase 'price':\n\t\t\treturn `price_minor:${d}`\n\t\tcase 'updatedAt':\n\t\tcase 'updated_at':\n\t\tcase 'createdAt':\n\t\tcase 'created_at':\n\t\t\treturn `updated_at:${d}`\n\t\tcase 'title':\n\t\tcase 'name':\n\t\t\treturn `title:${d}`\n\t\tdefault:\n\t\t\treturn undefined\n\t}\n}\n\n/** Newest first is the engine's own order, so these need no index. */\nconst NATURAL = new Set([\n\t'-createdAt',\n\t'createdAt:desc',\n\t'-updatedAt',\n\t'updatedAt:desc',\n\t'-popularity',\n\t'popularity:desc',\n])\n\nconst quote = (s: string) => `\"${s.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`\n\n/**\n * One shelf of products, from whichever engine route can answer the question.\n *\n * - A category, no reordering: `GET /api/categories/{slug}`, which sells the\n * category and its descendants.\n * - A search or the whole shop, no reordering: `GET /api/products?q=`.\n * - Any sort but newest, or a price range: the Meilisearch module, when it is\n * installed and configured. Without it the shelf comes back in the engine's\n * order with `sorted: false`, rather than failing or pretending.\n */\nexport class CatalogService extends BaseService {\n\tprotected readonly facts = new StoreFacts(this._fetch)\n\n\tprotected async queryCatalog(q: CatalogQuery): Promise<CatalogPage> {\n\t\tconst page = Math.max(1, Number(q.page) || 1)\n\t\tconst limit = Math.min(100, Math.max(1, Number(q.limit) || PAGE_SIZE))\n\t\tconst search = q.search?.trim() || undefined\n\t\tconst wantsRange = Number.isFinite(q.priceFrom) || Number.isFinite(q.priceTo)\n\t\tconst sortKey = q.sort && !NATURAL.has(q.sort) ? indexSort(q.sort) : undefined\n\t\tconst hierarchy = q.category ? await this.facts.hierarchy(q.category) : []\n\n\t\tif ((sortKey || wantsRange) && (await this.facts.pluginOn('meilisearch'))) {\n\t\t\tconst filters: string[] = []\n\t\t\tif (q.category) {\n\t\t\t\tconst names = (await this.facts.subtree(q.category).catch(() => [] as Category[])).map((c) =>\n\t\t\t\t\tquote(c.full_name),\n\t\t\t\t)\n\t\t\t\t// A slug the tree does not know sells nothing — say so, don't widen to the shop.\n\t\t\t\tif (!names.length) return { ...emptyCatalog(limit), categoryHierarchy: hierarchy, sorted: true }\n\t\t\t\tfilters.push(`category IN [${names.join(', ')}]`)\n\t\t\t}\n\t\t\tif (wantsRange) {\n\t\t\t\tconst { currency } = await this.facts.ready()\n\t\t\t\tif (Number.isFinite(q.priceFrom)) filters.push(`price_minor >= ${toMinor(q.priceFrom as number, currency)}`)\n\t\t\t\tif (Number.isFinite(q.priceTo)) filters.push(`price_minor <= ${toMinor(q.priceTo as number, currency)}`)\n\t\t\t}\n\t\t\tconst res = await this.data<SearchResult>('/x/meilisearch/search', {\n\t\t\t\tquery: {\n\t\t\t\t\tq: search ?? '',\n\t\t\t\t\tlimit,\n\t\t\t\t\toffset: (page - 1) * limit,\n\t\t\t\t\tfilter: filters.join(' AND ') || undefined,\n\t\t\t\t\tsort: sortKey,\n\t\t\t\t},\n\t\t\t})\n\t\t\tconst total = res.total ?? 0\n\t\t\treturn {\n\t\t\t\tdata: (res.hits ?? []).map(fromSearchDoc),\n\t\t\t\tcount: total,\n\t\t\t\tpageSize: limit,\n\t\t\t\tnoOfPage: Math.max(1, Math.ceil(total / limit)),\n\t\t\t\tpage,\n\t\t\t\tcategoryHierarchy: hierarchy,\n\t\t\t\tsorted: true,\n\t\t\t}\n\t\t}\n\n\t\tconst sorted = !sortKey && !wantsRange\n\t\tif (q.category && !search) {\n\t\t\tconst env = await this.engine<{ products: Product[] | null }>(\n\t\t\t\t`/api/categories/${encodeURIComponent(q.category)}`,\n\t\t\t\t{ query: { page, limit } },\n\t\t\t)\n\t\t\tconst products = env.data?.products ?? []\n\t\t\treturn {\n\t\t\t\t...toPage({ data: products, meta: env.meta }, (p: Product) => toProduct(p)),\n\t\t\t\tcategoryHierarchy: hierarchy,\n\t\t\t\tsorted,\n\t\t\t}\n\t\t}\n\t\t// A search inside a category, without the index, searches the whole shop:\n\t\t// the engine's category route takes no query and its search takes no\n\t\t// category, and filtering one page client-side would make the count a lie.\n\t\tconst env = await this.engine<Product[] | null>('/api/products', {\n\t\t\tquery: { q: search, page, limit, channel: this.creds.channel },\n\t\t})\n\t\treturn { ...toPage(env, (p: Product) => toProduct(p)), categoryHierarchy: hierarchy, sorted }\n\t}\n}\n\nexport function emptyCatalog(limit = PAGE_SIZE) {\n\treturn { data: [], count: 0, pageSize: limit, noOfPage: 0, page: 1 }\n}\n","import type { Product, ReviewPage } from '../engine'\nimport { GoCommerceError, NotSupportedError } from '../errors'\nimport { toProduct, toRating } from '../map'\nimport { currentMe } from '../browser'\nimport { CatalogService, PAGE_SIZE, type CatalogQuery } from './catalog'\n\n/**\n * Products: one by slug, and the shelves the homepage and listings draw.\n *\n * \"Featured\" and \"trending\" are curated rather than computed — the engine\n * keeps no sales or view counts to rank by. A collection with the slug\n * `featured` (or `trending`) is that shelf, so a merchant curates it in the\n * panel; without one, the shelf is the newest products, and says nothing more\n * about them than that.\n */\nexport class ProductService extends CatalogService {\n\t/**\n\t * A product page. `slug` may also be a numeric id or a variant SKU, which is\n\t * how an old link or a search hit sometimes arrives.\n\t *\n\t * Reviews ride along when ext/reviews is installed and switched on; a review\n\t * failure never costs the shopper the product page.\n\t */\n\tasync getOne(slug: string) {\n\t\tconst p = await this.findProduct(String(slug))\n\t\tconst product = toProduct(p, {\n\t\t\tcategoryHierarchy: p.category ? await this.facts.hierarchy(p.category.slug) : [],\n\t\t})\n\t\tif (await this.facts.pluginOn('product-reviews')) {\n\t\t\ttry {\n\t\t\t\tconst res = await this.data<ReviewPage>('/x/reviews', { query: { product_id: p.id, limit: 50 } })\n\t\t\t\tproduct.ratings = (res.reviews ?? []).map(toRating)\n\t\t\t\tproduct.rating = res.summary?.count ? res.summary.average : null\n\t\t\t\tproduct.ratingCount = res.summary?.count ?? 0\n\t\t\t\tproduct.reviewCount = res.summary?.count ?? 0\n\t\t\t} catch {\n\t\t\t\t// The page renders without stars rather than not at all.\n\t\t\t}\n\t\t}\n\t\treturn product\n\t}\n\n\tprivate async findProduct(slug: string): Promise<Product> {\n\t\ttry {\n\t\t\treturn await this.data<Product>(`/api/products/slug/${encodeURIComponent(slug)}`)\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof GoCommerceError) || err.status !== 404) throw err\n\t\t\t// Not a slug. An id or a SKU is worth one more question each, and a\n\t\t\t// miss on all three is the product's 404, not theirs.\n\t\t\tconst fallback = /^\\d+$/.test(slug) ? `/api/products/${slug}` : `/api/products/sku/${encodeURIComponent(slug)}`\n\t\t\ttry {\n\t\t\t\treturn await this.data<Product>(fallback)\n\t\t\t} catch {\n\t\t\t\tthrow err\n\t\t\t}\n\t\t}\n\t}\n\n\t/** The shop's listing: `{ page, search, sort }`, newest first unless the index can reorder it. */\n\tasync list({\n\t\tpage = 1,\n\t\tsearch,\n\t\tq,\n\t\tsort,\n\t\tlimit,\n\t\tcategories,\n\t}: CatalogQuery & { q?: string; categories?: string } = {}) {\n\t\tconst res = await this.queryCatalog({ page, search: search ?? q, sort, limit, category: categories || undefined })\n\t\treturn { data: res.data, count: res.count, pageSize: res.pageSize, noOfPage: res.noOfPage, page: res.page }\n\t}\n\n\tasync listFeaturedProducts({ page = 1, sort, limit }: { page?: number; sort?: string; limit?: number } = {}) {\n\t\treturn this.shelf('featured', { page, sort, limit })\n\t}\n\n\tasync listTrendingProducts({ page = 1, limit }: { page?: number; limit?: number } = {}) {\n\t\treturn this.shelf('trending', { page, limit })\n\t}\n\n\t/** More from this product's category. */\n\tasync listRelatedProducts({\n\t\tpage = 1,\n\t\tcategoryId,\n\t\tlimit,\n\t}: { page?: number; categoryId?: string; limit?: number } = {}) {\n\t\tif (!categoryId) return this.list({ page, limit })\n\t\tconst category = (await this.facts.categories()).find((c) => String(c.id) === String(categoryId))\n\t\tif (!category) return this.list({ page, limit })\n\t\treturn this.list({ page, limit, categories: category.slug })\n\t}\n\n\tprivate async shelf(slug: string, { page, sort, limit }: { page: number; sort?: string; limit?: number }) {\n\t\tconst size = Math.min(100, Math.max(1, Number(limit) || PAGE_SIZE))\n\t\ttry {\n\t\t\tconst env = await this.engine<{ products: Product[] | null }>(`/api/collections/${slug}`, {\n\t\t\t\tquery: { page, limit: size },\n\t\t\t})\n\t\t\tconst rows = env.data?.products ?? []\n\t\t\treturn {\n\t\t\t\tdata: rows.map((p) => toProduct(p)),\n\t\t\t\tcount: env.meta?.total ?? rows.length,\n\t\t\t\tpageSize: env.meta?.limit ?? size,\n\t\t\t\tnoOfPage: env.meta?.total_pages ?? 1,\n\t\t\t\tpage: env.meta?.page ?? page,\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tif (!(err instanceof GoCommerceError) || err.status !== 404) throw err\n\t\t\treturn this.list({ page, sort, limit: size })\n\t\t}\n\t}\n\n\t/**\n\t * A review, through ext/reviews. The engine asks for a name and an email\n\t * with every review, so a signed-out shopper is asked to sign in rather\n\t * than having one made up for them. Uploaded photos have nowhere to go: the\n\t * module stores text.\n\t */\n\tasync addReview({\n\t\tproductId,\n\t\trating,\n\t\treview,\n\t\ttitle,\n\t}: {\n\t\tproductId: string\n\t\tvariantId?: string\n\t\trating: number\n\t\treview: string\n\t\ttitle?: string\n\t}) {\n\t\tconst me = currentMe()\n\t\tif (!me?.email) throw new GoCommerceError('Please sign in to write a review.', 401, 'unauthorized')\n\t\tconst name = [me.firstName, me.lastName].filter(Boolean).join(' ') || me.email.split('@')[0]\n\t\treturn this.data<{ status: string; verified: boolean }>('/x/reviews', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: {\n\t\t\t\tproduct_id: Number(productId),\n\t\t\t\tname,\n\t\t\t\temail: me.email,\n\t\t\t\trating: Math.round(Number(rating)),\n\t\t\t\t...(title ? { title } : {}),\n\t\t\t\tbody: String(review ?? ''),\n\t\t\t},\n\t\t})\n\t}\n\n\tasync fetchReels(): Promise<never> {\n\t\tthrow new NotSupportedError('ProductService', 'fetchReels', 'the engine has no reels')\n\t}\n}\n\nexport const productService = new ProductService()\n","import { CatalogService } from './catalog'\n\nconst num = (v: string | null): number | undefined => {\n\tif (v === null || v.trim() === '') return undefined\n\tconst n = Number(v)\n\treturn Number.isFinite(n) ? n : undefined\n}\n\n/**\n * The listing pages' search: `/products?search=&sort=&page=` and the category\n * catch-all `/{slug}`.\n *\n * Facets are empty. The engine's search route returns hits and a total, not\n * distributions, and a facet list made from one page of hits would count that\n * page, not the shop. An empty `priceStat` hides the price slider rather than\n * drawing one with a made-up range.\n */\nexport class SearchService extends CatalogService {\n\temptyResult() {\n\t\treturn {\n\t\t\tdata: [],\n\t\t\tcount: 0,\n\t\t\ttotalPages: 0,\n\t\t\tcategoryHierarchy: [] as { name: string; slug: string }[],\n\t\t\tfacets: { priceStat: {}, categories: [], tags: [], allFilters: {} },\n\t\t}\n\t}\n\n\tasync searchWithUrl(url: URL | string, slug?: string) {\n\t\ttry {\n\t\t\tconst u = typeof url === 'string' ? new URL(url, 'http://localhost') : url\n\t\t\tconst p = u.searchParams\n\t\t\t// `?price=10,50` is the chip form; priceFrom/priceTo the slider's.\n\t\t\tconst [from, to] = (p.get('price') ?? '').split(/[,-]/)\n\t\t\tconst res = await this.queryCatalog({\n\t\t\t\tpage: num(p.get('page')),\n\t\t\t\tsearch: p.get('search') ?? p.get('q') ?? undefined,\n\t\t\t\tsort: p.get('sort') ?? undefined,\n\t\t\t\tcategory: slug || p.get('categories')?.split(',')[0] || undefined,\n\t\t\t\tpriceFrom: num(p.get('priceFrom')) ?? num(from ?? null),\n\t\t\t\tpriceTo: num(p.get('priceTo')) ?? num(to ?? null),\n\t\t\t})\n\t\t\treturn {\n\t\t\t\tdata: res.data,\n\t\t\t\tcount: res.count,\n\t\t\t\ttotalPages: res.noOfPage,\n\t\t\t\tpage: res.page,\n\t\t\t\tcategoryHierarchy: res.categoryHierarchy,\n\t\t\t\tfacets: { priceStat: {}, categories: [], tags: [], allFilters: {} },\n\t\t\t}\n\t\t} catch (err) {\n\t\t\t// A missing category is an empty result — the route turns that into\n\t\t\t// its 404 — but an engine that cannot be reached is not, and says so.\n\t\t\tif ((err as { status?: number })?.status === 404) return this.emptyResult()\n\t\t\tthrow err\n\t\t}\n\t}\n}\n\nexport const searchService = new SearchService()\n","import type { Product, SearchResult } from '../engine'\nimport { fromSearchDoc, toProduct } from '../map'\nimport { CatalogService } from './catalog'\n\n/**\n * The two places the storefront asks for raw search hits: \"more from this\n * category\" on a product page, and the header's type-ahead.\n *\n * Both go through ext/search-meilisearch when it is installed, and through the\n * engine's own listing when it is not — a type-ahead backed by a LIKE query is\n * slower and unranked, but it is not empty.\n */\nexport class MeilisearchService extends CatalogService {\n\t/** `{ query, categories, page }` → a Meilisearch-shaped answer: `hits`, `totalHits`, `totalPages`. */\n\tasync search({\n\t\tquery,\n\t\tsearch,\n\t\tcategories,\n\t\tpage = 1,\n\t\tlimit,\n\t}: { query?: string; search?: string; categories?: string; page?: number; limit?: number } = {}) {\n\t\tconst res = await this.queryCatalog({ page, limit, search: query ?? search, category: categories || undefined })\n\t\treturn {\n\t\t\thits: res.data,\n\t\t\ttotalHits: res.count,\n\t\t\testimatedTotalHits: res.count,\n\t\t\ttotalPages: res.noOfPage,\n\t\t\tpage: res.page,\n\t\t\tcategories: res.categoryHierarchy,\n\t\t\tfacetDistribution: {},\n\t\t}\n\t}\n\n\t/** The header's type-ahead: `{ data: [{ slug, title, thumbnail, price }] }`. */\n\tasync searchAutoComplete({ query, search, limit = 8 }: { query?: string; search?: string; limit?: number } = {}) {\n\t\tconst q = (query ?? search ?? '').trim()\n\t\tif (!q) return { data: [] }\n\t\tif (await this.facts.pluginOn('meilisearch')) {\n\t\t\tconst res = await this.data<SearchResult>('/x/meilisearch/search', { query: { q, limit } })\n\t\t\treturn { data: (res.hits ?? []).map(fromSearchDoc) }\n\t\t}\n\t\tconst rows =\n\t\t\t(await this.data<Product[] | null>('/api/products', { query: { q, limit, channel: this.creds.channel } })) ?? []\n\t\treturn { data: rows.map((p) => toProduct(p)) }\n\t}\n}\n\nexport const meilisearchService = new MeilisearchService()\n","import type { Category } from '../engine'\nimport { toCategory } from '../map'\nimport { BaseService } from './base.service'\nimport { StoreFacts } from './facts'\n\nconst asList = (rows: ReturnType<typeof toCategory>[]) => ({\n\tdata: rows,\n\tcount: rows.length,\n\tpageSize: rows.length,\n\tnoOfPage: 1,\n\tpage: 1,\n})\n\n/**\n * The category tree. The engine has no \"featured\" flag on a category, so the\n * featured row is the top level of the tree, in the merchant's order — which\n * is what a shop's first row of category tiles usually is anyway.\n */\nexport class CategoryService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\n\t/** Every category, flat, each naming its parent. The storefront builds the tree. */\n\tasync fetchAllCategories(_args: Record<string, unknown> = {}) {\n\t\tconst all = await this.facts.categories()\n\t\treturn asList(all.map(flat))\n\t}\n\n\tasync fetchFeaturedCategories({ limit = 18 }: { limit?: number } = {}) {\n\t\tconst roots = (await this.facts.categories()).filter((c) => c.parent_id === null)\n\t\treturn asList(roots.slice(0, Math.max(0, Number(limit) || 18)).map(flat))\n\t}\n\n\tasync fetchFooterCategories(args: { limit?: number } = {}) {\n\t\treturn this.fetchFeaturedCategories(args)\n\t}\n\n\t/** The nested tree, roots first. */\n\tasync getMegamenu(_args: Record<string, unknown> = {}) {\n\t\tconst tree = (await this.data<Category[] | null>('/api/categories')) ?? []\n\t\treturn tree.map(toCategory)\n\t}\n\n\tasync fetchCategory(slug: string) {\n\t\tconst c = await this.data<Category>(`/api/categories/${encodeURIComponent(slug)}`, { query: { limit: 1 } })\n\t\treturn toCategory(c)\n\t}\n\n\t/**\n\t * kitcommerce-core's category filter asks for `/api/categories/all` by path,\n\t * through the family's raw `get`. That is a Litekart path the rest-guard\n\t * would swallow, so it is answered here, from the engine's tree.\n\t */\n\toverride async get<T = any>(path: string): Promise<T> {\n\t\tif (path.split('?')[0] === '/api/categories/all') return (await this.fetchAllCategories()) as T\n\t\treturn super.get<T>(path)\n\t}\n}\n\n/** One row of the flat tree: no `children`, so the storefront's builder is the only one. */\nconst flat = (c: Category) => ({ ...toCategory(c), children: [] })\n\nexport const categoryService = new CategoryService()\n","import type { Collection, Product } from '../engine'\nimport { toCollection, toProduct } from '../map'\nimport { BaseService, toPage } from './base.service'\n\n/** Curated lists. Only collections holding at least one product on sale are listed. */\nexport class CollectionService extends BaseService {\n\tasync list({ page = 1, limit = 24 }: { page?: number; limit?: number; sort?: string; q?: string } = {}) {\n\t\tconst env = await this.engine<Collection[] | null>('/api/collections', { query: { page, limit } })\n\t\treturn toPage(env, toCollection)\n\t}\n\n\t/** A collection page: the collection, and its products in the merchant's order. */\n\tasync getOne(slug: string, { page = 1, limit = 48 }: { page?: number; limit?: number } = {}) {\n\t\tconst env = await this.engine<Collection & { products: Product[] | null }>(\n\t\t\t`/api/collections/${encodeURIComponent(slug)}`,\n\t\t\t{ query: { page, limit } },\n\t\t)\n\t\tconst products = (env.data.products ?? []).map((p) => toProduct(p))\n\t\treturn {\n\t\t\t...toCollection(env.data),\n\t\t\tproducts,\n\t\t\t// The family's shape for a collection's members.\n\t\t\tcollectionvalues: products.map((p) => ({ products: p })),\n\t\t\tcount: env.meta?.total ?? products.length,\n\t\t\tnoOfPage: env.meta?.total_pages ?? 1,\n\t\t\tpage: env.meta?.page ?? page,\n\t\t}\n\t}\n\n\t/** Collection-level ratings are a Litekart aggregate; the engine has none to report. */\n\tasync getAllRatings() {\n\t\treturn { data: [] as unknown[] }\n\t}\n}\n\nexport const collectionService = new CollectionService()\n","import type { AppliedDiscount, Cart, CartLine, Product } from '../engine'\nimport { GoCommerceError, NotSupportedError } from '../errors'\nimport { emptyCart, toCart } from '../map'\nimport { remember } from '../cache'\nimport {\n\tcartExtras,\n\tforgetCartExtras,\n\trememberCartId,\n\tsaveCartExtras,\n\tsessionToken,\n\tstoredCartId,\n\ttype StorefrontAddress,\n} from '../browser'\nimport { BaseService } from './base.service'\nimport { StoreFacts } from './facts'\n\n/** The storefront's \"take this line out\" sentinel, sent when − is pressed on a quantity of one. */\nconst REMOVE = -9999999\n\n/**\n * The bag.\n *\n * The engine's cart is addressed by an opaque token it mints, held by the\n * storefront in `localStorage.cart_id`. It keeps lines and an email; the\n * coupon, the address and the delivery choice the storefront collects before\n * checkout are kept beside it in the browser (browser.ts) and sent with the\n * checkout request, which is the only place the engine takes them.\n *\n * Every method answers the whole cart, as the storefront assigns it whole.\n */\nexport class CartService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\n\tasync getCartByCartId(cartId?: string | null) {\n\t\tconst id = clean(cartId)\n\t\tif (!id) return emptyCart(await this.currency())\n\t\ttry {\n\t\t\treturn await this.present(await this.data<Cart>(`/api/carts/${encodeURIComponent(id)}`))\n\t\t} catch (err) {\n\t\t\t// A cart expires after a month untouched. A shopper coming back to a\n\t\t\t// dead token sees an empty bag, not an error.\n\t\t\tif (err instanceof GoCommerceError && err.status === 404) return emptyCart(await this.currency())\n\t\t\tthrow err\n\t\t}\n\t}\n\n\tasync fetchCartData(cartId?: string | null) {\n\t\treturn this.getCartByCartId(cartId ?? storedCartId())\n\t}\n\n\t/**\n\t * The cart after an order: the engine marks it `converted` and keeps its\n\t * lines, and this answers it with none — which is how the storefront knows\n\t * to clear the bag on the success page.\n\t */\n\tasync refereshCart() {\n\t\tconst id = storedCartId()\n\t\tconst cart = await this.getCartByCartId(id)\n\t\tif (id && (cart as { status?: string }).status === 'converted') forgetCartExtras(id)\n\t\treturn cart\n\t}\n\n\t/**\n\t * `qty` is a change, not a total: +1 from a product page, −1 from a card's\n\t * minus button. With no cart yet, one is opened and remembered.\n\t */\n\tasync addToCart({\n\t\tcartId,\n\t\tlineId,\n\t\tqty = 1,\n\t\tvariantId,\n\t}: {\n\t\tcartId?: string | null\n\t\tlineId?: string | null\n\t\tqty?: number\n\t\tproductId?: string\n\t\tvariantId?: string\n\t}) {\n\t\tlet id = clean(cartId) ?? storedCartId()\n\t\tif (lineId && id) {\n\t\t\tconst cart = await this.data<Cart>(`/api/carts/${encodeURIComponent(id)}`)\n\t\t\tconst line = (cart.line_items ?? []).find((l) => String(l.id) === String(lineId))\n\t\t\tif (line) {\n\t\t\t\tconst next = qty === REMOVE ? 0 : line.quantity + Number(qty)\n\t\t\t\treturn this.setQuantity(id, line.id, next)\n\t\t\t}\n\t\t}\n\t\tif (qty === REMOVE || Number(qty) <= 0) return this.getCartByCartId(id)\n\t\tif (!variantId) throw new GoCommerceError('Please choose an option before adding this to your bag.', 400)\n\t\tif (!id) id = await this.open()\n\t\ttry {\n\t\t\treturn await this.present(\n\t\t\t\tawait this.data<Cart>(`/api/carts/${encodeURIComponent(id)}/line-items`, {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: { variant_id: Number(variantId), quantity: Number(qty) },\n\t\t\t\t}),\n\t\t\t)\n\t\t} catch (err) {\n\t\t\t// The remembered cart was checked out in another tab, or expired.\n\t\t\t// Start a new one rather than refusing the shopper's click.\n\t\t\tif (err instanceof GoCommerceError && (err.status === 404 || /checked out/.test(err.message))) {\n\t\t\t\tconst fresh = await this.open()\n\t\t\t\treturn this.present(\n\t\t\t\t\tawait this.data<Cart>(`/api/carts/${encodeURIComponent(fresh)}/line-items`, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\tbody: { variant_id: Number(variantId), quantity: Number(qty) },\n\t\t\t\t\t}),\n\t\t\t\t)\n\t\t\t}\n\t\t\tthrow err\n\t\t}\n\t}\n\n\t/** `qty` is the new total; 0 takes the line out. */\n\tasync updateCart({\n\t\tcartId,\n\t\tlineId,\n\t\tqty,\n\t}: {\n\t\tcartId?: string\n\t\tlineId: string\n\t\tqty: number\n\t\tisSelectedForCheckout?: boolean\n\t}) {\n\t\tconst id = clean(cartId) ?? storedCartId()\n\t\tif (!id) return emptyCart(await this.currency())\n\t\treturn this.setQuantity(id, lineId, Number(qty))\n\t}\n\n\tasync removeCart({ cartId, lineId }: { cartId?: string; lineId: string }) {\n\t\tconst id = clean(cartId) ?? storedCartId()\n\t\tif (!id) return emptyCart(await this.currency())\n\t\treturn this.present(\n\t\t\tawait this.data<Cart>(`/api/carts/${encodeURIComponent(id)}/line-items/${encodeURIComponent(String(lineId))}`, {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t}),\n\t\t)\n\t}\n\n\t/**\n\t * Contact details and addresses, from the checkout's address step. The\n\t * email goes to the engine — it is how an abandoned cart is followed up —\n\t * and the rest is kept for the checkout request.\n\t */\n\tasync updateCart2(args: {\n\t\tcartId?: string\n\t\temail?: string\n\t\tphone?: string\n\t\tshippingAddress?: StorefrontAddress | null\n\t\tbillingAddress?: StorefrontAddress | null\n\t\tisBillingAddressSameAsShipping?: boolean\n\t}) {\n\t\tconst id = clean(args.cartId) ?? storedCartId()\n\t\tif (!id) return emptyCart(await this.currency())\n\n\t\tconst patch: Parameters<typeof saveCartExtras>[1] = {}\n\t\tif (args.phone !== undefined) patch.phone = args.phone || undefined\n\t\tif (args.shippingAddress !== undefined) {\n\t\t\tpatch.shippingAddress = args.shippingAddress\n\t\t\tif (args.shippingAddress?.phone && !patch.phone) patch.phone = String(args.shippingAddress.phone)\n\t\t}\n\t\tif (args.billingAddress !== undefined || args.isBillingAddressSameAsShipping) {\n\t\t\tpatch.billingAddress = args.isBillingAddressSameAsShipping ? null : (args.billingAddress ?? null)\n\t\t}\n\t\t// A new destination may not be served by the rate chosen for the old one.\n\t\tconst before = cartExtras(id)\n\t\tconst country = (a?: StorefrontAddress | null) => String(a?.countryCode || a?.country || '').toUpperCase()\n\t\tif (args.shippingAddress !== undefined && country(args.shippingAddress) !== country(before.shippingAddress)) {\n\t\t\tpatch.shippingRateId = null\n\t\t\tpatch.shippingRate = null\n\t\t}\n\t\tsaveCartExtras(id, patch)\n\n\t\tconst email = args.email ?? (args.shippingAddress?.email ? String(args.shippingAddress.email) : undefined)\n\t\tif (email !== undefined) {\n\t\t\treturn this.present(\n\t\t\t\tawait this.data<Cart>(`/api/carts/${encodeURIComponent(id)}/email`, { method: 'PUT', body: { email } }),\n\t\t\t)\n\t\t}\n\t\treturn this.getCartByCartId(id)\n\t}\n\n\t/**\n\t * A discount code. The engine prices it against the basket now and decides\n\t * it again at checkout; what it answers is kept so the bag can show it,\n\t * because the cart itself does not carry the code.\n\t */\n\tasync applyCoupon({ cartId, couponCode }: { cartId?: string; couponCode: string }) {\n\t\tconst id = clean(cartId) ?? storedCartId()\n\t\tif (!id) throw new GoCommerceError('Add something to your bag before applying a code.', 400)\n\t\tconst cart = await this.data<Cart>(`/api/carts/${encodeURIComponent(id)}`)\n\t\tconst discount = await this.data<AppliedDiscount>(`/api/carts/${encodeURIComponent(id)}/discount`, {\n\t\t\tmethod: 'PUT',\n\t\t\tbody: { code: String(couponCode ?? '').trim(), ...(cart.email ? { email: cart.email } : {}) },\n\t\t})\n\t\tsaveCartExtras(id, { discount: { ...discount, code: discount.code || String(couponCode).trim() } })\n\t\treturn this.present(cart)\n\t}\n\n\tasync removeCoupon(cartId?: string) {\n\t\tconst id = clean(cartId) ?? storedCartId()\n\t\tif (!id) return emptyCart(await this.currency())\n\t\tawait this.engine(`/api/carts/${encodeURIComponent(id)}/discount`, { method: 'DELETE' })\n\t\tsaveCartExtras(id, { discount: null })\n\t\treturn this.getCartByCartId(id)\n\t}\n\n\t/** The delivery option the shopper picked, priced from the engine's own quote. */\n\tasync updateShippingRate({ cartId, shippingRateId }: { cartId?: string; shippingRateId: string }) {\n\t\tconst id = clean(cartId) ?? storedCartId()\n\t\tif (!id) return emptyCart(await this.currency())\n\t\tconst ship = cartExtras(id).shippingAddress\n\t\tconst country = String(ship?.countryCode || ship?.country || '').toUpperCase()\n\t\tif (!country) throw new GoCommerceError('Add a delivery address first.', 400)\n\t\tconst quote = await this.data<{\n\t\t\trates: { rate_id: number; name: string; price: { amount_minor: number; currency: string } }[] | null\n\t\t\tcurrency: string\n\t\t}>('/api/checkout/rates', { query: { cart: id, country, state: ship?.state ? String(ship.state) : undefined } })\n\t\tconst rate = (quote.rates ?? []).find((r) => String(r.rate_id) === String(shippingRateId))\n\t\tif (!rate) throw new GoCommerceError('That delivery option is not available for this address any more.', 409)\n\t\tsaveCartExtras(id, {\n\t\t\tshippingRateId: String(rate.rate_id),\n\t\t\tshippingRate: {\n\t\t\t\tid: String(rate.rate_id),\n\t\t\t\tname: rate.name,\n\t\t\t\tminor: rate.price.amount_minor,\n\t\t\t\tcurrency: rate.price.currency,\n\t\t\t},\n\t\t})\n\t\treturn this.getCartByCartId(id)\n\t}\n\n\t/** The payment method is chosen at checkout, by which checkout route is called. */\n\tasync updateCartPaymentMethod({ cartId }: { cartId?: string; paymentMethod?: string }) {\n\t\treturn this.getCartByCartId(clean(cartId) ?? storedCartId())\n\t}\n\n\tasync completeCart(): Promise<never> {\n\t\tthrow new NotSupportedError('CartService', 'completeCart', 'an order is placed through checkoutService')\n\t}\n\n\t// ------------------------------------------------------------ internals\n\n\tprivate async setQuantity(cartId: string, lineId: string | number, qty: number) {\n\t\tconst path = `/api/carts/${encodeURIComponent(cartId)}/line-items/${encodeURIComponent(String(lineId))}`\n\t\t// Zero is a removal: the engine accepts it on PATCH, and DELETE says it plainly.\n\t\tif (qty <= 0) return this.present(await this.data<Cart>(path, { method: 'DELETE' }))\n\t\treturn this.present(await this.data<Cart>(path, { method: 'PATCH', body: { quantity: qty } }))\n\t}\n\n\t/** A new cart, remembered — and priced for the signed-in shopper's group when the engine allows it. */\n\tprivate async open(): Promise<string> {\n\t\tconst channel = this.creds.channel\n\t\tconst cart = await this.data<Cart>('/api/carts', { method: 'POST', ...(channel ? { body: { channel } } : {}) })\n\t\trememberCartId(cart.id)\n\t\tif (sessionToken()) await this.claimCartForAccount(cart.id)\n\t\treturn cart.id\n\t}\n\n\tprivate async currency(): Promise<string> {\n\t\ttry {\n\t\t\treturn (await this.facts.ready()).currency\n\t\t} catch {\n\t\t\treturn 'USD'\n\t\t}\n\t}\n\n\t/** The engine's cart with the browser-held extras and each line's picture and link. */\n\tprivate async present(cart: Cart) {\n\t\tconst ids = [...new Set((cart.line_items ?? []).map((l) => l.product_id))]\n\t\tconst products = new Map<number, Product | null>()\n\t\tawait Promise.all(\n\t\t\tids.map(async (pid) => {\n\t\t\t\tproducts.set(pid, await this.productFor(pid))\n\t\t\t}),\n\t\t)\n\t\treturn toCart(cart, cartExtras(cart.id), (l: CartLine) => {\n\t\t\tconst p = products.get(l.product_id)\n\t\t\tif (!p) return {}\n\t\t\tconst v = (p.variants ?? []).find((x) => x.id === l.variant_id)\n\t\t\treturn { slug: p.slug, thumbnail: v?.image?.url ?? p.image_url ?? null }\n\t\t})\n\t}\n\n\tprivate productFor(id: number): Promise<Product | null> {\n\t\treturn remember(`${this.engineBase()}|product|${id}`, () =>\n\t\t\tthis.data<Product>(`/api/products/${id}`).catch(() => null),\n\t\t)\n\t}\n}\n\nconst clean = (id?: string | null): string | null => (id && id !== 'undefined' && id !== 'null' ? id : null)\n\nexport const cartService = new CartService()\n","import type { Cart, CheckoutResult } from '../engine'\nimport { GoCommerceError, NotSupportedError } from '../errors'\nimport { toEngineAddress } from '../map'\nimport { minorToMajor } from '../money'\nimport {\n\tcartExtras,\n\tplacedOrderByReference,\n\trememberOrder,\n\tsaveCartExtras,\n\tsessionToken,\n\tstoredCartId,\n} from '../browser'\nimport { BaseService } from './base.service'\n\n/**\n * Placing an order.\n *\n * The engine turns a cart into an order in one call, `POST /api/checkout/{code}`,\n * and that call is the only thing that moves stock and asks for money. It takes\n * the address, phone and delivery choice in its body — the cart keeps none of\n * them — so they are read back from what the address step stored (browser.ts).\n *\n * Payment is confirmed by the gateway's webhook to the engine, never by the\n * storefront. So the \"capture\" calls the storefront makes after a gateway's\n * modal closes do not capture anything: they hand back the order number, and\n * the order page shows `payment_status` once the webhook has landed.\n */\nexport class CheckoutService extends BaseService {\n\t/** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */\n\tasync getShippingRates({ cartId }: { cartId?: string } = {}) {\n\t\tconst id = cartId || storedCartId()\n\t\tconst ship = id ? cartExtras(id).shippingAddress : null\n\t\tconst country = String(ship?.countryCode || ship?.country || '').toUpperCase()\n\t\tif (!id || !country) return { data: [] }\n\t\tconst quote = await this.data<{\n\t\t\trates: { rate_id: number; name: string; price: { amount_minor: number; currency: string } }[] | null\n\t\t\tcurrency: string\n\t\t}>('/api/checkout/rates', { query: { cart: id, country, state: ship?.state ? String(ship.state) : undefined } })\n\t\treturn {\n\t\t\tdata: (quote.rates ?? []).map((r) => ({\n\t\t\t\tid: String(r.rate_id),\n\t\t\t\tname: r.name,\n\t\t\t\tdescription: null,\n\t\t\t\tbase_rate: minorToMajor(r.price.amount_minor, r.price.currency),\n\t\t\t\tprice: minorToMajor(r.price.amount_minor, r.price.currency),\n\t\t\t\tcurrencyCode: r.price.currency,\n\t\t\t\t// The engine's rates carry no delivery estimate; none is made up.\n\t\t\t\testimated_min_days: null,\n\t\t\t\testimated_max_days: null,\n\t\t\t})),\n\t\t}\n\t}\n\n\t/** Cash on delivery: the order is confirmed at once and paid on the doorstep. */\n\tasync checkoutCOD({ cartId }: { cartId?: string; origin?: string } = {}) {\n\t\tconst result = await this.place('cod', cartId)\n\t\treturn {\n\t\t\torder_no: result.order.number,\n\t\t\torderNo: result.order.number,\n\t\t\tid: String(result.order.id),\n\t\t\tstatus: result.order.status,\n\t\t}\n\t}\n\n\t/**\n\t * Razorpay's modal. The engine has already created the Razorpay order; this\n\t * hands the storefront what the modal needs. A store running Razorpay's\n\t * hosted (redirect) mode cannot be driven from this storefront's modal flow,\n\t * and says so rather than opening a modal on an order it cannot pay.\n\t */\n\tasync checkoutRazorpay({ cartId }: { cartId?: string; origin?: string } = {}) {\n\t\tconst result = await this.place('razorpay', cartId)\n\t\tconst data = result.payment.client_data ?? {}\n\t\tif (result.payment.kind !== 'client_action' || !data.razorpay_order_id) {\n\t\t\tthrow new GoCommerceError(\n\t\t\t\t'This store takes Razorpay payments on Razorpay’s own page, which this storefront does not support yet.',\n\t\t\t\t0,\n\t\t\t)\n\t\t}\n\t\treturn {\n\t\t\torder_no: result.order.number,\n\t\t\tid: data.razorpay_order_id,\n\t\t\tkey_id: data.key_id,\n\t\t\tamount: Number(data.amount),\n\t\t\tcurrency: data.currency,\n\t\t}\n\t}\n\n\t/** The modal closed with a payment. The engine learns of it from Razorpay itself. */\n\tasync captureRazorpayPayment({ razorpay_order_id }: { razorpay_order_id: string; razorpay_payment_id?: string }) {\n\t\tconst order = placedOrderByReference(razorpay_order_id)\n\t\tif (!order) throw new GoCommerceError('That payment does not belong to an order placed from this browser.', 404)\n\t\treturn { order_no: order.number, status: 'processing' }\n\t}\n\n\t// The family's other gateways. GoCommerce's Stripe is a Payment Element\n\t// (a client secret, not a hosted page), and PayPal, Cashfree, PhonePe and\n\t// Affirm are not engine gateways at all; paymentMethodService never lists\n\t// them, so these are reached only by a storefront that hard-codes one.\n\tasync checkoutStripe(): Promise<never> {\n\t\tthrow unsupported(\n\t\t\t'checkoutStripe',\n\t\t\t'GoCommerce’s Stripe gateway uses the Payment Element, not a hosted checkout page',\n\t\t)\n\t}\n\tasync checkoutStripeCapture(): Promise<never> {\n\t\tthrow unsupported('checkoutStripeCapture', 'Stripe confirms payments to the engine by webhook')\n\t}\n\tasync checkoutPaypal(): Promise<never> {\n\t\tthrow unsupported('checkoutPaypal', 'the engine has no PayPal gateway')\n\t}\n\tasync capturePaypalPayment(): Promise<never> {\n\t\tthrow unsupported('capturePaypalPayment', 'the engine has no PayPal gateway')\n\t}\n\tasync checkoutCashfree(): Promise<never> {\n\t\tthrow unsupported('checkoutCashfree', 'the engine has no Cashfree gateway')\n\t}\n\tasync captureCashfreePayment(): Promise<never> {\n\t\tthrow unsupported('captureCashfreePayment', 'the engine has no Cashfree gateway')\n\t}\n\tasync checkoutPhonepe(): Promise<never> {\n\t\tthrow unsupported('checkoutPhonepe', 'the engine has no PhonePe gateway')\n\t}\n\tasync createAffirmPayOrder(): Promise<never> {\n\t\tthrow unsupported('createAffirmPayOrder', 'the engine has no Affirm gateway')\n\t}\n\tasync confirmAffirmOrder(): Promise<never> {\n\t\tthrow unsupported('confirmAffirmOrder', 'the engine has no Affirm gateway')\n\t}\n\tasync cancelAffirmOrder(): Promise<never> {\n\t\tthrow unsupported('cancelAffirmOrder', 'the engine has no Affirm gateway')\n\t}\n\tasync checkoutPOS(): Promise<never> {\n\t\tthrow unsupported('checkoutPOS', 'point-of-sale orders are placed from the admin panel')\n\t}\n\n\t/**\n\t * One checkout attempt.\n\t *\n\t * The Idempotency-Key is kept with the cart and reused while the request is\n\t * the same, because a payment gateway that fails after the engine has\n\t * created the order leaves the cart converted: only a retry under the same\n\t * key resumes that order, and without one the shopper is stuck. A changed\n\t * request — a different address, a different method — gets a new key, since\n\t * the engine refuses a key replayed with a different body.\n\t */\n\tprivate async place(code: string, cartId?: string): Promise<CheckoutResult> {\n\t\tconst id = cartId || storedCartId()\n\t\tif (!id) throw new GoCommerceError('Your bag is empty.', 400)\n\t\tconst extras = cartExtras(id)\n\t\tconst ship = extras.shippingAddress\n\t\tif (!ship) throw new GoCommerceError('Add a delivery address first.', 400)\n\n\t\tconst cart = await this.data<Cart>(`/api/carts/${encodeURIComponent(id)}`)\n\t\tconst email = cart.email || (ship.email ? String(ship.email) : '')\n\t\tif (!email) throw new GoCommerceError('Add an email address so we can send your receipt.', 400)\n\t\tconst address = toEngineAddress(ship)\n\t\tconst body = {\n\t\t\tcart_id: id,\n\t\t\temail,\n\t\t\t...(extras.phone || address.phone ? { phone: String(extras.phone || address.phone) } : {}),\n\t\t\t...(address.name ? { name: address.name } : {}),\n\t\t\taddress,\n\t\t\t...(extras.shippingRateId ? { shipping_rate_id: Number(extras.shippingRateId) } : {}),\n\t\t}\n\t\tconst serialised = JSON.stringify(body)\n\t\tconst key = extras.attempt?.body === `${code}:${serialised}` ? extras.attempt.key : newKey()\n\t\tsaveCartExtras(id, { attempt: { key, body: `${code}:${serialised}` } })\n\n\t\tconst result = await this.data<CheckoutResult>(`/api/checkout/${encodeURIComponent(code)}`, {\n\t\t\tmethod: 'POST',\n\t\t\tbody,\n\t\t\theaders: { 'Idempotency-Key': key },\n\t\t})\n\n\t\t// The access token is returned once; a replayed response leaves it out,\n\t\t// so a replay must not overwrite the one already kept.\n\t\tif (result.order.access_token) {\n\t\t\trememberOrder({\n\t\t\t\tnumber: result.order.number,\n\t\t\t\ttoken: result.order.access_token,\n\t\t\t\tcartId: id,\n\t\t\t\treference: result.payment.client_data?.razorpay_order_id ?? result.payment.reference,\n\t\t\t})\n\t\t\t// A signed-in shopper's order joins their account. The engine never\n\t\t\t// links an order by email, so this call is the only way it appears\n\t\t\t// under \"My orders\".\n\t\t\tif (sessionToken()) {\n\t\t\t\tawait this.engine('/x/identity/me/orders', {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tbody: { number: result.order.number, token: result.order.access_token },\n\t\t\t\t\tauth: true,\n\t\t\t\t}).catch(() => undefined)\n\t\t\t}\n\t\t}\n\t\tsaveCartExtras(id, { attempt: null })\n\t\treturn result\n\t}\n}\n\nconst unsupported = (method: string, why: string) => new NotSupportedError('CheckoutService', method, why)\n\nfunction newKey(): string {\n\tconst c = (globalThis as { crypto?: { randomUUID?: () => string } }).crypto\n\tif (c?.randomUUID) return c.randomUUID()\n\treturn `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}-${Math.random().toString(36).slice(2)}`\n}\n\nexport const checkoutService = new CheckoutService()\n","import { BaseService } from './base.service'\nimport { StoreFacts } from './facts'\n\n/**\n * The engine's payment methods this storefront can actually drive.\n *\n * The storefront dispatches on an upper-cased code from a fixed list, and two\n * of the engine's gateways have a flow it can complete: cash on delivery, and\n * Razorpay's modal. The rest are left off rather than shown as a button that\n * fails at the last step — Stripe here is a Payment Element and the other\n * gateways are hosted pages this storefront has no route for. Each one left\n * off is reported once, so a merchant who switched one on can see why it is\n * missing.\n */\nconst DRIVABLE: Record<string, { code: string; img?: string }> = {\n\tcod: { code: 'COD', img: '/payment/cod.svg' },\n\trazorpay: { code: 'RAZORPAY' },\n}\n\nconst reported = new Set<string>()\n\nexport class PaymentMethodService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\tconst options = await this.facts.checkoutOptions()\n\t\tconst methods = options.methods ?? []\n\t\tconst data = methods\n\t\t\t.filter((m) => {\n\t\t\t\tif (DRIVABLE[m.code]) return true\n\t\t\t\tif (!reported.has(m.code)) {\n\t\t\t\t\treported.add(m.code)\n\t\t\t\t\tconsole.warn(\n\t\t\t\t\t\t`[gocommerce] payment method \"${m.code}\" is switched on but this storefront cannot drive its flow, so it is not offered.`,\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\treturn false\n\t\t\t})\n\t\t\t.map((m, i) => ({\n\t\t\t\tid: m.code,\n\t\t\t\tcode: DRIVABLE[m.code].code,\n\t\t\t\tengineCode: m.code,\n\t\t\t\tname: m.name,\n\t\t\t\ttitle: m.name,\n\t\t\t\tdescription: '',\n\t\t\t\timg: DRIVABLE[m.code].img ?? null,\n\t\t\t\trank: i,\n\t\t\t\tactive: true,\n\t\t\t\tisActive: true,\n\t\t\t}))\n\t\treturn { data, count: data.length, pageSize: data.length, noOfPage: 1, page: 1 }\n\t}\n}\n\nexport const paymentMethodService = new PaymentMethodService()\n","import { emptyPage } from './base.service'\nimport { BaseService } from './base.service'\n\n/**\n * Discount codes are typed, not browsed: the engine has no public list of\n * them, by design — a list would hand every shopper every code. An empty list\n * hides the storefront's coupon drawer, and the code box still works through\n * `cartService.applyCoupon`.\n */\nexport class CouponService extends BaseService {\n\tasync listCoupons(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const couponService = new CouponService()\n","import type { Order, Product } from '../engine'\nimport { GoCommerceError, NotSupportedError } from '../errors'\nimport { toOrder } from '../map'\nimport { toMajor } from '../money'\nimport { inBrowser, placedOrder, placedOrderForCart, sessionToken } from '../browser'\nimport { BaseService, emptyPage, toPage } from './base.service'\n\n/**\n * Orders, read back two ways.\n *\n * A guest's order is read with the access token checkout returned, which this\n * connector kept in the browser that placed it (`GET /api/orders/{n}?token=`).\n * A signed-in shopper's orders are the ones joined to their account\n * (ext/identity's `/me/orders`). There is no third way: an order list that\n * answered without either would be every order in the shop.\n */\nexport class OrderService extends BaseService {\n\t/**\n\t * The order-success page's lookup, by the number and cart in its URL.\n\t *\n\t * It runs on the server, where neither the token nor the session exists —\n\t * they live in the shopper's browser — so there it answers nothing and the\n\t * page says the details are not available yet. In the browser it answers\n\t * the order. Inventing a server-side credential from the cart token in the\n\t * URL would make that URL, which lands in history and referrers, a key to\n\t * the shopper's address.\n\t */\n\tasync listOrdersByParent({ orderNo, cartId }: { orderNo?: string; cartId?: string } = {}) {\n\t\tconst number = clean(orderNo) ?? (clean(cartId) ? placedOrderForCart(clean(cartId) as string)?.number : undefined)\n\t\tif (!number) return { data: [] }\n\t\ttry {\n\t\t\treturn { data: [await this.getOrder(number)] }\n\t\t} catch (err) {\n\t\t\tif (err instanceof GoCommerceError && (err.status === 404 || err.status === 401)) return { data: [] }\n\t\t\tthrow err\n\t\t}\n\t}\n\n\t/** The signed-in shopper's orders, newest claim first. */\n\tasync list({ page = 1, limit = 20 }: { page?: number; limit?: number; q?: string; sort?: string } = {}) {\n\t\tconst env = await this.engine<Order[] | null>('/x/identity/me/orders', { query: { page, limit }, auth: true })\n\t\treturn toPage(env, toOrder)\n\t}\n\n\t/** One order by number: the account's when signed in, otherwise one this browser placed. */\n\tasync getOrder(number: string) {\n\t\tconst kept = placedOrder(number)\n\t\tif (kept) {\n\t\t\treturn toOrder(\n\t\t\t\tawait this.data<Order>(`/api/orders/${encodeURIComponent(number)}`, { query: { token: kept.token } }),\n\t\t\t)\n\t\t}\n\t\tif (sessionToken()) {\n\t\t\treturn toOrder(await this.data<Order>(`/x/identity/me/orders/${encodeURIComponent(number)}`, { auth: true }))\n\t\t}\n\t\tthrow new GoCommerceError(\n\t\t\tinBrowser() ? 'Sign in to see this order, or open it from the browser that placed it.' : 'order not found',\n\t\t\t404,\n\t\t\t'not_found',\n\t\t)\n\t}\n\n\t/** Everything the signed-in shopper has bought, once each, most recent first. */\n\tasync buyAgain() {\n\t\tconst orders =\n\t\t\t(await this.data<Order[] | null>('/x/identity/me/orders', { query: { limit: 20 }, auth: true })) ?? []\n\t\tconst seen = new Set<number>()\n\t\tconst lines: {\n\t\t\tproductId: number\n\t\t\tvariantId: number\n\t\t\ttitle: string\n\t\t\timg: string | null\n\t\t\tprice: number\n\t\t\tqty: number\n\t\t}[] = []\n\t\tfor (const o of orders) {\n\t\t\tfor (const l of o.line_items ?? []) {\n\t\t\t\tif (!l.product_id || !l.variant_id || seen.has(l.variant_id)) continue\n\t\t\t\tseen.add(l.variant_id)\n\t\t\t\tlines.push({\n\t\t\t\t\tproductId: l.product_id,\n\t\t\t\t\tvariantId: l.variant_id,\n\t\t\t\t\ttitle: l.title,\n\t\t\t\t\timg: l.image_url ?? null,\n\t\t\t\t\tprice: toMajor(l.unit_price),\n\t\t\t\t\tqty: l.quantity,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\t// A product taken off sale is no longer something to buy again.\n\t\tconst live = await Promise.all(\n\t\t\tlines.map((l) => this.data<Product>(`/api/products/${l.productId}`).catch(() => null)),\n\t\t)\n\t\treturn lines.flatMap((l, i) => {\n\t\t\tconst p = live[i]\n\t\t\tif (!p) return []\n\t\t\treturn [{ ...l, productId: String(l.productId), variantId: String(l.variantId), slug: p.slug }]\n\t\t})\n\t}\n\n\t/** The \"someone just bought\" popup would publish other shoppers' purchases; the engine offers none. */\n\tasync listPublic(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n\n\tasync getOrderByEmailAndOTP(): Promise<never> {\n\t\tthrow new NotSupportedError(\n\t\t\t'OrderService',\n\t\t\t'getOrderByEmailAndOTP',\n\t\t\t'the engine sends no one-time codes; a guest reads an order with its access token',\n\t\t)\n\t}\n}\n\nconst clean = (v?: string | null) => (v && v !== 'undefined' && v !== 'null' ? v : undefined)\n\nexport const orderService = new OrderService()\n","import type { AuthResponse, Customer } from '../engine'\nimport { GoCommerceError, NotSupportedError } from '../errors'\nimport { toUser } from '../map'\nimport { endSession, startSession, storedCartId, updateMe } from '../browser'\nimport { BaseService } from './base.service'\n\n/**\n * Shopper accounts, through ext/identity.\n *\n * Guest checkout stays the engine's default (D22): an account is a place to\n * keep addresses and see past orders, never a requirement to buy. A store\n * built without `-identity` answers every call here with a 404, which arrives\n * as \"Accounts are not available on this store\" rather than as a route error.\n */\nexport class UserService extends BaseService {\n\t/** Email and password. The answer is the user object the storefront keeps in its `me` cookie. */\n\tasync login({ email, password }: { email: string; password: string; cartId?: string | null }) {\n\t\tconst auth = await this.account<AuthResponse>('/x/identity/login', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: { email: String(email ?? '').trim(), password: String(password ?? '') },\n\t\t})\n\t\treturn this.signedIn(auth)\n\t}\n\n\tasync signup({\n\t\temail,\n\t\tpassword,\n\t\tfirstName,\n\t\tlastName,\n\t\tphone,\n\t}: {\n\t\temail: string\n\t\tpassword: string\n\t\tfirstName?: string\n\t\tlastName?: string\n\t\tphone?: string\n\t\tcartId?: string | null\n\t\torigin?: string\n\t}) {\n\t\tconst name = [firstName, lastName].filter(Boolean).join(' ').trim()\n\t\tconst auth = await this.account<AuthResponse>('/x/identity/register', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: {\n\t\t\t\temail: String(email ?? '').trim(),\n\t\t\t\tpassword: String(password ?? ''),\n\t\t\t\t...(name ? { name } : {}),\n\t\t\t\t...(phone ? { phone: String(phone) } : {}),\n\t\t\t},\n\t\t})\n\t\treturn this.signedIn(auth)\n\t}\n\n\t/** Signs out here and on the engine. The storefront assigns the answer to its user: `null`. */\n\tasync logout() {\n\t\tawait this.engine('/x/identity/logout', { method: 'POST', auth: true }).catch(() => undefined)\n\t\tendSession()\n\t\treturn null\n\t}\n\n\tasync getMe() {\n\t\treturn toUser(await this.account<Customer>('/x/identity/me', { auth: true }))\n\t}\n\n\tasync updateProfile(user: { firstName?: string; lastName?: string; name?: string; email?: string; phone?: string }) {\n\t\tconst name =\n\t\t\tuser.name ??\n\t\t\t[user.firstName, user.lastName]\n\t\t\t\t.filter((v) => v !== undefined)\n\t\t\t\t.join(' ')\n\t\t\t\t.trim()\n\t\tconst c = await this.account<Customer>('/x/identity/me', {\n\t\t\tmethod: 'PATCH',\n\t\t\tauth: true,\n\t\t\tbody: {\n\t\t\t\t...(name !== undefined ? { name } : {}),\n\t\t\t\t...(user.email ? { email: String(user.email).trim() } : {}),\n\t\t\t\t...(user.phone !== undefined && user.phone !== null ? { phone: String(user.phone) } : {}),\n\t\t\t},\n\t\t})\n\t\tupdateMe(c)\n\t\treturn toUser(c)\n\t}\n\n\t/**\n\t * A password change ends every session the account had, this one included,\n\t * and the engine answers a fresh one — which is kept, so the shopper stays\n\t * signed in here and nowhere else.\n\t */\n\tasync changePassword({ old, oldPassword, password }: { old?: string; oldPassword?: string; password: string }) {\n\t\tconst auth = await this.account<AuthResponse>('/x/identity/me/password', {\n\t\t\tmethod: 'PUT',\n\t\t\tauth: true,\n\t\t\tbody: { current_password: String(old ?? oldPassword ?? ''), password: String(password ?? '') },\n\t\t})\n\t\tstartSession(auth)\n\t\treturn toUser(auth.record)\n\t}\n\n\tasync deleteUser(): Promise<never> {\n\t\tthrow new NotSupportedError('UserService', 'deleteUser', 'an account is closed by the store, on request')\n\t}\n\n\tasync checkEmail(): Promise<never> {\n\t\tthrow new NotSupportedError('UserService', 'checkEmail', 'the engine does not say which addresses have accounts')\n\t}\n\n\tasync joinAsVendor(): Promise<never> {\n\t\tthrow new NotSupportedError('UserService', 'joinAsVendor', 'sellers are invited by the store')\n\t}\n\n\tprivate async signedIn(auth: AuthResponse) {\n\t\tconst me = startSession(auth)\n\t\tconst cartId = storedCartId()\n\t\tif (cartId) await this.claimCartForAccount(cartId)\n\t\treturn me\n\t}\n\n\t/** An identity call, with a 404 from a build without the module said in words. */\n\tprotected async account<T>(path: string, req: Parameters<BaseService['engine']>[1] = {}): Promise<T> {\n\t\ttry {\n\t\t\treturn await this.data<T>(path, req)\n\t\t} catch (err) {\n\t\t\tif (err instanceof GoCommerceError && err.status === 404 && /no route/i.test(err.message)) {\n\t\t\t\tthrow new GoCommerceError('Accounts are not available on this store.', 404, 'not_found')\n\t\t\t}\n\t\t\tif (err instanceof GoCommerceError && err.status === 401 && req.auth) endSession()\n\t\t\tthrow err\n\t\t}\n\t}\n}\n\n/**\n * Password resets and email confirmation. Phone sign-in by one-time code is a\n * Litekart flow; the engine has no such thing and says so.\n */\nexport class AuthService extends UserService {\n\tasync forgotPassword({ email }: { email: string; referrer?: string }) {\n\t\treturn this.account<{ accepted: boolean }>('/x/identity/password-reset', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: { email: String(email ?? '').trim() },\n\t\t})\n\t}\n\n\t/** The token arrives in the link the engine emailed (`GOCOMMERCE_IDENTITY_RESET_URL`). */\n\tasync resetPassword({ token, password }: { userId?: string; token: string; password: string }) {\n\t\tconst auth = await this.account<AuthResponse>('/x/identity/password-reset/confirm', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: { token: String(token ?? ''), password: String(password ?? '') },\n\t\t})\n\t\treturn startSession(auth)\n\t}\n\n\t/** Answers `{ errorCode, message }` on failure rather than throwing: that is how the page reads it. */\n\tasync verifyEmail(_email: string | undefined, token: string) {\n\t\ttry {\n\t\t\tconst c = await this.account<Customer>('/x/identity/email-verification/confirm', {\n\t\t\t\tmethod: 'POST',\n\t\t\t\tbody: { token: String(token ?? '') },\n\t\t\t})\n\t\t\treturn { ...toUser(c), message: 'Your email address is confirmed.' }\n\t\t} catch (err) {\n\t\t\treturn { errorCode: (err as GoCommerceError).code ?? 'invalid_token', message: (err as Error).message }\n\t\t}\n\t}\n\n\tasync getOtp(): Promise<never> {\n\t\tthrow new NotSupportedError('AuthService', 'getOtp', 'sign in with an email and password')\n\t}\n\n\tasync verifyOtp(): Promise<never> {\n\t\tthrow new NotSupportedError('AuthService', 'verifyOtp', 'sign in with an email and password')\n\t}\n\n\tasync joinAsAdmin(): Promise<never> {\n\t\tthrow new NotSupportedError('AuthService', 'joinAsAdmin', 'operators are invited from the admin panel')\n\t}\n}\n\n/** The `/my/profile` form: the same account, read and saved. */\nexport class ProfileService extends UserService {\n\tasync getOne() {\n\t\treturn this.getMe()\n\t}\n\n\tasync save(profile: { firstName?: string; lastName?: string; email?: string; phone?: string }) {\n\t\treturn this.updateProfile(profile)\n\t}\n}\n\nexport const userService = new UserService()\nexport const authService = new AuthService()\nexport const profileService = new ProfileService()\n","import type { IdentityAddress } from '../engine'\nimport { fromIdentityAddress, toIdentityAddress } from '../map'\nimport { currentMe, type StorefrontAddress } from '../browser'\nimport { BaseService } from './base.service'\n\ntype AddressArg = StorefrontAddress & { isPrimary?: boolean; label?: string }\n\n/** The signed-in shopper's address book (ext/identity). A guest's address lives on the cart. */\nexport class AddressService extends BaseService {\n\tasync list({\n\t\tpage = 1,\n\t\tlimit = 20,\n\t}: { page?: number; limit?: number; user?: string; q?: string; sort?: string } = {}) {\n\t\tconst env = await this.engine<IdentityAddress[] | null>('/x/identity/me/addresses', {\n\t\t\tquery: { page, limit },\n\t\t\tauth: true,\n\t\t})\n\t\tconst email = currentMe()?.email\n\t\tconst rows = env.data ?? []\n\t\treturn {\n\t\t\tdata: rows.map((a) => fromIdentityAddress(a, email)),\n\t\t\tcount: env.meta?.total ?? rows.length,\n\t\t\tpageSize: env.meta?.limit ?? limit,\n\t\t\tnoOfPage: env.meta?.total_pages ?? 1,\n\t\t\tpage: env.meta?.page ?? page,\n\t\t}\n\t}\n\n\tasync fetchAddress(id: string) {\n\t\treturn fromIdentityAddress(\n\t\t\tawait this.data<IdentityAddress>(`/x/identity/me/addresses/${enc(id)}`, { auth: true }),\n\t\t\tcurrentMe()?.email,\n\t\t)\n\t}\n\n\t/** New when it has no id (or the form's `'new'`), an edit when it has one — the storefront saves both here. */\n\tasync saveAddress(address: AddressArg) {\n\t\tconst id = address?.id && address.id !== 'new' ? String(address.id) : null\n\t\tif (id) return this.editAddress(id, address)\n\t\tconst a = await this.data<IdentityAddress>('/x/identity/me/addresses', {\n\t\t\tmethod: 'POST',\n\t\t\tauth: true,\n\t\t\tbody: toIdentityAddress(address),\n\t\t})\n\t\treturn fromIdentityAddress(a, currentMe()?.email)\n\t}\n\n\tasync editAddress(id: string, address: AddressArg) {\n\t\tconst a = await this.data<IdentityAddress>(`/x/identity/me/addresses/${enc(id)}`, {\n\t\t\tmethod: 'PATCH',\n\t\t\tauth: true,\n\t\t\tbody: toIdentityAddress(address),\n\t\t})\n\t\treturn fromIdentityAddress(a, currentMe()?.email)\n\t}\n\n\tasync deleteAddress(id: string) {\n\t\tawait this.engine(`/x/identity/me/addresses/${enc(id)}`, { method: 'DELETE', auth: true })\n\t\treturn { id: String(id), deleted: true }\n\t}\n}\n\nconst enc = (id: string) => encodeURIComponent(String(id))\n\nexport const addressService = new AddressService()\n","import type { Product, Wishlist } from '../engine'\nimport { GoCommerceError } from '../errors'\nimport { toProduct } from '../map'\nimport { currentMe, forgetWishlistToken, rememberWishlistToken, wishlistToken } from '../browser'\nimport { BaseService } from './base.service'\n\n/**\n * Saved products, through ext/wishlist.\n *\n * The module keys a list by a token of its own rather than by an account, so\n * a guest can save things too; this connector keeps that token in the browser.\n * The signed-in shopper's email is attached so the store can tell them when a\n * saved product comes back in stock.\n */\nexport class WishlistService extends BaseService {\n\tasync fetchWishlist(_args: Record<string, unknown> = {}) {\n\t\tconst list = await this.current()\n\t\tif (!list) return { data: [], count: 0 }\n\t\tconst items = (list.items ?? []).filter((i) => !i.deleted)\n\t\tconst products = await Promise.all(\n\t\t\titems.map((i) => this.data<Product>(`/api/products/${i.product_id}`).catch(() => null)),\n\t\t)\n\t\tconst data = items.flatMap((item, n) => {\n\t\t\tconst p = products[n]\n\t\t\tif (!p) return []\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tid: String(item.id),\n\t\t\t\t\tproductId: String(item.product_id),\n\t\t\t\t\tvariantId: item.variant_id ? String(item.variant_id) : null,\n\t\t\t\t\tproduct: toProduct(p),\n\t\t\t\t\tvariant: { id: item.variant_id ? String(item.variant_id) : null },\n\t\t\t\t\tcreatedAt: item.created_at,\n\t\t\t\t},\n\t\t\t]\n\t\t})\n\t\treturn { data, count: data.length }\n\t}\n\n\t/** Saved → removed, removed → saved. `{ active }` is the state after the click. */\n\tasync toggleWishlist({ productId, variantId }: { productId: string; variantId?: string | null }) {\n\t\tconst list = (await this.current()) ?? (await this.create())\n\t\tconst item = (list.items ?? []).find((i) => String(i.product_id) === String(productId))\n\t\tif (item) {\n\t\t\tawait this.data<Wishlist>(`/x/wishlist/${enc(list.token!)}/items/${item.id}`, { method: 'DELETE' })\n\t\t\treturn { active: false, id: String(item.id) }\n\t\t}\n\t\tconst next = await this.data<Wishlist>(`/x/wishlist/${enc(list.token!)}/items`, {\n\t\t\tmethod: 'POST',\n\t\t\tbody: { product_id: Number(productId), ...(variantId ? { variant_id: Number(variantId) } : {}) },\n\t\t})\n\t\tconst added = (next.items ?? []).find((i) => String(i.product_id) === String(productId))\n\t\treturn { active: true, id: added ? String(added.id) : null }\n\t}\n\n\tasync checkWishlist({ productId }: { productId: string; variantId?: string | null }) {\n\t\tconst list = await this.current()\n\t\treturn !!list && (list.items ?? []).some((i) => String(i.product_id) === String(productId))\n\t}\n\n\tasync checkWishlistInBulk(pairs: { productId: string; variantId?: string | null }[]) {\n\t\tconst list = await this.current()\n\t\tconst saved = new Set((list?.items ?? []).map((i) => String(i.product_id)))\n\t\treturn (pairs ?? []).map((p) => ({ ...p, exists: saved.has(String(p.productId)) }))\n\t}\n\n\tprivate async current(): Promise<(Wishlist & { token: string }) | null> {\n\t\tconst token = wishlistToken()\n\t\tif (!token) return null\n\t\ttry {\n\t\t\treturn { ...(await this.data<Wishlist>(`/x/wishlist/${enc(token)}`)), token }\n\t\t} catch (err) {\n\t\t\tif (err instanceof GoCommerceError && err.status === 404 && !/no wishlist|no route/i.test(err.message)) {\n\t\t\t\tforgetWishlistToken()\n\t\t\t\treturn null\n\t\t\t}\n\t\t\tthrow err\n\t\t}\n\t}\n\n\tprivate async create(): Promise<Wishlist & { token: string }> {\n\t\tconst email = currentMe()?.email\n\t\tconst list = await this.data<Wishlist>('/x/wishlist', { method: 'POST', ...(email ? { body: { email } } : {}) })\n\t\tif (!list.token) throw new GoCommerceError('The store did not return a wishlist token.', 500)\n\t\trememberWishlistToken(list.token)\n\t\treturn { ...list, token: list.token }\n\t}\n}\n\nconst enc = (s: string) => encodeURIComponent(s)\n\nexport const wishlistService = new WishlistService()\n","import type { ReviewPage } from '../engine'\nimport { toRating } from '../map'\nimport { BaseService } from './base.service'\n\n/**\n * Product reviews (ext/reviews). Approved reviews only, newest first. The\n * product page gets them with the product; this is the paged form, and\n * `productService.addReview` writes one.\n */\nexport class ReviewService extends BaseService {\n\tasync fetchReviews({\n\t\tproductId,\n\t\tcurrentPage = 1,\n\t\tpage,\n\t\tlimit = 20,\n\t}: { productId?: string; currentPage?: number; page?: number; limit?: number; search?: string; sort?: string } = {}) {\n\t\t// A vendor's \"all my reviews\" page has no product to ask about.\n\t\tif (!productId) return { data: [], count: 0, pageSize: limit, noOfPage: 0, page: 1 }\n\t\tconst p = Math.max(1, Number(page ?? currentPage) || 1)\n\t\tconst res = await this.data<ReviewPage>('/x/reviews', { query: { product_id: productId, page: p, limit } })\n\t\tconst total = res.meta?.total ?? res.summary?.count ?? 0\n\t\treturn {\n\t\t\tdata: (res.reviews ?? []).map(toRating),\n\t\t\tcount: total,\n\t\t\tpageSize: limit,\n\t\t\tnoOfPage: Math.max(1, Math.ceil(total / limit)),\n\t\t\tpage: p,\n\t\t\tsummary: res.summary ?? null,\n\t\t}\n\t}\n\n\tasync allReviews(args: { productId?: string; page?: number } = {}) {\n\t\treturn this.fetchReviews(args)\n\t}\n}\n\nexport const reviewService = new ReviewService()\n","import type { Menu, MenuItem } from '../engine'\nimport { resolveRestLocally } from '../rest-guard'\nimport { BaseService } from './base.service'\nimport { StoreFacts } from './facts'\nimport { remember } from '../cache'\n\nexport type StorefrontMenu = { menuId: string; name: string; items: StorefrontMenuItem[] }\ntype StorefrontMenuItem = { id: string; name: string; link: string; items: StorefrontMenuItem[] }\n\n/**\n * A link where this storefront serves it. The navigation module resolves URLs\n * from its own patterns, whose defaults suit a different storefront; the\n * targets it names are slugs, so they are re-pointed at this one's routes.\n */\nfunction linkFor(item: MenuItem): string {\n\tconst t = item.target ?? ''\n\tswitch (item.kind) {\n\t\tcase 'home':\n\t\t\treturn '/'\n\t\tcase 'product':\n\t\t\treturn t ? `/products/${t}` : item.url\n\t\tcase 'collection':\n\t\t\treturn t ? `/collections/${t}` : item.url\n\t\tcase 'category':\n\t\t\treturn t ? `/${t}` : item.url\n\t\tcase 'page':\n\t\t\treturn t ? `/p/${t}` : item.url\n\t\tdefault:\n\t\t\treturn item.url\n\t}\n}\n\nconst toItem = (item: MenuItem, i: number): StorefrontMenuItem => ({\n\tid: String(item.id ?? i),\n\tname: item.title,\n\tlink: linkFor(item),\n\titems: (item.children ?? []).map(toItem),\n})\n\n/**\n * Menus from ext/navigation, when it is installed and switched on; otherwise\n * the storefront's own `store.menu`, which is what it shows anyway.\n */\nexport class MenuService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\tconst menus = await this.engineMenus()\n\t\tif (menus) return { data: menus }\n\t\treturn resolveRestLocally('get', '/api/menu')\n\t}\n\n\t/** The header and footer menus, or `null` when the module is not there. Cached: a menu is store-level. */\n\tasync engineMenus(): Promise<StorefrontMenu[] | null> {\n\t\tif (!(await this.facts.pluginOn('navigation'))) return null\n\t\treturn remember(`${this.engineBase()}|${this.creds.store ?? ''}|menus`, async () => {\n\t\t\tconst out: StorefrontMenu[] = []\n\t\t\tfor (const handle of ['header', 'footer']) {\n\t\t\t\ttry {\n\t\t\t\t\tconst m = await this.data<Menu>(`/x/navigation/menus/${handle}`)\n\t\t\t\t\tout.push({ menuId: handle, name: m.title, items: (m.items ?? []).map(toItem) })\n\t\t\t\t} catch {\n\t\t\t\t\t// A store may have deleted one of the two.\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn out\n\t\t}).catch(() => null)\n\t}\n}\n\nexport const menuService = new MenuService()\n","import { readStaticStore } from '../static-store'\nimport { BaseService } from './base.service'\nimport { StoreFacts } from './facts'\nimport { MenuService } from './menu-service'\n\n/** `$`, `€`, `₹` — from the platform's own tables rather than a list kept here. */\nfunction symbolFor(code: string): string {\n\ttry {\n\t\tconst part = new Intl.NumberFormat('en', { style: 'currency', currency: code })\n\t\t\t.formatToParts(0)\n\t\t\t.find((p) => p.type === 'currency')\n\t\treturn part?.value ?? code\n\t} catch {\n\t\treturn code\n\t}\n}\n\n/**\n * The store record every page renders from.\n *\n * Name, logo, theme and the rest are the storefront's own (its static store,\n * registered through `setStaticStore`); the engine has no opinion on them.\n * Where the engine does have one, it wins: the settlement currency — every\n * price on the site is formatted with it, and a store record saying USD over\n * an engine charging INR would print the wrong symbol on every price — the\n * modules that back a storefront feature, and the menus.\n *\n * This runs on every request and a throw here takes every page down, so the\n * engine's half is best-effort: unreachable, the storefront still renders\n * from its own record, and the failure shows up where a price is fetched.\n */\nexport class StoreService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\n\tasync getStoreByIdOrDomain(_args: { storeId?: string; domain?: string } = {}) {\n\t\tconst base = await readStaticStore()\n\t\tconst live = await this.live().catch(() => ({}))\n\t\t// `id` must be truthy and stable: the storefront keys a cookie on it.\n\t\treturn { ...base, ...live, id: base.id || 'gocommerce' }\n\t}\n\n\tasync getStore(storeId?: string) {\n\t\treturn this.getStoreByIdOrDomain({ storeId })\n\t}\n\n\t/**\n\t * The storefront's sitemap route asks for `/api/stores/<id>` and serves the\n\t * `sitemap` path it gets back from `PUBLIC_SITEMAP_URL`. With ext/sitemaps\n\t * installed, `/sitemaps/sitemap.xml` under `PUBLIC_SITEMAP_URL=<engine>/x`\n\t * is the engine's own sitemap; without it, an empty path is the route's\n\t * clean 404 rather than a crash.\n\t */\n\toverride async get<T = any>(path: string): Promise<T> {\n\t\tif (path.split('?')[0].startsWith('/api/stores/')) {\n\t\t\tconst on = await this.facts.pluginOn('sitemap')\n\t\t\treturn { sitemap: on ? '/sitemaps/sitemap.xml' : '' } as T\n\t\t}\n\t\treturn super.get<T>(path)\n\t}\n\n\tprivate async live(): Promise<Record<string, unknown>> {\n\t\tconst [ready, plugins, menus, base] = await Promise.all([\n\t\t\tthis.facts.ready(),\n\t\t\tthis.facts.plugins().catch(() => new Map()),\n\t\t\tnew MenuService(this._fetch).engineMenus(),\n\t\t\treadStaticStore(),\n\t\t])\n\t\tconst code = ready.currency\n\t\tconst sameCurrency = (base.currency?.code ?? base.currencyCode) === code\n\t\tconst flag = (on: boolean) => ({ ...(on ? { active: true } : { active: false }) })\n\t\tconst basePlugins = (base.plugins ?? {}) as Record<string, Record<string, unknown>>\n\t\treturn {\n\t\t\tcurrencyCode: code,\n\t\t\tcurrencySymbol: sameCurrency ? (base.currencySymbol ?? symbolFor(code)) : symbolFor(code),\n\t\t\tcurrency: {\n\t\t\t\t...(base.currency ?? {}),\n\t\t\t\tcode,\n\t\t\t\tsymbol: sameCurrency ? (base.currency?.symbol ?? symbolFor(code)) : symbolFor(code),\n\t\t\t},\n\t\t\tlanguage: ready.language,\n\t\t\tplugins: {\n\t\t\t\t...basePlugins,\n\t\t\t\t// Features this connector serves from a module: on exactly when the\n\t\t\t\t// module is installed and switched on, whatever the static record says.\n\t\t\t\tisWishlist: { ...basePlugins.isWishlist, ...flag(plugins.has('wishlist')) },\n\t\t\t\tisProductReviewsAndRatings: {\n\t\t\t\t\t...basePlugins.isProductReviewsAndRatings,\n\t\t\t\t\t...flag(plugins.has('product-reviews')),\n\t\t\t\t},\n\t\t\t},\n\t\t\t...(menus?.length ? { menu: menus } : {}),\n\t\t}\n\t}\n}\n\nexport const storeService = new StoreService()\n","import type { CmsPage, Faq } from '../engine'\nimport { toCmsPage as toStorefrontPage } from '../map'\nimport { BaseService, toPage } from './base.service'\n\n/**\n * Content pages from ext/cms, in the shopper's language with the store's\n * default as the fallback. A slug with no page is the page's 404.\n */\nexport class PageService extends BaseService {\n\tasync getOne(slug: string) {\n\t\treturn toStorefrontPage(await this.data<CmsPage>(`/x/cms/pages/${encodeURIComponent(String(slug))}`))\n\t}\n\n\tasync list({ page = 1, limit = 50 }: { page?: number; limit?: number; search?: string; sort?: string } = {}) {\n\t\tconst env = await this.engine<CmsPage[] | null>('/x/cms/pages', { query: { page, limit } })\n\t\treturn toPage(env, toStorefrontPage)\n\t}\n}\n\n/** The shop's questions and answers (ext/faq), flattened in the shop's own order. */\nexport class FaqService extends BaseService {\n\tasync listFaqs(_args: Record<string, unknown> = {}) {\n\t\tconst faq = await this.data<Faq>('/x/faq')\n\t\tconst data = (faq.sections ?? []).flatMap((s) =>\n\t\t\t(s.entries ?? []).map((e) => ({\n\t\t\t\tid: String(e.id),\n\t\t\t\tquestion: e.question,\n\t\t\t\tanswer: e.answer,\n\t\t\t\tcategory: s.section || null,\n\t\t\t})),\n\t\t)\n\t\treturn { data, count: data.length, heading: faq.heading, blurb: faq.blurb }\n\t}\n\n\tasync list(args: Record<string, unknown> = {}) {\n\t\treturn this.listFaqs(args)\n\t}\n}\n\nexport const pageService = new PageService()\nexport const faqService = new FaqService()\n","import type { Vendor } from '../engine'\nimport { toVendor } from '../map'\nimport { BaseService, emptyPage, toPage } from './base.service'\n\n/** The marketplace's sellers: approved vendors only. */\nexport class VendorService extends BaseService {\n\tasync list({\n\t\tpage = 1,\n\t\tlimit = 24,\n\t\tq,\n\t\tsearch,\n\t}: { page?: number; limit?: number; q?: string; search?: string; sort?: string } = {}) {\n\t\tconst env = await this.engine<Vendor[] | null>('/api/vendors', { query: { page, limit, q: q ?? search } })\n\t\treturn toPage(env, toVendor)\n\t}\n\n\tasync getVendor(slug: string) {\n\t\treturn toVendor(await this.data<Vendor>(`/api/vendors/${encodeURIComponent(String(slug))}`))\n\t}\n\n\t/**\n\t * A seller's shelf. The engine's vendors sell through offers on the shop's\n\t * own variants and the public API lists no products by seller, so the shelf\n\t * is empty — the seller's page still renders, with their details.\n\t */\n\tasync fetchProductsOfVendor(_vendorId?: string) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport const vendorService = new VendorService()\n","/**\n * The rest of the family's service surface.\n *\n * Svelte Commerce imports some four dozen services by name because Litekart\n * has them, and an export that is missing is a TypeError at import. Each one\n * is here. Where the engine has the thing, it is wired; where it does not, a\n * read of a list answers empty (a shop legitimately has no reels) and anything\n * that would write, or that names one record, throws `NotSupportedError` —\n * a silent success would tell a shopper their message was sent when nothing\n * left the browser.\n */\nimport type { Plugin } from '../engine'\nimport { NotSupportedError } from '../errors'\nimport { readStaticStore } from '../static-store'\nimport { resolveRestLocally } from '../rest-guard'\nimport { BaseService, emptyPage } from './base.service'\nimport { StoreFacts } from './facts'\nimport { MeilisearchService } from './meilisearch-service'\nimport { StoreService } from './store-service'\n\nconst refuse = (service: string, method: string, why: string) => new NotSupportedError(service, method, why)\n\n/** The storefront's contact form and product enquiries, through ext/contact's inbox. */\nexport class ContactService extends BaseService {\n\tasync submitContactUsForm({\n\t\tname,\n\t\temail,\n\t\tphone,\n\t\tmessage,\n\t\tsubject,\n\t}: {\n\t\tname: string\n\t\temail: string\n\t\tphone?: string\n\t\tmessage: string\n\t\tsubject?: string\n\t}) {\n\t\treturn this.data<{ status: string }>('/x/contact/messages', {\n\t\t\tmethod: 'POST',\n\t\t\tbody: {\n\t\t\t\tname: String(name ?? ''),\n\t\t\t\temail: String(email ?? ''),\n\t\t\t\t...(phone ? { phone: String(phone) } : {}),\n\t\t\t\t...(subject ? { subject: String(subject) } : {}),\n\t\t\t\tbody: String(message ?? ''),\n\t\t\t},\n\t\t})\n\t}\n}\n\nexport class EnquiryService extends ContactService {\n\tasync create({\n\t\tname,\n\t\temail,\n\t\tphone,\n\t\tmessage,\n\t\tproductId,\n\t}: {\n\t\tname: string\n\t\temail: string\n\t\tphone?: string\n\t\tmessage: string\n\t\tproductId?: string\n\t}) {\n\t\treturn this.submitContactUsForm({\n\t\t\tname,\n\t\t\temail,\n\t\t\tphone,\n\t\t\tsubject: productId ? `Enquiry about product ${productId}` : 'Enquiry',\n\t\t\tmessage,\n\t\t})\n\t}\n}\n\n/** Enabled plugins and their public settings, `{ key, title, settings }`. */\nexport class PluginService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\tconst data: Plugin[] = [...(await this.facts.plugins()).values()]\n\t\treturn { data, count: data.length, pageSize: data.length, noOfPage: 1, page: 1 }\n\t}\n}\n\n/** The store record again, for the callers that ask for it as \"settings\" or \"init\". */\nexport class SettingService extends BaseService {\n\tasync fetchSettings(_args: Record<string, unknown> = {}) {\n\t\treturn new StoreService(this._fetch).getStoreByIdOrDomain()\n\t}\n\tasync list(args: Record<string, unknown> = {}) {\n\t\treturn this.fetchSettings(args)\n\t}\n}\n\nexport class InitService extends SettingService {\n\tasync fetchInit(_args: Record<string, unknown> = {}) {\n\t\tconst store = await this.fetchSettings()\n\t\treturn { storeOne: store, store, settings: store }\n\t}\n}\n\nexport class HomeService extends BaseService {\n\t/** A homepage is assembled by the storefront from shelves; the engine has no page of its own for it. */\n\tasync getHome(_args: Record<string, unknown> = {}) {\n\t\treturn { banners: [], groupByBanner: [], categories: [], products: [] }\n\t}\n}\n\n/** Countries for the address form: the storefront's own list, which is what it offers anyway. */\nexport class CountryService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn resolveRestLocally('get', '/api/countries')\n\t}\n}\n\n/** The one currency an engine store settles in. */\nexport class CurrencyService extends BaseService {\n\tprivate readonly facts = new StoreFacts(this._fetch)\n\tasync listCurrencies(_args: Record<string, unknown> = {}) {\n\t\tconst { currency } = await this.facts.ready()\n\t\tconst data = [{ code: currency, name: currency, isDefault: true }]\n\t\treturn { data, count: 1, pageSize: 1, noOfPage: 1, page: 1 }\n\t}\n\tasync list(args: Record<string, unknown> = {}) {\n\t\treturn this.listCurrencies(args)\n\t}\n}\n\n/** States are free text on a GoCommerce address; there is no list to offer. */\nexport class StateService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport class RegionService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\n/** The header's type-ahead, under the name some storefront builds still call it by. */\nexport class AutocompleteService extends MeilisearchService {\n\tasync list({ q, search }: { q?: string; search?: string } = {}) {\n\t\treturn this.searchAutoComplete({ query: q ?? search })\n\t}\n}\n\nexport class PopularSearchService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\n/** The engine keeps no popularity score; a page view is not recorded. */\nexport class PopularityService extends BaseService {\n\tasync updatePopularity(_args: Record<string, unknown> = {}) {\n\t\treturn undefined\n\t}\n}\n\nexport class BlogService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n\tasync getOne(_slug: string): Promise<never> {\n\t\tthrow refuse('BlogService', 'getOne', 'the engine has no blog; publish articles as pages')\n\t}\n}\n\nexport class BannerService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n\tasync listBanners(args: Record<string, unknown> = {}) {\n\t\treturn this.list(args)\n\t}\n\tasync fetchBanners(args: Record<string, unknown> = {}) {\n\t\treturn this.list(args)\n\t}\n}\n\nexport class ReelsService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport class DealService extends BaseService {\n\tasync fetchDeals(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport class GalleryService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\nexport class ChatService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n\tasync chats(): Promise<never> {\n\t\tthrow refuse('ChatService', 'chats', 'the engine has no shopper chat')\n\t}\n\tasync save(): Promise<never> {\n\t\tthrow refuse('ChatService', 'save', 'the engine has no shopper chat')\n\t}\n}\n\nexport class FeedbackService extends BaseService {\n\tasync save(): Promise<never> {\n\t\tthrow refuse('FeedbackService', 'save', 'use the contact form')\n\t}\n}\n\nexport class DemoRequestService extends BaseService {\n\tasync save(): Promise<never> {\n\t\tthrow refuse('DemoRequestService', 'save', 'use the contact form')\n\t}\n}\n\nexport class UploadService extends BaseService {\n\tasync uploadMultipleToS3(): Promise<never> {\n\t\tthrow refuse('UploadService', 'uploadMultipleToS3', 'shoppers cannot upload files to the engine')\n\t}\n\tasync upload(): Promise<never> {\n\t\tthrow refuse('UploadService', 'upload', 'shoppers cannot upload files to the engine')\n\t}\n}\n\nexport class WarrantyService extends BaseService {\n\tasync submitWarrantyRegistration(): Promise<never> {\n\t\tthrow refuse('WarrantyService', 'submitWarrantyRegistration', 'the engine has no warranty registrations')\n\t}\n}\n\nexport class VarniCustomDesignService extends BaseService {\n\tasync submitForm(): Promise<never> {\n\t\tthrow refuse('VarniCustomDesignService', 'submitForm', 'custom design requests are a Litekart feature')\n\t}\n}\n\nexport class VarniCustomProductService extends BaseService {\n\tasync list(_args: Record<string, unknown> = {}) {\n\t\treturn emptyPage()\n\t}\n}\n\n/** The storefront's static store record, for code that wants the raw config. */\nexport const staticStore = () => readStaticStore()\n\nexport const contactService = new ContactService()\nexport const enquiryService = new EnquiryService()\nexport const pluginService = new PluginService()\nexport const settingService = new SettingService()\nexport const initService = new InitService()\nexport const homeService = new HomeService()\nexport const countryService = new CountryService()\nexport const currencyService = new CurrencyService()\nexport const stateService = new StateService()\nexport const regionService = new RegionService()\nexport const autocompleteService = new AutocompleteService()\nexport const popularSearchService = new PopularSearchService()\nexport const popularityService = new PopularityService()\nexport const blogService = new BlogService()\nexport const bannerService = new BannerService()\nexport const reelsService = new ReelsService()\nexport const dealService = new DealService()\nexport const galleryService = new GalleryService()\nexport const chatService = new ChatService()\nexport const feedbackService = new FeedbackService()\nexport const demoRequestService = new DemoRequestService()\nexport const uploadService = new UploadService()\nexport const warrantyService = new WarrantyService()\nexport const varniCustomDesignService = new VarniCustomDesignService()\nexport const varniCustomProductService = new VarniCustomProductService()\n\n// kitcommerce-core reads the plural spellings; the family exports the singular. Both, then.\nexport { PluginService as PluginsService, SettingService as SettingsService }\nexport const pluginsService = pluginService\nexport const settingsService = settingService\n"]}