ima2-gen 3.8.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/bin/commands/video.js +8 -4
  2. package/bin/lib/videoMcp.js +13 -7
  3. package/package.json +2 -2
  4. package/ui/dist/.vite/manifest.json +31 -31
  5. package/ui/dist/assets/{AgentWorkspace-DAjUdAsK.js → AgentWorkspace-bUd5NsQ_.js} +1 -1
  6. package/ui/dist/assets/{AssetGenWorkspace-CpAkJhms.js → AssetGenWorkspace-8fK-K64E.js} +2 -2
  7. package/ui/dist/assets/{AssetsWorkspace-Bh1OzpUk.js → AssetsWorkspace-DO_wfFQB.js} +1 -1
  8. package/ui/dist/assets/{CardNewsWorkspace-DSqExDy-.js → CardNewsWorkspace-D3M0w8pg.js} +1 -1
  9. package/ui/dist/assets/{GenerationRequestLogPanel-B9n86Nqn.js → GenerationRequestLogPanel-WvSV0yXP.js} +1 -1
  10. package/ui/dist/assets/{HomeWorkspace-Dr0j6d1O.js → HomeWorkspace-BGCBf9iK.js} +1 -1
  11. package/ui/dist/assets/{KeyingPanel-2-wMdwa8.js → KeyingPanel-CEBLIhhu.js} +1 -1
  12. package/ui/dist/assets/{NodeCanvas-DS3-x-hx.js → NodeCanvas-DwbR2nol.js} +1 -1
  13. package/ui/dist/assets/{PromptBuilderPanel-CvXqQl0o.js → PromptBuilderPanel-KSH3ChjC.js} +1 -1
  14. package/ui/dist/assets/{PromptImportDialog-CBw_qPiD.js → PromptImportDialog-CjHiCEo9.js} +2 -2
  15. package/ui/dist/assets/{PromptImportDiscoverySection-B1BY5Ntk.js → PromptImportDiscoverySection-CWU-vKyM.js} +1 -1
  16. package/ui/dist/assets/{PromptImportFolderSection-CPwnX0PB.js → PromptImportFolderSection-_zRnJGkJ.js} +1 -1
  17. package/ui/dist/assets/{PromptLibraryPanel-kXL1oFA8.js → PromptLibraryPanel-64VN4nml.js} +2 -2
  18. package/ui/dist/assets/{SettingsWorkspace-Cf7rRTV3.js → SettingsWorkspace-DZMNEpuq.js} +1 -1
  19. package/ui/dist/assets/{SpriteRecipeWorkspace-_WcHPSd4.js → SpriteRecipeWorkspace-Y6GqpVHs.js} +1 -1
  20. package/ui/dist/assets/{index-BTHxkxxS.js → index-CFixfKaC.js} +3 -3
  21. package/ui/dist/assets/index-XXtoj9ME.js +30 -0
  22. package/ui/dist/assets/{pptxgen.es-BOlreaat.js → pptxgen.es-hCJot2gG.js} +1 -1
  23. package/ui/dist/assets/{useAgentDialogFocus-CxsC04Sp.js → useAgentDialogFocus-PWmMjerz.js} +1 -1
  24. package/ui/dist/index.html +1 -1
  25. package/ui/dist/assets/index-BKW7WOYj.js +0 -30
@@ -79,6 +79,7 @@ const SPEC = {
79
79
  end: { type: "string" },
80
80
  ref: { type: "string", repeatable: true },
81
81
  voice: { type: "string", repeatable: true },
82
+ "as-reference": { type: "boolean" },
82
83
  "video-ref": { type: "string" },
83
84
  character: { type: "string" },
84
85
  out: { short: "o", type: "string" },
@@ -125,6 +126,8 @@ const HELP = `
125
126
  --voice <voice-id> Preset voice for the subject (grok-imagine-video-1.5,
126
127
  repeatable, max 3). e.g. eve, leo, rex, luna, atlas.
127
128
  An unknown id returns the full list of valid voices
129
+ --as-reference With exactly one --ref, guide a new scene instead of
130
+ animating that image. Ignored for 0 or 2+ refs
128
131
  Repeatable: Grok max 7, MCP max 3
129
132
  --video-ref <generated-filename> MCP V2V/restyle reference video
130
133
  --character <element-id|name> MCP lanes only: character binding element
@@ -139,10 +142,11 @@ const HELP = `
139
142
  --video <value> HTTPS URL, xAI file_id, data URL, or generated filename
140
143
  --duration <2..10> Extension duration only. Default: 6
141
144
 
142
- Grok modes (auto-detected from --ref count):
143
- 0 refs → text-to-video
144
- 1-7 refs reference-to-video (max 720p). References guide the subject without
145
- locking the first frame; use a node/continuity chain for a first frame.
145
+ Grok modes (from --ref count, and --as-reference when there is exactly one):
146
+ 0 refs → text-to-video
147
+ 1 ref image-to-video (that image is the opening frame)
148
+ 1 ref + --as-reference → reference-to-video (guides a new scene instead)
149
+ 2-7 refs → reference-to-video (max 720p)
146
150
 
147
151
  Examples:
148
152
  ima2 video "a cat playing piano"
@@ -94,9 +94,12 @@ function validateCoreOptions(args, refs, model) {
94
94
  die(2, "--aspect-ratio must be one of: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, auto");
95
95
  if (refs.length > 7)
96
96
  die(2, "max 7 --ref attachments for video");
97
- // `--ref` always fills the reference slot now, so any attachment means
98
- // reference-to-video the same conclusion the server reaches from the slot.
99
- const mode = refs.length > 0 ? "reference-to-video" : "text-to-video";
97
+ const asReference = Boolean(args["as-reference"]);
98
+ const mode = refs.length === 0
99
+ ? "text-to-video"
100
+ : refs.length === 1 && !asReference
101
+ ? "image-to-video"
102
+ : "reference-to-video";
100
103
  const check = validateVideoResolutionForRequest(model, resolution, mode, { allowTextCanvasShim: true });
101
104
  if (!("ok" in check))
102
105
  die(2, check.error);
@@ -135,10 +138,13 @@ function coreBody(args, context, options, references, requestId) {
135
138
  const voices = (Array.isArray(args.voice) ? args.voice : args.voice ? [args.voice] : []);
136
139
  if (voices.length > 0)
137
140
  body.referenceAudios = voices.map((v) => String(v));
138
- // `--ref` is the reference slot at any count; one reference guides the video without
139
- // locking the first frame. Mapping a single --ref to sourceImage made the CLI disagree
140
- // with the server contract and with the UI.
141
- if (references.length > 0)
141
+ // One `--ref` animates that image by default; `--as-reference` says to treat it as a
142
+ // guide for a new scene instead. Two or more can only be guides. This mirrors the app,
143
+ // where the same choice appears whenever exactly one reference is attached.
144
+ const asReference = Boolean(args["as-reference"]);
145
+ if (references.length === 1 && !asReference)
146
+ body.sourceImage = references[0];
147
+ else if (references.length > 0)
142
148
  body.referenceImages = references;
143
149
  return body;
144
150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ima2-gen",
3
- "version": "3.8.0",
3
+ "version": "3.8.1",
4
4
  "packageManager": "npm@11.18.0",
5
5
  "description": "Local-first visual generation runtime and studio for people and coding agents, with reproducible image and video workflows across multiple providers.",
6
6
  "type": "module",
@@ -119,5 +119,5 @@
119
119
  "tsx": "^4.23.12",
120
120
  "typescript": "^5.9.3"
121
121
  },
122
- "gitHead": "780f6da658d0ae69b5c5a22d946c4742c32a4b9b"
122
+ "gitHead": "04154ba017a080045bc12fdc37b8945dbcfd75b6"
123
123
  }
@@ -1,11 +1,11 @@
1
1
  {
2
- "_AssetGenWorkspace-CpAkJhms.js": {
3
- "file": "assets/AssetGenWorkspace-CpAkJhms.js",
2
+ "_AssetGenWorkspace-8fK-K64E.js": {
3
+ "file": "assets/AssetGenWorkspace-8fK-K64E.js",
4
4
  "name": "AssetGenWorkspace",
5
5
  "isDynamicEntry": true,
6
6
  "imports": [
7
7
  "index.html",
8
- "_KeyingPanel-2-wMdwa8.js"
8
+ "_KeyingPanel-CEBLIhhu.js"
9
9
  ],
10
10
  "dynamicImports": [
11
11
  "src/components/assetgen/SpriteRecipeWorkspace.tsx"
@@ -18,12 +18,12 @@
18
18
  "file": "assets/AssetGenWorkspace-Dkr80l12.css",
19
19
  "src": "_AssetGenWorkspace-Dkr80l12.css"
20
20
  },
21
- "_KeyingPanel-2-wMdwa8.js": {
22
- "file": "assets/KeyingPanel-2-wMdwa8.js",
21
+ "_KeyingPanel-CEBLIhhu.js": {
22
+ "file": "assets/KeyingPanel-CEBLIhhu.js",
23
23
  "name": "KeyingPanel",
24
24
  "imports": [
25
25
  "index.html",
26
- "_useAgentDialogFocus-CxsC04Sp.js"
26
+ "_useAgentDialogFocus-PWmMjerz.js"
27
27
  ]
28
28
  },
29
29
  "__vite-browser-external": {
@@ -32,15 +32,15 @@
32
32
  "src": "__vite-browser-external",
33
33
  "isDynamicEntry": true
34
34
  },
35
- "_useAgentDialogFocus-CxsC04Sp.js": {
36
- "file": "assets/useAgentDialogFocus-CxsC04Sp.js",
35
+ "_useAgentDialogFocus-PWmMjerz.js": {
36
+ "file": "assets/useAgentDialogFocus-PWmMjerz.js",
37
37
  "name": "useAgentDialogFocus",
38
38
  "imports": [
39
39
  "index.html"
40
40
  ]
41
41
  },
42
42
  "index.html": {
43
- "file": "assets/index-BKW7WOYj.js",
43
+ "file": "assets/index-XXtoj9ME.js",
44
44
  "name": "index",
45
45
  "src": "index.html",
46
46
  "isEntry": true,
@@ -55,7 +55,7 @@
55
55
  "src/components/card-news/CardNewsWorkspace.tsx",
56
56
  "src/components/agent/AgentWorkspace.tsx",
57
57
  "src/components/assets/AssetsWorkspace.tsx",
58
- "_AssetGenWorkspace-CpAkJhms.js",
58
+ "_AssetGenWorkspace-8fK-K64E.js",
59
59
  "src/components/home/HomeWorkspace.tsx",
60
60
  "src/components/PromptLibraryPanel.tsx"
61
61
  ],
@@ -64,7 +64,7 @@
64
64
  ]
65
65
  },
66
66
  "node_modules/pptxgenjs/dist/pptxgen.es.js": {
67
- "file": "assets/pptxgen.es-BOlreaat.js",
67
+ "file": "assets/pptxgen.es-hCJot2gG.js",
68
68
  "name": "pptxgen.es",
69
69
  "src": "node_modules/pptxgenjs/dist/pptxgen.es.js",
70
70
  "isDynamicEntry": true,
@@ -78,7 +78,7 @@
78
78
  ]
79
79
  },
80
80
  "src/components/GenerationRequestLogPanel.tsx": {
81
- "file": "assets/GenerationRequestLogPanel-B9n86Nqn.js",
81
+ "file": "assets/GenerationRequestLogPanel-WvSV0yXP.js",
82
82
  "name": "GenerationRequestLogPanel",
83
83
  "src": "src/components/GenerationRequestLogPanel.tsx",
84
84
  "isDynamicEntry": true,
@@ -87,7 +87,7 @@
87
87
  ]
88
88
  },
89
89
  "src/components/NodeCanvas.tsx": {
90
- "file": "assets/NodeCanvas-DS3-x-hx.js",
90
+ "file": "assets/NodeCanvas-DwbR2nol.js",
91
91
  "name": "NodeCanvas",
92
92
  "src": "src/components/NodeCanvas.tsx",
93
93
  "isDynamicEntry": true,
@@ -99,7 +99,7 @@
99
99
  ]
100
100
  },
101
101
  "src/components/PromptImportDialog.tsx": {
102
- "file": "assets/PromptImportDialog-CBw_qPiD.js",
102
+ "file": "assets/PromptImportDialog-CjHiCEo9.js",
103
103
  "name": "PromptImportDialog",
104
104
  "src": "src/components/PromptImportDialog.tsx",
105
105
  "isDynamicEntry": true,
@@ -112,7 +112,7 @@
112
112
  ]
113
113
  },
114
114
  "src/components/PromptImportDiscoverySection.tsx": {
115
- "file": "assets/PromptImportDiscoverySection-B1BY5Ntk.js",
115
+ "file": "assets/PromptImportDiscoverySection-CWU-vKyM.js",
116
116
  "name": "PromptImportDiscoverySection",
117
117
  "src": "src/components/PromptImportDiscoverySection.tsx",
118
118
  "isDynamicEntry": true,
@@ -121,7 +121,7 @@
121
121
  ]
122
122
  },
123
123
  "src/components/PromptImportFolderSection.tsx": {
124
- "file": "assets/PromptImportFolderSection-CPwnX0PB.js",
124
+ "file": "assets/PromptImportFolderSection-_zRnJGkJ.js",
125
125
  "name": "PromptImportFolderSection",
126
126
  "src": "src/components/PromptImportFolderSection.tsx",
127
127
  "isDynamicEntry": true,
@@ -130,7 +130,7 @@
130
130
  ]
131
131
  },
132
132
  "src/components/PromptLibraryPanel.tsx": {
133
- "file": "assets/PromptLibraryPanel-kXL1oFA8.js",
133
+ "file": "assets/PromptLibraryPanel-64VN4nml.js",
134
134
  "name": "PromptLibraryPanel",
135
135
  "src": "src/components/PromptLibraryPanel.tsx",
136
136
  "isDynamicEntry": true,
@@ -142,7 +142,7 @@
142
142
  ]
143
143
  },
144
144
  "src/components/SettingsWorkspace.tsx": {
145
- "file": "assets/SettingsWorkspace-Cf7rRTV3.js",
145
+ "file": "assets/SettingsWorkspace-DZMNEpuq.js",
146
146
  "name": "SettingsWorkspace",
147
147
  "src": "src/components/SettingsWorkspace.tsx",
148
148
  "isDynamicEntry": true,
@@ -151,43 +151,43 @@
151
151
  ]
152
152
  },
153
153
  "src/components/agent/AgentWorkspace.tsx": {
154
- "file": "assets/AgentWorkspace-DAjUdAsK.js",
154
+ "file": "assets/AgentWorkspace-bUd5NsQ_.js",
155
155
  "name": "AgentWorkspace",
156
156
  "src": "src/components/agent/AgentWorkspace.tsx",
157
157
  "isDynamicEntry": true,
158
158
  "imports": [
159
159
  "index.html",
160
- "_useAgentDialogFocus-CxsC04Sp.js"
160
+ "_useAgentDialogFocus-PWmMjerz.js"
161
161
  ]
162
162
  },
163
163
  "src/components/assetgen/SpriteRecipeWorkspace.tsx": {
164
- "file": "assets/SpriteRecipeWorkspace-_WcHPSd4.js",
164
+ "file": "assets/SpriteRecipeWorkspace-Y6GqpVHs.js",
165
165
  "name": "SpriteRecipeWorkspace",
166
166
  "src": "src/components/assetgen/SpriteRecipeWorkspace.tsx",
167
167
  "isDynamicEntry": true,
168
168
  "imports": [
169
169
  "index.html",
170
- "_AssetGenWorkspace-CpAkJhms.js",
171
- "_KeyingPanel-2-wMdwa8.js",
172
- "_useAgentDialogFocus-CxsC04Sp.js"
170
+ "_AssetGenWorkspace-8fK-K64E.js",
171
+ "_KeyingPanel-CEBLIhhu.js",
172
+ "_useAgentDialogFocus-PWmMjerz.js"
173
173
  ]
174
174
  },
