@sito/dashboard 0.0.64 → 0.0.65

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/README.md CHANGED
@@ -1,14 +1,13 @@
1
1
  # @sito/dashboard
2
2
 
3
- `@sito/dashboard` is a React + TypeScript UI library focused on reusable dashboard components.
3
+ `@sito/dashboard` is a React + TypeScript UI library for dashboard and admin interfaces.
4
4
 
5
- ## Project Description
5
+ ## Highlights
6
6
 
7
- This package provides ready-to-use components for admin/dashboard use cases, with focus on data-heavy screens:
8
-
9
- - `Table` with sorting, filtering, pagination, row selection, bulk actions, and expandable rows.
10
- - Form inputs and utility components (`Badge`, `Chip`, `Tooltip`, `Loading`, icons).
11
- - Built-in providers for translations and table state management.
7
+ - `Table` component with sorting, filtering, pagination, row selection, bulk actions, and expandable rows.
8
+ - Reusable UI pieces: `Badge`, `Button`, `Chip`, `Dropdown`, `IconButton`, `Loading`, `Tooltip`, and `SvgIcons`.
9
+ - Form controls: `TextInput`, `SelectInput`, `AutocompleteInput`, `CheckInput`, and `FileInput`.
10
+ - Built-in providers for translations and table state (`TranslationProvider`, `TableOptionsProvider`).
12
11
 
13
12
  ## Installation
14
13
 
@@ -18,22 +17,18 @@ npm install @sito/dashboard
18
17
 
19
18
  # yarn
20
19
  yarn add @sito/dashboard
21
- ```
22
20
 
23
- ### Peer dependencies
21
+ # pnpm
22
+ pnpm add @sito/dashboard
23
+ ```
24
24
 
25
- Make sure your app provides compatible versions:
25
+ ### Peer dependency
26
26
 
27
27
  - `react` (`>=18.2 <20`)
28
- - `@emotion/css` (`11.13.5`)
29
-
30
- ## Usage
31
28
 
32
- Important:
29
+ ## Quick Usage
33
30
 
34
- - Import from `@sito/dashboard` (not from `@sito/dashboard/lib`).
35
- - `Table` should be wrapped by `TranslationProvider` and `TableOptionsProvider`.
36
- - `actions` is a callback per row: `(row) => ActionType[]`.
31
+ Import directly from `@sito/dashboard` (do not import from internal paths).
37
32
 
38
33
  ```tsx
39
34
  import {
@@ -54,48 +49,7 @@ const rows: UserRow[] = [
54
49
  { id: 2, deletedAt: null, name: "Jane Smith", age: 25 },
55
50
  ];
56
51
 
57
- const actions = (row: UserRow) => [
58
- {
59
- id: "view",
60
- tooltip: `View ${row.name}`,
61
- icon: <span>View</span>,
62
- onClick: () => console.log("View", row),
63
- },
64
- {
65
- id: "delete",
66
- tooltip: "Delete selected",
67
- icon: <span>Delete</span>,
68
- multiple: true,
69
- onClick: () => console.log("Delete", row),
70
- onMultipleClick: (selectedRows: UserRow[]) =>
71
- console.log("Bulk delete", selectedRows.map(({ name }) => name)),
72
- },
73
- ];
74
-
75
- const translations: Record<string, string> = {
76
- "_accessibility:components.table.selectedCount": "Selected {{count}} items",
77
- "_accessibility:labels.actions": "Actions",
78
- "_accessibility:buttons.filters": "Filters",
79
- "_accessibility:buttons.previous": "Previous page",
80
- "_accessibility:buttons.next": "Next page",
81
- "_accessibility:buttons.clear": "Clear",
82
- "_accessibility:buttons.applyFilters": "Apply filters",
83
- "_accessibility:components.table.pageSizes": "Rows per page",
84
- "_accessibility:components.table.jumpToPage": "Jump to page",
85
- "_accessibility:components.table.of": "of",
86
- "_accessibility:components.table.empty": "No data available",
87
- "_accessibility:components.table.selectRow": "Select row",
88
- "_accessibility:components.table.selectAllRows": "Select all visible rows",
89
- };
90
-
91
- const t = (key: string, options?: Record<string, unknown>) => {
92
- if (key === "_accessibility:components.table.selectedCount") {
93
- const count = typeof options?.count === "number" ? options.count : 0;
94
- return translations[key].replace("{{count}}", String(count));
95
- }
96
-
97
- return translations[key] ?? key;
98
- };
52
+ const t = (key: string) => key;
99
53
 
100
54
  export function UsersTable() {
101
55
  return (
@@ -117,11 +71,14 @@ export function UsersTable() {
117
71
  },
118
72
  { key: "age", label: "Age", sortable: true },
119
73
  ]}
120
- actions={actions}
121
- onRowSelect={(row, selected) => console.log(selected, row)}
122
- onSelectedRowsChange={(selectedRows) =>
123
- console.log("Selected rows", selectedRows)
124
- }
74
+ actions={(row) => [
75
+ {
76
+ id: "view",
77
+ tooltip: `View ${row.name}`,
78
+ icon: <span>View</span>,
79
+ onClick: () => console.log("View", row),
80
+ },
81
+ ]}
125
82
  />
126
83
  </TableOptionsProvider>
127
84
  </TranslationProvider>
@@ -129,24 +86,38 @@ export function UsersTable() {
129
86
  }
130
87
  ```
131
88
 
132
- ## Core Table Props
133
-
134
- | Prop | Type | Required | Description |
135
- |---|---|---|---|
136
- | `entity` | `string` | Yes | Entity name used by internal components. |
137
- | `data` | `TRow[]` | Yes | Rows to render. `TRow` must extend `BaseDto` and include `id`. |
138
- | `columns` | `ColumnType<TRow>[]` | No | Column definitions. |
139
- | `actions` | `(row: TRow) => ActionType<TRow>[]` | No | Per-row action factory. |
140
- | `title` | `string` | No | Header title. |
141
- | `toolbar` | `ReactNode` | No | Custom header content. |
142
- | `onSort` | `(prop: string, sortOrder: SortOrder) => void` | No | Sort callback. |
143
- | `onRowSelect` | `(row: TRow, selected: boolean) => void` | No | Row selection callback. |
144
- | `onSelectedRowsChange` | `(rows: TRow[]) => void` | No | Selected rows callback. |
145
- | `onRowExpand` | `(expandedRow: TRow, collapsedRow: TRow \| null) => ReactNode` | No | Expand row content callback. |
146
- | `allowMultipleExpandedRows` | `boolean` | No | Allows multiple expanded rows at once. |
147
- | `expandedRowId` | `TRow["id"] \| null` | No | Controlled expansion mode. |
148
-
149
- ## Development Setup (Step-by-step)
89
+ ## Core `Table` Props
90
+
91
+ | Prop | Type | Required | Description |
92
+ | --------------------------- | ----------------------------------------------------------------- | -------- | --------------------------------------------------------------------------- |
93
+ | `entity` | `string` | Yes | Entity name used by internal table state. |
94
+ | `data` | `TRow[]` | Yes | Rows to render. `TRow` must extend `BaseDto` and include `id`. |
95
+ | `columns` | `ColumnType<TRow>[]` | No | Column definitions. |
96
+ | `actions` | `(row: TRow) => ActionType<TRow>[]` | No | Per-row action factory. |
97
+ | `title` | `string` | No | Header title. |
98
+ | `toolbar` | `ReactNode` | No | Extra content rendered in the table header. |
99
+ | `isLoading` | `boolean` | No | Loading state for table UI. |
100
+ | `filterOptions` | `FilterOptions` | No | Extra options passed to filter behavior/components. |
101
+ | `onSort` | `(prop: string, sortOrder: SortOrder) => void` | No | Sort callback when a sortable column is toggled. |
102
+ | `onRowSelect` | `(row: TRow, selected: boolean) => void` | No | Row selection callback. |
103
+ | `onSelectedRowsChange` | `(rows: TRow[]) => void` | No | Callback with selected rows. |
104
+ | `softDeleteProperty` | `keyof TRow` | No | Property name used to determine soft-deleted rows. Defaults to `deletedAt`. |
105
+ | `allowMultipleExpandedRows` | `boolean` | No | Enables multiple expanded rows (uncontrolled mode). |
106
+ | `expandedRowId` | `TRow["id"] \| null` | No | Controlled expanded row id. |
107
+ | `onExpandedRowChange` | `(expandedRow: TRow \| null, collapsedRow: TRow \| null) => void` | No | Called when expanded row changes. |
108
+ | `onRowExpand` | `(expandedRow: TRow, collapsedRow: TRow \| null) => ReactNode` | No | Returns content rendered inside expanded row area. |
109
+ | `className` | `string` | No | Wrapper class name. |
110
+ | `contentClassName` | `string` | No | Content container class name. |
111
+
112
+ ## Exported API
113
+
114
+ Main package exports include:
115
+
116
+ - Components: `Badge`, `Button`, `Chip`, `Dropdown`, `Form`, `IconButton`, `Loading`, `SvgIcons`, `Table`, `Tooltip`.
117
+ - Providers: `FiltersProvider`, `TableOptionsProvider`, `TranslationProvider` and related hooks/types.
118
+ - Utilities and models: `FilterTypes`, `SortOrder`, `BaseDto`, and query/filter helpers from `lib`.
119
+
120
+ ## Development Setup
150
121
 
151
122
  1. Clone the repository.
152
123
 
@@ -158,67 +129,45 @@ cd -- -sito-dashboard
158
129
  2. Use the expected Node version.
159
130
 
160
131
  ```bash
161
- nvm install 20.19.0
162
- nvm use 20.19.0
132
+ nvm install
133
+ nvm use
163
134
  ```
164
135
 
136
+ Current `.nvmrc`: `20.19.0`
137
+
165
138
  3. Install dependencies.
166
139
 
167
140
  ```bash
168
141
  npm install
169
142
  ```
170
143
 
171
- 4. Start local development.
144
+ 4. Start development.
172
145
 
173
146
  ```bash
174
147
  # Vite dev server
175
148
  npm run dev
176
149
 
177
- # Component-focused development (recommended)
150
+ # Storybook (recommended for component work)
178
151
  npm run storybook
179
152
  ```
180
153
 
181
- 5. Build the library.
154
+ ## Scripts
182
155
 
183
156
  ```bash
184
- npm run build
185
- ```
186
-
187
- ## How To Run Tests
188
-
189
- ```bash
190
- # run all tests once
191
- npm run test
192
-
193
- # run a specific test file
194
- npm run test -- src/components/Table/Table.expandable.test.tsx
195
- ```
196
-
197
- ## How To Run Linters
198
-
199
- ```bash
200
- # runs ESLint with auto-fix enabled in this project
201
- npm run lint
202
- ```
203
-
204
- ## Additional Useful Scripts
205
-
206
- ```bash
207
- # format source files
208
- npm run format
209
-
210
- # build static Storybook
211
- npm run build-storybook
212
-
213
- # preview production build
214
- npm run preview
157
+ npm run build # Build library (types + bundles)
158
+ npm run test # Run tests once with Vitest
159
+ npm run lint # ESLint + Prettier + depcheck
160
+ npm run format # Prettier on src files
161
+ npm run build-storybook # Build static Storybook
162
+ npm run preview # Preview Vite build
163
+ npm run full # lint + build + test
215
164
  ```
216
165
 
217
166
  ## Contributing
218
167
 
219
168
  1. Create a branch from `main`.
220
- 2. Add/adjust tests for your changes.
221
- 3. Run lint and tests.
169
+ 2. Add or update tests for your changes.
170
+ 3. Run `npm run full`.
222
171
  4. Open a pull request with a clear summary.
223
172
 
224
173
  ## License
@@ -1,7 +1,7 @@
1
1
  import { AutocompleteInputPropsType } from './types';
2
2
  /**
3
- *
4
- * @param props
5
- * @returns
3
+ * Text input with autocomplete suggestions, supporting single and multiple selection.
4
+ * @param props - Component props
5
+ * @param ref - Forwarded ref to the underlying input element
6
6
  */
7
7
  export declare const AutocompleteInput: import('react').ForwardRefExoticComponent<Omit<AutocompleteInputPropsType, "ref"> & import('react').RefAttributes<HTMLInputElement>>;
@@ -6,4 +6,3 @@ import { RowsPropsType } from './types';
6
6
  * @returns Function result.
7
7
  */
8
8
  export declare const Rows: <TRow extends BaseDto>(props: RowsPropsType<TRow>) => import("react/jsx-runtime").JSX.Element[];
9
- export default Rows;
@@ -0,0 +1,18 @@
1
+ import { BaseDto } from '../../../lib';
2
+ import { ActionType } from '../types';
3
+ type TableSelectionBarProps<TRow extends BaseDto> = {
4
+ count: number;
5
+ multiActions: ActionType<TRow>[];
6
+ onActionClick: (action: ActionType<TRow>) => void;
7
+ };
8
+ /**
9
+ * Renders the selection bar shown when one or more table rows are selected.
10
+ * Displays the count of selected rows and optional bulk action buttons.
11
+ * @param root0 - Component props.
12
+ * @param root0.count - Number of currently selected rows.
13
+ * @param root0.multiActions - List of actions available for the selected rows.
14
+ * @param root0.onActionClick - Callback invoked when a bulk action button is clicked.
15
+ * @returns Selection bar element.
16
+ */
17
+ export declare function TableSelectionBar<TRow extends BaseDto>({ count, multiActions, onActionClick, }: TableSelectionBarProps<TRow>): import("react/jsx-runtime").JSX.Element;
18
+ export {};
@@ -4,4 +4,5 @@ export * from './Footer';
4
4
  export * from './Rows';
5
5
  export * from './TableEmpty';
6
6
  export * from './TableHeader';
7
+ export * from './TableSelectionBar';
7
8
  export * from './types';
