webs-sdk 0.18.92 → 0.18.93

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 (57) hide show
  1. package/dist/components/ArtGenerator.d.ts +106 -0
  2. package/dist/components/ArtGenerator.d.ts.map +1 -0
  3. package/dist/components/ArtGenerator.js +701 -0
  4. package/dist/components/ArtGenerator.js.map +1 -0
  5. package/dist/components/AvatarAI.d.ts.map +1 -1
  6. package/dist/components/AvatarAI.js +70 -14
  7. package/dist/components/AvatarAI.js.map +1 -1
  8. package/dist/components/GifsIa.d.ts +88 -0
  9. package/dist/components/GifsIa.d.ts.map +1 -0
  10. package/dist/components/GifsIa.js +565 -0
  11. package/dist/components/GifsIa.js.map +1 -0
  12. package/dist/components/SpinningWheel/config.js +5 -5
  13. package/dist/components/SpinningWheel/config.js.map +1 -1
  14. package/dist/components/WallpapersName.d.ts +4 -2
  15. package/dist/components/WallpapersName.d.ts.map +1 -1
  16. package/dist/components/WallpapersName.js +6 -1
  17. package/dist/components/WallpapersName.js.map +1 -1
  18. package/dist/components/for-you/ForYouPage.d.ts +30 -0
  19. package/dist/components/for-you/ForYouPage.d.ts.map +1 -1
  20. package/dist/components/for-you/ForYouPage.js +14 -0
  21. package/dist/components/for-you/ForYouPage.js.map +1 -1
  22. package/dist/components/for-you/cards/ArtGeneratorCard.d.ts +7 -0
  23. package/dist/components/for-you/cards/ArtGeneratorCard.d.ts.map +1 -0
  24. package/dist/components/for-you/cards/ArtGeneratorCard.js +22 -0
  25. package/dist/components/for-you/cards/ArtGeneratorCard.js.map +1 -0
  26. package/dist/components/for-you/cards/GifsIaCard.d.ts +7 -0
  27. package/dist/components/for-you/cards/GifsIaCard.d.ts.map +1 -0
  28. package/dist/components/for-you/cards/GifsIaCard.js +22 -0
  29. package/dist/components/for-you/cards/GifsIaCard.js.map +1 -0
  30. package/dist/components/for-you/cards/index.d.ts +4 -0
  31. package/dist/components/for-you/cards/index.d.ts.map +1 -1
  32. package/dist/components/for-you/cards/index.js +5 -1
  33. package/dist/components/for-you/cards/index.js.map +1 -1
  34. package/dist/components/for-you/hooks/index.d.ts +4 -0
  35. package/dist/components/for-you/hooks/index.d.ts.map +1 -1
  36. package/dist/components/for-you/hooks/index.js +5 -1
  37. package/dist/components/for-you/hooks/index.js.map +1 -1
  38. package/dist/components/for-you/hooks/useArtGenerator.d.ts +47 -0
  39. package/dist/components/for-you/hooks/useArtGenerator.d.ts.map +1 -0
  40. package/dist/components/for-you/hooks/useArtGenerator.js +265 -0
  41. package/dist/components/for-you/hooks/useArtGenerator.js.map +1 -0
  42. package/dist/components/for-you/hooks/useGifsIa.d.ts +46 -0
  43. package/dist/components/for-you/hooks/useGifsIa.d.ts.map +1 -0
  44. package/dist/components/for-you/hooks/useGifsIa.js +240 -0
  45. package/dist/components/for-you/hooks/useGifsIa.js.map +1 -0
  46. package/dist/components/for-you/i18n/forYouTranslations.d.ts.map +1 -1
  47. package/dist/components/for-you/i18n/forYouTranslations.js +83 -1
  48. package/dist/components/for-you/i18n/forYouTranslations.js.map +1 -1
  49. package/dist/components/for-you/index.d.ts +9 -1
  50. package/dist/components/for-you/index.d.ts.map +1 -1
  51. package/dist/components/for-you/index.js +9 -1
  52. package/dist/components/for-you/index.js.map +1 -1
  53. package/dist/index.d.ts +13 -1
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +23 -11
  56. package/dist/index.js.map +1 -1
  57. package/package.json +3 -1
