@nice2dev/erp-adapter 1.1.10 → 1.2.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,178 @@
1
1
  # @nice2dev/erp-adapter — Changelog
2
2
 
3
+ ## 1.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 8c82c30: 1.2.1 — the decisions that waited since 1.2.0, and the debts the CI gates were holding. One API
8
+ change, agreed: `NiceIconSuggestorAI` suggests Nice icons only. Two stylesheets to import if you use
9
+ the packages: `@nice2dev/social/style.css`, `@nice2dev/ui-science/style.css`. Upgrade notes:
10
+ `documentation/omniverk/OMNIVERK_UPGRADE_1.2.1.md`.
11
+
12
+ **Tree-shaking.** An import from a package no longer brings the whole package. Module-level
13
+ statements that may have a side effect — a `displayName` assigned after each component (now
14
+ `Object.assign` inside `/* @__PURE__ */`, or under a development check for plain functions),
15
+ unannotated `forwardRef` / `memo` / `createContext` / icon-factory calls, spreads, registries filled
16
+ at import, `<style>` tags injected at import, a direct `eval` in ui-math — are gone. One import from
17
+ each of 53 packages: 5066.5 kB → 1171.6 kB (`@nice2dev/ui` 1928.2 kB → 12.9 kB, icon packs 48–275 kB
18
+ → 1.6–2.6 kB). `defaultViewRegistry` has the Nice\* input controls from the start, each loading its
19
+ module on first render; sixteen controls add their styles to `<head>` on first render.
20
+
21
+ **Dead code.** 405 source files no entry point imported (never on npm) are deleted;
22
+ `NiceClipboardStack` (`@nice2dev/ui`) and `NiceSampleBrowser` (`@nice2dev/ui-audio`), finished and
23
+ documented, are exported.
24
+
25
+ **ui-mobile draws Nice icons.** New peer `@nice2dev/icons ^1.2.0`; `TabIcons`, `DrawerIcons`,
26
+ `HeaderIcons`, the `NiceSwipeActions` presets and the `NiceInfiniteScroll` states are `Ntd*` icons
27
+ instead of pasted `<svg>`, simple glyphs are CSS marks. `@nice2dev/icons` adds `NtdReply` and
28
+ `NtdInbox`; an icon no longer throws without `window.matchMedia`.
29
+
30
+ **`NiceIconSuggestorAI` (breaking, agreed).** `AIIconLibrary` is `'nice'`; `svgPath` and `unicode`
31
+ left `AISuggestedIcon`; the preview is a `<NiceIcon>`, "Copy SVG" is "Copy JSX".
32
+
33
+ **Peer ranges.** Every internal `@nice2dev/*` peer is `^1.2.0` (was as wide as `^1.0.20`), except
34
+ `@nice2dev/icons ^1.2.1` where a package draws an icon new in 1.2.1: ui-mobile (`NtdReply`,
35
+ `NtdInbox`), ui-audio (`NtdMicrophoneOff`) and ui-security (`NtdBackspace`). ui-security, licensing
36
+ (`^1.2.0`) and templates (`^1.2.0`) gain the `@nice2dev/icons` peer: their glyph icons (`⌫`, `←`,
37
+ `→`, `↑`, `↓`) are Nice icons now. `@nice2dev/icons` adds `NtdBackspace`.
38
+
39
+ **Class names inside components.** 834 class names in library stylesheets had no `nice-` prefix
40
+ (`.tab-button`, `.status-badge`, `.selected`, …) and styled every element of that name on the page.
41
+ They follow `nice-{block}__{element}--{modifier}` now — no change on screen. The class theme hooks
42
+ next to `[data-theme]` on seven controls (`dark` on the AI chart / data grid / code and HTML
43
+ editors / form builder, `light-theme` on `NiceMAM` and `NiceVideoAnnotator`) are `nice-dark` /
44
+ `nice-light`; `NiceLowPowerMode` marks `<html>` with `nice-lpm-no-animations` /
45
+ `nice-lpm-reduced-quality`; the `NiceVideoEditor` of `@nice2dev/ui-video` styles its elements under
46
+ `nice-video-studio`, so they no longer collide with the `NiceVideoEditor` of `@nice2dev/ui`.
47
+ Rules for classes nothing rendered are gone, among them the stylesheet of `NiceGanttChart`, which
48
+ left ui-erp in 1.0.10.
49
+
50
+ **Translations.** About 3,400 UI texts in 32 packages were hard-coded; they go through `t()` now,
51
+ with the English text unchanged and pl / de / fr / es / uk in `@nice2dev/i18n` (ui-diagrams,
52
+ ui-presentations and ui-math in their own dictionaries). In `@nice2dev/events` and
53
+ `@nice2dev/admin` that includes column headers, option labels and the statuses and roles they used
54
+ to print raw (`checked-in`, `no-show`) — English labels for those come from the dictionary. ui-3d and ui-graphics read the app's
55
+ global translator, as ui-audio does since 1.2.0 — their own provider overrides it. ui-audio's
56
+ controls used 631 keys the dictionary did not have (English in every language), and the radio
57
+ player showed raw keys (`search_stations`). Texts that were hard-coded **in Polish** — in
58
+ `NiceSidebarNav`, `NiceNetworkDiscoveryPanel`, the backup and smart-home controls,
59
+ `NiceSavedQueryPanel`, `NiceNotificationPreferences`, the ui-buildings panels, the ui-printing
60
+ template editor and the photo editor — default to English now; Polish is in the dictionary. English
61
+ plurals glued on (`result{s}`) are two keys. `presentationsTranslator(lang)` (ui-presentations)
62
+ translates outside its provider.
63
+
64
+ **List props are optional.** 170 list props (`items`, `columns`, `data`, …) in 15 packages that
65
+ were required without a default are optional, with a stable empty default; every one of those
66
+ controls mounts without data (tested). `NiceStockChart` without data no longer computes NaN
67
+ coordinates.
68
+
69
+ **Unstyled components get stylesheets.** 98 components rendered class names no stylesheet had —
70
+ admin panels, auth forms, events rounds and pickers, the ERP invoice / purchase order / VAT table /
71
+ HR dashboard, the radio player, `NiceInbox`, PWA prompts, `NiceViewRenderer`, shells, smart-home,
72
+ … The fixed layout that sat in inline style objects is in classes now, so an app can override it;
73
+ values that depend on data stay inline. **`@nice2dev/social` and `@nice2dev/ui-science` ship a
74
+ stylesheet — import `@nice2dev/social/style.css` / `@nice2dev/ui-science/style.css`.** ui-science's
75
+ `sideEffects` is `["*.css"]`. Colours, spacing and radii in every stylesheet come from theme tokens
76
+ (visible in dark themes: `NiceRecipe` difficulty badges, transcoder states, warehouse heat map).
77
+
78
+ **Icons only from Nice.** About 130 glyphs (`×`, `→`, `↑`) and 100 pasted `<svg>` used as icons
79
+ are Nice icons; 11 `<svg>` stay as the control's own graphic (logos, spinners, checkbox mark). `NiceIcon`
80
+ gains `pin`, `mic-off`, `log-out`, `chevrons-left`, `chevrons-right`, `zoom-in`, `zoom-out`,
81
+ `navigation`, `refresh-ccw`, `minimize` and `smartphone`; `@nice2dev/icons` gains
82
+ `NtdMicrophoneOff`. The `icon` fields of the module, menu, tab, mode, quick-action, scene and admin
83
+ widget DTOs, notification channels and view toolbar items are rendered through `NiceIcon` — they
84
+ used to be printed as text. `NiceRatings` `thumbs` draws shapes instead of emoji.
85
+
86
+ **Dialogs instead of `window.prompt` / `confirm` / `alert`.** New `useNiceDialogs()` — `prompt`,
87
+ `confirm` and `alert` as promises on `NicePromptDialog` / `NiceConfirmDialog` — and
88
+ `NiceConfirmDialog.showReject`. Seventeen controls asked through the browser's blocking dialogs and
89
+ use the library's now (`NiceFileManager`, `NiceHtmlEditor`, `NiceViewRenderer` action `confirm`, the 3D,
90
+ vector and pixel editors, …). Keys pressed in `NicePromptDialog` / `NiceConfirmDialog` no longer
91
+ reach the page's shortcuts (Escape still closes them), and `NicePromptDialog`'s backdrop covers the
92
+ whole viewport.
93
+
94
+ **Smaller fixes.** `NiceFileManager.items` is optional. `NiceMLStudio` status badges: `draft`,
95
+ `registered`, `archived`, `cancelled` get a neutral colour, deploying / stopped deployments theirs.
96
+ Component docs (`doc.json`) list only props the components have. `NiceMobileTabs`: tabs beyond
97
+ `maxTabs` open from "More" (it only logged). `NiceInventoryManager`: new `onCreatePurchaseOrder`;
98
+ without it the "Create PO" button is gone (it only logged). Keyboard: `NiceNavShell` tabs follow the
99
+ WAI-ARIA tabs pattern, clickable `NiceDeviceTile` / `NiceCardGroup` cards and animated icons with
100
+ `trigger="click"` are focusable. ui-math: `CalculatorService.evaluate` parses instead of running
101
+ `new Function` (`asin`, `sinh`, `ceil`, exponents and `angleUnit` were wrong); `ExpressionParser`
102
+ takes `functions`, `constants`, `ignoreCase` and `strict`, multiplies implicitly (`2x`) and reads `^`
103
+ right to left. `InvoiceLine.vatRate` and `VatRate.rate` are documented as fractions (0.23).
104
+ `AmqpServerBinding` is `Record<string, never>`.
105
+
106
+ ## 1.2.0
107
+
108
+ ### Minor Changes
109
+
110
+ - 3a4939d: 1.2.0 — the API cleanup announced for this version, dictionaries per language by default, and
111
+ three new controls. **Breaking:** every removal has a replacement, listed name by name in
112
+ `documentation/omniverk/OMNIVERK_UPGRADE_1.2.0.md`.
113
+
114
+ **Removed (breaking).** All 118 `@deprecated` names: the aliases without the `Nice` prefix in
115
+ `ui-audio`, `ui-graphics` and `ui-3d`; `NiceBarcodeGenerator` (→ `NiceBarcode`), `NiceFloorPlanCanvas`
116
+ (→ `NiceSpatialEditor` in `@nice2dev/ui-buildings`), the v2 props and types of `NiceTopNav`,
117
+ `NiceProgress.showLabel`, `NiceCountryPicker.showDialCode` / `showFlag`, `type` on
118
+ `NiceDateTimePicker` / `NiceDateRangeBox` (→ `dateFormatPreset`); `ZoneOccupancy` in
119
+ `ui-buildings` and `events`, the `SmartHome*` types; the icon variant `flat` (→ `cutout`) and
120
+ `NiceIconEditor` (→ `NiceVectorEditor`); `NiceSizeLegacy`; the `snapGrid` module of `ui-diagrams` (→
121
+ `@nice2dev/spatial-core`); the opt-in stylesheet `@nice2dev/ui/css/legacy-bg-text-aliases.css`, which
122
+ formed an alias cycle with `style.css`. Props that were accepted and never read — 19 on
123
+ `NiceModuleGrid`, and more on `NiceAutocomplete`, `NiceTaskInbox`, `NiceConsentBanner`, the
124
+ building and communication controls, four `ui-audio` panels and `NiceStreamDashboard` — are gone
125
+ from the types. `NiceResourceAllocation` in `ui-erp` is `NiceCapacityPlanner` (the one in `ui`
126
+ keeps its name); `NiceGenericPlayerStageVisualizer` (→ `NiceStageVisualizer`) and
127
+ `NiceCubeBrowserProps` are removed. The `@nice2dev/ui/overlays` entry calls its modal, drawer,
128
+ bottom sheet and context menu `NiceOverlayModal`, `NiceOverlayDrawer`, `NiceOverlayBottomSheet` and
129
+ `NiceOverlayContextMenu`: the old names belonged to different components of `@nice2dev/ui`.
130
+
131
+ **Dictionaries per language.** `NiceI18nProvider` loads only the language in use, with `import()`
132
+ (it was `NiceI18nLazyProvider` in 1.1.10, which stays as the same component); the controls show their
133
+ built-in English until it arrives — `await loadNiceDictionary(lang)` before the first render to start
134
+ in the language. Nothing on the main entry of `@nice2dev/i18n` imports a dictionary any more:
135
+ `NICE_I18N_DICTIONARIES`, `createTranslator`, `NICE_I18N_VARIANTS` / `resolvePlVariant` and the
136
+ translation tooling moved to the new entry `@nice2dev/i18n/all`, and `@nice2dev/ui-core` no longer
137
+ re-exports the dictionary map. `@nice2dev/ui` with what it bundles: 1283 kB → 952 kB gzip loaded up
138
+ front. The `ui-audio` controls read the app's `NiceI18nProvider` now; their own provider overrides it.
139
+
140
+ **New controls.** `NiceRecurrenceEditor`, `NiceStopwatch`, `NiceCountdownTimer` (`@nice2dev/ui`) and
141
+ `NicePasswordGenerator` (`@nice2dev/auth`), plus `recurrenceDates()` and `generatePassword()`.
142
+ `NiceScheduler` honours a weekly rule's `byDay`, which it ignored.
143
+
144
+ **Visible changes.** The palette meets WCAG AA for text on every fill: darker fills in the light
145
+ theme, dark text on the fills of the dark theme (new `--nice-text-on-success` / `-error` / `-info` /
146
+ `-accent` / `-warning`; `NiceThemeText` takes `onSuccess`, `onError`, `onInfo`, `onWarning`). Mobile
147
+ and platform panels follow the app theme instead of `prefers-color-scheme`. Swipes in
148
+ `NiceSwipeActions`, `NiceTouchTable` and `NiceMobileCalendar` work with a mouse and a pen. The
149
+ `ui-forms` editors have the intended spacing (it was four times too large). `NiceMAM`,
150
+ `NiceTranscoder`, `NiceVideoAnnotator` and `NiceStreamDashboard` use `nice-`-prefixed BEM classes.
151
+
152
+ **Fixes.** Controls that invented results ask the host instead: `NiceIntegrationHub`,
153
+ `NiceMLStudio` (`onExperimentRun` may return metrics), `NiceRemoteManagement`
154
+ (`onCaptureScreenshot`), `NicePoseDetector` (`detector`), `NiceBatchScannerProvider`,
155
+ `NiceCacheStrategies`; `NiceLowCodeStudio` accepts dropped components. Controls that did nothing
156
+ work or say why they are off: `NiceStreamDashboard` adds sources, sends chat and runs the chosen
157
+ transition (new `onAddPlatform`, `onSendChatMessage`, `onTransition`, `onScreenshot`,
158
+ `onOpenAudioMixer`, `onOpenSettings`; `receiveChatMessage` feeds incoming chat), `NiceMLStudio`
159
+ downloads through `onModelDownload`, `NiceETLBuilder` saves through `onSave` (its Save button had
160
+ no handler), `NiceTranscoder` makes jobs of picked and dropped files, `NiceAutomationEditor` offers
161
+ the trigger types its model has. Texts of about fifty components go
162
+ through `t()` in six languages, among them the AI data grid, chart and form builders, the ML
163
+ studio, the report designer, the song picker, `NiceProtocolConfig`, `NiceETLBuilder` and
164
+ `NiceInlineHelp` — every key the controls pass to `t()` now has a dictionary entry, so none of
165
+ them stays English under another language; `NiceDataGridAI` sorts on a query in any language, not
166
+ only in English. `NiceWindow`, `NiceConsole`, `NiceFileManager` and `NiceGitManager` no longer
167
+ crash when `accessMode` switches to or from `'hidden'`. Ids come from `createId()` (`@nice2dev/ui-core`), so nothing throws
168
+ outside a secure context as `crypto.randomUUID()` did on plain http. `ui-3d` runs on three r183
169
+ without its deprecation warnings. `NiceRemoteManagement` calls the handlers of the latest render.
170
+ The AI hint popover and the `ui-platform` panels follow the app theme, not the system's or a
171
+ `.dark` class on the host. `NiceCommandPalette` has styles and its search filters;
172
+ `NiceTimeoutFeedback` starts its clock; `NiceOfflineBanner` takes `online`; Monaco's workers in
173
+ `NiceCodeEditor` load; the `ui-audio` panels that used Bootstrap classes use Nice controls; colours
174
+ that reached a canvas as `var(…)` (karaoke lanes and notes) are resolved first.
175
+
3
176
  ## 1.1.10
4
177
 
5
178
  ### Patch Changes
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * @since 1.0.6
6
6
  */
7
- export type IconStyle = 'solid' | 'outline' | 'duotone' | 'flat';
7
+ export type IconStyle = 'solid' | 'outline' | 'duotone' | 'cutout';
8
8
  export type IconPackage = '@nice2dev/icons' | '@nice2dev/icons-business' | '@nice2dev/icons-all' | '@nice2dev/icons-cursor' | '@nice2dev/icons-education' | '@nice2dev/icons-filetypes' | '@nice2dev/icons-game' | '@nice2dev/icons-gaming' | '@nice2dev/icons-life' | '@nice2dev/icons-math' | '@nice2dev/icons-media' | '@nice2dev/icons-science' | '@nice2dev/icons-social' | '@nice2dev/icons-tech';