175
175
  "src/components/assets/AssetsWorkspace.tsx": {
176
- "file": "assets/AssetsWorkspace-Bh1OzpUk.js",
176
+ "file": "assets/AssetsWorkspace-DO_wfFQB.js",
177
177
  "name": "AssetsWorkspace",
178
178
  "src": "src/components/assets/AssetsWorkspace.tsx",
179
179
  "isDynamicEntry": true,
180
180
  "imports": [
181
181
  "index.html",
182
- "_KeyingPanel-2-wMdwa8.js",
183
- "_useAgentDialogFocus-CxsC04Sp.js"
182
+ "_KeyingPanel-CEBLIhhu.js",
183
+ "_useAgentDialogFocus-PWmMjerz.js"
184
184
  ],
185
185
  "css": [
186
186
  "assets/AssetsWorkspace-BkUjPPKU.css"
187
187
  ]
188
188
  },
189
189
  "src/components/canvas-mode/index.ts": {
190
- "file": "assets/index-BTHxkxxS.js",
190
+ "file": "assets/index-CFixfKaC.js",
191
191
  "name": "index",
192
192
  "src": "src/components/canvas-mode/index.ts",
193
193
  "isDynamicEntry": true,
@@ -199,7 +199,7 @@
199
199
  ]
200
200
  },
201
201
  "src/components/card-news/CardNewsWorkspace.tsx": {
202
- "file": "assets/CardNewsWorkspace-DSqExDy-.js",
202
+ "file": "assets/CardNewsWorkspace-D3M0w8pg.js",
203
203
  "name": "CardNewsWorkspace",
204
204
  "src": "src/components/card-news/CardNewsWorkspace.tsx",
205
205
  "isDynamicEntry": true,
@@ -208,7 +208,7 @@
208
208
  ]
209
209
  },
210
210
  "src/components/home/HomeWorkspace.tsx": {
211
- "file": "assets/HomeWorkspace-Dr0j6d1O.js",
211
+ "file": "assets/HomeWorkspace-BGCBf9iK.js",
212
212
  "name": "HomeWorkspace",
213
213
  "src": "src/components/home/HomeWorkspace.tsx",
214
214
  "isDynamicEntry": true,
@@ -217,7 +217,7 @@
217
217
  ]
218
218
  },
