@rslsp1/fa-app-tools 1.2.4 → 1.2.6

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
@@ -5,6 +5,9 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __esm = (fn, res) => function __init() {
9
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
10
+ };
8
11
  var __export = (target, all) => {
9
12
  for (var name in all)
10
13
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -27,125 +30,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
27
30
  ));
28
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
32
 
30
- // src/index.ts
31
- var index_exports = {};
32
- __export(index_exports, {
33
- AvatarArchitectApp: () => AvatarArchitectApp,
34
- CollapsibleCard: () => CollapsibleCard,
35
- CompactDropdown: () => CompactDropdown,
36
- FaToolsBadge: () => FaToolsBadge,
37
- GLOBAL_STYLES: () => GLOBAL_STYLES,
38
- HistoryPanel: () => HistoryPanel,
39
- InspectPanel: () => InspectPanel,
40
- LIB_VERSION: () => LIB_VERSION,
41
- LabBlend: () => LabBlend,
42
- LabCompare: () => LabCompare,
43
- LabImagePicker: () => LabImagePicker,
44
- LabLoop: () => LabLoop,
45
- LabRemix: () => LabRemix,
46
- LabsTab: () => LabsTab,
47
- ListView: () => ListView,
48
- MediaLibrary: () => MediaLibrary,
49
- PillButton: () => PillButton,
50
- ProjectSyncTab: () => ProjectSyncTab,
51
- PromptTab: () => PromptTab,
52
- SectionLabel: () => SectionLabel,
53
- SetupPanel: () => SetupPanel,
54
- TagManagerPanel: () => TagManagerPanel,
55
- autoLabel: () => autoLabel,
56
- buildBlendInstruction: () => buildBlendInstruction,
57
- buildCompareInstruction: () => buildCompareInstruction,
58
- buildFallbackPrompt: () => buildFallbackPrompt,
59
- buildGenerationPrompt: () => buildGenerationPrompt,
60
- buildImageGenerationOptions: () => buildImageGenerationOptions,
61
- buildLoopInstruction: () => buildLoopInstruction,
62
- buildPromptTabPayload: () => buildPromptTabPayload,
63
- buildReferenceImageMediaIds: () => buildReferenceImageMediaIds,
64
- buildRemixInstruction: () => buildRemixInstruction,
65
- buildScanInstruction: () => buildScanInstruction,
66
- cleanAiResponse: () => cleanAiResponse,
67
- createFlowServices: () => createFlowServices,
68
- exportProjectToZip: () => exportProjectToZip,
69
- formatTreeToMarkdown: () => formatTreeToMarkdown,
70
- frameToGeneration: () => frameToGeneration,
71
- getFormattedTimestamp: () => getFormattedTimestamp,
72
- groupGenerationsToLabItems: () => groupGenerationsToLabItems,
73
- importProjectFromZip: () => importProjectFromZip,
74
- injectXMPMetadata: () => injectXMPMetadata,
75
- interpretSdkError: () => interpretSdkError,
76
- parsePromptFile: () => parsePromptFile,
77
- parsePromptResponse: () => parsePromptResponse,
78
- useKeyboardNavigation: () => useKeyboardNavigation,
79
- useOnClickOutside: () => useOnClickOutside
80
- });
81
- module.exports = __toCommonJS(index_exports);
82
-
83
- // src/hooks/useOnClickOutside.ts
84
- var import_react = require("react");
85
- function useOnClickOutside(ref, handler) {
86
- (0, import_react.useEffect)(() => {
87
- const listener = (event) => {
88
- if (!ref.current || ref.current.contains(event.target)) return;
89
- handler(event);
90
- };
91
- document.addEventListener("mousedown", listener);
92
- document.addEventListener("touchstart", listener);
93
- return () => {
94
- document.removeEventListener("mousedown", listener);
95
- document.removeEventListener("touchstart", listener);
96
- };
97
- }, [ref, handler]);
98
- }
99
-
100
- // src/hooks/useKeyboardNavigation.ts
101
- var import_react2 = require("react");
102
- function useKeyboardNavigation(history, currentResult, setCurrentResult) {
103
- (0, import_react2.useEffect)(() => {
104
- const handleKeyDown = (e) => {
105
- if (e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLInputElement) return;
106
- if (!currentResult || history.length === 0) return;
107
- const currentIndex = history.findIndex((h) => h.id === currentResult.id);
108
- if (e.key === "ArrowRight" && currentIndex < history.length - 1) {
109
- setCurrentResult(history[currentIndex + 1]);
110
- } else if (e.key === "ArrowLeft" && currentIndex > 0) {
111
- setCurrentResult(history[currentIndex - 1]);
112
- }
113
- };
114
- window.addEventListener("keydown", handleKeyDown);
115
- return () => window.removeEventListener("keydown", handleKeyDown);
116
- }, [currentResult, history, setCurrentResult]);
117
- }
118
-
119
- // src/lib/utils.ts
120
- var getFormattedTimestamp = () => {
121
- const d = /* @__PURE__ */ new Date();
122
- const pad = (n) => n.toString().padStart(2, "0");
123
- return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}_${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
124
- };
125
- var GLOBAL_STYLES = `
126
- .dark-scrollbar::-webkit-scrollbar { width: 4px; height: 4px; }
127
- .dark-scrollbar::-webkit-scrollbar-track { background: transparent; }
128
- .dark-scrollbar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
129
- html, body, #root { margin: 0; padding: 0; width: 100%; height: 100%; background: #0e0e0e; font-family: 'Google Sans Text', sans-serif; overflow: hidden; }
130
- @keyframes prompt-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
131
- .prompt-loading { background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%); background-size: 200% 100%; animation: prompt-shimmer 2s infinite linear; }
132
- @keyframes dropdown-enter { from { opacity: 0; transform: scale(0.95) translateY(-5px); } to { opacity: 1; transform: scale(1) translateY(0); } }
133
- .animate-dropdown { animation: dropdown-enter 0.1s ease-out forwards; }
134
- `;
135
-
136
33
  // src/lib/metadata.ts