@@ -0,0 +1,701 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_ART_STYLES = void 0;
4
+ exports.ArtGenerator = ArtGenerator;
5
+ exports.ArtGeneratorForYouCard = ArtGeneratorForYouCard;
6
+ const jsx_runtime_1 = require("react/jsx-runtime");
7
+ const react_1 = require("react");
8
+ const forYouFetch_1 = require("./for-you/api/forYouFetch");
9
+ const ART_GENERATOR_CSS = `
10
+ .artgen-grid {
11
+ display: grid;
12
+ grid-template-columns: 1fr;
13
+ gap: 0;
14
+ }
15
+ @media (min-width: 1024px) {
16
+ .artgen-grid {
17
+ grid-template-columns: 380px 1fr;
18
+ }
19
+ }
20
+ .artgen-styles-grid {
21
+ display: grid;
22
+ grid-template-columns: repeat(3, 1fr);
23
+ gap: 8px;
24
+ }
25
+ .artgen-collections-grid {
26
+ display: grid;
27
+ grid-template-columns: repeat(2, 1fr);
28
+ gap: 16px;
29
+ }
30
+ @media (min-width: 640px) {
31
+ .artgen-collections-grid {
32
+ grid-template-columns: repeat(3, 1fr);
33
+ }
34
+ }
35
+ @media (min-width: 1024px) {
36
+ .artgen-collections-grid {
37
+ grid-template-columns: repeat(4, 1fr);
38
+ }
39
+ }
40
+ @media (min-width: 1280px) {
41
+ .artgen-collections-grid {
42
+ grid-template-columns: repeat(6, 1fr);
43
+ }
44
+ }
45
+ .artgen-carousel-scroll {
46
+ display: flex;
47
+ gap: 12px;
48
+ overflow-x: auto;
49
+ scroll-snap-type: x mandatory;
50
+ -webkit-overflow-scrolling: touch;
51
+ scrollbar-width: none;
52
+ -ms-overflow-style: none;
53
+ }
54
+ .artgen-carousel-scroll::-webkit-scrollbar {
55
+ display: none;
56
+ }
57
+ .artgen-carousel-item {
58
+ scroll-snap-align: start;
59
+ flex: 0 0 calc(50% - 6px);
60
+ min-width: 0;
61
+ }
62
+ `;
63
+ exports.DEFAULT_ART_STYLES = [
64
+ {
65
+ key: 'no-style',
66
+ label: 'No style',
67
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/Preview_NOStyle_AI2.png',
68
+ prompt: '',
69
+ negative_prompt: '',
70
+ },
71
+ {
72
+ key: 'papercraft-papercut collage',
73
+ label: 'Papercut',
74
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_PaperCutCollage.png',
75
+ prompt: 'papercut collage of {prompt} . mixed media, textured paper, overlapping, asymmetrical, abstract, vibrant',
76
+ negative_prompt: 'photo, 3D, realistic, drawing, painting, high detail, disfigured',
77
+ },
78
+ {
79
+ key: 'sai-craft clay',
80
+ label: 'Play Doh',
81
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_PlayDoh.png',
82
+ prompt: 'play-doh style {prompt} . sculpture, clay art, centered composition, Claymation',
83
+ negative_prompt: 'sloppy, messy, grainy, highly detailed, ultra textured, photo',
84
+ },
85
+ {
86
+ key: 'game-minecraft',
87
+ label: 'Minecraft',
88
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_MineCraft.png',
89
+ prompt: 'Minecraft style {prompt} . blocky, pixelated, vibrant colors, recognizable characters and objects, game assets',
90
+ negative_prompt: 'smooth, realistic, detailed, photorealistic, noise, blurry, deformed',
91
+ },
92
+ {
93
+ key: 'artstyle-abstract expressionism',
94
+ label: 'Expressionist',
95
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_Expressionist.png',
96
+ prompt: 'abstract expressionist painting {prompt} . energetic brushwork, bold colors, abstract forms, expressive, emotional',
97
+ negative_prompt: 'realistic, photorealistic, low contrast, plain, simple, monochrome',
98
+ },
99
+ {
100
+ key: 'game-retro game',
101
+ label: 'Retro Game',
102
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_RetroGame.png',
103
+ prompt: 'retro game art {prompt} . 16-bit, vibrant colors, pixelated, nostalgic, charming, fun',
104
+ negative_prompt: 'realistic, photorealistic, 35mm film, deformed, glitch, low contrast, noisy',
105
+ },
106
+ {
107
+ key: 'artstyle-watercolor',
108
+ label: 'Watercolor',
109
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_Watercolor.png',
110
+ prompt: 'watercolor painting {prompt} . vibrant, beautiful, painterly, detailed, textural, artistic',
111
+ negative_prompt: 'anime, photorealistic, 35mm film, deformed, glitch, low contrast, noisy',
112
+ },
113
+ {
114
+ key: 'sai-line art',
115
+ label: 'Line Art',
116
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_LineArt.png',
117
+ prompt: 'line art drawing {prompt} . professional, sleek, modern, minimalist, graphic, line art, vector graphics',
118
+ negative_prompt: 'anime, photorealistic, 35mm film, deformed, glitch, blurry, noisy, off-center, deformed, cross-eyed, closed eyes, bad anatomy, ugly, disfigured, mutated, realism, realistic, impressionism, expressionism, oil, acrylic',
119
+ },
120
+ {
121
+ key: 'sai-comic book',
122
+ label: 'Comic Book',
123
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_ComicBook.png',
124
+ prompt: 'comic {prompt} . graphic illustration, comic art, graphic novel art, vibrant, highly detailed',
125
+ negative_prompt: 'photograph, deformed, glitch, noisy, realistic, stock photo',
126
+ },
127
+ {
128
+ key: 'artstyle-art deco',
129
+ label: 'Art Deco',
130
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_ArtDeco.png',
131
+ prompt: 'art deco style {prompt} . geometric shapes, bold colors, luxurious, elegant, decorative, symmetrical, ornate, detailed',
132
+ negative_prompt: 'ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, modernist, minimalist',
133
+ },
134
+ {
135
+ key: 'misc-kawaii',
136
+ label: 'Kawaii',
137
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_Kawaii.png',
138
+ prompt: 'kawaii style {prompt} . cute, adorable, brightly colored, cheerful, anime influence, highly detailed',
139
+ negative_prompt: 'dark, scary, realistic, monochrome, abstract',
140
+ },
141
+ {
142
+ key: 'misc-stained glass',
143
+ label: 'Stained Glass',
144
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_StainedGlass.png',
145
+ prompt: 'stained glass style {prompt} . vibrant, beautiful, translucent, intricate, detailed',
146
+ negative_prompt: 'ugly, deformed, noisy, blurry, low contrast, realism, photorealistic',
147
+ },
148
+ {
149
+ key: 'misc-disco',
150
+ label: 'Disco',
151
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_Disco.png',
152
+ prompt: 'disco-themed {prompt} . vibrant, groovy, retro 70s style, shiny disco balls, neon lights, dance floor, highly detailed',
153
+ negative_prompt: 'minimalist, rustic, monochrome, contemporary, simplistic',
154
+ },
155
+ {
156
+ key: 'photo-neon noir',
157
+ label: 'Neon Noir',
158
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_NeonNoir.png',
159
+ prompt: 'neon noir {prompt} . cyberpunk, dark, rainy streets, neon signs, high contrast, low light, vibrant, highly detailed',
160
+ negative_prompt: 'bright, sunny, daytime, low contrast, black and white, sketch, watercolor',
161
+ },
162
+ {
163
+ key: 'photo-film noir',
164
+ label: 'Film Noir',
165
+ url: 'https://b2c-portales.s3.amazonaws.com/ForYou/ArtGeneratorStyles/v2/Preview_Film.png',
166
+ prompt: 'film noir style {prompt} . monochrome, high contrast, dramatic shadows, 1940s style, mysterious, cinematic',
167
+ negative_prompt: 'ugly, deformed, noisy, blurry, low contrast, realism, photorealistic, vibrant, colorful',
168
+ },
169
+ ];
170
+ const defaultTheme = {
171
+ primaryColor: '#6C63FF',
172
+ primaryHoverColor: '#5a52d5',
173
+ backgroundColor: '#1A1A2E',
174
+ cardBackground: '#252540',
175
+ borderColor: '#3A3A5C',
176
+ textColor: '#FFFFFF',
177
+ textSecondaryColor: '#A0A0C0',
178
+ tabActiveColor: '#6C63FF',
179
+ disabledColor: '#4A4A6A',
180
+ };
181
+ const defaultTexts = {
182
+ createTabLabel: 'Create',
183
+ collectionsTabLabel: 'Collections',
184
+ examplesTitle: 'Try these examples',
185
+ tryButton: 'Try',
186
+ promptTitle: 'Describe the desired image',
187
+ promptTooltip: 'The more detailed the description, the better the result.',
188
+ promptPlaceholder: 'A mysterious enchanted forest at night, illuminated by moonlight...',
189
+ createButton: 'Create',
190
+ generatingButton: 'Generating...',
191
+ resultTitle: 'Your result',
192
+ emptyResultText: 'Your generated image will appear here',
193
+ startAgainButton: 'Start again',
194
+ downloadButton: 'Download',
195
+ stylesTitle: 'Choose an artistic style',
196
+ loadingText: 'Loading...',
197
+ errorText: 'An error occurred. Please try again.',
198
+ queueText: 'In queue',
199
+ recommendedLabel: 'Recommended',
200
+ };
201
+ function buildFinalPrompt(userPrompt, style) {
202
+ if (!style.prompt)
203
+ return userPrompt;
204
+ return style.prompt.replace('{prompt}', userPrompt);
205
+ }
206
+ function ArtGenerator({ config, styles = exports.DEFAULT_ART_STYLES, examples: examplesProp, collections: collectionsProp, theme = {}, texts = {}, onGenerationComplete, onDownload, onError, }) {
207
+ const t = Object.assign(Object.assign({}, defaultTexts), texts);
208
+ const th = Object.assign(Object.assign({}, defaultTheme), theme);
209
+ const tabActive = th.tabActiveColor || th.primaryColor;
210
+ (0, react_1.useEffect)(() => {
211
+ const id = 'artgenerator-styles';
212
+ if (document.getElementById(id))
213
+ return;
214
+ const style = document.createElement('style');
215
+ style.id = id;
216
+ style.textContent = ART_GENERATOR_CSS;
217
+ document.head.appendChild(style);
218
+ }, []);
219
+ const [activeTab, setActiveTab] = (0, react_1.useState)('create');
220
+ const [dynamicExamples, setDynamicExamples] = (0, react_1.useState)([]);
221
+ const [loadingExamples, setLoadingExamples] = (0, react_1.useState)(false);
222
+ (0, react_1.useEffect)(() => {
223
+ if (examplesProp && examplesProp.length > 0)
224
+ return;
225
+ const hasFetch = config.examplesTags || config.examplesContents || config.apiBaseUrl || config.apiUrl;
226
+ if (!hasFetch)
227
+ return;
228
+ const load = async () => {
229
+ var _a;
230
+ setLoadingExamples(true);
231
+ try {
232
+ const apiUrl = (_a = config.apiUrl) !== null && _a !== void 0 ? _a : (config.apiBaseUrl ? `${config.apiBaseUrl}/api/get_contents_by_tags` : '/api/get_contents_by_tags');
233
+ const tags = config.examplesTags
234
+ ? (Array.isArray(config.examplesTags) ? config.examplesTags : [config.examplesTags])
235
+ : undefined;
236
+ const items = await (0, forYouFetch_1.forYouFetch)({
237
+ apiUrl,
238
+ apiBaseUrl: config.apiBaseUrl,
239
+ tags,
240
+ contents: config.examplesContents,
241
+ locale: config.locale || 'en',
242
+ website_id: config.website_id,
243
+ });
244
+ const mapped = items
245
+ .map((item, idx) => {
246
+ var _a, _b, _c;
247
+ return ({
248
+ id: (_a = item.id) !== null && _a !== void 0 ? _a : idx,
249
+ image: item.thumbnail || ((_b = item.images) === null || _b === void 0 ? void 0 : _b.img1) || item.imageUrl || '',
250
+ description: ((_c = item.metadata) === null || _c === void 0 ? void 0 : _c.prompt) || item.title || '',
251
+ });
252
+ })
253
+ .filter((e) => e.image);
254
+ setDynamicExamples(mapped);
255
+ }
256
+ catch (err) {
257
+ console.error('[ArtGenerator] Error loading examples:', err);
258
+ }
259
+ finally {
260
+ setLoadingExamples(false);
261
+ }
262
+ };
263
+ load();
264
+ }, [config.apiUrl, config.apiBaseUrl, config.examplesTags]);
265
+ const examples = examplesProp && examplesProp.length > 0 ? examplesProp : dynamicExamples;
266
+ const [dynamicCollections, setDynamicCollections] = (0, react_1.useState)([]);
267
+ const [loadingCollections, setLoadingCollections] = (0, react_1.useState)(false);
268
+ (0, react_1.useEffect)(() => {
269
+ if (collectionsProp && collectionsProp.length > 0)
270
+ return;
271
+ const hasFetch = config.collectionsTags || config.collectionsContents;
272
+ if (!hasFetch)
273
+ return;
274
+ const load = async () => {
275
+ var _a;
276
+ setLoadingCollections(true);
277
+ try {
278
+ const apiUrl = (_a = config.apiUrl) !== null && _a !== void 0 ? _a : (config.apiBaseUrl ? `${config.apiBaseUrl}/api/get_contents_by_tags` : '/api/get_contents_by_tags');
279
+ if (config.collectionsContents && config.collectionsContents.length > 0) {
280
+ const categories = [];
281
+ for (const preset of config.collectionsContents) {
282
+ const items = await (0, forYouFetch_1.forYouFetch)({
283
+ apiUrl,
284
+ apiBaseUrl: config.apiBaseUrl,
285
+ contents: [preset],
286
+ locale: config.locale || 'en',
287
+ website_id: config.website_id,
288
+ });
289
+ const mapped = items.map((item, idx) => {
290
+ var _a, _b, _c;
291
+ return ({
292
+ id: (_a = item.id) !== null && _a !== void 0 ? _a : idx,
293
+ image: item.thumbnail || ((_b = item.images) === null || _b === void 0 ? void 0 : _b.img1) || item.imageUrl || '',
294
+ title: item.title || '',
295
+ description: ((_c = item.metadata) === null || _c === void 0 ? void 0 : _c.prompt) || item.description || '',
296
+ });
297
+ }).filter((i) => i.image);
298
+ if (mapped.length === 0)
299
+ continue;
300
+ let categoryLabel;
301
+ const presetAny = preset;
302
+ if (presetAny.tags && Array.isArray(presetAny.tags) && presetAny.tags.length > 0) {
303
+ const tag = presetAny.tags[0];
304
+ categoryLabel = tag.charAt(0).toUpperCase() + tag.slice(1).replace(/-/g, ' ');
305
+ }
306
+ else {
307
+ categoryLabel = t.recommendedLabel;
308
+ }
309
+ const existing = categories.find(c => c.label === categoryLabel);
310
+ if (existing) {
311
+ existing.items.push(...mapped);
312
+ }
313
+ else {
314
+ categories.push({ label: categoryLabel, items: mapped });
315
+ }
316
+ }
317
+ setDynamicCollections(categories);
318
+ return;
319
+ }
320
+ const tags = config.collectionsTags
321
+ ? (Array.isArray(config.collectionsTags) ? config.collectionsTags : [config.collectionsTags])
322
+ : undefined;
323
+ if (tags && tags.length > 1) {
324
+ const categories = [];
325
+ for (const tag of tags) {
326
+ const items = await (0, forYouFetch_1.forYouFetch)({
327
+ apiUrl,
328
+ apiBaseUrl: config.apiBaseUrl,
329
+ tags: [tag],
330
+ locale: config.locale || 'en',
331
+ website_id: config.website_id,
332
+ });
333
+ const mapped = items.map((item, idx) => {
334
+ var _a, _b, _c;
335
+ return ({
336
+ id: (_a = item.id) !== null && _a !== void 0 ? _a : idx,
337
+ image: item.thumbnail || ((_b = item.images) === null || _b === void 0 ? void 0 : _b.img1) || item.imageUrl || '',
338
+ title: item.title || '',
339
+ description: ((_c = item.metadata) === null || _c === void 0 ? void 0 : _c.prompt) || item.description || '',
340
+ });
341
+ }).filter((i) => i.image);
342
+ if (mapped.length > 0) {
343
+ const label = tag.charAt(0).toUpperCase() + tag.slice(1).replace(/-/g, ' ');
344
+ categories.push({ label, items: mapped });
345
+ }
346
+ }
347
+ setDynamicCollections(categories);
348
+ }
349
+ else {
350
+ const items = await (0, forYouFetch_1.forYouFetch)({
351
+ apiUrl,
352
+ apiBaseUrl: config.apiBaseUrl,
353
+ tags,
354
+ locale: config.locale || 'en',
355
+ website_id: config.website_id,
356
+ });
357
+ const mapped = items.map((item, idx) => {
358
+ var _a, _b, _c;
359
+ return ({
360
+ id: (_a = item.id) !== null && _a !== void 0 ? _a : idx,
361
+ image: item.thumbnail || ((_b = item.images) === null || _b === void 0 ? void 0 : _b.img1) || item.imageUrl || '',
362
+ title: item.title || '',
363
+ description: ((_c = item.metadata) === null || _c === void 0 ? void 0 : _c.prompt) || item.description || '',
364
+ });
365
+ }).filter((i) => i.image);
366
+ if (mapped.length > 0) {
367
+ const label = (tags === null || tags === void 0 ? void 0 : tags[0])
368
+ ? tags[0].charAt(0).toUpperCase() + tags[0].slice(1).replace(/-/g, ' ')
369
+ : t.recommendedLabel;
370
+ setDynamicCollections([{ label, items: mapped }]);
371
+ }
372
+ }
373
+ }
374
+ catch (err) {
375
+ console.error('[ArtGenerator] Error loading collections:', err);
376
+ }
377
+ finally {
378
+ setLoadingCollections(false);
379
+ }
380
+ };
381
+ load();
382
+ }, [config.apiUrl, config.apiBaseUrl, config.collectionsTags, config.collectionsContents]);
383
+ const collections = collectionsProp && collectionsProp.length > 0 ? collectionsProp : dynamicCollections;
384
+ const [prompt, setPrompt] = (0, react_1.useState)('');
385
+ const [selectedStyle, setSelectedStyle] = (0, react_1.useState)(styles[0]);
386
+ const carouselRef = (0, react_1.useRef)(null);
387
+ const [isGenerating, setIsGenerating] = (0, react_1.useState)(false);
388
+ const [generatedImageUrl, setGeneratedImageUrl] = (0, react_1.useState)(null);
389
+ const [progressPercent, setProgressPercent] = (0, react_1.useState)(null);
390
+ const [queuePosition, setQueuePosition] = (0, react_1.useState)(null);
391
+ const [genError, setGenError] = (0, react_1.useState)(null);
392
+ const pollRef = (0, react_1.useRef)(null);
393
+ const timeoutRef = (0, react_1.useRef)(null);
394
+ (0, react_1.useEffect)(() => {
395
+ const el = carouselRef.current;
396
+ if (!el)
397
+ return;
398
+ const onWheel = (e) => {
399
+ if (Math.abs(e.deltaX) > Math.abs(e.deltaY))
400
+ return;
401
+ e.preventDefault();
402
+ el.scrollLeft += e.deltaY;
403
+ };
404
+ el.addEventListener('wheel', onWheel, { passive: false });
405
+ return () => el.removeEventListener('wheel', onWheel);
406
+ }, []);
407
+ const clearPolls = (0, react_1.useCallback)(() => {
408
+ if (pollRef.current) {
409
+ clearInterval(pollRef.current);
410
+ pollRef.current = null;
411
+ }
412
+ if (timeoutRef.current) {
413
+ clearTimeout(timeoutRef.current);
414
+ timeoutRef.current = null;
415
+ }
416
+ }, []);
417
+ (0, react_1.useEffect)(() => () => clearPolls(), [clearPolls]);
418
+ const handleStartAgain = () => {
419
+ clearPolls();
420
+ setGeneratedImageUrl(null);
421
+ setProgressPercent(null);
422
+ setQueuePosition(null);
423
+ setGenError(null);
424
+ setIsGenerating(false);
425
+ setPrompt('');
426
+ };
427
+ const handleCreate = async () => {
428
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
429
+ if (!prompt.trim() || isGenerating)
430
+ return;
431
+ clearPolls();
432
+ setIsGenerating(true);
433
+ setGeneratedImageUrl(null);
434
+ setProgressPercent(0);
435
+ setQueuePosition(null);
436
+ setGenError(null);
437
+ const finalPrompt = buildFinalPrompt(prompt, selectedStyle);
438
+ const negativePrompt = selectedStyle.negative_prompt;
439
+ const pollInterval = (_a = config.pollInterval) !== null && _a !== void 0 ? _a : 3000;
440
+ const maxPollTime = (_b = config.maxPollTime) !== null && _b !== void 0 ? _b : 120000;
441
+ const generateUrl = (_c = config.generateApiUrl) !== null && _c !== void 0 ? _c : (config.generateBaseUrl ? `${config.generateBaseUrl.replace(/\/$/, '')}/get_art_generation` : null);
442
+ if (!generateUrl) {
443
+ setGenError(t.errorText);
444
+ setIsGenerating(false);
445
+ return;
446
+ }
447
+ try {
448
+ const genRes = await fetch(generateUrl, {
449
+ method: 'POST',
450
+ headers: { 'Content-Type': 'application/json' },
451
+ body: JSON.stringify(Object.assign(Object.assign(Object.assign({ prompt: finalPrompt, negative_prompt: negativePrompt }, (config.userId && { us_id: config.userId })), (config.userLogin && { us_login: config.userLogin })), (config.wid && { wid: config.wid }))),
452
+ });
453
+ if (!genRes.ok)
454
+ throw new Error(`Generation error: ${genRes.status}`);
455
+ const genData = await genRes.json();
456
+ console.log('[ArtGenerator] generate response:', JSON.stringify(genData));
457
+ if ((genData === null || genData === void 0 ? void 0 : genData.success) === 0 || (genData === null || genData === void 0 ? void 0 : genData.success) === false) {
458
+ throw new Error((genData === null || genData === void 0 ? void 0 : genData.msg) || (genData === null || genData === void 0 ? void 0 : genData.error) || 'Generation failed');
459
+ }
460
+ const jobId = ((_d = genData === null || genData === void 0 ? void 0 : genData.data) === null || _d === void 0 ? void 0 : _d.md5) ||
461
+ ((_e = genData === null || genData === void 0 ? void 0 : genData.data) === null || _e === void 0 ? void 0 : _e.request_id) ||
462
+ ((_f = genData === null || genData === void 0 ? void 0 : genData.data) === null || _f === void 0 ? void 0 : _f.job_id) ||
463
+ ((_g = genData === null || genData === void 0 ? void 0 : genData.data) === null || _g === void 0 ? void 0 : _g.id) ||
464
+ (genData === null || genData === void 0 ? void 0 : genData.md5) ||
465
+ (genData === null || genData === void 0 ? void 0 : genData.request_id) ||
466
+ (genData === null || genData === void 0 ? void 0 : genData.job_id) ||
467
+ (genData === null || genData === void 0 ? void 0 : genData.id);
468
+ console.log('[ArtGenerator] jobId extracted:', jobId);
469
+ if (!jobId)
470
+ throw new Error(`No job ID received. Response: ${JSON.stringify(genData)}`);
471
+ timeoutRef.current = setTimeout(() => {
472
+ clearPolls();
473
+ setIsGenerating(false);
474
+ setGenError(t.errorText);
475
+ onError === null || onError === void 0 ? void 0 : onError(t.errorText);
476
+ }, maxPollTime);
477
+ const base = (_j = (_h = config.generateBaseUrl) === null || _h === void 0 ? void 0 : _h.replace(/\/$/, '')) !== null && _j !== void 0 ? _j : '';
478
+ const poll = async () => {
479
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
480
+ try {
481
+ const queueUrl = (_a = config.queueApiUrl) !== null && _a !== void 0 ? _a : (base ? `${base}/get_queue_position` : null);
482
+ if (queueUrl) {
483
+ const queueRes = await fetch(queueUrl, {
484
+ method: 'POST',
485
+ headers: { 'Content-Type': 'application/json' },
486
+ body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
487
+ });
488
+ if (queueRes.ok) {
489
+ const queueData = await queueRes.json();
490
+ const pos = (_d = (_c = (_b = queueData === null || queueData === void 0 ? void 0 : queueData.data) === null || _b === void 0 ? void 0 : _b.position) !== null && _c !== void 0 ? _c : queueData === null || queueData === void 0 ? void 0 : queueData.position) !== null && _d !== void 0 ? _d : null;
491
+ setQueuePosition(pos);
492
+ }
493
+ }
494
+ const progressUrl = (_e = config.progressApiUrl) !== null && _e !== void 0 ? _e : (base ? `${base}/get_arg_pct` : null);
495
+ if (!progressUrl)
496
+ return;
497
+ const pctRes = await fetch(progressUrl, {
498
+ method: 'POST',
499
+ headers: { 'Content-Type': 'application/json' },
500
+ body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
501
+ });
502
+ if (!pctRes.ok)
503
+ return;
504
+ const pctData = await pctRes.json();
505
+ const pct = (_h = (_g = (_f = pctData === null || pctData === void 0 ? void 0 : pctData.data) === null || _f === void 0 ? void 0 : _f.pct) !== null && _g !== void 0 ? _g : pctData === null || pctData === void 0 ? void 0 : pctData.pct) !== null && _h !== void 0 ? _h : 0;
506
+ setProgressPercent(pct);
507
+ if (pct >= 100) {
508
+ clearPolls();
509
+ const resultUrl = (_j = config.resultApiUrl) !== null && _j !== void 0 ? _j : (base ? `${base}/get_art_job` : null);
510
+ if (!resultUrl)
511
+ throw new Error('No result URL configured');
512
+ const jobRes = await fetch(resultUrl, {
513
+ method: 'POST',
514
+ headers: { 'Content-Type': 'application/json' },
515
+ body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
516
+ });
517
+ if (!jobRes.ok)
518
+ throw new Error('Error fetching final image');
519
+ const jobData = await jobRes.json();
520
+ const imageUrl = ((_k = jobData === null || jobData === void 0 ? void 0 : jobData.data) === null || _k === void 0 ? void 0 : _k.url) || (jobData === null || jobData === void 0 ? void 0 : jobData.url) || (jobData === null || jobData === void 0 ? void 0 : jobData.image) || ((_l = jobData === null || jobData === void 0 ? void 0 : jobData.data) === null || _l === void 0 ? void 0 : _l.image);
521
+ if (!imageUrl)
522
+ throw new Error('No image URL received');
523
+ setGeneratedImageUrl(imageUrl);
524
+ setProgressPercent(100);
525
+ setIsGenerating(false);
526
+ onGenerationComplete === null || onGenerationComplete === void 0 ? void 0 : onGenerationComplete(imageUrl, finalPrompt);
527
+ }
528
+ }
529
+ catch (err) {
530
+ console.error('[ArtGenerator] Polling error:', err);
531
+ }
532
+ };
533
+ poll();
534
+ pollRef.current = setInterval(poll, pollInterval);
535
+ }
536
+ catch (err) {
537
+ clearPolls();
538
+ const msg = err instanceof Error ? err.message : t.errorText;
539
+ setGenError(msg);
540
+ setIsGenerating(false);
541
+ onError === null || onError === void 0 ? void 0 : onError(msg);
542
+ }
543
+ };
544
+ const handleDownload = async () => {
545
+ if (!generatedImageUrl)
546
+ return;
547
+ if (onDownload) {
548
+ onDownload(generatedImageUrl);
549
+ return;
550
+ }
551
+ try {
552
+ const res = await fetch(generatedImageUrl);
553
+ const blob = await res.blob();
554
+ const url = URL.createObjectURL(blob);
555
+ const a = document.createElement('a');
556
+ a.href = url;
557
+ a.download = `art-generator-${Date.now()}.png`;
558
+ document.body.appendChild(a);
559
+ a.click();
560
+ document.body.removeChild(a);
561
+ URL.revokeObjectURL(url);
562
+ }
563
+ catch (_a) {
564
+ window.open(generatedImageUrl, '_blank');
565
+ }
566
+ };
567
+ const renderProgressBar = () => {
568
+ if (progressPercent === null)
569
+ return null;
570
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { width: '100%', marginTop: '12px' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', justifyContent: 'space-between', marginBottom: '4px' }, children: (0, jsx_runtime_1.jsx)("span", { style: { fontSize: '12px', color: th.textSecondaryColor }, children: queuePosition !== null && queuePosition > 0
571
+ ? `${t.queueText} #${queuePosition}`
572
+ : `${progressPercent}%` }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: '100%', height: '6px', backgroundColor: th.borderColor, borderRadius: '3px', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
573
+ height: '100%',
574
+ width: `${progressPercent}%`,
575
+ backgroundColor: th.primaryColor,
576
+ borderRadius: '3px',
577
+ transition: 'width 0.3s ease',
578
+ } }) })] }));
579
+ };
580
+ const renderCreateTab = () => ((0, jsx_runtime_1.jsxs)("div", { className: "artgen-grid", children: [(0, jsx_runtime_1.jsxs)("div", { style: { padding: '24px', borderRight: `1px solid ${th.borderColor}`, display: 'flex', flexDirection: 'column', gap: '24px' }, children: [(loadingExamples || examples.length > 0) && ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { fontSize: '16px', fontWeight: 700, color: th.textColor, margin: '0 0 12px 0' }, children: t.examplesTitle }), loadingExamples ? ((0, jsx_runtime_1.jsx)("p", { style: { color: th.textSecondaryColor, fontSize: '13px' }, children: t.loadingText })) : ((0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => { if (carouselRef.current)
581
+ carouselRef.current.scrollBy({ left: -260, behavior: 'smooth' }); }, style: {
582
+ position: 'absolute', left: '4px', top: '40%', transform: 'translateY(-50%)',
583
+ zIndex: 10, width: '32px', height: '32px', borderRadius: '50%', border: 'none',
584
+ backgroundColor: `${th.primaryColor}dd`, color: '#FFFFFF',
585
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
586
+ cursor: 'pointer', boxShadow: '0 2px 8px rgba(0,0,0,0.5)',
587
+ transition: 'background-color 0.2s',
588
+ }, onMouseEnter: (e) => { e.currentTarget.style.backgroundColor = th.primaryColor; }, onMouseLeave: (e) => { e.currentTarget.style.backgroundColor = `${th.primaryColor}dd`; }, children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("polyline", { points: "15 18 9 12 15 6" }) }) }), (0, jsx_runtime_1.jsx)("div", { ref: carouselRef, style: {
589
+ display: 'flex',
590
+ flexDirection: 'row',
591
+ gap: '12px',
592
+ overflowX: 'auto',
593
+ overflowY: 'hidden',
594
+ scrollSnapType: 'x mandatory',
595
+ WebkitOverflowScrolling: 'touch',
596
+ scrollbarWidth: 'none',
597
+ msOverflowStyle: 'none',
598
+ width: '100%',
599
+ }, children: examples.map((ex) => ((0, jsx_runtime_1.jsxs)("div", { style: {
600
+ flexShrink: 0,
601
+ width: 'calc(50% - 6px)',
602
+ scrollSnapAlign: 'start',
603
+ }, children: [(0, jsx_runtime_1.jsx)("div", { style: { borderRadius: '8px', overflow: 'hidden', marginBottom: '8px' }, children: (0, jsx_runtime_1.jsx)("img", { src: ex.image, alt: ex.description, style: { width: '100%', height: '140px', objectFit: 'cover', display: 'block' } }) }), (0, jsx_runtime_1.jsx)("p", { style: { fontSize: '12px', color: th.textSecondaryColor, margin: '0 0 8px 0', lineHeight: 1.4, overflow: 'hidden', display: '-webkit-box', WebkitLineClamp: 3, WebkitBoxOrient: 'vertical' }, children: ex.description }), (0, jsx_runtime_1.jsxs)("button", { onClick: () => setPrompt(ex.description), style: {
604
+ width: '100%', padding: '6px 12px', borderRadius: '20px', border: `1px solid ${th.primaryColor}`,
605
+ backgroundColor: 'transparent', color: th.primaryColor, fontSize: '12px', fontWeight: 600,
606
+ cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '4px',
607
+ }, children: [(0, jsx_runtime_1.jsxs)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [(0, jsx_runtime_1.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })] }), t.tryButton] })] }, ex.id))) }), (0, jsx_runtime_1.jsx)("button", { onClick: () => { if (carouselRef.current)
608
+ carouselRef.current.scrollBy({ left: 260, behavior: 'smooth' }); }, style: {
609
+ position: 'absolute', right: '4px', top: '40%', transform: 'translateY(-50%)',
610
+ zIndex: 10, width: '32px', height: '32px', borderRadius: '50%', border: 'none',
611
+ backgroundColor: `${th.primaryColor}dd`, color: '#FFFFFF',
612
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
613
+ cursor: 'pointer', boxShadow: '0 2px 8px rgba(0,0,0,0.5)',
614
+ transition: 'background-color 0.2s',
615
+ }, onMouseEnter: (e) => { e.currentTarget.style.backgroundColor = th.primaryColor; }, onMouseLeave: (e) => { e.currentTarget.style.backgroundColor = `${th.primaryColor}dd`; }, children: (0, jsx_runtime_1.jsx)("svg", { width: "12", height: "12", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: (0, jsx_runtime_1.jsx)("polyline", { points: "9 18 15 12 9 6" }) }) })] }))] })), (0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("h3", { style: { fontSize: '16px', fontWeight: 700, color: th.textColor, margin: '0 0 12px 0' }, children: t.stylesTitle }), (0, jsx_runtime_1.jsx)("div", { className: "artgen-styles-grid", children: styles.map((style) => {
616
+ const isActive = selectedStyle.key === style.key;
617
+ const isNoStyle = style.key === 'no-style';
618
+ return ((0, jsx_runtime_1.jsx)("button", { onClick: () => setSelectedStyle(style), title: style.label, style: {
619
+ padding: 0,
620
+ border: `2px solid ${isActive ? th.primaryColor : th.borderColor}`,
621
+ borderRadius: '8px',
622
+ overflow: 'hidden',
623
+ cursor: 'pointer',
624
+ backgroundColor: 'transparent',
625
+ transition: 'border-color 0.2s',
626
+ position: 'relative',
627
+ }, children: isNoStyle ? ((0, jsx_runtime_1.jsx)("div", { style: {
628
+ width: '100%',
629
+ aspectRatio: '1',
630
+ display: 'flex',
631
+ alignItems: 'center',
632
+ justifyContent: 'center',
633
+ backgroundColor: isActive ? `${th.primaryColor}22` : 'rgba(255,255,255,0.06)',
634
+ }, children: (0, jsx_runtime_1.jsxs)("svg", { width: "36", height: "36", viewBox: "0 0 24 24", fill: "none", stroke: isActive ? th.primaryColor : th.textSecondaryColor, strokeWidth: "1.5", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "12", cy: "12", r: "10" }), (0, jsx_runtime_1.jsx)("line", { x1: "4.93", y1: "4.93", x2: "19.07", y2: "19.07" })] }) })) : ((0, jsx_runtime_1.jsx)("img", { src: style.url, alt: style.label, style: { width: '100%', aspectRatio: '1', objectFit: 'cover', display: 'block' } })) }, style.key));
635
+ }) })] })] }), (0, jsx_runtime_1.jsxs)("div", { style: { padding: '24px', display: 'flex', flexDirection: 'column', gap: '20px' }, children: [(0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '8px' }, children: [(0, jsx_runtime_1.jsx)("h3", { style: { fontSize: '16px', fontWeight: 700, color: th.textColor, margin: 0 }, children: t.promptTitle }), (0, jsx_runtime_1.jsx)("span", { title: t.promptTooltip, style: { width: '18px', height: '18px', borderRadius: '50%', border: `1px solid ${th.textSecondaryColor}`, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: '11px', color: th.textSecondaryColor, cursor: 'help', flexShrink: 0 }, children: "i" })] }), (0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsx)("textarea", { value: prompt, onChange: (e) => {
636
+ setPrompt(e.target.value);
637
+ e.target.style.height = 'auto';
638
+ e.target.style.height = `${e.target.scrollHeight}px`;
639
+ }, placeholder: t.promptPlaceholder, disabled: isGenerating, rows: 4, style: {
640
+ width: '100%',
641
+ padding: '12px',
642
+ paddingRight: '100px',
643
+ borderRadius: '8px',
644
+ border: `1px solid ${th.borderColor}`,
645
+ backgroundColor: th.cardBackground,
646
+ color: th.textColor,
647
+ fontSize: '14px',
648
+ resize: 'none',
649
+ outline: 'none',
650
+ lineHeight: 1.5,
651
+ boxSizing: 'border-box',
652
+ opacity: isGenerating ? 0.6 : 1,
653
+ overflowY: 'hidden',
654
+ minHeight: '100px',
655
+ } }), (0, jsx_runtime_1.jsx)("button", { onClick: handleCreate, disabled: !prompt.trim() || isGenerating, style: {
656
+ position: 'absolute', right: '8px', bottom: '8px',
657
+ padding: '8px 20px', borderRadius: '20px', border: 'none',
658
+ backgroundColor: (!prompt.trim() || isGenerating) ? th.disabledColor : th.primaryColor,
659
+ color: '#FFFFFF', fontSize: '14px', fontWeight: 700, cursor: (!prompt.trim() || isGenerating) ? 'not-allowed' : 'pointer',
660
+ display: 'flex', alignItems: 'center', gap: '6px',
661
+ transition: 'background-color 0.2s',
662
+ }, onMouseEnter: (e) => { if (prompt.trim() && !isGenerating)
663
+ e.currentTarget.style.backgroundColor = th.primaryHoverColor; }, onMouseLeave: (e) => { if (prompt.trim() && !isGenerating)
664
+ e.currentTarget.style.backgroundColor = th.primaryColor; }, children: isGenerating ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", style: { animation: 'artgen-spin 1s linear infinite' }, children: [(0, jsx_runtime_1.jsx)("polyline", { points: "23 4 23 10 17 10" }), (0, jsx_runtime_1.jsx)("polyline", { points: "1 20 1 14 7 14" }), (0, jsx_runtime_1.jsx)("path", { d: "M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" })] }), t.generatingButton] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: (0, jsx_runtime_1.jsx)("polygon", { points: "13 2 3 14 12 14 11 22 21 10 12 10 13 2" }) }), t.createButton] })) })] }), isGenerating && renderProgressBar()] }), (0, jsx_runtime_1.jsxs)("div", { style: { flex: 1 }, children: [(0, jsx_runtime_1.jsx)("h3", { style: { fontSize: '16px', fontWeight: 700, color: th.textColor, margin: '0 0 12px 0' }, children: t.resultTitle }), (0, jsx_runtime_1.jsx)("div", { style: {
665
+ minHeight: '320px', borderRadius: '12px', border: `1px solid ${th.borderColor}`,
666
+ backgroundColor: th.cardBackground, overflow: 'hidden', position: 'relative',
667
+ display: 'flex', alignItems: 'center', justifyContent: 'center',
668
+ }, children: genError ? ((0, jsx_runtime_1.jsx)("p", { style: { color: '#F87171', fontSize: '14px', textAlign: 'center', padding: '24px' }, children: genError })) : generatedImageUrl ? ((0, jsx_runtime_1.jsx)("img", { src: generatedImageUrl, alt: "Generated result", style: { width: '100%', height: 'auto', display: 'block' } })) : isGenerating ? ((0, jsx_runtime_1.jsxs)("div", { style: { textAlign: 'center', color: th.textSecondaryColor, padding: '24px' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { width: '48px', height: '48px', border: `3px solid ${th.borderColor}`, borderTop: `3px solid ${th.primaryColor}`, borderRadius: '50%', margin: '0 auto 16px', animation: 'artgen-spin 1s linear infinite' } }), (0, jsx_runtime_1.jsx)("p", { style: { margin: 0, fontSize: '14px' }, children: t.generatingButton })] })) : ((0, jsx_runtime_1.jsx)("p", { style: { color: th.textSecondaryColor, fontSize: '14px', textAlign: 'center', padding: '24px' }, children: t.emptyResultText })) }), generatedImageUrl && !isGenerating && ((0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '12px', marginTop: '12px', justifyContent: 'flex-end' }, children: [(0, jsx_runtime_1.jsxs)("button", { onClick: handleStartAgain, style: {
669
+ padding: '10px 20px', borderRadius: '20px', border: `1px solid ${th.borderColor}`,
670
+ backgroundColor: 'transparent', color: th.textColor, fontSize: '14px', fontWeight: 600,
671
+ cursor: 'pointer', display: 'flex', alignItems: 'center', gap: '6px',
672
+ }, children: [(0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [(0, jsx_runtime_1.jsx)("polyline", { points: "1 4 1 10 7 10" }), (0, jsx_runtime_1.jsx)("path", { d: "M3.51 15a9 9 0 1 0 .49-3" })] }), t.startAgainButton] }), (0, jsx_runtime_1.jsxs)("button", { onClick: handleDownload, style: {
673
+ padding: '10px 20px', borderRadius: '20px', border: 'none',
674
+ backgroundColor: th.primaryColor, color: '#FFFFFF', fontSize: '14px', fontWeight: 600,
675
+ cursor: 'pointer', display: 'flex', alignItems: 'center', gap: '6px',
676
+ }, onMouseEnter: (e) => { e.currentTarget.style.backgroundColor = th.primaryHoverColor; }, onMouseLeave: (e) => { e.currentTarget.style.backgroundColor = th.primaryColor; }, children: [(0, jsx_runtime_1.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [(0, jsx_runtime_1.jsx)("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }), (0, jsx_runtime_1.jsx)("polyline", { points: "7 10 12 15 17 10" }), (0, jsx_runtime_1.jsx)("line", { x1: "12", y1: "15", x2: "12", y2: "3" })] }), t.downloadButton] })] }))] })] })] }));
677
+ const renderCollectionsTab = () => ((0, jsx_runtime_1.jsx)("div", { style: { padding: '24px' }, children: loadingCollections ? ((0, jsx_runtime_1.jsx)("p", { style: { color: th.textSecondaryColor, fontSize: '14px' }, children: t.loadingText })) : collections.length === 0 ? ((0, jsx_runtime_1.jsx)("p", { style: { color: th.textSecondaryColor, fontSize: '14px' }, children: t.emptyResultText })) : (collections.map((cat, catIdx) => ((0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: '32px' }, children: [(0, jsx_runtime_1.jsx)("h3", { style: { fontSize: '18px', fontWeight: 700, color: th.textColor, margin: '0 0 16px 0' }, children: cat.label }), (0, jsx_runtime_1.jsx)("div", { className: "artgen-collections-grid", children: cat.items.map((item) => ((0, jsx_runtime_1.jsxs)("div", { style: { borderRadius: '8px', overflow: 'hidden', backgroundColor: th.cardBackground, border: `1px solid ${th.borderColor}` }, children: [(0, jsx_runtime_1.jsx)("img", { src: item.image, alt: item.title || '', style: { width: '100%', aspectRatio: '3/4', objectFit: 'cover', display: 'block' } }), (0, jsx_runtime_1.jsxs)("div", { style: { padding: '8px' }, children: [item.title && ((0, jsx_runtime_1.jsx)("p", { style: { margin: '0 0 6px', fontSize: '12px', color: th.textSecondaryColor, lineHeight: 1.4, overflow: 'hidden', display: '-webkit-box', WebkitLineClamp: 2, WebkitBoxOrient: 'vertical' }, children: item.title })), (0, jsx_runtime_1.jsxs)("button", { onClick: () => { setPrompt(item.description || item.title || ''); setActiveTab('create'); }, style: {
678
+ width: '100%', padding: '6px', borderRadius: '16px', border: `1px solid ${th.primaryColor}`,
679
+ backgroundColor: 'transparent', color: th.primaryColor, fontSize: '12px', fontWeight: 600,
680
+ cursor: 'pointer', display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '4px',
681
+ }, children: [(0, jsx_runtime_1.jsxs)("svg", { width: "10", height: "10", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [(0, jsx_runtime_1.jsx)("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })] }), t.tryButton] })] })] }, item.id))) })] }, catIdx)))) }));
682
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { backgroundColor: th.backgroundColor, borderRadius: '12px', overflow: 'hidden' }, children: [(0, jsx_runtime_1.jsx)("style", { children: `@keyframes artgen-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }` }), (0, jsx_runtime_1.jsx)("div", { style: { display: 'flex', gap: '8px', padding: '16px 24px', borderBottom: `1px solid ${th.borderColor}` }, children: [
683
+ { id: 'create', label: t.createTabLabel },
684
+ { id: 'collections', label: t.collectionsTabLabel },
685
+ ].map(tab => ((0, jsx_runtime_1.jsx)("button", { onClick: () => setActiveTab(tab.id), style: {
686
+ padding: '8px 20px', borderRadius: '20px',
687
+ border: activeTab === tab.id ? 'none' : `1px solid ${th.borderColor}`,
688
+ backgroundColor: activeTab === tab.id ? tabActive : 'transparent',
689
+ color: activeTab === tab.id ? '#FFFFFF' : th.textSecondaryColor,
690
+ fontSize: '14px', fontWeight: 600, cursor: 'pointer',
691
+ transition: 'all 0.2s',
692
+ }, children: tab.label }, tab.id))) }), activeTab === 'create' ? renderCreateTab() : renderCollectionsTab()] }));
693
+ }
694
+ function ArtGeneratorForYouCard({ title, description, ctaText, ctaHref, desktopImage, mobileImage, imageAlt = '', imageOnRight = true, titleColor = '#001B5E', descriptionColor = '#001B5E', ctaColor = '#6C63FF', ctaHoverColor = '#5a52d5', backgroundColor = '#F9F9F9', paddingClass = 'py-12 md:py-16 lg:py-20', }) {
695
+ const effectiveMobileImage = mobileImage || desktopImage;
696
+ const imageColumn = ((0, jsx_runtime_1.jsxs)("div", { className: `${imageOnRight ? '' : 'order-2 md:order-1'} overflow-hidden`, children: [(0, jsx_runtime_1.jsx)("img", { src: desktopImage, alt: imageAlt, className: "hidden md:block w-full h-auto object-contain" }), (0, jsx_runtime_1.jsx)("img", { src: effectiveMobileImage, alt: imageAlt, className: "block md:hidden w-full h-auto object-contain" })] }));
697
+ const contentColumn = ((0, jsx_runtime_1.jsxs)("div", { className: `${imageOnRight ? '' : 'order-1 md:order-2'} text-center md:text-left`, children: [(0, jsx_runtime_1.jsx)("h3", { className: "text-2xl md:text-3xl font-bold mb-4 md:mb-6", style: { color: titleColor }, children: title }), (0, jsx_runtime_1.jsx)("p", { className: "text-base md:text-lg mb-6 md:mb-8 leading-relaxed", style: { color: descriptionColor }, children: description }), (0, jsx_runtime_1.jsx)("a", { href: ctaHref, className: "inline-block text-white font-bold text-lg px-8 py-4 rounded-full transition-colors duration-300 cursor-pointer", style: { backgroundColor: ctaColor }, onMouseEnter: (e) => { e.currentTarget.style.backgroundColor = ctaHoverColor; }, onMouseLeave: (e) => { e.currentTarget.style.backgroundColor = ctaColor; }, children: ctaText })] }));
698
+ return ((0, jsx_runtime_1.jsx)("section", { className: "w-full", style: { backgroundColor }, children: (0, jsx_runtime_1.jsx)("div", { className: `container mx-auto px-4 ${paddingClass}`, children: (0, jsx_runtime_1.jsx)("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-8 md:gap-12 lg:gap-16 items-start", children: imageOnRight ? (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [contentColumn, imageColumn] }) : (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [imageColumn, contentColumn] }) }) }) }));
699
+ }
700
+ exports.default = ArtGenerator;
701
+ //# sourceMappingURL=ArtGenerator.js.map