@antontranelis/money-printer 1.0.4 → 1.0.5

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