137
- var crcTable = (() => {
138
- let c;
139
- const table = new Uint32Array(256);
140
- for (let n = 0; n < 256; n++) {
141
- c = n;
142
- for (let k = 0; k < 8; k++) {
143
- c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
144
- }
145
- table[n] = c;
146
- }
147
- return table;
148
- })();
149
34
  function calculateCRC(bytes) {
150
35
  let crc = 4294967295;
151
36
  for (let i = 0; i < bytes.length; i++) {
@@ -251,9 +136,31 @@ function injectXMPMetadata(base64, prompt, seed, model, id, tags = [], hierarchy
251
136
  return base64;
252
137
  }
253
138
  }
139
+ var crcTable;
140
+ var init_metadata = __esm({
141
+ "src/lib/metadata.ts"() {
142
+ "use strict";
143
+ crcTable = (() => {
144
+ let c;
145
+ const table = new Uint32Array(256);
146
+ for (let n = 0; n < 256; n++) {
147
+ c = n;
148
+ for (let k = 0; k < 8; k++) {
149
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
150
+ }
151
+ table[n] = c;
152
+ }
153
+ return table;
154
+ })();
155
+ }
156
+ });
254
157
 
255
158
  // src/lib/project.ts
256
- var import_jszip = __toESM(require("jszip"));
159
+ var project_exports = {};
160
+ __export(project_exports, {
161
+ exportProjectToZip: () => exportProjectToZip,
162
+ importProjectFromZip: () => importProjectFromZip
163
+ });
257
164
  function generateMarkdownReport(nodes, history) {
258
165
  let md = "# Avatar Architect - Projekt Report\n\n";
259
166
  md += `Exportiert: ${(/* @__PURE__ */ new Date()).toLocaleString()}
@@ -343,6 +250,234 @@ async function importProjectFromZip(file) {
343
250
  }
344
251
  return data;
345
252
  }
253
+ var import_jszip;
254
+ var init_project = __esm({
255
+ "src/lib/project.ts"() {
256
+ "use strict";
257
+ import_jszip = __toESM(require("jszip"));
258
+ init_metadata();
259
+ }
260
+ });
261
+
262
+ // src/lib/hfStateService.ts
263
+ var hfStateService_exports = {};
264
+ __export(hfStateService_exports, {
265
+ HF_TOKEN_KEY: () => HF_TOKEN_KEY,
266
+ getHFToken: () => getHFToken,
267
+ hfDeleteProject: () => hfDeleteProject,
268
+ hfDownloadProject: () => hfDownloadProject,
269
+ hfListProjects: () => hfListProjects,
270
+ hfUploadProject: () => hfUploadProject,
271
+ setHFToken: () => setHFToken
272
+ });
273
+ function getHFToken() {
274
+ try {
275
+ return localStorage.getItem(HF_TOKEN_KEY);
276
+ } catch {
277
+ return null;
278
+ }
279
+ }
280
+ function setHFToken(token) {
281
+ try {
282
+ localStorage.setItem(HF_TOKEN_KEY, token);
283
+ } catch {
284
+ }
285
+ }
286
+ async function hfListProjects(token) {
287
+ const res = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/tree/main`, {
288
+ headers: { Authorization: `Bearer ${token}` }
289
+ });
290
+ if (!res.ok) throw new Error(`HF list failed: ${res.status} ${res.statusText}`);
291
+ const files = await res.json();
292
+ return files.filter((f) => f.type === "file" && f.path.endsWith(".zip")).map((f) => ({
293
+ id: f.path.replace(/\.zip$/, ""),
294
+ name: f.path.replace(/\.zip$/, ""),
295
+ path: f.path,
296
+ size: f.size,
297
+ isLfs: !!f.lfs
298
+ }));
299
+ }
300
+ async function hfDownloadProject(path, token) {
301
+ const res = await fetch(
302
+ `${HF_BASE}/datasets/${HF_REPO}/resolve/main/${path}?download=true`,
303
+ { headers: { Authorization: `Bearer ${token}` } }
304
+ );
305
+ if (!res.ok) throw new Error(`HF download failed: ${res.status} ${res.statusText}`);
306
+ const blob = await res.blob();
307
+ return new File([blob], path, { type: "application/zip" });
308
+ }
309
+ async function hfUploadProject(zipBase64, name, token) {
310
+ const filename = name.endsWith(".zip") ? name : `${name}.zip`;
311
+ const binary = atob(zipBase64);
312
+ const bytes = new Uint8Array(binary.length);
313
+ for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
314
+ const hashBuffer = await crypto.subtle.digest("SHA-256", bytes);
315
+ const oid = Array.from(new Uint8Array(hashBuffer)).map((b) => b.toString(16).padStart(2, "0")).join("");
316
+ const size = bytes.length;
317
+ const sampleBytes = bytes.slice(0, 512);
318
+ let sampleBinary = "";
319
+ for (let i = 0; i < sampleBytes.length; i++) sampleBinary += String.fromCharCode(sampleBytes[i]);
320
+ const sample = btoa(sampleBinary);
321
+ const preRes = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/preupload/main`, {
322
+ method: "POST",
323
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json" },
324
+ body: JSON.stringify({ files: [{ path: filename, size, sample }] })
325
+ });
326
+ if (!preRes.ok) throw new Error(`HF preupload failed: ${preRes.status} ${preRes.statusText}`);
327
+ const preData = await preRes.json();
328
+ const fileInfo = preData.files?.[0];
329
+ if (fileInfo?.uploadMode === "lfs" && fileInfo?.uploadUrl) {
330
+ const uploadRes = await fetch(fileInfo.uploadUrl, {
331
+ method: "PUT",
332
+ headers: { "Content-Type": "application/octet-stream", ...fileInfo.header || {} },
333
+ body: bytes
334
+ });
335
+ if (!uploadRes.ok) throw new Error(`HF LFS upload failed: ${uploadRes.status}`);
336
+ }
337
+ const commitRes = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
338
+ method: "POST",
339
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/x-ndjson" },
340
+ body: [
341
+ JSON.stringify({ key: "header", value: { summary: `Upload ${filename}`, description: "" } }),
342
+ JSON.stringify({ key: "lfsFile", value: { path: filename, algo: "sha256", oid, size } })
343
+ ].join("\n")
344
+ });
345
+ if (!commitRes.ok) {
346
+ const err = await commitRes.text();
347
+ throw new Error(`HF commit failed: ${commitRes.status} \u2014 ${err}`);
348
+ }
349
+ return { id: filename.replace(/\.zip$/, ""), name: filename.replace(/\.zip$/, ""), path: filename, size, isLfs: true };
350
+ }
351
+ async function hfDeleteProject(path, token) {
352
+ const res = await fetch(`${HF_BASE}/api/datasets/${HF_REPO}/commit/main`, {
353
+ method: "POST",
354
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/x-ndjson" },
355
+ body: [
356
+ JSON.stringify({ key: "header", value: { summary: `Delete ${path}`, description: "" } }),
357
+ JSON.stringify({ key: "deletedFile", value: { path } })
358
+ ].join("\n")
359
+ });
360
+ if (!res.ok) throw new Error(`HF delete failed: ${res.status} ${res.statusText}`);
361
+ }
362
+ var HF_BASE, HF_REPO, HF_TOKEN_KEY;
363
+ var init_hfStateService = __esm({
364
+ "src/lib/hfStateService.ts"() {
365
+ "use strict";
366
+ HF_BASE = "https://huggingface.co";
367
+ HF_REPO = "RolandSch/fa-app-state";
368
+ HF_TOKEN_KEY = "hf-token";
369
+ }
370
+ });
371
+
372
+ // src/index.ts
373
+ var index_exports = {};
374
+ __export(index_exports, {
375
+ AvatarArchitectApp: () => AvatarArchitectApp,
376
+ CollapsibleCard: () => CollapsibleCard,
377
+ CompactDropdown: () => CompactDropdown,
378
+ FaToolsBadge: () => FaToolsBadge,
379
+ GLOBAL_STYLES: () => GLOBAL_STYLES,
380
+ HistoryPanel: () => HistoryPanel,
381
+ InspectPanel: () => InspectPanel,
382
+ LIB_VERSION: () => LIB_VERSION,
383
+ LabBlend: () => LabBlend,
384
+ LabCompare: () => LabCompare,
385
+ LabImagePicker: () => LabImagePicker,
386
+ LabLoop: () => LabLoop,
387
+ LabRemix: () => LabRemix,
388
+ LabsTab: () => LabsTab,
389
+ ListView: () => ListView,
390
+ MediaLibrary: () => MediaLibrary,
391
+ PillButton: () => PillButton,
392
+ ProjectSyncTab: () => ProjectSyncTab,
393
+ PromptTab: () => PromptTab,
394
+ SectionLabel: () => SectionLabel,
395
+ SetupPanel: () => SetupPanel,
396
+ TagManagerPanel: () => TagManagerPanel,
397
+ autoLabel: () => autoLabel,
398
+ buildBlendInstruction: () => buildBlendInstruction,
399
+ buildCompareInstruction: () => buildCompareInstruction,
400
+ buildFallbackPrompt: () => buildFallbackPrompt,
401
+ buildGenerationPrompt: () => buildGenerationPrompt,
402
+ buildImageGenerationOptions: () => buildImageGenerationOptions,
403
+ buildLoopInstruction: () => buildLoopInstruction,
404
+ buildPromptTabPayload: () => buildPromptTabPayload,
405
+ buildReferenceImageMediaIds: () => buildReferenceImageMediaIds,
406
+ buildRemixInstruction: () => buildRemixInstruction,
407
+ buildScanInstruction: () => buildScanInstruction,
408
+ cleanAiResponse: () => cleanAiResponse,
409
+ createFlowServices: () => createFlowServices,
410
+ exportProjectToZip: () => exportProjectToZip,
411
+ formatTreeToMarkdown: () => formatTreeToMarkdown,
412
+ frameToGeneration: () => frameToGeneration,
413
+ getFormattedTimestamp: () => getFormattedTimestamp,
414
+ groupGenerationsToLabItems: () => groupGenerationsToLabItems,
415
+ importProjectFromZip: () => importProjectFromZip,
416
+ injectXMPMetadata: () => injectXMPMetadata,
417
+ interpretSdkError: () => interpretSdkError,
418
+ parsePromptFile: () => parsePromptFile,
419
+ parsePromptResponse: () => parsePromptResponse,
420
+ useKeyboardNavigation: () => useKeyboardNavigation,
421
+ useOnClickOutside: () => useOnClickOutside
422
+ });
423
+ module.exports = __toCommonJS(index_exports);
424
+
425
+ // src/hooks/useOnClickOutside.ts
426
+ var import_react = require("react");
427
+ function useOnClickOutside(ref, handler) {
428
+ (0, import_react.useEffect)(() => {
429
+ const listener = (event) => {
430
+ if (!ref.current || ref.current.contains(event.target)) return;
431
+ handler(event);
432
+ };
433
+ document.addEventListener("mousedown", listener);
434
+ document.addEventListener("touchstart", listener);
435
+ return () => {
436
+ document.removeEventListener("mousedown", listener);
437
+ document.removeEventListener("touchstart", listener);
438
+ };
439
+ }, [ref, handler]);
440
+ }
441
+
442
+ // src/hooks/useKeyboardNavigation.ts
443
+ var import_react2 = require("react");
444
+ function useKeyboardNavigation(history, currentResult, setCurrentResult) {
445
+ (0, import_react2.useEffect)(() => {
446
+ const handleKeyDown = (e) => {
447
+ if (e.target instanceof HTMLTextAreaElement || e.target instanceof HTMLInputElement) return;
448
+ if (!currentResult || history.length === 0) return;
449
+ const currentIndex = history.findIndex((h) => h.id === currentResult.id);
450
+ if (e.key === "ArrowRight" && currentIndex < history.length - 1) {
451
+ setCurrentResult(history[currentIndex + 1]);
452
+ } else if (e.key === "ArrowLeft" && currentIndex > 0) {
453
+ setCurrentResult(history[currentIndex - 1]);
454
+ }
455
+ };
456
+ window.addEventListener("keydown", handleKeyDown);
457
+ return () => window.removeEventListener("keydown", handleKeyDown);
458
+ }, [currentResult, history, setCurrentResult]);
459
+ }
460
+
461
+ // src/lib/utils.ts
462
+ var getFormattedTimestamp = () => {
463
+ const d = /* @__PURE__ */ new Date();
464
+ const pad = (n) => n.toString().padStart(2, "0");
465
+ return `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}_${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
466
+ };
467
+ var GLOBAL_STYLES = `
468
+ .dark-scrollbar::-webkit-scrollbar { width: 4px; height: 4px; }
469
+ .dark-scrollbar::-webkit-scrollbar-track { background: transparent; }
470
+ .dark-scrollbar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
471
+ html, body, #root { margin: 0; padding: 0; width: 100%; height: 100%; background: #0e0e0e; font-family: 'Google Sans Text', sans-serif; overflow: hidden; }
472
+ @keyframes prompt-shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }
473
+ .prompt-loading { background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%); background-size: 200% 100%; animation: prompt-shimmer 2s infinite linear; }
474
+ @keyframes dropdown-enter { from { opacity: 0; transform: scale(0.95) translateY(-5px); } to { opacity: 1; transform: scale(1) translateY(0); } }
475
+ .animate-dropdown { animation: dropdown-enter 0.1s ease-out forwards; }
476
+ `;
477
+
478
+ // src/index.ts
479
+ init_metadata();
480
+ init_project();
346
481
 
