rich-react-component 0.1.0 → 0.2.0

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
@@ -64,7 +64,9 @@ import { RemoteComboBox } from "rich-react-component";
64
64
 
65
65
  ## What's in each layer
66
66
 
67
- **Base** (49 components) — form fields (`Input`, `NumberInput`, `PasswordInput`, `FileInput`, `CheckBox`, `Switch`, `RadioGroup`, `Select`, `MultiSelect`, `DatePicker`, `TimePicker`, `DateTimePicker`, `ComboBox`, `AutoComplete`, `FormField`), feedback (`Modal`, `Toast`, `Confirm`, `Alert`, `Spinner`, `Badge`, `Skeleton`), data display (`DataGrid`, `Pagination`, `Avatar`, `Tag`, `Rating`, `ProgressBar`), navigation (`Breadcrumb`, `Menu`, `Stepper`, `Tabs`, `Navbar`, `Sidebar`, `PageHeader`), layout (`Card`, `Divider`, `Stack`, `Container`, `Row`, `Col`), and more (`Button`, `Tooltip`, `Popover`, `Accordion`, `Icon`).
67
+ **Base** (55 components) — form fields (`Input`, `NumberInput`, `PasswordInput`, `FileInput`, `CheckBox`, `Switch`, `RadioGroup`, `Select`, `MultiSelect`, `DatePicker`, `TimePicker`, `DateTimePicker`, `ComboBox`, `AutoComplete`, `FormField`), feedback (`Modal`, `Toast`, `Confirm`, `Alert`, `Spinner`, `Badge`, `Skeleton`), data display (`DataGrid`, `Pagination`, `Avatar`, `Tag`, `Rating`, `ProgressBar`, `ListItem`, `Sparkline`, `Statistic`), navigation (`Breadcrumb`, `Menu`, `Stepper`, `Tabs`, `Navbar`, `Sidebar`, `PageHeader`), layout (`Card`, `Divider`, `Stack`, `Flex`, `Container`, `Row`, `Col`), typography (`Text`), and more (`Button`, `IconButton`, `Tooltip`, `Popover`, `Accordion`, `Icon`).
68
+
69
+ `DataGrid` columns are declarative by default (`{ field: "conversion", header: "CONV.", align: "end" }`) — `render` stays available as the escape hatch for genuinely custom cells, and `format`/`formatter` cover the common presentation cases (`dataGridFormatters` exports the built-in `text`/`date`/`currency`/`boolean` set). `Card` accepts `title`/`subtitle`/`icon`/`avatar`/`actions`/`loading` directly, with `header` remaining as the raw escape hatch. `Tabs` supports `variant` (`default`/`underline`/`pill`/`card`/`button`), `orientation`, `size`, `stretch`, and per-item `icon`/`badge`, with roving-tabindex keyboard navigation.
68
70
 
69
71
  **Remote** — `RemoteComboBox`, `RemoteAutoComplete`, `RemoteSelect`, `RemoteMultiSelect`, `RemoteDataGrid`, backed by a shared `HttpClient` abstraction and a `useRemoteData` hook that handles request cancellation, stale-response protection, and a consistent `idle/loading/success/empty/error` state model.
70
72
 
@@ -72,7 +74,7 @@ import { RemoteComboBox } from "rich-react-component";
72
74
 
73
75
  - **Metadata contract** — a discriminated union per component type (`InputMetadata | ComboBoxMetadata | DatePickerMetadata | DataGridMetadata`), plus `SmartActionMetadata` for buttons. Declarative only: no expressions, no serialized functions.
74
76
  - **Registries** — `SmartComponentRegistry` (keyed by the `component` discriminant, not a switch), `SmartDataSourceRegistry` and `SmartActionRegistry` (id-based indirection — metadata never carries a raw URL or a function).
75
- - **Built-in resolvers** — Input, ComboBox, DatePicker, and DataGrid, registered via `registerBuiltInResolvers()` through the exact same call a custom application component would use. DataGrid's column metadata (`format: "text" | "date" | "currency" | "boolean"`) maps to a small, Smart-owned set of formatters the server requests a formatter, never ships one.
77
+ - **Built-in resolvers** — Input, ComboBox, DatePicker, and DataGrid, registered via `registerBuiltInResolvers()` through the exact same call a custom application component would use. DataGrid's column metadata (`format: "text" | "date" | "currency" | "boolean"`) maps onto Base DataGrid's own `dataGridFormatters` — Smart requests a formatter, it doesn't maintain a second rendering system for it. The one exception is the boolean formatter's localized text, which Smart still resolves itself (via the `formatter` escape hatch) since that's a translation-catalog concern Base can't own.
76
78
  - **Headless engine** — `useSmartField` / `useSmartAction` resolve one field/action's metadata (visibility, validation, localized label, resolved request params); `useSmartDependencies` tracks `dependsOn` and reports which field needs fresh metadata when a value it depends on changes.
77
79
  - **Components** — `SmartField` / `SmartAction` resolve one piece of metadata into UI; `SmartForm` / `SmartActions` are thin iteration helpers over a whole `SmartFormMetadata` — no field-value ownership, no business-rule evaluation, no layout decisions.
78
80
 
@@ -1,9 +1,23 @@
1
1
  import { ReactNode } from 'react';
2
2
  export interface CardProps {
3
+ /** Standard header — renders an icon/avatar + title + subtitle row with a right-aligned actions slot, no manual header markup required. */
4
+ title?: ReactNode;
5
+ subtitle?: ReactNode;
6
+ /** Mutually exclusive with `avatar` — `avatar` wins if both are given. */
7
+ icon?: ReactNode;
8
+ avatar?: ReactNode;
9
+ /** Right-aligned header slot, typically Buttons/IconButtons/Menu. */
10
+ actions?: ReactNode;
11
+ /**
12
+ * Escape hatch for header content the title/subtitle/icon/avatar/actions
13
+ * shape can't express. Wins over all of the above when provided.
14
+ */
3
15
  header?: ReactNode;
4
16
  footer?: ReactNode;
17
+ /** Replaces `children` with a generic loading skeleton (reuses `Skeleton`, doc: no bespoke shimmer). */
18
+ loading?: boolean;
5
19
  className?: string;
6
20
  children?: ReactNode;
7
21
  }
8
22
  /** Generic content container — the most basic layout primitive, used to group everything else. */
9
- export declare function Card({ header, footer, className, children }: CardProps): import("react").JSX.Element;
23
+ export declare function Card({ title, subtitle, icon, avatar, actions, header, footer, loading, className, children }: CardProps): import("react").JSX.Element;
@@ -1,10 +1,34 @@
1
1
  import { ReactNode } from 'react';
2
+ export type DataGridAlign = "start" | "center" | "end";
3
+ /**
4
+ * Closed, finite formatter set — the same contract the Smart layer's
5
+ * `format` metadata already targeted, now owned here instead of being
6
+ * duplicated in a second Smart-side formatter map (doc: "Base DataGrid owns
7
+ * reusable presentation capability, Smart chooses a supported formatter").
8
+ * Never accepts an arbitrary/serialized function — that stays Smart's
9
+ * closed-enum contract too.
10
+ */
11
+ export type DataGridFormat = "text" | "date" | "currency" | "boolean";
12
+ export declare const dataGridFormatters: Record<DataGridFormat, (value: unknown) => ReactNode>;
2
13
  export interface DataGridColumn<TRow> {
3
- key: string;
14
+ /** Row-identity/sort key. Defaults to `field` when omitted — required only if `field` is also omitted (a fully custom `render`-only column). */
15
+ key?: string;
16
+ /** Row property this column reads its value from — strongly typed against `TRow`. Enables the declarative `align`/`format`/`formatter` path below instead of a `render` callback. */
17
+ field?: keyof TRow & string;
4
18
  header: string;
5
- render?: (row: TRow) => ReactNode;
6
- sortable?: boolean;
19
+ align?: DataGridAlign;
20
+ /** Defaults to `align` when omitted. */
21
+ headerAlign?: DataGridAlign;
7
22
  width?: string;
23
+ minWidth?: string;
24
+ maxWidth?: string;
25
+ sortable?: boolean;
26
+ /** Built-in formatter selection — the normal way to display a field (see `dataGridFormatters`). */
27
+ format?: DataGridFormat;
28
+ /** Escape hatch for a computed display value that still gets the standard aligned cell wrapper. */
29
+ formatter?: (value: unknown, row: TRow) => ReactNode;
30
+ /** Escape hatch for a fully custom cell — the exception, not the default way to display a field. */
31
+ render?: (row: TRow) => ReactNode;
8
32
  }
