@aglyn/plugins-ai 1.12.0 → 1.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +17 -17
- package/src/lib/components/ai-media-create.component.js +1 -1
- package/src/lib/components/ai-media-create.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js +1 -1
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -1
- package/src/lib/jobs/ai-job-import-step.js +11 -1
- package/src/lib/jobs/ai-job-import-step.js.map +1 -1
- package/src/lib/jobs/ai-site-import-look.d.ts +19 -4
- package/src/lib/jobs/ai-site-import-look.js +142 -45
- package/src/lib/jobs/ai-site-import-look.js.map +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.d.ts +12 -0
- package/src/lib/jobs/ai-theme-brand-inputs.js +1 -1
- package/src/lib/jobs/ai-theme-brand-inputs.js.map +1 -1
- package/src/lib/model/ai-site-import.d.ts +29 -1
- package/src/lib/model/ai-site-import.js.map +1 -1
- package/src/lib/model/ai-upsell-copy.js +1 -1
- package/src/lib/model/ai-upsell-copy.js.map +1 -1
- package/src/lib/site-import/fixtures/site-layout-recordings.d.ts +32 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js +55 -0
- package/src/lib/site-import/fixtures/site-layout-recordings.js.map +1 -1
- package/src/lib/site-import/site-import-crawl.d.ts +2 -0
- package/src/lib/site-import/site-import-crawl.js +27 -17
- package/src/lib/site-import/site-import-crawl.js.map +1 -1
- package/src/lib/site-import/site-import-css.d.ts +81 -0
- package/src/lib/site-import/site-import-css.js +443 -25
- package/src/lib/site-import/site-import-css.js.map +1 -1
- package/src/lib/site-import/site-import-data-forms.d.ts +32 -0
- package/src/lib/site-import/site-import-data-forms.js +531 -0
- package/src/lib/site-import/site-import-data-forms.js.map +1 -0
- package/src/lib/site-import/site-import-html.d.ts +8 -1
- package/src/lib/site-import/site-import-html.js +18 -5
- package/src/lib/site-import/site-import-html.js.map +1 -1
- package/src/lib/site-import/site-import-layout.d.ts +1 -1
- package/src/lib/site-import/site-import-layout.js +283 -36
- package/src/lib/site-import/site-import-layout.js.map +1 -1
- package/src/lib/site-import/site-import-nav.js +17 -3
- package/src/lib/site-import/site-import-nav.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-ai",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
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.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.
|
|
31
|
-
"@aglyn/shared-data-types": "1.
|
|
32
|
-
"@aglyn/shared-ui-email-campaigns": "1.
|
|
33
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
34
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
35
|
-
"@aglyn/shared-ui-theme": "1.
|
|
36
|
-
"@aglyn/shared-util-email": "1.
|
|
37
|
-
"@aglyn/shared-util-errors": "1.
|
|
38
|
-
"@aglyn/shared-util-http": "1.
|
|
39
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
40
|
-
"@aglyn/shared-util-tools": "1.
|
|
41
|
-
"@aglyn/tenant-data-admin": "1.
|
|
42
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
43
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.13.0",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.13.0",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.13.0",
|
|
31
|
+
"@aglyn/shared-data-types": "1.13.0",
|
|
32
|
+
"@aglyn/shared-ui-email-campaigns": "1.13.0",
|
|
33
|
+
"@aglyn/shared-ui-jsx": "1.13.0",
|
|
34
|
+
"@aglyn/shared-ui-snackstack": "1.13.0",
|
|
35
|
+
"@aglyn/shared-ui-theme": "1.13.0",
|
|
36
|
+
"@aglyn/shared-util-email": "1.13.0",
|
|
37
|
+
"@aglyn/shared-util-errors": "1.13.0",
|
|
38
|
+
"@aglyn/shared-util-http": "1.13.0",
|
|
39
|
+
"@aglyn/shared-util-timestamp": "1.13.0",
|
|
40
|
+
"@aglyn/shared-util-tools": "1.13.0",
|
|
41
|
+
"@aglyn/tenant-data-admin": "1.13.0",
|
|
42
|
+
"@aglyn/tenant-feature-instance": "1.13.0",
|
|
43
|
+
"@aglyn/tenant-runtime": "1.13.0",
|
|
44
44
|
"@swc/helpers": "0.5.23"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
@@ -148,7 +148,7 @@ export function AiMediaCreateButton(props) {
|
|
|
148
148
|
}),
|
|
149
149
|
/*#__PURE__*/ _jsx(DialogContent, {
|
|
150
150
|
children: /*#__PURE__*/ _jsx(Typography, {
|
|
151
|
-
children: upgrade.canManageBilling ? 'Creating pictures and illustrations comes with the AI add-on.' : 'Creating pictures and illustrations comes with the AI add-on. Ask
|
|
151
|
+
children: upgrade.canManageBilling ? 'Creating pictures and illustrations comes with the AI add-on.' : 'Creating pictures and illustrations comes with the AI add-on. Ask a member holding "Manage billing" to add it.'
|
|
152
152
|
})
|
|
153
153
|
}),
|
|
154
154
|
/*#__PURE__*/ _jsxs(DialogActions, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-media-create.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\nimport { lockdownRefusalText, parseLockdownRefusal, resolveEffectivePlan } from '@aglyn/aglyn'\nimport type { ConsoleMediaLibraryZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useFirestoreDoc, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n IconButton,\n LinearProgress,\n ListItemText,\n ListSubheader,\n MenuItem,\n Radio,\n RadioGroup,\n Stack,\n TextField,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n} from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport { aiMediaCreditsPerPicture } from '../model/ai-media-credits'\nimport {\n AI_MEDIA_KIND_GROUP_LABELS,\n AI_MEDIA_KIND_GROUPS,\n aiMediaKind,\n aiMediaKindsOffered,\n type AiMediaKind,\n type AiMediaKindId,\n} from '../model/ai-media-kinds'\nimport {\n AI_IMAGE_ASPECT_RATIOS,\n AI_IMAGE_MAX_COUNT,\n AI_IMAGE_PROMPT_MAX_CHARS,\n aiImageSizeForPlan,\n AI_SVG_MAX_COLORS,\n aiImagePhotosOffered,\n type AiImageAspectRatio,\n type AiImageMode,\n type AiImageSize,\n} from '../providers/image-contract'\n\n/**\n * \"Create with AI\" in Media (AGL-3602): pictures from a description, added to\n * the library that is open, through the `mediaLibrary` zone beside Upload\n * media and in the library's empty state.\n *\n * It draws from the shell's gates alone — the plan, the member's\n * `ai.generate`, the plugin being on for the workspace and the site — and asks\n * no server anything until someone creates a picture: the door decides then,\n * and the dialog says what it decided. One Kind menu, in sections: Vector\n * kinds (an SVG the text AI draws, wherever text AI runs) and, where the\n * deployment makes them, Photo, Art and Design kinds from the image provider.\n */\n\n/** Where the shell sends a reader to buy what the plan lacks (AGL-3601). */\nexport interface AiMediaUpgrade {\n billingHref: string\n canManageBilling: boolean\n}\n\nexport interface AiMediaCreateButtonProps extends ConsoleMediaLibraryZoneProps {\n /**\n * `false` when the shell mounted this as its own upsell: the plan lacks AI\n * generation and an add-on would grant it. Absent means entitled.\n */\n entitled?: boolean\n upgrade?: AiMediaUpgrade\n}\n\n/** The words each shape is offered in. */\nconst ASPECT_LABELS: Record<AiImageAspectRatio, string> = {\n '1:1': 'Square',\n '4:3': 'Landscape',\n '3:4': 'Portrait',\n '16:9': 'Wide',\n '9:16': 'Tall',\n}\n\n/**\n * What a picture from the image provider may be declined for, as the code\n * and the provider decide it: Google's filters, and its policies on real\n * people and brands. A declined picture is never charged.\n */\nexport const AI_MEDIA_RASTER_SAFETY_NOTE =\n 'Pictures of real, identifiable people, celebrities or brands may be declined by the image service. A declined picture is not charged.'\n\n/** The line under the description for a kind whose colors are described rather than picked. */\nexport const AI_MEDIA_DESCRIBE_COLORS_NOTE =\n 'To steer the colors, name them in the description, such as navy and coral.'\n\n/** The menu's items: each section's heading, then its kinds with what one costs. */\nfunction kindMenuItems(kinds: readonly AiMediaKind[], size: AiImageSize): ReactNode[] {\n const groups = AI_MEDIA_KIND_GROUPS.filter((group) => kinds.some((kind) => kind.group === group))\n const item = (kind: AiMediaKind) => (\n <MenuItem key={kind.id} value={kind.id} sx={{ gap: 2 }}>\n <ListItemText primary={kind.label} />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`about ${aiMediaCreditsPerPicture(kind.mode, undefined, size).toLocaleString()} credits`}\n </Typography>\n </MenuItem>\n )\n // One section needs no heading: a deployment without the image provider\n // lists the vector kinds alone, as it always has.\n if (groups.length < 2) return kinds.map(item)\n return groups.flatMap((group) => [\n <ListSubheader key={`group:${group}`}>{AI_MEDIA_KIND_GROUP_LABELS[group]}</ListSubheader>,\n ...kinds.filter((kind) => kind.group === group).map(item),\n ])\n}\n\n/**\n * The window's own help (AGL-3660): each control links the section of the\n * guide about it, not the guide's top.\n */\nconst AI_MEDIA_HELP = {\n dialog: pluginDocsHelp('aiImages', {\n anchor: '#make-a-picture',\n excerpt:\n 'Choose a kind, describe the picture, pick a shape and how many. The pictures land in the folder you have open, with alt text you can edit.',\n }),\n locked: pluginDocsHelp('aiImages', {\n anchor: '#who-can-use-it',\n excerpt:\n 'Creating pictures needs AI on your plan and the Generate with AI permission. A Free workspace creates them from its monthly credits.',\n }),\n shape: pluginDocsHelp('aiImages', {\n anchor: '#shapes-and-how-many',\n excerpt:\n 'Five shapes, from Square 1:1 to Tall 9:16, and one to four pictures per request. Each picture is charged on its own.',\n }),\n credits: pluginDocsHelp('aiImages', {\n anchor: '#credits',\n excerpt:\n 'The estimate is per picture times how many. You are charged only for pictures that reach your library; a declined or failed picture costs nothing.',\n }),\n declined: pluginDocsHelp('aiImages', {\n anchor: '#declined-pictures',\n excerpt:\n 'Google’s safety filters may decline real people, celebrities, brands and unsafe content. A declined picture is not charged.',\n }),\n}\n\n/**\n * The size the door will make a picture at for this workspace (AGL-3602):\n * 512 px on the Free plan, 1K on a paid one. The door decides from the plan\n * itself; this reads the same plan so the estimate matches, and reads 1K —\n * the dearer estimate — until the workspace has arrived.\n */\nexport function useAiMediaImageSize(orgId: string): AiImageSize {\n const firestore = useFirestore()\n const { data: org, status } = useFirestoreDoc<Record<string, unknown>>(\n () => doc(firestore, 'orgs', orgId),\n [firestore, orgId],\n )\n return aiImageSizeForPlan(status === 'success' && resolveEffectivePlan(org as never) === 'free')\n}\n\n/** The sentence the estimate reads as, before anything is spent. */\nexport function aiMediaCreditEstimate(\n mode: AiImageMode,\n count: number,\n size: AiImageSize = '1K',\n): string {\n const each = aiMediaCreditsPerPicture(mode, undefined, size)\n const pictures = count === 1 ? '1 picture' : `${count} pictures`\n return (\n `${pictures} uses about ${(count * each).toLocaleString()} AI credits ` +\n `(about ${each.toLocaleString()} each). A picture that is held back or does not come out is not charged.`\n )\n}\n\nexport function AiMediaCreateButton(props: AiMediaCreateButtonProps) {\n const { orgId, entitled, upgrade } = props\n const [open, setOpen] = useState(false)\n if (!orgId) return null\n const button = (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {'Create with AI'}\n </Button>\n )\n if (entitled === false) {\n if (!upgrade) return null\n return (\n <>\n {button}\n <Dialog open={open} onClose={() => setOpen(false)} fullWidth maxWidth=\"xs\">\n <DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>\n {'Create images with AI'}\n <HelpTip {...AI_MEDIA_HELP.locked} />\n </DialogTitle>\n <DialogContent>\n <Typography>\n {upgrade.canManageBilling\n ? 'Creating pictures and illustrations comes with the AI add-on.'\n : 'Creating pictures and illustrations comes with the AI add-on. Ask an owner or admin of this workspace to add it.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setOpen(false)}>{'Close'}</Button>\n {upgrade.canManageBilling ? (\n <Button variant=\"contained\" href={upgrade.billingHref}>\n {'See the AI add-on'}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n </>\n )\n }\n return (\n <>\n {button}\n <AiMediaCreateDialog {...props} orgId={orgId} open={open} onClose={() => setOpen(false)} />\n </>\n )\n}\n\nexport interface AiMediaCreateDialogProps\n extends Pick<ConsoleMediaLibraryZoneProps, 'hostId' | 'library' | 'folderId' | 'onCreated'> {\n open: boolean\n onClose: () => void\n orgId: string\n}\n\nexport function AiMediaCreateDialog({\n open,\n onClose,\n orgId,\n hostId,\n library,\n folderId,\n onCreated,\n}: AiMediaCreateDialogProps) {\n const { data: user } = useUser()\n const userRef = useRef(user)\n userRef.current = user\n const photos = aiImagePhotosOffered()\n const imageSize = useAiMediaImageSize(orgId)\n const kinds = useMemo(() => aiMediaKindsOffered(photos), [photos])\n const [kindId, setKindId] = useState<AiMediaKindId>(photos ? 'photo' : 'illustration')\n const kind = kinds.find((entry) => entry.id === kindId) ?? kinds[0]\n const mode = kind.mode\n // The site theme's colors need a site; the organization's library names none.\n const [paletteSource, setPaletteSource] = useState<'theme' | 'custom'>(hostId ? 'theme' : 'custom')\n const [colors, setColors] = useState<string[]>(['#1a73e8', '#fbbc04'])\n const [prompt, setPrompt] = useState('')\n const [aspectRatio, setAspectRatio] = useState<AiImageAspectRatio>(kind.aspectRatio)\n const [count, setCount] = useState(1)\n const [busy, setBusy] = useState(false)\n const [notice, setNotice] = useState<{ severity: 'error' | 'warning'; text: string } | null>(null)\n\n useEffect(() => {\n if (open) setNotice(null)\n }, [open])\n\n /** A new kind brings its own shape; the person may still change it. */\n const chooseKind = (next: AiMediaKindId) => {\n setKindId(next)\n const chosen = aiMediaKind(next)\n if (chosen) setAspectRatio(chosen.aspectRatio)\n }\n\n const create = useCallback(async () => {\n const description = prompt.trim()\n if (!description) return\n setBusy(true)\n setNotice(null)\n try {\n const response = await authorizedFetch(userRef.current, '/api/ai/media/images', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n library,\n hostId,\n folderId,\n mode,\n prompt: description,\n aspectRatio,\n count,\n style: kind.id,\n ...(kind.colors === 'palette'\n ? {\n palette:\n paletteSource === 'theme' ? { source: 'theme' } : { source: 'custom', colors },\n }\n : {}),\n }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice({\n severity: 'error',\n text: locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The pictures could not be made — try again.'),\n })\n return\n }\n const ids: string[] = Array.isArray(payload?.mediaIds) ? payload.mediaIds : []\n onCreated(ids)\n const missing = Number(payload?.filtered ?? 0) + Number(payload?.failed ?? 0)\n if (missing > 0) {\n setNotice({\n severity: 'warning',\n text:\n `Added ${ids.length} of ${count} to the library. ` +\n (payload?.warning\n ? String(payload.warning)\n : 'The rest were held back and were not charged.'),\n })\n return\n }\n setPrompt('')\n onClose()\n } catch {\n setNotice({ severity: 'error', text: 'The pictures could not be made — try again.' })\n } finally {\n setBusy(false)\n }\n }, [prompt, orgId, library, hostId, folderId, mode, aspectRatio, count, kind, paletteSource, colors, onCreated, onClose])\n\n return (\n <Dialog open={open} onClose={busy ? undefined : onClose} fullWidth maxWidth=\"sm\">\n <DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>\n {'Create images with AI'}\n <HelpTip {...AI_MEDIA_HELP.dialog} />\n </DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n select\n size=\"small\"\n label=\"Kind\"\n value={kind.id}\n onChange={(event) => chooseKind(event.target.value as AiMediaKindId)}\n disabled={busy}\n fullWidth\n helperText={kind.hint}\n slotProps={{\n select: {\n renderValue: (value) => aiMediaKind(String(value))?.label ?? String(value),\n MenuProps: { slotProps: { paper: { sx: { maxHeight: 420 } } } },\n },\n }}\n >\n {kindMenuItems(kinds, imageSize)}\n </TextField>\n <TextField\n label={mode === 'photo' ? 'Describe the picture' : 'Describe what to draw'}\n placeholder={kind.placeholder}\n value={prompt}\n onChange={(event) => setPrompt(event.target.value.slice(0, AI_IMAGE_PROMPT_MAX_CHARS))}\n multiline\n minRows={3}\n autoFocus\n disabled={busy}\n helperText={\n kind.colors === 'describe'\n ? `${AI_MEDIA_DESCRIBE_COLORS_NOTE} The description becomes each picture's alt text, which you can edit.`\n : \"The description becomes each picture's alt text, which you can edit.\"\n }\n />\n {mode === 'photo' ? (\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {AI_MEDIA_RASTER_SAFETY_NOTE}\n </Typography>\n <HelpTip {...AI_MEDIA_HELP.declined} />\n </Stack>\n ) : null}\n <Stack spacing={0.5}>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Shape'}\n </Typography>\n <HelpTip {...AI_MEDIA_HELP.shape} />\n </Stack>\n <ToggleButtonGroup\n size=\"small\"\n exclusive\n value={aspectRatio}\n onChange={(_event, next) => {\n if (next) setAspectRatio(next)\n }}\n aria-label=\"Shape\"\n disabled={busy}\n sx={{ flexWrap: 'wrap' }}\n >\n {AI_IMAGE_ASPECT_RATIOS.map((ratio) => (\n <ToggleButton key={ratio} value={ratio} aria-label={`${ASPECT_LABELS[ratio]} ${ratio}`}>\n {`${ASPECT_LABELS[ratio]} ${ratio}`}\n </ToggleButton>\n ))}\n </ToggleButtonGroup>\n </Stack>\n {kind.colors === 'palette' ? (\n <Stack spacing={1}>\n <RadioGroup\n value={paletteSource}\n onChange={(event) => setPaletteSource(event.target.value as 'theme' | 'custom')}\n aria-label=\"Colors\"\n >\n <FormControlLabel\n value=\"theme\"\n control={<Radio size=\"small\" />}\n label=\"Use my site's theme colors\"\n disabled={busy || !hostId}\n />\n <FormControlLabel\n value=\"custom\"\n control={<Radio size=\"small\" />}\n label=\"Choose colors\"\n disabled={busy}\n />\n </RadioGroup>\n {paletteSource === 'custom' ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>\n {colors.map((color, index) => (\n <Stack key={index} direction=\"row\" sx={{ alignItems: 'center' }}>\n <TextField\n type=\"color\"\n size=\"small\"\n value={color}\n onChange={(event) =>\n setColors((current) =>\n current.map((value, at) => (at === index ? event.target.value : value)),\n )\n }\n disabled={busy}\n slotProps={{ htmlInput: { 'aria-label': `Color ${index + 1}` } }}\n sx={{ width: 64 }}\n />\n {colors.length > 1 ? (\n <IconButton\n size=\"small\"\n aria-label={`Remove color ${index + 1}`}\n onClick={() => setColors((current) => current.filter((_value, at) => at !== index))}\n disabled={busy}\n >\n {'×'}\n </IconButton>\n ) : null}\n </Stack>\n ))}\n {colors.length < AI_SVG_MAX_COLORS ? (\n <Button size=\"small\" onClick={() => setColors((current) => [...current, '#333333'])} disabled={busy}>\n {'Add a color'}\n </Button>\n ) : null}\n </Stack>\n ) : null}\n </Stack>\n ) : null}\n <TextField\n select\n size=\"small\"\n label=\"How many\"\n value={count}\n onChange={(event) => setCount(Number(event.target.value))}\n disabled={busy}\n sx={{ maxWidth: 160 }}\n >\n {Array.from({ length: AI_IMAGE_MAX_COUNT }, (_unused, index) => index + 1).map((value) => (\n <MenuItem key={value} value={value}>\n {value}\n </MenuItem>\n ))}\n </TextField>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {aiMediaCreditEstimate(mode, count, imageSize)}\n </Typography>\n <HelpTip {...AI_MEDIA_HELP.credits} />\n </Stack>\n {busy ? (\n <Stack spacing={1}>\n <LinearProgress />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Making your pictures and adding them to the library…'}\n </Typography>\n </Stack>\n ) : null}\n {notice ? <Alert severity={notice.severity}>{notice.text}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={busy}>\n {'Close'}\n </Button>\n <Button variant=\"contained\" onClick={() => void create()} disabled={busy || !prompt.trim()}>\n {busy ? 'Creating…' : 'Create'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\nexport default AiMediaCreateButton\n"],"names":["lockdownRefusalText","parseLockdownRefusal","resolveEffectivePlan","mdiCreation","pluginDocsHelp","HelpTip","MdiIcon","authorizedFetch","useFirestore","useFirestoreDoc","useUser","Alert","Button","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","IconButton","LinearProgress","ListItemText","ListSubheader","MenuItem","Radio","RadioGroup","Stack","TextField","ToggleButton","ToggleButtonGroup","Typography","doc","useCallback","useEffect","useMemo","useRef","useState","aiMediaCreditsPerPicture","AI_MEDIA_KIND_GROUP_LABELS","AI_MEDIA_KIND_GROUPS","aiMediaKind","aiMediaKindsOffered","AI_IMAGE_ASPECT_RATIOS","AI_IMAGE_MAX_COUNT","AI_IMAGE_PROMPT_MAX_CHARS","aiImageSizeForPlan","AI_SVG_MAX_COLORS","aiImagePhotosOffered","ASPECT_LABELS","AI_MEDIA_RASTER_SAFETY_NOTE","AI_MEDIA_DESCRIBE_COLORS_NOTE","kindMenuItems","kinds","size","groups","filter","group","some","kind","item","value","id","sx","gap","primary","label","variant","color","mode","undefined","toLocaleString","length","map","flatMap","AI_MEDIA_HELP","dialog","anchor","excerpt","locked","shape","credits","declined","useAiMediaImageSize","orgId","firestore","data","org","status","aiMediaCreditEstimate","count","each","pictures","AiMediaCreateButton","props","entitled","upgrade","open","setOpen","button","startIcon","path","onClick","onClose","fullWidth","maxWidth","display","alignItems","canManageBilling","href","billingHref","AiMediaCreateDialog","hostId","library","folderId","onCreated","user","userRef","current","photos","imageSize","kindId","setKindId","find","entry","paletteSource","setPaletteSource","colors","setColors","prompt","setPrompt","aspectRatio","setAspectRatio","setCount","busy","setBusy","notice","setNotice","chooseKind","next","chosen","create","description","trim","response","method","headers","body","JSON","stringify","style","palette","source","payload","json","catch","ok","severity","text","String","error","ids","Array","isArray","mediaIds","missing","Number","filtered","failed","warning","spacing","pt","select","onChange","event","target","disabled","helperText","hint","slotProps","renderValue","MenuProps","paper","maxHeight","placeholder","slice","multiline","minRows","autoFocus","direction","exclusive","_event","aria-label","flexWrap","ratio","control","index","type","at","htmlInput","width","_value","from","_unused"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,EAAEC,oBAAoB,EAAEC,oBAAoB,QAAQ,eAAc;AAE9F,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AACvD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,eAAe,EAAEC,OAAO,QAAQ,iCAA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;sCAEnByD,MAAMwC,IAAI,CAAC;gCAAElI,QAAQ5B;4BAAmB,GAAG,CAAC+J,SAASP,QAAUA,QAAQ,GAAG3H,GAAG,CAAC,CAACZ,sBAC9E,KAACrC;oCAAqBqC,OAAOA;8CAC1BA;mCADYA;;sCAKnB,MAAClC;4BAAMkK,WAAU;4BAAMnB,SAAS;4BAAK3G,IAAI;gCAAE4C,YAAY;4BAAS;;8CAC9D,KAAC5E;oCAAWoC,SAAQ;oCAAQC,OAAM;8CAC/BqB,sBAAsBpB,MAAMqB,OAAO8B;;8CAEtC,KAACjH,sBAAYoE,cAAcM,OAAO;;;wBAEnCqD,qBACC,MAAC3G;4BAAM+I,SAAS;;8CACd,KAACrJ;8CACD,KAACU;oCAAWoC,SAAQ;oCAAQC,OAAM;8CAC/B;;;6BAGH;wBACHoE,uBAAS,KAAC3H;4BAAMgJ,UAAUrB,OAAOqB,QAAQ;sCAAGrB,OAAOsB,IAAI;6BAAY;;;;0BAGxE,MAAC9I;;kCACC,KAACF;wBAAOwF,SAASC;wBAASyE,UAAU1C;kCACjC;;kCAEH,KAACxH;wBAAOqD,SAAQ;wBAAYmC,SAAS,IAAM,KAAKuC;wBAAUmC,UAAU1C,QAAQ,CAACL,OAAOc,IAAI;kCACrFT,OAAO,cAAc;;;;;;AAKhC;AAEA,eAAezC,oBAAmB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-media-create.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\nimport { lockdownRefusalText, parseLockdownRefusal, resolveEffectivePlan } from '@aglyn/aglyn'\nimport type { ConsoleMediaLibraryZoneProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport { authorizedFetch } from '@aglyn/shared-util-http/authorized-token'\nimport { useFirestore, useFirestoreDoc, useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n FormControlLabel,\n IconButton,\n LinearProgress,\n ListItemText,\n ListSubheader,\n MenuItem,\n Radio,\n RadioGroup,\n Stack,\n TextField,\n ToggleButton,\n ToggleButtonGroup,\n Typography,\n} from '@mui/material'\nimport { doc } from 'firebase/firestore'\nimport { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'\nimport { aiMediaCreditsPerPicture } from '../model/ai-media-credits'\nimport {\n AI_MEDIA_KIND_GROUP_LABELS,\n AI_MEDIA_KIND_GROUPS,\n aiMediaKind,\n aiMediaKindsOffered,\n type AiMediaKind,\n type AiMediaKindId,\n} from '../model/ai-media-kinds'\nimport {\n AI_IMAGE_ASPECT_RATIOS,\n AI_IMAGE_MAX_COUNT,\n AI_IMAGE_PROMPT_MAX_CHARS,\n aiImageSizeForPlan,\n AI_SVG_MAX_COLORS,\n aiImagePhotosOffered,\n type AiImageAspectRatio,\n type AiImageMode,\n type AiImageSize,\n} from '../providers/image-contract'\n\n/**\n * \"Create with AI\" in Media (AGL-3602): pictures from a description, added to\n * the library that is open, through the `mediaLibrary` zone beside Upload\n * media and in the library's empty state.\n *\n * It draws from the shell's gates alone — the plan, the member's\n * `ai.generate`, the plugin being on for the workspace and the site — and asks\n * no server anything until someone creates a picture: the door decides then,\n * and the dialog says what it decided. One Kind menu, in sections: Vector\n * kinds (an SVG the text AI draws, wherever text AI runs) and, where the\n * deployment makes them, Photo, Art and Design kinds from the image provider.\n */\n\n/** Where the shell sends a reader to buy what the plan lacks (AGL-3601). */\nexport interface AiMediaUpgrade {\n billingHref: string\n canManageBilling: boolean\n}\n\nexport interface AiMediaCreateButtonProps extends ConsoleMediaLibraryZoneProps {\n /**\n * `false` when the shell mounted this as its own upsell: the plan lacks AI\n * generation and an add-on would grant it. Absent means entitled.\n */\n entitled?: boolean\n upgrade?: AiMediaUpgrade\n}\n\n/** The words each shape is offered in. */\nconst ASPECT_LABELS: Record<AiImageAspectRatio, string> = {\n '1:1': 'Square',\n '4:3': 'Landscape',\n '3:4': 'Portrait',\n '16:9': 'Wide',\n '9:16': 'Tall',\n}\n\n/**\n * What a picture from the image provider may be declined for, as the code\n * and the provider decide it: Google's filters, and its policies on real\n * people and brands. A declined picture is never charged.\n */\nexport const AI_MEDIA_RASTER_SAFETY_NOTE =\n 'Pictures of real, identifiable people, celebrities or brands may be declined by the image service. A declined picture is not charged.'\n\n/** The line under the description for a kind whose colors are described rather than picked. */\nexport const AI_MEDIA_DESCRIBE_COLORS_NOTE =\n 'To steer the colors, name them in the description, such as navy and coral.'\n\n/** The menu's items: each section's heading, then its kinds with what one costs. */\nfunction kindMenuItems(kinds: readonly AiMediaKind[], size: AiImageSize): ReactNode[] {\n const groups = AI_MEDIA_KIND_GROUPS.filter((group) => kinds.some((kind) => kind.group === group))\n const item = (kind: AiMediaKind) => (\n <MenuItem key={kind.id} value={kind.id} sx={{ gap: 2 }}>\n <ListItemText primary={kind.label} />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`about ${aiMediaCreditsPerPicture(kind.mode, undefined, size).toLocaleString()} credits`}\n </Typography>\n </MenuItem>\n )\n // One section needs no heading: a deployment without the image provider\n // lists the vector kinds alone, as it always has.\n if (groups.length < 2) return kinds.map(item)\n return groups.flatMap((group) => [\n <ListSubheader key={`group:${group}`}>{AI_MEDIA_KIND_GROUP_LABELS[group]}</ListSubheader>,\n ...kinds.filter((kind) => kind.group === group).map(item),\n ])\n}\n\n/**\n * The window's own help (AGL-3660): each control links the section of the\n * guide about it, not the guide's top.\n */\nconst AI_MEDIA_HELP = {\n dialog: pluginDocsHelp('aiImages', {\n anchor: '#make-a-picture',\n excerpt:\n 'Choose a kind, describe the picture, pick a shape and how many. The pictures land in the folder you have open, with alt text you can edit.',\n }),\n locked: pluginDocsHelp('aiImages', {\n anchor: '#who-can-use-it',\n excerpt:\n 'Creating pictures needs AI on your plan and the Generate with AI permission. A Free workspace creates them from its monthly credits.',\n }),\n shape: pluginDocsHelp('aiImages', {\n anchor: '#shapes-and-how-many',\n excerpt:\n 'Five shapes, from Square 1:1 to Tall 9:16, and one to four pictures per request. Each picture is charged on its own.',\n }),\n credits: pluginDocsHelp('aiImages', {\n anchor: '#credits',\n excerpt:\n 'The estimate is per picture times how many. You are charged only for pictures that reach your library; a declined or failed picture costs nothing.',\n }),\n declined: pluginDocsHelp('aiImages', {\n anchor: '#declined-pictures',\n excerpt:\n 'Google’s safety filters may decline real people, celebrities, brands and unsafe content. A declined picture is not charged.',\n }),\n}\n\n/**\n * The size the door will make a picture at for this workspace (AGL-3602):\n * 512 px on the Free plan, 1K on a paid one. The door decides from the plan\n * itself; this reads the same plan so the estimate matches, and reads 1K —\n * the dearer estimate — until the workspace has arrived.\n */\nexport function useAiMediaImageSize(orgId: string): AiImageSize {\n const firestore = useFirestore()\n const { data: org, status } = useFirestoreDoc<Record<string, unknown>>(\n () => doc(firestore, 'orgs', orgId),\n [firestore, orgId],\n )\n return aiImageSizeForPlan(status === 'success' && resolveEffectivePlan(org as never) === 'free')\n}\n\n/** The sentence the estimate reads as, before anything is spent. */\nexport function aiMediaCreditEstimate(\n mode: AiImageMode,\n count: number,\n size: AiImageSize = '1K',\n): string {\n const each = aiMediaCreditsPerPicture(mode, undefined, size)\n const pictures = count === 1 ? '1 picture' : `${count} pictures`\n return (\n `${pictures} uses about ${(count * each).toLocaleString()} AI credits ` +\n `(about ${each.toLocaleString()} each). A picture that is held back or does not come out is not charged.`\n )\n}\n\nexport function AiMediaCreateButton(props: AiMediaCreateButtonProps) {\n const { orgId, entitled, upgrade } = props\n const [open, setOpen] = useState(false)\n if (!orgId) return null\n const button = (\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {'Create with AI'}\n </Button>\n )\n if (entitled === false) {\n if (!upgrade) return null\n return (\n <>\n {button}\n <Dialog open={open} onClose={() => setOpen(false)} fullWidth maxWidth=\"xs\">\n <DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>\n {'Create images with AI'}\n <HelpTip {...AI_MEDIA_HELP.locked} />\n </DialogTitle>\n <DialogContent>\n <Typography>\n {upgrade.canManageBilling\n ? 'Creating pictures and illustrations comes with the AI add-on.'\n : 'Creating pictures and illustrations comes with the AI add-on. Ask a member holding \"Manage billing\" to add it.'}\n </Typography>\n </DialogContent>\n <DialogActions>\n <Button onClick={() => setOpen(false)}>{'Close'}</Button>\n {upgrade.canManageBilling ? (\n <Button variant=\"contained\" href={upgrade.billingHref}>\n {'See the AI add-on'}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n </>\n )\n }\n return (\n <>\n {button}\n <AiMediaCreateDialog {...props} orgId={orgId} open={open} onClose={() => setOpen(false)} />\n </>\n )\n}\n\nexport interface AiMediaCreateDialogProps\n extends Pick<ConsoleMediaLibraryZoneProps, 'hostId' | 'library' | 'folderId' | 'onCreated'> {\n open: boolean\n onClose: () => void\n orgId: string\n}\n\nexport function AiMediaCreateDialog({\n open,\n onClose,\n orgId,\n hostId,\n library,\n folderId,\n onCreated,\n}: AiMediaCreateDialogProps) {\n const { data: user } = useUser()\n const userRef = useRef(user)\n userRef.current = user\n const photos = aiImagePhotosOffered()\n const imageSize = useAiMediaImageSize(orgId)\n const kinds = useMemo(() => aiMediaKindsOffered(photos), [photos])\n const [kindId, setKindId] = useState<AiMediaKindId>(photos ? 'photo' : 'illustration')\n const kind = kinds.find((entry) => entry.id === kindId) ?? kinds[0]\n const mode = kind.mode\n // The site theme's colors need a site; the organization's library names none.\n const [paletteSource, setPaletteSource] = useState<'theme' | 'custom'>(hostId ? 'theme' : 'custom')\n const [colors, setColors] = useState<string[]>(['#1a73e8', '#fbbc04'])\n const [prompt, setPrompt] = useState('')\n const [aspectRatio, setAspectRatio] = useState<AiImageAspectRatio>(kind.aspectRatio)\n const [count, setCount] = useState(1)\n const [busy, setBusy] = useState(false)\n const [notice, setNotice] = useState<{ severity: 'error' | 'warning'; text: string } | null>(null)\n\n useEffect(() => {\n if (open) setNotice(null)\n }, [open])\n\n /** A new kind brings its own shape; the person may still change it. */\n const chooseKind = (next: AiMediaKindId) => {\n setKindId(next)\n const chosen = aiMediaKind(next)\n if (chosen) setAspectRatio(chosen.aspectRatio)\n }\n\n const create = useCallback(async () => {\n const description = prompt.trim()\n if (!description) return\n setBusy(true)\n setNotice(null)\n try {\n const response = await authorizedFetch(userRef.current, '/api/ai/media/images', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({\n orgId,\n library,\n hostId,\n folderId,\n mode,\n prompt: description,\n aspectRatio,\n count,\n style: kind.id,\n ...(kind.colors === 'palette'\n ? {\n palette:\n paletteSource === 'theme' ? { source: 'theme' } : { source: 'custom', colors },\n }\n : {}),\n }),\n })\n const payload = await response.json().catch(() => null)\n if (!response.ok) {\n const locked = parseLockdownRefusal(response.status, payload)\n setNotice({\n severity: 'error',\n text: locked\n ? lockdownRefusalText(locked)\n : String(payload?.error ?? 'The pictures could not be made — try again.'),\n })\n return\n }\n const ids: string[] = Array.isArray(payload?.mediaIds) ? payload.mediaIds : []\n onCreated(ids)\n const missing = Number(payload?.filtered ?? 0) + Number(payload?.failed ?? 0)\n if (missing > 0) {\n setNotice({\n severity: 'warning',\n text:\n `Added ${ids.length} of ${count} to the library. ` +\n (payload?.warning\n ? String(payload.warning)\n : 'The rest were held back and were not charged.'),\n })\n return\n }\n setPrompt('')\n onClose()\n } catch {\n setNotice({ severity: 'error', text: 'The pictures could not be made — try again.' })\n } finally {\n setBusy(false)\n }\n }, [prompt, orgId, library, hostId, folderId, mode, aspectRatio, count, kind, paletteSource, colors, onCreated, onClose])\n\n return (\n <Dialog open={open} onClose={busy ? undefined : onClose} fullWidth maxWidth=\"sm\">\n <DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>\n {'Create images with AI'}\n <HelpTip {...AI_MEDIA_HELP.dialog} />\n </DialogTitle>\n <DialogContent>\n <Stack spacing={2} sx={{ pt: 1 }}>\n <TextField\n select\n size=\"small\"\n label=\"Kind\"\n value={kind.id}\n onChange={(event) => chooseKind(event.target.value as AiMediaKindId)}\n disabled={busy}\n fullWidth\n helperText={kind.hint}\n slotProps={{\n select: {\n renderValue: (value) => aiMediaKind(String(value))?.label ?? String(value),\n MenuProps: { slotProps: { paper: { sx: { maxHeight: 420 } } } },\n },\n }}\n >\n {kindMenuItems(kinds, imageSize)}\n </TextField>\n <TextField\n label={mode === 'photo' ? 'Describe the picture' : 'Describe what to draw'}\n placeholder={kind.placeholder}\n value={prompt}\n onChange={(event) => setPrompt(event.target.value.slice(0, AI_IMAGE_PROMPT_MAX_CHARS))}\n multiline\n minRows={3}\n autoFocus\n disabled={busy}\n helperText={\n kind.colors === 'describe'\n ? `${AI_MEDIA_DESCRIBE_COLORS_NOTE} The description becomes each picture's alt text, which you can edit.`\n : \"The description becomes each picture's alt text, which you can edit.\"\n }\n />\n {mode === 'photo' ? (\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {AI_MEDIA_RASTER_SAFETY_NOTE}\n </Typography>\n <HelpTip {...AI_MEDIA_HELP.declined} />\n </Stack>\n ) : null}\n <Stack spacing={0.5}>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Shape'}\n </Typography>\n <HelpTip {...AI_MEDIA_HELP.shape} />\n </Stack>\n <ToggleButtonGroup\n size=\"small\"\n exclusive\n value={aspectRatio}\n onChange={(_event, next) => {\n if (next) setAspectRatio(next)\n }}\n aria-label=\"Shape\"\n disabled={busy}\n sx={{ flexWrap: 'wrap' }}\n >\n {AI_IMAGE_ASPECT_RATIOS.map((ratio) => (\n <ToggleButton key={ratio} value={ratio} aria-label={`${ASPECT_LABELS[ratio]} ${ratio}`}>\n {`${ASPECT_LABELS[ratio]} ${ratio}`}\n </ToggleButton>\n ))}\n </ToggleButtonGroup>\n </Stack>\n {kind.colors === 'palette' ? (\n <Stack spacing={1}>\n <RadioGroup\n value={paletteSource}\n onChange={(event) => setPaletteSource(event.target.value as 'theme' | 'custom')}\n aria-label=\"Colors\"\n >\n <FormControlLabel\n value=\"theme\"\n control={<Radio size=\"small\" />}\n label=\"Use my site's theme colors\"\n disabled={busy || !hostId}\n />\n <FormControlLabel\n value=\"custom\"\n control={<Radio size=\"small\" />}\n label=\"Choose colors\"\n disabled={busy}\n />\n </RadioGroup>\n {paletteSource === 'custom' ? (\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap' }}>\n {colors.map((color, index) => (\n <Stack key={index} direction=\"row\" sx={{ alignItems: 'center' }}>\n <TextField\n type=\"color\"\n size=\"small\"\n value={color}\n onChange={(event) =>\n setColors((current) =>\n current.map((value, at) => (at === index ? event.target.value : value)),\n )\n }\n disabled={busy}\n slotProps={{ htmlInput: { 'aria-label': `Color ${index + 1}` } }}\n sx={{ width: 64 }}\n />\n {colors.length > 1 ? (\n <IconButton\n size=\"small\"\n aria-label={`Remove color ${index + 1}`}\n onClick={() => setColors((current) => current.filter((_value, at) => at !== index))}\n disabled={busy}\n >\n {'×'}\n </IconButton>\n ) : null}\n </Stack>\n ))}\n {colors.length < AI_SVG_MAX_COLORS ? (\n <Button size=\"small\" onClick={() => setColors((current) => [...current, '#333333'])} disabled={busy}>\n {'Add a color'}\n </Button>\n ) : null}\n </Stack>\n ) : null}\n </Stack>\n ) : null}\n <TextField\n select\n size=\"small\"\n label=\"How many\"\n value={count}\n onChange={(event) => setCount(Number(event.target.value))}\n disabled={busy}\n sx={{ maxWidth: 160 }}\n >\n {Array.from({ length: AI_IMAGE_MAX_COUNT }, (_unused, index) => index + 1).map((value) => (\n <MenuItem key={value} value={value}>\n {value}\n </MenuItem>\n ))}\n </TextField>\n <Stack direction=\"row\" spacing={0.5} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {aiMediaCreditEstimate(mode, count, imageSize)}\n </Typography>\n <HelpTip {...AI_MEDIA_HELP.credits} />\n </Stack>\n {busy ? (\n <Stack spacing={1}>\n <LinearProgress />\n <Typography variant=\"body2\" color=\"text.secondary\">\n {'Making your pictures and adding them to the library…'}\n </Typography>\n </Stack>\n ) : null}\n {notice ? <Alert severity={notice.severity}>{notice.text}</Alert> : null}\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={busy}>\n {'Close'}\n </Button>\n <Button variant=\"contained\" onClick={() => void create()} disabled={busy || !prompt.trim()}>\n {busy ? 'Creating…' : 'Create'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\n\nexport default AiMediaCreateButton\n"],"names":["lockdownRefusalText","parseLockdownRefusal","resolveEffectivePlan","mdiCreation","pluginDocsHelp","HelpTip","MdiIcon","authorizedFetch","useFirestore","useFirestoreDoc","useUser","Alert","Button","Dialog","DialogActions","DialogContent","DialogTitle","FormControlLabel","IconButton","LinearProgress","ListItemText","ListSubheader","MenuItem","Radio","RadioGroup","Stack","TextField","ToggleButton","ToggleButtonGroup","Typography","doc","useCallback","useEffect","useMemo","useRef","useState","aiMediaCreditsPerPicture","AI_MEDIA_KIND_GROUP_LABELS","AI_MEDIA_KIND_GROUPS","aiMediaKind","aiMediaKindsOffered","AI_IMAGE_ASPECT_RATIOS","AI_IMAGE_MAX_COUNT","AI_IMAGE_PROMPT_MAX_CHARS","aiImageSizeForPlan","AI_SVG_MAX_COLORS","aiImagePhotosOffered","ASPECT_LABELS","AI_MEDIA_RASTER_SAFETY_NOTE","AI_MEDIA_DESCRIBE_COLORS_NOTE","kindMenuItems","kinds","size","groups","filter","group","some","kind","item","value","id","sx","gap","primary","label","variant","color","mode","undefined","toLocaleString","length","map","flatMap","AI_MEDIA_HELP","dialog","anchor","excerpt","locked","shape","credits","declined","useAiMediaImageSize","orgId","firestore","data","org","status","aiMediaCreditEstimate","count","each","pictures","AiMediaCreateButton","props","entitled","upgrade","open","setOpen","button","startIcon","path","onClick","onClose","fullWidth","maxWidth","display","alignItems","canManageBilling","href","billingHref","AiMediaCreateDialog","hostId","library","folderId","onCreated","user","userRef","current","photos","imageSize","kindId","setKindId","find","entry","paletteSource","setPaletteSource","colors","setColors","prompt","setPrompt","aspectRatio","setAspectRatio","setCount","busy","setBusy","notice","setNotice","chooseKind","next","chosen","create","description","trim","response","method","headers","body","JSON","stringify","style","palette","source","payload","json","catch","ok","severity","text","String","error","ids","Array","isArray","mediaIds","missing","Number","filtered","failed","warning","spacing","pt","select","onChange","event","target","disabled","helperText","hint","slotProps","renderValue","MenuProps","paper","maxHeight","placeholder","slice","multiline","minRows","autoFocus","direction","exclusive","_event","aria-label","flexWrap","ratio","control","index","type","at","htmlInput","width","_value","from","_unused"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,mBAAmB,EAAEC,oBAAoB,EAAEC,oBAAoB,QAAQ,eAAc;AAE9F,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,cAAc,QAAQ,mCAAkC;AACjE,SAASC,OAAO,EAAEC,OAAO,QAAQ,uBAAsB;AACvD,SAASC,eAAe,QAAQ,2CAA0C;AAC1E,SAASC,YAAY,EAAEC,eAAe,EAAEC,OAAO,QAAQ,iCAAgC;AACvF,SACEC,KAAK,EACLC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,gBAAgB,EAChBC,UAAU,EACVC,cAAc,EACdC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E,KAACrC;oCAAqBqC,OAAOA;8CAC1BA;mCADYA;;sCAKnB,MAAClC;4BAAMkK,WAAU;4BAAMnB,SAAS;4BAAK3G,IAAI;gCAAE4C,YAAY;4BAAS;;8CAC9D,KAAC5E;oCAAWoC,SAAQ;oCAAQC,OAAM;8CAC/BqB,sBAAsBpB,MAAMqB,OAAO8B;;8CAEtC,KAACjH,sBAAYoE,cAAcM,OAAO;;;wBAEnCqD,qBACC,MAAC3G;4BAAM+I,SAAS;;8CACd,KAACrJ;8CACD,KAACU;oCAAWoC,SAAQ;oCAAQC,OAAM;8CAC/B;;;6BAGH;wBACHoE,uBAAS,KAAC3H;4BAAMgJ,UAAUrB,OAAOqB,QAAQ;sCAAGrB,OAAOsB,IAAI;6BAAY;;;;0BAGxE,MAAC9I;;kCACC,KAACF;wBAAOwF,SAASC;wBAASyE,UAAU1C;kCACjC;;kCAEH,KAACxH;wBAAOqD,SAAQ;wBAAYmC,SAAS,IAAM,KAAKuC;wBAAUmC,UAAU1C,QAAQ,CAACL,OAAOc,IAAI;kCACrFT,OAAO,cAAc;;;;;;AAKhC;AAEA,eAAezC,oBAAmB"}
|
|
@@ -37,7 +37,7 @@ import { AI_UPSELL_COPY, AI_UPSELL_CREATE_LABEL, aiUpsellLabel, aiUpsellOffer }
|
|
|
37
37
|
export { AI_UPSELL_COPY, AI_UPSELL_CREATE_LABEL, aiUpsellLabel, aiUpsellOffer };
|
|
38
38
|
/** The add-on's own section of the Create with AI guide (AGL-3660). */ const aiUpsellHelp = ()=>pluginDocsHelp('aiCreate', {
|
|
39
39
|
anchor: '#without-the-add-on',
|
|
40
|
-
excerpt: `On every paid plan, Create with AI runs on the AI credits the plan includes. Where it is switched off for a workspace, ${aiAddonName()} credits switch it on;
|
|
40
|
+
excerpt: `On every paid plan, Create with AI runs on the AI credits the plan includes. Where it is switched off for a workspace, ${aiAddonName()} credits switch it on; a member holding Manage billing adds them in Billing.`
|
|
41
41
|
});
|
|
42
42
|
export function AiUpsellDialog({ kind, open, onClose, upgrade }) {
|
|
43
43
|
const copy = AI_UPSELL_COPY[kind];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-upsell-dialog.component.tsx"],"sourcesContent":["'use client'\n\n/**\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 { aiAddonName } from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport type { ConsoleWidgetUpgrade } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState, type ReactNode } from 'react'\nimport {\n AI_UPSELL_COPY,\n AI_UPSELL_CREATE_LABEL,\n aiUpsellLabel,\n aiUpsellOffer,\n type AiUpsellKind,\n} from '../model/ai-upsell-copy'\n\n/**\n * \"Create with AI\" where generation is switched off for a workspace that\n * could buy Aglyn AI credits (AGL-3601, AGL-4144). Since AGL-3965 every paid\n * plan's own credits pay for generation, so this is reached only where a\n * per-org setting closed it. The shell mounts the entry with\n * `entitled={false}` only where credit blocks are sold to this workspace, and the\n * jobs route has said that is the one thing missing; the entry then keeps its\n * place on the page and opens this instead of the brief.\n */\n\n// The entries' words are the model's, which the native apps' door reads too\n// (AGL-3854); re-exported for this dialog's existing readers.\nexport { AI_UPSELL_COPY, AI_UPSELL_CREATE_LABEL, aiUpsellLabel, aiUpsellOffer }\nexport type { AiUpsellCopy, AiUpsellKind } from '../model/ai-upsell-copy'\n\nexport interface AiUpsellDialogProps {\n kind: AiUpsellKind\n open: boolean\n onClose: () => void\n upgrade: ConsoleWidgetUpgrade\n}\n\n/** The add-on's own section of the Create with AI guide (AGL-3660). */\nconst aiUpsellHelp = () =>\n pluginDocsHelp('aiCreate', {\n anchor: '#without-the-add-on',\n excerpt: `On every paid plan, Create with AI runs on the AI credits the plan includes. Where it is switched off for a workspace, ${aiAddonName()} credits switch it on;
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-upsell-dialog.component.tsx"],"sourcesContent":["'use client'\n\n/**\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 { aiAddonName } from '@aglyn/aglyn'\nimport { trackEvent } from '@aglyn/aglyn/app-utils/analytics-events'\nimport type { ConsoleWidgetUpgrade } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { mdiCreation } from '@aglyn/shared-data-mdi'\nimport { pluginDocsHelp } from '@aglyn/aglyn/app-utils/docs-help'\nimport { HelpTip, MdiIcon } from '@aglyn/shared-ui-jsx'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useEffect, useState, type ReactNode } from 'react'\nimport {\n AI_UPSELL_COPY,\n AI_UPSELL_CREATE_LABEL,\n aiUpsellLabel,\n aiUpsellOffer,\n type AiUpsellKind,\n} from '../model/ai-upsell-copy'\n\n/**\n * \"Create with AI\" where generation is switched off for a workspace that\n * could buy Aglyn AI credits (AGL-3601, AGL-4144). Since AGL-3965 every paid\n * plan's own credits pay for generation, so this is reached only where a\n * per-org setting closed it. The shell mounts the entry with\n * `entitled={false}` only where credit blocks are sold to this workspace, and the\n * jobs route has said that is the one thing missing; the entry then keeps its\n * place on the page and opens this instead of the brief.\n */\n\n// The entries' words are the model's, which the native apps' door reads too\n// (AGL-3854); re-exported for this dialog's existing readers.\nexport { AI_UPSELL_COPY, AI_UPSELL_CREATE_LABEL, aiUpsellLabel, aiUpsellOffer }\nexport type { AiUpsellCopy, AiUpsellKind } from '../model/ai-upsell-copy'\n\nexport interface AiUpsellDialogProps {\n kind: AiUpsellKind\n open: boolean\n onClose: () => void\n upgrade: ConsoleWidgetUpgrade\n}\n\n/** The add-on's own section of the Create with AI guide (AGL-3660). */\nconst aiUpsellHelp = () =>\n pluginDocsHelp('aiCreate', {\n anchor: '#without-the-add-on',\n excerpt: `On every paid plan, Create with AI runs on the AI credits the plan includes. Where it is switched off for a workspace, ${aiAddonName()} credits switch it on; a member holding Manage billing adds them in Billing.`,\n })\n\nexport function AiUpsellDialog({ kind, open, onClose, upgrade }: AiUpsellDialogProps) {\n const copy = AI_UPSELL_COPY[kind]\n const { canManageBilling, billingHref } = upgrade\n\n // Counted once per opening: the denominator the click is a rate against.\n useEffect(() => {\n if (open) trackEvent('ai_upsell_shown', { kind, can_manage: canManageBilling })\n }, [open, kind, canManageBilling])\n\n return (\n <Dialog open={open} onClose={onClose} fullWidth maxWidth=\"xs\">\n <DialogTitle sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>\n {copy.title}\n <HelpTip {...aiUpsellHelp()} />\n </DialogTitle>\n <DialogContent>\n <Stack spacing={2}>\n <Typography variant=\"body2\">{copy.does}</Typography>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {aiUpsellOffer(canManageBilling, kind === 'insight' ? copy.title : AI_UPSELL_CREATE_LABEL)}\n </Typography>\n </Stack>\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose}>{canManageBilling ? 'Not now' : 'Close'}</Button>\n {canManageBilling ? (\n <Button\n variant=\"contained\"\n href={billingHref}\n onClick={() => trackEvent('ai_upsell_clicked', { kind })}\n >\n {`Add ${aiAddonName()}`}\n </Button>\n ) : null}\n </DialogActions>\n </Dialog>\n )\n}\n\n/**\n * The entry itself on a plan without the add-on: the same button, label and\n * icon as the entitled entry, opening {@link AiUpsellDialog}. Every entry that\n * draws it renders from the shell's client-side gates alone and asks the\n * server nothing until it is used (AGL-3601).\n */\nexport function AiUpsellButton({\n kind,\n upgrade,\n label,\n}: {\n kind: AiUpsellKind\n upgrade: ConsoleWidgetUpgrade\n /** The entitled entry's own label, when it is not the kind's. */\n label?: string\n}): ReactNode {\n const [open, setOpen] = useState(false)\n return (\n <>\n <Button\n size=\"small\"\n variant=\"outlined\"\n startIcon={<MdiIcon path={mdiCreation.path} />}\n onClick={() => setOpen(true)}\n >\n {label ?? aiUpsellLabel(kind)}\n </Button>\n <AiUpsellDialog kind={kind} open={open} onClose={() => setOpen(false)} upgrade={upgrade} />\n </>\n )\n}\n"],"names":["aiAddonName","trackEvent","mdiCreation","pluginDocsHelp","HelpTip","MdiIcon","Button","Dialog","DialogActions","DialogContent","DialogTitle","Stack","Typography","useEffect","useState","AI_UPSELL_COPY","AI_UPSELL_CREATE_LABEL","aiUpsellLabel","aiUpsellOffer","aiUpsellHelp","anchor","excerpt","AiUpsellDialog","kind","open","onClose","upgrade","copy","canManageBilling","billingHref","can_manage","fullWidth","maxWidth","sx","display","alignItems","gap","title","spacing","variant","does","color","onClick","href","AiUpsellButton","label","setOpen","size","startIcon","path"],"mappings":"AAAA;;;AAEA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,WAAW,QAAQ,eAAc;AAC1C,SAASC,UAAU,QAAQ,0CAAyC;AAEpE,SAASC,WAAW,QAAQ,yBAAwB;AACpD,SAASC,cAAc,QAA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YI,KAAKU,KAAK,GAAGrB;;;;;0BAIzE,MAACR;;kCACC,KAACF;wBAAOoC,SAASjB;kCAAUG,mBAAmB,YAAY;;oBACzDA,iCACC,KAACtB;wBACCiC,SAAQ;wBACRI,MAAMd;wBACNa,SAAS,IAAMzC,WAAW,qBAAqB;gCAAEsB;4BAAK;kCAErD,CAAC,IAAI,EAAEvB,eAAe;yBAEvB;;;;;AAIZ;AAEA;;;;;CAKC,GACD,OAAO,SAAS4C,eAAe,EAC7BrB,IAAI,EACJG,OAAO,EACPmB,KAAK,EAMN;IACC,MAAM,CAACrB,MAAMsB,QAAQ,GAAGhC,SAAS;IACjC,qBACE;;0BACE,KAACR;gBACCyC,MAAK;gBACLR,SAAQ;gBACRS,yBAAW,KAAC3C;oBAAQ4C,MAAM/C,YAAY+C,IAAI;;gBAC1CP,SAAS,IAAMI,QAAQ;0BAEtBD,gBAAAA,QAAS5B,cAAcM;;0BAE1B,KAACD;gBAAeC,MAAMA;gBAAMC,MAAMA;gBAAMC,SAAS,IAAMqB,QAAQ;gBAAQpB,SAASA;;;;AAGtF"}
|
|
@@ -632,7 +632,7 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
632
632
|
});
|
|
633
633
|
}
|
|
634
634
|
/** What the home page says of the site as a whole (AGL-4084), kept for the look, the header and footer and the listing. */ export function aiSiteImportHomeOf(crawled) {
|
|
635
|
-
var _crawled_pages_find, _page_title, _page_description, _page_ogImage, _ref, _page_icons, _page_icons1;
|
|
635
|
+
var _crawled_pages_find, _page_images, _page_title, _page_description, _page_ogImage, _ref, _page_icons, _page_icons1;
|
|
636
636
|
var _facts_organization;
|
|
637
637
|
const page = (_crawled_pages_find = crawled.pages.find((entry)=>entry.foundBy === 'home')) != null ? _crawled_pages_find : crawled.pages.find((entry)=>(entry.path.replace(/\/+$/, '') || '/') === '/');
|
|
638
638
|
if (!page) return null;
|
|
@@ -661,6 +661,11 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
661
661
|
const text = (line != null ? line : '').replace(/\s+/g, ' ').trim();
|
|
662
662
|
if (text && !lines.some((entry)=>entry.includes(text))) lines.push(text);
|
|
663
663
|
}
|
|
664
|
+
// The picture its opening shows, for a look with no color of its own (AGL-4152).
|
|
665
|
+
const hero = ((_page_images = page.images) != null ? _page_images : []).find((image)=>{
|
|
666
|
+
var _brand_logo;
|
|
667
|
+
return image.region === 'main' && image.url !== ((_brand_logo = brand.logo) == null ? void 0 : _brand_logo.url);
|
|
668
|
+
});
|
|
664
669
|
return _extends({
|
|
665
670
|
url: page.url,
|
|
666
671
|
title: siteImportLabel((_page_title = page.title) != null ? _page_title : '', 160),
|
|
@@ -689,6 +694,11 @@ const delivered = (items, slot)=>items.some((row)=>row.slot === slot && (row.sta
|
|
|
689
694
|
footer: page.footer
|
|
690
695
|
} : {}, page.look ? {
|
|
691
696
|
look: page.look
|
|
697
|
+
} : {}, hero ? {
|
|
698
|
+
hero: {
|
|
699
|
+
url: hero.url,
|
|
700
|
+
alt: siteImportLabel(hero.alt, 250)
|
|
701
|
+
}
|
|
692
702
|
} : {}, aiSiteImportFaviconOf((_page_icons = page.icons) != null ? _page_icons : []) ? {
|
|
693
703
|
favicon: aiSiteImportFaviconOf((_page_icons1 = page.icons) != null ? _page_icons1 : [])
|
|
694
704
|
} : {});
|