347
482
  // src/lib/aiHelpers.ts
348
483
  function buildGenerationPrompt(hierarchyText, mode = "creative") {
@@ -1591,6 +1726,7 @@ var PromptTab = ({
1591
1726
 
1592
1727
  // src/components/ProjectSyncTab.tsx
1593
1728
  var import_react13 = require("react");
1729
+ init_hfStateService();
1594
1730
  var import_jsx_runtime12 = require("react/jsx-runtime");
1595
1731
  var ProjectSyncTab = ({
1596
1732
  onProjectExport,
@@ -1603,7 +1739,10 @@ var ProjectSyncTab = ({
1603
1739
  onServerDelete,
1604
1740
  onRefreshServerProjects,
1605
1741
  onComputeSyncDiff,
1606
- onExecuteSync
1742
+ onExecuteSync,
1743
+ hfToken,
1744
+ onHfLoad,
1745
+ onProjectExportBase64
1607
1746
  }) => {
1608
1747
  const projectInputRef = (0, import_react13.useRef)(null);
1609
1748
  const workspaceInputRef = (0, import_react13.useRef)(null);
@@ -1658,6 +1797,25 @@ var ProjectSyncTab = ({
1658
1797
  });
1659
1798
  };
1660
1799
  const isWorking = projectActionState === "working" || projectActionState === "working-full";
1800
+ const [hfProjects, setHfProjects] = (0, import_react13.useState)([]);
1801
+ const [hfLoading, setHfLoading] = (0, import_react13.useState)(false);
1802
+ const [hfSaving, setHfSaving] = (0, import_react13.useState)(false);
1803
+ const [hfError, setHfError] = (0, import_react13.useState)(null);
1804
+ const [hfSaveName, setHfSaveName] = (0, import_react13.useState)("");
1805
+ const loadHfProjects = async (token) => {
1806
+ setHfLoading(true);
1807
+ setHfError(null);
1808
+ try {
1809
+ setHfProjects(await hfListProjects(token));
1810
+ } catch (e) {
1811
+ setHfError(e.message);
1812
+ } finally {
1813
+ setHfLoading(false);
1814
+ }
1815
+ };
1816
+ (0, import_react13.useEffect)(() => {
1817
+ if (hfToken) loadHfProjects(hfToken);
1818
+ }, [hfToken]);
1661
1819
  return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "absolute inset-0 overflow-y-auto dark-scrollbar", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "p-6 flex flex-col gap-8", children: [
1662
1820
  (onProjectExport || onProjectImport || onWorkspaceImport) && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-4", children: [
1663
1821
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SectionLabel, { children: "Projekt-ZIP" }),
@@ -1748,6 +1906,94 @@ var ProjectSyncTab = ({
1748
1906
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { onClick: () => onServerDelete?.(p.id), className: "w-8 h-8 flex items-center justify-center text-white/20 active:text-red-400 transition-colors", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "material-symbols-outlined text-[18px]", children: "delete" }) })
1749
1907
  ] }, p.id)) })