219
219
  "src/components/prompt-builder/PromptBuilderPanel.tsx": {
220
- "file": "assets/PromptBuilderPanel-CvXqQl0o.js",
220
+ "file": "assets/PromptBuilderPanel-KSH3ChjC.js",
221
221
  "name": "PromptBuilderPanel",
222
222
  "src": "src/components/prompt-builder/PromptBuilderPanel.tsx",
223
223
  "isDynamicEntry": true,
@@ -1,3 +1,3 @@
1
- import{P as Fe,a as m,j as e,u as x,i as Se,A as je,Q as St,b as E}from"./index-BKW7WOYj.js";import{u as ue}from"./useAgentDialogFocus-CxsC04Sp.js";async function D(t,n){const a=await fetch(t,n);if(!a.ok){const s=await a.json().catch(()=>({})),r=s.error,u=typeof r=="string"?r:r?.message??`Request failed: ${a.status}`,o=new Error(u);throw o.status=a.status,o.code=typeof r=="object"?r?.code:s.code,o}return await a.json()}function _t(t){return t.filename?`/generated/${t.filename}`:typeof t.url=="string"&&t.url?t.url:typeof t.thumb=="string"&&t.thumb?t.thumb:null}function Ge(t){const n=_t(t);if(!n)return null;const a=t.filename??t.canvasEditableFilename??"current-image.png";return{id:`current-${a}`,filename:a,url:n,thumbUrl:t.thumb??n,prompt:t.prompt??t.userPrompt??null,revisedPrompt:t.revisedPrompt??null,createdAt:t.createdAt??Date.now()}}async function qe(t){const n=t?`?selectedSessionId=${encodeURIComponent(t)}`:"";return D(`/api/agent/sessions${n}`)}async function Re(t){const n=t.currentImage?Ge(t.currentImage):null;return D("/api/agent/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,currentImage:n,webSearchEnabled:t.webSearchEnabled??!0})})}async function ie(t,n){return D(`/api/agent/sessions/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function wt(t){return D(`/api/agent/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Nt(t,n,a){return D(`/api/agent/sessions/${encodeURIComponent(t)}/queue`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:n,options:a})})}async function Ct(t){return D(`/api/agent/queue/${encodeURIComponent(t)}/cancel`,{method:"POST"})}async function kt(t){return D(`/api/agent/queue/${encodeURIComponent(t)}/retry`,{method:"POST"})}const ve=Fe,It=Fe,At={provider:"oauth",model:"gpt-5.6-luna",quality:"medium",size:"1024x1024",format:"png",moderation:"low",reasoningEffort:"none",webSearchEnabled:!0,generationStrategy:"auto",variants:1,maxAutoVariants:ve,parallelism:2};function $e(t){return{...At,...t??{}}}function Pe(t){const{width:n,height:a}=t;return n>=1280?"desktop-three-pane":a<560&&n<1280?n>=768?"tablet-stacked":"mobile-chat-image-sheet":n>=960&&a>=560?"desktop-rail":n>=768&&a>=700?"tablet-stacked":"mobile-chat-image-sheet"}function Tt(){return typeof window>"u"?1440:window.innerWidth}function De(){return typeof window>"u"?900:window.innerHeight}function Lt(){if(typeof window>"u"||typeof document>"u")return 1440;const t=document.querySelector('.app[data-ui-mode="agent"] .sidebar');if(!t)return window.innerWidth;const n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden")return window.innerWidth;const a=t.getBoundingClientRect().width;return Math.max(0,window.innerWidth-a)}function Mt(){const[t,n]=m.useState(()=>Pe({width:Tt(),height:De()}));return m.useEffect(()=>{const a=()=>n(Pe({width:Lt(),height:De()}));return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),t}function N({size:t=16,children:n}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n})}function Ke(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Et(t){return e.jsxs(N,{...t,children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"M21 21l-4.3-4.3"})]})}function B(t){return e.jsxs(N,{...t,children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),e.jsx("circle",{cx:"8",cy:"10",r:"1.5"}),e.jsx("path",{d:"M21 16l-5-5L5 19"})]})}function de(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}function qt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M22 2L11 13"}),e.jsx("path",{d:"M22 2l-7 20-4-9-9-4 20-7z"})]})}function Rt(t){return e.jsx(N,{...t,children:e.jsx("path",{d:"M21.4 11.1l-9.2 9.1a6 6 0 0 1-8.5-8.5l9.2-9.2a4 4 0 0 1 5.7 5.7l-9.2 9.2a2 2 0 0 1-2.8-2.8l8.5-8.5"})})}function $t(t){return e.jsxs(N,{...t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M2 12h20"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 0 20"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 0 0 20"})]})}function Ue(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("path",{d:"M4 12h16"}),e.jsx("path",{d:"M4 18h16"})]})}function Pt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("path",{d:"M12 19l-7-7 7-7"})]})}function Dt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M8 6h13"}),e.jsx("path",{d:"M8 12h13"}),e.jsx("path",{d:"M8 18h13"}),e.jsx("circle",{cx:"3",cy:"6",r:"1"}),e.jsx("circle",{cx:"3",cy:"12",r:"1"}),e.jsx("circle",{cx:"3",cy:"18",r:"1"})]})}function Bt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4h8v2"}),e.jsx("path",{d:"M19 6l-1 14H6L5 6"})]})}function Ot(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function He(t){return e.jsx(N,{...t,children:e.jsx("path",{d:"M6 9l6 6 6-6"})})}function _e(t){return e.jsx(N,{...t,children:e.jsx("path",{d:"M9 6l6 6-6 6"})})}function zt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M4 8h16"}),e.jsx("circle",{cx:"9",cy:"8",r:"2.5"}),e.jsx("path",{d:"M4 16h16"}),e.jsx("circle",{cx:"15",cy:"16",r:"2.5"})]})}const Be=[{name:"question",display:"/question",aliases:["question","ask","q"],descriptionKey:"agent.slashDesc_question"},{name:"variants",display:"/variants <N>",aliases:["variants","variant","v","n"],descriptionKey:"agent.slashDesc_variants",hasValue:!0},{name:"generate",display:"/generate <N>",aliases:["generate","gen","g"],descriptionKey:"agent.slashDesc_generate",hasValue:!0},{name:"parallelism",display:"/parallelism <N>",aliases:["parallelism","parallel","p"],descriptionKey:"agent.slashDesc_parallelism",hasValue:!0},{name:"help",display:"/help",aliases:["help","h"],descriptionKey:"agent.slashDesc_help"}];function Ve(t){const n=t.toLowerCase();return n?Be.filter(a=>a.aliases.some(s=>s.startsWith(n))):Be}function Wt({listboxId:t,query:n,highlightIndex:a,onSelect:s,onHighlightChange:r}){const{t:u}=x(),o=Ve(n);return o.length===0?null:e.jsx("ul",{id:t,className:"slash-command-menu",role:"listbox","aria-label":u("agent.slashCommands"),children:o.map((i,d)=>e.jsxs("li",{id:`${t}-opt-${d}`,role:"option","aria-selected":d===a,className:`slash-command-menu__item${d===a?" is-highlighted":""}`,onMouseDown:l=>l.preventDefault(),onClick:()=>s(i),onMouseEnter:()=>r(d),children:[e.jsx("span",{className:"slash-command-menu__name",children:i.display}),e.jsx("span",{className:"slash-command-menu__desc",children:u(i.descriptionKey)})]},i.name))})}function Qt(t){return Array.from(t).filter(n=>n.type.startsWith("image/"))}function Ft(t){return Array.from(t.clipboardData?.items??[]).filter(n=>n.kind==="file"&&n.type.startsWith("image/")).map(n=>n.getAsFile()).filter(n=>!!n)}function Gt({webSearchEnabled:t,insertedPrompt:n,onWebSearchChange:a,onAttachFiles:s,onSend:r}){const{t:u}=x(),[o,i]=m.useState(""),[d,l]=m.useState(0),[h,c]=m.useState(!1),p=m.useRef(null),f=m.useRef(null),v=m.useId(),S=o.trim().length>0,C=o.trimStart().match(/^\/([a-z]*)$/i),q=C!==null,G=q&&!h,K=C?.[1]??"",T=Ve(K),O=G&&T.length>0,A=T.length>0?Math.min(d,T.length-1):0,ge=O?`${v}-opt-${A}`:void 0;m.useEffect(()=>{l(0),c(!1)},[K]),m.useEffect(()=>{q&&c(!1)},[q]),m.useEffect(()=>{n?.text&&i(b=>b.trim()?`${b.trim()}
1
+ import{P as Fe,a as m,j as e,u as x,i as Se,A as je,Q as St,b as E}from"./index-XXtoj9ME.js";import{u as ue}from"./useAgentDialogFocus-PWmMjerz.js";async function D(t,n){const a=await fetch(t,n);if(!a.ok){const s=await a.json().catch(()=>({})),r=s.error,u=typeof r=="string"?r:r?.message??`Request failed: ${a.status}`,o=new Error(u);throw o.status=a.status,o.code=typeof r=="object"?r?.code:s.code,o}return await a.json()}function _t(t){return t.filename?`/generated/${t.filename}`:typeof t.url=="string"&&t.url?t.url:typeof t.thumb=="string"&&t.thumb?t.thumb:null}function Ge(t){const n=_t(t);if(!n)return null;const a=t.filename??t.canvasEditableFilename??"current-image.png";return{id:`current-${a}`,filename:a,url:n,thumbUrl:t.thumb??n,prompt:t.prompt??t.userPrompt??null,revisedPrompt:t.revisedPrompt??null,createdAt:t.createdAt??Date.now()}}async function qe(t){const n=t?`?selectedSessionId=${encodeURIComponent(t)}`:"";return D(`/api/agent/sessions${n}`)}async function Re(t){const n=t.currentImage?Ge(t.currentImage):null;return D("/api/agent/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t.title,currentImage:n,webSearchEnabled:t.webSearchEnabled??!0})})}async function ie(t,n){return D(`/api/agent/sessions/${encodeURIComponent(t)}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function wt(t){return D(`/api/agent/sessions/${encodeURIComponent(t)}`,{method:"DELETE"})}async function Nt(t,n,a){return D(`/api/agent/sessions/${encodeURIComponent(t)}/queue`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({prompt:n,options:a})})}async function Ct(t){return D(`/api/agent/queue/${encodeURIComponent(t)}/cancel`,{method:"POST"})}async function kt(t){return D(`/api/agent/queue/${encodeURIComponent(t)}/retry`,{method:"POST"})}const ve=Fe,It=Fe,At={provider:"oauth",model:"gpt-5.6-luna",quality:"medium",size:"1024x1024",format:"png",moderation:"low",reasoningEffort:"none",webSearchEnabled:!0,generationStrategy:"auto",variants:1,maxAutoVariants:ve,parallelism:2};function $e(t){return{...At,...t??{}}}function Pe(t){const{width:n,height:a}=t;return n>=1280?"desktop-three-pane":a<560&&n<1280?n>=768?"tablet-stacked":"mobile-chat-image-sheet":n>=960&&a>=560?"desktop-rail":n>=768&&a>=700?"tablet-stacked":"mobile-chat-image-sheet"}function Tt(){return typeof window>"u"?1440:window.innerWidth}function De(){return typeof window>"u"?900:window.innerHeight}function Lt(){if(typeof window>"u"||typeof document>"u")return 1440;const t=document.querySelector('.app[data-ui-mode="agent"] .sidebar');if(!t)return window.innerWidth;const n=window.getComputedStyle(t);if(n.display==="none"||n.visibility==="hidden")return window.innerWidth;const a=t.getBoundingClientRect().width;return Math.max(0,window.innerWidth-a)}function Mt(){const[t,n]=m.useState(()=>Pe({width:Tt(),height:De()}));return m.useEffect(()=>{const a=()=>n(Pe({width:Lt(),height:De()}));return a(),window.addEventListener("resize",a),()=>window.removeEventListener("resize",a)},[]),t}function N({size:t=16,children:n}){return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:n})}function Ke(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}function Et(t){return e.jsxs(N,{...t,children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"M21 21l-4.3-4.3"})]})}function B(t){return e.jsxs(N,{...t,children:[e.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2"}),e.jsx("circle",{cx:"8",cy:"10",r:"1.5"}),e.jsx("path",{d:"M21 16l-5-5L5 19"})]})}function de(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M18 6L6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})}function qt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M22 2L11 13"}),e.jsx("path",{d:"M22 2l-7 20-4-9-9-4 20-7z"})]})}function Rt(t){return e.jsx(N,{...t,children:e.jsx("path",{d:"M21.4 11.1l-9.2 9.1a6 6 0 0 1-8.5-8.5l9.2-9.2a4 4 0 0 1 5.7 5.7l-9.2 9.2a2 2 0 0 1-2.8-2.8l8.5-8.5"})})}function $t(t){return e.jsxs(N,{...t,children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("path",{d:"M2 12h20"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 0 20"}),e.jsx("path",{d:"M12 2a15.3 15.3 0 0 0 0 20"})]})}function Ue(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M4 6h16"}),e.jsx("path",{d:"M4 12h16"}),e.jsx("path",{d:"M4 18h16"})]})}function Pt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M19 12H5"}),e.jsx("path",{d:"M12 19l-7-7 7-7"})]})}function Dt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M8 6h13"}),e.jsx("path",{d:"M8 12h13"}),e.jsx("path",{d:"M8 18h13"}),e.jsx("circle",{cx:"3",cy:"6",r:"1"}),e.jsx("circle",{cx:"3",cy:"12",r:"1"}),e.jsx("circle",{cx:"3",cy:"18",r:"1"})]})}function Bt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M3 6h18"}),e.jsx("path",{d:"M8 6V4h8v2"}),e.jsx("path",{d:"M19 6l-1 14H6L5 6"})]})}function Ot(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M12 20h9"}),e.jsx("path",{d:"M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.5-12.5z"})]})}function He(t){return e.jsx(N,{...t,children:e.jsx("path",{d:"M6 9l6 6 6-6"})})}function _e(t){return e.jsx(N,{...t,children:e.jsx("path",{d:"M9 6l6 6-6 6"})})}function zt(t){return e.jsxs(N,{...t,children:[e.jsx("path",{d:"M4 8h16"}),e.jsx("circle",{cx:"9",cy:"8",r:"2.5"}),e.jsx("path",{d:"M4 16h16"}),e.jsx("circle",{cx:"15",cy:"16",r:"2.5"})]})}const Be=[{name:"question",display:"/question",aliases:["question","ask","q"],descriptionKey:"agent.slashDesc_question"},{name:"variants",display:"/variants <N>",aliases:["variants","variant","v","n"],descriptionKey:"agent.slashDesc_variants",hasValue:!0},{name:"generate",display:"/generate <N>",aliases:["generate","gen","g"],descriptionKey:"agent.slashDesc_generate",hasValue:!0},{name:"parallelism",display:"/parallelism <N>",aliases:["parallelism","parallel","p"],descriptionKey:"agent.slashDesc_parallelism",hasValue:!0},{name:"help",display:"/help",aliases:["help","h"],descriptionKey:"agent.slashDesc_help"}];function Ve(t){const n=t.toLowerCase();return n?Be.filter(a=>a.aliases.some(s=>s.startsWith(n))):Be}function Wt({listboxId:t,query:n,highlightIndex:a,onSelect:s,onHighlightChange:r}){const{t:u}=x(),o=Ve(n);return o.length===0?null:e.jsx("ul",{id:t,className:"slash-command-menu",role:"listbox","aria-label":u("agent.slashCommands"),children:o.map((i,d)=>e.jsxs("li",{id:`${t}-opt-${d}`,role:"option","aria-selected":d===a,className:`slash-command-menu__item${d===a?" is-highlighted":""}`,onMouseDown:l=>l.preventDefault(),onClick:()=>s(i),onMouseEnter:()=>r(d),children:[e.jsx("span",{className:"slash-command-menu__name",children:i.display}),e.jsx("span",{className:"slash-command-menu__desc",children:u(i.descriptionKey)})]},i.name))})}function Qt(t){return Array.from(t).filter(n=>n.type.startsWith("image/"))}function Ft(t){return Array.from(t.clipboardData?.items??[]).filter(n=>n.kind==="file"&&n.type.startsWith("image/")).map(n=>n.getAsFile()).filter(n=>!!n)}function Gt({webSearchEnabled:t,insertedPrompt:n,onWebSearchChange:a,onAttachFiles:s,onSend:r}){const{t:u}=x(),[o,i]=m.useState(""),[d,l]=m.useState(0),[h,c]=m.useState(!1),p=m.useRef(null),f=m.useRef(null),v=m.useId(),S=o.trim().length>0,C=o.trimStart().match(/^\/([a-z]*)$/i),q=C!==null,G=q&&!h,K=C?.[1]??"",T=Ve(K),O=G&&T.length>0,A=T.length>0?Math.min(d,T.length-1):0,ge=O?`${v}-opt-${A}`:void 0;m.useEffect(()=>{l(0),c(!1)},[K]),m.useEffect(()=>{q&&c(!1)},[q]),m.useEffect(()=>{n?.text&&i(b=>b.trim()?`${b.trim()}
2
2
 
3
3
  ${n.text}`:n.text)},[n]);const U=()=>{const b=o.trim();b&&(r(b),i(""))},H=b=>{i(`/${b.name} `),p.current?.focus()},V=b=>{const M=Ft(b);M.length!==0&&(b.preventDefault(),s(M))};return e.jsxs("div",{className:"agent-composer",children:[O&&e.jsx(Wt,{listboxId:v,query:K,highlightIndex:A,onSelect:H,onHighlightChange:l}),e.jsx("textarea",{ref:p,value:o,"aria-autocomplete":"list","aria-haspopup":"listbox","aria-label":u("agent.composerPlaceholder"),...O?{"aria-controls":v}:{},"aria-activedescendant":ge,autoCapitalize:"off",autoCorrect:"off",placeholder:u("agent.composerPlaceholder"),onChange:b=>i(b.target.value),onPaste:V,onKeyDown:b=>{if(b.key==="Enter"&&(b.metaKey||b.ctrlKey)){b.preventDefault(),U();return}if(O)switch(b.key){case"Tab":{b.preventDefault(),H(T[A]);return}case"ArrowDown":{b.preventDefault(),l((A+1)%T.length);return}case"ArrowUp":{b.preventDefault(),l((A-1+T.length)%T.length);return}case"Enter":{b.preventDefault(),H(T[A]);return}case"Escape":{b.preventDefault(),c(!0);return}}}}),e.jsx("input",{ref:f,type:"file",accept:"image/png,image/jpeg,image/webp",multiple:!0,hidden:!0,onChange:b=>{const M=Qt(b.target.files??[]);M.length>0&&s(M),b.target.value=""}}),e.jsxs("div",{className:"agent-composer__actions",children:[e.jsx("button",{type:"button",onClick:()=>f.current?.click(),"aria-label":u("agent.attachReference"),title:u("agent.attachReference"),children:e.jsx(Rt,{size:16})}),e.jsx("button",{type:"button",className:t?"is-active":"","aria-pressed":t,onClick:()=>a(!t),"aria-label":u("agent.webSearch"),title:u("agent.webSearch"),children:e.jsx($t,{size:16})}),e.jsxs("button",{type:"button",className:"agent-composer__send",onClick:U,disabled:!S,"aria-label":u("agent.send"),children:[e.jsx(qt,{size:16}),e.jsx("span",{children:u("agent.send")})]})]})]})}function Q({src:t,alt:n,className:a,fallbackClassName:s,iconSize:r=18}){const[u,o]=m.useState(!1);return!t||u?e.jsx("span",{className:s??"agent-image-fallback","aria-label":n,role:"img",children:e.jsx(B,{size:r})}):Se(t)?e.jsx("video",{className:a,src:t,preload:"metadata",playsInline:!0,muted:!0,onError:()=>o(!0),"aria-label":n}):e.jsx("img",{className:a,src:t,alt:n,onError:()=>o(!0)})}const F=m.forwardRef(function({image:n,selected:a=!1,compact:s=!1,onSelect:r},u){const{t:o}=x(),i=`${o("agent.mediaSelect")}: ${n.prompt??n.filename}`,d=`${s?"agent-result-thumb agent-result-thumb--compact":"agent-result-thumb"}${a?" is-selected":""}`;return e.jsx("button",{ref:u,type:"button",className:d,"aria-label":i,"aria-current":a?"true":void 0,onClick:()=>r(n.id),title:o("agent.mediaSelect"),children:e.jsx(Q,{src:n.thumbUrl??n.url,alt:n.prompt??o("agent.imageAlt"),iconSize:s?14:18})})});function Kt({turn:t,imagesById:n,currentImageId:a,onImageSelect:s}){const{t:r}=x(),u=t.role==="user"?r("agent.user"):t.status==="error"?r("agent.errorRole"):r("agent.assistant"),o=t.imageIds??[],i=t.status==="streaming"?" is-streaming":t.status==="error"?" is-error":"",d=`agent-message agent-message--${t.role}${i}`;return e.jsxs("article",{className:d,"aria-busy":t.status==="streaming"?"true":void 0,children:[e.jsx("div",{className:"agent-message__role",children:u}),e.jsx("p",{children:t.text}),o.length>0?e.jsx("div",{className:"agent-message__images",children:o.map(l=>{const h=n[l];return h?e.jsx(F,{image:h,selected:l===a,compact:!1,onSelect:s},l):null})}):null]})}const Ut=["ima2.get_image_context","ima2.web_search","ima2.generate_image","ima2.generate_video","ima2.get_generation_errors"];function Ht(t){return t.replace(/\s+/g," ").trim()||"tool"}function Vt(t){if(t.toolCalls?.length)return t.toolCalls;const n=Ht(t.text);return Ut.filter(a=>n.includes(a)).map((a,s)=>({id:`${t.id}-fallback-${s}`,name:a,status:t.status==="error"?"error":t.status==="streaming"?"running":"complete",outputSummary:n,imageIds:a==="ima2.generate_image"||a==="ima2.generate_video"?t.imageIds??[]:[],webFindingIds:a==="ima2.web_search"?t.webFindingIds??[]:[]}))}function Je(t){return!t||t<0?null:t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`}function Jt({call:t,imagesById:n,currentImageId:a,onImageSelect:s}){const{t:r}=x(),u=t.imageIds??[],o=Je(t.durationMs),[i,d]=m.useState({input:!1,output:!1}),l=(h,c)=>e.jsxs("dd",{className:i[h]?"is-expanded":void 0,children:[e.jsx("span",{children:c}),e.jsx("button",{type:"button",onClick:()=>d(p=>({...p,[h]:!p[h]})),children:r(i[h]?"agent.toolsShowLess":"agent.toolsShowMore")})]});return e.jsxs("div",{className:"agent-tool-call-details",children:[e.jsxs("dl",{children:[e.jsxs("div",{children:[e.jsx("dt",{children:r("agent.toolInput")}),l("input",t.inputSummary??"-")]}),e.jsxs("div",{children:[e.jsx("dt",{children:r("agent.toolOutput")}),l("output",t.errorMessage??t.outputSummary??"-")]}),t.requestId?e.jsxs("div",{children:[e.jsx("dt",{children:r("agent.requestId")}),e.jsx("dd",{children:t.requestId})]}):null,o?e.jsxs("div",{children:[e.jsx("dt",{children:r("agent.duration")}),e.jsx("dd",{children:o})]}):null]}),u.length>0?e.jsx("div",{className:"agent-tool-call-details__artifacts","aria-label":r("agent.toolArtifacts"),children:u.map(h=>{const c=n[h];return c?e.jsx(F,{image:c,selected:h===a,compact:!0,onSelect:s},h):null})}):null]})}function Xt({call:t,imagesById:n,currentImageId:a,onImageSelect:s}){const{t:r}=x(),u=m.useId(),[o,i]=m.useState(!1),d=Je(t.durationMs);return e.jsxs("li",{className:`agent-tool-call-row agent-tool-call-row--${t.status}`,children:[e.jsxs("button",{type:"button",className:"agent-tool-call-row__toggle","aria-expanded":o,"aria-controls":u,"aria-busy":t.status==="running"?"true":void 0,onClick:()=>i(l=>!l),children:[e.jsx("span",{className:"agent-tool-call-row__status","aria-label":r(`agent.toolStatus.${t.status}`)}),e.jsx("span",{className:"agent-tool-call-row__name",children:t.name}),t.imageIds?.length?e.jsx("span",{className:"agent-tool-call-row__meta",children:r("agent.toolImageCount",{count:t.imageIds.length})}):null,d?e.jsx("span",{className:"agent-tool-call-row__meta",children:d}):null,o?e.jsx(He,{size:13}):e.jsx(_e,{size:13})]}),e.jsx("div",{id:u,hidden:!o,children:e.jsx(Jt,{call:t,imagesById:n,currentImageId:a,onImageSelect:s})})]})}function Yt(t){const n=[],a=new Set;let s=!1;const r=[];for(const u of t){const o=Vt(u);n.push(...o);for(const i of u.imageIds??[])a.add(i);for(const i of o)for(const d of i.imageIds??[])a.add(d);u.status==="streaming"&&(s=!0);for(const i of o)r.includes(i.name)||r.push(i.name)}return{toolCalls:n,imageIds:[...a],isStreaming:s,label:r.join(" + ")||"tool"}}function Zt({turns:t,imagesById:n,currentImageId:a,onImageSelect:s}){const{t:r}=x(),u=m.useId(),[o,i]=m.useState(!1),{toolCalls:d,imageIds:l,isStreaming:h,label:c}=m.useMemo(()=>Yt(t),[t]),p=r(o?"agent.toolCollapse":"agent.toolExpand");return e.jsxs("article",{className:`agent-message agent-message--tool is-collapsible${h?" is-streaming":""}`,"aria-busy":h?"true":void 0,children:[e.jsx("div",{className:"agent-message__tool-summary",children:e.jsx("button",{type:"button",className:"agent-message__tool-toggle","aria-expanded":o,"aria-controls":u,"aria-label":`${p}: ${c}`,onClick:()=>i(f=>!f),children:e.jsxs("span",{className:"agent-message__tool-summary-line",children:[e.jsx("span",{className:"agent-message__tool-dot","aria-hidden":"true"}),e.jsx("span",{className:"agent-message__role",children:r("agent.toolGroup")}),l.length>0?e.jsx("span",{className:"agent-message__tool-count",children:r("agent.toolImageCount",{count:l.length})}):null,d.length>0?e.jsx("span",{className:"agent-message__tool-count",children:r("agent.toolCallCount",{count:d.length})}):null,o?e.jsx(He,{size:14}):e.jsx(_e,{size:14})]})})}),e.jsxs("div",{id:u,className:"agent-message__tool-details",hidden:!o,children:[e.jsx("div",{className:"agent-message__tool-label",children:c}),d.length>0?e.jsx("ul",{className:"agent-tool-call-list",children:d.map(f=>e.jsx(Xt,{call:f,imagesById:n,currentImageId:a,onImageSelect:s},f.id))}):null,l.length>0?e.jsx("div",{className:"agent-message__tool-thumbs",children:l.map(f=>{const v=n[f];return v?e.jsx(F,{image:v,selected:f===a,compact:!0,onSelect:s},f):null})}):null]})]})}function en(t){return t.role!=="tool"&&(t.text.trim().length>0||(t.imageIds?.length??0)>0)}function tn({turns:t,imagesById:n,currentImageId:a,onImageSelect:s}){const{t:r}=x(),u=t.filter(c=>c.role==="tool"),o=t.filter(en),i=t.some(c=>c.status==="streaming"),d=t.some(c=>c.status==="error"),l=i?" is-streaming":d?" is-error":"",h=r(d?"agent.errorRole":"agent.assistant");return e.jsxs("article",{className:`agent-message agent-message--assistant-run${l}`,"aria-busy":i?"true":void 0,children:[e.jsxs("div",{className:"agent-run__header",children:[e.jsx("div",{className:"agent-message__role",children:h}),u.length>0?e.jsx("div",{className:"agent-run__header-tool",children:e.jsx(Zt,{turns:u,imagesById:n,currentImageId:a,onImageSelect:s})}):null]}),o.length>0?e.jsx("ol",{className:"agent-run__steps","aria-label":h,children:o.map(c=>{const p=c.imageIds??[],f=c.status==="streaming"?" is-streaming":c.status==="error"?" is-error":"";return e.jsxs("li",{className:`agent-run__step${f}`,children:[e.jsx("span",{className:"agent-run__step-marker","aria-hidden":"true"}),e.jsxs("div",{className:"agent-run__step-body",children:[c.text.trim().length>0?e.jsx("p",{children:c.text}):null,p.length>0?e.jsx("div",{className:"agent-message__images",children:p.map(v=>{const S=n[v];return S?e.jsx(F,{image:S,selected:v===a,compact:!1,onSelect:s},v):null})}):null]})]},c.id)})}):null]})}function nn(t){const n=[];let a=[];const s=()=>{a.length!==0&&(n.push({kind:"run",turns:a,key:a.map(r=>r.id).join("+")}),a=[])};for(const r of t)r.role==="user"?(s(),n.push({kind:"single",turn:r})):a.push(r);return s(),n}function an({turns:t,imagesById:n,currentImageId:a,onImageSelect:s}){const{t:r}=x(),u=m.useRef(null),o=m.useRef(!0),[i,d]=m.useState(!1),l=m.useMemo(()=>nn(t),[t]),h=m.useCallback(()=>{const p=u.current;p&&(o.current=p.scrollHeight-p.scrollTop-p.clientHeight<=120,o.current&&d(!1))},[]),c=m.useCallback(()=>{const p=u.current;p&&(p.scrollTo({top:p.scrollHeight,behavior:"smooth"}),o.current=!0,d(!1))},[]);return m.useEffect(()=>{const p=u.current;p&&(o.current?p.scrollTop=p.scrollHeight:d(!0))},[t.length]),e.jsxs("div",{ref:u,className:"agent-message-list","aria-live":"polite",onScroll:h,children:[t.length===0?e.jsx("div",{className:"agent-message-list__empty",children:r("agent.emptyChat")}):null,l.map(p=>p.kind==="run"?e.jsx(tn,{turns:p.turns,imagesById:n,currentImageId:a,onImageSelect:s},p.key):e.jsx(Kt,{turn:p.turn,imagesById:n,currentImageId:a,onImageSelect:s},p.turn.id)),i?e.jsx("button",{type:"button",className:"agent-message-list__jump",onClick:c,children:r("agent.emptyJumpLatest")}):null]})}const ce=[{value:"gpt-5.6-luna",shortLabel:"5.6l",fullLabel:"GPT-5.6 Luna",provider:"oauth"},{value:"gpt-5.6-terra",shortLabel:"5.6t",fullLabel:"GPT-5.6 Terra",provider:"oauth"},{value:"gpt-5.6-sol",shortLabel:"5.6s",fullLabel:"GPT-5.6 Sol",provider:"oauth"},{value:"gpt-5.5",shortLabel:"5.5",fullLabel:"GPT-5.5",provider:"oauth"},{value:"gpt-5.4",shortLabel:"5.4",fullLabel:"GPT-5.4",provider:"oauth"},{value:"gpt-5.4-mini",shortLabel:"5.4m",fullLabel:"GPT-5.4 mini",provider:"oauth"},{value:"grok-4.6",shortLabel:"4.6",fullLabel:"Grok 4.6",provider:"grok"},{value:"grok-4.5",shortLabel:"4.5",fullLabel:"Grok 4.5",provider:"grok"},{value:"grok-4.3",shortLabel:"4.3",fullLabel:"Grok 4.3",provider:"grok"}];function sn(t){return ce.find(n=>n.value===t.model)??ce.find(n=>n.provider===t.provider)??ce[0]}function Xe({settings:t,onChange:n,onOpenModelTab:a}){const{t:s}=x(),[r,u]=m.useState(!1),o=m.useRef(null),i=sn(t),d=je.find(l=>l.value===t.reasoningEffort)??je[0];return m.useEffect(()=>{if(!r)return;const l=c=>{o.current?.contains(c.target)||u(!1)},h=c=>{c.key==="Escape"&&u(!1)};return window.addEventListener("pointerdown",l),window.addEventListener("keydown",h),()=>{window.removeEventListener("pointerdown",l),window.removeEventListener("keydown",h)}},[r]),e.jsxs("div",{ref:o,className:"image-model-select image-model-select--sidebar agent-model-select",children:[e.jsxs("button",{type:"button",className:"image-model-select__trigger image-model-select__trigger--pill","aria-haspopup":"menu","aria-expanded":r,"aria-label":s("sidebar.quickSettingsAria",{model:i.shortLabel,effort:d.shortLabel}),onClick:()=>u(l=>!l),children:[e.jsxs("span",{className:"image-model-select__trigger-top",children:[e.jsx("span",{className:"image-model-select__trigger-model",children:i.shortLabel}),e.jsx("span",{className:"image-model-select__trigger-chevron","aria-hidden":"true",children:"▾"})]}),e.jsx("span",{className:"image-model-select__trigger-effort",children:d.shortLabel})]}),a?e.jsx("button",{type:"button",className:"agent-model-select__open-tab",onClick:a,"aria-label":s("agent.modelTabView"),title:s("agent.modelTabView"),children:e.jsx(_e,{size:13})}):null,r?e.jsxs("div",{className:"image-model-select__menu agent-model-select__menu",role:"menu","aria-label":s("sidebar.quickSettingsMenu"),children:[e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":s("agent.model"),children:[e.jsx("div",{className:"image-model-select__section-title",children:s("agent.model")}),ce.map(l=>e.jsxs("button",{type:"button",className:`image-model-select__item${l.value===i.value?" is-active":""}`,role:"menuitemradio","aria-checked":l.value===i.value,onClick:()=>{n({model:l.value,provider:l.provider}),u(!1)},children:[e.jsx("span",{children:l.shortLabel}),e.jsx("small",{children:l.fullLabel})]},l.value))]}),e.jsxs("div",{className:"image-model-select__section",role:"group","aria-label":s("sidebar.reasoningLabel"),children:[e.jsx("div",{className:"image-model-select__section-title",children:s("sidebar.reasoningLabel")}),je.map(l=>e.jsxs("button",{type:"button",className:`image-model-select__item${l.value===t.reasoningEffort?" is-active":""}`,role:"menuitemradio","aria-checked":l.value===t.reasoningEffort,onClick:()=>{n({reasoningEffort:l.value}),u(!1)},children:[e.jsx("span",{children:l.shortLabel}),e.jsx("small",{children:s(l.fullLabelKey)})]},l.value))]})]}):null]})}function rn(t,n){if(!t)return null;const a=Math.max(0,Math.floor((n-t)/1e3));return`${String(Math.floor(a/60)).padStart(2,"0")}:${String(a%60).padStart(2,"0")}`}function ln({progress:t,queueSummary:n,onQueueOpen:a,onRetry:s}){const{t:r}=x(),[u,o]=m.useState(Date.now());m.useEffect(()=>{if(!t?.startedAt)return;o(Date.now());const p=window.setInterval(()=>o(Date.now()),1e3);return()=>window.clearInterval(p)},[t?.startedAt]);const i=n?.activeCount??(t?.queuedCount??0)+(t?.runningCount??0),d=n?.failedCount??t?.failedCount??0;if(!t?.active&&!n)return null;const l=t?.status==="queued"?"agent.progressQueued":t?.progressStage==="downloading"?"agent.progressDownloading":t?.status==="running"||t?.progressStage==="requesting"||t?.progressStage==="polling"?"agent.progressGenerating":t?.status==="error"?"agent.progressFailed":"agent.progressPlanning",h=rn(t?.startedAt,u),c=t?.jobKind?r("agent.progressJob",{kind:r(`agent.mediaKind.${t.jobKind}`),count:t.variantCount??1}):null;return e.jsxs("div",{className:`agent-run-status agent-run-status--${t?.status??"idle"}`,role:"status","aria-live":"polite",children:[t?.active?e.jsx("span",{className:"agent-run-status__indicator","aria-hidden":"true"}):null,t?.active?e.jsx("span",{className:"agent-run-status__label",children:r(l)}):null,c?e.jsx("span",{className:"agent-run-status__meta",children:c}):null,h?e.jsx("time",{className:"agent-run-status__elapsed",dateTime:`PT${Math.floor((u-(t?.startedAt??u))/1e3)}S`,children:h}):null,t?.status==="error"&&t.lastError?e.jsx("span",{className:"agent-run-status__meta",children:t.lastError}):null,t?.status==="error"&&s?e.jsx("button",{type:"button",className:"agent-run-status__retry",onClick:s,children:r("agent.retryQueue")}):null,e.jsx("button",{type:"button",className:"agent-run-status__queue",onClick:a,disabled:!a,children:r("agent.queueSummary",{active:i,failed:d})})]})}function on({status:t,compacted:n=!1}){const{t:a}=x(),s=a(t==="generating"?"agent.statusGenerating":t==="reconnecting"?"agent.statusReconnecting":"agent.statusReady");return e.jsxs("span",{className:`agent-status agent-status--${t}`,"aria-live":t==="ready"?void 0:"polite",children:[t==="generating"?e.jsx("span",{className:"agent-status__dot","aria-hidden":"true"}):null,e.jsx("span",{children:s}),n?e.jsx("em",{children:a("agent.compacted")}):null]})}function cn({session:t,turns:n,imagesById:a,currentImageId:s,runtimeStatus:r,runProgress:u,settings:o,insertedPrompt:i,onSettingsChange:d,onOpenModelTab:l,onWebSearchChange:h,onAttachFiles:c,onImageSelect:p,onSend:f,onRetryRun:v}){const{t:S}=x();return e.jsxs("section",{className:"agent-chat","aria-label":S("agent.chat"),children:[e.jsxs("header",{className:"agent-pane-header",children:[e.jsxs("div",{className:"agent-pane-header__title",children:[e.jsx("span",{children:S("agent.chat")}),e.jsx("strong",{children:t?.title??S("agent.newSession")})]}),e.jsxs("div",{className:"agent-pane-header__actions",children:[o&&d?e.jsx(Xe,{settings:o,onChange:d,onOpenModelTab:l}):null,e.jsx(on,{status:r,compacted:t?.compacted})]})]}),e.jsx(an,{turns:n,imagesById:a,currentImageId:s,onImageSelect:p}),e.jsx(ln,{progress:u,onRetry:v}),e.jsx(Gt,{webSearchEnabled:t?.webSearchEnabled??!1,insertedPrompt:i,onWebSearchChange:h,onAttachFiles:c,onSend:f})]})}const un=["image","refs","web","memory"];function dn({activeTab:t,onChange:n}){const{t:a}=x(),s={image:a("agent.imageTab"),refs:a("agent.refsTab"),web:a("agent.webTab"),memory:a("agent.memoryTab")};return e.jsx("div",{className:"agent-context-tabs",role:"tablist","aria-label":a("agent.contextTabs"),children:un.map(r=>e.jsx("button",{type:"button",role:"tab","aria-selected":t===r,className:t===r?"active":"",onClick:()=>n(r),children:s[r]},r))})}function gn({activeTab:t,currentImage:n}){const{t:a}=x();return t==="refs"?e.jsx("div",{className:"agent-tab-empty",children:a("agent.noRefs")}):t==="web"?e.jsx("div",{className:"agent-tab-empty",children:a("agent.noWeb")}):t==="memory"?e.jsxs("ul",{className:"agent-memory-list",children:[e.jsx("li",{children:a("agent.memoryItemStyle")}),e.jsx("li",{children:a("agent.memoryItemSubject")})]}):e.jsxs("dl",{className:"agent-image-meta",children:[e.jsxs("div",{children:[e.jsx("dt",{children:a("agent.filename")}),e.jsx("dd",{children:n?.filename??"-"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:a("agent.prompt")}),e.jsx("dd",{children:n?.prompt??n?.revisedPrompt??"-"})]})]})}function hn(t){const n=Math.max(0,Math.round(t));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Ye({image:t}){const{t:n}=x(),[a,s]=m.useState("loading"),[r,u]=m.useState(null),[o,i]=m.useState(0),d=h=>{const c=h.currentTarget.duration;u(Number.isFinite(c)?c:null),s("ready")},l=()=>{s("loading"),u(null),i(h=>h+1)};return e.jsxs("div",{className:"agent-video-preview",children:[a==="loading"?e.jsx("div",{className:"agent-video-preview__skeleton",role:"status",children:n("agent.mediaLoading")}):null,a==="error"?e.jsxs("div",{className:"agent-video-preview__error",role:"alert",children:[e.jsx(B,{size:34}),e.jsx("span",{children:n("agent.mediaLoadFailed")}),e.jsx("button",{type:"button",onClick:l,children:n("agent.mediaRetry")})]}):e.jsx("video",{src:t.url,controls:!0,playsInline:!0,preload:"metadata","aria-label":t.prompt??n("agent.mediaVideoLabel"),onLoadedMetadata:d,onError:()=>s("error")},o),e.jsxs("div",{className:"agent-video-preview__toolbar",children:[e.jsx("span",{children:r==null?n("agent.mediaDurationUnknown"):n("agent.mediaDuration",{duration:hn(r)})}),e.jsx("a",{href:t.url,download:t.filename,children:n("agent.mediaDownload")})]})]})}function Ze({currentImage:t,images:n,activeTab:a,onTabChange:s,onImageSelect:r,headerAction:u}){const{t:o}=x(),i=m.useRef({}),d=m.useMemo(()=>n.findIndex(c=>c.id===t?.id),[t?.id,n]);m.useEffect(()=>{t?.id&&i.current[t.id]?.scrollIntoView({block:"nearest",inline:"nearest"})},[t?.id]);const l=m.useCallback(c=>{const p=n[c];p&&r(p.id)},[n,r]),h=m.useCallback(c=>{if(n.length===0)return;const p=d>=0?d:0;let f=null;(c.key==="ArrowLeft"||c.key==="ArrowUp")&&(f=Math.max(0,p-1)),(c.key==="ArrowRight"||c.key==="ArrowDown")&&(f=Math.min(n.length-1,p+1)),c.key==="Home"&&(f=0),c.key==="End"&&(f=n.length-1),!(f===null||f===p)&&(c.preventDefault(),l(f))},[d,n.length,l]);return e.jsxs("section",{className:"agent-image","aria-label":o("agent.imagePane"),children:[e.jsxs("header",{className:"agent-pane-header",children:[e.jsxs("div",{className:"agent-pane-header__title",children:[e.jsx("span",{children:o("agent.imagePane")}),e.jsx("strong",{children:o("agent.currentImage")})]}),u]}),e.jsx("div",{className:"agent-image__preview",tabIndex:n.length>1?0:void 0,onKeyDown:h,"aria-label":n.length>1?o("agent.variants"):void 0,children:t?Se(t.url)?e.jsx(Ye,{image:t},t.id):e.jsx(Q,{src:t.url,alt:t.prompt??o("agent.imageAlt"),fallbackClassName:"agent-image__empty",iconSize:34}):e.jsxs("div",{className:"agent-image__empty",children:[e.jsx(B,{size:34}),e.jsx("span",{children:o("agent.noImage")})]})}),e.jsx("div",{className:"agent-image__variants","aria-label":o("agent.variants"),onKeyDown:h,children:n.map(c=>e.jsx(F,{ref:p=>{i.current[c.id]=p},image:c,selected:c.id===t?.id,onSelect:r},c.id))}),e.jsx(dn,{activeTab:a,onChange:s}),e.jsx(gn,{activeTab:a,currentImage:t})]})}function mn({open:t,currentImage:n,images:a,activeTab:s,onTabChange:r,onImageSelect:u,onClose:o}){const{t:i}=x(),d=m.useCallback(()=>o(),[o]),l=ue(t,d);return t?e.jsxs("div",{className:"agent-dialog agent-dialog--image",role:"presentation",children:[e.jsx("button",{type:"button",className:"agent-dialog__backdrop",onClick:o,"aria-label":i("agent.closeImage")}),e.jsx("section",{ref:l,className:"agent-image-sheet",role:"dialog","aria-modal":"true","aria-label":i("agent.imagePane"),children:e.jsx(Ze,{currentImage:n,images:a,activeTab:s,onTabChange:r,onImageSelect:u,headerAction:e.jsx("button",{type:"button",onClick:o,"aria-label":i("agent.closeImage"),children:e.jsx(de,{size:17})})})})]}):null}function pn(t){return t.status==="queued"?`#${t.position}`:t.status==="succeeded"?String(t.resultImageIds.length):""}function fn(t,n){if(!t)return"-";const a=Math.max(1,Math.round((Date.now()-t)/1e3));if(a<60)return n(a,"second");const s=Math.round(a/60);return s<60?n(s,"minute"):n(Math.round(s/60),"hour")}function xn(t){return!t.errorCode&&!t.errorClass&&!t.errorMessage?null:St({code:t.errorCode,errorClass:t.errorClass,message:t.errorMessage})}function jn(t,n){return t?.errorClass?t.spec.cardKey?n(`${t.spec.cardKey}.title`):t.spec.toastKey?n(t.spec.toastKey):null:null}function bn({item:t,onCancel:n,onRetry:a}){const{t:s}=x(),r=t.status==="queued"||t.status==="running",u=t.status==="failed"||t.status==="canceled",o=t.plan.plannedVariants||t.plan.prompts.length||1,i=t.plan.plannedParallelism||t.options.parallelism,d=pn(t),l=fn(t.createdAt,(c,p)=>s("agent.queueTimeAgo",{value:c,unit:s(`agent.queueTimeUnit.${p}`)})),h=jn(xn(t),s);return e.jsxs("div",{className:`agent-queue-row agent-queue-row--${t.status}`,children:[e.jsxs("div",{className:"agent-queue-row__main",children:[e.jsx("strong",{children:t.prompt}),e.jsx("span",{className:`agent-queue-row__badge agent-queue-row__badge--${t.status}`,children:s(`agent.queueStatus.${t.status}`)}),e.jsx("span",{children:[d,h,s("agent.queuePlanSummary",{variants:o,parallel:i}),l].filter(Boolean).join(" · ")}),t.plan.reason||t.errorCode||t.errorMessage?e.jsxs("details",{className:"agent-queue-row__details",children:[e.jsx("summary",{children:s("agent.queueDetails")}),t.plan.reason?e.jsx("small",{children:t.plan.reason}):null,t.errorCode?e.jsx("small",{children:t.errorCode}):null,t.errorMessage?e.jsx("small",{children:t.errorMessage}):null]}):null]}),e.jsxs("div",{className:"agent-queue-row__actions",children:[r?e.jsx("button",{type:"button",onClick:()=>n(t.id),children:s("agent.cancelQueue")}):null,u?e.jsx("button",{type:"button",onClick:()=>a(t.id),children:s("agent.retryQueue")}):null]})]})}function et({items:t,summary:n,onCancel:a,onRetry:s}){const{t:r}=x(),u=r("agent.queueAnnouncement",{running:n?.runningCount??0,queued:n?.queuedCount??0,failed:t.filter(o=>o.status==="failed").length});return e.jsxs("section",{className:"agent-sidebar-section","aria-label":r("agent.queue"),children:[e.jsx("header",{children:e.jsxs("div",{children:[e.jsx("span",{children:r("agent.queue")}),e.jsxs("strong",{children:[n?.runningCount??0," ",r("agent.runningShort")," · ",n?.queuedCount??0," ",r("agent.queuedShort")]})]})}),e.jsxs("div",{className:"agent-queue-list",children:[e.jsx("span",{className:"agent-sr-only","aria-live":"polite","aria-atomic":"true",children:u}),t.length===0?e.jsx("div",{className:"agent-tab-empty",children:r("agent.queueEmpty")}):t.map(o=>e.jsx(bn,{item:o,onCancel:a,onRetry:s},o.id))]})]})}function yn({open:t,items:n,summary:a,onCancel:s,onRetry:r,onClose:u}){const{t:o}=x(),i=m.useCallback(()=>u(),[u]),d=ue(t,i);return t?e.jsxs("div",{className:"agent-dialog agent-dialog--queue",role:"presentation",children:[e.jsx("button",{type:"button",className:"agent-dialog__backdrop",onClick:u,"aria-label":o("agent.topbarCloseQueue")}),e.jsxs("section",{ref:d,className:"agent-queue-sheet",role:"dialog","aria-modal":"true","aria-label":o("agent.topbarQueueSheet"),children:[e.jsxs("header",{children:[e.jsx("strong",{children:o("agent.topbarQueueSheet")}),e.jsx("button",{type:"button",onClick:u,"aria-label":o("agent.topbarCloseQueue"),children:e.jsx(de,{size:17})})]}),e.jsx(et,{items:n,summary:a,onCancel:s,onRetry:r})]})]}):null}function tt({mode:t,onInsert:n}){const{t:a}=x(),s=E(l=>l.promptLibrary),r=E(l=>l.promptLibraryLoading),u=E(l=>l.loadPromptLibrary),[o,i]=m.useState("");m.useEffect(()=>{u()},[u]);const d=m.useMemo(()=>{const l=o.trim().toLowerCase();return s.prompts.filter(h=>{const c=h.tags.map(p=>p.toLowerCase());return t==="forms"&&!c.includes("agent:form")?!1:l?h.name.toLowerCase().includes(l)||h.text.toLowerCase().includes(l)||c.some(p=>p.includes(l)):!0})},[s.prompts,t,o]);return e.jsxs("section",{className:"agent-sidebar-section","aria-label":a(t==="forms"?"agent.forms":"agent.promptLibrary"),children:[e.jsx("header",{children:e.jsxs("div",{children:[e.jsx("span",{children:a(t==="forms"?"agent.forms":"agent.promptLibrary")}),e.jsx("strong",{children:d.length})]})}),e.jsxs("label",{className:"agent-sidebar-search",children:[e.jsx("span",{children:a("promptLibrary.search")}),e.jsx("input",{value:o,onChange:l=>i(l.target.value),placeholder:a("promptLibrary.search")})]}),e.jsxs("div",{className:"agent-prompt-library-list",children:[r?e.jsx("div",{className:"agent-tab-empty",children:a("common.loading")}):null,!r&&d.length===0?e.jsx("div",{className:"agent-tab-empty",children:a(t==="forms"?"agent.noForms":"promptLibrary.empty")}):null,d.map(l=>e.jsxs("article",{className:"agent-prompt-library-row",children:[e.jsx("strong",{children:l.name||a("promptLibrary.untitled")}),e.jsx("p",{children:l.text}),e.jsx("button",{type:"button",onClick:()=>n(l.text),children:a("agent.insertPrompt")})]},l.id))]})]})}function vn({onInsert:t}){return e.jsx(tt,{mode:"forms",onInsert:t})}function te({label:t,value:n,options:a,onChange:s}){return e.jsxs("div",{className:"agent-settings-grid__field",children:[e.jsx("span",{children:t}),e.jsx("div",{className:"agent-segment-control",role:"group","aria-label":t,children:a.map(r=>e.jsx("button",{type:"button","aria-pressed":r.value===n,onClick:()=>s(r.value),children:r.label},r.value))})]})}function be({label:t,value:n,max:a,onChange:s}){return e.jsxs("div",{className:"agent-settings-grid__field",children:[e.jsx("span",{children:t}),e.jsxs("div",{className:"agent-stepper",role:"group","aria-label":t,children:[e.jsx("button",{type:"button","aria-label":`${t} -`,disabled:n<=1,onClick:()=>s(Math.max(1,n-1)),children:"-"}),e.jsx("output",{"aria-live":"polite",children:n}),e.jsx("button",{type:"button","aria-label":`${t} +`,disabled:n>=a,onClick:()=>s(Math.min(a,n+1)),children:"+"})]})]})}function Sn({settings:t,onChange:n}){const{t:a}=x();return e.jsxs("section",{className:"agent-settings-grid","aria-label":a("agent.quality"),children:[e.jsx(te,{label:a("agent.generationStrategy"),value:t.generationStrategy,options:[{value:"auto",label:a("agent.generationStrategyAuto")},{value:"manual",label:a("agent.generationStrategyManual")}],onChange:s=>n({generationStrategy:s})}),e.jsx(te,{label:a("agent.quality"),value:t.quality,options:[{value:"low",label:"low"},{value:"medium",label:"medium"},{value:"high",label:"high"}],onChange:s=>n({quality:s})}),e.jsx(te,{label:a("agent.size"),value:t.size,options:[{value:"1024x1024",label:"1:1"},{value:"1536x1024",label:"3:2"},{value:"1024x1536",label:"2:3"},{value:"2048x2048",label:"2K"}],onChange:s=>n({size:s})}),e.jsx(te,{label:a("agent.format"),value:t.format,options:[{value:"png",label:"PNG"},{value:"jpeg",label:"JPEG"},{value:"webp",label:"WebP"}],onChange:s=>n({format:s})}),e.jsx(te,{label:a("agent.moderation"),value:t.moderation,options:[{value:"auto",label:"auto"},{value:"low",label:"low"}],onChange:s=>n({moderation:s})}),t.generationStrategy==="manual"?e.jsx(be,{label:a("agent.variantsCount"),value:t.variants,max:ve,onChange:s=>n({variants:s})}):e.jsx(be,{label:a("agent.maxAutoVariants"),value:t.maxAutoVariants,max:ve,onChange:s=>n({maxAutoVariants:s})}),e.jsx(be,{label:a("agent.parallelism"),value:t.parallelism,max:It,onChange:s=>n({parallelism:s})})]})}const _n=["image","library","forms","quality","model","queue"];function wn({activeTab:t,onChange:n}){const{t:a}=x();return e.jsx("div",{className:"agent-sidebar-tabs",role:"tablist","aria-label":a("agent.rightSidebar"),children:_n.map(s=>e.jsx("button",{type:"button",role:"tab",id:`agent-sidebar-tab-${s}`,"aria-controls":`agent-sidebar-panel-${s}`,className:t===s?"active":"","aria-selected":t===s,onClick:()=>n(s),children:a(`agent.sidebarTabs.${s}`)},s))})}function Oe({currentImage:t,images:n,contextTab:a,sidebarTab:s,queueItems:r,runSummary:u,settings:o,onContextTabChange:i,onSidebarTabChange:d,onImageSelect:l,onSettingsChange:h,onInsertPrompt:c,onCancelQueue:p,onRetryQueue:f}){const{t:v}=x(),S=C=>({id:`agent-sidebar-panel-${C}`,role:"tabpanel","aria-labelledby":`agent-sidebar-tab-${C}`});return e.jsxs(e.Fragment,{children:[e.jsx(wn,{activeTab:s,onChange:d}),s==="image"?e.jsx("div",{...S("image"),className:"agent-sidebar-panel",children:e.jsx(Ze,{currentImage:t,images:n,activeTab:a,onTabChange:i,onImageSelect:l})}):null,s==="library"?e.jsx("div",{...S("library"),className:"agent-sidebar-panel",children:e.jsx(tt,{mode:"library",onInsert:c})}):null,s==="forms"?e.jsx("div",{...S("forms"),className:"agent-sidebar-panel",children:e.jsx(vn,{onInsert:c})}):null,s==="quality"?e.jsxs("section",{...S("quality"),className:"agent-sidebar-panel agent-sidebar-section","aria-label":v("agent.quality"),children:[e.jsx("header",{children:e.jsxs("div",{children:[e.jsx("span",{children:v("agent.quality")}),e.jsx("strong",{children:o.generationStrategy==="auto"?v("agent.generationStrategyAuto"):v("agent.generationStrategyManual")})]})}),e.jsx(Sn,{settings:o,onChange:h})]}):null,s==="model"?e.jsxs("section",{...S("model"),className:"agent-sidebar-panel agent-sidebar-section","aria-label":v("agent.modelSettings"),children:[e.jsx("header",{children:e.jsxs("div",{children:[e.jsx("span",{children:v("agent.modelSettings")}),e.jsx("strong",{children:o.model})]})}),e.jsx(Xe,{settings:o,onChange:h})]}):null,s==="queue"?e.jsx("div",{...S("queue"),className:"agent-sidebar-panel",children:e.jsx(et,{items:r,summary:u,onCancel:p,onRetry:f})}):null]})}const Nn=()=>{};function ze({overlay:t,onClose:n,...a}){const{t:s}=x(),r=ue(t===!0,n??Nn);return t?e.jsxs("div",{className:"agent-dialog agent-dialog--tools",role:"presentation",children:[e.jsx("button",{type:"button",className:"agent-dialog__backdrop",onClick:n,"aria-label":s("agent.closeTools")}),e.jsxs("section",{ref:r,className:"agent-right-sidebar agent-right-sidebar--overlay",role:"dialog","aria-modal":"true","aria-label":s("agent.openTools"),children:[e.jsxs("header",{className:"agent-right-sidebar__overlay-header",children:[e.jsx("strong",{children:s("agent.openTools")}),e.jsx("button",{type:"button",onClick:n,"aria-label":s("agent.closeTools"),children:e.jsx(de,{size:17})})]}),e.jsx(Oe,{...a})]})]}):e.jsx("aside",{className:"agent-right-sidebar",children:e.jsx(Oe,{...a})})}function nt({summary:t}){const{t:n}=x();if(!t||t.status==="idle")return null;const a=t.status==="running"?n("agent.sessionRunning"):t.status==="queued"?n("agent.sessionQueued",{count:t.queuedCount}):n("agent.sessionError");return e.jsxs("span",{className:`agent-session-spinner agent-session-spinner--${t.status}`,"data-motion-essential":!0,"aria-label":a,title:a,children:[e.jsx("span",{"aria-hidden":"true"}),t.queuedCount>0?e.jsx("em",{children:t.queuedCount}):null]})}function Cn(t){const n=Math.max(1,Math.round((Date.now()-t)/6e4));if(n<60)return`${n}m`;const a=Math.round(n/60);return a<24?`${a}h`:`${Math.round(a/24)}d`}function kn({sessions:t,selectedId:n,imagesById:a,runSummaryBySession:s={},onSelect:r,onRename:u,onDelete:o}){const{t:i}=x();return e.jsx("div",{className:"agent-session-list",children:t.map(d=>{const l=d.lastImageId?a[d.lastImageId]:null;return e.jsxs("div",{className:`agent-session-row${d.id===n?" is-active":""}`,children:[e.jsxs("button",{type:"button","aria-current":d.id===n?"page":void 0,onClick:()=>r(d.id),children:[e.jsx("span",{className:"agent-session-row__thumb",children:l?e.jsx(Q,{src:l.thumbUrl??l.url,alt:"",iconSize:17}):e.jsx(B,{size:17})}),e.jsxs("span",{className:"agent-session-row__body",children:[e.jsx("strong",{children:d.title}),e.jsxs("span",{children:[i("agent.imageCount",{count:d.imageCount})," · ",Cn(d.updatedAt)]})]}),e.jsxs("span",{className:"agent-session-row__badges",children:[e.jsx(nt,{summary:s[d.id]}),d.webSearchEnabled?e.jsx("em",{title:i("agent.web"),children:"W"}):null,d.compacted?e.jsx("em",{title:i("agent.compacted"),children:"C"}):null]})]}),e.jsxs("div",{className:"agent-session-row__actions",children:[e.jsx("button",{type:"button",onClick:()=>u(d.id),"aria-label":i("agent.renameSession"),title:i("agent.renameSession"),children:e.jsx(Ot,{size:14})}),e.jsx("button",{type:"button",onClick:()=>o(d.id),"aria-label":i("agent.deleteSession"),title:i("agent.deleteSession"),children:e.jsx(Bt,{size:14})})]})]},d.id)})})}function In({open:t,sessions:n,selectedId:a,imagesById:s,runSummaryBySession:r,onClose:u,onCreate:o,onSelect:i,onRename:d,onDelete:l}){const{t:h}=x(),[c,p]=m.useState(""),f=m.useCallback(()=>u(),[u]),v=ue(t,f),S=m.useMemo(()=>{const C=c.trim().toLowerCase();return C?n.filter(q=>q.title.toLowerCase().includes(C)):n},[c,n]);return t?e.jsxs("div",{className:"agent-dialog agent-dialog--drawer",role:"presentation",children:[e.jsx("button",{type:"button",className:"agent-dialog__backdrop",onClick:u,"aria-label":h("agent.closeSessions")}),e.jsxs("section",{ref:v,className:"agent-session-drawer",role:"dialog","aria-modal":"true","aria-label":h("agent.sessions"),children:[e.jsxs("header",{children:[e.jsx("strong",{children:h("agent.sessions")}),e.jsx("button",{type:"button",onClick:u,"aria-label":h("agent.closeSessions"),children:e.jsx(de,{size:17})})]}),e.jsxs("button",{type:"button",className:"agent-sessions__create",onClick:o,children:[e.jsx(Ke,{size:16}),e.jsx("span",{children:h("agent.newSession")})]}),e.jsxs("label",{className:"agent-sessions__search",children:[e.jsx(Et,{size:15}),e.jsx("input",{value:c,onChange:C=>p(C.target.value),placeholder:h("agent.sessionSearch")})]}),e.jsx(kn,{sessions:S,selectedId:a,imagesById:s,runSummaryBySession:r,onSelect:i,onRename:d,onDelete:l})]})]}):null}function An({sessions:t,selectedId:n,imagesById:a,runSummaryBySession:s={},onCreate:r,onSelect:u,onOpenDrawer:o}){const{t:i}=x();return e.jsxs("aside",{className:"agent-rail","aria-label":i("agent.sessions"),children:[e.jsx("button",{type:"button",onClick:o,"aria-label":i("agent.openSessions"),title:i("agent.openSessions"),children:e.jsx(Ue,{size:17})}),e.jsx("button",{type:"button",onClick:r,"aria-label":i("agent.newSession"),title:i("agent.newSession"),children:e.jsx(Ke,{size:17})}),e.jsx("div",{className:"agent-rail__sessions",children:t.map(d=>{const l=d.lastImageId?a[d.lastImageId]:null,h=`${d.title} — ${i("agent.imageCount",{count:d.imageCount})}`;return e.jsxs("button",{type:"button",className:d.id===n?"is-active":"",onClick:()=>u(d.id),title:h,"aria-label":h,"aria-current":d.id===n?"true":void 0,children:[l?e.jsx(Q,{src:l.thumbUrl??l.url,alt:"",iconSize:17}):e.jsx(B,{size:17}),e.jsx(nt,{summary:s[d.id]}),d.compacted?e.jsx("span",{"aria-label":i("agent.compacted")}):null]},d.id)})})]})}function Tn({currentImage:t,images:n,onImageSelect:a,onOpenPanel:s}){const{t:r}=x(),u=m.useRef({}),o=m.useMemo(()=>n.findIndex(l=>l.id===t?.id),[t?.id,n]);m.useEffect(()=>{t?.id&&u.current[t.id]?.scrollIntoView({block:"nearest",inline:"nearest"})},[t?.id]);const i=m.useCallback(l=>{const h=n[l];h&&a(h.id)},[n,a]),d=m.useCallback(l=>{if(n.length===0)return;const h=o>=0?o:0;let c=null;(l.key==="ArrowLeft"||l.key==="ArrowUp")&&(c=Math.max(0,h-1)),(l.key==="ArrowRight"||l.key==="ArrowDown")&&(c=Math.min(n.length-1,h+1)),l.key==="Home"&&(c=0),l.key==="End"&&(c=n.length-1),!(c===null||c===h)&&(l.preventDefault(),i(c))},[o,n.length,i]);return e.jsxs("section",{className:"agent-stage","aria-label":r("agent.imagePane"),children:[e.jsxs("header",{className:"agent-pane-header",children:[e.jsxs("div",{className:"agent-pane-header__title",children:[e.jsx("span",{children:r("agent.imagePane")}),e.jsx("strong",{children:r("agent.currentImage")})]}),e.jsx("button",{type:"button",className:"agent-stage__tools",onClick:s,"aria-label":r("agent.openTools"),title:r("agent.openTools"),children:e.jsx(zt,{size:16})})]}),e.jsx("div",{className:"agent-stage__viewport",tabIndex:n.length>1?0:void 0,onKeyDown:d,"aria-label":n.length>1?r("agent.variants"):void 0,children:t?Se(t.url)?e.jsx(Ye,{image:t},t.id):e.jsx(Q,{src:t.url,alt:t.prompt??r("agent.imageAlt"),fallbackClassName:"agent-stage__empty",iconSize:34}):e.jsxs("div",{className:"agent-stage__empty",children:[e.jsx(B,{size:34}),e.jsx("span",{children:r("agent.noImage")}),e.jsx("small",{children:r("agent.stageEmptyHint")})]})}),e.jsxs("div",{className:"agent-stage__caption",children:[e.jsx("strong",{children:t?.filename??"-"}),e.jsx("span",{children:t?.prompt??t?.revisedPrompt??""})]}),e.jsx("div",{className:"agent-stage__filmstrip","aria-label":r("agent.variants"),onKeyDown:d,children:n.map(l=>e.jsx(F,{ref:h=>{u.current[l.id]=h},image:l,selected:l.id===t?.id,onSelect:a},l.id))})]})}function We({layoutMode:t,session:n,currentImage:a,activeJobCount:s,onOpenSessions:r,onOpenImage:u,onOpenQueue:o}){const{t:i}=x(),d=E(h=>h.setUIMode),l=t==="mobile-chat-image-sheet";return e.jsxs("header",{className:"agent-topbar",children:[e.jsxs("button",{type:"button",className:"agent-topbar__back",onClick:()=>d("classic"),"aria-label":i("agent.topbarBackToStudio"),title:i("agent.topbarBackToStudio"),children:[e.jsx(Pt,{size:18}),e.jsx("span",{children:i("agent.topbarStudio")})]}),e.jsx("button",{type:"button",className:"agent-topbar__icon",onClick:r,"aria-label":i("agent.openSessions"),title:i("agent.openSessions"),children:e.jsx(Ue,{size:18})}),e.jsxs("div",{className:"agent-topbar__title",children:[e.jsx("span",{children:i("agent.title")}),e.jsx("strong",{children:n?.title??i("agent.newSession")})]}),l?e.jsxs("div",{className:"agent-topbar__actions",children:[e.jsxs("button",{type:"button",className:"agent-topbar__queue",onClick:o,"aria-label":i("agent.topbarOpenQueue",{count:s}),title:i("agent.topbarOpenQueue",{count:s}),children:[e.jsx(Dt,{size:17}),e.jsx("span",{children:s})]}),e.jsx("button",{type:"button",className:"agent-topbar__image",onClick:u,"aria-label":i("agent.openImage"),title:i("agent.openImage"),children:a?e.jsx(Q,{src:a.thumbUrl??a.url,alt:"",iconSize:18}):e.jsx(B,{size:18})})]}):null]})}async function Ln({sessionId:t,files:n,importLocalImageToHistory:a,applyWorkspace:s}){for(const r of n){const u=await a(r),o=u?Ge(u):null;if(!o)continue;const i=await ie(t,{currentImage:o});s(i)}}const we="agent-local-",Mn=`${we}pending-`;let Qe=0;function Ne(t){return Qe+=1,`${we}${t}-${Date.now()}-${Qe}`}function at(t){return t.id.startsWith(we)}function oe(t){return t.id.startsWith(Mn)}function En(t,n){return{id:Ne("user"),role:"user",text:t,imageIds:[],webFindingIds:[],status:"complete",createdAt:n}}function qn(t,n){return{id:Ne("pending"),role:"assistant",text:t,imageIds:[],webFindingIds:[],status:"streaming",createdAt:n}}function Rn(t){return{id:Ne("error"),role:"assistant",text:t,imageIds:[],webFindingIds:[],status:"error",createdAt:Date.now()}}function $n({turns:t,queueItems:n,runSummary:a,localPendingCount:s}){const r=n.filter(i=>i.status==="failed").length,u=Pn(n),o=u?Dn(u):{};if(a?.status==="error"&&a.lastError)return{active:!0,status:"error",labelKey:"runError",queuedCount:a.queuedCount,runningCount:a.runningCount,failedCount:r,lastError:a.lastError};if(a?.status==="queued")return{active:!0,status:"queued",labelKey:"pendingQueued",queuedCount:a.queuedCount,runningCount:a.runningCount,failedCount:r,...o};if(a?.status==="running"){const i=u?.startedAt??u?.createdAt??null,d=t.some(l=>!at(l)&&l.role==="tool"&&(!i||(l.createdAt??0)>=i));return{active:!0,status:d?"running":"planning",labelKey:d?"pendingGenerating":"pendingPlanning",queuedCount:a.queuedCount,runningCount:a.runningCount,failedCount:r,...o}}return s>0?{active:!0,status:"planning",labelKey:"pendingPlanning",queuedCount:a?.queuedCount??0,runningCount:a?.runningCount??0,failedCount:r}:null}function Pn(t){return[...t].filter(n=>n.status==="running"||n.status==="queued").sort((n,a)=>n.status!==a.status?n.status==="running"?-1:1:(n.startedAt??n.createdAt)-(a.startedAt??a.createdAt))[0]??null}function Dn(t){return{startedAt:t.startedAt??null,progressStage:t.progressStage??null,jobKind:t.plan.mode==="video"||t.plan.videoParams?"video":"image",variantCount:t.plan.plannedVariants||t.plan.prompts.length||1}}function ye(){return{sessions:[],turnsBySession:{},imagesById:{},imageIdsBySession:{},selectedSessionId:null,currentImageId:null,allowedTools:["ima2.get_image_context","ima2.web_search","ima2.generate_image","ima2.generate_video","ima2.get_generation_errors"],manifest:null,queueBySession:{},runSummaryBySession:{}}}function Bn(t){const n=t.filename.endsWith(".mp4");return{image:t.url,url:t.url,filename:t.filename,thumb:t.thumbUrl??void 0,prompt:t.prompt??void 0,revisedPrompt:t.revisedPrompt??null,createdAt:t.createdAt,mediaType:n?"video":"image",kind:"agent"}}function On(t,n,a){return{...t,turnsBySession:{...t.turnsBySession,[n]:[...t.turnsBySession[n]??[],...a]}}}function zn(t,n,a,s){const r=t.turnsBySession[n]??[];return{...t,turnsBySession:{...t.turnsBySession,[n]:[...r.filter(u=>u.id!==a),Rn(s)]}}}function Wn(t,n,a){const s={...n.turnsBySession};for(const[r,u]of Object.entries(t.turnsBySession)){const o=s[r]??[],i=new Set(o.map(h=>h.id)),d=Math.max(0,...o.map(h=>h.createdAt??0)),l=u.filter(h=>a.has(h.id)||i.has(h.id)?!1:at(h)||h.status==="streaming"?!0:(h.createdAt??0)>=d);l.length>0&&(s[r]=[...o,...l])}return{...n,turnsBySession:s}}function Gn(){const{t}=x(),n=Mt(),a=E(g=>g.currentImage),s=E(g=>g.importLocalImageToHistory),r=E(g=>g.addHistoryItem),u=E(g=>g.selectHistory),o=E(g=>g.showToast),i=m.useRef(!1),d=m.useRef(0),l=m.useRef(0),h=m.useRef(null),[c,p]=m.useState(()=>ye()),[f,v]=m.useState(null),[S,C]=m.useState("image"),[q,G]=m.useState("image"),[K,T]=m.useState(null),[O,A]=m.useState(!1),[ge,U]=m.useState(!1),[H,V]=m.useState(!1),[b,M]=m.useState(!1),[st,R]=m.useState("reconnecting"),[he,me]=m.useState(null),z=m.useCallback(g=>g instanceof Error?g.message:String(g),[]),rt=m.useCallback(()=>M(!1),[]),L=m.useCallback(g=>{o(t("agent.workspaceActionFailed",{reason:z(g)}),!0)},[z,o,t]),J=m.useCallback(g=>{p({...ye(),...g}),v(g.selectedSessionId??null)},[]),ne=m.useCallback((g,j)=>{const y={...ye(),...g};p(_=>Wn(_,y,j)),v(g.selectedSessionId??null)},[]),$=m.useCallback(g=>{d.current+=1,J(g)},[J]),lt=m.useCallback((g,j)=>{d.current+=1,ne(g,j)},[ne]),ot=()=>{l.current+=1,R("generating")},it=()=>{l.current=Math.max(0,l.current-1),l.current===0&&R("ready")},ae=m.useCallback(async g=>{const j=++d.current;R("reconnecting"),me(null);const y=await qe(g);if(j!==d.current)return;if(y.sessions.length>0){J(y),R("ready");return}const _=await Re({title:t("agent.newSession"),currentImage:a});j===d.current&&(J(_),R("ready"))},[J,a,t]),Ce=m.useCallback(async g=>{const j=++d.current,y=await qe(g);j===d.current&&(ne(y,new Set),R("ready"))},[ne]);m.useEffect(()=>{i.current||(i.current=!0,ae().catch(g=>{me(z(g)),R("reconnecting")}))},[z,ae]);const X=c.sessions.find(g=>g.id===f)??null,Y=c.currentImageId?c.imagesById[c.currentImageId]??null:null,se=f?(c.imageIdsBySession[f]??[]).map(g=>c.imagesById[g]).filter(g=>!!g):[],pe=X?c.turnsBySession[X.id]??[]:[],ct=pe.filter(oe).length,ut=pe.filter(g=>!oe(g)),W=f?c.queueBySession[f]??[]:[],k=f?c.runSummaryBySession[f]:void 0,dt=W.filter(g=>g.status==="queued"||g.status==="running").length,gt=$n({turns:pe,queueItems:W,runSummary:k,localPendingCount:ct}),Z=$e(X?.generationSettings),ht=st==="reconnecting"?"reconnecting":l.current>0||k?.status==="queued"||k?.status==="running"?"generating":"ready",mt=n!=="mobile-chat-image-sheet",ke=n==="desktop-three-pane"||n==="desktop-rail",Ie=n==="tablet-stacked"||n==="mobile-chat-image-sheet",pt=n==="desktop-three-pane"||n==="desktop-rail";m.useEffect(()=>{const g=Object.keys(c.imagesById);if(!h.current){(g.length>0||c.sessions.length>0)&&(h.current=new Set(g));return}const j=h.current,y=g.filter(w=>!j.has(w)).map(w=>c.imagesById[w]).filter(w=>!!w);if(y.length===0)return;for(const w of g)j.add(w);const _=y.map(Bn);for(const w of _)r(w);const P=_.reduce((w,I)=>(I.createdAt??0)>(w.createdAt??0)?I:w);u(P)},[c.imagesById,c.sessions.length,r,u]),m.useEffect(()=>{p(g=>{if(l.current>0)return g;let j=!1;const y={...g.turnsBySession};for(const[_,P]of Object.entries(y)){if(P.filter(oe).length===0)continue;const I=g.runSummaryBySession[_];I?.status==="queued"||I?.status==="running"||(y[_]=P.filter(xe=>!oe(xe)),j=!0)}return j?{...g,turnsBySession:y}:g})},[c.turnsBySession,c.runSummaryBySession]),m.useEffect(()=>{if(!f)return;const g=k?.status==="queued"||k?.status==="running",j=window.setInterval(()=>{Ce(f).catch(()=>R("reconnecting"))},g?1500:4e3);return()=>window.clearInterval(j)},[Ce,f,k?.queuedCount,k?.runningCount,k?.status]);const Ae=g=>{A(!1),V(!1),ae(g).catch(L)},Te=()=>{Re({title:t("agent.newSession"),currentImage:null}).then($).catch(L)},ft=g=>{const j=c.sessions.find(_=>_.id===g),y=window.prompt(t("agent.renameSession"),j?.title??"");y?.trim()&&ie(g,{title:y.trim()}).then($).catch(L)},xt=g=>{const j=c.sessions.find(y=>y.id===g);!j||!window.confirm(t("agent.deleteConfirm",{title:j.title}))||wt(g).then($).catch(L)},re=g=>{if(!f)return;const j=$e({...Z,...g});p(y=>({...y,sessions:y.sessions.map(_=>_.id===f?{..._,generationSettings:j,webSearchEnabled:j.webSearchEnabled}:_)})),ie(f,{generationSettings:g}).then($).catch(L)},jt=g=>{re({webSearchEnabled:g})},ee=g=>{if(!f||c.currentImageId===g)return;const j=f;p(y=>({...y,currentImageId:g})),ie(j,{currentImageId:g}).then($).catch(L)},Le=g=>{T({id:Date.now(),text:g})},fe=g=>{Ct(g).then($).catch(L)},le=g=>{kt(g).then($).catch(L)},Me=k?.status==="error"?W.find(g=>g.status==="failed")?.id:void 0,bt=Me?()=>le(Me):void 0,yt=g=>{!f||g.length===0||Ln({sessionId:f,files:g,importLocalImageToHistory:s,applyWorkspace:$}).catch(L)},vt=g=>{if(!f)return;const j=f,y=Date.now(),_=En(g,y),P=qn(t("agent.pending"),y+1),w=new Set([_.id]);ot(),p(I=>On(I,j,[_,P])),Nt(j,g,Z).then(I=>lt(I.workspace,w)).catch(I=>{const Ee=z(I);p(xe=>zn(xe,j,P.id,Ee)),L(I)}).finally(it)};return he?e.jsxs("main",{className:`agent-workspace agent-workspace--${n} agent-workspace--boot-error`,"data-layout":n,"aria-label":t("agent.workspace"),children:[Ie?e.jsx(We,{layoutMode:n,session:null,currentImage:null,activeJobCount:0,onOpenSessions:()=>{},onOpenImage:()=>{},onOpenQueue:()=>{}}):null,e.jsxs("section",{className:"agent-workspace__boot-error",role:"alert",children:[e.jsx("strong",{children:t("agent.bootFailed")}),e.jsx("span",{title:he,children:he}),e.jsx("button",{type:"button",onClick:()=>{ae().catch(g=>me(z(g)))},children:t("agent.bootRetry")})]})]}):e.jsxs("main",{className:`agent-workspace agent-workspace--${n}`,"data-layout":n,"aria-label":t("agent.workspace"),children:[pt?e.jsx("div",{className:"agent-session-rail-wrap",children:e.jsx(An,{sessions:c.sessions,selectedId:f??"",imagesById:c.imagesById,runSummaryBySession:c.runSummaryBySession,onCreate:Te,onSelect:Ae,onOpenDrawer:()=>A(!0)})}):null,Ie?e.jsx(We,{layoutMode:n,session:X,currentImage:Y,activeJobCount:dt,onOpenSessions:()=>A(!0),onOpenImage:()=>U(!0),onOpenQueue:()=>V(!0)}):null,e.jsxs("div",{className:"agent-workspace__body",children:[e.jsx(cn,{session:X,turns:ut,imagesById:c.imagesById,currentImageId:c.currentImageId,runtimeStatus:ht,runProgress:gt,settings:Z,insertedPrompt:K,onSettingsChange:re,onOpenModelTab:()=>{G("model"),M(!0)},onWebSearchChange:jt,onAttachFiles:yt,onImageSelect:ee,onSend:vt,onRetryRun:bt}),ke?e.jsx(Tn,{currentImage:Y,images:se,onImageSelect:ee,onOpenPanel:()=>M(!0)}):mt?e.jsx(ze,{currentImage:Y,images:se,contextTab:S,sidebarTab:q,queueItems:W,runSummary:k,settings:Z,onContextTabChange:C,onSidebarTabChange:G,onImageSelect:ee,onSettingsChange:re,onInsertPrompt:Le,onCancelQueue:fe,onRetryQueue:le}):null]}),ke&&b?e.jsx(ze,{overlay:!0,onClose:rt,currentImage:Y,images:se,contextTab:S,sidebarTab:q,queueItems:W,runSummary:k,settings:Z,onContextTabChange:C,onSidebarTabChange:G,onImageSelect:ee,onSettingsChange:re,onInsertPrompt:Le,onCancelQueue:fe,onRetryQueue:le}):null,e.jsx(In,{open:O,sessions:c.sessions,selectedId:f??"",imagesById:c.imagesById,runSummaryBySession:c.runSummaryBySession,onClose:()=>A(!1),onCreate:Te,onSelect:Ae,onRename:ft,onDelete:xt}),e.jsx(mn,{open:ge,currentImage:Y,images:se,activeTab:S,onTabChange:C,onImageSelect:ee,onClose:()=>U(!1)}),e.jsx(yn,{open:H,items:W,summary:k,onCancel:fe,onRetry:le,onClose:()=>V(!1)})]})}export{Gn as AgentWorkspace};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SpriteRecipeWorkspace-_WcHPSd4.js","assets/index-BKW7WOYj.js","assets/index-waPOg2eb.css","assets/KeyingPanel-2-wMdwa8.js","assets/useAgentDialogFocus-CxsC04Sp.js"])))=>i.map(i=>d[i]);
2
- import{u as v,b as a,a as d,a6 as q,j as e,a7 as H,a5 as z,a8 as $,a9 as U,aa as Q}from"./index-BKW7WOYj.js";import{K as Z,A as J}from"./KeyingPanel-2-wMdwa8.js";const X=48;function Y({selectedAssetId:t,onPreview:u}){const{t:i}=v(),l=a(r=>r.selectedProjectId),o=a(r=>r.assetGenItems.length),[b,m]=d.useState([]),[g,c]=d.useState(!1);return d.useEffect(()=>{let r=!1;return q({kind:null,folderId:l,tag:null,q:"",limit:X}).then(p=>{r||(m(p.assets.filter(h=>h.filePath&&(h.kind==="image"||h.kind==="video"))),c(!1))}).catch(()=>{r||c(!0)}),()=>{r=!0}},[l,o]),e.jsxs("aside",{className:"assetgen-rail","aria-label":i("assetGen.railTitle"),children:[e.jsx("h2",{className:"assetgen-rail__title",children:i("assetGen.railTitle")}),g?e.jsx("p",{className:"assetgen-rail__empty",children:i("assetGen.railError")}):b.length===0?e.jsx("p",{className:"assetgen-rail__empty",children:i("assetGen.railEmpty")}):e.jsx("div",{className:"assetgen-rail__list",role:"listbox","aria-label":i("assetGen.railTitle"),children:b.map(r=>{const p=r.filePath?H(r.filePath):null;if(!p)return null;const h=t===r.id;return e.jsxs("button",{type:"button",role:"option","aria-selected":h,className:`assetgen-rail__tile${h?" is-selected":""}`,title:r.name,onClick:()=>u(z(r),r.id),children:[r.kind==="video"?e.jsx("video",{src:p,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:p,alt:"",loading:"lazy",decoding:"async"}),e.jsx("span",{className:"assetgen-rail__name",children:r.name})]},r.id)})})]})}const ee=[{value:"chroma-green",swatch:"#00c853",labelKey:"assetGen.bgChroma"},{value:"white",swatch:"#ffffff",labelKey:"assetGen.bgWhite"},{value:"black",swatch:"#111111",labelKey:"assetGen.bgBlack"}];function se(){const{t}=v(),u=a(l=>l.assetGenBackground),i=a(l=>l.setAssetGenBackground);return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-bg-label",children:t("assetGen.background")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-bg-label",children:ee.map(l=>e.jsxs("button",{type:"button",className:u===l.value?"is-active":"","aria-pressed":u===l.value,onClick:()=>i(l.value),children:[e.jsx("span",{className:"assetgen-bg-picker__swatch",style:{background:l.swatch},"aria-hidden":"true"}),t(l.labelKey)]},l.value))}),e.jsx("p",{className:"assetgen-field__hint",children:t("assetGen.backgroundHint")})]})}const te=[{value:"oauth",labelKey:"assetGen.modelGpt"},{value:"grok",labelKey:"assetGen.modelGrok"}];function ae(){const{t}=v(),u=a(o=>o.assetGenProvider),i=a(o=>o.setAssetGenProvider),l=u==="grok"||u==="grok-api"?"grok":"oauth";return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-model-label",children:t("assetGen.model")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-model-label",children:te.map(o=>e.jsx("button",{type:"button",className:l===o.value?"is-active":"","aria-pressed":l===o.value,onClick:()=>i(o.value),children:t(o.labelKey)},o.value))})]})}function ne({onClose:t,onSelect:u}){const{t:i}=v(),l=a(c=>c.assetsFolders),[o,b]=d.useState(""),m=d.useRef(null);d.useEffect(()=>{m.current?.focus();const c=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[t]);const g=d.useMemo(()=>{const c=l.filter(p=>p.parentId===null),r=o.trim().toLowerCase();return r?c.filter(p=>p.name.toLowerCase().includes(r)):c},[l,o]);return e.jsx("div",{className:"assetgen-popup-backdrop",onClick:t,children:e.jsxs("div",{className:"assetgen-popup",role:"dialog","aria-modal":"true","aria-label":i("project.search"),onClick:c=>c.stopPropagation(),children:[e.jsx("input",{ref:m,type:"search",value:o,placeholder:i("project.searchPlaceholder"),"aria-label":i("project.search"),onChange:c=>b(c.target.value)}),e.jsxs("ul",{role:"listbox","aria-label":i("project.select"),children:[e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{u(null),t()},children:i("project.unassigned")})}),g.map(c=>e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{u(c.id),t()},children:c.name})},c.id)),g.length===0&&o.trim()?e.jsx("li",{className:"assetgen-popup__empty",children:i("project.searchEmpty")}):null]}),e.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:t,children:i("project.close")})]})})}function le(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})})}function re(){const{t}=v(),u=a(n=>n.assetsFolders),i=a(n=>n.selectedProjectId),l=a(n=>n.setSelectedProject),o=a(n=>n.loadAssetFolders),b=a(n=>n.createAssetFolder),[m,g]=d.useState(!1),[c,r]=d.useState(!1),p=d.useRef(null);d.useEffect(()=>{o()},[o]),d.useEffect(()=>{i&&u.length>0&&!u.some(n=>n.id===i)&&l(null)},[u,i,l]),d.useEffect(()=>{if(!m)return;const n=j=>{p.current&&!p.current.contains(j.target)&&g(!1)},k=j=>{j.key==="Escape"&&g(!1)};return window.addEventListener("mousedown",n),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",k)}},[m]);const h=u.filter(n=>n.parentId===null),_=h.find(n=>n.id===i),G=async()=>{const n=window.prompt(t("project.newPrompt"));if(!n||!n.trim())return;if(await b(n.trim(),null)){await o();const j=a.getState().assetsFolders.find(N=>N.parentId===null&&N.name===n.trim());j&&l(j.id)}g(!1)};return e.jsxs("div",{className:"assetgen-field assetgen-project",ref:p,children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-project-label",children:t("project.select")}),e.jsxs("button",{type:"button",className:"assetgen-project__trigger","aria-haspopup":"listbox","aria-expanded":m,"aria-labelledby":"assetgen-project-label",onClick:()=>g(n=>!n),children:[e.jsx(le,{}),_?_.name:t("project.unassigned"),e.jsx("span",{className:"assetgen-project__caret","aria-hidden":"true",children:"▾"})]}),m?e.jsxs("ul",{className:"assetgen-project__menu",role:"listbox","aria-labelledby":"assetgen-project-label",children:[e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":i===null,onClick:()=>{l(null),g(!1)},children:t("project.unassigned")})}),h.map(n=>e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":i===n.id,onClick:()=>{l(n.id),g(!1)},children:n.name})},n.id)),e.jsx("li",{className:"assetgen-project__menu-divider","aria-hidden":"true"}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{G()},children:t("project.new")})}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{g(!1),r(!0)},children:t("project.search")})})]}):null,c?e.jsx(ne,{onClose:()=>r(!1),onSelect:n=>l(n)}):null]})}const ie=d.lazy(()=>Q(()=>import("./SpriteRecipeWorkspace-_WcHPSd4.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.SpriteRecipeWorkspace})));function oe(){const{t}=v(),u=a(s=>s.assetGenPrompt),i=a(s=>s.setAssetGenPrompt),l=a(s=>s.assetGenKind),o=a(s=>s.setAssetGenKind),b=a(s=>s.assetGenProvider),m=a(s=>s.assetGenVideoDuration),g=a(s=>s.setAssetGenVideoDuration),c=a(s=>s.assetGenVideoResolution),r=a(s=>s.setAssetGenVideoResolution),p=a(s=>s.assetGenVideoAspect),h=a(s=>s.setAssetGenVideoAspect),_=a(s=>s.activeGenerations),G=a(s=>s.assetGenItems),n=a(s=>s.generateAssetGen),k=a(s=>s.assetGenSaveFailures),j=a(s=>s.retryAssetGenSave),N=a(s=>s.setKeyingTarget),C=a(s=>s.assetGenLastError),L=a(s=>s.setAssetGenLastError),R=a(s=>s.setUIMode),f=a(s=>s.assetGenWorkflow),A=a(s=>s.setAssetGenWorkflow),F=$(),[E,I]=d.useState(null),[T,S]=d.useState(null),V=d.useCallback(()=>{I(null),S(null)},[]),D=d.useCallback((s,x)=>{S(x),I(s)},[]),O=d.useCallback(()=>{document.getElementById("assetgen-prompt")?.focus()},[]),w=b==="grok"||b==="grok-api",y=l==="video"&&!w?"image":l,W=u.trim().length>0,K=e.jsxs("div",{className:"assetgen-workflow-tabs",role:"tablist","aria-label":t("sprite.tabs.label"),onKeyDown:F,children:[e.jsx("button",{type:"button",role:"tab","aria-selected":f==="generate",tabIndex:f==="generate"?0:-1,onClick:()=>A("generate"),children:t("sprite.tabs.generate")}),e.jsx("button",{type:"button",role:"tab","aria-selected":f==="sprite",tabIndex:f==="sprite"?0:-1,onClick:()=>A("sprite"),children:t("sprite.tabs.sprite")})]});return f==="sprite"?e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("sprite.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("sprite.lede")}),K]}),e.jsx("main",{className:"assetgen-results",children:e.jsx(d.Suspense,{fallback:e.jsx("p",{role:"status",children:t("sprite.loading")}),children:e.jsx(ie,{})})})]}):e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("assetGen.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("assetGen.lede")}),K,e.jsx(re,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("label",{className:"assetgen-field__label",htmlFor:"assetgen-prompt",children:t("assetGen.prompt")}),e.jsx("textarea",{id:"assetgen-prompt",value:u,rows:4,placeholder:t("assetGen.promptPlaceholder"),onChange:s=>i(s.target.value)})]}),e.jsx(se,{}),e.jsx(ae,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-kind-label",children:t("assetGen.kind")}),e.jsxs("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-kind-label",children:[e.jsx("button",{type:"button",className:y==="image"?"is-active":"","aria-pressed":y==="image",onClick:()=>o("image"),children:t("assetGen.kindImage")}),e.jsx("button",{type:"button",className:y==="video"?"is-active":"","aria-pressed":y==="video",disabled:!w,title:w?void 0:t("assetGen.videoGrokOnly"),onClick:()=>o("video"),children:t("assetGen.kindVideo")})]}),w?null:e.jsx("p",{className:"assetgen-field__hint",children:t("assetGen.videoGrokOnly")})]}),y==="video"?e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-video-label",children:t("assetGen.videoOptions")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoDuration"),children:[3,5,8].map(s=>e.jsxs("button",{type:"button",className:m===s?"is-active":"","aria-pressed":m===s,onClick:()=>g(s),children:[s,"s"]},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoResolution"),children:["480p","720p"].map(s=>e.jsx("button",{type:"button",className:c===s?"is-active":"","aria-pressed":c===s,onClick:()=>r(s),children:s},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoAspect"),children:["1:1","16:9","9:16"].map(s=>e.jsx("button",{type:"button",className:p===s?"is-active":"","aria-pressed":p===s,onClick:()=>h(s),children:s},s))})]}):null,e.jsx("button",{type:"button",className:"assetgen-generate",disabled:!W,onClick:()=>{n()},children:_>0?t("assetGen.generating"):t("assetGen.generate")}),e.jsx(U,{})]}),e.jsxs("main",{className:"assetgen-results",children:[e.jsxs("div",{className:"assetgen-results__main",children:[C?e.jsxs("div",{className:"assetgen-error",role:"alert",children:[e.jsxs("div",{className:"assetgen-error__text",children:[e.jsx("strong",{children:t("assetGen.errorTitle")}),e.jsx("span",{children:C}),e.jsx("span",{className:"assetgen-error__hint",children:t("assetGen.errorHint")})]}),e.jsx("button",{type:"button",className:"assetgen-error__dismiss",onClick:()=>L(null),children:t("assetGen.errorDismiss")})]}):null,G.length===0?e.jsxs("div",{className:"assetgen-empty",children:[e.jsx("h2",{children:t("assetGen.emptyTitle")}),e.jsx("p",{children:t("assetGen.emptyBody")}),e.jsx("button",{type:"button",className:"assetgen-empty__cta",onClick:O,children:t("assetGen.emptyCta")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"assetgen-saved-hint",children:[t("assetGen.savedHint")," ",e.jsx("button",{type:"button",className:"assetgen-saved-hint__link",onClick:()=>R("assets"),children:t("assetGen.savedLink")})]}),e.jsx("div",{className:"assetgen-grid",children:G.map(s=>{const x=s.kind==="edit",P=s.mediaType==="video",M=t(P?"assetGen.videoFallback":"assetGen.imageFallback"),B=t(P?"assetGen.previewVideo":"assetGen.previewImage",{prompt:s.prompt?.trim()||M});return e.jsxs("figure",{className:`assetgen-tile${x?" is-keyed":""}`,children:[x?e.jsx("span",{className:"assetgen-tile__badge",children:t("keying.resultBadge")}):null,e.jsxs("button",{type:"button",className:"assetgen-tile__media","aria-label":B,onClick:()=>I(s),children:[P?e.jsx("video",{src:s.url||s.image,poster:s.thumb||void 0,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:s.url||s.image,alt:"",loading:"lazy"}),e.jsx("span",{className:"assetgen-tile__open-hint","aria-hidden":"true",children:t(P?"assetGen.openHintVideo":"assetGen.openHintImage")})]}),e.jsx("figcaption",{title:s.prompt,children:s.prompt}),x?null:e.jsx("button",{type:"button",className:"assetgen-tile__key",onClick:()=>N(s),children:t("keying.open")}),!x&&s.requestId&&k.includes(s.requestId)?e.jsx("button",{type:"button",className:"assetgen-tile__retry",onClick:()=>{j(s.requestId)},children:t("project.saveRetry")}):null]},`${s.requestId}-${s.filename??s.createdAt}`)})})]})]}),e.jsx(Y,{selectedAssetId:T,onPreview:D})]}),e.jsx(Z,{}),E?e.jsx(J,{item:E,onClose:V}):null]})}const pe=Object.freeze(Object.defineProperty({__proto__:null,AssetGenWorkspace:oe},Symbol.toStringTag,{value:"Module"}));export{pe as A,re as P};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SpriteRecipeWorkspace-Y6GqpVHs.js","assets/index-XXtoj9ME.js","assets/index-waPOg2eb.css","assets/KeyingPanel-CEBLIhhu.js","assets/useAgentDialogFocus-PWmMjerz.js"])))=>i.map(i=>d[i]);
2
+ import{u as v,b as a,a as d,a6 as q,j as e,a7 as H,a5 as z,a8 as $,a9 as U,aa as Q}from"./index-XXtoj9ME.js";import{K as Z,A as J}from"./KeyingPanel-CEBLIhhu.js";const X=48;function Y({selectedAssetId:t,onPreview:u}){const{t:i}=v(),l=a(r=>r.selectedProjectId),o=a(r=>r.assetGenItems.length),[b,m]=d.useState([]),[g,c]=d.useState(!1);return d.useEffect(()=>{let r=!1;return q({kind:null,folderId:l,tag:null,q:"",limit:X}).then(p=>{r||(m(p.assets.filter(h=>h.filePath&&(h.kind==="image"||h.kind==="video"))),c(!1))}).catch(()=>{r||c(!0)}),()=>{r=!0}},[l,o]),e.jsxs("aside",{className:"assetgen-rail","aria-label":i("assetGen.railTitle"),children:[e.jsx("h2",{className:"assetgen-rail__title",children:i("assetGen.railTitle")}),g?e.jsx("p",{className:"assetgen-rail__empty",children:i("assetGen.railError")}):b.length===0?e.jsx("p",{className:"assetgen-rail__empty",children:i("assetGen.railEmpty")}):e.jsx("div",{className:"assetgen-rail__list",role:"listbox","aria-label":i("assetGen.railTitle"),children:b.map(r=>{const p=r.filePath?H(r.filePath):null;if(!p)return null;const h=t===r.id;return e.jsxs("button",{type:"button",role:"option","aria-selected":h,className:`assetgen-rail__tile${h?" is-selected":""}`,title:r.name,onClick:()=>u(z(r),r.id),children:[r.kind==="video"?e.jsx("video",{src:p,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:p,alt:"",loading:"lazy",decoding:"async"}),e.jsx("span",{className:"assetgen-rail__name",children:r.name})]},r.id)})})]})}const ee=[{value:"chroma-green",swatch:"#00c853",labelKey:"assetGen.bgChroma"},{value:"white",swatch:"#ffffff",labelKey:"assetGen.bgWhite"},{value:"black",swatch:"#111111",labelKey:"assetGen.bgBlack"}];function se(){const{t}=v(),u=a(l=>l.assetGenBackground),i=a(l=>l.setAssetGenBackground);return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-bg-label",children:t("assetGen.background")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-bg-label",children:ee.map(l=>e.jsxs("button",{type:"button",className:u===l.value?"is-active":"","aria-pressed":u===l.value,onClick:()=>i(l.value),children:[e.jsx("span",{className:"assetgen-bg-picker__swatch",style:{background:l.swatch},"aria-hidden":"true"}),t(l.labelKey)]},l.value))}),e.jsx("p",{className:"assetgen-field__hint",children:t("assetGen.backgroundHint")})]})}const te=[{value:"oauth",labelKey:"assetGen.modelGpt"},{value:"grok",labelKey:"assetGen.modelGrok"}];function ae(){const{t}=v(),u=a(o=>o.assetGenProvider),i=a(o=>o.setAssetGenProvider),l=u==="grok"||u==="grok-api"?"grok":"oauth";return e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-model-label",children:t("assetGen.model")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-model-label",children:te.map(o=>e.jsx("button",{type:"button",className:l===o.value?"is-active":"","aria-pressed":l===o.value,onClick:()=>i(o.value),children:t(o.labelKey)},o.value))})]})}function ne({onClose:t,onSelect:u}){const{t:i}=v(),l=a(c=>c.assetsFolders),[o,b]=d.useState(""),m=d.useRef(null);d.useEffect(()=>{m.current?.focus();const c=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[t]);const g=d.useMemo(()=>{const c=l.filter(p=>p.parentId===null),r=o.trim().toLowerCase();return r?c.filter(p=>p.name.toLowerCase().includes(r)):c},[l,o]);return e.jsx("div",{className:"assetgen-popup-backdrop",onClick:t,children:e.jsxs("div",{className:"assetgen-popup",role:"dialog","aria-modal":"true","aria-label":i("project.search"),onClick:c=>c.stopPropagation(),children:[e.jsx("input",{ref:m,type:"search",value:o,placeholder:i("project.searchPlaceholder"),"aria-label":i("project.search"),onChange:c=>b(c.target.value)}),e.jsxs("ul",{role:"listbox","aria-label":i("project.select"),children:[e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{u(null),t()},children:i("project.unassigned")})}),g.map(c=>e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{u(c.id),t()},children:c.name})},c.id)),g.length===0&&o.trim()?e.jsx("li",{className:"assetgen-popup__empty",children:i("project.searchEmpty")}):null]}),e.jsx("button",{type:"button",className:"assetgen-popup__close",onClick:t,children:i("project.close")})]})})}function le(){return e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e.jsx("path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"})})}function re(){const{t}=v(),u=a(n=>n.assetsFolders),i=a(n=>n.selectedProjectId),l=a(n=>n.setSelectedProject),o=a(n=>n.loadAssetFolders),b=a(n=>n.createAssetFolder),[m,g]=d.useState(!1),[c,r]=d.useState(!1),p=d.useRef(null);d.useEffect(()=>{o()},[o]),d.useEffect(()=>{i&&u.length>0&&!u.some(n=>n.id===i)&&l(null)},[u,i,l]),d.useEffect(()=>{if(!m)return;const n=j=>{p.current&&!p.current.contains(j.target)&&g(!1)},k=j=>{j.key==="Escape"&&g(!1)};return window.addEventListener("mousedown",n),window.addEventListener("keydown",k),()=>{window.removeEventListener("mousedown",n),window.removeEventListener("keydown",k)}},[m]);const h=u.filter(n=>n.parentId===null),_=h.find(n=>n.id===i),G=async()=>{const n=window.prompt(t("project.newPrompt"));if(!n||!n.trim())return;if(await b(n.trim(),null)){await o();const j=a.getState().assetsFolders.find(N=>N.parentId===null&&N.name===n.trim());j&&l(j.id)}g(!1)};return e.jsxs("div",{className:"assetgen-field assetgen-project",ref:p,children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-project-label",children:t("project.select")}),e.jsxs("button",{type:"button",className:"assetgen-project__trigger","aria-haspopup":"listbox","aria-expanded":m,"aria-labelledby":"assetgen-project-label",onClick:()=>g(n=>!n),children:[e.jsx(le,{}),_?_.name:t("project.unassigned"),e.jsx("span",{className:"assetgen-project__caret","aria-hidden":"true",children:"▾"})]}),m?e.jsxs("ul",{className:"assetgen-project__menu",role:"listbox","aria-labelledby":"assetgen-project-label",children:[e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":i===null,onClick:()=>{l(null),g(!1)},children:t("project.unassigned")})}),h.map(n=>e.jsx("li",{children:e.jsx("button",{type:"button","aria-selected":i===n.id,onClick:()=>{l(n.id),g(!1)},children:n.name})},n.id)),e.jsx("li",{className:"assetgen-project__menu-divider","aria-hidden":"true"}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{G()},children:t("project.new")})}),e.jsx("li",{children:e.jsx("button",{type:"button",onClick:()=>{g(!1),r(!0)},children:t("project.search")})})]}):null,c?e.jsx(ne,{onClose:()=>r(!1),onSelect:n=>l(n)}):null]})}const ie=d.lazy(()=>Q(()=>import("./SpriteRecipeWorkspace-Y6GqpVHs.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.SpriteRecipeWorkspace})));function oe(){const{t}=v(),u=a(s=>s.assetGenPrompt),i=a(s=>s.setAssetGenPrompt),l=a(s=>s.assetGenKind),o=a(s=>s.setAssetGenKind),b=a(s=>s.assetGenProvider),m=a(s=>s.assetGenVideoDuration),g=a(s=>s.setAssetGenVideoDuration),c=a(s=>s.assetGenVideoResolution),r=a(s=>s.setAssetGenVideoResolution),p=a(s=>s.assetGenVideoAspect),h=a(s=>s.setAssetGenVideoAspect),_=a(s=>s.activeGenerations),G=a(s=>s.assetGenItems),n=a(s=>s.generateAssetGen),k=a(s=>s.assetGenSaveFailures),j=a(s=>s.retryAssetGenSave),N=a(s=>s.setKeyingTarget),C=a(s=>s.assetGenLastError),L=a(s=>s.setAssetGenLastError),R=a(s=>s.setUIMode),f=a(s=>s.assetGenWorkflow),A=a(s=>s.setAssetGenWorkflow),F=$(),[E,I]=d.useState(null),[T,S]=d.useState(null),V=d.useCallback(()=>{I(null),S(null)},[]),D=d.useCallback((s,x)=>{S(x),I(s)},[]),O=d.useCallback(()=>{document.getElementById("assetgen-prompt")?.focus()},[]),w=b==="grok"||b==="grok-api",y=l==="video"&&!w?"image":l,W=u.trim().length>0,K=e.jsxs("div",{className:"assetgen-workflow-tabs",role:"tablist","aria-label":t("sprite.tabs.label"),onKeyDown:F,children:[e.jsx("button",{type:"button",role:"tab","aria-selected":f==="generate",tabIndex:f==="generate"?0:-1,onClick:()=>A("generate"),children:t("sprite.tabs.generate")}),e.jsx("button",{type:"button",role:"tab","aria-selected":f==="sprite",tabIndex:f==="sprite"?0:-1,onClick:()=>A("sprite"),children:t("sprite.tabs.sprite")})]});return f==="sprite"?e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("sprite.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("sprite.lede")}),K]}),e.jsx("main",{className:"assetgen-results",children:e.jsx(d.Suspense,{fallback:e.jsx("p",{role:"status",children:t("sprite.loading")}),children:e.jsx(ie,{})})})]}):e.jsxs("section",{className:"assetgen-workspace","aria-labelledby":"assetgen-title",children:[e.jsxs("aside",{className:"assetgen-form",children:[e.jsx("h1",{id:"assetgen-title",children:t("assetGen.title")}),e.jsx("p",{className:"assetgen-form__lede",children:t("assetGen.lede")}),K,e.jsx(re,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("label",{className:"assetgen-field__label",htmlFor:"assetgen-prompt",children:t("assetGen.prompt")}),e.jsx("textarea",{id:"assetgen-prompt",value:u,rows:4,placeholder:t("assetGen.promptPlaceholder"),onChange:s=>i(s.target.value)})]}),e.jsx(se,{}),e.jsx(ae,{}),e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-kind-label",children:t("assetGen.kind")}),e.jsxs("div",{className:"assetgen-bg-picker",role:"group","aria-labelledby":"assetgen-kind-label",children:[e.jsx("button",{type:"button",className:y==="image"?"is-active":"","aria-pressed":y==="image",onClick:()=>o("image"),children:t("assetGen.kindImage")}),e.jsx("button",{type:"button",className:y==="video"?"is-active":"","aria-pressed":y==="video",disabled:!w,title:w?void 0:t("assetGen.videoGrokOnly"),onClick:()=>o("video"),children:t("assetGen.kindVideo")})]}),w?null:e.jsx("p",{className:"assetgen-field__hint",children:t("assetGen.videoGrokOnly")})]}),y==="video"?e.jsxs("div",{className:"assetgen-field",children:[e.jsx("span",{className:"assetgen-field__label",id:"assetgen-video-label",children:t("assetGen.videoOptions")}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoDuration"),children:[3,5,8].map(s=>e.jsxs("button",{type:"button",className:m===s?"is-active":"","aria-pressed":m===s,onClick:()=>g(s),children:[s,"s"]},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoResolution"),children:["480p","720p"].map(s=>e.jsx("button",{type:"button",className:c===s?"is-active":"","aria-pressed":c===s,onClick:()=>r(s),children:s},s))}),e.jsx("div",{className:"assetgen-bg-picker",role:"group","aria-label":t("assetGen.videoAspect"),children:["1:1","16:9","9:16"].map(s=>e.jsx("button",{type:"button",className:p===s?"is-active":"","aria-pressed":p===s,onClick:()=>h(s),children:s},s))})]}):null,e.jsx("button",{type:"button",className:"assetgen-generate",disabled:!W,onClick:()=>{n()},children:_>0?t("assetGen.generating"):t("assetGen.generate")}),e.jsx(U,{})]}),e.jsxs("main",{className:"assetgen-results",children:[e.jsxs("div",{className:"assetgen-results__main",children:[C?e.jsxs("div",{className:"assetgen-error",role:"alert",children:[e.jsxs("div",{className:"assetgen-error__text",children:[e.jsx("strong",{children:t("assetGen.errorTitle")}),e.jsx("span",{children:C}),e.jsx("span",{className:"assetgen-error__hint",children:t("assetGen.errorHint")})]}),e.jsx("button",{type:"button",className:"assetgen-error__dismiss",onClick:()=>L(null),children:t("assetGen.errorDismiss")})]}):null,G.length===0?e.jsxs("div",{className:"assetgen-empty",children:[e.jsx("h2",{children:t("assetGen.emptyTitle")}),e.jsx("p",{children:t("assetGen.emptyBody")}),e.jsx("button",{type:"button",className:"assetgen-empty__cta",onClick:O,children:t("assetGen.emptyCta")})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"assetgen-saved-hint",children:[t("assetGen.savedHint")," ",e.jsx("button",{type:"button",className:"assetgen-saved-hint__link",onClick:()=>R("assets"),children:t("assetGen.savedLink")})]}),e.jsx("div",{className:"assetgen-grid",children:G.map(s=>{const x=s.kind==="edit",P=s.mediaType==="video",M=t(P?"assetGen.videoFallback":"assetGen.imageFallback"),B=t(P?"assetGen.previewVideo":"assetGen.previewImage",{prompt:s.prompt?.trim()||M});return e.jsxs("figure",{className:`assetgen-tile${x?" is-keyed":""}`,children:[x?e.jsx("span",{className:"assetgen-tile__badge",children:t("keying.resultBadge")}):null,e.jsxs("button",{type:"button",className:"assetgen-tile__media","aria-label":B,onClick:()=>I(s),children:[P?e.jsx("video",{src:s.url||s.image,poster:s.thumb||void 0,muted:!0,playsInline:!0,preload:"metadata","aria-hidden":"true"}):e.jsx("img",{src:s.url||s.image,alt:"",loading:"lazy"}),e.jsx("span",{className:"assetgen-tile__open-hint","aria-hidden":"true",children:t(P?"assetGen.openHintVideo":"assetGen.openHintImage")})]}),e.jsx("figcaption",{title:s.prompt,children:s.prompt}),x?null:e.jsx("button",{type:"button",className:"assetgen-tile__key",onClick:()=>N(s),children:t("keying.open")}),!x&&s.requestId&&k.includes(s.requestId)?e.jsx("button",{type:"button",className:"assetgen-tile__retry",onClick:()=>{j(s.requestId)},children:t("project.saveRetry")}):null]},`${s.requestId}-${s.filename??s.createdAt}`)})})]})]}),e.jsx(Y,{selectedAssetId:T,onPreview:D})]}),e.jsx(Z,{}),E?e.jsx(J,{item:E,onClose:V}):null]})}const pe=Object.freeze(Object.defineProperty({__proto__:null,AssetGenWorkspace:oe},Symbol.toStringTag,{value:"Module"}));export{pe as A,re as P};