webs-sdk 0.18.89 → 0.18.91
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ArtGenerator.d.ts +106 -0
- package/dist/components/ArtGenerator.d.ts.map +1 -0
- package/dist/components/ArtGenerator.js +701 -0
- package/dist/components/ArtGenerator.js.map +1 -0
- package/dist/components/GifsIa.d.ts +88 -0
- package/dist/components/GifsIa.d.ts.map +1 -0
- package/dist/components/GifsIa.js +565 -0
- package/dist/components/GifsIa.js.map +1 -0
- package/dist/components/for-you/ForYouPage.d.ts +30 -0
- package/dist/components/for-you/ForYouPage.d.ts.map +1 -1
- package/dist/components/for-you/ForYouPage.js +14 -0
- package/dist/components/for-you/ForYouPage.js.map +1 -1
- package/dist/components/for-you/cards/ArtGeneratorCard.d.ts +7 -0
- package/dist/components/for-you/cards/ArtGeneratorCard.d.ts.map +1 -0
- package/dist/components/for-you/cards/ArtGeneratorCard.js +22 -0
- package/dist/components/for-you/cards/ArtGeneratorCard.js.map +1 -0
- package/dist/components/for-you/cards/GifsIaCard.d.ts +7 -0
- package/dist/components/for-you/cards/GifsIaCard.d.ts.map +1 -0
- package/dist/components/for-you/cards/GifsIaCard.js +22 -0
- package/dist/components/for-you/cards/GifsIaCard.js.map +1 -0
- package/dist/components/for-you/cards/index.d.ts +4 -0
- package/dist/components/for-you/cards/index.d.ts.map +1 -1
- package/dist/components/for-you/cards/index.js +5 -1
- package/dist/components/for-you/cards/index.js.map +1 -1
- package/dist/components/for-you/hooks/index.d.ts +4 -0
- package/dist/components/for-you/hooks/index.d.ts.map +1 -1
- package/dist/components/for-you/hooks/index.js +5 -1
- package/dist/components/for-you/hooks/index.js.map +1 -1
- package/dist/components/for-you/hooks/useArtGenerator.d.ts +47 -0
- package/dist/components/for-you/hooks/useArtGenerator.d.ts.map +1 -0
- package/dist/components/for-you/hooks/useArtGenerator.js +265 -0
- package/dist/components/for-you/hooks/useArtGenerator.js.map +1 -0
- package/dist/components/for-you/hooks/useGifsIa.d.ts +46 -0
- package/dist/components/for-you/hooks/useGifsIa.d.ts.map +1 -0
- package/dist/components/for-you/hooks/useGifsIa.js +240 -0
- package/dist/components/for-you/hooks/useGifsIa.js.map +1 -0
- package/dist/components/for-you/i18n/forYouTranslations.d.ts.map +1 -1
- package/dist/components/for-you/i18n/forYouTranslations.js +83 -1
- package/dist/components/for-you/i18n/forYouTranslations.js.map +1 -1
- package/dist/components/for-you/index.d.ts +9 -1
- package/dist/components/for-you/index.d.ts.map +1 -1
- package/dist/components/for-you/index.js +9 -1
- package/dist/components/for-you/index.js.map +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,565 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GifsIa = GifsIa;
|
|
4
|
+
exports.GifsIaForYouCard = GifsIaForYouCard;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const forYouFetch_1 = require("./for-you/api/forYouFetch");
|
|
8
|
+
const GIFSÍA_CSS = `
|
|
9
|
+
.gifsía-layout {
|
|
10
|
+
display: grid;
|
|
11
|
+
grid-template-columns: 1fr;
|
|
12
|
+
gap: 16px;
|
|
13
|
+
}
|
|
14
|
+
@media (min-width: 768px) {
|
|
15
|
+
.gifsía-layout {
|
|
16
|
+
grid-template-columns: 1fr 1fr;
|
|
17
|
+
gap: 20px;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
.gifsía-checker {
|
|
21
|
+
background-image: linear-gradient(45deg, #3a3a4a 25%, transparent 25%),
|
|
22
|
+
linear-gradient(-45deg, #3a3a4a 25%, transparent 25%),
|
|
23
|
+
linear-gradient(45deg, transparent 75%, #3a3a4a 75%),
|
|
24
|
+
linear-gradient(-45deg, transparent 75%, #3a3a4a 75%);
|
|
25
|
+
background-size: 20px 20px;
|
|
26
|
+
background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
|
|
27
|
+
background-color: #2a2a3a;
|
|
28
|
+
}
|
|
29
|
+
.gifsía-gallery-scroll {
|
|
30
|
+
display: flex;
|
|
31
|
+
gap: 12px;
|
|
32
|
+
overflow-x: auto;
|
|
33
|
+
scroll-snap-type: x mandatory;
|
|
34
|
+
-webkit-overflow-scrolling: touch;
|
|
35
|
+
scrollbar-width: none;
|
|
36
|
+
-ms-overflow-style: none;
|
|
37
|
+
}
|
|
38
|
+
.gifsía-gallery-scroll::-webkit-scrollbar {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
.gifsía-gallery-item {
|
|
42
|
+
scroll-snap-align: start;
|
|
43
|
+
flex: 0 0 calc(25% - 9px);
|
|
44
|
+
min-width: 80px;
|
|
45
|
+
}
|
|
46
|
+
@keyframes gifsía-scan {
|
|
47
|
+
0% { top: 0%; }
|
|
48
|
+
100% { top: 100%; }
|
|
49
|
+
}
|
|
50
|
+
@keyframes gifsía-spin {
|
|
51
|
+
from { transform: rotate(0deg); }
|
|
52
|
+
to { transform: rotate(360deg); }
|
|
53
|
+
}
|
|
54
|
+
.gifsía-scan-line {
|
|
55
|
+
position: absolute;
|
|
56
|
+
left: 0;
|
|
57
|
+
width: 100%;
|
|
58
|
+
height: 3px;
|
|
59
|
+
background: linear-gradient(90deg, transparent, #6C63FF, transparent);
|
|
60
|
+
animation: gifsía-scan 1.8s linear infinite;
|
|
61
|
+
z-index: 10;
|
|
62
|
+
box-shadow: 0 0 8px 2px rgba(108, 99, 255, 0.6);
|
|
63
|
+
}
|
|
64
|
+
`;
|
|
65
|
+
const defaultTheme = {
|
|
66
|
+
primaryColor: '#6C63FF',
|
|
67
|
+
primaryHoverColor: '#5a52d5',
|
|
68
|
+
backgroundColor: '#1A1A2E',
|
|
69
|
+
cardBackground: '#252540',
|
|
70
|
+
borderColor: '#3A3A5C',
|
|
71
|
+
textColor: '#FFFFFF',
|
|
72
|
+
textSecondaryColor: '#A0A0C0',
|
|
73
|
+
createButtonColor: '#6C63FF',
|
|
74
|
+
disabledColor: '#4A4A6A',
|
|
75
|
+
gifPanelBackground: '#252540',
|
|
76
|
+
};
|
|
77
|
+
const defaultTexts = {
|
|
78
|
+
galleryTitle: 'GIF Gallery',
|
|
79
|
+
photoSectionTitle: 'Photo',
|
|
80
|
+
gifSectionTitle: 'GIF',
|
|
81
|
+
uploadButton: 'Upload image',
|
|
82
|
+
createGifButton: 'Create GIF',
|
|
83
|
+
creatingGifButton: 'Creating GIF...',
|
|
84
|
+
copyLinkButton: 'Copy link',
|
|
85
|
+
downloadButton: 'Download',
|
|
86
|
+
emptyPhotoText: 'Upload a photo to create your GIF',
|
|
87
|
+
emptyGifText: 'Your GIF will appear here',
|
|
88
|
+
loadingGalleryText: 'Loading gallery...',
|
|
89
|
+
errorText: 'An error occurred. Please try again.',
|
|
90
|
+
fileTooLargeText: 'File is too large. Max {size}MB.',
|
|
91
|
+
invalidFormatText: 'Invalid format. Please upload an image.',
|
|
92
|
+
linkCopiedText: 'Link copied!',
|
|
93
|
+
queueText: 'In queue',
|
|
94
|
+
pasteImageTooltip: 'Paste image from clipboard',
|
|
95
|
+
resetTooltip: 'Clear and start over',
|
|
96
|
+
};
|
|
97
|
+
function GifBadge({ color = '#6C63FF' }) {
|
|
98
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: "28", height: "20", viewBox: "0 0 28 20", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [(0, jsx_runtime_1.jsx)("rect", { width: "28", height: "20", rx: "4", fill: color }), (0, jsx_runtime_1.jsx)("text", { x: "4", y: "14", fill: "white", fontSize: "10", fontWeight: "700", fontFamily: "monospace", children: "GIF" })] }));
|
|
99
|
+
}
|
|
100
|
+
function CameraBadge({ color = '#6C63FF' }) {
|
|
101
|
+
return ((0, jsx_runtime_1.jsxs)("svg", { width: "18", height: "16", viewBox: "0 0 18 16", fill: "none", stroke: color, strokeWidth: "1.5", children: [(0, jsx_runtime_1.jsx)("path", { d: "M1 5.5A1.5 1.5 0 0 1 2.5 4h1.086a1.5 1.5 0 0 0 1.06-.44l1-1A1.5 1.5 0 0 1 6.706 2h4.588a1.5 1.5 0 0 1 1.06.44l1 1A1.5 1.5 0 0 0 14.414 4H15.5A1.5 1.5 0 0 1 17 5.5v7A1.5 1.5 0 0 1 15.5 14h-13A1.5 1.5 0 0 1 1 12.5v-7z" }), (0, jsx_runtime_1.jsx)("circle", { cx: "9", cy: "9", r: "2.5" })] }));
|
|
102
|
+
}
|
|
103
|
+
function GifsIa({ config, galleryItems: galleryProp, theme = {}, texts = {}, imageProxyUrl, onGifCreated, onDownload, onCopyLink, onError, }) {
|
|
104
|
+
var _a;
|
|
105
|
+
const t = Object.assign(Object.assign({}, defaultTexts), texts);
|
|
106
|
+
const th = Object.assign(Object.assign({}, defaultTheme), theme);
|
|
107
|
+
const createBtnColor = th.createButtonColor || th.primaryColor;
|
|
108
|
+
const gifBg = th.gifPanelBackground || th.cardBackground;
|
|
109
|
+
const maxFileMB = (_a = config.maxFileSizeMB) !== null && _a !== void 0 ? _a : 10;
|
|
110
|
+
(0, react_1.useEffect)(() => {
|
|
111
|
+
const id = 'gifsía-styles';
|
|
112
|
+
if (document.getElementById(id))
|
|
113
|
+
return;
|
|
114
|
+
const style = document.createElement('style');
|
|
115
|
+
style.id = id;
|
|
116
|
+
style.textContent = GIFSÍA_CSS;
|
|
117
|
+
document.head.appendChild(style);
|
|
118
|
+
}, []);
|
|
119
|
+
const [dynamicGallery, setDynamicGallery] = (0, react_1.useState)([]);
|
|
120
|
+
const [loadingGallery, setLoadingGallery] = (0, react_1.useState)(false);
|
|
121
|
+
(0, react_1.useEffect)(() => {
|
|
122
|
+
if (galleryProp && galleryProp.length > 0)
|
|
123
|
+
return;
|
|
124
|
+
const hasFetch = config.galleryTags || config.galleryContents || config.apiBaseUrl || config.apiUrl;
|
|
125
|
+
if (!hasFetch)
|
|
126
|
+
return;
|
|
127
|
+
const load = async () => {
|
|
128
|
+
var _a;
|
|
129
|
+
setLoadingGallery(true);
|
|
130
|
+
try {
|
|
131
|
+
const apiUrl = (_a = config.apiUrl) !== null && _a !== void 0 ? _a : (config.apiBaseUrl ? `${config.apiBaseUrl}/api/get_contents_by_tags` : '/api/get_contents_by_tags');
|
|
132
|
+
const tags = config.galleryTags
|
|
133
|
+
? (Array.isArray(config.galleryTags) ? config.galleryTags : [config.galleryTags])
|
|
134
|
+
: undefined;
|
|
135
|
+
const items = await (0, forYouFetch_1.forYouFetch)({
|
|
136
|
+
apiUrl,
|
|
137
|
+
apiBaseUrl: config.apiBaseUrl,
|
|
138
|
+
tags,
|
|
139
|
+
contents: config.galleryContents,
|
|
140
|
+
locale: config.locale || 'en',
|
|
141
|
+
website_id: config.website_id,
|
|
142
|
+
});
|
|
143
|
+
const mapped = items
|
|
144
|
+
.map((item, idx) => {
|
|
145
|
+
var _a, _b, _c, _d, _e;
|
|
146
|
+
return ({
|
|
147
|
+
id: (_a = item.id) !== null && _a !== void 0 ? _a : idx,
|
|
148
|
+
imageUrl: item.thumbnail || ((_b = item.images) === null || _b === void 0 ? void 0 : _b.img3) || ((_c = item.images) === null || _c === void 0 ? void 0 : _c.img1) || item.imageUrl || '',
|
|
149
|
+
gifUrl: ((_d = item.metadata) === null || _d === void 0 ? void 0 : _d.gif) || ((_e = item.metadata) === null || _e === void 0 ? void 0 : _e.gif_light) || item.gifUrl || item.gif_url || undefined,
|
|
150
|
+
title: item.title || '',
|
|
151
|
+
});
|
|
152
|
+
})
|
|
153
|
+
.filter((i) => i.imageUrl);
|
|
154
|
+
setDynamicGallery(mapped);
|
|
155
|
+
}
|
|
156
|
+
catch (err) {
|
|
157
|
+
console.error('[GifsIa] Error loading gallery:', err);
|
|
158
|
+
}
|
|
159
|
+
finally {
|
|
160
|
+
setLoadingGallery(false);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
load();
|
|
164
|
+
}, [config.apiUrl, config.apiBaseUrl, config.galleryTags]);
|
|
165
|
+
const gallery = galleryProp && galleryProp.length > 0 ? galleryProp : dynamicGallery;
|
|
166
|
+
const [selectedGalleryId, setSelectedGalleryId] = (0, react_1.useState)(null);
|
|
167
|
+
const [uploadedImageBase64, setUploadedImageBase64] = (0, react_1.useState)(null);
|
|
168
|
+
const [isGenerating, setIsGenerating] = (0, react_1.useState)(false);
|
|
169
|
+
const [generatedGifUrl, setGeneratedGifUrl] = (0, react_1.useState)(null);
|
|
170
|
+
const [progressPercent, setProgressPercent] = (0, react_1.useState)(null);
|
|
171
|
+
const [queuePosition, setQueuePosition] = (0, react_1.useState)(null);
|
|
172
|
+
const [genError, setGenError] = (0, react_1.useState)(null);
|
|
173
|
+
const [copySuccess, setCopySuccess] = (0, react_1.useState)(false);
|
|
174
|
+
const fileInputRef = (0, react_1.useRef)(null);
|
|
175
|
+
const pollRef = (0, react_1.useRef)(null);
|
|
176
|
+
const timeoutRef = (0, react_1.useRef)(null);
|
|
177
|
+
const galleryScrollRef = (0, react_1.useRef)(null);
|
|
178
|
+
(0, react_1.useEffect)(() => {
|
|
179
|
+
if (gallery.length > 0 && selectedGalleryId === null) {
|
|
180
|
+
setSelectedGalleryId(gallery[0].id);
|
|
181
|
+
}
|
|
182
|
+
}, [gallery, selectedGalleryId]);
|
|
183
|
+
(0, react_1.useEffect)(() => {
|
|
184
|
+
const el = galleryScrollRef.current;
|
|
185
|
+
if (!el)
|
|
186
|
+
return;
|
|
187
|
+
const onWheel = (e) => {
|
|
188
|
+
if (Math.abs(e.deltaX) > Math.abs(e.deltaY))
|
|
189
|
+
return;
|
|
190
|
+
e.preventDefault();
|
|
191
|
+
el.scrollLeft += e.deltaY;
|
|
192
|
+
};
|
|
193
|
+
el.addEventListener('wheel', onWheel, { passive: false });
|
|
194
|
+
return () => el.removeEventListener('wheel', onWheel);
|
|
195
|
+
}, []);
|
|
196
|
+
const clearPolls = (0, react_1.useCallback)(() => {
|
|
197
|
+
if (pollRef.current) {
|
|
198
|
+
clearInterval(pollRef.current);
|
|
199
|
+
pollRef.current = null;
|
|
200
|
+
}
|
|
201
|
+
if (timeoutRef.current) {
|
|
202
|
+
clearTimeout(timeoutRef.current);
|
|
203
|
+
timeoutRef.current = null;
|
|
204
|
+
}
|
|
205
|
+
}, []);
|
|
206
|
+
(0, react_1.useEffect)(() => () => clearPolls(), [clearPolls]);
|
|
207
|
+
const processFile = (file) => {
|
|
208
|
+
if (!file.type.startsWith('image/')) {
|
|
209
|
+
alert(t.invalidFormatText);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (file.size > maxFileMB * 1024 * 1024) {
|
|
213
|
+
alert(t.fileTooLargeText.replace('{size}', String(maxFileMB)));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
const reader = new FileReader();
|
|
217
|
+
reader.onloadend = () => {
|
|
218
|
+
setUploadedImageBase64(reader.result);
|
|
219
|
+
};
|
|
220
|
+
reader.readAsDataURL(file);
|
|
221
|
+
};
|
|
222
|
+
const handleFileChange = (e) => {
|
|
223
|
+
var _a;
|
|
224
|
+
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
225
|
+
if (file)
|
|
226
|
+
processFile(file);
|
|
227
|
+
};
|
|
228
|
+
const handleUploadClick = () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); };
|
|
229
|
+
const handleClipboardButtonClick = async () => {
|
|
230
|
+
if (uploadedImageBase64) {
|
|
231
|
+
handleReset();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
try {
|
|
235
|
+
const items = await navigator.clipboard.read();
|
|
236
|
+
for (const item of items) {
|
|
237
|
+
const imageType = item.types.find(t => t.startsWith('image/'));
|
|
238
|
+
if (imageType) {
|
|
239
|
+
const blob = await item.getType(imageType);
|
|
240
|
+
const file = new File([blob], 'clipboard.png', { type: imageType });
|
|
241
|
+
processFile(file);
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
catch (_a) {
|
|
247
|
+
console.warn('[GifsIa] No clipboard image or permission denied');
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
const handleReset = () => {
|
|
251
|
+
clearPolls();
|
|
252
|
+
setUploadedImageBase64(null);
|
|
253
|
+
setGeneratedGifUrl(null);
|
|
254
|
+
setProgressPercent(null);
|
|
255
|
+
setQueuePosition(null);
|
|
256
|
+
setGenError(null);
|
|
257
|
+
setIsGenerating(false);
|
|
258
|
+
if (fileInputRef.current)
|
|
259
|
+
fileInputRef.current.value = '';
|
|
260
|
+
};
|
|
261
|
+
const handleCreateGif = async () => {
|
|
262
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
263
|
+
if (!uploadedImageBase64 || isGenerating)
|
|
264
|
+
return;
|
|
265
|
+
clearPolls();
|
|
266
|
+
setIsGenerating(true);
|
|
267
|
+
setGeneratedGifUrl(null);
|
|
268
|
+
setProgressPercent(0);
|
|
269
|
+
setQueuePosition(null);
|
|
270
|
+
setGenError(null);
|
|
271
|
+
const pollInterval = (_a = config.pollInterval) !== null && _a !== void 0 ? _a : 3000;
|
|
272
|
+
const maxPollTime = (_b = config.maxPollTime) !== null && _b !== void 0 ? _b : 120000;
|
|
273
|
+
const selectedItem = gallery.find(g => g.id === selectedGalleryId);
|
|
274
|
+
const generateUrl = (_c = config.generateApiUrl) !== null && _c !== void 0 ? _c : (config.generateBaseUrl ? `${config.generateBaseUrl.replace(/\/$/, '')}/get_art_generation` : null);
|
|
275
|
+
if (!generateUrl) {
|
|
276
|
+
setGenError(t.errorText);
|
|
277
|
+
setIsGenerating(false);
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
280
|
+
try {
|
|
281
|
+
const genRes = await fetch(generateUrl, {
|
|
282
|
+
method: 'POST',
|
|
283
|
+
headers: { 'Content-Type': 'application/json' },
|
|
284
|
+
body: JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({ image: uploadedImageBase64 }, (selectedItem && { reference_image: selectedItem.gifUrl || selectedItem.imageUrl })), (config.userId && { us_id: config.userId })), (config.userLogin && { us_login: config.userLogin })), (config.wid && { wid: config.wid }))),
|
|
285
|
+
});
|
|
286
|
+
if (!genRes.ok)
|
|
287
|
+
throw new Error(`Generation error: ${genRes.status}`);
|
|
288
|
+
const genData = await genRes.json();
|
|
289
|
+
console.log('[GifsIa] generate response:', JSON.stringify(genData));
|
|
290
|
+
if ((genData === null || genData === void 0 ? void 0 : genData.success) === 0 || (genData === null || genData === void 0 ? void 0 : genData.success) === false) {
|
|
291
|
+
throw new Error((genData === null || genData === void 0 ? void 0 : genData.msg) || (genData === null || genData === void 0 ? void 0 : genData.error) || 'Generation failed');
|
|
292
|
+
}
|
|
293
|
+
const jobId = ((_d = genData === null || genData === void 0 ? void 0 : genData.data) === null || _d === void 0 ? void 0 : _d.md5) ||
|
|
294
|
+
((_e = genData === null || genData === void 0 ? void 0 : genData.data) === null || _e === void 0 ? void 0 : _e.request_id) ||
|
|
295
|
+
((_f = genData === null || genData === void 0 ? void 0 : genData.data) === null || _f === void 0 ? void 0 : _f.job_id) ||
|
|
296
|
+
((_g = genData === null || genData === void 0 ? void 0 : genData.data) === null || _g === void 0 ? void 0 : _g.id) ||
|
|
297
|
+
(genData === null || genData === void 0 ? void 0 : genData.md5) ||
|
|
298
|
+
(genData === null || genData === void 0 ? void 0 : genData.request_id) ||
|
|
299
|
+
(genData === null || genData === void 0 ? void 0 : genData.job_id) ||
|
|
300
|
+
(genData === null || genData === void 0 ? void 0 : genData.id);
|
|
301
|
+
console.log('[GifsIa] jobId extracted:', jobId);
|
|
302
|
+
if (!jobId)
|
|
303
|
+
throw new Error(`No job ID received. Response: ${JSON.stringify(genData)}`);
|
|
304
|
+
timeoutRef.current = setTimeout(() => {
|
|
305
|
+
clearPolls();
|
|
306
|
+
setIsGenerating(false);
|
|
307
|
+
setGenError(t.errorText);
|
|
308
|
+
onError === null || onError === void 0 ? void 0 : onError(t.errorText);
|
|
309
|
+
}, maxPollTime);
|
|
310
|
+
const base = (_j = (_h = config.generateBaseUrl) === null || _h === void 0 ? void 0 : _h.replace(/\/$/, '')) !== null && _j !== void 0 ? _j : '';
|
|
311
|
+
const poll = async () => {
|
|
312
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
313
|
+
try {
|
|
314
|
+
const progressUrl = (_a = config.progressApiUrl) !== null && _a !== void 0 ? _a : (base ? `${base}/get_arg_pct` : null);
|
|
315
|
+
if (progressUrl) {
|
|
316
|
+
const isProxy = !!config.progressApiUrl;
|
|
317
|
+
if (isProxy) {
|
|
318
|
+
const pctRes = await fetch(progressUrl, {
|
|
319
|
+
method: 'POST',
|
|
320
|
+
headers: { 'Content-Type': 'application/json' },
|
|
321
|
+
body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
|
|
322
|
+
});
|
|
323
|
+
if (pctRes.ok) {
|
|
324
|
+
const pctData = await pctRes.json();
|
|
325
|
+
const pct = (_d = (_c = (_b = pctData === null || pctData === void 0 ? void 0 : pctData.data) === null || _b === void 0 ? void 0 : _b.pct) !== null && _c !== void 0 ? _c : pctData === null || pctData === void 0 ? void 0 : pctData.pct) !== null && _d !== void 0 ? _d : 0;
|
|
326
|
+
const pos = (_f = (_e = pctData === null || pctData === void 0 ? void 0 : pctData.data) === null || _e === void 0 ? void 0 : _e.position) !== null && _f !== void 0 ? _f : null;
|
|
327
|
+
const gifUrl = (_h = (_g = pctData === null || pctData === void 0 ? void 0 : pctData.data) === null || _g === void 0 ? void 0 : _g.gifUrl) !== null && _h !== void 0 ? _h : null;
|
|
328
|
+
setProgressPercent(pct);
|
|
329
|
+
if (pos !== null)
|
|
330
|
+
setQueuePosition(pos);
|
|
331
|
+
if (gifUrl) {
|
|
332
|
+
clearPolls();
|
|
333
|
+
setGeneratedGifUrl(gifUrl);
|
|
334
|
+
setProgressPercent(100);
|
|
335
|
+
setIsGenerating(false);
|
|
336
|
+
onGifCreated === null || onGifCreated === void 0 ? void 0 : onGifCreated(gifUrl);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
else {
|
|
343
|
+
const queueUrl = `${base}/get_queue_position`;
|
|
344
|
+
const queueRes = await fetch(queueUrl, {
|
|
345
|
+
method: 'POST',
|
|
346
|
+
headers: { 'Content-Type': 'application/json' },
|
|
347
|
+
body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
|
|
348
|
+
});
|
|
349
|
+
if (queueRes.ok) {
|
|
350
|
+
const qd = await queueRes.json();
|
|
351
|
+
setQueuePosition((_l = (_k = (_j = qd === null || qd === void 0 ? void 0 : qd.data) === null || _j === void 0 ? void 0 : _j.position) !== null && _k !== void 0 ? _k : qd === null || qd === void 0 ? void 0 : qd.position) !== null && _l !== void 0 ? _l : null);
|
|
352
|
+
}
|
|
353
|
+
const pctRes = await fetch(progressUrl, {
|
|
354
|
+
method: 'POST',
|
|
355
|
+
headers: { 'Content-Type': 'application/json' },
|
|
356
|
+
body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
|
|
357
|
+
});
|
|
358
|
+
if (!pctRes.ok)
|
|
359
|
+
return;
|
|
360
|
+
const pctData = await pctRes.json();
|
|
361
|
+
const pct = (_p = (_o = (_m = pctData === null || pctData === void 0 ? void 0 : pctData.data) === null || _m === void 0 ? void 0 : _m.pct) !== null && _o !== void 0 ? _o : pctData === null || pctData === void 0 ? void 0 : pctData.pct) !== null && _p !== void 0 ? _p : 0;
|
|
362
|
+
setProgressPercent(pct);
|
|
363
|
+
if (pct >= 100) {
|
|
364
|
+
clearPolls();
|
|
365
|
+
const jobRes = await fetch(`${base}/get_art_job`, {
|
|
366
|
+
method: 'POST',
|
|
367
|
+
headers: { 'Content-Type': 'application/json' },
|
|
368
|
+
body: JSON.stringify(Object.assign(Object.assign({ md5: jobId }, (config.userId && { us_id: config.userId })), (config.wid && { wid: config.wid }))),
|
|
369
|
+
});
|
|
370
|
+
if (!jobRes.ok)
|
|
371
|
+
throw new Error('Error fetching GIF');
|
|
372
|
+
const jobData = await jobRes.json();
|
|
373
|
+
const gifUrl = ((_q = jobData === null || jobData === void 0 ? void 0 : jobData.data) === null || _q === void 0 ? void 0 : _q.url) || (jobData === null || jobData === void 0 ? void 0 : jobData.url) || (jobData === null || jobData === void 0 ? void 0 : jobData.gif) || ((_r = jobData === null || jobData === void 0 ? void 0 : jobData.data) === null || _r === void 0 ? void 0 : _r.gif);
|
|
374
|
+
if (!gifUrl)
|
|
375
|
+
throw new Error('No GIF URL received');
|
|
376
|
+
setGeneratedGifUrl(gifUrl);
|
|
377
|
+
setProgressPercent(100);
|
|
378
|
+
setIsGenerating(false);
|
|
379
|
+
onGifCreated === null || onGifCreated === void 0 ? void 0 : onGifCreated(gifUrl);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
catch (err) {
|
|
385
|
+
console.error('[GifsIa] Polling error:', err);
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
poll();
|
|
389
|
+
pollRef.current = setInterval(poll, pollInterval);
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
clearPolls();
|
|
393
|
+
const msg = err instanceof Error ? err.message : t.errorText;
|
|
394
|
+
setGenError(msg);
|
|
395
|
+
setIsGenerating(false);
|
|
396
|
+
onError === null || onError === void 0 ? void 0 : onError(msg);
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const handleCopyLink = async () => {
|
|
400
|
+
if (!generatedGifUrl)
|
|
401
|
+
return;
|
|
402
|
+
if (onCopyLink) {
|
|
403
|
+
onCopyLink(generatedGifUrl);
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
try {
|
|
407
|
+
await navigator.clipboard.writeText(generatedGifUrl);
|
|
408
|
+
setCopySuccess(true);
|
|
409
|
+
setTimeout(() => setCopySuccess(false), 2000);
|
|
410
|
+
}
|
|
411
|
+
catch (_a) {
|
|
412
|
+
console.warn('[GifsIa] Could not copy to clipboard');
|
|
413
|
+
}
|
|
414
|
+
};
|
|
415
|
+
const handleDownload = async () => {
|
|
416
|
+
if (!generatedGifUrl)
|
|
417
|
+
return;
|
|
418
|
+
if (onDownload) {
|
|
419
|
+
onDownload(generatedGifUrl);
|
|
420
|
+
return;
|
|
421
|
+
}
|
|
422
|
+
try {
|
|
423
|
+
const fetchUrl = imageProxyUrl ? `${imageProxyUrl}${encodeURIComponent(generatedGifUrl)}` : generatedGifUrl;
|
|
424
|
+
const res = await fetch(fetchUrl);
|
|
425
|
+
const blob = await res.blob();
|
|
426
|
+
const url = URL.createObjectURL(blob);
|
|
427
|
+
const a = document.createElement('a');
|
|
428
|
+
a.href = url;
|
|
429
|
+
a.download = `gif-ia-${Date.now()}.gif`;
|
|
430
|
+
document.body.appendChild(a);
|
|
431
|
+
a.click();
|
|
432
|
+
document.body.removeChild(a);
|
|
433
|
+
URL.revokeObjectURL(url);
|
|
434
|
+
}
|
|
435
|
+
catch (_a) {
|
|
436
|
+
window.open(generatedGifUrl, '_blank');
|
|
437
|
+
}
|
|
438
|
+
};
|
|
439
|
+
const handleDrop = (e) => {
|
|
440
|
+
var _a;
|
|
441
|
+
e.preventDefault();
|
|
442
|
+
const file = (_a = e.dataTransfer.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
443
|
+
if (file)
|
|
444
|
+
processFile(file);
|
|
445
|
+
};
|
|
446
|
+
const handleDragOver = (e) => e.preventDefault();
|
|
447
|
+
return ((0, jsx_runtime_1.jsxs)("div", { style: { backgroundColor: th.backgroundColor, padding: '24px', borderRadius: '12px' }, children: [(0, jsx_runtime_1.jsx)("style", { children: `
|
|
448
|
+
@keyframes gifsía-scan { 0% { top: 0%; } 100% { top: 100%; } }
|
|
449
|
+
@keyframes gifsía-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
|
|
450
|
+
.gifsía-scan-line { position: absolute; left: 0; width: 100%; height: 3px; background: linear-gradient(90deg, transparent, ${th.primaryColor}, transparent); animation: gifsía-scan 1.8s linear infinite; z-index: 10; box-shadow: 0 0 8px 2px ${th.primaryColor}80; }
|
|
451
|
+
` }), (0, jsx_runtime_1.jsx)("input", { ref: fileInputRef, type: "file", accept: config.acceptedFormats || 'image/*', onChange: handleFileChange, style: { display: 'none' } }), (0, jsx_runtime_1.jsxs)("div", { style: { marginBottom: '24px' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', gap: '8px', marginBottom: '12px' }, children: [(0, jsx_runtime_1.jsx)(GifBadge, { color: th.primaryColor }), (0, jsx_runtime_1.jsx)("h3", { style: { margin: 0, fontSize: '18px', fontWeight: 700, color: th.textColor }, children: t.galleryTitle })] }), loadingGallery ? ((0, jsx_runtime_1.jsx)("p", { style: { color: th.textSecondaryColor, fontSize: '14px' }, children: t.loadingGalleryText })) : gallery.length > 0 ? ((0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative' }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => { if (galleryScrollRef.current)
|
|
452
|
+
galleryScrollRef.current.scrollBy({ left: -300, behavior: 'smooth' }); }, style: {
|
|
453
|
+
position: 'absolute', left: '4px', top: '50%', transform: 'translateY(-50%)',
|
|
454
|
+
zIndex: 10, width: '32px', height: '32px', borderRadius: '50%', border: 'none',
|
|
455
|
+
backgroundColor: `${th.primaryColor}dd`, color: '#FFFFFF',
|
|
456
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
457
|
+
cursor: 'pointer', boxShadow: '0 2px 8px rgba(0,0,0,0.5)',
|
|
458
|
+
transition: 'background-color 0.2s',
|
|
459
|
+
}, 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: "14", height: "14", 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: galleryScrollRef, style: {
|
|
460
|
+
display: 'flex',
|
|
461
|
+
flexDirection: 'row',
|
|
462
|
+
gap: '12px',
|
|
463
|
+
overflowX: 'auto',
|
|
464
|
+
overflowY: 'hidden',
|
|
465
|
+
scrollSnapType: 'x mandatory',
|
|
466
|
+
WebkitOverflowScrolling: 'touch',
|
|
467
|
+
scrollbarWidth: 'none',
|
|
468
|
+
msOverflowStyle: 'none',
|
|
469
|
+
width: '100%',
|
|
470
|
+
}, children: gallery.map((item) => {
|
|
471
|
+
const isSelected = selectedGalleryId === item.id;
|
|
472
|
+
return ((0, jsx_runtime_1.jsx)("button", { onClick: () => setSelectedGalleryId(item.id), style: {
|
|
473
|
+
flexShrink: 0,
|
|
474
|
+
width: 'calc(25% - 9px)',
|
|
475
|
+
minWidth: '120px',
|
|
476
|
+
scrollSnapAlign: 'start',
|
|
477
|
+
padding: 0,
|
|
478
|
+
border: `3px solid ${isSelected ? th.primaryColor : 'transparent'}`,
|
|
479
|
+
borderRadius: '10px',
|
|
480
|
+
overflow: 'hidden',
|
|
481
|
+
cursor: 'pointer',
|
|
482
|
+
backgroundColor: 'transparent',
|
|
483
|
+
outline: 'none',
|
|
484
|
+
}, children: (0, jsx_runtime_1.jsx)("img", { src: item.gifUrl || item.imageUrl, alt: item.title || '', style: { width: '100%', aspectRatio: '4/3', objectFit: 'cover', display: 'block' } }) }, item.id));
|
|
485
|
+
}) }), (0, jsx_runtime_1.jsx)("button", { onClick: () => { if (galleryScrollRef.current)
|
|
486
|
+
galleryScrollRef.current.scrollBy({ left: 300, behavior: 'smooth' }); }, style: {
|
|
487
|
+
position: 'absolute', right: '4px', top: '50%', transform: 'translateY(-50%)',
|
|
488
|
+
zIndex: 10, width: '32px', height: '32px', borderRadius: '50%', border: 'none',
|
|
489
|
+
backgroundColor: `${th.primaryColor}dd`, color: '#FFFFFF',
|
|
490
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
491
|
+
cursor: 'pointer', boxShadow: '0 2px 8px rgba(0,0,0,0.5)',
|
|
492
|
+
transition: 'background-color 0.2s',
|
|
493
|
+
}, 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: "14", height: "14", 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" }) }) })] })) : null] }), (0, jsx_runtime_1.jsxs)("div", { className: "gifs\u00EDa-layout", children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '12px' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: [(0, jsx_runtime_1.jsx)(CameraBadge, { color: th.primaryColor }), (0, jsx_runtime_1.jsx)("span", { style: { fontSize: '16px', fontWeight: 700, color: th.primaryColor }, children: t.photoSectionTitle })] }), (0, jsx_runtime_1.jsxs)("div", { className: "gifs\u00EDa-checker", onDrop: handleDrop, onDragOver: handleDragOver, style: {
|
|
494
|
+
position: 'relative', borderRadius: '10px', border: `2px dashed ${th.borderColor}`,
|
|
495
|
+
minHeight: '320px', display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
496
|
+
overflow: 'hidden', cursor: uploadedImageBase64 ? 'default' : 'pointer',
|
|
497
|
+
}, onClick: !uploadedImageBase64 ? handleUploadClick : undefined, children: [(0, jsx_runtime_1.jsx)("button", { onClick: (e) => { e.stopPropagation(); handleClipboardButtonClick(); }, title: uploadedImageBase64 ? t.resetTooltip : t.pasteImageTooltip, style: {
|
|
498
|
+
position: 'absolute', top: '12px', right: '12px', zIndex: 20,
|
|
499
|
+
width: '40px', height: '40px', borderRadius: '50%', border: 'none',
|
|
500
|
+
backgroundColor: th.primaryColor, color: '#FFFFFF',
|
|
501
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
502
|
+
cursor: 'pointer', boxShadow: '0 2px 8px rgba(0,0,0,0.3)',
|
|
503
|
+
}, children: uploadedImageBase64 ? ((0, jsx_runtime_1.jsxs)("svg", { width: "18", height: "18", 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" })] })) : ((0, jsx_runtime_1.jsxs)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [(0, jsx_runtime_1.jsx)("path", { d: "M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" }), (0, jsx_runtime_1.jsx)("rect", { x: "8", y: "2", width: "8", height: "4", rx: "1", ry: "1" })] })) }), uploadedImageBase64 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: uploadedImageBase64, alt: "Uploaded photo", style: { width: '100%', height: '100%', objectFit: 'contain', position: 'absolute', inset: 0 } }), isGenerating && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: { position: 'absolute', inset: 0, backgroundColor: 'rgba(0,0,0,0.3)', zIndex: 9 } }), (0, jsx_runtime_1.jsx)("div", { className: "gifs\u00EDa-scan-line" })] }))] })) : ((0, jsx_runtime_1.jsxs)("button", { onClick: handleUploadClick, style: {
|
|
504
|
+
padding: '12px 24px', borderRadius: '24px', border: 'none',
|
|
505
|
+
backgroundColor: th.primaryColor, color: '#FFFFFF',
|
|
506
|
+
fontSize: '14px', fontWeight: 600, cursor: 'pointer',
|
|
507
|
+
display: 'flex', alignItems: 'center', gap: '8px',
|
|
508
|
+
}, children: [(0, jsx_runtime_1.jsxs)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: [(0, jsx_runtime_1.jsx)("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }), (0, jsx_runtime_1.jsx)("circle", { cx: "8.5", cy: "8.5", r: "1.5" }), (0, jsx_runtime_1.jsx)("polyline", { points: "21 15 16 10 5 21" })] }), t.uploadButton] }))] }), (0, jsx_runtime_1.jsx)("button", { onClick: handleCreateGif, disabled: !uploadedImageBase64 || isGenerating, style: {
|
|
509
|
+
width: '100%', padding: '14px', borderRadius: '28px', border: 'none',
|
|
510
|
+
backgroundColor: (!uploadedImageBase64 || isGenerating) ? th.disabledColor : createBtnColor,
|
|
511
|
+
color: '#FFFFFF', fontSize: '15px', fontWeight: 700,
|
|
512
|
+
cursor: (!uploadedImageBase64 || isGenerating) ? 'not-allowed' : 'pointer',
|
|
513
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '8px',
|
|
514
|
+
transition: 'background-color 0.2s',
|
|
515
|
+
}, onMouseEnter: (e) => { if (uploadedImageBase64 && !isGenerating)
|
|
516
|
+
e.currentTarget.style.backgroundColor = th.primaryHoverColor; }, onMouseLeave: (e) => { if (uploadedImageBase64 && !isGenerating)
|
|
517
|
+
e.currentTarget.style.backgroundColor = createBtnColor; }, children: isGenerating ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("div", { style: { width: '16px', height: '16px', border: '2px solid rgba(255,255,255,0.3)', borderTop: '2px solid #FFFFFF', borderRadius: '50%', animation: 'gifsía-spin 1s linear infinite' } }), t.creatingGifButton] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("svg", { width: "16", height: "16", 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.createGifButton] })) })] }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', flexDirection: 'column', gap: '12px' }, children: [(0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', alignItems: 'center', gap: '8px' }, children: [(0, jsx_runtime_1.jsx)(GifBadge, { color: th.primaryColor }), (0, jsx_runtime_1.jsx)("span", { style: { fontSize: '16px', fontWeight: 700, color: th.primaryColor }, children: t.gifSectionTitle })] }), (0, jsx_runtime_1.jsx)("div", { style: {
|
|
518
|
+
position: 'relative', borderRadius: '10px', border: `2px dashed ${th.borderColor}`,
|
|
519
|
+
minHeight: '320px', display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
520
|
+
overflow: 'hidden', flex: 1,
|
|
521
|
+
backgroundColor: gifBg,
|
|
522
|
+
}, children: genError ? ((0, jsx_runtime_1.jsx)("p", { style: { color: '#F87171', fontSize: '14px', textAlign: 'center', padding: '24px' }, children: genError })) : generatedGifUrl ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("img", { src: generatedGifUrl, alt: "Generated GIF", style: { width: '100%', height: '100%', objectFit: 'contain', position: 'absolute', inset: 0 }, unselectable: "on" }), (0, jsx_runtime_1.jsx)("button", { onClick: () => window.open(generatedGifUrl, '_blank'), style: {
|
|
523
|
+
position: 'absolute', bottom: '12px', right: '12px', zIndex: 20,
|
|
524
|
+
width: '40px', height: '40px', borderRadius: '50%', border: 'none',
|
|
525
|
+
backgroundColor: th.primaryColor, color: '#FFFFFF',
|
|
526
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center',
|
|
527
|
+
cursor: 'pointer', boxShadow: '0 2px 8px rgba(0,0,0,0.3)',
|
|
528
|
+
}, children: (0, jsx_runtime_1.jsx)("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", children: (0, jsx_runtime_1.jsx)("path", { d: "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3" }) }) })] })) : isGenerating ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [selectedGalleryId !== null && gallery.find(g => g.id === selectedGalleryId) && ((0, jsx_runtime_1.jsx)("img", { src: gallery.find(g => g.id === selectedGalleryId).imageUrl, alt: "", style: { position: 'absolute', inset: 0, width: '100%', height: '100%', objectFit: 'cover', filter: 'blur(4px)', opacity: 0.3 } })), (0, jsx_runtime_1.jsxs)("div", { style: { position: 'relative', zIndex: 10, width: '80%', textAlign: 'center' }, children: [(0, jsx_runtime_1.jsx)("div", { style: { backgroundColor: 'rgba(0,0,0,0.6)', borderRadius: '8px', padding: '4px 12px', marginBottom: '8px' }, children: (0, jsx_runtime_1.jsx)("span", { style: { fontSize: '14px', color: '#FFFFFF', fontWeight: 600 }, children: queuePosition !== null && queuePosition > 0
|
|
529
|
+
? `${t.queueText} #${queuePosition}`
|
|
530
|
+
: `${progressPercent !== null && progressPercent !== void 0 ? progressPercent : 0}%` }) }), (0, jsx_runtime_1.jsx)("div", { style: { width: '100%', height: '8px', backgroundColor: 'rgba(255,255,255,0.2)', borderRadius: '4px', overflow: 'hidden' }, children: (0, jsx_runtime_1.jsx)("div", { style: {
|
|
531
|
+
height: '100%', width: `${progressPercent !== null && progressPercent !== void 0 ? progressPercent : 0}%`,
|
|
532
|
+
backgroundColor: th.primaryColor, borderRadius: '4px',
|
|
533
|
+
transition: 'width 0.3s ease',
|
|
534
|
+
} }) })] })] })) : ((0, jsx_runtime_1.jsx)("p", { style: { color: th.textSecondaryColor, fontSize: '14px', textAlign: 'center', padding: '24px' }, children: t.emptyGifText })) }), (0, jsx_runtime_1.jsxs)("div", { style: { display: 'flex', gap: '10px' }, children: [(0, jsx_runtime_1.jsx)("button", { onClick: handleCopyLink, disabled: !generatedGifUrl, style: {
|
|
535
|
+
flex: 1, padding: '12px', borderRadius: '24px',
|
|
536
|
+
border: `1px solid ${generatedGifUrl ? th.primaryColor : th.borderColor}`,
|
|
537
|
+
backgroundColor: 'transparent',
|
|
538
|
+
color: generatedGifUrl ? th.primaryColor : th.textSecondaryColor,
|
|
539
|
+
fontSize: '14px', fontWeight: 600,
|
|
540
|
+
cursor: generatedGifUrl ? 'pointer' : 'not-allowed',
|
|
541
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '6px',
|
|
542
|
+
opacity: generatedGifUrl ? 1 : 0.5,
|
|
543
|
+
transition: 'all 0.2s',
|
|
544
|
+
}, children: copySuccess ? ((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)("polyline", { points: "20 6 9 17 4 12" }) }), t.linkCopiedText] })) : ((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", children: [(0, jsx_runtime_1.jsx)("path", { d: "M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" }), (0, jsx_runtime_1.jsx)("path", { d: "M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" })] }), t.copyLinkButton] })) }), (0, jsx_runtime_1.jsxs)("button", { onClick: handleDownload, disabled: !generatedGifUrl, style: {
|
|
545
|
+
flex: 1, padding: '12px', borderRadius: '24px',
|
|
546
|
+
border: `1px solid ${generatedGifUrl ? th.primaryColor : th.borderColor}`,
|
|
547
|
+
backgroundColor: generatedGifUrl ? th.primaryColor : 'transparent',
|
|
548
|
+
color: generatedGifUrl ? '#FFFFFF' : th.textSecondaryColor,
|
|
549
|
+
fontSize: '14px', fontWeight: 600,
|
|
550
|
+
cursor: generatedGifUrl ? 'pointer' : 'not-allowed',
|
|
551
|
+
display: 'flex', alignItems: 'center', justifyContent: 'center', gap: '6px',
|
|
552
|
+
opacity: generatedGifUrl ? 1 : 0.5,
|
|
553
|
+
transition: 'all 0.2s',
|
|
554
|
+
}, onMouseEnter: (e) => { if (generatedGifUrl)
|
|
555
|
+
e.currentTarget.style.backgroundColor = th.primaryHoverColor; }, onMouseLeave: (e) => { if (generatedGifUrl)
|
|
556
|
+
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] })] })] })] })] }));
|
|
557
|
+
}
|
|
558
|
+
function GifsIaForYouCard({ 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', }) {
|
|
559
|
+
const effectiveMobileImage = mobileImage || desktopImage;
|
|
560
|
+
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" })] }));
|
|
561
|
+
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 })] }));
|
|
562
|
+
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] }) }) }) }));
|
|
563
|
+
}
|
|
564
|
+
exports.default = GifsIa;
|
|
565
|
+
//# sourceMappingURL=GifsIa.js.map
|