1750
1908
  ] }),
1909
+ hfToken && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-4", children: [
1910
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center justify-between", children: [
1911
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SectionLabel, { children: "Hugging Face" }),
1912
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { onClick: () => loadHfProjects(hfToken), className: "text-white/30 hover:text-white/60 transition", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: `material-symbols-outlined text-[18px]${hfLoading ? " animate-spin" : ""}`, children: "refresh" }) })
1913
+ ] }),
1914
+ onProjectExportBase64 && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex gap-2", children: [
1915
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1916
+ "input",
1917
+ {
1918
+ type: "text",
1919
+ value: hfSaveName,
1920
+ onChange: (e) => setHfSaveName(e.target.value),
1921
+ placeholder: "Name (optional)",
1922
+ className: "flex-1 bg-white/5 border border-white/10 rounded-xl px-3 text-[12px] text-white/70 outline-none placeholder:text-white/20",
1923
+ style: { height: 40 }
1924
+ }
1925
+ ),
1926
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1927
+ PillButton,
1928
+ {
1929
+ variant: "filled",
1930
+ icon: "cloud_upload",
1931
+ loading: hfSaving,
1932
+ onClick: async () => {
1933
+ if (!onProjectExportBase64) return;
1934
+ setHfSaving(true);
1935
+ setHfError(null);
1936
+ try {
1937
+ const base64 = await onProjectExportBase64();
1938
+ const name = hfSaveName.trim() || `project_${(/* @__PURE__ */ new Date()).toISOString().slice(0, 16).replace("T", "_").replace(":", "")}`;
1939
+ await hfUploadProject(base64, name, hfToken);
1940
+ setHfSaveName("");
1941
+ await loadHfProjects(hfToken);
1942
+ } catch (e) {
1943
+ setHfError(e.message);
1944
+ } finally {
1945
+ setHfSaving(false);
1946
+ }
1947
+ },
1948
+ children: "Speichern"
1949
+ }
1950
+ )
1951
+ ] }),
1952
+ hfError && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-[10px] text-red-400 font-mono px-1", children: hfError }),
1953
+ !hfLoading && hfProjects.length === 0 && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-[10px] text-white/20 px-2", children: "Noch nichts auf HF gespeichert." }),
1954
+ hfProjects.map((p) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2 px-3 py-2 rounded-xl bg-white/5 border border-white/5", children: [
1955
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex-1 min-w-0", children: [
1956
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-[11px] text-white/70 font-bold truncate", children: p.name }),
1957
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-[9px] text-white/25", children: [
1958
+ (p.size / 1024 / 1024).toFixed(1),
1959
+ " MB",
1960
+ p.isLfs ? " \xB7 LFS" : ""
1961
+ ] })
1962
+ ] }),
1963
+ onHfLoad && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1964
+ "button",
1965
+ {
1966
+ onClick: async () => {
1967
+ try {
1968
+ const { hfDownloadProject: hfDownloadProject2 } = await Promise.resolve().then(() => (init_hfStateService(), hfStateService_exports));
1969
+ const file = await hfDownloadProject2(p.path, hfToken);
1970
+ onHfLoad(file);
1971
+ } catch (e) {
1972
+ setHfError(e.message);
1973
+ }
1974
+ },
1975
+ className: "w-8 h-8 flex items-center justify-center text-white/30 active:text-white transition-colors",
1976
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "material-symbols-outlined text-[18px]", children: "cloud_download" })
1977
+ }
1978
+ ),
1979
+ /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1980
+ "button",
1981
+ {
1982
+ onClick: async () => {
1983
+ if (!confirm(`"${p.name}" auf HF l\xF6schen?`)) return;
1984
+ try {
1985
+ await hfDeleteProject(p.path, hfToken);
1986
+ await loadHfProjects(hfToken);
1987
+ } catch (e) {
1988
+ setHfError(e.message);
1989
+ }
1990
+ },
1991
+ className: "w-8 h-8 flex items-center justify-center text-white/20 active:text-red-400 transition-colors",
1992
+ children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "material-symbols-outlined text-[18px]", children: "delete" })
1993
+ }
1994
+ )
1995
+ ] }, p.id))
1996
+ ] }),
1751
1997
  onComputeSyncDiff && onExecuteSync && /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex flex-col gap-4", children: [
