@aglyn/plugins-marketplace 1.27.0 → 1.28.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/package.json +15 -15
- package/src/lib/components/starter-picker-shelf.component.js +11 -6
- package/src/lib/components/starter-picker-shelf.component.js.map +1 -1
- package/src/lib/components/template-gallery-shelf.component.js +3 -27
- package/src/lib/components/template-gallery-shelf.component.js.map +1 -1
- package/src/lib/model/listing-query.d.ts +11 -0
- package/src/lib/model/listing-query.js +26 -0
- package/src/lib/model/listing-query.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-marketplace",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/aglyn-markdown-editor": "1.
|
|
30
|
-
"@aglyn/shared-data-enums": "1.
|
|
31
|
-
"@aglyn/shared-data-mdi": "1.
|
|
32
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
33
|
-
"@aglyn/shared-ui-next": "1.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
35
|
-
"@aglyn/shared-util-email": "1.
|
|
36
|
-
"@aglyn/shared-util-http": "1.
|
|
37
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
38
|
-
"@aglyn/shared-util-tools": "1.
|
|
39
|
-
"@aglyn/tenant-data-admin": "1.
|
|
40
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
41
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.28.0",
|
|
29
|
+
"@aglyn/aglyn-markdown-editor": "1.28.0",
|
|
30
|
+
"@aglyn/shared-data-enums": "1.28.0",
|
|
31
|
+
"@aglyn/shared-data-mdi": "1.28.0",
|
|
32
|
+
"@aglyn/shared-ui-jsx": "1.28.0",
|
|
33
|
+
"@aglyn/shared-ui-next": "1.28.0",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.28.0",
|
|
35
|
+
"@aglyn/shared-util-email": "1.28.0",
|
|
36
|
+
"@aglyn/shared-util-http": "1.28.0",
|
|
37
|
+
"@aglyn/shared-util-timestamp": "1.28.0",
|
|
38
|
+
"@aglyn/shared-util-tools": "1.28.0",
|
|
39
|
+
"@aglyn/tenant-data-admin": "1.28.0",
|
|
40
|
+
"@aglyn/tenant-feature-instance": "1.28.0",
|
|
41
|
+
"@aglyn/tenant-runtime": "1.28.0",
|
|
42
42
|
"@swc/helpers": "0.5.24"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -21,6 +21,7 @@ import { resolveMediaSrc } from "@aglyn/aglyn/app-utils/media-ref";
|
|
|
21
21
|
import { mdiWeb } from "@aglyn/shared-data-mdi";
|
|
22
22
|
import { OptionCardGrid } from "@aglyn/shared-ui-jsx/components/option-card-grid.component";
|
|
23
23
|
import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
|
|
24
|
+
import { useBuyingHidden } from "@aglyn/shared-ui-jsx/contexts/buying-hidden.context";
|
|
24
25
|
import { Alert, Box, Button, Link, LinearProgress, Skeleton, Stack } from "@mui/material";
|
|
25
26
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
26
27
|
import { useStarterAnswers } from "../hooks/use-starter-answers.js";
|
|
@@ -165,7 +166,7 @@ const narrowed = (filter)=>[
|
|
|
165
166
|
* never read: its answers are what it sells, and the door would ask payment
|
|
166
167
|
* for them. A door that still asks is told back to the dialog as unowned.
|
|
167
168
|
*/ export function StarterPickerShelf(props) {
|
|
168
|
-
var _ref,
|
|
169
|
+
var _ref, _rows_find, _pickedRow_buyBlockedReason, _pickedRow_buyBlockedReason1;
|
|
169
170
|
const { orgId, orgSlug, mode, search, filter, onPick, ready, selected } = props;
|
|
170
171
|
// The pick the dialog opened on, restored after paying for it: asked for
|
|
171
172
|
// by every search from then on, so it is listed (first) wherever the
|
|
@@ -190,12 +191,16 @@ const narrowed = (filter)=>[
|
|
|
190
191
|
const purchase = useStarterPurchase(orgId, orgSlug);
|
|
191
192
|
const starterAnswers = useStarterAnswers(orgId);
|
|
192
193
|
const value = selected !== undefined ? (_ref = selected == null ? void 0 : selected.listingId) != null ? _ref : null : picked;
|
|
193
|
-
const pickedRow = value ? (_found_rows_find = found.rows.find((row)=>row.listingId === value)) != null ? _found_rows_find : null : null;
|
|
194
194
|
const ownedOverride = (row)=>ownedHere.has(row.listingId) ? true : unpaidHere.has(row.listingId) ? false : (selected == null ? void 0 : selected.listingId) === row.listingId ? selected.owned : undefined;
|
|
195
|
+
// An app build for store review cannot buy, so a starter that would have to
|
|
196
|
+
// be bought first is not offered there; free and owned ones are.
|
|
197
|
+
const buyingHidden = useBuyingHidden();
|
|
198
|
+
const rows = buyingHidden ? found.rows.filter((row)=>row.priceUsd <= 0 || ownedOf(row, ownedOverride(row))) : found.rows;
|
|
199
|
+
const pickedRow = value ? (_rows_find = rows.find((row)=>row.listingId === value)) != null ? _rows_find : null : null;
|
|
195
200
|
const refused = found.error !== null && REFUSED.has(found.error.status);
|
|
196
201
|
// `null` until the first answer, which is the only one that may decide
|
|
197
202
|
// there is nothing to show; after that only a refusal takes it back.
|
|
198
|
-
const verdict = !found.settled ? null : refused ? false : shown ? true : found.error ? false :
|
|
203
|
+
const verdict = !found.settled ? null : refused ? false : shown ? true : found.error ? false : rows.length > 0 || search.trim() !== '' || narrowed(filter != null ? filter : {});
|
|
199
204
|
useEffect(()=>{
|
|
200
205
|
if (verdict === true) setShown(true);
|
|
201
206
|
if (verdict === false) setShown(false);
|
|
@@ -275,8 +280,8 @@ const narrowed = (filter)=>[
|
|
|
275
280
|
askedAnswers.current = null;
|
|
276
281
|
setReadAttempt((count)=>count + 1);
|
|
277
282
|
};
|
|
278
|
-
const options = useMemo(()=>
|
|
279
|
-
|
|
283
|
+
const options = useMemo(()=>rows.map(cardOf), [
|
|
284
|
+
rows
|
|
280
285
|
]);
|
|
281
286
|
const buy = async (row)=>{
|
|
282
287
|
const outcome = await purchase.buy({
|
|
@@ -358,7 +363,7 @@ const narrowed = (filter)=>[
|
|
|
358
363
|
md: 3
|
|
359
364
|
},
|
|
360
365
|
onChange: (listingId)=>{
|
|
361
|
-
const row =
|
|
366
|
+
const row = rows.find((candidate)=>candidate.listingId === listingId);
|
|
362
367
|
if (!row) return;
|
|
363
368
|
setPicked(listingId);
|
|
364
369
|
const override = ownedOverride(row);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/starter-picker-shelf.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { resolveMediaSrc } from '@aglyn/aglyn/app-utils/media-ref'\nimport type { SiteStarterFacets } from '@aglyn/aglyn/app-utils/site-starter'\nimport type { ConsoleHostStarterPickerZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport type { SiteStarterSummary } from '@aglyn/aglyn/plugin-manager/plugin-site-starters'\nimport { mdiWeb } from '@aglyn/shared-data-mdi'\nimport {\n OptionCardGrid,\n type OptionCard,\n type OptionCardChip,\n type OptionCardImage,\n} from '@aglyn/shared-ui-jsx/components/option-card-grid.component'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport {\n Alert,\n Box,\n Button,\n Link,\n LinearProgress,\n Skeleton,\n Stack,\n type SxProps,\n type Theme,\n} from '@mui/material'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { useStarterAnswers } from '../hooks/use-starter-answers'\nimport { useStarterPurchase } from '../hooks/use-starter-purchase'\nimport { useStarterSearch } from '../hooks/use-starter-search'\nimport { starterCardFacts, starterPriceLabel, type StarterCardFact } from '../model/starter-query'\n\n/**\n * What a picked starter's price or licence says, held at the foot of the\n * visible cards while the shelf is in view, so \"Buy and continue\" is beside\n * whichever card was clicked rather than below all of them.\n */\nconst PICK_NOTE_SX: SxProps<Theme> = {\n position: 'sticky',\n bottom: (theme) => theme.spacing(2),\n zIndex: 1,\n boxShadow: 3,\n}\n\n/**\n * The payment, where the note was, on its own surface. It may fill the window\n * below the app bar, so a form that has grown keeps its button on screen; a\n * smaller window scrolls inside it.\n */\nconst PAY_PANEL_SX: SxProps<Theme> = {\n position: 'sticky',\n bottom: (theme) => theme.spacing(2),\n zIndex: 1,\n boxShadow: 3,\n p: 2,\n borderRadius: 1,\n bgcolor: 'background.paper',\n maxHeight: (theme) => `calc(100dvh - ${theme.spacing(10)})`,\n overflow: 'auto',\n}\n\n/** The guide to site starters, linked from what the shelf says when it has nothing to show. */\nconst STARTERS_HELP = pluginDocsHelp('siteStarters')\n\n/**\n * A starter's preview as the card draws it: the size the platform's own\n * style previews are rendered at (square), so a row of cards stays level and\n * a publisher's picture is cropped to the same shape from its top.\n */\nconst PREVIEW_SIZE = { width: 800, height: 800 } as const\n\n/** How many placeholder cards stand in for the first answer. */\nconst PLACEHOLDER_CARDS = 3\n\n/** Statuses that mean this workspace may not have starters offered here: the dialog's own choice instead. */\nconst REFUSED = new Set([401, 403, 503])\n\n/** How each fact's chip is colored, from the theme: the price as the marketplace's own cards color it. */\nfunction chipOf(fact: StarterCardFact, row: SiteStarterSummary): OptionCardChip {\n switch (fact.key) {\n case 'price':\n return row.priceUsd > 0\n ? { label: fact.label, color: 'primary', variant: 'filled' }\n : { label: fact.label, color: 'success', variant: 'outlined' }\n case 'official':\n return { label: fact.label, color: 'primary', variant: 'outlined' }\n case 'ai':\n return { label: fact.label, color: 'secondary', variant: 'outlined' }\n default:\n return { label: fact.label }\n }\n}\n\n/** The picture a card draws, resolved the way the listing's own pages resolve it. */\nfunction previewOf(row: SiteStarterSummary): OptionCardImage | null {\n const src = resolveMediaSrc(row.previewImageUrl)\n if (!src) return null\n return { src, alt: `A preview of ${row.displayName || 'this starter'}`, ...PREVIEW_SIZE }\n}\n\n/** One starter as a card in the shared option grid. */\nfunction cardOf(row: SiteStarterSummary): OptionCard {\n const image = previewOf(row)\n return {\n id: row.listingId,\n title: row.displayName || 'Untitled starter',\n ...(row.authorName ? { description: `By ${row.authorName}` } : {}),\n ...(image ? { image } : { icon: mdiWeb.path }),\n chips: starterCardFacts(row).map((fact) => chipOf(fact, row)),\n }\n}\n\nconst narrowed = (filter: Partial<SiteStarterFacets>): boolean =>\n (['kind', 'base', 'fonts'] as const).some((key) => typeof filter[key] === 'string' && filter[key] !== '')\n\n/** A row with what the dialog or a purchase knows about owning it laid over the search's answer. */\nconst ownedOf = (row: SiteStarterSummary, override: boolean | undefined): boolean =>\n override ?? row.owned === true\n\n/** What an answer with no starters says, in the words of what was asked. */\nfunction emptyMessage(props: ConsoleHostStarterPickerZoneProps): string {\n if (props.search.trim()) return 'No starters match — try fewer words'\n if (narrowed(props.filter ?? {})) return 'No starters match these choices — try another'\n return props.mode === 'ai' ? 'No AI starters yet' : 'No starters yet'\n}\n\n/**\n * The marketplace's starters in \"Choose your starter\" (AGL-4049): the\n * `hostStarterPicker` zone, drawn before the site exists.\n *\n * Lists what the dialog asks for — its mode, its search words and its\n * filters — as cards of the shared option grid: a picture, the name, who made\n * it, and its price, kind, page count and the \"AI\" and platform marks as\n * chips. NOTHING is selected when it opens; a person picks, and the pick goes\n * to the dialog through `onPick`. It creates nothing: the dialog creates the\n * site from the starter it was handed.\n *\n * `ready` tells the dialog whether a picker is on screen. The first answer\n * decides: starters, or a search that found none (its empty state is a\n * picker with nothing in it yet), answer `true`; a workspace refused the\n * starters (no permission, the release flag off, no source) or a catalog with\n * nothing in it answers `false`, and the dialog offers its own choice\n * instead. Once shown, a later refusal hands back the same way; a later\n * failure is said here with a way to ask again.\n *\n * A picked starter with a price the workspace has not paid says so under\n * the cards, with \"Buy and continue\": the marketplace's payment, in place, on\n * the card on file, with the site still to be created. One it owns says that\n * instead. The dialog's own `selected` wins over the shelf's pick: it is how\n * a pick restored after paying is shown chosen, and how one the create\n * refused is cleared.\n *\n * An AI starter the workspace may use — free, owned, or just bought — has\n * the answers it carries read once it is picked (AGL-4049 phase 4), and\n * handed to the dialog with it (`onPick(pick, { answers })`), which goes on\n * to the AI start's questions with them. A priced one not yet bought is\n * never read: its answers are what it sells, and the door would ask payment\n * for them. A door that still asks is told back to the dialog as unowned.\n */\nexport function StarterPickerShelf(props: ConsoleHostStarterPickerZoneProps) {\n const { orgId, orgSlug, mode, search, filter, onPick, ready, selected } = props\n // The pick the dialog opened on, restored after paying for it: asked for\n // by every search from then on, so it is listed (first) wherever the\n // search would have put it, and never moves under the person's cursor.\n const [restored] = useState(() => selected?.listingId ?? null)\n const found = useStarterSearch({ orgId, mode, word: search, filter, include: restored })\n const [picked, setPicked] = useState<string | null>(null)\n const [shown, setShown] = useState(false)\n // Starters a purchase attempt found this workspace already owns.\n const [ownedHere, setOwnedHere] = useState<ReadonlySet<string>>(() => new Set())\n // AI starters whose answers the door still asked payment for (AGL-4049).\n const [unpaidHere, setUnpaidHere] = useState<ReadonlySet<string>>(() => new Set())\n const purchase = useStarterPurchase(orgId, orgSlug)\n const starterAnswers = useStarterAnswers(orgId)\n const value = selected !== undefined ? (selected?.listingId ?? null) : picked\n const pickedRow = value ? (found.rows.find((row) => row.listingId === value) ?? null) : null\n const ownedOverride = (row: SiteStarterSummary): boolean | undefined =>\n ownedHere.has(row.listingId)\n ? true\n : unpaidHere.has(row.listingId)\n ? false\n : selected?.listingId === row.listingId\n ? selected.owned\n : undefined\n\n const refused = found.error !== null && REFUSED.has(found.error.status)\n // `null` until the first answer, which is the only one that may decide\n // there is nothing to show; after that only a refusal takes it back.\n const verdict: boolean | null = !found.settled\n ? null\n : refused\n ? false\n : shown\n ? true\n : found.error\n ? false\n : found.rows.length > 0 || search.trim() !== '' || narrowed(filter ?? {})\n\n useEffect(() => {\n if (verdict === true) setShown(true)\n if (verdict === false) setShown(false)\n }, [verdict])\n\n // Each distinct verdict once, whatever identity the dialog's callback has.\n const readyRef = useRef(ready)\n readyRef.current = ready\n const reported = useRef<boolean | null>(null)\n useEffect(() => {\n if (verdict === null || reported.current === verdict) return\n reported.current = verdict\n readyRef.current(verdict)\n }, [verdict])\n\n // A pick the dialog restored is handed back once the shelf has read it,\n // so the dialog holds the starter as the search describes it.\n const onPickRef = useRef(onPick)\n onPickRef.current = onPick\n const handedBack = useRef(false)\n useEffect(() => {\n if (!restored || handedBack.current || !pickedRow || pickedRow.listingId !== restored) return\n handedBack.current = true\n const override = ownedOverride(pickedRow)\n onPickRef.current(override === undefined ? pickedRow : { ...pickedRow, owned: override })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [restored, pickedRow])\n\n // The picked AI starter's answers (AGL-4049), read once it is one the\n // workspace may use; keyed on the listing and whether it is owned, so a\n // purchase that makes it usable reads it, and nothing reads it twice.\n const pickedOwned = pickedRow ? ownedOf(pickedRow, ownedOverride(pickedRow)) : false\n const answersKey =\n pickedRow && pickedRow.facets.mode === 'ai' && (pickedRow.priceUsd <= 0 || pickedOwned)\n ? `${pickedRow.listingId}:${pickedOwned}`\n : null\n const [reading, setReading] = useState<{ key: string; failed: string | null } | null>(null)\n const [readAttempt, setReadAttempt] = useState(0)\n const askedAnswers = useRef<string | null>(null)\n useEffect(() => {\n if (!answersKey || !pickedRow || askedAnswers.current === answersKey) return\n askedAnswers.current = answersKey\n const row = pickedRow\n const override = ownedOverride(row)\n const handed = override === undefined ? row : { ...row, owned: override }\n setReading({ key: answersKey, failed: null })\n void starterAnswers.read(row.listingId).then((outcome) => {\n if (askedAnswers.current !== answersKey) return\n if (outcome.status === 'failed') return setReading({ key: answersKey, failed: outcome.message })\n setReading(null)\n if (outcome.status === 'ready') return onPickRef.current(handed, { answers: outcome.answers })\n setUnpaidHere((current) => new Set(current).add(row.listingId))\n onPickRef.current({ ...row, owned: false })\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [answersKey, readAttempt])\n const readingPicked = reading !== null && reading.key === answersKey ? reading : null\n const readAgain = () => {\n askedAnswers.current = null\n setReadAttempt((count) => count + 1)\n }\n\n const options = useMemo(() => found.rows.map(cardOf), [found.rows])\n\n const buy = async (row: SiteStarterSummary) => {\n const outcome = await purchase.buy({ listingId: row.listingId, displayName: row.displayName })\n if (outcome !== 'owned') return\n setOwnedHere((current) => new Set(current).add(row.listingId))\n setUnpaidHere((current) => {\n const next = new Set(current)\n next.delete(row.listingId)\n return next\n })\n onPick({ ...row, owned: true })\n }\n\n if (verdict === false) return null\n if (verdict === null) {\n return (\n <Box\n aria-busy\n aria-label=\"Loading starters\"\n sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, minmax(0, 1fr))', md: 'repeat(3, minmax(0, 1fr))' } }}\n >\n {Array.from({ length: PLACEHOLDER_CARDS }, (_, index) => (\n <Skeleton key={index} variant=\"rounded\" sx={{ height: 'auto', aspectRatio: '1 / 1', borderRadius: 2 }} />\n ))}\n </Box>\n )\n }\n\n return (\n <Stack spacing={2} data-starter-shelf={mode}>\n {found.loading ? <LinearProgress aria-label=\"Searching starters\" /> : null}\n {found.error ? (\n <Alert\n severity=\"error\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={found.refresh}>\n {'Try again'}\n </Button>\n }\n >\n {found.error.message}\n </Alert>\n ) : options.length === 0 ? (\n <Alert\n severity=\"info\"\n action={\n <Button\n color=\"inherit\"\n size=\"small\"\n component={Link}\n href={STARTERS_HELP.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {'How starters work'}\n </Button>\n }\n >\n {emptyMessage(props)}\n </Alert>\n ) : (\n <OptionCardGrid\n label={mode === 'ai' ? 'AI starters' : 'Starters'}\n options={options}\n value={value}\n columns={{ xs: 1, sm: 2, md: 3 }}\n onChange={(listingId) => {\n const row = found.rows.find((candidate) => candidate.listingId === listingId)\n if (!row) return\n setPicked(listingId)\n const override = ownedOverride(row)\n onPick(override === undefined ? row : { ...row, owned: override })\n }}\n />\n )}\n {pickedRow && pickedRow.priceUsd > 0 ? (\n ownedOf(pickedRow, ownedOverride(pickedRow)) ? (\n <Alert severity=\"success\" data-starter-owned={pickedRow.listingId} sx={PICK_NOTE_SX}>\n {'You own this starter. Create your site from it whenever you are ready.'}\n </Alert>\n ) : purchase.panel ? (\n <Box data-starter-pay={pickedRow.listingId} sx={PAY_PANEL_SX}>\n {purchase.panel}\n </Box>\n ) : (\n <Alert\n severity=\"info\"\n data-starter-buy={pickedRow.listingId}\n sx={PICK_NOTE_SX}\n action={\n <BlockedControl\n blocked={Boolean(pickedRow.buyBlockedReason)}\n reason={pickedRow.buyBlockedReason ?? ''}\n >\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={purchase.busy || !orgId}\n onClick={() => void buy(pickedRow)}\n >\n {purchase.busy ? 'Opening…' : 'Buy and continue'}\n </Button>\n </BlockedControl>\n }\n >\n {`${pickedRow.displayName || 'This starter'} costs ${starterPriceLabel(pickedRow.priceUsd)}. ` +\n (pickedRow.buyBlockedReason ?? 'Buy it here, then create your site from it.')}\n </Alert>\n )\n ) : null}\n {purchase.error ? <Alert severity=\"error\">{purchase.error}</Alert> : null}\n {readingPicked?.failed ? (\n <Alert\n severity=\"error\"\n data-starter-answers-failed={pickedRow?.listingId}\n action={\n <Button color=\"inherit\" size=\"small\" onClick={readAgain}>\n {'Try again'}\n </Button>\n }\n >\n {readingPicked.failed}\n </Alert>\n ) : readingPicked ? (\n <LinearProgress aria-label=\"Reading this starter’s answers\" />\n ) : null}\n </Stack>\n )\n}\n\nexport default StarterPickerShelf\n"],"names":["pluginDocsHelp","resolveMediaSrc","mdiWeb","OptionCardGrid","BlockedControl","Alert","Box","Button","Link","LinearProgress","Skeleton","Stack","useEffect","useMemo","useRef","useState","useStarterAnswers","useStarterPurchase","useStarterSearch","starterCardFacts","starterPriceLabel","PICK_NOTE_SX","position","bottom","theme","spacing","zIndex","boxShadow","PAY_PANEL_SX","p","borderRadius","bgcolor","maxHeight","overflow","STARTERS_HELP","PREVIEW_SIZE","width","height","PLACEHOLDER_CARDS","REFUSED","Set","chipOf","fact","row","key","priceUsd","label","color","variant","previewOf","src","previewImageUrl","alt","displayName","cardOf","image","id","listingId","title","authorName","description","icon","path","chips","map","narrowed","filter","some","ownedOf","override","owned","emptyMessage","props","search","trim","mode","StarterPickerShelf","found","pickedRow","orgId","orgSlug","onPick","ready","selected","restored","word","include","picked","setPicked","shown","setShown","ownedHere","setOwnedHere","unpaidHere","setUnpaidHere","purchase","starterAnswers","value","undefined","rows","find","ownedOverride","has","refused","error","status","verdict","settled","length","readyRef","current","reported","onPickRef","handedBack","pickedOwned","answersKey","facets","reading","setReading","readAttempt","setReadAttempt","askedAnswers","handed","failed","read","then","outcome","message","answers","add","readingPicked","readAgain","count","options","buy","next","delete","aria-busy","aria-label","sx","display","gap","gridTemplateColumns","xs","sm","md","Array","from","_","index","aspectRatio","data-starter-shelf","loading","severity","action","size","onClick","refresh","component","href","target","rel","columns","onChange","candidate","data-starter-owned","panel","data-starter-pay","data-starter-buy","blocked","Boolean","buyBlockedReason","reason","disabled","busy","data-starter-answers-failed"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AACjE,SAASC,eAAe,QAAQ,mCAAkC;AAIlE,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SAC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AAU6F,gBAAgB,YAA1B7F,8BAA8B;8BAEtC,cAAA,KAACvE;wBACCwC,OAAM;wBACN4G,MAAK;wBACLkB,UAAU9E,SAAS+E,IAAI,IAAI,CAAC/F;wBAC5B6E,SAAS,IAAM,KAAKtB,IAAIxD;kCAEvBiB,SAAS+E,IAAI,GAAG,aAAa;;;0BAKnC,GAAGhG,UAAUzB,WAAW,IAAI,eAAe,OAAO,EAAEjC,kBAAkB0D,UAAUjC,QAAQ,EAAE,EAAE,CAAC,KAC3FiC,+BAAAA,UAAU6F,gBAAgB,YAA1B7F,+BAA8B;iBAGnC;YACHiB,SAASS,KAAK,iBAAG,KAACnG;gBAAMoJ,UAAS;0BAAS1D,SAASS,KAAK;iBAAY;YACpE0B,CAAAA,iCAAAA,cAAeP,MAAM,kBACpB,KAACtH;gBACCoJ,UAAS;gBACTsB,6BAA2B,EAAEjG,6BAAAA,UAAWrB,SAAS;gBACjDiG,sBACE,KAACnJ;oBAAOwC,OAAM;oBAAU4G,MAAK;oBAAQC,SAASzB;8BAC3C;;0BAIJD,cAAcP,MAAM;iBAErBO,8BACF,KAACzH;gBAAeiI,cAAW;iBACzB;;;AAGV;AAEA,eAAe9D,mBAAkB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/starter-picker-shelf.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { resolveMediaSrc } from '@aglyn/aglyn/app-utils/media-ref'\nimport type { SiteStarterFacets } from '@aglyn/aglyn/app-utils/site-starter'\nimport type { ConsoleHostStarterPickerZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport type { SiteStarterSummary } from '@aglyn/aglyn/plugin-manager/plugin-site-starters'\nimport { mdiWeb } from '@aglyn/shared-data-mdi'\nimport {\n OptionCardGrid,\n type OptionCard,\n type OptionCardChip,\n type OptionCardImage,\n} from '@aglyn/shared-ui-jsx/components/option-card-grid.component'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useBuyingHidden } from '@aglyn/shared-ui-jsx/contexts/buying-hidden.context'\nimport {\n Alert,\n Box,\n Button,\n Link,\n LinearProgress,\n Skeleton,\n Stack,\n type SxProps,\n type Theme,\n} from '@mui/material'\nimport { useEffect, useMemo, useRef, useState } from 'react'\nimport { useStarterAnswers } from '../hooks/use-starter-answers'\nimport { useStarterPurchase } from '../hooks/use-starter-purchase'\nimport { useStarterSearch } from '../hooks/use-starter-search'\nimport { starterCardFacts, starterPriceLabel, type StarterCardFact } from '../model/starter-query'\n\n/**\n * What a picked starter's price or licence says, held at the foot of the\n * visible cards while the shelf is in view, so \"Buy and continue\" is beside\n * whichever card was clicked rather than below all of them.\n */\nconst PICK_NOTE_SX: SxProps<Theme> = {\n position: 'sticky',\n bottom: (theme) => theme.spacing(2),\n zIndex: 1,\n boxShadow: 3,\n}\n\n/**\n * The payment, where the note was, on its own surface. It may fill the window\n * below the app bar, so a form that has grown keeps its button on screen; a\n * smaller window scrolls inside it.\n */\nconst PAY_PANEL_SX: SxProps<Theme> = {\n position: 'sticky',\n bottom: (theme) => theme.spacing(2),\n zIndex: 1,\n boxShadow: 3,\n p: 2,\n borderRadius: 1,\n bgcolor: 'background.paper',\n maxHeight: (theme) => `calc(100dvh - ${theme.spacing(10)})`,\n overflow: 'auto',\n}\n\n/** The guide to site starters, linked from what the shelf says when it has nothing to show. */\nconst STARTERS_HELP = pluginDocsHelp('siteStarters')\n\n/**\n * A starter's preview as the card draws it: the size the platform's own\n * style previews are rendered at (square), so a row of cards stays level and\n * a publisher's picture is cropped to the same shape from its top.\n */\nconst PREVIEW_SIZE = { width: 800, height: 800 } as const\n\n/** How many placeholder cards stand in for the first answer. */\nconst PLACEHOLDER_CARDS = 3\n\n/** Statuses that mean this workspace may not have starters offered here: the dialog's own choice instead. */\nconst REFUSED = new Set([401, 403, 503])\n\n/** How each fact's chip is colored, from the theme: the price as the marketplace's own cards color it. */\nfunction chipOf(fact: StarterCardFact, row: SiteStarterSummary): OptionCardChip {\n switch (fact.key) {\n case 'price':\n return row.priceUsd > 0\n ? { label: fact.label, color: 'primary', variant: 'filled' }\n : { label: fact.label, color: 'success', variant: 'outlined' }\n case 'official':\n return { label: fact.label, color: 'primary', variant: 'outlined' }\n case 'ai':\n return { label: fact.label, color: 'secondary', variant: 'outlined' }\n default:\n return { label: fact.label }\n }\n}\n\n/** The picture a card draws, resolved the way the listing's own pages resolve it. */\nfunction previewOf(row: SiteStarterSummary): OptionCardImage | null {\n const src = resolveMediaSrc(row.previewImageUrl)\n if (!src) return null\n return { src, alt: `A preview of ${row.displayName || 'this starter'}`, ...PREVIEW_SIZE }\n}\n\n/** One starter as a card in the shared option grid. */\nfunction cardOf(row: SiteStarterSummary): OptionCard {\n const image = previewOf(row)\n return {\n id: row.listingId,\n title: row.displayName || 'Untitled starter',\n ...(row.authorName ? { description: `By ${row.authorName}` } : {}),\n ...(image ? { image } : { icon: mdiWeb.path }),\n chips: starterCardFacts(row).map((fact) => chipOf(fact, row)),\n }\n}\n\nconst narrowed = (filter: Partial<SiteStarterFacets>): boolean =>\n (['kind', 'base', 'fonts'] as const).some((key) => typeof filter[key] === 'string' && filter[key] !== '')\n\n/** A row with what the dialog or a purchase knows about owning it laid over the search's answer. */\nconst ownedOf = (row: SiteStarterSummary, override: boolean | undefined): boolean =>\n override ?? row.owned === true\n\n/** What an answer with no starters says, in the words of what was asked. */\nfunction emptyMessage(props: ConsoleHostStarterPickerZoneProps): string {\n if (props.search.trim()) return 'No starters match — try fewer words'\n if (narrowed(props.filter ?? {})) return 'No starters match these choices — try another'\n return props.mode === 'ai' ? 'No AI starters yet' : 'No starters yet'\n}\n\n/**\n * The marketplace's starters in \"Choose your starter\" (AGL-4049): the\n * `hostStarterPicker` zone, drawn before the site exists.\n *\n * Lists what the dialog asks for — its mode, its search words and its\n * filters — as cards of the shared option grid: a picture, the name, who made\n * it, and its price, kind, page count and the \"AI\" and platform marks as\n * chips. NOTHING is selected when it opens; a person picks, and the pick goes\n * to the dialog through `onPick`. It creates nothing: the dialog creates the\n * site from the starter it was handed.\n *\n * `ready` tells the dialog whether a picker is on screen. The first answer\n * decides: starters, or a search that found none (its empty state is a\n * picker with nothing in it yet), answer `true`; a workspace refused the\n * starters (no permission, the release flag off, no source) or a catalog with\n * nothing in it answers `false`, and the dialog offers its own choice\n * instead. Once shown, a later refusal hands back the same way; a later\n * failure is said here with a way to ask again.\n *\n * A picked starter with a price the workspace has not paid says so under\n * the cards, with \"Buy and continue\": the marketplace's payment, in place, on\n * the card on file, with the site still to be created. One it owns says that\n * instead. The dialog's own `selected` wins over the shelf's pick: it is how\n * a pick restored after paying is shown chosen, and how one the create\n * refused is cleared.\n *\n * An AI starter the workspace may use — free, owned, or just bought — has\n * the answers it carries read once it is picked (AGL-4049 phase 4), and\n * handed to the dialog with it (`onPick(pick, { answers })`), which goes on\n * to the AI start's questions with them. A priced one not yet bought is\n * never read: its answers are what it sells, and the door would ask payment\n * for them. A door that still asks is told back to the dialog as unowned.\n */\nexport function StarterPickerShelf(props: ConsoleHostStarterPickerZoneProps) {\n const { orgId, orgSlug, mode, search, filter, onPick, ready, selected } = props\n // The pick the dialog opened on, restored after paying for it: asked for\n // by every search from then on, so it is listed (first) wherever the\n // search would have put it, and never moves under the person's cursor.\n const [restored] = useState(() => selected?.listingId ?? null)\n const found = useStarterSearch({ orgId, mode, word: search, filter, include: restored })\n const [picked, setPicked] = useState<string | null>(null)\n const [shown, setShown] = useState(false)\n // Starters a purchase attempt found this workspace already owns.\n const [ownedHere, setOwnedHere] = useState<ReadonlySet<string>>(() => new Set())\n // AI starters whose answers the door still asked payment for (AGL-4049).\n const [unpaidHere, setUnpaidHere] = useState<ReadonlySet<string>>(() => new Set())\n const purchase = useStarterPurchase(orgId, orgSlug)\n const starterAnswers = useStarterAnswers(orgId)\n const value = selected !== undefined ? (selected?.listingId ?? null) : picked\n const ownedOverride = (row: SiteStarterSummary): boolean | undefined =>\n ownedHere.has(row.listingId)\n ? true\n : unpaidHere.has(row.listingId)\n ? false\n : selected?.listingId === row.listingId\n ? selected.owned\n : undefined\n // An app build for store review cannot buy, so a starter that would have to\n // be bought first is not offered there; free and owned ones are.\n const buyingHidden = useBuyingHidden()\n const rows = buyingHidden\n ? found.rows.filter((row) => row.priceUsd <= 0 || ownedOf(row, ownedOverride(row)))\n : found.rows\n const pickedRow = value ? (rows.find((row) => row.listingId === value) ?? null) : null\n\n const refused = found.error !== null && REFUSED.has(found.error.status)\n // `null` until the first answer, which is the only one that may decide\n // there is nothing to show; after that only a refusal takes it back.\n const verdict: boolean | null = !found.settled\n ? null\n : refused\n ? false\n : shown\n ? true\n : found.error\n ? false\n : rows.length > 0 || search.trim() !== '' || narrowed(filter ?? {})\n\n useEffect(() => {\n if (verdict === true) setShown(true)\n if (verdict === false) setShown(false)\n }, [verdict])\n\n // Each distinct verdict once, whatever identity the dialog's callback has.\n const readyRef = useRef(ready)\n readyRef.current = ready\n const reported = useRef<boolean | null>(null)\n useEffect(() => {\n if (verdict === null || reported.current === verdict) return\n reported.current = verdict\n readyRef.current(verdict)\n }, [verdict])\n\n // A pick the dialog restored is handed back once the shelf has read it,\n // so the dialog holds the starter as the search describes it.\n const onPickRef = useRef(onPick)\n onPickRef.current = onPick\n const handedBack = useRef(false)\n useEffect(() => {\n if (!restored || handedBack.current || !pickedRow || pickedRow.listingId !== restored) return\n handedBack.current = true\n const override = ownedOverride(pickedRow)\n onPickRef.current(override === undefined ? pickedRow : { ...pickedRow, owned: override })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [restored, pickedRow])\n\n // The picked AI starter's answers (AGL-4049), read once it is one the\n // workspace may use; keyed on the listing and whether it is owned, so a\n // purchase that makes it usable reads it, and nothing reads it twice.\n const pickedOwned = pickedRow ? ownedOf(pickedRow, ownedOverride(pickedRow)) : false\n const answersKey =\n pickedRow && pickedRow.facets.mode === 'ai' && (pickedRow.priceUsd <= 0 || pickedOwned)\n ? `${pickedRow.listingId}:${pickedOwned}`\n : null\n const [reading, setReading] = useState<{ key: string; failed: string | null } | null>(null)\n const [readAttempt, setReadAttempt] = useState(0)\n const askedAnswers = useRef<string | null>(null)\n useEffect(() => {\n if (!answersKey || !pickedRow || askedAnswers.current === answersKey) return\n askedAnswers.current = answersKey\n const row = pickedRow\n const override = ownedOverride(row)\n const handed = override === undefined ? row : { ...row, owned: override }\n setReading({ key: answersKey, failed: null })\n void starterAnswers.read(row.listingId).then((outcome) => {\n if (askedAnswers.current !== answersKey) return\n if (outcome.status === 'failed') return setReading({ key: answersKey, failed: outcome.message })\n setReading(null)\n if (outcome.status === 'ready') return onPickRef.current(handed, { answers: outcome.answers })\n setUnpaidHere((current) => new Set(current).add(row.listingId))\n onPickRef.current({ ...row, owned: false })\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [answersKey, readAttempt])\n const readingPicked = reading !== null && reading.key === answersKey ? reading : null\n const readAgain = () => {\n askedAnswers.current = null\n setReadAttempt((count) => count + 1)\n }\n\n const options = useMemo(() => rows.map(cardOf), [rows])\n\n const buy = async (row: SiteStarterSummary) => {\n const outcome = await purchase.buy({ listingId: row.listingId, displayName: row.displayName })\n if (outcome !== 'owned') return\n setOwnedHere((current) => new Set(current).add(row.listingId))\n setUnpaidHere((current) => {\n const next = new Set(current)\n next.delete(row.listingId)\n return next\n })\n onPick({ ...row, owned: true })\n }\n\n if (verdict === false) return null\n if (verdict === null) {\n return (\n <Box\n aria-busy\n aria-label=\"Loading starters\"\n sx={{ display: 'grid', gap: 2, gridTemplateColumns: { xs: '1fr', sm: 'repeat(2, minmax(0, 1fr))', md: 'repeat(3, minmax(0, 1fr))' } }}\n >\n {Array.from({ length: PLACEHOLDER_CARDS }, (_, index) => (\n <Skeleton key={index} variant=\"rounded\" sx={{ height: 'auto', aspectRatio: '1 / 1', borderRadius: 2 }} />\n ))}\n </Box>\n )\n }\n\n return (\n <Stack spacing={2} data-starter-shelf={mode}>\n {found.loading ? <LinearProgress aria-label=\"Searching starters\" /> : null}\n {found.error ? (\n <Alert\n severity=\"error\"\n action={\n <Button color=\"inherit\" size=\"small\" onClick={found.refresh}>\n {'Try again'}\n </Button>\n }\n >\n {found.error.message}\n </Alert>\n ) : options.length === 0 ? (\n <Alert\n severity=\"info\"\n action={\n <Button\n color=\"inherit\"\n size=\"small\"\n component={Link}\n href={STARTERS_HELP.href}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n {'How starters work'}\n </Button>\n }\n >\n {emptyMessage(props)}\n </Alert>\n ) : (\n <OptionCardGrid\n label={mode === 'ai' ? 'AI starters' : 'Starters'}\n options={options}\n value={value}\n columns={{ xs: 1, sm: 2, md: 3 }}\n onChange={(listingId) => {\n const row = rows.find((candidate) => candidate.listingId === listingId)\n if (!row) return\n setPicked(listingId)\n const override = ownedOverride(row)\n onPick(override === undefined ? row : { ...row, owned: override })\n }}\n />\n )}\n {pickedRow && pickedRow.priceUsd > 0 ? (\n ownedOf(pickedRow, ownedOverride(pickedRow)) ? (\n <Alert severity=\"success\" data-starter-owned={pickedRow.listingId} sx={PICK_NOTE_SX}>\n {'You own this starter. Create your site from it whenever you are ready.'}\n </Alert>\n ) : purchase.panel ? (\n <Box data-starter-pay={pickedRow.listingId} sx={PAY_PANEL_SX}>\n {purchase.panel}\n </Box>\n ) : (\n <Alert\n severity=\"info\"\n data-starter-buy={pickedRow.listingId}\n sx={PICK_NOTE_SX}\n action={\n <BlockedControl\n blocked={Boolean(pickedRow.buyBlockedReason)}\n reason={pickedRow.buyBlockedReason ?? ''}\n >\n <Button\n color=\"inherit\"\n size=\"small\"\n disabled={purchase.busy || !orgId}\n onClick={() => void buy(pickedRow)}\n >\n {purchase.busy ? 'Opening…' : 'Buy and continue'}\n </Button>\n </BlockedControl>\n }\n >\n {`${pickedRow.displayName || 'This starter'} costs ${starterPriceLabel(pickedRow.priceUsd)}. ` +\n (pickedRow.buyBlockedReason ?? 'Buy it here, then create your site from it.')}\n </Alert>\n )\n ) : null}\n {purchase.error ? <Alert severity=\"error\">{purchase.error}</Alert> : null}\n {readingPicked?.failed ? (\n <Alert\n severity=\"error\"\n data-starter-answers-failed={pickedRow?.listingId}\n action={\n <Button color=\"inherit\" size=\"small\" onClick={readAgain}>\n {'Try again'}\n </Button>\n }\n >\n {readingPicked.failed}\n </Alert>\n ) : readingPicked ? (\n <LinearProgress aria-label=\"Reading this starter’s answers\" />\n ) : null}\n </Stack>\n )\n}\n\nexport default StarterPickerShelf\n"],"names":["pluginDocsHelp","resolveMediaSrc","mdiWeb","OptionCardGrid","BlockedControl","useBuyingHidden","Alert","Box","Button","Link","LinearProgress","Skeleton","Stack","useEffect","useMemo","useRef","useState","useStarterAnswers","useStarterPurchase","useStarterSearch","starterCardFacts","starterPriceLabel","PICK_NOTE_SX","position","bottom","theme","spacing","zIndex","boxShadow","PAY_PANEL_SX","p","borderRadius","bgcolor","maxHeight","overflow","STARTERS_HELP","PREVIEW_SIZE","width","height","PLACEHOLDER_CARDS","REFUSED","Set","chipOf","fact","row","key","priceUsd","label","color","variant","previewOf","src","previewImageUrl","alt","displayName","cardOf","image","id","listingId","title","authorName","description","icon","path","chips","map","narrowed","filter","some","ownedOf","override","owned","emptyMessage","props","search","trim","mode","StarterPickerShelf","rows","pickedRow","orgId","orgSlug","onPick","ready","selected","restored","found","word","include","picked","setPicked","shown","setShown","ownedHere","setOwnedHere","unpaidHere","setUnpaidHere","purchase","starterAnswers","value","undefined","ownedOverride","has","buyingHidden","find","refused","error","status","verdict","settled","length","readyRef","current","reported","onPickRef","handedBack","pickedOwned","answersKey","facets","reading","setReading","readAttempt","setReadAttempt","askedAnswers","handed","failed","read","then","outcome","message","answers","add","readingPicked","readAgain","count","options","buy","next","delete","aria-busy","aria-label","sx","display","gap","gridTemplateColumns","xs","sm","md","Array","from","_","index","aspectRatio","data-starter-shelf","loading","severity","action","size","onClick","refresh","component","href","target","rel","columns","onChange","candidate","data-starter-owned","panel","data-starter-pay","data-starter-buy","blocked","Boolean","buyBlockedReason","reason","disabled","busy","data-starter-answers-failed"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,cAAc,QAAQ,mCAAkC;AACjE,SAASC,eAAe,QAAQ,mCAAkC;AAIlE,SAASC,MAAM,QAAQ,yBAAwB;AAC/C,SACEC,cAAc,QAIT,6DAA4D;AACnE,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,eAAe,QAAQ,sDAAqD;AACrF,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,cAAc,EACdC,QAAQ,EACRC,KAAK,QAGA,gBAAe;AACtB,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAC5D,SAASC,iBAAiB,QAAQ,kCAA8B;AAChE,SAASC,kBAAkB,QAAQ,mCAA+B;AAClE,SAASC,gBAAgB,QAAQ,iCAA6B;AAC9D,SAASC,gBAAgB,EAAEC,iBAAiB,QAA8B,4BAAwB;AAElG;;;;CAIC,GACD,MAAMC,eAA+B;IACnCC,UAAU;IACVC,QAAQ,CAACC,QAAUA,MAAMC,OAAO,CAAC;IACjCC,QAAQ;IACRC,WAAW;AACb;AAEA;;;;CAIC,GACD,MAAMC,eAA+B;IACnCN,UAAU;IACVC,QAAQ,CAACC,QAAUA,MAAMC,OAAO,CAAC;IACjCC,QAAQ;IACRC,WAAW;IACXE,GAAG;IACHC,cAAc;IACdC,SAAS;IACTC,WAAW,CAACR,QAAU,CAAC,cAAc,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AAOwC,OAAM;oBAAU6G,MAAK;oBAAQC,SAASzB;8BAC3C;;0BAIJD,cAAcP,MAAM;iBAErBO,8BACF,KAAC1H;gBAAekI,cAAW;iBACzB;;;AAGV;AAEA,eAAe/D,mBAAkB"}
|
|
@@ -18,7 +18,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
18
18
|
import { lockdownRefusalText, parseLockdownRefusal } from "@aglyn/aglyn";
|
|
19
19
|
import { useLoading } from "@aglyn/shared-ui-jsx";
|
|
20
20
|
import { ListPagination } from "@aglyn/shared-ui-jsx/components/list-pagination.component";
|
|
21
|
-
import { LIST_QUERY_ID_PATH } from "@aglyn/shared-ui-jsx/const/list-query-plan";
|
|
22
21
|
import { useSnackbar } from "@aglyn/shared-ui-snackstack";
|
|
23
22
|
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
24
23
|
import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
|
|
@@ -26,32 +25,9 @@ import { useListQuery } from "@aglyn/tenant-feature-instance/hooks/use-list-quer
|
|
|
26
25
|
import { Box, Button, Card, CardActions, CardContent, Chip, Grid, Typography } from "@mui/material";
|
|
27
26
|
import { collection } from "firebase/firestore";
|
|
28
27
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
28
|
+
import { SITE_TEMPLATE_SHELF_BASE, SITE_TEMPLATE_SHELF_QUERY } from "../model/listing-query.js";
|
|
29
29
|
import { ListingImage } from "./listing-image.component.js";
|
|
30
30
|
/** The name this shelf reports itself by to the gallery. */ const SHELF_ID = 'marketplace-site-templates';
|
|
31
|
-
/**
|
|
32
|
-
* What the shelf asks: no Filters panel, the walk's order (the document
|
|
33
|
-
* name, which the automatic single-field indexes serve under the one
|
|
34
|
-
* equality and the one array clause), and the listing's name keys, which
|
|
35
|
-
* every publish stamps (AGL-3321).
|
|
36
|
-
*/ const SITE_TEMPLATE_SHELF = {
|
|
37
|
-
fields: [],
|
|
38
|
-
sorts: [
|
|
39
|
-
{
|
|
40
|
-
path: LIST_QUERY_ID_PATH,
|
|
41
|
-
direction: 'asc'
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
search: {
|
|
45
|
-
tokensPath: 'nameTokens'
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
/** The shelf's scope: published site templates. */ const SITE_TEMPLATE_BASE = [
|
|
49
|
-
{
|
|
50
|
-
path: 'kind',
|
|
51
|
-
op: '==',
|
|
52
|
-
value: 'template'
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
31
|
/**
|
|
56
32
|
* Marketplace site templates in the template gallery (AGL-137) — the
|
|
57
33
|
* `templateGallery` zone, drawn here since AGL-3080.
|
|
@@ -84,11 +60,11 @@ import { ListingImage } from "./listing-image.component.js";
|
|
|
84
60
|
]);
|
|
85
61
|
const market = useListQuery({
|
|
86
62
|
collection: offered ? collection(firestore, 'marketplaceListings') : null,
|
|
87
|
-
declaration:
|
|
63
|
+
declaration: SITE_TEMPLATE_SHELF_QUERY,
|
|
88
64
|
request: {
|
|
89
65
|
clauses: [],
|
|
90
66
|
search: searchWords,
|
|
91
|
-
base:
|
|
67
|
+
base: SITE_TEMPLATE_SHELF_BASE
|
|
92
68
|
},
|
|
93
69
|
deps: [
|
|
94
70
|
firestore,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/template-gallery-shelf.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n lockdownRefusalText,\n parseLockdownRefusal,\n type ConsoleTemplateGalleryShelfState,\n type ConsoleTemplateGalleryZoneProps,\n} from '@aglyn/aglyn'\nimport { useLoading } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport {\n LIST_QUERY_ID_PATH,\n type ListQueryDeclaration,\n type ListQueryFilter,\n} from '@aglyn/shared-ui-jsx/const/list-query-plan'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\nimport {\n Box,\n Button,\n Card,\n CardActions,\n CardContent,\n Chip,\n Grid,\n Typography,\n} from '@mui/material'\nimport { collection } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { ListingImage } from './listing-image.component'\n\n/** The name this shelf reports itself by to the gallery. */\nconst SHELF_ID = 'marketplace-site-templates'\n\n/**\n * What the shelf asks: no Filters panel, the walk's order (the document\n * name, which the automatic single-field indexes serve under the one\n * equality and the one array clause), and the listing's name keys, which\n * every publish stamps (AGL-3321).\n */\nconst SITE_TEMPLATE_SHELF: ListQueryDeclaration = {\n fields: [],\n sorts: [{ path: LIST_QUERY_ID_PATH, direction: 'asc' }],\n search: { tokensPath: 'nameTokens' },\n}\n\n/** The shelf's scope: published site templates. */\nconst SITE_TEMPLATE_BASE: ListQueryFilter[] = [\n { path: 'kind', op: '==', value: 'template' },\n]\n\n/**\n * Marketplace site templates in the template gallery (AGL-137) — the\n * `templateGallery` zone, drawn here since AGL-3080.\n *\n * Published bundles with previews, searched by the gallery's search word.\n * Whole-site page bundles, so — like the gallery's starters — only in the\n * page-kind picker (AGL-699): a five-page site on the components list would\n * install pages nobody asked for.\n *\n * An unpublished listing keeps its document (`deletedAt`), and Firestore\n * cannot ask for the absence of that field without hiding every listing\n * written before the field existed — so it is dropped from the page it falls\n * in. That is the shelf's scope, not a filter: the search is on the query,\n * and a page can only render fewer cards than its size.\n *\n * \"Use template\" installs through `marketplace/install-template`, which\n * holds every check an install makes, and lands the bundle in the site's\n * library without publishing anything (AGL-669).\n */\nexport function TemplateGalleryShelf(props: ConsoleTemplateGalleryZoneProps) {\n const { hostId, kind, search, onInstalled, reportShelf } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { queueLoading } = useLoading()\n const offered = kind === 'page'\n const searchWords = useMemo(() => (search ? [search] : []), [search])\n\n const market = useListQuery<any>({\n collection: offered ? collection(firestore, 'marketplaceListings') : null,\n declaration: SITE_TEMPLATE_SHELF,\n request: { clauses: [], search: searchWords, base: SITE_TEMPLATE_BASE },\n deps: [firestore, offered],\n idField: '$id',\n })\n const listings = useMemo(\n () => market.rows.filter((listing: any) => !listing.deletedAt),\n [market.rows],\n )\n const visible = listings.length > 0 || market.hasMore || market.page > 0\n const state: ConsoleTemplateGalleryShelfState = !offered\n ? 'empty'\n : market.status === 'loading'\n ? 'loading'\n : visible\n ? 'shown'\n : 'empty'\n useEffect(() => {\n reportShelf(SHELF_ID, state)\n }, [reportShelf, state])\n\n const [installingId, setInstallingId] = useState<string | null>(null)\n const handleInstall = useCallback(\n (listing: any) => async () => {\n if (installingId) return\n setInstallingId(listing.$id)\n const dequeue = queueLoading()\n try {\n const response = await authorizedFetch(\n user,\n '/api/marketplace/install-template',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ listingId: listing.$id, hostId }),\n },\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n // An installs lock is not a broken listing (AGL-1532).\n const locked = parseLockdownRefusal(response.status, payload)\n if (locked) {\n return void enqueueSnackbar(lockdownRefusalText(locked), {\n variant: 'warning',\n persist: true,\n })\n }\n return void enqueueSnackbar(\n payload?.error ?? 'Template install failed',\n {\n variant: response.status === 402 ? 'warning' : 'error',\n allowDuplicate: true,\n },\n )\n }\n // Installing adds to the template library and publishes nothing\n // (AGL-669), so the message must not imply pages appeared.\n const added = Number(payload.templates ?? 0)\n enqueueSnackbar(\n `Saved ${added} template${added === 1 ? '' : 's'} from ` +\n `\"${listing.displayName}\" to your library — open Templates to ` +\n 'create pages from them.',\n { variant: 'success', persist: false },\n )\n onInstalled()\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setInstallingId(null)\n dequeue()\n }\n },\n [installingId, user, hostId, queueLoading, enqueueSnackbar, onInstalled],\n )\n\n if (!offered || !visible) return null\n // One element: the zone stacks its widgets, and the heading, the cards and\n // the pager are one shelf.\n return (\n <Box component=\"section\" aria-label=\"Marketplace templates\">\n <Typography variant=\"subtitle1\" sx={{ mb: 1 }}>\n {'Marketplace templates'}\n </Typography>\n <Grid container spacing={2}>\n {listings.map((listing: any) => (\n <Grid key={listing.$id} size={{ xs: 12, sm: 6, md: 4 }}>\n <Card variant=\"outlined\" sx={{ height: '100%' }}>\n <ListingImage\n src={listing.previewImageUrl}\n alt={`${listing.displayName} preview`}\n sx={{ width: '100%', height: 120, objectFit: 'cover' }}\n />\n <CardContent>\n <Typography variant=\"h6\">{listing.displayName}</Typography>\n {listing.category ? (\n <Chip\n label={listing.category}\n size=\"small\"\n variant=\"outlined\"\n sx={{ my: 1 }}\n />\n ) : null}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {listing.description ?? ''}\n </Typography>\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{ mt: 1 }}\n >\n {`${listing.screenCount ?? '?'} pages · v${listing.latestVersion}` +\n (Number(listing.priceUsd ?? 0) > 0\n ? ` · $${listing.priceUsd}`\n : ' · free')}\n </Typography>\n </CardContent>\n <CardActions>\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n disabled={installingId === listing.$id}\n onClick={handleInstall(listing)}\n >\n {installingId === listing.$id ? 'Installing…' : 'Use template'}\n </Button>\n </CardActions>\n </Card>\n </Grid>\n ))}\n </Grid>\n <ListPagination\n page={market.page}\n pageSize={market.pageSize}\n rowCount={listings.length}\n hasMore={market.hasMore}\n onPageChange={market.setPage}\n onPageSizeChange={market.setPageSize}\n />\n </Box>\n )\n}\n\nexport default TemplateGalleryShelf\n"],"names":["lockdownRefusalText","parseLockdownRefusal","useLoading","ListPagination","LIST_QUERY_ID_PATH","useSnackbar","authorizedFetch","useFirestore","useUser","useListQuery","Box","Button","Card","CardActions","CardContent","Chip","Grid","Typography","collection","useCallback","useEffect","useMemo","useState","ListingImage","SHELF_ID","SITE_TEMPLATE_SHELF","fields","sorts","path","direction","search","tokensPath","SITE_TEMPLATE_BASE","op","value","TemplateGalleryShelf","props","hostId","kind","onInstalled","reportShelf","firestore","data","user","enqueueSnackbar","queueLoading","offered","searchWords","market","declaration","request","clauses","base","deps","idField","listings","rows","filter","listing","deletedAt","visible","length","hasMore","page","state","status","installingId","setInstallingId","handleInstall","$id","dequeue","payload","response","method","headers","body","JSON","stringify","listingId","json","catch","ok","locked","variant","persist","error","allowDuplicate","added","Number","templates","displayName","console","component","aria-label","sx","mb","container","spacing","map","size","xs","sm","md","height","src","previewImageUrl","alt","width","objectFit","category","label","my","color","description","mt","screenCount","latestVersion","priceUsd","disabled","onClick","pageSize","rowCount","onPageChange","setPage","onPageSizeChange","setPageSize"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,mBAAmB,EACnBC,oBAAoB,QAGf,eAAc;AACrB,SAASC,UAAU,QAAQ,uBAAsB;AACjD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SACEC,kBAAkB,QAGb,6CAA4C;AACnD,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,OAAO,QAAQ,iCAAgC;AACtE,SAASC,YAAY,QAAQ,sDAAqD;AAClF,SACEC,GAAG,EACHC,MAAM,EACNC,IAAI,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SAAQ;4CACRW,IAAI;gDAAEiB,IAAI;4CAAE;6CAEZ;sDACJ,KAAC9F;4CAAWkE,SAAQ;4CAAQ6B,OAAM;uDAC/BtD,uBAAAA,QAAQuD,WAAW,YAAnBvD,uBAAuB;;sDAE1B,KAACzC;4CACCkE,SAAQ;4CACR6B,OAAM;4CACNpB,WAAU;4CACVE,IAAI;gDAAEoB,IAAI;4CAAE;sDAEX,IAAGxD,uBAAAA,QAAQyD,WAAW,YAAnBzD,uBAAuB,IAAI,UAAU,EAAEA,QAAQ0D,aAAa,EAAE,GAC/D5B,CAAAA,QAAO9B,oBAAAA,QAAQ2D,QAAQ,YAAhB3D,oBAAoB,KAAK,IAC7B,CAAC,IAAI,EAAEA,QAAQ2D,QAAQ,EAAE,GACzB,SAAQ;;;;8CAGlB,KAACxG;8CACC,cAAA,KAACF;wCACCwF,MAAK;wCACLhB,SAAQ;wCACR6B,OAAM;wCACNM,UAAUpD,iBAAiBR,QAAQW,GAAG;wCACtCkD,SAASnD,cAAcV;kDAEtBQ,iBAAiBR,QAAQW,GAAG,GAAG,gBAAgB;;;;;uBAxC7CX,QAAQW,GAAG;;;0BA+C1B,KAAClE;gBACC4D,MAAMf,OAAOe,IAAI;gBACjByD,UAAUxE,OAAOwE,QAAQ;gBACzBC,UAAUlE,SAASM,MAAM;gBACzBC,SAASd,OAAOc,OAAO;gBACvB4D,cAAc1E,OAAO2E,OAAO;gBAC5BC,kBAAkB5E,OAAO6E,WAAW;;;;AAI5C;AAEA,eAAe1F,qBAAoB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/template-gallery-shelf.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n lockdownRefusalText,\n parseLockdownRefusal,\n type ConsoleTemplateGalleryShelfState,\n type ConsoleTemplateGalleryZoneProps,\n} from '@aglyn/aglyn'\nimport { useLoading } from '@aglyn/shared-ui-jsx'\nimport { ListPagination } from '@aglyn/shared-ui-jsx/components/list-pagination.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useUser } from '@aglyn/tenant-feature-instance'\nimport { useListQuery } from '@aglyn/tenant-feature-instance/hooks/use-list-query'\nimport {\n Box,\n Button,\n Card,\n CardActions,\n CardContent,\n Chip,\n Grid,\n Typography,\n} from '@mui/material'\nimport { collection } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { SITE_TEMPLATE_SHELF_BASE, SITE_TEMPLATE_SHELF_QUERY } from '../model/listing-query'\nimport { ListingImage } from './listing-image.component'\n\n/** The name this shelf reports itself by to the gallery. */\nconst SHELF_ID = 'marketplace-site-templates'\n\n/**\n * Marketplace site templates in the template gallery (AGL-137) — the\n * `templateGallery` zone, drawn here since AGL-3080.\n *\n * Published bundles with previews, searched by the gallery's search word.\n * Whole-site page bundles, so — like the gallery's starters — only in the\n * page-kind picker (AGL-699): a five-page site on the components list would\n * install pages nobody asked for.\n *\n * An unpublished listing keeps its document (`deletedAt`), and Firestore\n * cannot ask for the absence of that field without hiding every listing\n * written before the field existed — so it is dropped from the page it falls\n * in. That is the shelf's scope, not a filter: the search is on the query,\n * and a page can only render fewer cards than its size.\n *\n * \"Use template\" installs through `marketplace/install-template`, which\n * holds every check an install makes, and lands the bundle in the site's\n * library without publishing anything (AGL-669).\n */\nexport function TemplateGalleryShelf(props: ConsoleTemplateGalleryZoneProps) {\n const { hostId, kind, search, onInstalled, reportShelf } = props\n const firestore = useFirestore()\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { queueLoading } = useLoading()\n const offered = kind === 'page'\n const searchWords = useMemo(() => (search ? [search] : []), [search])\n\n const market = useListQuery<any>({\n collection: offered ? collection(firestore, 'marketplaceListings') : null,\n declaration: SITE_TEMPLATE_SHELF_QUERY,\n request: { clauses: [], search: searchWords, base: SITE_TEMPLATE_SHELF_BASE },\n deps: [firestore, offered],\n idField: '$id',\n })\n const listings = useMemo(\n () => market.rows.filter((listing: any) => !listing.deletedAt),\n [market.rows],\n )\n const visible = listings.length > 0 || market.hasMore || market.page > 0\n const state: ConsoleTemplateGalleryShelfState = !offered\n ? 'empty'\n : market.status === 'loading'\n ? 'loading'\n : visible\n ? 'shown'\n : 'empty'\n useEffect(() => {\n reportShelf(SHELF_ID, state)\n }, [reportShelf, state])\n\n const [installingId, setInstallingId] = useState<string | null>(null)\n const handleInstall = useCallback(\n (listing: any) => async () => {\n if (installingId) return\n setInstallingId(listing.$id)\n const dequeue = queueLoading()\n try {\n const response = await authorizedFetch(\n user,\n '/api/marketplace/install-template',\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ listingId: listing.$id, hostId }),\n },\n )\n const payload = await response.json().catch(() => ({}))\n if (!response.ok) {\n // An installs lock is not a broken listing (AGL-1532).\n const locked = parseLockdownRefusal(response.status, payload)\n if (locked) {\n return void enqueueSnackbar(lockdownRefusalText(locked), {\n variant: 'warning',\n persist: true,\n })\n }\n return void enqueueSnackbar(\n payload?.error ?? 'Template install failed',\n {\n variant: response.status === 402 ? 'warning' : 'error',\n allowDuplicate: true,\n },\n )\n }\n // Installing adds to the template library and publishes nothing\n // (AGL-669), so the message must not imply pages appeared.\n const added = Number(payload.templates ?? 0)\n enqueueSnackbar(\n `Saved ${added} template${added === 1 ? '' : 's'} from ` +\n `\"${listing.displayName}\" to your library — open Templates to ` +\n 'create pages from them.',\n { variant: 'success', persist: false },\n )\n onInstalled()\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setInstallingId(null)\n dequeue()\n }\n },\n [installingId, user, hostId, queueLoading, enqueueSnackbar, onInstalled],\n )\n\n if (!offered || !visible) return null\n // One element: the zone stacks its widgets, and the heading, the cards and\n // the pager are one shelf.\n return (\n <Box component=\"section\" aria-label=\"Marketplace templates\">\n <Typography variant=\"subtitle1\" sx={{ mb: 1 }}>\n {'Marketplace templates'}\n </Typography>\n <Grid container spacing={2}>\n {listings.map((listing: any) => (\n <Grid key={listing.$id} size={{ xs: 12, sm: 6, md: 4 }}>\n <Card variant=\"outlined\" sx={{ height: '100%' }}>\n <ListingImage\n src={listing.previewImageUrl}\n alt={`${listing.displayName} preview`}\n sx={{ width: '100%', height: 120, objectFit: 'cover' }}\n />\n <CardContent>\n <Typography variant=\"h6\">{listing.displayName}</Typography>\n {listing.category ? (\n <Chip\n label={listing.category}\n size=\"small\"\n variant=\"outlined\"\n sx={{ my: 1 }}\n />\n ) : null}\n <Typography variant=\"body2\" color=\"text.secondary\">\n {listing.description ?? ''}\n </Typography>\n <Typography\n variant=\"caption\"\n color=\"text.secondary\"\n component=\"div\"\n sx={{ mt: 1 }}\n >\n {`${listing.screenCount ?? '?'} pages · v${listing.latestVersion}` +\n (Number(listing.priceUsd ?? 0) > 0\n ? ` · $${listing.priceUsd}`\n : ' · free')}\n </Typography>\n </CardContent>\n <CardActions>\n <Button\n size=\"small\"\n variant=\"contained\"\n color=\"primary\"\n disabled={installingId === listing.$id}\n onClick={handleInstall(listing)}\n >\n {installingId === listing.$id ? 'Installing…' : 'Use template'}\n </Button>\n </CardActions>\n </Card>\n </Grid>\n ))}\n </Grid>\n <ListPagination\n page={market.page}\n pageSize={market.pageSize}\n rowCount={listings.length}\n hasMore={market.hasMore}\n onPageChange={market.setPage}\n onPageSizeChange={market.setPageSize}\n />\n </Box>\n )\n}\n\nexport default TemplateGalleryShelf\n"],"names":["lockdownRefusalText","parseLockdownRefusal","useLoading","ListPagination","useSnackbar","authorizedFetch","useFirestore","useUser","useListQuery","Box","Button","Card","CardActions","CardContent","Chip","Grid","Typography","collection","useCallback","useEffect","useMemo","useState","SITE_TEMPLATE_SHELF_BASE","SITE_TEMPLATE_SHELF_QUERY","ListingImage","SHELF_ID","TemplateGalleryShelf","props","hostId","kind","search","onInstalled","reportShelf","firestore","data","user","enqueueSnackbar","queueLoading","offered","searchWords","market","declaration","request","clauses","base","deps","idField","listings","rows","filter","listing","deletedAt","visible","length","hasMore","page","state","status","installingId","setInstallingId","handleInstall","$id","dequeue","payload","response","method","headers","body","JSON","stringify","listingId","json","catch","ok","locked","variant","persist","error","allowDuplicate","added","Number","templates","displayName","console","component","aria-label","sx","mb","container","spacing","map","size","xs","sm","md","height","src","previewImageUrl","alt","width","objectFit","category","label","my","color","description","mt","screenCount","latestVersion","priceUsd","disabled","onClick","pageSize","rowCount","onPageChange","setPage","onPageSizeChange","setPageSize"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,mBAAmB,EACnBC,oBAAoB,QAGf,eAAc;AACrB,SAASC,UAAU,QAAQ,uBAAsB;AACjD,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,OAAO,QAAQ,iCAAgC;AACtE,SAASC,YAAY,QAAQ,sDAAqD;AAClF,SACEC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,WAAW,EACXC,WAAW,EACXC,IAAI,EACJC,IAAI,EACJC,UAAU,QACL,gBAAe;AACtB,SAASC,UAAU,QAAQ,qBAAoB;AAC/C,SAASC,WAAW,EAAEC,SAAS,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACjE,SAASC,wBAAwB,EAAEC,yBAAyB,QAAQ,4BAAwB;AAC5F,SAASC,YAAY,QAAQ,+BAA2B;AAExD,0DA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8CAGlB,KAACjG;8CACC,cAAA,KAACF;wCACCiF,MAAK;wCACLhB,SAAQ;wCACR6B,OAAM;wCACNM,UAAUpD,iBAAiBR,QAAQW,GAAG;wCACtCkD,SAASnD,cAAcV;kDAEtBQ,iBAAiBR,QAAQW,GAAG,GAAG,gBAAgB;;;;;uBAxC7CX,QAAQW,GAAG;;;0BA+C1B,KAAC1D;gBACCoD,MAAMf,OAAOe,IAAI;gBACjByD,UAAUxE,OAAOwE,QAAQ;gBACzBC,UAAUlE,SAASM,MAAM;gBACzBC,SAASd,OAAOc,OAAO;gBACvB4D,cAAc1E,OAAO2E,OAAO;gBAC5BC,kBAAkB5E,OAAO6E,WAAW;;;;AAI5C;AAEA,eAAe3F,qBAAoB"}
|
|
@@ -80,6 +80,17 @@ export declare const BROWSE_SORTS: Readonly<Record<BrowseSort, ListQuerySort>>;
|
|
|
80
80
|
* search folds into it.
|
|
81
81
|
*/
|
|
82
82
|
export declare const MARKETPLACE_BROWSE_QUERY: ListQueryDeclaration;
|
|
83
|
+
/**
|
|
84
|
+
* The template gallery's marketplace shelf (`TemplateGalleryShelf`,
|
|
85
|
+
* AGL-3321): no Filters panel, the walk's order (the document name, which the
|
|
86
|
+
* automatic single-field indexes serve under the one equality and the one
|
|
87
|
+
* array clause), and the listing's name keys, which every publish stamps.
|
|
88
|
+
* Here rather than in the shelf so the native gallery plans the same query
|
|
89
|
+
* (AGL-3668).
|
|
90
|
+
*/
|
|
91
|
+
export declare const SITE_TEMPLATE_SHELF_QUERY: ListQueryDeclaration;
|
|
92
|
+
/** The shelf's scope: published site templates. */
|
|
93
|
+
export declare const SITE_TEMPLATE_SHELF_BASE: ListQueryFilter[];
|
|
83
94
|
/** The base clause's path, for the index enumeration. */
|
|
84
95
|
export declare const MARKETPLACE_BROWSE_BASE_PATHS: readonly [{
|
|
85
96
|
readonly path: "browseAudience";
|
|
@@ -150,6 +150,32 @@ export const BROWSE_SORTS = {
|
|
|
150
150
|
scoped: scopedSearch(LISTING_BROWSE_TOKENS)
|
|
151
151
|
}
|
|
152
152
|
};
|
|
153
|
+
/**
|
|
154
|
+
* The template gallery's marketplace shelf (`TemplateGalleryShelf`,
|
|
155
|
+
* AGL-3321): no Filters panel, the walk's order (the document name, which the
|
|
156
|
+
* automatic single-field indexes serve under the one equality and the one
|
|
157
|
+
* array clause), and the listing's name keys, which every publish stamps.
|
|
158
|
+
* Here rather than in the shelf so the native gallery plans the same query
|
|
159
|
+
* (AGL-3668).
|
|
160
|
+
*/ export const SITE_TEMPLATE_SHELF_QUERY = {
|
|
161
|
+
fields: [],
|
|
162
|
+
sorts: [
|
|
163
|
+
{
|
|
164
|
+
path: LIST_QUERY_ID_PATH,
|
|
165
|
+
direction: 'asc'
|
|
166
|
+
}
|
|
167
|
+
],
|
|
168
|
+
search: {
|
|
169
|
+
tokensPath: LISTING_NAME_TOKENS
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
/** The shelf's scope: published site templates. */ export const SITE_TEMPLATE_SHELF_BASE = [
|
|
173
|
+
{
|
|
174
|
+
path: 'kind',
|
|
175
|
+
op: '==',
|
|
176
|
+
value: 'template'
|
|
177
|
+
}
|
|
178
|
+
];
|
|
153
179
|
/** The base clause's path, for the index enumeration. */ export const MARKETPLACE_BROWSE_BASE_PATHS = [
|
|
154
180
|
{
|
|
155
181
|
path: LISTING_BROWSE_AUDIENCE,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/listing-query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n displayNameSearchFields,\n scopedSearch,\n scopedSearchTokens,\n} from '@aglyn/aglyn/app-utils/name-search'\nimport {\n isListingBrowsable,\n isListingDeleted,\n isPrivateListing,\n} from './listing-visibility'\nimport type { ListFilterField } from '@aglyn/shared-ui-jsx/const/list-filter'\nimport type { ListFilterClause } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport {\n LIST_QUERY_ID_PATH,\n type ListQueryDeclaration,\n type ListQueryFilter,\n type ListQuerySort,\n} from '@aglyn/shared-ui-jsx/const/list-query-plan'\n\n/*\n * EVERY MARKETPLACE LIST ON ITS QUERY (AGL-3321).\n *\n * Browse, the licenses tab, the staff review queue and the abuse-report queue\n * each matched their filters and search over the rows they had loaded — a\n * window of ninety listings, two hundred reports, a hundred plugins. A match\n * on the next page was answered \"no match\". Each list now declares what its\n * query can hold, and the fields below are what the listing writers stamp so\n * the query has something to ask.\n *\n * ## What a listing carries for its lists\n *\n * - `nameLower`/`nameTokens`/`nameReversed` — the display name's search\n * keys (`displayNameSearchFields`), for the staff queue's search and for\n * the licenses tab's listing-name lookup.\n * - `browseAudience` — who browse shows the listing to, as scope tokens:\n * `*` for everyone, the publisher's org id for the owner's own view of a\n * listing still in review or taken down, and each again joined to the\n * publisher (`*|<org>`) so a publisher page asks the same question\n * narrowed to one publisher without a second equality. Empty for a\n * deleted or private listing, which browse never shows anyone.\n * - `browseTokens` — the name tokens under each audience scope\n * (`scopedSearchTokens`), so browse's search folds into its audience\n * clause: one `array-contains-any` answers both.\n * - `takenDown` — `hiddenAt` as a boolean, for the staff queue's Taken down\n * status by equality rather than by a range that would lead the order.\n *\n * All five follow from fields other writers own (`displayName`, `deletedAt`,\n * `visibility`, `hiddenAt`, `reviewStatus`, the artifact discriminators,\n * `profileId`), so no writer computes them from its own patch: each calls\n * `refreshListingQueryFields` after it writes, which re-derives them from the\n * document as stored. `tools/scripts/lib/listing-query-fields.mjs`\n * restates the derivation for the seeds and the backfill, held to\n * `listing-query-fields.fixtures.json` beside it by both sides.\n */\n\n/** Everyone, as a browse audience scope. */\nexport const BROWSE_EVERYONE = '*'\n/** Joins an audience scope to the publisher it is narrowed to. */\nexport const BROWSE_PUBLISHER_JOIN = '|'\n\nexport const LISTING_BROWSE_AUDIENCE = 'browseAudience'\nexport const LISTING_BROWSE_TOKENS = 'browseTokens'\nexport const LISTING_NAME_TOKENS = 'nameTokens'\nexport const LISTING_TAKEN_DOWN = 'takenDown'\n\n/** The fields a listing's lists query by, all derived. */\nexport interface ListingQueryFields {\n nameLower: string\n nameTokens: string[]\n nameReversed: string\n browseAudience: string[]\n browseTokens: string[]\n takenDown: boolean\n}\n\n/** What the derivation reads off a listing. */\nexport interface ListingQuerySource {\n displayName?: unknown\n profileId?: unknown\n deletedAt?: unknown\n hiddenAt?: unknown\n /** The publishing workspace is locked (AGL-3365). */\n workspaceLockedAt?: unknown\n visibility?: string\n reviewStatus?: string\n artifactType?: string\n type?: string\n kind?: string\n}\n\n/**\n * Who browse shows a listing to — the same rule the grid applied in memory:\n * never a deleted or private listing; a browsable one to everyone; one that\n * is not browsable (in review, rejected, taken down) to its own publisher\n * only, so a publisher can watch a submission move through review.\n */\nexport function listingBrowseAudience(listing: ListingQuerySource): string[] {\n if (isListingDeleted(listing) || isPrivateListing(listing)) return []\n const publisher = typeof listing.profileId === 'string' ? listing.profileId : ''\n const scope = isListingBrowsable(listing) ? BROWSE_EVERYONE : publisher\n if (!scope) return []\n return publisher\n ? [scope, `${scope}${BROWSE_PUBLISHER_JOIN}${publisher}`]\n : [scope]\n}\n\n/** Every derived field, from the listing as stored. */\nexport function listingQueryFields(listing: ListingQuerySource): ListingQueryFields {\n const name = displayNameSearchFields(listing.displayName)\n const browseAudience = listingBrowseAudience(listing)\n return {\n ...name,\n browseAudience,\n browseTokens: scopedSearchTokens(browseAudience, name.nameTokens),\n takenDown: Boolean(listing.hiddenAt),\n }\n}\n\nconst same = (left: unknown, right: unknown): boolean =>\n JSON.stringify(left ?? null) === JSON.stringify(right ?? null)\n\n/**\n * What a listing that never had one holds in each field browse ORDERS by. An\n * `orderBy` drops a document missing its field, so a listing nobody has\n * installed or rated would vanish from Most installed and Highest rated\n * rather than sort last. `null` sorts after every number in a descending\n * order, which is where \"not yet rated\" belongs; the reviews route writes a\n * number over it on the first rating. Only ever stamped where the field is\n * ABSENT — the install and review routes own the values.\n */\nexport const LISTING_SORT_DEFAULTS: Readonly<Record<string, number | null>> = {\n installCount: 0,\n ratingAverage: null,\n}\n\n/**\n * The derived fields a stored listing is missing or holds stale, plus any\n * sort field it lacks, or null when it is current — what a writer's refresh\n * and the backfill write.\n */\nexport function listingQueryFieldsPatch(\n listing: ListingQuerySource & Record<string, unknown>,\n): Record<string, unknown> | null {\n const computed = listingQueryFields(listing)\n const patch: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(computed)) {\n if (!same(listing[key], value)) patch[key] = value\n }\n for (const [key, value] of Object.entries(LISTING_SORT_DEFAULTS)) {\n if (listing[key] === undefined) patch[key] = value\n }\n return Object.keys(patch).length ? patch : null\n}\n\n/*==========================================\n * Browse (public, web SDK).\n *=========================================*/\n\nexport type BrowseSort = 'newest' | 'installed' | 'rated'\n\nexport const BROWSE_SORTS: Readonly<Record<BrowseSort, ListQuerySort>> = {\n newest: { path: 'createdAt', direction: 'desc' },\n installed: { path: 'installCount', direction: 'desc' },\n rated: { path: 'ratingAverage', direction: 'desc' },\n}\n\n/**\n * The browse shelf: a category chip, the search box and three orders, every\n * one on the query. The audience clause is its base (`browseBase`), and the\n * search folds into it.\n */\nexport const MARKETPLACE_BROWSE_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'category', kind: 'exact', path: 'category', operators: ['equals'] },\n ] satisfies ListFilterField[],\n sorts: [BROWSE_SORTS.newest, BROWSE_SORTS.installed, BROWSE_SORTS.rated],\n search: {\n tokensPath: LISTING_BROWSE_TOKENS,\n scoped: scopedSearch(LISTING_BROWSE_TOKENS),\n },\n}\n\n/** The base clause's path, for the index enumeration. */\nexport const MARKETPLACE_BROWSE_BASE_PATHS = [\n { path: LISTING_BROWSE_AUDIENCE, array: true },\n] as const\n\n/**\n * What a reader may see on browse: everything public, plus their own org's\n * listings still in review — narrowed to one publisher on a publisher page.\n */\nexport function browseBase(\n viewerOrgId: string | null | undefined,\n publisherId?: string | null,\n): ListQueryFilter[] {\n const scopes = [BROWSE_EVERYONE, ...(viewerOrgId ? [viewerOrgId] : [])]\n return [\n {\n path: LISTING_BROWSE_AUDIENCE,\n op: 'array-contains-any',\n value: publisherId\n ? scopes.map((scope) => `${scope}${BROWSE_PUBLISHER_JOIN}${publisherId}`)\n : scopes,\n },\n ]\n}\n\n/*==========================================\n * Licenses (`marketplacePurchases`, web SDK, buyer/org-gated).\n *=========================================*/\n\n/**\n * Both license tables keep the order they always had — Firestore's, by\n * document id — which index merging serves with no composite at all.\n */\nconst BY_ID: ListQuerySort = { path: LIST_QUERY_ID_PATH, direction: 'asc' }\n\n/** \"This workspace\": who on the team bought it. */\nexport const HELD_LICENCE_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'buyerUid', kind: 'exact', path: 'buyerUid', operators: ['equals'] },\n ] satisfies ListFilterField[],\n sorts: [BY_ID],\n}\n\n/**\n * \"Bought by you\": which workspace a license landed in. A purchase that\n * names none (before AGL-2331) is stored with `buyerOrgId: null` and is\n * asked for as empty.\n */\nexport const MINE_LICENCE_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'buyerOrgId',\n kind: 'exact',\n path: 'buyerOrgId',\n presence: 'nullable',\n operators: ['equals', 'isEmpty'],\n },\n ] satisfies ListFilterField[],\n sorts: [BY_ID],\n}\n\n/** The picked value that means \"every workspace\" — a purchase naming none. */\nexport const EVERY_WORKSPACE = 'every'\n\n/**\n * The Licensed-to select's \"every workspace\" as the query reads it: a\n * purchase whose `buyerOrgId` is null.\n */\nexport function mineLicenceClauses(\n clauses: readonly ListFilterClause[],\n): ListFilterClause[] {\n return clauses.map((clause) =>\n clause.field === 'buyerOrgId' && clause.op === 'equals' && clause.value === EVERY_WORKSPACE\n ? { ...clause, op: 'isEmpty', value: '' }\n : clause,\n )\n}\n\n/**\n * At most this many listings are named by one license search: they go on the\n * purchases query as `listingId in [...]`, which Firestore caps at thirty.\n */\nexport const LICENCE_LISTING_MATCH_CAP = 30\n\n/**\n * The listing-name lookup a license search runs first: the listings whose\n * name has the typed word, by the same token array the staff queue searches.\n */\nexport const LISTING_NAME_LOOKUP: ListQueryDeclaration = {\n fields: [],\n sorts: [BY_ID],\n search: { tokensPath: LISTING_NAME_TOKENS },\n}\n\n/**\n * A license table's scope: its owner clause, live purchases only (a refunded\n * purchase is not a license, AGL-1546), and the listings a search named.\n */\nexport function licenceBase(\n owner: { path: 'buyerOrgId' | 'buyerUid'; value: string },\n listingIds: readonly string[] | null,\n): ListQueryFilter[] {\n return [\n { path: owner.path, op: '==', value: owner.value },\n { path: 'refundedAt', op: '==', value: null },\n ...(listingIds ? [{ path: 'listingId', op: 'in' as const, value: [...listingIds] }] : []),\n ]\n}\n\n/*==========================================\n * The staff review queue (Admin SDK, staff route).\n *=========================================*/\n\n/** The queue's Status select, as clauses the query serves. */\nexport const REVIEW_QUEUE_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'reviewStatus', kind: 'exact', path: 'reviewStatus', operators: ['equals'] },\n { column: LISTING_TAKEN_DOWN, kind: 'boolean', path: LISTING_TAKEN_DOWN },\n ] satisfies ListFilterField[],\n sorts: [BY_ID],\n search: { tokensPath: LISTING_NAME_TOKENS },\n}\n\n/** The sections the queue reads, each its own query. */\nexport type ReviewQueueSection = 'queue' | 'listed' | 'verification' | 'starters'\n\n/**\n * The Starters section's query (AGL-4049): the same Status select and search\n * as the plugin sections, read newest first. The plugin sections read in id\n * order, which equality alone serves; this one pairs each field it can ask\n * with `createdAt` descending, the composites the index file carries for it.\n */\nexport const STARTER_REVIEW_QUEUE_QUERY: ListQueryDeclaration = {\n fields: REVIEW_QUEUE_QUERY.fields,\n sorts: [{ path: 'createdAt', direction: 'desc' }],\n search: REVIEW_QUEUE_QUERY.search,\n}\n\n/** What the Starters section shows while the Status select says All: the starters waiting for review. */\nexport const STARTER_AWAITING_REVIEW_STATUS = 'submitted'\n\n/** The predicates the Starters section can scope by, for its index enumeration. */\nexport const STARTER_REVIEW_QUEUE_BASE_PATHS: readonly { path: string }[] = [\n { path: 'artifactType' },\n { path: 'deletedAt' },\n { path: 'reviewStatus' },\n]\n\n/** A listing's newest bytes have no approval: the `latestVersionReviewState` values that mean it. */\nexport const AWAITING_REVIEW_STATES = ['pending', 'rejected'] as const\nexport const LISTED_REVIEW_STATUSES = ['listed', 'verified'] as const\n\n/**\n * One section's scope: live plugin listings, narrowed to the section. The\n * Listed section's own `reviewStatus in [...]` steps aside for a Status\n * clause that names one of its two values, and a clause naming any other\n * value leaves the section empty by definition — `null`, never queried.\n *\n * The Starters section is live site starter listings (AGL-4049): those\n * waiting for review, or, once the Status select names a status or Taken\n * down, those the select names in their place. It holds every status, so it\n * is never empty by definition.\n */\nexport function reviewQueueBase(\n section: ReviewQueueSection,\n clauses: readonly ListFilterClause[],\n): ListQueryFilter[] | null {\n if (section === 'starters') {\n const starters: ListQueryFilter[] = [\n { path: 'artifactType', op: '==', value: 'siteStarter' },\n { path: 'deletedAt', op: '==', value: null },\n ]\n const narrowed = clauses.some(\n (clause) =>\n (clause.field === 'reviewStatus' && clause.value) || clause.field === LISTING_TAKEN_DOWN,\n )\n if (!narrowed) {\n starters.push({ path: 'reviewStatus', op: '==', value: STARTER_AWAITING_REVIEW_STATUS })\n }\n return starters\n }\n const base: ListQueryFilter[] = [\n { path: 'type', op: '==', value: 'plugin' },\n { path: 'deletedAt', op: '==', value: null },\n ]\n if (section === 'queue') {\n base.push({\n path: 'latestVersionReviewState',\n op: 'in',\n value: [...AWAITING_REVIEW_STATES],\n })\n } else if (section === 'verification') {\n base.push({ path: 'verificationRequest.state', op: '==', value: 'pending' })\n } else {\n const status = clauses.find(\n (clause) => clause.field === 'reviewStatus' && clause.op === 'equals' && clause.value,\n )\n if (status) {\n if (!(LISTED_REVIEW_STATUSES as readonly string[]).includes(status.value)) return null\n } else {\n base.push({ path: 'reviewStatus', op: 'in', value: [...LISTED_REVIEW_STATUSES] })\n }\n }\n return base\n}\n\n/** The queue's Status select as the clause it asks for, or none for \"All\". */\nexport function reviewQueueStatusClauses(status: string): ListFilterClause[] {\n if (!status || status === 'all') return []\n if (status === 'hidden') return [{ field: LISTING_TAKEN_DOWN, op: 'is', value: 'true' }]\n return [{ field: 'reviewStatus', op: 'equals', value: status }]\n}\n\n/*==========================================\n * The abuse-report queue (Admin SDK, staff route).\n *=========================================*/\n\nexport const MARKETPLACE_REPORTS_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'status', kind: 'exact', path: 'status', operators: ['equals'] },\n ] satisfies ListFilterField[],\n sorts: [{ path: 'updatedAt', direction: 'desc' }],\n}\n"],"names":["displayNameSearchFields","scopedSearch","scopedSearchTokens","isListingBrowsable","isListingDeleted","isPrivateListing","LIST_QUERY_ID_PATH","BROWSE_EVERYONE","BROWSE_PUBLISHER_JOIN","LISTING_BROWSE_AUDIENCE","LISTING_BROWSE_TOKENS","LISTING_NAME_TOKENS","LISTING_TAKEN_DOWN","listingBrowseAudience","listing","publisher","profileId","scope","listingQueryFields","name","displayName","browseAudience","browseTokens","nameTokens","takenDown","Boolean","hiddenAt","same","left","right","JSON","stringify","LISTING_SORT_DEFAULTS","installCount","ratingAverage","listingQueryFieldsPatch","computed","patch","key","value","Object","entries","undefined","keys","length","BROWSE_SORTS","newest","path","direction","installed","rated","MARKETPLACE_BROWSE_QUERY","fields","column","kind","operators","sorts","search","tokensPath","scoped","MARKETPLACE_BROWSE_BASE_PATHS","array","browseBase","viewerOrgId","publisherId","scopes","op","map","BY_ID","HELD_LICENCE_QUERY","MINE_LICENCE_QUERY","presence","EVERY_WORKSPACE","mineLicenceClauses","clauses","clause","field","LICENCE_LISTING_MATCH_CAP","LISTING_NAME_LOOKUP","licenceBase","owner","listingIds","REVIEW_QUEUE_QUERY","STARTER_REVIEW_QUEUE_QUERY","STARTER_AWAITING_REVIEW_STATUS","STARTER_REVIEW_QUEUE_BASE_PATHS","AWAITING_REVIEW_STATES","LISTED_REVIEW_STATUSES","reviewQueueBase","section","starters","narrowed","some","push","base","status","find","includes","reviewQueueStatusClauses","MARKETPLACE_REPORTS_QUERY"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,uBAAuB,EACvBC,YAAY,EACZC,kBAAkB,QACb,qCAAoC;AAC3C,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,QACX,0BAAsB;AAG7B,SACEC,kBAAkB,QAIb,6CAA4C;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCC,GAED,0CAA0C,GAC1C,OAAO,MAAMC,kBAAkB,IAAG;AAClC,gEAAgE,GAChE,OAAO,MAAMC,wBAAwB,IAAG;AAExC,OAAO,MAAMC,0BAA0B,iBAAgB;AACvD,OAAO,MAAMC,wBAAwB,eAAc;AACnD,OAAO,MAAMC,sBAAsB,aAAY;AAC/C,OAAO,MAAMC,qBAAqB,YAAW;AA2B7C;;;;;CAKC,GACD,OAAO,SAASC,sBAAsBC,OAA2B;IAC/D,IAAIV,iBAAiBU,YAAYT,iBAAiBS,UAAU,OAAO,EAAE;IACrE,MAAMC,YAAY,OAAOD,QAAQE,SAAS,KAAK,WAAWF,QAAQE,SAAS,GAAG;IAC9E,MAAMC,QAAQd,mBAAmBW,WAAWP,kBAAkBQ;IAC9D,IAAI,CAACE,OAAO,OAAO,EAAE;IACrB,OAAOF,YACH;QAACE;QAAO,GAAGA,QAAQT,wBAAwBO,WAAW;KAAC,GACvD;QAACE;KAAM;AACb;AAEA,qDAAqD,GACrD,OAAO,SAASC,mBAAmBJ,OAA2B;IAC5D,MAAMK,OAAOnB,wBAAwBc,QAAQM,WAAW;IACxD,MAAMC,iBAAiBR,sBAAsBC;IAC7C,OAAO,aACFK;QACHE;QACA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GAC5E,OAAO,SAASI,yBAAyBH,MAAc;IACrD,IAAI,CAACA,UAAUA,WAAW,OAAO,OAAO,EAAE;IAC1C,IAAIA,WAAW,UAAU,OAAO;QAAC;YAAEnB,OAAOhE;YAAoBsD,IAAI;YAAM3B,OAAO;QAAO;KAAE;IACxF,OAAO;QAAC;YAAEqC,OAAO;YAAgBV,IAAI;YAAU3B,OAAOwD;QAAO;KAAE;AACjE;AAEA;;2CAE2C,GAE3C,OAAO,MAAMI,4BAAkD;IAC7D/C,QAAQ;QACN;YAAEC,QAAQ;YAAUC,MAAM;YAASP,MAAM;YAAUQ,WAAW;gBAAC;aAAS;QAAC;KAC1E;IACDC,OAAO;QAAC;YAAET,MAAM;YAAaC,WAAW;QAAO;KAAE;AACnD,EAAC"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/model/listing-query.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n displayNameSearchFields,\n scopedSearch,\n scopedSearchTokens,\n} from '@aglyn/aglyn/app-utils/name-search'\nimport {\n isListingBrowsable,\n isListingDeleted,\n isPrivateListing,\n} from './listing-visibility'\nimport type { ListFilterField } from '@aglyn/shared-ui-jsx/const/list-filter'\nimport type { ListFilterClause } from '@aglyn/shared-ui-jsx/const/list-grid-filter'\nimport {\n LIST_QUERY_ID_PATH,\n type ListQueryDeclaration,\n type ListQueryFilter,\n type ListQuerySort,\n} from '@aglyn/shared-ui-jsx/const/list-query-plan'\n\n/*\n * EVERY MARKETPLACE LIST ON ITS QUERY (AGL-3321).\n *\n * Browse, the licenses tab, the staff review queue and the abuse-report queue\n * each matched their filters and search over the rows they had loaded — a\n * window of ninety listings, two hundred reports, a hundred plugins. A match\n * on the next page was answered \"no match\". Each list now declares what its\n * query can hold, and the fields below are what the listing writers stamp so\n * the query has something to ask.\n *\n * ## What a listing carries for its lists\n *\n * - `nameLower`/`nameTokens`/`nameReversed` — the display name's search\n * keys (`displayNameSearchFields`), for the staff queue's search and for\n * the licenses tab's listing-name lookup.\n * - `browseAudience` — who browse shows the listing to, as scope tokens:\n * `*` for everyone, the publisher's org id for the owner's own view of a\n * listing still in review or taken down, and each again joined to the\n * publisher (`*|<org>`) so a publisher page asks the same question\n * narrowed to one publisher without a second equality. Empty for a\n * deleted or private listing, which browse never shows anyone.\n * - `browseTokens` — the name tokens under each audience scope\n * (`scopedSearchTokens`), so browse's search folds into its audience\n * clause: one `array-contains-any` answers both.\n * - `takenDown` — `hiddenAt` as a boolean, for the staff queue's Taken down\n * status by equality rather than by a range that would lead the order.\n *\n * All five follow from fields other writers own (`displayName`, `deletedAt`,\n * `visibility`, `hiddenAt`, `reviewStatus`, the artifact discriminators,\n * `profileId`), so no writer computes them from its own patch: each calls\n * `refreshListingQueryFields` after it writes, which re-derives them from the\n * document as stored. `tools/scripts/lib/listing-query-fields.mjs`\n * restates the derivation for the seeds and the backfill, held to\n * `listing-query-fields.fixtures.json` beside it by both sides.\n */\n\n/** Everyone, as a browse audience scope. */\nexport const BROWSE_EVERYONE = '*'\n/** Joins an audience scope to the publisher it is narrowed to. */\nexport const BROWSE_PUBLISHER_JOIN = '|'\n\nexport const LISTING_BROWSE_AUDIENCE = 'browseAudience'\nexport const LISTING_BROWSE_TOKENS = 'browseTokens'\nexport const LISTING_NAME_TOKENS = 'nameTokens'\nexport const LISTING_TAKEN_DOWN = 'takenDown'\n\n/** The fields a listing's lists query by, all derived. */\nexport interface ListingQueryFields {\n nameLower: string\n nameTokens: string[]\n nameReversed: string\n browseAudience: string[]\n browseTokens: string[]\n takenDown: boolean\n}\n\n/** What the derivation reads off a listing. */\nexport interface ListingQuerySource {\n displayName?: unknown\n profileId?: unknown\n deletedAt?: unknown\n hiddenAt?: unknown\n /** The publishing workspace is locked (AGL-3365). */\n workspaceLockedAt?: unknown\n visibility?: string\n reviewStatus?: string\n artifactType?: string\n type?: string\n kind?: string\n}\n\n/**\n * Who browse shows a listing to — the same rule the grid applied in memory:\n * never a deleted or private listing; a browsable one to everyone; one that\n * is not browsable (in review, rejected, taken down) to its own publisher\n * only, so a publisher can watch a submission move through review.\n */\nexport function listingBrowseAudience(listing: ListingQuerySource): string[] {\n if (isListingDeleted(listing) || isPrivateListing(listing)) return []\n const publisher = typeof listing.profileId === 'string' ? listing.profileId : ''\n const scope = isListingBrowsable(listing) ? BROWSE_EVERYONE : publisher\n if (!scope) return []\n return publisher\n ? [scope, `${scope}${BROWSE_PUBLISHER_JOIN}${publisher}`]\n : [scope]\n}\n\n/** Every derived field, from the listing as stored. */\nexport function listingQueryFields(listing: ListingQuerySource): ListingQueryFields {\n const name = displayNameSearchFields(listing.displayName)\n const browseAudience = listingBrowseAudience(listing)\n return {\n ...name,\n browseAudience,\n browseTokens: scopedSearchTokens(browseAudience, name.nameTokens),\n takenDown: Boolean(listing.hiddenAt),\n }\n}\n\nconst same = (left: unknown, right: unknown): boolean =>\n JSON.stringify(left ?? null) === JSON.stringify(right ?? null)\n\n/**\n * What a listing that never had one holds in each field browse ORDERS by. An\n * `orderBy` drops a document missing its field, so a listing nobody has\n * installed or rated would vanish from Most installed and Highest rated\n * rather than sort last. `null` sorts after every number in a descending\n * order, which is where \"not yet rated\" belongs; the reviews route writes a\n * number over it on the first rating. Only ever stamped where the field is\n * ABSENT — the install and review routes own the values.\n */\nexport const LISTING_SORT_DEFAULTS: Readonly<Record<string, number | null>> = {\n installCount: 0,\n ratingAverage: null,\n}\n\n/**\n * The derived fields a stored listing is missing or holds stale, plus any\n * sort field it lacks, or null when it is current — what a writer's refresh\n * and the backfill write.\n */\nexport function listingQueryFieldsPatch(\n listing: ListingQuerySource & Record<string, unknown>,\n): Record<string, unknown> | null {\n const computed = listingQueryFields(listing)\n const patch: Record<string, unknown> = {}\n for (const [key, value] of Object.entries(computed)) {\n if (!same(listing[key], value)) patch[key] = value\n }\n for (const [key, value] of Object.entries(LISTING_SORT_DEFAULTS)) {\n if (listing[key] === undefined) patch[key] = value\n }\n return Object.keys(patch).length ? patch : null\n}\n\n/*==========================================\n * Browse (public, web SDK).\n *=========================================*/\n\nexport type BrowseSort = 'newest' | 'installed' | 'rated'\n\nexport const BROWSE_SORTS: Readonly<Record<BrowseSort, ListQuerySort>> = {\n newest: { path: 'createdAt', direction: 'desc' },\n installed: { path: 'installCount', direction: 'desc' },\n rated: { path: 'ratingAverage', direction: 'desc' },\n}\n\n/**\n * The browse shelf: a category chip, the search box and three orders, every\n * one on the query. The audience clause is its base (`browseBase`), and the\n * search folds into it.\n */\nexport const MARKETPLACE_BROWSE_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'category', kind: 'exact', path: 'category', operators: ['equals'] },\n ] satisfies ListFilterField[],\n sorts: [BROWSE_SORTS.newest, BROWSE_SORTS.installed, BROWSE_SORTS.rated],\n search: {\n tokensPath: LISTING_BROWSE_TOKENS,\n scoped: scopedSearch(LISTING_BROWSE_TOKENS),\n },\n}\n\n/**\n * The template gallery's marketplace shelf (`TemplateGalleryShelf`,\n * AGL-3321): no Filters panel, the walk's order (the document name, which the\n * automatic single-field indexes serve under the one equality and the one\n * array clause), and the listing's name keys, which every publish stamps.\n * Here rather than in the shelf so the native gallery plans the same query\n * (AGL-3668).\n */\nexport const SITE_TEMPLATE_SHELF_QUERY: ListQueryDeclaration = {\n fields: [],\n sorts: [{ path: LIST_QUERY_ID_PATH, direction: 'asc' }],\n search: { tokensPath: LISTING_NAME_TOKENS },\n}\n\n/** The shelf's scope: published site templates. */\nexport const SITE_TEMPLATE_SHELF_BASE: ListQueryFilter[] = [\n { path: 'kind', op: '==', value: 'template' },\n]\n\n/** The base clause's path, for the index enumeration. */\nexport const MARKETPLACE_BROWSE_BASE_PATHS = [\n { path: LISTING_BROWSE_AUDIENCE, array: true },\n] as const\n\n/**\n * What a reader may see on browse: everything public, plus their own org's\n * listings still in review — narrowed to one publisher on a publisher page.\n */\nexport function browseBase(\n viewerOrgId: string | null | undefined,\n publisherId?: string | null,\n): ListQueryFilter[] {\n const scopes = [BROWSE_EVERYONE, ...(viewerOrgId ? [viewerOrgId] : [])]\n return [\n {\n path: LISTING_BROWSE_AUDIENCE,\n op: 'array-contains-any',\n value: publisherId\n ? scopes.map((scope) => `${scope}${BROWSE_PUBLISHER_JOIN}${publisherId}`)\n : scopes,\n },\n ]\n}\n\n/*==========================================\n * Licenses (`marketplacePurchases`, web SDK, buyer/org-gated).\n *=========================================*/\n\n/**\n * Both license tables keep the order they always had — Firestore's, by\n * document id — which index merging serves with no composite at all.\n */\nconst BY_ID: ListQuerySort = { path: LIST_QUERY_ID_PATH, direction: 'asc' }\n\n/** \"This workspace\": who on the team bought it. */\nexport const HELD_LICENCE_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'buyerUid', kind: 'exact', path: 'buyerUid', operators: ['equals'] },\n ] satisfies ListFilterField[],\n sorts: [BY_ID],\n}\n\n/**\n * \"Bought by you\": which workspace a license landed in. A purchase that\n * names none (before AGL-2331) is stored with `buyerOrgId: null` and is\n * asked for as empty.\n */\nexport const MINE_LICENCE_QUERY: ListQueryDeclaration = {\n fields: [\n {\n column: 'buyerOrgId',\n kind: 'exact',\n path: 'buyerOrgId',\n presence: 'nullable',\n operators: ['equals', 'isEmpty'],\n },\n ] satisfies ListFilterField[],\n sorts: [BY_ID],\n}\n\n/** The picked value that means \"every workspace\" — a purchase naming none. */\nexport const EVERY_WORKSPACE = 'every'\n\n/**\n * The Licensed-to select's \"every workspace\" as the query reads it: a\n * purchase whose `buyerOrgId` is null.\n */\nexport function mineLicenceClauses(\n clauses: readonly ListFilterClause[],\n): ListFilterClause[] {\n return clauses.map((clause) =>\n clause.field === 'buyerOrgId' && clause.op === 'equals' && clause.value === EVERY_WORKSPACE\n ? { ...clause, op: 'isEmpty', value: '' }\n : clause,\n )\n}\n\n/**\n * At most this many listings are named by one license search: they go on the\n * purchases query as `listingId in [...]`, which Firestore caps at thirty.\n */\nexport const LICENCE_LISTING_MATCH_CAP = 30\n\n/**\n * The listing-name lookup a license search runs first: the listings whose\n * name has the typed word, by the same token array the staff queue searches.\n */\nexport const LISTING_NAME_LOOKUP: ListQueryDeclaration = {\n fields: [],\n sorts: [BY_ID],\n search: { tokensPath: LISTING_NAME_TOKENS },\n}\n\n/**\n * A license table's scope: its owner clause, live purchases only (a refunded\n * purchase is not a license, AGL-1546), and the listings a search named.\n */\nexport function licenceBase(\n owner: { path: 'buyerOrgId' | 'buyerUid'; value: string },\n listingIds: readonly string[] | null,\n): ListQueryFilter[] {\n return [\n { path: owner.path, op: '==', value: owner.value },\n { path: 'refundedAt', op: '==', value: null },\n ...(listingIds ? [{ path: 'listingId', op: 'in' as const, value: [...listingIds] }] : []),\n ]\n}\n\n/*==========================================\n * The staff review queue (Admin SDK, staff route).\n *=========================================*/\n\n/** The queue's Status select, as clauses the query serves. */\nexport const REVIEW_QUEUE_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'reviewStatus', kind: 'exact', path: 'reviewStatus', operators: ['equals'] },\n { column: LISTING_TAKEN_DOWN, kind: 'boolean', path: LISTING_TAKEN_DOWN },\n ] satisfies ListFilterField[],\n sorts: [BY_ID],\n search: { tokensPath: LISTING_NAME_TOKENS },\n}\n\n/** The sections the queue reads, each its own query. */\nexport type ReviewQueueSection = 'queue' | 'listed' | 'verification' | 'starters'\n\n/**\n * The Starters section's query (AGL-4049): the same Status select and search\n * as the plugin sections, read newest first. The plugin sections read in id\n * order, which equality alone serves; this one pairs each field it can ask\n * with `createdAt` descending, the composites the index file carries for it.\n */\nexport const STARTER_REVIEW_QUEUE_QUERY: ListQueryDeclaration = {\n fields: REVIEW_QUEUE_QUERY.fields,\n sorts: [{ path: 'createdAt', direction: 'desc' }],\n search: REVIEW_QUEUE_QUERY.search,\n}\n\n/** What the Starters section shows while the Status select says All: the starters waiting for review. */\nexport const STARTER_AWAITING_REVIEW_STATUS = 'submitted'\n\n/** The predicates the Starters section can scope by, for its index enumeration. */\nexport const STARTER_REVIEW_QUEUE_BASE_PATHS: readonly { path: string }[] = [\n { path: 'artifactType' },\n { path: 'deletedAt' },\n { path: 'reviewStatus' },\n]\n\n/** A listing's newest bytes have no approval: the `latestVersionReviewState` values that mean it. */\nexport const AWAITING_REVIEW_STATES = ['pending', 'rejected'] as const\nexport const LISTED_REVIEW_STATUSES = ['listed', 'verified'] as const\n\n/**\n * One section's scope: live plugin listings, narrowed to the section. The\n * Listed section's own `reviewStatus in [...]` steps aside for a Status\n * clause that names one of its two values, and a clause naming any other\n * value leaves the section empty by definition — `null`, never queried.\n *\n * The Starters section is live site starter listings (AGL-4049): those\n * waiting for review, or, once the Status select names a status or Taken\n * down, those the select names in their place. It holds every status, so it\n * is never empty by definition.\n */\nexport function reviewQueueBase(\n section: ReviewQueueSection,\n clauses: readonly ListFilterClause[],\n): ListQueryFilter[] | null {\n if (section === 'starters') {\n const starters: ListQueryFilter[] = [\n { path: 'artifactType', op: '==', value: 'siteStarter' },\n { path: 'deletedAt', op: '==', value: null },\n ]\n const narrowed = clauses.some(\n (clause) =>\n (clause.field === 'reviewStatus' && clause.value) || clause.field === LISTING_TAKEN_DOWN,\n )\n if (!narrowed) {\n starters.push({ path: 'reviewStatus', op: '==', value: STARTER_AWAITING_REVIEW_STATUS })\n }\n return starters\n }\n const base: ListQueryFilter[] = [\n { path: 'type', op: '==', value: 'plugin' },\n { path: 'deletedAt', op: '==', value: null },\n ]\n if (section === 'queue') {\n base.push({\n path: 'latestVersionReviewState',\n op: 'in',\n value: [...AWAITING_REVIEW_STATES],\n })\n } else if (section === 'verification') {\n base.push({ path: 'verificationRequest.state', op: '==', value: 'pending' })\n } else {\n const status = clauses.find(\n (clause) => clause.field === 'reviewStatus' && clause.op === 'equals' && clause.value,\n )\n if (status) {\n if (!(LISTED_REVIEW_STATUSES as readonly string[]).includes(status.value)) return null\n } else {\n base.push({ path: 'reviewStatus', op: 'in', value: [...LISTED_REVIEW_STATUSES] })\n }\n }\n return base\n}\n\n/** The queue's Status select as the clause it asks for, or none for \"All\". */\nexport function reviewQueueStatusClauses(status: string): ListFilterClause[] {\n if (!status || status === 'all') return []\n if (status === 'hidden') return [{ field: LISTING_TAKEN_DOWN, op: 'is', value: 'true' }]\n return [{ field: 'reviewStatus', op: 'equals', value: status }]\n}\n\n/*==========================================\n * The abuse-report queue (Admin SDK, staff route).\n *=========================================*/\n\nexport const MARKETPLACE_REPORTS_QUERY: ListQueryDeclaration = {\n fields: [\n { column: 'status', kind: 'exact', path: 'status', operators: ['equals'] },\n ] satisfies ListFilterField[],\n sorts: [{ path: 'updatedAt', direction: 'desc' }],\n}\n"],"names":["displayNameSearchFields","scopedSearch","scopedSearchTokens","isListingBrowsable","isListingDeleted","isPrivateListing","LIST_QUERY_ID_PATH","BROWSE_EVERYONE","BROWSE_PUBLISHER_JOIN","LISTING_BROWSE_AUDIENCE","LISTING_BROWSE_TOKENS","LISTING_NAME_TOKENS","LISTING_TAKEN_DOWN","listingBrowseAudience","listing","publisher","profileId","scope","listingQueryFields","name","displayName","browseAudience","browseTokens","nameTokens","takenDown","Boolean","hiddenAt","same","left","right","JSON","stringify","LISTING_SORT_DEFAULTS","installCount","ratingAverage","listingQueryFieldsPatch","computed","patch","key","value","Object","entries","undefined","keys","length","BROWSE_SORTS","newest","path","direction","installed","rated","MARKETPLACE_BROWSE_QUERY","fields","column","kind","operators","sorts","search","tokensPath","scoped","SITE_TEMPLATE_SHELF_QUERY","SITE_TEMPLATE_SHELF_BASE","op","MARKETPLACE_BROWSE_BASE_PATHS","array","browseBase","viewerOrgId","publisherId","scopes","map","BY_ID","HELD_LICENCE_QUERY","MINE_LICENCE_QUERY","presence","EVERY_WORKSPACE","mineLicenceClauses","clauses","clause","field","LICENCE_LISTING_MATCH_CAP","LISTING_NAME_LOOKUP","licenceBase","owner","listingIds","REVIEW_QUEUE_QUERY","STARTER_REVIEW_QUEUE_QUERY","STARTER_AWAITING_REVIEW_STATUS","STARTER_REVIEW_QUEUE_BASE_PATHS","AWAITING_REVIEW_STATES","LISTED_REVIEW_STATUSES","reviewQueueBase","section","starters","narrowed","some","push","base","status","find","includes","reviewQueueStatusClauses","MARKETPLACE_REPORTS_QUERY"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,uBAAuB,EACvBC,YAAY,EACZC,kBAAkB,QACb,qCAAoC;AAC3C,SACEC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,QACX,0BAAsB;AAG7B,SACEC,kBAAkB,QAIb,6CAA4C;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCC,GAED,0CAA0C,GAC1C,OAAO,MAAMC,kBAAkB,IAAG;AAClC,gEAAgE,GAChE,OAAO,MAAMC,wBAAwB,IAAG;AAExC,OAAO,MAAMC,0BAA0B,iBAAgB;AACvD,OAAO,MAAMC,wBAAwB,eAAc;AACnD,OAAO,MAAMC,sBAAsB,aAAY;AAC/C,OAAO,MAAMC,qBAAqB,YAAW;AA2B7C;;;;;CAKC,GACD,OAAO,SAASC,sBAAsBC,OAA2B;IAC/D,IAAIV,iBAAiBU,YAAYT,iBAAiBS,UAAU,OAAO,EAAE;IACrE,MAAMC,YAAY,OAAOD,QAAQE,SAAS,KAAK,WAAWF,QAAQE,SAAS,GAAG;IAC9E,MAAMC,QAAQd,mBAAmBW,WAAWP,kBAAkBQ;IAC9D,IAAI,CAACE,OAAO,OAAO,EAAE;IACrB,OAAOF,YACH;QAACE;QAAO,GAAGA,QAAQT,wBAAwBO,WAAW;KAAC,GACvD;QAACE;KAAM;AACb;AAEA,qDAAqD,GACrD,OAAO,SAASC,mBAAmBJ,OAA2B;IAC5D,MAAMK,OAAOnB,wBAAwBc,Q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