@isaiahiroko/tilmart-ngx-apps-admin 0.2.12 → 0.2.14

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.
Files changed (89) hide show
  1. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-banners.module-sbSJXda_.mjs +92 -0
  2. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-banners.module-sbSJXda_.mjs.map +1 -0
  3. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-brands.module-EooAWVy_.mjs +73 -0
  4. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-brands.module-EooAWVy_.mjs.map +1 -0
  5. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-catalog.module-CnS35rup.mjs +605 -0
  6. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-catalog.module-CnS35rup.mjs.map +1 -0
  7. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-categories.module-u5VyaNWX.mjs +97 -0
  8. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-categories.module-u5VyaNWX.mjs.map +1 -0
  9. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-claims.module-Dk9mz7Wj.mjs → isaiahiroko-tilmart-ngx-apps-admin-claims.module-CLtalsnJ.mjs} +3 -3
  10. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-claims.module-CLtalsnJ.mjs.map +1 -0
  11. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-coupons.module-BCkLIQta.mjs +88 -0
  12. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-coupons.module-BCkLIQta.mjs.map +1 -0
  13. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-customers.module-CslGiOdq.mjs → isaiahiroko-tilmart-ngx-apps-admin-customers.module-BohEH2SB.mjs} +2 -2
  14. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-customers.module-CslGiOdq.mjs.map → isaiahiroko-tilmart-ngx-apps-admin-customers.module-BohEH2SB.mjs.map} +1 -1
  15. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-flash-sales.module-z6apTF3A.mjs +86 -0
  16. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-flash-sales.module-z6apTF3A.mjs.map +1 -0
  17. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-installation-requests.module-TryMzSXT.mjs → isaiahiroko-tilmart-ngx-apps-admin-installation-requests.module-Dnh9hEz_.mjs} +3 -3
  18. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-installation-requests.module-Dnh9hEz_.mjs.map +1 -0
  19. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-json-builder.component-BFroIYk9.mjs +1579 -0
  20. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-json-builder.component-BFroIYk9.mjs.map +1 -0
  21. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-list-page.base-Cl7JZ-Tp.mjs → isaiahiroko-tilmart-ngx-apps-admin-list-page.base-ChfiBo_X.mjs} +29 -5
  22. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-list-page.base-ChfiBo_X.mjs.map +1 -0
  23. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-orders.module-aIW0jRhm.mjs +239 -0
  24. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-orders.module-aIW0jRhm.mjs.map +1 -0
  25. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-overview.module-C6gjcJ84.mjs +105 -0
  26. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-overview.module-C6gjcJ84.mjs.map +1 -0
  27. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-payments.module-DstLDYM7.mjs → isaiahiroko-tilmart-ngx-apps-admin-payments.module-Bej9cdwM.mjs} +3 -3
  28. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-payments.module-Bej9cdwM.mjs.map +1 -0
  29. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-promotions.module-Dh7PTGG7.mjs +88 -0
  30. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-promotions.module-Dh7PTGG7.mjs.map +1 -0
  31. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-redirects.module-B8gaByYE.mjs +81 -0
  32. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-redirects.module-B8gaByYE.mjs.map +1 -0
  33. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-referrals.module-BIAY4L_u.mjs → isaiahiroko-tilmart-ngx-apps-admin-referrals.module-7OLTrySw.mjs} +3 -3
  34. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-referrals.module-7OLTrySw.mjs.map +1 -0
  35. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-reports.module-fjoFzY6t.mjs +137 -0
  36. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-reports.module-fjoFzY6t.mjs.map +1 -0
  37. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-returns.module-C9Iu9CX6.mjs → isaiahiroko-tilmart-ngx-apps-admin-returns.module-D0RKEzAr.mjs} +3 -3
  38. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-returns.module-D0RKEzAr.mjs.map +1 -0
  39. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-routes.module-BWZ9OBPH.mjs +84 -0
  40. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-routes.module-BWZ9OBPH.mjs.map +1 -0
  41. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-settings.module-D8HLxbUb.mjs → isaiahiroko-tilmart-ngx-apps-admin-settings.module-DZWUhyJg.mjs} +14 -7
  42. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-settings.module-DZWUhyJg.mjs.map +1 -0
  43. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-shipments.module-CWXgE2E_.mjs → isaiahiroko-tilmart-ngx-apps-admin-shipments.module-BG9DCmG-.mjs} +3 -3
  44. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-shipments.module-BG9DCmG-.mjs.map +1 -0
  45. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-staff.module-YjJJe00X.mjs → isaiahiroko-tilmart-ngx-apps-admin-staff.module-Br80U5_k.mjs} +2 -2
  46. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-staff.module-YjJJe00X.mjs.map → isaiahiroko-tilmart-ngx-apps-admin-staff.module-Br80U5_k.mjs.map} +1 -1
  47. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-status-badge-AXfNPKaS.mjs +66 -0
  48. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-status-badge-AXfNPKaS.mjs.map +1 -0
  49. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-stock.module-BFbm7118.mjs +178 -0
  50. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-stock.module-BFbm7118.mjs.map +1 -0
  51. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-users.module-C31RJJJ_.mjs → isaiahiroko-tilmart-ngx-apps-admin-users.module-C8nNzJ5X.mjs} +2 -2
  52. package/fesm2022/{isaiahiroko-tilmart-ngx-apps-admin-users.module-C31RJJJ_.mjs.map → isaiahiroko-tilmart-ngx-apps-admin-users.module-C8nNzJ5X.mjs.map} +1 -1
  53. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin.mjs +56 -46
  54. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin.mjs.map +1 -1
  55. package/package.json +1 -1
  56. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-banners.module-ClIiV2uK.mjs +0 -76
  57. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-banners.module-ClIiV2uK.mjs.map +0 -1
  58. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-brands.module-CSp0tWes.mjs +0 -70
  59. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-brands.module-CSp0tWes.mjs.map +0 -1
  60. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-catalog.module-BwjfFXDU.mjs +0 -562
  61. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-catalog.module-BwjfFXDU.mjs.map +0 -1
  62. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-categories.module-uKkUREjb.mjs +0 -94
  63. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-categories.module-uKkUREjb.mjs.map +0 -1
  64. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-claims.module-Dk9mz7Wj.mjs.map +0 -1
  65. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-coupons.module-Dcu1nJBW.mjs +0 -85
  66. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-coupons.module-Dcu1nJBW.mjs.map +0 -1
  67. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-flash-sales.module-DF7iSJaN.mjs +0 -83
  68. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-flash-sales.module-DF7iSJaN.mjs.map +0 -1
  69. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-installation-requests.module-TryMzSXT.mjs.map +0 -1
  70. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-list-page.base-Cl7JZ-Tp.mjs.map +0 -1
  71. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-orders.module-vldWwcAr.mjs +0 -190
  72. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-orders.module-vldWwcAr.mjs.map +0 -1
  73. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-payments.module-DstLDYM7.mjs.map +0 -1
  74. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-promotions.module-BO4zRytg.mjs +0 -94
  75. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-promotions.module-BO4zRytg.mjs.map +0 -1
  76. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-redirects.module-D8H6ujoy.mjs +0 -78
  77. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-redirects.module-D8H6ujoy.mjs.map +0 -1
  78. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-referrals.module-BIAY4L_u.mjs.map +0 -1
  79. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-reports.module-DORiIVLQ.mjs +0 -104
  80. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-reports.module-DORiIVLQ.mjs.map +0 -1
  81. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-returns.module-C9Iu9CX6.mjs.map +0 -1
  82. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-routes.module-fYKd3AOq.mjs +0 -81
  83. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-routes.module-fYKd3AOq.mjs.map +0 -1
  84. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-settings.module-D8HLxbUb.mjs.map +0 -1
  85. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-shipments.module-CWXgE2E_.mjs.map +0 -1
  86. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-simple-crud.base-C8SPw14H.mjs +0 -140
  87. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-simple-crud.base-C8SPw14H.mjs.map +0 -1
  88. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-stock.module-BSAe0CfZ.mjs +0 -102
  89. package/fesm2022/isaiahiroko-tilmart-ngx-apps-admin-stock.module-BSAe0CfZ.mjs.map +0 -1