1752
1998
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(SectionLabel, { children: "Sync" }),
1753
1999
  (syncState === "idle" || syncState === "computing") && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(PillButton, { variant: "outline", icon: "compare_arrows", loading: syncState === "computing", onClick: handleComputeDiff, children: "Diff berechnen" }),
@@ -1814,6 +2060,10 @@ var ProjectSyncTab = ({
1814
2060
  ] }) });
1815
2061
  };
1816
2062
 
2063
+ // src/components/AvatarArchitectApp.tsx
2064
+ init_project();
2065
+ init_metadata();
2066
+
1817
2067
  // src/lib/labHelpers.ts
1818
2068
  function groupGenerationsToLabItems(generations) {
1819
2069
  const map = /* @__PURE__ */ new Map();
@@ -3032,6 +3282,9 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
3032
3282
  }
3033
3283
  });
3034
3284
  const [projectLoaded, setProjectLoaded] = (0, import_react21.useState)(false);
3285
+ const [hfToken, setHfToken] = (0, import_react21.useState)("");
3286
+ const [hfTokenInput, setHfTokenInput] = (0, import_react21.useState)("");
3287
+ const [isLoadingFromHF, setIsLoadingFromHF] = (0, import_react21.useState)(false);
3035
3288
  const wsInputRef = (0, import_react21.useRef)(null);