9
33
  export type DataGridSort = {
10
34
  key: string;
@@ -0,0 +1,20 @@
1
+ import { StackProps } from './Stack';
2
+ export type FlexGap = NonNullable<StackProps["gap"]> | "xs" | "sm" | "md" | "lg" | "xl";
3
+ export interface FlexProps extends Omit<StackProps, "gap"> {
4
+ gap?: FlexGap;
5
+ /** `flex-grow-1` on the container itself (for a Flex nested inside another flex layout). */
6
+ grow?: boolean;
7
+ /** `flex-shrink-0` on the container itself. */
8
+ shrink?: boolean;
9
+ /** `w-100`. */
10
+ fullWidth?: boolean;
11
+ }
12
+ /**
13
+ * Arbitrary flex layout on top of the same `d-flex` machinery Stack already
14
+ * owns (doc: "do not duplicate Stack") — only the defaults and the extra
15
+ * grow/shrink/fullWidth concerns differ. Stack defaults to a column
16
+ * (vertical list of children); Flex defaults to a row, matching the
17
+ * `<div className="d-flex align-items-center justify-content-between">`
18
+ * call sites it's meant to replace.
19
+ */
20
+ export declare function Flex({ direction, gap, grow, shrink, fullWidth, className, ...rest }: FlexProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { ButtonProps } from './Button';
3
+ import { IconProps } from './Icon';
4
+ export interface IconButtonProps extends Omit<ButtonProps, "children"> {
5
+ /** Icon class name(s), passed straight through to `Icon` (icon-set agnostic — doc section 15). */
6
+ icon: string;
7
+ /** Required — an icon-only control has no visible text, so it must carry its own accessible name. */
8
+ "aria-label": string;
9
+ iconSize?: IconProps["size"];
10
+ /** Optional tooltip, composed from the existing `Tooltip` primitive rather than a second hover-label implementation. */
11
+ tooltip?: ReactNode;
12
+ }
13
+ /** Composes Button + Icon (doc: reuse, don't build a second button system) for the common icon-only action button. */
14
+ export declare function IconButton({ icon, "aria-label": ariaLabel, iconSize, tooltip, variant, loading, className, ...rest }: IconButtonProps): import("react").JSX.Element;
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ListItemProps {
3
+ /** Typically an `Avatar` or `Icon`. */
4
+ leading?: ReactNode;
5
+ title: ReactNode;
6
+ description?: ReactNode;
7
+ /** Typically an `IconButton`, `Badge`, or `Sparkline`. */
8
+ trailing?: ReactNode;
9
+ /** Presence makes the row an interactive `<button>` (established row-action pattern). */
10
+ onClick?: () => void;
11
+ disabled?: boolean;
12
+ /** Tighter vertical rhythm for dense lists (e.g. inside a DataGrid cell). */
13
+ dense?: boolean;
14
+ className?: string;
15
+ }
16
+ /**
17
+ * Generic leading/title-description/trailing row — the same shape as MUI's
18
+ * `ListItem` + `ListItemAvatar` + `ListItemText` or Ant Design's
19
+ * `List.Item.Meta`. Replaces repeated `<div className="d-flex
20
+ * align-items-center"><Avatar/><div><span/><span/></div></div>` markup.
21
+ * Intentionally has no domain-specific counterpart (no `AuthorItem`/
22
+ * `UserItem`) — callers pass whatever leading/title/description/trailing
23
+ * content their row needs.
24
+ */
25
+ export declare function ListItem({ leading, title, description, trailing, onClick, disabled, dense, className }: ListItemProps): import("react").JSX.Element;
@@ -0,0 +1,22 @@
1
+ export type SparklineType = "line" | "area" | "bar";
2
+ export type SparklineTone = "primary" | "secondary" | "success" | "danger" | "warning" | "info" | "dark";
3
+ export interface SparklineProps {
4
+ type?: SparklineType;
5
+ data: number[];
6
+ tone?: SparklineTone;
7
+ width?: number;
8
+ height?: number;
9
+ strokeWidth?: number;
10
+ className?: string;
11
+ /** Accessible label — omit for a purely decorative chart (default: aria-hidden), same convention as `Icon`. */
12
+ label?: string;
13
+ }
14
+ /**
15
+ * Compact inline chart — the established dashboard "sparkline" concept
16
+ * (MUI X `SparkLineChart`, DevExtreme/Kendo Sparkline). Implemented with
17
+ * plain inline SVG rather than a charting dependency: this repo doesn't
18
+ * already depend on one, and a public API shaped around `data`/`type`/
19
+ * `tone` stays implementation-agnostic either way (doc: avoid unnecessary
20
+ * dependencies; don't leak chart-library config as the public API).
21
+ */
22
+ export declare function Sparkline({ type, data, tone, width, height, strokeWidth, className, label }: SparklineProps): import("react").JSX.Element;
@@ -0,0 +1,16 @@
1
+ import { ReactNode } from 'react';
2
+ export type StatisticTrend = "up" | "down" | "neutral";
3
+ export interface StatisticProps {
4
+ label: ReactNode;
5
+ value: number | string;
6
+ prefix?: ReactNode;
7
+ suffix?: ReactNode;
8
+ /** Decimal places applied when `value` is a number. */
9
+ precision?: number;
10
+ trend?: StatisticTrend;
11
+ delta?: ReactNode;
12
+ loading?: boolean;
13
+ className?: string;
14
+ }
15
+ /** Label/value/prefix/suffix/trend — the established dashboard "Statistic"/"Stat" pattern (MUI, Ant Design, Mantine). No dashboard business logic. */
16
+ export declare function Statistic({ label, value, prefix, suffix, precision, trend, delta, loading, className }: StatisticProps): import("react").JSX.Element;
@@ -1,16 +1,33 @@
1
1
  import { ReactNode } from 'react';
2
+ export type TabsVariant = "default" | "underline" | "pill" | "card" | "button";
3
+ export type TabsOrientation = "horizontal" | "vertical";
4
+ export type TabsSize = "sm" | "lg";
2
5
  export interface TabItem {
3
6
  key: string;
4
- label: string;
7
+ label: ReactNode;
8
+ /** Icon class name(s), passed straight through to `Icon` (icon-set agnostic — doc section 15). */
9
+ icon?: string;
10
+ badge?: ReactNode;
5
11
  disabled?: boolean;
6
- content: ReactNode;
12
+ /**
13
+ * Optional — a tab can be nav-only (content driven externally, e.g. by
14
+ * the same `activeKey` state feeding a sibling `DataGrid`) instead of
15
+ * owning its panel.
16
+ */
17
+ content?: ReactNode;
7
18
  }
8
19
  export interface TabsProps {
9
20
  items: TabItem[];
10
21
  activeKey?: string;
11
22
  defaultActiveKey?: string;
12
23
  onChange?: (key: string) => void;
24
+ /** Generic nav look, not a Metronic widget name — express a Metronic visual as `variant="pill"` + `icon`, not a new named variant. */
25
+ variant?: TabsVariant;
26
+ orientation?: TabsOrientation;
27
+ size?: TabsSize;
28
+ /** Tab list fills its container width (`nav-fill`). */
29
+ stretch?: boolean;
13
30
  className?: string;
14
31
  }
15
32
  /** Tab definitions (`items`) are kept separate from rendering, per doc section 16. */
16
- export declare function Tabs({ items, activeKey, defaultActiveKey, onChange, className }: TabsProps): import("react").JSX.Element;
33
+ export declare function Tabs({ items, activeKey, defaultActiveKey, onChange, variant, orientation, size, stretch, className }: TabsProps): import("react").JSX.Element;
@@ -0,0 +1,21 @@
1
+ import { ElementType, ReactNode } from 'react';
2
+ export type TextSize = "xs" | "sm" | "md" | "lg" | "xl";
3
+ export type TextWeight = "normal" | "medium" | "semibold" | "bold";
4
+ export type TextTone = "default" | "muted" | "primary" | "success" | "danger" | "warning" | "info";
5
+ export type TextAlign = "start" | "center" | "end";
6
+ export interface TextProps {
7
+ /** Rendered element — defaults to `span`. Pass e.g. `"h3"`/`"p"`/`"label"` for a semantic element without losing the typography contract. */
8
+ as?: ElementType;
9
+ size?: TextSize;
10
+ weight?: TextWeight;
11
+ tone?: TextTone;
12
+ align?: TextAlign;
13
+ /** Single-line ellipsis truncation. */
14
+ truncate?: boolean;
15
+ /** `false` disables wrapping (`text-nowrap`) without truncating. */
16
+ wrap?: boolean;
17
+ className?: string;
18
+ children?: ReactNode;
19
+ }
20
+ /** Generic typography primitive — replaces ad hoc `<span className="text-gray-500 fw-semibold fs-7">` markup at call sites. */
21
+ export declare function Text({ as, size, weight, tone, align, truncate, wrap, className, children }: TextProps): import("react").JSX.Element;
@@ -47,6 +47,12 @@ export * from './Icon';
47
47
  export * from './Navbar';
48
48
  export * from './Sidebar';
49
49
  export * from './PageHeader';
50
+ export * from './Text';
51
+ export * from './Flex';
52
+ export * from './IconButton';
53
+ export * from './ListItem';
54
+ export * from './Sparkline';
55
+ export * from './Statistic';
50
56
  export { Popup } from './shared/Popup';
51
57
  export type { PopupProps } from './shared/Popup';
52
58
  export { Label } from './shared/Label';
package/dist/index.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react");function m(...e){return e.filter(Boolean).join(" ")}function oe({htmlFor:e,required:n,className:t,children:r}){return s.jsxs("label",{htmlFor:e,className:m("form-label",t),children:[r,n&&s.jsx("span",{className:"text-danger",children:" *"})]})}function Q({error:e,helpText:n,className:t}){return e?s.jsx("div",{className:m("invalid-feedback d-block",t),children:e}):n?s.jsx("div",{className:m("form-text",t),children:n}):null}function P({id:e,label:n,required:t,error:r,helpText:a,className:l,children:c}){return s.jsxs("div",{className:m("mb-3",l),children:[n&&s.jsx(oe,{htmlFor:e,required:t,children:n}),c,s.jsx(Q,{error:r,helpText:a})]})}function D({value:e,defaultValue:n,onChange:t}){const r=e!==void 0,a=f.useRef(r);process.env.NODE_ENV!=="production"&&a.current!==r&&console.error("[react-components] A component switched between controlled and uncontrolled `value`. Decide between passing `value` (controlled) or `defaultValue` (uncontrolled) for the lifetime of the component, per the library's controlled/uncontrolled policy.");const[l,c]=f.useState(n),o=r?e:l,i=f.useCallback(d=>{r||c(d),t==null||t(d)},[r,t]);return[o,i]}function B(e){const{id:n,name:t,disabled:r,readOnly:a,required:l,className:c,label:o,placeholder:i,helpText:d,error:u,value:b,defaultValue:h,onChange:x,onBlur:v,type:N="text",maxLength:j,autoFocus:p,inputProps:y,endAdornment:g}=e,[S,k]=D({value:b,defaultValue:h??"",onChange:x}),w=f.useId(),I=n??w,V=s.jsx("input",{id:I,name:t,className:m("form-control",u&&"is-invalid"),disabled:r,readOnly:a,required:l,placeholder:i,maxLength:j,autoFocus:p,value:S,onChange:A=>k(A.target.value),onBlur:v,type:N,...y});return s.jsx(P,{id:I,label:o,required:l,error:u,helpText:d,className:c,children:g?s.jsxs("div",{className:"input-group",children:[V,g]}):V})}function Ke(e){const{id:n,name:t,disabled:r,readOnly:a,required:l,className:c,label:o,placeholder:i,helpText:d,error:u,value:b,defaultValue:h,onChange:x,onBlur:v,rows:N=3,maxLength:j}=e,[p,y]=D({value:b,defaultValue:h??"",onChange:x}),g=f.useId(),S=n??g;return s.jsx(P,{id:S,label:o,required:l,error:u,helpText:d,className:c,children:s.jsx("textarea",{id:S,name:t,className:m("form-control",u&&"is-invalid"),disabled:r,readOnly:a,required:l,placeholder:i,rows:N,maxLength:j,value:p,onChange:k=>y(k.target.value),onBlur:v})})}function Be({value:e,defaultValue:n,onChange:t,min:r,max:a,step:l,...c}){const[o,i]=D({value:e,defaultValue:n??null,onChange:t});return s.jsx(B,{...c,value:o===null?"":String(o),onChange:d=>{if(d.trim()===""){i(null);return}const u=Number(d);Number.isNaN(u)||i(u)},inputProps:{inputMode:"decimal",min:r,max:a,step:l}})}function He(e){const[n,t]=f.useState(!1);return s.jsx(B,{...e,inputProps:{type:n?"text":"password",autoComplete:"current-password"},endAdornment:s.jsx("button",{type:"button",className:"btn btn-outline-secondary","aria-label":n?"Hide password":"Show password","aria-pressed":n,onClick:()=>t(r=>!r),children:n?"Hide":"Show"})})}function qe({id:e,name:n,disabled:t,required:r,className:a,label:l,helpText:c,error:o,accept:i,multiple:d,onChange:u}){const b=f.useId(),h=e??b;return s.jsx(P,{id:h,label:l,required:r,error:o,helpText:c,className:a,children:s.jsx("input",{id:h,name:n,type:"file",className:m("form-control",o&&"is-invalid"),disabled:t,required:r,accept:i,multiple:d,onChange:x=>u==null?void 0:u(x.target.files)})})}function ce({id:e,name:n,disabled:t,required:r,wrapperClassName:a,role:l,label:c,helpText:o,error:i,checked:d,onChange:u,className:b}){const h=f.useId(),x=e??h;return s.jsxs("div",{className:m(a,b),children:[s.jsx("input",{id:x,name:n,type:"checkbox",role:l,className:m("form-check-input",i&&"is-invalid"),disabled:t,required:r,checked:d,onChange:v=>u(v.target.checked)}),c&&s.jsx("label",{htmlFor:x,className:"form-check-label",children:c}),s.jsx(Q,{error:i,helpText:o})]})}function Ge(e){const[n,t]=D({value:e.checked,defaultValue:e.defaultChecked??!1,onChange:e.onChange});return s.jsx(ce,{id:e.id,name:e.name,disabled:e.disabled,required:e.required,className:e.className,wrapperClassName:"form-check mb-3",label:e.label,helpText:e.helpText,error:e.error,checked:n,onChange:t})}function Ue(e){const[n,t]=D({value:e.checked,defaultValue:e.defaultChecked??!1,onChange:e.onChange});return s.jsx(ce,{id:e.id,name:e.name,disabled:e.disabled,required:e.required,className:e.className,wrapperClassName:"form-check form-switch mb-3",role:"switch",label:e.label,helpText:e.helpText,error:e.error,checked:n,onChange:t})}function de({id:e,name:n,value:t,label:r,checked:a,disabled:l,className:c,onChange:o}){const i=f.useId(),d=e??i;return s.jsxs("div",{className:m("form-check",c),children:[s.jsx("input",{id:d,name:n,type:"radio",className:"form-check-input",value:String(t),checked:a,disabled:l,onChange:()=>o==null?void 0:o(t)}),r&&s.jsx("label",{htmlFor:d,className:"form-check-label",children:r})]})}function _e({options:e,value:n,defaultValue:t,onChange:r,inline:a,id:l,name:c,disabled:o,required:i,className:d,label:u,helpText:b,error:h}){const[x,v]=D({value:n,defaultValue:t??null,onChange:p=>{p!==null&&(r==null||r(p))}}),N=f.useId(),j=c??l??N;return s.jsx(P,{label:u,required:i,error:h,helpText:b,className:d,children:s.jsx("div",{role:"radiogroup","aria-label":u,"aria-required":i,className:m(a&&"d-flex gap-3"),children:e.map(p=>s.jsx(de,{name:j,value:p.value,label:p.label,checked:p.value===x,disabled:o||p.disabled,onChange:y=>v(y)},String(p.value)))})})}function ue({options:e,value:n,defaultValue:t,onChange:r,placeholder:a,loading:l,id:c,name:o,disabled:i,readOnly:d,required:u,className:b,label:h,helpText:x,error:v}){const[N,j]=D({value:n,defaultValue:t??null,onChange:r}),p=f.useId(),y=c??p;return s.jsx(P,{id:y,label:h,required:u,error:v,helpText:x,className:b,children:s.jsxs("select",{id:y,name:o,className:m("form-select",v&&"is-invalid"),disabled:i||d||l,required:u,value:N===null?"":String(N),onChange:g=>{const S=g.target.value;if(S===""){j(null);return}const k=e.find(w=>String(w.value)===S);j(k?k.value:null)},children:[l&&s.jsx("option",{value:"",children:"Loading…"}),!l&&a&&s.jsx("option",{value:"",children:a}),e.map(g=>s.jsx("option",{value:String(g.value),disabled:g.disabled,children:g.label},String(g.value)))]})})}function W(e,n){f.useEffect(()=>{if(!e)return;function t(r){r.key==="Escape"&&n()}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,n])}function $({open:e,onClose:n,anchorRef:t,className:r,role:a,children:l}){const c=f.useRef(null);return W(e,n),f.useEffect(()=>{if(!e)return;function o(i){var u,b;const d=i.target;(u=c.current)!=null&&u.contains(d)||(b=t.current)!=null&&b.contains(d)||n()}return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[e,n,t]),e?s.jsx("div",{ref:c,className:m("show",r),role:a,children:l}):null}function Y({itemCount:e,isOpen:n,onSelect:t,onClose:r}){const[a,l]=f.useState(-1);f.useEffect(()=>{n||l(-1)},[n]),W(n,r);const c=f.useCallback(o=>{if(!n){(o.key==="ArrowDown"||o.key==="Enter")&&o.preventDefault();return}switch(o.key){case"ArrowDown":o.preventDefault(),l(i=>e===0?-1:(i+1)%e);break;case"ArrowUp":o.preventDefault(),l(i=>e===0?-1:(i-1+e)%e);break;case"Home":o.preventDefault(),l(e===0?-1:0);break;case"End":o.preventDefault(),l(e===0?-1:e-1);break;case"Enter":a>=0&&(o.preventDefault(),t(a));break}},[n,e,a,t]);return{activeIndex:a,setActiveIndex:l,handleKeyDown:c}}function fe({options:e,values:n,defaultValues:t,onChange:r,loading:a,emptyText:l="No options",id:c,name:o,disabled:i,readOnly:d,required:u,className:b,label:h,placeholder:x="Select...",helpText:v,error:N}){const[j,p]=D({value:n,defaultValue:t??[],onChange:r}),[y,g]=f.useState(!1),S=f.useRef(null),k=f.useId(),w=c??k,I=new Set(j),V=f.useCallback(()=>g(!1),[]),A=f.useCallback(C=>{const E=e[C];if(!E||E.disabled)return;const _=I.has(E.value)?j.filter(Z=>Z!==E.value):[...j,E.value];p(_)},[e,j,I,p]),{activeIndex:L,setActiveIndex:U,handleKeyDown:K}=Y({itemCount:e.length,isOpen:y,onSelect:A,onClose:V}),R=e.filter(C=>I.has(C.value)).map(C=>C.label).join(", ");return s.jsx(P,{id:w,label:h,required:u,error:N,helpText:v,className:b,children:s.jsxs("div",{className:"position-relative",children:[s.jsx("button",{ref:S,id:w,type:"button",name:o,className:m("form-select text-start",N&&"is-invalid"),disabled:i||d,"aria-haspopup":"listbox","aria-expanded":y,onClick:()=>g(C=>!C),onKeyDown:K,children:R||s.jsx("span",{className:"text-body-secondary",children:x})}),s.jsx($,{open:y,onClose:V,anchorRef:S,className:"dropdown-menu w-100",role:"listbox",children:a?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:"Loading…"}):e.length===0?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:l}):e.map((C,E)=>s.jsxs("div",{role:"option","aria-selected":I.has(C.value),className:m("dropdown-item d-flex align-items-center gap-2",E===L&&"active",C.disabled&&"disabled"),onMouseEnter:()=>U(E),onMouseDown:_=>{_.preventDefault(),C.disabled||A(E)},children:[s.jsx("input",{type:"checkbox",className:"form-check-input m-0",checked:I.has(C.value),readOnly:!0,tabIndex:-1}),C.label]},String(C.value)))})]})})}function O(e){if(!e)return"";const n=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${t}-${r}`}function X(e){if(!e)return null;const n=e.split("-").map(Number),[t,r,a]=n;return!t||!r||!a?null:new Date(t,r-1,a)}function me({value:e,defaultValue:n,onChange:t,min:r,max:a,...l}){const[c,o]=D({value:e,defaultValue:n??null,onChange:t});return s.jsx(B,{...l,value:O(c),onChange:i=>o(X(i)),inputProps:{type:"date",min:r?O(r):void 0,max:a?O(a):void 0}})}function ee(e){if(!e)return"";const n=String(e.getHours()).padStart(2,"0"),t=String(e.getMinutes()).padStart(2,"0");return`${n}:${t}`}function ne(e){if(!e)return null;const[n,t]=e.split(":").map(Number);return n===void 0||t===void 0||Number.isNaN(n)||Number.isNaN(t)?null:new Date(1970,0,1,n,t,0,0)}function Je({value:e,defaultValue:n,onChange:t,step:r,...a}){const[l,c]=D({value:e,defaultValue:n??null,onChange:t});return s.jsx(B,{...a,value:ee(l),onChange:o=>c(ne(o)),inputProps:{type:"time",step:r}})}function re(e,n){const t=X(e);if(!t)return null;const r=ne(n||"00:00");return r&&t.setHours(r.getHours(),r.getMinutes(),0,0),t}function ze({value:e,defaultValue:n,onChange:t,min:r,max:a,id:l,name:c,disabled:o,readOnly:i,required:d,className:u,label:b,helpText:h,error:x}){const[v,N]=D({value:e,defaultValue:n??null,onChange:t}),j=f.useId(),p=l??j,y=O(v),g=ee(v);return s.jsx(P,{id:p,label:b,required:d,error:x,helpText:h,className:u,children:s.jsxs("div",{className:"d-flex gap-2",children:[s.jsx("input",{id:p,name:c?`${c}-date`:void 0,type:"date",className:m("form-control",x&&"is-invalid"),disabled:o,readOnly:i,required:d,min:r?O(r):void 0,max:a?O(a):void 0,value:y,onChange:S=>N(re(S.target.value,g))}),s.jsx("input",{name:c?`${c}-time`:void 0,type:"time",className:m("form-control",x&&"is-invalid"),disabled:o,readOnly:i,required:d,value:g,onChange:S=>N(re(y||O(new Date),S.target.value))})]})})}function he({options:e,value:n,defaultValue:t,onChange:r,loading:a,emptyText:l="No options",id:c,name:o,disabled:i,readOnly:d,required:u,className:b,label:h,placeholder:x="Select...",helpText:v,error:N}){const[j,p]=D({value:n,defaultValue:t??null,onChange:r}),[y,g]=f.useState(!1),S=f.useRef(null),k=f.useId(),w=c??k,I=e.find(T=>T.value===j)??null,V=f.useCallback(()=>g(!1),[]),A=f.useCallback(T=>{const R=e[T];!R||R.disabled||(p(R.value),V())},[e,p,V]),{activeIndex:L,setActiveIndex:U,handleKeyDown:K}=Y({itemCount:e.length,isOpen:y,onSelect:A,onClose:V});return s.jsx(P,{id:w,label:h,required:u,error:N,helpText:v,className:b,children:s.jsxs("div",{className:"position-relative",children:[s.jsx("button",{ref:S,id:w,type:"button",name:o,className:m("form-select text-start",N&&"is-invalid"),disabled:i||d,"aria-haspopup":"listbox","aria-expanded":y,onClick:()=>g(T=>!T),onKeyDown:K,children:I?I.label:s.jsx("span",{className:"text-body-secondary",children:x})}),s.jsx($,{open:y,onClose:V,anchorRef:S,className:"dropdown-menu w-100",role:"listbox",children:a?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:"Loading…"}):e.length===0?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:l}):e.map((T,R)=>s.jsx("div",{role:"option","aria-selected":T.value===j,className:m("dropdown-item",R===L&&"active",T.disabled&&"disabled"),onMouseEnter:()=>U(R),onMouseDown:C=>{C.preventDefault(),T.disabled||A(R)},children:T.label},String(T.value)))})]})})}function Ye(e,n){return n?e.label.toLowerCase().includes(n.toLowerCase()):!0}function be({options:e,value:n,defaultValue:t,onChange:r,inputValue:a,onInputValueChange:l,loading:c,emptyText:o="No results",filter:i,id:d,name:u,disabled:b,readOnly:h,required:x,className:v,label:N,placeholder:j,helpText:p,error:y}){const[g,S]=D({value:n,defaultValue:t??null,onChange:r}),k=e.find(M=>M.value===g)??null,[w,I]=D({value:a,defaultValue:(k==null?void 0:k.label)??"",onChange:l}),[V,A]=f.useState(!1),L=f.useRef(null),U=f.useId(),K=d??U,T=i??Ye,R=e.filter(M=>T(M,w)),C=f.useCallback(()=>A(!1),[]),E=f.useCallback(M=>{const F=R[M];!F||F.disabled||(S(F.value),I(F.label),C())},[R,S,I,C]),{activeIndex:_,setActiveIndex:Z,handleKeyDown:$e}=Y({itemCount:R.length,isOpen:V,onSelect:E,onClose:C});return s.jsx(P,{id:K,label:N,required:x,error:y,helpText:p,className:v,children:s.jsxs("div",{className:"position-relative",children:[s.jsx("input",{ref:L,id:K,name:u,type:"text",className:m("form-control",y&&"is-invalid"),disabled:b,readOnly:h,required:x,placeholder:j,autoComplete:"off",role:"combobox","aria-expanded":V,"aria-haspopup":"listbox",value:w,onFocus:()=>A(!0),onChange:M=>{const F=M.target.value;I(F),A(!0),g!==null&&S(null)},onKeyDown:$e}),s.jsx($,{open:V,onClose:C,anchorRef:L,className:"dropdown-menu w-100",role:"listbox",children:c?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:"Loading…"}):R.length===0?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:o}):R.map((M,F)=>s.jsx("div",{role:"option","aria-selected":M.value===g,className:m("dropdown-item",F===_&&"active",M.disabled&&"disabled"),onMouseEnter:()=>Z(F),onMouseDown:Le=>{Le.preventDefault(),M.disabled||E(F)},children:M.label},String(M.value)))})]})})}function Ze(e){return s.jsx(P,{...e})}function xe({open:e,onClose:n,title:t,children:r,footer:a,className:l}){return W(e,n),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"modal d-block",tabIndex:-1,role:"dialog","aria-modal":"true",children:s.jsx("div",{className:m("modal-dialog",l),role:"document",children:s.jsxs("div",{className:"modal-content",children:[s.jsxs("div",{className:"modal-header",children:[t&&s.jsx("h5",{className:"modal-title",children:t}),s.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:n})]}),s.jsx("div",{className:"modal-body",children:r}),a&&s.jsx("div",{className:"modal-footer",children:a})]})})}),s.jsx("div",{className:"modal-backdrop show",onClick:n})]}):null}function Qe(e,n,t){const r=[],a=Math.max(1,e-t),l=Math.min(n,e+t);a>1&&(r.push(1),a>2&&r.push("ellipsis"));for(let c=a;c<=l;c++)r.push(c);return l<n&&(l<n-1&&r.push("ellipsis"),r.push(n)),r}function ve({currentPage:e,pageSize:n,totalItems:t,onPageChange:r,siblingCount:a=1,className:l}){const c=Math.max(1,Math.ceil(t/n)),o=Qe(e,c,a);return s.jsx("nav",{"aria-label":"Pagination",className:l,children:s.jsxs("ul",{className:"pagination mb-0",children:[s.jsx("li",{className:m("page-item",e<=1&&"disabled"),children:s.jsx("button",{type:"button",className:"page-link",disabled:e<=1,onClick:()=>r(e-1),children:"Previous"})}),o.map((i,d)=>i==="ellipsis"?s.jsx("li",{className:"page-item disabled",children:s.jsx("span",{className:"page-link",children:"…"})},`ellipsis-${d}`):s.jsx("li",{className:m("page-item",i===e&&"active"),children:s.jsx("button",{type:"button",className:"page-link","aria-current":i===e?"page":void 0,onClick:()=>r(i),children:i})},i)),s.jsx("li",{className:m("page-item",e>=c&&"disabled"),children:s.jsx("button",{type:"button",className:"page-link",disabled:e>=c,onClick:()=>r(e+1),children:"Next"})})]})})}function We(e,n){return!e||e.key!==n?{key:n,direction:"asc"}:e.direction==="asc"?{key:n,direction:"desc"}:null}function pe({columns:e,rows:n,rowKey:t,loading:r,error:a,emptyText:l="No data",className:c,selectedRowKeys:o,onSelectionChange:i,sort:d,onSortChange:u,page:b,pageSize:h,totalCount:x,onPageChange:v}){const N=!!i,j=new Set(o??[]),p=b!==void 0&&h!==void 0&&x!==void 0,y=p?Math.max(1,Math.ceil(x/h)):1;function g(){i&&(j.size===n.length?i([]):i(n.map(t)))}function S(k){if(!i)return;const w=new Set(j);w.has(k)?w.delete(k):w.add(k),i(Array.from(w))}return s.jsxs("div",{className:m("table-responsive",c),children:[s.jsxs("table",{className:"table table-hover align-middle",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[N&&s.jsx("th",{style:{width:"2.5rem"},children:s.jsx("input",{type:"checkbox",className:"form-check-input",checked:n.length>0&&j.size===n.length,onChange:g,"aria-label":"Select all rows"})}),e.map(k=>s.jsxs("th",{style:{width:k.width},role:k.sortable?"button":void 0,onClick:k.sortable&&u?()=>u(We(d,k.key)):void 0,children:[k.header,k.sortable&&(d==null?void 0:d.key)===k.key&&s.jsxs("span",{"aria-hidden":"true",children:[" ",d.direction==="asc"?"▲":"▼"]})]},k.key))]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:e.length+(N?1:0),className:"text-center text-body-secondary py-4",children:"Loading…"})}):a?s.jsx("tr",{children:s.jsx("td",{colSpan:e.length+(N?1:0),className:"text-center text-danger py-4",children:a})}):n.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:e.length+(N?1:0),className:"text-center text-body-secondary py-4",children:l})}):n.map(k=>{const w=t(k);return s.jsxs("tr",{children:[N&&s.jsx("td",{children:s.jsx("input",{type:"checkbox",className:"form-check-input",checked:j.has(w),onChange:()=>S(w),"aria-label":"Select row"})}),e.map(I=>s.jsx("td",{children:I.render?I.render(k):String(k[I.key]??"")},I.key))]},w)})})]}),p&&s.jsxs("div",{className:"d-flex justify-content-between align-items-center mt-2",children:[s.jsxs("span",{className:"text-body-secondary small",children:["Page ",b," of ",y," (",x," rows)"]}),s.jsx(ve,{currentPage:b,pageSize:h,totalItems:x,onPageChange:v})]})]})}function ge({size:e="md",variant:n,className:t,label:r="Loading..."}){return s.jsx("span",{className:m("spinner-border",e==="sm"&&"spinner-border-sm",n&&`text-${n}`,t),role:"status",children:s.jsx("span",{className:"visually-hidden",children:r})})}function z({variant:e="primary",size:n,disabled:t,loading:r,type:a="button",className:l,children:c,onClick:o,...i}){const d=t||r;return s.jsxs("button",{type:a,className:m("btn",`btn-${e}`,n&&`btn-${n}`,l),disabled:d,"aria-busy":r||void 0,onClick:d?void 0:o,...i,children:[r&&s.jsx(ge,{size:"sm",className:"me-2",label:""}),c]})}function te({variant:e="info",dismissible:n,onDismiss:t,className:r,children:a}){return s.jsxs("div",{className:m("alert",`alert-${e}`,n&&"alert-dismissible",r),role:"alert",children:[a,n&&s.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:t})]})}const je=f.createContext(null),Xe=4e3;function en({children:e}){const[n,t]=f.useState([]),r=f.useRef(0),a=f.useRef(new Map);f.useEffect(()=>{const i=a.current;return()=>{i.forEach(clearTimeout),i.clear()}},[]);const l=f.useCallback(i=>{const d=a.current.get(i);d&&(clearTimeout(d),a.current.delete(i)),t(u=>u.filter(b=>b.id!==i))},[]),c=f.useCallback((i,d)=>{const u=r.current++,b=(d==null?void 0:d.variant)??"info",h=(d==null?void 0:d.duration)??Xe;return t(x=>[...x,{id:u,message:i,variant:b}]),h>0&&a.current.set(u,setTimeout(()=>l(u),h)),u},[l]),o=f.useMemo(()=>({show:c,dismiss:l,success:(i,d)=>c(i,{...d,variant:"success"}),error:(i,d)=>c(i,{...d,variant:"danger"}),info:(i,d)=>c(i,{...d,variant:"info"}),warning:(i,d)=>c(i,{...d,variant:"warning"})}),[c,l]);return s.jsxs(je.Provider,{value:o,children:[e,s.jsx("div",{className:"toast-container position-fixed bottom-0 end-0 p-3",style:{zIndex:1090},children:n.map(i=>s.jsx(te,{variant:i.variant,dismissible:!0,onDismiss:()=>l(i.id),className:"shadow-sm",children:i.message},i.id))})]})}function nn(){const e=f.useContext(je);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}const ye=f.createContext(null);function tn({children:e}){const[n,t]=f.useState(null),r=f.useCallback(l=>new Promise(c=>{t({...l,resolve:c})}),[]),a=f.useCallback(l=>{n==null||n.resolve(l),t(null)},[n]);return s.jsxs(ye.Provider,{value:r,children:[e,s.jsx(xe,{open:n!==null,onClose:()=>a(!1),title:(n==null?void 0:n.title)??"Confirm",footer:s.jsxs(s.Fragment,{children:[s.jsx(z,{variant:"outline-secondary",onClick:()=>a(!1),children:(n==null?void 0:n.cancelLabel)??"Cancel"}),s.jsx(z,{variant:(n==null?void 0:n.confirmVariant)??"danger",onClick:()=>a(!0),children:(n==null?void 0:n.confirmLabel)??"Confirm"})]}),children:n==null?void 0:n.message})]})}function sn(){const e=f.useContext(ye);if(!e)throw new Error("useConfirm must be used within a ConfirmProvider");return e}function rn({variant:e="primary",pill:n,className:t,children:r}){return s.jsx("span",{className:m("badge",`bg-${e}`,n&&"rounded-pill",t),children:r})}function an({items:e,activeKey:n,defaultActiveKey:t,onChange:r,className:a}){var i;const[l,c]=D({value:n,defaultValue:t??((i=e[0])==null?void 0:i.key)??"",onChange:r}),o=e.find(d=>d.key===l);return s.jsxs("div",{className:a,children:[s.jsx("ul",{className:"nav nav-tabs",role:"tablist",children:e.map(d=>s.jsx("li",{className:"nav-item",role:"presentation",children:s.jsx("button",{type:"button",className:m("nav-link",d.key===l&&"active"),role:"tab","aria-selected":d.key===l,disabled:d.disabled,onClick:()=>c(d.key),children:d.label})},d.key))}),s.jsx("div",{className:"tab-content pt-3",role:"tabpanel",children:o==null?void 0:o.content})]})}function Ne({items:e,multiple:n=!1,openKeys:t,defaultOpenKeys:r,onChange:a,className:l}){const[c,o]=D({value:t,defaultValue:r??[],onChange:a}),i=new Set(c);function d(u){i.has(u)?o(c.filter(b=>b!==u)):o(n?[...c,u]:[u])}return s.jsx("div",{className:m("accordion",l),children:e.map(u=>{const b=i.has(u.key);return s.jsxs("div",{className:"accordion-item",children:[s.jsx("h2",{className:"accordion-header",children:s.jsx("button",{type:"button",className:m("accordion-button",!b&&"collapsed"),"aria-expanded":b,disabled:u.disabled,onClick:()=>d(u.key),children:u.header})}),b&&s.jsx("div",{className:"accordion-collapse",children:s.jsx("div",{className:"accordion-body",children:u.content})})]},u.key)})})}function ln({content:e,children:n,placement:t="top",className:r}){const[a,l]=f.useState(!1),c=f.useRef(null),o=f.useId();return s.jsxs("span",{ref:c,className:"position-relative d-inline-block",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>l(!0),onBlur:()=>l(!1),"aria-describedby":a?o:void 0,children:[n,s.jsx($,{open:a,onClose:()=>l(!1),anchorRef:c,className:m("tooltip show",`bs-tooltip-${t}`,"position-absolute","w-auto",r),children:s.jsx("span",{id:o,role:"tooltip",className:"tooltip-inner",children:e})})]})}function on({title:e,content:n,children:t,placement:r="bottom",className:a}){const[l,c]=f.useState(!1),o=f.useRef(null);return s.jsxs("span",{ref:o,className:"position-relative d-inline-block",onClick:()=>c(i=>!i),children:[t,s.jsxs($,{open:l,onClose:()=>c(!1),anchorRef:o,className:m("popover show",`bs-popover-${r}`,"position-absolute","w-auto",a),children:[e&&s.jsx("h3",{className:"popover-header",children:e}),s.jsx("div",{className:"popover-body",children:n})]})]})}function cn({header:e,footer:n,className:t,children:r}){return s.jsxs("div",{className:m("card",t),children:[e&&s.jsx("div",{className:"card-header",children:e}),s.jsx("div",{className:"card-body",children:r}),n&&s.jsx("div",{className:"card-footer",children:n})]})}function dn({className:e,vertical:n,label:t}){return n?s.jsx("div",{className:m("vr",e),role:"separator","aria-orientation":"vertical"}):t?s.jsxs("div",{className:m("d-flex align-items-center gap-2 my-3",e),role:"separator",children:[s.jsx("hr",{className:"flex-grow-1 m-0"}),s.jsx("span",{className:"text-body-secondary small",children:t}),s.jsx("hr",{className:"flex-grow-1 m-0"})]}):s.jsx("hr",{className:m("my-3",e),role:"separator"})}function un({direction:e="column",gap:n=2,align:t,justify:r,wrap:a,className:l,children:c}){return s.jsx("div",{className:m("d-flex",e==="row"?"flex-row":"flex-column",`gap-${n}`,t&&`align-items-${t}`,r&&`justify-content-${r}`,a&&"flex-wrap",l),children:c})}function fn({fluid:e,className:n,children:t}){return s.jsx("div",{className:m(e?"container-fluid":"container",n),children:t})}function mn({className:e,children:n}){return s.jsx("div",{className:m("row",e),children:n})}function hn({span:e,sm:n,md:t,lg:r,xl:a,className:l,children:c}){return s.jsx("div",{className:m(e?`col-${e}`:"col",n?`col-sm-${n}`:void 0,t?`col-md-${t}`:void 0,r?`col-lg-${r}`:void 0,a?`col-xl-${a}`:void 0,l),children:c})}function ke({items:e,className:n}){return s.jsx("nav",{"aria-label":"breadcrumb",className:n,children:s.jsx("ol",{className:"breadcrumb mb-0",children:e.map((t,r)=>{const a=r===e.length-1,l=!a&&(t.href||t.onClick);return s.jsx("li",{className:m("breadcrumb-item",a&&"active"),"aria-current":a?"page":void 0,children:l?s.jsx("a",{href:t.href??"#",onClick:c=>{var o;t.href||c.preventDefault(),(o=t.onClick)==null||o.call(t)},children:t.label}):t.label},r)})})})}function bn({items:e,children:n,placement:t="start",className:r}){const[a,l]=f.useState(!1),c=f.useRef(null),o=f.useCallback(()=>l(!1),[]),i=f.useCallback(h=>{var v;const x=e[h];!x||x.disabled||((v=x.onSelect)==null||v.call(x),o())},[e,o]),{activeIndex:d,setActiveIndex:u,handleKeyDown:b}=Y({itemCount:e.length,isOpen:a,onSelect:i,onClose:o});return s.jsxs("span",{ref:c,className:"position-relative d-inline-block",onClick:()=>l(h=>!h),onKeyDown:b,children:[n,s.jsx($,{open:a,onClose:o,anchorRef:c,role:"menu",className:m("dropdown-menu show",t==="end"&&"dropdown-menu-end",r),children:e.map((h,x)=>s.jsx("button",{type:"button",role:"menuitem",className:m("dropdown-item",x===d&&"active",h.disabled&&"disabled",h.danger&&"text-danger"),disabled:h.disabled,onMouseEnter:()=>u(x),onMouseDown:v=>v.preventDefault(),onClick:v=>{v.stopPropagation(),i(x)},children:h.label},h.key))})]})}function xn({steps:e,currentStep:n,className:t}){return s.jsx("ol",{className:m("d-flex list-unstyled align-items-center",t),children:e.map((r,a)=>{const l=a<n?"complete":a===n?"active":"upcoming",c=a===e.length-1;return s.jsxs("li",{className:m("d-flex align-items-center",!c&&"flex-grow-1"),children:[s.jsxs("div",{className:"d-flex align-items-center gap-2",children:[s.jsx("span",{className:m("d-flex align-items-center justify-content-center rounded-circle flex-shrink-0",l==="complete"?"bg-primary text-white":l==="active"?"border border-primary text-primary":"border text-body-secondary"),style:{width:"2rem",height:"2rem"},"aria-current":l==="active"?"step":void 0,children:l==="complete"?"✓":a+1}),s.jsxs("div",{children:[s.jsx("div",{className:m("small fw-semibold",l==="upcoming"&&"text-body-secondary"),children:r.label}),r.description&&s.jsx("div",{className:"small text-body-secondary",children:r.description})]})]}),!c&&s.jsx("hr",{className:"flex-grow-1 mx-2"})]},r.key)})})}function vn(e){var a,l;const n=e.trim().split(/\s+/),t=((a=n[0])==null?void 0:a[0])??"",r=n.length>1?((l=n[n.length-1])==null?void 0:l[0])??"":"";return(t+r).toUpperCase()}const pn={sm:"1.75rem",md:"2.5rem",lg:"3.5rem"};function gn({src:e,name:n,size:t="md",className:r}){const a=pn[t];return e?s.jsx("img",{src:e,alt:n??"",className:m("rounded-circle",r),style:{width:a,height:a,objectFit:"cover"}}):s.jsx("span",{className:m("d-inline-flex align-items-center justify-content-center rounded-circle bg-secondary text-white",r),style:{width:a,height:a,fontSize:`calc(${a} * 0.4)`},role:n?"img":void 0,"aria-label":n,children:n?vn(n):null})}function jn({variant:e="secondary",onRemove:n,className:t,children:r}){return s.jsxs("span",{className:m("badge d-inline-flex align-items-center gap-1",`bg-${e}`,t),children:[r,n&&s.jsx("button",{type:"button",className:"btn-close btn-close-white",style:{fontSize:"0.55rem"},"aria-label":"Remove",onClick:n})]})}function yn({width:e="100%",height:n="1rem",circle:t,className:r}){return s.jsx("span",{className:m("placeholder-glow d-inline-block",r),style:{width:e,height:n},"aria-hidden":"true",children:s.jsx("span",{className:m("placeholder w-100 h-100 d-block",t&&"rounded-circle")})})}function Nn({value:e,defaultValue:n,onChange:t,min:r=0,max:a=100,step:l=1,id:c,name:o,disabled:i,required:d,className:u,label:b,helpText:h,error:x}){const[v,N]=D({value:e,defaultValue:n??r,onChange:t}),j=f.useId(),p=c??j;return s.jsxs(P,{id:p,label:b,required:d,error:x,helpText:h,className:u,children:[s.jsx("input",{id:p,name:o,type:"range",className:"form-range",disabled:i,required:d,min:r,max:a,step:l,value:v,onChange:y=>N(Number(y.target.value))}),s.jsx("div",{className:"small text-body-secondary",children:v})]})}function kn({value:e,defaultValue:n,onChange:t,max:r=5,disabled:a,className:l}){const[c,o]=D({value:e,defaultValue:n??0,onChange:t});return s.jsx("div",{className:m("d-inline-flex gap-1",l),role:"radiogroup","aria-label":"Rating",children:Array.from({length:r},(i,d)=>d+1).map(i=>s.jsx("button",{type:"button",className:"btn btn-link p-0 border-0",disabled:a,role:"radio","aria-checked":i===c,"aria-label":`${i} star${i>1?"s":""}`,onClick:()=>o(i),children:s.jsx("span",{"aria-hidden":"true",style:{fontSize:"1.25rem",color:i<=c?"#f5b301":"#ced4da"},children:"★"})},i))})}function Sn({value:e,variant:n="primary",label:t,className:r}){const a=Math.max(0,Math.min(100,e));return s.jsx("div",{className:m("progress",r),role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,children:s.jsx("div",{className:m("progress-bar",`bg-${n}`),style:{width:`${a}%`},children:t?`${Math.round(a)}%`:null})})}const wn={sm:"0.875em",lg:"1.5em",xl:"2em"};function Cn({name:e,size:n,className:t,label:r}){return s.jsx("i",{className:m(e,t),style:n?{fontSize:wn[n]}:void 0,role:r?"img":void 0,"aria-label":r,"aria-hidden":r?void 0:!0})}function In({brand:e,start:n,end:t,variant:r="light",className:a}){return s.jsx("nav",{className:m("navbar navbar-expand-lg border-bottom",r==="dark"?"navbar-dark bg-dark":"navbar-light bg-light",a),children:s.jsxs("div",{className:"container-fluid",children:[e&&s.jsx("span",{className:"navbar-brand mb-0",children:e}),n&&s.jsx("div",{className:"d-flex align-items-center gap-3",children:n}),t&&s.jsx("div",{className:"d-flex align-items-center gap-3 ms-auto",children:t})]})})}function Dn(e){return"items"in e}function ae({item:e}){return s.jsxs("a",{href:e.href??"#",className:m("nav-link d-flex align-items-center gap-2",e.active&&"active",e.disabled&&"disabled"),"aria-current":e.active?"page":void 0,"aria-disabled":e.disabled,onClick:n=>{var t;e.href||n.preventDefault(),!e.disabled&&((t=e.onClick)==null||t.call(e))},children:[e.icon,e.label]})}function Rn({sections:e,header:n,footer:t,className:r}){return s.jsxs("div",{className:m("d-flex flex-column h-100",r),children:[n&&s.jsx("div",{className:"p-3 border-bottom",children:n}),s.jsx("nav",{className:"nav flex-column flex-grow-1 p-2 gap-1",children:e.map(a=>Dn(a)?s.jsx(Ne,{className:"border-0",defaultOpenKeys:a.defaultOpen?[a.key]:[],items:[{key:a.key,header:a.label,content:s.jsx("div",{className:"nav flex-column ps-2 gap-1",children:a.items.map(l=>s.jsx(ae,{item:l},l.key))})}]},a.key):s.jsx(ae,{item:a},a.key))}),t&&s.jsx("div",{className:"p-3 border-top",children:t})]})}function Vn({title:e,description:n,breadcrumbItems:t,actions:r,className:a}){return s.jsxs("div",{className:m("mb-4",a),children:[t&&t.length>0&&s.jsx(ke,{items:t,className:"mb-2"}),s.jsxs("div",{className:"d-flex align-items-start justify-content-between gap-3 flex-wrap",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"h3 mb-1",children:e}),n&&s.jsx("p",{className:"text-body-secondary mb-0",children:n})]}),r&&s.jsx("div",{className:"d-flex align-items-center gap-2",children:r})]})]})}class Se extends Error{constructor(n,t,r){super(`HTTP ${n} ${t} for ${r}`),this.name="HttpError",this.status=n,this.statusText=t,this.url=r}}function Tn(e){if(!e)return"";const n=new URLSearchParams;for(const[r,a]of Object.entries(e))a!=null&&n.set(r,String(a));const t=n.toString();return t?`?${t}`:""}function we(e={}){const{baseUrl:n="",fetcher:t=fetch,buildRequestInit:r}=e;return{async get(a,l={}){const c=`${n}${a}${Tn(l.params)}`;let o={method:"GET",signal:l.signal};r&&(o=r(c,o));const i=await t(c,o);if(!i.ok)throw new Se(i.status,i.statusText,c);return await i.json()}}}const Ce=we();function Mn(e){return Object.keys(e).sort().reduce((n,t)=>(n[t]=e[t],n),{})}function H({client:e=Ce,url:n,params:t,mapResponse:r,enabled:a=!0}){const[l,c]=f.useState("idle"),[o,i]=f.useState([]),[d,u]=f.useState(null),[b,h]=f.useState(0),x=f.useMemo(()=>t?JSON.stringify(Mn(t)):"",[t]),v=f.useRef(0),N=f.useRef(r);N.current=r,f.useEffect(()=>{if(!a||!n){c("idle"),i([]),u(null);return}const p=++v.current,y=new AbortController;return c("loading"),u(null),e.get(n,{params:t,signal:y.signal}).then(g=>{if(p!==v.current)return;const S=N.current(g);i(S),c(S.length===0?"empty":"success")}).catch(g=>{p===v.current&&(g instanceof DOMException&&g.name==="AbortError"||(u(g instanceof Error?g:new Error(String(g))),c("error")))}),()=>{y.abort()}},[e,n,x,a,b]);const j=f.useCallback(()=>h(p=>p+1),[]);return{state:l,items:o,error:d,reload:j}}function Ie(e,n){const[t,r]=f.useState(e);return f.useEffect(()=>{const a=setTimeout(()=>r(e),n);return()=>clearTimeout(a)},[e,n]),t}function q(e){if(Array.isArray(e))return e;if(e&&typeof e=="object"&&Array.isArray(e.items))return e.items;throw new Error("Unable to normalize remote response into an array. Provide an explicit `mapResponse` for this endpoint's response shape.")}function J(e,n,t){if(e===null||typeof e!="object")throw new Error("Remote item is not an object; cannot read valueMember/displayMember from it.");const r=e;return{value:r[n],label:String(r[t]??"")}}function De({url:e,params:n,valueMember:t,displayMember:r,mapResponse:a,client:l,enabled:c,...o}){const{state:i,items:d,error:u}=H({client:l,url:e,params:n,enabled:c,mapResponse:h=>(a?a(h):q(h)).map(v=>J(v,t,r))}),b=o.error??(i==="error"?(u==null?void 0:u.message)??"Failed to load options":void 0);return s.jsx(he,{...o,options:d,loading:i==="loading",error:b})}function En({url:e,params:n,searchParam:t,valueMember:r,displayMember:a,mapResponse:l,minSearchLength:c=1,debounceMs:o=300,client:i,inputValue:d,onInputValueChange:u,...b}){const[h,x]=D({value:d,defaultValue:"",onChange:u}),v=Ie(h,o),N=v.length>=c,{state:j,items:p,error:y}=H({client:i,url:e,enabled:N,params:{...n,[t]:v},mapResponse:S=>(l?l(S):q(S)).map(w=>J(w,r,a))}),g=b.error??(j==="error"?(y==null?void 0:y.message)??"Failed to load suggestions":void 0);return s.jsx(be,{...b,options:p,loading:j==="loading",error:g,inputValue:h,onInputValueChange:x,filter:()=>!0})}function Re({url:e,params:n,mapResponse:t,getTotalCount:r,pageSize:a=20,client:l,...c}){const[o,i]=f.useState(1),[d,u]=f.useState(null),b=f.useMemo(()=>JSON.stringify(n??{}),[n]),h=f.useRef(!0);f.useEffect(()=>{if(h.current){h.current=!1;return}i(1)},[b]);const x=f.useMemo(()=>({...n,page:o,pageSize:a,...d?{sortKey:d.key,sortDirection:d.direction}:{}}),[n,o,a,d]),v=f.useRef(void 0),{state:N,items:j,error:p}=H({client:l,url:e,params:x,mapResponse:w=>(v.current=w,t?t(w):q(w))}),y=v.current!==void 0?r==null?void 0:r(v.current):void 0,S=j.length>=a&&a>0?o*a+1:(o-1)*a+j.length,k=y??S;return s.jsx(pe,{...c,rows:j,loading:N==="loading",error:p==null?void 0:p.message,page:o,pageSize:a,totalCount:k,onPageChange:i,sort:d,onSortChange:w=>{u(w),i(1)}})}function An({url:e,params:n,valueMember:t,displayMember:r,mapResponse:a,client:l,enabled:c,...o}){const{state:i,items:d,error:u}=H({client:l,url:e,params:n,enabled:c,mapResponse:h=>(a?a(h):q(h)).map(v=>J(v,t,r))}),b=o.error??(i==="error"?(u==null?void 0:u.message)??"Failed to load options":void 0);return s.jsx(ue,{...o,options:d,loading:i==="loading",error:b})}function Pn({url:e,params:n,valueMember:t,displayMember:r,mapResponse:a,client:l,enabled:c,...o}){const{state:i,items:d,error:u}=H({client:l,url:e,params:n,enabled:c,mapResponse:h=>(a?a(h):q(h)).map(v=>J(v,t,r))}),b=o.error??(i==="error"?(u==null?void 0:u.message)??"Failed to load options":void 0);return s.jsx(fe,{...o,options:d,loading:i==="loading",error:b})}function Fn(){const e=new Map,n=new Set;return{register(t,r){e.set(t,r)},resolve(t,r){const a=e.get(t.component);return a?a(t,r):(n.has(t.component)||(n.add(t.component),console.warn(`Smart: no resolver registered for component "${t.component}" (field "${t.name}"). Skipping.`)),null)},has(t){return e.has(t)}}}function On(e){const n=new Map(Object.entries(e??{}));return{register(t,r){n.set(t,r)},resolve(t){return n.get(t)}}}function $n(){const e=new Map;return{register(n,t){e.set(n,t)},resolve(n){return e.get(n)}}}function Ln(e){return"dataSource"in e}function Kn(e,n){if(!e)return;const t={};for(const[r,a]of Object.entries(e))t[r]=a.kind==="static"?a.value:n[a.field];return t}function le(e,n,t){return n&&t?t(n):e}function G(e,n){const{values:t,translate:r}=n;return{metadata:e,visible:e.visible??!0,readOnly:e.readOnly??!1,disabled:e.disabled??!1,required:e.required??!1,label:le(e.label,e.labelKey,r),placeholder:e.placeholder,helpText:e.helpText,validationMessage:le(e.validationMessage,e.validationMessageKey,r),params:Ln(e)?Kn(e.dataSource.params,t):void 0}}function Bn(e,n,t){const r=n==null?void 0:n.fields.find(a=>a.name===e);if(r)return G(r,t)}const Hn=[];function qn(e,n){const t={};for(const r of n)t[r]=e[r];return t}function Ve(e,n,t){const r=e??Hn,a=qn(n,r),l=r.length===0?"":JSON.stringify(a),c=f.useRef(null),o=f.useRef(t);o.current=t,f.useEffect(()=>{var d;if(r.length===0)return;const i=c.current;if(i&&i.key!==l)for(const u of r)Object.is(i.snapshot[u],a[u])||(d=o.current)==null||d.call(o,u);c.current={key:l,snapshot:a}},[l])}function se(e,n){const{actions:t,translate:r}=n,a=t.resolve(e.id);return{metadata:e,visible:e.visible??!0,enabled:(e.enabled??!0)&&!!a,label:e.labelKey&&r?r(e.labelKey):e.label,handler:a}}function Gn(e,n,t){var a;const r=(a=n==null?void 0:n.actions)==null?void 0:a.find(l=>l.id===e);if(r)return se(r,t)}const Te=(e,n)=>{const t=G(e,{values:n.values,translate:n.translate});if(!t.visible)return null;const r=n.dataSources.resolve(e.dataSource.id);return r?s.jsx(De,{label:t.label,url:r.url,client:r.client,params:t.params,valueMember:e.valueMember,displayMember:e.displayMember,required:t.required,readOnly:t.readOnly,disabled:t.disabled,helpText:t.helpText,error:t.validationMessage,value:n.values[e.name]??null,onChange:a=>n.onFieldChange(e.name,a)}):(console.warn(`Smart: no data source registered for id "${e.dataSource.id}" (field "${e.name}"). Skipping.`),null)},Un={text:e=>e==null?"":String(e),boolean:(e,n)=>n?n(e?"smart.boolean.true":"smart.boolean.false"):e?"Yes":"No",date:e=>{if(e==null||e==="")return"";const n=e instanceof Date?e:new Date(String(e));return Number.isNaN(n.getTime())?String(e):n.toLocaleDateString()},currency:e=>{const n=Number(e);return Number.isFinite(n)?n.toLocaleString(void 0,{style:"currency",currency:"USD"}):String(e??"")}};function _n(e,n){if(e.visible===!1)return null;const t=e.headerKey&&n?n(e.headerKey):e.header??e.key,r=e.format?Un[e.format]:void 0;return{key:e.key,header:t,sortable:e.sortable,render:r?a=>r(a[e.key],n):void 0}}const Me=(e,n)=>{const t=G(e,{values:n.values,translate:n.translate});if(!t.visible)return null;const r=n.dataSources.resolve(e.dataSource.id);if(!r)return console.warn(`Smart: no data source registered for id "${e.dataSource.id}" (field "${e.name}"). Skipping.`),null;const a=e.columns.map(o=>_n(o,n.translate)).filter(o=>o!==null),l=e.totalCountField,c=l?o=>{const i=o==null?void 0:o[l];return typeof i=="number"?i:void 0}:void 0;return s.jsx(Re,{url:r.url,client:r.client,params:t.params,columns:a,rowKey:o=>o[e.rowKey],getTotalCount:c})};function ie(e){if(!e)return;const n=new Date(e);return Number.isNaN(n.getTime())?void 0:n}const Ee=(e,n)=>{const t=G(e,{values:n.values,translate:n.translate});return t.visible?s.jsx(me,{label:t.label,required:t.required,readOnly:t.readOnly,disabled:t.disabled,helpText:t.helpText,error:t.validationMessage,min:ie(e.minDate),max:ie(e.maxDate),value:n.values[e.name]??null,onChange:r=>n.onFieldChange(e.name,r)}):null},Ae=(e,n)=>{const t=G(e,{values:n.values,translate:n.translate});return t.visible?s.jsx(B,{label:t.label,required:t.required,readOnly:t.readOnly,disabled:t.disabled,helpText:t.helpText,placeholder:t.placeholder,error:t.validationMessage,maxLength:e.maxLength,value:n.values[e.name]??"",onChange:r=>n.onFieldChange(e.name,r)}):null};function Jn(e){e.register("Input",Ae),e.register("ComboBox",Te),e.register("DatePicker",Ee),e.register("DataGrid",Me)}function Pe({metadata:e,ctx:n}){const t=n.onMetadataRefreshNeeded;return Ve(e.dependsOn,n.values,t?r=>t(e.name,r):void 0),e.visible===!1?null:n.registry.resolve(e,n)}const Fe=1;function zn(e){const n=Number(e.split(".")[0]);return Number.isFinite(n)&&n===Fe}function Yn({metadata:e,ctx:n}){return zn(e.schemaVersion)?s.jsx(s.Fragment,{children:e.fields.map(t=>s.jsx(Pe,{metadata:t,ctx:n},t.name))}):s.jsxs(te,{variant:"danger",children:['Unsupported form schema version "',e.schemaVersion,'" — this app understands schema version ',Fe,".x."]})}function Oe({metadata:e,ctx:n}){const t=se(e,n);return t.visible?s.jsx(z,{disabled:!t.enabled,onClick:()=>{var r;return(r=t.handler)==null?void 0:r.call(t)},children:t.label??e.id}):null}function Zn({metadata:e,ctx:n}){return!e.actions||e.actions.length===0?null:s.jsx(s.Fragment,{children:e.actions.map(t=>s.jsx(Oe,{metadata:t,ctx:n},t.id))})}exports.Accordion=Ne;exports.Alert=te;exports.AutoComplete=be;exports.Avatar=gn;exports.Badge=rn;exports.Breadcrumb=ke;exports.Button=z;exports.Card=cn;exports.CheckBox=Ge;exports.Col=hn;exports.ComboBox=he;exports.ConfirmProvider=tn;exports.Container=fn;exports.DataGrid=pe;exports.DatePicker=me;exports.DateTimePicker=ze;exports.Divider=dn;exports.FileInput=qe;exports.FormField=Ze;exports.HttpError=Se;exports.Icon=Cn;exports.Input=B;exports.Label=oe;exports.Menu=bn;exports.Modal=xe;exports.MultiSelect=fe;exports.Navbar=In;exports.NumberInput=Be;exports.PageHeader=Vn;exports.Pagination=ve;exports.PasswordInput=He;exports.Popover=on;exports.Popup=$;exports.ProgressBar=Sn;exports.RadioButton=de;exports.RadioGroup=_e;exports.Rating=kn;exports.RemoteAutoComplete=En;exports.RemoteComboBox=De;exports.RemoteDataGrid=Re;exports.RemoteMultiSelect=Pn;exports.RemoteSelect=An;exports.Row=mn;exports.Select=ue;exports.Sidebar=Rn;exports.Skeleton=yn;exports.Slider=Nn;exports.SmartAction=Oe;exports.SmartActions=Zn;exports.SmartField=Pe;exports.SmartForm=Yn;exports.Spinner=ge;exports.Stack=un;exports.Stepper=xn;exports.Switch=Ue;exports.Tabs=an;exports.Tag=jn;exports.TextArea=Ke;exports.TimePicker=Je;exports.ToastProvider=en;exports.Tooltip=ln;exports.ValidationMessage=Q;exports.comboBoxResolver=Te;exports.createHttpClient=we;exports.createSmartActionRegistry=$n;exports.createSmartComponentRegistry=Fn;exports.createSmartDataSourceRegistry=On;exports.dataGridResolver=Me;exports.datePickerResolver=Ee;exports.defaultArrayNormalization=q;exports.defaultHttpClient=Ce;exports.fromDateInputValue=X;exports.fromTimeInputValue=ne;exports.inputResolver=Ae;exports.registerBuiltInResolvers=Jn;exports.resolveSmartActionMetadata=se;exports.resolveSmartFieldMetadata=G;exports.toDateInputValue=O;exports.toSelectOption=J;exports.toTimeInputValue=ee;exports.useConfirm=sn;exports.useDebouncedValue=Ie;exports.useRemoteData=H;exports.useSmartAction=Gn;exports.useSmartDependencies=Ve;exports.useSmartField=Bn;exports.useToast=nn;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),f=require("react");function m(...e){return e.filter(Boolean).join(" ")}function he({htmlFor:e,required:n,className:t,children:r}){return s.jsxs("label",{htmlFor:e,className:m("form-label",t),children:[r,n&&s.jsx("span",{className:"text-danger",children:" *"})]})}function ee({error:e,helpText:n,className:t}){return e?s.jsx("div",{className:m("invalid-feedback d-block",t),children:e}):n?s.jsx("div",{className:m("form-text",t),children:n}):null}function F({id:e,label:n,required:t,error:r,helpText:a,className:l,children:o}){return s.jsxs("div",{className:m("mb-3",l),children:[n&&s.jsx(he,{htmlFor:e,required:t,children:n}),o,s.jsx(ee,{error:r,helpText:a})]})}function V({value:e,defaultValue:n,onChange:t}){const r=e!==void 0,a=f.useRef(r);process.env.NODE_ENV!=="production"&&a.current!==r&&console.error("[react-components] A component switched between controlled and uncontrolled `value`. Decide between passing `value` (controlled) or `defaultValue` (uncontrolled) for the lifetime of the component, per the library's controlled/uncontrolled policy.");const[l,o]=f.useState(n),c=r?e:l,i=f.useCallback(d=>{r||o(d),t==null||t(d)},[r,t]);return[c,i]}function G(e){const{id:n,name:t,disabled:r,readOnly:a,required:l,className:o,label:c,placeholder:i,helpText:d,error:u,value:x,defaultValue:h,onChange:p,onBlur:v,type:N="text",maxLength:w,autoFocus:g,inputProps:k,endAdornment:y}=e,[C,b]=V({value:x,defaultValue:h??"",onChange:p}),j=f.useId(),S=n??j,I=s.jsx("input",{id:S,name:t,className:m("form-control",u&&"is-invalid"),disabled:r,readOnly:a,required:l,placeholder:i,maxLength:w,autoFocus:g,value:C,onChange:R=>b(R.target.value),onBlur:v,type:N,...k});return s.jsx(F,{id:S,label:c,required:l,error:u,helpText:d,className:o,children:y?s.jsxs("div",{className:"input-group",children:[I,y]}):I})}function Je(e){const{id:n,name:t,disabled:r,readOnly:a,required:l,className:o,label:c,placeholder:i,helpText:d,error:u,value:x,defaultValue:h,onChange:p,onBlur:v,rows:N=3,maxLength:w}=e,[g,k]=V({value:x,defaultValue:h??"",onChange:p}),y=f.useId(),C=n??y;return s.jsx(F,{id:C,label:c,required:l,error:u,helpText:d,className:o,children:s.jsx("textarea",{id:C,name:t,className:m("form-control",u&&"is-invalid"),disabled:r,readOnly:a,required:l,placeholder:i,rows:N,maxLength:w,value:g,onChange:b=>k(b.target.value),onBlur:v})})}function Ze({value:e,defaultValue:n,onChange:t,min:r,max:a,step:l,...o}){const[c,i]=V({value:e,defaultValue:n??null,onChange:t});return s.jsx(G,{...o,value:c===null?"":String(c),onChange:d=>{if(d.trim()===""){i(null);return}const u=Number(d);Number.isNaN(u)||i(u)},inputProps:{inputMode:"decimal",min:r,max:a,step:l}})}function Ye(e){const[n,t]=f.useState(!1);return s.jsx(G,{...e,inputProps:{type:n?"text":"password",autoComplete:"current-password"},endAdornment:s.jsx("button",{type:"button",className:"btn btn-outline-secondary","aria-label":n?"Hide password":"Show password","aria-pressed":n,onClick:()=>t(r=>!r),children:n?"Hide":"Show"})})}function Qe({id:e,name:n,disabled:t,required:r,className:a,label:l,helpText:o,error:c,accept:i,multiple:d,onChange:u}){const x=f.useId(),h=e??x;return s.jsx(F,{id:h,label:l,required:r,error:c,helpText:o,className:a,children:s.jsx("input",{id:h,name:n,type:"file",className:m("form-control",c&&"is-invalid"),disabled:t,required:r,accept:i,multiple:d,onChange:p=>u==null?void 0:u(p.target.files)})})}function xe({id:e,name:n,disabled:t,required:r,wrapperClassName:a,role:l,label:o,helpText:c,error:i,checked:d,onChange:u,className:x}){const h=f.useId(),p=e??h;return s.jsxs("div",{className:m(a,x),children:[s.jsx("input",{id:p,name:n,type:"checkbox",role:l,className:m("form-check-input",i&&"is-invalid"),disabled:t,required:r,checked:d,onChange:v=>u(v.target.checked)}),o&&s.jsx("label",{htmlFor:p,className:"form-check-label",children:o}),s.jsx(ee,{error:i,helpText:c})]})}function Xe(e){const[n,t]=V({value:e.checked,defaultValue:e.defaultChecked??!1,onChange:e.onChange});return s.jsx(xe,{id:e.id,name:e.name,disabled:e.disabled,required:e.required,className:e.className,wrapperClassName:"form-check mb-3",label:e.label,helpText:e.helpText,error:e.error,checked:n,onChange:t})}function en(e){const[n,t]=V({value:e.checked,defaultValue:e.defaultChecked??!1,onChange:e.onChange});return s.jsx(xe,{id:e.id,name:e.name,disabled:e.disabled,required:e.required,className:e.className,wrapperClassName:"form-check form-switch mb-3",role:"switch",label:e.label,helpText:e.helpText,error:e.error,checked:n,onChange:t})}function be({id:e,name:n,value:t,label:r,checked:a,disabled:l,className:o,onChange:c}){const i=f.useId(),d=e??i;return s.jsxs("div",{className:m("form-check",o),children:[s.jsx("input",{id:d,name:n,type:"radio",className:"form-check-input",value:String(t),checked:a,disabled:l,onChange:()=>c==null?void 0:c(t)}),r&&s.jsx("label",{htmlFor:d,className:"form-check-label",children:r})]})}function nn({options:e,value:n,defaultValue:t,onChange:r,inline:a,id:l,name:o,disabled:c,required:i,className:d,label:u,helpText:x,error:h}){const[p,v]=V({value:n,defaultValue:t??null,onChange:g=>{g!==null&&(r==null||r(g))}}),N=f.useId(),w=o??l??N;return s.jsx(F,{label:u,required:i,error:h,helpText:x,className:d,children:s.jsx("div",{role:"radiogroup","aria-label":u,"aria-required":i,className:m(a&&"d-flex gap-3"),children:e.map(g=>s.jsx(be,{name:w,value:g.value,label:g.label,checked:g.value===p,disabled:c||g.disabled,onChange:k=>v(k)},String(g.value)))})})}function pe({options:e,value:n,defaultValue:t,onChange:r,placeholder:a,loading:l,id:o,name:c,disabled:i,readOnly:d,required:u,className:x,label:h,helpText:p,error:v}){const[N,w]=V({value:n,defaultValue:t??null,onChange:r}),g=f.useId(),k=o??g;return s.jsx(F,{id:k,label:h,required:u,error:v,helpText:p,className:x,children:s.jsxs("select",{id:k,name:c,className:m("form-select",v&&"is-invalid"),disabled:i||d||l,required:u,value:N===null?"":String(N),onChange:y=>{const C=y.target.value;if(C===""){w(null);return}const b=e.find(j=>String(j.value)===C);w(b?b.value:null)},children:[l&&s.jsx("option",{value:"",children:"Loading…"}),!l&&a&&s.jsx("option",{value:"",children:a}),e.map(y=>s.jsx("option",{value:String(y.value),disabled:y.disabled,children:y.label},String(y.value)))]})})}function ne(e,n){f.useEffect(()=>{if(!e)return;function t(r){r.key==="Escape"&&n()}return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,n])}function K({open:e,onClose:n,anchorRef:t,className:r,role:a,children:l}){const o=f.useRef(null);return ne(e,n),f.useEffect(()=>{if(!e)return;function c(i){var u,x;const d=i.target;(u=o.current)!=null&&u.contains(d)||(x=t.current)!=null&&x.contains(d)||n()}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[e,n,t]),e?s.jsx("div",{ref:o,className:m("show",r),role:a,children:l}):null}function Y({itemCount:e,isOpen:n,onSelect:t,onClose:r}){const[a,l]=f.useState(-1);f.useEffect(()=>{n||l(-1)},[n]),ne(n,r);const o=f.useCallback(c=>{if(!n){(c.key==="ArrowDown"||c.key==="Enter")&&c.preventDefault();return}switch(c.key){case"ArrowDown":c.preventDefault(),l(i=>e===0?-1:(i+1)%e);break;case"ArrowUp":c.preventDefault(),l(i=>e===0?-1:(i-1+e)%e);break;case"Home":c.preventDefault(),l(e===0?-1:0);break;case"End":c.preventDefault(),l(e===0?-1:e-1);break;case"Enter":a>=0&&(c.preventDefault(),t(a));break}},[n,e,a,t]);return{activeIndex:a,setActiveIndex:l,handleKeyDown:o}}function ve({options:e,values:n,defaultValues:t,onChange:r,loading:a,emptyText:l="No options",id:o,name:c,disabled:i,readOnly:d,required:u,className:x,label:h,placeholder:p="Select...",helpText:v,error:N}){const[w,g]=V({value:n,defaultValue:t??[],onChange:r}),[k,y]=f.useState(!1),C=f.useRef(null),b=f.useId(),j=o??b,S=new Set(w),I=f.useCallback(()=>y(!1),[]),R=f.useCallback(D=>{const A=e[D];if(!A||A.disabled)return;const U=S.has(A.value)?w.filter(X=>X!==A.value):[...w,A.value];g(U)},[e,w,S,g]),{activeIndex:T,setActiveIndex:B,handleKeyDown:H}=Y({itemCount:e.length,isOpen:k,onSelect:R,onClose:I}),E=e.filter(D=>S.has(D.value)).map(D=>D.label).join(", ");return s.jsx(F,{id:j,label:h,required:u,error:N,helpText:v,className:x,children:s.jsxs("div",{className:"position-relative",children:[s.jsx("button",{ref:C,id:j,type:"button",name:c,className:m("form-select text-start",N&&"is-invalid"),disabled:i||d,"aria-haspopup":"listbox","aria-expanded":k,onClick:()=>y(D=>!D),onKeyDown:H,children:E||s.jsx("span",{className:"text-body-secondary",children:p})}),s.jsx(K,{open:k,onClose:I,anchorRef:C,className:"dropdown-menu w-100",role:"listbox",children:a?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:"Loading…"}):e.length===0?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:l}):e.map((D,A)=>s.jsxs("div",{role:"option","aria-selected":S.has(D.value),className:m("dropdown-item d-flex align-items-center gap-2",A===T&&"active",D.disabled&&"disabled"),onMouseEnter:()=>B(A),onMouseDown:U=>{U.preventDefault(),D.disabled||R(A)},children:[s.jsx("input",{type:"checkbox",className:"form-check-input m-0",checked:S.has(D.value),readOnly:!0,tabIndex:-1}),D.label]},String(D.value)))})]})})}function L(e){if(!e)return"";const n=e.getFullYear(),t=String(e.getMonth()+1).padStart(2,"0"),r=String(e.getDate()).padStart(2,"0");return`${n}-${t}-${r}`}function te(e){if(!e)return null;const n=e.split("-").map(Number),[t,r,a]=n;return!t||!r||!a?null:new Date(t,r-1,a)}function ge({value:e,defaultValue:n,onChange:t,min:r,max:a,...l}){const[o,c]=V({value:e,defaultValue:n??null,onChange:t});return s.jsx(G,{...l,value:L(o),onChange:i=>c(te(i)),inputProps:{type:"date",min:r?L(r):void 0,max:a?L(a):void 0}})}function se(e){if(!e)return"";const n=String(e.getHours()).padStart(2,"0"),t=String(e.getMinutes()).padStart(2,"0");return`${n}:${t}`}function re(e){if(!e)return null;const[n,t]=e.split(":").map(Number);return n===void 0||t===void 0||Number.isNaN(n)||Number.isNaN(t)?null:new Date(1970,0,1,n,t,0,0)}function tn({value:e,defaultValue:n,onChange:t,step:r,...a}){const[l,o]=V({value:e,defaultValue:n??null,onChange:t});return s.jsx(G,{...a,value:se(l),onChange:c=>o(re(c)),inputProps:{type:"time",step:r}})}function oe(e,n){const t=te(e);if(!t)return null;const r=re(n||"00:00");return r&&t.setHours(r.getHours(),r.getMinutes(),0,0),t}function sn({value:e,defaultValue:n,onChange:t,min:r,max:a,id:l,name:o,disabled:c,readOnly:i,required:d,className:u,label:x,helpText:h,error:p}){const[v,N]=V({value:e,defaultValue:n??null,onChange:t}),w=f.useId(),g=l??w,k=L(v),y=se(v);return s.jsx(F,{id:g,label:x,required:d,error:p,helpText:h,className:u,children:s.jsxs("div",{className:"d-flex gap-2",children:[s.jsx("input",{id:g,name:o?`${o}-date`:void 0,type:"date",className:m("form-control",p&&"is-invalid"),disabled:c,readOnly:i,required:d,min:r?L(r):void 0,max:a?L(a):void 0,value:k,onChange:C=>N(oe(C.target.value,y))}),s.jsx("input",{name:o?`${o}-time`:void 0,type:"time",className:m("form-control",p&&"is-invalid"),disabled:c,readOnly:i,required:d,value:y,onChange:C=>N(oe(k||L(new Date),C.target.value))})]})})}function je({options:e,value:n,defaultValue:t,onChange:r,loading:a,emptyText:l="No options",id:o,name:c,disabled:i,readOnly:d,required:u,className:x,label:h,placeholder:p="Select...",helpText:v,error:N}){const[w,g]=V({value:n,defaultValue:t??null,onChange:r}),[k,y]=f.useState(!1),C=f.useRef(null),b=f.useId(),j=o??b,S=e.find(M=>M.value===w)??null,I=f.useCallback(()=>y(!1),[]),R=f.useCallback(M=>{const E=e[M];!E||E.disabled||(g(E.value),I())},[e,g,I]),{activeIndex:T,setActiveIndex:B,handleKeyDown:H}=Y({itemCount:e.length,isOpen:k,onSelect:R,onClose:I});return s.jsx(F,{id:j,label:h,required:u,error:N,helpText:v,className:x,children:s.jsxs("div",{className:"position-relative",children:[s.jsx("button",{ref:C,id:j,type:"button",name:c,className:m("form-select text-start",N&&"is-invalid"),disabled:i||d,"aria-haspopup":"listbox","aria-expanded":k,onClick:()=>y(M=>!M),onKeyDown:H,children:S?S.label:s.jsx("span",{className:"text-body-secondary",children:p})}),s.jsx(K,{open:k,onClose:I,anchorRef:C,className:"dropdown-menu w-100",role:"listbox",children:a?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:"Loading…"}):e.length===0?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:l}):e.map((M,E)=>s.jsx("div",{role:"option","aria-selected":M.value===w,className:m("dropdown-item",E===T&&"active",M.disabled&&"disabled"),onMouseEnter:()=>B(E),onMouseDown:D=>{D.preventDefault(),M.disabled||R(E)},children:M.label},String(M.value)))})]})})}function rn(e,n){return n?e.label.toLowerCase().includes(n.toLowerCase()):!0}function ye({options:e,value:n,defaultValue:t,onChange:r,inputValue:a,onInputValueChange:l,loading:o,emptyText:c="No results",filter:i,id:d,name:u,disabled:x,readOnly:h,required:p,className:v,label:N,placeholder:w,helpText:g,error:k}){const[y,C]=V({value:n,defaultValue:t??null,onChange:r}),b=e.find($=>$.value===y)??null,[j,S]=V({value:a,defaultValue:(b==null?void 0:b.label)??"",onChange:l}),[I,R]=f.useState(!1),T=f.useRef(null),B=f.useId(),H=d??B,M=i??rn,E=e.filter($=>M($,j)),D=f.useCallback(()=>R(!1),[]),A=f.useCallback($=>{const P=E[$];!P||P.disabled||(C(P.value),S(P.label),D())},[E,C,S,D]),{activeIndex:U,setActiveIndex:X,handleKeyDown:Ue}=Y({itemCount:E.length,isOpen:I,onSelect:A,onClose:D});return s.jsx(F,{id:H,label:N,required:p,error:k,helpText:g,className:v,children:s.jsxs("div",{className:"position-relative",children:[s.jsx("input",{ref:T,id:H,name:u,type:"text",className:m("form-control",k&&"is-invalid"),disabled:x,readOnly:h,required:p,placeholder:w,autoComplete:"off",role:"combobox","aria-expanded":I,"aria-haspopup":"listbox",value:j,onFocus:()=>R(!0),onChange:$=>{const P=$.target.value;S(P),R(!0),y!==null&&C(null)},onKeyDown:Ue}),s.jsx(K,{open:I,onClose:D,anchorRef:T,className:"dropdown-menu w-100",role:"listbox",children:o?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:"Loading…"}):E.length===0?s.jsx("div",{className:"px-3 py-2 text-body-secondary",children:c}):E.map(($,P)=>s.jsx("div",{role:"option","aria-selected":$.value===y,className:m("dropdown-item",P===U&&"active",$.disabled&&"disabled"),onMouseEnter:()=>X(P),onMouseDown:We=>{We.preventDefault(),$.disabled||A(P)},children:$.label},String($.value)))})]})})}function an(e){return s.jsx(F,{...e})}function Ne({open:e,onClose:n,title:t,children:r,footer:a,className:l}){return ne(e,n),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"modal d-block",tabIndex:-1,role:"dialog","aria-modal":"true",children:s.jsx("div",{className:m("modal-dialog",l),role:"document",children:s.jsxs("div",{className:"modal-content",children:[s.jsxs("div",{className:"modal-header",children:[t&&s.jsx("h5",{className:"modal-title",children:t}),s.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:n})]}),s.jsx("div",{className:"modal-body",children:r}),a&&s.jsx("div",{className:"modal-footer",children:a})]})})}),s.jsx("div",{className:"modal-backdrop show",onClick:n})]}):null}function ln(e,n,t){const r=[],a=Math.max(1,e-t),l=Math.min(n,e+t);a>1&&(r.push(1),a>2&&r.push("ellipsis"));for(let o=a;o<=l;o++)r.push(o);return l<n&&(l<n-1&&r.push("ellipsis"),r.push(n)),r}function we({currentPage:e,pageSize:n,totalItems:t,onPageChange:r,siblingCount:a=1,className:l}){const o=Math.max(1,Math.ceil(t/n)),c=ln(e,o,a);return s.jsx("nav",{"aria-label":"Pagination",className:l,children:s.jsxs("ul",{className:"pagination mb-0",children:[s.jsx("li",{className:m("page-item",e<=1&&"disabled"),children:s.jsx("button",{type:"button",className:"page-link",disabled:e<=1,onClick:()=>r(e-1),children:"Previous"})}),c.map((i,d)=>i==="ellipsis"?s.jsx("li",{className:"page-item disabled",children:s.jsx("span",{className:"page-link",children:"…"})},`ellipsis-${d}`):s.jsx("li",{className:m("page-item",i===e&&"active"),children:s.jsx("button",{type:"button",className:"page-link","aria-current":i===e?"page":void 0,onClick:()=>r(i),children:i})},i)),s.jsx("li",{className:m("page-item",e>=o&&"disabled"),children:s.jsx("button",{type:"button",className:"page-link",disabled:e>=o,onClick:()=>r(e+1),children:"Next"})})]})})}const ke={text:e=>e==null?"":String(e),boolean:e=>e?"Yes":"No",date:e=>{if(e==null||e==="")return"";const n=e instanceof Date?e:new Date(String(e));return Number.isNaN(n.getTime())?String(e):n.toLocaleDateString()},currency:e=>{const n=Number(e);return Number.isFinite(n)?n.toLocaleString(void 0,{style:"currency",currency:"USD"}):String(e??"")}};function on(e,n){return!e||e.key!==n?{key:n,direction:"asc"}:e.direction==="asc"?{key:n,direction:"desc"}:null}function ce(e){return e.key??e.field??e.header}function cn(e,n){const t=e.field??e.key;return t?n[t]:void 0}function dn(e,n){if(e.render)return e.render(n);const t=cn(e,n);return e.formatter?e.formatter(t,n):e.format?ke[e.format](t):t==null?"":String(t)}function de(e){return e&&`text-${e}`}function Se({columns:e,rows:n,rowKey:t,loading:r,error:a,emptyText:l="No data",className:o,selectedRowKeys:c,onSelectionChange:i,sort:d,onSortChange:u,page:x,pageSize:h,totalCount:p,onPageChange:v}){const N=!!i,w=new Set(c??[]),g=x!==void 0&&h!==void 0&&p!==void 0,k=g?Math.max(1,Math.ceil(p/h)):1;function y(){i&&(w.size===n.length?i([]):i(n.map(t)))}function C(b){if(!i)return;const j=new Set(w);j.has(b)?j.delete(b):j.add(b),i(Array.from(j))}return s.jsxs("div",{className:m("table-responsive",o),children:[s.jsxs("table",{className:"table table-hover align-middle",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[N&&s.jsx("th",{style:{width:"2.5rem"},children:s.jsx("input",{type:"checkbox",className:"form-check-input",checked:n.length>0&&w.size===n.length,onChange:y,"aria-label":"Select all rows"})}),e.map(b=>{const j=ce(b);return s.jsxs("th",{className:de(b.headerAlign??b.align),style:{width:b.width,minWidth:b.minWidth,maxWidth:b.maxWidth},role:b.sortable?"button":void 0,onClick:b.sortable&&u?()=>u(on(d,j)):void 0,children:[b.header,b.sortable&&(d==null?void 0:d.key)===j&&s.jsxs("span",{"aria-hidden":"true",children:[" ",d.direction==="asc"?"▲":"▼"]})]},j)})]})}),s.jsx("tbody",{children:r?s.jsx("tr",{children:s.jsx("td",{colSpan:e.length+(N?1:0),className:"text-center text-body-secondary py-4",children:"Loading…"})}):a?s.jsx("tr",{children:s.jsx("td",{colSpan:e.length+(N?1:0),className:"text-center text-danger py-4",children:a})}):n.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:e.length+(N?1:0),className:"text-center text-body-secondary py-4",children:l})}):n.map(b=>{const j=t(b);return s.jsxs("tr",{children:[N&&s.jsx("td",{children:s.jsx("input",{type:"checkbox",className:"form-check-input",checked:w.has(j),onChange:()=>C(j),"aria-label":"Select row"})}),e.map(S=>s.jsx("td",{className:de(S.align),children:dn(S,b)},ce(S)))]},j)})})]}),g&&s.jsxs("div",{className:"d-flex justify-content-between align-items-center mt-2",children:[s.jsxs("span",{className:"text-body-secondary small",children:["Page ",x," of ",k," (",p," rows)"]}),s.jsx(we,{currentPage:x,pageSize:h,totalItems:p,onPageChange:v})]})]})}function Ce({size:e="md",variant:n,className:t,label:r="Loading..."}){return s.jsx("span",{className:m("spinner-border",e==="sm"&&"spinner-border-sm",n&&`text-${n}`,t),role:"status",children:s.jsx("span",{className:"visually-hidden",children:r})})}function J({variant:e="primary",size:n,disabled:t,loading:r,type:a="button",className:l,children:o,onClick:c,...i}){const d=t||r;return s.jsxs("button",{type:a,className:m("btn",`btn-${e}`,n&&`btn-${n}`,l),disabled:d,"aria-busy":r||void 0,onClick:d?void 0:c,...i,children:[r&&s.jsx(Ce,{size:"sm",className:"me-2",label:""}),o]})}function ae({variant:e="info",dismissible:n,onDismiss:t,className:r,children:a}){return s.jsxs("div",{className:m("alert",`alert-${e}`,n&&"alert-dismissible",r),role:"alert",children:[a,n&&s.jsx("button",{type:"button",className:"btn-close","aria-label":"Close",onClick:t})]})}const Ie=f.createContext(null),un=4e3;function fn({children:e}){const[n,t]=f.useState([]),r=f.useRef(0),a=f.useRef(new Map);f.useEffect(()=>{const i=a.current;return()=>{i.forEach(clearTimeout),i.clear()}},[]);const l=f.useCallback(i=>{const d=a.current.get(i);d&&(clearTimeout(d),a.current.delete(i)),t(u=>u.filter(x=>x.id!==i))},[]),o=f.useCallback((i,d)=>{const u=r.current++,x=(d==null?void 0:d.variant)??"info",h=(d==null?void 0:d.duration)??un;return t(p=>[...p,{id:u,message:i,variant:x}]),h>0&&a.current.set(u,setTimeout(()=>l(u),h)),u},[l]),c=f.useMemo(()=>({show:o,dismiss:l,success:(i,d)=>o(i,{...d,variant:"success"}),error:(i,d)=>o(i,{...d,variant:"danger"}),info:(i,d)=>o(i,{...d,variant:"info"}),warning:(i,d)=>o(i,{...d,variant:"warning"})}),[o,l]);return s.jsxs(Ie.Provider,{value:c,children:[e,s.jsx("div",{className:"toast-container position-fixed bottom-0 end-0 p-3",style:{zIndex:1090},children:n.map(i=>s.jsx(ae,{variant:i.variant,dismissible:!0,onDismiss:()=>l(i.id),className:"shadow-sm",children:i.message},i.id))})]})}function mn(){const e=f.useContext(Ie);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}const De=f.createContext(null);function hn({children:e}){const[n,t]=f.useState(null),r=f.useCallback(l=>new Promise(o=>{t({...l,resolve:o})}),[]),a=f.useCallback(l=>{n==null||n.resolve(l),t(null)},[n]);return s.jsxs(De.Provider,{value:r,children:[e,s.jsx(Ne,{open:n!==null,onClose:()=>a(!1),title:(n==null?void 0:n.title)??"Confirm",footer:s.jsxs(s.Fragment,{children:[s.jsx(J,{variant:"outline-secondary",onClick:()=>a(!1),children:(n==null?void 0:n.cancelLabel)??"Cancel"}),s.jsx(J,{variant:(n==null?void 0:n.confirmVariant)??"danger",onClick:()=>a(!0),children:(n==null?void 0:n.confirmLabel)??"Confirm"})]}),children:n==null?void 0:n.message})]})}function xn(){const e=f.useContext(De);if(!e)throw new Error("useConfirm must be used within a ConfirmProvider");return e}function Re({variant:e="primary",pill:n,className:t,children:r}){return s.jsx("span",{className:m("badge",`bg-${e}`,n&&"rounded-pill",t),children:r})}const bn={sm:"0.875em",lg:"1.5em",xl:"2em"};function Q({name:e,size:n,className:t,label:r}){return s.jsx("i",{className:m(e,t),style:n?{fontSize:bn[n]}:void 0,role:r?"img":void 0,"aria-label":r,"aria-hidden":r?void 0:!0})}function pn(e){switch(e){case"pill":return"nav-pills";case"underline":return"nav-underline";case"card":return"nav-tabs card-header-tabs";default:return"nav-tabs"}}const vn={sm:"small",lg:"fs-5"};function gn({items:e,activeKey:n,defaultActiveKey:t,onChange:r,variant:a="default",orientation:l="horizontal",size:o,stretch:c,className:i}){var C;const[d,u]=V({value:n,defaultValue:t??((C=e[0])==null?void 0:C.key)??"",onChange:r}),x=e.find(b=>b.key===d),h=a==="button",p=l==="vertical",v=f.useRef([]);function N(b,j){var I;const S=e[b];S&&(u(S.key),j&&((I=v.current[b])==null||I.focus()))}function w(b,j){var I;if(e.length===0)return b;let S=b;for(let R=0;R<e.length;R++)if(S=(S+j+e.length)%e.length,!((I=e[S])!=null&&I.disabled))return S;return b}function g(b){var R;const j=e.findIndex(T=>T.key===d),S=p?"ArrowDown":"ArrowRight",I=p?"ArrowUp":"ArrowLeft";if(b.key===S)b.preventDefault(),N(w(j,1),!0);else if(b.key===I)b.preventDefault(),N(w(j,-1),!0);else if(b.key==="Home"){b.preventDefault();const T=e.findIndex(B=>!B.disabled);T>=0&&N(T,!0)}else if(b.key==="End"){b.preventDefault();for(let T=e.length-1;T>=0;T--)if(!((R=e[T])!=null&&R.disabled)){N(T,!0);break}}}const k=s.jsx("div",{className:m(h?"btn-group":"nav",!h&&pn(a),!h&&p&&"flex-column",!h&&c&&"nav-fill",!h&&o&&vn[o]),role:"tablist","aria-orientation":l,onKeyDown:g,children:e.map((b,j)=>{const S=b.key===d,I=s.jsxs(s.Fragment,{children:[b.icon&&s.jsx(Q,{name:b.icon,size:"sm",className:"me-1"}),b.label,b.badge!=null&&s.jsx(Re,{variant:S&&!h?"primary":"secondary",pill:!0,className:"ms-2",children:b.badge})]}),R=s.jsx("button",{ref:T=>{v.current[j]=T},type:"button",id:`tab-${b.key}`,className:m(h?m("btn",o?`btn-${o}`:"btn-sm",S?"btn-primary":"btn-outline-primary"):m("nav-link",S&&"active")),role:"tab","aria-selected":S,"aria-controls":`tabpanel-${b.key}`,tabIndex:S?0:-1,disabled:b.disabled,onClick:()=>N(j,!1),children:I},b.key);return h?R:s.jsx("div",{className:"nav-item",role:"presentation",children:R},b.key)})}),y=(x==null?void 0:x.content)!=null&&s.jsx("div",{id:`tabpanel-${x.key}`,className:m("tab-content",!p&&"pt-3"),role:"tabpanel","aria-labelledby":`tab-${x.key}`,children:x.content});return p?s.jsxs("div",{className:m("d-flex align-items-start gap-3",i),children:[k,y&&s.jsx("div",{className:"flex-grow-1",children:y})]}):s.jsxs("div",{className:i,children:[k,y]})}function Ve({items:e,multiple:n=!1,openKeys:t,defaultOpenKeys:r,onChange:a,className:l}){const[o,c]=V({value:t,defaultValue:r??[],onChange:a}),i=new Set(o);function d(u){i.has(u)?c(o.filter(x=>x!==u)):c(n?[...o,u]:[u])}return s.jsx("div",{className:m("accordion",l),children:e.map(u=>{const x=i.has(u.key);return s.jsxs("div",{className:"accordion-item",children:[s.jsx("h2",{className:"accordion-header",children:s.jsx("button",{type:"button",className:m("accordion-button",!x&&"collapsed"),"aria-expanded":x,disabled:u.disabled,onClick:()=>d(u.key),children:u.header})}),x&&s.jsx("div",{className:"accordion-collapse",children:s.jsx("div",{className:"accordion-body",children:u.content})})]},u.key)})})}function Te({content:e,children:n,placement:t="top",className:r}){const[a,l]=f.useState(!1),o=f.useRef(null),c=f.useId();return s.jsxs("span",{ref:o,className:"position-relative d-inline-block",onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onFocus:()=>l(!0),onBlur:()=>l(!1),"aria-describedby":a?c:void 0,children:[n,s.jsx(K,{open:a,onClose:()=>l(!1),anchorRef:o,className:m("tooltip show",`bs-tooltip-${t}`,"position-absolute","w-auto",r),children:s.jsx("span",{id:c,role:"tooltip",className:"tooltip-inner",children:e})})]})}function jn({title:e,content:n,children:t,placement:r="bottom",className:a}){const[l,o]=f.useState(!1),c=f.useRef(null);return s.jsxs("span",{ref:c,className:"position-relative d-inline-block",onClick:()=>o(i=>!i),children:[t,s.jsxs(K,{open:l,onClose:()=>o(!1),anchorRef:c,className:m("popover show",`bs-popover-${r}`,"position-absolute","w-auto",a),children:[e&&s.jsx("h3",{className:"popover-header",children:e}),s.jsx("div",{className:"popover-body",children:n})]})]})}function W({width:e="100%",height:n="1rem",circle:t,className:r}){return s.jsx("span",{className:m("placeholder-glow d-inline-block",r),style:{width:e,height:n},"aria-hidden":"true",children:s.jsx("span",{className:m("placeholder w-100 h-100 d-block",t&&"rounded-circle")})})}function le({direction:e="column",gap:n=2,align:t,justify:r,wrap:a,className:l,children:o}){return s.jsx("div",{className:m("d-flex",e==="row"?"flex-row":"flex-column",`gap-${n}`,t&&`align-items-${t}`,r&&`justify-content-${r}`,a&&"flex-wrap",l),children:o})}const yn={xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.25rem",xl:"1.5rem"},Nn={normal:"fw-normal",medium:"fw-medium",semibold:"fw-semibold",bold:"fw-bold"},wn={default:void 0,muted:"text-body-secondary",primary:"text-primary",success:"text-success",danger:"text-danger",warning:"text-warning",info:"text-info"};function O({as:e,size:n="md",weight:t,tone:r="default",align:a,truncate:l,wrap:o=!0,className:c,children:i}){const d=e??"span";return s.jsx(d,{className:m(t&&Nn[t],wn[r],a&&`text-${a}`,l&&"text-truncate",!o&&!l&&"text-nowrap",c),style:{fontSize:yn[n]},children:i})}function kn({title:e,subtitle:n,icon:t,avatar:r,actions:a}){return s.jsxs("div",{className:"d-flex align-items-center justify-content-between gap-3",children:[s.jsxs("div",{className:"d-flex align-items-center gap-3",style:{minWidth:0},children:[r||t&&s.jsx("span",{className:"fs-2 lh-1",children:t}),(e||n)&&s.jsxs("div",{style:{minWidth:0},children:[e&&s.jsx(O,{as:"div",size:"lg",weight:"semibold",truncate:!0,children:e}),n&&s.jsx(O,{as:"div",size:"sm",tone:"muted",truncate:!0,children:n})]})]}),a&&s.jsx("div",{className:"d-flex align-items-center gap-2 flex-shrink-0",children:a})]})}function Sn({title:e,subtitle:n,icon:t,avatar:r,actions:a,header:l,footer:o,loading:c,className:i,children:d}){const x=l??(!!(e||n||t||r||a)?s.jsx(kn,{title:e,subtitle:n,icon:t,avatar:r,actions:a}):void 0);return s.jsxs("div",{className:m("card",i),children:[x&&s.jsx("div",{className:"card-header",children:x}),s.jsx("div",{className:"card-body",children:c?s.jsxs(le,{gap:2,children:[s.jsx(W,{height:"1rem",width:"60%"}),s.jsx(W,{height:"1rem"}),s.jsx(W,{height:"1rem",width:"80%"})]}):d}),o&&s.jsx("div",{className:"card-footer",children:o})]})}function Cn({className:e,vertical:n,label:t}){return n?s.jsx("div",{className:m("vr",e),role:"separator","aria-orientation":"vertical"}):t?s.jsxs("div",{className:m("d-flex align-items-center gap-2 my-3",e),role:"separator",children:[s.jsx("hr",{className:"flex-grow-1 m-0"}),s.jsx("span",{className:"text-body-secondary small",children:t}),s.jsx("hr",{className:"flex-grow-1 m-0"})]}):s.jsx("hr",{className:m("my-3",e),role:"separator"})}function In({fluid:e,className:n,children:t}){return s.jsx("div",{className:m(e?"container-fluid":"container",n),children:t})}function Dn({className:e,children:n}){return s.jsx("div",{className:m("row",e),children:n})}function Rn({span:e,sm:n,md:t,lg:r,xl:a,className:l,children:o}){return s.jsx("div",{className:m(e?`col-${e}`:"col",n?`col-sm-${n}`:void 0,t?`col-md-${t}`:void 0,r?`col-lg-${r}`:void 0,a?`col-xl-${a}`:void 0,l),children:o})}function Ee({items:e,className:n}){return s.jsx("nav",{"aria-label":"breadcrumb",className:n,children:s.jsx("ol",{className:"breadcrumb mb-0",children:e.map((t,r)=>{const a=r===e.length-1,l=!a&&(t.href||t.onClick);return s.jsx("li",{className:m("breadcrumb-item",a&&"active"),"aria-current":a?"page":void 0,children:l?s.jsx("a",{href:t.href??"#",onClick:o=>{var c;t.href||o.preventDefault(),(c=t.onClick)==null||c.call(t)},children:t.label}):t.label},r)})})})}function Vn({items:e,children:n,placement:t="start",className:r}){const[a,l]=f.useState(!1),o=f.useRef(null),c=f.useCallback(()=>l(!1),[]),i=f.useCallback(h=>{var v;const p=e[h];!p||p.disabled||((v=p.onSelect)==null||v.call(p),c())},[e,c]),{activeIndex:d,setActiveIndex:u,handleKeyDown:x}=Y({itemCount:e.length,isOpen:a,onSelect:i,onClose:c});return s.jsxs("span",{ref:o,className:"position-relative d-inline-block",onClick:()=>l(h=>!h),onKeyDown:x,children:[n,s.jsx(K,{open:a,onClose:c,anchorRef:o,role:"menu",className:m("dropdown-menu show",t==="end"&&"dropdown-menu-end",r),children:e.map((h,p)=>s.jsx("button",{type:"button",role:"menuitem",className:m("dropdown-item",p===d&&"active",h.disabled&&"disabled",h.danger&&"text-danger"),disabled:h.disabled,onMouseEnter:()=>u(p),onMouseDown:v=>v.preventDefault(),onClick:v=>{v.stopPropagation(),i(p)},children:h.label},h.key))})]})}function Tn({steps:e,currentStep:n,className:t}){return s.jsx("ol",{className:m("d-flex list-unstyled align-items-center",t),children:e.map((r,a)=>{const l=a<n?"complete":a===n?"active":"upcoming",o=a===e.length-1;return s.jsxs("li",{className:m("d-flex align-items-center",!o&&"flex-grow-1"),children:[s.jsxs("div",{className:"d-flex align-items-center gap-2",children:[s.jsx("span",{className:m("d-flex align-items-center justify-content-center rounded-circle flex-shrink-0",l==="complete"?"bg-primary text-white":l==="active"?"border border-primary text-primary":"border text-body-secondary"),style:{width:"2rem",height:"2rem"},"aria-current":l==="active"?"step":void 0,children:l==="complete"?"✓":a+1}),s.jsxs("div",{children:[s.jsx("div",{className:m("small fw-semibold",l==="upcoming"&&"text-body-secondary"),children:r.label}),r.description&&s.jsx("div",{className:"small text-body-secondary",children:r.description})]})]}),!o&&s.jsx("hr",{className:"flex-grow-1 mx-2"})]},r.key)})})}function En(e){var a,l;const n=e.trim().split(/\s+/),t=((a=n[0])==null?void 0:a[0])??"",r=n.length>1?((l=n[n.length-1])==null?void 0:l[0])??"":"";return(t+r).toUpperCase()}const Mn={sm:"1.75rem",md:"2.5rem",lg:"3.5rem"};function $n({src:e,name:n,size:t="md",className:r}){const a=Mn[t];return e?s.jsx("img",{src:e,alt:n??"",className:m("rounded-circle",r),style:{width:a,height:a,objectFit:"cover"}}):s.jsx("span",{className:m("d-inline-flex align-items-center justify-content-center rounded-circle bg-secondary text-white",r),style:{width:a,height:a,fontSize:`calc(${a} * 0.4)`},role:n?"img":void 0,"aria-label":n,children:n?En(n):null})}function An({variant:e="secondary",onRemove:n,className:t,children:r}){return s.jsxs("span",{className:m("badge d-inline-flex align-items-center gap-1",`bg-${e}`,t),children:[r,n&&s.jsx("button",{type:"button",className:"btn-close btn-close-white",style:{fontSize:"0.55rem"},"aria-label":"Remove",onClick:n})]})}function Fn({value:e,defaultValue:n,onChange:t,min:r=0,max:a=100,step:l=1,id:o,name:c,disabled:i,required:d,className:u,label:x,helpText:h,error:p}){const[v,N]=V({value:e,defaultValue:n??r,onChange:t}),w=f.useId(),g=o??w;return s.jsxs(F,{id:g,label:x,required:d,error:p,helpText:h,className:u,children:[s.jsx("input",{id:g,name:c,type:"range",className:"form-range",disabled:i,required:d,min:r,max:a,step:l,value:v,onChange:k=>N(Number(k.target.value))}),s.jsx("div",{className:"small text-body-secondary",children:v})]})}function Pn({value:e,defaultValue:n,onChange:t,max:r=5,disabled:a,className:l}){const[o,c]=V({value:e,defaultValue:n??0,onChange:t});return s.jsx("div",{className:m("d-inline-flex gap-1",l),role:"radiogroup","aria-label":"Rating",children:Array.from({length:r},(i,d)=>d+1).map(i=>s.jsx("button",{type:"button",className:"btn btn-link p-0 border-0",disabled:a,role:"radio","aria-checked":i===o,"aria-label":`${i} star${i>1?"s":""}`,onClick:()=>c(i),children:s.jsx("span",{"aria-hidden":"true",style:{fontSize:"1.25rem",color:i<=o?"#f5b301":"#ced4da"},children:"★"})},i))})}function On({value:e,variant:n="primary",label:t,className:r}){const a=Math.max(0,Math.min(100,e));return s.jsx("div",{className:m("progress",r),role:"progressbar","aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100,children:s.jsx("div",{className:m("progress-bar",`bg-${n}`),style:{width:`${a}%`},children:t?`${Math.round(a)}%`:null})})}function Ln({brand:e,start:n,end:t,variant:r="light",className:a}){return s.jsx("nav",{className:m("navbar navbar-expand-lg border-bottom",r==="dark"?"navbar-dark bg-dark":"navbar-light bg-light",a),children:s.jsxs("div",{className:"container-fluid",children:[e&&s.jsx("span",{className:"navbar-brand mb-0",children:e}),n&&s.jsx("div",{className:"d-flex align-items-center gap-3",children:n}),t&&s.jsx("div",{className:"d-flex align-items-center gap-3 ms-auto",children:t})]})})}function Bn(e){return"items"in e}function ue({item:e}){return s.jsxs("a",{href:e.href??"#",className:m("nav-link d-flex align-items-center gap-2",e.active&&"active",e.disabled&&"disabled"),"aria-current":e.active?"page":void 0,"aria-disabled":e.disabled,onClick:n=>{var t;e.href||n.preventDefault(),!e.disabled&&((t=e.onClick)==null||t.call(e))},children:[e.icon,e.label]})}function Kn({sections:e,header:n,footer:t,className:r}){return s.jsxs("div",{className:m("d-flex flex-column h-100",r),children:[n&&s.jsx("div",{className:"p-3 border-bottom",children:n}),s.jsx("nav",{className:"nav flex-column flex-grow-1 p-2 gap-1",children:e.map(a=>Bn(a)?s.jsx(Ve,{className:"border-0",defaultOpenKeys:a.defaultOpen?[a.key]:[],items:[{key:a.key,header:a.label,content:s.jsx("div",{className:"nav flex-column ps-2 gap-1",children:a.items.map(l=>s.jsx(ue,{item:l},l.key))})}]},a.key):s.jsx(ue,{item:a},a.key))}),t&&s.jsx("div",{className:"p-3 border-top",children:t})]})}function Hn({title:e,description:n,breadcrumbItems:t,actions:r,className:a}){return s.jsxs("div",{className:m("mb-4",a),children:[t&&t.length>0&&s.jsx(Ee,{items:t,className:"mb-2"}),s.jsxs("div",{className:"d-flex align-items-start justify-content-between gap-3 flex-wrap",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"h3 mb-1",children:e}),n&&s.jsx("p",{className:"text-body-secondary mb-0",children:n})]}),r&&s.jsx("div",{className:"d-flex align-items-center gap-2",children:r})]})]})}const Gn={xs:1,sm:2,md:3,lg:4,xl:5};function _n(e){return typeof e=="number"?e:Gn[e]}function qn({direction:e="row",gap:n="sm",grow:t,shrink:r,fullWidth:a,className:l,...o}){return s.jsx(le,{direction:e,gap:_n(n),className:m(t&&"flex-grow-1",r&&"flex-shrink-0",a&&"w-100",l),...o})}function zn({icon:e,"aria-label":n,iconSize:t,tooltip:r,variant:a="light",loading:l,className:o,...c}){const i=s.jsx(J,{variant:a,loading:l,className:m("btn-icon",o),"aria-label":n,...c,children:!l&&s.jsx(Q,{name:e,size:t})});return r?s.jsx(Te,{content:r,children:i}):i}function Un({leading:e,title:n,description:t,trailing:r,onClick:a,disabled:l,dense:o,className:c}){const i=s.jsxs(s.Fragment,{children:[e&&s.jsx("span",{className:"flex-shrink-0 d-inline-flex align-items-center",children:e}),s.jsxs("span",{className:"flex-grow-1",style:{minWidth:0},children:[s.jsx("span",{className:"d-block text-truncate",children:n}),t&&s.jsx("span",{className:"d-block text-truncate small text-body-secondary",children:t})]}),r&&s.jsx("span",{className:"flex-shrink-0 d-inline-flex align-items-center",children:r})]}),d=m("d-flex align-items-center text-start",o?"gap-2 py-1":"gap-3 py-2",a&&"w-100 border-0 bg-transparent",l&&"opacity-50",c);return a?s.jsx("button",{type:"button",className:d,onClick:a,disabled:l,children:i}):s.jsx("div",{className:d,"aria-disabled":l||void 0,children:i})}function Wn(e,n,t,r){if(e.length===0)return[];const a=Math.min(...e),o=Math.max(...e)-a||1,c=n-r*2,i=t-r*2,d=e.length>1?c/(e.length-1):0;return e.map((u,x)=>{const h=r+d*x,p=r+i-(u-a)/o*i;return[h,p]})}function Jn({type:e,data:n,width:t,height:r,strokeWidth:a}){const l=a,o=Wn(n,t,r,l);if(o.length===0)return null;const c=o.map(([i,d])=>`${i},${d}`).join(" ");return s.jsxs(s.Fragment,{children:[e==="area"&&s.jsx("polygon",{points:`${l},${r-l} ${c} ${t-l},${r-l}`,fill:"currentColor",opacity:.2,stroke:"none"}),s.jsx("polyline",{points:c,fill:"none",stroke:"currentColor",strokeWidth:a,strokeLinecap:"round",strokeLinejoin:"round"})]})}function Zn({data:e,width:n,height:t}){if(e.length===0)return null;const r=Math.min(0,...e),l=Math.max(0,...e)-r||1,o=2,c=Math.max((n-o*(e.length-1))/e.length,1);return s.jsx(s.Fragment,{children:e.map((i,d)=>{const u=Math.max((i-r)/l*t,1),x=d*(c+o),h=t-u;return s.jsx("rect",{x,y:h,width:c,height:u,rx:1,fill:"currentColor"},d)})})}function Yn({type:e="line",data:n,tone:t="primary",width:r=80,height:a=28,strokeWidth:l=2,className:o,label:c}){return s.jsx("svg",{width:r,height:a,viewBox:`0 0 ${r} ${a}`,className:m(`text-${t}`,o),role:c?"img":void 0,"aria-label":c,"aria-hidden":c?void 0:!0,children:e==="bar"?s.jsx(Zn,{data:n,width:r,height:a}):s.jsx(Jn,{type:e,data:n,width:r,height:a,strokeWidth:l})})}const Qn={up:"success",down:"danger",neutral:"muted"},Xn={up:"bi bi-arrow-up-short",down:"bi bi-arrow-down-short",neutral:"bi bi-dash"};function et(e,n){return typeof e=="number"&&n!=null?e.toFixed(n):String(e)}function nt({label:e,value:n,prefix:t,suffix:r,precision:a,trend:l,delta:o,loading:c,className:i}){return s.jsxs("div",{className:m("d-flex flex-column gap-1",i),children:[s.jsx(O,{size:"sm",tone:"muted",children:e}),c?s.jsx(W,{height:"1.75rem",width:"60%"}):s.jsxs("div",{className:"d-flex align-items-baseline gap-1",children:[t&&s.jsx(O,{size:"lg",weight:"semibold",children:t}),s.jsx(O,{size:"xl",weight:"bold",children:et(n,a)}),r&&s.jsx(O,{size:"lg",weight:"semibold",children:r})]}),!c&&(l||o!=null)&&s.jsxs(O,{size:"sm",tone:l?Qn[l]:"muted",className:"d-inline-flex align-items-center gap-1",children:[l&&s.jsx(Q,{name:Xn[l],size:"sm"}),o]})]})}class Me extends Error{constructor(n,t,r){super(`HTTP ${n} ${t} for ${r}`),this.name="HttpError",this.status=n,this.statusText=t,this.url=r}}function tt(e){if(!e)return"";const n=new URLSearchParams;for(const[r,a]of Object.entries(e))a!=null&&n.set(r,String(a));const t=n.toString();return t?`?${t}`:""}function $e(e={}){const{baseUrl:n="",fetcher:t=fetch,buildRequestInit:r}=e;return{async get(a,l={}){const o=`${n}${a}${tt(l.params)}`;let c={method:"GET",signal:l.signal};r&&(c=r(o,c));const i=await t(o,c);if(!i.ok)throw new Me(i.status,i.statusText,o);return await i.json()}}}const Ae=$e();function st(e){return Object.keys(e).sort().reduce((n,t)=>(n[t]=e[t],n),{})}function _({client:e=Ae,url:n,params:t,mapResponse:r,enabled:a=!0}){const[l,o]=f.useState("idle"),[c,i]=f.useState([]),[d,u]=f.useState(null),[x,h]=f.useState(0),p=f.useMemo(()=>t?JSON.stringify(st(t)):"",[t]),v=f.useRef(0),N=f.useRef(r);N.current=r,f.useEffect(()=>{if(!a||!n){o("idle"),i([]),u(null);return}const g=++v.current,k=new AbortController;return o("loading"),u(null),e.get(n,{params:t,signal:k.signal}).then(y=>{if(g!==v.current)return;const C=N.current(y);i(C),o(C.length===0?"empty":"success")}).catch(y=>{g===v.current&&(y instanceof DOMException&&y.name==="AbortError"||(u(y instanceof Error?y:new Error(String(y))),o("error")))}),()=>{k.abort()}},[e,n,p,a,x]);const w=f.useCallback(()=>h(g=>g+1),[]);return{state:l,items:c,error:d,reload:w}}function Fe(e,n){const[t,r]=f.useState(e);return f.useEffect(()=>{const a=setTimeout(()=>r(e),n);return()=>clearTimeout(a)},[e,n]),t}function q(e){if(Array.isArray(e))return e;if(e&&typeof e=="object"&&Array.isArray(e.items))return e.items;throw new Error("Unable to normalize remote response into an array. Provide an explicit `mapResponse` for this endpoint's response shape.")}function Z(e,n,t){if(e===null||typeof e!="object")throw new Error("Remote item is not an object; cannot read valueMember/displayMember from it.");const r=e;return{value:r[n],label:String(r[t]??"")}}function Pe({url:e,params:n,valueMember:t,displayMember:r,mapResponse:a,client:l,enabled:o,...c}){const{state:i,items:d,error:u}=_({client:l,url:e,params:n,enabled:o,mapResponse:h=>(a?a(h):q(h)).map(v=>Z(v,t,r))}),x=c.error??(i==="error"?(u==null?void 0:u.message)??"Failed to load options":void 0);return s.jsx(je,{...c,options:d,loading:i==="loading",error:x})}function rt({url:e,params:n,searchParam:t,valueMember:r,displayMember:a,mapResponse:l,minSearchLength:o=1,debounceMs:c=300,client:i,inputValue:d,onInputValueChange:u,...x}){const[h,p]=V({value:d,defaultValue:"",onChange:u}),v=Fe(h,c),N=v.length>=o,{state:w,items:g,error:k}=_({client:i,url:e,enabled:N,params:{...n,[t]:v},mapResponse:C=>(l?l(C):q(C)).map(j=>Z(j,r,a))}),y=x.error??(w==="error"?(k==null?void 0:k.message)??"Failed to load suggestions":void 0);return s.jsx(ye,{...x,options:g,loading:w==="loading",error:y,inputValue:h,onInputValueChange:p,filter:()=>!0})}function Oe({url:e,params:n,mapResponse:t,getTotalCount:r,pageSize:a=20,client:l,...o}){const[c,i]=f.useState(1),[d,u]=f.useState(null),x=f.useMemo(()=>JSON.stringify(n??{}),[n]),h=f.useRef(!0);f.useEffect(()=>{if(h.current){h.current=!1;return}i(1)},[x]);const p=f.useMemo(()=>({...n,page:c,pageSize:a,...d?{sortKey:d.key,sortDirection:d.direction}:{}}),[n,c,a,d]),v=f.useRef(void 0),{state:N,items:w,error:g}=_({client:l,url:e,params:p,mapResponse:j=>(v.current=j,t?t(j):q(j))}),k=v.current!==void 0?r==null?void 0:r(v.current):void 0,C=w.length>=a&&a>0?c*a+1:(c-1)*a+w.length,b=k??C;return s.jsx(Se,{...o,rows:w,loading:N==="loading",error:g==null?void 0:g.message,page:c,pageSize:a,totalCount:b,onPageChange:i,sort:d,onSortChange:j=>{u(j),i(1)}})}function at({url:e,params:n,valueMember:t,displayMember:r,mapResponse:a,client:l,enabled:o,...c}){const{state:i,items:d,error:u}=_({client:l,url:e,params:n,enabled:o,mapResponse:h=>(a?a(h):q(h)).map(v=>Z(v,t,r))}),x=c.error??(i==="error"?(u==null?void 0:u.message)??"Failed to load options":void 0);return s.jsx(pe,{...c,options:d,loading:i==="loading",error:x})}function lt({url:e,params:n,valueMember:t,displayMember:r,mapResponse:a,client:l,enabled:o,...c}){const{state:i,items:d,error:u}=_({client:l,url:e,params:n,enabled:o,mapResponse:h=>(a?a(h):q(h)).map(v=>Z(v,t,r))}),x=c.error??(i==="error"?(u==null?void 0:u.message)??"Failed to load options":void 0);return s.jsx(ve,{...c,options:d,loading:i==="loading",error:x})}function it(){const e=new Map,n=new Set;return{register(t,r){e.set(t,r)},resolve(t,r){const a=e.get(t.component);return a?a(t,r):(n.has(t.component)||(n.add(t.component),console.warn(`Smart: no resolver registered for component "${t.component}" (field "${t.name}"). Skipping.`)),null)},has(t){return e.has(t)}}}function ot(e){const n=new Map(Object.entries(e??{}));return{register(t,r){n.set(t,r)},resolve(t){return n.get(t)}}}function ct(){const e=new Map;return{register(n,t){e.set(n,t)},resolve(n){return e.get(n)}}}function dt(e){return"dataSource"in e}function ut(e,n){if(!e)return;const t={};for(const[r,a]of Object.entries(e))t[r]=a.kind==="static"?a.value:n[a.field];return t}function fe(e,n,t){return n&&t?t(n):e}function z(e,n){const{values:t,translate:r}=n;return{metadata:e,visible:e.visible??!0,readOnly:e.readOnly??!1,disabled:e.disabled??!1,required:e.required??!1,label:fe(e.label,e.labelKey,r),placeholder:e.placeholder,helpText:e.helpText,validationMessage:fe(e.validationMessage,e.validationMessageKey,r),params:dt(e)?ut(e.dataSource.params,t):void 0}}function ft(e,n,t){const r=n==null?void 0:n.fields.find(a=>a.name===e);if(r)return z(r,t)}const mt=[];function ht(e,n){const t={};for(const r of n)t[r]=e[r];return t}function Le(e,n,t){const r=e??mt,a=ht(n,r),l=r.length===0?"":JSON.stringify(a),o=f.useRef(null),c=f.useRef(t);c.current=t,f.useEffect(()=>{var d;if(r.length===0)return;const i=o.current;if(i&&i.key!==l)for(const u of r)Object.is(i.snapshot[u],a[u])||(d=c.current)==null||d.call(c,u);o.current={key:l,snapshot:a}},[l])}function ie(e,n){const{actions:t,translate:r}=n,a=t.resolve(e.id);return{metadata:e,visible:e.visible??!0,enabled:(e.enabled??!0)&&!!a,label:e.labelKey&&r?r(e.labelKey):e.label,handler:a}}function xt(e,n,t){var a;const r=(a=n==null?void 0:n.actions)==null?void 0:a.find(l=>l.id===e);if(r)return ie(r,t)}const Be=(e,n)=>{const t=z(e,{values:n.values,translate:n.translate});if(!t.visible)return null;const r=n.dataSources.resolve(e.dataSource.id);return r?s.jsx(Pe,{label:t.label,url:r.url,client:r.client,params:t.params,valueMember:e.valueMember,displayMember:e.displayMember,required:t.required,readOnly:t.readOnly,disabled:t.disabled,helpText:t.helpText,error:t.validationMessage,value:n.values[e.name]??null,onChange:a=>n.onFieldChange(e.name,a)}):(console.warn(`Smart: no data source registered for id "${e.dataSource.id}" (field "${e.name}"). Skipping.`),null)};function bt(e,n){if(e.visible===!1)return null;const t=e.headerKey&&n?n(e.headerKey):e.header??e.key,r=e.format==="boolean"&&!!n;return{key:e.key,header:t,sortable:e.sortable,format:r?void 0:e.format,formatter:r?a=>n(a?"smart.boolean.true":"smart.boolean.false"):void 0}}const Ke=(e,n)=>{const t=z(e,{values:n.values,translate:n.translate});if(!t.visible)return null;const r=n.dataSources.resolve(e.dataSource.id);if(!r)return console.warn(`Smart: no data source registered for id "${e.dataSource.id}" (field "${e.name}"). Skipping.`),null;const a=e.columns.map(c=>bt(c,n.translate)).filter(c=>c!==null),l=e.totalCountField,o=l?c=>{const i=c==null?void 0:c[l];return typeof i=="number"?i:void 0}:void 0;return s.jsx(Oe,{url:r.url,client:r.client,params:t.params,columns:a,rowKey:c=>c[e.rowKey],getTotalCount:o})};function me(e){if(!e)return;const n=new Date(e);return Number.isNaN(n.getTime())?void 0:n}const He=(e,n)=>{const t=z(e,{values:n.values,translate:n.translate});return t.visible?s.jsx(ge,{label:t.label,required:t.required,readOnly:t.readOnly,disabled:t.disabled,helpText:t.helpText,error:t.validationMessage,min:me(e.minDate),max:me(e.maxDate),value:n.values[e.name]??null,onChange:r=>n.onFieldChange(e.name,r)}):null},Ge=(e,n)=>{const t=z(e,{values:n.values,translate:n.translate});return t.visible?s.jsx(G,{label:t.label,required:t.required,readOnly:t.readOnly,disabled:t.disabled,helpText:t.helpText,placeholder:t.placeholder,error:t.validationMessage,maxLength:e.maxLength,value:n.values[e.name]??"",onChange:r=>n.onFieldChange(e.name,r)}):null};function pt(e){e.register("Input",Ge),e.register("ComboBox",Be),e.register("DatePicker",He),e.register("DataGrid",Ke)}function _e({metadata:e,ctx:n}){const t=n.onMetadataRefreshNeeded;return Le(e.dependsOn,n.values,t?r=>t(e.name,r):void 0),e.visible===!1?null:n.registry.resolve(e,n)}const qe=1;function vt(e){const n=Number(e.split(".")[0]);return Number.isFinite(n)&&n===qe}function gt({metadata:e,ctx:n}){return vt(e.schemaVersion)?s.jsx(s.Fragment,{children:e.fields.map(t=>s.jsx(_e,{metadata:t,ctx:n},t.name))}):s.jsxs(ae,{variant:"danger",children:['Unsupported form schema version "',e.schemaVersion,'" — this app understands schema version ',qe,".x."]})}function ze({metadata:e,ctx:n}){const t=ie(e,n);return t.visible?s.jsx(J,{disabled:!t.enabled,onClick:()=>{var r;return(r=t.handler)==null?void 0:r.call(t)},children:t.label??e.id}):null}function jt({metadata:e,ctx:n}){return!e.actions||e.actions.length===0?null:s.jsx(s.Fragment,{children:e.actions.map(t=>s.jsx(ze,{metadata:t,ctx:n},t.id))})}exports.Accordion=Ve;exports.Alert=ae;exports.AutoComplete=ye;exports.Avatar=$n;exports.Badge=Re;exports.Breadcrumb=Ee;exports.Button=J;exports.Card=Sn;exports.CheckBox=Xe;exports.Col=Rn;exports.ComboBox=je;exports.ConfirmProvider=hn;exports.Container=In;exports.DataGrid=Se;exports.DatePicker=ge;exports.DateTimePicker=sn;exports.Divider=Cn;exports.FileInput=Qe;exports.Flex=qn;exports.FormField=an;exports.HttpError=Me;exports.Icon=Q;exports.IconButton=zn;exports.Input=G;exports.Label=he;exports.ListItem=Un;exports.Menu=Vn;exports.Modal=Ne;exports.MultiSelect=ve;exports.Navbar=Ln;exports.NumberInput=Ze;exports.PageHeader=Hn;exports.Pagination=we;exports.PasswordInput=Ye;exports.Popover=jn;exports.Popup=K;exports.ProgressBar=On;exports.RadioButton=be;exports.RadioGroup=nn;exports.Rating=Pn;exports.RemoteAutoComplete=rt;exports.RemoteComboBox=Pe;exports.RemoteDataGrid=Oe;exports.RemoteMultiSelect=lt;exports.RemoteSelect=at;exports.Row=Dn;exports.Select=pe;exports.Sidebar=Kn;exports.Skeleton=W;exports.Slider=Fn;exports.SmartAction=ze;exports.SmartActions=jt;exports.SmartField=_e;exports.SmartForm=gt;exports.Sparkline=Yn;exports.Spinner=Ce;exports.Stack=le;exports.Statistic=nt;exports.Stepper=Tn;exports.Switch=en;exports.Tabs=gn;exports.Tag=An;exports.Text=O;exports.TextArea=Je;exports.TimePicker=tn;exports.ToastProvider=fn;exports.Tooltip=Te;exports.ValidationMessage=ee;exports.comboBoxResolver=Be;exports.createHttpClient=$e;exports.createSmartActionRegistry=ct;exports.createSmartComponentRegistry=it;exports.createSmartDataSourceRegistry=ot;exports.dataGridFormatters=ke;exports.dataGridResolver=Ke;exports.datePickerResolver=He;exports.defaultArrayNormalization=q;exports.defaultHttpClient=Ae;exports.fromDateInputValue=te;exports.fromTimeInputValue=re;exports.inputResolver=Ge;exports.registerBuiltInResolvers=pt;exports.resolveSmartActionMetadata=ie;exports.resolveSmartFieldMetadata=z;exports.toDateInputValue=L;exports.toSelectOption=Z;exports.toTimeInputValue=se;exports.useConfirm=xn;exports.useDebouncedValue=Fe;exports.useRemoteData=_;exports.useSmartAction=xt;exports.useSmartDependencies=Le;exports.useSmartField=ft;exports.useToast=mn;
2
2
  //# sourceMappingURL=index.cjs.map