@@ -0,0 +1,3 @@
1
+ export * from './useExpandedRows';
2
+ export * from './useTableMultiActions';
3
+ export * from './useTableRowSelection';
@@ -0,0 +1,28 @@
1
+ import { BaseDto } from '../../../lib';
2
+ import { ReactNode } from 'react';
3
+ import { ExpandedRowStateType } from '../components/types';
4
+ interface UseExpandedRowsParams<TRow extends BaseDto> {
5
+ data: TRow[];
6
+ allowMultipleExpandedRows: boolean;
7
+ controlledExpandedRowId: TRow["id"] | null | undefined;
8
+ onExpandedRowChange?: (expandedRow: TRow | null, collapsedRow: TRow | null) => void;
9
+ onRowExpand?: (expandedRow: TRow, collapsedRow: TRow | null) => ReactNode;
10
+ findRowById: (rowId: TRow["id"] | null) => TRow | null;
11
+ }
12
+ /**
13
+ * Manages expand/collapse state and CSS transition animations for table rows.
14
+ * Supports both single and multiple expanded rows, as well as controlled mode via `controlledExpandedRowId`.
15
+ * @param root0 - Hook parameters.
16
+ * @param root0.data - Array of row data; used to clean up expanded state when rows are removed.
17
+ * @param root0.allowMultipleExpandedRows - When true, multiple rows can be expanded simultaneously.
18
+ * @param root0.controlledExpandedRowId - When provided, the expanded row is controlled externally.
19
+ * @param root0.onExpandedRowChange - Optional callback fired when a row is expanded or collapsed.
20
+ * @param root0.onRowExpand - Callback that returns the content to render inside an expanded row.
21
+ * @param root0.findRowById - Helper to look up a row by its id.
22
+ * @returns expandedRowsToRender — list of rows currently rendered with animation state, and onRowExpandChange — click handler for row expansion.
23
+ */
24
+ export declare function useExpandedRows<TRow extends BaseDto>({ data, allowMultipleExpandedRows, controlledExpandedRowId, onExpandedRowChange, onRowExpand, findRowById, }: UseExpandedRowsParams<TRow>): {
25
+ expandedRowsToRender: ExpandedRowStateType<TRow>[];
26
+ onRowExpandChange: (row: TRow) => void;
27
+ };
28
+ export {};
@@ -0,0 +1,20 @@
1
+ import { BaseDto } from '../../../lib';
2
+ import { ActionType } from '../types';
3
+ interface UseTableMultiActionsParams<TRow extends BaseDto> {
4
+ actions?: (row: TRow) => ActionType<TRow>[];
5
+ selectedRowsData: TRow[];
6
+ }
7
+ /**
8
+ * Computes the set of bulk actions shared across all selected rows and provides a click handler.
9
+ * An action is included only if it is present (and not hidden) on every selected row; the `disabled`
10
+ * flag is set if any row marks the action as disabled.
11
+ * @param root0 - Hook parameters.
12
+ * @param root0.actions - Function that returns the action list for a given row.
13
+ * @param root0.selectedRowsData - Array of currently selected row objects.
14
+ * @returns multiActions — filtered shared actions, and handleMultipleActionClick — handler that calls `onMultipleClick` or iterates over selected rows.
15
+ */
16
+ export declare function useTableMultiActions<TRow extends BaseDto>({ actions, selectedRowsData, }: UseTableMultiActionsParams<TRow>): {
17
+ multiActions: ActionType<TRow>[];
18
+ handleMultipleActionClick: (action: ActionType<TRow>) => void;
19
+ };
20
+ export {};
@@ -0,0 +1,26 @@
1
+ import { BaseDto } from '../../../lib';
2
+ interface UseTableRowSelectionParams<TRow extends BaseDto> {
3
+ data: TRow[];
4
+ onRowSelect?: (row: TRow, selected: boolean) => void;
5
+ onSelectedRowsChange?: (rows: TRow[]) => void;
6
+ }
7
+ /**
8
+ * Manages row selection state for the Table component.
9
+ * Handles individual row toggling, select-all, and keeps selection in sync when data changes.
10
+ * @param root0 - Hook parameters.
11
+ * @param root0.data - Array of row data; used to sync selection when rows are added or removed.
12
+ * @param root0.onRowSelect - Optional callback fired when a single row is selected or deselected.
13
+ * @param root0.onSelectedRowsChange - Optional callback fired with the full array of selected rows whenever selection changes.
14
+ * @returns Selection state and handlers: selectedRows, selectedRowsData, selectionState, onRowSelectionChange, onToggleAllRows.
15
+ */
16
+ export declare function useTableRowSelection<TRow extends BaseDto>({ data, onRowSelect, onSelectedRowsChange, }: UseTableRowSelectionParams<TRow>): {
17
+ selectedRows: Set<TRow["id"]>;
18
+ selectedRowsData: TRow[];
19
+ selectionState: {
20
+ allSelected: boolean;
21
+ hasSomeSelected: boolean;
22
+ };
23
+ onRowSelectionChange: (row: TRow) => void;
24
+ onToggleAllRows: () => void;
25
+ };
26
+ export {};
@@ -0,0 +1,8 @@
1
+ import { BaseDto } from '../../lib';
2
+ import { ColumnType } from './components/types';
3
+ /**
4
+ * Returns columns sorted by position (descending) with hidden columns filtered out.
5
+ * @param columns - Array of column definitions to sort and filter.
6
+ * @returns Sorted and filtered array of visible columns.
7
+ */
8
+ export declare function getSortedVisibleColumns<TRow extends BaseDto>(columns: ColumnType<TRow>[]): ColumnType<TRow>[];
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- var ts=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),l=require("react"),ut=e=>{const{count:t,className:s=""}=e,n=l.useRef(null);return l.useEffect(()=>{n.current?.parentNode&&((n.current?.parentNode).style.position="relative")},[n]),r.jsx("span",{ref:n,className:`${s} badge-main`,children:t})},dt=e=>{const{children:t,type:s="button",variant:n="text",color:a="default",className:i="",...o}=e;return r.jsx("button",{type:s,className:`button ${n} ${a} ${i}`,...o,children:t})};function se(e){const{text:t,onDelete:s,children:n,icon:a,variant:i="default",iconClassName:o="",className:c="",textClassName:u=""}=e;return r.jsxs("div",{className:`chip-main ${i} ${c}`,children:[r.jsx("span",{className:u,children:t}),n,s?r.jsx(re,{icon:a??r.jsx(Pe,{}),className:`chip-delete-button ${o}`,onClick:s}):null]})}const tn=e=>{const{children:t,open:s,onClose:n}=e,a=l.useRef(null),i=l.useCallback(c=>{const u=a.current;!s||!u||u.contains(c.target)||n()},[s,n]),o=l.useCallback(c=>{s&&c.key==="Escape"&&n()},[s,n]);return l.useEffect(()=>{if(s)return setTimeout(()=>a.current?.focus(),0),document.addEventListener("mousedown",i),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",o)}},[s,i,o]),r.jsx("div",{ref:a,role:"menu","aria-hidden":!s,tabIndex:-1,className:`dropdown-main ${s?"opened":"closed"}`,onClick:c=>c.stopPropagation(),children:t})};function nn(e){if(e.sheet)return e.sheet;for(var t=0;t<document.styleSheets.length;t++)if(document.styleSheets[t].ownerNode===e)return document.styleSheets[t]}function sn(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),e.nonce!==void 0&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}var rn=(function(){function e(s){var n=this;this._insertTag=function(a){var i;n.tags.length===0?n.insertionPoint?i=n.insertionPoint.nextSibling:n.prepend?i=n.container.firstChild:i=n.before:i=n.tags[n.tags.length-1].nextSibling,n.container.insertBefore(a,i),n.tags.push(a)},this.isSpeedy=s.speedy===void 0?!0:s.speedy,this.tags=[],this.ctr=0,this.nonce=s.nonce,this.key=s.key,this.container=s.container,this.prepend=s.prepend,this.insertionPoint=s.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(n){n.forEach(this._insertTag)},t.insert=function(n){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag(sn(this));var a=this.tags[this.tags.length-1];if(this.isSpeedy){var i=nn(a);try{i.insertRule(n,i.cssRules.length)}catch{}}else a.appendChild(document.createTextNode(n));this.ctr++},t.flush=function(){this.tags.forEach(function(n){var a;return(a=n.parentNode)==null?void 0:a.removeChild(n)}),this.tags=[],this.ctr=0},e})(),D="-ms-",Ee="-moz-",R="-webkit-",ft="comm",Ve="rule",Ue="decl",an="@import",pt="@keyframes",cn="@layer",ln=Math.abs,Ae=String.fromCharCode,on=Object.assign;function un(e,t){return L(e,0)^45?(((t<<2^L(e,0))<<2^L(e,1))<<2^L(e,2))<<2^L(e,3):0}function ht(e){return e.trim()}function dn(e,t){return(e=t.exec(e))?e[0]:e}function k(e,t,s){return e.replace(t,s)}function Be(e,t){return e.indexOf(t)}function L(e,t){return e.charCodeAt(t)|0}function ve(e,t,s){return e.slice(t,s)}function J(e){return e.length}function qe(e){return e.length}function ye(e,t){return t.push(e),e}function fn(e,t){return e.map(t).join("")}var Te=1,he=1,mt=0,B=0,O=0,me="";function Me(e,t,s,n,a,i,o){return{value:e,root:t,parent:s,type:n,props:a,children:i,line:Te,column:he,length:o,return:""}}function ge(e,t){return on(Me("",null,null,"",null,null,0),e,{length:-e.length},t)}function pn(){return O}function hn(){return O=B>0?L(me,--B):0,he--,O===10&&(he=1,Te--),O}function _(){return O=B<mt?L(me,B++):0,he++,O===10&&(he=1,Te++),O}function X(){return L(me,B)}function Se(){return B}function je(e,t){return ve(me,e,t)}function Ce(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function xt(e){return Te=he=1,mt=J(me=e),B=0,[]}function bt(e){return me="",e}function Re(e){return ht(je(B-1,_e(e===91?e+2:e===40?e+1:e)))}function mn(e){for(;(O=X())&&O<33;)_();return Ce(e)>2||Ce(O)>3?"":" "}function xn(e,t){for(;--t&&_()&&!(O<48||O>102||O>57&&O<65||O>70&&O<97););return je(e,Se()+(t<6&&X()==32&&_()==32))}function _e(e){for(;_();)switch(O){case e:return B;case 34:case 39:e!==34&&e!==39&&_e(O);break;case 40:e===41&&_e(e);break;case 92:_();break}return B}function bn(e,t){for(;_()&&e+O!==57;)if(e+O===84&&X()===47)break;return"/*"+je(t,B-1)+"*"+Ae(e===47?e:_())}function gn(e){for(;!Ce(X());)_();return je(e,B)}function vn(e){return bt(ke("",null,null,null,[""],e=xt(e),0,[0],e))}function ke(e,t,s,n,a,i,o,c,u){for(var f=0,d=0,m=o,x=0,h=0,g=0,j=1,E=1,b=1,v=0,S="",F=a,A=i,T=n,N=S;E;)switch(g=v,v=_()){case 40:if(g!=108&&L(N,m-1)==58){Be(N+=k(Re(v),"&","&\f"),"&\f")!=-1&&(b=-1);break}case 34:case 39:case 91:N+=Re(v);break;case 9:case 10:case 13:case 32:N+=mn(g);break;case 92:N+=xn(Se()-1,7);continue;case 47:switch(X()){case 42:case 47:ye(Cn(bn(_(),Se()),t,s),u);break;default:N+="/"}break;case 123*j:c[f++]=J(N)*b;case 125*j:case 59:case 0:switch(v){case 0:case 125:E=0;case 59+d:b==-1&&(N=k(N,/\f/g,"")),h>0&&J(N)-m&&ye(h>32?tt(N+";",n,s,m-1):tt(k(N," ","")+";",n,s,m-2),u);break;case 59:N+=";";default:if(ye(T=et(N,t,s,f,d,a,c,S,F=[],A=[],m),i),v===123)if(d===0)ke(N,t,T,T,F,i,m,c,A);else switch(x===99&&L(N,3)===110?100:x){case 100:case 108:case 109:case 115:ke(e,T,T,n&&ye(et(e,T,T,0,0,a,c,S,a,F=[],m),A),a,A,m,c,n?F:A);break;default:ke(N,T,T,T,[""],A,0,c,A)}}f=d=h=0,j=b=1,S=N="",m=o;break;case 58:m=1+J(N),h=g;default:if(j<1){if(v==123)--j;else if(v==125&&j++==0&&hn()==125)continue}switch(N+=Ae(v),v*j){case 38:b=d>0?1:(N+="\f",-1);break;case 44:c[f++]=(J(N)-1)*b,b=1;break;case 64:X()===45&&(N+=Re(_())),x=X(),d=m=J(S=N+=gn(Se())),v++;break;case 45:g===45&&J(N)==2&&(j=0)}}return i}function et(e,t,s,n,a,i,o,c,u,f,d){for(var m=a-1,x=a===0?i:[""],h=qe(x),g=0,j=0,E=0;g<n;++g)for(var b=0,v=ve(e,m+1,m=ln(j=o[g])),S=e;b<h;++b)(S=ht(j>0?x[b]+" "+v:k(v,/&\f/g,x[b])))&&(u[E++]=S);return Me(e,t,s,a===0?Ve:c,u,f,d)}function Cn(e,t,s){return Me(e,t,s,ft,Ae(pn()),ve(e,2,-2),0)}function tt(e,t,s,n){return Me(e,t,s,Ue,ve(e,0,n),ve(e,n+1,-1),n)}function pe(e,t){for(var s="",n=qe(e),a=0;a<n;a++)s+=t(e[a],a,e,t)||"";return s}function wn(e,t,s,n){switch(e.type){case cn:if(e.children.length)break;case an:case Ue:return e.return=e.return||e.value;case ft:return"";case pt:return e.return=e.value+"{"+pe(e.children,n)+"}";case Ve:e.value=e.props.join(",")}return J(s=pe(e.children,n))?e.return=e.value+"{"+s+"}":""}function jn(e){var t=qe(e);return function(s,n,a,i){for(var o="",c=0;c<t;c++)o+=e[c](s,n,a,i)||"";return o}}function Nn(e){return function(t){t.root||(t=t.return)&&e(t)}}function yn(e){var t=Object.create(null);return function(s){return t[s]===void 0&&(t[s]=e(s)),t[s]}}var Sn=function(t,s,n){for(var a=0,i=0;a=i,i=X(),a===38&&i===12&&(s[n]=1),!Ce(i);)_();return je(t,B)},Rn=function(t,s){var n=-1,a=44;do switch(Ce(a)){case 0:a===38&&X()===12&&(s[n]=1),t[n]+=Sn(B-1,s,n);break;case 2:t[n]+=Re(a);break;case 4:if(a===44){t[++n]=X()===58?"&\f":"",s[n]=t[n].length;break}default:t[n]+=Ae(a)}while(a=_());return t},kn=function(t,s){return bt(Rn(xt(t),s))},nt=new WeakMap,En=function(t){if(!(t.type!=="rule"||!t.parent||t.length<1)){for(var s=t.value,n=t.parent,a=t.column===n.column&&t.line===n.line;n.type!=="rule";)if(n=n.parent,!n)return;if(!(t.props.length===1&&s.charCodeAt(0)!==58&&!nt.get(n))&&!a){nt.set(t,!0);for(var i=[],o=kn(s,i),c=n.props,u=0,f=0;u<o.length;u++)for(var d=0;d<c.length;d++,f++)t.props[f]=i[u]?o[u].replace(/&\f/g,c[d]):c[d]+" "+o[u]}}},$n=function(t){if(t.type==="decl"){var s=t.value;s.charCodeAt(0)===108&&s.charCodeAt(2)===98&&(t.return="",t.value="")}};function gt(e,t){switch(un(e,t)){case 5103:return R+"print-"+e+e;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return R+e+e;case 5349:case 4246:case 4810:case 6968:case 2756:return R+e+Ee+e+D+e+e;case 6828:case 4268:return R+e+D+e+e;case 6165:return R+e+D+"flex-"+e+e;case 5187:return R+e+k(e,/(\w+).+(:[^]+)/,R+"box-$1$2"+D+"flex-$1$2")+e;case 5443:return R+e+D+"flex-item-"+k(e,/flex-|-self/,"")+e;case 4675:return R+e+D+"flex-line-pack"+k(e,/align-content|flex-|-self/,"")+e;case 5548:return R+e+D+k(e,"shrink","negative")+e;case 5292:return R+e+D+k(e,"basis","preferred-size")+e;case 6060:return R+"box-"+k(e,"-grow","")+R+e+D+k(e,"grow","positive")+e;case 4554:return R+k(e,/([^-])(transform)/g,"$1"+R+"$2")+e;case 6187:return k(k(k(e,/(zoom-|grab)/,R+"$1"),/(image-set)/,R+"$1"),e,"")+e;case 5495:case 3959:return k(e,/(image-set\([^]*)/,R+"$1$`$1");case 4968:return k(k(e,/(.+:)(flex-)?(.*)/,R+"box-pack:$3"+D+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+R+e+e;case 4095:case 3583:case 4068:case 2532:return k(e,/(.+)-inline(.+)/,R+"$1$2")+e;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(J(e)-1-t>6)switch(L(e,t+1)){case 109:if(L(e,t+4)!==45)break;case 102:return k(e,/(.+:)(.+)-([^]+)/,"$1"+R+"$2-$3$1"+Ee+(L(e,t+3)==108?"$3":"$2-$3"))+e;case 115:return~Be(e,"stretch")?gt(k(e,"stretch","fill-available"),t)+e:e}break;case 4949:if(L(e,t+1)!==115)break;case 6444:switch(L(e,J(e)-3-(~Be(e,"!important")&&10))){case 107:return k(e,":",":"+R)+e;case 101:return k(e,/(.+:)([^;!]+)(;|!.+)?/,"$1"+R+(L(e,14)===45?"inline-":"")+"box$3$1"+R+"$2$3$1"+D+"$2box$3")+e}break;case 5936:switch(L(e,t+11)){case 114:return R+e+D+k(e,/[svh]\w+-[tblr]{2}/,"tb")+e;case 108:return R+e+D+k(e,/[svh]\w+-[tblr]{2}/,"tb-rl")+e;case 45:return R+e+D+k(e,/[svh]\w+-[tblr]{2}/,"lr")+e}return R+e+D+e+e}return e}var An=function(t,s,n,a){if(t.length>-1&&!t.return)switch(t.type){case Ue:t.return=gt(t.value,t.length);break;case pt:return pe([ge(t,{value:k(t.value,"@","@"+R)})],a);case Ve:if(t.length)return fn(t.props,function(i){switch(dn(i,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return pe([ge(t,{props:[k(i,/:(read-\w+)/,":"+Ee+"$1")]})],a);case"::placeholder":return pe([ge(t,{props:[k(i,/:(plac\w+)/,":"+R+"input-$1")]}),ge(t,{props:[k(i,/:(plac\w+)/,":"+Ee+"$1")]}),ge(t,{props:[k(i,/:(plac\w+)/,D+"input-$1")]})],a)}return""})}},Tn=[An],Mn=function(t){var s=t.key;if(s==="css"){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,function(j){var E=j.getAttribute("data-emotion");E.indexOf(" ")!==-1&&(document.head.appendChild(j),j.setAttribute("data-s",""))})}var a=t.stylisPlugins||Tn,i={},o,c=[];o=t.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+s+' "]'),function(j){for(var E=j.getAttribute("data-emotion").split(" "),b=1;b<E.length;b++)i[E[b]]=!0;c.push(j)});var u,f=[En,$n];{var d,m=[wn,Nn(function(j){d.insert(j)})],x=jn(f.concat(a,m)),h=function(E){return pe(vn(E),x)};u=function(E,b,v,S){d=v,h(E?E+"{"+b.styles+"}":b.styles),S&&(g.inserted[b.name]=!0)}}var g={key:s,sheet:new rn({key:s,container:o,nonce:t.nonce,speedy:t.speedy,prepend:t.prepend,insertionPoint:t.insertionPoint}),nonce:t.nonce,inserted:i,registered:{},insert:u};return g.sheet.hydrate(c),g};function Fn(e){for(var t=0,s,n=0,a=e.length;a>=4;++n,a-=4)s=e.charCodeAt(n)&255|(e.charCodeAt(++n)&255)<<8|(e.charCodeAt(++n)&255)<<16|(e.charCodeAt(++n)&255)<<24,s=(s&65535)*1540483477+((s>>>16)*59797<<16),s^=s>>>24,t=(s&65535)*1540483477+((s>>>16)*59797<<16)^(t&65535)*1540483477+((t>>>16)*59797<<16);switch(a){case 3:t^=(e.charCodeAt(n+2)&255)<<16;case 2:t^=(e.charCodeAt(n+1)&255)<<8;case 1:t^=e.charCodeAt(n)&255,t=(t&65535)*1540483477+((t>>>16)*59797<<16)}return t^=t>>>13,t=(t&65535)*1540483477+((t>>>16)*59797<<16),((t^t>>>15)>>>0).toString(36)}var On={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Pn=/[A-Z]|^ms/g,In=/_EMO_([^_]+?)_([^]*?)_EMO_/g,vt=function(t){return t.charCodeAt(1)===45},st=function(t){return t!=null&&typeof t!="boolean"},Le=yn(function(e){return vt(e)?e:e.replace(Pn,"-$&").toLowerCase()}),rt=function(t,s){switch(t){case"animation":case"animationName":if(typeof s=="string")return s.replace(In,function(n,a,i){return ne={name:a,styles:i,next:ne},a})}return On[t]!==1&&!vt(t)&&typeof s=="number"&&s!==0?s+"px":s};function $e(e,t,s){if(s==null)return"";var n=s;if(n.__emotion_styles!==void 0)return n;switch(typeof s){case"boolean":return"";case"object":{var a=s;if(a.anim===1)return ne={name:a.name,styles:a.styles,next:ne},a.name;var i=s;if(i.styles!==void 0){var o=i.next;if(o!==void 0)for(;o!==void 0;)ne={name:o.name,styles:o.styles,next:ne},o=o.next;var c=i.styles+";";return c}return Ln(e,t,s)}}var u=s;if(t==null)return u;var f=t[u];return f!==void 0?f:u}function Ln(e,t,s){var n="";if(Array.isArray(s))for(var a=0;a<s.length;a++)n+=$e(e,t,s[a])+";";else for(var i in s){var o=s[i];if(typeof o!="object"){var c=o;t!=null&&t[c]!==void 0?n+=i+"{"+t[c]+"}":st(c)&&(n+=Le(i)+":"+rt(i,c)+";")}else if(Array.isArray(o)&&typeof o[0]=="string"&&(t==null||t[o[0]]===void 0))for(var u=0;u<o.length;u++)st(o[u])&&(n+=Le(i)+":"+rt(i,o[u])+";");else{var f=$e(e,t,o);switch(i){case"animation":case"animationName":{n+=Le(i)+":"+f+";";break}default:n+=i+"{"+f+"}"}}}return n}var at=/label:\s*([^\s;{]+)\s*(;|$)/g,ne;function De(e,t,s){if(e.length===1&&typeof e[0]=="object"&&e[0]!==null&&e[0].styles!==void 0)return e[0];var n=!0,a="";ne=void 0;var i=e[0];if(i==null||i.raw===void 0)n=!1,a+=$e(s,t,i);else{var o=i;a+=o[0]}for(var c=1;c<e.length;c++)if(a+=$e(s,t,e[c]),n){var u=i;a+=u[c]}at.lastIndex=0;for(var f="",d;(d=at.exec(a))!==null;)f+="-"+d[1];var m=Fn(a)+f;return{name:m,styles:a,next:ne}}function Ct(e,t,s){var n="";return s.split(" ").forEach(function(a){e[a]!==void 0?t.push(e[a]+";"):a&&(n+=a+" ")}),n}var Dn=function(t,s,n){var a=t.key+"-"+s.name;t.registered[a]===void 0&&(t.registered[a]=s.styles)},zn=function(t,s,n){Dn(t,s);var a=t.key+"-"+s.name;if(t.inserted[s.name]===void 0){var i=s;do t.insert(s===i?"."+a:"",i,t.sheet,!0),i=i.next;while(i!==void 0)}};function it(e,t){if(e.inserted[t.name]===void 0)return e.insert("",t,e.sheet,!0)}function ct(e,t,s){var n=[],a=Ct(e,n,s);return n.length<2?s:a+t(n)}var Bn=function(t){var s=Mn(t);s.sheet.speedy=function(c){this.isSpeedy=c},s.compat=!0;var n=function(){for(var u=arguments.length,f=new Array(u),d=0;d<u;d++)f[d]=arguments[d];var m=De(f,s.registered,void 0);return zn(s,m),s.key+"-"+m.name},a=function(){for(var u=arguments.length,f=new Array(u),d=0;d<u;d++)f[d]=arguments[d];var m=De(f,s.registered),x="animation-"+m.name;return it(s,{name:m.name,styles:"@keyframes "+x+"{"+m.styles+"}"}),x},i=function(){for(var u=arguments.length,f=new Array(u),d=0;d<u;d++)f[d]=arguments[d];var m=De(f,s.registered);it(s,m)},o=function(){for(var u=arguments.length,f=new Array(u),d=0;d<u;d++)f[d]=arguments[d];return ct(s.registered,n,_n(f))};return{css:n,cx:o,injectGlobal:i,keyframes:a,hydrate:function(u){u.forEach(function(f){s.inserted[f]=!0})},flush:function(){s.registered={},s.inserted={},s.sheet.flush()},sheet:s.sheet,cache:s,getRegisteredStyles:Ct.bind(null,s.registered),merge:ct.bind(null,s.registered,n)}},_n=function e(t){for(var s="",n=0;n<t.length;n++){var a=t[n];if(a!=null){var i=void 0;switch(typeof a){case"boolean":break;case"object":{if(Array.isArray(a))i=e(a);else{i="";for(var o in a)a[o]&&o&&(i&&(i+=" "),i+=o)}break}default:i=a}i&&(s&&(s+=" "),s+=i)}}return s},Wn=Bn({key:"css"}),Vn=Wn.css;const wt=l.forwardRef(function(e,t){const{state:s,value:n,onChange:a,options:i=[],name:o="",id:c="",label:u="",containerClassName:f="",inputContainerClassName:d="",helperText:m="",placeholder:x="",multiple:h=!1,...g}=e,[j,E]=l.useState("");l.useEffect(()=>{if(!h&&n&&!Array.isArray(n)){E(String(n.value??n.name??""));return}E("")},[h,n]);const[b,v]=l.useState(!1),S=i.filter(w=>{const M=String(w.value??w.name).toLowerCase().includes(j?.toLowerCase());return Array.isArray(n)&&n.length?!n.some(U=>U.id===w.id):n&&!Array.isArray(n)?n.id!==w.id:M}),F=l.useRef(null),A=l.useRef(null),[T,N]=l.useState(!1),K=l.useRef(null);l.useEffect(()=>{const w=U=>{F.current&&!F.current.contains(U.target)&&v(!1)},M=U=>{U.key==="Escape"&&v(!1)};return document.addEventListener("mousedown",w),document.addEventListener("keydown",M),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",M)}},[]);const xe=w=>{E(w.target.value)},ae=l.useCallback(w=>{w?h?(E(""),Array.isArray(n)&&n.length?a([...n,w]):a([w])):(E(String(w.name??w.value??"")),a(w)):a(null),v(!1)},[h,a,n]),ee=l.useCallback(w=>{if(!Array.isArray(n)){a(null);return}if(w!=null)if(w!==-1){const M=n.filter((U,be)=>be!==w);M.length?a(M):a(null)}else{const[M]=n;a([M])}else a(null)},[a,n]);return l.useEffect(()=>{const w=K.current?.offsetWidth??0,M=(t??A)?.current?.offsetWidth??0;w>M*.4?N(!0):N(!1)},[n]),r.jsxs("div",{className:`autocomplete-input-container ${f}`,ref:F,children:[r.jsxs("div",{className:"autocomplete-value-input-container",children:[r.jsx(we,{state:s,name:o,id:c,value:j,onChange:xe,placeholder:x,helperText:m,onFocus:()=>v(!0),label:u,containerClassName:`autocomplete-text-input ${d}`,ref:t??A,...g,children:!h&&n&&!Array.isArray(n)&&(n.value||n.name)&&r.jsx(re,{icon:r.jsx(Pe,{}),className:"autocomplete-delete-button",onClick:w=>{ae(),w.stopPropagation()}})}),h&&Array.isArray(n)&&n.length?r.jsx("ul",{ref:K,className:"autocomplete-value-container",children:T?r.jsxs(r.Fragment,{children:[r.jsx("li",{children:r.jsx(se,{text:n[0]?.value??n[0]?.name,onDelete:w=>{ee(0),w.stopPropagation()}})}),n.length>1&&r.jsx("li",{children:r.jsx(se,{text:`+${n.length-1}`,onDelete:w=>{ee(-1),w.stopPropagation()}})})]}):n.map((w,M)=>r.jsx("li",{children:r.jsx(se,{text:String(w.value??w.name),onDelete:U=>{ee(M),U.stopPropagation()}})},w.id??w.value??w.name))}):null]}),b&&r.jsx("ul",{className:`autocomplete-suggestions-container ${Vn({width:F.current?.offsetWidth})}`,children:S.map(w=>r.jsx("li",{className:"autocomplete-suggestion-item",onClick:M=>{ae(w),M.stopPropagation()},children:w.value??w.name},w.id??w.value??w.name))})]})}),jt=l.forwardRef(function(e,t){const{checked:s,onChange:n,name:a="",id:i="",label:o="",containerClassName:c="",inputClassName:u="",labelClassName:f="",...d}=e;return r.jsxs("label",{className:`input-check-container ${c}`,children:[r.jsx("input",{id:i,ref:t,name:a,type:"checkbox",checked:s,onChange:n,className:`input-check ${u}`,...d}),r.jsx("span",{className:`input-check-label ${f}`,children:o})]})});function lt(e,t=25){if(e.length<=t)return e;const s=e.lastIndexOf(".");if(s===-1)return e.slice(0,t-3)+"...";const n=e.slice(0,s),a=e.slice(s),i=t-a.length-3;return n.slice(0,i)+"..."+a}const Un=l.forwardRef(function(e,t){const{children:s,label:n,containerClassName:a="",inputClassName:i="",labelClassName:o="",helperText:c="",helperTextClassName:u="",iconClassName:f="",multiple:d=!1,onChange:m,onClear:x,...h}=e,[g,j]=l.useState([]),E=v=>{if(v.target.files){const S=Array.from(v.target.files);j(F=>[...F,...S])}m&&m(v)},b=v=>{j(S=>{const F=S.filter((A,T)=>T!==v);return F.length===0&&x?.(),F})};return r.jsxs("div",{className:`file-input-container ${a}`,children:[g.length===0&&r.jsxs("label",{htmlFor:h.name,className:`${o}`,children:[n,r.jsx("input",{type:"file",ref:t,multiple:d,onClick:v=>{v.currentTarget.value=""},onChange:E,className:`file-input ${i}`,...h}),h.required?" *":""]}),g.length>1&&r.jsx("ul",{className:"file-preview-list",children:g.map((v,S)=>r.jsx("li",{children:r.jsx("span",{"data-tooltip-id":"tooltip","data-tooltip-content":v.name,children:r.jsx(se,{text:lt(v.name,25),onDelete:()=>b(S)})})},S))}),g.length===1&&r.jsxs("div",{className:"file-preview",children:[r.jsx(Et,{className:`file-icon ${f}`}),r.jsx("span",{className:"!cursor-default","data-tooltip-id":"tooltip","data-tooltip-content":g[0]?.name??"",children:lt(g[0]?.name??"",25)}),r.jsx("button",{onClick:()=>{j([]),x?.()},className:"chip-delete-button",type:"button",children:r.jsx(Pe,{})})]}),s,!!c&&r.jsx("p",{className:`file-input-helper-text ${u}`,children:c})]})});var Fe=(e=>(e.error="error",e.good="good",e.default="default",e))(Fe||{});const Ge=e=>{switch(e){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},He=e=>{switch(e){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},Ke=e=>{switch(e){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}},Oe=l.forwardRef(function(e,t){const{value:s,onChange:n,options:a,containerClassName:i="",inputClassName:o="",labelClassName:c="",helperText:u="",helperTextClassName:f="",placeholder:d="",label:m="",name:x="",id:h="",state:g=Fe.default,children:j,...E}=e;return r.jsxs("div",{className:`select-input-container ${i}`,children:[r.jsx("select",{...E,id:h,ref:t,name:x,value:s,onChange:n,className:`select-input ${Ge(g)} peer ${o}`,children:a?.map(b=>r.jsx("option",{value:b.id,children:b.value??b.name??b.id},b.id))}),r.jsx("label",{htmlFor:x,className:`select-input-label ${He(g)} ${c}`,children:m}),j,(d||u)&&r.jsx("p",{className:`select-input-helper-text ${Ke(g)} ${f}`,children:g!=="error"&&g!=="good"?d:u})]})}),we=l.forwardRef(function(e,t){const{children:s,state:n=Fe.default,label:a="",containerClassName:i="",inputClassName:o="",labelClassName:c="",helperText:u="",helperTextClassName:f="",value:d="",...m}=e;return r.jsxs("div",{className:`text-input-container ${i}`,children:[r.jsx("input",{ref:t,value:d,className:`text-input ${Ge(n)} peer ${o} ${d?"has-value":""} ${m.placeholder?"has-placeholder":""}`,...m}),!!a&&r.jsxs("label",{htmlFor:m.name,className:`text-input-label ${He(n)} ${c}`,children:[a,m.required?" *":""]}),s,!!u&&r.jsx("p",{className:`text-input-helper-text ${Ke(n)} ${f}`,children:u})]})}),re=e=>{const{children:t,icon:s,type:n="button",className:a="",variant:i="text",color:o="default",iconClassName:c="",...u}=e;return r.jsxs("button",{type:n,className:`icon-button ${a} ${i} ${o}`,...u,children:[r.jsx("span",{className:c,children:s}),t]})};function Nt(e){const{color:t="stroke-blue-800",className:s="",loaderClass:n="",strokeWidth:a="4",...i}=e;return r.jsx("div",{...i,className:`loading ${s}`,children:r.jsx("div",{className:"loader-container",children:r.jsx("div",{className:`loader ${n}`,children:r.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:r.jsx("circle",{className:`path ${t}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:a,strokeMiterlimit:"10"})})})})})}function yt(e){const{className:t=""}=e;return r.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:r.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})})}function St(e){const{className:t=""}=e;return r.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:r.jsx("path",{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"})})}function Rt(e){const{className:t=""}=e;return r.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:r.jsx("path",{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"})})}function kt(e){const{className:t=""}=e;return r.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:r.jsx("path",{d:"M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"})})}function Pe(e){const{className:t=""}=e;return r.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor",children:r.jsx("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})})}function Et(e){const{className:t=""}=e;return r.jsx("svg",{className:t,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",children:r.jsx("path",{d:"M192 64C156.7 64 128 92.7 128 128L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 234.5C512 217.5 505.3 201.2 493.3 189.2L386.7 82.7C374.7 70.7 358.5 64 341.5 64L192 64zM453.5 240L360 240C346.7 240 336 229.3 336 216L336 122.5L453.5 240z"})})}const $t=e=>{const{className:t=""}=e;return r.jsx("svg",{className:t,viewBox:"0 0 16 16",children:r.jsx("path",{d:"M9 15H7a1 1 0 010-2h2a1 1 0 010 2zM11 11H5a1 1 0 010-2h6a1 1 0 010 2zM13 7H3a1 1 0 010-2h10a1 1 0 010 2zM15 3H1a1 1 0 010-2h14a1 1 0 010 2z"})})};var te=(e=>(e[e.text=0]="text",e[e.number=1]="number",e[e.select=2]="select",e[e.autocomplete=3]="autocomplete",e[e.date=4]="date",e[e.check=5]="check",e))(te||{}),ce=(e=>(e.ASC="ASC",e.DESC="DESC",e))(ce||{}),W=(e=>(e[e.update=0]="update",e[e.reset=1]="reset",e))(W||{});const We=e=>{if(e){const t={};return Object.keys(e)?.forEach(n=>{t[n]={value:e[n]}}),t}return{}};function At(e,t){const{type:s}=t;switch(s){case W.reset:return{};case W.update:{const{toUpdate:n}=t;return{...e,...n}}default:return e}}const Tt=l.createContext({}),Mt=e=>{const{children:t}=e,{filters:s}=Q(),[n,a]=l.useReducer(At,We(s));l.useEffect(()=>{a({type:W.reset});const o=We(s);Object.keys(o).length&&a({type:W.update,toUpdate:o})},[s]);const i={currentFilters:n,setCurrentFilters:a};return r.jsx(Tt.Provider,{value:i,children:t})},le=()=>{const e=l.useContext(Tt);if(e===void 0)throw new Error("tableOptionsContext must be used within a Provider");return e},qn=[20,50,100],Ft=l.createContext({}),Gn=e=>{const{children:t}=e,[s,n]=l.useState(0),[a,i]=l.useState(20),[o,c]=l.useState(0),[u,f]=l.useState("id"),[d,m]=l.useState(ce.DESC),[x,h]=l.useState({}),g=l.useCallback((S,F)=>{let A=d;u===S&&(d===ce.ASC?A=ce.DESC:A=ce.ASC),f(S),m(A),F&&F(S,A)},[u,d]),j=l.useCallback(S=>{const F=Object.entries(S).reduce((A,[T,N])=>(N&&typeof N.value<"u"&&N.value!==null&&(A[T]=N.value),A),{});h(F)},[]),E=l.useCallback(S=>{S?(delete x[S.toLowerCase()],h({...x})):h({})},[x]),b=l.useMemo(()=>Object.keys(x).length,[x]),v={onSort:g,total:s,setTotal:n,sortingBy:u,setSortingBy:f,sortingOrder:d,setSortingOrder:m,pageSize:a,pageSizes:qn,setPageSize:i,currentPage:o,setCurrentPage:c,filters:x,onFilterApply:j,clearFilters:E,countOfFilters:b};return r.jsx(Ft.Provider,{value:v,children:t})},Q=()=>{const e=l.useContext(Ft);if(e===void 0)throw new Error("tableOptionsContext must be used within a Provider");return e},Ot=l.createContext({});function Hn(e){const{children:t,t:s,language:n}=e;return r.jsx(Ot.Provider,{value:{t:s,language:n},children:t})}const V=()=>{const e=l.useContext(Ot);if(e===void 0)throw new Error("translationContext must be used within a Provider");return e};function Pt(e){const{t}=V(),{entity:s="",columns:n=[],hasAction:a=!0,onSortCallback:i,selectionState:o,onToggleAllRows:c}=e,u=l.useRef(null);l.useEffect(()=>{u.current&&(u.current.indeterminate=!!(o?.hasSomeSelected&&!o?.allSelected))},[o]);const{onSort:f,sortingOrder:d,sortingBy:m}=Q(),x=l.useMemo(()=>n.sort((h,g)=>(g.pos??0)-(h.pos??0)).filter(h=>h.display!=="none")?.map(h=>({id:h.key,label:h.label,className:h.className??"",sortable:h.sortable??!0,sortOptions:h.sortOptions})),[n,s,t]);return r.jsx("thead",{className:"table-headers-row",children:r.jsxs("tr",{children:[r.jsx("th",{scope:"col",className:"table-headers-column table-headers-checkbox",children:c?r.jsx("input",{type:"checkbox",ref:u,checked:o?.allSelected??!1,onChange:c,"aria-label":t("_accessibility:components.table.selectAllRows")}):null}),x.map(h=>r.jsx("th",{scope:"col",className:`table-headers-column ${h.className}`,children:r.jsxs(dt,{disabled:!h.sortable,onClick:()=>f(h.id,i),className:"table-headers-cell",children:[r.jsx("span",{className:"table-headers-label",children:h.label}),h.sortable&&m===h.id&&r.jsx("span",{children:d===ce.ASC?h.sortOptions?.icons?.asc??r.jsx(kt,{className:h.sortOptions?.icons?.className??"table-headers-sort-indicator"}):h.sortOptions?.icons?.desc??r.jsx(yt,{className:h.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},h.id)),a&&r.jsx("th",{scope:"col",className:"table-headers-action",children:r.jsx("span",{className:"button text default disabled",children:t("_accessibility:labels.actions")})})]})})}const It=e=>{const{items:t,text:s,id:n,onClearFilter:a}=e;return r.jsx(se,{text:`${s}: ${t.map(i=>i.value??i.name).join(", ")}`,onDelete:()=>a(n)})},Lt=e=>{const{end:t,start:s,text:n,id:a,onClearFilter:i}=e;return r.jsx(se,{text:`${n}: ${s||"♾️"} - ${t||"♾️"}`,onDelete:()=>i(a)})},Dt=e=>{const{filtersDefinition:t}=e,s=l.useMemo(()=>{const c={};return t.forEach(u=>{c[u.propertyName]=u.label??u.propertyName}),c},[t]),{filters:n,clearFilters:a}=Q(),i=l.useMemo(()=>Object.keys(n),[n]),o=l.useCallback(c=>n[c]?.end||n[c]?.start?r.jsx(Lt,{id:c,text:s[c],start:n[c].start,end:n[c].end,onClearFilter:a}):Array.isArray(n[c])?r.jsx(It,{id:c,text:s[c],items:n[c],onClearFilter:a}):r.jsx(se,{text:`${s[c]}: ${n[c]?.value??n[c]?.name??n[c]}`,onDelete:()=>a(c)}),[n,s]);return r.jsx("ul",{className:"active-filters-main",children:i?.map(c=>r.jsx("li",{children:o(c)},c))})};function Kn(e){const{propertyName:t,label:s,placeholder:n,options:a,multiple:i=!0}=e,{currentFilters:o,setCurrentFilters:c}=le(),u=l.useMemo(()=>o[t]??a[0],[o]),f=l.useCallback(d=>{c({type:W.update,toUpdate:{[t]:{value:d}}})},[i]);return r.jsx(wt,{value:u?.value,label:s,options:a,multiple:i,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:f,placeholder:n})}const Yn=e=>{const{propertyName:t,label:s}=e,{currentFilters:n,setCurrentFilters:a}=le(),i=l.useMemo(()=>n[t]?.value??"",[n]),o=l.useCallback(c=>{a({type:W.update,toUpdate:{[t]:{value:c.target.checked}}})},[]);return r.jsx(jt,{label:s,checked:i??!1,onChange:o})};function Zn(e){const{propertyName:t,options:s,label:n,placeholder:a}=e,{currentFilters:i,setCurrentFilters:o}=le(),c=l.useMemo(()=>i[t]?.value??s[0],[i]),u=l.useCallback(f=>{o({type:W.update,toUpdate:{[t]:{value:f.target.value}}})},[]);return r.jsx(Oe,{value:c,label:n,options:s,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u,placeholder:a})}const Jn=e=>{const{propertyName:t,label:s,placeholder:n}=e,{currentFilters:a,setCurrentFilters:i}=le(),o=l.useMemo(()=>a[t]?.value??"",[a]),c=l.useCallback(u=>{i({type:W.update,toUpdate:{[t]:{value:u.target.value}}})},[]);return r.jsx(we,{value:o??"",label:s,onChange:c,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:n})},ot=e=>{const{propertyName:t,label:s,inputType:n}=e,{t:a}=V(),{currentFilters:i,setCurrentFilters:o}=le(),c=l.useRef(null),u=l.useRef(null),f=l.useCallback(m=>{o({type:W.update,toUpdate:{[t]:{value:{end:u?.current?.value??null,start:m.target.value}}}})},[]),d=l.useCallback(m=>{o({type:W.update,toUpdate:{[t]:{value:{start:c?.current?.value??null,end:m.target.value}}}})},[]);return r.jsxs("div",{className:"range-widget-container",children:[r.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:s}),r.jsxs("div",{className:"range-widget-row",children:[r.jsx(we,{value:i[t]?.value?.start??"",placeholder:a("_accessibility:components.table.filters.range.start"),type:n,ref:c,onChange:f,containerClassName:"input-widget-container",helperTextClassName:""}),r.jsx(we,{value:i[t]?.value?.end??"",placeholder:a("_accessibility:components.table.filters.range.end"),type:n,ref:u,onChange:d,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},zt=e=>{switch(e.type){case te.text:return r.jsx(Jn,{...e});case te.number:return r.jsx(ot,{...e,inputType:"number"});case te.date:return r.jsx(ot,{...e,inputType:"date"});case te.select:return r.jsx(Zn,{...e});case te.autocomplete:return r.jsx(Kn,{...e});case te.check:return r.jsx(Yn,{...e})}return r.jsx(r.Fragment,{})},Bt=e=>{const{filters:t=[],show:s,handleShow:n}=e,{onFilterApply:a}=Q(),{currentFilters:i,setCurrentFilters:o}=le(),{t:c}=V(),u=l.useRef(null);return l.useEffect(()=>{const f=({target:d})=>{u.current&&(d?.closest(".filter-dropdown-trigger")||!s||u.current?.contains(d)||n(!1))};return document.addEventListener("click",f),()=>document.removeEventListener("click",f)},[n,s]),l.useEffect(()=>{const f=d=>{!s||d.code!=="Escape"||n(!1)};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[n,s]),r.jsx("div",{className:`filter-dropdown-backdrop ${s?"opened":"closed"}`,children:r.jsxs("div",{className:"filter-popup",ref:u,children:[r.jsx("div",{className:"filter-title",children:c("_accessibility:buttons.filters")}),r.jsx("ul",{className:"filter-container",children:t.map(f=>r.jsx("li",{className:"filter-container-item",children:zt(f)},f.propertyName))}),r.jsx("div",{className:"filter-footer",children:r.jsxs("ul",{className:"filter-buttons-row",children:[r.jsx("li",{children:r.jsx("button",{onClick:()=>o({type:W.reset,filters:t}),className:"filter-dropdown-button small filter-dropdown-cancel",children:c("_accessibility:buttons.clear")})}),r.jsx("li",{children:r.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit",onClick:()=>{n(!1),a(i)},onBlur:()=>n(!1),children:c("_accessibility:buttons.applyFilters")})})]})})]})})},_t=()=>{const{t:e}=V(),{total:t,pageSize:s,pageSizes:n,currentPage:a}=Q(),i=(a+1)*s>t?t:(a+1)*s;return r.jsxs("div",{className:"table-navigation-sizes",children:[n[0]<t&&r.jsx(r.Fragment,{children:r.jsxs("p",{children:[a*s+1," - ",i," ",e("_accessibility:components.table.of")]})}),r.jsx("p",{children:t})]})};function Xn(){const{t:e}=V(),{total:t,pageSize:s,currentPage:n,setCurrentPage:a}=Q(),i=l.useMemo(()=>{const o=Math.ceil(t/s);return Array.from({length:o},(c,u)=>({id:u,value:u+1}))},[t,s]);return r.jsxs("div",{className:"jump-to-page",children:[r.jsx("p",{children:e("_accessibility:components.table.jumpToPage")}),r.jsx(Oe,{value:n,options:i,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:o=>a(Number(o.target.value))})]})}const Wt=()=>{const{t:e}=V(),{total:t,pageSize:s,currentPage:n,setCurrentPage:a}=Q();return r.jsxs("div",{className:"table-navigation-pages",children:[r.jsx(re,{icon:r.jsx(St,{className:"w-2.5"}),className:"table-navigation-buttons",disabled:n===0,"aria-label":e("_accessibility:buttons.previous"),name:e("_accessibility:buttons.previous"),onClick:()=>a(n-1)}),r.jsx(re,{icon:r.jsx(Rt,{className:"w-2.5"}),disabled:Math.floor(t/((n+1)*s))===0,className:"table-navigation-buttons",name:e("_accessibility:buttons.next"),"aria-label":e("_accessibility:buttons.next"),onClick:()=>a(n+1)})]})};function Vt(){const{t:e}=V(),{pageSizes:t,pageSize:s,setPageSize:n}=Q(),a=l.useMemo(()=>t?.map(i=>({id:i,value:i})),[t]);return r.jsxs("div",{className:"page-size",children:[r.jsx("p",{children:e("_accessibility:components.table.pageSizes")}),r.jsx(Oe,{value:s,options:a,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:i=>n(Number(i.target.value))})]})}function Ut(){return r.jsxs("div",{className:"table-footer",children:[r.jsx(Xn,{}),r.jsx(Vt,{}),r.jsx(_t,{}),r.jsx(Wt,{})]})}const Qn=e=>e,qt=e=>{const{t}=V(),{columns:s,softDeleteProperty:n="deletedAt",data:a,actions:i,selectedRows:o,expandedRows:c=[],onRowSelectionChange:u,onRowExpand:f}=e,d=l.useMemo(()=>s.sort((x,h)=>(h.pos??0)-(x.pos??0)).filter(x=>x.display!=="none"),[s]),m=l.useMemo(()=>new Map(c.map(x=>[x.rowId,x])),[c]);return a?.map(x=>{const h=o.has(x.id),g=m.get(x.id),j=!!g,E=d.length+1+(i?1:0);return r.jsxs(l.Fragment,{children:[r.jsxs("tr",{className:`table-row ${f?"expandable":""} ${x[n]?"deleted-class":""} ${h?"selected":""} ${j?"expanded":""}`,onClick:()=>f?.(x),children:[r.jsx("td",{className:"table-row-cell table-row-checkbox",children:r.jsx("input",{type:"checkbox",checked:h,onClick:b=>b.stopPropagation(),onChange:()=>u(x),"aria-label":t("_accessibility:components.table.selectRow")})}),d?.map((b,v)=>r.jsx("td",{className:`table-row-cell ${v===0?"basic":""} ${b.className??""}`,children:b.renderBody?b.renderBody(x[b.key],x):Qn(x[b.key])},b.key)),i?r.jsx("td",{children:r.jsx("div",{className:"table-row-cell-action",children:i(x).filter(b=>!b.hidden)?.map(b=>r.jsx(Ye,{content:b.tooltip,children:r.jsx(re,{icon:b.icon,className:"row-table-action",onClick:v=>{v.stopPropagation(),b.onClick(x)}})},b.id))})}):null]}),j&&g?.content!==null&&typeof g?.content<"u"&&r.jsx("tr",{className:"table-row-expanded",children:r.jsx("td",{className:"table-row-expanded-cell",colSpan:E,children:r.jsx("div",{className:`table-row-expanded-content ${g.isVisible?"open":"closed"}`,children:r.jsx("div",{className:"table-row-expanded-inner",children:g.content})})})})]},x.id)})};function Gt(){const{t:e}=V();return r.jsx("div",{className:"table-empty",children:r.jsx("p",{children:e("_accessibility:components.table.empty")})})}const Ht=e=>{const{columns:t,title:s,isLoading:n,toolbar:a,filterOptions:i}=e,{countOfFilters:o}=Q(),{t:c}=V(),u=l.useMemo(()=>t?t.sort((h,g)=>(g.pos??0)-(h.pos??0)).filter(h=>!!h.filterOptions).map(h=>({...h.filterOptions,label:h.filterOptions?.label??h.label,propertyName:h.key})):[],[t]),[f,d]=l.useState(!1),m=l.useCallback(h=>{i?.dropdown?.setOpened?i.dropdown.setOpened(h??!1):d(h??!1)},[i]),x=l.useMemo(()=>i?.dropdown?.opened??f,[i,f]);return r.jsxs("div",{className:`table-header ${x?"showing-filters":""}`,children:[r.jsxs("div",{children:[s&&r.jsx("h1",{className:"table-header-title",children:s}),n?null:r.jsxs("div",{className:"table-header-content",children:[a,i?.button?.hide!==!0&&r.jsxs(re,{icon:i?.button?.icon??r.jsx($t,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>m(!x),"aria-expanded":x,children:[r.jsx(ut,{count:o,className:`${o>0?"show":"hide"} `}),r.jsx("span",{className:"sr-only",children:c("_accessibility:buttons.filters")}),r.jsx("wbr",{})]})]})]}),!!u&&!!u.length&&r.jsx(Bt,{filters:u,show:x,handleShow:m,options:i}),r.jsx(Dt,{filtersDefinition:u})]})},ze=220;function es(e){const{data:t,onSort:s,entity:n="",isLoading:a=!1,actions:i,columns:o=[],contentClassName:c="",className:u="",softDeleteProperty:f="deletedAt",onRowSelect:d,onSelectedRowsChange:m,allowMultipleExpandedRows:x=!1,expandedRowId:h,onExpandedRowChange:g,onRowExpand:j,...E}=e,{t:b}=V(),[v,S]=l.useState(new Set),[F,A]=l.useState(null),[T,N]=l.useState(null),[K,xe]=l.useState(null),[ae,ee]=l.useState(null),[w,M]=l.useState(!1),[U,be]=l.useState(new Set),[Ze,oe]=l.useState([]),ue=l.useRef(null),ie=l.useRef(null),de=l.useRef(new Map),Y=typeof h<"u",Z=x&&!Y,z=Y?h??null:F,Kt=l.useMemo(()=>!t?.length,[t]),q=l.useMemo(()=>t?.filter(p=>v.has(p.id))??[],[t,v]),fe=l.useCallback(p=>p===null?null:t.find(C=>C.id===p)??null,[t]),Ne=l.useCallback(()=>{ie.current&&(clearTimeout(ie.current),ie.current=null)},[]),G=l.useCallback(p=>{if(typeof p<"u"){const C=de.current.get(p);if(!C)return;clearTimeout(C),de.current.delete(p);return}de.current.forEach(C=>clearTimeout(C)),de.current.clear()},[]),Je=l.useCallback(p=>{G(p),oe(C=>C.some($=>$.rowId===p)?C.map($=>$.rowId===p?{...$,isVisible:!1}:$):C),de.current.set(p,setTimeout(()=>{oe(C=>C.filter(y=>y.rowId!==p)),de.current.delete(p)},ze))},[G]),Xe=l.useCallback((p,C)=>{G(p),oe(y=>y.some(P=>P.rowId===p)?y.map(P=>P.rowId===p?{...P,content:C,isVisible:!1}:P):[...y,{rowId:p,content:C,isVisible:!1}]),requestAnimationFrame(()=>{oe(y=>y.map($=>$.rowId===p?{...$,isVisible:!0}:$))})},[G]);l.useEffect(()=>{if(!t?.length){S(new Set);return}S(p=>{const C=new Set,y=new Set(t.map($=>$.id));return p.forEach($=>{y.has($)&&C.add($)}),C})},[t]),l.useEffect(()=>{if(!Z)return;const p=new Set(t.map(C=>C.id));be(C=>{const y=new Set;return C.forEach($=>{if(p.has($)){y.add($);return}G($)}),y}),oe(C=>(C.forEach(y=>{p.has(y.rowId)||G(y.rowId)}),C.filter(y=>p.has(y.rowId))))},[t,Z,G]),l.useEffect(()=>{if(Z)return;if(z===null){N(null),Y&&(ue.current=null);return}fe(z)||(Y||A(null),N(null),Y&&(ue.current=null))},[t,z,fe,Y,Z]),l.useEffect(()=>{if(!Z){if(Ne(),z===null||T===null){if(K===null){M(!1),ee(null);return}M(!1),ie.current=setTimeout(()=>{xe(null),ee(null),ie.current=null},ze);return}if(K===null){xe(z),ee(T),requestAnimationFrame(()=>M(!0));return}if(K===z){ee(T),requestAnimationFrame(()=>M(!0));return}M(!1),ie.current=setTimeout(()=>{xe(z),ee(T),requestAnimationFrame(()=>M(!0)),ie.current=null},ze)}},[Ne,T,z,Z,K]),l.useEffect(()=>()=>{Ne(),G()},[Ne,G]),l.useEffect(()=>{if(!Y)return;if(z===null){N(null),ue.current=null;return}const p=fe(z);if(!p){N(null),ue.current=null;return}const C=ue.current;N(j?.(p,C)??null),ue.current=p},[z,fe,Y,j]);const Yt=l.useCallback(p=>{S(C=>{const y=new Set(C);return y.has(p.id)?(y.delete(p.id),d?.(p,!1)):(y.add(p.id),d?.(p,!0)),y})},[d]),Zt=l.useCallback(p=>{if(Z){if(U.has(p.id)){be(I=>{const H=new Set(I);return H.delete(p.id),H}),Je(p.id),g?.(null,p);return}be(I=>{const H=new Set(I);return H.add(p.id),H});const P=j?.(p,null)??null;P!==null&&typeof P<"u"?Xe(p.id,P):(G(p.id),oe(I=>I.filter(H=>H.rowId!==p.id))),g?.(p,null);return}const C=z===p.id,y=C?p:fe(z);if(Y){g?.(C?null:p,y);return}if(C){A(null),N(null),g?.(null,p);return}A(p.id),N(j?.(p,y)??null),g?.(p,y)},[z,Je,G,Xe,fe,U,Y,Z,g,j]),Jt=l.useCallback(()=>{S(p=>{const C=new Set(p),y=t??[],$=y.every(P=>C.has(P.id));return y.forEach(P=>{const I=C.has(P.id);$?I&&(C.delete(P.id),d?.(P,!1)):I||(C.add(P.id),d?.(P,!0))}),C})},[t,d]),Xt=l.useMemo(()=>{if(!t?.length)return{allSelected:!1,hasSomeSelected:!1};const p=t.every(y=>v.has(y.id)),C=t.some(y=>v.has(y.id));return{allSelected:p,hasSomeSelected:C}},[t,v]);l.useEffect(()=>{m&&m(q)},[q,m]);const Qe=l.useMemo(()=>!i||!q.length?[]:q.reduce((p,C,y)=>{const $=i(C).filter(I=>I.multiple&&!I.hidden);if(y===0)return $;const P=new Map(p.map(I=>[I.id,I]));return $.reduce((I,H)=>{const Ie=P.get(H.id);return Ie&&I.push({...Ie,...H,disabled:H.disabled||Ie.disabled}),I},[])},[]),[i,q]),Qt=l.useCallback(p=>{if(q.length){if(p.onMultipleClick){p.onMultipleClick(q);return}q.forEach(C=>p.onClick(C))}},[q]),en=l.useMemo(()=>Z?Ze:K===null||ae===null||typeof ae>"u"?[]:[{rowId:K,content:ae,isVisible:w}],[w,Z,ae,K,Ze]);return r.jsx(Mt,{children:r.jsxs("div",{className:`${u} table-main`,children:[r.jsx(Ht,{columns:o,isLoading:a,...E}),a?r.jsx(Nt,{className:"table-loading"}):r.jsx(r.Fragment,{children:Kt?r.jsx(Gt,{}):r.jsxs(r.Fragment,{children:[!!q.length&&r.jsxs("div",{className:"table-selection-bar",children:[r.jsx("p",{className:"table-selection-bar-count",children:b("_accessibility:components.table.selectedCount",{count:q.length})}),Qe.length>0&&r.jsx("div",{className:"table-selection-bar-actions",children:Qe.map(p=>r.jsx(Ye,{content:p.tooltip,children:r.jsx(re,{icon:p.icon,className:"multi-table-action",onClick:()=>Qt(p),disabled:p.disabled})},p.id))})]}),r.jsx("div",{className:`${c} table-body`,children:r.jsxs("table",{className:"table-content",children:[r.jsx(Pt,{entity:n,columns:o,onSortCallback:s,hasAction:!!i,selectionState:Xt,onToggleAllRows:Jt}),r.jsx("tbody",{children:r.jsx(qt,{data:t,actions:i,columns:o,softDeleteProperty:f,selectedRows:v,expandedRows:en,onRowSelectionChange:Yt,onRowExpand:j?Zt:void 0})})]})}),r.jsx(Ut,{})]})})]})})}function Ye(e){const{content:t,children:s,className:n=""}=e;return r.jsxs("div",{className:`tooltip-container ${n}`,children:[s,r.jsx("div",{className:"tooltip-text",children:t})]})}exports.ActiveFilters=Dt;exports.ArrayChip=It;exports.AutocompleteInput=wt;exports.Badge=ut;exports.Button=dt;exports.CheckInput=jt;exports.ChevronDown=yt;exports.ChevronLeft=St;exports.ChevronRight=Rt;exports.ChevronUp=kt;exports.Chip=se;exports.Close=Pe;exports.Columns=Pt;exports.CountOfTotal=_t;exports.Dropdown=tn;exports.File=Et;exports.FileInput=Un;exports.FilterDropdown=Bt;exports.FilterTypes=te;exports.Filters=$t;exports.FiltersActions=W;exports.FiltersProvider=Mt;exports.Footer=Ut;exports.IconButton=re;exports.Loading=Nt;exports.Navigation=Wt;exports.PageSize=Vt;exports.RangeChip=Lt;exports.Rows=qt;exports.SelectInput=Oe;exports.SortOrder=ce;exports.State=Fe;exports.Table=es;exports.TableEmpty=Gt;exports.TableHeader=Ht;exports.TableOptionsProvider=Gn;exports.TextInput=we;exports.Tooltip=Ye;exports.TranslationProvider=Hn;exports.filtersReducer=At;exports.helperTextStateClassName=Ke;exports.initializer=We;exports.inputStateClassName=Ge;exports.labelStateClassName=He;exports.renderFilterComponent=zt;exports.useFilters=le;exports.useTableOptions=Q;exports.useTranslation=V;
1
+ var Ze=require("./main.css");Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),oe=t=>{const{count:s,className:r=""}=t;return e.jsx("span",{className:`${r} badge-main`,children:s})},ie=t=>{const{children:s,type:r="button",variant:n="text",color:l="default",className:o="",...p}=t;return e.jsx("button",{type:r,className:`button ${n} ${l} ${o}`,...p,children:s})};function W(t){const{text:s,onDelete:r,children:n,icon:l,variant:o="default",iconClassName:p="",className:i="",textClassName:u=""}=t;return e.jsxs("div",{className:`chip-main ${o} ${r?"deletable":""} ${i}`,children:[e.jsx("span",{className:u,children:s}),n,r?e.jsx(B,{icon:l??e.jsx(Z,{}),className:`chip-delete-button ${p}`,onClick:r}):null]})}const Ie=t=>{const{children:s,open:r,onClose:n}=t,l=a.useRef(null),o=a.useCallback(i=>{const u=l.current;!r||!u||u.contains(i.target)||n()},[r,n]),p=a.useCallback(i=>{r&&i.key==="Escape"&&n()},[r,n]);return a.useEffect(()=>{if(r)return setTimeout(()=>l.current?.focus(),0),document.addEventListener("mousedown",o),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",p)}},[r,o,p]),e.jsx("div",{ref:l,role:"menu","aria-hidden":!r,tabIndex:-1,className:`dropdown-main ${r?"opened":"closed"}`,onClick:i=>i.stopPropagation(),children:s})},ce=a.forwardRef(function(t,s){const{state:r,value:n,onChange:l,options:o=[],name:p="",id:i="",label:u="",containerClassName:d="",inputContainerClassName:h="",helperText:m="",placeholder:x="",multiple:c=!1,...j}=t,[w,S]=a.useState("");a.useEffect(()=>{if(!c&&n&&!Array.isArray(n)){S(String(n.value??n.name??""));return}S("")},[c,n]);const[g,$]=a.useState(!1),y=a.useMemo(()=>o.filter(b=>{const F=String(b.value??b.name).toLowerCase().includes(w?.toLowerCase());return Array.isArray(n)&&n.length?F&&!n.some(D=>D.id===b.id):n&&!Array.isArray(n)?F&&n.id!==b.id:F}),[o,n,w]),C=a.useRef(null),N=a.useRef(null),[T,k]=a.useState(!1),A=a.useRef(null);a.useEffect(()=>{const b=D=>{C.current&&!C.current.contains(D.target)&&$(!1)},F=D=>{D.key==="Escape"&&$(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",F),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",F)}},[]);const E=a.useCallback(b=>{S(b.target.value)},[]),I=a.useCallback(b=>{b?c?(S(""),Array.isArray(n)&&n.length?l([...n,b]):l([b])):(S(String(b.name??b.value??"")),l(b)):l(null),$(!1)},[c,l,n]),M=a.useCallback(b=>{if(!Array.isArray(n)){l(null);return}const F=n.filter((D,f)=>f!==b);F.length?l(F):l(null)},[l,n]),U=a.useCallback(()=>{Array.isArray(n)&&l([n[0]])},[l,n]);return a.useLayoutEffect(()=>{const b=A.current?.offsetWidth??0,F=C.current?.offsetWidth??0;k(b>F*.4)},[n]),e.jsxs("div",{className:`autocomplete-input-container ${d}`,ref:C,children:[e.jsxs("div",{className:"autocomplete-value-input-container",children:[e.jsx(X,{state:r,name:p,id:i,value:w,onChange:E,placeholder:x,helperText:m,onFocus:()=>$(!0),label:u,containerClassName:`autocomplete-text-input ${h}`,ref:s??N,...j,children:!c&&n&&!Array.isArray(n)&&(n.value||n.name)&&e.jsx(B,{icon:e.jsx(Z,{}),className:"autocomplete-delete-button",onClick:b=>{I(),b.stopPropagation()}})}),c&&Array.isArray(n)&&n.length?e.jsx("ul",{ref:A,className:"autocomplete-value-container",children:T?e.jsxs(e.Fragment,{children:[e.jsx("li",{children:e.jsx(W,{text:n[0]?.value??n[0]?.name,onDelete:b=>{M(0),b.stopPropagation()}})}),n.length>1&&e.jsx("li",{children:e.jsx(W,{text:`+${n.length-1}`,onDelete:b=>{U(),b.stopPropagation()}})})]}):n.map((b,F)=>e.jsx("li",{children:e.jsx(W,{text:String(b.value??b.name),onDelete:D=>{M(F),D.stopPropagation()}})},b.id??b.value??b.name))}):null]}),g&&e.jsx("ul",{className:"autocomplete-suggestions-container",style:{width:C.current?.offsetWidth},children:y.map(b=>e.jsx("li",{className:"autocomplete-suggestion-item",onClick:F=>{I(b),F.stopPropagation()},children:b.value??b.name},b.id??b.value??b.name))})]})}),ue=a.forwardRef(function(t,s){const{checked:r,onChange:n,name:l="",id:o="",label:p="",containerClassName:i="",inputClassName:u="",labelClassName:d="",...h}=t;return e.jsxs("label",{className:`input-check-container ${i}`,children:[e.jsx("input",{id:o,ref:s,name:l,type:"checkbox",checked:r,onChange:n,className:`input-check ${u}`,...h}),e.jsx("span",{className:`input-check-label ${d}`,children:p})]})});function ae(t,s=25){if(t.length<=s)return t;const r=t.lastIndexOf(".");if(r===-1)return t.slice(0,s-3)+"...";const n=t.slice(0,r),l=t.slice(r),o=s-l.length-3;return n.slice(0,o)+"..."+l}const De=a.forwardRef(function(t,s){const{children:r,label:n,containerClassName:l="",inputClassName:o="",labelClassName:p="",helperText:i="",helperTextClassName:u="",iconClassName:d="",multiple:h=!1,onChange:m,onClear:x,...c}=t,[j,w]=a.useState([]),S=a.useCallback(C=>{if(C.target.files){const N=Array.from(C.target.files);w(T=>[...T,...N])}m?.(C)},[m]),g=a.useCallback(C=>{w(N=>{const T=N.filter((k,A)=>A!==C);return T.length===0&&x?.(),T})},[x]),$=a.useCallback(()=>{w([]),x?.()},[x]),y=a.useCallback(C=>{C.currentTarget.value=""},[]);return e.jsxs("div",{className:`file-input-container ${l}`,children:[j.length===0&&e.jsxs("label",{htmlFor:c.name,className:`${p}`,children:[n,e.jsx("input",{type:"file",ref:s,multiple:h,onClick:y,onChange:S,className:`file-input ${o}`,...c}),c.required?" *":""]}),j.length>1&&e.jsx("ul",{className:"file-preview-list",children:j.map((C,N)=>e.jsx("li",{children:e.jsx(G,{content:C.name,children:e.jsx(W,{text:ae(C.name,25),onDelete:()=>g(N)})})},`${C.name}-${C.lastModified}`))}),j.length===1&&e.jsxs("div",{className:"file-preview",children:[e.jsx(fe,{className:`file-icon ${d}`}),e.jsx(G,{content:j[0]?.name??"",children:e.jsx("span",{className:"!cursor-default",children:ae(j[0]?.name??"",25)})}),e.jsx(B,{icon:e.jsx(Z,{}),onClick:$,type:"button"})]}),r,!!i&&e.jsx("p",{className:`file-input-helper-text ${u}`,children:i})]})});var Q=(t=>(t.error="error",t.good="good",t.default="default",t))(Q||{});const ne=t=>{switch(t){case"error":return"input-error";case"good":return"input-good";default:return"input-normal"}},se=t=>{switch(t){case"error":return"input-label-error";case"good":return"input-label-good";default:return"input-label-normal"}},le=t=>{switch(t){case"error":return"input-helper-text-error";case"good":return"input-helper-text-good";default:return"input-helper-text-normal"}},Y=a.forwardRef(function(t,s){const{value:r,onChange:n,options:l,containerClassName:o="",inputClassName:p="",labelClassName:i="",helperText:u="",helperTextClassName:d="",label:h="",name:m="",id:x="",state:c=Q.default,children:j,...w}=t;return e.jsxs("div",{className:`select-input-container ${o}`,children:[e.jsx("select",{...w,id:x,ref:s,name:m,value:r,onChange:n,className:`select-input ${ne(c)} peer ${p}`,children:l?.map(S=>e.jsx("option",{value:S.id,children:S.value??S.name??S.id},S.id))}),e.jsx("label",{htmlFor:x,className:`select-input-label ${se(c)} ${i}`,children:h}),j,u&&e.jsx("p",{className:`select-input-helper-text ${le(c)} ${d}`,children:u})]})}),X=a.forwardRef(function(t,s){const{children:r,state:n=Q.default,label:l="",containerClassName:o="",inputClassName:p="",labelClassName:i="",helperText:u="",helperTextClassName:d="",value:h="",...m}=t;return e.jsxs("div",{className:`text-input-container ${o}`,children:[e.jsx("input",{ref:s,value:h,className:`text-input ${ne(n)} peer ${p} ${h?"has-value":""} ${m.placeholder?"has-placeholder":""}`,...m}),!!l&&e.jsxs("label",{htmlFor:m.id,className:`text-input-label ${se(n)} ${i}`,children:[l,m.required?" *":""]}),r,!!u&&e.jsx("p",{className:`text-input-helper-text ${le(n)} ${d}`,children:u})]})}),B=t=>{const{children:s,icon:r,type:n="button",className:l="",variant:o="text",color:p="default",iconClassName:i="",...u}=t;return e.jsxs("button",{type:n,className:`icon-button ${l} ${o} ${p}`,...u,children:[e.jsx("span",{className:i,children:r}),s]})};function de(t){const{color:s="stroke-blue-800",className:r="",loaderClass:n="",strokeWidth:l="4",...o}=t;return e.jsx("div",{...o,className:`loading ${r}`,children:e.jsx("div",{className:"loader-container",children:e.jsx("div",{className:`loader ${n}`,children:e.jsx("svg",{className:"circular",viewBox:"25 25 50 50",children:e.jsx("circle",{className:`path ${s}`,cx:"50",cy:"50",r:"20",fill:"none",strokeWidth:l,strokeMiterlimit:"10"})})})})})}function pe(t){const{className:s=""}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:e.jsx("path",{d:"M233.4 406.6c12.5 12.5 32.8 12.5 45.3 0l192-192c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L256 338.7 86.6 169.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l192 192z"})})}function he(t){const{className:s=""}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M9.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l192 192c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L77.3 256 246.6 86.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-192 192z"})})}function me(t){const{className:s=""}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",fill:"currentColor",children:e.jsx("path",{d:"M310.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-192 192c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L242.7 256 73.4 86.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l192 192z"})})}function xe(t){const{className:s=""}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:e.jsx("path",{d:"M233.4 105.4c12.5-12.5 32.8-12.5 45.3 0l192 192c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L256 173.3 86.6 342.6c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3l192-192z"})})}function Z(t){const{className:s=""}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 384 512",fill:"currentColor",children:e.jsx("path",{d:"M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"})})}function fe(t){const{className:s=""}=t;return e.jsx("svg",{className:s,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 640 640",fill:"currentColor",children:e.jsx("path",{d:"M192 64C156.7 64 128 92.7 128 128L128 512C128 547.3 156.7 576 192 576L448 576C483.3 576 512 547.3 512 512L512 234.5C512 217.5 505.3 201.2 493.3 189.2L386.7 82.7C374.7 70.7 358.5 64 341.5 64L192 64zM453.5 240L360 240C346.7 240 336 229.3 336 216L336 122.5L453.5 240z"})})}const be=t=>{const{className:s=""}=t;return e.jsx("svg",{className:s,viewBox:"0 0 16 16",children:e.jsx("path",{d:"M9 15H7a1 1 0 010-2h2a1 1 0 010 2zM11 11H5a1 1 0 010-2h6a1 1 0 010 2zM13 7H3a1 1 0 010-2h10a1 1 0 010 2zM15 3H1a1 1 0 010-2h14a1 1 0 010 2z"})})};var V=(t=>(t[t.text=0]="text",t[t.number=1]="number",t[t.select=2]="select",t[t.autocomplete=3]="autocomplete",t[t.date=4]="date",t[t.check=5]="check",t))(V||{}),H=(t=>(t.ASC="ASC",t.DESC="DESC",t))(H||{}),O=(t=>(t[t.update=0]="update",t[t.reset=1]="reset",t))(O||{});const te=t=>{if(t){const s={};return Object.keys(t)?.forEach(n=>{s[n]={value:t[n]}}),s}return{}};function Ce(t,s){const{type:r}=s;switch(r){case O.reset:return{};case O.update:{const{toUpdate:n}=s;return{...t,...n}}default:return t}}const je=a.createContext({}),ge=t=>{const{children:s}=t,{filters:r}=z(),[n,l]=a.useReducer(Ce,te(r));a.useEffect(()=>{l({type:O.reset});const p=te(r);Object.keys(p).length&&l({type:O.update,toUpdate:p})},[r]);const o={currentFilters:n,setCurrentFilters:l};return e.jsx(je.Provider,{value:o,children:s})},J=()=>{const t=a.useContext(je);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t},_e=[20,50,100],ve=a.createContext({}),Be=t=>{const{children:s}=t,[r,n]=a.useState(0),[l,o]=a.useState(20),[p,i]=a.useState(0),[u,d]=a.useState("id"),[h,m]=a.useState(H.DESC),[x,c]=a.useState({}),j=a.useCallback((y,C)=>{let N=h;u===y&&(h===H.ASC?N=H.DESC:N=H.ASC),d(y),m(N),C&&C(y,N)},[u,h]),w=a.useCallback(y=>{const C=Object.entries(y).reduce((N,[T,k])=>(k&&typeof k.value<"u"&&k.value!==null&&(N[T]=k.value),N),{});c(C)},[]),S=a.useCallback(y=>{y?(delete x[y.toLowerCase()],c({...x})):c({})},[x]),g=a.useMemo(()=>Object.keys(x).length,[x]),$={onSort:j,total:r,setTotal:n,sortingBy:u,setSortingBy:d,sortingOrder:h,setSortingOrder:m,pageSize:l,pageSizes:_e,setPageSize:o,currentPage:p,setCurrentPage:i,filters:x,onFilterApply:w,clearFilters:S,countOfFilters:g};return e.jsx(ve.Provider,{value:$,children:s})},z=()=>{const t=a.useContext(ve);if(t===void 0)throw new Error("tableOptionsContext must be used within a Provider");return t},Ne=a.createContext({});function Ve(t){const{children:s,t:r,language:n}=t;return e.jsx(Ne.Provider,{value:{t:r,language:n},children:s})}const L=()=>{const t=a.useContext(Ne);if(t===void 0)throw new Error("translationContext must be used within a Provider");return t};function we(t){return[...t].sort((s,r)=>(r.pos??0)-(s.pos??0)).filter(s=>s.display!=="none")}function Se(t){const{t:s}=L(),{entity:r="",columns:n=[],hasAction:l=!0,onSortCallback:o,selectionState:p,onToggleAllRows:i}=t,u=a.useRef(null);a.useEffect(()=>{u.current&&(u.current.indeterminate=!!(p?.hasSomeSelected&&!p?.allSelected))},[p]);const{onSort:d,sortingOrder:h,sortingBy:m}=z(),x=a.useMemo(()=>we(n).map(c=>({id:c.key,label:c.label,className:c.className??"",sortable:c.sortable??!0,sortOptions:c.sortOptions})),[n,r,s]);return e.jsx("thead",{className:"table-headers-row",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"table-headers-column table-headers-checkbox",children:i?e.jsx("input",{type:"checkbox",ref:u,checked:p?.allSelected??!1,onChange:i,"aria-label":s("_accessibility:components.table.selectAllRows")}):null}),x.map(c=>e.jsx("th",{scope:"col",className:`table-headers-column ${c.className}`,children:e.jsxs(ie,{disabled:!c.sortable,onClick:()=>d(c.id,o),className:"table-headers-cell",children:[e.jsx("span",{className:"table-headers-label",children:c.label}),c.sortable&&m===c.id&&e.jsx("span",{children:h===H.ASC?c.sortOptions?.icons?.asc??e.jsx(xe,{className:c.sortOptions?.icons?.className??"table-headers-sort-indicator"}):c.sortOptions?.icons?.desc??e.jsx(pe,{className:c.sortOptions?.icons?.className??"table-headers-sort-indicator"})})]})},c.id)),l&&e.jsx("th",{scope:"col",className:"table-headers-action",children:e.jsx("span",{className:"button text default disabled",children:s("_accessibility:labels.actions")})})]})})}const ye=t=>{const{items:s,text:r,id:n,onClearFilter:l}=t;return e.jsx(W,{text:`${r}: ${s.map(o=>o.value??o.name).join(", ")}`,onDelete:()=>l(n)})},ke=t=>{const{end:s,start:r,text:n,id:l,onClearFilter:o}=t;return e.jsx(W,{text:`${n}: ${r||"♾️"} - ${s||"♾️"}`,onDelete:()=>o(l)})},Re=t=>{const{filtersDefinition:s}=t,r=a.useMemo(()=>{const i={};return s.forEach(u=>{i[u.propertyName]=u.label??u.propertyName}),i},[s]),{filters:n,clearFilters:l}=z(),o=a.useMemo(()=>Object.keys(n),[n]),p=a.useCallback(i=>n[i]?.end||n[i]?.start?e.jsx(ke,{id:i,text:r[i],start:n[i].start,end:n[i].end,onClearFilter:l}):Array.isArray(n[i])?e.jsx(ye,{id:i,text:r[i],items:n[i],onClearFilter:l}):e.jsx(W,{text:`${r[i]}: ${n[i]?.value??n[i]?.name??n[i]}`,onDelete:()=>l(i)}),[n,r]);return e.jsx("ul",{className:"active-filters-main",children:o?.map(i=>e.jsx("li",{children:p(i)},i))})};function We(t){const{propertyName:s,label:r,placeholder:n,options:l,multiple:o=!0}=t,{currentFilters:p,setCurrentFilters:i}=J(),u=a.useMemo(()=>p[s]??l[0],[p]),d=a.useCallback(h=>{i({type:O.update,toUpdate:{[s]:{value:h}}})},[o]);return e.jsx(ce,{value:u?.value,label:r,options:l,multiple:o,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:d,placeholder:n})}const Ue=t=>{const{propertyName:s,label:r}=t,{currentFilters:n,setCurrentFilters:l}=J(),o=a.useMemo(()=>n[s]?.value??"",[n]),p=a.useCallback(i=>{l({type:O.update,toUpdate:{[s]:{value:i.target.checked}}})},[]);return e.jsx(ue,{label:r,checked:o??!1,onChange:p})};function qe(t){const{propertyName:s,options:r,label:n,placeholder:l}=t,{currentFilters:o,setCurrentFilters:p}=J(),i=a.useMemo(()=>o[s]?.value??r[0],[o]),u=a.useCallback(d=>{p({type:O.update,toUpdate:{[s]:{value:d.target.value}}})},[]);return e.jsx(Y,{value:i,label:n,options:r,helperTextClassName:"hidden",containerClassName:"options-widget-container",onChange:u,placeholder:l})}const He=t=>{const{propertyName:s,label:r,placeholder:n}=t,{currentFilters:l,setCurrentFilters:o}=J(),p=a.useMemo(()=>l[s]?.value??"",[l]),i=a.useCallback(u=>{o({type:O.update,toUpdate:{[s]:{value:u.target.value}}})},[]);return e.jsx(X,{value:p??"",label:r,onChange:i,containerClassName:"input-widget-container",helperTextClassName:"",placeholder:n})},re=t=>{const{propertyName:s,label:r,inputType:n}=t,{t:l}=L(),{currentFilters:o,setCurrentFilters:p}=J(),i=a.useRef(null),u=a.useRef(null),d=a.useCallback(m=>{p({type:O.update,toUpdate:{[s]:{value:{end:u?.current?.value??null,start:m.target.value}}}})},[]),h=a.useCallback(m=>{p({type:O.update,toUpdate:{[s]:{value:{start:i?.current?.value??null,end:m.target.value}}}})},[]);return e.jsxs("div",{className:"range-widget-container",children:[e.jsx("p",{className:"text-input-label input-widget-label input-label-normal",children:r}),e.jsxs("div",{className:"range-widget-row",children:[e.jsx(X,{value:o[s]?.value?.start??"",placeholder:l("_accessibility:components.table.filters.range.start"),type:n,ref:i,onChange:d,containerClassName:"input-widget-container",helperTextClassName:""}),e.jsx(X,{value:o[s]?.value?.end??"",placeholder:l("_accessibility:components.table.filters.range.end"),type:n,ref:u,onChange:h,containerClassName:"input-widget-container",helperTextClassName:""})]})]})},Ee=t=>{switch(t.type){case V.text:return e.jsx(He,{...t});case V.number:return e.jsx(re,{...t,inputType:"number"});case V.date:return e.jsx(re,{...t,inputType:"date"});case V.select:return e.jsx(qe,{...t});case V.autocomplete:return e.jsx(We,{...t});case V.check:return e.jsx(Ue,{...t})}return e.jsx(e.Fragment,{})},$e=t=>{const{filters:s=[],show:r,handleShow:n}=t,{onFilterApply:l}=z(),{currentFilters:o,setCurrentFilters:p}=J(),{t:i}=L(),u=a.useRef(null);return a.useEffect(()=>{const d=({target:m})=>{u.current&&(m?.closest(".filter-dropdown-trigger")||!r||u.current.contains(m)||n(!1))},h=({code:m})=>{!r||m!=="Escape"||n(!1)};return document.addEventListener("click",d),document.addEventListener("keydown",h),()=>{document.removeEventListener("click",d),document.removeEventListener("keydown",h)}},[n,r]),e.jsx("div",{className:`filter-dropdown-backdrop ${r?"opened":"closed"}`,children:e.jsxs("div",{className:"filter-popup",ref:u,children:[e.jsx("div",{className:"filter-title",children:i("_accessibility:buttons.filters")}),e.jsx("ul",{className:"filter-container",children:s.map(d=>e.jsx("li",{className:"filter-container-item",children:Ee(d)},d.propertyName))}),e.jsx("div",{className:"filter-footer",children:e.jsxs("ul",{className:"filter-buttons-row",children:[e.jsx("li",{children:e.jsx("button",{onClick:()=>p({type:O.reset,filters:s}),className:"filter-dropdown-button small filter-dropdown-cancel",children:i("_accessibility:buttons.clear")})}),e.jsx("li",{children:e.jsx("button",{className:"filter-dropdown-button small filter-dropdown-submit",onClick:()=>{n(!1),l(o)},children:i("_accessibility:buttons.applyFilters")})})]})})]})})},Te=()=>{const{t}=L(),{total:s,pageSize:r,pageSizes:n,currentPage:l}=z(),o=(l+1)*r>s?s:(l+1)*r;return e.jsxs("div",{className:"table-navigation-sizes",children:[n[0]<s&&e.jsx(e.Fragment,{children:e.jsxs("p",{children:[l*r+1," - ",o," ",t("_accessibility:components.table.of")]})}),e.jsx("p",{children:s})]})};function Je(){const{t}=L(),{total:s,pageSize:r,currentPage:n,setCurrentPage:l}=z(),o=a.useMemo(()=>{const p=Math.ceil(s/r);return Array.from({length:p},(i,u)=>({id:u,value:u+1}))},[s,r]);return e.jsxs("div",{className:"jump-to-page",children:[e.jsx("p",{children:t("_accessibility:components.table.jumpToPage")}),e.jsx(Y,{value:n,options:o,inputClassName:"jump-to-page-input",containerClassName:"jump-to-page-input-container",helperTextClassName:"hidden",onChange:p=>l(Number(p.target.value))})]})}const Ae=()=>{const{t}=L(),{total:s,pageSize:r,currentPage:n,setCurrentPage:l}=z();return e.jsxs("div",{className:"table-navigation-pages",children:[e.jsx(B,{icon:e.jsx(he,{className:"w-2.5"}),className:"table-navigation-buttons",disabled:n===0,"aria-label":t("_accessibility:buttons.previous"),name:t("_accessibility:buttons.previous"),onClick:()=>l(n-1)}),e.jsx(B,{icon:e.jsx(me,{className:"w-2.5"}),disabled:Math.floor(s/((n+1)*r))===0,className:"table-navigation-buttons",name:t("_accessibility:buttons.next"),"aria-label":t("_accessibility:buttons.next"),onClick:()=>l(n+1)})]})};function Fe(){const{t}=L(),{pageSizes:s,pageSize:r,setPageSize:n}=z(),l=a.useMemo(()=>s?.map(o=>({id:o,value:o})),[s]);return e.jsxs("div",{className:"page-size",children:[e.jsx("p",{children:t("_accessibility:components.table.pageSizes")}),e.jsx(Y,{value:r,options:l,inputClassName:"page-size-input",containerClassName:"page-size-input-container",helperTextClassName:"hidden",onChange:o=>n(Number(o.target.value))})]})}function Me(){return e.jsxs("div",{className:"table-footer",children:[e.jsx(Je,{}),e.jsx(Fe,{}),e.jsx(Te,{}),e.jsx(Ae,{})]})}const Ke=t=>t,Pe=t=>{const{t:s}=L(),{columns:r,softDeleteProperty:n="deletedAt",data:l,actions:o,selectedRows:p,expandedRows:i=[],onRowSelectionChange:u,onRowExpand:d}=t,h=a.useMemo(()=>we(r),[r]),m=a.useMemo(()=>new Map(i.map(x=>[x.rowId,x])),[i]);return l?.map(x=>{const c=p.has(x.id),j=m.get(x.id),w=!!j,S=h.length+1+(o?1:0);return e.jsxs(a.Fragment,{children:[e.jsxs("tr",{className:`table-row ${d?"expandable":""} ${x[n]?"deleted-class":""} ${c?"selected":""} ${w?"expanded":""}`,onClick:()=>d?.(x),children:[e.jsx("td",{className:"table-row-cell table-row-checkbox",children:e.jsx("input",{type:"checkbox",checked:c,onClick:g=>g.stopPropagation(),onChange:()=>u(x),"aria-label":s("_accessibility:components.table.selectRow")})}),h?.map((g,$)=>e.jsx("td",{className:`table-row-cell ${$===0?"basic":""} ${g.className??""}`,children:g.renderBody?g.renderBody(x[g.key],x):Ke(x[g.key])},g.key)),o?e.jsx("td",{children:e.jsx("div",{className:"table-row-cell-action",children:o(x).filter(g=>!g.hidden)?.map(g=>e.jsx(G,{content:g.tooltip,children:e.jsx(B,{icon:g.icon,className:"row-table-action",onClick:$=>{$.stopPropagation(),g.onClick(x)}})},g.id))})}):null]}),w&&j?.content!==null&&typeof j?.content<"u"&&e.jsx("tr",{className:"table-row-expanded",children:e.jsx("td",{className:"table-row-expanded-cell",colSpan:S,children:e.jsx("div",{className:`table-row-expanded-content ${j.isVisible?"open":"closed"}`,children:e.jsx("div",{className:"table-row-expanded-inner",children:j.content})})})})]},x.id)})};function Oe(){const{t}=L();return e.jsx("div",{className:"table-empty",children:e.jsx("p",{children:t("_accessibility:components.table.empty")})})}const Le=t=>{const{columns:s,title:r,isLoading:n,toolbar:l,filterOptions:o}=t,{countOfFilters:p}=z(),{t:i}=L(),u=a.useMemo(()=>s?s.sort((c,j)=>(j.pos??0)-(c.pos??0)).filter(c=>!!c.filterOptions).map(c=>({...c.filterOptions,label:c.filterOptions?.label??c.label,propertyName:c.key})):[],[s]),[d,h]=a.useState(!1),m=a.useCallback(c=>{o?.dropdown?.setOpened?o.dropdown.setOpened(c??!1):h(c??!1)},[o]),x=a.useMemo(()=>o?.dropdown?.opened??d,[o,d]);return e.jsxs("div",{className:`table-header ${x?"showing-filters":""}`,children:[e.jsxs("div",{children:[r&&e.jsx("h1",{className:"table-header-title",children:r}),n?null:e.jsxs("div",{className:"table-header-content",children:[l,o?.button?.hide!==!0&&e.jsxs(B,{icon:o?.button?.icon??e.jsx(be,{className:"filter-dropdown-trigger-icon"}),className:"filter-dropdown-button normal filter-dropdown-trigger","aria-haspopup":"true",onClick:()=>m(!x),"aria-expanded":x,children:[e.jsx(oe,{count:p,className:`${p>0?"show":"hide"} `}),e.jsx("span",{className:"sr-only",children:i("_accessibility:buttons.filters")}),e.jsx("wbr",{})]})]})]}),!!u&&!!u.length&&e.jsx($e,{filters:u,show:x,handleShow:m,options:o}),e.jsx(Re,{filtersDefinition:u})]})};function ze({count:t,multiActions:s,onActionClick:r}){const{t:n}=L();return e.jsxs("div",{className:"table-selection-bar",children:[e.jsx("p",{className:"table-selection-bar-count",children:n("_accessibility:components.table.selectedCount",{count:t})}),s.length>0&&e.jsx("div",{className:"table-selection-bar-actions",children:s.map(l=>e.jsx(G,{content:l.tooltip,children:e.jsx(B,{icon:l.icon,className:"multi-table-action",onClick:()=>r(l),disabled:l.disabled})},l.id))})]})}const ee=220;function Xe({data:t,allowMultipleExpandedRows:s,controlledExpandedRowId:r,onExpandedRowChange:n,onRowExpand:l,findRowById:o}){const[p,i]=a.useState(null),[u,d]=a.useState(null),[h,m]=a.useState(null),[x,c]=a.useState(null),[j,w]=a.useState(!1),[S,g]=a.useState(new Set),[$,y]=a.useState([]),C=a.useRef(null),N=a.useRef(null),T=a.useRef(new Map),k=typeof r<"u",A=s&&!k,E=k?r??null:p,I=a.useCallback(()=>{N.current&&(clearTimeout(N.current),N.current=null)},[]),M=a.useCallback(f=>{if(typeof f<"u"){const v=T.current.get(f);if(!v)return;clearTimeout(v),T.current.delete(f);return}T.current.forEach(v=>clearTimeout(v)),T.current.clear()},[]),U=a.useCallback(f=>{M(f),y(v=>v.some(P=>P.rowId===f)?v.map(P=>P.rowId===f?{...P,isVisible:!1}:P):v),T.current.set(f,setTimeout(()=>{y(v=>v.filter(R=>R.rowId!==f)),T.current.delete(f)},ee))},[M]),b=a.useCallback((f,v)=>{M(f),y(R=>R.some(_=>_.rowId===f)?R.map(_=>_.rowId===f?{..._,content:v,isVisible:!1}:_):[...R,{rowId:f,content:v,isVisible:!1}]),requestAnimationFrame(()=>{y(R=>R.map(P=>P.rowId===f?{...P,isVisible:!0}:P))})},[M]);a.useEffect(()=>{if(!A)return;const f=new Set(t.map(v=>v.id));g(v=>{const R=new Set;return v.forEach(P=>{if(f.has(P)){R.add(P);return}M(P)}),R}),y(v=>(v.forEach(R=>{f.has(R.rowId)||M(R.rowId)}),v.filter(R=>f.has(R.rowId))))},[t,A,M]),a.useEffect(()=>{if(A)return;if(E===null){d(null),k&&(C.current=null);return}o(E)||(k||i(null),d(null),k&&(C.current=null))},[t,E,o,k,A]),a.useEffect(()=>{if(!A){if(I(),E===null||u===null){if(h===null){w(!1),c(null);return}w(!1),N.current=setTimeout(()=>{m(null),c(null),N.current=null},ee);return}if(h===null){m(E),c(u),requestAnimationFrame(()=>w(!0));return}if(h===E){c(u),requestAnimationFrame(()=>w(!0));return}w(!1),N.current=setTimeout(()=>{m(E),c(u),requestAnimationFrame(()=>w(!0)),N.current=null},ee)}},[I,u,E,A,h]),a.useEffect(()=>()=>{I(),M()},[I,M]),a.useEffect(()=>{if(!k)return;if(E===null){d(null),C.current=null;return}const f=o(E);if(!f){d(null),C.current=null;return}const v=C.current;d(l?.(f,v)??null),C.current=f},[E,o,k,l]);const F=a.useCallback(f=>{if(A){if(S.has(f.id)){g(K=>{const q=new Set(K);return q.delete(f.id),q}),U(f.id),n?.(null,f);return}g(K=>{const q=new Set(K);return q.add(f.id),q});const _=l?.(f,null)??null;_!==null&&typeof _<"u"?b(f.id,_):(M(f.id),y(K=>K.filter(q=>q.rowId!==f.id))),n?.(f,null);return}const v=E===f.id,R=v?f:o(E);if(k){n?.(v?null:f,R);return}if(v){i(null),d(null),n?.(null,f);return}i(f.id),d(l?.(f,R)??null),n?.(f,R)},[E,U,M,b,o,S,k,A,n,l]);return{expandedRowsToRender:a.useMemo(()=>A?$:h===null||x===null||typeof x>"u"?[]:[{rowId:h,content:x,isVisible:j}],[j,A,x,h,$]),onRowExpandChange:F}}function Ge({actions:t,selectedRowsData:s}){const r=a.useMemo(()=>!t||!s.length?[]:s.reduce((l,o,p)=>{const i=t(o).filter(d=>d.multiple&&!d.hidden);if(p===0)return i;const u=new Map(l.map(d=>[d.id,d]));return i.reduce((d,h)=>{const m=u.get(h.id);return m&&d.push({...m,...h,disabled:h.disabled||m.disabled}),d},[])},[]),[t,s]),n=a.useCallback(l=>{if(s.length){if(l.onMultipleClick){l.onMultipleClick(s);return}s.forEach(o=>l.onClick(o))}},[s]);return{multiActions:r,handleMultipleActionClick:n}}function Qe({data:t,onRowSelect:s,onSelectedRowsChange:r}){const[n,l]=a.useState(new Set),o=a.useMemo(()=>t?.filter(d=>n.has(d.id))??[],[t,n]);a.useEffect(()=>{if(!t?.length){l(new Set);return}l(d=>{const h=new Set,m=new Set(t.map(x=>x.id));return d.forEach(x=>{m.has(x)&&h.add(x)}),h})},[t]),a.useEffect(()=>{r&&r(o)},[o,r]);const p=a.useCallback(d=>{l(h=>{const m=new Set(h);return m.has(d.id)?(m.delete(d.id),s?.(d,!1)):(m.add(d.id),s?.(d,!0)),m})},[s]),i=a.useCallback(()=>{l(d=>{const h=new Set(d),m=t??[],x=m.every(c=>h.has(c.id));return m.forEach(c=>{const j=h.has(c.id);x?j&&(h.delete(c.id),s?.(c,!1)):j||(h.add(c.id),s?.(c,!0))}),h})},[t,s]),u=a.useMemo(()=>{if(!t?.length)return{allSelected:!1,hasSomeSelected:!1};const d=t.every(m=>n.has(m.id)),h=t.some(m=>n.has(m.id));return{allSelected:d,hasSomeSelected:h}},[t,n]);return{selectedRows:n,selectedRowsData:o,selectionState:u,onRowSelectionChange:p,onToggleAllRows:i}}function Ye(t){const{data:s,onSort:r,entity:n="",isLoading:l=!1,actions:o,columns:p=[],contentClassName:i="",className:u="",softDeleteProperty:d="deletedAt",onRowSelect:h,onSelectedRowsChange:m,allowMultipleExpandedRows:x=!1,expandedRowId:c,onExpandedRowChange:j,onRowExpand:w,...S}=t,g=a.useMemo(()=>!s?.length,[s]),$=a.useCallback(U=>U===null?null:s.find(b=>b.id===U)??null,[s]),{selectedRows:y,selectedRowsData:C,selectionState:N,onRowSelectionChange:T,onToggleAllRows:k}=Qe({data:s,onRowSelect:h,onSelectedRowsChange:m}),{expandedRowsToRender:A,onRowExpandChange:E}=Xe({data:s,allowMultipleExpandedRows:x,controlledExpandedRowId:c,onExpandedRowChange:j,onRowExpand:w,findRowById:$}),{multiActions:I,handleMultipleActionClick:M}=Ge({actions:o,selectedRowsData:C});return e.jsx(ge,{children:e.jsxs("div",{className:`${u} table-main`,children:[e.jsx(Le,{columns:p,isLoading:l,...S}),l?e.jsx(de,{className:"table-loading"}):e.jsx(e.Fragment,{children:g?e.jsx(Oe,{}):e.jsxs(e.Fragment,{children:[!!C.length&&e.jsx(ze,{count:C.length,multiActions:I,onActionClick:M}),e.jsx("div",{className:`${i} table-body`,children:e.jsxs("table",{className:"table-content",children:[e.jsx(Se,{entity:n,columns:p,onSortCallback:r,hasAction:!!o,selectionState:N,onToggleAllRows:k}),e.jsx("tbody",{children:e.jsx(Pe,{data:s,actions:o,columns:p,softDeleteProperty:d,selectedRows:y,expandedRows:A,onRowSelectionChange:T,onRowExpand:w?E:void 0})})]})}),e.jsx(Me,{})]})})]})})}function G(t){const{content:s,children:r,className:n=""}=t,l=a.useId(),o=a.isValidElement(r)?a.cloneElement(r,{"aria-describedby":l}):r;return e.jsxs("div",{className:`tooltip-container ${n}`,children:[o,e.jsx("div",{id:l,role:"tooltip",className:"tooltip-text",children:s})]})}exports.ActiveFilters=Re;exports.ArrayChip=ye;exports.AutocompleteInput=ce;exports.Badge=oe;exports.Button=ie;exports.CheckInput=ue;exports.ChevronDown=pe;exports.ChevronLeft=he;exports.ChevronRight=me;exports.ChevronUp=xe;exports.Chip=W;exports.Close=Z;exports.Columns=Se;exports.CountOfTotal=Te;exports.Dropdown=Ie;exports.File=fe;exports.FileInput=De;exports.FilterDropdown=$e;exports.FilterTypes=V;exports.Filters=be;exports.FiltersActions=O;exports.FiltersProvider=ge;exports.Footer=Me;exports.IconButton=B;exports.Loading=de;exports.Navigation=Ae;exports.PageSize=Fe;exports.RangeChip=ke;exports.Rows=Pe;exports.SelectInput=Y;exports.SortOrder=H;exports.State=Q;exports.Table=Ye;exports.TableEmpty=Oe;exports.TableHeader=Le;exports.TableOptionsProvider=Be;exports.TableSelectionBar=ze;exports.TextInput=X;exports.Tooltip=G;exports.TranslationProvider=Ve;exports.filtersReducer=Ce;exports.helperTextStateClassName=le;exports.initializer=te;exports.inputStateClassName=ne;exports.labelStateClassName=se;exports.renderFilterComponent=Ee;exports.useFilters=J;exports.useTableOptions=z;exports.useTranslation=L;