3036
3289
  const startApp = (choice) => {
3037
3290
  try {
@@ -3632,6 +3885,59 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
3632
3885
  ),
3633
3886
  !projectLoaded && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-white/20 text-[10px] text-center", children: "Baum, Bilder und Einstellungen wiederherstellen" })
3634
3887
  ] }),
3888
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col items-center gap-2 w-full max-w-[280px]", children: [
3889
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex gap-2 w-full", children: [
3890
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3891
+ "input",
3892
+ {
3893
+ type: "password",
3894
+ value: hfTokenInput,
3895
+ onChange: (e) => setHfTokenInput(e.target.value),
3896
+ onKeyDown: (e) => e.key === "Enter" && hfTokenInput.trim() && setHfToken(hfTokenInput.trim()),
3897
+ placeholder: "HF Token (hf_\u2026)",
3898
+ className: "flex-1 rounded-xl px-3 text-[11px] font-mono outline-none",
3899
+ style: { height: 44, background: "rgba(255,255,255,0.05)", border: "1px solid rgba(255,255,255,0.1)", color: "rgba(255,255,255,0.7)" }
3900
+ }
3901
+ ),
3902
+ hfTokenInput.trim() && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
3903
+ "button",
3904
+ {
3905
+ onClick: () => setHfToken(hfTokenInput.trim()),
3906
+ className: "px-3 rounded-xl text-[11px] font-bold text-white",
3907
+ style: { background: "#f59e0b", height: 44 },
3908
+ children: "OK"
3909
+ }
3910
+ )
3911
+ ] }),
3912
+ hfToken && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3913
+ "button",
3914
+ {
3915
+ disabled: isLoadingFromHF,
3916
+ onClick: async () => {
3917
+ setIsLoadingFromHF(true);
3918
+ try {
3919
+ const { hfListProjects: hfListProjects2, hfDownloadProject: hfDownloadProject2 } = await Promise.resolve().then(() => (init_hfStateService(), hfStateService_exports));
3920
+ const projects = await hfListProjects2(hfToken);
3921
+ if (projects.length > 0) {
3922
+ const file = await hfDownloadProject2(projects[0].path, hfToken);
3923
+ await handleProjectImport(file);
3924
+ }
3925
+ } catch (e) {
3926
+ alert("HF Fehler: " + e.message);
3927
+ } finally {
3928
+ setIsLoadingFromHF(false);
3929
+ }
3930
+ },
3931
+ className: "w-full flex items-center justify-center gap-3 rounded-2xl font-bold text-[14px] uppercase tracking-wide text-white active:scale-95 transition-transform disabled:opacity-50",
3932
+ style: { height: 56, background: "#f59e0b" },
3933
+ children: [
3934
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: `material-symbols-outlined text-[22px]${isLoadingFromHF ? " animate-spin" : ""}`, children: isLoadingFromHF ? "sync" : "cloud_download" }),
3935
+ isLoadingFromHF ? "Laden\u2026" : "Von HF laden"
3936
+ ]
3937
+ }
3938
+ ),
3939
+ hfToken && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "text-white/20 text-[10px] text-center", children: "Letzten Stand von Hugging Face laden" })
3940
+ ] }),
3635
3941
  onFetchServerProjects && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col items-center gap-2 w-full max-w-[280px]", children: [
