@aglyn/plugins-marketplace 1.20.1 → 1.20.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/package.json +15 -15
  2. package/src/lib/components/listing-content.component.d.ts +8 -1
  3. package/src/lib/components/listing-content.component.js +52 -12
  4. package/src/lib/components/listing-content.component.js.map +1 -1
  5. package/src/lib/components/listing-detail-page.component.d.ts +6 -0
  6. package/src/lib/components/listing-detail-page.component.js +24 -4
  7. package/src/lib/components/listing-detail-page.component.js.map +1 -1
  8. package/src/lib/components/marketplace-hub.component.js +2 -0
  9. package/src/lib/components/marketplace-hub.component.js.map +1 -1
  10. package/src/lib/components/org-plugin-installs-card.component.js +67 -9
  11. package/src/lib/components/org-plugin-installs-card.component.js.map +1 -1
  12. package/src/lib/components/org-seller-panel.component.js +14 -4
  13. package/src/lib/components/org-seller-panel.component.js.map +1 -1
  14. package/src/lib/components/plugin-reviews-surface.component.js +17 -6
  15. package/src/lib/components/plugin-reviews-surface.component.js.map +1 -1
  16. package/src/lib/components/plugin-site-set-panel.component.d.ts +11 -0
  17. package/src/lib/components/plugin-site-set-panel.component.js +52 -9
  18. package/src/lib/components/plugin-site-set-panel.component.js.map +1 -1
  19. package/src/lib/hooks/use-starter-publish-facts.js +5 -1
  20. package/src/lib/hooks/use-starter-publish-facts.js.map +1 -1
  21. package/src/lib/model/editor-connections.js +2 -1
  22. package/src/lib/model/editor-connections.js.map +1 -1
  23. package/src/lib/model/marketplace-catalog.d.ts +40 -1
  24. package/src/lib/model/marketplace-catalog.js +46 -2
  25. package/src/lib/model/marketplace-catalog.js.map +1 -1
  26. package/src/lib/model/marketplace.d.ts +1 -1
  27. package/src/lib/model/marketplace.js +1 -1
  28. package/src/lib/model/marketplace.js.map +1 -1
  29. package/src/lib/model/starter-publish.d.ts +12 -5
  30. package/src/lib/model/starter-publish.js +18 -6
  31. package/src/lib/model/starter-publish.js.map +1 -1
  32. package/src/lib/server/connect.js +45 -13
  33. package/src/lib/server/connect.js.map +1 -1
  34. package/src/lib/server/starter-publish-facts.js +4 -0
  35. package/src/lib/server/starter-publish-facts.js.map +1 -1
@@ -17,6 +17,12 @@ export declare function ListingDetailPage(props: {
17
17
  /** The site an install acts through, and every site for the target picker. */
18
18
  actingHost: string;
19
19
  hosts: ReadonlyArray<OrgInstallHost>;
20
+ /**
21
+ * Whether `hosts` is the workspace's whole site list yet (AGL-4047). While
22
+ * it loads there is no acting site, and that is not a workspace with none.
23
+ * Absent reads as true.
24
+ */
25
+ hostsReady?: boolean;
20
26
  permissions?: Record<string, boolean | undefined>;
21
27
  orgSlug: string;
22
28
  }): import("react").JSX.Element;
@@ -19,7 +19,7 @@ import { PageHeaderActions, PageHeaderHelp, PageHeaderRecord } from "@aglyn/agly
19
19
  import { AppLink } from "@aglyn/shared-ui-jsx";
20
20
  import { BlockedControl } from "@aglyn/shared-ui-jsx/components/blocked-control.component";
21
21
  import { useFirestore, useFirestoreDoc, useUser } from "@aglyn/tenant-feature-instance";
22
- import { Alert, Button, Stack } from "@mui/material";
22
+ import { Alert, Button, CircularProgress, Stack, Typography } from "@mui/material";
23
23
  import { doc } from "firebase/firestore";
24
24
  import { lazy, Suspense, useMemo, useState } from "react";
25
25
  import ListingDetailEditor from "./listing-detail-editor.component.js";
@@ -40,8 +40,9 @@ import { MARKETPLACE_MANAGE_LISTINGS_PERMISSION, marketplacePublisherPermissionR
40
40
  * Install pins validate against a site, so the detail acts through the org's
41
41
  * first site until targeting lands (AGL-773).
42
42
  */ export function ListingDetailPage(props) {
43
- var _ref, _ref1;
43
+ var _props_hostsReady, _ref, _ref1;
44
44
  const { listingId, orgId, basePath, actingHost, hosts, permissions, orgSlug } = props;
45
+ const hostsReady = (_props_hostsReady = props.hostsReady) != null ? _props_hostsReady : true;
45
46
  const firestore = useFirestore();
46
47
  const { data: user } = useUser();
47
48
  // The listing itself, so the owner can edit the whole page in place
@@ -155,7 +156,23 @@ import { MARKETPLACE_MANAGE_LISTINGS_PERMISSION, marketplacePublisherPermissionR
155
156
  }) : null
156
157
  ]
157
158
  }) : null,
158
- !actingHost ? // Owners can still edit their listing with no site of their own —
159
+ !actingHost && !hostsReady ? /*#__PURE__*/ _jsxs(Stack, {
160
+ direction: "row",
161
+ spacing: 1,
162
+ sx: {
163
+ alignItems: 'center'
164
+ },
165
+ children: [
166
+ /*#__PURE__*/ _jsx(CircularProgress, {
167
+ size: 16
168
+ }),
169
+ /*#__PURE__*/ _jsx(Typography, {
170
+ variant: "body2",
171
+ color: "text.secondary",
172
+ children: 'Loading your sites…'
173
+ })
174
+ ]
175
+ }) : !actingHost ? // Owners can still edit their listing with no site of their own —
159
176
  // through the hero's Edit listing action (AGL-1005).
160
177
  /*#__PURE__*/ _jsx(Alert, {
161
178
  severity: "info",
@@ -166,7 +183,10 @@ import { MARKETPLACE_MANAGE_LISTINGS_PERMISSION, marketplacePublisherPermissionR
166
183
  permissions: permissions,
167
184
  orgScoped: true,
168
185
  orgSlug: orgSlug,
169
- hosts: hosts
186
+ hosts: hosts,
187
+ // The workspace the hub already holds (AGL-4047), so the org
188
+ // pin is read under it rather than a lookup through a site.
189
+ orgId: orgId
170
190
  })
171
191
  ]