@@ -0,0 +1,605 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, Component, NgModule } from '@angular/core';
3
+ import * as i1$1 from '@angular/router';
4
+ import { RouterModule } from '@angular/router';
5
+ import { getEnv, BaseDirective, using, notify, SharedModule } from '@thescaffold/ngx-core';
6
+ import * as i2 from '@thescaffold/ngx-ui';
7
+ import { ElementsModule, WebgetsModule } from '@thescaffold/ngx-ui';
8
+ import { HttpClient } from '@angular/common/http';
9
+ import { firstValueFrom, takeUntil, catchError, of } from 'rxjs';
10
+ import { a as statusBadge } from './isaiahiroko-tilmart-ngx-apps-admin-status-badge-AXfNPKaS.mjs';
11
+ import * as i1 from '@angular/forms';
12
+ import * as i3 from '@angular/common';
13
+
14
+ // `ProductMedia.blobId` (P1.3) resolves to `GET {API_BASE_URL}/apps/blobs/
15
+ // download/:id` — same helper/reasoning as the buyer app's
16
+ // `lib/data/media.ts#blobUrl` (confirmed against the real
17
+ // `ntx-apps/libs/blobs` controller, not guessed).
18
+ function resolveBlobUrl(blobId) {
19
+ if (!blobId)
20
+ return '';
21
+ return `${getEnv('API_BASE_URL')}/apps/blobs/download/${blobId}`;
22
+ }
23
+ // `@thescaffold/jsx-blobs`'s own `upload()` helper is broken against this
24
+ // platform's response envelope: its internal `init()`/`verify()` return
25
+ // the raw `{status, title, message, data}` body but `upload()` then reads
26
+ // `file.id` (not `file.data.id`) — so it always reports "Failed to init
27
+ // file upload" even on a 201. Confirmed by driving the real upload flow
28
+ // in a browser and reading the network log: `init` returns 201 with a
29
+ // real file id, `upload()` still fails. Rather than depend on a broken
30
+ // vendor convenience function, this reimplements the same three-call
31
+ // contract (init → chunked batch → verify) directly against
32
+ // `apiService`, which is also how P1's demo-media seed script validated
33
+ // the contract in the first place, and gets Angular's existing
34
+ // `JwtInterceptor` auth for free instead of hand-managing SDK config.
35
+ async function uploadFileToBlobs(apiService, file, parentId, tags) {
36
+ const ext = file.name.split('.').pop()?.toLowerCase() || '';
37
+ const mime = file.type || 'application/octet-stream';
38
+ const meta = { type: ext, parentId, name: file.name, tags, size: file.size, mime };
39
+ const initRes = await firstValueFrom(apiService.post('apps/blobs/upload/init', meta));
40
+ const fileId = initRes?.data?.id;
41
+ if (!fileId)
42
+ throw new Error('Failed to init file upload');
43
+ const chunkSize = 512 * 1024;
44
+ const reader = file.stream().getReader();
45
+ let index = 0;
46
+ let buffer = new Uint8Array();
47
+ const flushChunk = async (bytes) => {
48
+ await firstValueFrom(apiService.post('apps/blobs/upload/batch', {
49
+ pages: [{ fileId, index: index++, raw: uint8ToBase64(bytes) }],
50
+ }));
51
+ };
52
+ while (true) {
53
+ const { done, value } = await reader.read();
54
+ if (done)
55
+ break;
56
+ const combined = new Uint8Array(buffer.length + value.length);
57
+ combined.set(buffer);
58
+ combined.set(value, buffer.length);
59
+ buffer = combined;
60
+ while (buffer.length >= chunkSize) {
61
+ await flushChunk(buffer.slice(0, chunkSize));
62
+ buffer = buffer.slice(chunkSize);
63
+ }
64
+ }
65
+ if (buffer.length > 0)
66
+ await flushChunk(buffer);
67
+ const verifyRes = await firstValueFrom(apiService.post('apps/blobs/upload/verify', meta));
68
+ const blobId = verifyRes?.data?.id;
69
+ if (!blobId)
70
+ throw new Error('Failed to verify file upload');
71
+ return blobId;
72
+ }
73
+ function uint8ToBase64(bytes) {
74
+ let binary = '';
75
+ const chunkSize = 0x8000;
76
+ for (let i = 0; i < bytes.length; i += chunkSize) {
77
+ binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
78
+ }
79
+ return btoa(binary);
80
+ }
81
+ const PRODUCT_TYPES = ['simple', 'variant', 'kit'];
82
+ const PRODUCT_STATUSES = ['draft', 'active', 'archived', 'discontinued'];
83
+ // A fixed "folder" id for every admin-uploaded product image.
84
+ // `BlobsFiles.parentId` is NOT NULL in the DB despite the entity/DTO
85
+ // marking it optional (`@IsOptional()`, `nullable: true`) — a genuine
86
+ // vendor-package mismatch, found by running the demo-catalogue media seed
87
+ // script against a live server and reading the resulting
88
+ // QueryFailedError (see the commerce migrations' own notes). No FK is
89
+ // declared on the column, so any UUID satisfies it.
90
+ // Product photo guidance — mirrored in the bulk importer and the admin hint.
91
+ const MAX_IMAGE_BYTES = 8 * 1024 * 1024;
92
+ const MIN_IMAGE_SIDE = 800;
93
+ async function readImageSize(file) {
94
+ try {
95
+ const bitmap = await createImageBitmap(file);
96
+ const size = { width: bitmap.width, height: bitmap.height };
97
+ bitmap.close();
98
+ return size;
99
+ }
100
+ catch {
101
+ return undefined;
102
+ }
103
+ }
104
+ const PRODUCT_MEDIA_PARENT_ID = '00000000-0000-4000-8000-000000000d30';
105
+ // P1.15 (original slice) + R1 production-readiness pass (this rebuild).
106
+ // The original version of this page was read-only: a product list plus
107
+ // the CAT-03 publish-validation check, with no create/edit/media/
108
+ // attribute/variant/pricing UI anywhere — "no way to add items to
109
+ // catalogue" was the single most direct gap this session set out to
110
+ // close. This keeps the publish-check list and adds a full create/edit
111
+ // flow: basic info → category/brand → the category's resolved attribute
112
+ // grid → one implicit variant (simple products; a per-variant grid for
113
+ // `variant`-type products is real, isolated follow-up work, same
114
+ // reasoning P1.15 originally gave for deferring it) → media upload → a
115
+ // single default price + stock level. Search/refresh on the list are
116
+ // real (not the generic `x-webget-collection` — this table needs a
117
+ // bespoke "Check" action + inline errors the generic collection can't
118
+ // render, so pagination/search are hand-wired here instead).
119
+ class CatalogComponent extends BaseDirective {
120
+ constructor() {
121
+ super(...arguments);
122
+ this.http = inject(HttpClient);
123
+ this.productSource = this.apiService.on('apps/commerce/product');
124
+ this.categorySource = this.apiService.on('apps/commerce/category');
125
+ this.brandSource = this.apiService.on('apps/commerce/brand');
126
+ this.variantSource = this.apiService.on('apps/commerce/product-variant');
127
+ this.attrValueSource = this.apiService.on('apps/commerce/product-attribute-value');
128
+ this.mediaSource = this.apiService.on('apps/commerce/product-media');
129
+ this.priceSource = this.apiService.on('apps/commerce/price');
130
+ this.stockLevelSource = this.apiService.on('apps/commerce/stock-level');
131
+ this.stockLocationSource = this.apiService.on('apps/commerce/stock-location');
132
+ this.types = PRODUCT_TYPES;
133
+ this.statuses = PRODUCT_STATUSES;
134
+ this.loading = true;
135
+ this.products = [];
136
+ this.categories = [];
137
+ this.brands = [];
138
+ this.stockLocations = [];
139
+ this.query = '';
140
+ /** Status tab: '' = all. */
141
+ this.statusFilter = '';
142
+ this.page = 1;
143
+ this.perPage = 25;
144
+ this.total = 0;
145
+ this.statusBadge = statusBadge;
146
+ this.editing = false;
147
+ this.saving = false;
148
+ this.uploadingMedia = false;
149
+ this.draft = null;
150
+ this.variant = null;
151
+ this.attributeDefs = [];
152
+ this.attributeValues = {};
153
+ this.media = [];
154
+ this.price = null;
155
+ this.stock = null;
156
+ this.init = () => {
157
+ this.loadProducts();
158
+ this.loadCategories();
159
+ this.loadBrands();
160
+ this.loadStockLocations();
161
+ };
162
+ }
163
+ loadProducts(page = this.page) {
164
+ this.loading = true;
165
+ this.page = page;
166
+ const params = { page, perPage: this.perPage };
167
+ if (this.query.trim())
168
+ params.query = this.query.trim();
169
+ if (this.statusFilter)
170
+ params.status = this.statusFilter;
171
+ this.productSource
172
+ .getMany(params)
173
+ .pipe(takeUntil(this.$))
174
+ .subscribe(using((response) => {
175
+ this.products = (response?.data ?? []).map((p) => ({
176
+ id: p.id,
177
+ name: p.name,
178
+ model: p.model,
179
+ type: p.type,
180
+ status: p.status,
181
+ updatedAt: p.updatedAt,
182
+ primaryCategoryId: p.primaryCategoryId,
183
+ checking: false,
184
+ checked: false,
185
+ }));
186
+ this.total = response?.meta?.total ?? this.products.length;
187
+ this.loading = false;
188
+ void this.fillRowDetails(this.products);
189
+ }));
190
+ }
191
+ search() {
192
+ this.loadProducts(1);
193
+ }
194
+ setStatusFilter(status) {
195
+ this.statusFilter = status;
196
+ this.loadProducts(1);
197
+ }
198
+ categoryName(id) {
199
+ return (id && this.categories.find((c) => c.id === id)?.name) || '—';
200
+ }
201
+ // SKU, thumbnail, price and stock for the visible rows, after the table
202
+ // has rendered: one `product/admin-summary` call for the whole page.
203
+ async fillRowDetails(rows) {
204
+ if (!rows.length)
205
+ return;
206
+ const res = await firstValueFrom(this.apiService
207
+ .post('apps/commerce/product/admin-summary', { productIds: rows.map((r) => r.id) })
208
+ .pipe(catchError(() => of(null))));
209
+ const data = res?.data ?? {};
210
+ for (const row of rows) {
211
+ const s = data[row.id];
212
+ row.summaryLoaded = true;
213
+ // Call failed / row missing: price and stock stay unknown ("—"), not "none".
214
+ if (!s)
215
+ continue;
216
+ row.sku = s.sku ?? '';
217
+ row.thumbUrl = s.thumbnailBlobId ? `${getEnv('API_BASE_URL')}/apps/commerce/media/${s.thumbnailBlobId}?w=96` : '';
218
+ row.price = s.price ?? null;
219
+ row.stockFree = Number(s.available ?? 0) - Number(s.reserved ?? 0);
220
+ row.variantCount = Number(s.variants ?? 0);
221
+ }
222
+ }
223
+ money(price) {
224
+ if (!price)
225
+ return '—';
226
+ return new Intl.NumberFormat('en-NG', { style: 'currency', currency: price.currency || 'NGN', maximumFractionDigits: 0 }).format(price.amount);
227
+ }
228
+ refresh() {
229
+ this.loadProducts(this.page);
230
+ }
231
+ prevPage() {
232
+ if (this.page > 1)
233
+ this.loadProducts(this.page - 1);
234
+ }
235
+ nextPage() {
236
+ if (this.page * this.perPage < this.total)
237
+ this.loadProducts(this.page + 1);
238
+ }
239
+ loadCategories() {
240
+ this.categorySource
241
+ .getMany({ page: 1, perPage: 300 })
242
+ .pipe(takeUntil(this.$))
243
+ .subscribe(using((response) => {
244
+ this.categories = (response?.data ?? []).sort((a, b) => String(a.name).localeCompare(String(b.name)));
245
+ }));
246
+ }
247
+ loadBrands() {
248
+ this.brandSource
249
+ .getMany({ page: 1, perPage: 200 })
250
+ .pipe(takeUntil(this.$))
251
+ .subscribe(using((response) => {
252
+ this.brands = (response?.data ?? []).sort((a, b) => String(a.name).localeCompare(String(b.name)));
253
+ }));
254
+ }
255
+ loadStockLocations() {
256
+ this.stockLocationSource
257
+ .getMany({ page: 1, perPage: 50 })
258
+ .pipe(takeUntil(this.$))
259
+ .subscribe(using((response) => (this.stockLocations = response?.data ?? [])));
260
+ }
261
+ checkPublish(product) {
262
+ product.checking = true;
263
+ this.productSource
264
+ .post(`apps/commerce/product/${product.id}/validate-publish`)
265
+ .pipe(takeUntil(this.$))
266
+ .subscribe(using((response) => {
267
+ product.checking = false;
268
+ product.checked = true;
269
+ product.canPublish = !!response?.data?.canPublish;
270
+ product.errors = response?.data?.errors ?? [];
271
+ }));
272
+ }
273
+ startCreate() {
274
+ this.editing = true;
275
+ this.draft = {
276
+ name: '',
277
+ slug: '',
278
+ model: '',
279
+ brandId: '',
280
+ primaryCategoryId: '',
281
+ shortDesc: '',
282
+ type: 'simple',
283
+ status: 'draft',
284
+ };
285
+ this.variant = { sku: '', weight: null, handlingClass: 'standard' };
286
+ this.attributeDefs = [];
287
+ this.attributeValues = {};
288
+ this.media = [];
289
+ this.price = { amount: null };
290
+ this.stock = { locationId: this.stockLocations[0]?.id ?? '', available: 0 };
291
+ }
292
+ async edit(row) {
293
+ this.editing = true;
294
+ const productRes = await firstValueFrom(this.productSource.getOne(row.id));
295
+ const p = productRes?.data;
296
+ this.draft = {
297
+ id: p.id,
298
+ name: p.name ?? '',
299
+ slug: p.slug ?? '',
300
+ model: p.model ?? '',
301
+ brandId: p.brandId ?? '',
302
+ primaryCategoryId: p.primaryCategoryId ?? '',
303
+ shortDesc: p.shortDesc ?? '',
304
+ type: p.type,
305
+ status: p.status,
306
+ };
307
+ this.attributeValues = {};
308
+ if (this.draft.primaryCategoryId) {
309
+ await this.loadAttributeTemplate(this.draft.primaryCategoryId);
310
+ }
311
+ else {
312
+ this.attributeDefs = [];
313
+ }
314
+ const [variantsRes, attrsRes, mediaRes] = await Promise.all([
315
+ firstValueFrom(this.variantSource.getMany({ productId: p.id, page: 1, perPage: 50 })),
316
+ firstValueFrom(this.attrValueSource.getMany({ productId: p.id, page: 1, perPage: 200 })),
317
+ firstValueFrom(this.mediaSource.getMany({ productId: p.id, page: 1, perPage: 50 })),
318
+ ]);
319
+ const firstVariant = variantsRes?.data?.[0];
320
+ this.variant = firstVariant
321
+ ? {
322
+ id: firstVariant.id,
323
+ sku: firstVariant.sku,
324
+ weight: firstVariant.weight ?? null,
325
+ handlingClass: firstVariant.handlingClass ?? 'standard',
326
+ }
327
+ : { sku: '', weight: null, handlingClass: 'standard' };
328
+ for (const v of attrsRes?.data ?? []) {
329
+ this.attributeValues[v.attributeDefinitionId] = {
330
+ id: v.id,
331
+ valueNumber: v.valueNumber,
332
+ valueNumberHigh: v.valueNumberHigh,
333
+ valueText: v.valueText,
334
+ valueBool: v.valueBool,
335
+ };
336
+ }
337
+ this.media = (mediaRes?.data ?? []).map((m) => ({
338
+ id: m.id,
339
+ blobId: m.blobId,
340
+ altText: m.altText,
341
+ type: m.type,
342
+ }));
343
+ for (const m of this.media) {
344
+ m.objectUrl = await this.resolveMediaObjectUrl(m.blobId);
345
+ }
346
+ if (this.variant.id) {
347
+ const priceRes = await firstValueFrom(this.priceSource.getMany({ variantId: this.variant.id, page: 1, perPage: 1 }));
348
+ const priceRow = priceRes?.data?.[0];
349
+ this.price = priceRow ? { id: priceRow.id, amount: priceRow.amount } : { amount: null };
350
+ const stockRes = await firstValueFrom(this.stockLevelSource.getMany({ variantId: this.variant.id, page: 1, perPage: 1 }));
351
+ const stockRow = stockRes?.data?.[0];
352
+ this.stock = stockRow
353
+ ? { id: stockRow.id, locationId: stockRow.locationId, available: stockRow.available }
354
+ : { locationId: this.stockLocations[0]?.id ?? '', available: 0 };
355
+ }
356
+ else {
357
+ this.price = { amount: null };
358
+ this.stock = { locationId: this.stockLocations[0]?.id ?? '', available: 0 };
359
+ }
360
+ }
361
+ async onCategoryChange() {
362
+ if (!this.draft?.primaryCategoryId) {
363
+ this.attributeDefs = [];
364
+ return;
365
+ }
366
+ await this.loadAttributeTemplate(this.draft.primaryCategoryId);
367
+ }
368
+ async loadAttributeTemplate(categoryId) {
369
+ try {
370
+ const res = await firstValueFrom(this.apiService.get(`apps/commerce/category/${categoryId}/attribute-template`));
371
+ this.attributeDefs = (res?.data?.definitions ?? []);
372
+ for (const def of this.attributeDefs) {
373
+ if (!this.attributeValues[def.id])
374
+ this.attributeValues[def.id] = {};
375
+ }
376
+ }
377
+ catch {
378
+ this.attributeDefs = [];
379
+ }
380
+ }
381
+ async saveProduct() {
382
+ if (!this.draft || !this.draft.name.trim()) {
383
+ notify('Name is required.', undefined, 'error');
384
+ return;
385
+ }
386
+ this.saving = true;
387
+ try {
388
+ const payload = {
389
+ name: this.draft.name.trim(),
390
+ slug: this.draft.slug.trim() || undefined,
391
+ brandId: this.draft.brandId || undefined,
392
+ model: this.draft.model.trim() || undefined,
393
+ primaryCategoryId: this.draft.primaryCategoryId || undefined,
394
+ shortDesc: this.draft.shortDesc.trim() || undefined,
395
+ type: this.draft.type,
396
+ status: this.draft.status,
397
+ };
398
+ if (this.draft.id) {
399
+ await firstValueFrom(this.productSource.update(this.draft.id, payload));
400
+ }
401
+ else {
402
+ const res = await firstValueFrom(this.productSource.create(payload));
403
+ this.draft.id = res?.data?.id;
404
+ }
405
+ const productId = this.draft.id;
406
+ if (this.variant && this.variant.sku.trim()) {
407
+ const variantPayload = {
408
+ productId,
409
+ sku: this.variant.sku.trim(),
410
+ weight: this.variant.weight != null ? Number(this.variant.weight) : undefined,
411
+ handlingClass: this.variant.handlingClass || 'standard',
412
+ };
413
+ if (this.variant.id) {
414
+ await firstValueFrom(this.variantSource.update(this.variant.id, variantPayload));
415
+ }
416
+ else {
417
+ const vRes = await firstValueFrom(this.variantSource.create(variantPayload));
418
+ this.variant.id = vRes?.data?.id;
419
+ }
420
+ }
421
+ for (const def of this.attributeDefs) {
422
+ const v = this.attributeValues[def.id];
423
+ if (!v)
424
+ continue;
425
+ const hasValue = (v.valueNumber !== null && v.valueNumber !== undefined && `${v.valueNumber}` !== '') ||
426
+ !!v.valueText ||
427
+ v.valueBool !== null && v.valueBool !== undefined;
428
+ if (!hasValue)
429
+ continue;
430
+ const attrPayload = {
431
+ productId,
432
+ attributeDefinitionId: def.id,
433
+ valueNumber: def.dataType === 'number' || def.dataType === 'range'
434
+ ? v.valueNumber != null && `${v.valueNumber}` !== ''
435
+ ? Number(v.valueNumber)
436
+ : undefined
437
+ : undefined,
438
+ valueNumberHigh: def.dataType === 'range' && v.valueNumberHigh != null && `${v.valueNumberHigh}` !== ''
439
+ ? Number(v.valueNumberHigh)
440
+ : undefined,
441
+ valueText: def.dataType === 'text' || def.dataType === 'enum' ? v.valueText || undefined : undefined,
442
+ valueBool: def.dataType === 'boolean' ? !!v.valueBool : undefined,
443
+ };
444
+ if (v.id) {
445
+ await firstValueFrom(this.attrValueSource.update(v.id, attrPayload));
446
+ }
447
+ else {
448
+ const aRes = await firstValueFrom(this.attrValueSource.create(attrPayload));
449
+ v.id = aRes?.data?.id;
450
+ }
451
+ }
452
+ if (this.variant?.id) {
453
+ if (this.price && this.price.amount != null && `${this.price.amount}` !== '') {
454
+ const pricePayload = {
455
+ variantId: this.variant.id,
456
+ amount: Number(this.price.amount),
457
+ minQuantity: 1,
458
+ };
459
+ if (this.price.id) {
460
+ await firstValueFrom(this.priceSource.update(this.price.id, pricePayload));
461
+ }
462
+ else {
463
+ const prRes = await firstValueFrom(this.priceSource.create(pricePayload));
464
+ this.price.id = prRes?.data?.id;
465
+ }
466
+ }
467
+ if (this.stock?.locationId) {
468
+ const stockPayload = {
469
+ variantId: this.variant.id,
470
+ locationId: this.stock.locationId,
471
+ available: Number(this.stock.available ?? 0),
472
+ };
473
+ if (this.stock.id) {
474
+ await firstValueFrom(this.stockLevelSource.update(this.stock.id, stockPayload));
475
+ }
476
+ else {
477
+ const stRes = await firstValueFrom(this.stockLevelSource.create(stockPayload));
478
+ this.stock.id = stRes?.data?.id;
479
+ }
480
+ }
481
+ }
482
+ notify('Product saved.', undefined, 'success');
483
+ this.loadProducts(this.page);
484
+ }
485
+ catch {
486
+ notify('Could not save the product (check required fields).', undefined, 'error');
487
+ }
488
+ finally {
489
+ this.saving = false;
490
+ }
491
+ }
492
+ async onMediaSelected(event) {
493
+ const input = event.target;
494
+ const files = input.files;
495
+ if (!files || !files.length || !this.draft?.id)
496
+ return;
497
+ const file = files[0];
498
+ if (file.size > MAX_IMAGE_BYTES) {
499
+ notify('That image is over 8 MB — export it at 1200–2000 px (JPG/WebP) and try again.', undefined, 'error');
500
+ input.value = '';
501
+ return;
502
+ }
503
+ const size = await readImageSize(file);
504
+ if (size && Math.min(size.width, size.height) < MIN_IMAGE_SIDE) {
505
+ notify(`That image is only ${size.width} × ${size.height}px — it will look soft on large screens. 1200 × 1200 px or more is recommended.`, undefined, 'warning');
506
+ }
507
+ this.uploadingMedia = true;
508
+ try {
509
+ const blobId = await uploadFileToBlobs(this.apiService, file, PRODUCT_MEDIA_PARENT_ID, [
510
+ 'product-media',
511
+ ]);
512
+ const altText = `${this.draft.name} — product photo`;
513
+ const res = await firstValueFrom(this.mediaSource.create({
514
+ productId: this.draft.id,
515
+ blobId,
516
+ type: 'gallery',
517
+ altText,
518
+ position: this.media.length,
519
+ }));
520
+ const objectUrl = await this.resolveMediaObjectUrl(blobId);
521
+ this.media.push({ id: res?.data?.id, blobId, altText, type: 'gallery', objectUrl });
522
+ notify('Image uploaded.', undefined, 'success');
523
+ }
524
+ catch (e) {
525
+ console.error('media upload failed', e);
526
+ notify('Could not upload the image.', undefined, 'error');
527
+ }
528
+ finally {
529
+ this.uploadingMedia = false;
530
+ input.value = '';
531
+ }
532
+ }
533
+ async removeMedia(item) {
534
+ try {
535
+ await firstValueFrom(this.mediaSource.remove(item.id));
536
+ this.media = this.media.filter((m) => m.id !== item.id);
537
+ }
538
+ catch {
539
+ notify('Could not remove the image.', undefined, 'error');
540
+ }
541
+ }
542
+ // `download/:id` needs the bearer header only `HttpClient` (via the
543
+ // app's existing `JwtInterceptor`) can attach — see the `MediaVm.
544
+ // objectUrl` comment. Empty string on failure just leaves the
545
+ // thumbnail blank rather than breaking the editor.
546
+ async resolveMediaObjectUrl(blobId) {
547
+ try {
548
+ const blob = await firstValueFrom(this.http.get(resolveBlobUrl(blobId), { responseType: 'blob' }));
549
+ // Not `URL.createObjectURL` — the app's CSP `img-src` allows `data:`
550
+ // but not `blob:`, so an object URL renders as a CSP violation
551
+ // (confirmed by driving this in a browser). A data URI sidesteps it.
552
+ return await new Promise((resolve, reject) => {
553
+ const reader = new FileReader();
554
+ reader.onload = () => resolve(reader.result);
555
+ reader.onerror = reject;
556
+ reader.readAsDataURL(blob);
557
+ });
558
+ }
559
+ catch {
560
+ return '';
561
+ }
562
+ }
563
+ cancelEdit() {
564
+ this.editing = false;
565
+ this.draft = null;
566
+ this.variant = null;
567
+ this.attributeDefs = [];
568
+ this.attributeValues = {};
569
+ this.media = [];
570
+ this.price = null;
571
+ this.stock = null;
572
+ }
573
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: CatalogComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
574
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.2.16", type: CatalogComponent, isStandalone: false, selector: "x-catalog", usesInheritance: true, ngImport: i0, template: "<div class=\"x-page-head\">\n <div class=\"x-page-title\">Catalogue</div>\n <div class=\"x-page-subtitle\">Products, variants, attributes, media, pricing and stock.</div>\n</div>\n\n@if (!editing) {\n <div class=\"x-cat-toolbar\">\n <input\n type=\"text\"\n class=\"x-cat-search\"\n placeholder=\"Search products\u2026\"\n [(ngModel)]=\"query\"\n (keyup.enter)=\"search()\"\n />\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"search()\">Search</button>\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"refresh()\">Refresh</button>\n <div class=\"x-cat-spacer\"></div>\n <a class=\"x-cat-btn\" routerLink=\"/admin/bulk-upload\">Bulk upload (Excel)</a>\n <button type=\"button\" class=\"x-cat-btn x-cat-btn-primary\" (click)=\"startCreate()\">+ New product</button>\n </div>\n\n <div class=\"x-cat-tabs\" role=\"tablist\" aria-label=\"Filter by status\">\n @for (tab of [''].concat(statuses); track tab) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"x-cat-tab\"\n [class.is-active]=\"statusFilter === tab\"\n [attr.aria-selected]=\"statusFilter === tab\"\n (click)=\"setStatusFilter(tab)\"\n >\n {{ tab ? (tab | titlecase) : 'All' }}\n </button>\n }\n </div>\n\n @if (loading) {\n <x-element-loader></x-element-loader>\n } @else {\n <div class=\"x-catalog-table\">\n <div class=\"x-catalog-row x-catalog-head\">\n <div class=\"x-catalog-col-name\">Product</div>\n <div class=\"x-catalog-col-sku\">SKU</div>\n <div class=\"x-catalog-col-category\">Category</div>\n <div class=\"x-catalog-col-price\">Price</div>\n <div class=\"x-catalog-col-stock\">Stock</div>\n <div class=\"x-catalog-col-status\">Status</div>\n <div class=\"x-catalog-col-check\">Publish check</div>\n <div class=\"x-catalog-col-action\"></div>\n </div>\n @for (product of products; track product.id) {\n <div class=\"x-catalog-row\">\n <div class=\"x-catalog-col-name\">\n @if (product.thumbUrl) {\n <img class=\"x-catalog-thumb\" [src]=\"product.thumbUrl\" alt=\"\" loading=\"lazy\" />\n } @else {\n <span class=\"x-catalog-thumb x-catalog-thumb-empty\" aria-hidden=\"true\"></span>\n }\n <span>\n {{ product.name }}\n <span class=\"x-catalog-model\">\n {{ product.type }}@if (product.model) { \u00B7 {{ product.model }} } \u00B7 updated {{ product.updatedAt | date: 'd MMM' }}\n </span>\n </span>\n </div>\n <div class=\"x-catalog-col-sku\">{{ product.sku || '\u2014' }}</div>\n <div class=\"x-catalog-col-category\">{{ categoryName(product.primaryCategoryId) }}</div>\n <div class=\"x-catalog-col-price\">\n @if (!product.summaryLoaded) {\n <span class=\"x-check-pending\">\u2026</span>\n } @else if (product.price) {\n {{ money(product.price) }}\n } @else if (product.price === null) {\n <span class=\"x-catalog-warn\">No price</span>\n } @else {\n \u2014\n }\n </div>\n <div class=\"x-catalog-col-stock\">\n @if (!product.summaryLoaded) {\n <span class=\"x-check-pending\">\u2026</span>\n } @else if (product.stockFree === undefined) {\n \u2014\n } @else if (product.stockFree > 0) {\n {{ product.stockFree }}\n @if ((product.variantCount ?? 0) > 1) {\n <span class=\"x-catalog-model\">{{ product.variantCount }} variants</span>\n }\n } @else {\n <span class=\"x-catalog-warn\">Out</span>\n }\n </div>\n <div class=\"x-catalog-col-status\" [innerHTML]=\"statusBadge(product.status)\"></div>\n <div class=\"x-catalog-col-check\">\n @if (product.checking) {\n <span class=\"x-check-pending\">Checking\u2026</span>\n } @else if (product.checked && product.canPublish) {\n <span class=\"x-check-ok\">\u2713 Ready to publish</span>\n } @else if (!product.checked) {\n <span class=\"x-check-pending\">Not checked \u2014 press Check</span>\n } @else if (product.checked && product.errors?.length) {\n <ul class=\"x-check-errors\">\n @for (err of product.errors; track err.field) {\n <li>{{ err.message }}</li>\n }\n </ul>\n }\n </div>\n <div class=\"x-catalog-col-action\">\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"edit(product)\">Edit</button>\n <button\n type=\"button\"\n class=\"x-check-btn\"\n [disabled]=\"product.checking\"\n (click)=\"checkPublish(product)\"\n >\n Check\n </button>\n </div>\n </div>\n }\n @if (!products.length) {\n <div class=\"x-catalog-empty\">No products yet \u2014 use \"+ New product\" to add one.</div>\n }\n </div>\n\n <div class=\"x-cat-pager\">\n <button type=\"button\" class=\"x-cat-btn\" [disabled]=\"page <= 1\" (click)=\"prevPage()\">\u2190 Prev</button>\n <span class=\"x-cat-pager-label\">Page {{ page }} \u00B7 {{ total }} total</span>\n <button type=\"button\" class=\"x-cat-btn\" [disabled]=\"page * perPage >= total\" (click)=\"nextPage()\">\n Next \u2192\n </button>\n </div>\n }\n} @else if (draft) {\n <div class=\"x-cat-editor\">\n <div class=\"x-cat-editor-head\">\n <div class=\"x-cat-editor-title\">{{ draft.id ? 'Edit product' : 'New product' }}</div>\n <div class=\"x-cat-editor-actions\">\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"cancelEdit()\">Close</button>\n <button type=\"button\" class=\"x-cat-btn x-cat-btn-primary\" [disabled]=\"saving\" (click)=\"saveProduct()\">\n {{ saving ? 'Saving\u2026' : 'Save' }}\n </button>\n </div>\n </div>\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Basic info</div>\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Name\n <input type=\"text\" [(ngModel)]=\"draft.name\" />\n </label>\n <label class=\"x-cat-f\">\n Slug (optional)\n <input type=\"text\" [(ngModel)]=\"draft.slug\" placeholder=\"auto from name if blank\" />\n </label>\n </div>\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Model\n <input type=\"text\" [(ngModel)]=\"draft.model\" />\n </label>\n <label class=\"x-cat-f\">\n Type\n <select [(ngModel)]=\"draft.type\">\n @for (t of types; track t) { <option [value]=\"t\">{{ t }}</option> }\n </select>\n </label>\n <label class=\"x-cat-f\">\n Status\n <select [(ngModel)]=\"draft.status\">\n @for (s of statuses; track s) { <option [value]=\"s\">{{ s }}</option> }\n </select>\n </label>\n </div>\n @if (draft.type !== 'simple') {\n <div class=\"x-cat-hint\">\n \"{{ draft.type }}\" products still save through this one-variant form for now \u2014 a full\n per-variant / per-component editor is a follow-up.\n </div>\n }\n <label class=\"x-cat-f\">\n Short description\n <textarea rows=\"2\" [(ngModel)]=\"draft.shortDesc\"></textarea>\n </label>\n </section>\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Category &amp; brand</div>\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Category\n <select [(ngModel)]=\"draft.primaryCategoryId\" (ngModelChange)=\"onCategoryChange()\">\n <option value=\"\">\u2014 none \u2014</option>\n @for (c of categories; track c.id) { <option [value]=\"c.id\">{{ c.name }}</option> }\n </select>\n </label>\n <label class=\"x-cat-f\">\n Brand\n <select [(ngModel)]=\"draft.brandId\">\n <option value=\"\">\u2014 none \u2014</option>\n @for (b of brands; track b.id) { <option [value]=\"b.id\">{{ b.name }}</option> }\n </select>\n </label>\n </div>\n </section>\n\n @if (attributeDefs.length) {\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Attributes</div>\n <div class=\"x-cat-attr-grid\">\n @for (def of attributeDefs; track def.id) {\n <label class=\"x-cat-f x-cat-attr\">\n {{ def.label }}{{ def.unit ? ' (' + def.unit + ')' : '' }}\n @if (def.required) {\n <span class=\"x-cat-required\">*</span>\n }\n @switch (def.dataType) {\n @case ('boolean') {\n <input type=\"checkbox\" [(ngModel)]=\"attributeValues[def.id].valueBool\" />\n }\n @case ('enum') {\n <select [(ngModel)]=\"attributeValues[def.id].valueText\">\n <option value=\"\">\u2014 choose \u2014</option>\n @for (opt of def.allowedValues; track opt) { <option [value]=\"opt\">{{ opt }}</option> }\n </select>\n }\n @case ('range') {\n <div class=\"x-cat-range\">\n <input type=\"number\" placeholder=\"min\" [(ngModel)]=\"attributeValues[def.id].valueNumber\" />\n <span>\u2013</span>\n <input\n type=\"number\"\n placeholder=\"max\"\n [(ngModel)]=\"attributeValues[def.id].valueNumberHigh\"\n />\n </div>\n }\n @case ('number') {\n <input type=\"number\" [(ngModel)]=\"attributeValues[def.id].valueNumber\" />\n }\n @default {\n <input type=\"text\" [(ngModel)]=\"attributeValues[def.id].valueText\" />\n }\n }\n </label>\n }\n </div>\n </section>\n }\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Variant, price &amp; stock</div>\n @if (variant) {\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n SKU\n <input type=\"text\" [(ngModel)]=\"variant.sku\" />\n </label>\n <label class=\"x-cat-f\">\n Weight (kg)\n <input type=\"number\" min=\"0\" step=\"0.1\" [(ngModel)]=\"variant.weight\" />\n @if (variant.weight == null || variant.weight <= 0) {\n <small class=\"x-cat-hint\" style=\"color: var(--color-warn)\">\n No weight \u2014 delivery is priced with the default weight. Add the packed weight for an accurate shipping fee.\n </small>\n }\n </label>\n <label class=\"x-cat-f\">\n Handling class\n <select [(ngModel)]=\"variant.handlingClass\">\n <option value=\"standard\">standard</option>\n <option value=\"bulky\">bulky</option>\n <option value=\"freight\">freight</option>\n <option value=\"hazmat\">hazmat</option>\n </select>\n </label>\n </div>\n }\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Price (\u20A6)\n <input type=\"number\" [(ngModel)]=\"price!.amount\" [disabled]=\"!variant?.sku\" />\n </label>\n <label class=\"x-cat-f\">\n Stock location\n <select [(ngModel)]=\"stock!.locationId\" [disabled]=\"!variant?.sku\">\n @for (loc of stockLocations; track loc.id) { <option [value]=\"loc.id\">{{ loc.name }}</option> }\n </select>\n </label>\n <label class=\"x-cat-f\">\n Available\n <input type=\"number\" [(ngModel)]=\"stock!.available\" [disabled]=\"!variant?.sku\" />\n </label>\n </div>\n @if (!variant?.sku) {\n <div class=\"x-cat-hint\">Enter a SKU above, then price/stock can be saved.</div>\n }\n </section>\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Media</div>\n @if (!draft.id) {\n <div class=\"x-cat-hint\">Save the product once first \u2014 media needs a real product to attach to.</div>\n } @else {\n <div class=\"x-cat-media-grid\">\n @for (m of media; track m.id) {\n <div class=\"x-cat-media-item\">\n <img [src]=\"m.objectUrl\" [alt]=\"m.altText\" />\n <button type=\"button\" class=\"x-cat-media-remove\" (click)=\"removeMedia(m)\">Remove</button>\n </div>\n }\n </div>\n <label class=\"x-cat-btn x-cat-upload\">\n {{ uploadingMedia ? 'Uploading\u2026' : '+ Add image' }}\n <input type=\"file\" accept=\"image/*\" hidden [disabled]=\"uploadingMedia\" (change)=\"onMediaSelected($event)\" />\n </label>\n <div class=\"x-cat-hint\">\n Best results: <strong>1200 \u00D7 1200 px</strong> or larger, square (4:3 also works), product centred on a\n plain white/light background, JPG or WebP, under 8 MB. The first image is the listing thumbnail \u2014\n use a clean front-on shot; add the rating plate, ports/back and box contents as extra images.\n The site downsizes photos for phones automatically, so upload the sharp original.\n </div>\n }\n </section>\n </div>\n}\n", styles: [".x-page-head{margin-bottom:20px}.x-page-title{font-size:24px;font-weight:800;color:var(--color-text)}.x-page-subtitle{font-size:13.5px;color:var(--color-text-muted);margin-top:2px}.x-cat-toolbar{display:flex;align-items:center;gap:8px;margin-bottom:14px}.x-cat-search{border:1px solid var(--color-border);border-radius:var(--radius-md);padding:6px 10px;font-size:13px;background:var(--color-surface);color:var(--color-text);min-width:220px}.x-cat-spacer{flex:1}.x-cat-btn{border:1px solid var(--color-border);background:transparent;border-radius:var(--radius-md);padding:6px 14px;font-size:12.5px;font-weight:700;cursor:pointer;color:var(--color-text-muted);display:inline-flex;align-items:center}.x-cat-btn:disabled{opacity:.5;cursor:default}.x-cat-btn-primary{border-color:var(--color-accent);color:var(--color-accent-hover)}.x-catalog-table{display:flex;flex-direction:column;border:1px solid var(--color-border);border-radius:var(--radius-lg);overflow:hidden}.x-catalog-row{display:grid;grid-template-columns:minmax(220px,2.4fr) 130px 1fr 100px 70px 110px 1.4fr 140px;gap:10px;align-items:center;padding:10px 14px;border-bottom:1px solid var(--color-border);font-size:13px}.x-catalog-row:last-child{border-bottom:none}.x-catalog-head{font-weight:700;font-size:11.5px;text-transform:uppercase;letter-spacing:.02em;color:var(--color-text-muted);background:var(--color-surface-alt, rgba(0, 0, 0, .02))}.x-catalog-model{display:block;font-size:11.5px;color:var(--color-text-muted)}.x-catalog-col-action{display:flex;gap:6px;justify-content:flex-end}.x-catalog-empty{padding:24px;text-align:center;color:var(--color-text-muted);font-size:13px}.x-status-badge{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;border:1px solid var(--color-border);text-transform:capitalize}.x-check-pending{color:var(--color-text-muted);font-size:12px}.x-check-ok{color:var(--color-success, #2a7a3b);font-size:12px;font-weight:700}.x-check-errors{margin:0;padding-left:16px;font-size:11.5px;color:var(--color-danger, #c0362c)}.x-check-btn{border:1px solid var(--color-border);background:transparent;border-radius:var(--radius-md);padding:4px 10px;font-size:11.5px;font-weight:700;cursor:pointer;color:var(--color-text-muted)}.x-check-btn:disabled{opacity:.5;cursor:default}.x-cat-pager{display:flex;align-items:center;justify-content:center;gap:14px;margin-top:12px}.x-cat-pager-label{font-size:12px;color:var(--color-text-muted)}.x-cat-editor{display:flex;flex-direction:column;gap:16px}.x-cat-editor-head{display:flex;align-items:center;justify-content:space-between}.x-cat-editor-title{font-size:18px;font-weight:800;color:var(--color-text)}.x-cat-editor-actions{display:flex;gap:8px}.x-cat-section{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);padding:16px;display:flex;flex-direction:column;gap:10px}.x-cat-section-title{font-size:13px;font-weight:800;color:var(--color-text);text-transform:uppercase;letter-spacing:.02em}.x-cat-f{display:flex;flex-direction:column;gap:4px;flex:1;font-size:11.5px;color:var(--color-text-muted);font-weight:700}.x-cat-f input,.x-cat-f select,.x-cat-f textarea{border:1px solid var(--color-border);border-radius:var(--radius-md);padding:6px 10px;font-size:13px;background:var(--color-surface);color:var(--color-text);font-weight:400}.x-cat-f-row{display:flex;gap:10px;flex-wrap:wrap}.x-cat-hint{font-size:12px;color:var(--color-text-muted);font-style:italic}.x-cat-required{color:var(--color-danger, #c0362c)}.x-cat-attr-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px}.x-cat-attr input[type=checkbox]{width:18px;height:18px}.x-cat-range{display:flex;align-items:center;gap:6px}.x-cat-range input{width:0;flex:1}.x-cat-media-grid{display:flex;flex-wrap:wrap;gap:12px}.x-cat-media-item{position:relative;width:100px;height:100px;border:1px solid var(--color-border);border-radius:var(--radius-md);overflow:hidden}.x-cat-media-item img{width:100%;height:100%;object-fit:cover;display:block}.x-cat-media-remove{position:absolute;bottom:0;left:0;right:0;border:none;background:#0009;color:#fff;font-size:10px;padding:3px 0;cursor:pointer}.x-cat-upload{align-self:flex-start;cursor:pointer}.x-catalog-col-name{display:flex;align-items:center;gap:10px;min-width:0}.x-catalog-thumb{flex:0 0 40px;width:40px;height:40px;object-fit:contain;border-radius:var(--radius-sm, 4px);border:1px solid var(--color-border);background:var(--color-surface)}.x-catalog-thumb-empty{display:inline-block;background:var(--color-surface-2, rgba(0, 0, 0, .04))}.x-catalog-col-sku{font-family:var(--font-mono);font-size:12px;overflow:hidden;text-overflow:ellipsis}.x-cat-tabs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 12px}.x-cat-tab{padding:5px 12px;border-radius:999px;border:1px solid var(--color-border);background:var(--color-surface);color:var(--color-text);font-size:12.5px;font-weight:600;cursor:pointer}.x-cat-tab.is-active{background:var(--color-accent);border-color:var(--color-accent);color:var(--color-accent-fg)}.x-catalog-table{overflow-x:auto}.x-catalog-row{min-width:1040px}.x-catalog-col-price,.x-catalog-col-stock{font-family:var(--font-mono);font-size:12px}.x-catalog-warn{color:var(--color-warn, #8a5a12);font-weight:600}\n"], dependencies: [{ kind: "directive", type: i1.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { kind: "directive", type: i1.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }, { kind: "directive", type: i1.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.MinValidator, selector: "input[type=number][min][formControlName],input[type=number][min][formControl],input[type=number][min][ngModel]", inputs: ["min"] }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "directive", type: i1$1.RouterLink, selector: "[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "state", "info", "relativeTo", "preserveFragment", "skipLocationChange", "replaceUrl", "routerLink"] }, { kind: "component", type: i2.LoaderComponent, selector: "x-element-loader", inputs: ["data"] }, { kind: "pipe", type: i3.TitleCasePipe, name: "titlecase" }, { kind: "pipe", type: i3.DatePipe, name: "date" }] }); }
575
+ }
576
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: CatalogComponent, decorators: [{
577
+ type: Component,
578
+ args: [{ standalone: false, selector: 'x-catalog', template: "<div class=\"x-page-head\">\n <div class=\"x-page-title\">Catalogue</div>\n <div class=\"x-page-subtitle\">Products, variants, attributes, media, pricing and stock.</div>\n</div>\n\n@if (!editing) {\n <div class=\"x-cat-toolbar\">\n <input\n type=\"text\"\n class=\"x-cat-search\"\n placeholder=\"Search products\u2026\"\n [(ngModel)]=\"query\"\n (keyup.enter)=\"search()\"\n />\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"search()\">Search</button>\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"refresh()\">Refresh</button>\n <div class=\"x-cat-spacer\"></div>\n <a class=\"x-cat-btn\" routerLink=\"/admin/bulk-upload\">Bulk upload (Excel)</a>\n <button type=\"button\" class=\"x-cat-btn x-cat-btn-primary\" (click)=\"startCreate()\">+ New product</button>\n </div>\n\n <div class=\"x-cat-tabs\" role=\"tablist\" aria-label=\"Filter by status\">\n @for (tab of [''].concat(statuses); track tab) {\n <button\n type=\"button\"\n role=\"tab\"\n class=\"x-cat-tab\"\n [class.is-active]=\"statusFilter === tab\"\n [attr.aria-selected]=\"statusFilter === tab\"\n (click)=\"setStatusFilter(tab)\"\n >\n {{ tab ? (tab | titlecase) : 'All' }}\n </button>\n }\n </div>\n\n @if (loading) {\n <x-element-loader></x-element-loader>\n } @else {\n <div class=\"x-catalog-table\">\n <div class=\"x-catalog-row x-catalog-head\">\n <div class=\"x-catalog-col-name\">Product</div>\n <div class=\"x-catalog-col-sku\">SKU</div>\n <div class=\"x-catalog-col-category\">Category</div>\n <div class=\"x-catalog-col-price\">Price</div>\n <div class=\"x-catalog-col-stock\">Stock</div>\n <div class=\"x-catalog-col-status\">Status</div>\n <div class=\"x-catalog-col-check\">Publish check</div>\n <div class=\"x-catalog-col-action\"></div>\n </div>\n @for (product of products; track product.id) {\n <div class=\"x-catalog-row\">\n <div class=\"x-catalog-col-name\">\n @if (product.thumbUrl) {\n <img class=\"x-catalog-thumb\" [src]=\"product.thumbUrl\" alt=\"\" loading=\"lazy\" />\n } @else {\n <span class=\"x-catalog-thumb x-catalog-thumb-empty\" aria-hidden=\"true\"></span>\n }\n <span>\n {{ product.name }}\n <span class=\"x-catalog-model\">\n {{ product.type }}@if (product.model) { \u00B7 {{ product.model }} } \u00B7 updated {{ product.updatedAt | date: 'd MMM' }}\n </span>\n </span>\n </div>\n <div class=\"x-catalog-col-sku\">{{ product.sku || '\u2014' }}</div>\n <div class=\"x-catalog-col-category\">{{ categoryName(product.primaryCategoryId) }}</div>\n <div class=\"x-catalog-col-price\">\n @if (!product.summaryLoaded) {\n <span class=\"x-check-pending\">\u2026</span>\n } @else if (product.price) {\n {{ money(product.price) }}\n } @else if (product.price === null) {\n <span class=\"x-catalog-warn\">No price</span>\n } @else {\n \u2014\n }\n </div>\n <div class=\"x-catalog-col-stock\">\n @if (!product.summaryLoaded) {\n <span class=\"x-check-pending\">\u2026</span>\n } @else if (product.stockFree === undefined) {\n \u2014\n } @else if (product.stockFree > 0) {\n {{ product.stockFree }}\n @if ((product.variantCount ?? 0) > 1) {\n <span class=\"x-catalog-model\">{{ product.variantCount }} variants</span>\n }\n } @else {\n <span class=\"x-catalog-warn\">Out</span>\n }\n </div>\n <div class=\"x-catalog-col-status\" [innerHTML]=\"statusBadge(product.status)\"></div>\n <div class=\"x-catalog-col-check\">\n @if (product.checking) {\n <span class=\"x-check-pending\">Checking\u2026</span>\n } @else if (product.checked && product.canPublish) {\n <span class=\"x-check-ok\">\u2713 Ready to publish</span>\n } @else if (!product.checked) {\n <span class=\"x-check-pending\">Not checked \u2014 press Check</span>\n } @else if (product.checked && product.errors?.length) {\n <ul class=\"x-check-errors\">\n @for (err of product.errors; track err.field) {\n <li>{{ err.message }}</li>\n }\n </ul>\n }\n </div>\n <div class=\"x-catalog-col-action\">\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"edit(product)\">Edit</button>\n <button\n type=\"button\"\n class=\"x-check-btn\"\n [disabled]=\"product.checking\"\n (click)=\"checkPublish(product)\"\n >\n Check\n </button>\n </div>\n </div>\n }\n @if (!products.length) {\n <div class=\"x-catalog-empty\">No products yet \u2014 use \"+ New product\" to add one.</div>\n }\n </div>\n\n <div class=\"x-cat-pager\">\n <button type=\"button\" class=\"x-cat-btn\" [disabled]=\"page <= 1\" (click)=\"prevPage()\">\u2190 Prev</button>\n <span class=\"x-cat-pager-label\">Page {{ page }} \u00B7 {{ total }} total</span>\n <button type=\"button\" class=\"x-cat-btn\" [disabled]=\"page * perPage >= total\" (click)=\"nextPage()\">\n Next \u2192\n </button>\n </div>\n }\n} @else if (draft) {\n <div class=\"x-cat-editor\">\n <div class=\"x-cat-editor-head\">\n <div class=\"x-cat-editor-title\">{{ draft.id ? 'Edit product' : 'New product' }}</div>\n <div class=\"x-cat-editor-actions\">\n <button type=\"button\" class=\"x-cat-btn\" (click)=\"cancelEdit()\">Close</button>\n <button type=\"button\" class=\"x-cat-btn x-cat-btn-primary\" [disabled]=\"saving\" (click)=\"saveProduct()\">\n {{ saving ? 'Saving\u2026' : 'Save' }}\n </button>\n </div>\n </div>\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Basic info</div>\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Name\n <input type=\"text\" [(ngModel)]=\"draft.name\" />\n </label>\n <label class=\"x-cat-f\">\n Slug (optional)\n <input type=\"text\" [(ngModel)]=\"draft.slug\" placeholder=\"auto from name if blank\" />\n </label>\n </div>\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Model\n <input type=\"text\" [(ngModel)]=\"draft.model\" />\n </label>\n <label class=\"x-cat-f\">\n Type\n <select [(ngModel)]=\"draft.type\">\n @for (t of types; track t) { <option [value]=\"t\">{{ t }}</option> }\n </select>\n </label>\n <label class=\"x-cat-f\">\n Status\n <select [(ngModel)]=\"draft.status\">\n @for (s of statuses; track s) { <option [value]=\"s\">{{ s }}</option> }\n </select>\n </label>\n </div>\n @if (draft.type !== 'simple') {\n <div class=\"x-cat-hint\">\n \"{{ draft.type }}\" products still save through this one-variant form for now \u2014 a full\n per-variant / per-component editor is a follow-up.\n </div>\n }\n <label class=\"x-cat-f\">\n Short description\n <textarea rows=\"2\" [(ngModel)]=\"draft.shortDesc\"></textarea>\n </label>\n </section>\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Category &amp; brand</div>\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Category\n <select [(ngModel)]=\"draft.primaryCategoryId\" (ngModelChange)=\"onCategoryChange()\">\n <option value=\"\">\u2014 none \u2014</option>\n @for (c of categories; track c.id) { <option [value]=\"c.id\">{{ c.name }}</option> }\n </select>\n </label>\n <label class=\"x-cat-f\">\n Brand\n <select [(ngModel)]=\"draft.brandId\">\n <option value=\"\">\u2014 none \u2014</option>\n @for (b of brands; track b.id) { <option [value]=\"b.id\">{{ b.name }}</option> }\n </select>\n </label>\n </div>\n </section>\n\n @if (attributeDefs.length) {\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Attributes</div>\n <div class=\"x-cat-attr-grid\">\n @for (def of attributeDefs; track def.id) {\n <label class=\"x-cat-f x-cat-attr\">\n {{ def.label }}{{ def.unit ? ' (' + def.unit + ')' : '' }}\n @if (def.required) {\n <span class=\"x-cat-required\">*</span>\n }\n @switch (def.dataType) {\n @case ('boolean') {\n <input type=\"checkbox\" [(ngModel)]=\"attributeValues[def.id].valueBool\" />\n }\n @case ('enum') {\n <select [(ngModel)]=\"attributeValues[def.id].valueText\">\n <option value=\"\">\u2014 choose \u2014</option>\n @for (opt of def.allowedValues; track opt) { <option [value]=\"opt\">{{ opt }}</option> }\n </select>\n }\n @case ('range') {\n <div class=\"x-cat-range\">\n <input type=\"number\" placeholder=\"min\" [(ngModel)]=\"attributeValues[def.id].valueNumber\" />\n <span>\u2013</span>\n <input\n type=\"number\"\n placeholder=\"max\"\n [(ngModel)]=\"attributeValues[def.id].valueNumberHigh\"\n />\n </div>\n }\n @case ('number') {\n <input type=\"number\" [(ngModel)]=\"attributeValues[def.id].valueNumber\" />\n }\n @default {\n <input type=\"text\" [(ngModel)]=\"attributeValues[def.id].valueText\" />\n }\n }\n </label>\n }\n </div>\n </section>\n }\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Variant, price &amp; stock</div>\n @if (variant) {\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n SKU\n <input type=\"text\" [(ngModel)]=\"variant.sku\" />\n </label>\n <label class=\"x-cat-f\">\n Weight (kg)\n <input type=\"number\" min=\"0\" step=\"0.1\" [(ngModel)]=\"variant.weight\" />\n @if (variant.weight == null || variant.weight <= 0) {\n <small class=\"x-cat-hint\" style=\"color: var(--color-warn)\">\n No weight \u2014 delivery is priced with the default weight. Add the packed weight for an accurate shipping fee.\n </small>\n }\n </label>\n <label class=\"x-cat-f\">\n Handling class\n <select [(ngModel)]=\"variant.handlingClass\">\n <option value=\"standard\">standard</option>\n <option value=\"bulky\">bulky</option>\n <option value=\"freight\">freight</option>\n <option value=\"hazmat\">hazmat</option>\n </select>\n </label>\n </div>\n }\n <div class=\"x-cat-f-row\">\n <label class=\"x-cat-f\">\n Price (\u20A6)\n <input type=\"number\" [(ngModel)]=\"price!.amount\" [disabled]=\"!variant?.sku\" />\n </label>\n <label class=\"x-cat-f\">\n Stock location\n <select [(ngModel)]=\"stock!.locationId\" [disabled]=\"!variant?.sku\">\n @for (loc of stockLocations; track loc.id) { <option [value]=\"loc.id\">{{ loc.name }}</option> }\n </select>\n </label>\n <label class=\"x-cat-f\">\n Available\n <input type=\"number\" [(ngModel)]=\"stock!.available\" [disabled]=\"!variant?.sku\" />\n </label>\n </div>\n @if (!variant?.sku) {\n <div class=\"x-cat-hint\">Enter a SKU above, then price/stock can be saved.</div>\n }\n </section>\n\n <section class=\"x-cat-section\">\n <div class=\"x-cat-section-title\">Media</div>\n @if (!draft.id) {\n <div class=\"x-cat-hint\">Save the product once first \u2014 media needs a real product to attach to.</div>\n } @else {\n <div class=\"x-cat-media-grid\">\n @for (m of media; track m.id) {\n <div class=\"x-cat-media-item\">\n <img [src]=\"m.objectUrl\" [alt]=\"m.altText\" />\n <button type=\"button\" class=\"x-cat-media-remove\" (click)=\"removeMedia(m)\">Remove</button>\n </div>\n }\n </div>\n <label class=\"x-cat-btn x-cat-upload\">\n {{ uploadingMedia ? 'Uploading\u2026' : '+ Add image' }}\n <input type=\"file\" accept=\"image/*\" hidden [disabled]=\"uploadingMedia\" (change)=\"onMediaSelected($event)\" />\n </label>\n <div class=\"x-cat-hint\">\n Best results: <strong>1200 \u00D7 1200 px</strong> or larger, square (4:3 also works), product centred on a\n plain white/light background, JPG or WebP, under 8 MB. The first image is the listing thumbnail \u2014\n use a clean front-on shot; add the rating plate, ports/back and box contents as extra images.\n The site downsizes photos for phones automatically, so upload the sharp original.\n </div>\n }\n </section>\n </div>\n}\n", styles: [".x-page-head{margin-bottom:20px}.x-page-title{font-size:24px;font-weight:800;color:var(--color-text)}.x-page-subtitle{font-size:13.5px;color:var(--color-text-muted);margin-top:2px}.x-cat-toolbar{display:flex;align-items:center;gap:8px;margin-bottom:14px}.x-cat-search{border:1px solid var(--color-border);border-radius:var(--radius-md);padding:6px 10px;font-size:13px;background:var(--color-surface);color:var(--color-text);min-width:220px}.x-cat-spacer{flex:1}.x-cat-btn{border:1px solid var(--color-border);background:transparent;border-radius:var(--radius-md);padding:6px 14px;font-size:12.5px;font-weight:700;cursor:pointer;color:var(--color-text-muted);display:inline-flex;align-items:center}.x-cat-btn:disabled{opacity:.5;cursor:default}.x-cat-btn-primary{border-color:var(--color-accent);color:var(--color-accent-hover)}.x-catalog-table{display:flex;flex-direction:column;border:1px solid var(--color-border);border-radius:var(--radius-lg);overflow:hidden}.x-catalog-row{display:grid;grid-template-columns:minmax(220px,2.4fr) 130px 1fr 100px 70px 110px 1.4fr 140px;gap:10px;align-items:center;padding:10px 14px;border-bottom:1px solid var(--color-border);font-size:13px}.x-catalog-row:last-child{border-bottom:none}.x-catalog-head{font-weight:700;font-size:11.5px;text-transform:uppercase;letter-spacing:.02em;color:var(--color-text-muted);background:var(--color-surface-alt, rgba(0, 0, 0, .02))}.x-catalog-model{display:block;font-size:11.5px;color:var(--color-text-muted)}.x-catalog-col-action{display:flex;gap:6px;justify-content:flex-end}.x-catalog-empty{padding:24px;text-align:center;color:var(--color-text-muted);font-size:13px}.x-status-badge{display:inline-block;padding:2px 8px;border-radius:999px;font-size:11px;font-weight:700;border:1px solid var(--color-border);text-transform:capitalize}.x-check-pending{color:var(--color-text-muted);font-size:12px}.x-check-ok{color:var(--color-success, #2a7a3b);font-size:12px;font-weight:700}.x-check-errors{margin:0;padding-left:16px;font-size:11.5px;color:var(--color-danger, #c0362c)}.x-check-btn{border:1px solid var(--color-border);background:transparent;border-radius:var(--radius-md);padding:4px 10px;font-size:11.5px;font-weight:700;cursor:pointer;color:var(--color-text-muted)}.x-check-btn:disabled{opacity:.5;cursor:default}.x-cat-pager{display:flex;align-items:center;justify-content:center;gap:14px;margin-top:12px}.x-cat-pager-label{font-size:12px;color:var(--color-text-muted)}.x-cat-editor{display:flex;flex-direction:column;gap:16px}.x-cat-editor-head{display:flex;align-items:center;justify-content:space-between}.x-cat-editor-title{font-size:18px;font-weight:800;color:var(--color-text)}.x-cat-editor-actions{display:flex;gap:8px}.x-cat-section{background:var(--color-surface);border:1px solid var(--color-border);border-radius:var(--radius-lg);padding:16px;display:flex;flex-direction:column;gap:10px}.x-cat-section-title{font-size:13px;font-weight:800;color:var(--color-text);text-transform:uppercase;letter-spacing:.02em}.x-cat-f{display:flex;flex-direction:column;gap:4px;flex:1;font-size:11.5px;color:var(--color-text-muted);font-weight:700}.x-cat-f input,.x-cat-f select,.x-cat-f textarea{border:1px solid var(--color-border);border-radius:var(--radius-md);padding:6px 10px;font-size:13px;background:var(--color-surface);color:var(--color-text);font-weight:400}.x-cat-f-row{display:flex;gap:10px;flex-wrap:wrap}.x-cat-hint{font-size:12px;color:var(--color-text-muted);font-style:italic}.x-cat-required{color:var(--color-danger, #c0362c)}.x-cat-attr-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px}.x-cat-attr input[type=checkbox]{width:18px;height:18px}.x-cat-range{display:flex;align-items:center;gap:6px}.x-cat-range input{width:0;flex:1}.x-cat-media-grid{display:flex;flex-wrap:wrap;gap:12px}.x-cat-media-item{position:relative;width:100px;height:100px;border:1px solid var(--color-border);border-radius:var(--radius-md);overflow:hidden}.x-cat-media-item img{width:100%;height:100%;object-fit:cover;display:block}.x-cat-media-remove{position:absolute;bottom:0;left:0;right:0;border:none;background:#0009;color:#fff;font-size:10px;padding:3px 0;cursor:pointer}.x-cat-upload{align-self:flex-start;cursor:pointer}.x-catalog-col-name{display:flex;align-items:center;gap:10px;min-width:0}.x-catalog-thumb{flex:0 0 40px;width:40px;height:40px;object-fit:contain;border-radius:var(--radius-sm, 4px);border:1px solid var(--color-border);background:var(--color-surface)}.x-catalog-thumb-empty{display:inline-block;background:var(--color-surface-2, rgba(0, 0, 0, .04))}.x-catalog-col-sku{font-family:var(--font-mono);font-size:12px;overflow:hidden;text-overflow:ellipsis}.x-cat-tabs{display:flex;flex-wrap:wrap;gap:6px;margin:0 0 12px}.x-cat-tab{padding:5px 12px;border-radius:999px;border:1px solid var(--color-border);background:var(--color-surface);color:var(--color-text);font-size:12.5px;font-weight:600;cursor:pointer}.x-cat-tab.is-active{background:var(--color-accent);border-color:var(--color-accent);color:var(--color-accent-fg)}.x-catalog-table{overflow-x:auto}.x-catalog-row{min-width:1040px}.x-catalog-col-price,.x-catalog-col-stock{font-family:var(--font-mono);font-size:12px}.x-catalog-warn{color:var(--color-warn, #8a5a12);font-weight:600}\n"] }]
579
+ }] });
580
+
581
+ class CatalogModule {
582
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: CatalogModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
583
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.16", ngImport: i0, type: CatalogModule, declarations: [CatalogComponent], imports: [SharedModule,
584
+ ElementsModule,
585
+ WebgetsModule, i1$1.RouterModule] }); }
586
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: CatalogModule, imports: [SharedModule,
587
+ ElementsModule,
588
+ WebgetsModule,
589
+ RouterModule.forChild([{ path: '', component: CatalogComponent }])] }); }
590
+ }
591
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: CatalogModule, decorators: [{
592
+ type: NgModule,
593
+ args: [{
594
+ declarations: [CatalogComponent],
595
+ imports: [
596
+ SharedModule,
597
+ ElementsModule,
598
+ WebgetsModule,
599
+ RouterModule.forChild([{ path: '', component: CatalogComponent }]),
600
+ ],
601
+ }]
602
+ }] });
603
+
604
+ export { CatalogModule };
605
+ //# sourceMappingURL=isaiahiroko-tilmart-ngx-apps-admin-catalog.module-CnS35rup.mjs.map