3636
3942
  /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
3637
3943
  "button",
@@ -3924,7 +4230,13 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
3924
4230
  onServerDelete: onServerDelete ? handleServerDelete : void 0,
3925
4231
  onRefreshServerProjects: onFetchServerProjects ? fetchServerProjects : void 0,
3926
4232
  onComputeSyncDiff: onFetchServerProjects && onServerLoad && onServerSave ? handleComputeSyncDiff : void 0,
3927
- onExecuteSync: onFetchServerProjects && onServerLoad && onServerSave ? handleExecuteSync : void 0
4233
+ onExecuteSync: onFetchServerProjects && onServerLoad && onServerSave ? handleExecuteSync : void 0,
4234
+ hfToken: hfToken || void 0,
4235
+ onHfLoad: (f) => handleProjectImport(f),
4236
+ onProjectExportBase64: async () => {
4237
+ const { base64 } = await Promise.resolve().then(() => (init_project(), project_exports)).then((m) => m.exportProjectToZip(nodes, edges, history, galleryItems, { aspectRatio, selectedModel, seed, seedMode }, workspaceTags, recentLabItems.map((i) => i.id)));
4238
+ return base64;
4239
+ }
3928
4240
  }
3929
4241
  ),
3930
4242
  activeTab === "tags" && workspaceTags && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
