@enyxs/wikex-components 0.11.10 → 0.11.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.
package/dist/fees.js ADDED
@@ -0,0 +1,1724 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/fees.ts
32
+ var fees_exports = {};
33
+ __export(fees_exports, {
34
+ FeesManager: () => FeesManager,
35
+ FeesTable: () => FeesTable
36
+ });
37
+ module.exports = __toCommonJS(fees_exports);
38
+
39
+ // src/wikex/fees-manager.tsx
40
+ var import_material = require("@mui/material");
41
+
42
+ // src/wikex/fees-table.tsx
43
+ var import_jsx_runtime5 = require("react/jsx-runtime");
44
+ var import_react2 = require("react");
45
+ var import_styled_components6 = __toESM(require("styled-components"));
46
+ var import_TextField = __toESM(require("@mui/material/TextField"));
47
+ var import_Dialog = __toESM(require("@mui/material/Dialog"));
48
+ var import_DialogTitle = __toESM(require("@mui/material/DialogTitle"));
49
+ var import_DialogContent = __toESM(require("@mui/material/DialogContent"));
50
+ var import_DialogContentText = __toESM(require("@mui/material/DialogContentText"));
51
+ var import_DialogActions = __toESM(require("@mui/material/DialogActions"));
52
+ var import_Button = __toESM(require("@mui/material/Button"));
53
+ var import_Select = __toESM(require("@mui/material/Select"));
54
+ var import_MenuItem = __toESM(require("@mui/material/MenuItem"));
55
+ var import_Checkbox = __toESM(require("@mui/material/Checkbox"));
56
+
57
+ // src/commodity-original/styles/colors.ts
58
+ var lightColors = {
59
+ background: {
60
+ canvas: "#ffffff",
61
+ card: "#ffffff",
62
+ deep: "#ffffff",
63
+ hover: "#f5f5f5",
64
+ input: "#f3f4f6",
65
+ warm: "#fffbf3",
66
+ popup: "#f9fafb"
67
+ },
68
+ text: {
69
+ primary: "#171717",
70
+ secondary: "#707580",
71
+ placeholder: "#9ea3ad",
72
+ content: "#4E5560"
73
+ },
74
+ action: {
75
+ primaryBackground: "#171717",
76
+ primaryForeground: "#ffffff",
77
+ primaryHover: "#383838"
78
+ },
79
+ accent: {
80
+ primary: "#f9bb3a",
81
+ foreground: "#05080f",
82
+ deep: "#c78806"
83
+ },
84
+ border: {
85
+ subtle: "#D2D5DA",
86
+ line: "#E6E7EA"
87
+ },
88
+ informationHero: {
89
+ start: "#e55f2a",
90
+ middle: "#e87a2f",
91
+ foreground: "#ffffff",
92
+ placeholder: "rgb(116 116 116 / 50%)"
93
+ },
94
+ datePicker: {
95
+ selected: "#4f39f6",
96
+ range: "#eef2ff",
97
+ rangeForeground: "#312c85"
98
+ },
99
+ effect: {
100
+ popupShadow: "rgb(5 8 16 / 5%)"
101
+ }
102
+ };
103
+ var cssVariableColors = {
104
+ background: {
105
+ canvas: "var(--color-background-canvas)",
106
+ card: "var(--color-background-card)",
107
+ deep: "var(--color-background-deep)",
108
+ hover: "var(--color-background-hover)",
109
+ input: "var(--color-background-input)",
110
+ warm: "var(--color-background-warm)",
111
+ popup: "var(--color-background-popup)"
112
+ },
113
+ text: {
114
+ primary: "var(--color-text-primary)",
115
+ secondary: "var(--color-text-secondary)",
116
+ placeholder: "var(--color-text-placeholder)",
117
+ content: "var(--color-text-content)"
118
+ },
119
+ action: {
120
+ primaryBackground: "var(--color-action-primary-background)",
121
+ primaryForeground: "var(--color-action-primary-foreground)",
122
+ primaryHover: "var(--color-action-primary-hover)"
123
+ },
124
+ accent: {
125
+ primary: "var(--color-accent-primary)",
126
+ foreground: "var(--color-accent-foreground)",
127
+ deep: "var(--color-accent-deep)"
128
+ },
129
+ border: {
130
+ subtle: "var(--color-border-subtle)",
131
+ line: "var(--color-border-line)"
132
+ },
133
+ informationHero: {
134
+ start: "var(--color-information-hero-start)",
135
+ middle: "var(--color-information-hero-middle)",
136
+ foreground: "var(--color-information-hero-foreground)",
137
+ placeholder: "var(--color-information-hero-placeholder)"
138
+ },
139
+ datePicker: {
140
+ selected: "var(--color-date-picker-selected)",
141
+ range: "var(--color-date-picker-range)",
142
+ rangeForeground: "var(--color-date-picker-range-foreground)"
143
+ },
144
+ effect: {
145
+ popupShadow: "var(--color-effect-popup-shadow)"
146
+ }
147
+ };
148
+
149
+ // src/commodity-original/styles/theme.ts
150
+ var appTheme = {
151
+ colors: cssVariableColors
152
+ };
153
+
154
+ // src/commodity-original/components/Table/index.tsx
155
+ var import_react = require("react");
156
+
157
+ // src/commodity-original/components/Table/style.ts
158
+ var import_styled_components = __toESM(require("styled-components"));
159
+ var TableScrollContainer = import_styled_components.default.div.withConfig({
160
+ componentId: "sc-b3eceaf0-0"
161
+ })([
162
+ `min-width:0;width:100%;max-width:100%;overflow-x:auto;overscroll-behavior-inline:contain;`
163
+ ]);
164
+ var TableRoot = import_styled_components.default.table.withConfig({
165
+ componentId: "sc-b3eceaf0-1"
166
+ })([
167
+ `width:100%;min-width:`,
168
+ `;border-spacing:0;border-collapse:separate;border-radius:12px 12px 0 0;color:`,
169
+ `;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;text-align:left;`
170
+ ], ({ $minWidth }) => $minWidth ?? "100%", ({ theme }) => theme.colors.text.primary);
171
+ var TableHeaderRow = import_styled_components.default.tr.withConfig({
172
+ componentId: "sc-b3eceaf0-2"
173
+ })([
174
+ `background:`,
175
+ `;`
176
+ ], ({ theme }) => theme.colors.background.input);
177
+ var TableHeaderCell = import_styled_components.default.th.withConfig({
178
+ componentId: "sc-b3eceaf0-3"
179
+ })([
180
+ ``,
181
+ ` padding:11.5px 8px 11.5px 16px;border-bottom:1px solid `,
182
+ `;color:`,
183
+ `;font-size:10px;font-weight:600;line-height:14px;vertical-align:middle;&:first-child{padding-left:16px;border-top-left-radius:12px;}&:last-child{border-top-right-radius:12px;}`,
184
+ `[data-size="sm"] &{padding:12px 8px 12px 16px;font-size:var(--Size-Overline-M,8px);font-weight:600;line-height:var(--Line-height-Overline-M,10px);}`
185
+ ], ({ $fixed, $fixedOffset, $width, theme }) => `
186
+ ${$width ? `width: ${$width}; min-width: ${$width};` : ""}
187
+ ${$fixed && $fixedOffset ? `
188
+ position: sticky;
189
+ ${$fixed}: ${$fixedOffset};
190
+ z-index: 3;
191
+ background: ${theme.colors.background.input};
192
+ ` : ""}
193
+ `, ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.primary, TableRoot);
194
+ var TableRow = import_styled_components.default.tr.withConfig({
195
+ componentId: "sc-b3eceaf0-4"
196
+ })([
197
+ `background:`,
198
+ `;`
199
+ ], ({ theme }) => theme.colors.background.deep);
200
+ var TableCell = import_styled_components.default.td.withConfig({
201
+ componentId: "sc-b3eceaf0-5"
202
+ })([
203
+ ``,
204
+ ` padding:7.5px 8px 7.5px 16px;border-bottom:1px solid `,
205
+ `;color:`,
206
+ `;font-size:12px;font-weight:500;line-height:16px;vertical-align:middle;&:first-child{padding-left:16px;}`,
207
+ `[data-size="sm"] &{padding:8px 8px 8px 16px;font-size:var(--Size-Caption-S,10px);font-weight:500;line-height:var(--Line-height-Caption-S,14px);}`
208
+ ], ({ $fixed, $fixedOffset, $width, theme }) => `
209
+ ${$width ? `width: ${$width}; min-width: ${$width};` : ""}
210
+ ${$fixed && $fixedOffset ? `
211
+ position: sticky;
212
+ ${$fixed}: ${$fixedOffset};
213
+ z-index: 2;
214
+ background: ${theme.colors.background.deep};
215
+ ` : ""}
216
+ `, ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.primary, TableRoot);
217
+ var TableSortButton = import_styled_components.default.button.withConfig({
218
+ componentId: "sc-b3eceaf0-6"
219
+ })([
220
+ `display:inline-flex;max-width:100%;margin:0;padding:0;align-items:center;border:0;color:inherit;background:transparent;cursor:pointer;font:inherit;line-height:inherit;text-align:left;&:focus-visible{outline:2px solid `,
221
+ `;outline-offset:3px;}`
222
+ ], ({ theme }) => theme.colors.accent.primary);
223
+ var TableSelectionInput = import_styled_components.default.input.withConfig({
224
+ componentId: "sc-b3eceaf0-7"
225
+ })([
226
+ `width:16px;height:16px;margin:0;accent-color:`,
227
+ `;cursor:pointer;&:disabled{cursor:not-allowed;}`
228
+ ], ({ theme }) => theme.colors.accent.primary);
229
+ var TableExpandButton = import_styled_components.default.button.withConfig({
230
+ componentId: "sc-b3eceaf0-8"
231
+ })([
232
+ `margin:0;padding:0;border:0;color:`,
233
+ `;background:transparent;cursor:pointer;font:inherit;line-height:inherit;&:focus-visible{outline:2px solid `,
234
+ `;outline-offset:3px;}`
235
+ ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
236
+ var TableExpandedCell = (0, import_styled_components.default)(TableCell).withConfig({
237
+ componentId: "sc-b3eceaf0-9"
238
+ })([
239
+ `background:`,
240
+ `;`
241
+ ], ({ theme }) => theme.colors.background.hover);
242
+
243
+ // src/commodity-original/components/Table/utils.ts
244
+ function getTableRowKey(record, rowKey) {
245
+ if (typeof rowKey === "function") {
246
+ return rowKey(record);
247
+ }
248
+ return String(record[rowKey]);
249
+ }
250
+ function getTableColumnSize(value) {
251
+ return typeof value === "number" ? `${value}px` : value;
252
+ }
253
+ function getTableFixedColumnOffset(columns, columnIndex) {
254
+ const column = columns[columnIndex];
255
+ if (!column?.fixed) {
256
+ return void 0;
257
+ }
258
+ const precedingColumns = column.fixed === "left" ? columns.slice(0, columnIndex) : columns.slice(columnIndex + 1);
259
+ const fixedColumnSizes = precedingColumns.filter((item) => item.fixed === column.fixed).map(
260
+ (item) => item.width === void 0 ? void 0 : getTableColumnSize(item.width)
261
+ );
262
+ if (fixedColumnSizes.some((size) => size === void 0)) {
263
+ return void 0;
264
+ }
265
+ const sizes = fixedColumnSizes.filter(
266
+ (size) => size !== void 0
267
+ );
268
+ return sizes.length === 0 ? "0px" : `calc(${sizes.join(" + ")})`;
269
+ }
270
+
271
+ // src/commodity-original/components/Table/index.tsx
272
+ var import_jsx_runtime = require("react/jsx-runtime");
273
+ function getCellValue(column, record) {
274
+ return column.dataIndex === void 0 ? void 0 : record[column.dataIndex];
275
+ }
276
+ function getNextSort(sort, field) {
277
+ if (sort?.field === field && sort.order === "asc") {
278
+ return { field, order: "desc" };
279
+ }
280
+ return { field, order: "asc" };
281
+ }
282
+ function getSelectedRows(dataSource, selectedRowKeys, getRowKey) {
283
+ const selectedKeySet = new Set(selectedRowKeys);
284
+ return dataSource.filter((record) => selectedKeySet.has(getRowKey(record)));
285
+ }
286
+ function getSelectionType(rowSelection) {
287
+ return rowSelection.type ?? "checkbox";
288
+ }
289
+ function Table({
290
+ ariaLabel,
291
+ className,
292
+ columns,
293
+ dataSource,
294
+ empty = null,
295
+ expandable,
296
+ loading = false,
297
+ loadingContent = null,
298
+ onSortChange,
299
+ rowKey,
300
+ rowSelection,
301
+ scroll,
302
+ size = "md",
303
+ sort
304
+ }) {
305
+ const getRowKey = (record) => getTableRowKey(record, rowKey);
306
+ const selectedRowKeys = rowSelection?.selectedRowKeys ?? [];
307
+ const selectedRowKeySet = new Set(selectedRowKeys);
308
+ const expandedRowKeySet = new Set(expandable?.expandedRowKeys ?? []);
309
+ const selectionType = rowSelection ? getSelectionType(rowSelection) : void 0;
310
+ const selectableRecords = rowSelection ? dataSource.filter(
311
+ (record) => !rowSelection.getCheckboxProps?.(record).disabled
312
+ ) : [];
313
+ const selectableRowKeys = selectableRecords.map(getRowKey);
314
+ const isAllSelected = selectionType === "checkbox" && selectableRowKeys.length > 0 && selectableRowKeys.every((key) => selectedRowKeySet.has(key));
315
+ const columnCount = columns.length + (rowSelection ? 1 : 0) + (expandable ? 1 : 0);
316
+ const emitSelectionChange = (nextSelectedRowKeys) => {
317
+ rowSelection?.onChange?.(
318
+ nextSelectedRowKeys,
319
+ getSelectedRows(dataSource, nextSelectedRowKeys, getRowKey)
320
+ );
321
+ };
322
+ const handleSelectAll = (event) => {
323
+ if (!rowSelection || selectionType !== "checkbox") {
324
+ return;
325
+ }
326
+ const selectableKeySet = new Set(selectableRowKeys);
327
+ const preservedRowKeys = selectedRowKeys.filter(
328
+ (key) => !selectableKeySet.has(key)
329
+ );
330
+ const nextSelectedRowKeys = event.target.checked ? [...preservedRowKeys, ...selectableRowKeys] : preservedRowKeys;
331
+ emitSelectionChange(nextSelectedRowKeys);
332
+ };
333
+ const handleRowSelectionChange = (event, record) => {
334
+ if (!rowSelection) {
335
+ return;
336
+ }
337
+ const recordKey = getRowKey(record);
338
+ if (selectionType === "radio") {
339
+ emitSelectionChange(event.target.checked ? [recordKey] : []);
340
+ return;
341
+ }
342
+ const nextSelectedRowKeys = event.target.checked ? [...selectedRowKeys, recordKey] : selectedRowKeys.filter((key) => key !== recordKey);
343
+ emitSelectionChange(nextSelectedRowKeys);
344
+ };
345
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableScrollContainer, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
346
+ TableRoot,
347
+ {
348
+ $minWidth: scroll?.x === void 0 ? void 0 : getTableColumnSize(scroll.x),
349
+ "aria-busy": loading || void 0,
350
+ "aria-label": ariaLabel,
351
+ className,
352
+ "data-size": size,
353
+ children: [
354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("thead", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableHeaderRow, { children: [
355
+ rowSelection ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableHeaderCell, { scope: "col", children: selectionType === "checkbox" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
356
+ TableSelectionInput,
357
+ {
358
+ checked: isAllSelected,
359
+ disabled: selectableRowKeys.length === 0,
360
+ onChange: handleSelectAll,
361
+ type: "checkbox"
362
+ }
363
+ ) : null }) : null,
364
+ expandable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableHeaderCell, { scope: "col" }) : null,
365
+ columns.map((column, columnIndex) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
366
+ TableHeaderCell,
367
+ {
368
+ $fixed: column.fixed,
369
+ $fixedOffset: getTableFixedColumnOffset(columns, columnIndex),
370
+ $width: column.width === void 0 ? void 0 : getTableColumnSize(column.width),
371
+ "data-column-key": column.key,
372
+ scope: "col",
373
+ children: column.sortable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
374
+ TableSortButton,
375
+ {
376
+ "aria-pressed": sort?.field === column.key,
377
+ onClick: () => onSortChange?.(getNextSort(sort, column.key)),
378
+ type: "button",
379
+ children: column.title
380
+ }
381
+ ) : column.title
382
+ },
383
+ column.key
384
+ ))
385
+ ] }) }),
386
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("tbody", { children: loading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { colSpan: columnCount, children: loadingContent }) }) : dataSource.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { colSpan: columnCount, children: empty }) }) : dataSource.map((record, index) => {
387
+ const recordKey = getRowKey(record);
388
+ const selectionProps = rowSelection?.getCheckboxProps?.(record);
389
+ const isExpanded = expandedRowKeySet.has(recordKey);
390
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_react.Fragment, { children: [
391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(TableRow, { "data-row-key": recordKey, children: [
392
+ rowSelection ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
393
+ TableSelectionInput,
394
+ {
395
+ checked: selectedRowKeySet.has(recordKey),
396
+ disabled: selectionProps?.disabled,
397
+ name: selectionType === "radio" ? "table-row-selection" : void 0,
398
+ onChange: (event) => handleRowSelectionChange(event, record),
399
+ type: selectionType
400
+ }
401
+ ) }) : null,
402
+ expandable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableCell, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
403
+ TableExpandButton,
404
+ {
405
+ "aria-expanded": isExpanded,
406
+ onClick: () => expandable.onExpand?.(!isExpanded, record),
407
+ type: "button",
408
+ children: isExpanded ? "Collapse" : "Expand"
409
+ }
410
+ ) }) : null,
411
+ columns.map((column, columnIndex) => {
412
+ const value = getCellValue(column, record);
413
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
414
+ TableCell,
415
+ {
416
+ $fixed: column.fixed,
417
+ $fixedOffset: getTableFixedColumnOffset(columns, columnIndex),
418
+ $width: column.width === void 0 ? void 0 : getTableColumnSize(column.width),
419
+ children: column.render ? column.render(value, record, index) : value === void 0 || value === null ? null : String(value)
420
+ },
421
+ column.key
422
+ );
423
+ })
424
+ ] }),
425
+ expandable?.render && isExpanded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableRow, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TableExpandedCell, { colSpan: columnCount, children: expandable.render(record) }) }) : null
426
+ ] }, recordKey);
427
+ }) })
428
+ ]
429
+ }
430
+ ) });
431
+ }
432
+
433
+ // src/commodity-original/components/Pagination/index.tsx
434
+ var import_react_i18next = require("react-i18next");
435
+
436
+ // src/wikex/assets/products/chevron-right.svg
437
+ var chevron_right_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNCIgaGVpZ2h0PSIxNCIgdmlld0JveD0iMCAwIDE0IDE0IiBmaWxsPSJub25lIj4KICA8cGF0aCBkPSJNNS4yNSAzLjVMOC43NSA3TDUuMjUgMTAuNSIgc3Ryb2tlPSJjdXJyZW50Q29sb3IiIHN0cm9rZS13aWR0aD0iMS4xNjY2NyIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+Cjwvc3ZnPgo=";
438
+
439
+ // src/commodity-original/components/Pagination/style.ts
440
+ var import_styled_components2 = require("styled-components");
441
+ var PaginationNav = import_styled_components2.styled.nav.withConfig({
442
+ componentId: "sc-522a1750-0"
443
+ })([
444
+ `display:flex;justify-content:center;`
445
+ ]);
446
+ var PaginationList = import_styled_components2.styled.ul.withConfig({
447
+ componentId: "sc-522a1750-1"
448
+ })([
449
+ `display:flex;margin:0;padding:0;align-items:center;gap:8px;list-style:none;`
450
+ ]);
451
+ var PaginationItem = import_styled_components2.styled.li.withConfig({
452
+ componentId: "sc-522a1750-2"
453
+ })([
454
+ `display:flex;`
455
+ ]);
456
+ var PaginationButton = import_styled_components2.styled.button.withConfig({
457
+ componentId: "sc-522a1750-3"
458
+ })([
459
+ `display:inline-flex;width:28px;height:28px;align-items:center;justify-content:center;border:1px solid `,
460
+ `;border-radius:4px;padding:4px;color:`,
461
+ `;background:`,
462
+ `;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;font-size:14px;font-weight:500;line-height:18px;cursor:pointer;transition:color 160ms ease,background-color 160ms ease,border-color 160ms ease;&[data-control]{border-color:transparent;background:transparent;}&[data-active]{border-color:`,
463
+ `;color:`,
464
+ `;background:`,
465
+ `;}&:not(:disabled):hover{color:`,
466
+ `;background:`,
467
+ `;}&[data-active]:not(:disabled):hover{background:`,
468
+ `;}&:disabled{cursor:not-allowed;}&:focus-visible{outline:2px solid `,
469
+ `;outline-offset:2px;}`
470
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.text.secondary, ({ theme }) => theme.colors.background.canvas, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.foreground, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.background.hover, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.accent.primary);
471
+ var PaginationArrow = import_styled_components2.styled.span.withConfig({
472
+ componentId: "sc-522a1750-4"
473
+ })([
474
+ `width:16px;height:16px;background:currentColor;mask:url("`,
475
+ `") center / contain no-repeat;-webkit-mask:url("`,
476
+ `") center / contain no-repeat;&[data-direction="previous"]{transform:scaleX(-1);}`
477
+ ], chevron_right_default, chevron_right_default);
478
+
479
+ // src/commodity-original/components/Pagination/index.tsx
480
+ var import_jsx_runtime2 = require("react/jsx-runtime");
481
+ function getPaginationItems(page, pageCount, siblingCount) {
482
+ const maxVisibleItems = siblingCount * 2 + 5;
483
+ if (pageCount <= maxVisibleItems) {
484
+ return Array.from({ length: pageCount }, (_, index) => index + 1);
485
+ }
486
+ const leftSibling = Math.max(page - siblingCount, 2);
487
+ const rightSibling = Math.min(page + siblingCount, pageCount - 1);
488
+ const items = [1];
489
+ if (leftSibling > 2) {
490
+ items.push("ellipsis");
491
+ }
492
+ for (let value = leftSibling; value <= rightSibling; value += 1) {
493
+ items.push(value);
494
+ }
495
+ if (rightSibling < pageCount - 1) {
496
+ items.push("ellipsis");
497
+ }
498
+ items.push(pageCount);
499
+ return items;
500
+ }
501
+ function Pagination({
502
+ page,
503
+ pageCount,
504
+ onPageChange,
505
+ siblingCount = 1,
506
+ ariaLabel,
507
+ labels,
508
+ className
509
+ }) {
510
+ const { t } = (0, import_react_i18next.useTranslation)();
511
+ const safePageCount = Math.max(1, Math.floor(pageCount));
512
+ const currentPage = Math.min(Math.max(1, Math.floor(page)), safePageCount);
513
+ const items = getPaginationItems(currentPage, safePageCount, siblingCount);
514
+ const hasPreviousPage = currentPage > 1;
515
+ const hasNextPage = currentPage < safePageCount;
516
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
517
+ PaginationNav,
518
+ {
519
+ "aria-label": ariaLabel ?? t("pagination.navigation"),
520
+ className,
521
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(PaginationList, { children: [
522
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationItem, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
523
+ PaginationButton,
524
+ {
525
+ "aria-label": labels?.previous ?? t("pagination.previous"),
526
+ "data-control": "previous",
527
+ disabled: !hasPreviousPage,
528
+ onClick: () => onPageChange(currentPage - 1),
529
+ type: "button",
530
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationArrow, { "data-direction": "previous" })
531
+ }
532
+ ) }),
533
+ items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationItem, { children: item === "ellipsis" ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationButton, { "aria-hidden": "true", disabled: true, tabIndex: -1, type: "button", children: "\u2026" }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
534
+ PaginationButton,
535
+ {
536
+ "aria-current": item === currentPage ? "page" : void 0,
537
+ "aria-label": item === currentPage ? labels?.current(item) ?? t("pagination.current", { page: item }) : labels?.page(item) ?? t("pagination.page", { page: item }),
538
+ "data-active": item === currentPage || void 0,
539
+ onClick: () => onPageChange(item),
540
+ type: "button",
541
+ children: item
542
+ }
543
+ ) }, `${item}-${index}`)),
544
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationItem, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
545
+ PaginationButton,
546
+ {
547
+ "aria-label": labels?.next ?? t("pagination.next"),
548
+ "data-control": "next",
549
+ disabled: !hasNextPage,
550
+ onClick: () => onPageChange(currentPage + 1),
551
+ type: "button",
552
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(PaginationArrow, { "data-direction": "next" })
553
+ }
554
+ ) })
555
+ ] })
556
+ }
557
+ );
558
+ }
559
+
560
+ // src/commodity-original/components/InputCommon/style.ts
561
+ var import_styled_components3 = __toESM(require("styled-components"));
562
+ var InputCommonRoot = import_styled_components3.default.div.withConfig({
563
+ componentId: "sc-5ccafcdd-0"
564
+ })([
565
+ `display:flex;width:100%;min-width:0;gap:6px;padding:10px 12px;align-items:center;border:1px solid transparent;border-radius:6px;background:`,
566
+ `;transition:border-color 160ms ease,background-color 160ms ease;&[data-size="sm"]{gap:4px;padding:8px 12px;}&[data-size="lg"]{gap:8px;padding:14px 16px;}&:focus-within{border-color:`,
567
+ `;background:`,
568
+ `;}&[data-disabled]{cursor:not-allowed;opacity:0.6;}&[data-error]{border-color:#dc2626;}> button{border:0;background:transparent;cursor:pointer;font-size:18px;}> [role="alert"]{position:absolute;margin-top:52px;color:#dc2626;font-size:12px;}`
569
+ ], ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.accent.primary, ({ theme }) => theme.colors.background.canvas);
570
+ var InputCommonField = import_styled_components3.default.input.withConfig({
571
+ componentId: "sc-5ccafcdd-1"
572
+ })([
573
+ `width:100%;min-width:0;border:0;outline:0;color:`,
574
+ `;background:transparent;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;font-size:14px;font-weight:500;line-height:18px;`,
575
+ `[data-size="sm"] &{font-size:12px;line-height:16px;}`,
576
+ `[data-size="lg"] &{font-size:16px;line-height:22px;}&::placeholder{color:#9ea3ad;opacity:1;}&:disabled{cursor:not-allowed;}`
577
+ ], ({ theme }) => theme.colors.text.primary, InputCommonRoot, InputCommonRoot);
578
+ var InputAdornment = import_styled_components3.default.span.withConfig({
579
+ componentId: "sc-5ccafcdd-2"
580
+ })([
581
+ `display:inline-flex;width:16px;height:16px;flex:0 0 16px;align-items:center;justify-content:center;color:`,
582
+ `;> svg,> img{width:100%;height:100%;}`,
583
+ `[data-size="sm"] &{width:14px;height:14px;flex-basis:14px;}`,
584
+ `[data-size="lg"] &{width:20px;height:20px;flex-basis:20px;}`
585
+ ], ({ theme }) => theme.colors.text.secondary, InputCommonRoot, InputCommonRoot);
586
+
587
+ // src/commodity-original/components/InputCommon/index.tsx
588
+ var import_jsx_runtime3 = require("react/jsx-runtime");
589
+ function InputCommon({
590
+ leftIcon,
591
+ rightIcon,
592
+ size = "md",
593
+ error = false,
594
+ errorMessage,
595
+ clearable = false,
596
+ onClear,
597
+ ...inputProps
598
+ }) {
599
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(InputCommonRoot, { "data-disabled": inputProps.disabled || void 0, "data-error": error || void 0, "data-size": size, children: [
600
+ leftIcon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InputAdornment, { "aria-hidden": "true", children: leftIcon }) : null,
601
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InputCommonField, { ...inputProps }),
602
+ clearable && inputProps.value ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("button", { "aria-label": "X\xF3a n\u1ED9i dung", onClick: onClear, type: "button", children: "\xD7" }) : rightIcon ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(InputAdornment, { "aria-hidden": "true", children: rightIcon }) : null,
603
+ errorMessage ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { role: "alert", children: errorMessage }) : null
604
+ ] });
605
+ }
606
+
607
+ // src/commodity-original/components/TabCommon/style.ts
608
+ var import_styled_components4 = __toESM(require("styled-components"));
609
+ var TabCommonList = import_styled_components4.default.div.withConfig({
610
+ componentId: "sc-370a48e5-0"
611
+ })([
612
+ `display:flex;gap:16px;align-items:center;overflow-x:auto;&[data-size="sm"]{gap:12px;}&[data-size="lg"]{gap:20px;}`
613
+ ]);
614
+ var TabButton = import_styled_components4.default.button.withConfig({
615
+ componentId: "sc-370a48e5-1"
616
+ })([
617
+ `position:relative;display:inline-flex;padding:8px 0;align-items:center;border:0;color:`,
618
+ `;background:transparent;font-family:var(--font-manrope),Arial,Helvetica,sans-serif;font-size:16px;font-weight:700;line-height:22px;white-space:nowrap;cursor:pointer;transition:color 160ms ease;`,
619
+ `[data-size="sm"] &{padding-block:4px;font-size:14px;line-height:18px;}`,
620
+ `[data-size="lg"] &{padding-block:12px;font-size:18px;line-height:26px;}&[data-active]{color:`,
621
+ `;}&:not(:disabled):hover{color:`,
622
+ `;}&:not(:disabled):hover > span,&[data-active] > span{transform:translateX(-50%) scaleX(1);}&:disabled{cursor:not-allowed;opacity:0.5;}&:focus-visible{outline:2px solid `,
623
+ `;outline-offset:2px;}`
624
+ ], ({ theme }) => theme.colors.text.secondary, TabCommonList, TabCommonList, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
625
+ var TabLine = import_styled_components4.default.span.withConfig({
626
+ componentId: "sc-370a48e5-2"
627
+ })([
628
+ `position:absolute;bottom:0;left:50%;width:107px;max-width:100%;height:2px;color:`,
629
+ `;background:currentColor;mask:url("/icons/tab-active-line.svg") center / 100% 2px no-repeat;-webkit-mask:url("/icons/tab-active-line.svg") center / 100% 2px no-repeat;transform:translateX(-50%) scaleX(0);transform-origin:center;transition:transform 200ms ease-out;`,
630
+ `[data-size="sm"] &{width:89px;}`,
631
+ `[data-size="lg"] &{width:125px;}`
632
+ ], ({ theme }) => theme.colors.accent.primary, TabCommonList, TabCommonList);
633
+
634
+ // src/commodity-original/components/TabCommon/index.tsx
635
+ var import_jsx_runtime4 = require("react/jsx-runtime");
636
+ function TabCommon({
637
+ items,
638
+ value,
639
+ onValueChange,
640
+ ariaLabel,
641
+ className,
642
+ size = "md"
643
+ }) {
644
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
645
+ TabCommonList,
646
+ {
647
+ "aria-label": ariaLabel,
648
+ className,
649
+ "data-size": size,
650
+ role: "tablist",
651
+ children: items.map((item) => {
652
+ const isActive = item.id === value;
653
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
654
+ TabButton,
655
+ {
656
+ "aria-selected": isActive,
657
+ "data-active": isActive || void 0,
658
+ disabled: item.disabled,
659
+ onClick: () => onValueChange(item.id),
660
+ role: "tab",
661
+ type: "button",
662
+ children: [
663
+ item.label,
664
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(TabLine, { "aria-hidden": "true" })
665
+ ]
666
+ },
667
+ item.id
668
+ );
669
+ })
670
+ }
671
+ );
672
+ }
673
+
674
+ // src/commodity-original/app/bang-phi-ky-quy/style.ts
675
+ var import_styled_components5 = __toESM(require("styled-components"));
676
+ var FeesAndMarginMain = import_styled_components5.default.main.withConfig({
677
+ componentId: "sc-a2e40b03-0"
678
+ })([
679
+ `min-height:calc(100vh - var(--header-height));background:`,
680
+ `;`
681
+ ], ({ theme }) => theme.colors.background.warm);
682
+ var FeesAndMarginPageContent = import_styled_components5.default.div.withConfig({
683
+ componentId: "sc-a2e40b03-1"
684
+ })([
685
+ `width:min(1920px,100%);margin:0 auto;padding:58px 16px 80px;@media (max-width:767px){padding:32px 16px 48px;}`
686
+ ]);
687
+ var FeesAndMarginHeader = import_styled_components5.default.header.withConfig({
688
+ componentId: "sc-a2e40b03-2"
689
+ })([
690
+ `h1{margin:0;color:`,
691
+ `;font-family:var(--Font-Landingpage,Inter);font-size:40px;font-weight:700;line-height:50px;}p{margin:16px 0 0;color:`,
692
+ `;font-family:var(--Font-Landingpage,Inter);font-size:var(--Size-Body-M,16px);font-style:normal;font-weight:600;line-height:var(--Line-height-Body-M,22px);}@media (max-width:767px){h1{font-size:24px;line-height:36px;}p{font-size:14px;line-height:18px;}}`
693
+ ], ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.text.primary);
694
+ var FeesAndMarginToolbar = import_styled_components5.default.section.withConfig({
695
+ componentId: "sc-a2e40b03-3"
696
+ })([
697
+ `margin-top:32px;`
698
+ ]);
699
+ var FeesAndMarginToolbarInner = import_styled_components5.default.div.withConfig({
700
+ componentId: "sc-a2e40b03-4"
701
+ })([
702
+ `display:flex;gap:16px;align-items:center;justify-content:space-between;@media (max-width:767px){align-items:stretch;flex-direction:column;}`
703
+ ]);
704
+ var FeesAndMarginSearch = import_styled_components5.default.div.withConfig({
705
+ componentId: "sc-a2e40b03-5"
706
+ })([
707
+ `width:220px;@media (max-width:767px){order:-1;width:100%;}`
708
+ ]);
709
+ var FeesSearchIcon = import_styled_components5.default.span.withConfig({
710
+ componentId: "sc-a2e40b03-6"
711
+ })([
712
+ `display:block;width:14px;height:14px;background:currentColor;mask:url("/icons/search.svg") center / contain no-repeat;-webkit-mask:url("/icons/search.svg") center / contain no-repeat;`
713
+ ]);
714
+ var FeesAndMarginTable = import_styled_components5.default.section.withConfig({
715
+ componentId: "sc-a2e40b03-7"
716
+ })([
717
+ `margin-top:24px;td{white-space:pre-line;}`
718
+ ]);
719
+ var FeesAndMarginPagination = import_styled_components5.default.div.withConfig({
720
+ componentId: "sc-a2e40b03-8"
721
+ })([
722
+ `display:flex;margin-top:32px;justify-content:center;`
723
+ ]);
724
+ var FeesMonthNavigation = import_styled_components5.default.nav.withConfig({
725
+ componentId: "sc-a2e40b03-9"
726
+ })([
727
+ `margin-top:32px;@media (max-width:767px){display:none;}`
728
+ ]);
729
+ var FeesMonthTitle = import_styled_components5.default.p.withConfig({
730
+ componentId: "sc-a2e40b03-10"
731
+ })([
732
+ `margin:0;color:`,
733
+ `;font-family:var(--Font-Main,Manrope);font-size:var(--Size-Title-S,14px);font-style:normal;font-weight:700;line-height:var(--Line-height-Title-S,18px);text-align:center;`
734
+ ], ({ theme }) => theme.colors.text.primary);
735
+ var FeesMonthList = import_styled_components5.default.ul.withConfig({
736
+ componentId: "sc-a2e40b03-11"
737
+ })([
738
+ `display:flex;margin:8px 0 0;padding:0;justify-content:center;gap:16px;list-style:none;@media (max-width:767px){justify-content:flex-start;overflow-x:auto;padding-bottom:4px;}`
739
+ ]);
740
+ var FeesMonthButton = import_styled_components5.default.button.withConfig({
741
+ componentId: "sc-a2e40b03-12"
742
+ })([
743
+ `display:inline-flex;gap:4px;padding:0;border:0;background:transparent;cursor:pointer;white-space:nowrap;&:focus-visible{outline:2px solid `,
744
+ `;outline-offset:2px;}`
745
+ ], ({ theme }) => theme.colors.accent.primary);
746
+ var FeesMonthName = import_styled_components5.default.span.withConfig({
747
+ componentId: "sc-a2e40b03-13"
748
+ })([
749
+ `color:`,
750
+ `;font-family:var(--Font-Main,Manrope);font-size:var(--Size-Title-S,14px);font-style:normal;font-weight:700;line-height:var(--Line-height-Title-S,18px);`
751
+ ], ({ theme }) => theme.colors.text.secondary);
752
+ var FeesMonthCode = import_styled_components5.default.span.withConfig({
753
+ componentId: "sc-a2e40b03-14"
754
+ })([
755
+ `color:`,
756
+ `;font-family:var(--Font-Main,Manrope);font-size:var(--Size-Title-S,14px);font-style:normal;font-weight:500;line-height:var(--Line-height-Body-S,18px);`
757
+ ], ({ theme }) => theme.colors.text.primary);
758
+
759
+ // src/wikex/fees-table-model.ts
760
+ var FEES_PAGE_SIZE = 25;
761
+ function normalizeFeesSearch(value) {
762
+ return value.normalize("NFD").replace(/[\u0300-\u036f]/g, "").replace(/đ/g, "d").replace(/Đ/g, "D").toLowerCase().trim();
763
+ }
764
+ function filterFeesRows(data, search, tag) {
765
+ const query = normalizeFeesSearch(search);
766
+ return data.rows.filter((row) => (!tag || row.tags.includes(tag)) && (!query || Object.values(row.cells).some((cell) => normalizeFeesSearch(cell).includes(query))));
767
+ }
768
+ function paginateFeesRows(rows, requestedPage, pageSize = FEES_PAGE_SIZE) {
769
+ const size = pageSize === -1 ? Math.max(1, rows.length) : Number.isInteger(pageSize) && pageSize > 0 ? pageSize : FEES_PAGE_SIZE;
770
+ const pageCount = Math.max(1, Math.ceil(rows.length / size));
771
+ const page = Math.min(pageCount, Math.max(1, Number.isFinite(requestedPage) ? Math.floor(requestedPage) : 1));
772
+ return { page, pageCount, rows: rows.slice((page - 1) * size, page * size) };
773
+ }
774
+ function moveFeesItem(items, from, to) {
775
+ if (!Number.isInteger(from) || !Number.isInteger(to) || from < 0 || from >= items.length || to < 0 || to >= items.length || from === to) return items;
776
+ const next = [...items];
777
+ const [item] = next.splice(from, 1);
778
+ next.splice(to, 0, item);
779
+ return next;
780
+ }
781
+
782
+ // src/wikex/fees-table.tsx
783
+ var fallbackColors = lightColors;
784
+ var feesTheme = {
785
+ colors: Object.fromEntries(Object.entries(appTheme.colors).map(([group, tokens]) => [
786
+ group,
787
+ Object.fromEntries(Object.entries(tokens).map(([name, variable]) => [
788
+ name,
789
+ variable.replace(/\)$/, `, ${fallbackColors[group][name]})`)
790
+ ]))
791
+ ]))
792
+ };
793
+ var EditorActions = import_styled_components6.default.div.withConfig({
794
+ componentId: "sc-a6ff7adc-0"
795
+ })([
796
+ `display:flex;flex-wrap:wrap;gap:8px;margin-top:16px;`
797
+ ]);
798
+ var EditGroup = import_styled_components6.default.div.withConfig({
799
+ componentId: "sc-a6ff7adc-1"
800
+ })([
801
+ `display:flex;flex-direction:column;gap:6px;`
802
+ ]);
803
+ var HeaderGroup = (0, import_styled_components6.default)(EditGroup).withConfig({
804
+ componentId: "sc-a6ff7adc-2"
805
+ })([
806
+ `gap:8px;`
807
+ ]);
808
+ var HeaderTitle = import_styled_components6.default.div.withConfig({
809
+ componentId: "sc-a6ff7adc-3"
810
+ })([
811
+ `display:flex;align-items:flex-start;min-height:var(--fees-header-title-height,36px);`
812
+ ]);
813
+ var HeaderActions = import_styled_components6.default.div.withConfig({
814
+ componentId: "sc-a6ff7adc-4"
815
+ })([
816
+ `display:flex;align-items:center;min-height:24px;`
817
+ ]);
818
+ var AlignedFeesTable = (0, import_styled_components6.default)(FeesAndMarginTable).withConfig({
819
+ componentId: "sc-a6ff7adc-5"
820
+ })([
821
+ `&[data-editable] th{vertical-align:top;}`
822
+ ]);
823
+ var EditorButton = import_styled_components6.default.button.withConfig({
824
+ componentId: "sc-a6ff7adc-6"
825
+ })([
826
+ `padding:7px 12px;border:1px solid `,
827
+ `;border-radius:6px;background:`,
828
+ `;color:`,
829
+ `;font:inherit;font-size:13px;cursor:pointer;&:hover,&:focus-visible{border-color:`,
830
+ `;}&:disabled{cursor:default;opacity:.4;}`
831
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
832
+ var OrderActions = import_styled_components6.default.div.withConfig({
833
+ componentId: "sc-a6ff7adc-7"
834
+ })([
835
+ `display:flex;gap:6px;align-items:center;flex-wrap:wrap;`
836
+ ]);
837
+ var PositionLabel = import_styled_components6.default.label.withConfig({
838
+ componentId: "sc-a6ff7adc-8"
839
+ })([
840
+ `display:inline-flex;align-items:center;gap:6px;font-size:12px;`
841
+ ]);
842
+ var PositionInput = import_styled_components6.default.input.withConfig({
843
+ componentId: "sc-a6ff7adc-9"
844
+ })([
845
+ `width:56px;padding:5px;border:1px solid `,
846
+ `;border-radius:4px;background:`,
847
+ `;color:`,
848
+ `;font:inherit;&:focus{outline:1px solid `,
849
+ `;}`
850
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.background.input, ({ theme }) => theme.colors.text.primary, ({ theme }) => theme.colors.accent.primary);
851
+ var ColumnRow = import_styled_components6.default.div.withConfig({
852
+ componentId: "sc-a6ff7adc-10"
853
+ })([
854
+ `display:flex;gap:12px;align-items:center;margin:16px 0;> textarea{flex:1;min-width:120px;}@media (max-width:600px){align-items:stretch;flex-direction:column;}`
855
+ ]);
856
+ var PaginationControls = (0, import_styled_components6.default)(FeesAndMarginPagination).withConfig({
857
+ componentId: "sc-a6ff7adc-11"
858
+ })([
859
+ `align-items:center;flex-wrap:wrap;gap:16px 24px;`
860
+ ]);
861
+ var PageSizeLabel = import_styled_components6.default.div.withConfig({
862
+ componentId: "sc-a6ff7adc-12"
863
+ })([
864
+ `display:inline-flex;align-items:center;gap:8px;color:`,
865
+ `;font:inherit;font-size:13px;`
866
+ ], ({ theme }) => theme.colors.text.primary);
867
+ function Position({ value, max, label, onMove }) {
868
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(PositionLabel, {
869
+ children: [
870
+ "V\u1ECB tr\xED",
871
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PositionInput, {
872
+ "aria-label": label,
873
+ type: "number",
874
+ min: 1,
875
+ max,
876
+ defaultValue: value + 1,
877
+ onKeyDown: (event) => {
878
+ if (event.key === "Enter") event.currentTarget.blur();
879
+ },
880
+ onBlur: (event) => {
881
+ const next = Number(event.currentTarget.value);
882
+ if (Number.isInteger(next) && next >= 1 && next <= max) onMove(next - 1);
883
+ else event.currentTarget.value = String(value + 1);
884
+ }
885
+ }, value)
886
+ ]
887
+ });
888
+ }
889
+ var DeleteButton = (0, import_styled_components6.default)(EditorButton).withConfig({
890
+ componentId: "sc-a6ff7adc-13"
891
+ })([
892
+ `align-self:flex-start;padding:4px 8px;border:0;border-radius:4px;background:#d32f2f;color:#fff;font-size:11px;font-weight:600;line-height:16px;white-space:nowrap;text-decoration:none;&:hover{background:#b71c1c;}&:focus-visible{outline:2px solid #d32f2f;outline-offset:2px;}`
893
+ ]);
894
+ var CellEditorInput = import_styled_components6.default.textarea.withConfig({
895
+ componentId: "sc-a6ff7adc-14"
896
+ })([
897
+ `display:block;box-sizing:border-box;width:100%;min-width:0;padding:3px;border:1px solid transparent;border-radius:3px;color:inherit;background:transparent;font:inherit;line-height:inherit;resize:none;overflow:hidden;&:hover{border-color:`,
898
+ `;}&:focus{outline:1px solid `,
899
+ `;}`
900
+ ], ({ theme }) => theme.colors.border.line, ({ theme }) => theme.colors.accent.primary);
901
+ function CellEditor({ onInput, ...props }) {
902
+ const ref = (0, import_react2.useRef)(null);
903
+ const fit = () => {
904
+ const element = ref.current;
905
+ if (!element) return;
906
+ element.style.height = "0px";
907
+ const style = element.ownerDocument.defaultView.getComputedStyle(element);
908
+ const border = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
909
+ element.style.height = `${element.scrollHeight + border}px`;
910
+ };
911
+ (0, import_react2.useLayoutEffect)(fit, [
912
+ props.value,
913
+ props.defaultValue
914
+ ]);
915
+ (0, import_react2.useLayoutEffect)(() => {
916
+ const element = ref.current;
917
+ if (!element) return;
918
+ let width = element.getBoundingClientRect().width;
919
+ const observer = new ResizeObserver(() => {
920
+ const nextWidth = element.getBoundingClientRect().width;
921
+ if (nextWidth !== width) {
922
+ width = nextWidth;
923
+ fit();
924
+ }
925
+ });
926
+ observer.observe(element);
927
+ let active = true;
928
+ void element.ownerDocument.fonts.ready.then(() => {
929
+ if (active) fit();
930
+ });
931
+ return () => {
932
+ active = false;
933
+ observer.disconnect();
934
+ };
935
+ }, []);
936
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CellEditorInput, {
937
+ ...props,
938
+ ref,
939
+ rows: 1,
940
+ onInput: (event) => {
941
+ fit();
942
+ onInput?.(event);
943
+ }
944
+ });
945
+ }
946
+ function RowTagSelect({ selected, options, onChange }) {
947
+ const selectRoot = (0, import_react2.useRef)(null);
948
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditGroup, {
949
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
950
+ ref: selectRoot,
951
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Select.default, {
952
+ multiple: true,
953
+ fullWidth: true,
954
+ size: "small",
955
+ displayEmpty: true,
956
+ value: selected,
957
+ inputProps: {
958
+ "aria-label": "Ch\u1ECDn tag"
959
+ },
960
+ renderValue: (value) => value.length ? `\u0110\xE3 ch\u1ECDn ${value.length} tag` : "Ch\u1ECDn tag\u2026",
961
+ MenuProps: {
962
+ container: () => selectRoot.current?.ownerDocument.body ?? document.body
963
+ },
964
+ onChange: (event) => {
965
+ const value = event.target.value;
966
+ onChange(typeof value === "string" ? value.split(",") : value);
967
+ },
968
+ sx: {
969
+ fontSize: 13
970
+ },
971
+ children: [
972
+ options.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_MenuItem.default, {
973
+ value: item,
974
+ children: [
975
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Checkbox.default, {
976
+ size: "small",
977
+ checked: selected.includes(item),
978
+ tabIndex: -1,
979
+ disableRipple: true
980
+ }),
981
+ item
982
+ ]
983
+ }, item)),
984
+ !options.length && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_MenuItem.default, {
985
+ disabled: true,
986
+ children: "Ch\u01B0a c\xF3 tag \u2014 d\xF9ng n\xFAt Th\xEAm tag ph\xEDa tr\xEAn"
987
+ })
988
+ ]
989
+ })
990
+ })
991
+ });
992
+ }
993
+ var columnWidths = {
994
+ name: 100,
995
+ code: 96,
996
+ exchange: 94,
997
+ initialMargin: 126,
998
+ tradingFee: 100,
999
+ tickSize: 92,
1000
+ margin: 100,
1001
+ priceUnit: 112,
1002
+ contractSize: 150,
1003
+ settlement: 126,
1004
+ deliveryDay: 154,
1005
+ tradingHours: 160,
1006
+ priceRange: 112
1007
+ };
1008
+ function FeesTable({ value, editable = false, onChange, labels, size = "md", tagOrder = [], language = "vi" }) {
1009
+ const [search, setSearch] = (0, import_react2.useState)("");
1010
+ const [tag, setTag] = (0, import_react2.useState)("");
1011
+ const [page, setPage] = (0, import_react2.useState)(1);
1012
+ const [pageSize, setPageSize] = (0, import_react2.useState)(FEES_PAGE_SIZE);
1013
+ const [columnsOpen, setColumnsOpen] = (0, import_react2.useState)(false);
1014
+ const english = language === "en";
1015
+ const canEdit = editable && Boolean(onChange);
1016
+ const tableRoot = (0, import_react2.useRef)(null);
1017
+ (0, import_react2.useLayoutEffect)(() => {
1018
+ const root = tableRoot.current;
1019
+ if (!root || !canEdit) return;
1020
+ const editors = [
1021
+ ...root.querySelectorAll("thead textarea")
1022
+ ];
1023
+ const align = () => {
1024
+ const height = Math.max(36, ...editors.map((editor) => editor.getBoundingClientRect().height));
1025
+ root.style.setProperty("--fees-header-title-height", `${height}px`);
1026
+ };
1027
+ const observer = new ResizeObserver(align);
1028
+ editors.forEach((editor) => observer.observe(editor));
1029
+ align();
1030
+ return () => observer.disconnect();
1031
+ }, [
1032
+ canEdit,
1033
+ value.columns
1034
+ ]);
1035
+ const dialogId = (0, import_react2.useId)();
1036
+ const [createTagOpen, setCreateTagOpen] = (0, import_react2.useState)(false);
1037
+ const [tagDraft, setTagDraft] = (0, import_react2.useState)("");
1038
+ const [deleteTarget, setDeleteTarget] = (0, import_react2.useState)(null);
1039
+ const confirmDelete = () => {
1040
+ if (!deleteTarget || !canEdit) return;
1041
+ if (deleteTarget.kind === "row") {
1042
+ onChange?.({
1043
+ ...value,
1044
+ rows: value.rows.filter((row) => row.id !== deleteTarget.id)
1045
+ });
1046
+ } else if (deleteTarget.id !== "name") {
1047
+ onChange?.({
1048
+ ...value,
1049
+ columns: value.columns.filter((column) => column.key !== deleteTarget.id),
1050
+ rows: value.rows.map((row) => ({
1051
+ ...row,
1052
+ cells: Object.fromEntries(Object.entries(row.cells).filter(([key]) => key !== deleteTarget.id))
1053
+ }))
1054
+ });
1055
+ }
1056
+ setDeleteTarget(null);
1057
+ };
1058
+ const rowTags = [
1059
+ .../* @__PURE__ */ new Set([
1060
+ ...value.tags ?? [],
1061
+ ...value.rows.flatMap((row) => row.tags)
1062
+ ])
1063
+ ].filter(Boolean);
1064
+ const tags = [
1065
+ ...tagOrder.filter((item) => rowTags.includes(item)),
1066
+ ...rowTags.filter((item) => !tagOrder.includes(item))
1067
+ ];
1068
+ const newTagName = tagDraft.trim().replace(/\s+/g, " ");
1069
+ const duplicateTag = tags.some((item) => item.toLocaleLowerCase("vi") === newTagName.toLocaleLowerCase("vi"));
1070
+ const createTag = () => {
1071
+ if (!canEdit || !newTagName || duplicateTag) return;
1072
+ onChange?.({
1073
+ ...value,
1074
+ tags: [
1075
+ ...tags,
1076
+ newTagName
1077
+ ]
1078
+ });
1079
+ setCreateTagOpen(false);
1080
+ setTagDraft("");
1081
+ };
1082
+ const activeTag = tags.includes(tag) ? tag : "";
1083
+ const filtered = filterFeesRows(value, search, activeTag);
1084
+ const pagination = paginateFeesRows(filtered, page, pageSize);
1085
+ const moveColumn = (from, to) => onChange?.({
1086
+ ...value,
1087
+ columns: moveFeesItem(value.columns, from, to)
1088
+ });
1089
+ const moveRow = (id, to) => {
1090
+ const rows = moveFeesItem(value.rows, value.rows.findIndex((row) => row.id === id), to);
1091
+ onChange?.({
1092
+ ...value,
1093
+ rows
1094
+ });
1095
+ const filteredIds = new Set(filtered.map((row) => row.id));
1096
+ const index = rows.filter((row) => filteredIds.has(row.id)).findIndex((row) => row.id === id);
1097
+ setPage(pageSize === -1 ? 1 : Math.floor(Math.max(0, index) / pageSize) + 1);
1098
+ };
1099
+ const addColumn = () => {
1100
+ const key = `column-${crypto.randomUUID()}`;
1101
+ onChange?.({
1102
+ ...value,
1103
+ columns: [
1104
+ ...value.columns,
1105
+ {
1106
+ key,
1107
+ title: "C\u1ED9t m\u1EDBi"
1108
+ }
1109
+ ],
1110
+ rows: value.rows.map((row) => ({
1111
+ ...row,
1112
+ cells: {
1113
+ ...row.cells,
1114
+ [key]: ""
1115
+ }
1116
+ }))
1117
+ });
1118
+ };
1119
+ const changeRow = (id, patch) => onChange?.({
1120
+ ...value,
1121
+ rows: value.rows.map((row) => row.id === id ? {
1122
+ ...row,
1123
+ ...patch
1124
+ } : row)
1125
+ });
1126
+ const columns = value.columns.map((column, index) => ({
1127
+ key: column.key,
1128
+ width: columnWidths[column.key] ?? 140,
1129
+ fixed: index === 0 ? "left" : void 0,
1130
+ title: canEdit ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HeaderGroup, {
1131
+ children: [
1132
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeaderTitle, {
1133
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CellEditor, {
1134
+ rows: 2,
1135
+ value: column.title,
1136
+ "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1137
+ onChange: (event) => onChange?.({
1138
+ ...value,
1139
+ columns: value.columns.map((item) => item.key === column.key ? {
1140
+ ...item,
1141
+ title: event.target.value
1142
+ } : item)
1143
+ })
1144
+ })
1145
+ }),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeaderActions, {
1147
+ children: column.key !== "name" && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DeleteButton, {
1148
+ type: "button",
1149
+ onClick: () => {
1150
+ setDeleteTarget({
1151
+ kind: "column",
1152
+ id: column.key,
1153
+ label: column.title
1154
+ });
1155
+ },
1156
+ children: "X\xF3a c\u1ED9t"
1157
+ })
1158
+ })
1159
+ ]
1160
+ }) : column.title,
1161
+ render: (_unused, row) => canEdit ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CellEditor, {
1162
+ rows: Math.max(2, (row.cells[column.key] ?? "").split("\n").length),
1163
+ value: row.cells[column.key] ?? "",
1164
+ "aria-label": `${column.title} \u2014 ${row.cells.name || "H\xE0ng m\u1EDBi"}`,
1165
+ onChange: (event) => changeRow(row.id, {
1166
+ cells: {
1167
+ ...row.cells,
1168
+ [column.key]: event.target.value
1169
+ }
1170
+ })
1171
+ }) : row.cells[column.key] ?? ""
1172
+ }));
1173
+ if (canEdit) columns.push({
1174
+ key: "__tags",
1175
+ title: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(HeaderGroup, {
1176
+ children: [
1177
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeaderTitle, {
1178
+ children: "Tag & th\u1EE9 t\u1EF1 d\xF2ng"
1179
+ }),
1180
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(HeaderActions, {})
1181
+ ]
1182
+ }),
1183
+ width: 300,
1184
+ render: (_unused, row) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(EditGroup, {
1185
+ children: [
1186
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RowTagSelect, {
1187
+ selected: row.tags,
1188
+ options: tags,
1189
+ onChange: (next) => changeRow(row.id, {
1190
+ tags: next
1191
+ })
1192
+ }),
1193
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OrderActions, {
1194
+ children: [
1195
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Position, {
1196
+ value: value.rows.findIndex((item) => item.id === row.id),
1197
+ max: value.rows.length,
1198
+ label: `V\u1ECB tr\xED d\xF2ng ${row.cells.name}`,
1199
+ onMove: (to) => moveRow(row.id, to)
1200
+ }),
1201
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1202
+ type: "button",
1203
+ "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} l\xEAn`,
1204
+ disabled: value.rows[0]?.id === row.id,
1205
+ onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) - 1),
1206
+ children: "\u2191"
1207
+ }),
1208
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1209
+ type: "button",
1210
+ "aria-label": `\u0110\u01B0a d\xF2ng ${row.cells.name} xu\u1ED1ng`,
1211
+ disabled: value.rows[value.rows.length - 1]?.id === row.id,
1212
+ onClick: () => moveRow(row.id, value.rows.findIndex((item) => item.id === row.id) + 1),
1213
+ children: "\u2193"
1214
+ })
1215
+ ]
1216
+ }),
1217
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DeleteButton, {
1218
+ type: "button",
1219
+ onClick: () => {
1220
+ setDeleteTarget({
1221
+ kind: "row",
1222
+ id: row.id,
1223
+ label: row.cells.name || "H\xE0ng m\u1EDBi"
1224
+ });
1225
+ },
1226
+ children: "X\xF3a h\xE0ng"
1227
+ })
1228
+ ]
1229
+ })
1230
+ });
1231
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_styled_components6.ThemeProvider, {
1232
+ theme: feesTheme,
1233
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", {
1234
+ ref: tableRoot,
1235
+ "data-cms-table-editor": true,
1236
+ onClick: (event) => {
1237
+ if (canEdit) event.stopPropagation();
1238
+ },
1239
+ children: [
1240
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FeesAndMarginToolbar, {
1241
+ "aria-label": "L\u1ECDc b\u1EA3ng ph\xED v\xE0 k\xFD qu\u1EF9",
1242
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FeesAndMarginToolbarInner, {
1243
+ children: [
1244
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
1245
+ style: {
1246
+ minWidth: 0
1247
+ },
1248
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TabCommon, {
1249
+ ariaLabel: "L\u1ECDc theo tag",
1250
+ size,
1251
+ items: [
1252
+ {
1253
+ id: "",
1254
+ label: labels?.all ?? "T\u1EA5t c\u1EA3"
1255
+ },
1256
+ ...tags.map((item) => ({
1257
+ id: item,
1258
+ label: item
1259
+ }))
1260
+ ],
1261
+ value: activeTag,
1262
+ onValueChange: (next) => {
1263
+ setTag(next);
1264
+ setPage(1);
1265
+ }
1266
+ })
1267
+ }),
1268
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FeesAndMarginSearch, {
1269
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(InputCommon, {
1270
+ leftIcon: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FeesSearchIcon, {}),
1271
+ size: "sm",
1272
+ "aria-label": labels?.search ?? "T\xECm t\xEAn h\xE0ng h\xF3a ho\u1EB7c m\xE3",
1273
+ placeholder: labels?.search ?? "T\xECm t\xEAn h\xE0ng h\xF3a ho\u1EB7c m\xE3",
1274
+ value: search,
1275
+ onChange: (event) => {
1276
+ setSearch(event.target.value);
1277
+ setPage(1);
1278
+ }
1279
+ })
1280
+ })
1281
+ ]
1282
+ })
1283
+ }),
1284
+ canEdit && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(EditorActions, {
1285
+ children: [
1286
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1287
+ type: "button",
1288
+ onClick: () => {
1289
+ const row = {
1290
+ id: crypto.randomUUID(),
1291
+ cells: Object.fromEntries(value.columns.map((column) => [
1292
+ column.key,
1293
+ column.key === "name" ? "H\xE0ng h\xF3a m\u1EDBi" : ""
1294
+ ])),
1295
+ tags: []
1296
+ };
1297
+ onChange?.({
1298
+ ...value,
1299
+ rows: [
1300
+ ...value.rows,
1301
+ row
1302
+ ]
1303
+ });
1304
+ setSearch("");
1305
+ setTag("");
1306
+ setPage(pageSize === -1 ? 1 : Math.ceil((value.rows.length + 1) / pageSize));
1307
+ },
1308
+ children: "+ Th\xEAm h\xE0ng"
1309
+ }),
1310
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1311
+ type: "button",
1312
+ onClick: addColumn,
1313
+ children: "+ Th\xEAm c\u1ED9t"
1314
+ }),
1315
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(EditorButton, {
1316
+ type: "button",
1317
+ onClick: () => setColumnsOpen(true),
1318
+ children: [
1319
+ "Qu\u1EA3n l\xFD c\u1ED9t (",
1320
+ value.columns.length,
1321
+ ")"
1322
+ ]
1323
+ }),
1324
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1325
+ type: "button",
1326
+ onClick: () => {
1327
+ setTagDraft("");
1328
+ setCreateTagOpen(true);
1329
+ },
1330
+ children: "+ Th\xEAm tag"
1331
+ })
1332
+ ]
1333
+ }),
1334
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AlignedFeesTable, {
1335
+ "data-editable": canEdit || void 0,
1336
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Table, {
1337
+ ariaLabel: english ? "Fees and margin table" : "B\u1EA3ng ph\xED v\xE0 k\xFD qu\u1EF9",
1338
+ columns,
1339
+ dataSource: pagination.rows,
1340
+ rowKey: "id",
1341
+ size,
1342
+ empty: labels?.empty ?? "Kh\xF4ng t\xECm th\u1EA5y h\xE0ng h\xF3a",
1343
+ scroll: {
1344
+ x: Math.max(1440, value.columns.reduce((sum, column) => sum + (columnWidths[column.key] ?? 140), 0) + (canEdit ? 300 : 0))
1345
+ }
1346
+ })
1347
+ }),
1348
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(PaginationControls, {
1349
+ children: [
1350
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(PageSizeLabel, {
1351
+ children: [
1352
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", {
1353
+ id: `${dialogId}-page-size-label`,
1354
+ children: english ? "Rows per page:" : "S\u1ED1 d\xF2ng m\u1ED7i trang:"
1355
+ }),
1356
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Select.default, {
1357
+ size: "small",
1358
+ value: pageSize,
1359
+ labelId: `${dialogId}-page-size-label`,
1360
+ inputProps: {
1361
+ "aria-label": english ? "Rows per page" : "S\u1ED1 d\xF2ng m\u1ED7i trang"
1362
+ },
1363
+ MenuProps: {
1364
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body
1365
+ },
1366
+ sx: {
1367
+ minWidth: 80,
1368
+ fontSize: 13,
1369
+ fontFamily: "inherit"
1370
+ },
1371
+ onChange: (event) => {
1372
+ setPageSize(Number(event.target.value));
1373
+ setPage(1);
1374
+ },
1375
+ children: [
1376
+ [
1377
+ 5,
1378
+ 10,
1379
+ 25,
1380
+ 50,
1381
+ 100
1382
+ ].map((size2) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_MenuItem.default, {
1383
+ value: size2,
1384
+ children: size2
1385
+ }, size2)),
1386
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_MenuItem.default, {
1387
+ value: -1,
1388
+ children: english ? "All" : "T\u1EA5t c\u1EA3"
1389
+ })
1390
+ ]
1391
+ })
1392
+ ]
1393
+ }),
1394
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", {
1395
+ "aria-live": "polite",
1396
+ style: {
1397
+ fontSize: 13
1398
+ },
1399
+ children: [
1400
+ filtered.length ? pageSize === -1 ? 1 : (pagination.page - 1) * pageSize + 1 : 0,
1401
+ "\u2013",
1402
+ pageSize === -1 ? filtered.length : Math.min(pagination.page * pageSize, filtered.length),
1403
+ " / ",
1404
+ filtered.length
1405
+ ]
1406
+ }),
1407
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Pagination, {
1408
+ page: pagination.page,
1409
+ pageCount: pagination.pageCount,
1410
+ onPageChange: setPage,
1411
+ ariaLabel: english ? "Fees pagination" : "Ph\xE2n trang b\u1EA3ng ph\xED",
1412
+ labels: {
1413
+ previous: english ? "Previous page" : "Trang tr\u01B0\u1EDBc",
1414
+ next: english ? "Next page" : "Trang sau",
1415
+ page: (number) => `${english ? "Go to page" : "\u0110i t\u1EDBi trang"} ${number}`,
1416
+ current: (number) => `${english ? "Current page" : "Trang hi\u1EC7n t\u1EA1i"}, ${number}`
1417
+ }
1418
+ })
1419
+ ]
1420
+ }),
1421
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Dialog.default, {
1422
+ open: columnsOpen && canEdit,
1423
+ onClose: () => setColumnsOpen(false),
1424
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body,
1425
+ "aria-labelledby": `${dialogId}-columns-title`,
1426
+ fullWidth: true,
1427
+ maxWidth: "md",
1428
+ children: [
1429
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogTitle.default, {
1430
+ id: `${dialogId}-columns-title`,
1431
+ children: "Qu\u1EA3n l\xFD c\u1ED9t"
1432
+ }),
1433
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_DialogContent.default, {
1434
+ children: [
1435
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogContentText.default, {
1436
+ children: "\u0110\u1ED5i ti\xEAu \u0111\u1EC1 v\xE0 v\u1ECB tr\xED c\u1ED9t. V\u1ECB tr\xED d\xF2ng/c\u1ED9t \u0111\u01B0\u1EE3c t\xEDnh trong to\xE0n b\u1EA3ng, k\u1EC3 c\u1EA3 c\xE1c d\xF2ng \u0111ang \u1EA9n b\u1EDFi b\u1ED9 l\u1ECDc."
1437
+ }),
1438
+ value.columns.map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(ColumnRow, {
1439
+ children: [
1440
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CellEditor, {
1441
+ "aria-label": `Ti\xEAu \u0111\u1EC1 c\u1ED9t ${index + 1}`,
1442
+ value: column.title,
1443
+ onChange: (event) => onChange?.({
1444
+ ...value,
1445
+ columns: value.columns.map((item) => item.key === column.key ? {
1446
+ ...item,
1447
+ title: event.target.value
1448
+ } : item)
1449
+ })
1450
+ }),
1451
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(OrderActions, {
1452
+ children: [
1453
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Position, {
1454
+ value: index,
1455
+ max: value.columns.length,
1456
+ label: `V\u1ECB tr\xED c\u1ED9t ${column.title}`,
1457
+ onMove: (to) => moveColumn(index, to)
1458
+ }),
1459
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1460
+ type: "button",
1461
+ "aria-label": `\u0110\u01B0a c\u1ED9t ${column.title} l\xEAn`,
1462
+ disabled: index === 0,
1463
+ onClick: () => moveColumn(index, index - 1),
1464
+ children: "\u2191"
1465
+ }),
1466
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1467
+ type: "button",
1468
+ "aria-label": `\u0110\u01B0a c\u1ED9t ${column.title} xu\u1ED1ng`,
1469
+ disabled: index === value.columns.length - 1,
1470
+ onClick: () => moveColumn(index, index + 1),
1471
+ children: "\u2193"
1472
+ }),
1473
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(DeleteButton, {
1474
+ type: "button",
1475
+ disabled: column.key === "name",
1476
+ onClick: () => setDeleteTarget({
1477
+ kind: "column",
1478
+ id: column.key,
1479
+ label: column.title
1480
+ }),
1481
+ children: "X\xF3a c\u1ED9t"
1482
+ })
1483
+ ]
1484
+ })
1485
+ ]
1486
+ }, column.key)),
1487
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(EditorButton, {
1488
+ type: "button",
1489
+ onClick: addColumn,
1490
+ children: "+ Th\xEAm c\u1ED9t"
1491
+ })
1492
+ ]
1493
+ }),
1494
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogActions.default, {
1495
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Button.default, {
1496
+ variant: "contained",
1497
+ onClick: () => setColumnsOpen(false),
1498
+ children: "Xong"
1499
+ })
1500
+ })
1501
+ ]
1502
+ }),
1503
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Dialog.default, {
1504
+ open: createTagOpen && canEdit,
1505
+ onClose: () => setCreateTagOpen(false),
1506
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body,
1507
+ "aria-labelledby": `${dialogId}-create-tag-title`,
1508
+ fullWidth: true,
1509
+ maxWidth: "xs",
1510
+ children: [
1511
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogTitle.default, {
1512
+ id: `${dialogId}-create-tag-title`,
1513
+ children: "T\u1EA1o tag m\u1EDBi"
1514
+ }),
1515
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogContent.default, {
1516
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_TextField.default, {
1517
+ autoFocus: true,
1518
+ fullWidth: true,
1519
+ margin: "dense",
1520
+ label: "T\xEAn tag",
1521
+ value: tagDraft,
1522
+ onChange: (event) => setTagDraft(event.target.value),
1523
+ error: duplicateTag,
1524
+ helperText: duplicateTag ? "Tag n\xE0y \u0111\xE3 t\u1ED3n t\u1EA1i." : "Tag m\u1EDBi s\u1EBD c\xF3 trong danh s\xE1ch ch\u1ECDn c\u1EE7a t\u1EA5t c\u1EA3 h\xE0ng.",
1525
+ onKeyDown: (event) => {
1526
+ if (event.key === "Enter") {
1527
+ event.preventDefault();
1528
+ createTag();
1529
+ }
1530
+ }
1531
+ })
1532
+ }),
1533
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_DialogActions.default, {
1534
+ children: [
1535
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Button.default, {
1536
+ onClick: () => setCreateTagOpen(false),
1537
+ children: "H\u1EE7y"
1538
+ }),
1539
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Button.default, {
1540
+ variant: "contained",
1541
+ disabled: !newTagName || duplicateTag,
1542
+ onClick: createTag,
1543
+ children: "T\u1EA1o tag"
1544
+ })
1545
+ ]
1546
+ })
1547
+ ]
1548
+ }),
1549
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Dialog.default, {
1550
+ open: Boolean(deleteTarget) && canEdit,
1551
+ onClose: () => setDeleteTarget(null),
1552
+ container: () => tableRoot.current?.ownerDocument.body ?? document.body,
1553
+ "aria-labelledby": `${dialogId}-title`,
1554
+ "aria-describedby": `${dialogId}-description`,
1555
+ fullWidth: true,
1556
+ maxWidth: "xs",
1557
+ children: [
1558
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_DialogTitle.default, {
1559
+ id: `${dialogId}-title`,
1560
+ children: [
1561
+ "X\xF3a ",
1562
+ deleteTarget?.kind === "column" ? "c\u1ED9t" : "h\xE0ng",
1563
+ "?"
1564
+ ]
1565
+ }),
1566
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogContent.default, {
1567
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_DialogContentText.default, {
1568
+ id: `${dialogId}-description`,
1569
+ children: deleteTarget?.kind === "column" ? `B\u1EA1n c\xF3 mu\u1ED1n x\xF3a c\u1ED9t \u201C${deleteTarget.label}\u201D v\xE0 to\xE0n b\u1ED9 n\u1ED9i dung trong c\u1ED9t n\xE0y?` : `B\u1EA1n c\xF3 mu\u1ED1n x\xF3a h\xE0ng \u201C${deleteTarget?.label ?? ""}\u201D?`
1570
+ })
1571
+ }),
1572
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_DialogActions.default, {
1573
+ children: [
1574
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_Button.default, {
1575
+ autoFocus: true,
1576
+ onClick: () => setDeleteTarget(null),
1577
+ children: "H\u1EE7y"
1578
+ }),
1579
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_Button.default, {
1580
+ color: "error",
1581
+ variant: "contained",
1582
+ onClick: confirmDelete,
1583
+ children: [
1584
+ "X\xF3a ",
1585
+ deleteTarget?.kind === "column" ? "c\u1ED9t" : "h\xE0ng"
1586
+ ]
1587
+ })
1588
+ ]
1589
+ })
1590
+ ]
1591
+ })
1592
+ ]
1593
+ })
1594
+ });
1595
+ }
1596
+
1597
+ // src/wikex/fees-manager.tsx
1598
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1599
+ function FeesManager({
1600
+ entries,
1601
+ selectedId,
1602
+ language,
1603
+ table,
1604
+ dirtyKeys,
1605
+ canWrite,
1606
+ saving = false,
1607
+ notice,
1608
+ parseError,
1609
+ statusChipVariant = "filled",
1610
+ onSelectEntry,
1611
+ onSelectLanguage,
1612
+ onChange,
1613
+ onSave,
1614
+ onDismissNotice
1615
+ }) {
1616
+ const entry = entries.find((item) => item.id === selectedId);
1617
+ const key = `${selectedId}:${language}`;
1618
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { spacing: 3, sx: { minWidth: 0, width: 1, maxWidth: 1800, mx: "auto" }, children: [
1619
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { direction: { xs: "column", md: "row" }, justifyContent: "space-between", alignItems: { md: "center" }, gap: 2.5, children: [
1620
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { spacing: 1, sx: { minWidth: 0, maxWidth: 720 }, children: [
1621
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "h4", children: "Ph\xED & k\xFD qu\u1EF9" }),
1622
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "body2", color: "text.secondary", children: "Qu\u1EA3n l\xFD d\u1EEF li\u1EC7u, tag v\xE0 th\u1EE9 t\u1EF1 hi\u1EC3n th\u1ECB. B\u1ED1 c\u1EE5c v\xE0 n\u1ED9i dung gi\u1EDBi thi\u1EC7u \u0111\u01B0\u1EE3c ch\u1EC9nh trong Layout trang t\u0129nh." })
1623
+ ] }),
1624
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { direction: "row", spacing: 1.5, alignItems: "center", flexShrink: 0, children: [
1625
+ dirtyKeys.includes(key) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Chip, { size: "small", color: "warning", label: "Ch\u01B0a l\u01B0u" }),
1626
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1627
+ import_material.Button,
1628
+ {
1629
+ variant: "contained",
1630
+ loading: saving,
1631
+ disabled: !canWrite || !dirtyKeys.includes(key) || saving,
1632
+ onClick: onSave,
1633
+ sx: { minHeight: 44, px: 3, flex: { xs: 1, md: "initial" }, minWidth: { md: 156 } },
1634
+ children: "L\u01B0u b\u1EA3ng ph\xED"
1635
+ }
1636
+ )
1637
+ ] })
1638
+ ] }),
1639
+ !canWrite && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Alert, { severity: "info", children: "B\u1EA1n c\xF3 quy\u1EC1n xem b\u1EA3ng ph\xED. C\u1EA7n quy\u1EC1n s\u1EEDa n\u1ED9i dung \u0111\u1EC3 thay \u0111\u1ED5i d\u1EEF li\u1EC7u." }),
1640
+ notice && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Alert, { severity: notice.severity, onClose: onDismissNotice, children: notice.message }),
1641
+ !entries.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Alert, { severity: "info", children: "Ch\u01B0a c\xF3 b\u1EA3ng ph\xED. Th\xEAm component B\u1EA3ng ph\xED & K\xFD qu\u1EF9 v\xE0o m\u1ED9t trang trong Layout trang t\u0129nh \u0111\u1EC3 b\u1EAFt \u0111\u1EA7u." }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1642
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Card, { variant: "outlined", sx: { p: { xs: 2.5, md: 3 }, boxShadow: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { spacing: 2.5, children: [
1643
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { direction: "row", alignItems: "center", justifyContent: "space-between", gap: 1.5, flexWrap: "wrap", children: [
1644
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "subtitle1", children: "B\u1EA3ng \u0111ang qu\u1EA3n l\xFD" }),
1645
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Chip, { size: "small", variant: statusChipVariant, label: entry?.status === "published" ? "Trang \u0111\xE3 xu\u1EA5t b\u1EA3n" : "Trang b\u1EA3n nh\xE1p", color: entry?.status === "published" ? "success" : "default" })
1646
+ ] }),
1647
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { direction: { xs: "column", md: "row" }, spacing: 2.5, alignItems: { md: "flex-end" }, children: [
1648
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1649
+ import_material.TextField,
1650
+ {
1651
+ select: true,
1652
+ size: "small",
1653
+ label: "B\u1EA3ng tr\xEAn trang",
1654
+ value: selectedId,
1655
+ disabled: saving,
1656
+ fullWidth: true,
1657
+ sx: { flex: 1, minWidth: 0 },
1658
+ onChange: (event) => onSelectEntry(event.target.value),
1659
+ children: entries.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.MenuItem, { value: item.id, children: [
1660
+ item.pageTitle,
1661
+ " \xB7 /",
1662
+ item.slug,
1663
+ " \xB7 #",
1664
+ index + 1,
1665
+ dirtyKeys.some((draft) => draft.startsWith(`${item.id}:`)) ? " (ch\u01B0a l\u01B0u)" : ""
1666
+ ] }, item.id))
1667
+ }
1668
+ ),
1669
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { spacing: 1, sx: { width: { xs: 1, md: 240 }, flexShrink: 0 }, children: [
1670
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "caption", color: "text.secondary", children: "Ng\xF4n ng\u1EEF n\u1ED9i dung" }),
1671
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1672
+ import_material.ToggleButtonGroup,
1673
+ {
1674
+ size: "small",
1675
+ exclusive: true,
1676
+ value: language,
1677
+ disabled: saving,
1678
+ "aria-label": "Ng\xF4n ng\u1EEF b\u1EA3ng ph\xED",
1679
+ sx: { minHeight: 40, "& .MuiToggleButton-root": { flex: 1, px: 2 } },
1680
+ onChange: (_, next) => {
1681
+ if (next === "vi" || next === "en") onSelectLanguage(next);
1682
+ },
1683
+ children: [
1684
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.ToggleButton, { value: "vi", children: [
1685
+ "Ti\u1EBFng Vi\u1EC7t",
1686
+ dirtyKeys.includes(`${selectedId}:vi`) ? " \u2022" : ""
1687
+ ] }),
1688
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.ToggleButton, { value: "en", children: [
1689
+ "English",
1690
+ dirtyKeys.includes(`${selectedId}:en`) ? " \u2022" : ""
1691
+ ] })
1692
+ ]
1693
+ }
1694
+ )
1695
+ ] })
1696
+ ] })
1697
+ ] }) }),
1698
+ parseError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Alert, { severity: "error", children: parseError }),
1699
+ table && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Card, { inert: saving, "aria-busy": saving, sx: { minWidth: 0, opacity: saving ? 0.65 : 1 }, children: [
1700
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { direction: { xs: "column", sm: "row" }, spacing: 2, justifyContent: "space-between", alignItems: { sm: "center" }, sx: { px: { xs: 2.5, md: 3 }, py: 2.5 }, children: [
1701
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { spacing: 0.5, children: [
1702
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "subtitle1", children: "D\u1EEF li\u1EC7u ph\xED & k\xFD qu\u1EF9" }),
1703
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "body2", color: "text.secondary", children: canWrite ? "S\u1EEDa tr\u1EF1c ti\u1EBFp trong \xF4. D\xF9ng Qu\u1EA3n l\xFD c\u1ED9t ho\u1EB7c V\u1ECB tr\xED \u0111\u1EC3 \u0111\u1ED5i th\u1EE9 t\u1EF1." : "Tra c\u1EE9u d\u1EEF li\u1EC7u v\xE0 l\u1ECDc theo nh\xF3m h\xE0ng h\xF3a." })
1704
+ ] }),
1705
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Stack, { direction: "row", spacing: 1, flexShrink: 0, children: [
1706
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Chip, { size: "small", variant: "outlined", label: `${table.rows.length} d\xF2ng` }),
1707
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Chip, { size: "small", variant: "outlined", label: `${table.columns.length} c\u1ED9t` })
1708
+ ] })
1709
+ ] }),
1710
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Divider, {}),
1711
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_material.Box, { sx: { p: { xs: 2.5, md: 3 }, minWidth: 0 }, children: [
1712
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_material.Typography, { variant: "caption", color: "text.secondary", sx: { display: { xs: "block", md: "none" }, mb: 2 }, children: "Vu\u1ED1t ngang trong b\u1EA3ng \u0111\u1EC3 xem th\xEAm c\xE1c c\u1ED9t." }),
1713
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FeesTable, { value: table, language, editable: canWrite, onChange: canWrite && !saving ? onChange : void 0 }, key)
1714
+ ] })
1715
+ ] })
1716
+ ] })
1717
+ ] });
1718
+ }
1719
+ // Annotate the CommonJS export names for ESM import in node:
1720
+ 0 && (module.exports = {
1721
+ FeesManager,
1722
+ FeesTable
1723
+ });
1724
+ //# sourceMappingURL=fees.js.map