9
9
  export interface IconRef {
10
10
  /** Icon component name, e.g. "NtdBriefcase" or "CustomerIcon" */
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var we=Object.create;var ie=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Ee=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ve(e))!Ce.call(i,a)&&a!==t&&ie(i,a,{get:()=>e[a],enumerable:!(n=Se(e,a))||n.enumerable});return i};var Te=(i,e,t)=>(t=i!=null?we(ke(i)):{},Ee(e||!i||!i.__esModule?ie(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react");class Ve{constructor(e){this.cfg=typeof e=="string"?{baseUrl:e}:e}async request(e,t){const n=this.cfg.fetch??globalThis.fetch,a={"Content-Type":"application/json",...this.cfg.headers};if(this.cfg.tokenFactory){const l=await this.cfg.tokenFactory();a.Authorization=`Bearer ${l}`}const r=await n(`${this.cfg.baseUrl}${e}`,{...t,headers:{...a,...t==null?void 0:t.headers}});if(!r.ok)throw new Error(`ERP request failed: ${r.status} ${r.statusText}`);return r.json()}async load(e){var a,r;const t=new URLSearchParams;(e==null?void 0:e.skip)!=null&&t.set("skip",String(e.skip)),(e==null?void 0:e.take)!=null&&t.set("take",String(e.take)),e!=null&&e.search&&t.set("search",e.search),(a=e==null?void 0:e.sort)!=null&&a.length&&t.set("sort",JSON.stringify(e.sort)),(r=e==null?void 0:e.filters)!=null&&r.length&&t.set("filters",JSON.stringify(e.filters));const n=t.toString();return this.request(n?`?${n}`:"")}async getById(e){return this.request(`/${e}`)}async create(e){return this.request("",{method:"POST",body:JSON.stringify(e)})}async update(e,t){return this.request(`/${e}`,{method:"PUT",body:JSON.stringify(t)})}async remove(e){return this.request(`/${e}`,{method:"DELETE"})}async removeBatch(e){return this.request("/batch-delete",{method:"POST",body:JSON.stringify({ids:e})})}async createBatch(e){return this.request("/batch",{method:"POST",body:JSON.stringify({items:e})})}async updateBatch(e){return this.request("/batch",{method:"PUT",body:JSON.stringify({items:e})})}async patch(e,t){return this.request(`/${e}`,{method:"PATCH",body:JSON.stringify(t)})}}async function Pe(i){const e=await import("@microsoft/signalr");let t="disconnected";const n=new Set,a=d=>{t=d,n.forEach(g=>g(d))},l=new e.HubConnectionBuilder().withUrl(i.hubUrl,{accessTokenFactory:i.accessTokenFactory?()=>i.accessTokenFactory():void 0}).withAutomaticReconnect().build();return l.onreconnecting(()=>a("reconnecting")),l.onreconnected(()=>a("connected")),l.onclose(()=>a("disconnected")),{get status(){return t},async start(){a("connecting"),await l.start(),a("connected")},async stop(){await l.stop(),a("disconnected")},on(d,g){l.on(d,g)},off(d,g){l.off(d,g)},invoke(d,...g){return l.invoke(d,...g)},onStatusChange(d){return n.add(d),()=>n.delete(d)}}}function ue(i){const{adapter:e,entityName:t,keyField:n,initialData:a=[],onBeforeChange:r,onAfterChange:l,onConflict:c,subscribeMethod:d="SubscribeToEntity",unsubscribeMethod:g="UnsubscribeFromEntity",changeEventName:S="EntityChanged",flashChanges:w=!0,flashDuration:T=500,optimisticUpdates:A=!0}=i,[W,L]=o.useState(a),[Q,G]=o.useState(e.status),[X,D]=o.useState(new Set),[q,O]=o.useState(new Set),[Z,ee]=o.useState(null),B=o.useRef(new Map),z=o.useRef(new Map),_=o.useCallback((y,V)=>{const{operation:v,key:E,data:k,changes:M}=V;switch(v){case"insert":return!k||y.some(R=>R[n]===E)?y:[...y,k];case"update":return y.map(R=>{if(R[n]!==E)return R;const K=B.current.get(E);if(K&&c){const ae=c({...R,...K.changes},k??{...R,...M},V);return ae==="local"?{...R,...K.changes}:ae==="remote"?(B.current.delete(E),k??{...R,...M}):ae==="merge"?{...R,...M,...K.changes}:ae}return k||{...R,...M}});case"delete":return y.filter(R=>R[n]!==E);default:return y}},[n,c]),N=o.useCallback(y=>{if(!w)return;const V=z.current.get(y);V&&clearTimeout(V),D(E=>new Set([...E,y]));const v=setTimeout(()=>{D(E=>{const k=new Set(E);return k.delete(y),k}),z.current.delete(y)},T);z.current.set(y,v)},[w,T]),$=o.useCallback(async y=>{y.entityName===t&&(r&&!await r(y)||(L(V=>{const v=_(V,y);return l==null||l(y,v),v}),N(y.key)))},[t,r,_,l,N]),p=o.useCallback(y=>{$(y)},[$]),se=o.useCallback((y,V)=>{if(!A)return;const v=W.find(E=>E[n]===y);v&&(B.current.set(y,{original:v,changes:V}),O(E=>new Set([...E,y])))},[W,n,A]),j=o.useCallback(y=>{B.current.delete(y),O(V=>{const v=new Set(V);return v.delete(y),v})},[]),U=o.useCallback(y=>{const V=B.current.get(y);V&&(L(v=>v.map(E=>E[n]===y?V.original:E)),B.current.delete(y),O(v=>{const E=new Set(v);return E.delete(y),E}))},[n]),te=o.useCallback(async()=>{if(e.status==="connected")try{await e.invoke(d,t),ee(null)}catch(y){ee(y instanceof Error?y:new Error(String(y)))}},[e,d,t]),ne=o.useCallback(async()=>{if(e.status==="connected")try{await e.invoke(g,t)}catch{}},[e,g,t]);return o.useEffect(()=>{const y=e.onStatusChange(v=>{G(v),v==="connected"&&te()});e.on(S,$),e.status==="connected"&&te();const V=z.current;return()=>{y(),e.off(S,$),ne(),V.forEach(v=>clearTimeout(v)),V.clear()}},[e,S,$,te,ne]),o.useEffect(()=>{L(a)},[a]),{data:W,status:Q,flashedKeys:X,pendingKeys:q,error:Z,applyRemoteUpdate:p,registerPendingChange:se,confirmPendingChange:j,rollbackPendingChange:U,resubscribe:te}}function Ae(i){const{adapter:e,entityName:t,keyField:n,fetchMethod:a="GetEntities",insertMethod:r="InsertEntity",updateMethod:l="UpdateEntity",deleteMethod:c="DeleteEntity"}=i;return{async fetchAll(d){return e.invoke(a,t,d)},async insert(d){return e.invoke(r,t,d)},async update(d,g){return e.invoke(l,t,d,g)},async remove(d){return e.invoke(c,t,d)},getKeyField(){return n}}}function Oe(i,e,t){const n=new Map(i.map(a=>[a[t],a]));for(const a of e)switch(a.operation){case"insert":a.data&&!n.has(a.key)&&n.set(a.key,a.data);break;case"update":if(n.has(a.key)){const r=n.get(a.key);n.set(a.key,a.data??{...r,...a.changes})}break;case"delete":n.delete(a.key);break}return Array.from(n.values())}function ce(i){const{adapter:e,entityType:t,entityId:n,currentUser:a,initialStatus:r="viewing",heartbeatInterval:l=3e4,idleTimeout:c=6e4,awayTimeout:d=3e5,joinMethod:g="JoinEntityView",leaveMethod:S="LeaveEntityView",updateMethod:w="UpdateEntityPresence",presenceEventName:T="EntityPresenceChanged",joinedEventName:A="EntityUserJoined",leftEventName:W="EntityUserLeft",onPresenceChange:L,onEditConflict:Q}=i,[G,X]=o.useState([]),[D,q]=o.useState(r),[O,Z]=o.useState(),[ee,B]=o.useState(e.status),z=o.useRef(Date.now()),_=o.useRef(null),N=o.useRef(null),$=o.useRef(null),p=o.useMemo(()=>Array.isArray(n)?n:[n],[n]),se=o.useMemo(()=>`${t}:${[...p].sort().join(",")}`,[t,p]),j=o.useCallback(async(f,C,s)=>{if(e.status==="connected")try{await e.invoke(w,{entityType:t,entityIds:p,userId:a.id,status:f,editingField:C,selection:s,timestamp:new Date().toISOString()})}catch{}},[e,w,t,p,a.id]),U=o.useCallback((f,C)=>{q(f),Z(C),j(f,C),z.current=Date.now()},[j]),te=o.useCallback(f=>{const C=G.find(s=>s.user.id!==a.id&&s.status==="editing"&&s.editingField===f);C&&(Q==null||Q(C.user,f)),U("editing",f)},[G,a.id,Q,U]),ne=o.useCallback(()=>{U("viewing",void 0)},[U]),y=o.useCallback(f=>{j(D,O,f),z.current=Date.now()},[j,D,O]),V=o.useCallback(f=>{const C=G.find(s=>s.user.id!==a.id&&s.status==="editing"&&s.editingField===f);return(C==null?void 0:C.user)??null},[G,a.id]),v=o.useCallback(f=>{const C=G.find(s=>s.status==="editing"&&s.editingField===f);return(C==null?void 0:C.user)??null},[G]),E=o.useCallback(async()=>{if(e.status==="connected")try{const f=await e.invoke("GetEntityPresence",t,p);Array.isArray(f)&&(X(f),L==null||L(f))}catch{}},[e,t,p,L]),k=o.useCallback(()=>{z.current=Date.now(),N.current&&clearTimeout(N.current),$.current&&clearTimeout($.current),(D==="idle"||D==="away")&&U(O?"editing":"viewing",O),N.current=setTimeout(()=>{U("idle",O)},c),$.current=setTimeout(()=>{U("away",O)},d)},[D,O,c,d,U]),M=o.useCallback(f=>{f.entityType!==t||!f.entityIds.some(s=>p.includes(s))||(X(f.presence.filter(s=>s.user.id!==a.id)),L==null||L(f.presence))},[t,p,a.id,L]),R=o.useCallback(f=>{f.entityType!==t||!f.entityIds.some(s=>p.includes(s))||f.presence.user.id===a.id||X(s=>{const b=s.findIndex(I=>I.user.id===f.presence.user.id);if(b>=0){const I=[...s];return I[b]=f.presence,I}return[...s,f.presence]})},[t,p,a.id]),K=o.useCallback(f=>{f.entityType!==t||!f.entityIds.some(s=>p.includes(s))||X(s=>s.filter(b=>b.user.id!==f.userId))},[t,p]);o.useEffect(()=>{const f=e.onStatusChange(B);e.on(T,M),e.on(A,R),e.on(W,K);const C=async()=>{if(e.status==="connected")try{await e.invoke(g,{entityType:t,entityIds:p,user:a,status:D}),await E()}catch{}};return e.status==="connected"&&C(),()=>{f(),e.off(T,M),e.off(A,R),e.off(W,K),e.status==="connected"&&e.invoke(S,{entityType:t,entityIds:p,userId:a.id}).catch(()=>{})}},[e,se,g,S,T,A,W,M,R,K,E,a,D,t,p]),o.useEffect(()=>(_.current=setInterval(()=>{j(D,O)},l),()=>{_.current&&clearInterval(_.current)}),[l,j,D,O]),o.useEffect(()=>{const f=["mousemove","keydown","mousedown","touchstart","scroll"];return f.forEach(C=>window.addEventListener(C,k,{passive:!0})),N.current=setTimeout(()=>{U("idle",O)},c),$.current=setTimeout(()=>{U("away",O)},d),()=>{f.forEach(C=>window.removeEventListener(C,k)),N.current&&clearTimeout(N.current),$.current&&clearTimeout($.current)}},[k,c,d,O,U]);const ae=G.filter(f=>f.status==="viewing"||f.status==="idle").map(f=>f.user),oe=G.filter(f=>f.status==="editing").map(f=>f.user),re=oe.length>0;return{presence:G,viewers:ae,editors:oe,myStatus:D,setMyStatus:U,startEditing:te,stopEditing:ne,updateSelection:y,connectionStatus:ee,isFieldLocked:V,hasActiveEditors:re,getFieldEditor:v,refresh:E}}function de(i){const e=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16","#f97316","#14b8a6"];let t=0;for(let n=0;n<i.length;n++)t=i.charCodeAt(n)+((t<<5)-t);return e[Math.abs(t)%e.length]}function Re(i){switch(i){case"viewing":return"Viewing";case"editing":return"Editing";case"idle":return"Idle";case"away":return"Away";default:return"Unknown"}}function xe(i){const{adapter:e,entityType:t,currentUser:n,batchEventName:a="BatchPresenceUpdate"}=i,[r,l]=o.useState(new Map),c=o.useCallback(w=>{w.entityType===t&&l(new Map(Object.entries(w.presenceByEntity)))},[t]);o.useEffect(()=>(e.on(a,c),()=>{e.off(a,c)}),[e,a,c]);const d=o.useCallback(w=>r.get(w)??[],[r]),g=o.useCallback(w=>{const T=r.get(w);return(T==null?void 0:T.some(A=>A.status==="editing"&&A.user.id!==n.id))??!1},[r,n.id]),S=o.useCallback(w=>{const T=r.get(w);return(T==null?void 0:T.filter(A=>A.status==="editing").map(A=>A.user))??[]},[r]);return{presenceByEntity:r,getPresence:d,isEntityBeingEdited:g,getEntityEditors:S}}function J(i){return`${String(i.rowKey)}:${i.field}`}function Le(i){return i?typeof i=="number"?i:new Date(i).getTime():Date.now()}function De(i){const{adapter:e,entityType:t,keyField:n,currentUser:a,initialData:r=[],conflictStrategy:l="last-write-wins",mergeFunction:c,onConflict:d,onBeforeCommit:g,onAfterCommit:S,enableCellLocking:w=!0,lockTimeout:T=6e4,enableCursorSharing:A=!0,cursorDebounce:W=50,optimisticUpdates:L=!0,flashChanges:Q=!0,flashDuration:G=500,liveDataOptions:X={}}=i,[D,q]=o.useState(new Map),[O,Z]=o.useState(new Map),[ee,B]=o.useState([]),[z,_]=o.useState(null),[N,$]=o.useState([]),[p,se]=o.useState([]),[j,U]=o.useState(null),[te,ne]=o.useState([]),y=o.useRef(null),V=o.useRef(new Map),v=o.useCallback(u=>(V.current.has(u)||V.current.set(u,de(u)),V.current.get(u)),[]),E=o.useCallback((u,m,h)=>{if(!h.changes)return m;const P=O.get(J({rowKey:h.key,field:Object.keys(h.changes)[0]}));if(!P)return m;const F=P.timestamp,x=Le(h.timestamp);switch(l){case"last-write-wins":return F>x?"local":"remote";case"first-write-wins":return F<x?"local":"remote";case"merge":return c?c(u,m,Object.keys(h.changes)[0]):"merge";case"ask-user":{const H={cell:{rowKey:h.key,field:Object.keys(h.changes)[0]},localValue:P.newValue,remoteValue:h.changes[Object.keys(h.changes)[0]],localUser:a,remoteUser:h.changedBy?{id:h.changedBy,name:h.changedBy}:{id:"unknown",name:"Unknown"},localTimestamp:F,remoteTimestamp:x};return B(le=>[...le,H]),"local"}case"reject":return"remote";default:return"remote"}},[O,l,c,a]),k=ue({adapter:e,entityName:t,keyField:n,initialData:r,flashChanges:Q,flashDuration:G,optimisticUpdates:L,onConflict:E,...X}),M=ce({adapter:e,entityType:t,entityId:"grid",currentUser:a,initialStatus:"viewing"}),R=o.useCallback(()=>{!A||e.status!=="connected"||e.invoke("UpdateGridSelection",{entityType:t,userId:a.id,focusedCell:z,selectedCells:N,selectedRows:p,editingCell:j}).catch(()=>{})},[e,A,t,a.id,z,N,p,j]);o.useEffect(()=>{if(A)return y.current&&clearTimeout(y.current),y.current=setTimeout(R,W),()=>{y.current&&clearTimeout(y.current)}},[A,R,W,z,N,p,j]),o.useEffect(()=>{if(!A)return;const u=m=>{m.entityType!==t||m.userId===a.id||ne(h=>{const P=h.findIndex(x=>x.user.id===m.userId),F={user:{id:m.userId,name:m.userName,avatarUrl:m.avatarUrl},focusedCell:m.focusedCell,selectedCells:m.selectedCells,selectedRows:m.selectedRows,editingCell:m.editingCell,color:v(m.userId)};if(P>=0){const x=[...h];return x[P]=F,x}return[...h,F]})};return e.on("GridSelectionUpdated",u),()=>{e.off("GridSelectionUpdated",u)}},[e,A,t,a.id,v]),o.useEffect(()=>{if(!w)return;const u=h=>{h.entityType===t&&q(P=>{const F=new Map(P);return F.set(J(h.cell),{user:h.user,timestamp:h.timestamp}),F})},m=h=>{h.entityType===t&&q(P=>{const F=new Map(P);return F.delete(J(h.cell)),F})};return e.on("CellLocked",u),e.on("CellUnlocked",m),()=>{e.off("CellLocked",u),e.off("CellUnlocked",m)}},[e,w,t]),o.useEffect(()=>{if(!w)return;const u=setInterval(()=>{const m=Date.now();q(h=>{const P=new Map(h);let F=!1;for(const[x,H]of P)m-H.timestamp>T&&(P.delete(x),F=!0);return F?P:h})},1e4);return()=>clearInterval(u)},[w,T]);const K=o.useCallback(u=>{if(!w)return!1;const m=D.get(J(u));return m?m.user.id!==a.id&&Date.now()-m.timestamp<T:!1},[w,D,a.id,T]),ae=o.useCallback(u=>{const m=D.get(J(u));return!m||Date.now()-m.timestamp>T?null:m.user},[D,T]),oe=o.useCallback(u=>K(u)?!1:(U(u),M.startEditing(`${u.rowKey}:${u.field}`),w&&e.status==="connected"&&(e.invoke("AcquireCellLock",{entityType:t,cell:u,user:a,timestamp:Date.now()}).catch(()=>{}),q(m=>{const h=new Map(m);return h.set(J(u),{user:a,timestamp:Date.now()}),h})),!0),[K,M,w,e,t,a]),re=o.useCallback(async(u,m)=>{const h=k.data.find(x=>x[n]===u.rowKey);if(!h)return!1;const P=h[u.field];if(g&&!await g(u,P,m))return f(u),!1;const F={cell:u,originalValue:P,newValue:m,timestamp:Date.now()};Z(x=>{const H=new Map(x);return H.set(J(u),F),H}),L&&k.registerPendingChange(u.rowKey,{[u.field]:m});try{return await e.invoke("UpdateEntityField",{entityType:t,entityId:u.rowKey,field:u.field,value:m,userId:a.id,timestamp:F.timestamp}),k.confirmPendingChange(u.rowKey),Z(x=>{const H=new Map(x);return H.delete(J(u)),H}),S==null||S(u,m),w&&(e.invoke("ReleaseCellLock",{entityType:t,cell:u}).catch(()=>{}),q(x=>{const H=new Map(x);return H.delete(J(u)),H})),U(null),M.stopEditing(),!0}catch(x){throw k.rollbackPendingChange(u.rowKey),Z(H=>{const le=new Map(H);return le.delete(J(u)),le}),x}},[k,n,g,L,e,t,a.id,S,w,M]),f=o.useCallback(u=>{U(null),M.stopEditing(),w&&e.status==="connected"&&(e.invoke("ReleaseCellLock",{entityType:t,cell:u}).catch(()=>{}),q(m=>{const h=new Map(m);return h.delete(J(u)),h})),Z(m=>{const h=new Map(m);return h.delete(J(u)),h})},[M,w,e,t]),C=o.useCallback((u,m)=>{const h=ee.find(P=>J(P.cell)===J(u));h&&(m==="remote"&&k.applyRemoteUpdate({operation:"update",entityName:t,key:u.rowKey,changes:{[u.field]:h.remoteValue}}),B(P=>P.filter(F=>J(F.cell)!==J(u))))},[ee,k,t]),s=o.useCallback(async u=>{await e.invoke("InsertEntity",t,u)},[e,t]),b=o.useCallback(async(u,m)=>{L&&k.registerPendingChange(u,m);try{await e.invoke("UpdateEntity",t,u,m),k.confirmPendingChange(u)}catch(h){throw k.rollbackPendingChange(u),h}},[e,t,L,k]),I=o.useCallback(async u=>{await e.invoke("DeleteEntity",t,u)},[e,t]),Y=o.useMemo(()=>({user:a,focusedCell:z,selectedCells:N,selectedRows:p,editingCell:j,color:v(a.id)}),[a,z,N,p,j,v]);return{data:k.data,presence:M.presence,userSelections:te,mySelection:Y,flashedKeys:k.flashedKeys,pendingEdits:O,connectionStatus:k.status,myPresenceStatus:M.myStatus,setFocusedCell:_,setSelectedCells:$,setSelectedRows:se,startCellEdit:oe,commitCellEdit:re,cancelCellEdit:f,isCellLocked:K,getCellEditor:ae,getUserColor:v,insertRow:s,updateRow:b,deleteRow:I,resolveConflict:C,conflicts:ee}}class Ne{constructor(e){this.accessToken=null,this.refreshToken=null,this.tokenFactory=async()=>{if(!this.accessToken)throw new Error("Not authenticated");return this.accessToken},this.cfg=e}getAccessToken(){return this.accessToken}async post(e,t){const a=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`Auth request failed: ${a.status}`);return a.json()}async login(e){var n,a;const t=await this.post("/login",e);return t.token&&(this.accessToken=t.token,this.refreshToken=t.refreshToken??null,(a=(n=this.cfg).onTokens)==null||a.call(n,t.token,t.refreshToken??"")),t}async refresh(){var t,n;if(!this.refreshToken)throw new Error("No refresh token");const e=await this.post("/refresh",{refreshToken:this.refreshToken});return e.token&&(this.accessToken=e.token,this.refreshToken=e.refreshToken??this.refreshToken,(n=(t=this.cfg).onTokens)==null||n.call(t,e.token,this.refreshToken)),e}async me(){const t=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/me`,{headers:{Authorization:`Bearer ${this.accessToken}`}});if(!t.ok)throw new Error(`Auth /me failed: ${t.status}`);return t.json()}async logout(){try{await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/logout`,{method:"POST",headers:{Authorization:`Bearer ${this.accessToken}`}})}finally{this.accessToken=null,this.refreshToken=null}}}class Ue{constructor(e){this.cfg=e}async headers(){const e={};return this.cfg.tokenFactory&&(e.Authorization=`Bearer ${await this.cfg.tokenFactory()}`),e}async upload(e,t){const n=this.cfg.fetch??globalThis.fetch,a=new FormData;a.append("file",e),t&&a.append("folder",t);const r=await n(this.cfg.baseUrl,{method:"POST",headers:await this.headers(),body:a});if(!r.ok)throw new Error(`File upload failed: ${r.status}`);return r.json()}async uploadMultiple(e,t){const n=this.cfg.fetch??globalThis.fetch,a=new FormData;e.forEach(l=>a.append("files",l)),t&&a.append("folder",t);const r=await n(`${this.cfg.baseUrl}/batch`,{method:"POST",headers:await this.headers(),body:a});if(!r.ok)throw new Error(`Batch upload failed: ${r.status}`);return r.json()}async getInfo(e){const n=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/${e}/info`,{headers:{...await this.headers(),"Content-Type":"application/json"}});if(!n.ok)throw new Error(`File info failed: ${n.status}`);return n.json()}async getDownloadUrl(e){const n=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/${e}`,{headers:await this.headers()});if(!n.ok)throw new Error(`File download failed: ${n.status}`);const a=await n.blob();return URL.createObjectURL(a)}async remove(e){const n=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/${e}`,{method:"DELETE",headers:{...await this.headers(),"Content-Type":"application/json"}});if(!n.ok)throw new Error(`File delete failed: ${n.status}`);return n.json()}async uploadWithProgress(e,t,n,a){if(typeof XMLHttpRequest>"u")return this.upload(e,n);const r=await this.headers();return new Promise((l,c)=>{const d=new XMLHttpRequest,g=new FormData;if(g.append("file",e),n&&g.append("folder",n),a){if(a.aborted){c(new DOMException("Aborted","AbortError"));return}a.addEventListener("abort",()=>{d.abort(),c(new DOMException("Aborted","AbortError"))})}d.upload.addEventListener("progress",S=>{t({loaded:S.loaded,total:S.total,percent:S.lengthComputable?S.loaded/S.total:NaN})}),d.addEventListener("load",()=>{if(d.status>=200&&d.status<300)try{l(JSON.parse(d.responseText))}catch{c(new Error("Invalid JSON response"))}else c(new Error(`File upload failed: ${d.status}`))}),d.addEventListener("error",()=>c(new Error("Network error during upload"))),d.addEventListener("abort",()=>c(new DOMException("Aborted","AbortError"))),d.open("POST",this.cfg.baseUrl),Object.entries(r).forEach(([S,w])=>d.setRequestHeader(S,w)),d.send(g)})}async uploadMultipleWithProgress(e,t,n,a){const r=[];for(let l=0;l<e.length;l++){if(a!=null&&a.aborted)throw new DOMException("Aborted","AbortError");const c=await this.uploadWithProgress(e[l],d=>t(l,d),n,a);r.push(c)}return r}}class Fe{constructor(e){this.cfg=e}async headers(){const e={"Content-Type":"application/json"};return this.cfg.tokenFactory&&(e.Authorization=`Bearer ${await this.cfg.tokenFactory()}`),e}async requestExport(e){const n=await(this.cfg.fetch??globalThis.fetch)(this.cfg.baseUrl,{method:"POST",headers:await this.headers(),body:JSON.stringify(e)});if(!n.ok)throw new Error(`Export request failed: ${n.status}`);return n.json()}async download(e){const n=await(this.cfg.fetch??globalThis.fetch)(e,{headers:await this.headers()});if(!n.ok)throw new Error(`Export download failed: ${n.status}`);return n.blob()}async downloadToFile(e,t){var c;const n=await this.requestExport(e);if(!((c=n.data)!=null&&c.downloadUrl))throw new Error("No download URL returned");const a=await this.download(n.data.downloadUrl),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=t??`export.${e.format}`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}}function Me(i){return e=>{const t=e??globalThis.fetch;return(a,r)=>{const d={url:typeof a=="string"?a:a instanceof URL?a.toString():a.url,init:r??{},meta:{}};let g=S=>t(S.url,S.init);for(let S=i.length-1;S>=0;S--){const w=i[S],T=g;g=A=>w(A,T)}return g(d)}}}function Ie(){return async(i,e)=>{const t=performance.now(),n=(i.init.method??"GET").toUpperCase();try{const a=await e(i),r=(performance.now()-t).toFixed(1);return console.debug(`[ERP] ${n} ${i.url} → ${a.status} (${r}ms)`),a}catch(a){const r=(performance.now()-t).toFixed(1);throw console.error(`[ERP] ${n} ${i.url} FAILED (${r}ms)`,a),a}}}function $e(i){const e=(i==null?void 0:i.maxRetries)??3,t=(i==null?void 0:i.baseDelay)??500,n=new Set((i==null?void 0:i.retryOn)??[408,429,500,502,503,504]);return async(a,r)=>{let l;for(let c=0;c<=e;c++){try{const g=await r(a);if(g.ok||!n.has(g.status)||c===e)return g;l=new Error(`HTTP ${g.status}`)}catch(g){if(l=g,c===e)throw g}const d=t*Math.pow(2,c)*(.5+Math.random()*.5);await new Promise(g=>setTimeout(g,d))}throw l}}function Be(i){return async(e,t)=>{const n=typeof i=="function"?await i():i;return e.init.headers={...e.init.headers,...n},t(e)}}class ze{constructor(e){this.inFlight=0,this.timestamps=[],this.queue=[],this.processing=!1,this.backingOff=!1,this.maxConcurrent=(e==null?void 0:e.maxConcurrent)??6,this.maxPerSecond=(e==null?void 0:e.maxPerSecond)??20,this.backoffDelay=(e==null?void 0:e.backoffDelay)??2e3,this.baseFetch=(e==null?void 0:e.baseFetch)??globalThis.fetch.bind(globalThis),this.fetch=this.fetch.bind(this)}fetch(e,t){return new Promise((n,a)=>{this.queue.push({resolve:n,reject:a,input:e,init:t}),this.drain()})}get pending(){return this.queue.length}get active(){return this.inFlight}drain(){if(this.processing)return;this.processing=!0;const e=()=>{if(this.queue.length===0||this.backingOff){this.processing=!1;return}if(this.inFlight>=this.maxConcurrent){this.processing=!1;return}const t=Date.now();if(this.timestamps=this.timestamps.filter(a=>t-a<1e3),this.timestamps.length>=this.maxPerSecond){const a=this.timestamps[0],r=1e3-(t-a)+1;setTimeout(()=>{this.processing=!1,this.drain()},r);return}const n=this.queue.shift();this.inFlight++,this.timestamps.push(t),this.baseFetch(n.input,n.init).then(a=>{if(this.inFlight--,a.status===429){this.queue.unshift(n),this.inFlight++,this.inFlight--,this.backingOff=!0,setTimeout(()=>{this.backingOff=!1,this.drain()},this.backoffDelay);return}n.resolve(a),queueMicrotask(e)}).catch(a=>{this.inFlight--,n.reject(a),queueMicrotask(e)}),queueMicrotask(e)};e()}}class je{constructor(e,t="id"){this.items=[],this.mutations=[],this.listeners=new Set,this.nextMutationId=1,this.adapter=e,this.keyField=t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){const e=[...this.items],t=[...this.mutations];this.listeners.forEach(n=>n(e,t))}getItems(){return[...this.items]}getPending(){return this.mutations.filter(e=>e.status==="pending")}setItems(e){this.items=[...e],this.notify()}async load(...e){const t=await this.adapter.load(...e);return t.success&&(this.items=t.data,this.mutations=[],this.notify()),t}async create(e){const t=`__temp_${this.nextMutationId}`,n={...e,[this.keyField]:t},r={id:String(this.nextMutationId++),type:"create",optimisticData:n,timestamp:Date.now(),status:"pending"};this.items=[...this.items,n],this.mutations.push(r),this.notify();try{const l=await this.adapter.create(e);return l.success?(this.items=this.items.map(c=>c[this.keyField]===t?l.data:c),r.status="confirmed",r.entityId=l.data[this.keyField]):(this.items=this.items.filter(c=>c[this.keyField]!==t),r.status="failed",r.error=l.error),this.notify(),l}catch(l){throw this.items=this.items.filter(c=>c[this.keyField]!==t),r.status="failed",r.error=l instanceof Error?l.message:String(l),this.notify(),l}}async update(e,t){const n=this.items.findIndex(c=>c[this.keyField]===e),a=n>=0?{...this.items[n]}:void 0,l={id:String(this.nextMutationId++),type:"update",entityId:e,previousData:a,timestamp:Date.now(),status:"pending"};n>=0&&(this.items=this.items.map((c,d)=>d===n?{...c,...t}:c)),this.mutations.push(l),this.notify();try{const c=await this.adapter.update(e,t);return c.success?(this.items=this.items.map(d=>d[this.keyField]===e?c.data:d),l.status="confirmed"):(a&&n>=0&&(this.items=this.items.map(d=>d[this.keyField]===e?a:d)),l.status="failed",l.error=c.error),this.notify(),c}catch(c){throw a&&n>=0&&(this.items=this.items.map(d=>d[this.keyField]===e?a:d)),l.status="failed",l.error=c instanceof Error?c.message:String(c),this.notify(),c}}async remove(e){const t=this.items.findIndex(l=>l[this.keyField]===e),n=t>=0?{...this.items[t]}:void 0,r={id:String(this.nextMutationId++),type:"delete",entityId:e,previousData:n,timestamp:Date.now(),status:"pending"};this.items=this.items.filter(l=>l[this.keyField]!==e),this.mutations.push(r),this.notify();try{const l=await this.adapter.remove(e);return l.success?r.status="confirmed":(n&&this.items.splice(t,0,n),r.status="failed",r.error=l.error),this.notify(),l}catch(l){throw n&&this.items.splice(t,0,n),r.status="failed",r.error=l instanceof Error?l.message:String(l),this.notify(),l}}}class Je{constructor(e){this.queue=[],this.syncing=!1,this.nextId=1,this.config=e??{},this.baseFetch=(e==null?void 0:e.baseFetch)??globalThis.fetch.bind(globalThis),this.storageKey=(e==null?void 0:e.storageKey)??"erp_offline_",this.fetch=this.fetch.bind(this),this.restoreQueue(),this.boundOnline=()=>{var t,n;(n=(t=this.config).onStatusChange)==null||n.call(t,!0),this.sync()},this.boundOffline=()=>{var t,n;(n=(t=this.config).onStatusChange)==null||n.call(t,!1)},typeof window<"u"&&(window.addEventListener("online",this.boundOnline),window.addEventListener("offline",this.boundOffline))}fetch(e,t){var l,c;const n=typeof e=="string"?e:e instanceof URL?e.toString():e.url,a=((t==null?void 0:t.method)??"GET").toUpperCase();if(this.isOnline())return this.baseFetch(e,t);if(a==="GET"||a==="HEAD")return Promise.reject(new Error("Offline: GET requests are not queued"));const r={id:`q_${this.nextId++}`,url:n,method:a,headers:{...t==null?void 0:t.headers},body:typeof(t==null?void 0:t.body)=="string"?t.body:void 0,timestamp:Date.now()};return this.queue.push(r),this.persistQueue(),(c=(l=this.config).onQueued)==null||c.call(l,r),Promise.resolve(new Response(JSON.stringify({queued:!0,queueId:r.id}),{status:202,headers:{"Content-Type":"application/json"}}))}isOnline(){return typeof navigator>"u"||navigator.onLine}get pendingCount(){return this.queue.length}getQueue(){return[...this.queue]}clear(){this.queue=[],this.persistQueue()}async sync(){var t,n;if(this.syncing||this.queue.length===0||!this.isOnline())return[];this.syncing=!0;const e=[];for(;this.queue.length>0&&this.isOnline();){const a=this.queue[0];try{const r=await this.baseFetch(a.url,{method:a.method,headers:a.headers,body:a.body});e.push({entry:a,success:r.ok,status:r.status,error:r.ok?void 0:`HTTP ${r.status}`}),this.queue.shift()}catch(r){e.push({entry:a,success:!1,error:r instanceof Error?r.message:String(r)});break}}return this.persistQueue(),this.syncing=!1,e.length>0&&((n=(t=this.config).onSync)==null||n.call(t,e)),e}destroy(){typeof window<"u"&&(window.removeEventListener("online",this.boundOnline),window.removeEventListener("offline",this.boundOffline))}persistQueue(){try{typeof localStorage<"u"&&localStorage.setItem(`${this.storageKey}queue`,JSON.stringify(this.queue))}catch{}}restoreQueue(){try{if(typeof localStorage<"u"){const e=localStorage.getItem(`${this.storageKey}queue`);e&&(this.queue=JSON.parse(e),this.nextId=this.queue.reduce((t,n)=>Math.max(t,parseInt(n.id.replace("q_",""),10)||0),0)+1)}}catch{this.queue=[]}}}const he=[{type:"NiceAudioPlayer",label:"Audio Player",category:"Audio",icon:"music",defaultProps:{src:"",autoplay:!1,showWaveform:!0},propDescriptors:[{name:"src",type:"string",label:"Audio source URL"},{name:"autoplay",type:"boolean",label:"Auto-play",defaultValue:!1},{name:"loop",type:"boolean",label:"Loop",defaultValue:!1},{name:"showWaveform",type:"boolean",label:"Show waveform",defaultValue:!0},{name:"showPlaylist",type:"boolean",label:"Show playlist",defaultValue:!1},{name:"visualizerMode",type:"select",label:"Visualizer mode",options:[{label:"None",value:"none"},{label:"Bars",value:"bars"},{label:"Wave",value:"wave"},{label:"Circle",value:"circle"}],defaultValue:"bars"},{name:"height",type:"size",label:"Height",group:"Layout"}]},{type:"NiceWaveform",label:"Waveform",category:"Audio",icon:"waveform",defaultProps:{peaks:[],color:"#4a90d9"},propDescriptors:[{name:"peaks",type:"json",label:"Peak data (JSON array)"},{name:"color",type:"color",label:"Waveform color",defaultValue:"#4a90d9"},{name:"progressColor",type:"color",label:"Progress color",defaultValue:"#1b5e20"},{name:"barWidth",type:"number",label:"Bar width (px)",min:1,max:10,step:1,defaultValue:2},{name:"height",type:"size",label:"Height",group:"Layout"},{name:"interactive",type:"boolean",label:"Allow seeking",defaultValue:!0}]},{type:"NicePianoRoll",label:"Piano Roll",category:"Audio",icon:"piano",defaultProps:{notes:[],octaves:4,startOctave:3},propDescriptors:[{name:"notes",type:"json",label:"MIDI notes (JSON)"},{name:"octaves",type:"number",label:"Visible octaves",min:1,max:8,defaultValue:4},{name:"startOctave",type:"number",label:"Start octave",min:0,max:8,defaultValue:3},{name:"quantize",type:"select",label:"Quantize",options:[{label:"1/4",value:"4"},{label:"1/8",value:"8"},{label:"1/16",value:"16"},{label:"1/32",value:"32"}],defaultValue:"16"},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1},{name:"height",type:"size",label:"Height",group:"Layout"}]},{type:"NiceKaraoke",label:"Karaoke",category:"Audio",icon:"microphone",defaultProps:{lyrics:[],audioSrc:""},propDescriptors:[{name:"audioSrc",type:"string",label:"Audio source URL"},{name:"lyrics",type:"json",label:"Lyrics (JSON array of {time, text})"},{name:"showScore",type:"boolean",label:"Show score",defaultValue:!0},{name:"pitchDetection",type:"boolean",label:"Pitch detection",defaultValue:!0},{name:"highlightColor",type:"color",label:"Highlight color",defaultValue:"#ffd700"},{name:"fontSize",type:"size",label:"Font size",group:"Typography"}]}],pe=[{type:"NiceLoginForm",label:"Login Form",category:"Auth",icon:"log-in",defaultProps:{showRemember:!0,showForgotPassword:!0},propDescriptors:[{name:"title",type:"string",label:"Form title",defaultValue:"Sign In"},{name:"showRemember",type:"boolean",label:"Show 'Remember me'",defaultValue:!0},{name:"showForgotPassword",type:"boolean",label:"Show 'Forgot password'",defaultValue:!0},{name:"showRegisterLink",type:"boolean",label:"Show register link",defaultValue:!1},{name:"showLogo",type:"boolean",label:"Show logo",defaultValue:!0},{name:"logoUrl",type:"string",label:"Logo URL",group:"Branding"},{name:"primaryColor",type:"color",label:"Primary color",defaultValue:"#1976d2",group:"Branding"},{name:"variant",type:"variant",label:"Visual style",defaultValue:"card"}]},{type:"NiceCaptcha",label:"Captcha",category:"Auth",icon:"shield",defaultProps:{provider:"recaptcha",size:"normal"},propDescriptors:[{name:"provider",type:"select",label:"Provider",options:[{label:"reCAPTCHA v2",value:"recaptcha"},{label:"reCAPTCHA v3",value:"recaptcha-v3"},{label:"hCaptcha",value:"hcaptcha"},{label:"Turnstile",value:"turnstile"}],defaultValue:"recaptcha"},{name:"siteKey",type:"string",label:"Site key"},{name:"size",type:"select",label:"Size",options:[{label:"Normal",value:"normal"},{label:"Compact",value:"compact"},{label:"Invisible",value:"invisible"}],defaultValue:"normal"},{name:"theme",type:"select",label:"Theme",options:[{label:"Light",value:"light"},{label:"Dark",value:"dark"}],defaultValue:"light"}]},{type:"Nice2FASetup",label:"2FA Setup",category:"Auth",icon:"key",defaultProps:{method:"totp"},propDescriptors:[{name:"method",type:"select",label:"2FA method",options:[{label:"TOTP (Authenticator)",value:"totp"},{label:"SMS",value:"sms"},{label:"Email",value:"email"}],defaultValue:"totp"},{name:"issuer",type:"string",label:"Issuer name",defaultValue:"OmniVerk"},{name:"showBackupCodes",type:"boolean",label:"Show backup codes",defaultValue:!0},{name:"showQR",type:"boolean",label:"Show QR code",defaultValue:!0},{name:"codeLength",type:"number",label:"Code length",min:4,max:8,defaultValue:6}]}],fe=[{type:"NiceAddress",label:"Address Editor",category:"Business",icon:"map-pin",defaultProps:{country:"PL"},propDescriptors:[{name:"street",type:"string",label:"Street",group:"Address"},{name:"city",type:"string",label:"City",group:"Address"},{name:"postalCode",type:"string",label:"Postal code",group:"Address"},{name:"country",type:"select",label:"Country",options:[{label:"Poland",value:"PL"},{label:"Germany",value:"DE"},{label:"USA",value:"US"},{label:"UK",value:"GB"},{label:"France",value:"FR"}],defaultValue:"PL",group:"Address"},{name:"showMap",type:"boolean",label:"Show map preview",defaultValue:!1},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NicePhone",label:"Phone Input",category:"Business",icon:"phone",defaultProps:{countryCode:"+48"},propDescriptors:[{name:"value",type:"string",label:"Phone number"},{name:"countryCode",type:"string",label:"Default country code",defaultValue:"+48"},{name:"showFlag",type:"boolean",label:"Show country flag",defaultValue:!0},{name:"format",type:"select",label:"Format",options:[{label:"International",value:"international"},{label:"National",value:"national"},{label:"E.164",value:"e164"}],defaultValue:"international"},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceCurrency",label:"Currency Input",category:"Business",icon:"dollar-sign",defaultProps:{currency:"PLN",decimals:2},propDescriptors:[{name:"value",type:"number",label:"Amount",defaultValue:0},{name:"currency",type:"select",label:"Currency",options:[{label:"PLN",value:"PLN"},{label:"EUR",value:"EUR"},{label:"USD",value:"USD"},{label:"GBP",value:"GBP"}],defaultValue:"PLN"},{name:"decimals",type:"number",label:"Decimal places",min:0,max:4,defaultValue:2},{name:"showCurrencySymbol",type:"boolean",label:"Show symbol",defaultValue:!0},{name:"thousandSeparator",type:"boolean",label:"Thousand separator",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceVAT",label:"VAT Input",category:"Business",icon:"percent",defaultProps:{rate:23,country:"PL"},propDescriptors:[{name:"netValue",type:"number",label:"Net value",defaultValue:0,group:"Values"},{name:"rate",type:"number",label:"VAT rate (%)",min:0,max:100,defaultValue:23,group:"Values"},{name:"country",type:"select",label:"Country",options:[{label:"Poland",value:"PL"},{label:"Germany",value:"DE"},{label:"France",value:"FR"}],defaultValue:"PL"},{name:"showGross",type:"boolean",label:"Show gross value",defaultValue:!0},{name:"showVatAmount",type:"boolean",label:"Show VAT amount",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceInvoiceLines",label:"Invoice Lines",category:"Business",icon:"file-text",defaultProps:{lines:[],currency:"PLN"},propDescriptors:[{name:"lines",type:"json",label:"Invoice lines (JSON)"},{name:"currency",type:"select",label:"Currency",options:[{label:"PLN",value:"PLN"},{label:"EUR",value:"EUR"},{label:"USD",value:"USD"}],defaultValue:"PLN"},{name:"showVAT",type:"boolean",label:"Show VAT column",defaultValue:!0},{name:"showDiscount",type:"boolean",label:"Show discount column",defaultValue:!1},{name:"showTotal",type:"boolean",label:"Show totals row",defaultValue:!0},{name:"editable",type:"boolean",label:"Editable",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]}],me=[{type:"NiceLeaderboard",label:"Leaderboard",category:"Gamification",icon:"trophy",defaultProps:{dataSource:[],maxRows:10},propDescriptors:[{name:"dataSource",type:"json",label:"Data source (JSON)"},{name:"maxRows",type:"number",label:"Max visible rows",min:3,max:100,defaultValue:10},{name:"showRank",type:"boolean",label:"Show rank column",defaultValue:!0},{name:"showAvatar",type:"boolean",label:"Show avatar",defaultValue:!0},{name:"highlightCurrentUser",type:"boolean",label:"Highlight current user",defaultValue:!0},{name:"scoreField",type:"string",label:"Score field name",defaultValue:"score"},{name:"nameField",type:"string",label:"Name field name",defaultValue:"name"},{name:"variant",type:"variant",label:"Visual style",defaultValue:"default"}]},{type:"NiceAchievement",label:"Achievement Badge",category:"Gamification",icon:"award",defaultProps:{title:"Achievement",unlocked:!1},propDescriptors:[{name:"title",type:"string",label:"Achievement title",defaultValue:"Achievement"},{name:"description",type:"string",label:"Description"},{name:"icon",type:"string",label:"Icon URL"},{name:"unlocked",type:"boolean",label:"Unlocked",defaultValue:!1},{name:"progress",type:"number",label:"Progress (0-100)",min:0,max:100,defaultValue:0},{name:"rarity",type:"select",label:"Rarity",options:[{label:"Common",value:"common"},{label:"Rare",value:"rare"},{label:"Epic",value:"epic"},{label:"Legendary",value:"legendary"}],defaultValue:"common"},{name:"size",type:"size",label:"Badge size",group:"Layout"}]},{type:"NiceQuest",label:"Quest Tracker",category:"Gamification",icon:"map",defaultProps:{title:"Quest",steps:[]},propDescriptors:[{name:"title",type:"string",label:"Quest title",defaultValue:"Quest"},{name:"description",type:"string",label:"Quest description"},{name:"steps",type:"json",label:"Steps (JSON array of {title, completed})"},{name:"reward",type:"string",label:"Reward description"},{name:"rewardXP",type:"number",label:"Reward XP",min:0,defaultValue:100},{name:"showProgress",type:"boolean",label:"Show progress bar",defaultValue:!0},{name:"variant",type:"variant",label:"Visual style",defaultValue:"default"}]},{type:"NiceProgress",label:"XP / Level Bar",category:"Gamification",icon:"zap",defaultProps:{value:350,max:1e3,label:"Level 5",variant:"success",showValue:!0},propDescriptors:[{name:"value",type:"number",label:"Current XP",min:0,defaultValue:350},{name:"max",type:"number",label:"Max XP (next level)",min:1,defaultValue:1e3},{name:"label",type:"string",label:"Label (e.g. level)",defaultValue:"Level 5"},{name:"showValue",type:"boolean",label:"Show value",defaultValue:!0},{name:"variant",type:"variant",label:"Visual style",defaultValue:"success"},{name:"striped",type:"boolean",label:"Striped",defaultValue:!1},{name:"animated",type:"boolean",label:"Animate changes",defaultValue:!0},{name:"size",type:"size",label:"Bar height",group:"Layout"}]}],ye=[{type:"NicePixelEditor",label:"Pixel Editor",category:"Graphics",icon:"grid",defaultProps:{width:32,height:32,palette:[]},propDescriptors:[{name:"width",type:"number",label:"Canvas width (px)",min:1,max:256,defaultValue:32},{name:"height",type:"number",label:"Canvas height (px)",min:1,max:256,defaultValue:32},{name:"palette",type:"json",label:"Color palette (JSON array)"},{name:"gridVisible",type:"boolean",label:"Show grid",defaultValue:!0},{name:"zoom",type:"number",label:"Zoom level",min:1,max:32,step:1,defaultValue:8},{name:"layers",type:"boolean",label:"Enable layers",defaultValue:!0},{name:"onion",type:"boolean",label:"Onion skin (animation)",defaultValue:!1}]},{type:"NiceVectorEditor",label:"Vector Editor",category:"Graphics",icon:"pen-tool",defaultProps:{width:800,height:600},propDescriptors:[{name:"width",type:"number",label:"Canvas width",min:100,max:4096,defaultValue:800,group:"Layout"},{name:"height",type:"number",label:"Canvas height",min:100,max:4096,defaultValue:600,group:"Layout"},{name:"showRulers",type:"boolean",label:"Show rulers",defaultValue:!0},{name:"snapToGrid",type:"boolean",label:"Snap to grid",defaultValue:!0},{name:"gridSize",type:"number",label:"Grid size",min:1,max:100,defaultValue:10},{name:"fillColor",type:"color",label:"Default fill",defaultValue:"#ffffff"},{name:"strokeColor",type:"color",label:"Default stroke",defaultValue:"#000000"},{name:"strokeWidth",type:"number",label:"Stroke width",min:0,max:20,step:.5,defaultValue:1}]},{type:"NicePhotoEditor",label:"Photo Editor",category:"Graphics",icon:"image",defaultProps:{src:""},propDescriptors:[{name:"src",type:"string",label:"Image source URL"},{name:"crop",type:"boolean",label:"Allow crop",defaultValue:!0},{name:"rotate",type:"boolean",label:"Allow rotate",defaultValue:!0},{name:"filters",type:"boolean",label:"Show filters",defaultValue:!0},{name:"adjustments",type:"boolean",label:"Show adjustments",defaultValue:!0},{name:"text",type:"boolean",label:"Allow text overlay",defaultValue:!0},{name:"outputFormat",type:"select",label:"Output format",options:[{label:"PNG",value:"png"},{label:"JPEG",value:"jpeg"},{label:"WebP",value:"webp"}],defaultValue:"png"},{name:"maxWidth",type:"number",label:"Max output width",min:100,max:8192,group:"Output"}]}],be=[{type:"NiceComments",label:"Comments",category:"Social",icon:"message-circle",defaultProps:{threadId:"",allowReplies:!0},propDescriptors:[{name:"threadId",type:"string",label:"Thread ID / entity ID"},{name:"allowReplies",type:"boolean",label:"Allow replies (nested)",defaultValue:!0},{name:"maxDepth",type:"number",label:"Max nesting depth",min:1,max:10,defaultValue:3},{name:"sortOrder",type:"select",label:"Default sort",options:[{label:"Newest first",value:"newest"},{label:"Oldest first",value:"oldest"},{label:"Most liked",value:"popular"}],defaultValue:"newest"},{name:"allowReactions",type:"boolean",label:"Allow reactions",defaultValue:!0},{name:"showAvatar",type:"boolean",label:"Show avatars",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceRatings",label:"Ratings",category:"Social",icon:"star",defaultProps:{maxStars:5,allowHalf:!0},propDescriptors:[{name:"value",type:"number",label:"Current rating",min:0,max:10,step:.5,defaultValue:0},{name:"maxStars",type:"number",label:"Maximum stars",min:3,max:10,defaultValue:5},{name:"allowHalf",type:"boolean",label:"Allow half stars",defaultValue:!0},{name:"showCount",type:"boolean",label:"Show vote count",defaultValue:!0},{name:"showAverage",type:"boolean",label:"Show average",defaultValue:!0},{name:"color",type:"color",label:"Star color",defaultValue:"#ffc107"},{name:"size",type:"size",label:"Star size",group:"Layout"},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceWiki",label:"Wiki Editor",category:"Social",icon:"book",defaultProps:{content:"",showTOC:!0},propDescriptors:[{name:"content",type:"string",label:"Initial content (Markdown)"},{name:"showTOC",type:"boolean",label:"Show table of contents",defaultValue:!0},{name:"showHistory",type:"boolean",label:"Show version history",defaultValue:!0},{name:"allowEdit",type:"boolean",label:"Allow editing",defaultValue:!0},{name:"showToolbar",type:"boolean",label:"Show Markdown toolbar",defaultValue:!0},{name:"previewMode",type:"select",label:"Preview mode",options:[{label:"Side by side",value:"split"},{label:"Tab switch",value:"tabs"},{label:"Live preview",value:"live"}],defaultValue:"split"},{name:"maxLength",type:"number",label:"Max content length",min:0,defaultValue:0}]}],ge=[{type:"NiceModelEditor",label:"3D Model Editor",category:"3D",icon:"cube",defaultProps:{modelUrl:""},propDescriptors:[{name:"modelUrl",type:"string",label:"Model URL (.glb / .gltf)"},{name:"environmentMap",type:"select",label:"Environment",options:[{label:"Studio",value:"studio"},{label:"Outdoor",value:"outdoor"},{label:"Warehouse",value:"warehouse"},{label:"None",value:"none"}],defaultValue:"studio"},{name:"showGrid",type:"boolean",label:"Show grid",defaultValue:!0},{name:"showAxes",type:"boolean",label:"Show axes",defaultValue:!0},{name:"enablePhysics",type:"boolean",label:"Enable physics",defaultValue:!1},{name:"wireframe",type:"boolean",label:"Wireframe mode",defaultValue:!1},{name:"backgroundColor",type:"color",label:"Background",defaultValue:"#1a1a2e"},{name:"height",type:"size",label:"Viewport height",group:"Layout"}]},{type:"NiceModelViewer",label:"3D Model Viewer",category:"3D",icon:"eye",defaultProps:{modelUrl:"",autoRotate:!0},propDescriptors:[{name:"modelUrl",type:"string",label:"Model URL (.glb / .gltf)"},{name:"autoRotate",type:"boolean",label:"Auto-rotate",defaultValue:!0},{name:"rotateSpeed",type:"number",label:"Rotate speed",min:.1,max:10,step:.1,defaultValue:1},{name:"zoom",type:"boolean",label:"Allow zoom",defaultValue:!0},{name:"pan",type:"boolean",label:"Allow pan",defaultValue:!0},{name:"environmentMap",type:"select",label:"Environment",options:[{label:"Studio",value:"studio"},{label:"Outdoor",value:"outdoor"},{label:"Warehouse",value:"warehouse"},{label:"None",value:"none"}],defaultValue:"studio"},{name:"backgroundColor",type:"color",label:"Background",defaultValue:"#1a1a2e"},{name:"showAnnotations",type:"boolean",label:"Show annotations",defaultValue:!1},{name:"height",type:"size",label:"Viewport height",group:"Layout"}]}],Ge=[...he,...ye,...ge,...me,...fe,...pe,...be];async function qe(i,e){const t=await fetch(i,{...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}});if(!t.ok){const n=await t.text();let a={};try{a=JSON.parse(n)}catch{}throw{code:a.code||`HTTP_${t.status}`,message:a.message||t.statusText,statusCode:t.status}}return t.json()}function Ke(i){const{baseUrl:e,currency:t="PLN",timeout:n=3e4,fetcher:a=qe,getAuthToken:r,onError:l}=i,[c,d]=o.useState([]),[g,S]=o.useState(null),[w,T]=o.useState(null),[A,W]=o.useState(null),[L,Q]=o.useState(null),[G,X]=o.useState(null),[D,q]=o.useState([]),[O,Z]=o.useState([]),[ee,B]=o.useState(null),[z,_]=o.useState({offers:!1,calculate:!1,compare:!1,apply:!1,creditCheck:!1,refinancing:!1,consolidation:!1,savedCalculations:!1}),N=o.useRef(new Map),$=o.useCallback(()=>{const s={"Content-Type":"application/json"},b=r==null?void 0:r();return b&&(s.Authorization=`Bearer ${b}`),s},[r]),p=o.useCallback(async(s,b={},I)=>{const Y=N.current.get(s);Y&&Y.abort();const u=new AbortController;N.current.set(s,u);const m=setTimeout(()=>u.abort(),n);_(h=>({...h,[I]:!0})),B(null);try{const h=`${e}${s}`;return await a(h,{...b,headers:{...$(),...b.headers},signal:u.signal})}catch(h){const P={code:h.code||"UNKNOWN_ERROR",message:h.message||"An unknown error occurred",details:h.details,endpoint:s,statusCode:h.statusCode};throw h.name!=="AbortError"&&(B(P),l==null||l(P)),P}finally{clearTimeout(m),N.current.delete(s),_(h=>({...h,[I]:!1}))}},[e,n,a,$,l]),se=o.useCallback(async s=>{var m,h;const b=new URLSearchParams;s!=null&&s.loanType&&b.set("loanType",s.loanType),s!=null&&s.minAmount&&b.set("minAmount",String(s.minAmount)),s!=null&&s.maxAmount&&b.set("maxAmount",String(s.maxAmount)),s!=null&&s.minTerm&&b.set("minTerm",String(s.minTerm)),s!=null&&s.maxTerm&&b.set("maxTerm",String(s.maxTerm)),s!=null&&s.maxApr&&b.set("maxApr",String(s.maxApr)),(m=s==null?void 0:s.banks)!=null&&m.length&&b.set("banks",s.banks.join(",")),(h=s==null?void 0:s.features)!=null&&h.length&&b.set("features",s.features.join(",")),b.set("currency",(s==null?void 0:s.currency)||t);const I=b.toString(),Y=`/offers${I?`?${I}`:""}`,u=await p(Y,{method:"GET"},"offers");return d(u),u},[p,t]),j=o.useCallback(s=>{S(s)},[]),U=o.useCallback(async s=>p(`/offers/${s}`,{method:"GET"},"offers"),[p]),te=o.useCallback(async s=>{const b=await p("/calculate/amortization",{method:"POST",body:JSON.stringify({...s,currency:s.currency||t})},"calculate");return T(b),b},[p,t]),ne=o.useCallback(async s=>{const b=await p("/calculate/compare",{method:"POST",body:JSON.stringify({scenarios:s,currency:t})},"compare");return W(b),b},[p,t]),y=o.useCallback(async(s,b,I)=>{const Y=await p("/credit/analyze",{method:"POST",body:JSON.stringify({monthlyIncome:s,monthlyDebts:b,requestedAmount:I,currency:t})},"creditCheck");return X(Y),Y},[p,t]),V=o.useCallback(async s=>{const b=await p("/applications",{method:"POST",body:JSON.stringify(s)},"apply");return Q(b),b},[p]),v=o.useCallback(async s=>{const b=await p(`/applications/${s}`,{method:"GET"},"apply");return Q(b),b},[p]),E=o.useCallback(async s=>{await p(`/applications/${s}/cancel`,{method:"POST"},"apply"),Q(null)},[p]),k=o.useCallback(async(s,b,I,Y)=>{const u=await p("/calculations",{method:"POST",body:JSON.stringify({name:s,config:b,result:I,notes:Y})},"savedCalculations");return q(m=>[...m,u]),u},[p]),M=o.useCallback(async s=>p(`/calculations/${s}`,{method:"GET"},"savedCalculations"),[p]),R=o.useCallback(async s=>{await p(`/calculations/${s}`,{method:"DELETE"},"savedCalculations"),q(b=>b.filter(I=>I.id!==s))},[p]),K=o.useCallback(async()=>{const s=await p("/calculations",{method:"GET"},"savedCalculations");return q(s),s},[p]),ae=o.useCallback(async(s,b)=>p("/refinancing/analyze",{method:"POST",body:JSON.stringify({currentLoanId:s,newOfferIds:b})},"refinancing"),[p]),oe=o.useCallback(async(s,b)=>p("/consolidation/simulate",{method:"POST",body:JSON.stringify({debts:s,targetRate:b,currency:t})},"consolidation"),[p,t]),re=o.useCallback(async()=>{const s=await p("/active",{method:"GET"},"offers");return Z(s),s},[p]),f=o.useCallback(()=>{B(null)},[]),C=o.useCallback(()=>{d([]),S(null),T(null),W(null),Q(null),X(null),q([]),Z([]),B(null),_({offers:!1,calculate:!1,compare:!1,apply:!1,creditCheck:!1,refinancing:!1,consolidation:!1,savedCalculations:!1})},[]);return o.useEffect(()=>{const s=N.current;return()=>{s.forEach(b=>b.abort()),s.clear()}},[]),{offers:c,selectedOffer:g,latestCalculation:w,latestComparison:A,applicationState:L,creditAnalysis:G,savedCalculations:D,activeLoans:O,loading:z,error:ee,fetchOffers:se,selectOffer:j,getOfferDetails:U,calculateAmortization:te,compareLoanScenarios:ne,runCreditAnalysis:y,submitApplication:V,getApplicationStatus:v,cancelApplication:E,saveCalculation:k,loadCalculation:M,deleteSavedCalculation:R,fetchSavedCalculations:K,analyzeRefinancing:ae,simulateConsolidation:oe,fetchActiveLoans:re,clearError:f,reset:C}}class He{constructor(e){this.baseUrl=e.baseUrl,this.currency=e.currency||"PLN",this.timeout=e.timeout||3e4,this.getAuthToken=e.getAuthToken}async request(e,t={}){var c;const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r={"Content-Type":"application/json"},l=(c=this.getAuthToken)==null?void 0:c.call(this);l&&(r.Authorization=`Bearer ${l}`);try{const d=await fetch(`${this.baseUrl}${e}`,{...t,headers:{...r,...t.headers},signal:n.signal});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);return d.json()}finally{clearTimeout(a)}}async getOffers(e){const t=new URLSearchParams;e!=null&&e.loanType&&t.set("loanType",e.loanType),e!=null&&e.minAmount&&t.set("minAmount",String(e.minAmount)),e!=null&&e.maxAmount&&t.set("maxAmount",String(e.maxAmount)),t.set("currency",(e==null?void 0:e.currency)||this.currency);const n=t.toString();return this.request(`/offers${n?`?${n}`:""}`)}async getOfferById(e){return this.request(`/offers/${e}`)}async calculateAmortization(e){return this.request("/calculate/amortization",{method:"POST",body:JSON.stringify({...e,currency:e.currency||this.currency})})}async compareScenarios(e){return this.request("/calculate/compare",{method:"POST",body:JSON.stringify({scenarios:e,currency:this.currency})})}async submitApplication(e){return this.request("/applications",{method:"POST",body:JSON.stringify(e)})}async getApplicationStatus(e){return this.request(`/applications/${e}`)}async analyzeRefinancing(e,t){return this.request("/refinancing/analyze",{method:"POST",body:JSON.stringify({currentLoanId:e,newOfferIds:t})})}async simulateConsolidation(e,t){return this.request("/consolidation/simulate",{method:"POST",body:JSON.stringify({debts:e,targetRate:t,currency:this.currency})})}async getActiveLoans(){return this.request("/active")}}exports.ErpAuthAdapter=Ne;exports.ErpDataAdapter=Ve;exports.ErpExportAdapter=Fe;exports.ErpFileAdapter=Ue;exports.ErpOfflineQueue=Je;exports.ErpOptimisticStore=je;exports.ErpRateLimiter=ze;exports.LoanService=He;exports.allControlRegistries=Ge;exports.applyBatchChanges=Oe;exports.audioControlRegistry=he;exports.authControlRegistry=pe;exports.businessControlRegistry=fe;exports.createMiddlewarePipeline=Me;exports.createSignalRAdapter=Pe;exports.createSignalRDataOperations=Ae;exports.formatPresenceStatus=Re;exports.gamificationControlRegistry=me;exports.generateUserColor=de;exports.graphicControlRegistry=ye;exports.headerMiddleware=Be;exports.loggingMiddleware=Ie;exports.retryMiddleware=$e;exports.socialControlRegistry=be;exports.threeControlRegistry=ge;exports.useCollaborativeDataGrid=De;exports.useEntityPresence=ce;exports.useLoanApi=Ke;exports.useMultiEntityPresence=xe;exports.useSignalRLiveData=ue;
1
+ "use strict";var we=Object.create;var ie=Object.defineProperty;var Se=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var ke=Object.getPrototypeOf,Ce=Object.prototype.hasOwnProperty;var Ee=(i,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ve(e))!Ce.call(i,a)&&a!==t&&ie(i,a,{get:()=>e[a],enumerable:!(n=Se(e,a))||n.enumerable});return i};var Te=(i,e,t)=>(t=i!=null?we(ke(i)):{},Ee(e||!i||!i.__esModule?ie(t,"default",{value:i,enumerable:!0}):t,i));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react");class Ve{constructor(e){this.cfg=typeof e=="string"?{baseUrl:e}:e}async request(e,t){const n=this.cfg.fetch??globalThis.fetch,a={"Content-Type":"application/json",...this.cfg.headers};if(this.cfg.tokenFactory){const l=await this.cfg.tokenFactory();a.Authorization=`Bearer ${l}`}const r=await n(`${this.cfg.baseUrl}${e}`,{...t,headers:{...a,...t==null?void 0:t.headers}});if(!r.ok)throw new Error(`ERP request failed: ${r.status} ${r.statusText}`);return r.json()}async load(e){var a,r;const t=new URLSearchParams;(e==null?void 0:e.skip)!=null&&t.set("skip",String(e.skip)),(e==null?void 0:e.take)!=null&&t.set("take",String(e.take)),e!=null&&e.search&&t.set("search",e.search),(a=e==null?void 0:e.sort)!=null&&a.length&&t.set("sort",JSON.stringify(e.sort)),(r=e==null?void 0:e.filters)!=null&&r.length&&t.set("filters",JSON.stringify(e.filters));const n=t.toString();return this.request(n?`?${n}`:"")}async getById(e){return this.request(`/${e}`)}async create(e){return this.request("",{method:"POST",body:JSON.stringify(e)})}async update(e,t){return this.request(`/${e}`,{method:"PUT",body:JSON.stringify(t)})}async remove(e){return this.request(`/${e}`,{method:"DELETE"})}async removeBatch(e){return this.request("/batch-delete",{method:"POST",body:JSON.stringify({ids:e})})}async createBatch(e){return this.request("/batch",{method:"POST",body:JSON.stringify({items:e})})}async updateBatch(e){return this.request("/batch",{method:"PUT",body:JSON.stringify({items:e})})}async patch(e,t){return this.request(`/${e}`,{method:"PATCH",body:JSON.stringify(t)})}}async function Pe(i){const e=await import("@microsoft/signalr");let t="disconnected";const n=new Set,a=d=>{t=d,n.forEach(g=>g(d))},l=new e.HubConnectionBuilder().withUrl(i.hubUrl,{accessTokenFactory:i.accessTokenFactory?()=>i.accessTokenFactory():void 0}).withAutomaticReconnect().build();return l.onreconnecting(()=>a("reconnecting")),l.onreconnected(()=>a("connected")),l.onclose(()=>a("disconnected")),{get status(){return t},async start(){a("connecting"),await l.start(),a("connected")},async stop(){await l.stop(),a("disconnected")},on(d,g){l.on(d,g)},off(d,g){l.off(d,g)},invoke(d,...g){return l.invoke(d,...g)},onStatusChange(d){return n.add(d),()=>n.delete(d)}}}function ue(i){const{adapter:e,entityName:t,keyField:n,initialData:a=[],onBeforeChange:r,onAfterChange:l,onConflict:c,subscribeMethod:d="SubscribeToEntity",unsubscribeMethod:g="UnsubscribeFromEntity",changeEventName:S="EntityChanged",flashChanges:w=!0,flashDuration:T=500,optimisticUpdates:A=!0}=i,[W,L]=o.useState(a),[Q,G]=o.useState(e.status),[X,D]=o.useState(new Set),[q,O]=o.useState(new Set),[Z,ee]=o.useState(null),B=o.useRef(new Map),z=o.useRef(new Map),_=o.useCallback((y,V)=>{const{operation:v,key:E,data:k,changes:M}=V;switch(v){case"insert":return!k||y.some(R=>R[n]===E)?y:[...y,k];case"update":return y.map(R=>{if(R[n]!==E)return R;const K=B.current.get(E);if(K&&c){const ae=c({...R,...K.changes},k??{...R,...M},V);return ae==="local"?{...R,...K.changes}:ae==="remote"?(B.current.delete(E),k??{...R,...M}):ae==="merge"?{...R,...M,...K.changes}:ae}return k||{...R,...M}});case"delete":return y.filter(R=>R[n]!==E);default:return y}},[n,c]),N=o.useCallback(y=>{if(!w)return;const V=z.current.get(y);V&&clearTimeout(V),D(E=>new Set([...E,y]));const v=setTimeout(()=>{D(E=>{const k=new Set(E);return k.delete(y),k}),z.current.delete(y)},T);z.current.set(y,v)},[w,T]),$=o.useCallback(async y=>{y.entityName===t&&(r&&!await r(y)||(L(V=>{const v=_(V,y);return l==null||l(y,v),v}),N(y.key)))},[t,r,_,l,N]),p=o.useCallback(y=>{$(y)},[$]),se=o.useCallback((y,V)=>{if(!A)return;const v=W.find(E=>E[n]===y);v&&(B.current.set(y,{original:v,changes:V}),O(E=>new Set([...E,y])))},[W,n,A]),j=o.useCallback(y=>{B.current.delete(y),O(V=>{const v=new Set(V);return v.delete(y),v})},[]),U=o.useCallback(y=>{const V=B.current.get(y);V&&(L(v=>v.map(E=>E[n]===y?V.original:E)),B.current.delete(y),O(v=>{const E=new Set(v);return E.delete(y),E}))},[n]),te=o.useCallback(async()=>{if(e.status==="connected")try{await e.invoke(d,t),ee(null)}catch(y){ee(y instanceof Error?y:new Error(String(y)))}},[e,d,t]),ne=o.useCallback(async()=>{if(e.status==="connected")try{await e.invoke(g,t)}catch{}},[e,g,t]);return o.useEffect(()=>{const y=e.onStatusChange(v=>{G(v),v==="connected"&&te()});e.on(S,$),e.status==="connected"&&te();const V=z.current;return()=>{y(),e.off(S,$),ne(),V.forEach(v=>clearTimeout(v)),V.clear()}},[e,S,$,te,ne]),o.useEffect(()=>{L(a)},[a]),{data:W,status:Q,flashedKeys:X,pendingKeys:q,error:Z,applyRemoteUpdate:p,registerPendingChange:se,confirmPendingChange:j,rollbackPendingChange:U,resubscribe:te}}function Ae(i){const{adapter:e,entityName:t,keyField:n,fetchMethod:a="GetEntities",insertMethod:r="InsertEntity",updateMethod:l="UpdateEntity",deleteMethod:c="DeleteEntity"}=i;return{async fetchAll(d){return e.invoke(a,t,d)},async insert(d){return e.invoke(r,t,d)},async update(d,g){return e.invoke(l,t,d,g)},async remove(d){return e.invoke(c,t,d)},getKeyField(){return n}}}function Oe(i,e,t){const n=new Map(i.map(a=>[a[t],a]));for(const a of e)switch(a.operation){case"insert":a.data&&!n.has(a.key)&&n.set(a.key,a.data);break;case"update":if(n.has(a.key)){const r=n.get(a.key);n.set(a.key,a.data??{...r,...a.changes})}break;case"delete":n.delete(a.key);break}return Array.from(n.values())}function ce(i){const{adapter:e,entityType:t,entityId:n,currentUser:a,initialStatus:r="viewing",heartbeatInterval:l=3e4,idleTimeout:c=6e4,awayTimeout:d=3e5,joinMethod:g="JoinEntityView",leaveMethod:S="LeaveEntityView",updateMethod:w="UpdateEntityPresence",presenceEventName:T="EntityPresenceChanged",joinedEventName:A="EntityUserJoined",leftEventName:W="EntityUserLeft",onPresenceChange:L,onEditConflict:Q}=i,[G,X]=o.useState([]),[D,q]=o.useState(r),[O,Z]=o.useState(),[ee,B]=o.useState(e.status),z=o.useRef(Date.now()),_=o.useRef(null),N=o.useRef(null),$=o.useRef(null),p=o.useMemo(()=>Array.isArray(n)?n:[n],[n]),se=o.useMemo(()=>`${t}:${[...p].sort().join(",")}`,[t,p]),j=o.useCallback(async(f,C,s)=>{if(e.status==="connected")try{await e.invoke(w,{entityType:t,entityIds:p,userId:a.id,status:f,editingField:C,selection:s,timestamp:new Date().toISOString()})}catch{}},[e,w,t,p,a.id]),U=o.useCallback((f,C)=>{q(f),Z(C),j(f,C),z.current=Date.now()},[j]),te=o.useCallback(f=>{const C=G.find(s=>s.user.id!==a.id&&s.status==="editing"&&s.editingField===f);C&&(Q==null||Q(C.user,f)),U("editing",f)},[G,a.id,Q,U]),ne=o.useCallback(()=>{U("viewing",void 0)},[U]),y=o.useCallback(f=>{j(D,O,f),z.current=Date.now()},[j,D,O]),V=o.useCallback(f=>{const C=G.find(s=>s.user.id!==a.id&&s.status==="editing"&&s.editingField===f);return(C==null?void 0:C.user)??null},[G,a.id]),v=o.useCallback(f=>{const C=G.find(s=>s.status==="editing"&&s.editingField===f);return(C==null?void 0:C.user)??null},[G]),E=o.useCallback(async()=>{if(e.status==="connected")try{const f=await e.invoke("GetEntityPresence",t,p);Array.isArray(f)&&(X(f),L==null||L(f))}catch{}},[e,t,p,L]),k=o.useCallback(()=>{z.current=Date.now(),N.current&&clearTimeout(N.current),$.current&&clearTimeout($.current),(D==="idle"||D==="away")&&U(O?"editing":"viewing",O),N.current=setTimeout(()=>{U("idle",O)},c),$.current=setTimeout(()=>{U("away",O)},d)},[D,O,c,d,U]),M=o.useCallback(f=>{f.entityType!==t||!f.entityIds.some(s=>p.includes(s))||(X(f.presence.filter(s=>s.user.id!==a.id)),L==null||L(f.presence))},[t,p,a.id,L]),R=o.useCallback(f=>{f.entityType!==t||!f.entityIds.some(s=>p.includes(s))||f.presence.user.id===a.id||X(s=>{const b=s.findIndex(I=>I.user.id===f.presence.user.id);if(b>=0){const I=[...s];return I[b]=f.presence,I}return[...s,f.presence]})},[t,p,a.id]),K=o.useCallback(f=>{f.entityType!==t||!f.entityIds.some(s=>p.includes(s))||X(s=>s.filter(b=>b.user.id!==f.userId))},[t,p]);o.useEffect(()=>{const f=e.onStatusChange(B);e.on(T,M),e.on(A,R),e.on(W,K);const C=async()=>{if(e.status==="connected")try{await e.invoke(g,{entityType:t,entityIds:p,user:a,status:D}),await E()}catch{}};return e.status==="connected"&&C(),()=>{f(),e.off(T,M),e.off(A,R),e.off(W,K),e.status==="connected"&&e.invoke(S,{entityType:t,entityIds:p,userId:a.id}).catch(()=>{})}},[e,se,g,S,T,A,W,M,R,K,E,a,D,t,p]),o.useEffect(()=>(_.current=setInterval(()=>{j(D,O)},l),()=>{_.current&&clearInterval(_.current)}),[l,j,D,O]),o.useEffect(()=>{const f=["mousemove","keydown","mousedown","touchstart","scroll"];return f.forEach(C=>window.addEventListener(C,k,{passive:!0})),N.current=setTimeout(()=>{U("idle",O)},c),$.current=setTimeout(()=>{U("away",O)},d),()=>{f.forEach(C=>window.removeEventListener(C,k)),N.current&&clearTimeout(N.current),$.current&&clearTimeout($.current)}},[k,c,d,O,U]);const ae=G.filter(f=>f.status==="viewing"||f.status==="idle").map(f=>f.user),oe=G.filter(f=>f.status==="editing").map(f=>f.user),re=oe.length>0;return{presence:G,viewers:ae,editors:oe,myStatus:D,setMyStatus:U,startEditing:te,stopEditing:ne,updateSelection:y,connectionStatus:ee,isFieldLocked:V,hasActiveEditors:re,getFieldEditor:v,refresh:E}}function de(i){const e=["#3b82f6","#ef4444","#22c55e","#f59e0b","#8b5cf6","#ec4899","#06b6d4","#84cc16","#f97316","#14b8a6"];let t=0;for(let n=0;n<i.length;n++)t=i.charCodeAt(n)+((t<<5)-t);return e[Math.abs(t)%e.length]}function Re(i){switch(i){case"viewing":return"Viewing";case"editing":return"Editing";case"idle":return"Idle";case"away":return"Away";default:return"Unknown"}}function xe(i){const{adapter:e,entityType:t,currentUser:n,batchEventName:a="BatchPresenceUpdate"}=i,[r,l]=o.useState(new Map),c=o.useCallback(w=>{w.entityType===t&&l(new Map(Object.entries(w.presenceByEntity)))},[t]);o.useEffect(()=>(e.on(a,c),()=>{e.off(a,c)}),[e,a,c]);const d=o.useCallback(w=>r.get(w)??[],[r]),g=o.useCallback(w=>{const T=r.get(w);return(T==null?void 0:T.some(A=>A.status==="editing"&&A.user.id!==n.id))??!1},[r,n.id]),S=o.useCallback(w=>{const T=r.get(w);return(T==null?void 0:T.filter(A=>A.status==="editing").map(A=>A.user))??[]},[r]);return{presenceByEntity:r,getPresence:d,isEntityBeingEdited:g,getEntityEditors:S}}function J(i){return`${String(i.rowKey)}:${i.field}`}function Le(i){return i?typeof i=="number"?i:new Date(i).getTime():Date.now()}function De(i){const{adapter:e,entityType:t,keyField:n,currentUser:a,initialData:r=[],conflictStrategy:l="last-write-wins",mergeFunction:c,onConflict:d,onBeforeCommit:g,onAfterCommit:S,enableCellLocking:w=!0,lockTimeout:T=6e4,enableCursorSharing:A=!0,cursorDebounce:W=50,optimisticUpdates:L=!0,flashChanges:Q=!0,flashDuration:G=500,liveDataOptions:X={}}=i,[D,q]=o.useState(new Map),[O,Z]=o.useState(new Map),[ee,B]=o.useState([]),[z,_]=o.useState(null),[N,$]=o.useState([]),[p,se]=o.useState([]),[j,U]=o.useState(null),[te,ne]=o.useState([]),y=o.useRef(null),V=o.useRef(new Map),v=o.useCallback(u=>(V.current.has(u)||V.current.set(u,de(u)),V.current.get(u)),[]),E=o.useCallback((u,m,h)=>{if(!h.changes)return m;const P=O.get(J({rowKey:h.key,field:Object.keys(h.changes)[0]}));if(!P)return m;const F=P.timestamp,x=Le(h.timestamp);switch(l){case"last-write-wins":return F>x?"local":"remote";case"first-write-wins":return F<x?"local":"remote";case"merge":return c?c(u,m,Object.keys(h.changes)[0]):"merge";case"ask-user":{const H={cell:{rowKey:h.key,field:Object.keys(h.changes)[0]},localValue:P.newValue,remoteValue:h.changes[Object.keys(h.changes)[0]],localUser:a,remoteUser:h.changedBy?{id:h.changedBy,name:h.changedBy}:{id:"unknown",name:"Unknown"},localTimestamp:F,remoteTimestamp:x};return B(le=>[...le,H]),"local"}case"reject":return"remote";default:return"remote"}},[O,l,c,a]),k=ue({adapter:e,entityName:t,keyField:n,initialData:r,flashChanges:Q,flashDuration:G,optimisticUpdates:L,onConflict:E,...X}),M=ce({adapter:e,entityType:t,entityId:"grid",currentUser:a,initialStatus:"viewing"}),R=o.useCallback(()=>{!A||e.status!=="connected"||e.invoke("UpdateGridSelection",{entityType:t,userId:a.id,focusedCell:z,selectedCells:N,selectedRows:p,editingCell:j}).catch(()=>{})},[e,A,t,a.id,z,N,p,j]);o.useEffect(()=>{if(A)return y.current&&clearTimeout(y.current),y.current=setTimeout(R,W),()=>{y.current&&clearTimeout(y.current)}},[A,R,W,z,N,p,j]),o.useEffect(()=>{if(!A)return;const u=m=>{m.entityType!==t||m.userId===a.id||ne(h=>{const P=h.findIndex(x=>x.user.id===m.userId),F={user:{id:m.userId,name:m.userName,avatarUrl:m.avatarUrl},focusedCell:m.focusedCell,selectedCells:m.selectedCells,selectedRows:m.selectedRows,editingCell:m.editingCell,color:v(m.userId)};if(P>=0){const x=[...h];return x[P]=F,x}return[...h,F]})};return e.on("GridSelectionUpdated",u),()=>{e.off("GridSelectionUpdated",u)}},[e,A,t,a.id,v]),o.useEffect(()=>{if(!w)return;const u=h=>{h.entityType===t&&q(P=>{const F=new Map(P);return F.set(J(h.cell),{user:h.user,timestamp:h.timestamp}),F})},m=h=>{h.entityType===t&&q(P=>{const F=new Map(P);return F.delete(J(h.cell)),F})};return e.on("CellLocked",u),e.on("CellUnlocked",m),()=>{e.off("CellLocked",u),e.off("CellUnlocked",m)}},[e,w,t]),o.useEffect(()=>{if(!w)return;const u=setInterval(()=>{const m=Date.now();q(h=>{const P=new Map(h);let F=!1;for(const[x,H]of P)m-H.timestamp>T&&(P.delete(x),F=!0);return F?P:h})},1e4);return()=>clearInterval(u)},[w,T]);const K=o.useCallback(u=>{if(!w)return!1;const m=D.get(J(u));return m?m.user.id!==a.id&&Date.now()-m.timestamp<T:!1},[w,D,a.id,T]),ae=o.useCallback(u=>{const m=D.get(J(u));return!m||Date.now()-m.timestamp>T?null:m.user},[D,T]),oe=o.useCallback(u=>K(u)?!1:(U(u),M.startEditing(`${u.rowKey}:${u.field}`),w&&e.status==="connected"&&(e.invoke("AcquireCellLock",{entityType:t,cell:u,user:a,timestamp:Date.now()}).catch(()=>{}),q(m=>{const h=new Map(m);return h.set(J(u),{user:a,timestamp:Date.now()}),h})),!0),[K,M,w,e,t,a]),re=o.useCallback(async(u,m)=>{const h=k.data.find(x=>x[n]===u.rowKey);if(!h)return!1;const P=h[u.field];if(g&&!await g(u,P,m))return f(u),!1;const F={cell:u,originalValue:P,newValue:m,timestamp:Date.now()};Z(x=>{const H=new Map(x);return H.set(J(u),F),H}),L&&k.registerPendingChange(u.rowKey,{[u.field]:m});try{return await e.invoke("UpdateEntityField",{entityType:t,entityId:u.rowKey,field:u.field,value:m,userId:a.id,timestamp:F.timestamp}),k.confirmPendingChange(u.rowKey),Z(x=>{const H=new Map(x);return H.delete(J(u)),H}),S==null||S(u,m),w&&(e.invoke("ReleaseCellLock",{entityType:t,cell:u}).catch(()=>{}),q(x=>{const H=new Map(x);return H.delete(J(u)),H})),U(null),M.stopEditing(),!0}catch(x){throw k.rollbackPendingChange(u.rowKey),Z(H=>{const le=new Map(H);return le.delete(J(u)),le}),x}},[k,n,g,L,e,t,a.id,S,w,M]),f=o.useCallback(u=>{U(null),M.stopEditing(),w&&e.status==="connected"&&(e.invoke("ReleaseCellLock",{entityType:t,cell:u}).catch(()=>{}),q(m=>{const h=new Map(m);return h.delete(J(u)),h})),Z(m=>{const h=new Map(m);return h.delete(J(u)),h})},[M,w,e,t]),C=o.useCallback((u,m)=>{const h=ee.find(P=>J(P.cell)===J(u));h&&(m==="remote"&&k.applyRemoteUpdate({operation:"update",entityName:t,key:u.rowKey,changes:{[u.field]:h.remoteValue}}),B(P=>P.filter(F=>J(F.cell)!==J(u))))},[ee,k,t]),s=o.useCallback(async u=>{await e.invoke("InsertEntity",t,u)},[e,t]),b=o.useCallback(async(u,m)=>{L&&k.registerPendingChange(u,m);try{await e.invoke("UpdateEntity",t,u,m),k.confirmPendingChange(u)}catch(h){throw k.rollbackPendingChange(u),h}},[e,t,L,k]),I=o.useCallback(async u=>{await e.invoke("DeleteEntity",t,u)},[e,t]),Y=o.useMemo(()=>({user:a,focusedCell:z,selectedCells:N,selectedRows:p,editingCell:j,color:v(a.id)}),[a,z,N,p,j,v]);return{data:k.data,presence:M.presence,userSelections:te,mySelection:Y,flashedKeys:k.flashedKeys,pendingEdits:O,connectionStatus:k.status,myPresenceStatus:M.myStatus,setFocusedCell:_,setSelectedCells:$,setSelectedRows:se,startCellEdit:oe,commitCellEdit:re,cancelCellEdit:f,isCellLocked:K,getCellEditor:ae,getUserColor:v,insertRow:s,updateRow:b,deleteRow:I,resolveConflict:C,conflicts:ee}}class Ne{constructor(e){this.accessToken=null,this.refreshToken=null,this.tokenFactory=async()=>{if(!this.accessToken)throw new Error("Not authenticated");return this.accessToken},this.cfg=e}getAccessToken(){return this.accessToken}async post(e,t){const a=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}${e}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!a.ok)throw new Error(`Auth request failed: ${a.status}`);return a.json()}async login(e){var n,a;const t=await this.post("/login",e);return t.token&&(this.accessToken=t.token,this.refreshToken=t.refreshToken??null,(a=(n=this.cfg).onTokens)==null||a.call(n,t.token,t.refreshToken??"")),t}async refresh(){var t,n;if(!this.refreshToken)throw new Error("No refresh token");const e=await this.post("/refresh",{refreshToken:this.refreshToken});return e.token&&(this.accessToken=e.token,this.refreshToken=e.refreshToken??this.refreshToken,(n=(t=this.cfg).onTokens)==null||n.call(t,e.token,this.refreshToken)),e}async me(){const t=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/me`,{headers:{Authorization:`Bearer ${this.accessToken}`}});if(!t.ok)throw new Error(`Auth /me failed: ${t.status}`);return t.json()}async logout(){try{await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/logout`,{method:"POST",headers:{Authorization:`Bearer ${this.accessToken}`}})}finally{this.accessToken=null,this.refreshToken=null}}}class Ue{constructor(e){this.cfg=e}async headers(){const e={};return this.cfg.tokenFactory&&(e.Authorization=`Bearer ${await this.cfg.tokenFactory()}`),e}async upload(e,t){const n=this.cfg.fetch??globalThis.fetch,a=new FormData;a.append("file",e),t&&a.append("folder",t);const r=await n(this.cfg.baseUrl,{method:"POST",headers:await this.headers(),body:a});if(!r.ok)throw new Error(`File upload failed: ${r.status}`);return r.json()}async uploadMultiple(e,t){const n=this.cfg.fetch??globalThis.fetch,a=new FormData;e.forEach(l=>a.append("files",l)),t&&a.append("folder",t);const r=await n(`${this.cfg.baseUrl}/batch`,{method:"POST",headers:await this.headers(),body:a});if(!r.ok)throw new Error(`Batch upload failed: ${r.status}`);return r.json()}async getInfo(e){const n=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/${e}/info`,{headers:{...await this.headers(),"Content-Type":"application/json"}});if(!n.ok)throw new Error(`File info failed: ${n.status}`);return n.json()}async getDownloadUrl(e){const n=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/${e}`,{headers:await this.headers()});if(!n.ok)throw new Error(`File download failed: ${n.status}`);const a=await n.blob();return URL.createObjectURL(a)}async remove(e){const n=await(this.cfg.fetch??globalThis.fetch)(`${this.cfg.baseUrl}/${e}`,{method:"DELETE",headers:{...await this.headers(),"Content-Type":"application/json"}});if(!n.ok)throw new Error(`File delete failed: ${n.status}`);return n.json()}async uploadWithProgress(e,t,n,a){if(typeof XMLHttpRequest>"u")return this.upload(e,n);const r=await this.headers();return new Promise((l,c)=>{const d=new XMLHttpRequest,g=new FormData;if(g.append("file",e),n&&g.append("folder",n),a){if(a.aborted){c(new DOMException("Aborted","AbortError"));return}a.addEventListener("abort",()=>{d.abort(),c(new DOMException("Aborted","AbortError"))})}d.upload.addEventListener("progress",S=>{t({loaded:S.loaded,total:S.total,percent:S.lengthComputable?S.loaded/S.total:NaN})}),d.addEventListener("load",()=>{if(d.status>=200&&d.status<300)try{l(JSON.parse(d.responseText))}catch{c(new Error("Invalid JSON response"))}else c(new Error(`File upload failed: ${d.status}`))}),d.addEventListener("error",()=>c(new Error("Network error during upload"))),d.addEventListener("abort",()=>c(new DOMException("Aborted","AbortError"))),d.open("POST",this.cfg.baseUrl),Object.entries(r).forEach(([S,w])=>d.setRequestHeader(S,w)),d.send(g)})}async uploadMultipleWithProgress(e,t,n,a){const r=[];for(let l=0;l<e.length;l++){if(a!=null&&a.aborted)throw new DOMException("Aborted","AbortError");const c=await this.uploadWithProgress(e[l],d=>t(l,d),n,a);r.push(c)}return r}}class Fe{constructor(e){this.cfg=e}async headers(){const e={"Content-Type":"application/json"};return this.cfg.tokenFactory&&(e.Authorization=`Bearer ${await this.cfg.tokenFactory()}`),e}async requestExport(e){const n=await(this.cfg.fetch??globalThis.fetch)(this.cfg.baseUrl,{method:"POST",headers:await this.headers(),body:JSON.stringify(e)});if(!n.ok)throw new Error(`Export request failed: ${n.status}`);return n.json()}async download(e){const n=await(this.cfg.fetch??globalThis.fetch)(e,{headers:await this.headers()});if(!n.ok)throw new Error(`Export download failed: ${n.status}`);return n.blob()}async downloadToFile(e,t){var c;const n=await this.requestExport(e);if(!((c=n.data)!=null&&c.downloadUrl))throw new Error("No download URL returned");const a=await this.download(n.data.downloadUrl),r=URL.createObjectURL(a),l=document.createElement("a");l.href=r,l.download=t??`export.${e.format}`,document.body.appendChild(l),l.click(),document.body.removeChild(l),URL.revokeObjectURL(r)}}function Me(i){return e=>{const t=e??globalThis.fetch;return(a,r)=>{const d={url:typeof a=="string"?a:a instanceof URL?a.toString():a.url,init:r??{},meta:{}};let g=S=>t(S.url,S.init);for(let S=i.length-1;S>=0;S--){const w=i[S],T=g;g=A=>w(A,T)}return g(d)}}}function Ie(){return async(i,e)=>{const t=performance.now(),n=(i.init.method??"GET").toUpperCase();try{const a=await e(i),r=(performance.now()-t).toFixed(1);return console.debug(`[ERP] ${n} ${i.url} → ${a.status} (${r}ms)`),a}catch(a){const r=(performance.now()-t).toFixed(1);throw console.error(`[ERP] ${n} ${i.url} FAILED (${r}ms)`,a),a}}}function $e(i){const e=(i==null?void 0:i.maxRetries)??3,t=(i==null?void 0:i.baseDelay)??500,n=new Set((i==null?void 0:i.retryOn)??[408,429,500,502,503,504]);return async(a,r)=>{let l;for(let c=0;c<=e;c++){try{const g=await r(a);if(g.ok||!n.has(g.status)||c===e)return g;l=new Error(`HTTP ${g.status}`)}catch(g){if(l=g,c===e)throw g}const d=t*Math.pow(2,c)*(.5+Math.random()*.5);await new Promise(g=>setTimeout(g,d))}throw l}}function Be(i){return async(e,t)=>{const n=typeof i=="function"?await i():i;return e.init.headers={...e.init.headers,...n},t(e)}}class ze{constructor(e){this.inFlight=0,this.timestamps=[],this.queue=[],this.processing=!1,this.backingOff=!1,this.maxConcurrent=(e==null?void 0:e.maxConcurrent)??6,this.maxPerSecond=(e==null?void 0:e.maxPerSecond)??20,this.backoffDelay=(e==null?void 0:e.backoffDelay)??2e3,this.baseFetch=(e==null?void 0:e.baseFetch)??globalThis.fetch.bind(globalThis),this.fetch=this.fetch.bind(this)}fetch(e,t){return new Promise((n,a)=>{this.queue.push({resolve:n,reject:a,input:e,init:t}),this.drain()})}get pending(){return this.queue.length}get active(){return this.inFlight}drain(){if(this.processing)return;this.processing=!0;const e=()=>{if(this.queue.length===0||this.backingOff){this.processing=!1;return}if(this.inFlight>=this.maxConcurrent){this.processing=!1;return}const t=Date.now();if(this.timestamps=this.timestamps.filter(a=>t-a<1e3),this.timestamps.length>=this.maxPerSecond){const a=this.timestamps[0],r=1e3-(t-a)+1;setTimeout(()=>{this.processing=!1,this.drain()},r);return}const n=this.queue.shift();this.inFlight++,this.timestamps.push(t),this.baseFetch(n.input,n.init).then(a=>{if(this.inFlight--,a.status===429){this.queue.unshift(n),this.inFlight++,this.inFlight--,this.backingOff=!0,setTimeout(()=>{this.backingOff=!1,this.drain()},this.backoffDelay);return}n.resolve(a),queueMicrotask(e)}).catch(a=>{this.inFlight--,n.reject(a),queueMicrotask(e)}),queueMicrotask(e)};e()}}class je{constructor(e,t="id"){this.items=[],this.mutations=[],this.listeners=new Set,this.nextMutationId=1,this.adapter=e,this.keyField=t}subscribe(e){return this.listeners.add(e),()=>this.listeners.delete(e)}notify(){const e=[...this.items],t=[...this.mutations];this.listeners.forEach(n=>n(e,t))}getItems(){return[...this.items]}getPending(){return this.mutations.filter(e=>e.status==="pending")}setItems(e){this.items=[...e],this.notify()}async load(...e){const t=await this.adapter.load(...e);return t.success&&(this.items=t.data,this.mutations=[],this.notify()),t}async create(e){const t=`__temp_${this.nextMutationId}`,n={...e,[this.keyField]:t},r={id:String(this.nextMutationId++),type:"create",optimisticData:n,timestamp:Date.now(),status:"pending"};this.items=[...this.items,n],this.mutations.push(r),this.notify();try{const l=await this.adapter.create(e);return l.success?(this.items=this.items.map(c=>c[this.keyField]===t?l.data:c),r.status="confirmed",r.entityId=l.data[this.keyField]):(this.items=this.items.filter(c=>c[this.keyField]!==t),r.status="failed",r.error=l.error),this.notify(),l}catch(l){throw this.items=this.items.filter(c=>c[this.keyField]!==t),r.status="failed",r.error=l instanceof Error?l.message:String(l),this.notify(),l}}async update(e,t){const n=this.items.findIndex(c=>c[this.keyField]===e),a=n>=0?{...this.items[n]}:void 0,l={id:String(this.nextMutationId++),type:"update",entityId:e,previousData:a,timestamp:Date.now(),status:"pending"};n>=0&&(this.items=this.items.map((c,d)=>d===n?{...c,...t}:c)),this.mutations.push(l),this.notify();try{const c=await this.adapter.update(e,t);return c.success?(this.items=this.items.map(d=>d[this.keyField]===e?c.data:d),l.status="confirmed"):(a&&n>=0&&(this.items=this.items.map(d=>d[this.keyField]===e?a:d)),l.status="failed",l.error=c.error),this.notify(),c}catch(c){throw a&&n>=0&&(this.items=this.items.map(d=>d[this.keyField]===e?a:d)),l.status="failed",l.error=c instanceof Error?c.message:String(c),this.notify(),c}}async remove(e){const t=this.items.findIndex(l=>l[this.keyField]===e),n=t>=0?{...this.items[t]}:void 0,r={id:String(this.nextMutationId++),type:"delete",entityId:e,previousData:n,timestamp:Date.now(),status:"pending"};this.items=this.items.filter(l=>l[this.keyField]!==e),this.mutations.push(r),this.notify();try{const l=await this.adapter.remove(e);return l.success?r.status="confirmed":(n&&this.items.splice(t,0,n),r.status="failed",r.error=l.error),this.notify(),l}catch(l){throw n&&this.items.splice(t,0,n),r.status="failed",r.error=l instanceof Error?l.message:String(l),this.notify(),l}}}class Je{constructor(e){this.queue=[],this.syncing=!1,this.nextId=1,this.config=e??{},this.baseFetch=(e==null?void 0:e.baseFetch)??globalThis.fetch.bind(globalThis),this.storageKey=(e==null?void 0:e.storageKey)??"erp_offline_",this.fetch=this.fetch.bind(this),this.restoreQueue(),this.boundOnline=()=>{var t,n;(n=(t=this.config).onStatusChange)==null||n.call(t,!0),this.sync()},this.boundOffline=()=>{var t,n;(n=(t=this.config).onStatusChange)==null||n.call(t,!1)},typeof window<"u"&&(window.addEventListener("online",this.boundOnline),window.addEventListener("offline",this.boundOffline))}fetch(e,t){var l,c;const n=typeof e=="string"?e:e instanceof URL?e.toString():e.url,a=((t==null?void 0:t.method)??"GET").toUpperCase();if(this.isOnline())return this.baseFetch(e,t);if(a==="GET"||a==="HEAD")return Promise.reject(new Error("Offline: GET requests are not queued"));const r={id:`q_${this.nextId++}`,url:n,method:a,headers:{...t==null?void 0:t.headers},body:typeof(t==null?void 0:t.body)=="string"?t.body:void 0,timestamp:Date.now()};return this.queue.push(r),this.persistQueue(),(c=(l=this.config).onQueued)==null||c.call(l,r),Promise.resolve(new Response(JSON.stringify({queued:!0,queueId:r.id}),{status:202,headers:{"Content-Type":"application/json"}}))}isOnline(){return typeof navigator>"u"||navigator.onLine}get pendingCount(){return this.queue.length}getQueue(){return[...this.queue]}clear(){this.queue=[],this.persistQueue()}async sync(){var t,n;if(this.syncing||this.queue.length===0||!this.isOnline())return[];this.syncing=!0;const e=[];for(;this.queue.length>0&&this.isOnline();){const a=this.queue[0];try{const r=await this.baseFetch(a.url,{method:a.method,headers:a.headers,body:a.body});e.push({entry:a,success:r.ok,status:r.status,error:r.ok?void 0:`HTTP ${r.status}`}),this.queue.shift()}catch(r){e.push({entry:a,success:!1,error:r instanceof Error?r.message:String(r)});break}}return this.persistQueue(),this.syncing=!1,e.length>0&&((n=(t=this.config).onSync)==null||n.call(t,e)),e}destroy(){typeof window<"u"&&(window.removeEventListener("online",this.boundOnline),window.removeEventListener("offline",this.boundOffline))}persistQueue(){try{typeof localStorage<"u"&&localStorage.setItem(`${this.storageKey}queue`,JSON.stringify(this.queue))}catch{}}restoreQueue(){try{if(typeof localStorage<"u"){const e=localStorage.getItem(`${this.storageKey}queue`);e&&(this.queue=JSON.parse(e),this.nextId=this.queue.reduce((t,n)=>Math.max(t,parseInt(n.id.replace("q_",""),10)||0),0)+1)}}catch{this.queue=[]}}}const he=[{type:"NiceAudioPlayer",label:"Audio Player",category:"Audio",icon:"music",defaultProps:{src:"",autoplay:!1,showWaveform:!0},propDescriptors:[{name:"src",type:"string",label:"Audio source URL"},{name:"autoplay",type:"boolean",label:"Auto-play",defaultValue:!1},{name:"loop",type:"boolean",label:"Loop",defaultValue:!1},{name:"showWaveform",type:"boolean",label:"Show waveform",defaultValue:!0},{name:"showPlaylist",type:"boolean",label:"Show playlist",defaultValue:!1},{name:"visualizerMode",type:"select",label:"Visualizer mode",options:[{label:"None",value:"none"},{label:"Bars",value:"bars"},{label:"Wave",value:"wave"},{label:"Circle",value:"circle"}],defaultValue:"bars"},{name:"height",type:"size",label:"Height",group:"Layout"}]},{type:"NiceWaveform",label:"Waveform",category:"Audio",icon:"waveform",defaultProps:{peaks:[],color:"#4a90d9"},propDescriptors:[{name:"peaks",type:"json",label:"Peak data (JSON array)"},{name:"color",type:"color",label:"Waveform color",defaultValue:"#4a90d9"},{name:"progressColor",type:"color",label:"Progress color",defaultValue:"#1b5e20"},{name:"barWidth",type:"number",label:"Bar width (px)",min:1,max:10,step:1,defaultValue:2},{name:"height",type:"size",label:"Height",group:"Layout"},{name:"interactive",type:"boolean",label:"Allow seeking",defaultValue:!0}]},{type:"NicePianoRoll",label:"Piano Roll",category:"Audio",icon:"piano",defaultProps:{notes:[],octaves:4,startOctave:3},propDescriptors:[{name:"notes",type:"json",label:"MIDI notes (JSON)"},{name:"octaves",type:"number",label:"Visible octaves",min:1,max:8,defaultValue:4},{name:"startOctave",type:"number",label:"Start octave",min:0,max:8,defaultValue:3},{name:"quantize",type:"select",label:"Quantize",options:[{label:"1/4",value:"4"},{label:"1/8",value:"8"},{label:"1/16",value:"16"},{label:"1/32",value:"32"}],defaultValue:"16"},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1},{name:"height",type:"size",label:"Height",group:"Layout"}]},{type:"NiceKaraoke",label:"Karaoke",category:"Audio",icon:"microphone",defaultProps:{lyrics:[],audioSrc:""},propDescriptors:[{name:"audioSrc",type:"string",label:"Audio source URL"},{name:"lyrics",type:"json",label:"Lyrics (JSON array of {time, text})"},{name:"showScore",type:"boolean",label:"Show score",defaultValue:!0},{name:"pitchDetection",type:"boolean",label:"Pitch detection",defaultValue:!0},{name:"highlightColor",type:"color",label:"Highlight color",defaultValue:"#ffd700"},{name:"fontSize",type:"size",label:"Font size",group:"Typography"}]}],pe=[{type:"NiceLoginForm",label:"Login Form",category:"Auth",icon:"log-in",defaultProps:{showRemember:!0,showForgotPassword:!0},propDescriptors:[{name:"title",type:"string",label:"Form title",defaultValue:"Sign In"},{name:"showRemember",type:"boolean",label:"Show 'Remember me'",defaultValue:!0},{name:"showForgotPassword",type:"boolean",label:"Show 'Forgot password'",defaultValue:!0},{name:"showRegisterLink",type:"boolean",label:"Show register link",defaultValue:!1},{name:"showLogo",type:"boolean",label:"Show logo",defaultValue:!0},{name:"logoUrl",type:"string",label:"Logo URL",group:"Branding"},{name:"primaryColor",type:"color",label:"Primary color",defaultValue:"#1976d2",group:"Branding"},{name:"variant",type:"variant",label:"Visual style",defaultValue:"card"}]},{type:"NiceCaptcha",label:"Captcha",category:"Auth",icon:"shield",defaultProps:{provider:"recaptcha",size:"normal"},propDescriptors:[{name:"provider",type:"select",label:"Provider",options:[{label:"reCAPTCHA v2",value:"recaptcha"},{label:"reCAPTCHA v3",value:"recaptcha-v3"},{label:"hCaptcha",value:"hcaptcha"},{label:"Turnstile",value:"turnstile"}],defaultValue:"recaptcha"},{name:"siteKey",type:"string",label:"Site key"},{name:"size",type:"select",label:"Size",options:[{label:"Normal",value:"normal"},{label:"Compact",value:"compact"},{label:"Invisible",value:"invisible"}],defaultValue:"normal"},{name:"theme",type:"select",label:"Theme",options:[{label:"Light",value:"light"},{label:"Dark",value:"dark"}],defaultValue:"light"}]},{type:"Nice2FASetup",label:"2FA Setup",category:"Auth",icon:"key",defaultProps:{method:"totp"},propDescriptors:[{name:"method",type:"select",label:"2FA method",options:[{label:"TOTP (Authenticator)",value:"totp"},{label:"SMS",value:"sms"},{label:"Email",value:"email"}],defaultValue:"totp"},{name:"issuer",type:"string",label:"Issuer name",defaultValue:"OmniVerk"},{name:"showBackupCodes",type:"boolean",label:"Show backup codes",defaultValue:!0},{name:"showQR",type:"boolean",label:"Show QR code",defaultValue:!0},{name:"codeLength",type:"number",label:"Code length",min:4,max:8,defaultValue:6}]}],fe=[{type:"NiceAddress",label:"Address Editor",category:"Business",icon:"map-pin",defaultProps:{country:"PL"},propDescriptors:[{name:"street",type:"string",label:"Street",group:"Address"},{name:"city",type:"string",label:"City",group:"Address"},{name:"postalCode",type:"string",label:"Postal code",group:"Address"},{name:"country",type:"select",label:"Country",options:[{label:"Poland",value:"PL"},{label:"Germany",value:"DE"},{label:"USA",value:"US"},{label:"UK",value:"GB"},{label:"France",value:"FR"}],defaultValue:"PL",group:"Address"},{name:"showMap",type:"boolean",label:"Show map preview",defaultValue:!1},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NicePhone",label:"Phone Input",category:"Business",icon:"phone",defaultProps:{countryCode:"+48"},propDescriptors:[{name:"value",type:"string",label:"Phone number"},{name:"countryCode",type:"string",label:"Default country code",defaultValue:"+48"},{name:"showFlag",type:"boolean",label:"Show country flag",defaultValue:!0},{name:"format",type:"select",label:"Format",options:[{label:"International",value:"international"},{label:"National",value:"national"},{label:"E.164",value:"e164"}],defaultValue:"international"},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceCurrency",label:"Currency Input",category:"Business",icon:"dollar-sign",defaultProps:{currency:"PLN",decimals:2},propDescriptors:[{name:"value",type:"number",label:"Amount",defaultValue:0},{name:"currency",type:"select",label:"Currency",options:[{label:"PLN",value:"PLN"},{label:"EUR",value:"EUR"},{label:"USD",value:"USD"},{label:"GBP",value:"GBP"}],defaultValue:"PLN"},{name:"decimals",type:"number",label:"Decimal places",min:0,max:4,defaultValue:2},{name:"showCurrencySymbol",type:"boolean",label:"Show symbol",defaultValue:!0},{name:"thousandSeparator",type:"boolean",label:"Thousand separator",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceVAT",label:"VAT Input",category:"Business",icon:"percent",defaultProps:{rate:23,country:"PL"},propDescriptors:[{name:"netValue",type:"number",label:"Net value",defaultValue:0,group:"Values"},{name:"rate",type:"number",label:"VAT rate (%)",min:0,max:100,defaultValue:23,group:"Values"},{name:"country",type:"select",label:"Country",options:[{label:"Poland",value:"PL"},{label:"Germany",value:"DE"},{label:"France",value:"FR"}],defaultValue:"PL"},{name:"showGross",type:"boolean",label:"Show gross value",defaultValue:!0},{name:"showVatAmount",type:"boolean",label:"Show VAT amount",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceInvoiceLines",label:"Invoice Lines",category:"Business",icon:"file-text",defaultProps:{lines:[],currency:"PLN"},propDescriptors:[{name:"lines",type:"json",label:"Invoice lines (JSON)"},{name:"currency",type:"select",label:"Currency",options:[{label:"PLN",value:"PLN"},{label:"EUR",value:"EUR"},{label:"USD",value:"USD"}],defaultValue:"PLN"},{name:"showVAT",type:"boolean",label:"Show VAT column",defaultValue:!0},{name:"showDiscount",type:"boolean",label:"Show discount column",defaultValue:!1},{name:"showTotal",type:"boolean",label:"Show totals row",defaultValue:!0},{name:"editable",type:"boolean",label:"Editable",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]}],me=[{type:"NiceLeaderboard",label:"Leaderboard",category:"Gamification",icon:"trophy",defaultProps:{dataSource:[],maxRows:10},propDescriptors:[{name:"dataSource",type:"json",label:"Data source (JSON)"},{name:"maxRows",type:"number",label:"Max visible rows",min:3,max:100,defaultValue:10},{name:"showRank",type:"boolean",label:"Show rank column",defaultValue:!0},{name:"showAvatar",type:"boolean",label:"Show avatar",defaultValue:!0},{name:"highlightCurrentUser",type:"boolean",label:"Highlight current user",defaultValue:!0},{name:"scoreField",type:"string",label:"Score field name",defaultValue:"score"},{name:"nameField",type:"string",label:"Name field name",defaultValue:"name"},{name:"variant",type:"variant",label:"Visual style",defaultValue:"default"}]},{type:"NiceAchievement",label:"Achievement Badge",category:"Gamification",icon:"award",defaultProps:{title:"Achievement",unlocked:!1},propDescriptors:[{name:"title",type:"string",label:"Achievement title",defaultValue:"Achievement"},{name:"description",type:"string",label:"Description"},{name:"icon",type:"string",label:"Icon URL"},{name:"unlocked",type:"boolean",label:"Unlocked",defaultValue:!1},{name:"progress",type:"number",label:"Progress (0-100)",min:0,max:100,defaultValue:0},{name:"rarity",type:"select",label:"Rarity",options:[{label:"Common",value:"common"},{label:"Rare",value:"rare"},{label:"Epic",value:"epic"},{label:"Legendary",value:"legendary"}],defaultValue:"common"},{name:"size",type:"size",label:"Badge size",group:"Layout"}]},{type:"NiceQuest",label:"Quest Tracker",category:"Gamification",icon:"map",defaultProps:{title:"Quest",steps:[]},propDescriptors:[{name:"title",type:"string",label:"Quest title",defaultValue:"Quest"},{name:"description",type:"string",label:"Quest description"},{name:"steps",type:"json",label:"Steps (JSON array of {title, completed})"},{name:"reward",type:"string",label:"Reward description"},{name:"rewardXP",type:"number",label:"Reward XP",min:0,defaultValue:100},{name:"showProgress",type:"boolean",label:"Show progress bar",defaultValue:!0},{name:"variant",type:"variant",label:"Visual style",defaultValue:"default"}]},{type:"NiceProgress",label:"XP / Level Bar",category:"Gamification",icon:"zap",defaultProps:{value:350,max:1e3,label:"Level 5",variant:"success",showValue:!0},propDescriptors:[{name:"value",type:"number",label:"Current XP",min:0,defaultValue:350},{name:"max",type:"number",label:"Max XP (next level)",min:1,defaultValue:1e3},{name:"label",type:"string",label:"Label (e.g. level)",defaultValue:"Level 5"},{name:"showValue",type:"boolean",label:"Show value",defaultValue:!0},{name:"variant",type:"variant",label:"Visual style",defaultValue:"success"},{name:"striped",type:"boolean",label:"Striped",defaultValue:!1},{name:"animated",type:"boolean",label:"Animate changes",defaultValue:!0},{name:"size",type:"size",label:"Bar height",group:"Layout"}]}],ye=[{type:"NicePixelEditor",label:"Pixel Editor",category:"Graphics",icon:"grid",defaultProps:{width:32,height:32,palette:[]},propDescriptors:[{name:"width",type:"number",label:"Canvas width (px)",min:1,max:256,defaultValue:32},{name:"height",type:"number",label:"Canvas height (px)",min:1,max:256,defaultValue:32},{name:"palette",type:"json",label:"Color palette (JSON array)"},{name:"gridVisible",type:"boolean",label:"Show grid",defaultValue:!0},{name:"zoom",type:"number",label:"Zoom level",min:1,max:32,step:1,defaultValue:8},{name:"layers",type:"boolean",label:"Enable layers",defaultValue:!0},{name:"onion",type:"boolean",label:"Onion skin (animation)",defaultValue:!1}]},{type:"NiceVectorEditor",label:"Vector Editor",category:"Graphics",icon:"pen-tool",defaultProps:{width:800,height:600},propDescriptors:[{name:"width",type:"number",label:"Canvas width",min:100,max:4096,defaultValue:800,group:"Layout"},{name:"height",type:"number",label:"Canvas height",min:100,max:4096,defaultValue:600,group:"Layout"},{name:"showRulers",type:"boolean",label:"Show rulers",defaultValue:!0},{name:"snapToGrid",type:"boolean",label:"Snap to grid",defaultValue:!0},{name:"gridSize",type:"number",label:"Grid size",min:1,max:100,defaultValue:10},{name:"fillColor",type:"color",label:"Default fill",defaultValue:"#ffffff"},{name:"strokeColor",type:"color",label:"Default stroke",defaultValue:"#000000"},{name:"strokeWidth",type:"number",label:"Stroke width",min:0,max:20,step:.5,defaultValue:1}]},{type:"NicePhotoEditor",label:"Photo Editor",category:"Graphics",icon:"image",defaultProps:{src:""},propDescriptors:[{name:"src",type:"string",label:"Image source URL"},{name:"crop",type:"boolean",label:"Allow crop",defaultValue:!0},{name:"rotate",type:"boolean",label:"Allow rotate",defaultValue:!0},{name:"filters",type:"boolean",label:"Show filters",defaultValue:!0},{name:"adjustments",type:"boolean",label:"Show adjustments",defaultValue:!0},{name:"text",type:"boolean",label:"Allow text overlay",defaultValue:!0},{name:"outputFormat",type:"select",label:"Output format",options:[{label:"PNG",value:"png"},{label:"JPEG",value:"jpeg"},{label:"WebP",value:"webp"}],defaultValue:"png"},{name:"maxWidth",type:"number",label:"Max output width",min:100,max:8192,group:"Output"}]}],be=[{type:"NiceComments",label:"Comments",category:"Social",icon:"message-circle",defaultProps:{threadId:"",allowReplies:!0},propDescriptors:[{name:"threadId",type:"string",label:"Thread ID / entity ID"},{name:"allowReplies",type:"boolean",label:"Allow replies (nested)",defaultValue:!0},{name:"maxDepth",type:"number",label:"Max nesting depth",min:1,max:10,defaultValue:3},{name:"sortOrder",type:"select",label:"Default sort",options:[{label:"Newest first",value:"newest"},{label:"Oldest first",value:"oldest"},{label:"Most liked",value:"popular"}],defaultValue:"newest"},{name:"allowReactions",type:"boolean",label:"Allow reactions",defaultValue:!0},{name:"showAvatar",type:"boolean",label:"Show avatars",defaultValue:!0},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceRatings",label:"Ratings",category:"Social",icon:"star",defaultProps:{maxStars:5,allowHalf:!0},propDescriptors:[{name:"value",type:"number",label:"Current rating",min:0,max:10,step:.5,defaultValue:0},{name:"maxStars",type:"number",label:"Maximum stars",min:3,max:10,defaultValue:5},{name:"allowHalf",type:"boolean",label:"Allow half stars",defaultValue:!0},{name:"showCount",type:"boolean",label:"Show vote count",defaultValue:!0},{name:"showAverage",type:"boolean",label:"Show average",defaultValue:!0},{name:"color",type:"color",label:"Star color",defaultValue:"#ffc107"},{name:"size",type:"size",label:"Star size",group:"Layout"},{name:"readOnly",type:"boolean",label:"Read only",defaultValue:!1}]},{type:"NiceWiki",label:"Wiki Editor",category:"Social",icon:"book",defaultProps:{content:"",showTOC:!0},propDescriptors:[{name:"content",type:"string",label:"Initial content (Markdown)"},{name:"showTOC",type:"boolean",label:"Show table of contents",defaultValue:!0},{name:"showHistory",type:"boolean",label:"Show version history",defaultValue:!0},{name:"allowEdit",type:"boolean",label:"Allow editing",defaultValue:!0},{name:"showToolbar",type:"boolean",label:"Show Markdown toolbar",defaultValue:!0},{name:"previewMode",type:"select",label:"Preview mode",options:[{label:"Side by side",value:"split"},{label:"Tab switch",value:"tabs"},{label:"Live preview",value:"live"}],defaultValue:"split"},{name:"maxLength",type:"number",label:"Max content length",min:0,defaultValue:0}]}],ge=[{type:"NiceModelEditor",label:"3D Model Editor",category:"3D",icon:"cube",defaultProps:{modelUrl:""},propDescriptors:[{name:"modelUrl",type:"string",label:"Model URL (.glb / .gltf)"},{name:"environmentMap",type:"select",label:"Environment",options:[{label:"Studio",value:"studio"},{label:"Outdoor",value:"outdoor"},{label:"Warehouse",value:"warehouse"},{label:"None",value:"none"}],defaultValue:"studio"},{name:"showGrid",type:"boolean",label:"Show grid",defaultValue:!0},{name:"showAxes",type:"boolean",label:"Show axes",defaultValue:!0},{name:"enablePhysics",type:"boolean",label:"Enable physics",defaultValue:!1},{name:"wireframe",type:"boolean",label:"Wireframe mode",defaultValue:!1},{name:"backgroundColor",type:"color",label:"Background",defaultValue:"#1a1a2e"},{name:"height",type:"size",label:"Viewport height",group:"Layout"}]},{type:"NiceModelViewer",label:"3D Model Viewer",category:"3D",icon:"eye",defaultProps:{modelUrl:"",autoRotate:!0},propDescriptors:[{name:"modelUrl",type:"string",label:"Model URL (.glb / .gltf)"},{name:"autoRotate",type:"boolean",label:"Auto-rotate",defaultValue:!0},{name:"rotateSpeed",type:"number",label:"Rotate speed",min:.1,max:10,step:.1,defaultValue:1},{name:"zoom",type:"boolean",label:"Allow zoom",defaultValue:!0},{name:"pan",type:"boolean",label:"Allow pan",defaultValue:!0},{name:"environmentMap",type:"select",label:"Environment",options:[{label:"Studio",value:"studio"},{label:"Outdoor",value:"outdoor"},{label:"Warehouse",value:"warehouse"},{label:"None",value:"none"}],defaultValue:"studio"},{name:"backgroundColor",type:"color",label:"Background",defaultValue:"#1a1a2e"},{name:"showAnnotations",type:"boolean",label:"Show annotations",defaultValue:!1},{name:"height",type:"size",label:"Viewport height",group:"Layout"}]}],Ge=(function(){return[...he,...ye,...ge,...me,...fe,...pe,...be]})();async function qe(i,e){const t=await fetch(i,{...e,headers:{"Content-Type":"application/json",...e==null?void 0:e.headers}});if(!t.ok){const n=await t.text();let a={};try{a=JSON.parse(n)}catch{}throw{code:a.code||`HTTP_${t.status}`,message:a.message||t.statusText,statusCode:t.status}}return t.json()}function Ke(i){const{baseUrl:e,currency:t="PLN",timeout:n=3e4,fetcher:a=qe,getAuthToken:r,onError:l}=i,[c,d]=o.useState([]),[g,S]=o.useState(null),[w,T]=o.useState(null),[A,W]=o.useState(null),[L,Q]=o.useState(null),[G,X]=o.useState(null),[D,q]=o.useState([]),[O,Z]=o.useState([]),[ee,B]=o.useState(null),[z,_]=o.useState({offers:!1,calculate:!1,compare:!1,apply:!1,creditCheck:!1,refinancing:!1,consolidation:!1,savedCalculations:!1}),N=o.useRef(new Map),$=o.useCallback(()=>{const s={"Content-Type":"application/json"},b=r==null?void 0:r();return b&&(s.Authorization=`Bearer ${b}`),s},[r]),p=o.useCallback(async(s,b={},I)=>{const Y=N.current.get(s);Y&&Y.abort();const u=new AbortController;N.current.set(s,u);const m=setTimeout(()=>u.abort(),n);_(h=>({...h,[I]:!0})),B(null);try{const h=`${e}${s}`;return await a(h,{...b,headers:{...$(),...b.headers},signal:u.signal})}catch(h){const P={code:h.code||"UNKNOWN_ERROR",message:h.message||"An unknown error occurred",details:h.details,endpoint:s,statusCode:h.statusCode};throw h.name!=="AbortError"&&(B(P),l==null||l(P)),P}finally{clearTimeout(m),N.current.delete(s),_(h=>({...h,[I]:!1}))}},[e,n,a,$,l]),se=o.useCallback(async s=>{var m,h;const b=new URLSearchParams;s!=null&&s.loanType&&b.set("loanType",s.loanType),s!=null&&s.minAmount&&b.set("minAmount",String(s.minAmount)),s!=null&&s.maxAmount&&b.set("maxAmount",String(s.maxAmount)),s!=null&&s.minTerm&&b.set("minTerm",String(s.minTerm)),s!=null&&s.maxTerm&&b.set("maxTerm",String(s.maxTerm)),s!=null&&s.maxApr&&b.set("maxApr",String(s.maxApr)),(m=s==null?void 0:s.banks)!=null&&m.length&&b.set("banks",s.banks.join(",")),(h=s==null?void 0:s.features)!=null&&h.length&&b.set("features",s.features.join(",")),b.set("currency",(s==null?void 0:s.currency)||t);const I=b.toString(),Y=`/offers${I?`?${I}`:""}`,u=await p(Y,{method:"GET"},"offers");return d(u),u},[p,t]),j=o.useCallback(s=>{S(s)},[]),U=o.useCallback(async s=>p(`/offers/${s}`,{method:"GET"},"offers"),[p]),te=o.useCallback(async s=>{const b=await p("/calculate/amortization",{method:"POST",body:JSON.stringify({...s,currency:s.currency||t})},"calculate");return T(b),b},[p,t]),ne=o.useCallback(async s=>{const b=await p("/calculate/compare",{method:"POST",body:JSON.stringify({scenarios:s,currency:t})},"compare");return W(b),b},[p,t]),y=o.useCallback(async(s,b,I)=>{const Y=await p("/credit/analyze",{method:"POST",body:JSON.stringify({monthlyIncome:s,monthlyDebts:b,requestedAmount:I,currency:t})},"creditCheck");return X(Y),Y},[p,t]),V=o.useCallback(async s=>{const b=await p("/applications",{method:"POST",body:JSON.stringify(s)},"apply");return Q(b),b},[p]),v=o.useCallback(async s=>{const b=await p(`/applications/${s}`,{method:"GET"},"apply");return Q(b),b},[p]),E=o.useCallback(async s=>{await p(`/applications/${s}/cancel`,{method:"POST"},"apply"),Q(null)},[p]),k=o.useCallback(async(s,b,I,Y)=>{const u=await p("/calculations",{method:"POST",body:JSON.stringify({name:s,config:b,result:I,notes:Y})},"savedCalculations");return q(m=>[...m,u]),u},[p]),M=o.useCallback(async s=>p(`/calculations/${s}`,{method:"GET"},"savedCalculations"),[p]),R=o.useCallback(async s=>{await p(`/calculations/${s}`,{method:"DELETE"},"savedCalculations"),q(b=>b.filter(I=>I.id!==s))},[p]),K=o.useCallback(async()=>{const s=await p("/calculations",{method:"GET"},"savedCalculations");return q(s),s},[p]),ae=o.useCallback(async(s,b)=>p("/refinancing/analyze",{method:"POST",body:JSON.stringify({currentLoanId:s,newOfferIds:b})},"refinancing"),[p]),oe=o.useCallback(async(s,b)=>p("/consolidation/simulate",{method:"POST",body:JSON.stringify({debts:s,targetRate:b,currency:t})},"consolidation"),[p,t]),re=o.useCallback(async()=>{const s=await p("/active",{method:"GET"},"offers");return Z(s),s},[p]),f=o.useCallback(()=>{B(null)},[]),C=o.useCallback(()=>{d([]),S(null),T(null),W(null),Q(null),X(null),q([]),Z([]),B(null),_({offers:!1,calculate:!1,compare:!1,apply:!1,creditCheck:!1,refinancing:!1,consolidation:!1,savedCalculations:!1})},[]);return o.useEffect(()=>{const s=N.current;return()=>{s.forEach(b=>b.abort()),s.clear()}},[]),{offers:c,selectedOffer:g,latestCalculation:w,latestComparison:A,applicationState:L,creditAnalysis:G,savedCalculations:D,activeLoans:O,loading:z,error:ee,fetchOffers:se,selectOffer:j,getOfferDetails:U,calculateAmortization:te,compareLoanScenarios:ne,runCreditAnalysis:y,submitApplication:V,getApplicationStatus:v,cancelApplication:E,saveCalculation:k,loadCalculation:M,deleteSavedCalculation:R,fetchSavedCalculations:K,analyzeRefinancing:ae,simulateConsolidation:oe,fetchActiveLoans:re,clearError:f,reset:C}}class He{constructor(e){this.baseUrl=e.baseUrl,this.currency=e.currency||"PLN",this.timeout=e.timeout||3e4,this.getAuthToken=e.getAuthToken}async request(e,t={}){var c;const n=new AbortController,a=setTimeout(()=>n.abort(),this.timeout),r={"Content-Type":"application/json"},l=(c=this.getAuthToken)==null?void 0:c.call(this);l&&(r.Authorization=`Bearer ${l}`);try{const d=await fetch(`${this.baseUrl}${e}`,{...t,headers:{...r,...t.headers},signal:n.signal});if(!d.ok)throw new Error(`HTTP ${d.status}: ${d.statusText}`);return d.json()}finally{clearTimeout(a)}}async getOffers(e){const t=new URLSearchParams;e!=null&&e.loanType&&t.set("loanType",e.loanType),e!=null&&e.minAmount&&t.set("minAmount",String(e.minAmount)),e!=null&&e.maxAmount&&t.set("maxAmount",String(e.maxAmount)),t.set("currency",(e==null?void 0:e.currency)||this.currency);const n=t.toString();return this.request(`/offers${n?`?${n}`:""}`)}async getOfferById(e){return this.request(`/offers/${e}`)}async calculateAmortization(e){return this.request("/calculate/amortization",{method:"POST",body:JSON.stringify({...e,currency:e.currency||this.currency})})}async compareScenarios(e){return this.request("/calculate/compare",{method:"POST",body:JSON.stringify({scenarios:e,currency:this.currency})})}async submitApplication(e){return this.request("/applications",{method:"POST",body:JSON.stringify(e)})}async getApplicationStatus(e){return this.request(`/applications/${e}`)}async analyzeRefinancing(e,t){return this.request("/refinancing/analyze",{method:"POST",body:JSON.stringify({currentLoanId:e,newOfferIds:t})})}async simulateConsolidation(e,t){return this.request("/consolidation/simulate",{method:"POST",body:JSON.stringify({debts:e,targetRate:t,currency:this.currency})})}async getActiveLoans(){return this.request("/active")}}exports.ErpAuthAdapter=Ne;exports.ErpDataAdapter=Ve;exports.ErpExportAdapter=Fe;exports.ErpFileAdapter=Ue;exports.ErpOfflineQueue=Je;exports.ErpOptimisticStore=je;exports.ErpRateLimiter=ze;exports.LoanService=He;exports.allControlRegistries=Ge;exports.applyBatchChanges=Oe;exports.audioControlRegistry=he;exports.authControlRegistry=pe;exports.businessControlRegistry=fe;exports.createMiddlewarePipeline=Me;exports.createSignalRAdapter=Pe;exports.createSignalRDataOperations=Ae;exports.formatPresenceStatus=Re;exports.gamificationControlRegistry=me;exports.generateUserColor=de;exports.graphicControlRegistry=ye;exports.headerMiddleware=Be;exports.loggingMiddleware=Ie;exports.retryMiddleware=$e;exports.socialControlRegistry=be;exports.threeControlRegistry=ge;exports.useCollaborativeDataGrid=De;exports.useEntityPresence=ce;exports.useLoanApi=Ke;exports.useMultiEntityPresence=xe;exports.useSignalRLiveData=ue;
package/dist/index.mjs CHANGED
@@ -2130,15 +2130,17 @@ const ye = [
2130
2130
  { name: "height", type: "size", label: "Viewport height", group: "Layout" }
2131
2131
  ]
2132
2132
  }
2133
- ], je = [
2134
- ...ye,
2135
- ...ve,
2136
- ...ke,
2137
- ...we,
2138
- ...ge,
2139
- ...be,
2140
- ...Se
2141
- ];
2133
+ ], je = /* @__PURE__ */ (function() {
2134
+ return [
2135
+ ...ye,
2136
+ ...ve,
2137
+ ...ke,
2138
+ ...we,
2139
+ ...ge,
2140
+ ...be,
2141
+ ...Se
2142
+ ];
2143
+ })();
2142
2144
  async function Te(c, e) {
2143
2145
  const t = await fetch(c, {
2144
2146
  ...e,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nice2dev/erp-adapter",
3
- "version": "1.1.10",
3
+ "version": "1.2.1",
4
4
  "description": "Adapter layer connecting OmniVerk .NET backend with @nice2dev/* React components",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",