@aglyn/plugins-ai 1.33.1 → 1.33.2
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,22 +25,22 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.33.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.33.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.33.
|
|
31
|
-
"@aglyn/shared-data-types": "1.33.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.33.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.33.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.33.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.33.
|
|
36
|
-
"@aglyn/shared-util-email": "1.33.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.33.
|
|
38
|
-
"@aglyn/shared-util-http": "1.33.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.33.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.33.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.33.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.33.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.33.
|
|
28
|
+
"@aglyn/aglyn": "1.33.2",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.33.2",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.33.2",
|
|
31
|
+
"@aglyn/shared-data-types": "1.33.2",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.33.2",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.33.2",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.33.2",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.33.2",
|
|
36
|
+
"@aglyn/shared-util-email": "1.33.2",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.33.2",
|
|
38
|
+
"@aglyn/shared-util-http": "1.33.2",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.33.2",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.33.2",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.33.2",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.33.2",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.33.2",
|
|
44
44
|
"@swc/helpers": "0.5.24"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -171,9 +171,9 @@ import { registerAiDeclarations } from "./declarations.js";
|
|
|
171
171
|
}, {
|
|
172
172
|
pluginId: AI_PLUGIN_ID
|
|
173
173
|
});
|
|
174
|
-
// The look each style starts a new site in (AGL-4049)
|
|
175
|
-
// style before it creates anything, and the 21
|
|
176
|
-
// kinds of site. Asked on the create, so the look module loads then; the
|
|
174
|
+
// The look each style starts a new site in (AGL-4049), and the site it
|
|
175
|
+
// starts: Create site asks a style before it creates anything, and the 21
|
|
176
|
+
// styles are this plugin's kinds of site. Asked on the create, so the look module loads then; the
|
|
177
177
|
// built-in themes this deployment has are read at that moment too.
|
|
178
178
|
registerPluginSiteStyleLooks({
|
|
179
179
|
look: async (styleId)=>{
|
|
@@ -187,6 +187,12 @@ import { registerAiDeclarations } from "./declarations.js";
|
|
|
187
187
|
return aiSiteKindDefaultLook(kind, {
|
|
188
188
|
presetIds
|
|
189
189
|
}).theme;
|
|
190
|
+
},
|
|
191
|
+
// The site the style's card pictures (2026-12-01), built from the same
|
|
192
|
+
// page the picture is drawn from (`site-style-starters/`).
|
|
193
|
+
starter: async (styleId)=>{
|
|
194
|
+
const { siteStyleStarter } = await import("./site-style-starters/index.js");
|
|
195
|
+
return siteStyleStarter(styleId);
|
|
190
196
|
}
|
|
191
197
|
}, {
|
|
192
198
|
pluginId: AI_PLUGIN_ID
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/declarations.server.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\n// Each registry from its own module, not the `@aglyn/aglyn/server` barrel:\n// boot needs three registries rather than the whole server surface, and a\n// suite that stubs that barrel wholesale still loads these declarations\n// against the real registries.\nimport {\n listPluginEventHandlers,\n registerPluginEventHandler,\n} from '@aglyn/aglyn/plugin-manager/plugin-events'\nimport {\n listPluginUserErasers,\n registerPluginUserEraser,\n} from '@aglyn/aglyn/plugin-manager/plugin-user-erasure'\nimport {\n listUsageAlertContributors,\n registerUsageAlertContributor,\n} from '@aglyn/aglyn/plugin-manager/usage-alert-contributors'\nimport { registerPluginUsageMeter } from '@aglyn/aglyn/plugin-manager/plugin-usage-meters'\nimport { registerOperatorAlerts } from '@aglyn/aglyn/plugin-manager/operator-alerts'\nimport { registerStockPhotoPicker } from '@aglyn/aglyn/plugin-manager/stock-photo-provider'\nimport { registerPluginSiteStyleLooks } from '@aglyn/aglyn/plugin-manager/plugin-site-style-looks'\nimport { registerPluginPageContent } from '@aglyn/aglyn/plugin-manager/plugin-page-content'\nimport { listServerThemePresets } from '@aglyn/aglyn/plugin-manager/plugin-theme-presets'\nimport { AI_PLUGIN_ID, AI_USAGE_METER_ID } from './constants'\nimport { AI_BUILD_PARTLY_FAILED, AI_JOB_FAILED, AI_PROVIDER_UNAVAILABLE } from './operator-alerts'\nimport { registerAiDeclarations } from './declarations'\n\n/** The provider-spend staff alerts' contributor id under the plugin. */\nconst AI_USAGE_ALERTS_ID = 'provider-spend'\n\n/**\n * The plugin's SERVER declarations (AGL-2939): what the server must know\n * at boot, before any door of the plugin has been called. The two platform\n * events the plugin writes activity for — the AI add-on bought or dropped,\n * an `ai.*` permission moved — are raised by core billing and membership\n * routes that never load the plugin's API surface, so the subscriptions\n * have to be in place from the first request. So does the eraser: an\n * account erasure is a core route too, and a person's AI usage months sit\n * under each org, keyed by the uid, where no core delete reaches them. So\n * does the usage alert contributor (AGL-2984): the usage-alerts sweep is a\n * core cron, and it evaluates the plugin's staff alerts on provider spend for\n * every org it reads.\n *\n * Light at boot by construction: the writers behind the handlers are\n * imported when the first event arrives, and the alert rules when the sweep\n * first evaluates an org, not when the process starts, so the boot cost is\n * the registration and nothing that touches Firestore.\n */\nexport function registerAiServerDeclarations(): void {\n registerAiDeclarations()\n // Idempotent against each REGISTRY rather than a module flag, so a\n // registry reset (a spec) or a second module instance registers again.\n if (!listPluginEventHandlers('org.seatAddons.changed').includes(AI_PLUGIN_ID)) {\n registerPluginEventHandler(\n 'org.seatAddons.changed',\n async ({ orgId, actor, before, after }) => {\n const { logAiAddonChanged } = await import('./activity/ai-activity')\n await logAiAddonChanged(orgId, actor, { before, after })\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'org.permissions.changed',\n async ({ orgId, actor, subject, permission, granted }) => {\n if (!permission.startsWith('ai.')) return\n const { logAiPermissionChanged } = await import('./activity/ai-activity')\n await logAiPermissionChanged(orgId, actor, { subject, permission, granted })\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // THE PLATFORM'S PER-SITE TOGGLE DOOR (AGL-4047). The collaborators card\n // sets every per-site key through the platform's generic door now, so this\n // plugin keeps its display copy (`aiPermissions` on the site's roster row,\n // which the native apps read) in step from the verdict that door wrote.\n if (!listPluginEventHandlers('host.member.permissions.changed').includes(AI_PLUGIN_ID)) {\n registerPluginEventHandler(\n 'host.member.permissions.changed',\n async ({ hostId, memberId, permissions }) => {\n const { recordAiPermissionsOnRoster } = await import('./server/ai-host-permissions-roster')\n await recordAiPermissionsOnRoster(hostId, memberId, permissions)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // THE PLATFORM'S BILLING EVENTS (AGL-3011). Subscribed at boot for the\n // same reason as the two above: they are raised by the billing webhook,\n // which never loads an AI door, and a workspace's overage standing moving\n // late is a workspace charged or refused against a fact we already had.\n //\n // The handler modules are imported when the first event arrives, so a\n // process that never receives one pays only for the registration.\n if (!listPluginEventHandlers('billing.invoice.paid').includes(AI_PLUGIN_ID)) {\n registerPluginEventHandler(\n 'billing.invoice.paid',\n async (payload) => {\n const { onAiBillingInvoicePaid } = await import('./billing/ai-overage-events')\n await onAiBillingInvoicePaid(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.invoice.failed',\n async (payload) => {\n const { onAiBillingInvoiceFailed } = await import('./billing/ai-overage-events')\n await onAiBillingInvoiceFailed(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.invoice.closed',\n async (payload) => {\n const { onAiBillingInvoiceClosed } = await import('./billing/ai-overage-events')\n await onAiBillingInvoiceClosed(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.dispute.opened',\n async (payload) => {\n const { onAiBillingDisputeOpened } = await import('./billing/ai-overage-events')\n await onAiBillingDisputeOpened(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.paymentMethod.changed',\n async (payload) => {\n const { onAiBillingPaymentMethodChanged } = await import(\n './billing/ai-overage-events'\n )\n await onAiBillingPaymentMethodChanged(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // The plugin's meter in the monthly usage sweep: the month's provider spend\n // onto the rollup, the credits past the band onto the invoice, and — from\n // the cutover month (AGL-3011) — the close-out of what the plugin invoices\n // itself. Registered at boot because the sweep is a core cron, and declared\n // in `usageAxes` so the sweep refuses to bill a month without it. The same\n // registration again replaces itself.\n registerPluginUsageMeter({\n pluginId: AI_PLUGIN_ID,\n id: AI_USAGE_METER_ID,\n measure: async (context) => {\n const { measureAiMonth } = await import('./billing/ai-month-meter')\n return measureAiMonth(context)\n },\n closeMonth: async (context) => {\n const { closeAiMonth } = await import('./billing/ai-month-meter')\n await closeAiMonth(context)\n },\n })\n if (!listPluginUserErasers().includes(AI_PLUGIN_ID)) {\n registerPluginUserEraser(\n async (request) => {\n const { eraseAiUsageForUser } = await import('./usage/ai-usage-eraser')\n return eraseAiUsageForUser(request)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // The platform provider account alert (AGL-3377), and a job failing or a\n // build finishing with parts failed on our side (AGL-3683), listed on\n // Staff → Operator alerts before the first one is raised.\n registerOperatorAlerts([AI_PROVIDER_UNAVAILABLE, AI_JOB_FAILED, AI_BUILD_PARTLY_FAILED], {\n pluginId: AI_PLUGIN_ID,\n })\n // The stock photo picker another plugin's draft writer asks for (AGL-3755):\n // an event's cover, chosen as a page's pictures are. The choosing loads on\n // the first pick; registering again replaces it.\n registerStockPhotoPicker(\n {\n pick: async (request) => {\n const { aiStockPhotoPick } = await import('./jobs/ai-stock-photo-picker')\n return aiStockPhotoPick(request)\n },\n },\n { pluginId: AI_PLUGIN_ID },\n )\n // The look each style starts a new site in (AGL-4049): Create site asks a\n // style before it creates anything, and the 21 styles are this plugin's\n // kinds of site. Asked on the create, so the look module loads then; the\n // built-in themes this deployment has are read at that moment too.\n registerPluginSiteStyleLooks(\n {\n look: async (styleId) => {\n const [{ aiSiteKind }, { aiSiteKindDefaultLook }] = await Promise.all([\n import('./model/ai-site-kinds'),\n import('./model/ai-site-look'),\n ])\n const kind = aiSiteKind(styleId)\n if (!kind) return null\n const presetIds = new Set(listServerThemePresets().map((preset) => preset.id))\n return aiSiteKindDefaultLook(kind, { presetIds }).theme\n },\n },\n { pluginId: AI_PLUGIN_ID },\n )\n // Reading and draft-editing a page's elements for the public API\n // (AGL-4235): the platform's `/v1` door asks the core contract, and the only\n // server page editor is this plugin's edit rung. Asked on the request, so\n // the editor loads then; registering again replaces it.\n registerPluginPageContent(\n {\n read: async (input) => {\n const { aiPageContentService } = await import('./server/ai-page-content')\n return aiPageContentService.read(input)\n },\n editDraft: async (input) => {\n const { aiPageContentService } = await import('./server/ai-page-content')\n return aiPageContentService.editDraft(input)\n },\n },\n { pluginId: AI_PLUGIN_ID },\n )\n if (\n !listUsageAlertContributors().some(\n (contributor) =>\n contributor.pluginId === AI_PLUGIN_ID &&\n contributor.id === AI_USAGE_ALERTS_ID,\n )\n ) {\n registerUsageAlertContributor({\n pluginId: AI_PLUGIN_ID,\n id: AI_USAGE_ALERTS_ID,\n evaluate: async (context) => {\n const { evaluateAiUsageAlerts } = await import('./usage/ai-usage-alerts')\n await evaluateAiUsageAlerts(context)\n },\n quotaChecks: async (context) => {\n const { aiQuotaChecks } = await import('./usage/ai-quota-checks')\n return aiQuotaChecks(context)\n },\n })\n }\n}\n\nregisterAiServerDeclarations()\n"],"names":["listPluginEventHandlers","registerPluginEventHandler","listPluginUserErasers","registerPluginUserEraser","listUsageAlertContributors","registerUsageAlertContributor","registerPluginUsageMeter","registerOperatorAlerts","registerStockPhotoPicker","registerPluginSiteStyleLooks","registerPluginPageContent","listServerThemePresets","AI_PLUGIN_ID","AI_USAGE_METER_ID","AI_BUILD_PARTLY_FAILED","AI_JOB_FAILED","AI_PROVIDER_UNAVAILABLE","registerAiDeclarations","AI_USAGE_ALERTS_ID","registerAiServerDeclarations","includes","orgId","actor","before","after","logAiAddonChanged","pluginId","subject","permission","granted","startsWith","logAiPermissionChanged","hostId","memberId","permissions","recordAiPermissionsOnRoster","payload","onAiBillingInvoicePaid","onAiBillingInvoiceFailed","onAiBillingInvoiceClosed","onAiBillingDisputeOpened","onAiBillingPaymentMethodChanged","id","measure","context","measureAiMonth","closeMonth","closeAiMonth","request","eraseAiUsageForUser","pick","aiStockPhotoPick","look","styleId","aiSiteKind","aiSiteKindDefaultLook","Promise","all","kind","presetIds","Set","map","preset","theme","read","input","aiPageContentService","editDraft","some","contributor","evaluate","evaluateAiUsageAlerts","quotaChecks","aiQuotaChecks"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,+BAA+B;AAC/B,SACEA,uBAAuB,EACvBC,0BAA0B,QACrB,4CAA2C;AAClD,SACEC,qBAAqB,EACrBC,wBAAwB,QACnB,kDAAiD;AACxD,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,uDAAsD;AAC7D,SAASC,wBAAwB,QAAQ,kDAAiD;AAC1F,SAASC,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,wBAAwB,QAAQ,mDAAkD;AAC3F,SAASC,4BAA4B,QAAQ,sDAAqD;AAClG,SAASC,yBAAyB,QAAQ,kDAAiD;AAC3F,SAASC,sBAAsB,QAAQ,mDAAkD;AACzF,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,iBAAa;AAC7D,SAASC,sBAAsB,EAAEC,aAAa,EAAEC,uBAAuB,QAAQ,uBAAmB;AAClG,SAASC,sBAAsB,QAAQ,oBAAgB;AAEvD,sEAAsE,GACtE,MAAMC,qBAAqB;AAE3B;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC;IACdF;IACA,mEAAmE;IACnE,uEAAuE;IACvE,IAAI,CAACjB,wBAAwB,0BAA0BoB,QAAQ,CAACR,eAAe;QAC7EX,2BACE,0BACA,OAAO,EAAEoB,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAE;YACpC,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;YAC3C,MAAMA,kBAAkBJ,OAAOC,OAAO;gBAAEC;gBAAQC;YAA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M,OAAOC;YACX,MAAM,CAAC,EAAEC,UAAU,EAAE,EAAE,EAAEC,qBAAqB,EAAE,CAAC,GAAG,MAAMC,QAAQC,GAAG,CAAC;gBACpE,MAAM,CAAC;gBACP,MAAM,CAAC;aACR;YACD,MAAMC,OAAOJ,WAAWD;YACxB,IAAI,CAACK,MAAM,OAAO;YAClB,MAAMC,YAAY,IAAIC,IAAIjD,yBAAyBkD,GAAG,CAAC,CAACC,SAAWA,OAAOpB,EAAE;YAC5E,OAAOa,sBAAsBG,MAAM;gBAAEC;YAAU,GAAGI,KAAK;QACzD;IACF,GACA;QAAErC,UAAUd;IAAa;IAE3B,iEAAiE;IACjE,6EAA6E;IAC7E,0EAA0E;IAC1E,wDAAwD;IACxDF,0BACE;QACEsD,MAAM,OAAOC;YACX,MAAM,EAAEC,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC;YAC9C,OAAOA,qBAAqBF,IAAI,CAACC;QACnC;QACAE,WAAW,OAAOF;YAChB,MAAM,EAAEC,oBAAoB,EAAE,GAAG,MAAM,MAAM,CAAC;YAC9C,OAAOA,qBAAqBC,SAAS,CAACF;QACxC;IACF,GACA;QAAEvC,UAAUd;IAAa;IAE3B,IACE,CAACR,6BAA6BgE,IAAI,CAChC,CAACC,cACCA,YAAY3C,QAAQ,KAAKd,gBACzByD,YAAY3B,EAAE,KAAKxB,qBAEvB;QACAb,8BAA8B;YAC5BqB,UAAUd;YACV8B,IAAIxB;YACJoD,UAAU,OAAO1B;gBACf,MAAM,EAAE2B,qBAAqB,EAAE,GAAG,MAAM,MAAM,CAAC;gBAC/C,MAAMA,sBAAsB3B;YAC9B;YACA4B,aAAa,OAAO5B;gBAClB,MAAM,EAAE6B,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC;gBACvC,OAAOA,cAAc7B;YACvB;QACF;IACF;AACF;AAEAzB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/declarations.server.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\n// Each registry from its own module, not the `@aglyn/aglyn/server` barrel:\n// boot needs three registries rather than the whole server surface, and a\n// suite that stubs that barrel wholesale still loads these declarations\n// against the real registries.\nimport {\n listPluginEventHandlers,\n registerPluginEventHandler,\n} from '@aglyn/aglyn/plugin-manager/plugin-events'\nimport {\n listPluginUserErasers,\n registerPluginUserEraser,\n} from '@aglyn/aglyn/plugin-manager/plugin-user-erasure'\nimport {\n listUsageAlertContributors,\n registerUsageAlertContributor,\n} from '@aglyn/aglyn/plugin-manager/usage-alert-contributors'\nimport { registerPluginUsageMeter } from '@aglyn/aglyn/plugin-manager/plugin-usage-meters'\nimport { registerOperatorAlerts } from '@aglyn/aglyn/plugin-manager/operator-alerts'\nimport { registerStockPhotoPicker } from '@aglyn/aglyn/plugin-manager/stock-photo-provider'\nimport { registerPluginSiteStyleLooks } from '@aglyn/aglyn/plugin-manager/plugin-site-style-looks'\nimport { registerPluginPageContent } from '@aglyn/aglyn/plugin-manager/plugin-page-content'\nimport { listServerThemePresets } from '@aglyn/aglyn/plugin-manager/plugin-theme-presets'\nimport { AI_PLUGIN_ID, AI_USAGE_METER_ID } from './constants'\nimport { AI_BUILD_PARTLY_FAILED, AI_JOB_FAILED, AI_PROVIDER_UNAVAILABLE } from './operator-alerts'\nimport { registerAiDeclarations } from './declarations'\n\n/** The provider-spend staff alerts' contributor id under the plugin. */\nconst AI_USAGE_ALERTS_ID = 'provider-spend'\n\n/**\n * The plugin's SERVER declarations (AGL-2939): what the server must know\n * at boot, before any door of the plugin has been called. The two platform\n * events the plugin writes activity for — the AI add-on bought or dropped,\n * an `ai.*` permission moved — are raised by core billing and membership\n * routes that never load the plugin's API surface, so the subscriptions\n * have to be in place from the first request. So does the eraser: an\n * account erasure is a core route too, and a person's AI usage months sit\n * under each org, keyed by the uid, where no core delete reaches them. So\n * does the usage alert contributor (AGL-2984): the usage-alerts sweep is a\n * core cron, and it evaluates the plugin's staff alerts on provider spend for\n * every org it reads.\n *\n * Light at boot by construction: the writers behind the handlers are\n * imported when the first event arrives, and the alert rules when the sweep\n * first evaluates an org, not when the process starts, so the boot cost is\n * the registration and nothing that touches Firestore.\n */\nexport function registerAiServerDeclarations(): void {\n registerAiDeclarations()\n // Idempotent against each REGISTRY rather than a module flag, so a\n // registry reset (a spec) or a second module instance registers again.\n if (!listPluginEventHandlers('org.seatAddons.changed').includes(AI_PLUGIN_ID)) {\n registerPluginEventHandler(\n 'org.seatAddons.changed',\n async ({ orgId, actor, before, after }) => {\n const { logAiAddonChanged } = await import('./activity/ai-activity')\n await logAiAddonChanged(orgId, actor, { before, after })\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'org.permissions.changed',\n async ({ orgId, actor, subject, permission, granted }) => {\n if (!permission.startsWith('ai.')) return\n const { logAiPermissionChanged } = await import('./activity/ai-activity')\n await logAiPermissionChanged(orgId, actor, { subject, permission, granted })\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // THE PLATFORM'S PER-SITE TOGGLE DOOR (AGL-4047). The collaborators card\n // sets every per-site key through the platform's generic door now, so this\n // plugin keeps its display copy (`aiPermissions` on the site's roster row,\n // which the native apps read) in step from the verdict that door wrote.\n if (!listPluginEventHandlers('host.member.permissions.changed').includes(AI_PLUGIN_ID)) {\n registerPluginEventHandler(\n 'host.member.permissions.changed',\n async ({ hostId, memberId, permissions }) => {\n const { recordAiPermissionsOnRoster } = await import('./server/ai-host-permissions-roster')\n await recordAiPermissionsOnRoster(hostId, memberId, permissions)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // THE PLATFORM'S BILLING EVENTS (AGL-3011). Subscribed at boot for the\n // same reason as the two above: they are raised by the billing webhook,\n // which never loads an AI door, and a workspace's overage standing moving\n // late is a workspace charged or refused against a fact we already had.\n //\n // The handler modules are imported when the first event arrives, so a\n // process that never receives one pays only for the registration.\n if (!listPluginEventHandlers('billing.invoice.paid').includes(AI_PLUGIN_ID)) {\n registerPluginEventHandler(\n 'billing.invoice.paid',\n async (payload) => {\n const { onAiBillingInvoicePaid } = await import('./billing/ai-overage-events')\n await onAiBillingInvoicePaid(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.invoice.failed',\n async (payload) => {\n const { onAiBillingInvoiceFailed } = await import('./billing/ai-overage-events')\n await onAiBillingInvoiceFailed(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.invoice.closed',\n async (payload) => {\n const { onAiBillingInvoiceClosed } = await import('./billing/ai-overage-events')\n await onAiBillingInvoiceClosed(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.dispute.opened',\n async (payload) => {\n const { onAiBillingDisputeOpened } = await import('./billing/ai-overage-events')\n await onAiBillingDisputeOpened(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n registerPluginEventHandler(\n 'billing.paymentMethod.changed',\n async (payload) => {\n const { onAiBillingPaymentMethodChanged } = await import(\n './billing/ai-overage-events'\n )\n await onAiBillingPaymentMethodChanged(payload)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // The plugin's meter in the monthly usage sweep: the month's provider spend\n // onto the rollup, the credits past the band onto the invoice, and — from\n // the cutover month (AGL-3011) — the close-out of what the plugin invoices\n // itself. Registered at boot because the sweep is a core cron, and declared\n // in `usageAxes` so the sweep refuses to bill a month without it. The same\n // registration again replaces itself.\n registerPluginUsageMeter({\n pluginId: AI_PLUGIN_ID,\n id: AI_USAGE_METER_ID,\n measure: async (context) => {\n const { measureAiMonth } = await import('./billing/ai-month-meter')\n return measureAiMonth(context)\n },\n closeMonth: async (context) => {\n const { closeAiMonth } = await import('./billing/ai-month-meter')\n await closeAiMonth(context)\n },\n })\n if (!listPluginUserErasers().includes(AI_PLUGIN_ID)) {\n registerPluginUserEraser(\n async (request) => {\n const { eraseAiUsageForUser } = await import('./usage/ai-usage-eraser')\n return eraseAiUsageForUser(request)\n },\n { pluginId: AI_PLUGIN_ID },\n )\n }\n // The platform provider account alert (AGL-3377), and a job failing or a\n // build finishing with parts failed on our side (AGL-3683), listed on\n // Staff → Operator alerts before the first one is raised.\n registerOperatorAlerts([AI_PROVIDER_UNAVAILABLE, AI_JOB_FAILED, AI_BUILD_PARTLY_FAILED], {\n pluginId: AI_PLUGIN_ID,\n })\n // The stock photo picker another plugin's draft writer asks for (AGL-3755):\n // an event's cover, chosen as a page's pictures are. The choosing loads on\n // the first pick; registering again replaces it.\n registerStockPhotoPicker(\n {\n pick: async (request) => {\n const { aiStockPhotoPick } = await import('./jobs/ai-stock-photo-picker')\n return aiStockPhotoPick(request)\n },\n },\n { pluginId: AI_PLUGIN_ID },\n )\n // The look each style starts a new site in (AGL-4049), and the site it\n // starts: Create site asks a style before it creates anything, and the 21\n // styles are this plugin's kinds of site. Asked on the create, so the look module loads then; the\n // built-in themes this deployment has are read at that moment too.\n registerPluginSiteStyleLooks(\n {\n look: async (styleId) => {\n const [{ aiSiteKind }, { aiSiteKindDefaultLook }] = await Promise.all([\n import('./model/ai-site-kinds'),\n import('./model/ai-site-look'),\n ])\n const kind = aiSiteKind(styleId)\n if (!kind) return null\n const presetIds = new Set(listServerThemePresets().map((preset) => preset.id))\n return aiSiteKindDefaultLook(kind, { presetIds }).theme\n },\n // The site the style's card pictures (2026-12-01), built from the same\n // page the picture is drawn from (`site-style-starters/`).\n starter: async (styleId) => {\n const { siteStyleStarter } = await import('./site-style-starters')\n return siteStyleStarter(styleId)\n },\n },\n { pluginId: AI_PLUGIN_ID },\n )\n // Reading and draft-editing a page's elements for the public API\n // (AGL-4235): the platform's `/v1` door asks the core contract, and the only\n // server page editor is this plugin's edit rung. Asked on the request, so\n // the editor loads then; registering again replaces it.\n registerPluginPageContent(\n {\n read: async (input) => {\n const { aiPageContentService } = await import('./server/ai-page-content')\n return aiPageContentService.read(input)\n },\n editDraft: async (input) => {\n const { aiPageContentService } = await import('./server/ai-page-content')\n return aiPageContentService.editDraft(input)\n },\n },\n { pluginId: AI_PLUGIN_ID },\n )\n if (\n !listUsageAlertContributors().some(\n (contributor) =>\n contributor.pluginId === AI_PLUGIN_ID &&\n contributor.id === AI_USAGE_ALERTS_ID,\n )\n ) {\n registerUsageAlertContributor({\n pluginId: AI_PLUGIN_ID,\n id: AI_USAGE_ALERTS_ID,\n evaluate: async (context) => {\n const { evaluateAiUsageAlerts } = await import('./usage/ai-usage-alerts')\n await evaluateAiUsageAlerts(context)\n },\n quotaChecks: async (context) => {\n const { aiQuotaChecks } = await import('./usage/ai-quota-checks')\n return aiQuotaChecks(context)\n },\n })\n }\n}\n\nregisterAiServerDeclarations()\n"],"names":["listPluginEventHandlers","registerPluginEventHandler","listPluginUserErasers","registerPluginUserEraser","listUsageAlertContributors","registerUsageAlertContributor","registerPluginUsageMeter","registerOperatorAlerts","registerStockPhotoPicker","registerPluginSiteStyleLooks","registerPluginPageContent","listServerThemePresets","AI_PLUGIN_ID","AI_USAGE_METER_ID","AI_BUILD_PARTLY_FAILED","AI_JOB_FAILED","AI_PROVIDER_UNAVAILABLE","registerAiDeclarations","AI_USAGE_ALERTS_ID","registerAiServerDeclarations","includes","orgId","actor","before","after","logAiAddonChanged","pluginId","subject","permission","granted","startsWith","logAiPermissionChanged","hostId","memberId","permissions","recordAiPermissionsOnRoster","payload","onAiBillingInvoicePaid","onAiBillingInvoiceFailed","onAiBillingInvoiceClosed","onAiBillingDisputeOpened","onAiBillingPaymentMethodChanged","id","measure","context","measureAiMonth","closeMonth","closeAiMonth","request","eraseAiUsageForUser","pick","aiStockPhotoPick","look","styleId","aiSiteKind","aiSiteKindDefaultLook","Promise","all","kind","presetIds","Set","map","preset","theme","starter","siteStyleStarter","read","input","aiPageContentService","editDraft","some","contributor","evaluate","evaluateAiUsageAlerts","quotaChecks","aiQuotaChecks"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,2EAA2E;AAC3E,0EAA0E;AAC1E,wEAAwE;AACxE,+BAA+B;AAC/B,SACEA,uBAAuB,EACvBC,0BAA0B,QACrB,4CAA2C;AAClD,SACEC,qBAAqB,EACrBC,wBAAwB,QACnB,kDAAiD;AACxD,SACEC,0BAA0B,EAC1BC,6BAA6B,QACxB,uDAAsD;AAC7D,SAASC,wBAAwB,QAAQ,kDAAiD;AAC1F,SAASC,sBAAsB,QAAQ,8CAA6C;AACpF,SAASC,wBAAwB,QAAQ,mDAAkD;AAC3F,SAASC,4BAA4B,QAAQ,sDAAqD;AAClG,SAASC,yBAAyB,QAAQ,kDAAiD;AAC3F,SAASC,sBAAsB,QAAQ,mDAAkD;AACzF,SAASC,YAAY,EAAEC,iBAAiB,QAAQ,iBAAa;AAC7D,SAASC,sBAAsB,EAAEC,aAAa,EAAEC,uBAAuB,QAAQ,uBAAmB;AAClG,SAASC,sBAAsB,QAAQ,oBAAgB;AAEvD,sEAAsE,GACtE,MAAMC,qBAAqB;AAE3B;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,SAASC;IACdF;IACA,mEAAmE;IACnE,uEAAuE;IACvE,IAAI,CAACjB,wBAAwB,0BAA0BoB,QAAQ,CAACR,eAAe;QAC7EX,2BACE,0BACA,OAAO,EAAEoB,KAAK,EAAEC,KAAK,EAAEC,MAAM,EAAEC,KAAK,EAAE;YACpC,MAAM,EAAEC,iBAAiB,EAAE,GAAG,MAAM,MAAM,CAAC;YAC3C,MAAMA,kBAAkBJ,OAAOC,OAAO;gBAAEC;gBAAQC;YAAM;QACxD,GACA;YAAEE,UAAUd;QAAa;QAE3BX,2BACE,2BACA,OAAO,EAAEoB,KAAK,EAAEC,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
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { SiteStarterPayload } from '@aglyn/aglyn/app-utils/site-starter';
|
|
18
|
+
/** The styles that start a site of their own. */
|
|
19
|
+
export declare const SITE_STYLE_STARTER_IDS: readonly string[];
|
|
20
|
+
/** The site a style starts, or `null` for a style with none. */
|
|
21
|
+
export declare function siteStyleStarter(styleId: string): Promise<SiteStarterPayload | null>;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ /**
|
|
17
|
+
* The site each style in Create site starts (2026-12-01): the home page the
|
|
18
|
+
* style's card pictures, its header and footer, and the full theme its look
|
|
19
|
+
* builds, as a starter carries them.
|
|
20
|
+
*
|
|
21
|
+
* GENERATED, never edited by hand: each `<kind>.json` is written by
|
|
22
|
+
* `libs/plugins/ai/scripts/build-site-style-starters.mts` from the same
|
|
23
|
+
* stand-in page (`scripts/site-style-previews.json`) the card's picture is
|
|
24
|
+
* drawn from, so the two cannot drift. Change the page there and run both
|
|
25
|
+
* that script and `render-site-style-previews.mts`.
|
|
26
|
+
*
|
|
27
|
+
* Each is loaded on the create that asks for it, and only on the server.
|
|
28
|
+
*/ const STARTERS = {
|
|
29
|
+
beauty: ()=>import("./beauty.json"),
|
|
30
|
+
blog: ()=>import("./blog.json"),
|
|
31
|
+
business: ()=>import("./business.json"),
|
|
32
|
+
'coming-soon': ()=>import("./coming-soon.json"),
|
|
33
|
+
education: ()=>import("./education.json"),
|
|
34
|
+
events: ()=>import("./events.json"),
|
|
35
|
+
fitness: ()=>import("./fitness.json"),
|
|
36
|
+
landing: ()=>import("./landing.json"),
|
|
37
|
+
music: ()=>import("./music.json"),
|
|
38
|
+
nonprofit: ()=>import("./nonprofit.json"),
|
|
39
|
+
personal: ()=>import("./personal.json"),
|
|
40
|
+
photography: ()=>import("./photography.json"),
|
|
41
|
+
portfolio: ()=>import("./portfolio.json"),
|
|
42
|
+
professional: ()=>import("./professional.json"),
|
|
43
|
+
realestate: ()=>import("./realestate.json"),
|
|
44
|
+
restaurant: ()=>import("./restaurant.json"),
|
|
45
|
+
store: ()=>import("./store.json"),
|
|
46
|
+
studio: ()=>import("./studio.json"),
|
|
47
|
+
trades: ()=>import("./trades.json"),
|
|
48
|
+
wellness: ()=>import("./wellness.json"),
|
|
49
|
+
yoga: ()=>import("./yoga.json")
|
|
50
|
+
};
|
|
51
|
+
/** The styles that start a site of their own. */ export const SITE_STYLE_STARTER_IDS = Object.keys(STARTERS);
|
|
52
|
+
const loaded = new Map();
|
|
53
|
+
/** The site a style starts, or `null` for a style with none. */ export function siteStyleStarter(styleId) {
|
|
54
|
+
const load = Object.prototype.hasOwnProperty.call(STARTERS, styleId) ? STARTERS[styleId] : undefined;
|
|
55
|
+
if (!load) return Promise.resolve(null);
|
|
56
|
+
let starter = loaded.get(styleId);
|
|
57
|
+
if (!starter) {
|
|
58
|
+
starter = load().then((module)=>{
|
|
59
|
+
var _module_default;
|
|
60
|
+
return (_module_default = module.default) != null ? _module_default : module;
|
|
61
|
+
});
|
|
62
|
+
// A load that failed is tried again on the next create, not remembered.
|
|
63
|
+
starter.catch(()=>loaded.delete(styleId));
|
|
64
|
+
loaded.set(styleId, starter);
|
|
65
|
+
}
|
|
66
|
+
// A copy, so a create that adjusts what it writes never changes the next
|
|
67
|
+
// one's. The payload is JSON as read, so a JSON round trip copies it whole.
|
|
68
|
+
return starter.then((payload)=>payload ? JSON.parse(JSON.stringify(payload)) : null);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/site-style-starters/index.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 type { SiteStarterPayload } from '@aglyn/aglyn/app-utils/site-starter'\n\n/**\n * The site each style in Create site starts (2026-12-01): the home page the\n * style's card pictures, its header and footer, and the full theme its look\n * builds, as a starter carries them.\n *\n * GENERATED, never edited by hand: each `<kind>.json` is written by\n * `libs/plugins/ai/scripts/build-site-style-starters.mts` from the same\n * stand-in page (`scripts/site-style-previews.json`) the card's picture is\n * drawn from, so the two cannot drift. Change the page there and run both\n * that script and `render-site-style-previews.mts`.\n *\n * Each is loaded on the create that asks for it, and only on the server.\n */\nconst STARTERS: Readonly<Record<string, () => Promise<unknown>>> = {\n beauty: () => import('./beauty.json'),\n blog: () => import('./blog.json'),\n business: () => import('./business.json'),\n 'coming-soon': () => import('./coming-soon.json'),\n education: () => import('./education.json'),\n events: () => import('./events.json'),\n fitness: () => import('./fitness.json'),\n landing: () => import('./landing.json'),\n music: () => import('./music.json'),\n nonprofit: () => import('./nonprofit.json'),\n personal: () => import('./personal.json'),\n photography: () => import('./photography.json'),\n portfolio: () => import('./portfolio.json'),\n professional: () => import('./professional.json'),\n realestate: () => import('./realestate.json'),\n restaurant: () => import('./restaurant.json'),\n store: () => import('./store.json'),\n studio: () => import('./studio.json'),\n trades: () => import('./trades.json'),\n wellness: () => import('./wellness.json'),\n yoga: () => import('./yoga.json'),\n}\n\n/** The styles that start a site of their own. */\nexport const SITE_STYLE_STARTER_IDS: readonly string[] = Object.keys(STARTERS)\n\nconst loaded = new Map<string, Promise<SiteStarterPayload | null>>()\n\n/** The site a style starts, or `null` for a style with none. */\nexport function siteStyleStarter(styleId: string): Promise<SiteStarterPayload | null> {\n const load = Object.prototype.hasOwnProperty.call(STARTERS, styleId) ? STARTERS[styleId] : undefined\n if (!load) return Promise.resolve(null)\n let starter = loaded.get(styleId)\n if (!starter) {\n starter = load().then((module) => ((module as { default?: unknown }).default ?? module) as SiteStarterPayload)\n // A load that failed is tried again on the next create, not remembered.\n starter.catch(() => loaded.delete(styleId))\n loaded.set(styleId, starter)\n }\n // A copy, so a create that adjusts what it writes never changes the next\n // one's. The payload is JSON as read, so a JSON round trip copies it whole.\n return starter.then((payload) => (payload ? (JSON.parse(JSON.stringify(payload)) as SiteStarterPayload) : null))\n}\n"],"names":["STARTERS","beauty","blog","business","education","events","fitness","landing","music","nonprofit","personal","photography","portfolio","professional","realestate","restaurant","store","studio","trades","wellness","yoga","SITE_STYLE_STARTER_IDS","Object","keys","loaded","Map","siteStyleStarter","styleId","load","prototype","hasOwnProperty","call","undefined","Promise","resolve","starter","get","then","module","default","catch","delete","set","payload","JSON","parse","stringify"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID;;;;;;;;;;;;CAYC,GACD,MAAMA,WAA6D;IACjEC,QAAQ,IAAM,MAAM,CAAC;IACrBC,MAAM,IAAM,MAAM,CAAC;IACnBC,UAAU,IAAM,MAAM,CAAC;IACvB,eAAe,IAAM,MAAM,CAAC;IAC5BC,WAAW,IAAM,MAAM,CAAC;IACxBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,SAAS,IAAM,MAAM,CAAC;IACtBC,SAAS,IAAM,MAAM,CAAC;IACtBC,OAAO,IAAM,MAAM,CAAC;IACpBC,WAAW,IAAM,MAAM,CAAC;IACxBC,UAAU,IAAM,MAAM,CAAC;IACvBC,aAAa,IAAM,MAAM,CAAC;IAC1BC,WAAW,IAAM,MAAM,CAAC;IACxBC,cAAc,IAAM,MAAM,CAAC;IAC3BC,YAAY,IAAM,MAAM,CAAC;IACzBC,YAAY,IAAM,MAAM,CAAC;IACzBC,OAAO,IAAM,MAAM,CAAC;IACpBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,QAAQ,IAAM,MAAM,CAAC;IACrBC,UAAU,IAAM,MAAM,CAAC;IACvBC,MAAM,IAAM,MAAM,CAAC;AACrB;AAEA,+CAA+C,GAC/C,OAAO,MAAMC,yBAA4CC,OAAOC,IAAI,CAACvB,UAAS;AAE9E,MAAMwB,SAAS,IAAIC;AAEnB,8DAA8D,GAC9D,OAAO,SAASC,iBAAiBC,OAAe;IAC9C,MAAMC,OAAON,OAAOO,SAAS,CAACC,cAAc,CAACC,IAAI,CAAC/B,UAAU2B,WAAW3B,QAAQ,CAAC2B,QAAQ,GAAGK;IAC3F,IAAI,CAACJ,MAAM,OAAOK,QAAQC,OAAO,CAAC;IAClC,IAAIC,UAAUX,OAAOY,GAAG,CAACT;IACzB,IAAI,CAACQ,SAAS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