@@ -4247,7 +4559,13 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
4247
4559
  onServerDelete: onServerDelete ? handleServerDelete : void 0,
4248
4560
  onRefreshServerProjects: onFetchServerProjects ? fetchServerProjects : void 0,
4249
4561
  onComputeSyncDiff: onFetchServerProjects && onServerLoad && onServerSave ? handleComputeSyncDiff : void 0,
4250
- onExecuteSync: onFetchServerProjects && onServerLoad && onServerSave ? handleExecuteSync : void 0
4562
+ onExecuteSync: onFetchServerProjects && onServerLoad && onServerSave ? handleExecuteSync : void 0,
4563
+ hfToken: hfToken || void 0,
4564
+ onHfLoad: (f) => handleProjectImport(f),
4565
+ onProjectExportBase64: async () => {
4566
+ const { base64 } = await Promise.resolve().then(() => (init_project(), project_exports)).then((m) => m.exportProjectToZip(nodes, edges, history, galleryItems, { aspectRatio, selectedModel, seed, seedMode }, workspaceTags, recentLabItems.map((i) => i.id)));
4567
+ return base64;
4568
+ }
4251
4569
  }
4252
4570
  )
4253
4571
  ] })
@@ -4256,7 +4574,7 @@ function AvatarArchitectApp({ onGenerateImage, onGeneratePrompt, onDownload, onS
4256
4574
  }
4257
4575
 
4258
4576
  // src/index.ts
4259
- var LIB_VERSION = "1.2.4";
4577
+ var LIB_VERSION = "1.2.6";
4260
4578
  // Annotate the CommonJS export names for ESM import in node:
4261
4579
  0 && (module.exports = {
4262
4580
  AvatarArchitectApp,