@uploadcare/ai-enhancer 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -288
- package/dist/UcAiEnhancer-OUmStG-E.cjs +444 -0
- package/dist/{UcAiEnhancer-D1z2-v9q.js → UcAiEnhancer-qk-y4FHK.js} +432 -427
- package/dist/ai-enhancer.cjs +1 -1
- package/dist/ai-enhancer.d.ts +1 -1
- package/dist/ai-enhancer.js +1 -1
- package/dist/plugin.cjs +1 -1
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +1 -1
- package/package.json +6 -3
- package/dist/UcAiEnhancer-D0mic9eT.cjs +0 -444
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var vt = Object.defineProperty;
|
|
2
|
+
var Me = (t) => {
|
|
3
3
|
throw TypeError(t);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var b = (t, e, i) =>
|
|
7
|
-
var E = (t, e, i) => (
|
|
8
|
-
import { unsafeCSS as
|
|
9
|
-
import { property as c, state as C, query as F, customElement as
|
|
5
|
+
var bt = (t, e, i) => e in t ? vt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
|
|
6
|
+
var b = (t, e, i) => bt(t, typeof e != "symbol" ? e + "" : e, i), ne = (t, e, i) => e.has(t) || Me("Cannot " + i);
|
|
7
|
+
var E = (t, e, i) => (ne(t, e, "read from private field"), i ? i.call(t) : e.get(t)), le = (t, e, i) => e.has(t) ? Me("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(t) : e.set(t, i), Ie = (t, e, i, r) => (ne(t, e, "write to private field"), r ? r.call(t, i) : e.set(t, i), i), J = (t, e, i) => (ne(t, e, "access private method"), i);
|
|
8
|
+
import { unsafeCSS as j, LitElement as G, html as f, nothing as v } from "lit";
|
|
9
|
+
import { property as c, state as C, query as F, customElement as H } from "lit/decorators.js";
|
|
10
10
|
import { classMap as S } from "lit/directives/class-map.js";
|
|
11
|
-
import { unsafeSVG as
|
|
12
|
-
import { nothing as
|
|
13
|
-
import { directive as
|
|
14
|
-
import { AsyncDirective as
|
|
15
|
-
import { repeat as
|
|
16
|
-
|
|
11
|
+
import { unsafeSVG as ie } from "lit/directives/unsafe-svg.js";
|
|
12
|
+
import { nothing as it } from "lit/html.js";
|
|
13
|
+
import { directive as rt, PartType as st } from "lit/directive.js";
|
|
14
|
+
import { AsyncDirective as ot } from "lit/async-directive.js";
|
|
15
|
+
import { repeat as yt } from "lit/directives/repeat.js";
|
|
16
|
+
import { ifDefined as wt } from "lit/directives/if-defined.js";
|
|
17
|
+
const V = "original";
|
|
17
18
|
function O(t) {
|
|
18
|
-
return t != null && t !==
|
|
19
|
+
return t != null && t !== V;
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
-
return t ===
|
|
21
|
+
function fe(t, e) {
|
|
22
|
+
return t === V || e === V ? t === e : Ut(t, e);
|
|
22
23
|
}
|
|
23
|
-
const
|
|
24
|
+
const xt = [
|
|
24
25
|
[2, 3],
|
|
25
26
|
[3, 2],
|
|
26
27
|
[1, 1],
|
|
27
28
|
[9, 16],
|
|
28
29
|
[16, 9]
|
|
29
|
-
],
|
|
30
|
+
], kt = [3, 2], Et = {
|
|
30
31
|
"1:1": "ai-enhancer-aspect-square",
|
|
31
32
|
"2:3": "ai-enhancer-aspect-tall",
|
|
32
33
|
"3:2": "ai-enhancer-aspect-wide",
|
|
@@ -34,23 +35,23 @@ const yt = [
|
|
|
34
35
|
"5:4": "ai-enhancer-aspect-landscape",
|
|
35
36
|
"9:16": "ai-enhancer-aspect-vertical",
|
|
36
37
|
"16:9": "ai-enhancer-aspect-widescreen"
|
|
37
|
-
},
|
|
38
|
-
function
|
|
38
|
+
}, Rt = 0.1, St = 10;
|
|
39
|
+
function we(t) {
|
|
39
40
|
const [e, i] = t;
|
|
40
41
|
if (!Number.isFinite(e) || !Number.isFinite(i) || e <= 0 || i <= 0) return !1;
|
|
41
42
|
const r = e / i;
|
|
42
|
-
return r >=
|
|
43
|
+
return r >= Rt && r <= St;
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function Q(t) {
|
|
45
46
|
return `${t[0]}:${t[1]}`;
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
-
return
|
|
48
|
+
function Ct(t) {
|
|
49
|
+
return Et[Q(t)] ?? null;
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
return { value: t, labelKey:
|
|
51
|
+
function $t(t) {
|
|
52
|
+
return { value: t, labelKey: Ct(t) };
|
|
52
53
|
}
|
|
53
|
-
function
|
|
54
|
+
function At(t) {
|
|
54
55
|
const e = [];
|
|
55
56
|
for (const i of t.split(/[\s,]+/)) {
|
|
56
57
|
const r = i.trim();
|
|
@@ -58,18 +59,18 @@ function Ct(t) {
|
|
|
58
59
|
const s = r.indexOf(":");
|
|
59
60
|
if (s === -1) continue;
|
|
60
61
|
const o = Number(r.slice(0, s)), a = Number(r.slice(s + 1)), n = [o, a];
|
|
61
|
-
|
|
62
|
+
we(n) && e.push(n);
|
|
62
63
|
}
|
|
63
64
|
return e;
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
+
function Ut(t, e) {
|
|
66
67
|
return t[0] === e[0] && t[1] === e[1];
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
+
function Tt(t) {
|
|
69
70
|
const [e, i] = t, r = 12, s = e >= i ? r : r * (e / i), o = i >= e ? r : r * (i / e), a = (16 - s) / 2, n = (16 - o) / 2;
|
|
70
71
|
return `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><rect x="${a.toFixed(2)}" y="${n.toFixed(2)}" width="${s.toFixed(2)}" height="${o.toFixed(2)}" rx="1.5" stroke="currentColor" stroke-width="1.4"/></svg>`;
|
|
71
72
|
}
|
|
72
|
-
const
|
|
73
|
+
const me = {
|
|
73
74
|
generate: {
|
|
74
75
|
id: "generate",
|
|
75
76
|
placeholderKey: "ai-enhancer-generate-placeholder",
|
|
@@ -130,18 +131,18 @@ const fe = {
|
|
|
130
131
|
]
|
|
131
132
|
}
|
|
132
133
|
};
|
|
133
|
-
class
|
|
134
|
+
class xe extends Error {
|
|
134
135
|
constructor(e, i, r) {
|
|
135
136
|
super(i), this.name = "AiProviderError", this.errorCode = e, this.errorSource = r;
|
|
136
137
|
}
|
|
137
138
|
}
|
|
138
|
-
function
|
|
139
|
+
function Ft(t) {
|
|
139
140
|
const e = t == null ? void 0 : t.error;
|
|
140
141
|
return !!e && typeof e == "object" && typeof e.error_code == "string";
|
|
141
142
|
}
|
|
142
|
-
async function
|
|
143
|
+
async function Z(t, e) {
|
|
143
144
|
}
|
|
144
|
-
async function
|
|
145
|
+
async function Oe(t, e) {
|
|
145
146
|
const i = await t.text().catch(() => "");
|
|
146
147
|
let r = null;
|
|
147
148
|
if (i)
|
|
@@ -149,9 +150,9 @@ async function Ie(t, e) {
|
|
|
149
150
|
r = JSON.parse(i);
|
|
150
151
|
} catch {
|
|
151
152
|
}
|
|
152
|
-
if (
|
|
153
|
+
if (Ft(r)) {
|
|
153
154
|
const { error_code: s, content: o } = r.error;
|
|
154
|
-
throw new
|
|
155
|
+
throw new xe(s, o ?? s);
|
|
155
156
|
}
|
|
156
157
|
if (!t.ok)
|
|
157
158
|
throw new Error(
|
|
@@ -159,7 +160,7 @@ async function Ie(t, e) {
|
|
|
159
160
|
);
|
|
160
161
|
return r;
|
|
161
162
|
}
|
|
162
|
-
class
|
|
163
|
+
class Mt {
|
|
163
164
|
constructor(e) {
|
|
164
165
|
if (!e.publicKey)
|
|
165
166
|
throw new Error("UploadcareApiClient: publicKey is required");
|
|
@@ -173,7 +174,7 @@ class Tt {
|
|
|
173
174
|
aspect_ratio: [e.aspectRatio[0], e.aspectRatio[1]],
|
|
174
175
|
filename: e.filename
|
|
175
176
|
};
|
|
176
|
-
return e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await
|
|
177
|
+
return e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await Z(), this.startJob(new URL("/derivative/image/generate/", this.baseUrl), i, "generate", e.signal);
|
|
177
178
|
}
|
|
178
179
|
/** Start an image→image edit job. Resolves to the job handle. */
|
|
179
180
|
async edit(e) {
|
|
@@ -183,14 +184,14 @@ class Tt {
|
|
|
183
184
|
source: e.source,
|
|
184
185
|
filename: e.filename
|
|
185
186
|
};
|
|
186
|
-
return e.aspectRatio && (i.aspect_ratio = [e.aspectRatio[0], e.aspectRatio[1]]), e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await
|
|
187
|
+
return e.aspectRatio && (i.aspect_ratio = [e.aspectRatio[0], e.aspectRatio[1]]), e.store !== void 0 && (i.store = e.store), e.metadata && (i.metadata = e.metadata), await Z(), this.startJob(new URL("/derivative/image/edit/", this.baseUrl), i, "edit", e.signal);
|
|
187
188
|
}
|
|
188
189
|
/** Fetch the current state of a generation/edit job. */
|
|
189
190
|
async getJobStatus(e, i) {
|
|
190
191
|
const r = new URL("/derivative/status/", this.baseUrl);
|
|
191
192
|
r.searchParams.set("pub_key", this.publicKey), r.searchParams.set("job_id", e);
|
|
192
|
-
const s = await this.doFetch(r.href, { method: "GET", headers: { Accept: "application/json" }, signal: i }), o = await
|
|
193
|
-
return await
|
|
193
|
+
const s = await this.doFetch(r.href, { method: "GET", headers: { Accept: "application/json" }, signal: i }), o = await Oe(s, "generate status");
|
|
194
|
+
return await Z(), o;
|
|
194
195
|
}
|
|
195
196
|
async startJob(e, i, r, s) {
|
|
196
197
|
const o = await this.doFetch(e.href, {
|
|
@@ -198,36 +199,36 @@ class Tt {
|
|
|
198
199
|
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
199
200
|
body: JSON.stringify(i),
|
|
200
201
|
signal: s
|
|
201
|
-
}), a = await
|
|
202
|
-
return await
|
|
202
|
+
}), a = await Oe(o, r);
|
|
203
|
+
return await Z(), a;
|
|
203
204
|
}
|
|
204
205
|
}
|
|
205
|
-
const
|
|
206
|
-
function
|
|
206
|
+
const at = "[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", It = new RegExp(`^${at}$`, "i"), Ot = new RegExp(`^(${at})~([0-9]+)$`, "i");
|
|
207
|
+
function ke(t) {
|
|
207
208
|
return t.replace(/\/+$/, "");
|
|
208
209
|
}
|
|
209
|
-
function
|
|
210
|
+
function _e(t, e = "size") {
|
|
210
211
|
return typeof t == "number" ? String(t) : t.replace("%", "p");
|
|
211
212
|
}
|
|
212
|
-
function
|
|
213
|
-
const r = t == null ? "" :
|
|
213
|
+
function nt(t, e, i = "dimensions") {
|
|
214
|
+
const r = t == null ? "" : _e(t, `${i} width`), s = e == null ? "" : _e(e, `${i} height`);
|
|
214
215
|
return `${r}x${s}`;
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
-
return typeof t == "number" ? String(t) :
|
|
217
|
+
function Pe(t, e) {
|
|
218
|
+
return typeof t == "number" ? String(t) : _e(t, e);
|
|
218
219
|
}
|
|
219
|
-
function
|
|
220
|
-
return typeof t == "string" ? t : `${
|
|
220
|
+
function Pt(t, e = "alignment") {
|
|
221
|
+
return typeof t == "string" ? t : `${Pe(t.x, `${e} x`)},${Pe(t.y, `${e} y`)}`;
|
|
221
222
|
}
|
|
222
|
-
const
|
|
223
|
+
const zt = [
|
|
223
224
|
"video",
|
|
224
225
|
"document",
|
|
225
226
|
"gif2video"
|
|
226
|
-
],
|
|
227
|
-
function
|
|
228
|
-
return t != null &&
|
|
227
|
+
], Lt = /\/(https?:\/\/.+)$/i;
|
|
228
|
+
function Dt(t) {
|
|
229
|
+
return t != null && zt.includes(t);
|
|
229
230
|
}
|
|
230
|
-
function
|
|
231
|
+
function lt(t) {
|
|
231
232
|
var _;
|
|
232
233
|
let e;
|
|
233
234
|
try {
|
|
@@ -235,20 +236,20 @@ function nt(t) {
|
|
|
235
236
|
} catch {
|
|
236
237
|
throw new TypeError(`Invalid URL: "${t}"`);
|
|
237
238
|
}
|
|
238
|
-
const i = `${e.protocol}//${e.host}`, r = e.pathname, s = (_ = r.match(
|
|
239
|
+
const i = `${e.protocol}//${e.host}`, r = e.pathname, s = (_ = r.match(Lt)) == null ? void 0 : _[1];
|
|
239
240
|
if (s !== void 0) {
|
|
240
241
|
const x = r.slice(0, r.length - s.length);
|
|
241
242
|
return {
|
|
242
243
|
kind: "proxy",
|
|
243
244
|
origin: i,
|
|
244
|
-
operations:
|
|
245
|
+
operations: ce(ze(x), "proxy prefix"),
|
|
245
246
|
sourceUrl: s + e.search + e.hash
|
|
246
247
|
};
|
|
247
248
|
}
|
|
248
|
-
const o = r.endsWith("/"), a =
|
|
249
|
+
const o = r.endsWith("/"), a = ze(r), n = a.shift();
|
|
249
250
|
if (n === void 0)
|
|
250
251
|
throw new TypeError(`Not a CDN URL (empty path): "${t}"`);
|
|
251
|
-
const l = { origin: i, search: e.search, hash: e.hash }, h = n.match(
|
|
252
|
+
const l = { origin: i, search: e.search, hash: e.hash }, h = n.match(Ot);
|
|
252
253
|
if ((h == null ? void 0 : h[1]) !== void 0) {
|
|
253
254
|
const x = {
|
|
254
255
|
uuid: h[1],
|
|
@@ -259,13 +260,13 @@ function nt(t) {
|
|
|
259
260
|
if (!Number.isInteger(w))
|
|
260
261
|
throw new TypeError(`Invalid group element index in "${t}"`);
|
|
261
262
|
a.splice(0, 2);
|
|
262
|
-
const $ =
|
|
263
|
+
const $ = Le(a, o);
|
|
263
264
|
return {
|
|
264
265
|
kind: "group-element",
|
|
265
266
|
...l,
|
|
266
267
|
group: x,
|
|
267
268
|
nth: w,
|
|
268
|
-
operations:
|
|
269
|
+
operations: ce(a, t),
|
|
269
270
|
filename: $
|
|
270
271
|
};
|
|
271
272
|
}
|
|
@@ -273,29 +274,29 @@ function nt(t) {
|
|
|
273
274
|
throw new TypeError(`Unexpected path after group id in "${t}"`);
|
|
274
275
|
return { kind: "group", ...l, group: x };
|
|
275
276
|
}
|
|
276
|
-
if (!
|
|
277
|
+
if (!It.test(n))
|
|
277
278
|
throw new TypeError(
|
|
278
279
|
`Not a CDN URL (no uuid, group or proxy source): "${t}"`
|
|
279
280
|
);
|
|
280
281
|
let p = null;
|
|
281
|
-
|
|
282
|
-
const u =
|
|
282
|
+
Dt(a[0]) && (p = a[0], a.shift());
|
|
283
|
+
const u = Le(a, o);
|
|
283
284
|
return {
|
|
284
285
|
kind: "file",
|
|
285
286
|
...l,
|
|
286
287
|
uuid: n,
|
|
287
288
|
conversion: p,
|
|
288
|
-
operations:
|
|
289
|
+
operations: ce(a, t),
|
|
289
290
|
filename: u
|
|
290
291
|
};
|
|
291
292
|
}
|
|
292
|
-
function
|
|
293
|
+
function ze(t) {
|
|
293
294
|
return t.split("/").filter((e) => e !== "");
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
+
function Le(t, e) {
|
|
296
297
|
return e || t.length === 0 ? null : t.pop() ?? null;
|
|
297
298
|
}
|
|
298
|
-
function
|
|
299
|
+
function ce(t, e) {
|
|
299
300
|
const i = [];
|
|
300
301
|
let r = 0;
|
|
301
302
|
for (; r < t.length; ) {
|
|
@@ -318,11 +319,11 @@ function le(t, e) {
|
|
|
318
319
|
}
|
|
319
320
|
return i;
|
|
320
321
|
}
|
|
321
|
-
function
|
|
322
|
+
function ct(t) {
|
|
322
323
|
return t.map((e) => `-/${[e.name, ...e.params].join("/")}/`).join("");
|
|
323
324
|
}
|
|
324
|
-
function
|
|
325
|
-
const e =
|
|
325
|
+
function ht(t) {
|
|
326
|
+
const e = ke(t.origin), i = ct(t.operations ?? []);
|
|
326
327
|
if ("sourceUrl" in t && t.sourceUrl != null)
|
|
327
328
|
return `${e}/${i}${t.sourceUrl}`;
|
|
328
329
|
const r = ("search" in t ? t.search : "") ?? "", s = ("hash" in t ? t.hash : "") ?? "";
|
|
@@ -336,59 +337,59 @@ function ct(t) {
|
|
|
336
337
|
}
|
|
337
338
|
throw new TypeError("serializeCdnUrl requires one of: uuid, group, sourceUrl");
|
|
338
339
|
}
|
|
339
|
-
function
|
|
340
|
+
function Nt(t) {
|
|
340
341
|
return typeof t == "string" ? t : "opName" in t ? t.opName : t.name;
|
|
341
342
|
}
|
|
342
|
-
function
|
|
343
|
-
const i =
|
|
343
|
+
function he(t, e) {
|
|
344
|
+
const i = Nt(e);
|
|
344
345
|
return t.name === i || t.name.startsWith(`${i}~`);
|
|
345
346
|
}
|
|
346
|
-
function
|
|
347
|
+
function ut(t, e) {
|
|
347
348
|
return Object.assign(e, { opName: t });
|
|
348
349
|
}
|
|
349
|
-
const
|
|
350
|
+
const Bt = (t, e) => {
|
|
350
351
|
const i = new URL(e);
|
|
351
352
|
return i.hostname = `${t}.${i.hostname}`, i.toString().replace(/\/$/, "");
|
|
352
|
-
},
|
|
353
|
+
}, jt = "0123456789abcdefghijklmnopqrstuvwxyz", Gt = (t) => {
|
|
353
354
|
if (t <= 0n)
|
|
354
355
|
return "0";
|
|
355
356
|
let e = "";
|
|
356
357
|
for (; t > 0n; ) {
|
|
357
358
|
const i = t % 36n;
|
|
358
|
-
e =
|
|
359
|
+
e = jt[Number(i)] + e, t = t / 36n;
|
|
359
360
|
}
|
|
360
361
|
return e;
|
|
361
|
-
},
|
|
362
|
+
}, Ht = (t, e) => {
|
|
362
363
|
try {
|
|
363
364
|
const i = new URL(t), r = new URL(e);
|
|
364
365
|
return i.hostname.endsWith(r.hostname);
|
|
365
366
|
} catch {
|
|
366
367
|
return !1;
|
|
367
368
|
}
|
|
368
|
-
},
|
|
369
|
+
}, Wt = async (t) => {
|
|
369
370
|
const e = new TextEncoder().encode(t), i = await window.crypto.subtle.digest("SHA-256", e), r = Array.from(new Uint8Array(i)).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
370
371
|
return BigInt(`0x${r}`);
|
|
371
|
-
},
|
|
372
|
-
const e = await
|
|
373
|
-
return
|
|
374
|
-
},
|
|
375
|
-
const i = await
|
|
376
|
-
return
|
|
372
|
+
}, Vt = 10, qt = async (t) => {
|
|
373
|
+
const e = await Wt(t);
|
|
374
|
+
return Gt(e).slice(0, Vt);
|
|
375
|
+
}, Kt = async (t, e) => {
|
|
376
|
+
const i = await qt(t);
|
|
377
|
+
return Bt(i, e);
|
|
377
378
|
};
|
|
378
|
-
function
|
|
379
|
+
function De(t) {
|
|
379
380
|
return Object.prototype.toString.call(t) === "[object Object]";
|
|
380
381
|
}
|
|
381
|
-
const
|
|
382
|
-
function
|
|
383
|
-
return t.split(
|
|
382
|
+
const Yt = /\W|_/g;
|
|
383
|
+
function Xt(t) {
|
|
384
|
+
return t.split(Yt).map((e, i) => e.charAt(0)[i > 0 ? "toUpperCase" : "toLowerCase"]() + e.slice(1)).join("");
|
|
384
385
|
}
|
|
385
|
-
function
|
|
386
|
-
return Array.isArray(t) ? t.map((i) =>
|
|
386
|
+
function Ne(t, { ignoreKeys: e } = { ignoreKeys: [] }) {
|
|
387
|
+
return Array.isArray(t) ? t.map((i) => Ee(i, { ignoreKeys: e })) : t;
|
|
387
388
|
}
|
|
388
|
-
function
|
|
389
|
+
function Ee(t, { ignoreKeys: e } = { ignoreKeys: [] }) {
|
|
389
390
|
if (Array.isArray(t))
|
|
390
|
-
return
|
|
391
|
-
if (!
|
|
391
|
+
return Ne(t, { ignoreKeys: e });
|
|
392
|
+
if (!De(t))
|
|
392
393
|
return t;
|
|
393
394
|
const i = {};
|
|
394
395
|
for (const r of Object.keys(t)) {
|
|
@@ -397,12 +398,12 @@ function ke(t, { ignoreKeys: e } = { ignoreKeys: [] }) {
|
|
|
397
398
|
i[r] = s;
|
|
398
399
|
continue;
|
|
399
400
|
}
|
|
400
|
-
|
|
401
|
+
De(s) ? s = Ee(s, { ignoreKeys: e }) : Array.isArray(s) && (s = Ne(s, { ignoreKeys: e })), i[Xt(r)] = s;
|
|
401
402
|
}
|
|
402
403
|
return i;
|
|
403
404
|
}
|
|
404
|
-
const
|
|
405
|
-
function
|
|
405
|
+
const Jt = (t) => new Promise((e) => setTimeout(e, t));
|
|
406
|
+
function Zt({ libraryName: t, libraryVersion: e, userAgent: i, publicKey: r = "", integration: s = "" }) {
|
|
406
407
|
const o = "JavaScript";
|
|
407
408
|
if (typeof i == "string")
|
|
408
409
|
return i;
|
|
@@ -417,53 +418,53 @@ function Xt({ libraryName: t, libraryVersion: e, userAgent: i, publicKey: r = ""
|
|
|
417
418
|
const a = [t, e, r].filter(Boolean).join("/"), n = [o, s].filter(Boolean).join("; ");
|
|
418
419
|
return `${a} (${n})`;
|
|
419
420
|
}
|
|
420
|
-
const
|
|
421
|
+
const Qt = {
|
|
421
422
|
factor: 2,
|
|
422
423
|
time: 100
|
|
423
424
|
};
|
|
424
|
-
function
|
|
425
|
+
function ei(t, e = Qt) {
|
|
425
426
|
let i = 0;
|
|
426
427
|
function r(s) {
|
|
427
428
|
const o = Math.round(e.time * e.factor ** i);
|
|
428
429
|
return s({
|
|
429
430
|
attempt: i,
|
|
430
|
-
retry: (n) =>
|
|
431
|
+
retry: (n) => Jt(n ?? o).then(() => (i += 1, r(s)))
|
|
431
432
|
});
|
|
432
433
|
}
|
|
433
434
|
return r(t);
|
|
434
435
|
}
|
|
435
|
-
class
|
|
436
|
+
class Re extends Error {
|
|
436
437
|
}
|
|
437
|
-
class
|
|
438
|
+
class re extends Re {
|
|
438
439
|
constructor(i) {
|
|
439
440
|
super();
|
|
440
441
|
b(this, "originalProgressEvent");
|
|
441
|
-
this.name = "NetworkError", this.message = "Network error", Object.setPrototypeOf(this,
|
|
442
|
+
this.name = "NetworkError", this.message = "Network error", Object.setPrototypeOf(this, re.prototype), this.originalProgressEvent = i;
|
|
442
443
|
}
|
|
443
444
|
}
|
|
444
|
-
const
|
|
445
|
+
const ti = (t, e) => {
|
|
445
446
|
t && (t.aborted ? Promise.resolve().then(e) : t.addEventListener("abort", () => e(), { once: !0 }));
|
|
446
447
|
};
|
|
447
|
-
class
|
|
448
|
+
class Se extends Re {
|
|
448
449
|
constructor(i = "Request canceled") {
|
|
449
450
|
super(i);
|
|
450
451
|
b(this, "isCancel", !0);
|
|
451
|
-
this.name = "CancelError", Object.setPrototypeOf(this,
|
|
452
|
+
this.name = "CancelError", Object.setPrototypeOf(this, Se.prototype);
|
|
452
453
|
}
|
|
453
454
|
}
|
|
454
|
-
const
|
|
455
|
+
const ee = {
|
|
455
456
|
baseCDN: "https://ucarecdn.com",
|
|
456
457
|
baseURL: "https://upload.uploadcare.com",
|
|
457
458
|
retryThrottledRequestMaxTimes: 1,
|
|
458
459
|
retryNetworkErrorMaxTimes: 3
|
|
459
|
-
},
|
|
460
|
+
}, ii = ({ method: t, url: e, data: i, headers: r = {}, signal: s, onProgress: o }) => new Promise((a, n) => {
|
|
460
461
|
const l = new XMLHttpRequest(), h = (t == null ? void 0 : t.toUpperCase()) || "GET";
|
|
461
462
|
let p = !1;
|
|
462
463
|
l.open(h, e, !0), r && Object.entries(r).forEach((u) => {
|
|
463
464
|
const [_, x] = u;
|
|
464
465
|
typeof x < "u" && !Array.isArray(x) && l.setRequestHeader(_, x);
|
|
465
|
-
}), l.responseType = "text",
|
|
466
|
-
p = !0, l.abort(), n(new
|
|
466
|
+
}), l.responseType = "text", ti(s, () => {
|
|
467
|
+
p = !0, l.abort(), n(new Se());
|
|
467
468
|
}), l.onload = () => {
|
|
468
469
|
if (l.status != 200)
|
|
469
470
|
n(new Error(`Error ${l.status}: ${l.statusText}`));
|
|
@@ -477,8 +478,8 @@ const Q = {
|
|
|
477
478
|
onProgress: o
|
|
478
479
|
}, _ = l.getAllResponseHeaders().trim().split(/[\r\n]+/), x = {};
|
|
479
480
|
_.forEach(function(R) {
|
|
480
|
-
const I = R.split(": "),
|
|
481
|
-
|
|
481
|
+
const I = R.split(": "), W = I.shift(), X = I.join(": ");
|
|
482
|
+
W && typeof W < "u" && (x[W] = X);
|
|
482
483
|
});
|
|
483
484
|
const w = l.response, $ = l.status;
|
|
484
485
|
a({
|
|
@@ -489,7 +490,7 @@ const Q = {
|
|
|
489
490
|
});
|
|
490
491
|
}
|
|
491
492
|
}, l.onerror = (u) => {
|
|
492
|
-
p || n(new
|
|
493
|
+
p || n(new re(u));
|
|
493
494
|
}, o && typeof o == "function" && (l.upload.onprogress = (u) => {
|
|
494
495
|
u.lengthComputable ? o({
|
|
495
496
|
isComputable: !0,
|
|
@@ -497,69 +498,69 @@ const Q = {
|
|
|
497
498
|
}) : o({ isComputable: !1 });
|
|
498
499
|
}), i ? l.send(i) : l.send();
|
|
499
500
|
});
|
|
500
|
-
class
|
|
501
|
+
class Ce extends Re {
|
|
501
502
|
constructor(i, r, s, o, a) {
|
|
502
503
|
super();
|
|
503
504
|
b(this, "code");
|
|
504
505
|
b(this, "request");
|
|
505
506
|
b(this, "response");
|
|
506
507
|
b(this, "headers");
|
|
507
|
-
this.name = "UploadError", this.message = i, this.code = r, this.request = s, this.response = o, this.headers = a, Object.setPrototypeOf(this,
|
|
508
|
+
this.name = "UploadError", this.message = i, this.code = r, this.request = s, this.response = o, this.headers = a, Object.setPrototypeOf(this, Ce.prototype);
|
|
508
509
|
}
|
|
509
510
|
}
|
|
510
|
-
const
|
|
511
|
+
const ri = (t) => {
|
|
511
512
|
const e = new URLSearchParams();
|
|
512
513
|
for (const [i, r] of Object.entries(t))
|
|
513
514
|
r && typeof r == "object" && !Array.isArray(r) ? Object.entries(r).filter((s) => s[1] ?? !1).forEach((s) => e.set(`${i}[${s[0]}]`, String(s[1]))) : Array.isArray(r) ? r.forEach((s) => {
|
|
514
515
|
e.append(`${i}[]`, s);
|
|
515
516
|
}) : typeof r == "string" && r ? e.set(i, r) : typeof r == "number" && e.set(i, r.toString());
|
|
516
517
|
return e.toString();
|
|
517
|
-
},
|
|
518
|
+
}, ge = (t, e, i) => {
|
|
518
519
|
const r = new URL(t);
|
|
519
|
-
return r.pathname = (r.pathname + e).replace("//", "/"), i && (r.search =
|
|
520
|
+
return r.pathname = (r.pathname + e).replace("//", "/"), i && (r.search = ri(i)), r.toString();
|
|
520
521
|
};
|
|
521
|
-
var
|
|
522
|
-
const
|
|
523
|
-
function
|
|
524
|
-
return
|
|
525
|
-
libraryName:
|
|
526
|
-
libraryVersion:
|
|
522
|
+
var si = "6.18.4";
|
|
523
|
+
const oi = "UploadcareUploadClient", ai = si;
|
|
524
|
+
function ni(t) {
|
|
525
|
+
return Zt({
|
|
526
|
+
libraryName: oi,
|
|
527
|
+
libraryVersion: ai,
|
|
527
528
|
...t
|
|
528
529
|
});
|
|
529
530
|
}
|
|
530
|
-
const
|
|
531
|
-
function
|
|
531
|
+
const li = "RequestThrottledError", Be = 15e3, ci = 1e3;
|
|
532
|
+
function hi(t) {
|
|
532
533
|
const { headers: e } = t || {};
|
|
533
534
|
if (!e || typeof e["retry-after"] != "string")
|
|
534
|
-
return
|
|
535
|
+
return Be;
|
|
535
536
|
const i = parseInt(e["retry-after"], 10);
|
|
536
|
-
return Number.isFinite(i) ? i * 1e3 :
|
|
537
|
+
return Number.isFinite(i) ? i * 1e3 : Be;
|
|
537
538
|
}
|
|
538
|
-
function
|
|
539
|
+
function ui(t, e) {
|
|
539
540
|
const { retryThrottledRequestMaxTimes: i, retryNetworkErrorMaxTimes: r } = e;
|
|
540
|
-
return
|
|
541
|
-
if ("response" in a && (a == null ? void 0 : a.code) ===
|
|
542
|
-
return o(
|
|
543
|
-
if (a instanceof
|
|
544
|
-
return o((s + 1) *
|
|
541
|
+
return ei(({ attempt: s, retry: o }) => t().catch((a) => {
|
|
542
|
+
if ("response" in a && (a == null ? void 0 : a.code) === li && s < i)
|
|
543
|
+
return o(hi(a));
|
|
544
|
+
if (a instanceof re && s < r)
|
|
545
|
+
return o((s + 1) * ci);
|
|
545
546
|
throw a;
|
|
546
547
|
}));
|
|
547
548
|
}
|
|
548
|
-
var
|
|
549
|
+
var je;
|
|
549
550
|
(function(t) {
|
|
550
551
|
t.Token = "token", t.FileInfo = "file_info";
|
|
551
|
-
})(
|
|
552
|
-
var
|
|
552
|
+
})(je || (je = {}));
|
|
553
|
+
var Ge;
|
|
553
554
|
(function(t) {
|
|
554
555
|
t.Unknown = "unknown", t.Waiting = "waiting", t.Progress = "progress", t.Error = "error", t.Success = "success";
|
|
555
|
-
})(
|
|
556
|
-
function
|
|
557
|
-
return
|
|
556
|
+
})(Ge || (Ge = {}));
|
|
557
|
+
function di(t, { publicKey: e, baseURL: i = ee.baseURL, signal: r, source: s, integration: o, userAgent: a, retryThrottledRequestMaxTimes: n = ee.retryThrottledRequestMaxTimes, retryNetworkErrorMaxTimes: l = ee.retryNetworkErrorMaxTimes }) {
|
|
558
|
+
return ui(() => ii({
|
|
558
559
|
method: "GET",
|
|
559
560
|
headers: {
|
|
560
|
-
"X-UC-User-Agent":
|
|
561
|
+
"X-UC-User-Agent": ni({ publicKey: e, integration: o, userAgent: a })
|
|
561
562
|
},
|
|
562
|
-
url:
|
|
563
|
+
url: ge(i, "/info/", {
|
|
563
564
|
jsonerrors: 1,
|
|
564
565
|
pub_key: e,
|
|
565
566
|
file_id: t,
|
|
@@ -567,17 +568,17 @@ function hi(t, { publicKey: e, baseURL: i = Q.baseURL, signal: r, source: s, int
|
|
|
567
568
|
}),
|
|
568
569
|
signal: r
|
|
569
570
|
}).then(({ data: h, headers: p, request: u }) => {
|
|
570
|
-
const _ =
|
|
571
|
+
const _ = Ee(JSON.parse(h));
|
|
571
572
|
if ("error" in _)
|
|
572
|
-
throw new
|
|
573
|
+
throw new Ce(_.error.content, _.error.errorCode, u, _, p);
|
|
573
574
|
return _;
|
|
574
575
|
}), { retryThrottledRequestMaxTimes: n, retryNetworkErrorMaxTimes: l });
|
|
575
576
|
}
|
|
576
|
-
function
|
|
577
|
+
function pi(t) {
|
|
577
578
|
return "defaultEffects" in t;
|
|
578
579
|
}
|
|
579
|
-
class
|
|
580
|
-
constructor(e, { baseCDN: i =
|
|
580
|
+
class He {
|
|
581
|
+
constructor(e, { baseCDN: i = ee.baseCDN, fileName: r } = {}) {
|
|
581
582
|
b(this, "uuid");
|
|
582
583
|
b(this, "name");
|
|
583
584
|
b(this, "size");
|
|
@@ -593,29 +594,29 @@ class Ge {
|
|
|
593
594
|
b(this, "metadata");
|
|
594
595
|
b(this, "s3Bucket");
|
|
595
596
|
b(this, "defaultEffects", null);
|
|
596
|
-
const { uuid: s, s3Bucket: o } = e, a =
|
|
597
|
-
this.uuid = s, this.name = r || e.filename, this.size = e.size, this.isStored = e.isStored, this.isImage = e.isImage, this.mimeType = e.mimeType, this.cdnUrl = a, this.originalFilename = e.originalFilename, this.imageInfo = e.imageInfo, this.videoInfo = e.videoInfo, this.contentInfo = e.contentInfo, this.metadata = e.metadata || null, this.s3Bucket = o || null, this.s3Url = n,
|
|
597
|
+
const { uuid: s, s3Bucket: o } = e, a = ge(i, `${s}/`), n = o ? ge(`https://${o}.s3.amazonaws.com/`, `${s}/${e.filename}`) : null;
|
|
598
|
+
this.uuid = s, this.name = r || e.filename, this.size = e.size, this.isStored = e.isStored, this.isImage = e.isImage, this.mimeType = e.mimeType, this.cdnUrl = a, this.originalFilename = e.originalFilename, this.imageInfo = e.imageInfo, this.videoInfo = e.videoInfo, this.contentInfo = e.contentInfo, this.metadata = e.metadata || null, this.s3Bucket = o || null, this.s3Url = n, pi(e) && (this.defaultEffects = e.defaultEffects);
|
|
598
599
|
}
|
|
599
600
|
}
|
|
600
|
-
const
|
|
601
|
-
function
|
|
601
|
+
const fi = /\W|_/g;
|
|
602
|
+
function mi(t) {
|
|
602
603
|
return typeof t == "object" && t !== null && !Array.isArray(t);
|
|
603
604
|
}
|
|
604
|
-
function
|
|
605
|
-
return t.split(
|
|
605
|
+
function _i(t) {
|
|
606
|
+
return t.split(fi).map((e, i) => e && e.charAt(0)[i > 0 ? "toUpperCase" : "toLowerCase"]() + e.slice(1)).join("");
|
|
606
607
|
}
|
|
607
|
-
function
|
|
608
|
+
function ve(t) {
|
|
608
609
|
if (Array.isArray(t))
|
|
609
|
-
return t.map((i) =>
|
|
610
|
-
if (!
|
|
610
|
+
return t.map((i) => ve(i));
|
|
611
|
+
if (!mi(t))
|
|
611
612
|
return t;
|
|
612
613
|
const e = {};
|
|
613
614
|
for (const i of Object.keys(t))
|
|
614
|
-
e[
|
|
615
|
+
e[_i(i)] = ve(t[i]);
|
|
615
616
|
return e;
|
|
616
617
|
}
|
|
617
|
-
const
|
|
618
|
-
function
|
|
618
|
+
const gi = [1, 1], We = "https://ucarecdn.com", vi = 1500, bi = 1e6;
|
|
619
|
+
function yi(t, e) {
|
|
619
620
|
return new Promise((i, r) => {
|
|
620
621
|
if (e != null && e.aborted) {
|
|
621
622
|
r(new DOMException("Aborted", "AbortError"));
|
|
@@ -629,18 +630,18 @@ function vi(t, e) {
|
|
|
629
630
|
e == null || e.addEventListener("abort", o, { once: !0 });
|
|
630
631
|
});
|
|
631
632
|
}
|
|
632
|
-
function
|
|
633
|
+
function Ve() {
|
|
633
634
|
return typeof performance < "u" && typeof performance.now == "function" ? performance.now() : Date.now();
|
|
634
635
|
}
|
|
635
|
-
class
|
|
636
|
+
class wi {
|
|
636
637
|
constructor(e) {
|
|
637
638
|
if (this.id = "uploadcare-derivative", !e.publicKey)
|
|
638
639
|
throw new Error("UploadcareDerivativeApi: publicKey is required");
|
|
639
|
-
this.api = new
|
|
640
|
+
this.api = new Mt({
|
|
640
641
|
publicKey: e.publicKey,
|
|
641
642
|
baseUrl: e.baseUrl,
|
|
642
643
|
fetch: e.fetch
|
|
643
|
-
}), this.publicKey = e.publicKey, this.baseUrl = e.baseUrl, this.filename = e.filename ?? "generated.png", this.store = e.store, this.cname = e.cdnBaseUrl ??
|
|
644
|
+
}), this.publicKey = e.publicKey, this.baseUrl = e.baseUrl, this.filename = e.filename ?? "generated.png", this.store = e.store, this.cname = e.cdnBaseUrl ?? We, this.cnamePrefixed = e.cdnCnamePrefixed ?? "https://ucarecd.net", this.pollIntervalMs = e.pollIntervalMs ?? vi, this.pollTimeoutMs = e.pollTimeoutMs ?? bi;
|
|
644
645
|
}
|
|
645
646
|
async generate(e) {
|
|
646
647
|
const i = await this.startJob(e);
|
|
@@ -652,7 +653,7 @@ class bi {
|
|
|
652
653
|
* the editor produced.
|
|
653
654
|
*/
|
|
654
655
|
async resolveCdnUrl(e) {
|
|
655
|
-
return
|
|
656
|
+
return ht({ origin: await this.getCdnBase(), uuid: e });
|
|
656
657
|
}
|
|
657
658
|
/**
|
|
658
659
|
* Resolve a stored file's full info (image dimensions, original filename,
|
|
@@ -661,13 +662,13 @@ class bi {
|
|
|
661
662
|
* true aspect ratio before the image decodes, and name outputs after it.
|
|
662
663
|
*/
|
|
663
664
|
async getFileInfo(e, i) {
|
|
664
|
-
const r = await
|
|
665
|
-
return new
|
|
665
|
+
const r = await di(e, { publicKey: this.publicKey, baseURL: this.baseUrl, signal: i });
|
|
666
|
+
return new He(r, { baseCDN: await this.getCdnBase() });
|
|
666
667
|
}
|
|
667
668
|
async startJob(e) {
|
|
668
|
-
const i = e.aspectRatio &&
|
|
669
|
+
const i = e.aspectRatio && we(e.aspectRatio) ? [e.aspectRatio[0], e.aspectRatio[1]] : void 0, r = e.filename ?? this.filename, s = e.mode === "edit" ? await this.startEditJob(e, i, r, e.metadata) : await this.api.generate({
|
|
669
670
|
prompt: e.prompt,
|
|
670
|
-
aspectRatio: i ??
|
|
671
|
+
aspectRatio: i ?? gi,
|
|
671
672
|
filename: r,
|
|
672
673
|
store: this.store,
|
|
673
674
|
signal: e.signal,
|
|
@@ -691,22 +692,22 @@ class bi {
|
|
|
691
692
|
});
|
|
692
693
|
}
|
|
693
694
|
async pollUntilDone(e, i) {
|
|
694
|
-
const r = this.pollTimeoutMs +
|
|
695
|
+
const r = this.pollTimeoutMs + Ve();
|
|
695
696
|
for (; ; ) {
|
|
696
697
|
const s = await this.api.getJobStatus(e, i.signal);
|
|
697
698
|
if (s.status === "success") {
|
|
698
699
|
if (!s.uuid)
|
|
699
700
|
throw new Error("Uploadcare derivative: response did not include a uuid");
|
|
700
|
-
const o =
|
|
701
|
+
const o = ve(s), a = new He(o, { baseCDN: await this.getCdnBase() });
|
|
701
702
|
return { url: a.cdnUrl, uuid: a.uuid, prompt: i.prompt, mode: i.mode, file: a };
|
|
702
703
|
}
|
|
703
704
|
if (s.status === "error") {
|
|
704
705
|
const o = s.error_code ?? "unknown", a = s.error ?? o;
|
|
705
|
-
throw new
|
|
706
|
+
throw new xe(o, a, s.error_source);
|
|
706
707
|
}
|
|
707
|
-
if (
|
|
708
|
+
if (Ve() >= r)
|
|
708
709
|
throw new Error(`Uploadcare derivative: timed out waiting for job ${e}`);
|
|
709
|
-
await
|
|
710
|
+
await yi(this.pollIntervalMs, i.signal);
|
|
710
711
|
}
|
|
711
712
|
}
|
|
712
713
|
/**
|
|
@@ -715,11 +716,11 @@ class bi {
|
|
|
715
716
|
* applies in its `cdnCname` computed config. Computed once and cached.
|
|
716
717
|
*/
|
|
717
718
|
getCdnBase() {
|
|
718
|
-
return this.cdnBasePromise || (this.cdnBasePromise = this.cname ===
|
|
719
|
+
return this.cdnBasePromise || (this.cdnBasePromise = this.cname === We || Ht(this.cname, this.cnamePrefixed) ? Kt(this.publicKey, this.cnamePrefixed) : Promise.resolve(this.cname)), this.cdnBasePromise;
|
|
719
720
|
}
|
|
720
721
|
}
|
|
721
|
-
const
|
|
722
|
-
class
|
|
722
|
+
const qe = 20;
|
|
723
|
+
class xi {
|
|
723
724
|
constructor(e) {
|
|
724
725
|
this.busy = !1, this.resultUrl = null, this.result = null, this.error = null, this.errorCode = null, this.history = [], this._abortController = null, this._host = e, e.addController(this);
|
|
725
726
|
}
|
|
@@ -740,7 +741,7 @@ class yi {
|
|
|
740
741
|
/** Replace the strip with entries hydrated from storage (e.g. when the editor
|
|
741
742
|
* opens on a source whose lineage was generated in a past session). */
|
|
742
743
|
setHistory(e) {
|
|
743
|
-
this.history = e.slice(0,
|
|
744
|
+
this.history = e.slice(0, qe), this._host.requestUpdate();
|
|
744
745
|
}
|
|
745
746
|
setResult(e) {
|
|
746
747
|
this.resultUrl = e.url, this.result = e, this.error = null, this.errorCode = null, this._host.requestUpdate();
|
|
@@ -771,16 +772,16 @@ class yi {
|
|
|
771
772
|
ratio: e.ratioValue ?? null
|
|
772
773
|
},
|
|
773
774
|
...this.history
|
|
774
|
-
].slice(0,
|
|
775
|
+
].slice(0, qe), s);
|
|
775
776
|
} catch (s) {
|
|
776
777
|
if ((s == null ? void 0 : s.name) === "AbortError") return null;
|
|
777
|
-
throw this.error = s.message || "Generation failed", this.errorCode = s instanceof
|
|
778
|
+
throw this.error = s.message || "Generation failed", this.errorCode = s instanceof xe ? s.errorCode : null, s;
|
|
778
779
|
} finally {
|
|
779
780
|
this._abortController === i && (this.busy = !1, this._abortController = null), this._host.requestUpdate();
|
|
780
781
|
}
|
|
781
782
|
}
|
|
782
783
|
}
|
|
783
|
-
const
|
|
784
|
+
const ki = {
|
|
784
785
|
"ai-enhancer-source-label": "Generate image",
|
|
785
786
|
"ai-enhancer-file-action-label": "AI Edit",
|
|
786
787
|
"ai-enhancer-generate-title": "Generate image",
|
|
@@ -805,7 +806,7 @@ const wi = {
|
|
|
805
806
|
"ai-enhancer-aspect-landscape": "Landscape",
|
|
806
807
|
"ai-enhancer-aspect-vertical": "Vertical",
|
|
807
808
|
"ai-enhancer-aspect-widescreen": "Widescreen"
|
|
808
|
-
},
|
|
809
|
+
}, Ei = {
|
|
809
810
|
// Platform validation (POST generate/edit/outpaint, GET status)
|
|
810
811
|
"ai-enhancer-error-invalid_request": "Something went wrong with the request. Please try again.",
|
|
811
812
|
"ai-enhancer-error-invalid_source": "The source image couldn't be read. Please try a different image.",
|
|
@@ -829,8 +830,8 @@ const wi = {
|
|
|
829
830
|
"ai-enhancer-error-DownloadFileHTTPClientError": "Couldn't retrieve the generated image. Please try again.",
|
|
830
831
|
"ai-enhancer-error-DownloadFileNotFoundError": "The generated image couldn't be found. Please try again.",
|
|
831
832
|
"ai-enhancer-error-DownloadFileTaskFailedError": "Couldn't save the generated image. Please try again."
|
|
832
|
-
},
|
|
833
|
-
en: async () =>
|
|
833
|
+
}, B = { ...ki, ...Ei }, ue = {
|
|
834
|
+
en: async () => B,
|
|
834
835
|
ar: () => import("./ar-0rfB4z3f.js").then((t) => t.default),
|
|
835
836
|
az: () => import("./az-CyK2FKx4.js").then((t) => t.default),
|
|
836
837
|
ca: () => import("./ca-CAoPN2lq.js").then((t) => t.default),
|
|
@@ -866,12 +867,12 @@ const wi = {
|
|
|
866
867
|
zh: () => import("./zh-C0AOtYB8.js").then((t) => t.default),
|
|
867
868
|
"zh-TW": () => import("./zh-TW-BNfdfwdz.js").then((t) => t.default)
|
|
868
869
|
};
|
|
869
|
-
function
|
|
870
|
-
return (e == null ? void 0 : e[t]) ??
|
|
870
|
+
function Ri(t, e) {
|
|
871
|
+
return (e == null ? void 0 : e[t]) ?? B[t];
|
|
871
872
|
}
|
|
872
|
-
function
|
|
873
|
+
function Si(t) {
|
|
873
874
|
if ("kind" in t) return t;
|
|
874
|
-
const e =
|
|
875
|
+
const e = ke(t.origin);
|
|
875
876
|
if ("sourceUrl" in t)
|
|
876
877
|
return {
|
|
877
878
|
kind: "proxy",
|
|
@@ -900,12 +901,12 @@ function Ei(t) {
|
|
|
900
901
|
hash: r
|
|
901
902
|
};
|
|
902
903
|
}
|
|
903
|
-
var k,
|
|
904
|
-
let
|
|
904
|
+
var k, q, te, M;
|
|
905
|
+
let Ci = (M = class {
|
|
905
906
|
constructor(e) {
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
907
|
+
le(this, q);
|
|
908
|
+
le(this, k);
|
|
909
|
+
Ie(this, k, Si(e));
|
|
909
910
|
}
|
|
910
911
|
/**
|
|
911
912
|
* Parses an existing CDN URL.
|
|
@@ -913,7 +914,7 @@ let Ri = (M = class {
|
|
|
913
914
|
* @throws TypeError when the URL cannot be interpreted as a CDN URL.
|
|
914
915
|
*/
|
|
915
916
|
static parse(e) {
|
|
916
|
-
return new M(
|
|
917
|
+
return new M(lt(e));
|
|
917
918
|
}
|
|
918
919
|
/** A defensive copy of the operation chain (empty for group root urls). */
|
|
919
920
|
get operations() {
|
|
@@ -921,7 +922,7 @@ let Ri = (M = class {
|
|
|
921
922
|
}
|
|
922
923
|
/** The serialized URL string. */
|
|
923
924
|
get href() {
|
|
924
|
-
return
|
|
925
|
+
return ht(E(this, k));
|
|
925
926
|
}
|
|
926
927
|
/** Alias of {@link CdnUrl.href} for string coercion. */
|
|
927
928
|
toString() {
|
|
@@ -937,18 +938,18 @@ let Ri = (M = class {
|
|
|
937
938
|
* @throws TypeError on group root urls, which cannot carry operations.
|
|
938
939
|
*/
|
|
939
940
|
with(...e) {
|
|
940
|
-
return
|
|
941
|
+
return J(this, q, te).call(this, (i) => [...i, ...e]);
|
|
941
942
|
}
|
|
942
943
|
/**
|
|
943
944
|
* Removes every occurrence of an operation. Accepts the operation name,
|
|
944
945
|
* an operation object, or the creator itself: `url.without(resize)`.
|
|
945
946
|
*/
|
|
946
947
|
without(e) {
|
|
947
|
-
return
|
|
948
|
+
return J(this, q, te).call(this, (i) => i.filter((r) => !he(r, e)));
|
|
948
949
|
}
|
|
949
950
|
/** Replaces the first same-named operation in place, or appends it. */
|
|
950
951
|
replace(e) {
|
|
951
|
-
return
|
|
952
|
+
return J(this, q, te).call(this, (i) => {
|
|
952
953
|
const r = i.findIndex((o) => o.name === e.name);
|
|
953
954
|
if (r === -1) return [...i, e];
|
|
954
955
|
const s = [...i];
|
|
@@ -957,11 +958,11 @@ let Ri = (M = class {
|
|
|
957
958
|
}
|
|
958
959
|
/** Whether a matching operation is present (name, object or creator ref). */
|
|
959
960
|
has(e) {
|
|
960
|
-
return this.operations.some((i) =>
|
|
961
|
+
return this.operations.some((i) => he(i, e));
|
|
961
962
|
}
|
|
962
963
|
/** First matching operation (name, object or creator ref), or null. */
|
|
963
964
|
get(e) {
|
|
964
|
-
return this.operations.find((i) =>
|
|
965
|
+
return this.operations.find((i) => he(i, e)) ?? null;
|
|
965
966
|
}
|
|
966
967
|
/**
|
|
967
968
|
* Sets or clears (`null`) the trailing filename.
|
|
@@ -973,51 +974,51 @@ let Ri = (M = class {
|
|
|
973
974
|
}
|
|
974
975
|
/** Rebases the url onto another domain. */
|
|
975
976
|
setOrigin(e) {
|
|
976
|
-
return new M({ ...E(this, k), origin:
|
|
977
|
+
return new M({ ...E(this, k), origin: ke(e) });
|
|
977
978
|
}
|
|
978
|
-
}, k = new WeakMap(),
|
|
979
|
+
}, k = new WeakMap(), q = new WeakSet(), te = function(e) {
|
|
979
980
|
return "operations" in E(this, k) ? new M({
|
|
980
981
|
...E(this, k),
|
|
981
982
|
operations: e(E(this, k).operations)
|
|
982
983
|
}) : this;
|
|
983
984
|
}, M);
|
|
984
|
-
const
|
|
985
|
+
const be = (t, ...e) => ({
|
|
985
986
|
name: t,
|
|
986
987
|
params: e
|
|
987
|
-
}),
|
|
988
|
+
}), $i = /* @__PURE__ */ ut(
|
|
988
989
|
"preview",
|
|
989
990
|
function(t, e) {
|
|
990
|
-
return t == null && e == null ?
|
|
991
|
+
return t == null && e == null ? be("preview") : be("preview", nt(t, e, "preview"));
|
|
991
992
|
}
|
|
992
|
-
),
|
|
993
|
+
), Ai = /* @__PURE__ */ ut(
|
|
993
994
|
"scale_crop",
|
|
994
995
|
function(t, e, i = {}) {
|
|
995
|
-
const r = [
|
|
996
|
-
return i.type != null && r.push(i.type), i.align != null && r.push(
|
|
996
|
+
const r = [nt(t, e, "scale_crop")];
|
|
997
|
+
return i.type != null && r.push(i.type), i.align != null && r.push(Pt(i.align, "scale_crop alignment")), be("scale_crop", ...r);
|
|
997
998
|
}
|
|
998
|
-
),
|
|
999
|
-
function
|
|
999
|
+
), Ui = 3e3;
|
|
1000
|
+
function dt(t) {
|
|
1000
1001
|
const e = typeof window < "u" ? window.devicePixelRatio : 1;
|
|
1001
|
-
return Math.min(Math.ceil(t * Math.max(e, 1)),
|
|
1002
|
+
return Math.min(Math.ceil(t * Math.max(e, 1)), Ui);
|
|
1002
1003
|
}
|
|
1003
|
-
function
|
|
1004
|
+
function pt(t, e) {
|
|
1004
1005
|
if (e.length === 0) return t;
|
|
1005
1006
|
try {
|
|
1006
|
-
return
|
|
1007
|
+
return Ci.parse(t).with(...e).href;
|
|
1007
1008
|
} catch {
|
|
1008
1009
|
return t;
|
|
1009
1010
|
}
|
|
1010
1011
|
}
|
|
1011
|
-
function
|
|
1012
|
-
const i =
|
|
1013
|
-
return
|
|
1012
|
+
function Ti(t, e) {
|
|
1013
|
+
const i = dt(e);
|
|
1014
|
+
return pt(t, [$i(i, i)]);
|
|
1014
1015
|
}
|
|
1015
|
-
function
|
|
1016
|
-
const i =
|
|
1017
|
-
return
|
|
1016
|
+
function Fi(t, e) {
|
|
1017
|
+
const i = dt(e);
|
|
1018
|
+
return pt(t, [Ai(i, i, { align: "center" })]);
|
|
1018
1019
|
}
|
|
1019
|
-
const
|
|
1020
|
-
class
|
|
1020
|
+
const Mi = "uc-ai-enhancer/history", Ke = 200, Ii = 10080 * 60 * 1e3;
|
|
1021
|
+
class Oi {
|
|
1021
1022
|
constructor(e) {
|
|
1022
1023
|
this._key = null, e.addController(this);
|
|
1023
1024
|
}
|
|
@@ -1025,7 +1026,7 @@ class Mi {
|
|
|
1025
1026
|
}
|
|
1026
1027
|
/** Namespace the store by pubkey. Passing an empty key disables persistence. */
|
|
1027
1028
|
setNamespace(e) {
|
|
1028
|
-
this._key = e ? `${
|
|
1029
|
+
this._key = e ? `${Mi}/${e}` : null;
|
|
1029
1030
|
}
|
|
1030
1031
|
/** Upsert the result as a node and persist (evicting expired/overflowing nodes). */
|
|
1031
1032
|
record(e) {
|
|
@@ -1056,7 +1057,7 @@ class Mi {
|
|
|
1056
1057
|
*/
|
|
1057
1058
|
lineage(e) {
|
|
1058
1059
|
const i = this._key;
|
|
1059
|
-
return !i || !e ? [] : this._component(this._read(i), e).sort((r, s) => s.createdAt - r.createdAt).map(
|
|
1060
|
+
return !i || !e ? [] : this._component(this._read(i), e).sort((r, s) => s.createdAt - r.createdAt).map(Pi);
|
|
1060
1061
|
}
|
|
1061
1062
|
/** Nodes in `start`'s connected component, walking both parent and child edges.
|
|
1062
1063
|
* `start` may be a node itself or only a parent uuid (a source not yet edited). */
|
|
@@ -1082,8 +1083,8 @@ class Mi {
|
|
|
1082
1083
|
* middle node just orphans its descendants (their lineage walk stops early). */
|
|
1083
1084
|
_evict(e) {
|
|
1084
1085
|
const i = Date.now();
|
|
1085
|
-
let r = Object.values(e).filter((o) => i - o.createdAt <
|
|
1086
|
-
r.length >
|
|
1086
|
+
let r = Object.values(e).filter((o) => i - o.createdAt < Ii);
|
|
1087
|
+
r.length > Ke && (r = r.sort((o, a) => a.createdAt - o.createdAt).slice(0, Ke));
|
|
1087
1088
|
const s = {};
|
|
1088
1089
|
for (const o of r) s[o.uuid] = o;
|
|
1089
1090
|
return s;
|
|
@@ -1107,7 +1108,7 @@ class Mi {
|
|
|
1107
1108
|
}
|
|
1108
1109
|
}
|
|
1109
1110
|
}
|
|
1110
|
-
function
|
|
1111
|
+
function Pi(t) {
|
|
1111
1112
|
return {
|
|
1112
1113
|
id: t.uuid,
|
|
1113
1114
|
prompt: t.prompt,
|
|
@@ -1117,23 +1118,23 @@ function Ii(t) {
|
|
|
1117
1118
|
ratio: t.ratio
|
|
1118
1119
|
};
|
|
1119
1120
|
}
|
|
1120
|
-
function
|
|
1121
|
+
function zi(t) {
|
|
1121
1122
|
try {
|
|
1122
|
-
const e =
|
|
1123
|
+
const e = lt(t);
|
|
1123
1124
|
if (e.kind === "file")
|
|
1124
1125
|
return {
|
|
1125
1126
|
uuid: e.uuid,
|
|
1126
|
-
cdnUrlModifiers:
|
|
1127
|
+
cdnUrlModifiers: ct(e.operations),
|
|
1127
1128
|
fileName: e.filename ?? ""
|
|
1128
1129
|
};
|
|
1129
1130
|
} catch {
|
|
1130
1131
|
}
|
|
1131
1132
|
return { uuid: "", cdnUrlModifiers: "", fileName: "" };
|
|
1132
1133
|
}
|
|
1133
|
-
function
|
|
1134
|
-
return e ? e(t,
|
|
1134
|
+
function Li(t, e) {
|
|
1135
|
+
return e ? e(t, zi(t)) : t;
|
|
1135
1136
|
}
|
|
1136
|
-
class
|
|
1137
|
+
class ft {
|
|
1137
1138
|
constructor(e) {
|
|
1138
1139
|
this._cache = /* @__PURE__ */ new Map(), this._pending = /* @__PURE__ */ new Set(), this._host = e, e.addController(this);
|
|
1139
1140
|
}
|
|
@@ -1150,39 +1151,39 @@ class pt {
|
|
|
1150
1151
|
const i = this._cache.get(e);
|
|
1151
1152
|
if (i !== void 0) return i;
|
|
1152
1153
|
if (this._pending.has(e)) return null;
|
|
1153
|
-
const r =
|
|
1154
|
+
const r = Li(e, this._resolver);
|
|
1154
1155
|
return typeof r == "string" ? (this._cache.set(e, r), r) : (this._pending.add(e), r.then((s) => this._cache.set(e, s)).catch(() => this._cache.set(e, e)).finally(() => {
|
|
1155
1156
|
this._pending.delete(e), this._host.requestUpdate();
|
|
1156
1157
|
}), null);
|
|
1157
1158
|
}
|
|
1158
1159
|
}
|
|
1159
|
-
const
|
|
1160
|
+
const jr = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1160
1161
|
<path d="M9.5 3 11 6.5 14.5 8 11 9.5 9.5 13 8 9.5 4.5 8 8 6.5 9.5 3Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
|
|
1161
1162
|
<path d="M17.5 12 18.4 14.1 20.5 15 18.4 15.9 17.5 18 16.6 15.9 14.5 15 16.6 14.1 17.5 12Z" stroke="currentColor" stroke-width="1.25" stroke-linejoin="round"/>
|
|
1162
1163
|
<path d="M5.5 16 6.1 17.4 7.5 18 6.1 18.6 5.5 20 4.9 18.6 3.5 18 4.9 17.4 5.5 16Z" stroke="currentColor" stroke-width="1.25" stroke-linejoin="round"/>
|
|
1163
|
-
</svg>`,
|
|
1164
|
+
</svg>`, Gr = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1164
1165
|
<path d="m14.5 4.5 5 5L9 20H4v-5L14.5 4.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/>
|
|
1165
1166
|
<path d="m13 6 5 5" stroke="currentColor" stroke-width="1.5"/>
|
|
1166
1167
|
<path d="M18.5 14.5 19 16l1.5.5L19 17l-.5 1.5L18 17l-1.5-.5L18 16l.5-1.5Z" stroke="currentColor" stroke-width="1.1" stroke-linejoin="round"/>
|
|
1167
|
-
</svg>`,
|
|
1168
|
+
</svg>`, Di = `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1168
1169
|
<path d="M3 6.74251L8 2L13 6.74251M7.99961 14V2.10636" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1169
|
-
</svg>`,
|
|
1170
|
+
</svg>`, Ni = `<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1170
1171
|
<rect x="2" y="3" width="12" height="10" rx="1.6" stroke="currentColor" stroke-width="1.4"/>
|
|
1171
1172
|
<circle cx="5.75" cy="6.25" r="1.05" stroke="currentColor" stroke-width="1.2"/>
|
|
1172
1173
|
<path d="M3 11.5l3-2.6 2.3 1.8L11 8l2 2.4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1173
|
-
</svg>`,
|
|
1174
|
+
</svg>`, Bi = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1174
1175
|
<path d="M9 4H4v5M15 4h5v5M9 20H4v-5M15 20h5v-5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1175
|
-
</svg>`,
|
|
1176
|
+
</svg>`, ji = `<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
|
1176
1177
|
<path d="M4 9h5V4M20 9h-5V4M4 15h5v5M20 15h-5v5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1177
|
-
</svg>`,
|
|
1178
|
-
var
|
|
1179
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1178
|
+
</svg>`, Gi = ":host{display:inline-flex;position:relative}.trigger{anchor-name:--ai-aspect-anchor;display:inline-flex;align-items:center;gap:8px;height:var(--uc-ai-button-size);padding:0 10px;background:var(--uc-ai-secondary);border:0;border-radius:var(--uc-ai-radius-button);color:var(--uc-ai-foreground);cursor:pointer;font:inherit;transition:background var(--uc-ai-transition),transform .14s var(--uc-ai-ease-out, ease)}.trigger:hover,.trigger[aria-expanded=true]{background:var(--uc-ai-secondary-hover)}.trigger:active{transform:scale(.97)}.trigger:disabled{opacity:.4;cursor:not-allowed}.trigger svg{width:14px;height:14px;color:var(--uc-ai-foreground)}.trigger-label{font-variant-numeric:tabular-nums;font-size:12px;font-weight:500;letter-spacing:.02em;line-height:20px}.popover{margin:0 0 6px;padding:0;border:0;background:transparent;color:inherit;overflow:visible;width:max-content;min-width:180px;max-width:320px;position-anchor:--ai-aspect-anchor;inset:auto;bottom:anchor(top);right:anchor(right);transform-origin:bottom right;transition:opacity .15s var(--uc-ai-ease-out, ease),transform .15s var(--uc-ai-ease-out, ease),display .15s allow-discrete,overlay .15s allow-discrete}.popover:not(:popover-open){display:none;opacity:0;transform:scale(.96) translateY(4px)}@starting-style{.popover:popover-open{opacity:0;transform:scale(.96) translateY(4px)}}.popover-inner{background:var(--uc-ai-background);border:1px solid var(--uc-ai-border);border-radius:var(--uc-ai-radius-input, 12px);box-shadow:var(--uc-ai-dialog-shadow);padding:5px;display:flex;flex-direction:column;gap:2px}.option{display:flex;align-items:center;gap:10px;width:100%;padding:6px 10px;background:transparent;border:0;border-radius:max(0px,calc(var(--uc-ai-radius-input) - 5px));cursor:pointer;color:var(--uc-ai-foreground);font:inherit;font-size:13px;text-align:left;transition:background .12s ease}.option:hover{background:var(--uc-ai-secondary)}.option[aria-selected=true]{background:var(--uc-ai-secondary-hover)}.option svg{width:16px;height:16px;flex:0 0 16px;color:var(--uc-ai-foreground)}.option-ratio{flex:0 0 36px;font-variant-numeric:tabular-nums;font-weight:500;white-space:nowrap;color:var(--uc-ai-foreground)}.option-label{flex:1;min-width:0;color:var(--uc-ai-muted-foreground);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(prefers-reduced-motion:reduce){.trigger,.popover{transition-property:opacity,background,display,overlay}.trigger:active{transform:none}.popover:not(:popover-open){transform:none}}";
|
|
1179
|
+
var Hi = Object.defineProperty, Wi = Object.getOwnPropertyDescriptor, z = (t, e, i, r) => {
|
|
1180
|
+
for (var s = r > 1 ? void 0 : r ? Wi(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1180
1181
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1181
|
-
return r && s &&
|
|
1182
|
+
return r && s && Hi(e, i, s), s;
|
|
1182
1183
|
};
|
|
1183
|
-
let A = class extends
|
|
1184
|
+
let A = class extends G {
|
|
1184
1185
|
constructor() {
|
|
1185
|
-
super(...arguments), this.options = [], this.selected = null, this.busy = !1, this.labelText = null, this.labelFor = (t) => O(t.value) ?
|
|
1186
|
+
super(...arguments), this.options = [], this.selected = null, this.busy = !1, this.labelText = null, this.labelFor = (t) => O(t.value) ? Q(t.value) : "", this.open = !1, this._onToggle = (t) => {
|
|
1186
1187
|
t.newState === "closed" && this.open && (this.open = !1);
|
|
1187
1188
|
};
|
|
1188
1189
|
}
|
|
@@ -1207,12 +1208,12 @@ let A = class extends j {
|
|
|
1207
1208
|
}
|
|
1208
1209
|
/** Icon for a selection: the ratio's shape, or the generic "Original" glyph. */
|
|
1209
1210
|
_iconFor(t) {
|
|
1210
|
-
return O(t) ?
|
|
1211
|
+
return O(t) ? Tt(t) : Ni;
|
|
1211
1212
|
}
|
|
1212
1213
|
_triggerLabel() {
|
|
1213
1214
|
const t = this.selected;
|
|
1214
1215
|
if (!t) return "";
|
|
1215
|
-
if (O(t)) return
|
|
1216
|
+
if (O(t)) return Q(t);
|
|
1216
1217
|
const e = this.options.find((i) => i.value === t);
|
|
1217
1218
|
return e ? this.labelFor(e) : "";
|
|
1218
1219
|
}
|
|
@@ -1228,13 +1229,13 @@ let A = class extends j {
|
|
|
1228
1229
|
?disabled=${this.busy}
|
|
1229
1230
|
@click=${this._toggle}
|
|
1230
1231
|
>
|
|
1231
|
-
${this.selected ?
|
|
1232
|
+
${this.selected ? ie(this._iconFor(this.selected)) : null}
|
|
1232
1233
|
${t ? f`<span class="trigger-label">${t}</span>` : null}
|
|
1233
1234
|
</button>
|
|
1234
1235
|
<div class="popover" popover="auto" role="listbox" @toggle=${this._onToggle}>
|
|
1235
1236
|
<div class="popover-inner">
|
|
1236
1237
|
${this.options.map((e) => {
|
|
1237
|
-
const i = this.selected ?
|
|
1238
|
+
const i = this.selected ? fe(e.value, this.selected) : !1;
|
|
1238
1239
|
return f`
|
|
1239
1240
|
<button
|
|
1240
1241
|
type="button"
|
|
@@ -1243,8 +1244,8 @@ let A = class extends j {
|
|
|
1243
1244
|
aria-selected="${i ? "true" : "false"}"
|
|
1244
1245
|
@click=${() => this._select(e.value)}
|
|
1245
1246
|
>
|
|
1246
|
-
${
|
|
1247
|
-
<span class="option-ratio">${O(e.value) ?
|
|
1247
|
+
${ie(this._iconFor(e.value))}
|
|
1248
|
+
<span class="option-ratio">${O(e.value) ? Q(e.value) : ""}</span>
|
|
1248
1249
|
<span class="option-label">${this.labelFor(e)}</span>
|
|
1249
1250
|
</button>
|
|
1250
1251
|
`;
|
|
@@ -1254,7 +1255,7 @@ let A = class extends j {
|
|
|
1254
1255
|
`;
|
|
1255
1256
|
}
|
|
1256
1257
|
};
|
|
1257
|
-
A.styles =
|
|
1258
|
+
A.styles = j(Gi);
|
|
1258
1259
|
z([
|
|
1259
1260
|
c({ attribute: !1 })
|
|
1260
1261
|
], A.prototype, "options", 2);
|
|
@@ -1277,36 +1278,36 @@ z([
|
|
|
1277
1278
|
F(".popover")
|
|
1278
1279
|
], A.prototype, "_popover", 2);
|
|
1279
1280
|
A = z([
|
|
1280
|
-
|
|
1281
|
+
H("uc-ai-aspect-ratio")
|
|
1281
1282
|
], A);
|
|
1282
|
-
const
|
|
1283
|
-
let
|
|
1284
|
-
const
|
|
1283
|
+
const Vi = /* @__PURE__ */ new WeakMap();
|
|
1284
|
+
let Ye = 0;
|
|
1285
|
+
const de = /* @__PURE__ */ new Map(), Xe = /* @__PURE__ */ new WeakSet(), Je = () => new Promise((t) => requestAnimationFrame(t)), Ze = (t, e) => {
|
|
1285
1286
|
const i = t - e;
|
|
1286
1287
|
return i === 0 ? void 0 : i;
|
|
1287
|
-
},
|
|
1288
|
+
}, Qe = (t, e) => {
|
|
1288
1289
|
const i = t / e;
|
|
1289
1290
|
return i === 1 ? void 0 : i;
|
|
1290
|
-
},
|
|
1291
|
-
const i =
|
|
1291
|
+
}, pe = { left: (t, e) => {
|
|
1292
|
+
const i = Ze(t, e);
|
|
1292
1293
|
return { value: i, transform: i == null || isNaN(i) ? void 0 : `translateX(${i}px)` };
|
|
1293
1294
|
}, top: (t, e) => {
|
|
1294
|
-
const i =
|
|
1295
|
+
const i = Ze(t, e);
|
|
1295
1296
|
return { value: i, transform: i == null || isNaN(i) ? void 0 : `translateY(${i}px)` };
|
|
1296
1297
|
}, width: (t, e) => {
|
|
1297
1298
|
let i;
|
|
1298
1299
|
e === 0 && (e = 1, i = { width: "1px" });
|
|
1299
|
-
const r =
|
|
1300
|
+
const r = Qe(t, e);
|
|
1300
1301
|
return { value: r, overrideFrom: i, transform: r == null || isNaN(r) ? void 0 : `scaleX(${r})` };
|
|
1301
1302
|
}, height: (t, e) => {
|
|
1302
1303
|
let i;
|
|
1303
1304
|
e === 0 && (e = 1, i = { height: "1px" });
|
|
1304
|
-
const r =
|
|
1305
|
+
const r = Qe(t, e);
|
|
1305
1306
|
return { value: r, overrideFrom: i, transform: r == null || isNaN(r) ? void 0 : `scaleY(${r})` };
|
|
1306
|
-
} },
|
|
1307
|
-
class
|
|
1307
|
+
} }, qi = { duration: 333, easing: "ease-in-out" }, Ki = ["left", "top", "width", "height", "opacity", "color", "background"], et = /* @__PURE__ */ new WeakMap();
|
|
1308
|
+
class Yi extends ot {
|
|
1308
1309
|
constructor(e) {
|
|
1309
|
-
if (super(e), this.t = !1, this.i = null, this.o = null, this.h = !0, this.shouldLog = !1, e.type ===
|
|
1310
|
+
if (super(e), this.t = !1, this.i = null, this.o = null, this.h = !0, this.shouldLog = !1, e.type === st.CHILD) throw Error("The `animate` directive must be used in attribute position.");
|
|
1310
1311
|
this.createFinished();
|
|
1311
1312
|
}
|
|
1312
1313
|
createFinished() {
|
|
@@ -1320,10 +1321,10 @@ class qi extends st {
|
|
|
1320
1321
|
(e = this.l) == null || e.call(this), this.l = void 0;
|
|
1321
1322
|
}
|
|
1322
1323
|
render(e) {
|
|
1323
|
-
return
|
|
1324
|
+
return it;
|
|
1324
1325
|
}
|
|
1325
1326
|
getController() {
|
|
1326
|
-
return
|
|
1327
|
+
return Vi.get(this.u);
|
|
1327
1328
|
}
|
|
1328
1329
|
isDisabled() {
|
|
1329
1330
|
var e;
|
|
@@ -1332,17 +1333,17 @@ class qi extends st {
|
|
|
1332
1333
|
update(e, [i]) {
|
|
1333
1334
|
var s;
|
|
1334
1335
|
const r = this.u === void 0;
|
|
1335
|
-
return r && (this.u = (s = e.options) == null ? void 0 : s.host, this.u.addController(this), this.u.updateComplete.then((o) => this.t = !0), this.element = e.element,
|
|
1336
|
+
return r && (this.u = (s = e.options) == null ? void 0 : s.host, this.u.addController(this), this.u.updateComplete.then((o) => this.t = !0), this.element = e.element, et.set(this.element, this)), this.optionsOrCallback = i, (r || typeof i != "function") && this.m(i), this.render(i);
|
|
1336
1337
|
}
|
|
1337
1338
|
m(e) {
|
|
1338
1339
|
e = e ?? {};
|
|
1339
1340
|
const i = this.getController();
|
|
1340
|
-
i !== void 0 && ((e = { ...i.defaultOptions, ...e }).keyframeOptions = { ...i.defaultOptions.keyframeOptions, ...e.keyframeOptions }), e.properties ?? (e.properties =
|
|
1341
|
+
i !== void 0 && ((e = { ...i.defaultOptions, ...e }).keyframeOptions = { ...i.defaultOptions.keyframeOptions, ...e.keyframeOptions }), e.properties ?? (e.properties = Ki), this.options = e;
|
|
1341
1342
|
}
|
|
1342
1343
|
p() {
|
|
1343
1344
|
const e = {}, i = this.element.getBoundingClientRect(), r = getComputedStyle(this.element);
|
|
1344
1345
|
return this.options.properties.forEach((s) => {
|
|
1345
|
-
const o = i[s] ?? (
|
|
1346
|
+
const o = i[s] ?? (pe[s] ? void 0 : r[s]), a = Number(o);
|
|
1346
1347
|
e[s] = isNaN(a) ? o + "" : a;
|
|
1347
1348
|
}), e;
|
|
1348
1349
|
}
|
|
@@ -1361,17 +1362,17 @@ class qi extends st {
|
|
|
1361
1362
|
async hostUpdated() {
|
|
1362
1363
|
if (!this.h || !this.element.isConnected || this.options.skipInitial && !this.isHostRendered) return;
|
|
1363
1364
|
let e;
|
|
1364
|
-
this.prepare(), await
|
|
1365
|
+
this.prepare(), await Je;
|
|
1365
1366
|
const i = this.P(), r = this.V(this.options.keyframeOptions, i), s = this.p();
|
|
1366
1367
|
if (this.A !== void 0) {
|
|
1367
1368
|
const { from: o, to: a } = this.O(this.A, s, i);
|
|
1368
1369
|
this.log("measured", [this.A, s, o, a]), e = this.calculateKeyframes(o, a);
|
|
1369
1370
|
} else {
|
|
1370
|
-
const o =
|
|
1371
|
+
const o = de.get(this.options.inId);
|
|
1371
1372
|
if (o) {
|
|
1372
|
-
|
|
1373
|
+
de.delete(this.options.inId);
|
|
1373
1374
|
const { from: a, to: n } = this.O(o, s, i);
|
|
1374
|
-
e = this.calculateKeyframes(a, n), e = this.options.in ? [{ ...this.options.in[0], ...e[0] }, ...this.options.in.slice(1), e[1]] : e,
|
|
1375
|
+
e = this.calculateKeyframes(a, n), e = this.options.in ? [{ ...this.options.in[0], ...e[0] }, ...this.options.in.slice(1), e[1]] : e, Ye++, e.forEach((l) => l.zIndex = Ye);
|
|
1375
1376
|
} else this.options.in && (e = [...this.options.in, {}]);
|
|
1376
1377
|
}
|
|
1377
1378
|
this.animate(e, r);
|
|
@@ -1387,8 +1388,8 @@ class qi extends st {
|
|
|
1387
1388
|
}
|
|
1388
1389
|
async disconnected() {
|
|
1389
1390
|
var i;
|
|
1390
|
-
if (!this.h || (this.options.id !== void 0 &&
|
|
1391
|
-
if (this.prepare(), await
|
|
1391
|
+
if (!this.h || (this.options.id !== void 0 && de.set(this.options.id, this.A), this.options.out === void 0)) return;
|
|
1392
|
+
if (this.prepare(), await Je(), (i = this.i) == null ? void 0 : i.isConnected) {
|
|
1392
1393
|
const r = this.o && this.o.parentNode === this.i ? this.o : null;
|
|
1393
1394
|
if (this.i.insertBefore(this.element, r), this.options.stabilizeOut) {
|
|
1394
1395
|
const s = this.p();
|
|
@@ -1414,19 +1415,19 @@ class qi extends st {
|
|
|
1414
1415
|
P() {
|
|
1415
1416
|
const e = [];
|
|
1416
1417
|
for (let i = this.element.parentNode; i; i = i == null ? void 0 : i.parentNode) {
|
|
1417
|
-
const r =
|
|
1418
|
+
const r = et.get(i);
|
|
1418
1419
|
r && !r.isDisabled() && r && e.push(r);
|
|
1419
1420
|
}
|
|
1420
1421
|
return e;
|
|
1421
1422
|
}
|
|
1422
1423
|
get isHostRendered() {
|
|
1423
|
-
const e =
|
|
1424
|
+
const e = Xe.has(this.u);
|
|
1424
1425
|
return e || this.u.updateComplete.then(() => {
|
|
1425
|
-
|
|
1426
|
+
Xe.add(this.u);
|
|
1426
1427
|
}), e;
|
|
1427
1428
|
}
|
|
1428
1429
|
V(e, i = this.P()) {
|
|
1429
|
-
const r = { ...
|
|
1430
|
+
const r = { ...qi };
|
|
1430
1431
|
return i.forEach((s) => Object.assign(r, s.options.keyframeOptions)), Object.assign(r, e), r;
|
|
1431
1432
|
}
|
|
1432
1433
|
O(e, i, r) {
|
|
@@ -1443,8 +1444,8 @@ class qi extends st {
|
|
|
1443
1444
|
const n = {};
|
|
1444
1445
|
for (const l in i) {
|
|
1445
1446
|
const h = e[l], p = i[l];
|
|
1446
|
-
if (l in
|
|
1447
|
-
const u =
|
|
1447
|
+
if (l in pe) {
|
|
1448
|
+
const u = pe[l];
|
|
1448
1449
|
if (h === void 0 || p === void 0) continue;
|
|
1449
1450
|
const _ = u(h, p);
|
|
1450
1451
|
_.transform !== void 0 && (n[l] = _.value, a = !0, s.transform = `${s.transform ?? ""} ${_.transform}`, _.overrideFrom !== void 0 && Object.assign(s, _.overrideFrom));
|
|
@@ -1475,13 +1476,13 @@ class qi extends st {
|
|
|
1475
1476
|
this.shouldLog && !this.isDisabled() && console.log(e, this.options.id, i);
|
|
1476
1477
|
}
|
|
1477
1478
|
}
|
|
1478
|
-
const
|
|
1479
|
-
class
|
|
1479
|
+
const Xi = rt(Yi), Ji = ["top", "right", "bottom", "left"];
|
|
1480
|
+
class Zi extends ot {
|
|
1480
1481
|
constructor(e) {
|
|
1481
|
-
if (super(e), e.type !==
|
|
1482
|
+
if (super(e), e.type !== st.ELEMENT) throw Error("The `position` directive must be used in attribute position.");
|
|
1482
1483
|
}
|
|
1483
1484
|
render(e, i) {
|
|
1484
|
-
return
|
|
1485
|
+
return it;
|
|
1485
1486
|
}
|
|
1486
1487
|
update(e, [i, r]) {
|
|
1487
1488
|
var s;
|
|
@@ -1496,22 +1497,22 @@ class Xi extends st {
|
|
|
1496
1497
|
if (e === void 0 || !i) return;
|
|
1497
1498
|
const r = e.getBoundingClientRect(), s = i.getBoundingClientRect();
|
|
1498
1499
|
(a = this.S) == null || a.forEach((n) => {
|
|
1499
|
-
const l =
|
|
1500
|
+
const l = Ji.includes(n) ? r[n] - s[n] : r[n];
|
|
1500
1501
|
this.C.style[n] = l + "px";
|
|
1501
1502
|
});
|
|
1502
1503
|
}
|
|
1503
1504
|
}
|
|
1504
|
-
|
|
1505
|
-
const
|
|
1506
|
-
var
|
|
1507
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1505
|
+
rt(Zi);
|
|
1506
|
+
const Qi = ':host{display:flex;justify-content:center}.strip{position:relative;display:inline-flex;align-items:center;min-height:44px}.chip{display:flex;align-items:center;padding:2px;margin-right:-11px;background:var(--uc-ai-floating, var(--uc-ai-background));border:1px solid transparent;border-radius:calc(var(--uc-ai-radius-button, 8px) + 2px);box-shadow:0 1px 8px #0000004d;cursor:pointer;transform:scale(1);transition:margin .3s var(--uc-ai-ease-out, ease),border-color 225ms ease,transform .27s var(--uc-ai-ease-out, ease),opacity .33s var(--uc-ai-ease-out, ease)}.chip:disabled{cursor:not-allowed}.chip:last-child{margin-right:0}@media(hover:hover)and (pointer:fine){.chip:hover:not(:disabled){transform:scale(1.1)}.strip:hover .chip:not(:disabled){margin-right:7px}.strip:hover .chip:not(:disabled):last-child{margin-right:0}}.chip--selected{border-color:var(--uc-ai-primary);transform:scale(1.2)}.thumb{position:relative;display:block;width:40px;height:40px;border-radius:var(--uc-ai-radius-button, 8px);background-color:var(--uc-ai-muted);overflow:hidden}.thumb:not(.thumb--loaded):after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;background:linear-gradient(100deg,transparent 30%,color-mix(in srgb,var(--uc-ai-foreground) 9%,transparent) 50%,transparent 70%);transform:translate(-100%);animation:thumb-shimmer 1.2s ease-in-out infinite}@keyframes thumb-shimmer{to{transform:translate(100%)}}.thumb__img{display:block;width:100%;height:100%;object-fit:cover;opacity:0;transition:opacity .24s var(--uc-ai-ease-out, ease)}.thumb--loaded .thumb__img{opacity:1}@media(prefers-reduced-motion:reduce){.thumb:not(.thumb--loaded):after{animation:none}.thumb__img{transition:none}}.startover{position:absolute;right:calc(100% + 10px);top:50%;display:flex;align-items:center;background:var(--uc-ai-floating, var(--uc-ai-background));border:1px solid var(--uc-ai-floating-border, transparent);border-radius:calc(var(--uc-ai-radius-button, 8px) + 2px);box-shadow:var(--uc-ai-dialog-shadow);white-space:nowrap;opacity:0;transform:translateY(-50%) translate(-6px) scale(.95);transform-origin:right center;pointer-events:none;transition:opacity .26s var(--uc-ai-ease-out, ease),transform .26s var(--uc-ai-ease-out, ease)}.strip:hover .startover,.strip:focus-within .startover{opacity:1;transform:translateY(-50%) translate(0) scale(1);pointer-events:auto}.strip--empty .startover{position:static;opacity:1;transform:none;pointer-events:auto}.startover__btn{height:var(--uc-ai-button-size, 32px);padding:0 12px;background:transparent;border:0;border-radius:inherit;color:var(--uc-ai-foreground);font:inherit;font-size:13px;cursor:pointer}.startover__btn:disabled{cursor:not-allowed}.startover__btn:hover{background:var(--uc-ai-secondary)}.strip:before{content:"";position:absolute;right:100%;top:-12px;bottom:-12px;width:200px}.strip--empty:before{content:none}@media(prefers-reduced-motion:reduce){.chip,.startover{transition-property:opacity,border-color,margin}.chip:hover,.chip--selected{transform:scale(1)}.strip:not(.strip--empty) .startover,.strip:not(.strip--empty):hover .startover,.strip:not(.strip--empty):focus-within .startover{transform:translateY(-50%)}}';
|
|
1507
|
+
var er = Object.defineProperty, tr = Object.getOwnPropertyDescriptor, L = (t, e, i, r) => {
|
|
1508
|
+
for (var s = r > 1 ? void 0 : r ? tr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1508
1509
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1509
|
-
return r && s &&
|
|
1510
|
+
return r && s && er(e, i, s), s;
|
|
1510
1511
|
};
|
|
1511
|
-
const
|
|
1512
|
-
let U = class extends
|
|
1512
|
+
const ir = 80;
|
|
1513
|
+
let U = class extends G {
|
|
1513
1514
|
constructor() {
|
|
1514
|
-
super(...arguments), this.entries = [], this.selectedUuid = null, this.showStartOver = !1, this.startOverLabel = "", this.listLabel = "Generation history", this.busy = !1, this._secure = new
|
|
1515
|
+
super(...arguments), this.entries = [], this.selectedUuid = null, this.showStartOver = !1, this.startOverLabel = "", this.listLabel = "Generation history", this.busy = !1, this._secure = new ft(this), this._loaded = /* @__PURE__ */ new Set();
|
|
1515
1516
|
}
|
|
1516
1517
|
willUpdate(t) {
|
|
1517
1518
|
if (t.has("secureResolver") && this._secure.setResolver(this.secureResolver), t.has("entries")) {
|
|
@@ -1544,11 +1545,11 @@ let U = class extends j {
|
|
|
1544
1545
|
</button>
|
|
1545
1546
|
</div>
|
|
1546
1547
|
` : v}
|
|
1547
|
-
${
|
|
1548
|
+
${yt(
|
|
1548
1549
|
i,
|
|
1549
1550
|
(r) => r.id,
|
|
1550
1551
|
(r) => {
|
|
1551
|
-
const s = this._secure.resolve(
|
|
1552
|
+
const s = this._secure.resolve(Fi(r.url, ir)), o = this.selectedUuid != null && r.file.uuid === this.selectedUuid, a = this._loaded.has(r.id);
|
|
1552
1553
|
return f`
|
|
1553
1554
|
<button
|
|
1554
1555
|
type="button"
|
|
@@ -1558,7 +1559,7 @@ let U = class extends j {
|
|
|
1558
1559
|
aria-label=${r.prompt || "Result"}
|
|
1559
1560
|
title=${r.prompt}
|
|
1560
1561
|
@click=${() => this._select(r)}
|
|
1561
|
-
${
|
|
1562
|
+
${Xi({ keyframeOptions: { duration: 300, easing: "cubic-bezier(0.23, 1, 0.32, 1)" } })}
|
|
1562
1563
|
>
|
|
1563
1564
|
<span class=${S({ thumb: !0, "thumb--loaded": a })}>
|
|
1564
1565
|
${// Rendering the <img> preloads it; the skeleton shows until it
|
|
@@ -1581,7 +1582,7 @@ let U = class extends j {
|
|
|
1581
1582
|
`;
|
|
1582
1583
|
}
|
|
1583
1584
|
};
|
|
1584
|
-
U.styles =
|
|
1585
|
+
U.styles = j(Qi);
|
|
1585
1586
|
L([
|
|
1586
1587
|
c({ attribute: !1 })
|
|
1587
1588
|
], U.prototype, "entries", 2);
|
|
@@ -1604,15 +1605,15 @@ L([
|
|
|
1604
1605
|
c({ attribute: !1 })
|
|
1605
1606
|
], U.prototype, "secureResolver", 2);
|
|
1606
1607
|
U = L([
|
|
1607
|
-
|
|
1608
|
+
H("uc-ai-history")
|
|
1608
1609
|
], U);
|
|
1609
|
-
const
|
|
1610
|
-
var
|
|
1611
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1610
|
+
const rr = ':host{display:block}.card{width:100%;box-sizing:border-box;background:color-mix(in srgb,var(--uc-ai-floating, var(--uc-ai-background)) 80%,transparent);backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px);border:1px solid var(--uc-ai-floating-border, transparent);border-radius:var(--uc-ai-composer-radius-top) var(--uc-ai-composer-radius-top) var(--uc-ai-composer-radius-bottom) var(--uc-ai-composer-radius-bottom);transition:border-radius .4s var(--uc-ai-ease-out),box-shadow .4s var(--uc-ai-ease-out);box-shadow:var(--uc-ai-composer-shadow);overflow:visible;--uc-ai-radius-button: max(0px, calc(var(--uc-ai-composer-radius) - var(--uc-ai-padding)))}.body{display:flex;flex-direction:column;gap:var(--uc-ai-padding);padding:var(--uc-ai-padding)}.input{box-sizing:border-box;width:100%;min-height:40px;max-height:var(--uc-ai-prompt-max-height, calc(var(--uc-ai-prompt-max-lines, 6) * 1.5em + 10px));resize:none;border:0;outline:none;padding:0 3px;background:transparent;font-family:inherit;font-size:var(--uc-ai-font-size);line-height:20px;color:var(--uc-ai-foreground);overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--uc-ai-border) transparent;transition:height .16s var(--uc-ai-ease-out, ease)}@supports (field-sizing: content){.input{field-sizing:content;transition:none}}.input::placeholder{color:var(--uc-ai-muted-foreground)}.input:disabled{color:var(--uc-ai-muted-foreground);-webkit-text-fill-color:var(--uc-ai-muted-foreground);cursor:not-allowed}.row{display:flex;align-items:center;gap:10px}.actions{flex:1;min-width:0;display:flex;align-items:center}.actions::slotted(*){min-width:0}.controls{display:flex;align-items:center;gap:0;flex:none}.send{margin-left:5px;width:var(--uc-ai-button-size, 32px);height:var(--uc-ai-button-size, 32px);flex:none;min-width:0;display:inline-flex;align-items:center;justify-content:center;position:relative;background:var(--uc-ai-primary);color:var(--uc-ai-primary-foreground);border:none;border-radius:var(--uc-ai-radius-button);cursor:pointer;overflow:hidden;transition:width .22s var(--uc-ai-ease-out, ease),margin-left .22s var(--uc-ai-ease-out, ease),opacity .15s var(--uc-ai-ease-out, ease),transform .15s var(--uc-ai-ease-out, ease),background var(--uc-ai-transition)}.send:hover:not(:disabled){background:var(--uc-ai-primary-hover)}.send:active:not(:disabled){transform:scale(.95)}.send:disabled{cursor:default}.send[hidden]{display:inline-flex;width:0;min-width:0;padding:0;margin-left:0;opacity:0;transform:scale(.8);pointer-events:none}.send__icon,.send__spinner{position:absolute;top:50%;left:50%;width:16px;height:16px;transition:opacity .2s var(--uc-ai-ease-out, ease),transform .2s var(--uc-ai-ease-out, ease),filter .2s var(--uc-ai-ease-out, ease)}.send__icon{opacity:1;transform:translate(-50%,-50%) scale(1);filter:blur(0)}.send__icon svg{width:16px;height:16px;display:block}.send__spinner{opacity:0;transform:translate(-50%,-50%) scale(.95);filter:blur(3px)}.send__spinner:before,.send__spinner:after{content:"";position:absolute;top:0;right:0;bottom:0;left:0;border-radius:50%;border:1.5px solid currentColor}.send__spinner:before{opacity:.3}.send__spinner:after{border-top-color:transparent;animation:send-spin .7s linear infinite;will-change:transform}@keyframes send-spin{to{transform:rotate(360deg)}}.send--busy .send__icon{opacity:0;transform:translate(-50%,-50%) scale(.95);filter:blur(3px)}.send--busy .send__spinner{opacity:1;transform:translate(-50%,-50%) scale(1);filter:blur(0)}.send--busy:disabled{opacity:1}@media(prefers-reduced-motion:reduce){.input,.send{transition-property:opacity,background,width,margin-left}.send__icon,.send__spinner{transition-property:opacity}.send__spinner:after{animation:none}.send:active:not(:disabled){transform:none}}';
|
|
1611
|
+
var sr = Object.defineProperty, or = Object.getOwnPropertyDescriptor, D = (t, e, i, r) => {
|
|
1612
|
+
for (var s = r > 1 ? void 0 : r ? or(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1612
1613
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1613
|
-
return r && s &&
|
|
1614
|
+
return r && s && sr(e, i, s), s;
|
|
1614
1615
|
};
|
|
1615
|
-
let T = class extends
|
|
1616
|
+
let T = class extends G {
|
|
1616
1617
|
constructor() {
|
|
1617
1618
|
super(...arguments), this.mode = "generate", this.value = "", this.placeholder = "", this.busy = !1, this.allowCustom = !0, this.sendAriaLabel = "";
|
|
1618
1619
|
}
|
|
@@ -1681,7 +1682,7 @@ let T = class extends j {
|
|
|
1681
1682
|
?disabled=${this.busy || t}
|
|
1682
1683
|
@click=${this._emitSend}
|
|
1683
1684
|
>
|
|
1684
|
-
<span class="send__icon">${
|
|
1685
|
+
<span class="send__icon">${ie(Di)}</span>
|
|
1685
1686
|
<span class="send__spinner" aria-hidden="true"></span>
|
|
1686
1687
|
</button>
|
|
1687
1688
|
</div>
|
|
@@ -1691,7 +1692,7 @@ let T = class extends j {
|
|
|
1691
1692
|
`;
|
|
1692
1693
|
}
|
|
1693
1694
|
};
|
|
1694
|
-
T.styles =
|
|
1695
|
+
T.styles = j(rr);
|
|
1695
1696
|
D([
|
|
1696
1697
|
c()
|
|
1697
1698
|
], T.prototype, "mode", 2);
|
|
@@ -1714,15 +1715,15 @@ D([
|
|
|
1714
1715
|
F(".input")
|
|
1715
1716
|
], T.prototype, "_inputEl", 2);
|
|
1716
1717
|
T = D([
|
|
1717
|
-
|
|
1718
|
+
H("uc-ai-prompt-row")
|
|
1718
1719
|
], T);
|
|
1719
|
-
const
|
|
1720
|
-
var
|
|
1721
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
1720
|
+
const ar = ":host{display:block;min-width:0}.row{display:flex;flex-wrap:nowrap;align-items:center;gap:5px;overflow-x:auto;scrollbar-width:none}.row::-webkit-scrollbar{display:none}.row.fade-left.fade-right{-webkit-mask-image:linear-gradient(to right,transparent 0,#000 10px,#000 calc(100% - 10px),transparent 100%);mask-image:linear-gradient(to right,transparent 0,#000 10px,#000 calc(100% - 10px),transparent 100%)}.row.fade-left:not(.fade-right){-webkit-mask-image:linear-gradient(to right,transparent 0,#000 10px);mask-image:linear-gradient(to right,transparent 0,#000 10px)}.row.fade-right:not(.fade-left){-webkit-mask-image:linear-gradient(to right,#000 calc(100% - 10px),transparent 100%);mask-image:linear-gradient(to right,#000 calc(100% - 10px),transparent 100%)}.chip{flex:none;height:var(--uc-ai-button-size, 32px);display:inline-flex;align-items:center;justify-content:center;padding:0 10px;background:var(--uc-ai-secondary);border:0;border-radius:var(--uc-ai-radius-button);font-family:inherit;font-size:13px;line-height:20px;color:var(--uc-ai-secondary-foreground);cursor:pointer;white-space:nowrap;transition:background .15s ease,transform .14s var(--uc-ai-ease-out, ease)}@media(hover:hover)and (pointer:fine){.chip:hover{background:var(--uc-ai-secondary-hover)}}.chip:active{background:var(--uc-ai-secondary-hover);transform:scale(.97)}.chip:disabled{opacity:.5;cursor:not-allowed}@media(prefers-reduced-motion:reduce){.chip{transition-property:background}.chip:active{transform:none}}";
|
|
1721
|
+
var nr = Object.defineProperty, lr = Object.getOwnPropertyDescriptor, Y = (t, e, i, r) => {
|
|
1722
|
+
for (var s = r > 1 ? void 0 : r ? lr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
1722
1723
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
1723
|
-
return r && s &&
|
|
1724
|
+
return r && s && nr(e, i, s), s;
|
|
1724
1725
|
};
|
|
1725
|
-
let P = class extends
|
|
1726
|
+
let P = class extends G {
|
|
1726
1727
|
constructor() {
|
|
1727
1728
|
super(...arguments), this.mode = "generate", this.presets = null, this.busy = !1, this.labelText = "Quick prompts";
|
|
1728
1729
|
}
|
|
@@ -1759,7 +1760,7 @@ let P = class extends j {
|
|
|
1759
1760
|
);
|
|
1760
1761
|
}
|
|
1761
1762
|
render() {
|
|
1762
|
-
const t = this.presets ??
|
|
1763
|
+
const t = this.presets ?? me[this.mode].presets;
|
|
1763
1764
|
return f`
|
|
1764
1765
|
<div
|
|
1765
1766
|
class="row"
|
|
@@ -1779,26 +1780,30 @@ let P = class extends j {
|
|
|
1779
1780
|
`;
|
|
1780
1781
|
}
|
|
1781
1782
|
};
|
|
1782
|
-
P.styles =
|
|
1783
|
-
|
|
1783
|
+
P.styles = j(ar);
|
|
1784
|
+
Y([
|
|
1784
1785
|
c()
|
|
1785
1786
|
], P.prototype, "mode", 2);
|
|
1786
|
-
|
|
1787
|
+
Y([
|
|
1787
1788
|
c({ attribute: !1 })
|
|
1788
1789
|
], P.prototype, "presets", 2);
|
|
1789
|
-
|
|
1790
|
+
Y([
|
|
1790
1791
|
c({ type: Boolean })
|
|
1791
1792
|
], P.prototype, "busy", 2);
|
|
1792
|
-
|
|
1793
|
+
Y([
|
|
1793
1794
|
c({ attribute: "aria-label-text" })
|
|
1794
1795
|
], P.prototype, "labelText", 2);
|
|
1795
|
-
|
|
1796
|
+
Y([
|
|
1796
1797
|
F(".row")
|
|
1797
1798
|
], P.prototype, "_rowEl", 2);
|
|
1798
|
-
P =
|
|
1799
|
-
|
|
1799
|
+
P = Y([
|
|
1800
|
+
H("uc-ai-chips")
|
|
1800
1801
|
], P);
|
|
1801
|
-
|
|
1802
|
+
function N(t, e) {
|
|
1803
|
+
if (t === null) throw new Error(`DotGrid GL: failed to create ${e} (context lost?)`);
|
|
1804
|
+
return t;
|
|
1805
|
+
}
|
|
1806
|
+
const ye = 8, cr = `#version 300 es
|
|
1802
1807
|
precision highp float;
|
|
1803
1808
|
precision highp int;
|
|
1804
1809
|
in vec2 aCorner; // unit quad corner, -0.5..0.5
|
|
@@ -1817,7 +1822,7 @@ uniform float uMinScale;
|
|
|
1817
1822
|
uniform float uPeakScale;
|
|
1818
1823
|
uniform float uIdleScale;
|
|
1819
1824
|
uniform int uEpiCount;
|
|
1820
|
-
uniform vec2 uEpis[${
|
|
1825
|
+
uniform vec2 uEpis[${ye}];
|
|
1821
1826
|
uniform float uEpiRadius;
|
|
1822
1827
|
uniform float uEpiFalloff;
|
|
1823
1828
|
uniform float uColorA;
|
|
@@ -1834,7 +1839,7 @@ float epiIntensity(vec2 p) {
|
|
|
1834
1839
|
// Low-frequency warp of the distance field — dissolves ring banding.
|
|
1835
1840
|
float k = uFalloffWarp > 0.0 ? (6.2831853 / (uEpiRadius * 0.7)) : 0.0;
|
|
1836
1841
|
float warp = k > 0.0 ? uFalloffWarp * uEpiRadius * sin(p.x * k + 1.3) * cos(p.y * k * 0.9) : 0.0;
|
|
1837
|
-
for (int i = 0; i < ${
|
|
1842
|
+
for (int i = 0; i < ${ye}; i++) {
|
|
1838
1843
|
if (i >= uEpiCount) break;
|
|
1839
1844
|
float d = max(0.0, distance(p, uEpis[i]) + warp);
|
|
1840
1845
|
if (d >= uEpiRadius) continue;
|
|
@@ -1895,7 +1900,7 @@ void main() {
|
|
|
1895
1900
|
gl_Position = vec4(ndc.x, -ndc.y, 0.0, 1.0);
|
|
1896
1901
|
|
|
1897
1902
|
vAlpha = (uMask == 1) ? 1.0 : uColorA;
|
|
1898
|
-
}`,
|
|
1903
|
+
}`, hr = `#version 300 es
|
|
1899
1904
|
precision highp float;
|
|
1900
1905
|
precision highp int;
|
|
1901
1906
|
in float vAlpha;
|
|
@@ -1914,7 +1919,7 @@ void main() {
|
|
|
1914
1919
|
float cov = clamp(0.5 - sd / aaw, 0.0, 1.0);
|
|
1915
1920
|
vec3 rgb = (uMask == 1) ? vec3(1.0) : uColorRGB;
|
|
1916
1921
|
frag = vec4(rgb * vAlpha * cov, vAlpha * cov); // premultiplied
|
|
1917
|
-
}`,
|
|
1922
|
+
}`, ur = `#version 300 es
|
|
1918
1923
|
precision highp float;
|
|
1919
1924
|
in vec2 aQuad; // 0..1
|
|
1920
1925
|
uniform vec2 uResolution;
|
|
@@ -1925,7 +1930,7 @@ void main() {
|
|
|
1925
1930
|
vFramePx = px - uFrame.xy;
|
|
1926
1931
|
vec2 ndc = (px / uResolution) * 2.0 - 1.0;
|
|
1927
1932
|
gl_Position = vec4(ndc.x, -ndc.y, 0.0, 1.0);
|
|
1928
|
-
}`,
|
|
1933
|
+
}`, dr = `#version 300 es
|
|
1929
1934
|
precision highp float;
|
|
1930
1935
|
in vec2 vFramePx;
|
|
1931
1936
|
uniform sampler2D uImage;
|
|
@@ -1940,13 +1945,13 @@ void main() {
|
|
|
1940
1945
|
vec2 uv = (vFramePx - off) / dsz;
|
|
1941
1946
|
frag = vec4(texture(uImage, uv).rgb, 1.0);
|
|
1942
1947
|
}`;
|
|
1943
|
-
class
|
|
1948
|
+
class $e {
|
|
1944
1949
|
constructor(e) {
|
|
1945
|
-
this._dotUniforms = {}, this._imgUniforms = {}, this._appliedW = 0, this._appliedH = 0, this._appliedScale = 0, this._texImage = null, this._texOk = !1, this._gl = e, this._dotProgram = this._link(
|
|
1950
|
+
this._dotUniforms = {}, this._imgUniforms = {}, this._appliedW = 0, this._appliedH = 0, this._appliedScale = 0, this._texImage = null, this._texOk = !1, this._gl = e, this._dotProgram = this._link(cr, hr), this._imgProgram = this._link(ur, dr), this._cornerBuf = this._staticBuffer([-0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5]), this._quadBuf = this._staticBuffer([0, 0, 1, 0, 0, 1, 1, 1]), this._clipBuf = N(e.createBuffer(), "buffer"), this._dotVao = N(e.createVertexArray(), "vertex array"), e.bindVertexArray(this._dotVao);
|
|
1946
1951
|
const i = e.getAttribLocation(this._dotProgram, "aCorner");
|
|
1947
1952
|
e.bindBuffer(e.ARRAY_BUFFER, this._cornerBuf), e.enableVertexAttribArray(i), e.vertexAttribPointer(i, 2, e.FLOAT, !1, 0, 0);
|
|
1948
1953
|
const r = e.getAttribLocation(this._dotProgram, "aClip");
|
|
1949
|
-
e.bindBuffer(e.ARRAY_BUFFER, this._clipBuf), e.enableVertexAttribArray(r), e.vertexAttribPointer(r, 1, e.FLOAT, !1, 0, 0), e.vertexAttribDivisor(r, 1), e.bindVertexArray(null), this._imgVao = e.createVertexArray(), e.bindVertexArray(this._imgVao);
|
|
1954
|
+
e.bindBuffer(e.ARRAY_BUFFER, this._clipBuf), e.enableVertexAttribArray(r), e.vertexAttribPointer(r, 1, e.FLOAT, !1, 0, 0), e.vertexAttribDivisor(r, 1), e.bindVertexArray(null), this._imgVao = N(e.createVertexArray(), "vertex array"), e.bindVertexArray(this._imgVao);
|
|
1950
1955
|
const s = e.getAttribLocation(this._imgProgram, "aQuad");
|
|
1951
1956
|
e.bindBuffer(e.ARRAY_BUFFER, this._quadBuf), e.enableVertexAttribArray(s), e.vertexAttribPointer(s, 2, e.FLOAT, !1, 0, 0), e.bindVertexArray(null);
|
|
1952
1957
|
for (const o of [
|
|
@@ -1975,7 +1980,7 @@ class Ce {
|
|
|
1975
1980
|
this._dotUniforms[o] = e.getUniformLocation(this._dotProgram, o);
|
|
1976
1981
|
for (const o of ["uResolution", "uFrame", "uImage", "uFrameSize", "uImageSize"])
|
|
1977
1982
|
this._imgUniforms[o] = e.getUniformLocation(this._imgProgram, o);
|
|
1978
|
-
this._texture = e.createTexture(), e.bindTexture(e.TEXTURE_2D, this._texture), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1);
|
|
1983
|
+
this._texture = N(e.createTexture(), "texture"), e.bindTexture(e.TEXTURE_2D, this._texture), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MIN_FILTER, e.LINEAR), e.texParameteri(e.TEXTURE_2D, e.TEXTURE_MAG_FILTER, e.LINEAR), e.pixelStorei(e.UNPACK_FLIP_Y_WEBGL, !1), e.pixelStorei(e.UNPACK_PREMULTIPLY_ALPHA_WEBGL, !1);
|
|
1979
1984
|
}
|
|
1980
1985
|
/** Create a renderer on `canvas`, or null if WebGL2 / compilation is unavailable. */
|
|
1981
1986
|
static create(e) {
|
|
@@ -1992,7 +1997,7 @@ class Ce {
|
|
|
1992
1997
|
}
|
|
1993
1998
|
if (!i) return null;
|
|
1994
1999
|
try {
|
|
1995
|
-
return new
|
|
2000
|
+
return new $e(i);
|
|
1996
2001
|
} catch (r) {
|
|
1997
2002
|
return typeof console < "u" && console.warn("[dot-grid] WebGL init failed, using 2D:", r), null;
|
|
1998
2003
|
}
|
|
@@ -2025,7 +2030,7 @@ class Ce {
|
|
|
2025
2030
|
}
|
|
2026
2031
|
i.bindBuffer(i.ARRAY_BUFFER, this._clipBuf), i.bufferData(i.ARRAY_BUFFER, e.clip, i.DYNAMIC_DRAW), i.enable(i.BLEND), i.blendFunc(i.ONE, i.ONE_MINUS_SRC_ALPHA), i.useProgram(this._dotProgram), i.bindVertexArray(this._dotVao);
|
|
2027
2032
|
const s = this._dotUniforms;
|
|
2028
|
-
if (i.uniform2f(s.uResolution, e.cssW, e.cssH), i.uniform1f(s.uCols, e.cols), i.uniform2f(s.uOffset, e.offsetX, e.offsetY), i.uniform1f(s.uCell, e.cell), i.uniform1f(s.uBaseRadius, e.baseRadius), i.uniform1f(s.uFullHalf, e.fullHalf), i.uniform1f(s.uEnv, e.env), i.uniform1f(s.uShimMix, e.shimMix), i.uniform1i(s.uMask, e.mask ? 1 : 0), i.uniform1i(s.uGenerating, e.generating ? 1 : 0), i.uniform1f(s.uMinScale, e.minScale), i.uniform1f(s.uPeakScale, e.peakScale), i.uniform1f(s.uIdleScale, e.idleScale), i.uniform1i(s.uEpiCount, Math.min(e.epiCount,
|
|
2033
|
+
if (i.uniform2f(s.uResolution, e.cssW, e.cssH), i.uniform1f(s.uCols, e.cols), i.uniform2f(s.uOffset, e.offsetX, e.offsetY), i.uniform1f(s.uCell, e.cell), i.uniform1f(s.uBaseRadius, e.baseRadius), i.uniform1f(s.uFullHalf, e.fullHalf), i.uniform1f(s.uEnv, e.env), i.uniform1f(s.uShimMix, e.shimMix), i.uniform1i(s.uMask, e.mask ? 1 : 0), i.uniform1i(s.uGenerating, e.generating ? 1 : 0), i.uniform1f(s.uMinScale, e.minScale), i.uniform1f(s.uPeakScale, e.peakScale), i.uniform1f(s.uIdleScale, e.idleScale), i.uniform1i(s.uEpiCount, Math.min(e.epiCount, ye)), i.uniform2fv(s.uEpis, e.epis), i.uniform1f(s.uEpiRadius, e.epiRadius), i.uniform1f(s.uEpiFalloff, e.epiFalloff), i.uniform1f(s.uColorA, e.color[3]), i.uniform3f(s.uColorRGB, e.color[0], e.color[1], e.color[2]), i.uniform1f(s.uFalloffWarp, e.falloffWarp), i.uniform1f(s.uDither, e.dither), i.drawArraysInstanced(i.TRIANGLE_STRIP, 0, 4, r), e.mask && this._texOk && this._texImage) {
|
|
2029
2034
|
i.blendFunc(i.DST_ALPHA, i.ZERO), i.useProgram(this._imgProgram), i.bindVertexArray(this._imgVao);
|
|
2030
2035
|
const o = this._imgUniforms;
|
|
2031
2036
|
i.uniform2f(o.uResolution, e.cssW, e.cssH), i.uniform4f(o.uFrame, e.frameLeft, e.frameTop, e.frameRight, e.frameBottom), i.uniform2f(o.uFrameSize, e.frameRight - e.frameLeft, e.frameBottom - e.frameTop), i.uniform2f(o.uImageSize, this._texImage.naturalWidth, this._texImage.naturalHeight), i.activeTexture(i.TEXTURE0), i.bindTexture(i.TEXTURE_2D, this._texture), i.uniform1i(o.uImage, 0), i.drawArrays(i.TRIANGLE_STRIP, 0, 4);
|
|
@@ -2043,11 +2048,11 @@ class Ce {
|
|
|
2043
2048
|
s.canvas.width = Math.round(e * r), s.canvas.height = Math.round(i * r), s.canvas.style.width = `${e}px`, s.canvas.style.height = `${i}px`, s.viewport(0, 0, s.canvas.width, s.canvas.height), this._appliedW = e, this._appliedH = i, this._appliedScale = r;
|
|
2044
2049
|
}
|
|
2045
2050
|
_staticBuffer(e) {
|
|
2046
|
-
const i = this._gl, r = i.createBuffer();
|
|
2051
|
+
const i = this._gl, r = N(i.createBuffer(), "buffer");
|
|
2047
2052
|
return i.bindBuffer(i.ARRAY_BUFFER, r), i.bufferData(i.ARRAY_BUFFER, new Float32Array(e), i.STATIC_DRAW), r;
|
|
2048
2053
|
}
|
|
2049
2054
|
_link(e, i) {
|
|
2050
|
-
const r = this._gl, s = this._compile(r.VERTEX_SHADER, e), o = this._compile(r.FRAGMENT_SHADER, i), a = r.createProgram();
|
|
2055
|
+
const r = this._gl, s = this._compile(r.VERTEX_SHADER, e), o = this._compile(r.FRAGMENT_SHADER, i), a = N(r.createProgram(), "program");
|
|
2051
2056
|
if (r.attachShader(a, s), r.attachShader(a, o), r.linkProgram(a), r.deleteShader(s), r.deleteShader(o), !r.getProgramParameter(a, r.LINK_STATUS)) {
|
|
2052
2057
|
const n = r.getProgramInfoLog(a);
|
|
2053
2058
|
throw r.deleteProgram(a), new Error(`DotGrid GL link failed: ${n}`);
|
|
@@ -2055,7 +2060,7 @@ class Ce {
|
|
|
2055
2060
|
return a;
|
|
2056
2061
|
}
|
|
2057
2062
|
_compile(e, i) {
|
|
2058
|
-
const r = this._gl, s = r.createShader(e);
|
|
2063
|
+
const r = this._gl, s = N(r.createShader(e), "shader");
|
|
2059
2064
|
if (r.shaderSource(s, i), r.compileShader(s), !r.getShaderParameter(s, r.COMPILE_STATUS)) {
|
|
2060
2065
|
const o = r.getShaderInfoLog(s);
|
|
2061
2066
|
throw r.deleteShader(s), new Error(`DotGrid GL compile failed: ${o}`);
|
|
@@ -2063,7 +2068,7 @@ class Ce {
|
|
|
2063
2068
|
return s;
|
|
2064
2069
|
}
|
|
2065
2070
|
}
|
|
2066
|
-
const
|
|
2071
|
+
const pr = 1200, fr = 800, mr = 1.5, tt = (t) => 1 - (1 - t) ** 3, _r = {
|
|
2067
2072
|
cellSize: 6,
|
|
2068
2073
|
dotRatio: 0.46,
|
|
2069
2074
|
sizeScale: 1,
|
|
@@ -2084,19 +2089,19 @@ const ur = 1200, dr = 800, pr = 1.5, et = (t) => 1 - (1 - t) ** 3, fr = {
|
|
|
2084
2089
|
shimEnterMs: 450,
|
|
2085
2090
|
shimExitMs: 450
|
|
2086
2091
|
};
|
|
2087
|
-
class
|
|
2092
|
+
class gr {
|
|
2088
2093
|
constructor(e, i) {
|
|
2089
|
-
this._refs = null, this._ctx = null, this._gl = null, this._glImageEl = null, this._glImageReady = !1, this._cfg = { ...
|
|
2094
|
+
this._refs = null, this._ctx = null, this._gl = null, this._glImageEl = null, this._glImageReady = !1, this._cfg = { ..._r }, this._sizeMul = 1, this._dotColor = "rgba(0, 0, 0, 0.16)", this._dotColorRGBA = [0, 0, 0, 0.16], this._w = 0, this._h = 0, this._cols = 0, this._rows = 0, this._offsetX = 0, this._offsetY = 0, this._epiRadius = 1, this._appliedScale = 0, this._clip = new Float32Array(0), this._env = 0, this._envFrom = 0, this._envTo = 0, this._envStart = 0, this._envDur = 0, this._envAnimating = !1, this._shimMix = 0, this._shimFrom = 0, this._shimTo = 0, this._shimStart = 0, this._shimDur = 0, this._shimAnimating = !1, this._exitPending = !1, this._prevShim = !1, this._opacityManual = !1, this._hiddenImage = null, this._rafId = null, this._lastTime = 0, this._state = { shimmering: !1, empty: !0, generating: !1 }, this._epis = [], this._onThemeChange = () => {
|
|
2090
2095
|
this.refreshColor();
|
|
2091
2096
|
}, this._rectCache = null, this._glEpis = new Float32Array(16), this._tick = (r) => {
|
|
2092
2097
|
const s = this._lastTime ? Math.min(64, r - this._lastTime) : 16;
|
|
2093
2098
|
if (this._lastTime = r, this._rectCache = this._frameRect(), this._envAnimating) {
|
|
2094
2099
|
const a = Math.min(1, (r - this._envStart) / this._envDur);
|
|
2095
|
-
this._env = this._envFrom + (this._envTo - this._envFrom) *
|
|
2100
|
+
this._env = this._envFrom + (this._envTo - this._envFrom) * tt(a), a >= 1 && (this._env = this._envTo, this._envAnimating = !1);
|
|
2096
2101
|
}
|
|
2097
2102
|
if (this._shimAnimating) {
|
|
2098
2103
|
const a = Math.min(1, (r - this._shimStart) / this._shimDur);
|
|
2099
|
-
this._shimMix = this._shimFrom + (this._shimTo - this._shimFrom) *
|
|
2104
|
+
this._shimMix = this._shimFrom + (this._shimTo - this._shimFrom) * tt(a), a >= 1 && (this._shimMix = this._shimTo, this._shimAnimating = !1);
|
|
2100
2105
|
}
|
|
2101
2106
|
this._state.generating && !this._reduceMotion && this._moveEpicenters(s);
|
|
2102
2107
|
const o = this._followFrame(s);
|
|
@@ -2116,11 +2121,11 @@ class mr {
|
|
|
2116
2121
|
* proportional, >1 exaggerates, <0 inverts). Always positive, so it never
|
|
2117
2122
|
* produces a negative radius/speed however far it's pushed. */
|
|
2118
2123
|
_computeSizeMul() {
|
|
2119
|
-
return this._w <= 0 || this._h <= 0 ? 1 : Math.sqrt(this._w * this._h / (
|
|
2124
|
+
return this._w <= 0 || this._h <= 0 ? 1 : Math.sqrt(this._w * this._h / (pr * fr)) ** this._cfg.sizeScale;
|
|
2120
2125
|
}
|
|
2121
2126
|
/** Wire the painter to the canvas's rendered elements. */
|
|
2122
2127
|
attach(e) {
|
|
2123
|
-
if (this._refs = e, this._cfg.useWebgl !== !1 && (this._gl =
|
|
2128
|
+
if (this._refs = e, this._cfg.useWebgl !== !1 && (this._gl = $e.create(e.surface)), this._gl || (this._ctx = e.surface.getContext("2d")), !!this._canDraw) {
|
|
2124
2129
|
if (this._readDotColor(), typeof ResizeObserver == "function" && (this._resizeObserver = new ResizeObserver(() => {
|
|
2125
2130
|
this._resize(), this.sync(this._state);
|
|
2126
2131
|
}), this._resizeObserver.observe(e.viewport), this._frameObserver = new ResizeObserver(() => this._ensureLoop()), this._frameObserver.observe(e.frame)), typeof window < "u" && typeof window.matchMedia == "function" && (this._schemeMql = window.matchMedia("(prefers-color-scheme: dark)"), this._schemeMql.addEventListener("change", this._onThemeChange)), typeof MutationObserver == "function" && typeof document < "u") {
|
|
@@ -2196,7 +2201,7 @@ class mr {
|
|
|
2196
2201
|
if (!i) return this._dotColorRGBA;
|
|
2197
2202
|
i.clearRect(0, 0, 1, 1), i.fillStyle = "#000", i.fillStyle = e, i.fillRect(0, 0, 1, 1);
|
|
2198
2203
|
const r = i.getImageData(0, 0, 1, 1).data;
|
|
2199
|
-
return [r[0] / 255, r[1] / 255, r[2] / 255, r[3] / 255];
|
|
2204
|
+
return [(r[0] ?? 0) / 255, (r[1] ?? 0) / 255, (r[2] ?? 0) / 255, (r[3] ?? 0) / 255];
|
|
2200
2205
|
}
|
|
2201
2206
|
_hasImage() {
|
|
2202
2207
|
var i;
|
|
@@ -2274,7 +2279,7 @@ class mr {
|
|
|
2274
2279
|
* {@link MAX_ANIMATED_DPR} so per-frame raster stays cheap on hi-dpi. */
|
|
2275
2280
|
_scale(e = !1) {
|
|
2276
2281
|
const i = Math.min(window.devicePixelRatio || 1, this._cfg.maxDpr);
|
|
2277
|
-
return e ? Math.min(i,
|
|
2282
|
+
return e ? Math.min(i, mr) : i;
|
|
2278
2283
|
}
|
|
2279
2284
|
/** Size the backing store to `scale`× the viewport. Note: setting width/height
|
|
2280
2285
|
* clears the canvas and resets the context, so the transform is re-applied. */
|
|
@@ -2462,16 +2467,16 @@ class mr {
|
|
|
2462
2467
|
this._exitPending && this._hasImage() && (this._exitPending = !1, this._env = 1, this._startEnv(0, this._cfg.exitMs));
|
|
2463
2468
|
}
|
|
2464
2469
|
}
|
|
2465
|
-
const
|
|
2466
|
-
var
|
|
2467
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2470
|
+
const vr = ":host{display:block;width:100%;height:100%;container-type:inline-size}.canvas{position:relative;width:100%;height:100%;min-height:240px;overflow:hidden}.canvas__bg{position:absolute;top:0;right:0;bottom:0;left:0;background:var(--uc-ai-background)}.canvas__viewport{position:absolute;top:20px;right:20px;bottom:20px;left:20px;display:grid;place-items:center;pointer-events:none}.canvas__frame{position:relative;overflow:hidden}.canvas.is-ready .canvas__frame{transition:width .46s var(--uc-ai-ease-in-out, ease),height .46s var(--uc-ai-ease-in-out, ease)}.canvas__image{position:relative;z-index:1;width:100%;height:100%;display:block;object-fit:cover;transition:opacity .3s var(--uc-ai-ease-out, ease)}.canvas__under{position:absolute;top:0;right:0;bottom:0;left:0;z-index:0;width:100%;height:100%;display:block;object-fit:cover}.dot-grid{position:absolute;top:0;right:0;bottom:0;left:0;pointer-events:none;opacity:0;color:var(--uc-ai-dot-grid-color, color-mix(in srgb, currentColor 15%, transparent));transition:opacity .2s ease}.canvas.is-empty .dot-grid,.canvas.is-loading .dot-grid{opacity:1}.preload{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.layer.full{position:absolute;top:0;right:0;bottom:0;left:0;width:100%;height:100%;object-fit:contain;z-index:4}.fullscreen-btn{position:absolute;top:12px;right:12px;z-index:5;display:grid;place-items:center;width:var(--uc-ai-button-size, 32px);height:var(--uc-ai-button-size, 32px);padding:0;border:0;border-radius:var(--uc-ai-radius-button, 8px);background:color-mix(in oklch,var(--uc-ai-background) 75%,transparent);backdrop-filter:blur(4px);-webkit-backdrop-filter:blur(4px);color:var(--uc-ai-foreground);cursor:pointer;opacity:0;transition:opacity var(--uc-ai-transition, .2s ease),background var(--uc-ai-transition, .2s ease)}.fullscreen-btn svg{width:18px;height:18px}.canvas:hover .fullscreen-btn,.fullscreen-btn:focus-visible{opacity:1}.fullscreen-btn:hover{background:var(--uc-ai-background)}@media(hover:none){.fullscreen-btn{opacity:1}}.canvas:fullscreen{background:#000}.canvas:fullscreen .canvas__bg{background:#000}.error-state{position:absolute;top:0;right:0;bottom:0;left:0;display:grid;place-items:center;padding:16px;text-align:center;color:var(--uc-ai-muted-foreground);font-size:.875em;z-index:3}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}@media(prefers-reduced-motion:reduce){.canvas__viewport,.canvas__frame,.canvas__image,.fullscreen-btn{transition:none}}";
|
|
2471
|
+
var br = Object.defineProperty, yr = Object.getOwnPropertyDescriptor, y = (t, e, i, r) => {
|
|
2472
|
+
for (var s = r > 1 ? void 0 : r ? yr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
2468
2473
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
2469
|
-
return r && s &&
|
|
2474
|
+
return r && s && br(e, i, s), s;
|
|
2470
2475
|
};
|
|
2471
|
-
const
|
|
2472
|
-
let g = class extends
|
|
2476
|
+
const wr = 3 / 2, xr = 70;
|
|
2477
|
+
let g = class extends G {
|
|
2473
2478
|
constructor() {
|
|
2474
|
-
super(...arguments), this.url = null, this.ratio = null, this.naturalRatio = null, this.busy = !1, this.alt = "", this.busyLabel = "", this.errorLabel = "", this.fullscreenLabel = "", this.exitFullscreenLabel = "", this.fullsizeUrl = null, this._displayedUrl = null, this._fadingUrl = null, this._failed = !1, this._frameReady = !1, this._fullscreen = !1, this._dotGrid = new
|
|
2479
|
+
super(...arguments), this.url = null, this.ratio = null, this.naturalRatio = null, this.busy = !1, this.alt = "", this.busyLabel = "", this.errorLabel = "", this.fullscreenLabel = "", this.exitFullscreenLabel = "", this.fullsizeUrl = null, this._displayedUrl = null, this._fadingUrl = null, this._failed = !1, this._frameReady = !1, this._fullscreen = !1, this._dotGrid = new gr(this), this._switchCovering = !1, this._seenUrls = /* @__PURE__ */ new Set(), this._instantSwap = !1, this._onVisibilityChange = () => {
|
|
2475
2480
|
document.visibilityState !== "visible" || this.busy || !this._displayedUrl || (this._clearCoverTimer(), this._switchCovering = !1, this._dotGrid.settle());
|
|
2476
2481
|
}, this._preloadedFullsizeUrl = null, this._onFullscreenKeydown = (t) => {
|
|
2477
2482
|
t.key === "Escape" && document.fullscreenElement && (t.preventDefault(), t.stopPropagation(), document.exitFullscreen());
|
|
@@ -2535,7 +2540,7 @@ let g = class extends j {
|
|
|
2535
2540
|
}
|
|
2536
2541
|
this._instantSwap = !1, !(this._switchCovering || this._coverTimer != null) && (this._coverTimer = window.setTimeout(() => {
|
|
2537
2542
|
this._coverTimer = void 0, this.url != null && this.url !== this._displayedUrl && !this._failed && !this.busy && !this._switchCovering && (this._switchCovering = !0, this._syncGrid());
|
|
2538
|
-
},
|
|
2543
|
+
}, xr));
|
|
2539
2544
|
}
|
|
2540
2545
|
_clearCoverTimer() {
|
|
2541
2546
|
this._coverTimer != null && (clearTimeout(this._coverTimer), this._coverTimer = void 0);
|
|
@@ -2548,7 +2553,7 @@ let g = class extends j {
|
|
|
2548
2553
|
if (this.ratio && this.ratio > 0) return this.ratio;
|
|
2549
2554
|
if (this.naturalRatio && this.naturalRatio > 0) return this.naturalRatio;
|
|
2550
2555
|
const t = this._imageEl;
|
|
2551
|
-
return t && t.naturalWidth > 0 && t.naturalHeight > 0 ? t.naturalWidth / t.naturalHeight :
|
|
2556
|
+
return t && t.naturalWidth > 0 && t.naturalHeight > 0 ? t.naturalWidth / t.naturalHeight : wr;
|
|
2552
2557
|
}
|
|
2553
2558
|
/** Size the frame to the largest box of the chosen ratio that fits the viewport. */
|
|
2554
2559
|
_updateFrame() {
|
|
@@ -2626,7 +2631,7 @@ let g = class extends j {
|
|
|
2626
2631
|
this._fullscreen && this.fullsizeUrl ? f`<img class="layer full" src="${this.fullsizeUrl}" alt="${this.alt || "AI image"}" decoding="async" />` : v}
|
|
2627
2632
|
${t ? f`<img
|
|
2628
2633
|
class="preload"
|
|
2629
|
-
src="${this.url}"
|
|
2634
|
+
src="${wt(this.url ?? void 0)}"
|
|
2630
2635
|
alt=""
|
|
2631
2636
|
aria-hidden="true"
|
|
2632
2637
|
decoding="async"
|
|
@@ -2645,7 +2650,7 @@ let g = class extends j {
|
|
|
2645
2650
|
@focus=${this._preloadFullsize}
|
|
2646
2651
|
@click=${this._toggleFullscreen}
|
|
2647
2652
|
>
|
|
2648
|
-
${
|
|
2653
|
+
${ie(this._fullscreen ? ji : Bi)}
|
|
2649
2654
|
</button>
|
|
2650
2655
|
` : v}
|
|
2651
2656
|
<span class="sr-only" role="status" aria-live="polite">${this.busy ? this.busyLabel : ""}</span>
|
|
@@ -2653,7 +2658,7 @@ let g = class extends j {
|
|
|
2653
2658
|
`;
|
|
2654
2659
|
}
|
|
2655
2660
|
};
|
|
2656
|
-
g.styles =
|
|
2661
|
+
g.styles = j(vr);
|
|
2657
2662
|
y([
|
|
2658
2663
|
c()
|
|
2659
2664
|
], g.prototype, "url", 2);
|
|
@@ -2718,15 +2723,15 @@ y([
|
|
|
2718
2723
|
F(".dot-grid")
|
|
2719
2724
|
], g.prototype, "_dotGridEl", 2);
|
|
2720
2725
|
g = y([
|
|
2721
|
-
|
|
2726
|
+
H("uc-ai-canvas")
|
|
2722
2727
|
], g);
|
|
2723
|
-
const
|
|
2724
|
-
var
|
|
2725
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2728
|
+
const kr = ":host{display:block;container-type:inline-size}.footer{display:flex;justify-content:space-between;align-items:center;gap:8px;padding:var(--uc-ai-padding);background:transparent}.btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:var(--uc-ai-button-size);padding:0 14px;border:0;border-radius:var(--uc-ai-radius-button);font-family:inherit;font-size:14px;font-weight:500;cursor:pointer;transition:background .15s ease,filter .15s ease,transform .14s var(--uc-ai-ease-out, ease)}.btn:active{transform:scale(.97)}.btn--ghost{background:var(--uc-ai-secondary);color:var(--uc-ai-secondary-foreground)}.btn--primary{background:var(--uc-ai-primary);color:var(--uc-ai-primary-foreground)}@media(hover:hover)and (pointer:fine){.btn--ghost:hover{background:var(--uc-ai-secondary-hover)}.btn--primary:hover{background:var(--uc-ai-primary-hover)}}.btn--primary:disabled{opacity:.5;cursor:not-allowed;background:var(--uc-ai-primary)}.btn svg{width:14px;height:14px}@media(prefers-reduced-motion:reduce){.btn{transition-property:background,filter}.btn:active{transform:none}}";
|
|
2729
|
+
var Er = Object.defineProperty, Rr = Object.getOwnPropertyDescriptor, se = (t, e, i, r) => {
|
|
2730
|
+
for (var s = r > 1 ? void 0 : r ? Rr(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
2726
2731
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
2727
|
-
return r && s &&
|
|
2732
|
+
return r && s && Er(e, i, s), s;
|
|
2728
2733
|
};
|
|
2729
|
-
let
|
|
2734
|
+
let K = class extends G {
|
|
2730
2735
|
constructor() {
|
|
2731
2736
|
super(...arguments), this.cancelLabel = "", this.primaryLabel = "", this.primaryDisabled = !1;
|
|
2732
2737
|
}
|
|
@@ -2754,39 +2759,39 @@ let q = class extends j {
|
|
|
2754
2759
|
`;
|
|
2755
2760
|
}
|
|
2756
2761
|
};
|
|
2757
|
-
|
|
2758
|
-
|
|
2762
|
+
K.styles = j(kr);
|
|
2763
|
+
se([
|
|
2759
2764
|
c({ attribute: "cancel-label" })
|
|
2760
|
-
],
|
|
2761
|
-
|
|
2765
|
+
], K.prototype, "cancelLabel", 2);
|
|
2766
|
+
se([
|
|
2762
2767
|
c({ attribute: "primary-label" })
|
|
2763
|
-
],
|
|
2764
|
-
|
|
2768
|
+
], K.prototype, "primaryLabel", 2);
|
|
2769
|
+
se([
|
|
2765
2770
|
c({ type: Boolean, attribute: "primary-disabled" })
|
|
2766
|
-
],
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
],
|
|
2770
|
-
const
|
|
2771
|
-
var
|
|
2772
|
-
for (var s = r > 1 ? void 0 : r ?
|
|
2771
|
+
], K.prototype, "primaryDisabled", 2);
|
|
2772
|
+
K = se([
|
|
2773
|
+
H("uc-ai-footer")
|
|
2774
|
+
], K);
|
|
2775
|
+
const Sr = ":host{--uc-ai-foreground: light-dark(#181818, #e1e1e1);--uc-ai-background: light-dark(#ffffff, #1b1b1b);--uc-ai-floating: var(--uc-floating, light-dark(#ffffff, #242424));--uc-ai-floating-border: var(--uc-floating-border, light-dark(transparent, rgba(255, 255, 255, .05)));--uc-ai-muted: light-dark(#f5f5f5, #242424);--uc-ai-muted-foreground: light-dark(#717171, #989898);--uc-ai-primary: light-dark(#174bd7, #579aff);--uc-ai-primary-hover: light-dark(#1141c0, #4a8aef);--uc-ai-primary-foreground: light-dark(#ffffff, #000000);--uc-ai-primary-transparent: light-dark(rgba(23, 75, 215, .07), rgba(87, 154, 255, .07));--uc-ai-secondary: light-dark(rgba(24, 24, 24, .05), rgba(225, 225, 225, .07));--uc-ai-secondary-hover: light-dark(rgba(24, 24, 24, .08), rgba(225, 225, 225, .1));--uc-ai-secondary-foreground: light-dark(#181818, #e1e1e1);--uc-ai-border: light-dark(#e4e4e8, #3d3d3d);--uc-ai-shadow-color: light-dark(rgba(24, 24, 24, .18), rgba(0, 0, 0, .5));--uc-ai-dialog-shadow: 0 6px 20px light-dark(rgba(0, 0, 0, .1), rgba(0, 0, 0, .25));--uc-ai-composer-shadow: 0 4px 14px light-dark(rgba(0, 0, 0, .18), rgba(0, 0, 0, .34)), 0 0 26px light-dark(rgba(0, 0, 0, .2), rgba(0, 0, 0, .42));--uc-ai-composer-shadow-peek: 0 2px 10px light-dark(rgba(0, 0, 0, .16), rgba(0, 0, 0, .34));--uc-ai-composer-radius: var(--uc-ai-radius-frame);--uc-ai-composer-radius-top: var(--uc-ai-composer-radius);--uc-ai-composer-radius-bottom: var(--uc-ai-composer-radius);--uc-ai-destructive: #d8473e;--uc-ai-destructive-foreground: light-dark(#b3261e, #ff9d96);--uc-ai-radius: 8px;--uc-ai-radius-button: var(--uc-ai-radius);--uc-ai-radius-input: calc(var(--uc-ai-radius) * 1.5);--uc-ai-radius-card: calc(var(--uc-ai-radius) * 2);--uc-ai-radius-frame: calc(var(--uc-ai-radius) * 2.25);--uc-ai-padding: 10px;--uc-ai-button-size: 32px;--uc-ai-font-family: system-ui, -apple-system, sans-serif;--uc-ai-font-size: 14px;--uc-ai-transition: .2s ease;--uc-ai-ease-out: cubic-bezier(.23, 1, .32, 1);--uc-ai-ease-in-out: cubic-bezier(.77, 0, .175, 1);--uc-ai-dot-grid-color: light-dark(rgba(0, 0, 0, .21), rgba(255, 255, 255, .1));--uc-ai-prompt-max-lines: 6;--uc-ai-prompt-max-height: calc(var(--uc-ai-prompt-max-lines) * 1.5em + 10px);display:block;width:100%;height:100%;font-family:var(--uc-ai-font-family);font-size:var(--uc-ai-font-size);color:var(--uc-ai-foreground);color-scheme:light dark;container-type:inline-size}:host([hidden]){display:none}:host(.uc-light),:host-context(.uc-light){color-scheme:light}:host(.uc-dark),:host-context(.uc-dark){color-scheme:dark}.shell{display:flex;flex-direction:column;background:var(--uc-ai-background);border-radius:var(--uc-ai-radius-card);overflow:hidden;box-shadow:var(--uc-ai-dialog-shadow);height:100%}.stage{position:relative;flex:1;min-height:360px;overflow:hidden;background:var(--uc-ai-background)}uc-ai-canvas{position:absolute;top:0;right:0;bottom:0;left:0}.composer{width:700px;max-width:calc(100% - 40px)}.composer__content{display:flex;flex-direction:column;gap:14px;align-items:center}.composer--overlay{position:absolute;left:50%;transform:translate(-50%);z-index:5;transition:transform .48s var(--uc-ai-ease-out)}.composer--overlay-bottom{bottom:32px}.composer--overlay-top{top:32px}.composer--docked{margin-inline:auto;padding:14px 20px;position:relative;z-index:1}.composer--docked-bottom{padding-top:8px}.composer--docked-top{padding-bottom:8px}.history-pinned{position:absolute;left:50%;transform:translate(-50%);width:700px;max-width:calc(100% - 40px);z-index:5}.history-pinned--canvas-top{top:20px}.history-pinned--canvas-bottom{bottom:20px}.history-pinned--docked.history-pinned--canvas-top{top:6px}.history-pinned--docked.history-pinned--canvas-bottom{bottom:6px}.dock-hotzone{position:absolute;left:0;right:0;height:100px;z-index:4;pointer-events:none}.dock-hotzone--bottom{bottom:0}.dock-hotzone--top{top:0}:host([composer-auto-hide]) .stage:not(.is-empty) .dock-hotzone{pointer-events:auto}.composer-fade{position:absolute;left:0;right:0;height:26px;z-index:6;pointer-events:none;opacity:0;transition:opacity .3s var(--uc-ai-ease-out)}.composer-fade--bottom{bottom:0;background:linear-gradient(to top,var(--uc-ai-background) 0,var(--uc-ai-background) 8px,transparent)}.composer-fade--top{top:0;background:linear-gradient(to bottom,var(--uc-ai-background) 0,var(--uc-ai-background) 8px,transparent)}:host([composer-auto-hide]) .stage:not(.is-empty) .composer-fade{opacity:1}:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone:hover) .composer-fade,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:hover) .composer-fade,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:focus-within) .composer-fade{opacity:0}:host([composer-auto-hide]) .stage:not(.is-empty) .composer--overlay-bottom{transform:translate(-50%,calc(100% + 4px))}:host([composer-auto-hide]) .stage:not(.is-empty) .composer--overlay-top{transform:translate(-50%,calc(-100% - 4px))}:host([composer-auto-hide]) .stage:not(.is-empty):not(:has(.composer--overlay:hover)):not(:has(.composer--overlay:focus-within)):not(:has(.dock-hotzone:hover)) .composer--overlay{--uc-ai-composer-shadow: var(--uc-ai-composer-shadow-peek)}:host([composer-auto-hide]) .stage:not(.is-empty):not(:has(.composer--overlay:hover)):not(:has(.composer--overlay:focus-within)):not(:has(.dock-hotzone:hover)) .composer--overlay-bottom{--uc-ai-composer-radius-bottom: 0px}:host([composer-auto-hide]) .stage:not(.is-empty):not(:has(.composer--overlay:hover)):not(:has(.composer--overlay:focus-within)):not(:has(.dock-hotzone:hover)) .composer--overlay-top{--uc-ai-composer-radius-top: 0px}:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone--bottom:hover) .composer--overlay-bottom,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-bottom:hover) .composer--overlay-bottom,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-bottom:focus-within) .composer--overlay-bottom,:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone--top:hover) .composer--overlay-top,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-top:hover) .composer--overlay-top,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay-top:focus-within) .composer--overlay-top{transform:translate(-50%)}:host([composer-auto-hide]) .stage:not(.is-empty):has(.dock-hotzone:hover) .dock-hotzone,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:hover) .dock-hotzone,:host([composer-auto-hide]) .stage:not(.is-empty):has(.composer--overlay:focus-within) .dock-hotzone{height:320px}:host([composer-auto-hide]) .shell--has-image .composer--docked{margin-block:8px 14px;position:relative}:host([composer-auto-hide]) .shell--has-image .composer--docked .composer__content{position:relative;transition:transform .5s var(--uc-ai-ease-out)}:host([composer-auto-hide]) .shell--has-image .composer--docked .composer__content uc-ai-history{position:absolute;left:0;right:0}:host([composer-auto-hide]) .shell--has-image .composer--docked-bottom .composer__content uc-ai-history{bottom:calc(100% + 14px)}:host([composer-auto-hide]) .shell--has-image .composer--docked-top .composer__content uc-ai-history{top:calc(100% + 14px)}:host([composer-auto-hide]) .shell--has-image .composer--docked-bottom{clip-path:inset(-200px -200px 0 -200px)}:host([composer-auto-hide]) .shell--has-image .composer--docked-top{clip-path:inset(0 -200px -200px -200px)}:host([composer-auto-hide]) .shell--has-image:not(:has(.composer--docked:hover)):not(:has(.composer--docked:focus-within)) .composer--docked{--uc-ai-composer-shadow: var(--uc-ai-composer-shadow-peek)}:host([composer-auto-hide]) .shell--has-image:not(:has(.composer--docked:hover)):not(:has(.composer--docked:focus-within)) .composer--docked-bottom .composer__content{transform:translateY(calc(100% - 22px))}:host([composer-auto-hide]) .shell--has-image:not(:has(.composer--docked:hover)):not(:has(.composer--docked:focus-within)) .composer--docked-top .composer__content{transform:translateY(calc(-100% + 22px))}uc-ai-history,uc-ai-prompt-row{width:100%}.error-box{position:absolute;top:0;right:0;bottom:0;left:0;z-index:6;display:grid;place-items:center;padding:20px;pointer-events:none}.error-box__card{pointer-events:auto;max-width:75%;padding:10px 15px;background:var(--uc-ai-floating, var(--uc-ai-background));border:1px solid var(--uc-ai-floating-border, transparent);border-radius:var(--uc-ai-radius-card);box-shadow:var(--uc-ai-dialog-shadow);color:var(--uc-ai-destructive-foreground);font-size:14px;line-height:1.4;text-align:center}";
|
|
2776
|
+
var Cr = Object.defineProperty, $r = Object.getOwnPropertyDescriptor, m = (t, e, i, r) => {
|
|
2777
|
+
for (var s = r > 1 ? void 0 : r ? $r(e, i) : e, o = t.length - 1, a; o >= 0; o--)
|
|
2773
2778
|
(a = t[o]) && (s = (r ? a(e, i, s) : a(s)) || s);
|
|
2774
|
-
return r && s &&
|
|
2779
|
+
return r && s && Cr(e, i, s), s;
|
|
2775
2780
|
};
|
|
2776
|
-
const
|
|
2781
|
+
const Ar = ["top", "bottom"], Ur = ["full", "available"], Tr = [
|
|
2777
2782
|
"composer-above",
|
|
2778
2783
|
"composer-below",
|
|
2779
2784
|
"canvas-top",
|
|
2780
2785
|
"canvas-bottom"
|
|
2781
2786
|
];
|
|
2782
|
-
let d = class extends
|
|
2787
|
+
let d = class extends G {
|
|
2783
2788
|
constructor() {
|
|
2784
|
-
super(...arguments), this.sourceUuid = null, this.pubkey = "", this.aspectRatios = null, this.localeName = "en", this.localeDefinitionOverride = {}, this.presetsOnly = !1, this.presets = {}, this.composerPlacement = "bottom", this.canvasFit = "available", this.historyPlacement = "composer-above", this.composerAutoHide = !1, this.toolbarPlacement = "bottom", this._prompt = "", this._selectedRatio = null, this._inputUrl = null, this._gen = new
|
|
2789
|
+
super(...arguments), this.sourceUuid = null, this.pubkey = "", this.aspectRatios = null, this.localeName = "en", this.localeDefinitionOverride = {}, this.presetsOnly = !1, this.presets = {}, this.composerPlacement = "bottom", this.canvasFit = "available", this.historyPlacement = "composer-above", this.composerAutoHide = !1, this.toolbarPlacement = "bottom", this._prompt = "", this._selectedRatio = null, this._inputUrl = null, this._gen = new xi(this), this._history = new Oi(this), this._secure = new ft(this), this._localeStrings = B, this._localeToken = 0, this._lastPreviewUrl = null, this._ratioOptionsCache = /* @__PURE__ */ new Map(), this._labelForOption = (t) => t.labelKey ? this._l(t.labelKey) : "";
|
|
2785
2790
|
}
|
|
2786
2791
|
/** @internal */
|
|
2787
2792
|
willUpdate(t) {
|
|
2788
2793
|
const e = t.has("provider") || t.has("pubkey") || t.has("baseUrl") || t.has("cdnCname") || t.has("cdnCnamePrefixed");
|
|
2789
|
-
e && (this._provider = this.provider ?? (this.pubkey ? new
|
|
2794
|
+
e && (this._provider = this.provider ?? (this.pubkey ? new wi({
|
|
2790
2795
|
publicKey: this.pubkey,
|
|
2791
2796
|
baseUrl: this.baseUrl,
|
|
2792
2797
|
cdnBaseUrl: this.cdnCname,
|
|
@@ -2808,10 +2813,10 @@ let d = class extends j {
|
|
|
2808
2813
|
(e || i) && this._resolveInputUrl(), (e || i) && this._resolveSourceFileInfo();
|
|
2809
2814
|
const r = this._mode;
|
|
2810
2815
|
if (r !== this._lastMode)
|
|
2811
|
-
this._lastMode = r, this._selectedRatio = r === "edit" ?
|
|
2816
|
+
this._lastMode = r, this._selectedRatio = r === "edit" ? V : this._defaultGenerateRatio();
|
|
2812
2817
|
else if (t.has("aspectRatios")) {
|
|
2813
2818
|
const s = this._selectedRatio;
|
|
2814
|
-
O(s) && !this._standardRatios().some((o) =>
|
|
2819
|
+
O(s) && !this._standardRatios().some((o) => fe(o, s)) && (this._selectedRatio = this._defaultGenerateRatio());
|
|
2815
2820
|
}
|
|
2816
2821
|
t.has("aspectRatios") && this._ratioOptionsCache.clear(), (t.has("localeName") || t.has("localeDefinitionOverride")) && this._resolveLocale();
|
|
2817
2822
|
}
|
|
@@ -2819,19 +2824,19 @@ let d = class extends j {
|
|
|
2819
2824
|
async _resolveLocale() {
|
|
2820
2825
|
var s, o;
|
|
2821
2826
|
const t = this.localeName || "en", e = ++this._localeToken;
|
|
2822
|
-
let i =
|
|
2827
|
+
let i = B;
|
|
2823
2828
|
if (t !== "en")
|
|
2824
2829
|
try {
|
|
2825
|
-
i = await ((s =
|
|
2830
|
+
i = await ((s = ue[t]) == null ? void 0 : s.call(ue)) ?? B;
|
|
2826
2831
|
} catch {
|
|
2827
|
-
i =
|
|
2832
|
+
i = B;
|
|
2828
2833
|
}
|
|
2829
2834
|
if (e !== this._localeToken) return;
|
|
2830
2835
|
const r = (o = this.localeDefinitionOverride) == null ? void 0 : o[t];
|
|
2831
2836
|
this._localeStrings = r ? { ...i, ...r } : i;
|
|
2832
2837
|
}
|
|
2833
2838
|
_l(t) {
|
|
2834
|
-
return
|
|
2839
|
+
return Ri(t, this._localeStrings);
|
|
2835
2840
|
}
|
|
2836
2841
|
/** Friendly message for the current failure: the per-`error_code` string
|
|
2837
2842
|
* (`ai-enhancer-error-<code>`, overridable via the locale) when one is
|
|
@@ -2839,7 +2844,7 @@ let d = class extends j {
|
|
|
2839
2844
|
_errorMessage() {
|
|
2840
2845
|
const t = this._gen.errorCode;
|
|
2841
2846
|
if (t) {
|
|
2842
|
-
const e = `ai-enhancer-error-${t}`, i = this._localeStrings[e] ??
|
|
2847
|
+
const e = `ai-enhancer-error-${t}`, i = this._localeStrings[e] ?? B[e];
|
|
2843
2848
|
if (i) return i;
|
|
2844
2849
|
}
|
|
2845
2850
|
return this._l("ai-enhancer-error");
|
|
@@ -2916,7 +2921,7 @@ let d = class extends j {
|
|
|
2916
2921
|
*/
|
|
2917
2922
|
get _sourceEntry() {
|
|
2918
2923
|
const t = this._sourceUuid, e = this._effectiveSourceFileInfo, i = this._inputUrl;
|
|
2919
|
-
return !t || !i || !e ? null : { id: t, prompt: "", mode: "edit", url: i, file: e, ratio:
|
|
2924
|
+
return !t || !i || !e ? null : { id: t, prompt: "", mode: "edit", url: i, file: e, ratio: V };
|
|
2920
2925
|
}
|
|
2921
2926
|
/** Strip entries: the generated results (newest-first) plus the original source
|
|
2922
2927
|
* appended as the base (oldest) when editing. */
|
|
@@ -2939,7 +2944,7 @@ let d = class extends j {
|
|
|
2939
2944
|
const t = this._displayUrl;
|
|
2940
2945
|
if (!t)
|
|
2941
2946
|
return this._lastPreviewUrl = null, null;
|
|
2942
|
-
const e = this._secure.resolve(
|
|
2947
|
+
const e = this._secure.resolve(Ti(t, this.clientWidth || 1024));
|
|
2943
2948
|
return e != null && (this._lastPreviewUrl = e), this._lastPreviewUrl;
|
|
2944
2949
|
}
|
|
2945
2950
|
/** Full-resolution rendition for fullscreen, secure-delivery-resolved. */
|
|
@@ -2948,8 +2953,8 @@ let d = class extends j {
|
|
|
2948
2953
|
}
|
|
2949
2954
|
/** The configured (or popular) standard ratios, validated. */
|
|
2950
2955
|
_standardRatios() {
|
|
2951
|
-
const t = (this.aspectRatios ?? []).filter(
|
|
2952
|
-
return t.length > 0 ? t : [...
|
|
2956
|
+
const t = (this.aspectRatios ?? []).filter(we);
|
|
2957
|
+
return t.length > 0 ? t : [...xt];
|
|
2953
2958
|
}
|
|
2954
2959
|
/**
|
|
2955
2960
|
* The ratio the generate flow starts on: the prototype's landscape default
|
|
@@ -2958,12 +2963,12 @@ let d = class extends j {
|
|
|
2958
2963
|
*/
|
|
2959
2964
|
_defaultGenerateRatio() {
|
|
2960
2965
|
const t = this._standardRatios();
|
|
2961
|
-
return t.find((e) =>
|
|
2966
|
+
return t.find((e) => fe(e, kt)) ?? t[0] ?? null;
|
|
2962
2967
|
}
|
|
2963
2968
|
_ratioOptions(t) {
|
|
2964
2969
|
const e = this._ratioOptionsCache.get(t);
|
|
2965
2970
|
if (e) return e;
|
|
2966
|
-
const i = this._standardRatios().map(
|
|
2971
|
+
const i = this._standardRatios().map($t), r = t === "edit" ? [{ value: V, labelKey: "ai-enhancer-aspect-original" }, ...i] : i;
|
|
2967
2972
|
return this._ratioOptionsCache.set(t, r), r;
|
|
2968
2973
|
}
|
|
2969
2974
|
/**
|
|
@@ -3080,15 +3085,15 @@ let d = class extends j {
|
|
|
3080
3085
|
}
|
|
3081
3086
|
/** @internal */
|
|
3082
3087
|
render() {
|
|
3083
|
-
var
|
|
3084
|
-
const t = this._mode, e = t === "edit" && !this.sourceUuid && !this.sourceFileInfo, i =
|
|
3088
|
+
var Te, Fe;
|
|
3089
|
+
const t = this._mode, e = t === "edit" && !this.sourceUuid && !this.sourceFileInfo, i = me[t].placeholderKey, r = ((Te = this.presets) == null ? void 0 : Te[t]) ?? me[t].presets, s = this._gen.busy || !this._gen.result, o = this._ratioOptions(t), a = this._displayUrl != null, n = O(this._selectedRatio) ? this._selectedRatio[0] / this._selectedRatio[1] : null, l = {
|
|
3085
3090
|
stage: !0,
|
|
3086
3091
|
"is-empty": !a
|
|
3087
|
-
}, h =
|
|
3092
|
+
}, h = Ar.includes(this.composerPlacement) ? this.composerPlacement : "bottom", u = (Ur.includes(this.canvasFit) ? this.canvasFit : "available") === "full", _ = !u, x = `${u ? "overlay" : "docked"}-${h}`, w = Tr.includes(this.historyPlacement) ? this.historyPlacement : "composer-above", $ = w === "composer-above" || w === "composer-below", R = (u || _ && this.composerAutoHide) && $, I = w === "canvas-top" ? "top" : w === "canvas-bottom" ? "bottom" : h, W = this._historyEntries, X = W.length > 0 || e, oe = X ? f`
|
|
3088
3093
|
<uc-ai-history
|
|
3089
3094
|
.busy=${this._gen.busy}
|
|
3090
|
-
.entries=${
|
|
3091
|
-
.selectedUuid=${((
|
|
3095
|
+
.entries=${W}
|
|
3096
|
+
.selectedUuid=${((Fe = this._gen.result) == null ? void 0 : Fe.uuid) ?? this._sourceUuid}
|
|
3092
3097
|
?show-start-over=${e}
|
|
3093
3098
|
start-over-label="${this._l("ai-enhancer-start-over")}"
|
|
3094
3099
|
list-label="${this._l("ai-enhancer-history-title")}"
|
|
@@ -3096,7 +3101,7 @@ let d = class extends j {
|
|
|
3096
3101
|
@uc:select=${this._onSelectHistoryEntry}
|
|
3097
3102
|
@uc:start-over=${this._onStartOver}
|
|
3098
3103
|
></uc-ai-history>
|
|
3099
|
-
` : v,
|
|
3104
|
+
` : v, mt = f`
|
|
3100
3105
|
<uc-ai-prompt-row
|
|
3101
3106
|
.mode=${t}
|
|
3102
3107
|
.value=${this._prompt}
|
|
@@ -3128,7 +3133,7 @@ let d = class extends j {
|
|
|
3128
3133
|
></uc-ai-aspect-ratio>
|
|
3129
3134
|
` : v}
|
|
3130
3135
|
</uc-ai-prompt-row>
|
|
3131
|
-
`,
|
|
3136
|
+
`, ae = f`
|
|
3132
3137
|
<div
|
|
3133
3138
|
class=${S({
|
|
3134
3139
|
composer: !0,
|
|
@@ -3138,23 +3143,23 @@ let d = class extends j {
|
|
|
3138
3143
|
})}
|
|
3139
3144
|
>
|
|
3140
3145
|
<div class="composer__content">
|
|
3141
|
-
${R && w === "composer-above" ?
|
|
3142
|
-
${
|
|
3143
|
-
${R && w === "composer-below" ?
|
|
3146
|
+
${R && w === "composer-above" ? oe : v}
|
|
3147
|
+
${mt}
|
|
3148
|
+
${R && w === "composer-below" ? oe : v}
|
|
3144
3149
|
</div>
|
|
3145
3150
|
</div>
|
|
3146
|
-
`,
|
|
3151
|
+
`, _t = X && !R ? f`<div
|
|
3147
3152
|
class=${S({
|
|
3148
3153
|
"history-pinned": !0,
|
|
3149
3154
|
"history-pinned--docked": _,
|
|
3150
3155
|
[`history-pinned--canvas-${I}`]: !0
|
|
3151
3156
|
})}
|
|
3152
3157
|
>
|
|
3153
|
-
${
|
|
3154
|
-
</div>` : v,
|
|
3158
|
+
${oe}
|
|
3159
|
+
</div>` : v, gt = this.composerAutoHide && u ? f`
|
|
3155
3160
|
<div class=${S({ "dock-hotzone": !0, [`dock-hotzone--${h}`]: !0 })}></div>
|
|
3156
3161
|
<div class=${S({ "composer-fade": !0, [`composer-fade--${h}`]: !0 })}></div>
|
|
3157
|
-
` : v,
|
|
3162
|
+
` : v, Ae = this.toolbarPlacement === "top", Ue = f`
|
|
3158
3163
|
<uc-ai-footer
|
|
3159
3164
|
cancel-label="${this._l("ai-enhancer-cancel")}"
|
|
3160
3165
|
primary-label="${this._l("ai-enhancer-done-btn")}"
|
|
@@ -3169,8 +3174,8 @@ let d = class extends j {
|
|
|
3169
3174
|
role="region"
|
|
3170
3175
|
aria-label="${this._l(t === "edit" ? "ai-enhancer-edit-title" : "ai-enhancer-generate-title")}"
|
|
3171
3176
|
>
|
|
3172
|
-
${
|
|
3173
|
-
${_ && h === "top" ?
|
|
3177
|
+
${Ae ? Ue : v}
|
|
3178
|
+
${_ && h === "top" ? ae : v}
|
|
3174
3179
|
<div class=${S(l)}>
|
|
3175
3180
|
<uc-ai-canvas
|
|
3176
3181
|
.url=${this._previewUrl}
|
|
@@ -3186,21 +3191,21 @@ let d = class extends j {
|
|
|
3186
3191
|
exit-fullscreen-label="${this._l("ai-enhancer-exit-fullscreen")}"
|
|
3187
3192
|
></uc-ai-canvas>
|
|
3188
3193
|
|
|
3194
|
+
${gt}
|
|
3189
3195
|
${_t}
|
|
3190
|
-
${
|
|
3191
|
-
${u ? oe : v}
|
|
3196
|
+
${u ? ae : v}
|
|
3192
3197
|
|
|
3193
3198
|
${this._gen.error ? f`<div class="error-box" role="alert">
|
|
3194
3199
|
<div class="error-box__card">${this._errorMessage()}</div>
|
|
3195
3200
|
</div>` : v}
|
|
3196
3201
|
</div>
|
|
3197
|
-
${_ && h === "bottom" ?
|
|
3198
|
-
${
|
|
3202
|
+
${_ && h === "bottom" ? ae : v}
|
|
3203
|
+
${Ae ? v : Ue}
|
|
3199
3204
|
</div>
|
|
3200
3205
|
`;
|
|
3201
3206
|
}
|
|
3202
3207
|
};
|
|
3203
|
-
d.styles =
|
|
3208
|
+
d.styles = j(Sr);
|
|
3204
3209
|
m([
|
|
3205
3210
|
c({ attribute: "source-uuid" })
|
|
3206
3211
|
], d.prototype, "sourceUuid", 2);
|
|
@@ -3232,7 +3237,7 @@ m([
|
|
|
3232
3237
|
c({ attribute: !1 })
|
|
3233
3238
|
], d.prototype, "secureDeliveryProxyUrlResolver", 2);
|
|
3234
3239
|
m([
|
|
3235
|
-
c({ type: Array, attribute: "aspect-ratios", converter: (t) => t ?
|
|
3240
|
+
c({ type: Array, attribute: "aspect-ratios", converter: (t) => t ? At(t) : null })
|
|
3236
3241
|
], d.prototype, "aspectRatios", 2);
|
|
3237
3242
|
m([
|
|
3238
3243
|
c({ attribute: "locale-name" })
|
|
@@ -3286,14 +3291,14 @@ m([
|
|
|
3286
3291
|
C()
|
|
3287
3292
|
], d.prototype, "_localeStrings", 2);
|
|
3288
3293
|
d = m([
|
|
3289
|
-
|
|
3294
|
+
H("uc-ai-enhancer")
|
|
3290
3295
|
], d);
|
|
3291
3296
|
export {
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3297
|
+
Gr as I,
|
|
3298
|
+
ue as L,
|
|
3299
|
+
xt as P,
|
|
3295
3300
|
d as U,
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
|
|
3301
|
+
jr as a,
|
|
3302
|
+
B as e,
|
|
3303
|
+
we as i
|
|
3299
3304
|
};
|