@antontranelis/money-printer 1.0.5 → 1.0.7

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.js CHANGED
@@ -1,9 +1,9 @@
1
- import { jsxs as f, jsx as l, Fragment as $ } from "react/jsx-runtime";
2
- import { create as he } from "zustand";
3
- import { persist as pe } from "zustand/middleware";
4
- import { useState as S, useCallback as C, useRef as L, useEffect as V } from "react";
5
- import me from "jspdf";
6
- const G = {
1
+ import { jsxs as m, jsx as l, Fragment as M } from "react/jsx-runtime";
2
+ import { create as fe } from "zustand";
3
+ import { persist as be } from "zustand/middleware";
4
+ import { useState as E, useCallback as C, useRef as $, useEffect as G } from "react";
5
+ import ye from "jspdf";
6
+ const V = {
7
7
  personalInfo: {
8
8
  name: "",
9
9
  email: "",
@@ -23,10 +23,10 @@ const G = {
23
23
  currentSide: "front",
24
24
  isEnhancing: !1,
25
25
  isExporting: !1
26
- }, y = he()(
27
- pe(
26
+ }, y = fe()(
27
+ be(
28
28
  (e) => ({
29
- ...G,
29
+ ...V,
30
30
  setPersonalInfo: (t) => e((a) => ({
31
31
  personalInfo: { ...a.personalInfo, ...t }
32
32
  })),
@@ -72,7 +72,7 @@ const G = {
72
72
  setHours: (t) => e((a) => ({
73
73
  voucherConfig: { ...a.voucherConfig, hours: t }
74
74
  })),
75
- reset: () => e(G)
75
+ reset: () => e(V)
76
76
  }),
77
77
  {
78
78
  name: "money-generator-storage",
@@ -82,7 +82,7 @@ const G = {
82
82
  })
83
83
  }
84
84
  )
85
- ), ue = {
85
+ ), we = {
86
86
  header: {
87
87
  title: "Money Generator",
88
88
  subtitle: "Erstelle deinen persönlichen Zeitgutschein"
@@ -129,7 +129,7 @@ const G = {
129
129
  bill: {
130
130
  descriptionText: "Für diesen Schein erhältst du {hours} {hourLabel} meiner Zeit oder ein gleichwertiges Dankeschön"
131
131
  }
132
- }, ge = {
132
+ }, ve = {
133
133
  header: {
134
134
  title: "Money Generator",
135
135
  subtitle: "Create your personal time voucher"
@@ -176,20 +176,20 @@ const G = {
176
176
  bill: {
177
177
  descriptionText: "This voucher entitles you to {hours} {hourLabel} of my time or an equivalent thank you"
178
178
  }
179
- }, fe = { de: ue, en: ge };
180
- function D(e) {
181
- return fe[e];
179
+ }, xe = { de: we, en: ve };
180
+ function z(e) {
181
+ return xe[e];
182
182
  }
183
183
  function J(e, t, a) {
184
184
  if (a && a.trim())
185
185
  return a;
186
- const n = D(e), r = t === 1 ? n.form.voucher.hourLabel : n.form.voucher.hoursLabel;
186
+ const n = z(e), r = t === 1 ? n.form.voucher.hourLabel : n.form.voucher.hoursLabel;
187
187
  return n.bill.descriptionText.replace("{hours}", t.toString()).replace("{hourLabel}", r);
188
188
  }
189
- function Oe() {
190
- const e = y((r) => r.voucherConfig.language), t = y((r) => r.personalInfo), a = y((r) => r.setPersonalInfo), n = D(e);
191
- return /* @__PURE__ */ f("div", { className: "space-y-4", children: [
192
- /* @__PURE__ */ f("div", { className: "form-control", children: [
189
+ function Ve() {
190
+ const e = y((r) => r.voucherConfig.language), t = y((r) => r.personalInfo), a = y((r) => r.setPersonalInfo), n = z(e);
191
+ return /* @__PURE__ */ m("div", { className: "space-y-4", children: [
192
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
193
193
  /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: n.form.personalInfo.name }) }),
194
194
  /* @__PURE__ */ l(
195
195
  "input",
@@ -202,7 +202,7 @@ function Oe() {
202
202
  }
203
203
  )
204
204
  ] }),
205
- /* @__PURE__ */ f("div", { className: "form-control", children: [
205
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
206
206
  /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: n.form.personalInfo.email }) }),
207
207
  /* @__PURE__ */ l(
208
208
  "input",
@@ -215,7 +215,7 @@ function Oe() {
215
215
  }
216
216
  )
217
217
  ] }),
218
- /* @__PURE__ */ f("div", { className: "form-control", children: [
218
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
219
219
  /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text font-medium", children: n.form.personalInfo.phone }) }),
220
220
  /* @__PURE__ */ l(
221
221
  "input",
@@ -230,7 +230,7 @@ function Oe() {
230
230
  ] })
231
231
  ] });
232
232
  }
233
- const K = {}, be = "https://api.stability.ai/v1/generation", ye = "https://api.stability.ai/v2beta/stable-image/edit/remove-background", Q = "stability_api_key", we = {
233
+ const j = {}, Ie = "https://api.stability.ai/v1/generation", ke = "https://api.stability.ai/v2beta/stable-image/edit/remove-background", Q = "stability_api_key", Ne = {
234
234
  vintage: "portrait in the style of vintage currency engraving, fine line work, crosshatching, sepia tones, detailed stippling, classic bank note portrait style",
235
235
  engraved: "portrait as detailed intaglio engraving, currency bill style, fine parallel lines, high contrast, official government portrait",
236
236
  currency: "portrait rendered as US dollar bill engraving, official currency portrait style, green tint, fine line engraving technique"
@@ -245,80 +245,80 @@ const K = {}, be = "https://api.stability.ai/v1/generation", ye = "https://api.s
245
245
  { width: 832, height: 1216 },
246
246
  { width: 896, height: 1152 }
247
247
  ];
248
- function ve(e, t) {
248
+ function Ee(e, t) {
249
249
  const a = e / t;
250
250
  let n = Z[0], r = 1 / 0;
251
- for (const i of Z) {
252
- const c = i.width / i.height, s = Math.abs(a - c);
253
- s < r && (r = s, n = i);
251
+ for (const s of Z) {
252
+ const d = s.width / s.height, o = Math.abs(a - d);
253
+ o < r && (r = o, n = s);
254
254
  }
255
255
  return n;
256
256
  }
257
- function xe(e) {
257
+ function Pe(e) {
258
258
  return new Promise((t, a) => {
259
259
  const n = new Image();
260
260
  n.onload = () => {
261
- const r = ve(n.width, n.height), i = document.createElement("canvas");
262
- i.width = r.width, i.height = r.height;
263
- const c = i.getContext("2d");
264
- if (!c) {
261
+ const r = Ee(n.width, n.height), s = document.createElement("canvas");
262
+ s.width = r.width, s.height = r.height;
263
+ const d = s.getContext("2d");
264
+ if (!d) {
265
265
  a(new Error("Failed to get canvas context"));
266
266
  return;
267
267
  }
268
- const s = n.width / n.height, o = r.width / r.height;
269
- let d = 0, p = 0, u = n.width, b = n.height;
270
- s > o ? (u = n.height * o, d = (n.width - u) / 2) : (b = n.width / o, p = (n.height - b) / 2), c.drawImage(n, d, p, u, b, 0, 0, r.width, r.height), t(i.toDataURL("image/png"));
268
+ const o = n.width / n.height, i = r.width / r.height;
269
+ let c = 0, u = 0, g = n.width, f = n.height;
270
+ o > i ? (g = n.height * i, c = (n.width - g) / 2) : (f = n.width / i, u = (n.height - f) / 2), d.drawImage(n, c, u, g, f, 0, 0, r.width, r.height), t(s.toDataURL("image/png"));
271
271
  }, n.onerror = () => a(new Error("Failed to load image")), n.src = e;
272
272
  });
273
273
  }
274
274
  function ee(e) {
275
- var c;
276
- const t = e.split(","), a = ((c = t[0].match(/:(.*?);/)) == null ? void 0 : c[1]) || "image/png", n = atob(t[1]), r = n.length, i = new Uint8Array(r);
277
- for (let s = 0; s < r; s++)
278
- i[s] = n.charCodeAt(s);
279
- return new Blob([i], { type: a });
275
+ var d;
276
+ const t = e.split(","), a = ((d = t[0].match(/:(.*?);/)) == null ? void 0 : d[1]) || "image/png", n = atob(t[1]), r = n.length, s = new Uint8Array(r);
277
+ for (let o = 0; o < r; o++)
278
+ s[o] = n.charCodeAt(o);
279
+ return new Blob([s], { type: a });
280
280
  }
281
- function Y() {
281
+ function q() {
282
282
  var t;
283
- const e = typeof import.meta < "u" && (K == null ? void 0 : K.VITE_STABILITY_API_KEY) || typeof process < "u" && ((t = process.env) == null ? void 0 : t.NEXT_PUBLIC_STABILITY_API_KEY);
283
+ const e = typeof import.meta < "u" && (j == null ? void 0 : j.VITE_STABILITY_API_KEY) || typeof process < "u" && ((t = process.env) == null ? void 0 : t.NEXT_PUBLIC_STABILITY_API_KEY);
284
284
  return e && e !== "your-api-key-here" ? e : typeof localStorage < "u" ? localStorage.getItem(Q) : null;
285
285
  }
286
- function ke(e) {
286
+ function Se(e) {
287
287
  localStorage.setItem(Q, e);
288
288
  }
289
- function Ie() {
290
- return Y() !== null;
289
+ function Ce() {
290
+ return q() !== null;
291
291
  }
292
- async function je(e) {
293
- const t = Y();
292
+ async function Ze(e) {
293
+ const t = q();
294
294
  if (!t)
295
295
  throw new Error("No Stability AI API key configured");
296
- const { imageDataUrl: a, style: n, strength: r = 0.35 } = e, i = await xe(a), c = ee(i), s = new FormData();
297
- 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]", we[n]), s.append("text_prompts[0][weight]", "1"), s.append("cfg_scale", "7"), s.append("samples", "1"), s.append("steps", "30");
298
- const d = await fetch(`${be}/stable-diffusion-xl-1024-v1-0/image-to-image`, {
296
+ const { imageDataUrl: a, style: n, strength: r = 0.35 } = e, s = await Pe(a), d = ee(s), o = new FormData();
297
+ o.append("init_image", d, "portrait.png"), o.append("init_image_mode", "IMAGE_STRENGTH"), o.append("image_strength", String(1 - r)), o.append("text_prompts[0][text]", Ne[n]), o.append("text_prompts[0][weight]", "1"), o.append("cfg_scale", "7"), o.append("samples", "1"), o.append("steps", "30");
298
+ const c = await fetch(`${Ie}/stable-diffusion-xl-1024-v1-0/image-to-image`, {
299
299
  method: "POST",
300
300
  headers: {
301
301
  Authorization: `Bearer ${t}`,
302
302
  Accept: "application/json"
303
303
  },
304
- body: s
304
+ body: o
305
305
  });
306
- if (!d.ok) {
307
- const u = await d.text();
308
- throw console.error("Stability AI error:", u), d.status === 401 ? new Error("Invalid API key") : d.status === 402 ? new Error("Insufficient credits") : d.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${d.status}`);
306
+ if (!c.ok) {
307
+ const g = await c.text();
308
+ throw console.error("Stability AI error:", g), c.status === 401 ? new Error("Invalid API key") : c.status === 402 ? new Error("Insufficient credits") : c.status === 429 ? new Error("Rate limit exceeded. Please try again later.") : new Error(`API error: ${c.status}`);
309
309
  }
310
- const p = await d.json();
311
- if (!p.artifacts || p.artifacts.length === 0)
310
+ const u = await c.json();
311
+ if (!u.artifacts || u.artifacts.length === 0)
312
312
  throw new Error("No image generated");
313
- return `data:image/png;base64,${p.artifacts[0].base64}`;
313
+ return `data:image/png;base64,${u.artifacts[0].base64}`;
314
314
  }
315
- async function Ee(e) {
316
- const t = Y();
315
+ async function Ae(e) {
316
+ const t = q();
317
317
  if (!t)
318
318
  throw new Error("No Stability AI API key configured");
319
319
  const a = ee(e), n = new FormData();
320
320
  n.append("image", a, "image.png"), n.append("output_format", "png");
321
- const r = await fetch(ye, {
321
+ const r = await fetch(ke, {
322
322
  method: "POST",
323
323
  headers: {
324
324
  Authorization: `Bearer ${t}`,
@@ -327,63 +327,62 @@ async function Ee(e) {
327
327
  body: n
328
328
  });
329
329
  if (!r.ok) {
330
- const c = await r.text();
331
- 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}`);
330
+ const d = await r.text();
331
+ throw console.error("Stability AI remove background error:", d), 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}`);
332
332
  }
333
- const i = await r.blob();
334
- return new Promise((c, s) => {
335
- const o = new FileReader();
336
- o.onload = () => c(o.result), o.onerror = () => s(new Error("Failed to read result")), o.readAsDataURL(i);
333
+ const s = await r.blob();
334
+ return new Promise((d, o) => {
335
+ const i = new FileReader();
336
+ i.onload = () => d(i.result), i.onerror = () => o(new Error("Failed to read result")), i.readAsDataURL(s);
337
337
  });
338
338
  }
339
- async function Pe(e) {
339
+ async function Te(e) {
340
340
  return new Promise((t, a) => {
341
341
  const n = new Image();
342
342
  n.onload = () => {
343
- const r = document.createElement("canvas"), i = r.getContext("2d");
344
- if (!i) {
343
+ const r = document.createElement("canvas"), s = r.getContext("2d");
344
+ if (!s) {
345
345
  a(new Error("Failed to get canvas context"));
346
346
  return;
347
347
  }
348
- r.width = n.width, r.height = n.height, i.drawImage(n, 0, 0);
349
- const c = i.getImageData(0, 0, r.width, r.height), s = c.data;
350
- for (let o = 0; o < s.length; o += 4) {
351
- const d = s[o], p = s[o + 1], u = s[o + 2];
352
- if (s[o + 3] === 0) continue;
353
- const g = 0.299 * d + 0.587 * p + 0.114 * u, h = 1.4;
354
- let v = 259 * (h * 255 + 255) / (255 * (259 - h * 255)) * (g - 128) + 128;
355
- v = Math.max(0, Math.min(255, v));
356
- const I = Math.min(255, v * 1.1 + 20), P = Math.min(255, v * 0.95 + 10), w = Math.min(255, v * 0.8);
357
- s[o] = I, s[o + 1] = P, s[o + 2] = w;
348
+ r.width = n.width, r.height = n.height, s.drawImage(n, 0, 0);
349
+ const d = s.getImageData(0, 0, r.width, r.height), o = d.data;
350
+ for (let i = 0; i < o.length; i += 4) {
351
+ const c = o[i], u = o[i + 1], g = o[i + 2];
352
+ if (o[i + 3] === 0) continue;
353
+ let x = (((0.299 * c + 0.587 * u + 0.114 * g) / 255 - 0.5) * 1.15 + 0.5) * 255;
354
+ x = Math.max(0, Math.min(255, x));
355
+ const k = Math.min(255, x * 0.95 + 30), v = Math.min(255, x * 0.85 + 20), S = Math.min(255, x * 0.65 + 10);
356
+ o[i] = k, o[i + 1] = v, o[i + 2] = S;
358
357
  }
359
- i.putImageData(c, 0, 0), t(r.toDataURL("image/png"));
358
+ s.putImageData(d, 0, 0), t(r.toDataURL("image/png"));
360
359
  }, n.onerror = () => a(new Error("Failed to load image")), n.src = e;
361
360
  });
362
361
  }
363
- function Ne() {
364
- const [e, t] = S(!1), [a, n] = S(!1), [r, i] = S(null), [c, s] = S(Ie()), o = C(() => i(null), []), d = C((b) => {
365
- ke(b), s(!0), i(null);
366
- }, []), p = C(
367
- async (b, g = "vintage") => {
368
- t(!0), i(null);
362
+ function Le() {
363
+ const [e, t] = E(!1), [a, n] = E(!1), [r, s] = E(null), [d, o] = E(Ce()), i = C(() => s(null), []), c = C((f) => {
364
+ Se(f), o(!0), s(null);
365
+ }, []), u = C(
366
+ async (f, b = "vintage") => {
367
+ t(!0), s(null);
369
368
  try {
370
- return await Pe(b);
369
+ return await Te(f);
371
370
  } catch (h) {
372
- const E = h instanceof Error ? h.message : "Enhancement failed";
373
- throw i(E), h;
371
+ const x = h instanceof Error ? h.message : "Enhancement failed";
372
+ throw s(x), h;
374
373
  } finally {
375
374
  t(!1);
376
375
  }
377
376
  },
378
377
  []
379
- ), u = C(
380
- async (b) => {
381
- n(!0), i(null);
378
+ ), g = C(
379
+ async (f) => {
380
+ n(!0), s(null);
382
381
  try {
383
- return await Ee(b);
384
- } catch (g) {
385
- const h = g instanceof Error ? g.message : "Background removal failed";
386
- throw i(h), g;
382
+ return await Ae(f);
383
+ } catch (b) {
384
+ const h = b instanceof Error ? b.message : "Background removal failed";
385
+ throw s(h), b;
387
386
  } finally {
388
387
  n(!1);
389
388
  }
@@ -391,22 +390,22 @@ function Ne() {
391
390
  []
392
391
  );
393
392
  return {
394
- enhance: p,
395
- removeBg: u,
393
+ enhance: u,
394
+ removeBg: g,
396
395
  isEnhancing: e,
397
396
  isRemovingBg: a,
398
397
  error: r,
399
- hasKey: c,
400
- setApiKey: d,
401
- clearError: o
398
+ hasKey: d,
399
+ setApiKey: c,
400
+ clearError: i
402
401
  };
403
402
  }
404
- function Se({ isOpen: e, onClose: t, onSubmit: a }) {
405
- const n = y((d) => d.voucherConfig.language), [r, i] = S("");
403
+ function De({ isOpen: e, onClose: t, onSubmit: a }) {
404
+ const n = y((c) => c.voucherConfig.language), [r, s] = E("");
406
405
  if (!e) return null;
407
- const c = (d) => {
408
- d.preventDefault(), r.trim() && (a(r.trim()), i(""), t());
409
- }, o = {
406
+ const d = (c) => {
407
+ c.preventDefault(), r.trim() && (a(r.trim()), s(""), t());
408
+ }, i = {
410
409
  de: {
411
410
  title: "Stability AI API Key",
412
411
  description: "Um die AI-Bildverbesserung zu nutzen, benötigst du einen Stability AI API Key. Du kannst ihn auf platform.stability.ai erhalten.",
@@ -424,104 +423,104 @@ function Se({ isOpen: e, onClose: t, onSubmit: a }) {
424
423
  hint: "The key is stored locally in your browser."
425
424
  }
426
425
  }[n];
427
- return /* @__PURE__ */ f("dialog", { className: "modal modal-open", children: [
428
- /* @__PURE__ */ f("div", { className: "modal-box", children: [
429
- /* @__PURE__ */ l("h3", { className: "font-bold text-lg", children: o.title }),
430
- /* @__PURE__ */ l("p", { className: "py-4 text-sm opacity-80", children: o.description }),
431
- /* @__PURE__ */ f("form", { onSubmit: c, children: [
432
- /* @__PURE__ */ f("div", { className: "form-control", children: [
426
+ return /* @__PURE__ */ m("dialog", { className: "modal modal-open", children: [
427
+ /* @__PURE__ */ m("div", { className: "modal-box", children: [
428
+ /* @__PURE__ */ l("h3", { className: "font-bold text-lg", children: i.title }),
429
+ /* @__PURE__ */ l("p", { className: "py-4 text-sm opacity-80", children: i.description }),
430
+ /* @__PURE__ */ m("form", { onSubmit: d, children: [
431
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
433
432
  /* @__PURE__ */ l(
434
433
  "input",
435
434
  {
436
435
  type: "password",
437
- placeholder: o.placeholder,
436
+ placeholder: i.placeholder,
438
437
  className: "input input-bordered w-full",
439
438
  value: r,
440
- onChange: (d) => i(d.target.value),
439
+ onChange: (c) => s(c.target.value),
441
440
  autoFocus: !0
442
441
  }
443
442
  ),
444
- /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text-alt", children: o.hint }) })
443
+ /* @__PURE__ */ l("label", { className: "label", children: /* @__PURE__ */ l("span", { className: "label-text-alt", children: i.hint }) })
445
444
  ] }),
446
- /* @__PURE__ */ f("div", { className: "modal-action", children: [
447
- /* @__PURE__ */ l("button", { type: "button", className: "btn btn-ghost", onClick: t, children: o.cancel }),
448
- /* @__PURE__ */ l("button", { type: "submit", className: "btn btn-primary", disabled: !r.trim(), children: o.submit })
445
+ /* @__PURE__ */ m("div", { className: "modal-action", children: [
446
+ /* @__PURE__ */ l("button", { type: "button", className: "btn btn-ghost", onClick: t, children: i.cancel }),
447
+ /* @__PURE__ */ l("button", { type: "submit", className: "btn btn-primary", disabled: !r.trim(), children: i.submit })
449
448
  ] })
450
449
  ] })
451
450
  ] }),
452
451
  /* @__PURE__ */ l("form", { method: "dialog", className: "modal-backdrop", children: /* @__PURE__ */ l("button", { onClick: t, children: "close" }) })
453
452
  ] });
454
453
  }
455
- function Ye() {
456
- const e = y((m) => m.voucherConfig.language), t = y((m) => m.portrait), a = y((m) => m.setPortrait), n = y((m) => m.setEnhancedPortrait), r = y((m) => m.toggleUseEnhanced), i = y((m) => m.setPortraitZoom), { enhance: c, removeBg: s, isEnhancing: o, isRemovingBg: d, error: p, hasKey: u, setApiKey: b } = Ne(), g = D(e), h = L(null), [E, v] = S(!1), [I, P] = S(!1), w = C(
457
- async (m) => {
458
- if (!m.type.startsWith("image/"))
454
+ function Xe() {
455
+ const e = y((p) => p.voucherConfig.language), t = y((p) => p.portrait), a = y((p) => p.setPortrait), n = y((p) => p.setPortraitZoom), { enhance: r, removeBg: s, isEnhancing: d, isRemovingBg: o, error: i, hasKey: c, setApiKey: u } = Le(), g = z(e), f = $(null), [b, h] = E(!1), [x, k] = E(!1), [v, S] = E(null), [w, N] = E(!1), [T, L] = E(!1), H = C(
456
+ async (p) => {
457
+ if (!p.type.startsWith("image/"))
459
458
  return;
460
- const x = new FileReader();
461
- x.onload = async (R) => {
462
- var q;
463
- const F = (q = R.target) == null ? void 0 : q.result;
464
- if (u)
465
- try {
466
- const W = await s(F);
467
- a(W);
468
- } catch (W) {
469
- console.error("Background removal failed, using original:", W), a(F);
470
- }
471
- else
472
- a(F);
473
- }, x.readAsDataURL(m);
459
+ const P = new FileReader();
460
+ P.onload = async (D) => {
461
+ var _;
462
+ const A = (_ = D.target) == null ? void 0 : _.result;
463
+ S(A), a(A), N(!1), L(!1);
464
+ }, P.readAsDataURL(p);
474
465
  },
475
- [a, u, s]
476
- ), N = C(
477
- (m) => {
478
- m.preventDefault(), v(!1);
479
- const x = m.dataTransfer.files[0];
480
- x && w(x);
466
+ [a]
467
+ ), W = C(
468
+ (p) => {
469
+ p.preventDefault(), h(!1);
470
+ const P = p.dataTransfer.files[0];
471
+ P && H(P);
481
472
  },
482
- [w]
483
- ), _ = C((m) => {
484
- m.preventDefault(), v(!0);
485
- }, []), B = C((m) => {
486
- m.preventDefault(), v(!1);
487
- }, []), U = () => {
488
- var m;
489
- (m = h.current) == null || m.click();
490
- }, H = (m) => {
491
- var R;
492
- const x = (R = m.target.files) == null ? void 0 : R[0];
493
- x && w(x);
494
- }, se = async () => {
495
- if (t.original) {
496
- if (!u) {
497
- P(!0);
498
- return;
499
- }
473
+ [H]
474
+ ), se = C((p) => {
475
+ p.preventDefault(), h(!0);
476
+ }, []), le = C((p) => {
477
+ p.preventDefault(), h(!1);
478
+ }, []), ce = () => {
479
+ var p;
480
+ (p = f.current) == null || p.click();
481
+ }, de = (p) => {
482
+ var D;
483
+ const P = (D = p.target.files) == null ? void 0 : D[0];
484
+ P && H(P);
485
+ }, K = C(async (p, P, D) => {
486
+ let A = p;
487
+ if (P && c)
500
488
  try {
501
- const m = await c(t.original, "vintage");
502
- n(m);
503
- } catch (m) {
504
- console.error("Enhancement failed:", m);
489
+ A = await s(A);
490
+ } catch (_) {
491
+ console.error("Background removal failed:", _);
505
492
  }
506
- }
507
- }, le = async (m) => {
508
- if (b(m), t.original)
493
+ if (D)
509
494
  try {
510
- const x = await c(t.original, "vintage");
511
- n(x);
512
- } catch (x) {
513
- console.error("Enhancement failed:", x);
495
+ A = await r(A, "vintage");
496
+ } catch (_) {
497
+ console.error("Enhancement failed:", _);
514
498
  }
515
- }, ce = () => {
516
- a(null);
517
- }, de = t.useEnhanced && t.enhanced ? t.enhanced : t.original;
518
- return /* @__PURE__ */ f("div", { className: "space-y-4", children: [
519
- t.original ? /* @__PURE__ */ f("div", { className: "space-y-4", children: [
520
- /* @__PURE__ */ l("div", { className: "flex justify-center", children: /* @__PURE__ */ f("div", { className: "relative", children: [
499
+ a(A);
500
+ }, [c, s, r, a]), he = async () => {
501
+ if (!v) return;
502
+ if (!w && !c) {
503
+ k(!0);
504
+ return;
505
+ }
506
+ const p = !w;
507
+ N(p), await K(v, p, T);
508
+ }, pe = async () => {
509
+ if (!v) return;
510
+ const p = !T;
511
+ L(p), await K(v, w, p);
512
+ }, me = async (p) => {
513
+ u(p), v && (N(!0), await K(v, !0, T));
514
+ }, ue = () => {
515
+ a(null), S(null), N(!1), L(!1);
516
+ }, ge = t.original;
517
+ return /* @__PURE__ */ m("div", { className: "space-y-4", children: [
518
+ t.original ? /* @__PURE__ */ m("div", { className: "space-y-4", children: [
519
+ /* @__PURE__ */ l("div", { className: "flex justify-center", children: /* @__PURE__ */ m("div", { className: "relative", children: [
521
520
  /* @__PURE__ */ l("div", { className: "w-32 h-32 rounded-full overflow-hidden border-4 border-currency-gold shadow-lg", children: /* @__PURE__ */ l(
522
521
  "img",
523
522
  {
524
- src: de || "",
523
+ src: ge || "",
525
524
  alt: "Portrait",
526
525
  className: "w-full h-full object-cover",
527
526
  style: { transform: `scale(${t.zoom})` }
@@ -531,7 +530,7 @@ function Ye() {
531
530
  "button",
532
531
  {
533
532
  className: "btn btn-circle btn-xs btn-error absolute -top-1 -right-1",
534
- onClick: ce,
533
+ onClick: ue,
535
534
  children: /* @__PURE__ */ l(
536
535
  "svg",
537
536
  {
@@ -554,10 +553,10 @@ function Ye() {
554
553
  }
555
554
  )
556
555
  ] }) }),
557
- /* @__PURE__ */ f("div", { className: "form-control", children: [
558
- /* @__PURE__ */ f("label", { className: "label", children: [
556
+ /* @__PURE__ */ m("div", { className: "form-control", children: [
557
+ /* @__PURE__ */ m("label", { className: "label", children: [
559
558
  /* @__PURE__ */ l("span", { className: "label-text", children: g.form.portrait.zoom }),
560
- /* @__PURE__ */ f("span", { className: "label-text-alt", children: [
559
+ /* @__PURE__ */ m("span", { className: "label-text-alt", children: [
561
560
  Math.round(t.zoom * 100),
562
561
  "%"
563
562
  ] })
@@ -570,85 +569,75 @@ function Ye() {
570
569
  max: "2",
571
570
  step: "0.05",
572
571
  value: t.zoom,
573
- onChange: (m) => i(parseFloat(m.target.value)),
572
+ onChange: (p) => n(parseFloat(p.target.value)),
574
573
  className: "range range-primary range-sm"
575
574
  }
576
575
  )
577
576
  ] }),
578
- u && /* @__PURE__ */ f("div", { className: "flex flex-col gap-2", children: [
579
- /* @__PURE__ */ l(
580
- "button",
581
- {
582
- className: `btn btn-secondary ${o ? "loading" : ""}`,
583
- onClick: se,
584
- disabled: o,
585
- children: o ? /* @__PURE__ */ f($, { children: [
586
- /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-sm" }),
587
- g.form.portrait.enhancing
588
- ] }) : /* @__PURE__ */ f($, { children: [
589
- /* @__PURE__ */ l(
590
- "svg",
591
- {
592
- xmlns: "http://www.w3.org/2000/svg",
593
- className: "h-5 w-5 mr-1",
594
- fill: "none",
595
- viewBox: "0 0 24 24",
596
- stroke: "currentColor",
597
- children: /* @__PURE__ */ l(
598
- "path",
599
- {
600
- strokeLinecap: "round",
601
- strokeLinejoin: "round",
602
- strokeWidth: 2,
603
- d: "M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"
604
- }
605
- )
606
- }
607
- ),
608
- g.form.portrait.enhance
609
- ] })
610
- }
611
- ),
612
- p && /* @__PURE__ */ f("div", { className: "alert alert-warning text-sm py-2", children: [
613
- /* @__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" }) }),
614
- /* @__PURE__ */ l("span", { children: p })
615
- ] }),
616
- t.enhanced && /* @__PURE__ */ l("div", { className: "form-control", children: /* @__PURE__ */ f("label", { className: "label cursor-pointer justify-start gap-3", children: [
577
+ /* @__PURE__ */ m("div", { className: "flex flex-col gap-3", children: [
578
+ /* @__PURE__ */ l("div", { className: "form-control", children: /* @__PURE__ */ m("label", { className: "label cursor-pointer justify-start gap-3", children: [
579
+ /* @__PURE__ */ l(
580
+ "input",
581
+ {
582
+ type: "checkbox",
583
+ className: `toggle toggle-primary ${o ? "opacity-50" : ""}`,
584
+ checked: w,
585
+ onChange: he,
586
+ disabled: o
587
+ }
588
+ ),
589
+ /* @__PURE__ */ m("span", { className: "label-text flex items-center gap-2", children: [
590
+ o ? /* @__PURE__ */ m(M, { children: [
591
+ /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-xs" }),
592
+ e === "de" ? "Hintergrund wird entfernt..." : "Removing background..."
593
+ ] }) : e === "de" ? "Hintergrund entfernen" : "Remove background",
594
+ !c && /* @__PURE__ */ l("span", { className: "badge badge-sm badge-outline", children: "API" })
595
+ ] })
596
+ ] }) }),
597
+ /* @__PURE__ */ l("div", { className: "form-control", children: /* @__PURE__ */ m("label", { className: "label cursor-pointer justify-start gap-3", children: [
617
598
  /* @__PURE__ */ l(
618
599
  "input",
619
600
  {
620
601
  type: "checkbox",
621
- className: "toggle toggle-primary",
622
- checked: t.useEnhanced,
623
- onChange: r
602
+ className: `toggle toggle-secondary ${d ? "opacity-50" : ""}`,
603
+ checked: T,
604
+ onChange: pe,
605
+ disabled: d
624
606
  }
625
607
  ),
626
- /* @__PURE__ */ l("span", { className: "label-text", children: t.useEnhanced ? g.form.portrait.useEnhanced : g.form.portrait.useOriginal })
627
- ] }) })
608
+ /* @__PURE__ */ l("span", { className: "label-text flex items-center gap-2", children: d ? /* @__PURE__ */ m(M, { children: [
609
+ /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-xs" }),
610
+ e === "de" ? "Gravur-Effekt wird angewendet..." : "Applying engraving effect..."
611
+ ] }) : e === "de" ? "Gravur-Effekt" : "Engraving effect" })
612
+ ] }) }),
613
+ i && /* @__PURE__ */ m("div", { className: "alert alert-warning text-sm py-2", children: [
614
+ /* @__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" }) }),
615
+ /* @__PURE__ */ l("span", { children: i })
616
+ ] })
628
617
  ] })
629
- ] }) : /* @__PURE__ */ f(
618
+ ] }) : /* @__PURE__ */ m(
630
619
  "div",
631
620
  {
632
- className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${d ? "border-primary bg-primary/10 pointer-events-none" : E ? "border-primary bg-primary/10" : "border-base-300 hover:border-primary hover:bg-base-200"}`,
633
- onDrop: N,
634
- onDragOver: _,
635
- onDragLeave: B,
636
- onClick: U,
621
+ className: `border-2 border-dashed rounded-lg p-8 text-center cursor-pointer transition-colors ${o ? "border-primary bg-primary/10 pointer-events-none" : b ? "border-primary bg-primary/10" : "border-base-300 hover:border-primary hover:bg-base-200"}`,
622
+ onDrop: W,
623
+ onDragOver: se,
624
+ onDragLeave: le,
625
+ onClick: ce,
637
626
  children: [
638
627
  /* @__PURE__ */ l(
639
628
  "input",
640
629
  {
641
- ref: h,
630
+ ref: f,
642
631
  type: "file",
643
632
  accept: "image/*",
644
633
  className: "hidden",
645
- onChange: H
634
+ onChange: de
646
635
  }
647
636
  ),
648
- d ? /* @__PURE__ */ f("div", { className: "flex flex-col items-center gap-2", children: [
637
+ o ? /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2", children: [
649
638
  /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-lg text-primary" }),
650
639
  /* @__PURE__ */ l("p", { className: "font-medium", children: e === "de" ? "Hintergrund wird entfernt..." : "Removing background..." })
651
- ] }) : /* @__PURE__ */ f("div", { className: "flex flex-col items-center gap-2", children: [
640
+ ] }) : /* @__PURE__ */ m("div", { className: "flex flex-col items-center gap-2", children: [
652
641
  /* @__PURE__ */ l(
653
642
  "svg",
654
643
  {
@@ -675,60 +664,60 @@ function Ye() {
675
664
  }
676
665
  ),
677
666
  /* @__PURE__ */ l(
678
- Se,
667
+ De,
679
668
  {
680
- isOpen: I,
681
- onClose: () => P(!1),
682
- onSubmit: le
669
+ isOpen: x,
670
+ onClose: () => k(!1),
671
+ onSubmit: me
683
672
  }
684
673
  )
685
674
  ] });
686
675
  }
687
- function qe() {
676
+ function Je() {
688
677
  return null;
689
678
  }
690
- const k = typeof import.meta < "u" && "/" || "/", Ce = {
679
+ const I = typeof import.meta < "u" && "/" || "/", _e = {
691
680
  en: {
692
681
  1: {
693
- front: `${k}templates/front_ldpi_en.png`,
694
- back: `${k}templates/back_ldpi_en.png`,
682
+ front: `${I}templates/front_ldpi_en.png`,
683
+ back: `${I}templates/back_ldpi_en.png`,
695
684
  width: 1536,
696
685
  height: 1024
697
686
  },
698
687
  5: {
699
- front: `${k}templates/front_ldpi_en.png`,
700
- back: `${k}templates/back_ldpi_en.png`,
688
+ front: `${I}templates/front_ldpi_en.png`,
689
+ back: `${I}templates/back_ldpi_en.png`,
701
690
  width: 1536,
702
691
  height: 1024
703
692
  },
704
693
  10: {
705
- front: `${k}templates/front_ldpi_en.png`,
706
- back: `${k}templates/back_ldpi_en.png`,
694
+ front: `${I}templates/front_ldpi_en.png`,
695
+ back: `${I}templates/back_ldpi_en.png`,
707
696
  width: 1536,
708
697
  height: 1024
709
698
  }
710
699
  },
711
700
  de: {
712
701
  1: {
713
- front: `${k}templates/front_hdpi_de.webp`,
714
- back: `${k}templates/back_hdpi_de.webp`,
702
+ front: `${I}templates/front_hdpi_de.webp`,
703
+ back: `${I}templates/back_hdpi_de.webp`,
715
704
  width: 6144,
716
705
  height: 3200
717
706
  },
718
707
  5: {
719
- front: `${k}templates/front_hdpi_de.webp`,
720
- back: `${k}templates/back_hdpi_de.webp`,
708
+ front: `${I}templates/front_hdpi_de.webp`,
709
+ back: `${I}templates/back_hdpi_de.webp`,
721
710
  width: 6144,
722
711
  height: 3200
723
712
  },
724
713
  10: {
725
- front: `${k}templates/front_hdpi_de.webp`,
726
- back: `${k}templates/back_hdpi_de.webp`,
714
+ front: `${I}templates/front_hdpi_de.webp`,
715
+ back: `${I}templates/back_hdpi_de.webp`,
727
716
  width: 6144,
728
717
  height: 3200
729
718
  }
730
719
  }
731
- }, T = {
720
+ }, B = {
732
721
  front: {
733
722
  portrait: {
734
723
  x: 768,
@@ -774,7 +763,7 @@ const k = typeof import.meta < "u" && "/" || "/", Ce = {
774
763
  align: "center"
775
764
  }
776
765
  }
777
- }, A = {
766
+ }, R = {
778
767
  front: {
779
768
  portrait: {
780
769
  x: 3074,
@@ -822,13 +811,13 @@ const k = typeof import.meta < "u" && "/" || "/", Ce = {
822
811
  }
823
812
  };
824
813
  function te(e) {
825
- return e === "de" ? A : T;
814
+ return e === "de" ? R : B;
826
815
  }
827
816
  function ne(e, t) {
828
- return Ce[e][t];
817
+ return _e[e][t];
829
818
  }
830
819
  const O = /* @__PURE__ */ new Map();
831
- async function j(e) {
820
+ async function Y(e) {
832
821
  return O.has(e) ? O.get(e) : new Promise((t, a) => {
833
822
  const n = new Image();
834
823
  n.crossOrigin = "anonymous", n.onload = () => {
@@ -839,121 +828,121 @@ async function j(e) {
839
828
  function ae(e, t, a, n) {
840
829
  e.drawImage(t, 0, 0, a, n);
841
830
  }
842
- function Te(e, t, a, n, r, i, c = 1) {
843
- e.save(), e.beginPath(), e.ellipse(a, n, r, i, 0, 0, Math.PI * 2), e.closePath(), e.clip();
844
- const s = t.width / t.height, o = r / i, d = r * 2, p = i * 2;
845
- let u, b;
846
- s > o ? (b = p, u = p * s) : (u = d, b = d / s), u *= c, b *= c;
847
- const g = a - u / 2, h = n - b / 2;
848
- e.drawImage(t, g, h, u, b), e.restore();
831
+ function Be(e, t, a, n, r, s, d = 1) {
832
+ e.save(), e.beginPath(), e.ellipse(a, n, r, s, 0, 0, Math.PI * 2), e.closePath(), e.clip();
833
+ const o = t.width / t.height, i = r / s, c = r * 2, u = s * 2;
834
+ let g, f;
835
+ o > i ? (f = u, g = u * o) : (g = c, f = c / o), g *= d, f *= d;
836
+ const b = a - g / 2, h = n - f / 2;
837
+ e.drawImage(t, b, h, g, f), e.restore();
849
838
  }
850
839
  function re(e, t, a, n = "#2a3a2a") {
851
840
  e.save(), e.font = `${a.fontSize}px "Times New Roman", serif`, e.textAlign = a.align || "center", e.textBaseline = "middle", e.fillStyle = n, a.maxWidth ? e.fillText(t, a.x, a.y, a.maxWidth) : e.fillText(t, a.x, a.y), e.restore();
852
841
  }
853
- function Ae(e, t, a, n = "#2a3a2a") {
842
+ function Re(e, t, a, n = "#2a3a2a") {
854
843
  e.save(), e.font = `${a.fontSize}px "Times New Roman", serif`, e.textAlign = a.align || "center", e.textBaseline = "top", e.fillStyle = n;
855
- const r = a.maxWidth || 400, i = a.lineHeight || a.fontSize * 1.4, c = t.split(" "), s = [];
856
- let o = "";
857
- for (const u of c) {
858
- const b = o ? `${o} ${u}` : u;
859
- e.measureText(b).width > r && o ? (s.push(o), o = u) : o = b;
844
+ const r = a.maxWidth || 400, s = a.lineHeight || a.fontSize * 1.4, d = t.split(" "), o = [];
845
+ let i = "";
846
+ for (const g of d) {
847
+ const f = i ? `${i} ${g}` : g;
848
+ e.measureText(f).width > r && i ? (o.push(i), i = g) : i = f;
860
849
  }
861
- o && s.push(o);
862
- const d = s.length * i;
863
- let p = a.y - d / 2;
864
- for (const u of s)
865
- e.fillText(u, a.x, p), p += i;
850
+ i && o.push(i);
851
+ const c = o.length * s;
852
+ let u = a.y - c / 2;
853
+ for (const g of o)
854
+ e.fillText(g, a.x, u), u += s;
866
855
  e.restore();
867
856
  }
868
- function Le(e, t, a, n, r, i = "#2a3a2a") {
869
- e.save(), e.font = `${r.fontSize}px "Times New Roman", serif`, e.textAlign = r.align || "center", e.textBaseline = "middle", e.fillStyle = i;
870
- const c = r.lineHeight || r.fontSize * 1.8, s = [t, a, n].filter(Boolean), o = (s.length - 1) * c;
871
- let d = r.y - o / 2;
872
- for (const p of s)
873
- p && (e.fillText(p, r.x, d), d += c);
857
+ function $e(e, t, a, n, r, s = "#2a3a2a") {
858
+ e.save(), e.font = `${r.fontSize}px "Times New Roman", serif`, e.textAlign = r.align || "center", e.textBaseline = "middle", e.fillStyle = s;
859
+ const d = r.lineHeight || r.fontSize * 1.8, o = [t, a, n].filter(Boolean), i = (o.length - 1) * d;
860
+ let c = r.y - i / 2;
861
+ for (const u of o)
862
+ u && (e.fillText(u, r.x, c), c += d);
874
863
  e.restore();
875
864
  }
876
- async function oe(e, t, a, n, r, i, c, s = 1) {
877
- const o = e.getContext("2d");
878
- if (!o) return;
879
- e.width = i, e.height = c, o.clearRect(0, 0, i, c);
880
- const d = await j(t);
881
- if (ae(o, d, i, c), a)
865
+ async function oe(e, t, a, n, r, s, d, o = 1) {
866
+ const i = e.getContext("2d");
867
+ if (!i) return;
868
+ e.width = s, e.height = d, i.clearRect(0, 0, s, d);
869
+ const c = await Y(t);
870
+ if (ae(i, c, s, d), a)
882
871
  try {
883
- const p = await j(a);
884
- Te(
885
- o,
886
- p,
872
+ const u = await Y(a);
873
+ Be(
874
+ i,
875
+ u,
887
876
  r.portrait.x,
888
877
  r.portrait.y,
889
878
  r.portrait.radiusX,
890
879
  r.portrait.radiusY,
891
- s
880
+ o
892
881
  );
893
- } catch (p) {
894
- console.error("Failed to load portrait:", p);
882
+ } catch (u) {
883
+ console.error("Failed to load portrait:", u);
895
884
  }
896
- n && re(o, n, r.namePlate);
885
+ n && re(i, n, r.namePlate);
897
886
  }
898
- async function ie(e, t, a, n, r, i, c, s, o) {
899
- const d = e.getContext("2d");
900
- if (!d) return;
901
- e.width = s, e.height = o, d.clearRect(0, 0, s, o);
902
- const p = await j(t);
903
- ae(d, p, s, o), c.contactInfo && (a || n || r) && Le(d, a, n, r, c.contactInfo), c.description && i && Ae(d, i, c.description), a && re(d, a, c.namePlate);
887
+ async function ie(e, t, a, n, r, s, d, o, i) {
888
+ const c = e.getContext("2d");
889
+ if (!c) return;
890
+ e.width = o, e.height = i, c.clearRect(0, 0, o, i);
891
+ const u = await Y(t);
892
+ ae(c, u, o, i), d.contactInfo && (a || n || r) && $e(c, a, n, r, d.contactInfo), d.description && s && Re(c, s, d.description), a && re(c, a, d.namePlate);
904
893
  }
905
- function Ve() {
906
- const e = y((w) => w.voucherConfig.language), t = y((w) => w.voucherConfig.hours), a = y((w) => w.voucherConfig.description), n = y((w) => w.personalInfo), r = y((w) => w.portrait), i = y((w) => w.currentSide), c = y((w) => w.flipSide), s = D(e), o = L(null), d = L(null), p = L(null), [u, b] = S(!1), g = ne(e, t), h = te(e), E = r.useEnhanced && r.enhanced ? r.enhanced : r.original, v = J(e, t, a);
907
- V(() => {
908
- o.current && oe(
909
- o.current,
910
- g.front,
911
- E,
894
+ function Qe() {
895
+ const e = y((w) => w.voucherConfig.language), t = y((w) => w.voucherConfig.hours), a = y((w) => w.voucherConfig.description), n = y((w) => w.personalInfo), r = y((w) => w.portrait), s = y((w) => w.currentSide), d = y((w) => w.flipSide), o = z(e), i = $(null), c = $(null), u = $(null), [g, f] = E(!1), b = ne(e, t), h = te(e), x = r.useEnhanced && r.enhanced ? r.enhanced : r.original, k = J(e, t, a);
896
+ G(() => {
897
+ i.current && oe(
898
+ i.current,
899
+ b.front,
900
+ x,
912
901
  n.name,
913
902
  h.front,
914
- g.width,
915
- g.height,
903
+ b.width,
904
+ b.height,
916
905
  r.zoom
917
906
  );
918
- }, [g, E, n.name, h, r.zoom]), V(() => {
919
- d.current && ie(
920
- d.current,
921
- g.back,
907
+ }, [b, x, n.name, h, r.zoom]), G(() => {
908
+ c.current && ie(
909
+ c.current,
910
+ b.back,
922
911
  n.name,
923
912
  n.email,
924
913
  n.phone,
925
- v,
914
+ k,
926
915
  h.back,
927
- g.width,
928
- g.height
916
+ b.width,
917
+ b.height
929
918
  );
930
- }, [g, n, v, h]);
931
- const I = () => {
932
- b(!0), setTimeout(() => {
933
- c(), b(!1);
919
+ }, [b, n, k, h]);
920
+ const v = () => {
921
+ f(!0), setTimeout(() => {
922
+ d(), f(!1);
934
923
  }, 150);
935
- }, P = g.width / g.height;
936
- return /* @__PURE__ */ f("div", { className: "space-y-4", children: [
937
- /* @__PURE__ */ f("div", { className: "flex justify-between items-center", children: [
938
- /* @__PURE__ */ f("div", { className: "tabs tabs-boxed bg-base-200", children: [
924
+ }, S = b.width / b.height;
925
+ return /* @__PURE__ */ m("div", { className: "space-y-4", children: [
926
+ /* @__PURE__ */ m("div", { className: "flex justify-between items-center", children: [
927
+ /* @__PURE__ */ m("div", { className: "tabs tabs-boxed bg-base-200", children: [
939
928
  /* @__PURE__ */ l(
940
929
  "button",
941
930
  {
942
- className: `tab ${i === "front" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
943
- onClick: () => i !== "front" && I(),
944
- children: s.preview.front
931
+ className: `tab ${s === "front" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
932
+ onClick: () => s !== "front" && v(),
933
+ children: o.preview.front
945
934
  }
946
935
  ),
947
936
  /* @__PURE__ */ l(
948
937
  "button",
949
938
  {
950
- className: `tab ${i === "back" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
951
- onClick: () => i !== "back" && I(),
952
- children: s.preview.back
939
+ className: `tab ${s === "back" ? "tab-active bg-primary text-primary-content font-semibold" : ""}`,
940
+ onClick: () => s !== "back" && v(),
941
+ children: o.preview.back
953
942
  }
954
943
  )
955
944
  ] }),
956
- /* @__PURE__ */ f("button", { className: "btn btn-ghost btn-sm", onClick: I, children: [
945
+ /* @__PURE__ */ m("button", { className: "btn btn-ghost btn-sm", onClick: v, children: [
957
946
  /* @__PURE__ */ l(
958
947
  "svg",
959
948
  {
@@ -973,28 +962,28 @@ function Ve() {
973
962
  )
974
963
  }
975
964
  ),
976
- s.preview.flip
965
+ o.preview.flip
977
966
  ] })
978
967
  ] }),
979
- /* @__PURE__ */ f(
968
+ /* @__PURE__ */ m(
980
969
  "div",
981
970
  {
982
- ref: p,
971
+ ref: u,
983
972
  className: "relative w-full overflow-hidden shadow-lg",
984
- style: { aspectRatio: P },
973
+ style: { aspectRatio: S },
985
974
  children: [
986
975
  /* @__PURE__ */ l(
987
976
  "canvas",
988
977
  {
989
- ref: o,
990
- className: `absolute inset-0 w-full h-full transition-all duration-300 ${i === "front" ? u ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
978
+ ref: i,
979
+ className: `absolute inset-0 w-full h-full transition-all duration-300 ${s === "front" ? g ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
991
980
  }
992
981
  ),
993
982
  /* @__PURE__ */ l(
994
983
  "canvas",
995
984
  {
996
- ref: d,
997
- className: `absolute inset-0 w-full h-full transition-all duration-300 ${i === "back" ? u ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
985
+ ref: c,
986
+ className: `absolute inset-0 w-full h-full transition-all duration-300 ${s === "back" ? g ? "opacity-0 scale-95" : "opacity-100 scale-100" : "opacity-0 scale-95 pointer-events-none"}`
998
987
  }
999
988
  )
1000
989
  ]
@@ -1002,85 +991,85 @@ function Ve() {
1002
991
  )
1003
992
  ] });
1004
993
  }
1005
- function Ge() {
1006
- const e = L(null), t = L(null);
994
+ function et() {
995
+ const e = $(null), t = $(null);
1007
996
  return { frontCanvasRef: e, backCanvasRef: t };
1008
997
  }
1009
- async function De(e) {
998
+ async function ze(e) {
1010
999
  const {
1011
1000
  frontTemplateSrc: t,
1012
1001
  backTemplateSrc: a,
1013
1002
  templateWidth: n,
1014
1003
  templateHeight: r,
1015
- layout: i,
1016
- portrait: c,
1017
- portraitZoom: s = 1,
1018
- name: o,
1019
- email: d,
1020
- phone: p,
1021
- description: u
1022
- } = e, b = document.createElement("canvas"), g = document.createElement("canvas");
1004
+ layout: s,
1005
+ portrait: d,
1006
+ portraitZoom: o = 1,
1007
+ name: i,
1008
+ email: c,
1009
+ phone: u,
1010
+ description: g
1011
+ } = e, f = document.createElement("canvas"), b = document.createElement("canvas");
1023
1012
  await Promise.all([
1024
- oe(b, t, c, o, i.front, n, r, s),
1025
- ie(g, a, o, d, p, u, i.back, n, r)
1013
+ oe(f, t, d, i, s.front, n, r, o),
1014
+ ie(b, a, i, c, u, g, s.back, n, r)
1026
1015
  ]);
1027
- const h = new me({
1016
+ const h = new ye({
1028
1017
  orientation: "landscape",
1029
1018
  unit: "mm",
1030
1019
  format: "a4"
1031
- }), E = 297, v = 210, I = 10, P = n / r;
1032
- let w = E - I * 2, N = w / P;
1033
- N > v - I * 2 && (N = v - I * 2, w = N * P);
1034
- const _ = (E - w) / 2, B = (v - N) / 2, U = b.toDataURL("image/jpeg", 0.95);
1035
- h.addImage(U, "JPEG", _, B, w, N), h.addPage();
1036
- const H = g.toDataURL("image/jpeg", 0.95);
1037
- return h.addImage(H, "JPEG", _, B, w, N), h.output("blob");
1020
+ }), x = 297, k = 210, v = 10, S = n / r;
1021
+ let w = x - v * 2, N = w / S;
1022
+ N > k - v * 2 && (N = k - v * 2, w = N * S);
1023
+ const T = (x - w) / 2, L = (k - N) / 2, H = f.toDataURL("image/jpeg", 0.95);
1024
+ h.addImage(H, "JPEG", T, L, w, N), h.addPage();
1025
+ const W = b.toDataURL("image/jpeg", 0.95);
1026
+ return h.addImage(W, "JPEG", T, L, w, N), h.output("blob");
1038
1027
  }
1039
- function _e(e, t) {
1028
+ function He(e, t) {
1040
1029
  const a = URL.createObjectURL(e), n = document.createElement("a");
1041
1030
  n.href = a, n.download = t, document.body.appendChild(n), n.click(), document.body.removeChild(n), URL.revokeObjectURL(a);
1042
1031
  }
1043
- async function Be(e) {
1044
- const t = await De(e);
1045
- _e(t, e.filename);
1032
+ async function Me(e) {
1033
+ const t = await ze(e);
1034
+ He(t, e.filename);
1046
1035
  }
1047
- function Ze() {
1048
- const e = y((h) => h.voucherConfig.language), t = y((h) => h.voucherConfig.hours), a = y((h) => h.voucherConfig.description), n = y((h) => h.personalInfo), r = y((h) => h.portrait), i = y((h) => h.isExporting), c = y((h) => h.setIsExporting), s = D(e), o = ne(e, t), d = te(e), p = r.useEnhanced && r.enhanced ? r.enhanced : r.original, u = J(e, t, a), b = n.name.trim().length > 0 && n.email.trim().length > 0 && n.phone.trim().length > 0 && r.original !== null;
1036
+ function tt() {
1037
+ const e = y((h) => h.voucherConfig.language), t = y((h) => h.voucherConfig.hours), a = y((h) => h.voucherConfig.description), n = y((h) => h.personalInfo), r = y((h) => h.portrait), s = y((h) => h.isExporting), d = y((h) => h.setIsExporting), o = z(e), i = ne(e, t), c = te(e), u = r.useEnhanced && r.enhanced ? r.enhanced : r.original, g = J(e, t, a), f = n.name.trim().length > 0 && n.email.trim().length > 0 && n.phone.trim().length > 0 && r.original !== null;
1049
1038
  return /* @__PURE__ */ l(
1050
1039
  "button",
1051
1040
  {
1052
- className: `btn btn-primary flex-1 ${i ? "loading" : ""}`,
1041
+ className: `btn btn-primary flex-1 ${s ? "loading" : ""}`,
1053
1042
  onClick: async () => {
1054
- if (!(!b || i)) {
1055
- c(!0);
1043
+ if (!(!f || s)) {
1044
+ d(!0);
1056
1045
  try {
1057
1046
  const h = `zeitgutschein-${t}h-${n.name.replace(/\s+/g, "-").toLowerCase()}.pdf`;
1058
- await Be({
1059
- frontTemplateSrc: o.front,
1060
- backTemplateSrc: o.back,
1061
- templateWidth: o.width,
1062
- templateHeight: o.height,
1063
- layout: d,
1064
- portrait: p,
1047
+ await Me({
1048
+ frontTemplateSrc: i.front,
1049
+ backTemplateSrc: i.back,
1050
+ templateWidth: i.width,
1051
+ templateHeight: i.height,
1052
+ layout: c,
1053
+ portrait: u,
1065
1054
  portraitZoom: r.zoom,
1066
1055
  name: n.name,
1067
1056
  email: n.email,
1068
1057
  phone: n.phone,
1069
- description: u,
1058
+ description: g,
1070
1059
  filename: h
1071
1060
  });
1072
1061
  } catch (h) {
1073
1062
  console.error("PDF export failed:", h);
1074
1063
  } finally {
1075
- c(!1);
1064
+ d(!1);
1076
1065
  }
1077
1066
  }
1078
1067
  },
1079
- disabled: !b || i,
1080
- children: i ? /* @__PURE__ */ f($, { children: [
1068
+ disabled: !f || s,
1069
+ children: s ? /* @__PURE__ */ m(M, { children: [
1081
1070
  /* @__PURE__ */ l("span", { className: "loading loading-spinner loading-sm" }),
1082
- s.export.exporting
1083
- ] }) : /* @__PURE__ */ f($, { children: [
1071
+ o.export.exporting
1072
+ ] }) : /* @__PURE__ */ m(M, { children: [
1084
1073
  /* @__PURE__ */ l(
1085
1074
  "svg",
1086
1075
  {
@@ -1100,16 +1089,16 @@ function Ze() {
1100
1089
  )
1101
1090
  }
1102
1091
  ),
1103
- s.export.button
1092
+ o.export.button
1104
1093
  ] })
1105
1094
  }
1106
1095
  );
1107
1096
  }
1108
- function Re() {
1097
+ function Ue() {
1109
1098
  const e = y((n) => n.voucherConfig.language), t = y((n) => n.setLanguage), a = (n) => {
1110
1099
  t(n);
1111
1100
  };
1112
- return /* @__PURE__ */ f("div", { className: "join", children: [
1101
+ return /* @__PURE__ */ m("div", { className: "join", children: [
1113
1102
  /* @__PURE__ */ l(
1114
1103
  "button",
1115
1104
  {
@@ -1128,22 +1117,22 @@ function Re() {
1128
1117
  )
1129
1118
  ] });
1130
1119
  }
1131
- function Xe() {
1132
- const e = y((a) => a.voucherConfig.language), t = D(e);
1133
- return /* @__PURE__ */ f("div", { className: "navbar bg-currency-green text-currency-cream shadow-lg", children: [
1120
+ function nt() {
1121
+ const e = y((a) => a.voucherConfig.language), t = z(e);
1122
+ return /* @__PURE__ */ m("div", { className: "navbar bg-currency-green text-currency-cream shadow-lg", children: [
1134
1123
  /* @__PURE__ */ l("div", { className: "navbar-start", children: /* @__PURE__ */ l("a", { className: "btn btn-ghost text-xl font-currency font-bold", children: t.header.title }) }),
1135
1124
  /* @__PURE__ */ l("div", { className: "navbar-center hidden sm:flex", children: /* @__PURE__ */ l("span", { className: "text-sm opacity-80", children: t.header.subtitle }) }),
1136
- /* @__PURE__ */ l("div", { className: "navbar-end", children: /* @__PURE__ */ l(Re, {}) })
1125
+ /* @__PURE__ */ l("div", { className: "navbar-end", children: /* @__PURE__ */ l(Ue, {}) })
1137
1126
  ] });
1138
1127
  }
1139
- const M = "/", $e = {
1128
+ const U = "/", Fe = {
1140
1129
  id: "time-voucher-classic-de",
1141
1130
  name: "Zeitgutschein Classic",
1142
1131
  type: "time-voucher",
1143
1132
  category: "classic",
1144
1133
  images: {
1145
- front: `${M}templates/front_hdpi_de.jpg`,
1146
- back: `${M}templates/back_hdpi_de.jpg`,
1134
+ front: `${U}templates/front_hdpi_de.jpg`,
1135
+ back: `${U}templates/back_hdpi_de.jpg`,
1147
1136
  width: 6144,
1148
1137
  height: 4096
1149
1138
  },
@@ -1190,24 +1179,24 @@ const M = "/", $e = {
1190
1179
  ],
1191
1180
  layout: {
1192
1181
  front: {
1193
- portrait: A.front.portrait,
1194
- name: A.front.namePlate
1182
+ portrait: R.front.portrait,
1183
+ name: R.front.namePlate
1195
1184
  },
1196
1185
  back: {
1197
- name: A.back.namePlate,
1198
- contactInfo: A.back.contactInfo,
1199
- description: A.back.description
1186
+ name: R.back.namePlate,
1187
+ contactInfo: R.back.contactInfo,
1188
+ description: R.back.description
1200
1189
  }
1201
1190
  },
1202
1191
  languages: ["de"]
1203
- }, Me = {
1192
+ }, We = {
1204
1193
  id: "time-voucher-classic-en",
1205
1194
  name: "Time Voucher Classic",
1206
1195
  type: "time-voucher",
1207
1196
  category: "classic",
1208
1197
  images: {
1209
- front: `${M}templates/front_ldpi_en.png`,
1210
- back: `${M}templates/back_ldpi_en.png`,
1198
+ front: `${U}templates/front_ldpi_en.png`,
1199
+ back: `${U}templates/back_ldpi_en.png`,
1211
1200
  width: 1536,
1212
1201
  height: 1024
1213
1202
  },
@@ -1254,20 +1243,20 @@ const M = "/", $e = {
1254
1243
  ],
1255
1244
  layout: {
1256
1245
  front: {
1257
- portrait: T.front.portrait,
1258
- name: T.front.namePlate
1246
+ portrait: B.front.portrait,
1247
+ name: B.front.namePlate
1259
1248
  },
1260
1249
  back: {
1261
- name: T.back.namePlate,
1262
- contactInfo: T.back.contactInfo,
1263
- description: T.back.description
1250
+ name: B.back.namePlate,
1251
+ contactInfo: B.back.contactInfo,
1252
+ description: B.back.description
1264
1253
  }
1265
1254
  },
1266
1255
  languages: ["en"]
1267
1256
  }, X = [
1268
- $e,
1269
- Me
1270
- ], ze = {
1257
+ Fe,
1258
+ We
1259
+ ], Ke = {
1271
1260
  async listTemplates(e) {
1272
1261
  let t = [...X];
1273
1262
  return e != null && e.type && (t = t.filter((a) => a.type === e.type)), e != null && e.category && (t = t.filter((a) => a.category === e.category)), e != null && e.language && (t = t.filter((a) => a.languages.includes(e.language))), t;
@@ -1279,61 +1268,61 @@ const M = "/", $e = {
1279
1268
  return t;
1280
1269
  }
1281
1270
  };
1282
- function Je(e) {
1271
+ function at(e) {
1283
1272
  return e === "de" ? "time-voucher-classic-de" : "time-voucher-classic-en";
1284
1273
  }
1285
- let z = ze;
1286
- function Qe(e) {
1287
- z = e;
1274
+ let F = Ke;
1275
+ function rt(e) {
1276
+ F = e;
1288
1277
  }
1289
- function et() {
1290
- return z;
1278
+ function ot() {
1279
+ return F;
1291
1280
  }
1292
- async function tt(e) {
1293
- return z.listTemplates(e);
1281
+ async function it(e) {
1282
+ return F.listTemplates(e);
1294
1283
  }
1295
- async function nt(e) {
1296
- return z.getTemplate(e);
1284
+ async function st(e) {
1285
+ return F.getTemplate(e);
1297
1286
  }
1298
1287
  export {
1299
- Se as ApiKeyModal,
1300
- Ve as BillPreview,
1301
- Ze as ExportButton,
1302
- Xe as Header,
1303
- A as LAYOUT_HDPI,
1304
- T as LAYOUT_LDPI,
1305
- Re as LanguageToggle,
1306
- Oe as PersonalInfoForm,
1307
- Ye as PortraitUpload,
1308
- Ce as TEMPLATES,
1309
- qe as VoucherConfig,
1310
- _e as downloadBlob,
1311
- Le as drawContactInfo,
1312
- Ae as drawMultilineText,
1313
- Te as drawOvalPortrait,
1288
+ De as ApiKeyModal,
1289
+ Qe as BillPreview,
1290
+ tt as ExportButton,
1291
+ nt as Header,
1292
+ R as LAYOUT_HDPI,
1293
+ B as LAYOUT_LDPI,
1294
+ Ue as LanguageToggle,
1295
+ Ve as PersonalInfoForm,
1296
+ Xe as PortraitUpload,
1297
+ _e as TEMPLATES,
1298
+ Je as VoucherConfig,
1299
+ He as downloadBlob,
1300
+ $e as drawContactInfo,
1301
+ Re as drawMultilineText,
1302
+ Be as drawOvalPortrait,
1314
1303
  ae as drawTemplate,
1315
1304
  re as drawText,
1316
- je as enhancePortrait,
1317
- Pe as enhancePortraitFallback,
1318
- Be as exportBillAsPDF,
1305
+ Ze as enhancePortrait,
1306
+ Te as enhancePortraitFallback,
1307
+ Me as exportBillAsPDF,
1319
1308
  J as formatDescription,
1320
- De as generateBillPDF,
1321
- Y as getApiKey,
1322
- Je as getDefaultTemplateId,
1309
+ ze as generateBillPDF,
1310
+ q as getApiKey,
1311
+ at as getDefaultTemplateId,
1323
1312
  te as getLayout,
1324
1313
  ne as getTemplate,
1325
- nt as getTemplateById,
1326
- et as getTemplateProvider,
1327
- Ie as hasApiKey,
1328
- tt as listTemplates,
1329
- j as loadImage,
1330
- Ee as removeBackground,
1314
+ st as getTemplateById,
1315
+ ot as getTemplateProvider,
1316
+ Ce as hasApiKey,
1317
+ it as listTemplates,
1318
+ Y as loadImage,
1319
+ Ae as removeBackground,
1331
1320
  ie as renderBackSide,
1332
1321
  oe as renderFrontSide,
1333
- ke as setApiKey,
1334
- Qe as setTemplateProvider,
1335
- ze as staticTemplateProvider,
1336
- D as t,
1337
- Ge as useBillCanvasRefs,
1322
+ Se as setApiKey,
1323
+ rt as setTemplateProvider,
1324
+ Ke as staticTemplateProvider,
1325
+ z as t,
1326
+ et as useBillCanvasRefs,
1338
1327
  y as useBillStore
1339
1328
  };