@antontranelis/money-printer 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.js +335 -307
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsxs as u, jsx as l, Fragment as
|
|
1
|
+
import { jsxs as u, jsx as l, Fragment as O } from "react/jsx-runtime";
|
|
2
2
|
import { create as ve } from "zustand";
|
|
3
|
-
import { persist as
|
|
4
|
-
import { useState as
|
|
5
|
-
import
|
|
6
|
-
const
|
|
3
|
+
import { persist as ye } from "zustand/middleware";
|
|
4
|
+
import { useState as N, useCallback as T, useRef as _, useEffect as Y } from "react";
|
|
5
|
+
import xe from "jspdf";
|
|
6
|
+
const J = {
|
|
7
7
|
personalInfo: {
|
|
8
8
|
name: "",
|
|
9
9
|
email: "",
|
|
@@ -23,10 +23,10 @@ const X = {
|
|
|
23
23
|
currentSide: "front",
|
|
24
24
|
isEnhancing: !1,
|
|
25
25
|
isExporting: !1
|
|
26
|
-
},
|
|
27
|
-
|
|
26
|
+
}, v = ve()(
|
|
27
|
+
ye(
|
|
28
28
|
(e) => ({
|
|
29
|
-
...
|
|
29
|
+
...J,
|
|
30
30
|
setPersonalInfo: (t) => e((n) => ({
|
|
31
31
|
personalInfo: { ...n.personalInfo, ...t }
|
|
32
32
|
})),
|
|
@@ -73,7 +73,7 @@ const X = {
|
|
|
73
73
|
setHours: (t) => e((n) => ({
|
|
74
74
|
voucherConfig: { ...n.voucherConfig, hours: t }
|
|
75
75
|
})),
|
|
76
|
-
reset: () => e(
|
|
76
|
+
reset: () => e(J)
|
|
77
77
|
}),
|
|
78
78
|
{
|
|
79
79
|
name: "money-generator-storage",
|
|
@@ -84,7 +84,7 @@ const X = {
|
|
|
84
84
|
})
|
|
85
85
|
}
|
|
86
86
|
)
|
|
87
|
-
),
|
|
87
|
+
), ke = {
|
|
88
88
|
header: {
|
|
89
89
|
title: "Money Generator",
|
|
90
90
|
subtitle: "Erstelle deinen persönlichen Zeitgutschein"
|
|
@@ -178,18 +178,18 @@ const X = {
|
|
|
178
178
|
bill: {
|
|
179
179
|
descriptionText: "This voucher entitles you to {hours} {hourLabel} of my time or an equivalent thank you"
|
|
180
180
|
}
|
|
181
|
-
},
|
|
182
|
-
function
|
|
183
|
-
return
|
|
181
|
+
}, Ee = { de: ke, en: Ie };
|
|
182
|
+
function M(e) {
|
|
183
|
+
return Ee[e];
|
|
184
184
|
}
|
|
185
|
-
function
|
|
185
|
+
function te(e, t, n) {
|
|
186
186
|
if (n && n.trim())
|
|
187
187
|
return n;
|
|
188
|
-
const a =
|
|
188
|
+
const a = M(e), r = t === 1 ? a.form.voucher.hourLabel : a.form.voucher.hoursLabel;
|
|
189
189
|
return a.bill.descriptionText.replace("{hours}", t.toString()).replace("{hourLabel}", r);
|
|
190
190
|
}
|
|
191
|
-
function
|
|
192
|
-
const e =
|
|
191
|
+
function Je() {
|
|
192
|
+
const e = v((r) => r.voucherConfig.language), t = v((r) => r.personalInfo), n = v((r) => r.setPersonalInfo), a = M(e);
|
|
193
193
|
return /* @__PURE__ */ u("div", { className: "space-y-4", children: [
|
|
194
194
|
/* @__PURE__ */ u("div", { className: "form-control", children: [
|
|
195
195
|
/* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: a.form.personalInfo.name }) }),
|
|
@@ -236,30 +236,41 @@ async function Ne(e, t = 0.5) {
|
|
|
236
236
|
return new Promise((n, a) => {
|
|
237
237
|
const r = new Image();
|
|
238
238
|
r.onload = () => {
|
|
239
|
-
const
|
|
239
|
+
const i = document.createElement("canvas"), c = i.getContext("2d");
|
|
240
240
|
if (!c) {
|
|
241
241
|
a(new Error("Failed to get canvas context"));
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
|
-
|
|
245
|
-
const s = c.getImageData(0, 0,
|
|
246
|
-
for (let h = 0; h <
|
|
247
|
-
const g =
|
|
248
|
-
if (
|
|
249
|
-
let
|
|
250
|
-
|
|
251
|
-
const x = Math.min(255,
|
|
252
|
-
|
|
244
|
+
i.width = r.width, i.height = r.height, c.drawImage(r, 0, 0);
|
|
245
|
+
const s = c.getImageData(0, 0, i.width, i.height), o = s.data, d = 1 + t * 0.8;
|
|
246
|
+
for (let h = 0; h < o.length; h += 4) {
|
|
247
|
+
const g = o[h], f = o[h + 1], b = o[h + 2];
|
|
248
|
+
if (o[h + 3] === 0) continue;
|
|
249
|
+
let k = (((0.299 * g + 0.587 * f + 0.114 * b) / 255 - 0.5) * d + 0.5) * 255;
|
|
250
|
+
k = Math.max(0, Math.min(255, k));
|
|
251
|
+
const x = Math.min(255, k * 0.9 + 25), A = Math.min(255, k * 0.78 + 15), y = Math.min(255, k * 0.55 + 5);
|
|
252
|
+
o[h] = Math.round(g * (1 - t) + x * t), o[h + 1] = Math.round(f * (1 - t) + A * t), o[h + 2] = Math.round(b * (1 - t) + y * t);
|
|
253
253
|
}
|
|
254
|
-
c.putImageData(s, 0, 0), n(
|
|
254
|
+
c.putImageData(s, 0, 0), n(i.toDataURL("image/png"));
|
|
255
255
|
}, r.onerror = () => a(new Error("Failed to load image")), r.src = e;
|
|
256
256
|
});
|
|
257
257
|
}
|
|
258
|
-
const
|
|
258
|
+
const Pe = "https://api.stability.ai/v1/generation", Se = "https://api.stability.ai/v2beta/stable-image/edit/remove-background", ne = "stability_api_key";
|
|
259
|
+
let $ = null;
|
|
260
|
+
function Qe(e) {
|
|
261
|
+
$ = e;
|
|
262
|
+
}
|
|
263
|
+
function et() {
|
|
264
|
+
return $;
|
|
265
|
+
}
|
|
266
|
+
function tt() {
|
|
267
|
+
return $ !== null;
|
|
268
|
+
}
|
|
269
|
+
const Ce = {
|
|
259
270
|
vintage: "portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",
|
|
260
271
|
engraved: "portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",
|
|
261
272
|
currency: "portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"
|
|
262
|
-
},
|
|
273
|
+
}, Q = [
|
|
263
274
|
{ width: 1024, height: 1024 },
|
|
264
275
|
{ width: 1152, height: 896 },
|
|
265
276
|
{ width: 1216, height: 832 },
|
|
@@ -270,57 +281,57 @@ const Ee = "https://api.stability.ai/v1/generation", Pe = "https://api.stability
|
|
|
270
281
|
{ width: 832, height: 1216 },
|
|
271
282
|
{ width: 896, height: 1152 }
|
|
272
283
|
];
|
|
273
|
-
function
|
|
284
|
+
function Te(e, t) {
|
|
274
285
|
const n = e / t;
|
|
275
|
-
let a =
|
|
276
|
-
for (const
|
|
277
|
-
const c =
|
|
278
|
-
s < r && (r = s, a =
|
|
286
|
+
let a = Q[0], r = 1 / 0;
|
|
287
|
+
for (const i of Q) {
|
|
288
|
+
const c = i.width / i.height, s = Math.abs(n - c);
|
|
289
|
+
s < r && (r = s, a = i);
|
|
279
290
|
}
|
|
280
291
|
return a;
|
|
281
292
|
}
|
|
282
|
-
function
|
|
293
|
+
function Ae(e) {
|
|
283
294
|
return new Promise((t, n) => {
|
|
284
295
|
const a = new Image();
|
|
285
296
|
a.onload = () => {
|
|
286
|
-
const r =
|
|
287
|
-
|
|
288
|
-
const c =
|
|
297
|
+
const r = Te(a.width, a.height), i = document.createElement("canvas");
|
|
298
|
+
i.width = r.width, i.height = r.height;
|
|
299
|
+
const c = i.getContext("2d");
|
|
289
300
|
if (!c) {
|
|
290
301
|
n(new Error("Failed to get canvas context"));
|
|
291
302
|
return;
|
|
292
303
|
}
|
|
293
|
-
const s = a.width / a.height,
|
|
304
|
+
const s = a.width / a.height, o = r.width / r.height;
|
|
294
305
|
let d = 0, h = 0, g = a.width, f = a.height;
|
|
295
|
-
s >
|
|
306
|
+
s > o ? (g = a.height * o, d = (a.width - g) / 2) : (f = a.width / o, h = (a.height - f) / 2), c.drawImage(a, d, h, g, f, 0, 0, r.width, r.height), t(i.toDataURL("image/png"));
|
|
296
307
|
}, a.onerror = () => n(new Error("Failed to load image")), a.src = e;
|
|
297
308
|
});
|
|
298
309
|
}
|
|
299
|
-
function
|
|
310
|
+
function ae(e) {
|
|
300
311
|
var c;
|
|
301
|
-
const t = e.split(","), n = ((c = t[0].match(/:(.*?);/)) == null ? void 0 : c[1]) || "image/png", a = atob(t[1]), r = a.length,
|
|
312
|
+
const t = e.split(","), n = ((c = t[0].match(/:(.*?);/)) == null ? void 0 : c[1]) || "image/png", a = atob(t[1]), r = a.length, i = new Uint8Array(r);
|
|
302
313
|
for (let s = 0; s < r; s++)
|
|
303
|
-
|
|
304
|
-
return new Blob([
|
|
314
|
+
i[s] = a.charCodeAt(s);
|
|
315
|
+
return new Blob([i], { type: n });
|
|
305
316
|
}
|
|
306
|
-
function
|
|
317
|
+
function V() {
|
|
307
318
|
var t;
|
|
308
319
|
const e = typeof import.meta < "u" && "sk-7mEKklrqaltdtgbX0VoZbkA8E1cl939Spn75jSIYRvp1BW0b" || typeof process < "u" && ((t = process.env) == null ? void 0 : t.NEXT_PUBLIC_STABILITY_API_KEY);
|
|
309
|
-
return e && e !== "your-api-key-here" ? e : typeof localStorage < "u" ? localStorage.getItem(
|
|
320
|
+
return e && e !== "your-api-key-here" ? e : typeof localStorage < "u" ? localStorage.getItem(ne) : null;
|
|
310
321
|
}
|
|
311
|
-
function
|
|
312
|
-
localStorage.setItem(
|
|
322
|
+
function Le(e) {
|
|
323
|
+
localStorage.setItem(ne, e);
|
|
313
324
|
}
|
|
314
|
-
function
|
|
315
|
-
return
|
|
325
|
+
function De() {
|
|
326
|
+
return $ ? !0 : V() !== null;
|
|
316
327
|
}
|
|
317
|
-
async function
|
|
318
|
-
const t =
|
|
328
|
+
async function nt(e) {
|
|
329
|
+
const t = V();
|
|
319
330
|
if (!t)
|
|
320
331
|
throw new Error("No Stability AI API key configured");
|
|
321
|
-
const { imageDataUrl: n, style: a, strength: r = 0.35 } = e,
|
|
322
|
-
s.append("init_image", c, "portrait.png"), s.append("init_image_mode", "IMAGE_STRENGTH"), s.append("image_strength", String(1 - r)), s.append("text_prompts[0][text]",
|
|
323
|
-
const d = await fetch(`${
|
|
332
|
+
const { imageDataUrl: n, style: a, strength: r = 0.35 } = e, i = await Ae(n), c = ae(i), s = new FormData();
|
|
333
|
+
s.append("init_image", c, "portrait.png"), s.append("init_image_mode", "IMAGE_STRENGTH"), s.append("image_strength", String(1 - r)), s.append("text_prompts[0][text]", Ce[a]), s.append("text_prompts[0][weight]", "1"), s.append("cfg_scale", "7"), s.append("samples", "1"), s.append("steps", "30");
|
|
334
|
+
const d = await fetch(`${Pe}/stable-diffusion-xl-1024-v1-0/image-to-image`, {
|
|
324
335
|
method: "POST",
|
|
325
336
|
headers: {
|
|
326
337
|
Authorization: `Bearer ${t}`,
|
|
@@ -338,12 +349,26 @@ async function Je(e) {
|
|
|
338
349
|
return `data:image/png;base64,${h.artifacts[0].base64}`;
|
|
339
350
|
}
|
|
340
351
|
async function _e(e) {
|
|
341
|
-
|
|
352
|
+
if ($) {
|
|
353
|
+
const c = await fetch($, {
|
|
354
|
+
method: "POST",
|
|
355
|
+
headers: {
|
|
356
|
+
"Content-Type": "application/json"
|
|
357
|
+
},
|
|
358
|
+
body: JSON.stringify({ imageDataUrl: e })
|
|
359
|
+
});
|
|
360
|
+
if (!c.ok) {
|
|
361
|
+
const o = await c.json().catch(() => ({}));
|
|
362
|
+
throw new Error(o.error || `API error: ${c.status}`);
|
|
363
|
+
}
|
|
364
|
+
return (await c.json()).imageDataUrl;
|
|
365
|
+
}
|
|
366
|
+
const t = V();
|
|
342
367
|
if (!t)
|
|
343
368
|
throw new Error("No Stability AI API key configured");
|
|
344
|
-
const n =
|
|
369
|
+
const n = ae(e), a = new FormData();
|
|
345
370
|
a.append("image", n, "image.png"), a.append("output_format", "png");
|
|
346
|
-
const r = await fetch(
|
|
371
|
+
const r = await fetch(Se, {
|
|
347
372
|
method: "POST",
|
|
348
373
|
headers: {
|
|
349
374
|
Authorization: `Bearer ${t}`,
|
|
@@ -355,23 +380,23 @@ async function _e(e) {
|
|
|
355
380
|
const c = await r.text();
|
|
356
381
|
throw console.error("Stability AI remove background error:", c), r.status === 401 ? new Error("Invalid API key") : r.status === 402 ? new Error("Insufficient credits") : r.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${r.status}`);
|
|
357
382
|
}
|
|
358
|
-
const
|
|
383
|
+
const i = await r.blob();
|
|
359
384
|
return new Promise((c, s) => {
|
|
360
|
-
const
|
|
361
|
-
|
|
385
|
+
const o = new FileReader();
|
|
386
|
+
o.onload = () => c(o.result), o.onerror = () => s(new Error("Failed to read result")), o.readAsDataURL(i);
|
|
362
387
|
});
|
|
363
388
|
}
|
|
364
|
-
function
|
|
365
|
-
const [e, t] =
|
|
366
|
-
|
|
389
|
+
function Re() {
|
|
390
|
+
const [e, t] = N(!1), [n, a] = N(!1), [r, i] = N(null), [c, s] = N(De()), o = T(() => i(null), []), d = T((f) => {
|
|
391
|
+
Le(f), s(!0), i(null);
|
|
367
392
|
}, []), h = T(
|
|
368
393
|
async (f, b = 0.5) => {
|
|
369
|
-
t(!0),
|
|
394
|
+
t(!0), i(null);
|
|
370
395
|
try {
|
|
371
396
|
return await Ne(f, b);
|
|
372
397
|
} catch (m) {
|
|
373
398
|
const S = m instanceof Error ? m.message : "Enhancement failed";
|
|
374
|
-
throw
|
|
399
|
+
throw i(S), m;
|
|
375
400
|
} finally {
|
|
376
401
|
t(!1);
|
|
377
402
|
}
|
|
@@ -379,12 +404,12 @@ function De() {
|
|
|
379
404
|
[]
|
|
380
405
|
), g = T(
|
|
381
406
|
async (f) => {
|
|
382
|
-
a(!0),
|
|
407
|
+
a(!0), i(null);
|
|
383
408
|
try {
|
|
384
409
|
return await _e(f);
|
|
385
410
|
} catch (b) {
|
|
386
411
|
const m = b instanceof Error ? b.message : "Background removal failed";
|
|
387
|
-
throw
|
|
412
|
+
throw i(m), b;
|
|
388
413
|
} finally {
|
|
389
414
|
a(!1);
|
|
390
415
|
}
|
|
@@ -399,15 +424,15 @@ function De() {
|
|
|
399
424
|
error: r,
|
|
400
425
|
hasKey: c,
|
|
401
426
|
setApiKey: d,
|
|
402
|
-
clearError:
|
|
427
|
+
clearError: o
|
|
403
428
|
};
|
|
404
429
|
}
|
|
405
|
-
function
|
|
406
|
-
const a =
|
|
430
|
+
function Be({ isOpen: e, onClose: t, onSubmit: n }) {
|
|
431
|
+
const a = v((d) => d.voucherConfig.language), [r, i] = N("");
|
|
407
432
|
if (!e) return null;
|
|
408
433
|
const c = (d) => {
|
|
409
|
-
d.preventDefault(), r.trim() && (n(r.trim()),
|
|
410
|
-
},
|
|
434
|
+
d.preventDefault(), r.trim() && (n(r.trim()), i(""), t());
|
|
435
|
+
}, o = {
|
|
411
436
|
de: {
|
|
412
437
|
title: "Stability AI API Key",
|
|
413
438
|
description: "Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",
|
|
@@ -427,120 +452,120 @@ function Re({ isOpen: e, onClose: t, onSubmit: n }) {
|
|
|
427
452
|
}[a];
|
|
428
453
|
return /* @__PURE__ */ u("dialog", { className: "modal modal-open", children: [
|
|
429
454
|
/* @__PURE__ */ u("div", { className: "modal-box", children: [
|
|
430
|
-
/* @__PURE__ */ l("h3", { className: "font-bold text-lg", children:
|
|
431
|
-
/* @__PURE__ */ l("p", { className: "py-4 text-sm opacity-80", children:
|
|
455
|
+
/* @__PURE__ */ l("h3", { className: "font-bold text-lg", children: o.title }),
|
|
456
|
+
/* @__PURE__ */ l("p", { className: "py-4 text-sm opacity-80", children: o.description }),
|
|
432
457
|
/* @__PURE__ */ u("form", { onSubmit: c, children: [
|
|
433
458
|
/* @__PURE__ */ u("div", { className: "form-control", children: [
|
|
434
459
|
/* @__PURE__ */ l(
|
|
435
460
|
"input",
|
|
436
461
|
{
|
|
437
462
|
type: "password",
|
|
438
|
-
placeholder:
|
|
463
|
+
placeholder: o.placeholder,
|
|
439
464
|
className: "input input-bordered w-full",
|
|
440
465
|
value: r,
|
|
441
|
-
onChange: (d) =>
|
|
466
|
+
onChange: (d) => i(d.target.value),
|
|
442
467
|
autoFocus: !0
|
|
443
468
|
}
|
|
444
469
|
),
|
|
445
|
-
/* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text-alt", children:
|
|
470
|
+
/* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text-alt", children: o.hint }) })
|
|
446
471
|
] }),
|
|
447
472
|
/* @__PURE__ */ u("div", { className: "modal-action", children: [
|
|
448
|
-
/* @__PURE__ */ l("button", { type: "button", className: "btn btn-ghost", onClick: t, children:
|
|
449
|
-
/* @__PURE__ */ l("button", { type: "submit", className: "btn btn-primary", disabled: !r.trim(), children:
|
|
473
|
+
/* @__PURE__ */ l("button", { type: "button", className: "btn btn-ghost", onClick: t, children: o.cancel }),
|
|
474
|
+
/* @__PURE__ */ l("button", { type: "submit", className: "btn btn-primary", disabled: !r.trim(), children: o.submit })
|
|
450
475
|
] })
|
|
451
476
|
] })
|
|
452
477
|
] }),
|
|
453
478
|
/* @__PURE__ */ l("form", { method: "dialog", className: "modal-backdrop", children: /* @__PURE__ */ l("button", { onClick: t, children: "close" }) })
|
|
454
479
|
] });
|
|
455
480
|
}
|
|
456
|
-
function
|
|
457
|
-
const e =
|
|
458
|
-
|
|
459
|
-
|
|
481
|
+
function at() {
|
|
482
|
+
const e = v((p) => p.voucherConfig.language), t = v((p) => p.portrait), n = v((p) => p.setPortrait), a = v((p) => p.setPortraitZoom), { enhance: r, removeBg: i, isEnhancing: c, isRemovingBg: s, error: o, hasKey: d, setApiKey: h } = Re(), g = M(e), f = _(null), [b, m] = N(!1), [S, k] = N(!1), [x, A] = N(null), [y, P] = N(null), [L, D] = N(!1), [C, z] = N(0), H = _(null);
|
|
483
|
+
Y(() => () => {
|
|
484
|
+
H.current && clearTimeout(H.current);
|
|
460
485
|
}, []);
|
|
461
|
-
const
|
|
486
|
+
const j = T(
|
|
462
487
|
async (p) => {
|
|
463
488
|
if (!p.type.startsWith("image/"))
|
|
464
489
|
return;
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
var
|
|
468
|
-
const
|
|
469
|
-
A(
|
|
470
|
-
},
|
|
490
|
+
const w = new FileReader();
|
|
491
|
+
w.onload = async (I) => {
|
|
492
|
+
var X;
|
|
493
|
+
const Z = (X = I.target) == null ? void 0 : X.result;
|
|
494
|
+
A(Z), n(Z), D(!1), P(null), z(0);
|
|
495
|
+
}, w.readAsDataURL(p);
|
|
471
496
|
},
|
|
472
497
|
[n]
|
|
473
|
-
),
|
|
498
|
+
), de = T(
|
|
474
499
|
(p) => {
|
|
475
500
|
p.preventDefault(), m(!1);
|
|
476
|
-
const
|
|
477
|
-
|
|
501
|
+
const w = p.dataTransfer.files[0];
|
|
502
|
+
w && j(w);
|
|
478
503
|
},
|
|
479
|
-
[
|
|
480
|
-
),
|
|
504
|
+
[j]
|
|
505
|
+
), he = T((p) => {
|
|
481
506
|
p.preventDefault(), m(!0);
|
|
482
|
-
}, []),
|
|
507
|
+
}, []), me = T((p) => {
|
|
483
508
|
p.preventDefault(), m(!1);
|
|
484
|
-
}, []),
|
|
509
|
+
}, []), pe = () => {
|
|
485
510
|
var p;
|
|
486
511
|
(p = f.current) == null || p.click();
|
|
487
|
-
},
|
|
488
|
-
var
|
|
489
|
-
const
|
|
490
|
-
|
|
491
|
-
},
|
|
512
|
+
}, ue = (p) => {
|
|
513
|
+
var I;
|
|
514
|
+
const w = (I = p.target.files) == null ? void 0 : I[0];
|
|
515
|
+
w && j(w);
|
|
516
|
+
}, U = T(async (p, w) => {
|
|
492
517
|
try {
|
|
493
|
-
return await r(p,
|
|
494
|
-
} catch (
|
|
495
|
-
return console.error("Enhancement failed:",
|
|
518
|
+
return await r(p, w);
|
|
519
|
+
} catch (I) {
|
|
520
|
+
return console.error("Enhancement failed:", I), p;
|
|
496
521
|
}
|
|
497
|
-
}, [r]),
|
|
522
|
+
}, [r]), G = T(async (p) => {
|
|
498
523
|
try {
|
|
499
|
-
const
|
|
500
|
-
return P(
|
|
501
|
-
} catch (
|
|
502
|
-
return console.error("Background removal failed:",
|
|
524
|
+
const w = await i(p);
|
|
525
|
+
return P(w), w;
|
|
526
|
+
} catch (w) {
|
|
527
|
+
return console.error("Background removal failed:", w), p;
|
|
503
528
|
}
|
|
504
|
-
}, [
|
|
529
|
+
}, [i]), ge = async () => {
|
|
505
530
|
if (!x) return;
|
|
506
531
|
if (!L && !d) {
|
|
507
|
-
|
|
532
|
+
k(!0);
|
|
508
533
|
return;
|
|
509
534
|
}
|
|
510
535
|
const p = !L;
|
|
511
|
-
if (
|
|
512
|
-
const
|
|
536
|
+
if (D(p), p) {
|
|
537
|
+
const w = await G(x);
|
|
513
538
|
if (C > 0) {
|
|
514
|
-
const
|
|
515
|
-
n(
|
|
539
|
+
const I = await U(w, C);
|
|
540
|
+
n(I);
|
|
516
541
|
} else
|
|
517
|
-
n(
|
|
542
|
+
n(w);
|
|
518
543
|
} else if (P(null), C > 0) {
|
|
519
|
-
const
|
|
520
|
-
n(
|
|
544
|
+
const w = await U(x, C);
|
|
545
|
+
n(w);
|
|
521
546
|
} else
|
|
522
547
|
n(x);
|
|
523
|
-
},
|
|
524
|
-
|
|
525
|
-
const
|
|
548
|
+
}, fe = (p) => {
|
|
549
|
+
z(p), H.current && clearTimeout(H.current), x && (H.current = setTimeout(async () => {
|
|
550
|
+
const w = L && y ? y : x;
|
|
526
551
|
if (p === 0)
|
|
527
|
-
n(
|
|
552
|
+
n(w);
|
|
528
553
|
else {
|
|
529
|
-
const
|
|
530
|
-
n(
|
|
554
|
+
const I = await U(w, p);
|
|
555
|
+
n(I);
|
|
531
556
|
}
|
|
532
557
|
}, 150));
|
|
533
|
-
},
|
|
558
|
+
}, be = async (p) => {
|
|
534
559
|
if (h(p), !x) return;
|
|
535
|
-
|
|
536
|
-
const
|
|
560
|
+
D(!0);
|
|
561
|
+
const w = await G(x);
|
|
537
562
|
if (C > 0) {
|
|
538
|
-
const
|
|
539
|
-
n(
|
|
563
|
+
const I = await U(w, C);
|
|
564
|
+
n(I);
|
|
540
565
|
} else
|
|
541
|
-
n(
|
|
542
|
-
},
|
|
543
|
-
n(null), A(null), P(null),
|
|
566
|
+
n(w);
|
|
567
|
+
}, we = () => {
|
|
568
|
+
n(null), A(null), P(null), D(!1), z(0);
|
|
544
569
|
};
|
|
545
570
|
return /* @__PURE__ */ u("div", { className: "space-y-4", children: [
|
|
546
571
|
t.original ? /* @__PURE__ */ u("div", { className: "flex flex-col items-center space-y-4", children: [
|
|
@@ -558,7 +583,7 @@ function Qe() {
|
|
|
558
583
|
"button",
|
|
559
584
|
{
|
|
560
585
|
className: "btn btn-circle btn-xs btn-error absolute -top-1 -right-1",
|
|
561
|
-
onClick:
|
|
586
|
+
onClick: we,
|
|
562
587
|
children: /* @__PURE__ */ l(
|
|
563
588
|
"svg",
|
|
564
589
|
{
|
|
@@ -621,7 +646,7 @@ function Qe() {
|
|
|
621
646
|
max: "1",
|
|
622
647
|
step: "0.05",
|
|
623
648
|
value: C,
|
|
624
|
-
onChange: (p) =>
|
|
649
|
+
onChange: (p) => fe(parseFloat(p.target.value)),
|
|
625
650
|
className: "range range-secondary range-sm",
|
|
626
651
|
disabled: c
|
|
627
652
|
}
|
|
@@ -634,30 +659,30 @@ function Qe() {
|
|
|
634
659
|
type: "checkbox",
|
|
635
660
|
className: `toggle toggle-primary ${s ? "opacity-50" : ""}`,
|
|
636
661
|
checked: L,
|
|
637
|
-
onChange:
|
|
662
|
+
onChange: ge,
|
|
638
663
|
disabled: s
|
|
639
664
|
}
|
|
640
665
|
),
|
|
641
666
|
/* @__PURE__ */ u("span", { className: "label-text flex items-center gap-2", children: [
|
|
642
|
-
s ? /* @__PURE__ */ u(
|
|
667
|
+
s ? /* @__PURE__ */ u(O, { children: [
|
|
643
668
|
/* @__PURE__ */ l("span", { className: "loading loading-spinner loading-xs" }),
|
|
644
669
|
e === "de" ? "Hintergrund wird entfernt..." : "Removing background..."
|
|
645
670
|
] }) : e === "de" ? "Hintergrund entfernen" : "Remove background",
|
|
646
671
|
!d && /* @__PURE__ */ l("span", { className: "badge badge-sm badge-outline", children: "API" })
|
|
647
672
|
] })
|
|
648
673
|
] }) }),
|
|
649
|
-
|
|
674
|
+
o && /* @__PURE__ */ u("div", { className: "alert alert-warning text-sm py-2", children: [
|
|
650
675
|
/* @__PURE__ */ l("svg", { xmlns: "http://www.w3.org/2000/svg", className: "stroke-current shrink-0 h-5 w-5", fill: "none", viewBox: "0 0 24 24", children: /* @__PURE__ */ l("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
|
|
651
|
-
/* @__PURE__ */ l("span", { children:
|
|
676
|
+
/* @__PURE__ */ l("span", { children: o })
|
|
652
677
|
] })
|
|
653
678
|
] }) : /* @__PURE__ */ u(
|
|
654
679
|
"div",
|
|
655
680
|
{
|
|
656
681
|
className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${s ? "border-primary bg-primary/10 pointer-events-none" : b ? "border-primary bg-primary/10" : "border-base-300 hover:border-primary hover:bg-base-200"}`,
|
|
657
|
-
onDrop:
|
|
658
|
-
onDragOver:
|
|
659
|
-
onDragLeave:
|
|
660
|
-
onClick:
|
|
682
|
+
onDrop: de,
|
|
683
|
+
onDragOver: he,
|
|
684
|
+
onDragLeave: me,
|
|
685
|
+
onClick: pe,
|
|
661
686
|
children: [
|
|
662
687
|
/* @__PURE__ */ l(
|
|
663
688
|
"input",
|
|
@@ -666,7 +691,7 @@ function Qe() {
|
|
|
666
691
|
type: "file",
|
|
667
692
|
accept: "image/*",
|
|
668
693
|
className: "hidden",
|
|
669
|
-
onChange:
|
|
694
|
+
onChange: ue
|
|
670
695
|
}
|
|
671
696
|
),
|
|
672
697
|
s ? /* @__PURE__ */ u("div", { className: "flex flex-col items-center gap-2", children: [
|
|
@@ -699,55 +724,55 @@ function Qe() {
|
|
|
699
724
|
}
|
|
700
725
|
),
|
|
701
726
|
/* @__PURE__ */ l(
|
|
702
|
-
|
|
727
|
+
Be,
|
|
703
728
|
{
|
|
704
729
|
isOpen: S,
|
|
705
|
-
onClose: () =>
|
|
706
|
-
onSubmit:
|
|
730
|
+
onClose: () => k(!1),
|
|
731
|
+
onSubmit: be
|
|
707
732
|
}
|
|
708
733
|
)
|
|
709
734
|
] });
|
|
710
735
|
}
|
|
711
|
-
function
|
|
736
|
+
function rt() {
|
|
712
737
|
return null;
|
|
713
738
|
}
|
|
714
|
-
const
|
|
739
|
+
const E = typeof import.meta < "u" && "/" || "/", $e = {
|
|
715
740
|
en: {
|
|
716
741
|
1: {
|
|
717
|
-
front: `${
|
|
718
|
-
back: `${
|
|
742
|
+
front: `${E}templates/front_ldpi_en.png`,
|
|
743
|
+
back: `${E}templates/back_ldpi_en.png`,
|
|
719
744
|
width: 1536,
|
|
720
745
|
height: 1024
|
|
721
746
|
},
|
|
722
747
|
5: {
|
|
723
|
-
front: `${
|
|
724
|
-
back: `${
|
|
748
|
+
front: `${E}templates/front_ldpi_en.png`,
|
|
749
|
+
back: `${E}templates/back_ldpi_en.png`,
|
|
725
750
|
width: 1536,
|
|
726
751
|
height: 1024
|
|
727
752
|
},
|
|
728
753
|
10: {
|
|
729
|
-
front: `${
|
|
730
|
-
back: `${
|
|
754
|
+
front: `${E}templates/front_ldpi_en.png`,
|
|
755
|
+
back: `${E}templates/back_ldpi_en.png`,
|
|
731
756
|
width: 1536,
|
|
732
757
|
height: 1024
|
|
733
758
|
}
|
|
734
759
|
},
|
|
735
760
|
de: {
|
|
736
761
|
1: {
|
|
737
|
-
front: `${
|
|
738
|
-
back: `${
|
|
762
|
+
front: `${E}templates/front_hdpi_de.webp`,
|
|
763
|
+
back: `${E}templates/back_hdpi_de.webp`,
|
|
739
764
|
width: 6144,
|
|
740
765
|
height: 3200
|
|
741
766
|
},
|
|
742
767
|
5: {
|
|
743
|
-
front: `${
|
|
744
|
-
back: `${
|
|
768
|
+
front: `${E}templates/front_hdpi_de.webp`,
|
|
769
|
+
back: `${E}templates/back_hdpi_de.webp`,
|
|
745
770
|
width: 6144,
|
|
746
771
|
height: 3200
|
|
747
772
|
},
|
|
748
773
|
10: {
|
|
749
|
-
front: `${
|
|
750
|
-
back: `${
|
|
774
|
+
front: `${E}templates/front_hdpi_de.webp`,
|
|
775
|
+
back: `${E}templates/back_hdpi_de.webp`,
|
|
751
776
|
width: 6144,
|
|
752
777
|
height: 3200
|
|
753
778
|
}
|
|
@@ -845,14 +870,14 @@ const N = typeof import.meta < "u" && "/" || "/", Be = {
|
|
|
845
870
|
}
|
|
846
871
|
}
|
|
847
872
|
};
|
|
848
|
-
function
|
|
873
|
+
function re(e) {
|
|
849
874
|
return e === "de" ? B : R;
|
|
850
875
|
}
|
|
851
|
-
function
|
|
852
|
-
return
|
|
876
|
+
function oe(e, t) {
|
|
877
|
+
return $e[e][t];
|
|
853
878
|
}
|
|
854
879
|
const K = /* @__PURE__ */ new Map();
|
|
855
|
-
async function
|
|
880
|
+
async function q(e) {
|
|
856
881
|
return K.has(e) ? K.get(e) : new Promise((t, n) => {
|
|
857
882
|
const a = new Image();
|
|
858
883
|
a.crossOrigin = "anonymous", a.onload = () => {
|
|
@@ -860,53 +885,53 @@ async function Y(e) {
|
|
|
860
885
|
}, a.onerror = n, a.src = e;
|
|
861
886
|
});
|
|
862
887
|
}
|
|
863
|
-
function
|
|
888
|
+
function ie(e, t, n, a) {
|
|
864
889
|
e.drawImage(t, 0, 0, n, a);
|
|
865
890
|
}
|
|
866
|
-
function
|
|
867
|
-
e.save(), e.beginPath(), e.ellipse(n, a, r,
|
|
868
|
-
const s = t.width / t.height,
|
|
891
|
+
function Me(e, t, n, a, r, i, c = 1) {
|
|
892
|
+
e.save(), e.beginPath(), e.ellipse(n, a, r, i, 0, 0, Math.PI * 2), e.closePath(), e.clip();
|
|
893
|
+
const s = t.width / t.height, o = r / i, d = r * 2, h = i * 2;
|
|
869
894
|
let g, f;
|
|
870
|
-
s >
|
|
895
|
+
s > o ? (f = h, g = h * s) : (g = d, f = d / s), g *= c, f *= c;
|
|
871
896
|
const b = n - g / 2, m = a - f / 2;
|
|
872
897
|
e.drawImage(t, b, m, g, f), e.restore();
|
|
873
898
|
}
|
|
874
|
-
function
|
|
899
|
+
function se(e, t, n, a = "#2a3a2a") {
|
|
875
900
|
e.save(), e.font = `${n.fontSize}px "Times New Roman", serif`, e.textAlign = n.align || "center", e.textBaseline = "middle", e.fillStyle = a, n.maxWidth ? e.fillText(t, n.x, n.y, n.maxWidth) : e.fillText(t, n.x, n.y), e.restore();
|
|
876
901
|
}
|
|
877
|
-
function
|
|
902
|
+
function ze(e, t, n, a = "#2a3a2a") {
|
|
878
903
|
e.save(), e.font = `${n.fontSize}px "Times New Roman", serif`, e.textAlign = n.align || "center", e.textBaseline = "top", e.fillStyle = a;
|
|
879
|
-
const r = n.maxWidth || 400,
|
|
880
|
-
let
|
|
904
|
+
const r = n.maxWidth || 400, i = n.lineHeight || n.fontSize * 1.4, c = t.split(" "), s = [];
|
|
905
|
+
let o = "";
|
|
881
906
|
for (const g of c) {
|
|
882
|
-
const f =
|
|
883
|
-
e.measureText(f).width > r &&
|
|
907
|
+
const f = o ? `${o} ${g}` : g;
|
|
908
|
+
e.measureText(f).width > r && o ? (s.push(o), o = g) : o = f;
|
|
884
909
|
}
|
|
885
|
-
|
|
886
|
-
const d = s.length *
|
|
910
|
+
o && s.push(o);
|
|
911
|
+
const d = s.length * i;
|
|
887
912
|
let h = n.y - d / 2;
|
|
888
913
|
for (const g of s)
|
|
889
|
-
e.fillText(g, n.x, h), h +=
|
|
914
|
+
e.fillText(g, n.x, h), h += i;
|
|
890
915
|
e.restore();
|
|
891
916
|
}
|
|
892
|
-
function
|
|
893
|
-
e.save(), e.font = `${r.fontSize}px "Times New Roman", serif`, e.textAlign = r.align || "center", e.textBaseline = "middle", e.fillStyle =
|
|
894
|
-
const c = r.lineHeight || r.fontSize * 1.8, s = [t, n, a].filter(Boolean),
|
|
895
|
-
let d = r.y -
|
|
917
|
+
function He(e, t, n, a, r, i = "#2a3a2a") {
|
|
918
|
+
e.save(), e.font = `${r.fontSize}px "Times New Roman", serif`, e.textAlign = r.align || "center", e.textBaseline = "middle", e.fillStyle = i;
|
|
919
|
+
const c = r.lineHeight || r.fontSize * 1.8, s = [t, n, a].filter(Boolean), o = (s.length - 1) * c;
|
|
920
|
+
let d = r.y - o / 2;
|
|
896
921
|
for (const h of s)
|
|
897
922
|
h && (e.fillText(h, r.x, d), d += c);
|
|
898
923
|
e.restore();
|
|
899
924
|
}
|
|
900
|
-
async function
|
|
901
|
-
const
|
|
902
|
-
if (!
|
|
903
|
-
e.width =
|
|
904
|
-
const d = await
|
|
905
|
-
if (
|
|
925
|
+
async function le(e, t, n, a, r, i, c, s = 1) {
|
|
926
|
+
const o = e.getContext("2d");
|
|
927
|
+
if (!o) return;
|
|
928
|
+
e.width = i, e.height = c, o.clearRect(0, 0, i, c);
|
|
929
|
+
const d = await q(t);
|
|
930
|
+
if (ie(o, d, i, c), n)
|
|
906
931
|
try {
|
|
907
|
-
const h = await
|
|
908
|
-
|
|
909
|
-
|
|
932
|
+
const h = await q(n);
|
|
933
|
+
Me(
|
|
934
|
+
o,
|
|
910
935
|
h,
|
|
911
936
|
r.portrait.x,
|
|
912
937
|
r.portrait.y,
|
|
@@ -917,20 +942,20 @@ async function se(e, t, n, a, r, o, c, s = 1) {
|
|
|
917
942
|
} catch (h) {
|
|
918
943
|
console.error("Failed to load portrait:", h);
|
|
919
944
|
}
|
|
920
|
-
a &&
|
|
945
|
+
a && se(o, a, r.namePlate);
|
|
921
946
|
}
|
|
922
|
-
async function
|
|
947
|
+
async function ce(e, t, n, a, r, i, c, s, o) {
|
|
923
948
|
const d = e.getContext("2d");
|
|
924
949
|
if (!d) return;
|
|
925
|
-
e.width = s, e.height =
|
|
926
|
-
const h = await
|
|
927
|
-
|
|
950
|
+
e.width = s, e.height = o, d.clearRect(0, 0, s, o);
|
|
951
|
+
const h = await q(t);
|
|
952
|
+
ie(d, h, s, o), c.contactInfo && (n || a || r) && He(d, n, a, r, c.contactInfo), c.description && i && ze(d, i, c.description), n && se(d, n, c.namePlate);
|
|
928
953
|
}
|
|
929
|
-
function
|
|
930
|
-
const e =
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
954
|
+
function ot() {
|
|
955
|
+
const e = v((y) => y.voucherConfig.language), t = v((y) => y.voucherConfig.hours), n = v((y) => y.voucherConfig.description), a = v((y) => y.personalInfo), r = v((y) => y.portrait), i = v((y) => y.currentSide), c = v((y) => y.flipSide), s = M(e), o = _(null), d = _(null), h = _(null), [g, f] = N(!1), b = oe(e, t), m = re(e), S = r.useEnhanced && r.enhanced ? r.enhanced : r.original, k = te(e, t, n);
|
|
956
|
+
Y(() => {
|
|
957
|
+
o.current && le(
|
|
958
|
+
o.current,
|
|
934
959
|
b.front,
|
|
935
960
|
S,
|
|
936
961
|
a.name,
|
|
@@ -939,19 +964,19 @@ function tt() {
|
|
|
939
964
|
b.height,
|
|
940
965
|
r.zoom
|
|
941
966
|
);
|
|
942
|
-
}, [b, S, a.name, m, r.zoom]),
|
|
943
|
-
d.current &&
|
|
967
|
+
}, [b, S, a.name, m, r.zoom]), Y(() => {
|
|
968
|
+
d.current && ce(
|
|
944
969
|
d.current,
|
|
945
970
|
b.back,
|
|
946
971
|
a.name,
|
|
947
972
|
a.email,
|
|
948
973
|
a.phone,
|
|
949
|
-
|
|
974
|
+
k,
|
|
950
975
|
m.back,
|
|
951
976
|
b.width,
|
|
952
977
|
b.height
|
|
953
978
|
);
|
|
954
|
-
}, [b, a,
|
|
979
|
+
}, [b, a, k, m]);
|
|
955
980
|
const x = () => {
|
|
956
981
|
f(!0), setTimeout(() => {
|
|
957
982
|
c(), f(!1);
|
|
@@ -963,16 +988,16 @@ function tt() {
|
|
|
963
988
|
/* @__PURE__ */ l(
|
|
964
989
|
"button",
|
|
965
990
|
{
|
|
966
|
-
className: `tab ${
|
|
967
|
-
onClick: () =>
|
|
991
|
+
className: `tab ${i === "front" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
|
|
992
|
+
onClick: () => i !== "front" && x(),
|
|
968
993
|
children: s.preview.front
|
|
969
994
|
}
|
|
970
995
|
),
|
|
971
996
|
/* @__PURE__ */ l(
|
|
972
997
|
"button",
|
|
973
998
|
{
|
|
974
|
-
className: `tab ${
|
|
975
|
-
onClick: () =>
|
|
999
|
+
className: `tab ${i === "back" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
|
|
1000
|
+
onClick: () => i !== "back" && x(),
|
|
976
1001
|
children: s.preview.back
|
|
977
1002
|
}
|
|
978
1003
|
)
|
|
@@ -1010,15 +1035,15 @@ function tt() {
|
|
|
1010
1035
|
/* @__PURE__ */ l(
|
|
1011
1036
|
"canvas",
|
|
1012
1037
|
{
|
|
1013
|
-
ref:
|
|
1014
|
-
className: `absolute inset-0 w-full h-full transition-all duration-300 ${
|
|
1038
|
+
ref: o,
|
|
1039
|
+
className: `absolute inset-0 w-full h-full transition-all duration-300 ${i === "front" ? g ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
|
|
1015
1040
|
}
|
|
1016
1041
|
),
|
|
1017
1042
|
/* @__PURE__ */ l(
|
|
1018
1043
|
"canvas",
|
|
1019
1044
|
{
|
|
1020
1045
|
ref: d,
|
|
1021
|
-
className: `absolute inset-0 w-full h-full transition-all duration-300 ${
|
|
1046
|
+
className: `absolute inset-0 w-full h-full transition-all duration-300 ${i === "back" ? g ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
|
|
1022
1047
|
}
|
|
1023
1048
|
)
|
|
1024
1049
|
]
|
|
@@ -1026,64 +1051,64 @@ function tt() {
|
|
|
1026
1051
|
)
|
|
1027
1052
|
] });
|
|
1028
1053
|
}
|
|
1029
|
-
function
|
|
1030
|
-
const e =
|
|
1054
|
+
function it() {
|
|
1055
|
+
const e = _(null), t = _(null);
|
|
1031
1056
|
return { frontCanvasRef: e, backCanvasRef: t };
|
|
1032
1057
|
}
|
|
1033
|
-
async function
|
|
1058
|
+
async function Ue(e) {
|
|
1034
1059
|
const {
|
|
1035
1060
|
frontTemplateSrc: t,
|
|
1036
1061
|
backTemplateSrc: n,
|
|
1037
1062
|
templateWidth: a,
|
|
1038
1063
|
templateHeight: r,
|
|
1039
|
-
layout:
|
|
1064
|
+
layout: i,
|
|
1040
1065
|
portrait: c,
|
|
1041
1066
|
portraitZoom: s = 1,
|
|
1042
|
-
name:
|
|
1067
|
+
name: o,
|
|
1043
1068
|
email: d,
|
|
1044
1069
|
phone: h,
|
|
1045
1070
|
description: g
|
|
1046
1071
|
} = e, f = document.createElement("canvas"), b = document.createElement("canvas");
|
|
1047
1072
|
await Promise.all([
|
|
1048
|
-
|
|
1049
|
-
|
|
1073
|
+
le(f, t, c, o, i.front, a, r, s),
|
|
1074
|
+
ce(b, n, o, d, h, g, i.back, a, r)
|
|
1050
1075
|
]);
|
|
1051
|
-
const m = new
|
|
1076
|
+
const m = new xe({
|
|
1052
1077
|
orientation: "landscape",
|
|
1053
1078
|
unit: "mm",
|
|
1054
1079
|
format: "a4"
|
|
1055
|
-
}), S = 297,
|
|
1080
|
+
}), S = 297, k = 210, x = 10, A = a / r;
|
|
1056
1081
|
let y = S - x * 2, P = y / A;
|
|
1057
|
-
P >
|
|
1058
|
-
const L = (S - y) / 2,
|
|
1059
|
-
m.addImage(C, "JPEG", L,
|
|
1060
|
-
const
|
|
1061
|
-
return m.addImage(
|
|
1082
|
+
P > k - x * 2 && (P = k - x * 2, y = P * A);
|
|
1083
|
+
const L = (S - y) / 2, D = (k - P) / 2, C = f.toDataURL("image/jpeg", 0.95);
|
|
1084
|
+
m.addImage(C, "JPEG", L, D, y, P), m.addPage();
|
|
1085
|
+
const z = b.toDataURL("image/jpeg", 0.95);
|
|
1086
|
+
return m.addImage(z, "JPEG", L, D, y, P), m.output("blob");
|
|
1062
1087
|
}
|
|
1063
|
-
function
|
|
1088
|
+
function Fe(e, t) {
|
|
1064
1089
|
const n = URL.createObjectURL(e), a = document.createElement("a");
|
|
1065
1090
|
a.href = n, a.download = t, document.body.appendChild(a), a.click(), document.body.removeChild(a), URL.revokeObjectURL(n);
|
|
1066
1091
|
}
|
|
1067
|
-
async function
|
|
1068
|
-
const t = await
|
|
1069
|
-
|
|
1092
|
+
async function We(e) {
|
|
1093
|
+
const t = await Ue(e);
|
|
1094
|
+
Fe(t, e.filename);
|
|
1070
1095
|
}
|
|
1071
|
-
function
|
|
1072
|
-
const e =
|
|
1096
|
+
function st() {
|
|
1097
|
+
const e = v((m) => m.voucherConfig.language), t = v((m) => m.voucherConfig.hours), n = v((m) => m.voucherConfig.description), a = v((m) => m.personalInfo), r = v((m) => m.portrait), i = v((m) => m.isExporting), c = v((m) => m.setIsExporting), s = M(e), o = oe(e, t), d = re(e), h = r.useEnhanced && r.enhanced ? r.enhanced : r.original, g = te(e, t, n), f = a.name.trim().length > 0 && a.email.trim().length > 0 && a.phone.trim().length > 0 && r.original !== null;
|
|
1073
1098
|
return /* @__PURE__ */ l(
|
|
1074
1099
|
"button",
|
|
1075
1100
|
{
|
|
1076
|
-
className: `btn btn-primary flex-1 ${
|
|
1101
|
+
className: `btn btn-primary flex-1 ${i ? "loading" : ""}`,
|
|
1077
1102
|
onClick: async () => {
|
|
1078
|
-
if (!(!f ||
|
|
1103
|
+
if (!(!f || i)) {
|
|
1079
1104
|
c(!0);
|
|
1080
1105
|
try {
|
|
1081
1106
|
const m = `zeitgutschein-${t}h-${a.name.replace(/\s+/g, "-").toLowerCase()}.pdf`;
|
|
1082
|
-
await
|
|
1083
|
-
frontTemplateSrc:
|
|
1084
|
-
backTemplateSrc:
|
|
1085
|
-
templateWidth:
|
|
1086
|
-
templateHeight:
|
|
1107
|
+
await We({
|
|
1108
|
+
frontTemplateSrc: o.front,
|
|
1109
|
+
backTemplateSrc: o.back,
|
|
1110
|
+
templateWidth: o.width,
|
|
1111
|
+
templateHeight: o.height,
|
|
1087
1112
|
layout: d,
|
|
1088
1113
|
portrait: h,
|
|
1089
1114
|
portraitZoom: r.zoom,
|
|
@@ -1100,11 +1125,11 @@ function at() {
|
|
|
1100
1125
|
}
|
|
1101
1126
|
}
|
|
1102
1127
|
},
|
|
1103
|
-
disabled: !f ||
|
|
1104
|
-
children:
|
|
1128
|
+
disabled: !f || i,
|
|
1129
|
+
children: i ? /* @__PURE__ */ u(O, { children: [
|
|
1105
1130
|
/* @__PURE__ */ l("span", { className: "loading loading-spinner loading-sm" }),
|
|
1106
1131
|
s.export.exporting
|
|
1107
|
-
] }) : /* @__PURE__ */ u(
|
|
1132
|
+
] }) : /* @__PURE__ */ u(O, { children: [
|
|
1108
1133
|
/* @__PURE__ */ l(
|
|
1109
1134
|
"svg",
|
|
1110
1135
|
{
|
|
@@ -1129,8 +1154,8 @@ function at() {
|
|
|
1129
1154
|
}
|
|
1130
1155
|
);
|
|
1131
1156
|
}
|
|
1132
|
-
function
|
|
1133
|
-
const e =
|
|
1157
|
+
function je() {
|
|
1158
|
+
const e = v((a) => a.voucherConfig.language), t = v((a) => a.setLanguage), n = (a) => {
|
|
1134
1159
|
t(a);
|
|
1135
1160
|
};
|
|
1136
1161
|
return /* @__PURE__ */ u("div", { className: "join", children: [
|
|
@@ -1152,22 +1177,22 @@ function We() {
|
|
|
1152
1177
|
)
|
|
1153
1178
|
] });
|
|
1154
1179
|
}
|
|
1155
|
-
function
|
|
1156
|
-
const e =
|
|
1180
|
+
function lt() {
|
|
1181
|
+
const e = v((n) => n.voucherConfig.language), t = M(e);
|
|
1157
1182
|
return /* @__PURE__ */ u("div", { className: "navbar bg-currency-green text-currency-cream shadow-lg", children: [
|
|
1158
1183
|
/* @__PURE__ */ l("div", { className: "navbar-start", children: /* @__PURE__ */ l("a", { className: "btn btn-ghost text-xl font-currency font-bold", children: t.header.title }) }),
|
|
1159
1184
|
/* @__PURE__ */ l("div", { className: "navbar-center hidden sm:flex", children: /* @__PURE__ */ l("span", { className: "text-sm opacity-80", children: t.header.subtitle }) }),
|
|
1160
|
-
/* @__PURE__ */ l("div", { className: "navbar-end", children: /* @__PURE__ */ l(
|
|
1185
|
+
/* @__PURE__ */ l("div", { className: "navbar-end", children: /* @__PURE__ */ l(je, {}) })
|
|
1161
1186
|
] });
|
|
1162
1187
|
}
|
|
1163
|
-
const
|
|
1188
|
+
const F = "/", Ke = {
|
|
1164
1189
|
id: "time-voucher-classic-de",
|
|
1165
1190
|
name: "Zeitgutschein Classic",
|
|
1166
1191
|
type: "time-voucher",
|
|
1167
1192
|
category: "classic",
|
|
1168
1193
|
images: {
|
|
1169
|
-
front: `${
|
|
1170
|
-
back: `${
|
|
1194
|
+
front: `${F}templates/front_hdpi_de.jpg`,
|
|
1195
|
+
back: `${F}templates/back_hdpi_de.jpg`,
|
|
1171
1196
|
width: 6144,
|
|
1172
1197
|
height: 4096
|
|
1173
1198
|
},
|
|
@@ -1224,14 +1249,14 @@ const U = "/", Ke = {
|
|
|
1224
1249
|
}
|
|
1225
1250
|
},
|
|
1226
1251
|
languages: ["de"]
|
|
1227
|
-
},
|
|
1252
|
+
}, Oe = {
|
|
1228
1253
|
id: "time-voucher-classic-en",
|
|
1229
1254
|
name: "Time Voucher Classic",
|
|
1230
1255
|
type: "time-voucher",
|
|
1231
1256
|
category: "classic",
|
|
1232
1257
|
images: {
|
|
1233
|
-
front: `${
|
|
1234
|
-
back: `${
|
|
1258
|
+
front: `${F}templates/front_ldpi_en.png`,
|
|
1259
|
+
back: `${F}templates/back_ldpi_en.png`,
|
|
1235
1260
|
width: 1536,
|
|
1236
1261
|
height: 1024
|
|
1237
1262
|
},
|
|
@@ -1288,76 +1313,79 @@ const U = "/", Ke = {
|
|
|
1288
1313
|
}
|
|
1289
1314
|
},
|
|
1290
1315
|
languages: ["en"]
|
|
1291
|
-
},
|
|
1316
|
+
}, ee = [
|
|
1292
1317
|
Ke,
|
|
1293
|
-
|
|
1294
|
-
],
|
|
1318
|
+
Oe
|
|
1319
|
+
], Ye = {
|
|
1295
1320
|
async listTemplates(e) {
|
|
1296
|
-
let t = [...
|
|
1321
|
+
let t = [...ee];
|
|
1297
1322
|
return e != null && e.type && (t = t.filter((n) => n.type === e.type)), e != null && e.category && (t = t.filter((n) => n.category === e.category)), e != null && e.language && (t = t.filter((n) => n.languages.includes(e.language))), t;
|
|
1298
1323
|
},
|
|
1299
1324
|
async getTemplate(e) {
|
|
1300
|
-
const t =
|
|
1325
|
+
const t = ee.find((n) => n.id === e);
|
|
1301
1326
|
if (!t)
|
|
1302
1327
|
throw new Error(`Template not found: ${e}`);
|
|
1303
1328
|
return t;
|
|
1304
1329
|
}
|
|
1305
1330
|
};
|
|
1306
|
-
function
|
|
1331
|
+
function ct(e) {
|
|
1307
1332
|
return e === "de" ? "time-voucher-classic-de" : "time-voucher-classic-en";
|
|
1308
1333
|
}
|
|
1309
|
-
let
|
|
1310
|
-
function
|
|
1311
|
-
|
|
1334
|
+
let W = Ye;
|
|
1335
|
+
function dt(e) {
|
|
1336
|
+
W = e;
|
|
1312
1337
|
}
|
|
1313
|
-
function
|
|
1314
|
-
return
|
|
1338
|
+
function ht() {
|
|
1339
|
+
return W;
|
|
1315
1340
|
}
|
|
1316
|
-
async function
|
|
1317
|
-
return
|
|
1341
|
+
async function mt(e) {
|
|
1342
|
+
return W.listTemplates(e);
|
|
1318
1343
|
}
|
|
1319
|
-
async function
|
|
1320
|
-
return
|
|
1344
|
+
async function pt(e) {
|
|
1345
|
+
return W.getTemplate(e);
|
|
1321
1346
|
}
|
|
1322
1347
|
export {
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1348
|
+
Be as ApiKeyModal,
|
|
1349
|
+
ot as BillPreview,
|
|
1350
|
+
st as ExportButton,
|
|
1351
|
+
lt as Header,
|
|
1327
1352
|
B as LAYOUT_HDPI,
|
|
1328
1353
|
R as LAYOUT_LDPI,
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1354
|
+
je as LanguageToggle,
|
|
1355
|
+
Je as PersonalInfoForm,
|
|
1356
|
+
at as PortraitUpload,
|
|
1357
|
+
$e as TEMPLATES,
|
|
1358
|
+
rt as VoucherConfig,
|
|
1334
1359
|
Ne as applyEngravingEffect,
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1360
|
+
Fe as downloadBlob,
|
|
1361
|
+
He as drawContactInfo,
|
|
1362
|
+
ze as drawMultilineText,
|
|
1363
|
+
Me as drawOvalPortrait,
|
|
1364
|
+
ie as drawTemplate,
|
|
1365
|
+
se as drawText,
|
|
1366
|
+
nt as enhancePortrait,
|
|
1367
|
+
We as exportBillAsPDF,
|
|
1368
|
+
te as formatDescription,
|
|
1369
|
+
Ue as generateBillPDF,
|
|
1370
|
+
V as getApiKey,
|
|
1371
|
+
ct as getDefaultTemplateId,
|
|
1372
|
+
re as getLayout,
|
|
1373
|
+
et as getRemoveBackgroundEndpoint,
|
|
1374
|
+
oe as getTemplate,
|
|
1375
|
+
pt as getTemplateById,
|
|
1376
|
+
ht as getTemplateProvider,
|
|
1377
|
+
De as hasApiKey,
|
|
1378
|
+
tt as hasCustomEndpoint,
|
|
1379
|
+
mt as listTemplates,
|
|
1380
|
+
q as loadImage,
|
|
1354
1381
|
_e as removeBackground,
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1382
|
+
ce as renderBackSide,
|
|
1383
|
+
le as renderFrontSide,
|
|
1384
|
+
Le as setApiKey,
|
|
1385
|
+
Qe as setRemoveBackgroundEndpoint,
|
|
1386
|
+
dt as setTemplateProvider,
|
|
1387
|
+
Ye as staticTemplateProvider,
|
|
1388
|
+
M as t,
|
|
1389
|
+
it as useBillCanvasRefs,
|
|
1390
|
+
v as useBillStore
|
|
1363
1391
|
};
|