172
192
  })
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/listing-detail-page.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 PageHeaderActions,\n PageHeaderHelp,\n PageHeaderRecord,\n} from '@aglyn/aglyn'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useFirestore, useFirestoreDoc, useUser } from '@aglyn/tenant-feature-instance'\nimport { Alert, Button, Stack } from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { lazy, Suspense, useMemo, useState } from 'react'\nimport ListingDetailEditor from './listing-detail-editor.component'\nimport ListingReviewStatus from './listing-review-status.component'\nimport ListingVerificationRequest from './listing-verification-request.component'\nimport { MarketplaceListingContent } from './listing-content.component'\nimport type { OrgInstallHost } from '../model/marketplace'\nimport { publishPluginPath } from '../model/marketplace-paths'\nimport {\n MARKETPLACE_MANAGE_LISTINGS_PERMISSION,\n marketplacePublisherPermissionRefusal,\n} from '../model/marketplace-publisher-permissions'\n\n/** The publisher's connection credentials: drawn only for an owner's plugin listing, so it loads then. */\nconst ListingConnectionCredentialsCard = lazy(() => import('./listing-connection-credentials-card.component'))\n\n/**\n * Org marketplace listing detail (AGL-772), at `{marketplace}/{listingId}`.\n *\n * It was a console route until AGL-3080, which is why it used to reach the\n * body through the `marketplaceListing` zone: an app page could not import\n * this plugin. This page IS the plugin now, so it renders the content\n * directly — the zone stays registered for the surfaces that still need it.\n *\n * Install pins validate against a site, so the detail acts through the org's\n * first site until targeting lands (AGL-773).\n */\nexport function ListingDetailPage(props: {\n listingId: string\n orgId: string | null\n basePath: string\n /** The site an install acts through, and every site for the target picker. */\n actingHost: string\n hosts: ReadonlyArray<OrgInstallHost>\n permissions?: Record<string, boolean | undefined>\n orgSlug: string\n}) {\n const { listingId, orgId, basePath, actingHost, hosts, permissions, orgSlug } =\n props\n const firestore = useFirestore()\n const { data: user } = useUser()\n\n // The listing itself, so the owner can edit the whole page in place\n // (AGL-869) rather than through a cramped sidebar card.\n const { data: listing } = useFirestoreDoc<any>(\n () => doc(firestore, 'marketplaceListings', listingId || '-missing-'),\n [firestore, listingId],\n { idField: '$id' },\n )\n // Listings are org-owned (AGL-652): ownership is an org comparison.\n const isOwner = Boolean(orgId && listing?.profileId === orgId)\n // Editing it asks \"Manage published listings\" (AGL-4047), as its save\n // route and the listing rules do. Off with the permission named, not\n // hidden; an absent key reads as allowed, and the route still decides.\n const canManageListings =\n permissions?.[MARKETPLACE_MANAGE_LISTINGS_PERMISSION] !== false\n const [editing, setEditing] = useState(false)\n\n // Name the thing you are looking at (AGL-1000). The page used to announce\n // itself as \"Marketplace listing\" over a breadcrumb ending in \"Listing\",\n // which made the largest text on the page the one part identical on every\n // listing. This page already reads the doc for the in-place editor, so the\n // name costs nothing; the surface's declared title stays as the fallback\n // for the beat before it resolves and for a listing that does not exist.\n const listingName = String(listing?.displayName ?? '').trim()\n const isPlugin = (listing?.artifactType ?? listing?.type) === 'plugin'\n\n /*\n * The hero's owner actions, memoized (AGL-1005). `PageHeaderActions`\n * publishes upward through an effect keyed on what it is handed, so a node\n * rebuilt every render would republish every render. The dependencies are\n * exactly the four facts the buttons read.\n */\n const ownerActions = useMemo(\n () =>\n isOwner && !editing ? (\n <Stack\n direction=\"row\"\n spacing={1}\n useFlexGap\n sx={{ flexWrap: 'wrap' }}\n >\n {/* Shipping a new version had no door on the listing itself\n (AGL-1008) — Edit changes metadata and View changes nothing,\n so the only reading left was \"make a second listing\". Same\n publish form, pre-bound to this listing. Plugins only: a\n bundle is the thing a new version ships. */}\n {isPlugin ? (\n <AppLink href={publishPluginPath(basePath, listingId)}>\n <Button variant=\"contained\" color=\"primary\" component=\"span\">\n {'Publish new version'}\n </Button>\n </AppLink>\n ) : null}\n <BlockedControl\n blocked={!canManageListings}\n reason={marketplacePublisherPermissionRefusal(\n MARKETPLACE_MANAGE_LISTINGS_PERMISSION,\n )}\n >\n <Button\n variant=\"outlined\"\n color=\"primary\"\n onClick={() => setEditing(true)}\n >\n {'Edit listing'}\n </Button>\n </BlockedControl>\n </Stack>\n ) : null,\n [isOwner, editing, isPlugin, basePath, listingId, canManageListings],\n )\n\n return (\n <>\n <PageHeaderRecord title={listingName} />\n <PageHeaderHelp\n topic=\"plugins\"\n anchor=\"#what-the-badges-on-a-listing-mean\"\n />\n {/* Owner action in the hero (AGL-1005), where the chrome already has a\n slot for it. It used to float in a bare right-aligned box above the\n content — unanchored to anything, and it moved depending on whether\n the org had a site yet. */}\n <PageHeaderActions>{ownerActions}</PageHeaderActions>\n {editing && isOwner && canManageListings && orgId && listing ? (\n <ListingDetailEditor\n orgId={orgId}\n listingId={listingId}\n listing={listing}\n user={user}\n onDone={() => setEditing(false)}\n />\n ) : (\n // One stack, one gap: the owner cards and the listing body share the\n // same edges and the same spacing between them.\n <Stack spacing={3}>\n {/* The publisher's own view of the queue (AGL-1079). Owner-only:\n review state, rejection reasons and what was attested are the\n publisher's business, and a buyer is never offered a version\n this card exists to explain. Above the buyer-facing body,\n because \"what is happening to my submission\" is why an owner\n opened their own listing. */}\n {isOwner ? (\n <>\n <ListingReviewStatus\n listingId={listingId}\n isPlugin={isPlugin}\n permissions={permissions}\n />\n {/* The door to the Verified badge (AGL-1217). Below the review\n card on purpose: \"where is my submission\" is the more urgent\n question, and asking for a badge only makes sense once the\n listing is live. */}\n <ListingVerificationRequest\n listingId={listingId}\n listing={listing}\n viewerOrgId={orgId ?? undefined}\n user={user}\n isPlugin={isPlugin}\n permissions={permissions}\n />\n {/* The publisher's OAuth app for each connection the latest\n version declares (AGL-4196). Draws nothing for a listing\n that declares none. */}\n {isPlugin ? (\n <Suspense fallback={null}>\n <ListingConnectionCredentialsCard\n listingId={listingId}\n permissions={permissions}\n />\n </Suspense>\n ) : null}\n </>\n ) : null}\n {!actingHost ? (\n // Owners can still edit their listing with no site of their own —\n // through the hero's Edit listing action (AGL-1005).\n <Alert severity=\"info\">\n {isOwner\n ? 'Add a site to your organization to install marketplace ' +\n 'items. You can still edit this listing above.'\n : 'Add a site to your organization to view and install ' +\n 'marketplace items.'}\n </Alert>\n ) : (\n <MarketplaceListingContent\n hostId={actingHost}\n listingId={listingId}\n permissions={permissions}\n orgScoped\n orgSlug={orgSlug}\n hosts={hosts}\n />\n )}\n </Stack>\n )}\n </>\n )\n}\n\nListingDetailPage.displayName = 'ListingDetailPage'\n\nexport default ListingDetailPage\n"],"names":["PageHeaderActions","PageHeaderHelp","PageHeaderRecord","AppLink","BlockedControl","useFirestore","useFirestoreDoc","useUser","Alert","Button","Stack","doc","lazy","Suspense","useMemo","useState","ListingDetailEditor","ListingReviewStatus","ListingVerificationRequest","MarketplaceListingContent","publishPluginPath","MARKETPLACE_MANAGE_LISTINGS_PERMISSION","marketplacePublisherPermissionRefusal","ListingConnectionCredentialsCard","ListingDetailPage","props","listingId","orgId","basePath","actingHost","hosts","permissions","orgSlug","firestore","data","user","listing","idField","isOwner","Boolean","profileId","canManageListings","editing","setEditing","listingName","String","displayName","trim","isPlugin","artifactType","type","ownerActions","direction","spacing","useFlexGap","sx","flexWrap","href","variant","color","component","blocked","reason","onClick","title","topic","anchor","onDone","viewerOrgId","undefined","fallback","severity","hostId","orgScoped"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,QACX,eAAc;AACrB,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,YAAY,EAAEC,eAAe,EAAEC,OAAO,QAAQ,iCAAgC;AACvF,SAASC,KAAK,EAAEC,MAAM,EAAEC,KAAK,QAAQ,gBAAe;AACpD,SAASC,GAAG,QAAQ,qBAAoB;AACxC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACzD,OAAOC,yBAAyB,uCAAmC;AACnE,OAAOC,yBAAyB,uCAAmC;AACnE,OAAOC,gCAAgC,8CAA0C;AACjF,SAASC,yBAAyB,QAAQ,iCAA6B;AAEvE,SAASC,iBAAiB,QAAQ,gCAA4B;AAC9D,SACEC,sCAAsC,EACtCC,qCAAqC,QAChC,gDAA4C;AAEnD,wGAAwG,GACxG,MAAMC,iDAAmCX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ACCyD,SAAS,CAACpB;oBACVqB,QAAQxC,sCACND;8BAGF,cAAA,KAACZ;wBACCiD,SAAQ;wBACRC,OAAM;wBACNI,SAAS,IAAMpB,WAAW;kCAEzB;;;;aAIL,MACN;QAACL;QAASI;QAASM;QAAUpB;QAAUF;QAAWe;KAAkB;IAGtE,qBACE;;0BACE,KAACvC;gBAAiB8D,OAAOpB;;0BACzB,KAAC3C;gBACCgE,OAAM;gBACNC,QAAO;;0BAMT,KAAClE;0BAAmBmD;;YACnBT,WAAWJ,WAAWG,qBAAqBd,SAASS,wBACnD,KAACpB;gBACCW,OAAOA;gBACPD,WAAWA;gBACXU,SAASA;gBACTD,MAAMA;gBACNgC,QAAQ,IAAMxB,WAAW;iBAG3B,qEAAqE;YACrE,gDAAgD;0BAChD,MAACjC;gBAAM2C,SAAS;;oBAObf,wBACC;;0CACE,KAACrB;gCACCS,WAAWA;gCACXsB,UAAUA;gCACVjB,aAAaA;;0CAMf,KAACb;gCACCQ,WAAWA;gCACXU,SAASA;gCACTgC,WAAW,EAAEzC,gBAAAA,QAAS0C;gCACtBlC,MAAMA;gCACNa,UAAUA;gCACVjB,aAAaA;;4BAKdiB,yBACC,KAACnC;gCAASyD,UAAU;0CAClB,cAAA,KAAC/C;oCACCG,WAAWA;oCACXK,aAAaA;;iCAGf;;yBAEJ;oBACH,CAACF,aACA,kEAAkE;oBAClE,qDAAqD;kCACrD,KAACrB;wBAAM+D,UAAS;kCACbjC,UACG,4DACA,kDACA,yDACA;uCAGN,KAACnB;wBACCqD,QAAQ3C;wBACRH,WAAWA;wBACXK,aAAaA;wBACb0C,SAAS;wBACTzC,SAASA;wBACTF,OAAOA;;;;;;AAOrB;AAEAN,kBAAkBsB,WAAW,GAAG;AAEhC,eAAetB,kBAAiB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/listing-detail-page.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 PageHeaderActions,\n PageHeaderHelp,\n PageHeaderRecord,\n} from '@aglyn/aglyn'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useFirestore, useFirestoreDoc, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n CircularProgress,\n Stack,\n Typography,\n} from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { lazy, Suspense, useMemo, useState } from 'react'\nimport ListingDetailEditor from './listing-detail-editor.component'\nimport ListingReviewStatus from './listing-review-status.component'\nimport ListingVerificationRequest from './listing-verification-request.component'\nimport { MarketplaceListingContent } from './listing-content.component'\nimport type { OrgInstallHost } from '../model/marketplace'\nimport { publishPluginPath } from '../model/marketplace-paths'\nimport {\n MARKETPLACE_MANAGE_LISTINGS_PERMISSION,\n marketplacePublisherPermissionRefusal,\n} from '../model/marketplace-publisher-permissions'\n\n/** The publisher's connection credentials: drawn only for an owner's plugin listing, so it loads then. */\nconst ListingConnectionCredentialsCard = lazy(() => import('./listing-connection-credentials-card.component'))\n\n/**\n * Org marketplace listing detail (AGL-772), at `{marketplace}/{listingId}`.\n *\n * It was a console route until AGL-3080, which is why it used to reach the\n * body through the `marketplaceListing` zone: an app page could not import\n * this plugin. This page IS the plugin now, so it renders the content\n * directly — the zone stays registered for the surfaces that still need it.\n *\n * Install pins validate against a site, so the detail acts through the org's\n * first site until targeting lands (AGL-773).\n */\nexport function ListingDetailPage(props: {\n listingId: string\n orgId: string | null\n basePath: string\n /** The site an install acts through, and every site for the target picker. */\n actingHost: string\n hosts: ReadonlyArray<OrgInstallHost>\n /**\n * Whether `hosts` is the workspace's whole site list yet (AGL-4047). While\n * it loads there is no acting site, and that is not a workspace with none.\n * Absent reads as true.\n */\n hostsReady?: boolean\n permissions?: Record<string, boolean | undefined>\n orgSlug: string\n}) {\n const { listingId, orgId, basePath, actingHost, hosts, permissions, orgSlug } =\n props\n const hostsReady = props.hostsReady ?? true\n const firestore = useFirestore()\n const { data: user } = useUser()\n\n // The listing itself, so the owner can edit the whole page in place\n // (AGL-869) rather than through a cramped sidebar card.\n const { data: listing } = useFirestoreDoc<any>(\n () => doc(firestore, 'marketplaceListings', listingId || '-missing-'),\n [firestore, listingId],\n { idField: '$id' },\n )\n // Listings are org-owned (AGL-652): ownership is an org comparison.\n const isOwner = Boolean(orgId && listing?.profileId === orgId)\n // Editing it asks \"Manage published listings\" (AGL-4047), as its save\n // route and the listing rules do. Off with the permission named, not\n // hidden; an absent key reads as allowed, and the route still decides.\n const canManageListings =\n permissions?.[MARKETPLACE_MANAGE_LISTINGS_PERMISSION] !== false\n const [editing, setEditing] = useState(false)\n\n // Name the thing you are looking at (AGL-1000). The page used to announce\n // itself as \"Marketplace listing\" over a breadcrumb ending in \"Listing\",\n // which made the largest text on the page the one part identical on every\n // listing. This page already reads the doc for the in-place editor, so the\n // name costs nothing; the surface's declared title stays as the fallback\n // for the beat before it resolves and for a listing that does not exist.\n const listingName = String(listing?.displayName ?? '').trim()\n const isPlugin = (listing?.artifactType ?? listing?.type) === 'plugin'\n\n /*\n * The hero's owner actions, memoized (AGL-1005). `PageHeaderActions`\n * publishes upward through an effect keyed on what it is handed, so a node\n * rebuilt every render would republish every render. The dependencies are\n * exactly the four facts the buttons read.\n */\n const ownerActions = useMemo(\n () =>\n isOwner && !editing ? (\n <Stack\n direction=\"row\"\n spacing={1}\n useFlexGap\n sx={{ flexWrap: 'wrap' }}\n >\n {/* Shipping a new version had no door on the listing itself\n (AGL-1008) — Edit changes metadata and View changes nothing,\n so the only reading left was \"make a second listing\". Same\n publish form, pre-bound to this listing. Plugins only: a\n bundle is the thing a new version ships. */}\n {isPlugin ? (\n <AppLink href={publishPluginPath(basePath, listingId)}>\n <Button variant=\"contained\" color=\"primary\" component=\"span\">\n {'Publish new version'}\n </Button>\n </AppLink>\n ) : null}\n <BlockedControl\n blocked={!canManageListings}\n reason={marketplacePublisherPermissionRefusal(\n MARKETPLACE_MANAGE_LISTINGS_PERMISSION,\n )}\n >\n <Button\n variant=\"outlined\"\n color=\"primary\"\n onClick={() => setEditing(true)}\n >\n {'Edit listing'}\n </Button>\n </BlockedControl>\n </Stack>\n ) : null,\n [isOwner, editing, isPlugin, basePath, listingId, canManageListings],\n )\n\n return (\n <>\n <PageHeaderRecord title={listingName} />\n <PageHeaderHelp\n topic=\"plugins\"\n anchor=\"#what-the-badges-on-a-listing-mean\"\n />\n {/* Owner action in the hero (AGL-1005), where the chrome already has a\n slot for it. It used to float in a bare right-aligned box above the\n content — unanchored to anything, and it moved depending on whether\n the org had a site yet. */}\n <PageHeaderActions>{ownerActions}</PageHeaderActions>\n {editing && isOwner && canManageListings && orgId && listing ? (\n <ListingDetailEditor\n orgId={orgId}\n listingId={listingId}\n listing={listing}\n user={user}\n onDone={() => setEditing(false)}\n />\n ) : (\n // One stack, one gap: the owner cards and the listing body share the\n // same edges and the same spacing between them.\n <Stack spacing={3}>\n {/* The publisher's own view of the queue (AGL-1079). Owner-only:\n review state, rejection reasons and what was attested are the\n publisher's business, and a buyer is never offered a version\n this card exists to explain. Above the buyer-facing body,\n because \"what is happening to my submission\" is why an owner\n opened their own listing. */}\n {isOwner ? (\n <>\n <ListingReviewStatus\n listingId={listingId}\n isPlugin={isPlugin}\n permissions={permissions}\n />\n {/* The door to the Verified badge (AGL-1217). Below the review\n card on purpose: \"where is my submission\" is the more urgent\n question, and asking for a badge only makes sense once the\n listing is live. */}\n <ListingVerificationRequest\n listingId={listingId}\n listing={listing}\n viewerOrgId={orgId ?? undefined}\n user={user}\n isPlugin={isPlugin}\n permissions={permissions}\n />\n {/* The publisher's OAuth app for each connection the latest\n version declares (AGL-4196). Draws nothing for a listing\n that declares none. */}\n {isPlugin ? (\n <Suspense fallback={null}>\n <ListingConnectionCredentialsCard\n listingId={listingId}\n permissions={permissions}\n />\n </Suspense>\n ) : null}\n </>\n ) : null}\n {!actingHost && !hostsReady ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Loading your sites…'}\n </Typography>\n </Stack>\n ) : !actingHost ? (\n // Owners can still edit their listing with no site of their own —\n // through the hero's Edit listing action (AGL-1005).\n <Alert severity=\"info\">\n {isOwner\n ? 'Add a site to your organization to install marketplace ' +\n 'items. You can still edit this listing above.'\n : 'Add a site to your organization to view and install ' +\n 'marketplace items.'}\n </Alert>\n ) : (\n <MarketplaceListingContent\n hostId={actingHost}\n listingId={listingId}\n permissions={permissions}\n orgScoped\n orgSlug={orgSlug}\n hosts={hosts}\n // The workspace the hub already holds (AGL-4047), so the org\n // pin is read under it rather than a lookup through a site.\n orgId={orgId}\n />\n )}\n </Stack>\n )}\n </>\n )\n}\n\nListingDetailPage.displayName = 'ListingDetailPage'\n\nexport default ListingDetailPage\n"],"names":["PageHeaderActions","PageHeaderHelp","PageHeaderRecord","AppLink","BlockedControl","useFirestore","useFirestoreDoc","useUser","Alert","Button","CircularProgress","Stack","Typography","doc","lazy","Suspense","useMemo","useState","ListingDetailEditor","ListingReviewStatus","ListingVerificationRequest","MarketplaceListingContent","publishPluginPath","MARKETPLACE_MANAGE_LISTINGS_PERMISSION","marketplacePublisherPermissionRefusal","ListingConnectionCredentialsCard","ListingDetailPage","props","listingId","orgId","basePath","actingHost","hosts","permissions","orgSlug","hostsReady","firestore","data","user","listing","idField","isOwner","Boolean","profileId","canManageListings","editing","setEditing","listingName","String","displayName","trim","isPlugin","artifactType","type","ownerActions","direction","spacing","useFlexGap","sx","flexWrap","href","variant","color","component","blocked","reason","onClick","title","topic","anchor","onDone","viewerOrgId","undefined","fallback","alignItems","size","severity","hostId","orgScoped"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SACEA,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,QACX,eAAc;AACrB,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,YAAY,EAAEC,eAAe,EAAEC,OAAO,QAAQ,iCAAgC;AACvF,SACEC,KAAK,EACLC,MAAM,EACNC,gBAAgB,EAChBC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SAASC,GAAG,QAAQ,qBAAoB;AACxC,SAASC,IAAI,EAAEC,QAAQ,EAAEC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACzD,OAAOC,yBAAyB,uCAAmC;AACnE,OAAOC,yBAAyB,uCAAmC;AACnE,OAAOC,gCAAgC,8CAA0C;AACjF,SAASC,yBAAyB,QAAQ,iCAA6B;AAEvE,SAASC,iBAAiB,QAAQ,gCAA4B;AAC9D,SACEC,sCAAsC,EACtCC,qCAAqC,QAChC,gDAA4C;AAEnD,wGAAwG,GACxG,MAAMC,iDAAmCX,KAAK,IAAM,MAAM,CAAC;AAE3D;;;;;;;;;;CAUC,GACD,OAAO,SAASY,kBAAkBC,KAejC;QAGoBA;IAFnB,MAAM,EAAEC,SAAS,EAAEC,KAAK,EAAEC,QAAQ,EAAEC,UAAU,EAAEC,KAAK,EAAEC,WAAW,EAAEC,OAAO,EAAE,GAC3EP;IACF,MAAMQ,cAAaR,oBAAAA,MAAMQ,UAAU,YAAhBR,oBAAoB;IACvC,MAAMS,YAAY/B;IAClB,MAAM,EAAEgC,MAAMC,IAAI,EAAE,GAAG/B;IAEvB,oEAAoE;IACpE,wDAAwD;IACxD,MAAM,EAAE8B,MAAME,OAAO,EAAE,GAAGjC,gBACxB,IAAMO,IAAIuB,WAAW,uBAAuBR,aAAa,cACzD;QAACQ;QAAWR;KAAU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;gBACNgC,QAAQ,IAAMxB,WAAW;iBAG3B,qEAAqE;YACrE,gDAAgD;0BAChD,MAACnC;gBAAM6C,SAAS;;oBAObf,wBACC;;0CACE,KAACtB;gCACCS,WAAWA;gCACXuB,UAAUA;gCACVlB,aAAaA;;0CAMf,KAACb;gCACCQ,WAAWA;gCACXW,SAASA;gCACTgC,WAAW,EAAE1C,gBAAAA,QAAS2C;gCACtBlC,MAAMA;gCACNa,UAAUA;gCACVlB,aAAaA;;4BAKdkB,yBACC,KAACpC;gCAAS0D,UAAU;0CAClB,cAAA,KAAChD;oCACCG,WAAWA;oCACXK,aAAaA;;iCAGf;;yBAEJ;oBACH,CAACF,cAAc,CAACI,2BACf,MAACxB;wBAAM4C,WAAU;wBAAMC,SAAS;wBAAGE,IAAI;4BAAEgB,YAAY;wBAAS;;0CAC5D,KAAChE;gCAAiBiE,MAAM;;0CACxB,KAAC/D;gCAAWiD,SAAQ;gCAAQC,OAAM;0CAC/B;;;yBAGH,CAAC/B,aACH,kEAAkE;oBAClE,qDAAqD;kCACrD,KAACvB;wBAAMoE,UAAS;kCACbnC,UACG,4DACA,kDACA,yDACA;uCAGN,KAACpB;wBACCwD,QAAQ9C;wBACRH,WAAWA;wBACXK,aAAaA;wBACb6C,SAAS;wBACT5C,SAASA;wBACTF,OAAOA;wBACP,6DAA6D;wBAC7D,4DAA4D;wBAC5DH,OAAOA;;;;;;AAOrB;AAEAH,kBAAkBuB,WAAW,GAAG;AAEhC,eAAevB,kBAAiB"}
@@ -134,12 +134,14 @@ import PublishPluginPage from "./publish-plugin-page.component.js";
134
134
  // has to be able to do anyway for a listing deleted while a link to it
135
135
  // was still in someone's inbox.
136
136
  if (segments.length === 1) {
137
+ var _ref2;
137
138
  return /*#__PURE__*/ _jsx(ListingDetailPage, {
138
139
  listingId: String(segments[0]),
139
140
  orgId: orgId,
140
141
  basePath: mount,
141
142
  actingHost: actingHost,
142
143
  hosts: hostList,
144
+ hostsReady: (_ref2 = orgMount == null ? void 0 : orgMount.hostsReady) != null ? _ref2 : true,
143
145
  permissions: permissions,
144
146
  orgSlug: orgSlug
145
147
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/marketplace-hub.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 type { ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { HubSections } from '@aglyn/shared-ui-next/components/hub-tabs'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport {\n Alert,\n Button,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useMemo, useState } from 'react'\nimport HostPluginsCard from './host-plugins-card.component'\nimport ListingDetailPage from './listing-detail-page.component'\nimport MarketplaceBrowse from './marketplace-browse.component'\nimport MarketplacePaymentsNotice from './marketplace-payments-notice.component'\nimport OrgLicencesPanel from './org-licences-panel.component'\nimport OrgPublishPanel from './org-publish-panel.component'\nimport OrgSellerPanel from './org-seller-panel.component'\nimport PublisherProfilePage from './publisher-profile-page.component'\nimport PublishPluginPage from './publish-plugin-page.component'\n\n/**\n * The Marketplace hub (AGL-772/2501), as a plugin surface (AGL-3080).\n *\n * ## What moved, and what did not\n *\n * Every section of this hub — browse, installed, licences, and the four\n * seller cards — was a hand-written console route under\n * `app/(app)/[orgSlug]/marketplace/`, ten route files whose whole job was to\n * assemble chrome around a body that already belonged to this plugin. The\n * shell's generic org plugin route does that assembly for every other\n * surface, from one declaration. So the declaration is now in `plugin.ts`\n * and this is the body.\n *\n * NO URL CHANGED. `ConsoleNavItem.ownsSubtree` is what makes that true: a\n * segment naming a declared section resolves as a section, and anything else\n * beneath the surface is handed over as `segments` for this page to read. So\n * `/{org}/marketplace/browse` is still the browse tab and\n * `/{org}/marketplace/{listingId}` is still a listing — the same addresses,\n * served by a declaration instead of by seventeen files.\n *\n * ## The gates are the shell's now, and that is the point\n *\n * The seller sections read the organization's REVENUE and its payout account,\n * and the old sections layout gated them itself — above the pages rather than\n * in the rail, because a route can be typed whether or not a tab was ever\n * offered. That is exactly what `ConsoleNavSection.permission` does, applied\n * by the same shell that hides the tab, so a hidden tab and a refused deep\n * link are one verdict instead of two copies of one. The permission map fails\n * OPEN while it loads, and the shell holds the whole page on it — so this\n * component never has to know that.\n *\n * Likewise `release_marketplace`: the sections layout wrapped itself in a\n * `FeatureGate` because the flag also feeds the plugin LOADER, and a hub that\n * went on rendering with its widgets empty made turning the feature off its\n * own broken state (AGL-2019). The shell applies the same flag through the\n * nav item's `navTabId`, around the same page.\n */\nexport function MarketplaceHub(props: ConsolePluginPageProps) {\n const {\n orgMount,\n basePath,\n sections,\n section,\n segments,\n permissions,\n viewerOrgs,\n org,\n } = props\n\n const orgId = orgMount?.orgId ?? null\n const orgSlug = orgMount?.orgSlug ?? ''\n // Each site's own switch rides along (AGL-4047): the listing's\n // installed-sites panel must not call a site that turned a plugin off a\n // site running it.\n const hostList = useMemo(\n () =>\n (orgMount?.hosts ?? []).map((host) => ({\n id: host.id,\n label: host.name,\n disabledPlugins: host.disabledPlugins ?? null,\n })),\n [orgMount?.hosts],\n )\n /**\n * The site an install acts through. Installs pin to a site and pins are\n * validated against host membership, so every section that installs needs\n * the same answer — which is why it is chosen once here rather than per\n * section.\n */\n const [selectedHost, setSelectedHost] = useState('')\n const actingHost = selectedHost || hostList[0]?.id || ''\n\n const mount = basePath ?? ''\n\n if (!orgId) {\n return (\n <Alert severity=\"info\">\n {'Create your first site to start an organization, then browse and ' +\n 'install marketplace items here.'}\n </Alert>\n )\n }\n\n /*\n * An entity beneath the surface, not a section: `ownsSubtree` hands those\n * over with no `section` set. Each owns its own chrome, and none of them\n * takes the acting-site picker or the section rail — a listing is one\n * thing, not a tab of the hub.\n */\n if (!section && segments?.length) {\n if (segments[0] === 'publish' && segments[1] === 'plugin') {\n return (\n <PublishPluginPage\n orgId={orgId}\n basePath={mount}\n permissions={permissions}\n /*\n * The shell holds this whole page behind a spinner until the\n * permission map settles — it fails OPEN, so rendering on it early\n * offers a publish form to a member who is about to be refused.\n * Mounted at all therefore means settled, and saying so here keeps\n * the form's own gate honest when it is mounted anywhere else.\n */\n permissionsLoaded\n />\n )\n }\n if (segments[0] === 'publisher' && segments[1]) {\n return (\n <PublisherProfilePage\n segment={String(segments[1])}\n basePath={mount}\n actingHost={actingHost}\n permissions={permissions}\n orgSlug={orgSlug}\n />\n )\n }\n // Anything else one level down is a listing id. The surface owns its\n // subtree, so it also owns saying \"no such thing\" — which the detail page\n // has to be able to do anyway for a listing deleted while a link to it\n // was still in someone's inbox.\n if (segments.length === 1) {\n return (\n <ListingDetailPage\n listingId={String(segments[0])}\n orgId={orgId}\n basePath={mount}\n actingHost={actingHost}\n hosts={hostList}\n permissions={permissions}\n orgSlug={orgSlug}\n />\n )\n }\n return (\n <Alert severity=\"warning\">\n {'This marketplace page does not exist. It may have moved, or the ' +\n 'link may be incomplete.'}\n </Alert>\n )\n }\n\n if (!actingHost) {\n return (\n <Alert severity=\"info\">\n {'Add a site to your organization to install marketplace items — ' +\n 'installs apply to a site (or every site).'}\n </Alert>\n )\n }\n\n return (\n <Stack spacing={2}>\n {/*\n What this deployment cannot do, said BEFORE the click (AGL-2019). The\n app supplies only the fact, through the deployment-capability context\n its org layout provides; the sentence is this plugin's, because it\n names what still works without a Stripe platform. Draws nothing at all\n on a configured deployment.\n */}\n <MarketplacePaymentsNotice />\n {hostList.length > 1 ? (\n <Stack\n useFlexGap\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', flexWrap: 'wrap' }}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Acting site'}\n </Typography>\n <TextField\n select\n size=\"small\"\n label=\"Site\"\n value={actingHost}\n onChange={(event) => setSelectedHost(event.target.value)}\n sx={{ minWidth: 200 }}\n >\n {hostList.map((host) => (\n <MenuItem key={host.id} value={host.id}>\n {host.label}\n </MenuItem>\n ))}\n </TextField>\n </Stack>\n ) : null}\n <HubSections sections={sections ?? []}>\n {section === 'browse' ? (\n <MarketplaceBrowse\n hostId={actingHost}\n permissions={permissions}\n orgScoped\n // The shell already knows the org (AGL-867): passing it keeps\n // listing links resolving synchronously instead of via an async\n // hostIndex→org lookup that can come back empty and leave the\n // detail page unreachable from browse.\n orgSlug={orgSlug}\n />\n ) : section === 'installed' ? (\n <Stack spacing={2}>\n {/* A convenience, not the inventory (AGL-1011). Administering what\n you already run belongs in Plugins; this stays so uninstalling\n something you just installed does not send you elsewhere. */}\n <Alert\n severity=\"info\"\n action={\n <AppLink href={`/${orgSlug}/plugins`}>\n <Button size=\"small\" color=\"inherit\" component=\"span\">\n {'Open Plugins'}\n </Button>\n </AppLink>\n }\n >\n {'A quick list of what this organization installed from the ' +\n 'marketplace. Settings, per-site scope and built-in plugins ' +\n 'live in Plugins.'}\n </Alert>\n <HostPluginsCard hostId={actingHost} orgSlug={orgSlug} />\n </Stack>\n ) : section === 'licences' ? (\n <OrgLicencesPanel\n orgId={orgId}\n basePath={mount}\n viewerOrgs={viewerOrgs}\n />\n ) : section === 'upload' ? (\n <OrgPublishPanel\n orgId={orgId}\n hosts={hostList}\n basePath={mount}\n billingPath={orgMount?.billingPath}\n org={org as never}\n // The shell holds this page behind a spinner until the org doc\n // settles, so an org in hand means an org that arrived. Stated\n // rather than assumed: the fee this panel prints is a claim about\n // a publisher's plan, and the free rate is what an absent doc\n // resolves to.\n orgReady={Boolean(org)}\n />\n ) : section === 'profile' ||\n section === 'listings' ||\n section === 'payouts' ||\n section === 'sales' ? (\n <OrgSellerPanel\n orgId={orgId}\n section={section}\n basePath={mount}\n permissions={permissions}\n />\n ) : null}\n </HubSections>\n </Stack>\n )\n}\n\nMarketplaceHub.displayName = 'MarketplaceHub'\n\nexport default MarketplaceHub\n"],"names":["HubSections","AppLink","Alert","Button","MenuItem","Stack","TextField","Typography","useMemo","useState","HostPluginsCard","ListingDetailPage","MarketplaceBrowse","MarketplacePaymentsNotice","OrgLicencesPanel","OrgPublishPanel","OrgSellerPanel","PublisherProfilePage","PublishPluginPage","MarketplaceHub","props","hostList","orgMount","basePath","sections","section","segments","permissions","viewerOrgs","org","orgId","orgSlug","hosts","map","host","id","label","name","disabledPlugins","selectedHost","setSelectedHost","actingHost","mount","severity","length","permissionsLoaded","segment","String","listingId","spacing","useFlexGap","direction","sx","alignItems","flexWrap","variant","color","select","size","value","onChange","event","target","minWidth","hostId","orgScoped","action","href","component","billingPath","orgReady","Boolean","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,WAAW,QAAQ,4CAA2C;AACvE,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SACEC,KAAK,EACLC,MAAM,EACNC,QAAQ,EACRC,KAAK,EACLC,SAAS,EACTC,UAAU,QACL,gBAAe;AACtB,SAASC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACzC,OAAOC,qBAAqB,mCAA+B;AAC3D,OAAOC,uBAAuB,qCAAiC;AAC/D,OAAOC,uBAAuB,oCAAgC;AAC9D,OAAOC,+BAA+B,6CAAyC;AAC/E,OAAOC,sBAAsB,oCAAgC;AAC7D,OAAOC,qBAAqB,mCAA+B;AAC3D,OAAOC,oBAAoB,kCAA8B;AACzD,OAAOC,0BAA0B,wCAAoC;AACrE,OAAOC,uBAAuB,qCAAiC;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoCC,GACD,OAAO,SAASC,eAAeC,KAA6B;;QAiCvBC;IAhCnC,MAAM,EACJC,QAAQ,EACRC,QAAQ,EACRC,QAAQ,EACRC,OAAO,EACPC,QAAQ,EACRC,WAAW,E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Q,CAAC;0CAClC,cAAA,KAAC5B;oCAAOuD,MAAK;oCAAQF,OAAM;oCAAUY,WAAU;8CAC5C;;;sCAKN,+DACC,gEACA;;sCAEJ,KAAC1D;4BAAgBsD,QAAQvB;4BAAYV,SAASA;;;qBAE9CN,YAAY,2BACd,KAACX;oBACCgB,OAAOA;oBACPP,UAAUmB;oBACVd,YAAYA;qBAEZH,YAAY,yBACd,KAACV;oBACCe,OAAOA;oBACPE,OAAOX;oBACPE,UAAUmB;oBACV2B,WAAW,EAAE/C,4BAAAA,SAAU+C,WAAW;oBAClCxC,KAAKA;oBACL,+DAA+D;oBAC/D,+DAA+D;oBAC/D,kEAAkE;oBAClE,8DAA8D;oBAC9D,eAAe;oBACfyC,UAAUC,QAAQ1C;qBAElBJ,YAAY,aACdA,YAAY,cACZA,YAAY,aACZA,YAAY,wBACZ,KAACT;oBACCc,OAAOA;oBACPL,SAASA;oBACTF,UAAUmB;oBACVf,aAAaA;qBAEb;;;;AAIZ;AAEAR,eAAeqD,WAAW,GAAG;AAE7B,eAAerD,eAAc"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/marketplace-hub.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 type { ConsolePluginPageProps } from '@aglyn/aglyn'\nimport { HubSections } from '@aglyn/shared-ui-next/components/hub-tabs'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport {\n Alert,\n Button,\n MenuItem,\n Stack,\n TextField,\n Typography,\n} from '@mui/material'\nimport { useMemo, useState } from 'react'\nimport HostPluginsCard from './host-plugins-card.component'\nimport ListingDetailPage from './listing-detail-page.component'\nimport MarketplaceBrowse from './marketplace-browse.component'\nimport MarketplacePaymentsNotice from './marketplace-payments-notice.component'\nimport OrgLicencesPanel from './org-licences-panel.component'\nimport OrgPublishPanel from './org-publish-panel.component'\nimport OrgSellerPanel from './org-seller-panel.component'\nimport PublisherProfilePage from './publisher-profile-page.component'\nimport PublishPluginPage from './publish-plugin-page.component'\n\n/**\n * The Marketplace hub (AGL-772/2501), as a plugin surface (AGL-3080).\n *\n * ## What moved, and what did not\n *\n * Every section of this hub — browse, installed, licences, and the four\n * seller cards — was a hand-written console route under\n * `app/(app)/[orgSlug]/marketplace/`, ten route files whose whole job was to\n * assemble chrome around a body that already belonged to this plugin. The\n * shell's generic org plugin route does that assembly for every other\n * surface, from one declaration. So the declaration is now in `plugin.ts`\n * and this is the body.\n *\n * NO URL CHANGED. `ConsoleNavItem.ownsSubtree` is what makes that true: a\n * segment naming a declared section resolves as a section, and anything else\n * beneath the surface is handed over as `segments` for this page to read. So\n * `/{org}/marketplace/browse` is still the browse tab and\n * `/{org}/marketplace/{listingId}` is still a listing — the same addresses,\n * served by a declaration instead of by seventeen files.\n *\n * ## The gates are the shell's now, and that is the point\n *\n * The seller sections read the organization's REVENUE and its payout account,\n * and the old sections layout gated them itself — above the pages rather than\n * in the rail, because a route can be typed whether or not a tab was ever\n * offered. That is exactly what `ConsoleNavSection.permission` does, applied\n * by the same shell that hides the tab, so a hidden tab and a refused deep\n * link are one verdict instead of two copies of one. The permission map fails\n * OPEN while it loads, and the shell holds the whole page on it — so this\n * component never has to know that.\n *\n * Likewise `release_marketplace`: the sections layout wrapped itself in a\n * `FeatureGate` because the flag also feeds the plugin LOADER, and a hub that\n * went on rendering with its widgets empty made turning the feature off its\n * own broken state (AGL-2019). The shell applies the same flag through the\n * nav item's `navTabId`, around the same page.\n */\nexport function MarketplaceHub(props: ConsolePluginPageProps) {\n const {\n orgMount,\n basePath,\n sections,\n section,\n segments,\n permissions,\n viewerOrgs,\n org,\n } = props\n\n const orgId = orgMount?.orgId ?? null\n const orgSlug = orgMount?.orgSlug ?? ''\n // Each site's own switch rides along (AGL-4047): the listing's\n // installed-sites panel must not call a site that turned a plugin off a\n // site running it.\n const hostList = useMemo(\n () =>\n (orgMount?.hosts ?? []).map((host) => ({\n id: host.id,\n label: host.name,\n disabledPlugins: host.disabledPlugins ?? null,\n })),\n [orgMount?.hosts],\n )\n /**\n * The site an install acts through. Installs pin to a site and pins are\n * validated against host membership, so every section that installs needs\n * the same answer — which is why it is chosen once here rather than per\n * section.\n */\n const [selectedHost, setSelectedHost] = useState('')\n const actingHost = selectedHost || hostList[0]?.id || ''\n\n const mount = basePath ?? ''\n\n if (!orgId) {\n return (\n <Alert severity=\"info\">\n {'Create your first site to start an organization, then browse and ' +\n 'install marketplace items here.'}\n </Alert>\n )\n }\n\n /*\n * An entity beneath the surface, not a section: `ownsSubtree` hands those\n * over with no `section` set. Each owns its own chrome, and none of them\n * takes the acting-site picker or the section rail — a listing is one\n * thing, not a tab of the hub.\n */\n if (!section && segments?.length) {\n if (segments[0] === 'publish' && segments[1] === 'plugin') {\n return (\n <PublishPluginPage\n orgId={orgId}\n basePath={mount}\n permissions={permissions}\n /*\n * The shell holds this whole page behind a spinner until the\n * permission map settles — it fails OPEN, so rendering on it early\n * offers a publish form to a member who is about to be refused.\n * Mounted at all therefore means settled, and saying so here keeps\n * the form's own gate honest when it is mounted anywhere else.\n */\n permissionsLoaded\n />\n )\n }\n if (segments[0] === 'publisher' && segments[1]) {\n return (\n <PublisherProfilePage\n segment={String(segments[1])}\n basePath={mount}\n actingHost={actingHost}\n permissions={permissions}\n orgSlug={orgSlug}\n />\n )\n }\n // Anything else one level down is a listing id. The surface owns its\n // subtree, so it also owns saying \"no such thing\" — which the detail page\n // has to be able to do anyway for a listing deleted while a link to it\n // was still in someone's inbox.\n if (segments.length === 1) {\n return (\n <ListingDetailPage\n listingId={String(segments[0])}\n orgId={orgId}\n basePath={mount}\n actingHost={actingHost}\n hosts={hostList}\n hostsReady={orgMount?.hostsReady ?? true}\n permissions={permissions}\n orgSlug={orgSlug}\n />\n )\n }\n return (\n <Alert severity=\"warning\">\n {'This marketplace page does not exist. It may have moved, or the ' +\n 'link may be incomplete.'}\n </Alert>\n )\n }\n\n if (!actingHost) {\n return (\n <Alert severity=\"info\">\n {'Add a site to your organization to install marketplace items — ' +\n 'installs apply to a site (or every site).'}\n </Alert>\n )\n }\n\n return (\n <Stack spacing={2}>\n {/*\n What this deployment cannot do, said BEFORE the click (AGL-2019). The\n app supplies only the fact, through the deployment-capability context\n its org layout provides; the sentence is this plugin's, because it\n names what still works without a Stripe platform. Draws nothing at all\n on a configured deployment.\n */}\n <MarketplacePaymentsNotice />\n {hostList.length > 1 ? (\n <Stack\n useFlexGap\n direction=\"row\"\n spacing={1}\n sx={{ alignItems: 'center', flexWrap: 'wrap' }}\n >\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Acting site'}\n </Typography>\n <TextField\n select\n size=\"small\"\n label=\"Site\"\n value={actingHost}\n onChange={(event) => setSelectedHost(event.target.value)}\n sx={{ minWidth: 200 }}\n >\n {hostList.map((host) => (\n <MenuItem key={host.id} value={host.id}>\n {host.label}\n </MenuItem>\n ))}\n </TextField>\n </Stack>\n ) : null}\n <HubSections sections={sections ?? []}>\n {section === 'browse' ? (\n <MarketplaceBrowse\n hostId={actingHost}\n permissions={permissions}\n orgScoped\n // The shell already knows the org (AGL-867): passing it keeps\n // listing links resolving synchronously instead of via an async\n // hostIndex→org lookup that can come back empty and leave the\n // detail page unreachable from browse.\n orgSlug={orgSlug}\n />\n ) : section === 'installed' ? (\n <Stack spacing={2}>\n {/* A convenience, not the inventory (AGL-1011). Administering what\n you already run belongs in Plugins; this stays so uninstalling\n something you just installed does not send you elsewhere. */}\n <Alert\n severity=\"info\"\n action={\n <AppLink href={`/${orgSlug}/plugins`}>\n <Button size=\"small\" color=\"inherit\" component=\"span\">\n {'Open Plugins'}\n </Button>\n </AppLink>\n }\n >\n {'A quick list of what this organization installed from the ' +\n 'marketplace. Settings, per-site scope and built-in plugins ' +\n 'live in Plugins.'}\n </Alert>\n <HostPluginsCard hostId={actingHost} orgSlug={orgSlug} />\n </Stack>\n ) : section === 'licences' ? (\n <OrgLicencesPanel\n orgId={orgId}\n basePath={mount}\n viewerOrgs={viewerOrgs}\n />\n ) : section === 'upload' ? (\n <OrgPublishPanel\n orgId={orgId}\n hosts={hostList}\n basePath={mount}\n billingPath={orgMount?.billingPath}\n org={org as never}\n // The shell holds this page behind a spinner until the org doc\n // settles, so an org in hand means an org that arrived. Stated\n // rather than assumed: the fee this panel prints is a claim about\n // a publisher's plan, and the free rate is what an absent doc\n // resolves to.\n orgReady={Boolean(org)}\n />\n ) : section === 'profile' ||\n section === 'listings' ||\n section === 'payouts' ||\n section === 'sales' ? (\n <OrgSellerPanel\n orgId={orgId}\n section={section}\n basePath={mount}\n permissions={permissions}\n />\n ) : null}\n </HubSections>\n </Stack>\n )\n}\n\nMarketplaceHub.displayName = 'MarketplaceHub'\n\nexport default MarketplaceHub\n"],"names":["HubSections","AppLink","Alert","Button","MenuItem","Stack","TextField","Typography","useMemo","useState","HostPluginsCard","ListingDetailPage","MarketplaceBrowse","MarketplacePaymentsNotice","OrgLicencesPanel","OrgPublishPanel","OrgSellerPanel","PublisherProfilePage","PublishPluginPage","MarketplaceHub","props","hostList","orgMount","basePath","sections","section","segments","permissions","viewerOrgs","org","orgId","orgSlug","hosts","map","host","id","label","name","disabledPlugins","selectedHost","setSelectedHost","actingHost","mount","severity","length","permissionsLoaded","segment","String","listingId","hostsReady","spacing","useFlexGap","direction","sx","alignItems","flexWrap","variant","color","select","size","value","onChange","event","target","minWidth","hostId","orgScoped","action","href","component","billingPath","orgReady","Boolean","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAGA,SAASA,WAAW,QAAQ,4CAA2C;AACvE,SAASC,OAAO,QAAQ,uBAAsB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,UAAUmB;oBACVf,aAAaA;qBAEb;;;;AAIZ;AAEAR,eAAesD,WAAW,GAAG;AAE7B,eAAetD,eAAc"}
@@ -19,11 +19,11 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
19
19
  import { buildRoute, pluginDocsHelp, Route } from "@aglyn/aglyn";
20
20
  import { mdiChevronRight } from "@aglyn/shared-data-mdi";
21
21
  import { AppLink, CardDisplay, MdiIcon } from "@aglyn/shared-ui-jsx";
22
- import { Alert, Chip, Stack, Tooltip, Typography } from "@mui/material";
22
+ import { Alert, Chip, CircularProgress, Stack, Tooltip, Typography } from "@mui/material";
23
23
  import { collection, documentId, getDocs, limit, query, where } from "firebase/firestore";
24
24
  import { useEffect, useMemo, useState } from "react";
25
25
  import { useFirestore, useFirestoreCollection } from "@aglyn/tenant-feature-instance";
26
- import { installedPluginCaption } from "../model/marketplace-catalog.js";
26
+ import { installedPluginCaption, installPictureReadPhase } from "../model/marketplace-catalog.js";
27
27
  import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
28
28
  /**
29
29
  * "Installed from the marketplace", on the workspace's Plugins page — the
@@ -42,17 +42,19 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
42
42
  * outright. Every row goes to the shell's installation page, which is where
43
43
  * an installation is managed.
44
44
  */ export function OrgPluginInstallsCard(props) {
45
- const { orgId, orgSlug, hosts } = props;
45
+ var _orgInstallsRead_data;
46
+ const { orgId, orgSlug, hosts, hostsReady = true } = props;
46
47
  const firestore = useFirestore();
47
48
  // Held at null while the org resolves, never `orgs/-pending-` (AGL-1440):
48
49
  // installs are member-gated, so the sentinel was a guaranteed-denied listen
49
50
  // on every mount.
50
- const { data: orgInstalls } = useFirestoreCollection(()=>orgId ? query(collection(firestore, 'orgs', orgId, 'installs'), limit(100)) : null, [
51
+ const orgInstallsRead = useFirestoreCollection(()=>orgId ? query(collection(firestore, 'orgs', orgId, 'installs'), limit(100)) : null, [
51
52
  firestore,
52
53
  orgId
53
54
  ], {
54
55
  idField: '$id'
55
56
  });
57
+ const orgInstalls = orgInstallsRead.data;
56
58
  // Site pins too (AGL-1012). Reading only the org pins meant a plugin
57
59
  // targeted at specific sites — installed, running, and the whole point of
58
60
  // AGL-773/997 — was absent from the workspace's own plugin inventory.
@@ -60,7 +62,13 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
60
62
  // the hook count between renders.
61
63
  const hostIdsKey = hosts.map((host)=>host.id).join('|');
62
64
  const [sitePins, setSitePins] = useState({});
65
+ /**
66
+ * Which site set the pins above answer for, or that reading them failed
67
+ * (AGL-4047): until they answer, "Nothing installed" would be a guess.
68
+ */ const [sitePinsFor, setSitePinsFor] = useState(null);
69
+ const [sitePinsFailed, setSitePinsFailed] = useState(false);
63
70
  useEffect(()=>{
71
+ setSitePinsFailed(false);
64
72
  if (!hosts.length) return;
65
73
  let active = true;
66
74
  void Promise.all(hosts.map(async (host)=>{
@@ -72,8 +80,12 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
72
80
  }, entry.data()))
73
81
  ];
74
82
  })).then((entries)=>{
75
- if (active) setSitePins(Object.fromEntries(entries));
76
- }).catch(()=>undefined);
83
+ if (!active) return;
84
+ setSitePins(Object.fromEntries(entries));
85
+ setSitePinsFor(hostIdsKey);
86
+ }).catch(()=>{
87
+ if (active) setSitePinsFailed(true);
88
+ });
77
89
  return ()=>{
78
90
  active = false;
79
91
  };
@@ -82,11 +94,24 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
82
94
  firestore,
83
95
  hostIdsKey
84
96
  ]);
97
+ /**
98
+ * Whether the page may say what is installed (AGL-4047). An empty list the
99
+ * server has not confirmed is a cache's guess, and the sites' pins answer
100
+ * only once every one is read; a site list with no sites has none to read.
101
+ */ const readPhase = installPictureReadPhase({
102
+ orgPin: orgId ? {
103
+ data: ((_orgInstallsRead_data = orgInstallsRead.data) == null ? void 0 : _orgInstallsRead_data.length) ? orgInstallsRead.data : undefined,
104
+ status: orgInstallsRead.data === undefined && orgInstallsRead.status == null ? 'loading' : orgInstallsRead.status,
105
+ fromCache: orgInstallsRead.fromCache
106
+ } : 'pending',
107
+ sitePins: sitePinsFailed ? 'failed' : !hostsReady ? 'loading' : !hosts.length || sitePinsFor === hostIdsKey ? 'answered' : 'loading'
108
+ });
85
109
  const installations = useMemo(()=>{
86
110
  const byListing = new Map();
87
111
  for (const install of orgInstalls != null ? orgInstalls : []){
88
112
  byListing.set(install.$id, _extends({}, install, {
89
113
  siteLabels: [],
114
+ siteIds: [],
90
115
  orgWide: true
91
116
  }));
92
117
  }
@@ -94,11 +119,16 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
94
119
  var _sitePins_host_id;
95
120
  for (const pin of (_sitePins_host_id = sitePins[host.id]) != null ? _sitePins_host_id : []){
96
121
  const existing = byListing.get(pin.$id);
97
- if (existing) existing.siteLabels.push(host.label);
98
- else byListing.set(pin.$id, _extends({}, pin, {
122
+ if (existing) {
123
+ existing.siteLabels.push(host.label);
124
+ existing.siteIds.push(host.id);
125
+ } else byListing.set(pin.$id, _extends({}, pin, {
99
126
  siteLabels: [
100
127
  host.label
101
128
  ],
129
+ siteIds: [
130
+ host.id
131
+ ],
102
132
  orgWide: false
103
133
  }));
104
134
  }
@@ -173,7 +203,16 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
173
203
  pluginRef: install.$id
174
204
  }),
175
205
  label: (_ref = (_install_displayName = install.displayName) != null ? _install_displayName : install.pluginId) != null ? _ref : install.$id,
176
- caption: installedPluginCaption(install),
206
+ caption: installedPluginCaption(_extends({}, install, {
207
+ // The sites it covers whose own switch has it off
208
+ // (AGL-4047): every site for an org-wide install, the
209
+ // pinned ones otherwise.
210
+ switchedOff: hosts.filter((host)=>{
211
+ var _host_disabledPlugins;
212
+ return (install.orgWide || install.siteIds.includes(host.id)) && ((_host_disabledPlugins = host.disabledPlugins) == null ? void 0 : _host_disabledPlugins.includes(install.$id));
213
+ }).map((host)=>host.label),
214
+ siteCount: hosts.length
215
+ })),
177
216
  trailing: status.state === 'update-available' ? /*#__PURE__*/ _jsx(Chip, {
178
217
  size: "small",
179
218
  color: "primary",
@@ -189,6 +228,25 @@ import { resolveUpdateState, updateStateLabel } from "../model/update-state.js";
189
228
  }) : undefined
190
229
  }, install.$id);
191
230
  })
231
+ }) : readPhase === 'loading' ? /*#__PURE__*/ _jsxs(Stack, {
232
+ direction: "row",
233
+ spacing: 1,
234
+ sx: {
235
+ alignItems: 'center'
236
+ },
237
+ children: [
238
+ /*#__PURE__*/ _jsx(CircularProgress, {
239
+ size: 16
240
+ }),
241
+ /*#__PURE__*/ _jsx(Typography, {
242
+ variant: "body2",
243
+ color: "text.secondary",
244
+ children: 'Loading what this workspace installed…'
245
+ })
246
+ ]
247
+ }) : readPhase === 'error' ? /*#__PURE__*/ _jsx(Alert, {
248
+ severity: "warning",
249
+ children: 'Could not load what this workspace installed. Reload the page to ' + 'try again.'
192
250
  }) : /*#__PURE__*/ _jsx(Alert, {
193
251
  severity: "info",
194
252
  children: 'Nothing installed from the marketplace yet — browse it to add one.'
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/org-plugin-installs-card.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 buildRoute,\n pluginDocsHelp,\n Route,\n type ConsoleOrgPluginInstallsZoneProps,\n} from '@aglyn/aglyn'\nimport { mdiChevronRight } from '@aglyn/shared-data-mdi'\nimport { AppLink, CardDisplay, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { Alert, Chip, Stack, Tooltip, Typography } from '@mui/material'\nimport {\n collection,\n documentId,\n getDocs,\n limit,\n query,\n where,\n} from 'firebase/firestore'\nimport { useEffect, useMemo, useState, type ReactNode } from 'react'\nimport {\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport { installedPluginCaption } from '../model/marketplace-catalog'\nimport { resolveUpdateState, updateStateLabel } from '../model/update-state'\n\n/** One installation: its org pin, or the sites that pin it. */\ninterface Installation {\n $id: string\n displayName?: string\n pluginId?: string\n version?: string\n siteLabels: string[]\n orgWide: boolean\n}\n\n/**\n * \"Installed from the marketplace\", on the workspace's Plugins page — the\n * `orgPluginInstalls` zone (AGL-1011, drawn here since AGL-3080).\n *\n * The page is the workspace's inventory, first-party and marketplace\n * together, because where a plugin came from is a fact about it rather than a\n * different kind of thing. The built-in half is the shell's. This half is the\n * marketplace's: the pins are its `installs`, and the update chip compares\n * them with its listings and its kill switches — so the page hands over the\n * sites it can see and this card draws the rest.\n *\n * One row per INSTALLATION, not per pin: a plugin on three sites is one thing\n * an admin manages, and the scope is a fact about it rather than three\n * separate entries. An org pin covers every site, so it wins the caption\n * outright. Every row goes to the shell's installation page, which is where\n * an installation is managed.\n */\nexport function OrgPluginInstallsCard(props: ConsoleOrgPluginInstallsZoneProps) {\n const { orgId, orgSlug, hosts } = props\n const firestore = useFirestore()\n\n // Held at null while the org resolves, never `orgs/-pending-` (AGL-1440):\n // installs are member-gated, so the sentinel was a guaranteed-denied listen\n // on every mount.\n const { data: orgInstalls } = useFirestoreCollection<any>(\n () =>\n orgId\n ? query(collection(firestore, 'orgs', orgId, 'installs'), limit(100))\n : null,\n [firestore, orgId],\n { idField: '$id' },\n )\n\n // Site pins too (AGL-1012). Reading only the org pins meant a plugin\n // targeted at specific sites — installed, running, and the whole point of\n // AGL-773/997 — was absent from the workspace's own plugin inventory.\n // Fan-in per site: the host count is data, so a hook per host would change\n // the hook count between renders.\n const hostIdsKey = hosts.map((host) => host.id).join('|')\n const [sitePins, setSitePins] = useState<Record<string, any[]>>({})\n useEffect(() => {\n if (!hosts.length) return\n let active = true\n void Promise.all(\n hosts.map(async (host) => {\n const snapshot = await getDocs(\n query(collection(firestore, 'hosts', host.id, 'installs'), limit(100)),\n )\n return [\n host.id,\n snapshot.docs.map((entry) => ({ $id: entry.id, ...entry.data() })),\n ] as const\n }),\n )\n .then((entries) => {\n if (active) setSitePins(Object.fromEntries(entries))\n })\n .catch(() => undefined)\n return () => {\n active = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [firestore, hostIdsKey])\n\n const installations = useMemo(() => {\n const byListing = new Map<string, Installation>()\n for (const install of orgInstalls ?? []) {\n byListing.set(install.$id, { ...install, siteLabels: [], orgWide: true })\n }\n for (const host of hosts) {\n for (const pin of sitePins[host.id] ?? []) {\n const existing = byListing.get(pin.$id)\n if (existing) existing.siteLabels.push(host.label)\n else\n byListing.set(pin.$id, {\n ...pin,\n siteLabels: [host.label],\n orgWide: false,\n })\n }\n }\n return [...byListing.values()]\n }, [orgInstalls, hosts, sitePins])\n\n /**\n * The listings behind those installs, for the update chip (AGL-1016), and\n * their kill switches (AGL-2368) — a revoked version stays `approved`,\n * because revocation does not clear a review verdict, so without them the\n * chip offered an update `install-plugin` answers 409 to.\n *\n * Both are public reads, so plain fetches — but `in` caps at 30 ids, and a\n * workspace can run more plugins than that, so they chunk. A failure leaves\n * a map empty and every row resolves to `unknown`, which reads as \"we can't\n * say\" rather than a false \"up to date\".\n */\n const listingIdsKey = installations\n .map((install) => install.$id)\n .sort()\n .join('|')\n const [listings, setListings] = useState<Record<string, any>>({})\n const [revocations, setRevocations] = useState<Record<string, any>>({})\n useEffect(() => {\n const ids = listingIdsKey ? listingIdsKey.split('|') : []\n if (!ids.length) return\n let active = true\n const chunks: string[][] = []\n for (let index = 0; index < ids.length; index += 30) {\n chunks.push(ids.slice(index, index + 30))\n }\n const fetchChunks = (path: string) =>\n Promise.all(\n chunks.map((chunk) =>\n getDocs(\n query(collection(firestore, path), where(documentId(), 'in', chunk)),\n ),\n ),\n ).then((results) =>\n Object.fromEntries(\n results.flatMap((snapshot) =>\n snapshot.docs.map((entry) => [entry.id, entry.data()]),\n ),\n ),\n )\n void fetchChunks('marketplaceListings')\n .then((map) => {\n if (active) setListings(map)\n })\n .catch(() => undefined)\n void fetchChunks('revocations')\n .then((map) => {\n if (active) setRevocations(map)\n })\n .catch(() => undefined)\n return () => {\n active = false\n }\n }, [firestore, listingIdsKey])\n\n return (\n <CardDisplay\n header={'Installed from the marketplace'}\n // Card-level help, not just the page's (AGL-2129). This is the card\n // people arrive at looking for a switch, having read in Marketplace\n // that installing is done there — so it points at the step of the\n // walkthrough that explains the split.\n help={pluginDocsHelp('publisherHandbook', {\n anchor: '#installed-from-the-marketplace',\n })}\n contentGutterX\n contentGutterY\n >\n {installations.length ? (\n <Stack>\n {installations.map((install) => {\n // The update signal (AGL-1016/2368), from the one shared\n // comparison — for plugins that is the newest INSTALLABLE\n // version, so this can never offer what install refuses.\n const status = resolveUpdateState(\n install as never,\n listings[install.$id] ?? null,\n 'plugin',\n revocations[install.$id] ?? null,\n )\n return (\n <InstallationRow\n key={install.$id}\n href={buildRoute(Route.ORG_PLUGIN_INSTALLATION, {\n orgSlug,\n pluginRef: install.$id,\n })}\n label={install.displayName ?? install.pluginId ?? install.$id}\n caption={installedPluginCaption(install)}\n trailing={\n status.state === 'update-available' ? (\n <Chip\n size=\"small\"\n color=\"primary\"\n variant=\"outlined\"\n label={`v${status.availableVersion} available`}\n />\n ) : status.state === 'unknown' ? (\n <Tooltip title={updateStateLabel(status)}>\n <Chip size=\"small\" variant=\"outlined\" label={'Unknown'} />\n </Tooltip>\n ) : undefined\n }\n />\n )\n })}\n </Stack>\n ) : (\n <Alert severity=\"info\">\n {'Nothing installed from the marketplace yet — browse it to add one.'}\n </Alert>\n )}\n </CardDisplay>\n )\n}\n\n/**\n * One row, drawn the way the page draws its built-in rows: the whole row is\n * the link and a chevron says so, because the entry point AGL-1011 replaced\n * was a name rendered as body text that nothing said went anywhere.\n */\nfunction InstallationRow(props: {\n href: string\n label: string\n caption: string\n trailing?: ReactNode\n}) {\n const { href, label, caption, trailing } = props\n return (\n <AppLink href={href} color=\"inherit\" underline=\"none\">\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{\n alignItems: 'center',\n py: 1.25,\n px: 1,\n mx: -1,\n borderRadius: 1,\n '&:hover': { bgcolor: 'action.hover' },\n }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {label}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {caption}\n </Typography>\n </Stack>\n {trailing}\n <MdiIcon path={mdiChevronRight.path} color=\"disabled\" sx={{ fontSize: 20 }} />\n </Stack>\n </AppLink>\n )\n}\n\nexport default OrgPluginInstallsCard\n"],"names":["buildRoute","pluginDocsHelp","Route","mdiChevronRight","AppLink","CardDisplay","MdiIcon","Alert","Chip","Stack","Tooltip","Typography","collection","documentId","getDocs","limit","query","where","useEffect","useMemo","useState","useFirestore","useFirestoreCollection","installedPluginCaption","resolveUpdateState","updateStateLabel","OrgPluginInstallsCard","props","orgId","orgSlug","hosts","firestore","data","orgInstalls","idField","hostIdsKey","map","host","id","join","sitePins","setSitePins","length","active","Promise","all","snapshot","docs","entry","$id","then","entries","Object","fromEntries","catch","undefined","installations","byListing","Map","install","set","siteLabels","orgWide","pin","existing","get","push","label","values","listingIdsKey","sort","listings","setListings","revocations","setRevocations","ids","split","chunks","index","slice","fetchChunks","path","chunk","results","flatMap","header","help","anchor","contentGutterX","contentGutterY","status","InstallationRow","href","ORG_PLUGIN_INSTALLATION","pluginRef","displayName","pluginId","caption","trailing","state","size","color","variant","availableVersion","title","severity","underline","direction","spacing","sx","alignItems","py","px","mx","borderRadius","bgcolor","flex","minWidth","noWrap","fontSize"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,UAAU,E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d,WAAW;oBAAEC,SAAS;gBAAe;YACvC;;8BAEA,MAAC1G;oBAAMoG,IAAI;wBAAEO,MAAM;wBAAGC,UAAU;oBAAE;;sCAChC,KAAC1G;4BAAW2F,SAAQ;4BAAQgB,MAAM;sCAC/BnD;;sCAEH,KAACxD;4BAAW2F,SAAQ;4BAAUD,OAAM;4BAAiBiB,MAAM;sCACxDrB;;;;gBAGJC;8BACD,KAAC5F;oBAAQ2E,MAAM9E,gBAAgB8E,IAAI;oBAAEoB,OAAM;oBAAWQ,IAAI;wBAAEU,UAAU;oBAAG;;;;;AAIjF;AAEA,eAAe7F,sBAAqB"}
1
+ {"version":3,"sources":["../../../../../../../libs/plugins/marketplace/src/lib/components/org-plugin-installs-card.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 buildRoute,\n pluginDocsHelp,\n Route,\n type ConsoleOrgPluginInstallsZoneProps,\n} from '@aglyn/aglyn'\nimport { mdiChevronRight } from '@aglyn/shared-data-mdi'\nimport { AppLink, CardDisplay, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n Alert,\n Chip,\n CircularProgress,\n Stack,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport {\n collection,\n documentId,\n getDocs,\n limit,\n query,\n where,\n} from 'firebase/firestore'\nimport { useEffect, useMemo, useState, type ReactNode } from 'react'\nimport {\n useFirestore,\n useFirestoreCollection,\n} from '@aglyn/tenant-feature-instance'\nimport {\n installedPluginCaption,\n installPictureReadPhase,\n} from '../model/marketplace-catalog'\nimport { resolveUpdateState, updateStateLabel } from '../model/update-state'\n\n/** One installation: its org pin, or the sites that pin it. */\ninterface Installation {\n $id: string\n displayName?: string\n pluginId?: string\n version?: string\n siteLabels: string[]\n /** The sites pinning it, by id (AGL-4047). */\n siteIds: string[]\n orgWide: boolean\n}\n\n/**\n * \"Installed from the marketplace\", on the workspace's Plugins page — the\n * `orgPluginInstalls` zone (AGL-1011, drawn here since AGL-3080).\n *\n * The page is the workspace's inventory, first-party and marketplace\n * together, because where a plugin came from is a fact about it rather than a\n * different kind of thing. The built-in half is the shell's. This half is the\n * marketplace's: the pins are its `installs`, and the update chip compares\n * them with its listings and its kill switches — so the page hands over the\n * sites it can see and this card draws the rest.\n *\n * One row per INSTALLATION, not per pin: a plugin on three sites is one thing\n * an admin manages, and the scope is a fact about it rather than three\n * separate entries. An org pin covers every site, so it wins the caption\n * outright. Every row goes to the shell's installation page, which is where\n * an installation is managed.\n */\nexport function OrgPluginInstallsCard(props: ConsoleOrgPluginInstallsZoneProps) {\n const { orgId, orgSlug, hosts, hostsReady = true } = props\n const firestore = useFirestore()\n\n // Held at null while the org resolves, never `orgs/-pending-` (AGL-1440):\n // installs are member-gated, so the sentinel was a guaranteed-denied listen\n // on every mount.\n const orgInstallsRead = useFirestoreCollection<any>(\n () =>\n orgId\n ? query(collection(firestore, 'orgs', orgId, 'installs'), limit(100))\n : null,\n [firestore, orgId],\n { idField: '$id' },\n )\n const orgInstalls = orgInstallsRead.data\n\n // Site pins too (AGL-1012). Reading only the org pins meant a plugin\n // targeted at specific sites — installed, running, and the whole point of\n // AGL-773/997 — was absent from the workspace's own plugin inventory.\n // Fan-in per site: the host count is data, so a hook per host would change\n // the hook count between renders.\n const hostIdsKey = hosts.map((host) => host.id).join('|')\n const [sitePins, setSitePins] = useState<Record<string, any[]>>({})\n /**\n * Which site set the pins above answer for, or that reading them failed\n * (AGL-4047): until they answer, \"Nothing installed\" would be a guess.\n */\n const [sitePinsFor, setSitePinsFor] = useState<string | null>(null)\n const [sitePinsFailed, setSitePinsFailed] = useState(false)\n useEffect(() => {\n setSitePinsFailed(false)\n if (!hosts.length) return\n let active = true\n void Promise.all(\n hosts.map(async (host) => {\n const snapshot = await getDocs(\n query(collection(firestore, 'hosts', host.id, 'installs'), limit(100)),\n )\n return [\n host.id,\n snapshot.docs.map((entry) => ({ $id: entry.id, ...entry.data() })),\n ] as const\n }),\n )\n .then((entries) => {\n if (!active) return\n setSitePins(Object.fromEntries(entries))\n setSitePinsFor(hostIdsKey)\n })\n .catch(() => {\n if (active) setSitePinsFailed(true)\n })\n return () => {\n active = false\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [firestore, hostIdsKey])\n /**\n * Whether the page may say what is installed (AGL-4047). An empty list the\n * server has not confirmed is a cache's guess, and the sites' pins answer\n * only once every one is read; a site list with no sites has none to read.\n */\n const readPhase = installPictureReadPhase({\n orgPin: orgId\n ? {\n data: orgInstallsRead.data?.length ? orgInstallsRead.data : undefined,\n status:\n orgInstallsRead.data === undefined && orgInstallsRead.status == null\n ? 'loading'\n : orgInstallsRead.status,\n fromCache: orgInstallsRead.fromCache,\n }\n : 'pending',\n sitePins: sitePinsFailed\n ? 'failed'\n : !hostsReady\n ? 'loading'\n : !hosts.length || sitePinsFor === hostIdsKey\n ? 'answered'\n : 'loading',\n })\n\n const installations = useMemo(() => {\n const byListing = new Map<string, Installation>()\n for (const install of orgInstalls ?? []) {\n byListing.set(install.$id, {\n ...install,\n siteLabels: [],\n siteIds: [],\n orgWide: true,\n })\n }\n for (const host of hosts) {\n for (const pin of sitePins[host.id] ?? []) {\n const existing = byListing.get(pin.$id)\n if (existing) {\n existing.siteLabels.push(host.label)\n existing.siteIds.push(host.id)\n } else\n byListing.set(pin.$id, {\n ...pin,\n siteLabels: [host.label],\n siteIds: [host.id],\n orgWide: false,\n })\n }\n }\n return [...byListing.values()]\n }, [orgInstalls, hosts, sitePins])\n\n /**\n * The listings behind those installs, for the update chip (AGL-1016), and\n * their kill switches (AGL-2368) — a revoked version stays `approved`,\n * because revocation does not clear a review verdict, so without them the\n * chip offered an update `install-plugin` answers 409 to.\n *\n * Both are public reads, so plain fetches — but `in` caps at 30 ids, and a\n * workspace can run more plugins than that, so they chunk. A failure leaves\n * a map empty and every row resolves to `unknown`, which reads as \"we can't\n * say\" rather than a false \"up to date\".\n */\n const listingIdsKey = installations\n .map((install) => install.$id)\n .sort()\n .join('|')\n const [listings, setListings] = useState<Record<string, any>>({})\n const [revocations, setRevocations] = useState<Record<string, any>>({})\n useEffect(() => {\n const ids = listingIdsKey ? listingIdsKey.split('|') : []\n if (!ids.length) return\n let active = true\n const chunks: string[][] = []\n for (let index = 0; index < ids.length; index += 30) {\n chunks.push(ids.slice(index, index + 30))\n }\n const fetchChunks = (path: string) =>\n Promise.all(\n chunks.map((chunk) =>\n getDocs(\n query(collection(firestore, path), where(documentId(), 'in', chunk)),\n ),\n ),\n ).then((results) =>\n Object.fromEntries(\n results.flatMap((snapshot) =>\n snapshot.docs.map((entry) => [entry.id, entry.data()]),\n ),\n ),\n )\n void fetchChunks('marketplaceListings')\n .then((map) => {\n if (active) setListings(map)\n })\n .catch(() => undefined)\n void fetchChunks('revocations')\n .then((map) => {\n if (active) setRevocations(map)\n })\n .catch(() => undefined)\n return () => {\n active = false\n }\n }, [firestore, listingIdsKey])\n\n return (\n <CardDisplay\n header={'Installed from the marketplace'}\n // Card-level help, not just the page's (AGL-2129). This is the card\n // people arrive at looking for a switch, having read in Marketplace\n // that installing is done there — so it points at the step of the\n // walkthrough that explains the split.\n help={pluginDocsHelp('publisherHandbook', {\n anchor: '#installed-from-the-marketplace',\n })}\n contentGutterX\n contentGutterY\n >\n {installations.length ? (\n <Stack>\n {installations.map((install) => {\n // The update signal (AGL-1016/2368), from the one shared\n // comparison — for plugins that is the newest INSTALLABLE\n // version, so this can never offer what install refuses.\n const status = resolveUpdateState(\n install as never,\n listings[install.$id] ?? null,\n 'plugin',\n revocations[install.$id] ?? null,\n )\n return (\n <InstallationRow\n key={install.$id}\n href={buildRoute(Route.ORG_PLUGIN_INSTALLATION, {\n orgSlug,\n pluginRef: install.$id,\n })}\n label={install.displayName ?? install.pluginId ?? install.$id}\n caption={installedPluginCaption({\n ...install,\n // The sites it covers whose own switch has it off\n // (AGL-4047): every site for an org-wide install, the\n // pinned ones otherwise.\n switchedOff: hosts\n .filter(\n (host) =>\n (install.orgWide || install.siteIds.includes(host.id)) &&\n host.disabledPlugins?.includes(install.$id),\n )\n .map((host) => host.label),\n siteCount: hosts.length,\n })}\n trailing={\n status.state === 'update-available' ? (\n <Chip\n size=\"small\"\n color=\"primary\"\n variant=\"outlined\"\n label={`v${status.availableVersion} available`}\n />\n ) : status.state === 'unknown' ? (\n <Tooltip title={updateStateLabel(status)}>\n <Chip size=\"small\" variant=\"outlined\" label={'Unknown'} />\n </Tooltip>\n ) : undefined\n }\n />\n )\n })}\n </Stack>\n ) : readPhase === 'loading' ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <CircularProgress size={16} />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Loading what this workspace installed…'}\n </Typography>\n </Stack>\n ) : readPhase === 'error' ? (\n <Alert severity=\"warning\">\n {'Could not load what this workspace installed. Reload the page to ' +\n 'try again.'}\n </Alert>\n ) : (\n <Alert severity=\"info\">\n {'Nothing installed from the marketplace yet — browse it to add one.'}\n </Alert>\n )}\n </CardDisplay>\n )\n}\n\n/**\n * One row, drawn the way the page draws its built-in rows: the whole row is\n * the link and a chevron says so, because the entry point AGL-1011 replaced\n * was a name rendered as body text that nothing said went anywhere.\n */\nfunction InstallationRow(props: {\n href: string\n label: string\n caption: string\n trailing?: ReactNode\n}) {\n const { href, label, caption, trailing } = props\n return (\n <AppLink href={href} color=\"inherit\" underline=\"none\">\n <Stack\n direction=\"row\"\n spacing={1}\n sx={{\n alignItems: 'center',\n py: 1.25,\n px: 1,\n mx: -1,\n borderRadius: 1,\n '&:hover': { bgcolor: 'action.hover' },\n }}\n >\n <Stack sx={{ flex: 1, minWidth: 0 }}>\n <Typography variant=\"body2\" noWrap>\n {label}\n </Typography>\n <Typography variant=\"caption\" color=\"text.secondary\" noWrap>\n {caption}\n </Typography>\n </Stack>\n {trailing}\n <MdiIcon path={mdiChevronRight.path} color=\"disabled\" sx={{ fontSize: 20 }} />\n </Stack>\n </AppLink>\n )\n}\n\nexport default OrgPluginInstallsCard\n"],"names":["buildRoute","pluginDocsHelp","Route","mdiChevronRight","AppLink","CardDisplay","MdiIcon","Alert","Chip","CircularProgress","Stack","Tooltip","Typography","collection","documentId","getDocs","limit","query","where","useEffect","useMemo","useState","useFirestore","useFirestoreCollection","installedPluginCaption","installPictureReadPhase","resolveUpdateState","updateStateLabel","OrgPluginInstallsCard","props","orgInstallsRead","orgId","orgSlug","hosts","hostsReady","firestore","idField","orgInstalls","data","hostIdsKey","map","host","id","join","sitePins","setSitePins","sitePinsFor","setSitePinsFor","sitePinsFailed","setSitePinsFailed","length","active","Promise","all","snapshot","docs","entry","$id","then","entries","Object","fromEntries","catch","readPhase","orgPin","undefined","status","fromCache","installations","byListing","Map","install","set","siteLabels","siteIds","orgWide","pin","existing","get","push","label","values","listingIdsKey","sort","listings","setListings","revocations","setRevocations","ids","split","chunks","index","slice","fetchChunks","path","chunk","results","flatMap","header","help","anchor","contentGutterX","contentGutterY","InstallationRow","href","ORG_PLUGIN_INSTALLATION","pluginRef","displayName","pluginId","caption","switchedOff","filter","includes","disabledPlugins","siteCount","trailing","state","size","color","variant","availableVersion","title","direction","spacing","sx","alignItems","severity","underline","py","px","mx","borderRadius","bgcolor","flex","minWidth","noWrap","fontSize"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SACEA,UAAU,EACVC,cAAc,EACdC,KAAK,QAEA,eAAc;AACrB,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SAASC,OAAO,EAAEC,WAAW,EAAEC,OAAO,QAAQ,uBAAsB;AACpE,SACEC,KAAK,EACLC,IAAI,EACJC,gBAAgB,EAChBC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AW;oBAAEC,SAAS;gBAAe;YACvC;;8BAEA,MAAC1H;oBAAMkH,IAAI;wBAAES,MAAM;wBAAGC,UAAU;oBAAE;;sCAChC,KAAC1H;4BAAW2G,SAAQ;4BAAQgB,MAAM;sCAC/BvD;;sCAEH,KAACpE;4BAAW2G,SAAQ;4BAAUD,OAAM;4BAAiBiB,MAAM;sCACxD1B;;;;gBAGJM;8BACD,KAAC7G;oBAAQwF,MAAM3F,gBAAgB2F,IAAI;oBAAEwB,OAAM;oBAAWM,IAAI;wBAAEY,UAAU;oBAAG;;;;;AAIjF;AAEA,eAAe5G,sBAAqB"}
@@ -38,6 +38,7 @@ import { useRouter } from "next/navigation";
38
38
  import { collection, doc, query, where } from "firebase/firestore";
39
39
  import { useCallback, useEffect, useState } from "react";
40
40
  import { useFirestore, useUser } from "@aglyn/tenant-feature-instance";
41
+ import { merchantPaymentsPlatformMode, merchantPaymentsStateFromProfile } from "@aglyn/tenant-feature-instance/hooks/merchant-payments-state";
41
42
  import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
42
43
  import { pluginDocsHelp, useMediaPicker } from "@aglyn/aglyn";
43
44
  import { useFirestoreCollection } from "@aglyn/tenant-feature-instance";
@@ -94,11 +95,20 @@ const HANDLE_PATTERN = /^[a-z0-9][a-z0-9-]{2,29}$/;
94
95
  * MONEY — and never read `stripePayoutsEnabled`, whether the money can
95
96
  * LEAVE. The decision itself lives in `payoutReadiness` so each of its six
96
97
  * outcomes can be asserted without mounting this tree.
97
- */ const readiness = payoutReadiness({
98
+ */ /**
99
+ * The account is RECORDED in the other Stripe mode from this deployment
100
+ * (AGL-2471): a test account on a live deployment, which the sale door
101
+ * refuses. `payoutReadiness` counts any recorded mode as verified, so the
102
+ * mismatch is asked here, with the console's copy of the door's rule, and
103
+ * handed on as an unrecorded mode: every sale is refused either way, and
104
+ * the button's connect route replaces such an account with a new one.
105
+ */ const platformMode = merchantPaymentsPlatformMode();
106
+ const modeMismatch = payoutsState === 'loaded' && merchantPaymentsStateFromProfile(profile, platformMode) === 'mode-mismatch';
107
+ const readiness = payoutReadiness({
98
108
  state: payoutsState,
99
109
  chargesEnabled: profile == null ? void 0 : profile.stripeChargesEnabled,
100
110
  payoutsEnabled: profile == null ? void 0 : profile.stripePayoutsEnabled,
101
- accountLivemode: profile == null ? void 0 : profile.stripeAccountLivemode
111
+ accountLivemode: modeMismatch ? undefined : profile == null ? void 0 : profile.stripeAccountLivemode
102
112
  });
103
113
  /** Stripe will let this account take money — four of the seven outcomes. */ const chargesEnabled = readiness === 'ready' || readiness === 'blocked' || readiness === 'unknown' || readiness === 'unverified';
104
114
  // Both held at null while the org is unknown, like the profile above
@@ -835,7 +845,7 @@ const HANDLE_PATTERN = /^[a-z0-9][a-z0-9-]{2,29}$/;
835
845
  }) : null,
836
846
  readiness === 'unverified' ? /*#__PURE__*/ _jsx(Alert, {
837
847
  severity: "error",
838
- children: 'This Stripe account has not been verified for payments ' + 'here, so sales will be refused. Reconnect it to ' + 'confirm — if it was set up against Stripe test mode, ' + 'you will need to connect a live account.'
848
+ children: modeMismatch ? platformMode === 'test' ? 'The connected Stripe account is a live account, and ' + 'this site takes test payments only, so sales are ' + 'refused. Set up payouts to connect a test account.' : 'The connected Stripe account is a test account, so ' + 'sales are refused. Live payouts need a live Stripe ' + 'account: set up payouts to connect one.' : 'This Stripe account has not been verified for payments ' + 'here, so sales will be refused. Reconnect it to ' + 'confirm — if it was set up against Stripe test mode, ' + 'you will need to connect a live account.'
839
849
  }) : null,
840
850
  /*#__PURE__*/ _jsx(Typography, {
841
851
  variant: "body2",
@@ -848,7 +858,7 @@ const HANDLE_PATTERN = /^[a-z0-9][a-z0-9-]{2,29}$/;
848
858
  color: "primary",
849
859
  disabled: payoutsBusy || !canManagePayouts,
850
860
  onClick: handlePayouts,
851
- children: payoutsBusy ? 'Opening Stripe…' : readiness === 'ready' ? 'Payouts enabled — recheck status' : readiness === 'blocked' ? 'Finish payout setup in Stripe' : readiness === 'unverified' ? 'Reconnect Stripe to verify' : readiness === 'unknown' ? 'Recheck payout status' : 'Set up payouts'
861
+ children: payoutsBusy ? 'Opening Stripe…' : readiness === 'ready' ? 'Payouts enabled — recheck status' : readiness === 'blocked' ? 'Finish payout setup in Stripe' : readiness === 'unverified' ? modeMismatch ? 'Set up payouts' : 'Reconnect Stripe to verify' : readiness === 'unknown' ? 'Recheck payout status' : 'Set up payouts'
852
862
  }),
853
863
  canManagePayouts ? null : /*#__PURE__*/ _jsx(Typography, {
854
864
  variant: "caption",