@nice2dev/ui 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 +183 -0
- package/README.md +12 -20
- package/dist/NiceApiExplorer.doc-CFJndg5h.js +25 -0
- package/dist/NiceApiExplorer.doc-TEx67kV5.cjs +1 -0
- package/dist/NiceBPMNDesigner.doc-6lK1pXRq.js +32 -0
- package/dist/NiceBPMNDesigner.doc-BY8t7qOi.cjs +8 -0
- package/dist/NiceBackupDiffViewer.doc-CYvOeX19.js +25 -0
- package/dist/NiceBackupDiffViewer.doc-ChQaZCg1.cjs +1 -0
- package/dist/NiceBackupList.doc-BdQCw0_D.cjs +1 -0
- package/dist/NiceBackupList.doc-BwjIAoqz.js +25 -0
- package/dist/NiceBackupRestoreDialog.doc-B2iiqTps.cjs +1 -0
- package/dist/NiceBackupRestoreDialog.doc-DuXSGJiD.js +25 -0
- package/dist/NiceBackupScheduler.doc-BpY45181.js +31 -0
- package/dist/NiceBackupScheduler.doc-ByeL3iH1.cjs +7 -0
- package/dist/NiceBackupStatusBadge.doc-BA3dYgiW.cjs +1 -0
- package/dist/NiceBackupStatusBadge.doc-CxwkVarP.js +25 -0
- package/dist/NiceBackupTagEditor.doc-Bej1KHco.cjs +7 -0
- package/dist/NiceBackupTagEditor.doc-CNy4uNws.js +31 -0
- package/dist/NiceBottomSheet.doc-keq-Fzlz.cjs +8 -0
- package/dist/NiceBottomSheet.doc-v-UPUKQk.js +32 -0
- package/dist/NiceBranchManager.doc-BTyRjX7X.cjs +6 -0
- package/dist/NiceBranchManager.doc-Cz4SyEqE.js +30 -0
- package/dist/NiceButton-3AcJJ15c.cjs +1 -0
- package/dist/NiceButton-5tWvfXKl.cjs +1 -0
- package/dist/NiceButton-DHSgQT1_.js +112 -0
- package/dist/NiceButton-vkI07DP0.js +88 -0
- package/dist/NiceCodeEditor-B8At55f5.js +1179 -0
- package/dist/NiceCodeEditor-BJSEzhcY.cjs +260 -0
- package/dist/NiceCodeEditor-VGIDWSkS.js +1181 -0
- package/dist/NiceCodeEditor-qX39PSnQ.cjs +260 -0
- package/dist/NiceColorPicker-CQhhjZ8w.cjs +1 -0
- package/dist/NiceColorPicker-Cbop7VMu.js +491 -0
- package/dist/NiceColorPicker-DCgmE-3H.cjs +1 -0
- package/dist/NiceColorPicker-DK30kJgy.js +486 -0
- package/dist/NiceColorPicker-DtPFxDKM.cjs +1 -0
- package/dist/NiceColorPicker-bNJBAU_c.js +598 -0
- package/dist/NiceConnectorConfigForm.doc-BKrDuhXw.cjs +7 -0
- package/dist/NiceConnectorConfigForm.doc-BsHeXz3M.js +31 -0
- package/dist/NiceDataBranchGraph.doc-Axidz41W.js +29 -0
- package/dist/NiceDataBranchGraph.doc-sjLmrrtE.cjs +5 -0
- package/dist/NiceDataBranchManager.doc-B1-Rp2X4.cjs +6 -0
- package/dist/NiceDataBranchManager.doc-GUqfTFvW.js +30 -0
- package/dist/NiceDataConflictResolver.doc-CjQryrTu.cjs +5 -0
- package/dist/NiceDataConflictResolver.doc-L-TcnQMX.js +29 -0
- package/dist/NiceDataDiffViewer.doc-BzGrf0U-.cjs +6 -0
- package/dist/NiceDataDiffViewer.doc-goxhSldH.js +30 -0
- package/dist/NiceDataGrid-BDEIbuBS.js +2218 -0
- package/dist/NiceDataGrid-BOCJr6XF.js +2217 -0
- package/dist/NiceDataGrid-BV5Oh-gy.cjs +10 -0
- package/dist/NiceDataGrid-CS5aB-EN.cjs +10 -0
- package/dist/NiceDataGrid-Dd7SI-M6.cjs +10 -0
- package/dist/NiceDataGrid-DjZchXYG.js +2217 -0
- package/dist/NiceDataMapper.doc-QmnmnvVq.js +30 -0
- package/dist/NiceDataMapper.doc-ytGVtYVr.cjs +6 -0
- package/dist/NiceDataMergeBuilder.doc-BcmzKxh2.cjs +6 -0
- package/dist/NiceDataMergeBuilder.doc-BvYa4aUJ.js +30 -0
- package/dist/NiceDataSnapshot.doc-C73K1biG.cjs +6 -0
- package/dist/NiceDataSnapshot.doc-hU7wnOzM.js +30 -0
- package/dist/NiceDesktopViews.doc-DJjYlyP2.cjs +1 -0
- package/dist/NiceDesktopViews.doc-ly-VUAJj.js +25 -0
- package/dist/NiceDeviceControlCard.doc-BZIo92-w.cjs +1 -0
- package/dist/NiceDeviceControlCard.doc-DIzZcW9L.js +25 -0
- package/dist/NiceDocumentViewer-B9VIVKyw.js +726 -0
- package/dist/NiceDocumentViewer-CDXAmPp7.cjs +180 -0
- package/dist/NiceDocumentationViewer.doc-BSNGa7a_.js +25 -0
- package/dist/NiceDocumentationViewer.doc-CrwlvPFg.cjs +1 -0
- package/dist/NiceEnergyChart.doc-DW-jllDV.cjs +1 -0
- package/dist/NiceEnergyChart.doc-DnEehTff.js +25 -0
- package/dist/NiceFeatureGate.doc-DN17uS_B.cjs +3 -0
- package/dist/NiceFeatureGate.doc-DNfFSRrh.js +27 -0
- package/dist/NiceForm-BCEXovJR.cjs +1 -0
- package/dist/NiceForm-BcN4p2kG.cjs +1 -0
- package/dist/NiceForm-D7oyWHXg.js +4820 -0
- package/dist/NiceForm-DUhxXArr.js +4817 -0
- package/dist/NiceForm-tIXS-M6b.js +4770 -0
- package/dist/NiceForm-uCeVmTrD.cjs +1 -0
- package/dist/NiceFormItem.doc-BJwEnDz2.js +36 -0
- package/dist/NiceFormItem.doc-Ck3PgaPD.cjs +12 -0
- package/dist/NiceGantt-CTbqCuwv.cjs +1 -0
- package/dist/NiceGantt-Dao7pN9z.js +328 -0
- package/dist/NiceGantt.doc-B6YZcJvG.cjs +11 -0
- package/dist/NiceGantt.doc-DsI1QXly.js +48 -0
- package/dist/NiceGitBlame.doc-BQ2KvGkD.js +30 -0
- package/dist/NiceGitBlame.doc-DuTSjZVN.cjs +6 -0
- package/dist/NiceGitDiffViewer.doc-D24AGos_.js +30 -0
- package/dist/NiceGitDiffViewer.doc-D9FVquBC.cjs +6 -0
- package/dist/NiceGitGraph.doc-C-8VGMIz.js +29 -0
- package/dist/NiceGitGraph.doc-eRvTmefl.cjs +5 -0
- package/dist/NiceGitHooks.doc-DCTVw7HX.cjs +5 -0
- package/dist/NiceGitHooks.doc-OCFj5w6v.js +29 -0
- package/dist/NiceHtmlEditor-BYk1roA4.cjs +10 -0
- package/dist/NiceHtmlEditor-C5kLeF9H.cjs +10 -0
- package/dist/NiceHtmlEditor-CFVMIC5L.js +848 -0
- package/dist/NiceHtmlEditor-DUwcqj5N.cjs +10 -0
- package/dist/NiceHtmlEditor-DiAphF1k.js +889 -0
- package/dist/NiceHtmlEditor-mWebBmy1.js +849 -0
- package/dist/NiceInstanceMonitor.doc-BSDZp5xa.js +31 -0
- package/dist/NiceInstanceMonitor.doc-HVbLufnh.cjs +7 -0
- package/dist/NiceLocaleManager.doc-CbVHDEWu.js +25 -0
- package/dist/NiceLocaleManager.doc-XH6hMW0Z.cjs +1 -0
- package/dist/NiceLockButton.doc-BMhSj3TB.cjs +1 -0
- package/dist/NiceLockButton.doc-DvHGhcfm.js +25 -0
- package/dist/NiceLoginForm-BHyDY7br.cjs +1 -0
- package/dist/NiceLoginForm-BuxFY2Rk.js +750 -0
- package/dist/NiceLoginForm-DQe77Isv.js +747 -0
- package/dist/NiceLoginForm-NBCo-DUZ.cjs +1 -0
- package/dist/NiceLoginForm.css +1 -0
- package/dist/NiceMAM.doc-CsQ57saR.cjs +8 -0
- package/dist/NiceMAM.doc-hjW7buTH.js +32 -0
- package/dist/NiceMention--3P3vO-W.cjs +430 -0
- package/dist/NiceMention-CA7CL5BI.js +11263 -0
- package/dist/NiceMention-CHcKRl-L.cjs +430 -0
- package/dist/NiceMention-Co2cqkVM.js +11316 -0
- package/dist/NiceMention-DJD0BLcp.js +11269 -0
- package/dist/NiceMention-DcaUEMSg.cjs +430 -0
- package/dist/NiceMention.css +1 -1
- package/dist/NiceModal-C4p8a82e.cjs +1 -0
- package/dist/NiceModal-TNlkaL_i.js +85 -0
- package/dist/NiceModuleLifecyclePanel-BWbKdVC_.js +7054 -0
- package/dist/NiceModuleLifecyclePanel-CZHIzvkE.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-DV3F_QdI.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-OC9YK2kG.js +7052 -0
- package/dist/NiceModuleLifecyclePanel-_OcfDmtC.cjs +1 -0
- package/dist/NiceModuleLifecyclePanel-gaZkIEtK.js +6825 -0
- package/dist/NiceModuleLifecyclePanel.css +1 -1
- package/dist/NiceNetworkDiscoveryPanel.doc-B0RtGaS3.js +25 -0
- package/dist/NiceNetworkDiscoveryPanel.doc-BFgFZI5G.cjs +1 -0
- package/dist/NicePagination-8XsBbMNx.js +165 -0
- package/dist/NicePagination-B3nZDZem.js +165 -0
- package/dist/NicePagination-B8rg1Y67.cjs +1 -0
- package/dist/NicePagination-CkOoXf0f.js +165 -0
- package/dist/NicePagination-D7lek1G7.cjs +1 -0
- package/dist/NicePagination-OjTEfZJE.cjs +1 -0
- package/dist/NicePipelineEditor.doc-CjqDKe2x.js +29 -0
- package/dist/NicePipelineEditor.doc-DZ0pTVTp.cjs +5 -0
- package/dist/NicePipelineMonitor.doc-C88-TagI.cjs +5 -0
- package/dist/NicePipelineMonitor.doc-CFtH4XJx.js +29 -0
- package/dist/NicePivotGrid-BJRSciWl.js +1183 -0
- package/dist/NicePivotGrid-BaZa2YZW.js +1157 -0
- package/dist/NicePivotGrid-CS1dPmNI.cjs +152 -0
- package/dist/NicePivotGrid-D2AxqDzJ.js +1183 -0
- package/dist/NicePivotGrid-DxQ6Py9D.cjs +152 -0
- package/dist/NicePivotGrid-DyOPhPO8.cjs +152 -0
- package/dist/NiceRoomGrid.doc-DJPVUQVg.cjs +8 -0
- package/dist/NiceRoomGrid.doc-DLHJS_Wb.js +32 -0
- package/dist/NiceSavedQueryPanel-B5HhqlAI.cjs +586 -0
- package/dist/NiceSavedQueryPanel-BC84uRfh.cjs +586 -0
- package/dist/NiceSavedQueryPanel-CMStDOKe.js +5125 -0
- package/dist/NiceSavedQueryPanel-CMfcODIO.js +5120 -0
- package/dist/NiceSavedQueryPanel-D2i34e_b.cjs +586 -0
- package/dist/NiceSavedQueryPanel-mPO2THs7.js +5142 -0
- package/dist/NiceSavedQueryPanel.css +1 -1
- package/dist/NiceSceneBar.doc-09sc3yuF.cjs +1 -0
- package/dist/NiceSceneBar.doc-DLePMuVU.js +25 -0
- package/dist/NiceSceneSelector.doc-CPzCAy-d.cjs +7 -0
- package/dist/NiceSceneSelector.doc-FCLZvPc0.js +31 -0
- package/dist/NiceScheduler-7gP7vcLy.cjs +5 -0
- package/dist/NiceScheduler-BAJRzFQN.js +1690 -0
- package/dist/NiceScheduler-Cy7F9tgH.js +1693 -0
- package/dist/NiceScheduler-DquRUZxD.cjs +5 -0
- package/dist/NiceScheduler-dJ7gHDv7.cjs +5 -0
- package/dist/NiceScheduler-l8N4yCWd.js +1716 -0
- package/dist/NiceSchedulerViews.doc-C9opZpgg.cjs +1 -0
- package/dist/NiceSchedulerViews.doc-Dy7ZH1iL.js +25 -0
- package/dist/NiceSelect-CZR8Zu_k.js +420 -0
- package/dist/NiceSelect-DIKGbaJo.cjs +1 -0
- package/dist/NiceSelect-DZB1Rs9x.js +435 -0
- package/dist/NiceSelect-tMz9QQUs.cjs +1 -0
- package/dist/NiceSensorGaugePanel.doc-BHirbWLn.cjs +8 -0
- package/dist/NiceSensorGaugePanel.doc-DjKmooI6.js +32 -0
- package/dist/NiceSpotlight.doc-BVZFfDVI.cjs +10 -0
- package/dist/NiceSpotlight.doc-JqwkzrEm.js +34 -0
- package/dist/NiceStateDesigner.doc-CfnwiwfU.js +29 -0
- package/dist/NiceStateDesigner.doc-DV4zEC50.cjs +5 -0
- package/dist/NiceStepper.doc-5VjaLM6r.js +31 -0
- package/dist/NiceStepper.doc-f8lYpr33.cjs +7 -0
- package/dist/NiceStreamDashboard.doc-74KUXya1.cjs +8 -0
- package/dist/NiceStreamDashboard.doc-k8PQfCM0.js +32 -0
- package/dist/NiceTaskInbox.doc-CHrxthqp.js +32 -0
- package/dist/NiceTaskInbox.doc-CdCTfgBq.cjs +8 -0
- package/dist/NiceTestBuilder.doc-BoBzLfa0.js +30 -0
- package/dist/NiceTestBuilder.doc-Cj1fNTvk.cjs +6 -0
- package/dist/NiceTranscoder.doc-Dnirl3wg.cjs +7 -0
- package/dist/NiceTranscoder.doc-cInCYZh7.js +31 -0
- package/dist/NiceVideoAnnotator.doc-C1iEi7OM.cjs +7 -0
- package/dist/NiceVideoAnnotator.doc-C8zyfKH_.js +31 -0
- package/dist/NiceVideoEditor.doc-C6mhEb-q.cjs +7 -0
- package/dist/NiceVideoEditor.doc-lrwmKjqj.js +31 -0
- package/dist/NiceWindow-BEov3s9F.js +2094 -0
- package/dist/NiceWindow-CDt6PCEg.cjs +1 -0
- package/dist/NiceWindow-CWN8OCHF.js +2109 -0
- package/dist/NiceWindow-Dd8qjkIW.cjs +1 -0
- package/dist/NiceWindow.css +1 -1
- package/dist/charts-Bo2WAI5T.cjs +768 -0
- package/dist/charts-ByrdMeQP.js +4767 -0
- package/dist/charts-C047IMVn.cjs +768 -0
- package/dist/charts-CCXSb3xk.js +4752 -0
- package/dist/charts-CqETcUhH.js +4752 -0
- package/dist/charts-DouiiHOT.cjs +768 -0
- package/dist/charts.cjs +1 -1
- package/dist/charts.css +1 -1
- package/dist/charts.d.ts +28 -18
- package/dist/charts.mjs +1 -1
- package/dist/core-B8eBUE4m.js +438 -0
- package/dist/core-BL-KmGYC.js +795 -0
- package/dist/core-Chg-oYCr.cjs +1 -0
- package/dist/core-CxBnKAhs.cjs +1 -0
- package/dist/core-D_LRh59n.js +795 -0
- package/dist/core-lBFqvT0V.cjs +1 -0
- package/dist/core-lazy-Bh2yg4Et.js +351 -0
- package/dist/core-lazy-CkWKjfc6.cjs +1 -0
- package/dist/data-branching-Dak1_ZKR.cjs +1 -0
- package/dist/data-branching-DiLAO4Qt.js +6386 -0
- package/dist/data-branching-Km4lc8P_.cjs +1 -0
- package/dist/data-branching-YQtJJEtn.js +6273 -0
- package/dist/data-branching.cjs +1 -1
- package/dist/data-branching.mjs +1 -1
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +22 -69
- package/dist/data.mjs +3 -3
- package/dist/devops-D5yIDM3e.js +8312 -0
- package/dist/devops-DkVluHBp.cjs +17 -0
- package/dist/devops-rVpB0ZAX.cjs +17 -0
- package/dist/devops-zsMUueTd.js +8648 -0
- package/dist/devops.cjs +1 -1
- package/dist/devops.d.ts +3 -3
- package/dist/devops.mjs +1 -1
- package/dist/editors.cjs +1 -1
- package/dist/editors.d.ts +106 -63
- package/dist/editors.mjs +55 -54
- package/dist/feedback.cjs +1 -1
- package/dist/feedback.d.ts +76 -2
- package/dist/feedback.mjs +10 -9
- package/dist/index.cjs +261 -261
- package/dist/index.css +1 -1
- package/dist/index.d.ts +831 -433
- package/dist/index.mjs +27339 -26540
- package/dist/injectStyleOnce-BzC_BCs_.js +9 -0
- package/dist/injectStyleOnce-DeWaxcdf.cjs +1 -0
- package/dist/lazy.cjs +1 -1
- package/dist/lazy.d.ts +9 -7
- package/dist/lazy.mjs +55 -55
- package/dist/navigation.cjs +1 -1
- package/dist/navigation.css +1 -0
- package/dist/navigation.d.ts +99 -43
- package/dist/navigation.mjs +504 -547
- package/dist/no-code-6WyYb3hL.cjs +331 -0
- package/dist/no-code-BH5oVFC6.js +8186 -0
- package/dist/no-code-CnHG5_Vn.js +8186 -0
- package/dist/no-code-DMKlg1Zl.cjs +331 -0
- package/dist/no-code-DiTEnuRv.js +8288 -0
- package/dist/no-code-wG9c0z_T.cjs +331 -0
- package/dist/no-code.cjs +1 -1
- package/dist/no-code.css +1 -1
- package/dist/no-code.d.ts +25 -18
- package/dist/no-code.mjs +3 -3
- package/dist/overlays.cjs +1 -1
- package/dist/overlays.d.ts +36 -30
- package/dist/overlays.mjs +24 -490
- package/dist/pickerCommons-0vyK1Knv.js +547 -0
- package/dist/pickerCommons-BCRiHDE_.cjs +1 -0
- package/dist/pickerCommons-BFbItm8o.cjs +1 -0
- package/dist/pickerCommons-BHirHJyn.js +548 -0
- package/dist/pickerCommons-Bt8JIaTN.cjs +1 -0
- package/dist/pickerCommons-DkumQ3KE.js +548 -0
- package/dist/pickerCommons.css +1 -1
- package/dist/style.css +15 -9
- package/package.json +4 -6
- package/css/legacy-bg-text-aliases.css +0 -87
|
@@ -0,0 +1,586 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),pt=require("@nice2dev/i18n"),z=require("@nice2dev/ui-core"),t=require("react"),ft=require("./NiceDataGrid-BV5Oh-gy.cjs"),De=require("./NiceColorPicker-DCgmE-3H.cjs"),gt=require("./NiceForm-uCeVmTrD.cjs"),_t=require("./NiceModal-Dr1e3nQZ.cjs"),xt=require("./core-Chg-oYCr.cjs"),bt=require("./NiceSelect-tMz9QQUs.cjs"),Wn=require("./no-code-DMKlg1Zl.cjs");function yt(n,i){return n.filter(a=>i.every(s=>{const d=a[s.field],m=s.value;switch(s.operator){case"eq":return d===m;case"ne":return d!==m;case"gt":return typeof d=="number"&&typeof m=="number"&&d>m;case"gte":return typeof d=="number"&&typeof m=="number"&&d>=m;case"lt":return typeof d=="number"&&typeof m=="number"&&d<m;case"lte":return typeof d=="number"&&typeof m=="number"&&d<=m;case"contains":return String(d).toLowerCase().includes(String(m).toLowerCase());case"startsWith":return String(d).toLowerCase().startsWith(String(m).toLowerCase());case"endsWith":return String(d).toLowerCase().endsWith(String(m).toLowerCase());default:return!0}}))}function vt(n){return n.map(i=>({field:i.field,type:i.dataType||"string",label:typeof i.header=="string"?i.header:i.field}))}function Nt(n,i){const{enableAI:a=!0,aiModel:s,enableNLSearch:d=!0,enableInsights:m=!0,nlPlaceholder:f,onAIFilter:u,onInsights:C,showAISearchBar:w=!0,exampleQueries:k=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:F,data:N,...J}=n,[X,E]=t.useState(""),[g,y]=t.useState([]),[b,_]=t.useState([]),[j,M]=t.useState(!1),[P,ee]=t.useState(null),ce=t.useRef(null),{t:de}=pt.useNiceTranslation(),le=z.useNiceAI(),{parseFilter:me,isLoading:ne}=z.useNaturalLanguageFilter(),ye=a&&le.isConfigured,B=g.length>0?yt(N||[],g):N,ue=t.useCallback(async x=>{if(!ye||!d||!x.trim())return;ee(x);const l=vt(F);try{const R=await me(x,l);y(R),u?.(x,R)}catch{y([])}},[ye,d,F,me,u]),we=t.useCallback(()=>{y([]),ee(null),E("")},[]),Ne=t.useCallback(()=>g,[g]),O=t.useCallback(async()=>{if(!ye||!m||!N?.length)return[];try{const x=await le.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${N.length} total rows): ${JSON.stringify(N.slice(0,20))}
|
|
2
|
+
|
|
3
|
+
Columns: ${F.map(l=>l.field).join(", ")}
|
|
4
|
+
|
|
5
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const l=JSON.parse(x.content),R=Array.isArray(l)?l:[];return _(R),C?.(R),R}catch{return[]}}catch{return[]}},[ye,m,N,F,le,C]),V=x=>{x.preventDefault(),X.trim()&&ue(X)},h=x=>{E(x),ue(x)};return t.useImperativeHandle(i,()=>({applyNLFilter:ue,clearAIFilters:we,getAIFilters:Ne,generateInsights:O})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":n["data-testid"],children:[w&&ye&&d&&e.jsxs("div",{className:"nice-data-grid-ai__search-bar",children:[e.jsx("div",{className:"nice-data-grid-ai__search-left",children:e.jsx("span",{className:"nice-data-grid-ai__badge",children:"AI"})}),e.jsxs("form",{onSubmit:V,className:"nice-data-grid-ai__search-form",children:[e.jsxs("div",{className:"nice-data-grid-ai__input-wrapper",children:[e.jsx("span",{className:"nice-data-grid-ai__search-icon",children:e.jsx(z.NiceIcon,{name:"search",size:14})}),e.jsx("input",{ref:ce,type:"text",value:X,onChange:x=>E(x.target.value),placeholder:f||de("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:ne}),ne&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),X&&!ne&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>E(""),"aria-label":de("dataGridAI.clearInput","Clear"),children:e.jsx(z.NiceIcon,{name:"close",size:14})})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:ne||!X.trim(),children:ne?de("dataGridAI.searching","Searching..."):de("dataGridAI.search","Search")})]}),m&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{O(),M(!0)},disabled:ne||!N?.length,title:de("dataGridAI.generateInsights","Generate AI Insights"),children:[e.jsx(z.NiceIcon,{name:"lightbulb",size:14})," ",de("dataGridAI.insights","Insights")]})]}),w&&ye&&d&&!P&&k.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:de("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:k.slice(0,4).map((x,l)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>h(x),children:['"',x,'"']},l))})]}),P&&g.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__active-filter",children:[e.jsxs("div",{className:"nice-data-grid-ai__filter-info",children:[e.jsx("span",{className:"nice-data-grid-ai__filter-icon",children:e.jsx(z.NiceIcon,{name:"target",size:14})}),e.jsxs("span",{className:"nice-data-grid-ai__filter-query",children:['"',P,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",B?.length||0," ",de("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:g.map((x,l)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[x.field," ",x.operator," ",String(x.value)]},l))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:we,children:[e.jsx(z.NiceIcon,{name:"close",size:14})," ",de("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx(ft.NiceDataGrid,{columns:F,data:B,...J})}),j&&e.jsxs("div",{className:"nice-data-grid-ai__insights-panel",children:[e.jsxs("div",{className:"nice-data-grid-ai__insights-header",children:[e.jsxs("h4",{children:[e.jsx(z.NiceIcon,{name:"lightbulb",size:14})," ",de("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>M(!1),"aria-label":de("dataGridAI.closeInsights","Close"),children:e.jsx(z.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:ne?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:de("dataGridAI.analyzing","Analyzing data...")}):b.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:b.map((x,l)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),x]},l))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:de("dataGridAI.noInsights","Click to generate insights from your data")})}),e.jsx("div",{className:"nice-data-grid-ai__insights-footer",children:e.jsxs("button",{type:"button",className:"nice-data-grid-ai__refresh-insights",onClick:()=>O(),disabled:ne,children:[e.jsx(z.NiceIcon,{name:"refresh",size:14})," ",de("dataGridAI.refresh","Refresh")]})})]})]})}const jt=t.forwardRef(Nt);function wt(n,i,a){const s=new Map,d=[];n.forEach(f=>s.set(String(f[i]),{data:f,children:[],key:String(f[i]),depth:0})),n.forEach(f=>{const u=f[a],C=s.get(String(f[i]));if(u!=null&&u!==""&&s.has(String(u))){const w=s.get(String(u));C.depth=w.depth+1,w.children.push(C)}else d.push(C)});const m=(f,u)=>{f.forEach(C=>{C.depth=u,m(C.children,u+1)})};return m(d,0),d}function Qn(n,i,a,s=0){return n.map(d=>({data:d,key:String(d[a]),depth:s,children:Array.isArray(d[i])?Qn(d[i],i,a,s+1):[]}))}function kt(n){const i=[],a=s=>{s.forEach(d=>{i.push(d.key),a(d.children)})};return a(n),i}function St(n,i){const a=[],s=d=>{d.forEach(m=>{a.push(m),m.children.length>0&&i.has(m.key)&&s(m.children)})};return s(n),a}function Vn(n,i,a){return!i||!a?n:[...n].sort((d,m)=>{const f=d.data[i]??"",u=m.data[i]??"",C=typeof f=="number"&&typeof u=="number"?f-u:String(f).localeCompare(String(u));return a==="desc"?-C:C}).map(d=>({...d,children:Vn(d.children,i,a)}))}function Ct({columns:n,data:i,keyField:a="id",parentKeyField:s="parentId",nested:d=!1,childrenField:m="children",expandedKeys:f,onExpandedChange:u,defaultExpandAll:C=!1,sortable:w=!0,sortField:k,sortDirection:F,onSort:N,selectable:J,selectedKeys:X,onSelectionChange:E,searchable:g,searchPlaceholder:y,striped:b,compact:_,size:j="md",loading:M,disabled:P,readOnly:ee,error:ce,emptyText:de,toolbar:le,onRowClick:me,className:ne,style:ye}){const{t:B}=z.useNiceTranslation(),ue=t.useMemo(()=>d?Qn(i,m,a):wt(i,a,s),[i,a,s,d,m]),we=t.useMemo(()=>kt(ue),[ue]),[Ne,O]=t.useState(()=>C?new Set(we):new Set),V=f?new Set(f):Ne,[h,x]=t.useState({field:"",dir:null}),[l,R]=t.useState(new Set),[q,S]=t.useState(""),se=k??h.field,oe=F??h.dir,re=X??l,G=t.useMemo(()=>n.filter(U=>!U.hidden),[n]),_e=t.useCallback(U=>{const o=se===U?oe==="asc"?"desc":oe==="desc"?null:"asc":"asc";N?N(U,o):x({field:U,dir:o})},[se,oe,N]),Me=t.useCallback(U=>{const o=new Set(V);o.has(U)?o.delete(U):o.add(U),u?u([...o]):O(o)},[V,u]),ze=t.useCallback(U=>{const o=new Set(re);o.has(U)?o.delete(U):o.add(U),E?E(o):R(o)},[re,E]),Te=t.useMemo(()=>{if(!q)return ue;const U=q.toLowerCase(),o=pe=>pe.reduce((te,I)=>{const T=o(I.children);return(G.some(ve=>String(I.data[ve.field]??"").toLowerCase().includes(U))||T.length>0)&&te.push({...I,children:T}),te},[]);return o(ue)},[ue,q,G]),Be=t.useMemo(()=>Vn(Te,se,oe),[Te,se,oe]),Fe=t.useMemo(()=>St(Be,V),[Be,V]),ke=({field:U})=>se!==U||!oe?e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:.3},children:e.jsx(z.NiceIcon,{name:"sort",size:12})}):e.jsx("span",{className:"nice-table__sort-icon",children:e.jsx(z.NiceIcon,{name:oe==="asc"?"sort-asc":"sort-desc",size:12})});return e.jsxs("div",{className:`nice-treegrid nice-datagrid ${P?"nice-treegrid--disabled":""} ${ee?"nice-treegrid--readonly":""} ${ce?"nice-treegrid--error":""} ${ne||""}`,style:ye,"aria-disabled":P||void 0,"aria-busy":M||void 0,"aria-invalid":!!ce||void 0,children:[(g||le)&&e.jsxs("div",{className:"nice-datagrid__toolbar",children:[g&&e.jsx("div",{className:"nice-datagrid__search",children:e.jsx("input",{type:"text",value:q,onChange:U=>S(U.target.value),placeholder:y||B("controls.search","Search...")})}),le]}),e.jsx("div",{className:"nice-datagrid__table-wrap",children:e.jsxs("table",{className:`nice-table nice-table--${j} ${b?"nice-table--striped":""} ${_?"nice-table--compact":""}`,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[J&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),G.map(U=>e.jsxs("th",{style:{width:U.width,minWidth:U.minWidth,textAlign:U.align},className:w&&U.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>w&&U.sortable!==!1&&_e(U.field),children:[U.header,w&&U.sortable!==!1&&e.jsx(ke,{field:U.field})]},U.field))]})}),e.jsx("tbody",{children:M?e.jsx("tr",{children:e.jsx("td",{colSpan:G.length+(J?1:0),className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):ce?e.jsx("tr",{children:e.jsx("td",{colSpan:G.length+(J?1:0),className:"nice-datagrid__empty nice-treegrid__error",role:"alert",children:ce})}):Fe.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:G.length+(J?1:0),className:"nice-datagrid__empty",children:de||B("controls.noData","No data available")})}):Fe.map((U,o)=>{const pe=re.has(U.key),te=U.children.length>0,I=V.has(U.key);return e.jsxs("tr",{className:pe?"nice-datagrid__row--selected":void 0,onClick:()=>{ee||me?.(U.data)},style:me&&!ee?{cursor:"pointer"}:void 0,children:[J&&e.jsx("td",{className:"nice-datagrid__checkbox",onClick:T=>T.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:pe,onChange:()=>ze(U.key),disabled:ee,"aria-label":`Select row ${U.key}`})}),G.map((T,H)=>e.jsxs("td",{style:{textAlign:T.align},children:[H===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{display:"inline-block",width:U.depth*20}}),e.jsx("button",{className:`nice-treegrid__toggle ${te?"":"nice-treegrid__toggle--leaf"}`,onClick:ve=>{ve.stopPropagation(),te&&Me(U.key)},tabIndex:te?0:-1,"aria-expanded":te?I:void 0,"aria-label":te?I?"Collapse":"Expand":void 0,children:te?e.jsx(z.NiceIcon,{name:I?"chevron-down":"chevron-right",size:12}):""})]}),T.render?T.render(U.data[T.field],U.data,o):String(U.data[T.field]??"")]},T.field))]},U.key)})})]})})]})}function It(n,i,a){const s=new Map,d=[];return n.forEach(m=>{const f={...m,children:[]};s.set(String(f[i]),f)}),n.forEach(m=>{const f=m[a];f!=null&&s.has(String(f))?s.get(String(f)).children.push(s.get(String(m[i]))):d.push(s.get(String(m[i])))}),d}function Dt({columns:n,data:i,keyField:a="key",parentKeyField:s="parentKey",expandedKeys:d,onExpandedChange:m,selectedKeys:f=[],onSelectionChange:u,selectable:C,sortable:w,loading:k,emptyText:F,className:N,style:J,accessMode:X,id:E}){const y=z.useNiceAccessMode(X,E)==="hidden",{t:b}=z.useNiceTranslation(),[_,j]=t.useState([]),M=d??_,[P,ee]=t.useState(f),ce=u?f:P,de=t.useMemo(()=>It(i,a,s),[i,a,s]),le=t.useMemo(()=>n.filter(h=>!h.hidden),[n]),[me,ne]=t.useState(null),ye=t.useCallback(h=>{ne(x=>x?.field===h?x.dir==="asc"?{field:h,dir:"desc"}:null:{field:h,dir:"asc"})},[]),B=t.useCallback(h=>me?[...h].sort((l,R)=>{const q=l[me.field]??"",S=R[me.field]??"",se=typeof q=="number"?q-S:String(q).localeCompare(String(S));return me.dir==="desc"?-se:se}).map(l=>l.children&&l.children.length?{...l,children:B(l.children)}:l):h,[me]),ue=t.useMemo(()=>B(de),[de,B]),we=t.useCallback(h=>{const x=M.includes(h)?M.filter(l=>l!==h):[...M,h];m?m(x):j(x)},[M,m]),Ne=t.useCallback(h=>{const x=[],l=R=>{R.children?.forEach(q=>{x.push(String(q[a])),l(q)})};return l(h),x},[a]),O=t.useCallback(h=>{const x=[String(h[a]),...Ne(h)],R=x.every(q=>ce.includes(q))?ce.filter(q=>!x.includes(q)):Array.from(new Set([...ce,...x]));u?u(R):ee(R)},[ce,u,a,Ne]),V=(h,x)=>{const l=String(h[a]),R=!!(h.children&&h.children.length>0),q=M.includes(l),S=R?Ne(h):[],se=S.filter(G=>ce.includes(G)).length,oe=R&&S.length>0?se===S.length:ce.includes(l),re=R&&se>0&&se<S.length;return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:oe?"nice-treelist__row--selected":"",children:[C&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:oe,ref:G=>{G&&(G.indeterminate=re)},onChange:()=>O(h)})}),le.map((G,_e)=>e.jsxs("td",{style:{textAlign:G.align},children:[_e===0&&e.jsx("span",{style:{display:"inline-block",width:x*20}}),_e===0&&e.jsx("span",{className:"nice-treelist__toggle",onClick:()=>R&&we(l),style:{cursor:R?"pointer":"default",width:20,display:"inline-block"},children:R?e.jsx(z.NiceIcon,{name:q?"chevron-down":"chevron-right",size:12}):""}),G.render?G.render(h[G.field],h,0):String(h[G.field]??"")]},G.field))]}),R&&q&&h.children.map(G=>V(G,x+1))]},l)};return y?null:e.jsx("div",{className:`nice-treelist ${N||""}`,style:J,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[C&&e.jsx("th",{className:"nice-treelist__checkbox"}),le.map(h=>{const x=!!w&&!!h.sortable;return e.jsxs("th",{style:{width:h.width,minWidth:h.minWidth,textAlign:h.align},className:x?"nice-treelist__th--sortable":void 0,onClick:()=>x&&ye(h.field),scope:"col","aria-sort":x?me?.field===h.field?me.dir==="asc"?"ascending":"descending":"none":void 0,children:[h.header,x&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(z.NiceIcon,{name:me?.field===h.field?me.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},h.field)})]})}),e.jsx("tbody",{children:k?e.jsx("tr",{children:e.jsx("td",{colSpan:le.length+(C?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):de.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:le.length+(C?1:0),className:"nice-treelist__empty",children:F||b("controls.noData","No data available")})}):ue.map(h=>V(h,0))})]})})}function qn(n){const i=[];if(n.children)for(const a of n.children)i.push(a.key),i.push(...qn(a));return i}function Pn(n,i){if(!n.children||n.children.length===0)return i.has(n.key)?"checked":"unchecked";let a=!0,s=i.has(n.key);for(const d of n.children){const m=Pn(d,i);m==="checked"?s=!0:(m==="indeterminate"&&(s=!0),a=!1)}return a&&s?"checked":s?"indeterminate":"unchecked"}const Mt=[],At=({nodes:n=Mt,header:i,selectedKeys:a=[],expandedKeys:s,onSelectionChange:d,onExpandedChange:m,selectionMode:f="none",showCheckboxes:u,searchable:C,searchPlaceholder:w,onNodeClick:k,renderNode:F,showLines:N,loading:J,className:X,style:E,accessMode:g,id:y,draggable:b,onNodeDrop:_,onLoadChildren:j,contextMenuItems:M,onContextMenuAction:P,editable:ee,onNodeEdit:ce,maxDepth:de})=>{const me=z.useNiceAccessMode(g,y)==="hidden",{t:ne}=z.useNiceTranslation(),[ye,B]=t.useState([]),[ue,we]=t.useState(""),[Ne,O]=t.useState(new Set),[V,h]=t.useState(new Map),[x,l]=t.useState(null),[R,q]=t.useState(null),[S,se]=t.useState(null),[oe,re]=t.useState(""),G=t.useRef(null),_e=s??ye,Me=t.useMemo(()=>new Set(a),[a]),ze=t.useCallback(async(o,pe)=>{const te=!_e.includes(o),I=te?[..._e,o]:_e.filter(T=>T!==o);if(m?m(I):B(I),te&&j&&!pe.children?.length&&pe.leaf!==!0&&!V.has(o)){O(H=>new Set(H).add(o));const T=await j(pe);h(H=>new Map(H).set(o,T)),O(H=>{const ve=new Set(H);return ve.delete(o),ve})}},[_e,m,j,V]),Te=t.useCallback((o,pe)=>{if(d){if(f==="single")d(a.includes(o)?[]:[o]);else if(f==="multiple")if(u&&pe.children?.length){const te=qn(pe),I=[o,...te];if(Pn(pe,Me)==="checked")d(a.filter(H=>!I.includes(H)));else{const H=new Set([...a,...I]);d(Array.from(H))}}else d(a.includes(o)?a.filter(te=>te!==o):[...a,o])}},[a,f,d,u,Me]),Be=t.useCallback(o=>{if(!ue)return!0;const pe=ue.toLowerCase();return o.text.toLowerCase().includes(pe)?!0:(V.get(o.key)??o.children)?.some(I=>Be(I))??!1},[ue,V]),Fe=t.useCallback((o,pe)=>{M?.length&&(o.preventDefault(),q({x:o.clientX,y:o.clientY,node:pe}))},[M]),ke=t.useCallback(()=>{S&&ce&&ce(S,oe),se(null)},[S,oe,ce]),U=(o,pe)=>{if(ue&&!Be(o))return null;const te=typeof de=="number"?Math.min(10,Math.max(1,de)):1/0,I=pe+1>=te,T=I?void 0:V.get(o.key)??o.children,H=!I&&(T&&T.length>0||o.leaf!==!0&&j&&!T?.length),ve=_e.includes(o.key),Ie=Me.has(o.key),fe=Ne.has(o.key),ie=u&&f==="multiple"&&T?.length?Pn(o,Me):Ie?"checked":"unchecked",Ge=Math.min(pe+1,10),un={paddingLeft:pe*20+4,"--nice-row-bg":`var(--nice-tree-level-${Ge}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${Ge}-text, inherit)`,"--nice-row-border":`var(--nice-tree-level-${Ge}-border, transparent)`,"--nice-row-hover-bg":`var(--nice-tree-level-${Ge}-hover-bg, var(--nice-hover-bg, color-mix(in srgb, var(--nice-text-primary) 6%, transparent)))`,"--nice-row-active-bg":`var(--nice-tree-level-${Ge}-active-bg, color-mix(in srgb, var(--nice-color-primary) 14%, transparent))`};return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-expanded":H?ve:void 0,"data-nice-depth":Ge,draggable:b&&!o.disabled,onDragStart:b?K=>{K.stopPropagation(),l(o.key)}:void 0,onDragOver:b?K=>{K.preventDefault(),K.stopPropagation()}:void 0,onDrop:b&&x?K=>{K.stopPropagation(),_?.(x,o.key,"inside"),l(null)}:void 0,onDragEnd:b?()=>l(null):void 0,children:[e.jsxs("div",{className:`nice-tree__row ${Ie?"nice-tree__row--selected":""} ${o.disabled?"nice-tree__row--disabled":""} ${x===o.key?"nice-tree__row--dragging":""}`,style:un,onClick:()=>{o.disabled||(Te(o.key,o),k?.(o))},onContextMenu:K=>Fe(K,o),onDoubleClick:ee&&!o.disabled?()=>{se(o.key),re(o.text)}:void 0,children:[e.jsx("span",{className:`nice-tree__toggle ${H?ve?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:K=>{K.stopPropagation(),H&&ze(o.key,o)},children:fe?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):H?ve?e.jsx(z.NiceIcon,{name:"chevron-down",size:12}):e.jsx(z.NiceIcon,{name:"chevron-right",size:12}):""}),u&&f!=="none"&&e.jsx("input",{type:"checkbox",checked:ie==="checked",ref:K=>{K&&(K.indeterminate=ie==="indeterminate")},onChange:()=>Te(o.key,o),onClick:K=>K.stopPropagation(),tabIndex:-1,className:"nice-tree__checkbox"}),S===o.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:oe,onChange:K=>re(K.target.value),onBlur:ke,onKeyDown:K=>{K.key==="Enter"&&ke(),K.key==="Escape"&&se(null)},autoFocus:!0,onClick:K=>K.stopPropagation()}):F?F(o):e.jsxs(e.Fragment,{children:[o.icon&&e.jsx("span",{className:"nice-tree__icon",children:o.icon}),e.jsx("span",{className:"nice-tree__text",children:o.text})]})]}),T&&T.length>0&&ve&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:T.map(K=>U(K,pe+1))})]},o.key)};return me?null:e.jsxs("div",{className:`nice-tree ${N?"nice-tree--lines":""} ${X||""}`,style:E,ref:G,onClick:()=>q(null),children:[i!=null&&i!==!1&&e.jsx("div",{className:"nice-tree__header",children:i}),C&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:ue,onChange:o=>we(o.target.value),placeholder:w||ne("controls.search","Search..."),"aria-label":w||ne("controls.search","Search tree")})}),J?e.jsx("div",{className:"nice-tree__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):e.jsx("ul",{className:"nice-tree__root",role:"tree",children:n.map(o=>U(o,0))}),R&&M&&e.jsx("div",{className:"nice-tree__context-menu",style:{position:"fixed",top:R.y,left:R.x,zIndex:9999},children:M.map(o=>e.jsxs("div",{className:`nice-tree__context-item ${o.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{o.disabled||(P?.(o.key,R.node),q(null))},children:[o.icon&&e.jsx("span",{children:o.icon}),o.label]},o.key))})]})},Rt=({items:n,selectedKeys:i=[],onSelectionChange:a,selectionMode:s="none",searchable:d,searchPlaceholder:m,grouped:f,groupField:u="group",reorderable:C,onReorder:w,onItemClick:k,renderItem:F,showCheckboxes:N,loading:J,emptyText:X,size:E="md",header:g,disabled:y,readOnly:b,error:_,bordered:j=!0,swipeActions:M,className:P,style:ee,accessMode:ce,id:de})=>{const me=z.useNiceAccessMode(ce,de)==="hidden",{t:ne}=z.useNiceTranslation(),[ye,B]=t.useState(""),[ue,we]=t.useState(null),[Ne,O]=t.useState(null),V=t.useRef(null),h=t.useMemo(()=>{if(!ye)return n;const S=ye.toLowerCase();return n.filter(se=>se.text.toLowerCase().includes(S))},[n,ye]),x=t.useMemo(()=>{if(!f)return null;const S=new Map;return h.forEach(se=>{const oe=String(se[u]??"");S.has(oe)||S.set(oe,[]),S.get(oe).push(se)}),S},[h,f,u]),l=t.useCallback(S=>{a&&(s==="single"?a(i.includes(S)?[]:[S]):s==="multiple"&&a(i.includes(S)?i.filter(se=>se!==S):[...i,S]))},[i,s,a]),R=t.useCallback(S=>{ue!==null&&ue!==S&&w&&w(ue,S),we(null)},[ue,w]),q=(S,se)=>{const oe=i.includes(S.key),re=Ne===S.key;return e.jsxs("li",{className:`nice-list__item ${oe?"nice-list__item--selected":""} ${S.disabled?"nice-list__item--disabled":""} ${re?"nice-list__item--swiped":""}`,onClick:()=>{!S.disabled&&!y&&!b&&(l(S.key),k?.(S))},draggable:C&&!y&&!b,onDragStart:()=>we(se),onDragOver:G=>G.preventDefault(),onDrop:()=>R(se),onTouchStart:M?.length?G=>{V.current={x:G.touches[0].clientX,key:S.key}}:void 0,onTouchEnd:M?.length?G=>{if(!V.current)return;const _e=G.changedTouches[0].clientX-V.current.x;_e<-50&&V.current.key===S.key?O(S.key):_e>50&&O(null),V.current=null}:void 0,role:s!=="none"?"option":void 0,"aria-selected":s!=="none"?oe:void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[N&&s!=="none"&&e.jsx("input",{type:"checkbox",checked:oe,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),F?F(S):e.jsxs(e.Fragment,{children:[S.icon&&e.jsx("span",{className:"nice-list__icon",children:S.icon}),e.jsx("span",{className:"nice-list__text",children:S.text}),S.badge&&e.jsx("span",{className:"nice-list__badge",children:S.badge})]})]}),M&&re&&e.jsx("div",{className:"nice-list__swipe-actions",children:M.map(G=>e.jsx("button",{className:"nice-list__swipe-btn",style:G.color?{backgroundColor:G.color}:void 0,onClick:_e=>{_e.stopPropagation(),G.onClick(S),O(null)},children:G.label},G.key))})]},S.key)};return me?null:e.jsxs("div",{className:`nice-list nice-list--${E} ${j?"nice-list--bordered":""} ${y?"nice-list--disabled":""} ${b?"nice-list--readonly":""} ${_?"nice-list--error":""} ${P||""}`,style:ee,"aria-disabled":y||void 0,"aria-busy":J||void 0,children:[g&&e.jsx("div",{className:"nice-list__header",children:g}),d&&!J&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:ye,onChange:S=>B(S.target.value),placeholder:m||ne("controls.search","Search...")})}),J?e.jsx("div",{className:"nice-list__loading",role:"status","aria-live":"polite",children:e.jsx("div",{className:`nice-spinner nice-spinner--${E}`})}):_?e.jsx("div",{className:"nice-list__error",role:"alert",children:_}):h.length===0?e.jsx("div",{className:"nice-list__empty",children:X||ne("controls.noData","No data available")}):x?e.jsx("div",{role:"listbox",children:Array.from(x.entries()).map(([S,se])=>e.jsxs("div",{className:"nice-list__group",children:[e.jsx("div",{className:"nice-list__group-header",children:S}),e.jsx("ul",{className:"nice-list__items",children:se.map((oe,re)=>q(oe,re))})]},S))}):e.jsx("ul",{className:"nice-list__items",role:"listbox",children:h.map((S,se)=>q(S,se))})]})};function Et({columns:n,data:i,striped:a,compact:s,size:d="md",emptyText:m,className:f,style:u,accessMode:C,id:w,displayStyle:k}){const F=z.normalizeSize(d),J=z.useNiceAccessMode(C,w)==="hidden",X=z.useComponentDisplayStyle("table",k),E=z.useComponentDisplayClass("table",k),[g,y]=t.useState(null),b=t.useMemo(()=>g?[...i].sort((j,M)=>{const P=j[g.field]??"",ee=M[g.field]??"",ce=typeof P=="number"?P-ee:String(P).localeCompare(String(ee));return g.dir==="desc"?-ce:ce}):i,[i,g]),_=j=>{y(M=>M?.field===j?M.dir==="asc"?{field:j,dir:"desc"}:null:{field:j,dir:"asc"})};return J?null:e.jsx("div",{className:`nice-table-wrapper ${f||""}`,style:{...X,...u},children:e.jsxs("table",{className:`nice-table nice-table--ds-${E} nice-table--${F} ${a?"nice-table--striped":""} ${s?"nice-table--compact":""}`,"aria-rowcount":b.length,"aria-colcount":n.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:n.map(j=>{const M=j.sortable?g?.field===j.field?g.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:j.width,textAlign:j.align},className:j.sortable?"th--sortable":void 0,onClick:()=>j.sortable&&_(j.field),scope:"col","aria-sort":M,children:[j.header,j.sortable&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(z.NiceIcon,{name:g?.field===j.field?g.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},j.field)})})}),e.jsx("tbody",{children:b.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:n.length,className:"nice-table__empty",children:m||"No data"})}):b.map((j,M)=>e.jsx("tr",{children:n.map(P=>e.jsx("td",{style:{textAlign:P.align},children:P.render?P.render(j[P.field],j):String(j[P.field]??"")},P.field))},M))})]})})}function zt({items:n,tileWidth:i=180,tileHeight:a=180,direction:s="horizontal",renderTile:d,onTileClick:m,loading:f,emptyText:u,className:C,style:w}){const{t:k}=z.useNiceTranslation();return e.jsx("div",{className:`nice-tileview nice-tileview--${s} ${C||""}`,style:w,children:f?e.jsx("div",{className:"nice-tileview__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--md"})}):n.length===0?e.jsx("div",{className:"nice-tileview__empty",children:u||k("controls.noData","No data available")}):e.jsx("div",{className:"nice-tileview__container",style:{display:"flex",flexWrap:"wrap",gap:8,flexDirection:s==="vertical"?"column":"row"},children:n.map(F=>e.jsx("div",{className:"nice-tileview__tile",style:{width:i,height:a,cursor:m?"pointer":void 0},onClick:()=>m?.(F),children:d?d(F):e.jsxs(e.Fragment,{children:[F.image&&e.jsx("img",{src:F.image,alt:F.text||"",className:"nice-tileview__image"}),F.text&&e.jsx("div",{className:"nice-tileview__label",children:F.text})]})},F.key))})})}function Tt({open:n}){return e.jsx("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",style:{transition:"transform 160ms ease",transform:n?"rotate(0deg)":"rotate(-90deg)"},children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function $t(){return e.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}const Lt=[{target:".nice-kanban",titleKey:"tutorial.kanbanBoard.intro.title",title:"Kanban board",contentKey:"tutorial.kanbanBoard.intro.content",content:'Drag cards between columns to change their status, add cards with the "+" button, and click a card to edit its details.',placement:"auto"}],Hn=t.forwardRef(({columns:n,cards:i,onCardMove:a,onCardClick:s,renderCard:d,onAddCard:m,disabled:f=!1,size:u="md",collapsible:C=!1,collapseDirection:w="vertical",layoutMode:k="scroll",viewMode:F,onViewModeChange:N,collapsedColumns:J,onCollapsedColumnsChange:X,formItems:E,formColumns:g=1,formProps:y,editCardTitle:b,newCardTitle:_,onCardEdit:j,onCardCreate:M,onCardDelete:P,tutorial:ee,cookies:ce=!1,localStorage:de=!0,sessionStorage:le=!1,storageMode:me,storageKey:ne,className:ye,style:B,id:ue,...we},Ne)=>{const{t:O}=z.useNiceTranslation(),[V,h]=t.useState(null),[x,l]=t.useState(null),[R,q]=t.useState(null),S=!!E&&(!!j||!!M),se=t.useCallback(I=>{if(S&&j){q({key:I.key,data:{...I},column:I.column});return}s?.(I)},[S,s,j]),oe=t.useCallback(I=>{if(S&&M){q({key:null,data:{title:"",description:""},column:I});return}m?.(I)},[S,m,M]),re=xt.useStorageAdapter(ne??"nice-kanban"),[G,_e]=t.useState(()=>re.get("state")??{collapsedColumns:[],viewMode:"default"}),Me=J??G.collapsedColumns??[],ze=F??G.viewMode??"default",Te=t.useCallback(I=>{_e(T=>{const H={...T,...I};return re.set("state",H),H})},[re]),Be=t.useCallback(I=>{const T=Me.includes(I)?Me.filter(H=>H!==I):[...Me,I];X?X(T):Te({collapsedColumns:T})},[Me,X,Te]);t.useCallback(I=>{N?N(I):Te({viewMode:I})},[N,Te]);const Fe=t.useCallback(I=>i.filter(T=>T.column===I).sort((T,H)=>(T.order??0)-(H.order??0)),[i]),ke=t.useCallback((I,T)=>{f||(I.dataTransfer.effectAllowed="move",I.dataTransfer.setData("text/plain",String(T.key)),h({cardKey:T.key,fromColumn:T.column}))},[f]),U=t.useCallback((I,T)=>{I.preventDefault(),I.dataTransfer.dropEffect="move",l({column:T})},[]),o=t.useCallback(()=>{l(null)},[]),pe=t.useCallback((I,T)=>{if(I.preventDefault(),l(null),!V||f)return;const H=Fe(T);a?.(V.cardKey,T,H.length),h(null)},[V,f,Fe,a]),te=t.useCallback(()=>{h(null),l(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:Ne,id:ue,className:`nice-kanban nice-kanban--${u} nice-kanban--${ze} nice-kanban--layout-${k} ${f?"nice-kanban--disabled":""} ${ye||""}`,style:{position:"relative",...B},...we,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(z.NiceTutorialButton,{steps:z.resolveTutorial(ee,Lt)})}),n.map(I=>{const T=Fe(I.key),H=x?.column===I.key,ve=I.limit!=null&&T.length>=I.limit,Ie=C&&Me.includes(I.key);return e.jsxs("div",{className:`nice-kanban__column ${H?"nice-kanban__column--dragover":""} ${Ie?`nice-kanban__column--collapsed nice-kanban__column--collapse-${w}`:""}`,onDragOver:fe=>!Ie&&U(fe,I.key),onDragLeave:o,onDrop:fe=>!Ie&&pe(fe,I.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:I.color?{borderTopColor:I.color}:void 0,onClick:C?()=>Be(I.key):void 0,role:C?"button":void 0,tabIndex:C?0:void 0,onKeyDown:C?fe=>{(fe.key==="Enter"||fe.key===" ")&&Be(I.key)}:void 0,children:[C&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:e.jsx(Tt,{open:!Ie})}),e.jsx("span",{className:"nice-kanban__column-title",children:I.title}),e.jsx("span",{className:"nice-kanban__column-count",children:I.limit!=null?e.jsxs("span",{className:"nice-kanban__count-frac",children:[e.jsx("span",{className:"nice-kanban__count-num",children:T.length}),e.jsx("span",{className:"nice-kanban__count-slash",children:"/"}),e.jsx("span",{className:"nice-kanban__count-den",children:I.limit})]}):T.length})]}),!Ie&&e.jsxs("div",{className:"nice-kanban__column-body",children:[T.map(fe=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${ze} ${V?.cardKey===fe.key?"nice-kanban__card--dragging":""}`,draggable:!f,onDragStart:ie=>ke(ie,fe),onDragEnd:te,onClick:()=>se(fe),role:"article",children:d?d(fe):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:fe.title}),ze!=="compact"&&fe.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:fe.description})]})},fe.key)),T.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:O("kanban.empty","No cards")})]}),!Ie&&(m||S&&M)&&!ve&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>oe(I.key),disabled:f,children:[e.jsx($t,{})," ",O("kanban.addCard","Add card")]})]},I.key)})]}),S&&R&&e.jsxs(_t.NiceModal,{open:!0,onClose:()=>q(null),title:R.key==null?_||O("kanban.newCard","New card"):b||O("kanban.editCard","Edit card"),children:[e.jsx(gt.NiceForm,{items:E,data:R.data,columns:g,...y,onFieldChange:(I,T)=>q(H=>H&&{...H,data:{...H.data,[I]:T}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[R.key!=null&&P&&e.jsx(De.NiceButton,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{P(R.key),q(null)},children:O("controls.delete","Delete")}),e.jsx(De.NiceButton,{type:"button",size:"sm",variant:"secondary",onClick:()=>q(null),children:O("controls.cancel","Cancel")}),e.jsx(De.NiceButton,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(R.key==null){const I={key:`card-${Date.now()}`,title:"",column:R.column,...R.data};M?.(I)}else j?.(R.key,{...R.data,key:R.key,column:R.column});q(null)},children:O("controls.save","Save")})]})]})]})});Hn.displayName="NiceKanbanBoard";function tn(...n){return n.filter(Boolean).map(i=>typeof i=="object"?Object.entries(i).filter(([,a])=>a).map(([a])=>a).join(" "):i).join(" ")}const Pt=50,Ot=[10,25,50,100,200],Bt=40,Ft={compact:32,normal:Bt,comfortable:48},Ut=10,Wt=768,Gt=500,Kt=10;function qe(n,i){return i.split(".").reduce((a,s)=>a?.[s],n)}function Zn(n){return n.width==="auto"?{flex:"1 1 0",minWidth:n.minWidth??80,maxWidth:n.maxWidth}:{width:n.width||150,minWidth:n.minWidth,maxWidth:n.maxWidth}}function wn(n,i,a="pl-PL"){if(n==null)return"—";switch(i.type){case"number":return new Intl.NumberFormat(a,{minimumFractionDigits:i.format?.includes(".")?i.format.split(".")[1].length:0}).format(n);case"currency":return new Intl.NumberFormat(a,{style:"currency",currency:i.currencyCode||"PLN"}).format(n);case"percent":return new Intl.NumberFormat(a,{style:"percent",minimumFractionDigits:0,maximumFractionDigits:2}).format(n/100);case"date":return new Intl.DateTimeFormat(a,{dateStyle:"short"}).format(new Date(n));case"datetime":return new Intl.DateTimeFormat(a,{dateStyle:"short",timeStyle:"short"}).format(new Date(n));case"boolean":return n?e.jsx(z.NiceIcon,{name:"check",size:14}):e.jsx(z.NiceIcon,{name:"close",size:14});case"enum":return i.enumOptions?.find(d=>d.value===n)?.label||String(n);default:return String(n)}}function Qt(n,i,a,s){const[d,m]=t.useState(0),{startIndex:f,endIndex:u,totalHeight:C,offsetY:w}=t.useMemo(()=>{const N=n.length*a,J=Math.ceil(i/a),X=Math.max(0,Math.floor(d/a)-s),E=Math.min(n.length,Math.ceil(d/a)+J+s),g=X*a;return{startIndex:X,endIndex:E,totalHeight:N,offsetY:g}},[n.length,i,a,d,s]),k=t.useMemo(()=>n.slice(f,u),[n,f,u]),F=t.useCallback(N=>{m(N.currentTarget.scrollTop)},[]);return{visibleData:k,totalHeight:C,offsetY:w,handleScroll:F,startIndex:f}}function Vt(n,i){const[a,s]=t.useState(()=>{if(n&&typeof window<"u"){const m=localStorage.getItem(`nice-module-grid-${n}`);if(m)return JSON.parse(m)}return i||{}}),d=t.useCallback(m=>{s(f=>{const u={...f,...m};return n&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${n}`,JSON.stringify(u)),u})},[n]);return[a,d]}function qt(n){const[i,a]=t.useState(typeof window<"u"&&window.innerWidth<n);return t.useEffect(()=>{if(typeof window>"u")return;const s=()=>a(window.innerWidth<n);return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[n]),i}function Ht({column:n,sort:i,onSort:a,onResize:s,resizable:d,t:m}){const f=t.useRef(null),[u,C]=t.useState(!1),w=t.useCallback(N=>{if(!d||!s)return;N.preventDefault(),C(!0);const J=N.clientX,X=n.width||150,E=y=>{const b=y.clientX-J,_=Math.max(n.minWidth||50,X+b);s(n.field,Math.min(_,n.maxWidth||1/0))},g=()=>{C(!1),document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",g)};document.addEventListener("mousemove",E),document.addEventListener("mouseup",g)},[n,d,s]),k=i?.direction,F=k==="asc"?e.jsx(z.NiceIcon,{name:"sort-asc",size:12}):k==="desc"?e.jsx(z.NiceIcon,{name:"sort-desc",size:12}):null;return e.jsxs("div",{className:tn("nice-module-grid__header-cell",n.sortable&&"nice-module-grid__header-cell--sortable",u&&"nice-module-grid__header-cell--resizing"),style:{...Zn(n),textAlign:n.align},onClick:()=>n.sortable&&a?.(n.field),role:"columnheader","aria-sort":k==="asc"?"ascending":k==="desc"?"descending":"none",title:n.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:n.header}),F&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:F}),d&&e.jsx("div",{ref:f,className:"nice-module-grid__resize-handle",onMouseDown:w})]})}function Zt({column:n,row:i,rowIndex:a,value:s,locale:d="pl-PL",onClick:m}){const f=z.useAccessibleClick({onClick:m}),u=m?f:{},C={...Zn(n),textAlign:n.align};if(n.render)return e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:n.render(s,i,a)});if((n.type==="enum"||n.type==="badge")&&n.enumOptions){const w=n.enumOptions.find(k=>k.value===s);if(w)return e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:e.jsxs("span",{className:tn("nice-module-grid__badge",`nice-module-grid__badge--${w.color||"default"}`),children:[w.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:w.icon}),w.label]})})}if(n.type==="progress"){const w=Math.min(100,Math.max(0,Number(s)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:"nice-module-grid__progress-bar",children:e.jsx("div",{className:tn("nice-module-grid__progress-fill",`nice-module-grid__progress-fill--${n.progressColor||"primary"}`),style:{width:`${w}%`}})}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[w,"%"]})]})})}if(n.type==="rating"){const w=n.maxRating||5,k=Number(s)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":`${k} out of ${w} stars`,children:Array.from({length:w},(F,N)=>e.jsx("span",{className:tn("nice-module-grid__rating-star",N<k&&"nice-module-grid__rating-star--filled"),children:e.jsx(z.NiceIcon,{name:"star",size:14})},N))})})}if(n.type==="link"&&n.linkTemplate){const w=n.linkTemplate.replace(/\{\{(\w+)\}\}/g,(k,F)=>String(qe(i,F)??""));return e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:e.jsx("a",{href:w,target:n.linkNewTab?"_blank":void 0,rel:n.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:wn(s,n,d)})})}if(n.type==="image"){const k={xs:24,sm:32,md:48,lg:64}[n.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:s?e.jsx("img",{src:String(s),alt:"",className:"nice-module-grid__image",style:{width:k,height:k}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:k,height:k}})})}return n.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:s?e.jsx("img",{src:String(s),alt:"",className:"nice-module-grid__avatar"}):e.jsx("div",{className:"nice-module-grid__avatar-placeholder",children:"?"})}):n.type==="color"?e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:e.jsx("span",{className:"nice-module-grid__color-swatch",style:{backgroundColor:s||"transparent"},title:s})}):n.type==="boolean"?e.jsx("div",{className:"nice-module-grid__cell",style:{...C,textAlign:n.align||"center"},...u,children:e.jsx("span",{className:tn("nice-module-grid__boolean",!!s&&"nice-module-grid__boolean--true"),children:e.jsx(z.NiceIcon,{name:s?"check":"close",size:14})})}):e.jsx("div",{className:"nice-module-grid__cell",style:C,...u,children:wn(s,n,d)})}function Xt({row:n,index:i,columns:a,primaryField:s,secondaryField:d,customRender:m,selected:f,onClick:u,locale:C="pl-PL",t:w}){if(m)return e.jsx("div",{className:tn("nice-module-grid__mobile-card",f&&"nice-module-grid__mobile-card--selected"),onClick:u,children:m(n,i)});const k=a.find(N=>N.field===s)||a[0],F=a.find(N=>N.field===d)||a[1];return e.jsxs("div",{className:tn("nice-module-grid__mobile-card",f&&"nice-module-grid__mobile-card--selected"),onClick:u,role:"row","aria-selected":f,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:wn(qe(n,k?.field||""),k,C)}),F&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:wn(qe(n,F.field),F,C)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:a.filter(N=>!N.hidden&&N.field!==s&&N.field!==d).slice(0,4).map(N=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:N.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:wn(qe(n,N.field),N,C)})]},N.field))})]})}function Yt({page:n,pageSize:i,totalRows:a,pageSizeOptions:s,onPageChange:d,t:m}){const f=Math.ceil(a/i),u=(n-1)*i+1,C=Math.min(n*i,a);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":m("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[m("pagination.showing","Showing")," ",u,"–",C," ",m("pagination.of","of")," ",a]}),e.jsxs("div",{className:"nice-module-grid__pagination-controls",children:[e.jsx("select",{className:"nice-module-grid__page-size-select",value:i,onChange:w=>d(1,Number(w.target.value)),"aria-label":m("pagination.rowsPerPage","Rows per page"),children:s.map(w=>e.jsx("option",{value:w,children:w},w))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(1,i),disabled:n===1,"aria-label":m("pagination.first","First"),children:e.jsx(z.NiceIcon,{name:"skip-back",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(n-1,i),disabled:n===1,"aria-label":m("pagination.previous","Previous"),children:e.jsx(z.NiceIcon,{name:"chevron-left",size:14})}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[n," / ",f]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(n+1,i),disabled:n>=f,"aria-label":m("pagination.next","Next"),children:e.jsx(z.NiceIcon,{name:"chevron-right",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>d(f,i),disabled:n>=f,"aria-label":m("pagination.last","Last"),children:e.jsx(z.NiceIcon,{name:"skip-forward",size:14})})]})]})}function Jt({columns:n}){return e.jsx("div",{className:"nice-module-grid__row nice-module-grid__row--skeleton",role:"row",children:n.filter(i=>!i.hidden).map(i=>e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--skeleton",style:{width:i.width==="auto"?"auto":i.width||150},children:e.jsx("div",{className:"nice-module-grid__skeleton-bar"})},i.field))})}function ei(n,i){const{columns:a,data:s,keyField:d="id",dataSource:m,onFetch:f,sortable:u=!0,sort:C,onSortChange:w,multiSort:k=!1,filterable:F=!1,filter:N,onFilterChange:J,searchText:X,onSearchChange:E,searchPlaceholder:g,pagination:y=!0,page:b,pageSize:_,pageSizeOptions:j=Ot,totalRows:M,onPageChange:P,virtualScroll:ee=!0,rowHeight:ce,overscan:de=Ut,selectionMode:le="none",selectedKeys:me,onSelectionChange:ne,columnReorder:ye=!0,onColumnOrderChange:B,columnResize:ue=!0,onColumnWidthChange:we,groupBy:Ne,onGroupByChange:O,groupRowRender:V,expandAllGroups:h=!1,editable:x=!1,onCellEdit:l,onRowEdit:R,editMode:q="cell",contextMenuItems:S,onContextMenuAction:se,exportable:oe=!0,exportFormats:re=["csv","excel"],onExport:G,preferencesKey:_e,initialPreferences:Me,onPreferencesChange:ze,density:Te="normal",striped:Be=!0,bordered:Fe=!1,hoverable:ke=!0,loading:U=!1,emptyState:o,toolbar:pe,onRowClick:te,onRowDoubleClick:I,rowClassName:T,rowStyle:H,mobileCardView:ve=!0,mobileBreakpoint:Ie=Wt,mobileCardRender:fe,mobilePrimaryField:ie,mobileSecondaryField:Ge,moduleId:un,permissions:K,size:an="medium",skeletonLoading:Xe=!0,skeletonRows:Je=Kt,"aria-label":v,"aria-labelledby":Z,"aria-describedby":he,className:Ue,style:Qe,id:ge,testId:Re}=n,$e=ce??Ft[Te],{t:Ee,lang:We}=z.useNiceTranslation();z.useNiceAccessMode(),z.useComponentDisplayStyle("table");const Ye=qt(Ie),[sn,bn]=Vt(_e,Me),yn=t.useRef(null),In=t.useRef(null),[Dn,Mn]=t.useState([]),[An,Rn]=t.useState(),[En,He]=t.useState(""),[zn,kn]=t.useState(1),[Tn,vn]=t.useState(_||Pt),[mn,Nn]=t.useState(new Set),[r,c]=t.useState([]),[D,L]=t.useState(0),[W,A]=t.useState(!1),[$,Y]=t.useState(new Set),[Q,Se]=t.useState(null),[Ce,Pe]=t.useState({}),Ae=C??Dn,_n=N??An,en=X??En,hn=b??zn,rn=_??Tn,cn=me??mn,pn=!!(f||m),On=M??(pn?D:s?.length??0),ln=t.useMemo(()=>{const p=new Set(sn.hiddenColumns||[]);return a.filter(ae=>!ae.hidden&&!p.has(ae.field))},[a,sn.hiddenColumns]),jn=t.useMemo(()=>{if(pn)return r;if(!s)return[];let p=[...s];if(en){const ae=en.toLowerCase(),xe=a.filter(je=>je.searchable!==!1).map(je=>je.field);p=p.filter(je=>xe.some(Ze=>{const on=qe(je,Ze);return String(on??"").toLowerCase().includes(ae)}))}return Ae.length>0&&p.sort((ae,xe)=>{for(const je of Ae){const Ze=qe(ae,je.field),on=qe(xe,je.field),dn=Ze<on?-1:Ze>on?1:0;if(dn!==0)return je.direction==="asc"?dn:-dn}return 0}),p},[pn,r,s,en,Ae,a]),fn=t.useMemo(()=>{if(pn||!y)return jn;const p=(hn-1)*rn;return jn.slice(p,p+rn)},[pn,jn,y,hn,rn]),Jn=yn.current?.clientHeight||400,Sn=ee&&fn.length>Gt,{visibleData:et,totalHeight:nt,offsetY:tt,handleScroll:it,startIndex:$n}=Qt(fn,Jn,$e,de),gn=Sn?et:fn,Bn=t.useCallback(async()=>{if(f){A(!0);try{const ae=await f({page:hn,pageSize:rn,sort:Ae,filter:_n,search:en});c(ae.data),L(ae.total)}catch(p){console.error("NiceModuleGrid fetch error:",p)}finally{A(!1)}}},[f,hn,rn,Ae,_n,en]);t.useEffect(()=>{pn&&Bn()},[pn,Bn]);const at=t.useCallback(p=>{const ae=Ae.find(je=>je.field===p);let xe;ae?ae.direction==="asc"?xe=Ae.map(je=>je.field===p?{...je,direction:"desc"}:je):xe=Ae.filter(je=>je.field!==p):xe=k?[...Ae,{field:p,direction:"asc"}]:[{field:p,direction:"asc"}],w?w(xe):Mn(xe)},[Ae,k,w]),st=t.useCallback((p,ae)=>{P?P(p,ae):(kn(p),vn(ae))},[P]),rt=t.useCallback(p=>{E?E(p):He(p),P||kn(1)},[E,P]),Ln=t.useCallback((p,ae)=>{const xe=new Set(cn);if(le==="single"?(xe.clear(),xe.add(p)):(le==="multiple"||le==="checkbox")&&(xe.has(p)?xe.delete(p):xe.add(p)),ne){const je=fn.filter(Ze=>xe.has(String(qe(Ze,d))));ne(xe,je)}else Nn(xe)},[cn,le,ne,fn,d]),ct=t.useCallback((p,ae)=>{Pe(xe=>({...xe,[p]:ae})),we?.(p,ae),bn({columnWidths:{...sn.columnWidths,[p]:ae}})},[we,bn,sn.columnWidths]),lt=t.useCallback((p,ae)=>{S?.length&&(p.preventDefault(),Se({x:p.clientX,y:p.clientY,row:ae}))},[S]),ot=t.useCallback(p=>{Q&&se?.(p,Q.row),Se(null)},[Q,se]),dt=t.useCallback(async p=>{if(G)await G(p,{selectedOnly:cn.size>0,columns:ln.map(ae=>ae.field)});else if(p==="csv"){const ae=ln.map(Ve=>Ve.header).join(","),xe=fn.map(Ve=>ln.map(ht=>JSON.stringify(qe(Ve,ht.field)??"")).join(",")),je=[ae,...xe].join(`
|
|
6
|
+
`),Ze=new Blob([je],{type:"text/csv;charset=utf-8;"}),on=URL.createObjectURL(Ze),dn=document.createElement("a");dn.href=on,dn.download=`export-${new Date().toISOString().slice(0,10)}.csv`,dn.click(),URL.revokeObjectURL(on)}},[G,cn,ln,fn,Ee]);t.useEffect(()=>{if(!Q)return;const p=()=>Se(null);return document.addEventListener("click",p),()=>document.removeEventListener("click",p)},[Q]);const ut=t.useCallback(p=>{p.key==="Escape"&&Se(null)},[]),xn=U||W,Fn=!xn&&gn.length===0,Un=Ye&&ve,mt=tn("nice-module-grid",`nice-module-grid--${Te}`,`nice-module-grid--${an}`,Be&&"nice-module-grid--striped",Fe&&"nice-module-grid--bordered",ke&&"nice-module-grid--hoverable",xn&&"nice-module-grid--loading",Un&&"nice-module-grid--mobile",Ue);return e.jsxs("div",{ref:i,id:ge,"data-testid":Re,className:mt,style:Qe,onKeyDown:ut,role:"grid","aria-label":v,"aria-labelledby":Z,"aria-describedby":he,"aria-rowcount":On,"aria-colcount":ln.length,"aria-busy":xn,children:[e.jsxs("div",{className:"nice-module-grid__toolbar",children:[e.jsx("div",{className:"nice-module-grid__toolbar-search",children:e.jsx("input",{type:"search",className:"nice-module-grid__search-input",placeholder:g??Ee("moduleGrid.searchPlaceholder","Search…"),value:en,onChange:p=>rt(p.target.value),"aria-label":Ee("moduleGrid.searchAriaLabel","Search")})}),pe,oe&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:re.map(p=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>dt(p),"aria-label":Ee(`moduleGrid.export.${p}`,`Export to ${p.toUpperCase()}`),children:p.toUpperCase()},p))})]}),e.jsx("div",{ref:yn,className:"nice-module-grid__container",onScroll:Sn?it:void 0,children:Un?e.jsx("div",{className:"nice-module-grid__mobile-list",children:xn&&Xe?Array.from({length:Je},(p,ae)=>e.jsxs("div",{className:"nice-module-grid__mobile-card nice-module-grid__mobile-card--skeleton",children:[e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"60%",height:20}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"40%",height:14}}),e.jsx("div",{className:"nice-module-grid__skeleton-bar",style:{width:"80%",height:14}})]},ae)):Fn?e.jsxs("div",{className:"nice-module-grid__empty",children:[o?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:o.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:o?.title||Ee("moduleGrid.noData","No data")}),o?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:o.description}),o?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:o.action.onClick,children:[o.action.icon,o.action.label]})]}):gn.map((p,ae)=>{const xe=String(qe(p,d));return e.jsx(Xt,{row:p,index:$n+ae,columns:ln,primaryField:ie,secondaryField:Ge,customRender:fe,selected:cn.has(xe),locale:We,onClick:()=>{le!=="none"&&Ln(xe,p),te?.(p,$n+ae)},t:Ee},xe)})}):e.jsxs("div",{ref:In,className:"nice-module-grid__table",children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[le==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:cn.size>0&&cn.size===gn.length,onChange:()=>{if(cn.size===gn.length)ne?.(new Set,[]),Nn(new Set);else{const p=new Set(gn.map(ae=>String(qe(ae,d))));ne?.(p,gn),Nn(p)}},"aria-label":Ee("moduleGrid.selectAll","Select all")})}),ln.map(p=>e.jsx(Ht,{column:{...p,width:Ce[p.field]||p.width},sort:Ae.find(ae=>ae.field===p.field),onSort:u?at:void 0,onResize:ue?ct:void 0,resizable:ue,t:Ee},p.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:Sn?{height:nt,position:"relative"}:void 0,children:xn&&Xe?Array.from({length:Je},(p,ae)=>e.jsx(Jt,{columns:ln},ae)):Fn?e.jsxs("div",{className:"nice-module-grid__empty",children:[o?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:o.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:o?.title||Ee("moduleGrid.noData","No data")}),o?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:o.description}),o?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:o.action.onClick,children:[o.action.icon,o.action.label]})]}):e.jsx("div",{style:Sn?{transform:`translateY(${tt}px)`}:void 0,children:gn.map((p,ae)=>{const xe=String(qe(p,d)),je=$n+ae,Ze=cn.has(xe),on=typeof T=="function"?T(p,je):T,dn=typeof H=="function"?H(p,je):H;return e.jsxs("div",{className:tn("nice-module-grid__row",Ze&&"nice-module-grid__row--selected",on),style:{...dn,height:$e},role:"row","aria-rowindex":je+1,"aria-selected":Ze,onClick:()=>{le!=="none"&&Ln(xe,p),te?.(p,je)},onDoubleClick:()=>I?.(p,je),onContextMenu:Ve=>lt(Ve,p),children:[le==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",children:e.jsx("input",{type:"checkbox",checked:Ze,onChange:()=>Ln(xe,p),onClick:Ve=>Ve.stopPropagation(),"aria-label":Ee("moduleGrid.selectRow","Select row")})}),ln.map(Ve=>e.jsx(Zt,{column:{...Ve,width:Ce[Ve.field]||Ve.width},row:p,rowIndex:je,value:qe(p,Ve.field),locale:We},Ve.field))]},xe)})})})]})}),y&&On>0&&e.jsx(Yt,{page:hn,pageSize:rn,totalRows:pn?D:jn.length,pageSizeOptions:j,onPageChange:st,t:Ee}),Q&&S&&e.jsx("div",{className:"nice-module-grid__context-menu",style:{left:Q.x,top:Q.y},role:"menu",children:S.filter(p=>typeof p.hidden=="function"?!p.hidden(Q.row):!p.hidden).map(p=>{if(p.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},p.key);const ae=typeof p.disabled=="function"?p.disabled(Q.row):p.disabled;return e.jsxs("button",{className:tn("nice-module-grid__context-menu-item",p.danger&&"nice-module-grid__context-menu-item--danger",ae&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{ae||(p.onClick?.(Q.row),ot(p.key))},disabled:ae,role:"menuitem",children:[p.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:p.icon}),p.label]},p.key)})}),xn&&!Xe&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":Ee("moduleGrid.loading","Loading")})})]})}const ni=t.forwardRef(ei),Ke={width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},ti=()=>e.jsxs("svg",{...Ke,children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13"})]}),ii=()=>e.jsxs("svg",{...Ke,children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 0 1 15-6.7L21 13"})]}),ai=()=>e.jsxs("svg",{...Ke,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"3",y1:"12",x2:"15",y2:"12"}),e.jsx("line",{x1:"3",y1:"18",x2:"18",y2:"18"})]}),si=()=>e.jsxs("svg",{...Ke,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"6",y1:"12",x2:"18",y2:"12"}),e.jsx("line",{x1:"4",y1:"18",x2:"20",y2:"18"})]}),ri=()=>e.jsxs("svg",{...Ke,children:[e.jsx("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),e.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),e.jsx("line",{x1:"6",y1:"18",x2:"21",y2:"18"})]}),ci=()=>e.jsxs("svg",{...Ke,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"18",height:"6",rx:"1"}),e.jsx("line",{x1:"12",y1:"11",x2:"12",y2:"13"})]}),li=()=>e.jsxs("svg",{...Ke,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"11",y1:"12",x2:"13",y2:"12"})]}),oi=()=>e.jsxs("svg",{...Ke,children:[e.jsx("rect",{x:"3",y:"4",width:"18",height:"6",rx:"1"}),e.jsx("line",{x1:"6",y1:"17",x2:"18",y2:"17"})]}),di=()=>e.jsxs("svg",{...Ke,children:[e.jsx("rect",{x:"4",y:"3",width:"6",height:"18",rx:"1"}),e.jsx("line",{x1:"14",y1:"12",x2:"20",y2:"12"})]}),ui=()=>e.jsx("svg",{...Ke,children:e.jsx("polyline",{points:"6 9 12 4 18 9"})}),mi=()=>e.jsx("svg",{...Ke,children:e.jsx("polyline",{points:"6 15 12 20 18 15"})}),hi=()=>e.jsxs("svg",{...Ke,style:{opacity:.55},children:[e.jsx("polyline",{points:"6 9 12 4 18 9"}),e.jsx("polyline",{points:"6 15 12 20 18 15"})]}),pi=()=>e.jsxs("svg",{...Ke,children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),fi=()=>e.jsxs("svg",{...Ke,children:[e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"})]});function Xn(n){let i="",a=n;for(;a>=0;)i=String.fromCharCode(65+a%26)+i,a=Math.floor(a/26)-1;return i}function be(n,i){return`${Xn(i)}${n+1}`}function Oe(n){const i=n.match(/^([A-Z]+)(\d+)$/);if(!i)return null;let a=0;for(let s=0;s<i[1].length;s++)a=a*26+(i[1].charCodeAt(s)-64);return{row:parseInt(i[2],10)-1,col:a-1}}function gi(n,i,a=new Set){const s=n.startsWith("=")?n.slice(1).trim():n,d=(g,y)=>{if(!g||!y)return[];const b=[];for(let _=g.row;_<=y.row;_++)for(let j=g.col;j<=y.col;j++){const M=Le(be(_,j),i,new Set(a));typeof M=="number"&&b.push(M)}return b},m=(g,y)=>{if(!g||!y)return[];const b=[];for(let _=g.row;_<=y.row;_++)for(let j=g.col;j<=y.col;j++)b.push(Le(be(_,j),i,new Set(a)));return b},f=s.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(f){const g=f[1].toUpperCase(),y=Oe(f[2].toUpperCase()),b=Oe(f[3].toUpperCase());switch(g){case"SUM":return d(y,b).reduce((j,M)=>j+M,0);case"AVG":case"AVERAGE":{const _=d(y,b);return _.length>0?_.reduce((j,M)=>j+M,0)/_.length:0}case"COUNT":return d(y,b).length;case"COUNTA":return m(y,b).filter(_=>_!==null&&_!=="").length;case"COUNTBLANK":return m(y,b).filter(_=>_===null||_==="").length;case"MIN":{const _=d(y,b);return _.length?Math.min(..._):0}case"MAX":{const _=d(y,b);return _.length?Math.max(..._):0}case"MEDIAN":{const _=d(y,b).sort((M,P)=>M-P);if(!_.length)return 0;const j=Math.floor(_.length/2);return _.length%2?_[j]:(_[j-1]+_[j])/2}case"STDEV":{const _=d(y,b);if(_.length<2)return 0;const j=_.reduce((M,P)=>M+P,0)/_.length;return Math.sqrt(_.reduce((M,P)=>M+(P-j)**2,0)/(_.length-1))}case"PRODUCT":{const _=d(y,b);return _.length?_.reduce((j,M)=>j*M,1):0}}}const u=s.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(u){const g=u[1].toUpperCase(),y=Oe(u[2].toUpperCase()),b=Oe(u[3].toUpperCase()),_=u[4];if(y&&b){let j=0;for(let M=y.row;M<=b.row;M++)for(let P=y.col;P<=b.col;P++){const ee=Le(be(M,P),i,new Set(a));(_.startsWith(">")?Number(ee)>Number(_.slice(1)):_.startsWith("<")?Number(ee)<Number(_.slice(1)):String(ee)===_||typeof ee=="number"&&ee===Number(_))&&(j+=g==="SUMIF"?typeof ee=="number"?ee:0:1)}return j}}const C=s.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(C){const g=C[1].trim(),y=C[2].trim(),b=C[3].trim(),_=g.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let j=!1;if(_){const ee=Le(_[1].toUpperCase(),i,new Set(a)),ce=isNaN(Number(_[3]))?_[3].replace(/^"|"$/g,""):Number(_[3]),de=_[2],le=typeof ee=="number"?ee:Number(ee)||0,me=typeof ce=="number"?ce:Number(ce)||0;switch(de){case">":j=le>me;break;case"<":j=le<me;break;case">=":j=le>=me;break;case"<=":j=le<=me;break;case"=":case"==":j=le===me;break;case"<>":case"!=":j=le!==me;break}}const M=j?y:b;if(Oe(M.toUpperCase()))return Le(M.toUpperCase(),i,new Set(a));const P=Number(M);return isNaN(P)?M.replace(/^"|"$/g,""):P}const w=s.match(/^CONCAT\((.+)\)$/i);if(w)return w[1].split(",").map(y=>y.trim()).map(y=>{if(y.startsWith('"')&&y.endsWith('"'))return y.slice(1,-1);if(Oe(y.toUpperCase())){const _=Le(y.toUpperCase(),i,new Set(a));return _!==null?String(_):""}return y}).join("");const k=s.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(k){let g;Oe(k[1].trim().toUpperCase())?g=Le(k[1].trim().toUpperCase(),i,new Set(a)):g=isNaN(Number(k[1]))?k[1].replace(/^"|"$/g,""):Number(k[1]);const b=Oe(k[2].toUpperCase()),_=Oe(k[3].toUpperCase()),j=parseInt(k[4])-1;if(b&&_)for(let M=b.row;M<=_.row;M++){const P=Le(be(M,b.col),i,new Set(a));if(String(P)===String(g))return Le(be(M,b.col+j),i,new Set(a))}return null}const F=s.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(F){const g=F[1].toUpperCase(),y=F[2].trim();let b;switch(Oe(y.toUpperCase())?b=Le(y.toUpperCase(),i,new Set(a)):b=isNaN(Number(y))?y.replace(/^"|"$/g,""):Number(y),g){case"ABS":return Math.abs(Number(b)||0);case"ROUND":return Math.round(Number(b)||0);case"FLOOR":return Math.floor(Number(b)||0);case"CEIL":case"CEILING":return Math.ceil(Number(b)||0);case"SQRT":return Math.sqrt(Number(b)||0);case"INT":return Math.trunc(Number(b)||0);case"LEN":return String(b??"").length;case"UPPER":return String(b??"").toUpperCase();case"LOWER":return String(b??"").toLowerCase();case"TRIM":return String(b??"").trim()}}const N=s.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(N){const g=Number(Oe(N[1].trim().toUpperCase())?Le(N[1].trim().toUpperCase(),i,new Set(a)):N[1].trim())||0,y=Number(Oe(N[2].trim().toUpperCase())?Le(N[2].trim().toUpperCase(),i,new Set(a)):N[2].trim())||0;return Math.pow(g,y)}if(/^NOW\(\)$/i.test(s))return new Date().toISOString();if(/^TODAY\(\)$/i.test(s))return new Date().toISOString().split("T")[0];if(/^PI\(\)$/i.test(s))return Math.PI;const J=s.match(/^([A-Z]+\d+)$/i);if(J)return Le(J[1].toUpperCase(),i,a);const X=s.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(X){const g=X[1].toUpperCase(),y=X[2],b=X[3],_=Le(g,i,a),M=Oe(b.toUpperCase())?Le(b.toUpperCase(),i,a):parseFloat(b),P=typeof _=="number"?_:0,ee=typeof M=="number"?M:0;switch(y){case"+":return P+ee;case"-":return P-ee;case"*":return P*ee;case"/":return ee!==0?P/ee:null}}const E=parseFloat(s);return isNaN(E)?s:E}function Le(n,i,a){if(a.has(n))return null;a.add(n);const s=i[n];return s?s.formula?gi(s.formula,i,a):s.value:null}function Gn(n,i){return n==null?"":i==="percent"&&typeof n=="number"?`${(n*100).toFixed(1)}%`:i==="currency"&&typeof n=="number"?`$${n.toFixed(2)}`:String(n)}function Kn(n){return{name:n,data:{}}}const Yn=t.forwardRef(({sheets:n,activeSheet:i,rows:a=50,cols:s=26,showToolbar:d=!0,showFormulaBar:m=!0,showSheetTabs:f=!0,readOnly:u=!1,disabled:C=!1,loading:w=!1,error:k,size:F="md",onChange:N,onActiveSheetChange:J,onCellSelect:X,onCopy:E,onPaste:g,onInsert:y,onRemove:b,maxUndo:_=50,sortable:j=!1,filterable:M=!1,rangeSelection:P=!0,className:ee,style:ce,id:de,...le},me)=>{const ne=u||C,ye=z.useControlId(de),{t:B}=z.useNiceTranslation(),[ue,we]=t.useState(()=>n??[Kn(B("spreadsheet.sheet","Sheet")+" 1")]),[Ne,O]=t.useState(0),V=n??ue,h=i??Ne,x=V[h]??V[0],[l,R]=t.useState(null),[q,S]=t.useState(null),[se,oe]=t.useState(!1),[re,G]=t.useState(null),[_e,Me]=t.useState(""),ze=t.useRef(null),Te=t.useRef(null),[Be,Fe]=t.useState([]),[ke,U]=t.useState([]),[o,pe]=t.useState(null),te=t.useRef({x:0,width:80}),[I,T]=t.useState(null),[H,ve]=t.useState(null),[Ie,fe]=t.useState("");t.useEffect(()=>{re&&ze.current&&ze.current.focus()},[re]);const ie=t.useMemo(()=>{if(!l)return null;const r=q??l;return{startRow:Math.min(l.row,r.row),startCol:Math.min(l.col,r.col),endRow:Math.max(l.row,r.row),endCol:Math.max(l.col,r.col)}},[l,q]),Ge=t.useCallback((r,c)=>ie?r>=ie.startRow&&r<=ie.endRow&&c>=ie.startCol&&c<=ie.endCol:!1,[ie]),un=t.useCallback(r=>{Fe(c=>{const D=[...c,r.map(L=>({...L,data:{...L.data}}))];return D.length>_?D.slice(-_):D}),U([])},[_]),K=t.useCallback((r,c=!0)=>{c&&un(V);const D=r(V);n||we(D),N?.(D)},[V,n,N,un]),an=t.useCallback(()=>{if(Be.length===0)return;const r=Be[Be.length-1];U(c=>[...c,V.map(D=>({...D,data:{...D.data}}))]),Fe(c=>c.slice(0,-1)),n||we(r),N?.(r)},[Be,V,n,N]),Xe=t.useCallback(()=>{if(ke.length===0)return;const r=ke[ke.length-1];Fe(c=>[...c,V.map(D=>({...D,data:{...D.data}}))]),U(c=>c.slice(0,-1)),n||we(r),N?.(r)},[ke,V,n,N]),Je=t.useCallback(r=>{i||O(r),J?.(r),R(null),S(null),G(null)},[i,J]),v=t.useCallback((r,c,D)=>{const L=be(r,c);K(W=>{const A=W.map((Y,Q)=>Q===h?{...Y,data:{...Y.data}}:Y),$=D.startsWith("=");return A[h].data[L]={...A[h].data[L]??{value:null},formula:$?D:void 0,value:$?null:isNaN(Number(D))?D:Number(D)},A})},[h,K]),Z=t.useCallback((r,c,D)=>{D?.shiftKey&&P&&l?S({row:r,col:c}):(R({row:r,col:c}),S(null)),G(null),X?.(h,r,c)},[h,X,P,l]),he=t.useCallback((r,c,D)=>{D.button===0&&(Z(r,c,D),P&&!D.shiftKey&&oe(!0))},[Z,P]),Ue=t.useCallback((r,c)=>{se&&S({row:r,col:c})},[se]);t.useEffect(()=>{if(!se)return;const r=()=>oe(!1);return document.addEventListener("mouseup",r),()=>document.removeEventListener("mouseup",r)},[se]);const Qe=t.useCallback((r,c)=>{if(ne)return;const D=be(r,c),L=x.data[D];L?.readOnly||(G({row:r,col:c}),Me(L?.formula??(L?.value!=null?String(L.value):"")))},[ne,x.data]),ge=t.useCallback(()=>{re&&(v(re.row,re.col,_e),G(null))},[re,_e,v]),Re=t.useCallback(r=>{if(r.key==="Enter")ge();else if(r.key==="Escape")G(null);else if(r.key==="Tab"&&(r.preventDefault(),ge(),l)){const c=r.shiftKey?Math.max(0,l.col-1):Math.min(s-1,l.col+1);R({row:l.row,col:c})}},[ge,l,s]),$e=t.useCallback((r,c)=>{if(!l)return;const D=ie??{startRow:l.row,startCol:l.col,endRow:l.row,endCol:l.col};K(L=>{const W=L.map((A,$)=>$===h?{...A,data:{...A.data}}:A);for(let A=D.startRow;A<=D.endRow;A++)for(let $=D.startCol;$<=D.endCol;$++){const Y=be(A,$);W[h].data[Y]={...W[h].data[Y]??{value:null},[r]:c}}return W})},[l,ie,h,K]),Ee=t.useCallback(r=>{if(!ie||E?.(ie)===!1)return;const{startRow:c,startCol:D,endRow:L,endCol:W}=ie,A=[];for(let $=c;$<=L;$++){const Y=[];for(let Q=D;Q<=W;Q++){const Se=be($,Q),Ce=x.data[Se],Pe=Ce?Le(Se,x.data,new Set):null;Y.push(Gn(Pe,Ce?.format))}A.push(Y.join(" "))}r.clipboardData.setData("text/plain",A.join(`
|
|
7
|
+
`)),r.preventDefault()},[ie,x.data,E]),We=t.useCallback(r=>{if(ne||!l)return;const c=r.clipboardData.getData("text/plain");if(!c)return;const D=c.split(`
|
|
8
|
+
`).map(L=>L.split(" "));g?.(D,l.row,l.col)!==!1&&(K(L=>{const W=L.map((A,$)=>$===h?{...A,data:{...A.data}}:A);return D.forEach((A,$)=>{A.forEach((Y,Q)=>{const Se=be(l.row+$,l.col+Q),Ce=Y.startsWith("=");W[h].data[Se]={...W[h].data[Se]??{value:null},formula:Ce?Y:void 0,value:Ce?null:isNaN(Number(Y))?Y:Number(Y)}})}),W}),r.preventDefault())},[ne,l,h,K,g]),Ye=t.useCallback(r=>{K(c=>c.map((L,W)=>{if(W!==h)return L;const A={};for(const[$,Y]of Object.entries(L.data)){const Q=Oe($);Q&&(Q.row>r?A[be(Q.row+1,Q.col)]=Y:A[$]=Y)}return{...L,data:A}})),y?.("row",r)},[h,K,y]),sn=t.useCallback(r=>{K(c=>c.map((L,W)=>{if(W!==h)return L;const A={};for(const[$,Y]of Object.entries(L.data)){const Q=Oe($);Q&&(Q.col>r?A[be(Q.row,Q.col+1)]=Y:A[$]=Y)}return{...L,data:A}})),y?.("column",r)},[h,K,y]),bn=t.useCallback(r=>{K(c=>c.map((L,W)=>{if(W!==h)return L;const A={};for(const[$,Y]of Object.entries(L.data)){const Q=Oe($);Q&&Q.row!==r&&(Q.row>r?A[be(Q.row-1,Q.col)]=Y:A[$]=Y)}return{...L,data:A}})),b?.("row",r)},[h,K,b]),yn=t.useCallback(r=>{K(c=>c.map((L,W)=>{if(W!==h)return L;const A={};for(const[$,Y]of Object.entries(L.data)){const Q=Oe($);Q&&Q.col!==r&&(Q.col>r?A[be(Q.row,Q.col-1)]=Y:A[$]=Y)}return{...L,data:A}})),b?.("column",r)},[h,K,b]),In=t.useCallback((r,c)=>{K(D=>D.map((W,A)=>{if(A!==h)return W;const $=new Map;for(const[Se,Ce]of Object.entries(W.data)){const Pe=Oe(Se);Pe&&($.has(Pe.row)||$.set(Pe.row,{}),$.get(Pe.row)[Pe.col]=Ce)}const Y=Array.from($.entries()).sort((Se,Ce)=>{const Pe=Le(be(Se[0],r),W.data,new Set),Ae=Le(be(Ce[0],r),W.data,new Set),_n=typeof Pe=="number"?Pe:Number(Pe),en=typeof Ae=="number"?Ae:Number(Ae);if(!isNaN(_n)&&!isNaN(en))return c==="asc"?_n-en:en-_n;const hn=String(Pe??""),rn=String(Ae??"");return c==="asc"?hn.localeCompare(rn):rn.localeCompare(hn)}),Q={};return Y.forEach(([,Se],Ce)=>{for(const[Pe,Ae]of Object.entries(Se))Q[be(Ce,Number(Pe))]=Ae}),{...W,data:Q,sortColumn:r,sortDirection:c}}))},[h,K]),Dn=t.useCallback((r,c)=>{const D=x.conditionalFormats;if(!D?.length)return;const L=be(r,c),W=Le(L,x.data,new Set),A=typeof W=="number"?W:Number(W);for(const $ of D){const Y=$.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!Y)continue;const Q=Oe(Y[1].toUpperCase()),Se=Oe(Y[2].toUpperCase());if(!Q||!Se||r<Q.row||r>Se.row||c<Q.col||c>Se.col)continue;let Ce=!1;switch($.type){case"greaterThan":Ce=!isNaN(A)&&A>Number($.value);break;case"lessThan":Ce=!isNaN(A)&&A<Number($.value);break;case"equalTo":Ce=String(W)===String($.value);break;case"between":Ce=!isNaN(A)&&A>=Number($.value)&&A<=Number($.value2);break;case"textContains":Ce=String(W).includes(String($.value));break;case"isEmpty":Ce=W===null||W==="";break;case"isNotEmpty":Ce=W!==null&&W!=="";break}if(Ce)return{backgroundColor:$.style.bgColor,color:$.style.color,fontWeight:$.style.bold?"bold":void 0,fontStyle:$.style.italic?"italic":void 0}}},[x.conditionalFormats,x.data]),Mn=t.useCallback(()=>{const r=`${B("spreadsheet.sheet","Sheet")} ${V.length+1}`;K(c=>[...c,Kn(r)]),Je(V.length)},[V.length,K,Je,B]),An=t.useCallback(()=>{V.length<=1||(K(r=>r.filter((c,D)=>D!==h)),Je(Math.max(0,h-1)))},[V.length,h,K,Je]),Rn=t.useCallback((r,c)=>{c.trim()&&(K(D=>D.map((L,W)=>W===r?{...L,name:c.trim()}:L),!1),ve(null))},[K]),En=t.useMemo(()=>{if(!l)return"";const r=be(l.row,l.col),c=x.data[r];return c?.formula??(c?.value!=null?String(c.value):"")},[l,x.data]),He=t.useMemo(()=>{if(!ie)return null;const{startRow:r,startCol:c,endRow:D,endCol:L}=ie;if(r===D&&c===L)return null;const W=[];let A=0;for(let $=r;$<=D;$++)for(let Y=c;Y<=L;Y++){const Q=be($,Y),Se=Le(Q,x.data,new Set);Se!==null&&Se!==""&&A++,typeof Se=="number"&&W.push(Se)}return W.length===0?{count:A}:{count:A,sum:W.reduce(($,Y)=>$+Y,0),avg:W.reduce(($,Y)=>$+Y,0)/W.length,min:Math.min(...W),max:Math.max(...W)}},[ie,x.data]),zn=t.useCallback((r,c)=>{c.preventDefault(),c.stopPropagation(),pe(r),te.current={x:c.clientX,width:x.colWidths?.[r]??80}},[x.colWidths]);t.useEffect(()=>{if(o===null)return;const r=D=>{const L=D.clientX-te.current.x,W=Math.max(30,te.current.width+L);K(A=>A.map((Y,Q)=>Q===h?{...Y,colWidths:{...Y.colWidths,[o]:W}}:Y),!1)},c=()=>pe(null);return document.addEventListener("mousemove",r),document.addEventListener("mouseup",c),()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",c)}},[o,h,K]);const kn=t.useCallback((r,c,D)=>{r.preventDefault(),R({row:c,col:D}),T({x:r.clientX,y:r.clientY})},[]);t.useEffect(()=>{if(!I)return;const r=()=>T(null);return document.addEventListener("click",r),()=>document.removeEventListener("click",r)},[I]);const Tn=t.useCallback(r=>{if((r.ctrlKey||r.metaKey)&&!re){if(r.key==="z"){r.preventDefault(),an();return}if(r.key==="y"){r.preventDefault(),Xe();return}}if(re||!l)return;let{row:c,col:D}=l;switch(r.key){case"ArrowUp":c=Math.max(0,c-1);break;case"ArrowDown":c=Math.min(a-1,c+1);break;case"ArrowLeft":D=Math.max(0,D-1);break;case"ArrowRight":D=Math.min(s-1,D+1);break;case"Enter":Qe(c,D);return;case"Delete":case"Backspace":ne||(ie&&(ie.startRow!==ie.endRow||ie.startCol!==ie.endCol)?K(L=>{const W=L.map((A,$)=>$===h?{...A,data:{...A.data}}:A);for(let A=ie.startRow;A<=ie.endRow;A++)for(let $=ie.startCol;$<=ie.endCol;$++)delete W[h].data[be(A,$)];return W}):v(c,D,""));return;default:if(r.key.length===1&&!r.ctrlKey&&!r.metaKey&&!ne){G({row:c,col:D}),Me(r.key);return}return}r.preventDefault(),r.shiftKey&&P?S({row:c,col:D}):(R({row:c,col:D}),S(null)),X?.(h,c,D)},[re,l,a,s,ne,Qe,v,h,X,an,Xe,ie,K,P]),vn=x.frozenRows??0,mn=x.frozenCols??0,Nn=[{value:"text",label:B("spreadsheet.formatText","Text")},{value:"number",label:B("spreadsheet.formatNumber","Number")},{value:"percent",label:B("spreadsheet.formatPercent","Percent")},{value:"currency",label:B("spreadsheet.formatCurrency","Currency")},{value:"date",label:B("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:me,id:ye,className:`nice-spreadsheet nice-spreadsheet--${F} ${u&&!C?"nice-spreadsheet--readonly":""} ${C?"nice-spreadsheet--disabled":""} ${w?"nice-spreadsheet--loading":""} ${k?"nice-spreadsheet--error":""} ${ee??""}`,style:{...ce,position:w?"relative":ce?.position},onKeyDown:Tn,onCopy:Ee,onPaste:We,tabIndex:C?-1:0,role:"application","aria-label":B("spreadsheet.label","Spreadsheet"),"aria-disabled":C||void 0,"aria-busy":w||void 0,...le,children:[k&&e.jsx("div",{className:"nice-spreadsheet__error",role:"alert",children:k}),w&&e.jsx("span",{className:"nice-spreadsheet__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),d&&!ne&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:an,disabled:Be.length===0,title:B("spreadsheet.undo","Undo"),children:e.jsx(ti,{})}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:Xe,disabled:ke.length===0,title:B("spreadsheet.redo","Redo"),children:e.jsx(ii,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(De.NiceButton,{variant:x.data[l?be(l.row,l.col):""]?.bold?"primary":"ghost",size:"sm",onClick:()=>$e("bold",!x.data[l?be(l.row,l.col):""]?.bold),title:B("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(De.NiceButton,{variant:x.data[l?be(l.row,l.col):""]?.italic?"primary":"ghost",size:"sm",onClick:()=>$e("italic",!x.data[l?be(l.row,l.col):""]?.italic),title:B("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>$e("align","left"),title:B("spreadsheet.alignLeft","Align left"),children:e.jsx(ai,{})}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>$e("align","center"),title:B("spreadsheet.alignCenter","Center"),children:e.jsx(si,{})}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>$e("align","right"),title:B("spreadsheet.alignRight","Align right"),children:e.jsx(ri,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(De.NiceColorPicker,{value:x.data[l?be(l.row,l.col):""]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:r=>$e("bgColor",r),title:B("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(De.NiceColorPicker,{value:x.data[l?be(l.row,l.col):""]?.color??"var(--nice-text-primary, #000000)",onChange:r=>$e("color",r),title:B("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(bt.NiceSelect,{size:"sm",value:x.data[l?be(l.row,l.col):""]?.format??"text",onChange:r=>$e("format",r),options:Nn,"aria-label":B("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>l&&Ye(l.row),title:B("spreadsheet.insertRow","Insert row"),children:e.jsx(ci,{})}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>l&&sn(l.col),title:B("spreadsheet.insertCol","Insert column"),children:e.jsx(li,{})}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>l&&bn(l.row),title:B("spreadsheet.deleteRow","Delete row"),children:e.jsx(oi,{})}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>l&&yn(l.col),title:B("spreadsheet.deleteCol","Delete column"),children:e.jsx(di,{})})]}),m&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[l?be(l.row,l.col):"",ie&&ie.startRow!==ie.endRow||ie&&ie.startCol!==ie.endCol?`:${be(ie.endRow,ie.endCol)}`:""]}),e.jsx(Wn.NiceTextInput,{className:"nice-spreadsheet__formula-input",value:re?_e:En,onChange:r=>{re?Me(r):l&&(G(l),Me(r))},onKeyDown:Re,readOnly:ne,"aria-label":B("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:Te,children:e.jsxs("table",{role:"grid","aria-label":x.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:s},(r,c)=>e.jsxs("th",{className:`nice-spreadsheet__col-header ${c<mn?"nice-spreadsheet__col-header--frozen":""}`,style:{width:x.colWidths?.[c]??80,position:c<mn?"sticky":void 0,left:c<mn?c*80+40:void 0,zIndex:c<mn?3:void 0},children:[e.jsx("span",{children:Xn(c)}),j&&e.jsx("span",{className:"nice-spreadsheet__sort-trigger",onClick:()=>In(c,x.sortColumn===c&&x.sortDirection==="asc"?"desc":"asc"),title:B("spreadsheet.sort","Sort"),children:x.sortColumn===c?x.sortDirection==="asc"?e.jsx(ui,{}):e.jsx(mi,{}):e.jsx(hi,{})}),!ne&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:D=>zn(c,D)})]},c))]})}),e.jsx("tbody",{children:Array.from({length:a},(r,c)=>e.jsxs("tr",{className:c<vn?"nice-spreadsheet__row--frozen":"",style:c<vn?{position:"sticky",top:c*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:c+1}),Array.from({length:s},(D,L)=>{const W=be(c,L),A=x.data[W];if(A?.mergedInto)return null;const $=l?.row===c&&l?.col===L,Y=Ge(c,L),Q=re?.row===c&&re?.col===L,Se=A?Le(W,x.data,new Set):null,Ce=Dn(c,L),Pe=c<vn||L<mn;return e.jsxs("td",{className:`nice-spreadsheet__cell ${$?"nice-spreadsheet__cell--selected":""} ${Y&&!$?"nice-spreadsheet__cell--in-range":""} ${A?.readOnly?"nice-spreadsheet__cell--readonly":""} ${Pe?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:A?.align,fontWeight:A?.bold?"bold":void 0,fontStyle:A?.italic?"italic":void 0,backgroundColor:Ce?.backgroundColor??A?.bgColor,color:Ce?.color??A?.color,width:x.colWidths?.[L],height:x.rowHeights?.[c],position:Pe?"sticky":void 0,left:L<mn?L*80+40:void 0,zIndex:Pe?1:void 0,...Ce},colSpan:A?.colSpan,rowSpan:A?.rowSpan,onMouseDown:Ae=>he(c,L,Ae),onMouseEnter:()=>Ue(c,L),onDoubleClick:()=>Qe(c,L),onContextMenu:Ae=>kn(Ae,c,L),role:"gridcell","aria-selected":$,title:A?.comment,children:[A?.comment&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),Q?e.jsx("input",{ref:ze,className:"nice-spreadsheet__cell-editor",value:_e,onChange:Ae=>Me(Ae.target.value),onKeyDown:Re,onBlur:ge}):Gn(Se,A?.format)]},L)})]},c))})]})}),I&&!ne&&l&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:I.x,top:I.y,zIndex:1e3},children:[e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ye(l.row),T(null)},children:B("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{Ye(l.row+1),T(null)},children:B("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{sn(l.col),T(null)},children:B("spreadsheet.insertColLeft","Insert column left")}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{sn(l.col+1),T(null)},children:B("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{bn(l.row),T(null)},children:B("spreadsheet.deleteRow","Delete row")}),e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{yn(l.col),T(null)},children:B("spreadsheet.deleteCol","Delete column")})]}),He&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[B("spreadsheet.count","Count"),": ",He.count]}),He.sum!==void 0&&e.jsxs("span",{children:[B("spreadsheet.sum","Sum"),": ",He.sum.toFixed(2)]}),He.avg!==void 0&&e.jsxs("span",{children:[B("spreadsheet.avg","Avg"),": ",He.avg.toFixed(2)]}),He.min!==void 0&&e.jsxs("span",{children:[B("spreadsheet.min","Min"),": ",He.min]}),He.max!==void 0&&e.jsxs("span",{children:[B("spreadsheet.max","Max"),": ",He.max]})]}),f&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",children:[V.map((r,c)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:H===c?e.jsx(Wn.NiceTextInput,{className:"nice-spreadsheet__tab-rename",value:Ie,onChange:D=>fe(D),onBlur:()=>Rn(c,Ie),onKeyDown:D=>{D.key==="Enter"&&Rn(c,Ie),D.key==="Escape"&&ve(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{ne||(ve(c),fe(r.name))},children:e.jsx(De.NiceButton,{variant:c===h?"primary":"ghost",size:"sm",onClick:()=>Je(c),children:r.name})})},c)),!ne&&e.jsxs(e.Fragment,{children:[e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:Mn,title:B("spreadsheet.addSheet","Add sheet"),children:e.jsx(pi,{})}),V.length>1&&e.jsx(De.NiceButton,{variant:"ghost",size:"sm",onClick:An,title:B("spreadsheet.removeSheet","Remove sheet"),children:e.jsx(fi,{})})]})]})]})});Yn.displayName="NiceSpreadsheet";const _i=`
|
|
9
|
+
.nice-reconciliation {
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
height: 100%;
|
|
13
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
14
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
15
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
16
|
+
overflow: hidden;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.nice-reconciliation__toolbar {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
gap: 0.75rem;
|
|
23
|
+
padding: 0.75rem 1rem;
|
|
24
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
25
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
26
|
+
flex-wrap: wrap;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.nice-reconciliation__toolbar-group {
|
|
30
|
+
display: flex;
|
|
31
|
+
align-items: center;
|
|
32
|
+
gap: 0.5rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.nice-reconciliation__toolbar-group--end {
|
|
36
|
+
margin-inline-start: auto;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.nice-reconciliation__btn {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: center;
|
|
42
|
+
gap: 0.375rem;
|
|
43
|
+
padding: 0.375rem 0.75rem;
|
|
44
|
+
font-size: 0.8125rem;
|
|
45
|
+
font-weight: 500;
|
|
46
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
transition: all 0.15s ease;
|
|
49
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
50
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
51
|
+
color: var(--nice-text-primary);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.nice-reconciliation__btn:hover {
|
|
55
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.nice-reconciliation__btn--primary {
|
|
59
|
+
background: var(--nice-primary, #3b82f6);
|
|
60
|
+
border-color: var(--nice-primary, #3b82f6);
|
|
61
|
+
color: white;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.nice-reconciliation__btn--primary:hover {
|
|
65
|
+
background: var(--nice-primary-dark, #2563eb);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.nice-reconciliation__btn--success {
|
|
69
|
+
background: var(--nice-success, #10b981);
|
|
70
|
+
border-color: var(--nice-success, #10b981);
|
|
71
|
+
color: white;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.nice-reconciliation__btn:disabled {
|
|
75
|
+
opacity: 0.5;
|
|
76
|
+
cursor: not-allowed;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.nice-reconciliation__content {
|
|
80
|
+
display: flex;
|
|
81
|
+
flex: 1;
|
|
82
|
+
overflow: hidden;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.nice-reconciliation--vertical .nice-reconciliation__content {
|
|
86
|
+
flex-direction: column;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.nice-reconciliation__panel {
|
|
90
|
+
flex: 1;
|
|
91
|
+
display: flex;
|
|
92
|
+
flex-direction: column;
|
|
93
|
+
min-width: 0;
|
|
94
|
+
min-height: 0;
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.nice-reconciliation__panel--statements {
|
|
99
|
+
border-inline-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.nice-reconciliation--vertical .nice-reconciliation__panel--statements {
|
|
103
|
+
border-inline-end: none;
|
|
104
|
+
border-block-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.nice-reconciliation__panel-header {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: space-between;
|
|
111
|
+
padding: 0.75rem 1rem;
|
|
112
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
113
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.nice-reconciliation__panel-title {
|
|
117
|
+
font-weight: 600;
|
|
118
|
+
font-size: 0.875rem;
|
|
119
|
+
color: var(--nice-text-primary);
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: center;
|
|
122
|
+
gap: 0.5rem;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.nice-reconciliation__panel-badge {
|
|
126
|
+
font-size: 0.75rem;
|
|
127
|
+
font-weight: 500;
|
|
128
|
+
padding: 0.125rem 0.5rem;
|
|
129
|
+
border-radius: var(--nice-radius-full, 9999px);
|
|
130
|
+
background: var(--nice-bg-tertiary, #e5e7eb);
|
|
131
|
+
color: var(--nice-text-secondary);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.nice-reconciliation__panel-content {
|
|
135
|
+
flex: 1;
|
|
136
|
+
overflow: auto;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.nice-reconciliation__row {
|
|
140
|
+
display: flex;
|
|
141
|
+
align-items: center;
|
|
142
|
+
gap: 0.75rem;
|
|
143
|
+
padding: 0.625rem 1rem;
|
|
144
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
145
|
+
cursor: pointer;
|
|
146
|
+
user-select: none;
|
|
147
|
+
transition: background 0.1s ease;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.nice-reconciliation__row:hover {
|
|
151
|
+
background: var(--nice-bg-hover, rgba(0, 0, 0, 0.02));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.nice-reconciliation__row--selected {
|
|
155
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.1));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.nice-reconciliation__row--dragging {
|
|
159
|
+
opacity: 0.6;
|
|
160
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.15));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
.nice-reconciliation__row--drop-target {
|
|
164
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
165
|
+
box-shadow: inset 0 0 0 2px var(--nice-success, #10b981);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.nice-reconciliation__row--matched {
|
|
169
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.nice-reconciliation__row--partial {
|
|
173
|
+
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.08));
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.nice-reconciliation__row--unmatched {
|
|
177
|
+
background: transparent;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
.nice-reconciliation__row--excluded {
|
|
181
|
+
opacity: 0.5;
|
|
182
|
+
background: var(--nice-bg-tertiary, #f3f4f6);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
.nice-reconciliation__status {
|
|
186
|
+
width: 0.5rem;
|
|
187
|
+
height: 0.5rem;
|
|
188
|
+
border-radius: var(--nice-radius-full, 50%);
|
|
189
|
+
flex-shrink: 0;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
.nice-reconciliation__status--matched {
|
|
193
|
+
background: var(--nice-success, #10b981);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.nice-reconciliation__status--partial {
|
|
197
|
+
background: var(--nice-warning, #f59e0b);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.nice-reconciliation__status--unmatched {
|
|
201
|
+
background: var(--nice-danger, #ef4444);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.nice-reconciliation__status--excluded {
|
|
205
|
+
background: var(--nice-text-disabled, #9ca3af);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
.nice-reconciliation__row-main {
|
|
209
|
+
flex: 1;
|
|
210
|
+
min-width: 0;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
.nice-reconciliation__row-date {
|
|
214
|
+
font-size: 0.75rem;
|
|
215
|
+
color: var(--nice-text-secondary);
|
|
216
|
+
margin-bottom: 0.125rem;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.nice-reconciliation__row-description {
|
|
220
|
+
font-size: 0.8125rem;
|
|
221
|
+
color: var(--nice-text-primary);
|
|
222
|
+
white-space: nowrap;
|
|
223
|
+
overflow: hidden;
|
|
224
|
+
text-overflow: ellipsis;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.nice-reconciliation__row-counterparty {
|
|
228
|
+
font-size: 0.75rem;
|
|
229
|
+
color: var(--nice-text-tertiary);
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
overflow: hidden;
|
|
232
|
+
text-overflow: ellipsis;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.nice-reconciliation__row-amount {
|
|
236
|
+
font-size: 0.875rem;
|
|
237
|
+
font-weight: 600;
|
|
238
|
+
font-variant-numeric: tabular-nums;
|
|
239
|
+
white-space: nowrap;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.nice-reconciliation__row-amount--positive {
|
|
243
|
+
color: var(--nice-success, #10b981);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.nice-reconciliation__row-amount--negative {
|
|
247
|
+
color: var(--nice-danger, #ef4444);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
.nice-reconciliation__confidence {
|
|
251
|
+
display: flex;
|
|
252
|
+
align-items: center;
|
|
253
|
+
gap: 0.25rem;
|
|
254
|
+
font-size: 0.6875rem;
|
|
255
|
+
padding: 0.125rem 0.375rem;
|
|
256
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.nice-reconciliation__confidence--high {
|
|
260
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
261
|
+
color: var(--nice-success-dark, #059669);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.nice-reconciliation__confidence--medium {
|
|
265
|
+
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.15));
|
|
266
|
+
color: var(--nice-warning-dark, #d97706);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.nice-reconciliation__confidence--low {
|
|
270
|
+
background: var(--nice-danger-bg, rgba(239, 68, 68, 0.15));
|
|
271
|
+
color: var(--nice-danger-dark, #dc2626);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.nice-reconciliation__empty {
|
|
275
|
+
display: flex;
|
|
276
|
+
flex-direction: column;
|
|
277
|
+
align-items: center;
|
|
278
|
+
justify-content: center;
|
|
279
|
+
padding: 3rem 1rem;
|
|
280
|
+
color: var(--nice-text-secondary);
|
|
281
|
+
text-align: center;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
.nice-reconciliation__empty-icon {
|
|
285
|
+
font-size: 2.5rem;
|
|
286
|
+
margin-bottom: 0.75rem;
|
|
287
|
+
opacity: 0.5;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
.nice-reconciliation__summary {
|
|
291
|
+
display: flex;
|
|
292
|
+
align-items: center;
|
|
293
|
+
gap: 1.5rem;
|
|
294
|
+
padding: 0.75rem 1rem;
|
|
295
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
296
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
297
|
+
font-size: 0.8125rem;
|
|
298
|
+
flex-wrap: wrap;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
.nice-reconciliation__summary-item {
|
|
302
|
+
display: flex;
|
|
303
|
+
align-items: center;
|
|
304
|
+
gap: 0.375rem;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.nice-reconciliation__summary-label {
|
|
308
|
+
color: var(--nice-text-secondary);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
.nice-reconciliation__summary-value {
|
|
312
|
+
font-weight: 600;
|
|
313
|
+
color: var(--nice-text-primary);
|
|
314
|
+
font-variant-numeric: tabular-nums;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.nice-reconciliation__summary-value--success {
|
|
318
|
+
color: var(--nice-success, #10b981);
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
.nice-reconciliation__summary-value--warning {
|
|
322
|
+
color: var(--nice-warning, #f59e0b);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
.nice-reconciliation__summary-value--danger {
|
|
326
|
+
color: var(--nice-danger, #ef4444);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
.nice-reconciliation__resizer {
|
|
330
|
+
width: 4px;
|
|
331
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
332
|
+
cursor: col-resize;
|
|
333
|
+
transition: background 0.15s ease;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
.nice-reconciliation__resizer:hover {
|
|
337
|
+
background: var(--nice-primary, #3b82f6);
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
.nice-reconciliation--vertical .nice-reconciliation__resizer {
|
|
341
|
+
width: 100%;
|
|
342
|
+
height: 4px;
|
|
343
|
+
cursor: row-resize;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
.nice-reconciliation__suggestions {
|
|
347
|
+
padding: 0.75rem 1rem;
|
|
348
|
+
background: var(--nice-info-bg, rgba(59, 130, 246, 0.08));
|
|
349
|
+
border-bottom: 1px solid var(--nice-info, #3b82f6);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
.nice-reconciliation__suggestion {
|
|
353
|
+
display: flex;
|
|
354
|
+
align-items: center;
|
|
355
|
+
gap: 0.75rem;
|
|
356
|
+
padding: 0.5rem;
|
|
357
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
358
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
359
|
+
margin-bottom: 0.5rem;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.nice-reconciliation__suggestion:last-child {
|
|
363
|
+
margin-bottom: 0;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/* Dark mode */
|
|
367
|
+
.dark .nice-reconciliation {
|
|
368
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
369
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
.dark .nice-reconciliation__toolbar,
|
|
373
|
+
.dark .nice-reconciliation__panel-header,
|
|
374
|
+
.dark .nice-reconciliation__summary {
|
|
375
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
376
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
.dark .nice-reconciliation__row--selected {
|
|
380
|
+
background: var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2));
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/* RTL support */
|
|
384
|
+
[dir="rtl"] .nice-reconciliation__row-amount {
|
|
385
|
+
direction: ltr;
|
|
386
|
+
text-align: left;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/* Detail Panel */
|
|
390
|
+
.nice-reconciliation__detail-panel {
|
|
391
|
+
position: fixed;
|
|
392
|
+
inset-inline-end: 0;
|
|
393
|
+
top: 0;
|
|
394
|
+
bottom: 0;
|
|
395
|
+
width: 420px;
|
|
396
|
+
max-width: 90vw;
|
|
397
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
398
|
+
box-shadow: -4px 0 24px var(--nice-overlay-15, rgba(0, 0, 0, 0.15));
|
|
399
|
+
z-index: 1000;
|
|
400
|
+
display: flex;
|
|
401
|
+
flex-direction: column;
|
|
402
|
+
transform: translateX(100%);
|
|
403
|
+
transition: transform 0.25s ease-out;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.nice-reconciliation__detail-panel--open {
|
|
407
|
+
transform: translateX(0);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
.nice-reconciliation__detail-header {
|
|
411
|
+
display: flex;
|
|
412
|
+
align-items: center;
|
|
413
|
+
justify-content: space-between;
|
|
414
|
+
padding: 1rem;
|
|
415
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
416
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
.nice-reconciliation__detail-title {
|
|
420
|
+
font-weight: 600;
|
|
421
|
+
font-size: 1rem;
|
|
422
|
+
color: var(--nice-text-primary);
|
|
423
|
+
display: flex;
|
|
424
|
+
align-items: center;
|
|
425
|
+
gap: 0.5rem;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
.nice-reconciliation__detail-close {
|
|
429
|
+
width: 2rem;
|
|
430
|
+
height: 2rem;
|
|
431
|
+
display: flex;
|
|
432
|
+
align-items: center;
|
|
433
|
+
justify-content: center;
|
|
434
|
+
background: transparent;
|
|
435
|
+
border: none;
|
|
436
|
+
cursor: pointer;
|
|
437
|
+
font-size: 1.25rem;
|
|
438
|
+
color: var(--nice-text-secondary);
|
|
439
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
440
|
+
transition: all 0.15s ease;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
.nice-reconciliation__detail-close:hover {
|
|
444
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
445
|
+
color: var(--nice-text-primary);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
.nice-reconciliation__detail-content {
|
|
449
|
+
flex: 1;
|
|
450
|
+
overflow: auto;
|
|
451
|
+
padding: 1rem;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
.nice-reconciliation__detail-section {
|
|
455
|
+
margin-bottom: 1.5rem;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
.nice-reconciliation__detail-section-title {
|
|
459
|
+
font-weight: 600;
|
|
460
|
+
font-size: 0.875rem;
|
|
461
|
+
color: var(--nice-text-primary);
|
|
462
|
+
margin-bottom: 0.75rem;
|
|
463
|
+
display: flex;
|
|
464
|
+
align-items: center;
|
|
465
|
+
gap: 0.375rem;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
.nice-reconciliation__detail-row {
|
|
469
|
+
display: flex;
|
|
470
|
+
justify-content: space-between;
|
|
471
|
+
align-items: flex-start;
|
|
472
|
+
padding: 0.5rem 0;
|
|
473
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
.nice-reconciliation__detail-row:last-child {
|
|
477
|
+
border-bottom: none;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
.nice-reconciliation__detail-label {
|
|
481
|
+
font-size: 0.8125rem;
|
|
482
|
+
color: var(--nice-text-secondary);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
.nice-reconciliation__detail-value {
|
|
486
|
+
font-size: 0.8125rem;
|
|
487
|
+
font-weight: 500;
|
|
488
|
+
color: var(--nice-text-primary);
|
|
489
|
+
text-align: end;
|
|
490
|
+
max-width: 60%;
|
|
491
|
+
word-break: break-word;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.nice-reconciliation__detail-divider {
|
|
495
|
+
height: 1px;
|
|
496
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
497
|
+
margin: 1rem 0;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.nice-reconciliation__detail-match-info {
|
|
501
|
+
padding: 0.75rem;
|
|
502
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
503
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
504
|
+
margin-bottom: 1rem;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
.nice-reconciliation__detail-match-header {
|
|
508
|
+
display: flex;
|
|
509
|
+
align-items: center;
|
|
510
|
+
gap: 0.5rem;
|
|
511
|
+
font-weight: 600;
|
|
512
|
+
font-size: 0.8125rem;
|
|
513
|
+
color: var(--nice-success-dark, #059669);
|
|
514
|
+
margin-bottom: 0.5rem;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
.nice-reconciliation__detail-match-detail {
|
|
518
|
+
font-size: 0.75rem;
|
|
519
|
+
color: var(--nice-text-secondary);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
.nice-reconciliation__detail-side-by-side {
|
|
523
|
+
display: grid;
|
|
524
|
+
grid-template-columns: 1fr 1fr;
|
|
525
|
+
gap: 1rem;
|
|
526
|
+
padding: 0.75rem;
|
|
527
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
528
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
529
|
+
margin-top: 0.75rem;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
.nice-reconciliation__detail-side-item {
|
|
533
|
+
padding: 0.5rem;
|
|
534
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
535
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
536
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.nice-reconciliation__detail-side-label {
|
|
540
|
+
font-size: 0.6875rem;
|
|
541
|
+
font-weight: 500;
|
|
542
|
+
text-transform: uppercase;
|
|
543
|
+
color: var(--nice-text-tertiary);
|
|
544
|
+
margin-bottom: 0.375rem;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
.nice-reconciliation__detail-side-amount {
|
|
548
|
+
font-size: 1.125rem;
|
|
549
|
+
font-weight: 600;
|
|
550
|
+
font-variant-numeric: tabular-nums;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
.nice-reconciliation__detail-backdrop {
|
|
554
|
+
position: fixed;
|
|
555
|
+
inset: 0;
|
|
556
|
+
background: var(--nice-overlay-30, rgba(0, 0, 0, 0.3));
|
|
557
|
+
z-index: 999;
|
|
558
|
+
opacity: 0;
|
|
559
|
+
pointer-events: none;
|
|
560
|
+
transition: opacity 0.2s ease;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
.nice-reconciliation__detail-backdrop--visible {
|
|
564
|
+
opacity: 1;
|
|
565
|
+
pointer-events: auto;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
.dark .nice-reconciliation__detail-panel {
|
|
569
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
570
|
+
box-shadow: -4px 0 24px var(--nice-overlay-40, rgba(0, 0, 0, 0.4));
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
.dark .nice-reconciliation__detail-header {
|
|
574
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
575
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
.dark .nice-reconciliation__detail-side-by-side {
|
|
579
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
.dark .nice-reconciliation__detail-side-item {
|
|
583
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
584
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
585
|
+
}
|
|
586
|
+
`;function nn(n,i="PLN",a="pl-PL"){return new Intl.NumberFormat(a,{style:"currency",currency:i,minimumFractionDigits:2,maximumFractionDigits:2}).format(n)}function Cn(n,i="pl-PL"){return n?(typeof n=="string"?new Date(n):n).toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function xi(n){return n>=80?"high":n>=50?"medium":"low"}function bi(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function yi({item:n,isSelected:i,isDragging:a,isDropTarget:s,suggestion:d,currency:m,locale:f,onSelect:u,onDoubleClick:C,onDragStart:w,onDragEnd:k,onDrop:F,disabled:N}){const J=n.status??"unmatched",X=d?.confidence??n.confidence,E=y=>{y.dataTransfer.setData("text/plain",n.id),y.dataTransfer.setData("source","statement"),y.dataTransfer.effectAllowed="move",w()},g=y=>{y.dataTransfer.types.includes("source")&&y.dataTransfer.getData("source")!=="statement"&&y.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${J} ${i?"nice-reconciliation__row--selected":""} ${a?"nice-reconciliation__row--dragging":""} ${s?"nice-reconciliation__row--drop-target":""}`,draggable:!N&&J!=="matched",onDragStart:E,onDragEnd:k,onDragOver:g,onDrop:F,onClick:u,onDoubleClick:C,role:"row","aria-selected":i,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${J}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsx("div",{className:"nice-reconciliation__row-date",children:Cn(n.date,f)}),e.jsx("div",{className:"nice-reconciliation__row-description",title:n.description,children:n.description}),n.counterparty&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:n.counterparty})]}),X!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${xi(X)}`,children:[X,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:nn(n.amount,m,f)})]})}function vi({item:n,isSelected:i,isDragging:a,isDropTarget:s,currency:d,locale:m,onSelect:f,onDoubleClick:u,onDragStart:C,onDragEnd:w,onDrop:k,disabled:F}){const N=n.status??"unmatched",J=E=>{E.dataTransfer.setData("text/plain",n.id),E.dataTransfer.setData("source","entry"),E.dataTransfer.effectAllowed="move",C()},X=E=>{E.dataTransfer.types.includes("source")&&E.dataTransfer.getData("source")!=="entry"&&E.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${N} ${i?"nice-reconciliation__row--selected":""} ${a?"nice-reconciliation__row--dragging":""} ${s?"nice-reconciliation__row--drop-target":""}`,draggable:!F&&N!=="matched",onDragStart:J,onDragEnd:w,onDragOver:X,onDrop:k,onClick:f,onDoubleClick:u,role:"row","aria-selected":i,tabIndex:0,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${N}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[Cn(n.date,m),n.documentNumber&&e.jsxs("span",{children:[" · ",n.documentNumber]})]}),e.jsx("div",{className:"nice-reconciliation__row-description",title:n.description,children:n.description}),n.partyName&&e.jsx("div",{className:"nice-reconciliation__row-counterparty",children:n.partyName})]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:nn(n.amount,d,m)})]})}const Ni=t.forwardRef(function(i,a){const{statements:s,bankTransactions:d,entries:m,accountingEntries:f,matches:u,defaultMatches:C=[],suggestions:w=[],config:k={},currency:F,showConfidence:N,statementPanelConfig:J,entryPanelConfig:X,onMatch:E,onAutoMatch:g,onUnmatch:y,onBatchAction:b,onFilterChange:_,onRequestSuggestions:j,onSelectionChange:M,onComplete:P,size:ee="medium",showToolbar:ce=!0,showFilters:de=!0,showSummary:le=!0,showSuggestions:me=!0,layout:ne="horizontal",enableDragDrop:ye=!0,enableKeyboard:B=!0,enableDetailPanel:ue=!0,loading:we=!1,disabled:Ne=!1,readOnly:O=!1,locale:V="pl-PL",labels:h={},className:x,style:l}=i,R=s??d??[],q=m??f??[],S=F??k.currency??"PLN",[se,oe]=t.useState(C),[re,G]=t.useState(new Set),[_e,Me]=t.useState(new Set),[ze,Te]=t.useState(null),[Be,Fe]=t.useState(null),[ke,U]=t.useState({}),[o,pe]=t.useState(null),te=u??se,I=t.useRef(null),T=t.useRef(null);t.useEffect(()=>{const v="nice-reconciliation-styles";if(!document.getElementById(v)){const Z=document.createElement("style");Z.id=v,Z.textContent=_i,document.head.appendChild(Z)}},[]);const H=t.useMemo(()=>{const v=new Set;return te.forEach(Z=>Z.statementIds.forEach(he=>v.add(he))),v},[te]),ve=t.useMemo(()=>{const v=new Set;return te.forEach(Z=>Z.entryIds.forEach(he=>v.add(he))),v},[te]),Ie=t.useMemo(()=>{const v=R.filter(ge=>!H.has(ge.id)),Z=q.filter(ge=>!ve.has(ge.id)),he=R.reduce((ge,Re)=>ge+Re.amount,0),Ue=q.reduce((ge,Re)=>ge+Re.amount,0),Qe=R.filter(ge=>H.has(ge.id)).reduce((ge,Re)=>ge+Re.amount,0);return{totalStatements:R.length,totalEntries:q.length,matchedStatements:R.length-v.length,matchedEntries:q.length-Z.length,unmatchedStatements:v.length,unmatchedEntries:Z.length,statementTotal:he,entryTotal:Ue,matchedAmount:Qe,unmatchedStatementAmount:v.reduce((ge,Re)=>ge+Re.amount,0),unmatchedEntryAmount:Z.reduce((ge,Re)=>ge+Re.amount,0),difference:he-Ue,matchPercentage:R.length>0?Math.round((R.length-v.length)/R.length*100):0,matchCount:te.length,partialMatchCount:te.filter(ge=>ge.status==="partial").length,pendingSuggestions:w.length}},[R,q,te,w,H,ve]),fe=t.useCallback((v,Z)=>{const he=R.filter(We=>v.includes(We.id)),Ue=q.filter(We=>Z.includes(We.id));if(he.length===0||Ue.length===0)return null;const Qe=he.reduce((We,Ye)=>We+Ye.amount,0),ge=Ue.reduce((We,Ye)=>We+Ye.amount,0),Re=Math.abs(Qe-ge),$e=k.amountTolerance??.01,Ee={id:bi(),statementIds:v,entryIds:Z,status:Re<=$e?"matched":"partial",statementTotal:Qe,entryTotal:ge,difference:Re,confidence:Re<=$e?100:Math.max(0,100-Re/Math.max(Math.abs(Qe),1)*100),matchedBy:"user",matchedAt:new Date};return u||oe(We=>[...We,Ee]),E?.(Ee,he,Ue),G(new Set),Me(new Set),Ee},[R,q,k.amountTolerance,u,E]),ie=t.useCallback(v=>{const Z=te.find(he=>he.id===v);Z&&(u||oe(he=>he.filter(Ue=>Ue.id!==v)),y?.(v,Z.statementIds,Z.entryIds))},[te,u,y]),Ge=t.useCallback(async()=>{const v=[],Z=new Set(H),he=new Set(ve),Ue=k.amountTolerance??.01,Qe=k.dateTolerance??3;for(const ge of R){if(Z.has(ge.id))continue;const Re=q.filter($e=>{if(he.has($e.id)||Math.abs(ge.amount-$e.amount)>Ue)return!1;const We=new Date(ge.date),Ye=new Date($e.date);return!(Math.abs(We.getTime()-Ye.getTime())/(1e3*60*60*24)>Qe)});if(Re.length===1){const $e=Re[0],Ee=fe([ge.id],[$e.id]);Ee&&(v.push(Ee),Z.add(ge.id),he.add($e.id))}}return b?.("autoMatch",v),v},[R,q,H,ve,k,fe,b]),un=t.useCallback((v,Z,he,Ue)=>{Ue!==Z&&(Ue==="statement"?fe([he],[v]):fe([v],[he]),Te(null),Fe(null))},[fe]),K=t.useCallback(()=>{const v=Array.from(re),Z=Array.from(_e);v.length>0&&Z.length>0&&fe(v,Z)},[re,_e,fe]);t.useEffect(()=>{M?.(Array.from(re),Array.from(_e))},[re,_e,M]),t.useImperativeHandle(a,()=>({getMatches:()=>te,getUnmatchedStatements:()=>R.filter(v=>!H.has(v.id)),getUnmatchedEntries:()=>q.filter(v=>!ve.has(v.id)),createMatch:fe,removeMatch:ie,autoMatch:Ge,getSuggestions:async v=>j?j(v??R.filter(Z=>!H.has(Z.id)).map(Z=>Z.id)):[],applySuggestion:v=>fe([v.statementId],v.entryIds),approveAll:()=>{b?.("approveAll",te)},clearAll:()=>{u||oe([]),b?.("clearAll",[])},exportMatched:v=>{b?.("exportMatched",te)},getSummary:()=>Ie,reset:()=>{u||oe([]),G(new Set),Me(new Set),U({})},focusStatements:()=>I.current?.focus(),focusEntries:()=>T.current?.focus()}),[te,R,q,H,ve,fe,ie,Ge,j,b,u,Ie]);const an=t.useMemo(()=>R.filter(v=>{if(ke.status&&ke.status.length>0){const Z=H.has(v.id)?"matched":"unmatched";if(!ke.status.includes(Z))return!1}if(ke.searchText){const Z=ke.searchText.toLowerCase();if(!v.description?.toLowerCase().includes(Z)&&!v.counterparty?.toLowerCase().includes(Z))return!1}return!0}),[R,ke,H]),Xe=t.useMemo(()=>q.filter(v=>{if(ke.status&&ke.status.length>0){const Z=ve.has(v.id)?"matched":"unmatched";if(!ke.status.includes(Z))return!1}if(ke.searchText){const Z=ke.searchText.toLowerCase();if(!v.description?.toLowerCase().includes(Z)&&!v.partyName?.toLowerCase().includes(Z))return!1}return!0}),[q,ke,ve]),Je=re.size>0&&_e.size>0&&!O&&!Ne;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${ne} ${x??""}`,style:l,children:[ce&&e.jsxs("div",{className:"nice-reconciliation__toolbar",children:[e.jsxs("div",{className:"nice-reconciliation__toolbar-group",children:[e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--primary",onClick:Ge,disabled:Ne||O||we,children:[e.jsx(z.NiceIcon,{name:"zap",size:14})," ",h.autoMatch??"Auto-match"]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:K,disabled:!Je||we,children:[e.jsx(z.NiceIcon,{name:"link",size:14})," Match Selected"]})]}),e.jsxs("div",{className:"nice-reconciliation__toolbar-group nice-reconciliation__toolbar-group--end",children:[e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>b?.("approveAll",te),disabled:te.length===0||Ne||we,children:[e.jsx(z.NiceIcon,{name:"check",size:14})," ",h.approveAll??"Approve All"]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{u||oe([]),b?.("clearAll",[])},disabled:te.length===0||Ne||O||we,children:[e.jsx(z.NiceIcon,{name:"close",size:14})," ",h.clearAll??"Clear All"]})]})]}),e.jsxs("div",{className:"nice-reconciliation__content",children:[e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--statements",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:[e.jsx(z.NiceIcon,{name:"file",size:14})," ",h.statementPanelTitle??"Bank Statement",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:an.length})]})}),e.jsx("div",{ref:I,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:an.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(z.NiceIcon,{name:"clipboard",size:32})}),h.noStatements??"No statement items"]}):an.map(v=>e.jsx(yi,{item:{...v,status:H.has(v.id)?"matched":"unmatched"},isSelected:re.has(v.id),isDragging:ze===v.id,isDropTarget:Be===v.id,suggestion:w.find(Z=>Z.statementId===v.id),currency:S,locale:V,onSelect:()=>{Ne||G(Z=>{const he=new Set(Z);return he.has(v.id)?he.delete(v.id):he.add(v.id),he})},onDoubleClick:()=>ue&&pe({type:"statement",id:v.id}),onDragStart:()=>Te(v.id),onDragEnd:()=>{Te(null),Fe(null)},onDrop:()=>{ze&&ze!==v.id&&un(v.id,"statement",ze,"entry")},disabled:Ne||O||!ye},v.id))})]}),e.jsxs("div",{className:"nice-reconciliation__panel nice-reconciliation__panel--entries",children:[e.jsx("div",{className:"nice-reconciliation__panel-header",children:e.jsxs("span",{className:"nice-reconciliation__panel-title",children:[e.jsx(z.NiceIcon,{name:"book",size:14})," ",h.entryPanelTitle??"Book Entries",e.jsx("span",{className:"nice-reconciliation__panel-badge",children:Xe.length})]})}),e.jsx("div",{ref:T,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:Xe.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(z.NiceIcon,{name:"book",size:32})}),h.noEntries??"No book entries"]}):Xe.map(v=>e.jsx(vi,{item:{...v,status:ve.has(v.id)?"matched":"unmatched"},isSelected:_e.has(v.id),isDragging:ze===v.id,isDropTarget:Be===v.id,currency:S,locale:V,onSelect:()=>{Ne||Me(Z=>{const he=new Set(Z);return he.has(v.id)?he.delete(v.id):he.add(v.id),he})},onDoubleClick:()=>ue&&pe({type:"entry",id:v.id}),onDragStart:()=>Te(v.id),onDragEnd:()=>{Te(null),Fe(null)},onDrop:()=>{ze&&ze!==v.id&&un(v.id,"entry",ze,"statement")},disabled:Ne||O||!ye},v.id))})]})]}),le&&e.jsxs("div",{className:"nice-reconciliation__summary",children:[e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Matched:"}),e.jsxs("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--success",children:[Ie.matchedStatements,"/",Ie.totalStatements," (",Ie.matchPercentage,"%)"]})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Matched Amount:"}),e.jsx("span",{className:"nice-reconciliation__summary-value",children:nn(Ie.matchedAmount,S,V)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Unmatched:"}),e.jsx("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--warning",children:nn(Ie.unmatchedStatementAmount,S,V)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:"Difference:"}),e.jsx("span",{className:`nice-reconciliation__summary-value ${Math.abs(Ie.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:nn(Ie.difference,S,V)})]})]}),ue&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`nice-reconciliation__detail-backdrop ${o?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>pe(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${o?"nice-reconciliation__detail-panel--open":""}`,children:o&&e.jsx(ji,{type:o.type,id:o.id,statements:R,entries:q,matches:te,currency:S,locale:V,labels:h,onClose:()=>pe(null)})})]})]})});function ji({type:n,id:i,statements:a,entries:s,matches:d,currency:m,locale:f,labels:u,onClose:C}){const w=n==="statement"?a.find(E=>E.id===i):s.find(E=>E.id===i),k=n==="statement"?d.find(E=>E.statementIds.includes(i)):d.find(E=>E.entryIds.includes(i)),F=k?n==="statement"?s.filter(E=>k.entryIds.includes(E.id)):a.filter(E=>k.statementIds.includes(E.id)):[];if(!w)return null;const N=n==="statement",J=N?w:null,X=N?null:w;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"nice-reconciliation__detail-header",children:[e.jsxs("span",{className:"nice-reconciliation__detail-title",children:[e.jsx(z.NiceIcon,{name:N?"file":"book",size:14})," ",N?u.statementDetails??"Transaction Details":u.entryDetails??"Entry Details"]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:C,"aria-label":"Close",children:e.jsx(z.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[k&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:[e.jsx(z.NiceIcon,{name:"check",size:14})," ",u.matchedWith??"Matched"," (",k.confidence?.toFixed(0)??100,"% confidence)"]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:k.matchedBy==="ai"?u.matchedByAI??"Matched automatically by AI":u.matchedManually??"Matched manually"}),e.jsxs("div",{className:"nice-reconciliation__detail-side-by-side",children:[e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:u.statementTotal??"Statement"}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${k.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:nn(k.statementTotal,m,f)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:u.entryTotal??"Book Entry"}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${k.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:nn(k.entryTotal,m,f)})]})]}),k.difference>.01&&e.jsxs("div",{className:"nice-reconciliation__detail-row",style:{marginTop:"0.5rem",borderBottom:"none"},children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.difference??"Difference",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{color:"var(--nice-warning, #f59e0b)"},children:nn(k.difference,m,f)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(z.NiceIcon,{name:"clipboard",size:14})," ",N?u.transactionInfo??"Transaction Information":u.entryInfo??"Entry Information"]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.date??"Date",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:Cn(w.date,f)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.description??"Description",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:w.description})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.amount??"Amount",":"]}),e.jsx("span",{className:`nice-reconciliation__detail-value ${w.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:nn(w.amount,m,f)})]}),N&&J?.counterparty&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.counterparty??"Counterparty",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:J.counterparty})]}),N&&J?.counterpartyAccount&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.accountNumber??"Account",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:J.counterpartyAccount})]}),!N&&X?.partyName&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.party??"Party",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:X.partyName})]}),!N&&X?.documentNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.documentRef??"Document Ref",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:X.documentNumber})]}),N&&J?.referenceNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[u.reference??"Reference",":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:J.referenceNumber})]})]}),F.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(z.NiceIcon,{name:"link",size:14})," ",N?u.matchedEntries??"Matched Entries":u.matchedStatements??"Matched Statements"]}),F.map(E=>e.jsxs("div",{style:{padding:"0.5rem",background:"var(--nice-bg-secondary, #f9fafb)",borderRadius:"0.25rem",marginBottom:"0.5rem",fontSize:"0.8125rem"},children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"0.25rem"},children:E.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:Cn(E.date,f)}),e.jsx("span",{style:{fontWeight:600,color:E.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:nn(E.amount,m,f)})]})]},E.id))]})]})]})}const wi=({queries:n,currentFilter:i,currentColumns:a,currentSort:s,onLoad:d,onSave:m,onUpdate:f,onDelete:u,onShare:C,onSetDefault:w,allowSharing:k=!0,allowPinning:F=!0,position:N="dropdown",className:J,style:X,"data-testid":E})=>{const{t:g}=z.useNiceTranslation(),[y,b]=t.useState(!1),[_,j]=t.useState(""),[M,P]=t.useState(!1),[ee,ce]=t.useState(""),[de,le]=t.useState(""),[me,ne]=t.useState(!1),ye=n.filter(O=>O.name.toLowerCase().includes(_.toLowerCase())),B=ye.filter(O=>!O.isShared),ue=ye.filter(O=>O.isShared),we=async()=>{if(ee.trim()){P(!0);try{await m({name:ee,description:de||void 0,filter:i??{},columns:a,sort:s}),ne(!1),ce(""),le("")}finally{P(!1)}}},Ne=O=>e.jsxs("div",{className:"nice-saved-query__item",children:[O.icon&&e.jsx("span",{className:"nice-saved-query__icon","aria-hidden":"true",children:O.icon}),e.jsx("span",{className:"nice-saved-query__name",children:O.name}),O.isDefault&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--default",children:g("savedQuery.default","default")}),O.isShared&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--shared",children:g("savedQuery.shared","shared")}),O.isPinned&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--pinned",children:g("savedQuery.pinned","pinned")}),e.jsxs("div",{className:"nice-saved-query__actions",children:[e.jsx("button",{onClick:()=>{d(O),b(!1)},type:"button",children:g("savedQuery.load","Load")}),w&&e.jsx("button",{onClick:()=>w(O.id),type:"button",title:g("savedQuery.setDefault","Set as default"),"aria-label":g("savedQuery.setDefault","Set as default"),children:e.jsx(z.NiceIcon,{name:"star",size:14})}),k&&C&&e.jsx("button",{onClick:()=>C(O.id,[]),type:"button",title:g("savedQuery.share","Share"),"aria-label":g("savedQuery.share","Share"),children:e.jsx(z.NiceIcon,{name:"external-link",size:14})}),F&&e.jsx("button",{onClick:()=>f(O.id,{...O}),type:"button",title:g("savedQuery.pin","Pin"),"aria-label":g("savedQuery.pin","Pin"),children:e.jsx(z.NiceIcon,{name:"map-pin",size:14})}),e.jsx("button",{onClick:()=>u(O.id),type:"button",title:g("savedQuery.remove","Remove"),"aria-label":`${g("savedQuery.removeQuery","Remove query")} ${O.name}`,children:e.jsx(z.NiceIcon,{name:"close",size:14})})]})]},O.id);return e.jsxs("div",{className:`nice-saved-query nice-saved-query--${N} ${y?"nice-saved-query--open":""} ${J??""}`,style:X,"data-testid":E,children:[e.jsx("button",{className:"nice-saved-query__trigger",onClick:()=>b(O=>!O),"aria-expanded":y,"aria-haspopup":"listbox",type:"button",children:g("savedQuery.trigger","Views and queries")}),y&&e.jsxs("div",{className:"nice-saved-query__panel",role:"dialog","aria-label":g("savedQuery.manage","Manage saved queries"),children:[e.jsxs("div",{className:"nice-saved-query__search-row",children:[e.jsx("input",{type:"search",placeholder:g("savedQuery.searchPlaceholder","Search queries…"),value:_,onChange:O=>j(O.target.value),"aria-label":g("savedQuery.search","Search queries")}),e.jsxs("button",{onClick:()=>ne(O=>!O),type:"button",children:[e.jsx(z.NiceIcon,{name:"plus",size:12})," ",g("savedQuery.saveCurrent","Save current view")]})]}),me&&e.jsxs("div",{className:"nice-saved-query__save-form",children:[e.jsx("input",{type:"text",placeholder:g("savedQuery.name","Query name"),value:ee,onChange:O=>ce(O.target.value),"aria-label":g("savedQuery.name","Query name")}),e.jsx("input",{type:"text",placeholder:g("savedQuery.descriptionPlaceholder","Description (optional)"),value:de,onChange:O=>le(O.target.value),"aria-label":g("savedQuery.description","Query description")}),e.jsx("button",{onClick:we,disabled:M||!ee.trim(),type:"button",children:M?g("savedQuery.saving","Saving…"):g("savedQuery.save","Save")}),e.jsx("button",{onClick:()=>ne(!1),type:"button",children:g("savedQuery.cancel","Cancel")})]}),B.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-mine",children:[e.jsx("h3",{id:"nice-saved-query-mine",className:"nice-saved-query__group-title",children:"Moje"}),B.map(Ne)]}),ue.length>0&&e.jsxs("section",{className:"nice-saved-query__group","aria-labelledby":"nice-saved-query-shared",children:[e.jsx("h3",{id:"nice-saved-query-shared",className:"nice-saved-query__group-title",children:g("savedQuery.sharedSection","Shared")}),ue.map(Ne)]}),ye.length===0&&e.jsx("p",{className:"nice-saved-query__empty",children:g("savedQuery.empty","No saved queries")})]})]})};exports.NiceDataGridAI=jt;exports.NiceKanbanBoard=Hn;exports.NiceList=Rt;exports.NiceModuleGrid=ni;exports.NiceReconciliationView=Ni;exports.NiceSavedQueryPanel=wi;exports.NiceSpreadsheet=Yn;exports.NiceTable=Et;exports.NiceTileView=zt;exports.NiceTreeGrid=Ct;exports.NiceTreeList=Dt;exports.NiceTreeView=At;
|