@nice2dev/ui 1.3.8 → 1.3.9
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 +70 -0
- package/dist/NiceSavedQueryPanel-B8hVgWR2.cjs +587 -0
- package/dist/NiceSavedQueryPanel-BFtY9GOP.js +6002 -0
- package/dist/NiceTree.doc-AIR9cRQp.js +40 -0
- package/dist/NiceTree.doc-DGrIAx3G.cjs +16 -0
- package/dist/data.cjs +1 -1
- package/dist/data.d.ts +146 -12
- package/dist/data.mjs +1 -1
- package/dist/index.cjs +77 -77
- package/dist/index.css +1 -1
- package/dist/index.d.ts +145 -12
- package/dist/index.mjs +1062 -1099
- package/dist/style.css +1 -1
- package/package.json +4 -4
|
@@ -0,0 +1,587 @@
|
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),zt=require("@nice2dev/i18n"),k=require("@nice2dev/ui-core"),t=require("react"),$t=require("./NiceDataGrid-C_E6zIGS.cjs"),Qe=require("./NiceButton-DzCqkG5a.cjs"),Lt=require("./NiceForm-D2P6XuaT.cjs"),Pt=require("./NiceModal-BRVzjuUN.cjs"),Ot=require("./core-lBFqvT0V.cjs"),Vt=require("./NiceSelect-CTwSAb8G.cjs"),ft=require("./no-code-DnT061qn.cjs"),pt=require("./NiceColorPicker-Bzvei7D6.cjs"),Ft=[];function Bt(n,i){return n.filter(a=>i.every(s=>{const l=a[s.field],d=s.value;switch(s.operator){case"eq":return l===d;case"ne":return l!==d;case"gt":return typeof l=="number"&&typeof d=="number"&&l>d;case"gte":return typeof l=="number"&&typeof d=="number"&&l>=d;case"lt":return typeof l=="number"&&typeof d=="number"&&l<d;case"lte":return typeof l=="number"&&typeof d=="number"&&l<=d;case"contains":return String(l).toLowerCase().includes(String(d).toLowerCase());case"startsWith":return String(l).toLowerCase().startsWith(String(d).toLowerCase());case"endsWith":return String(l).toLowerCase().endsWith(String(d).toLowerCase());default:return!0}}))}function Kt(n){return n.map(i=>({field:i.field,type:i.dataType||"string",label:typeof i.header=="string"?i.header:i.field}))}function Ut(n,i){const{enableAI:a=!0,aiModel:s,enableNLSearch:l=!0,enableInsights:d=!0,nlPlaceholder:o,onAIFilter:c,onInsights:f,showAISearchBar:p=!0,exampleQueries:C=["Show items from last week","Filter by status = active","Orders over $1000",'Names starting with "A"'],columns:w=Ft,data:L,...D}=n,[I,P]=t.useState(""),[_,g]=t.useState([]),[j,x]=t.useState([]),[O,v]=t.useState(!1),[K,Q]=t.useState(null),ue=t.useRef(null),{t:re}=zt.useNiceTranslation(),_e=k.useNiceAI(),{parseFilter:pe,isLoading:ee}=k.useNaturalLanguageFilter(),ve=a&&_e.isConfigured,U=_.length>0?Bt(L||[],_):L,le=t.useCallback(async A=>{if(!ve||!l||!A.trim())return;Q(A);const b=Kt(w);try{const de=await pe(A,b);g(de),c?.(A,de)}catch{g([])}},[ve,l,w,pe,c]),Ce=t.useCallback(()=>{g([]),Q(null),P("")},[]),xe=t.useCallback(()=>_,[_]),oe=t.useCallback(async()=>{if(!ve||!d||!L?.length)return[];try{const A=await _e.complete([{role:"user",content:`Analyze this data and provide 3-5 key insights. Data sample (${L.length} total rows): ${JSON.stringify(L.slice(0,20))}
|
|
2
|
+
|
|
3
|
+
Columns: ${w.map(b=>b.field).join(", ")}
|
|
4
|
+
|
|
5
|
+
Return a JSON array of insight strings. Be specific with numbers and trends.`}],{temperature:.3,maxTokens:500});try{const b=JSON.parse(A.content),de=Array.isArray(b)?b:[];return x(de),f?.(de),de}catch{return[]}}catch{return[]}},[ve,d,L,w,_e,f]),R=A=>{A.preventDefault(),I.trim()&&le(I)},W=A=>{P(A),le(A)};return t.useImperativeHandle(i,()=>({applyNLFilter:le,clearAIFilters:Ce,getAIFilters:xe,generateInsights:oe})),e.jsxs("div",{className:"nice-data-grid-ai","data-testid":n["data-testid"],children:[p&&ve&&l&&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:re("dataGridAI.ai","AI")})}),e.jsxs("form",{onSubmit:R,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(k.NiceIcon,{name:"search",size:14})}),e.jsx("input",{ref:ue,type:"text",value:I,onChange:A=>P(A.target.value),placeholder:o||re("dataGridAI.searchPlaceholder","Search with natural language..."),className:"nice-data-grid-ai__input",disabled:ee}),ee&&e.jsx("span",{className:"nice-data-grid-ai__loading-spinner"}),I&&!ee&&e.jsx("button",{type:"button",className:"nice-data-grid-ai__clear-input",onClick:()=>P(""),"aria-label":re("dataGridAI.clearInput","Clear"),children:e.jsx(k.NiceIcon,{name:"close",size:14})})]}),e.jsx("button",{type:"submit",className:"nice-data-grid-ai__search-btn",disabled:ee||!I.trim(),children:ee?re("dataGridAI.searching","Searching..."):re("dataGridAI.search","Search")})]}),d&&e.jsxs("button",{type:"button",className:"nice-data-grid-ai__insights-btn",onClick:()=>{oe(),v(!0)},disabled:ee||!L?.length,title:re("dataGridAI.generateInsights","Generate AI Insights"),children:[e.jsx(k.NiceIcon,{name:"lightbulb",size:14})," ",re("dataGridAI.insights","Insights")]})]}),p&&ve&&l&&!K&&C.length>0&&e.jsxs("div",{className:"nice-data-grid-ai__examples",children:[e.jsx("span",{className:"nice-data-grid-ai__examples-label",children:re("dataGridAI.tryAsking","Try asking:")}),e.jsx("div",{className:"nice-data-grid-ai__examples-list",children:C.slice(0,4).map((A,b)=>e.jsxs("button",{type:"button",className:"nice-data-grid-ai__example",onClick:()=>W(A),children:['"',A,'"']},b))})]}),K&&_.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(k.NiceIcon,{name:"target",size:14})}),e.jsxs("span",{className:"nice-data-grid-ai__filter-query",children:['"',K,'"']}),e.jsxs("span",{className:"nice-data-grid-ai__filter-count",children:["(",U?.length||0," ",re("dataGridAI.results","results"),")"]})]}),e.jsx("div",{className:"nice-data-grid-ai__filter-badges",children:_.map((A,b)=>e.jsxs("span",{className:"nice-data-grid-ai__filter-badge",children:[A.field," ",A.operator," ",String(A.value)]},b))}),e.jsxs("button",{type:"button",className:"nice-data-grid-ai__clear-filter",onClick:Ce,children:[e.jsx(k.NiceIcon,{name:"close",size:14})," ",re("dataGridAI.clearFilter","Clear")]})]}),e.jsx("div",{className:"nice-data-grid-ai__grid-wrapper",children:e.jsx($t.NiceDataGrid,{columns:w,data:U,...D})}),O&&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(k.NiceIcon,{name:"lightbulb",size:14})," ",re("dataGridAI.aiInsights","AI Insights")]}),e.jsx("button",{type:"button",className:"nice-data-grid-ai__insights-close",onClick:()=>v(!1),"aria-label":re("dataGridAI.closeInsights","Close"),children:e.jsx(k.NiceIcon,{name:"close",size:14})})]}),e.jsx("div",{className:"nice-data-grid-ai__insights-body",children:ee?e.jsx("div",{className:"nice-data-grid-ai__insights-loading",children:re("dataGridAI.analyzing","Analyzing data...")}):j.length>0?e.jsx("ul",{className:"nice-data-grid-ai__insights-list",children:j.map((A,b)=>e.jsxs("li",{className:"nice-data-grid-ai__insight",children:[e.jsx("span",{className:"nice-data-grid-ai__insight-bullet",children:"•"}),A]},b))}):e.jsx("div",{className:"nice-data-grid-ai__insights-empty",children:re("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:()=>oe(),disabled:ee,children:[e.jsx(k.NiceIcon,{name:"refresh",size:14})," ",re("dataGridAI.refresh","Refresh")]})})]})]})}const Gt=t.forwardRef(Ut);function Wt(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}const st=({text:n,query:i,highlightTag:a="mark",highlightClassName:s="",caseSensitive:l=!1,className:d="",style:o,testId:c,"data-testid":f})=>{const p=(Array.isArray(i)?i:[i]).map(D=>(D??"").trim()).filter(Boolean).map(Wt);if(p.length===0||!n)return e.jsx("span",{className:`nice-highlight ${d}`,style:o,"data-testid":f??c,children:n});const C=l?"g":"gi",w=new RegExp(`(${p.join("|")})`,C),L=n.split(w);return e.jsx("span",{className:`nice-highlight ${d}`,style:o,"data-testid":f??c,children:L.map((D,I)=>I%2===1?e.jsx(a,{className:`nice-highlight__mark ${s}`.trim(),children:D},I):e.jsx(t.Fragment,{children:D},I))})};process.env.NODE_ENV!=="production"&&(st.displayName="NiceHighlight");function Qt(n,i,a){const s=new Map,l=[];n.forEach(o=>s.set(String(o[i]),{data:o,children:[],key:String(o[i]),depth:0})),n.forEach(o=>{const c=o[a],f=s.get(String(o[i]));if(c!=null&&c!==""&&s.has(String(c))){const p=s.get(String(c));f.depth=p.depth+1,p.children.push(f)}else l.push(f)});const d=(o,c)=>{o.forEach(f=>{f.depth=c,d(f.children,c+1)})};return d(l,0),l}function kt(n,i,a,s=0){return n.map(l=>({data:l,key:String(l[a]),depth:s,children:Array.isArray(l[i])?kt(l[i],i,a,s+1):[]}))}function it(n){const i=[],a=s=>{s.forEach(l=>{l.children.length>0&&(i.push(l.key),a(l.children))})};return a(n),i}function qt(n){const i=[],a=s=>{s.forEach(l=>{i.push(l.key),a(l.children)})};return a(n),i}function wt(n,i,a){return!i||!a?n:[...n].sort((l,d)=>{const o=l.data[i]??"",c=d.data[i]??"",f=typeof o=="number"&&typeof c=="number"?o-c:String(o).localeCompare(String(c));return a==="desc"?-f:f}).map(l=>({...l,children:wt(l.children,i,a)}))}function Yt(n,i,a){const s=new Set,l=new Set,d=o=>o.reduce((c,f)=>{const p=d(f.children),C=i(f);return C&&l.add(f.key),p.length>0&&s.add(f.key),C&&a?c.push(f):(C||p.length>0)&&c.push({...f,children:p}),c},[]);return{tree:d(n),expand:s,matched:l}}function Ht(n,i){const a=(s,l)=>s.reduce((d,o)=>{if(l)return d.push({...o,children:a(o.children,!0)}),d;if(i.isCheckable(o.key)){const f=i.state(o.key);if(f!=="unchecked"){const p=i.isLeaf(o.key)&&f==="checked";d.push({...o,children:a(o.children,p)})}return d}const c=a(o.children,!1);return c.length>0&&d.push({...o,children:c}),d},[]);return a(n,!1)}function Zt(n,i){const a=[],s=(l,d)=>{l.forEach((o,c)=>{a.push({node:o,level:d,posInSet:c+1,setSize:l.length}),o.children.length>0&&i(o.key)&&s(o.children,d+1)})};return s(n,1),a}function rt(n,i,a={}){const{getKey:s,getChildren:l,isCheckable:d,isDisabled:o}=i,c=a.inheritDisabled!==!1,f=[],p=[],C=[],w=new Map,L=(I,P,_,g)=>{const j=s(I);if(w.has(j))return;const x=d?d(I):!0,O=(o?o(I):!1)||c&&g,v={pos:f.length,subtreeEnd:0,leafStart:p.length,leafEnd:0,checkable:x,leaf:!1,disabled:O,parent:_};w.set(j,v),f.push(j);const K=l(I,P);if(K)for(const Q of K)L(Q,P+1,j,O);x&&p.length===v.leafStart&&(v.leaf=!0,p.push(j),C.push(O)),v.leafEnd=p.length,v.subtreeEnd=f.length};for(const I of n)L(I,0,void 0,!1);const D=new Int32Array(p.length+1);for(let I=0;I<p.length;I++)D[I+1]=D[I]+(C[I]?1:0);return{keys:f,leaves:p,records:w,lockedBefore:D,has:I=>w.has(I),isCheckable:I=>w.get(I)?.checkable??!1,isLeaf:I=>w.get(I)?.leaf??!1,isLocked:I=>{const P=w.get(I);if(!P)return!1;const _=P.leafEnd-P.leafStart;return P.disabled||_===0?P.disabled:D[P.leafEnd]-D[P.leafStart]===_},leavesOf:I=>{const P=w.get(I);return P?p.slice(P.leafStart,P.leafEnd):[]},parentOf:I=>w.get(I)?.parent}}function ct(n,i){const a=new Set,s=[];if(!i)return{leaves:a,unknown:s};const l=new Set;for(const d of i){const o=n.records.get(d);if(!o){l.has(d)||(l.add(d),s.push(d));continue}if(o.checkable)for(let c=o.leafStart;c<o.leafEnd;c++)a.add(n.leaves[c])}return{leaves:a,unknown:s}}function Hn(n,i){const a=new Int32Array(n.leaves.length+1);for(let o=0;o<n.leaves.length;o++)a[o+1]=a[o]+(i.has(n.leaves[o])?1:0);const s=o=>{const c=n.records.get(o);return c?{checked:a[c.leafEnd]-a[c.leafStart],total:c.leafEnd-c.leafStart}:{checked:0,total:0}},l=o=>{const{checked:c,total:f}=s(o);return c===0||f===0?"unchecked":c===f?"checked":"indeterminate"},d=[];for(const o of n.keys){const c=n.records.get(o);c.checkable&&!c.leaf&&l(o)==="indeterminate"&&d.push(o)}return{state:l,count:s,total:{checked:a[n.leaves.length],total:n.leaves.length},halfChecked:d}}function lt(n,i,a,s){const l=n.records.get(a);if(!l||!l.checkable)return i;const d=[];for(let c=l.leafStart;c<l.leafEnd;c++)n.lockedBefore[c+1]===n.lockedBefore[c]&&d.push(n.leaves[c]);if(d.length===0)return i;const o=!d.every(c=>i.has(c));return jt(i,d,o)}function gt(n,i,a,s){const l=[];for(const d of a){const o=n.records.get(d);o?.leaf&&!o.disabled&&l.push(d)}return l.length===0?i:jt(i,l,s)}function jt(n,i,a){const s=new Set(n);for(const l of i)a?s.add(l):s.delete(l);return s}function Zn(n,i,a,s=[]){const l=[];if(a==="leaves")for(const d of n.leaves)i.has(d)&&l.push(d);else{const d=new Int32Array(n.leaves.length+1);for(let c=0;c<n.leaves.length;c++)d[c+1]=d[c]+(i.has(n.leaves[c])?1:0);const o=c=>c.leafEnd>c.leafStart&&d[c.leafEnd]-d[c.leafStart]===c.leafEnd-c.leafStart;for(let c=0;c<n.keys.length;){const f=n.keys[c],p=n.records.get(f);if(p.checkable&&o(p)&&(l.push(f),a==="parents")){c=p.subtreeEnd;continue}c++}}for(const d of s)l.push(d);return l}const Xt=[],Jt=[],at=[],ei=new Set,ni=new Map,ti=[],_t=["expandAll","collapseAll","onlyChecked","clearChecked"],bt=10;function ii({node:n,level:i,posInSet:a,setSize:s,rowIndex:l,ariaRowIndex:d,columns:o,highlight:c,query:f,hasChildren:p,expanded:C,expandLabel:w,collapseLabel:L,checkMode:D,hasCheckbox:I,checkState:P,checkLabel:_,locked:g,countChecked:j,countTotal:x,countTitle:O,selectColumn:v,selected:K,selectLabel:Q,readOnly:ue,className:re,clickable:_e,height:pe,handlers:ee}){const ve=I?e.jsx("input",{type:"checkbox",className:"nice-treegrid__check-input",checked:P==="checked",ref:le=>{le&&(le.indeterminate=P==="indeterminate")},disabled:g||ue,tabIndex:-1,"aria-label":_,onClick:le=>le.stopPropagation(),onChange:le=>{ee.toggleCheck(n.key),le.currentTarget.closest("tr")?.focus({preventScroll:!0})}}):null,U=["nice-treegrid__row",D!=="none"&&!I?"nice-treegrid__row--info":"",g?"nice-treegrid__row--disabled":"",I&&P==="checked"?"nice-treegrid__row--checked":"",K?"nice-datagrid__row--selected":"",re??""].filter(Boolean).join(" ");return e.jsxs("tr",{className:U,"data-key":n.key,tabIndex:-1,"aria-level":i,"aria-posinset":a,"aria-setsize":s,"aria-rowindex":d,"aria-expanded":p?C:void 0,"aria-selected":K,"aria-disabled":g||void 0,onClick:()=>ee.rowClick(n),style:_e||pe!==void 0?{cursor:_e?"pointer":void 0,height:pe}:void 0,children:[D==="column"&&e.jsx("td",{className:"nice-datagrid__checkbox nice-treegrid__check-cell",children:ve}),v&&e.jsx("td",{className:"nice-datagrid__checkbox",children:e.jsx("input",{type:"checkbox",checked:!!K,onChange:()=>ee.toggleSelected(n.key),onClick:le=>le.stopPropagation(),disabled:ue,tabIndex:-1,"aria-label":Q})}),o.map((le,Ce)=>{const xe=n.data[le.field];return e.jsxs("td",{style:{textAlign:le.align},children:[Ce===0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-treegrid__indent",style:{width:(i-1)*20}}),e.jsx("button",{type:"button",className:`nice-treegrid__toggle ${p?"":"nice-treegrid__toggle--leaf"}`,onClick:oe=>{oe.stopPropagation(),p&&ee.toggleExpand(n.key)},tabIndex:-1,"aria-hidden":p?void 0:!0,"aria-label":p?C?L:w:void 0,children:p?e.jsx(k.NiceIcon,{name:C?"chevron-down":"chevron-right",size:12}):""}),D==="tree"&&e.jsx("span",{className:`nice-treegrid__check${I?"":" nice-treegrid__check--none"}`,children:ve})]}),le.render?le.render(xe,n.data,l):c[Ce]&&f?e.jsx(st,{text:String(xe??""),query:f,highlightClassName:"nice-treegrid__match"}):String(xe??""),Ce===0&&x>0&&e.jsxs("span",{className:`nice-treegrid__count${j===x?" nice-treegrid__count--full":""}`,title:O,children:[j,"/",x]})]},le.field)})]})}const ai=t.memo(ii);function si({columns:n=Xt,data:i=Jt,keyField:a="id",parentKeyField:s="parentId",nested:l=!1,childrenField:d="children",expandedKeys:o,defaultExpandedKeys:c,onExpandedChange:f,defaultExpandAll:p=!1,sortable:C=!0,sortField:w,sortDirection:L,onSort:D,selectable:I,selectedKeys:P,onSelectionChange:_,checkable:g,checkedKeys:j,defaultCheckedKeys:x,onCheckedChange:O,checkStrategy:v="all",isRowCheckable:K,isRowDisabled:Q,checkboxPlacement:ue="tree",checkOnRowClick:re,showCheckedCount:_e,showSelectAll:pe=!0,showOnlyChecked:ee,defaultShowOnlyChecked:ve,onShowOnlyCheckedChange:U,toolbarActions:le,searchable:Ce,searchPlaceholder:xe,searchText:oe,defaultSearchText:R,onSearchChange:W,searchFields:A,searchFilter:b,searchKeepDescendants:de=!1,searchAutoExpand:T=!0,highlightMatches:z=!0,rowClassName:ne,getRowLabel:Ke,virtualScroll:S,rowHeight:H=36,height:me,striped:Ie,compact:he,size:Re="md",loading:be,disabled:Le,readOnly:Oe,error:De,emptyText:on,toolbar:tn,onRowClick:an,className:Se,style:B,id:fe,testId:Ae,"data-testid":Ve,accessMode:ze,"aria-label":ce,"aria-labelledby":m}){const{t:X}=k.useNiceTranslation(),we=k.useNiceAccessMode(ze,fe),q=!!Le||we==="disabled",Ue=!!Oe||we==="readOnly",$e=t.useMemo(()=>l?kt(i,d,a):Qt(i,a,s),[i,a,s,l,d]),Te=t.useMemo(()=>n.filter(r=>!r.hidden),[n]),sn=t.useMemo(()=>it($e),[$e]),[M,Y]=t.useState(null),ae=t.useMemo(()=>{if(o)return new Set(o);if(M)return M;const r=new Set(c??at);return p&&sn.forEach(G=>r.add(G)),r},[o,M,c,p,sn]),Fe=t.useCallback(r=>{o||Y(r),f?.([...r])},[o,f]),[te,Ne]=t.useState({field:"",dir:null}),ye=w??te.field,qe=L??te.dir,fn=t.useCallback(r=>{const G=ye===r?qe==="asc"?"desc":qe==="desc"?null:"asc":"asc";D?D(r,G):Ne({field:r,dir:G})},[ye,qe,D]),[He,dn]=k.useControllableState({value:P,fallbackValue:ei,onChange:_,componentName:"NiceTreeGrid"}),kn=t.useCallback(r=>{dn(G=>{const je=new Set(G);return je.has(r)?je.delete(r):je.add(r),je})},[dn]),se=t.useMemo(()=>g?rt($e,{getKey:r=>r.key,getChildren:r=>r.children,isCheckable:K?r=>K(r.data):void 0,isDisabled:Q?r=>Q(r.data):void 0}):null,[g,$e,K,Q]),[Tn,Rn]=k.useControllableState({value:j,defaultValue:x,fallbackValue:at,componentName:"NiceTreeGrid"}),Be=t.useMemo(()=>se?ct(se,Tn):null,[se,Tn]),cn=t.useMemo(()=>se&&Be?Hn(se,Be.leaves):null,[se,Be]),zn=t.useMemo(()=>{const r=new Map,G=je=>je.forEach(vn=>{r.set(vn.key,vn.data),G(vn.children)});return g&&G($e),r},[g,$e]),Ze=t.useCallback((r,G)=>{if(!se||!Be||r===Be.leaves)return;const je=Zn(se,r,v,Be.unknown);Rn(je),O?.(je,{...G,leafKeys:Zn(se,r,"leaves"),halfCheckedKeys:[...Hn(se,r).halfChecked]})},[se,Be,v,Rn,O]),Xe=t.useCallback(r=>{if(!se||!Be)return;const G=lt(se,Be.leaves,r);Ze(G,{source:"row",checked:G.size>Be.leaves.size,key:r,row:zn.get(r)})},[se,Be,Ze,zn]),[In,Mn]=k.useControllableState({value:oe,defaultValue:R,fallbackValue:"",onChange:W,componentName:"NiceTreeGrid"}),Ge=In.trim(),bn=t.useMemo(()=>A??Te.map(r=>r.field),[A,Te]),en=t.useMemo(()=>{if(!Ge)return null;const r=Ge.toLowerCase();return Yt($e,b?je=>b(je.data,Ge):je=>bn.some(vn=>String(je.data[vn]??"").toLowerCase().includes(r)),de)},[$e,Ge,b,bn,de]),pn=en?.tree??$e,[h,u]=k.useControllableState({value:ee,defaultValue:ve,fallbackValue:!1,onChange:U,componentName:"NiceTreeGrid"}),N=!!g&&h&&cn!==null,V=t.useMemo(()=>N&&cn&&se?Ht(pn,{state:cn.state,isCheckable:se.isCheckable,isLeaf:se.isLeaf}):pn,[N,cn,se,pn]),F=Ge!==""||N,E=`${Ge}
|
|
6
|
+
${N?1:0}`,[$,Z]=t.useState(()=>({key:"",map:new Map})),J=$.key===E?$.map:ni,Pe=t.useMemo(()=>{const r=new Set;return en&&T&&en.expand.forEach(G=>r.add(G)),N&&se&&it(V).forEach(G=>{se.isLeaf(G)||r.add(G)}),r},[en,T,N,se,V]),ke=t.useCallback(r=>F?J.get(r)??(ae.has(r)||Pe.has(r)):ae.has(r),[F,J,ae,Pe]),We=t.useCallback(r=>{if(F){const je=!ke(r);Z(vn=>{const Dn=new Map(vn.key===E?vn.map:void 0);return Dn.set(r,je),{key:E,map:Dn}});return}const G=new Set(ae);G.has(r)?G.delete(r):G.add(r),Fe(G)},[F,ke,E,ae,Fe]),ln=t.useCallback(r=>{Fe(r?new Set(sn):new Set),F&&Z({key:E,map:new Map(it(V).map(G=>[G,r]))})},[Fe,sn,F,E,V]),wn=t.useMemo(()=>wt(V,ye,qe),[V,ye,qe]),Ye=t.useMemo(()=>Zt(wn,ke),[wn,ke]),_n=t.useMemo(()=>se?Ge?qt(pn).filter(r=>se.isLeaf(r)):se.leaves:at,[se,Ge,pn]),En=t.useMemo(()=>{if(!Be||_n.length===0)return"unchecked";let r=0;for(const G of _n)Be.leaves.has(G)&&r++;return r===0?"unchecked":r===_n.length?"checked":"indeterminate"},[Be,_n]),Jn=t.useCallback(()=>{if(!se||!Be)return;const r=_n.filter(je=>!se.isLocked(je)),G=!r.every(je=>Be.leaves.has(je));Ze(gt(se,Be.leaves,r,G),{source:"selectAll",checked:G})},[se,Be,_n,Ze]),et=t.useCallback(()=>{se&&Be&&Ze(gt(se,Be.leaves,se.leaves,!1),{source:"clear",checked:!1})},[se,Be,Ze]),$n=r=>{Ue||q||(g&&re&&se?.isCheckable(r.key)?Xe(r.key):g&&I&&kn(r.key),an?.(r.data))},An=t.useRef({toggleExpand:We,toggleCheck:Xe,toggleSelected:kn,rowClick:$n});An.current={toggleExpand:We,toggleCheck:Xe,toggleSelected:kn,rowClick:$n};const Kn=t.useMemo(()=>({toggleExpand:r=>An.current.toggleExpand(r),toggleCheck:r=>An.current.toggleCheck(r),toggleSelected:r=>An.current.toggleSelected(r),rowClick:r=>An.current.rowClick(r)}),[]),rn=!!S,Ln=t.useRef(null),[Un,Gn]=t.useState(typeof me=="number"?me:480);t.useEffect(()=>{const r=Ln.current;if(!rn||!r||typeof ResizeObserver>"u")return;const G=new ResizeObserver(()=>{r.clientHeight>0&&Gn(r.clientHeight)});return G.observe(r),()=>G.disconnect()},[rn]);const jn=k.useVirtualScroll({itemCount:rn?Ye.length:0,itemHeight:H,containerHeight:Un,overscan:8}),Pn=rn?jn.startIndex:0,On=rn?jn.endIndex:Ye.length,Vn=t.useRef(null),y=t.useRef(ke);y.current=ke,k.useTreeFocus(Vn,{itemSelector:"tr.nice-treegrid__row",enabled:!q,onToggle:(r,G)=>{const je=r.dataset.key;je!==void 0&&r.hasAttribute("aria-expanded")&&y.current(je)!==G&&Kn.toggleExpand(je)}});const ie=t.useCallback(r=>[...Vn.current?.querySelectorAll("tr.nice-treegrid__row")??[]].find(G=>G.dataset.key===r),[]),[ge,Me]=t.useState(null);t.useEffect(()=>{if(ge===null)return;const r=ie(ge);r&&(r.focus(),Me(null))},[ge,Pn,On,ie]);const mn=r=>{const G=Ye[r]?.node.key;if(G===void 0)return;const je=ie(G);je?je.focus():rn&&Ln.current&&(Ln.current.scrollTop=Math.max(0,r*H-Un/2),Me(G))},xn=r=>{const G=r.target;if(r.altKey||r.ctrlKey||r.metaKey||!G.matches?.("tr.nice-treegrid__row"))return;const je=G.dataset.key??"";if(r.key===" "){if(Ue)return;g&&se?.isCheckable(je)?(r.preventDefault(),Xe(je)):I&&(r.preventDefault(),kn(je));return}if(!(r.key==="PageDown"||r.key==="PageUp")&&!(rn&&(r.key==="Home"||r.key==="End")))return;const Dn=Ye.findIndex(Nn=>Nn.node.key===je);Dn<0||(r.preventDefault(),mn(r.key==="PageDown"?Math.min(Ye.length-1,Dn+bt):r.key==="PageUp"?Math.max(0,Dn-bt):r.key==="Home"?0:Ye.length-1))},yn=X("controls.expand","Expand"),un=X("controls.collapse","Collapse"),Wn=Te[0]?.field,Mt=r=>Ke?Ke(r.data):String((Wn!=null?r.data[Wn]:void 0)??r.key),ot=(r,G)=>X("treeGrid.checkedSummary","{checked} of {total} selected").replace("{checked}",String(r)).replace("{total}",String(G)),Et=t.useMemo(()=>{const r=new Set(bn);return Te.map(G=>z&&!b&&r.has(G.field))},[Te,bn,z,b]),nt=le===!0?g?_t:_t.slice(0,2):Array.isArray(le)?le.filter(r=>g||r==="expandAll"||r==="collapseAll"):ti,Qn=g?ue==="column"?"column":"tree":"none",qn=!!I&&!g,Yn=Te.length+(Qn==="column"||qn?1:0),dt=[cn?ot(cn.total.checked,cn.total.total):"",en?X("treeGrid.matchCount","{count} matching rows").replace("{count}",String(en.matched.size)):""].filter(Boolean);if(we==="hidden")return null;const tt=g&&pe&&se&&se.leaves.length>0?e.jsx("input",{type:"checkbox",className:"nice-treegrid__check-input nice-treegrid__select-all",checked:En==="checked",ref:r=>{r&&(r.indeterminate=En==="indeterminate")},disabled:Ue||q,"aria-label":Ge?X("treeGrid.selectAllResults","Select all results"):X("controls.selectAll","Select all"),onClick:r=>r.stopPropagation(),onChange:Jn}):null,At=r=>{const G={expandAll:{icon:"expand",label:X("treeGrid.expandAll","Expand all")},collapseAll:{icon:"collapse",label:X("treeGrid.collapseAll","Collapse all")},onlyChecked:{icon:"filter",label:X("treeGrid.showOnlyChecked","Show selected only")},clearChecked:{icon:"eraser",label:X("treeGrid.clearChecked","Clear selection")}}[r];return e.jsxs("button",{type:"button",className:`nice-btn nice-btn--sm nice-btn--ghost nice-treegrid__action${r==="onlyChecked"&&N?" nice-treegrid__action--active":""}`,"aria-pressed":r==="onlyChecked"?N:void 0,disabled:q||r==="clearChecked"&&(Ue||!cn||cn.total.checked===0),onClick:()=>{r==="expandAll"||r==="collapseAll"?ln(r==="expandAll"):r==="onlyChecked"?u(!h):et()},children:[e.jsx(k.NiceIcon,{name:G.icon,size:14}),e.jsx("span",{children:G.label})]},r)},Tt=r=>{const{node:G,level:je,posInSet:vn,setSize:Dn}=Ye[r],Nn=G.key,ht=!!se?.isCheckable(Nn),Fn=_e&&cn&&se&&!se.isLeaf(Nn)?cn.count(Nn):null,Rt=Mt(G);return e.jsx(ai,{node:G,level:je,posInSet:vn,setSize:Dn,rowIndex:r,ariaRowIndex:rn?r+2:void 0,columns:Te,highlight:Et,query:Ge,hasChildren:G.children.length>0,expanded:G.children.length>0&&ke(Nn),expandLabel:yn,collapseLabel:un,checkMode:Qn,hasCheckbox:ht,checkState:cn?cn.state(Nn):"unchecked",checkLabel:ht?X("treeGrid.checkRow","Select {label}").replace("{label}",Rt):"",locked:!!se?.isLocked(Nn),countChecked:Fn?.checked??0,countTotal:Fn?.total??0,countTitle:Fn?ot(Fn.checked,Fn.total):"",selectColumn:qn,selected:I?He.has(Nn):void 0,selectLabel:qn?X("controls.selectRow","Select row {key}").replace("{key}",Nn):"",readOnly:Ue,className:typeof ne=="function"?ne(G.data,r):ne,clickable:!Ue&&(!!an||!!re||!!g&&!!I),height:rn?H:void 0,handlers:Kn},Nn)},ut=[];for(let r=Pn;r<On;r++)ut.push(Tt(r));const mt=(r,G)=>r>0?e.jsx("tr",{className:"nice-treegrid__spacer","aria-hidden":"true",children:e.jsx("td",{colSpan:Yn,style:{height:r*H}})},G):null;return e.jsxs("div",{id:fe,"data-testid":Ve??Ae,className:`nice-treegrid nice-datagrid ${q?"nice-treegrid--disabled":""} ${Ue?"nice-treegrid--readonly":""} ${De?"nice-treegrid--error":""} ${rn?"nice-treegrid--virtual":""} ${Se||""}`,style:B,"aria-disabled":q||void 0,"aria-busy":be||void 0,"aria-invalid":!!De||void 0,children:[(Ce||tn||nt.length>0)&&e.jsxs("div",{className:"nice-datagrid__toolbar nice-treegrid__toolbar",children:[Ce&&e.jsxs("div",{className:"nice-datagrid__search nice-treegrid__search",children:[e.jsx("input",{type:"search",value:In,onChange:r=>Mn(r.target.value),onKeyDown:r=>{r.key==="Escape"&&In&&(r.preventDefault(),Mn(""))},placeholder:xe||X("controls.search","Search..."),"aria-label":xe||X("controls.search","Search...")}),In&&e.jsx("button",{type:"button",className:"nice-treegrid__search-clear",onClick:()=>Mn(""),"aria-label":X("treeGrid.clearSearch","Clear search"),children:e.jsx(k.NiceIcon,{name:"close",size:12})})]}),nt.length>0&&e.jsx("div",{className:"nice-treegrid__actions",children:nt.map(At)}),tn,dt.length>0&&e.jsx("span",{className:"nice-treegrid__summary",role:"status",children:dt.join(" · ")})]}),e.jsx("div",{ref:Ln,className:"nice-datagrid__table-wrap",style:rn?{height:me??480,overflow:"auto"}:void 0,onScroll:rn?jn.onScroll:void 0,children:e.jsxs("table",{ref:Vn,role:"treegrid","aria-label":ce,"aria-labelledby":m,"aria-multiselectable":I||g||void 0,"aria-rowcount":rn?Ye.length+1:void 0,className:`nice-table nice-table--${Re} ${Ie?"nice-table--striped":""} ${he?"nice-table--compact":""}`,onKeyDownCapture:xn,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[Qn==="column"&&e.jsx("th",{className:"nice-datagrid__checkbox nice-treegrid__th-check",children:tt}),qn&&e.jsx("th",{className:"nice-datagrid__checkbox",style:{width:36}}),Te.map((r,G)=>e.jsxs("th",{style:{width:r.width,minWidth:r.minWidth,textAlign:r.align},className:C&&r.sortable!==!1?"nice-datagrid__th--sortable":void 0,onClick:()=>C&&r.sortable!==!1&&fn(r.field),children:[G===0&&Qn==="tree"&&tt&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"nice-treegrid__toggle nice-treegrid__toggle--leaf","aria-hidden":"true"}),e.jsx("span",{className:"nice-treegrid__check",children:tt})]}),r.header,C&&r.sortable!==!1&&e.jsx("span",{className:"nice-table__sort-icon",style:{opacity:ye===r.field&&qe?void 0:.3},children:e.jsx(k.NiceIcon,{name:ye===r.field&&qe?qe==="asc"?"sort-asc":"sort-desc":"sort",size:12})})]},r.field))]})}),e.jsx("tbody",{children:be?e.jsx("tr",{children:e.jsx("td",{colSpan:Yn,className:"nice-datagrid__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):De?e.jsx("tr",{children:e.jsx("td",{colSpan:Yn,className:"nice-datagrid__empty nice-treegrid__error",role:"alert",children:De})}):Ye.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:Yn,className:"nice-datagrid__empty",children:Ge?X("controls.noResults","No results"):on||X("controls.noData","No data available")})}):e.jsxs(e.Fragment,{children:[mt(Pn,"top"),ut,mt(Ye.length-On,"bottom")]})})]})})]})}const ri=[],ci=[],li=[];function oi(n,i,a){const s=[],l=(c,f)=>{c.forEach(p=>{s.push({item:p,parent:p[a]??f}),Array.isArray(p.children)&&p.children.length>0&&l(p.children,p[i])})};l(n,null);const d=new Map,o=[];return s.forEach(({item:c})=>{const f={...c,children:[]};d.set(String(f[i]),f)}),s.forEach(({item:c,parent:f})=>{f!=null&&d.has(String(f))?d.get(String(f)).children.push(d.get(String(c[i]))):o.push(d.get(String(c[i])))}),o}function di({columns:n=ri,data:i=ci,keyField:a="key",parentKeyField:s="parentKey",expandedKeys:l,onExpandedChange:d,selectedKeys:o=li,onSelectionChange:c,selectable:f,sortable:p,loading:C,emptyText:w,className:L,style:D,accessMode:I,id:P}){const g=k.useNiceAccessMode(I,P)==="hidden",{t:j}=k.useNiceTranslation(),[x,O]=t.useState([]),v=l??x,[K,Q]=t.useState(o),ue=c?o:K,re=t.useMemo(()=>oi(i,a,s),[i,a,s]),_e=t.useMemo(()=>n.filter(T=>!T.hidden),[n]),[pe,ee]=t.useState(null),ve=t.useCallback(T=>{ee(z=>z?.field===T?z.dir==="asc"?{field:T,dir:"desc"}:null:{field:T,dir:"asc"})},[]),U=t.useCallback(T=>pe?[...T].sort((ne,Ke)=>{const S=ne[pe.field]??"",H=Ke[pe.field]??"",me=typeof S=="number"?S-H:String(S).localeCompare(String(H));return pe.dir==="desc"?-me:me}).map(ne=>ne.children&&ne.children.length?{...ne,children:U(ne.children)}:ne):T,[pe]),le=t.useMemo(()=>U(re),[re,U]),Ce=t.useCallback(T=>{const z=v.includes(T)?v.filter(ne=>ne!==T):[...v,T];d?d(z):O(z)},[v,d]),xe=t.useMemo(()=>rt(re,{getKey:T=>String(T[a]),getChildren:T=>T.children}),[re,a]),oe=t.useMemo(()=>ct(xe,ue),[xe,ue]),R=t.useMemo(()=>Hn(xe,oe.leaves),[xe,oe]),W=t.useCallback(T=>{const z=lt(xe,oe.leaves,T),ne=Zn(xe,z,"all",oe.unknown);c?c(ne):Q(ne)},[xe,oe,c]),A=_e[0]?.field;let b=0;const de=(T,z)=>{const ne=String(T[a]),Ke=b++,S=!!(T.children&&T.children.length>0),H=v.includes(ne),me=R.state(ne),Ie=me==="checked",he=me==="indeterminate",Re=A!=null?String(T[A]??ne):ne;return e.jsxs(t.Fragment,{children:[e.jsxs("tr",{className:Ie?"nice-treelist__row--selected":"",children:[f&&e.jsx("td",{className:"nice-treelist__checkbox",children:e.jsx("input",{type:"checkbox",checked:Ie,ref:be=>{be&&(be.indeterminate=he)},onChange:()=>W(ne),"aria-label":j("controls.selectRow","Select row {key}").replace("{key}",Re)})}),_e.map((be,Le)=>e.jsxs("td",{style:{textAlign:be.align},children:[Le===0&&e.jsx("span",{style:{display:"inline-block",width:z*20}}),Le===0&&e.jsx("span",{role:S?"button":void 0,tabIndex:S?0:void 0,"aria-expanded":S?H:void 0,"aria-label":S?j(H?"controls.collapse":"controls.expand",H?"Collapse":"Expand"):void 0,onKeyDown:S?k.clickOnActivationKey:void 0,className:"nice-treelist__toggle",onClick:()=>S&&Ce(ne),style:{cursor:S?"pointer":"default",width:20,display:"inline-block"},children:S?e.jsx(k.NiceIcon,{name:H?"chevron-down":"chevron-right",size:12}):""}),be.render?be.render(T[be.field],T,Ke):String(T[be.field]??"")]},be.field))]}),S&&H&&T.children.map(be=>de(be,z+1))]},ne)};return g?null:e.jsx("div",{className:`nice-treelist ${L||""}`,style:D,children:e.jsxs("table",{children:[e.jsx("thead",{children:e.jsxs("tr",{children:[f&&e.jsx("th",{className:"nice-treelist__checkbox"}),_e.map(T=>{const z=!!p&&!!T.sortable;return e.jsxs("th",{style:{width:T.width,minWidth:T.minWidth,textAlign:T.align},className:z?"nice-treelist__th--sortable":void 0,onClick:()=>z&&ve(T.field),scope:"col","aria-sort":z?pe?.field===T.field?pe.dir==="asc"?"ascending":"descending":"none":void 0,children:[T.header,z&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(k.NiceIcon,{name:pe?.field===T.field?pe.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},T.field)})]})}),e.jsx("tbody",{children:C?e.jsx("tr",{children:e.jsx("td",{colSpan:_e.length+(f?1:0),className:"nice-treelist__empty",children:e.jsx("div",{className:"nice-spinner nice-spinner--md",style:{margin:"0 auto"}})})}):re.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:_e.length+(f?1:0),className:"nice-treelist__empty",children:w||j("controls.noData","No data available")})}):le.map(T=>de(T,0))})]})})}function St(n,i=[]){for(const a of n)a.expanded&&i.push(a.key),a.children&&St(a.children,i);return i}const xt=[],ui=[],mi=({nodes:n=xt,header:i,selectedKeys:a=ui,expandedKeys:s,onSelectionChange:l,onExpandedChange:d,selectionMode:o="none",showCheckboxes:c,searchable:f,searchPlaceholder:p,onNodeClick:C,renderNode:w,showLines:L,loading:D,className:I,style:P,accessMode:_,id:g,draggable:j,onNodeDrop:x,onLoadChildren:O,contextMenuItems:v,onContextMenuAction:K,editable:Q,onNodeEdit:ue,maxDepth:re})=>{const pe=k.useNiceAccessMode(_,g)==="hidden",{t:ee}=k.useNiceTranslation(),[ve,U]=t.useState(()=>St(n)),[le,Ce]=t.useState(""),[xe,oe]=t.useState(new Set),[R,W]=t.useState(new Map),[A,b]=t.useState(null),[de,T]=t.useState(null),[z,ne]=t.useState(null),[Ke,S]=t.useState(""),H=t.useRef(null),me=s??ve,Ie=t.useRef(me);Ie.current=me;const he=t.useMemo(()=>new Set(a),[a]),Re=typeof re=="number"?Math.min(10,Math.max(1,re)):1/0,be=!!c&&o==="multiple",Le=t.useMemo(()=>be?rt(n,{getKey:m=>m.key,getChildren:(m,X)=>X+1>=Re?null:R.get(m.key)??m.children,isDisabled:m=>!!m.disabled},{inheritDisabled:!1}):null,[be,n,R,Re]),Oe=t.useMemo(()=>Le?ct(Le,a):null,[Le,a]),De=t.useMemo(()=>Le&&Oe?Hn(Le,Oe.leaves):null,[Le,Oe]),on=t.useCallback(async(m,X)=>{const we=Ie.current,q=!we.includes(m),Ue=q?[...we,m]:we.filter($e=>$e!==m);if(Ie.current=Ue,d?d(Ue):U(Ue),q&&O&&!X.children?.length&&X.leaf!==!0&&!R.has(m)){oe(Te=>new Set(Te).add(m));const $e=await O(X);W(Te=>new Map(Te).set(m,$e)),oe(Te=>{const sn=new Set(Te);return sn.delete(m),sn})}},[d,O,R]),tn=t.useCallback(m=>{if(l){if(o==="single")l(a.includes(m)?[]:[m]);else if(o==="multiple")if(Le&&Oe){const X=lt(Le,Oe.leaves,m);X!==Oe.leaves&&l(Zn(Le,X,"all",Oe.unknown))}else l(a.includes(m)?a.filter(X=>X!==m):[...a,m])}},[a,o,l,Le,Oe]),an=t.useCallback(m=>{if(!le)return!0;const X=le.toLowerCase();return m.text.toLowerCase().includes(X)?!0:(R.get(m.key)??m.children)?.some(q=>an(q))??!1},[le,R]),Se=t.useCallback((m,X)=>{v?.length&&(m.preventDefault(),T({x:m.clientX,y:m.clientY,node:X}))},[v]),B=t.useCallback(()=>{z&&ue&&ue(z,Ke),ne(null)},[z,Ke,ue]),fe=t.useRef(null),Ae=(m,X=n)=>{for(const we of X){const q=we.key===m?we:Ae(m,R.get(we.key)??we.children??xt);if(q)return q}};k.useTreeFocus(fe,{rowSelector:".nice-tree__row",onToggle:(m,X)=>{const we=m.dataset.key===void 0?void 0:Ae(m.dataset.key);we&&Ie.current.includes(we.key)!==X&&on(we.key,we)}});const Ve=t.useRef(null);t.useEffect(()=>{if(z!==null||Ve.current===null)return;const m=Ve.current;Ve.current=null,[...fe.current?.querySelectorAll('[role="treeitem"]')??[]].find(X=>X.dataset.key===m)?.focus()},[z]);const ze=t.useRef(null);k.useRovingFocus(ze,{orientation:"vertical",wrap:!0,typeahead:!0}),k.useOverlayFocus(ze,{open:!!de,modal:!1,onClose:()=>T(null)});const ce=(m,X)=>{if(le&&!an(m))return null;const we=X+1>=Re,q=we?void 0:R.get(m.key)??m.children,Ue=!we&&(q&&q.length>0||m.leaf!==!0&&O&&!q?.length),$e=me.includes(m.key),Te=De?De.state(m.key):he.has(m.key)?"checked":"unchecked",sn=De?Te==="checked":he.has(m.key),M=!!m.disabled||!!Le?.isLocked(m.key),Y=xe.has(m.key),ae=Math.min(X+1,10),Fe={paddingLeft:X*20+4,"--nice-row-bg":`var(--nice-tree-level-${ae}-bg, transparent)`,"--nice-row-text":`var(--nice-tree-level-${ae}-text, inherit)`,"--nice-row-border":`var(--nice-tree-level-${ae}-border, transparent)`,"--nice-row-hover-bg":`var(--nice-tree-level-${ae}-hover-bg, var(--nice-hover-bg, color-mix(in srgb, var(--nice-text-primary) 6%, transparent)))`,"--nice-row-active-bg":`var(--nice-tree-level-${ae}-active-bg, color-mix(in srgb, var(--nice-color-primary) 14%, transparent))`};return e.jsxs("li",{className:"nice-tree__node",role:"treeitem","aria-label":m.text,"aria-expanded":Ue?$e:void 0,"aria-selected":o!=="none"?sn:void 0,"aria-disabled":m.disabled||void 0,"data-key":m.key,"data-nice-depth":ae,onKeyDown:Q&&!m.disabled?te=>{te.key==="F2"&&te.target===te.currentTarget&&(te.preventDefault(),ne(m.key),S(m.text))}:void 0,draggable:j&&!m.disabled,onDragStart:j?te=>{te.stopPropagation(),b(m.key)}:void 0,onDragOver:j?te=>{te.preventDefault(),te.stopPropagation()}:void 0,onDrop:j&&A?te=>{te.stopPropagation(),x?.(A,m.key,"inside"),b(null)}:void 0,onDragEnd:j?()=>b(null):void 0,children:[e.jsxs("div",{role:"presentation",className:`nice-tree__row ${sn?"nice-tree__row--selected":""} ${m.disabled?"nice-tree__row--disabled":""} ${A===m.key?"nice-tree__row--dragging":""}`,style:Fe,onClick:()=>{m.disabled||(tn(m.key),C?.(m))},onContextMenu:te=>Se(te,m),onDoubleClick:Q&&!m.disabled?()=>{ne(m.key),S(m.text)}:void 0,children:[e.jsx("span",{role:"presentation",className:`nice-tree__toggle ${Ue?$e?"nice-tree__toggle--expanded":"":"nice-tree__toggle--leaf"}`,onClick:te=>{te.stopPropagation(),Ue&&on(m.key,m)},children:Y?e.jsx("span",{className:"nice-spinner nice-spinner--xs"}):Ue?$e?e.jsx(k.NiceIcon,{name:"chevron-down",size:12}):e.jsx(k.NiceIcon,{name:"chevron-right",size:12}):""}),c&&o!=="none"&&e.jsx("input",{type:"checkbox",checked:Te==="checked",ref:te=>{te&&(te.indeterminate=Te==="indeterminate")},onChange:()=>tn(m.key),onClick:te=>te.stopPropagation(),disabled:M,tabIndex:-1,"aria-label":m.text,className:"nice-tree__checkbox"}),z===m.key?e.jsx("input",{type:"text",className:"nice-tree__edit-input",value:Ke,onChange:te=>S(te.target.value),onBlur:B,onKeyDown:te=>{te.key==="Enter"&&(Ve.current=m.key,B()),te.key==="Escape"&&(te.preventDefault(),Ve.current=m.key,ne(null))},autoFocus:!0,onClick:te=>te.stopPropagation()}):w?w(m):e.jsxs(e.Fragment,{children:[m.icon&&e.jsx("span",{className:"nice-tree__icon",children:m.icon}),e.jsx("span",{className:"nice-tree__text",children:m.text})]})]}),q&&q.length>0&&$e&&e.jsx("ul",{className:"nice-tree__children",role:"group",children:q.map(te=>ce(te,X+1))})]},m.key)};return pe?null:e.jsxs("div",{role:"presentation",className:`nice-tree ${L?"nice-tree--lines":""} ${I||""}`,style:P,ref:H,onClick:()=>T(null),children:[i!=null&&i!==!1&&e.jsx("div",{className:"nice-tree__header",children:i}),f&&e.jsx("div",{className:"nice-tree__search",children:e.jsx("input",{type:"text",value:le,onChange:m=>Ce(m.target.value),placeholder:p||ee("controls.search","Search..."),"aria-label":p||ee("controls.search","Search tree")})}),D?e.jsx("div",{className:"nice-tree__loading",children:e.jsx("div",{className:"nice-spinner nice-spinner--sm"})}):e.jsx("ul",{ref:fe,className:"nice-tree__root",role:"tree","aria-multiselectable":o==="multiple"||void 0,children:n.map(m=>ce(m,0))}),de&&v&&e.jsx("div",{ref:ze,className:"nice-tree__context-menu",role:"menu","aria-label":de.node.text,style:{position:"fixed",top:de.y,left:de.x,zIndex:9999},children:v.map(m=>e.jsxs("button",{type:"button",role:"menuitem",disabled:m.disabled,className:`nice-tree__context-item ${m.disabled?"nice-tree__context-item--disabled":""}`,onClick:()=>{m.disabled||(K?.(m.key,de.node),T(null))},children:[m.icon&&e.jsx("span",{children:m.icon}),m.label]},m.key))})]})},hi=[],fi=({items:n=hi,selectedKeys:i=[],onSelectionChange:a,selectionMode:s="none",searchable:l,searchPlaceholder:d,grouped:o,groupField:c="group",reorderable:f,onReorder:p,onItemClick:C,renderItem:w,showCheckboxes:L,loading:D,emptyText:I,size:P="md",header:_,disabled:g,readOnly:j,error:x,bordered:O=!0,swipeActions:v,className:K,style:Q,accessMode:ue,id:re})=>{const pe=k.useNiceAccessMode(ue,re)==="hidden",{t:ee}=k.useNiceTranslation(),[ve,U]=t.useState(""),[le,Ce]=t.useState(null),[xe,oe]=t.useState(null),R=t.useRef(null),W=t.useMemo(()=>{if(!ve)return n;const S=ve.toLowerCase();return n.filter(H=>H.text.toLowerCase().includes(S))},[n,ve]),A=t.useMemo(()=>{if(!o)return null;const S=new Map;return W.forEach(H=>{const me=String(H[c]??"");S.has(me)||S.set(me,[]),S.get(me).push(H)}),S},[W,o,c]),b=t.useCallback(S=>{a&&(s==="single"?a(i.includes(S)?[]:[S]):s==="multiple"&&a(i.includes(S)?i.filter(H=>H!==S):[...i,S]))},[i,s,a]),de=t.useCallback(S=>{le!==null&&le!==S&&p&&p(le,S),Ce(null)},[le,p]),T=t.useRef(null),z=t.useCallback(S=>{T.current=S},[]);k.useRovingFocus(T,{orientation:"vertical",itemSelector:".nice-list__item",typeahead:!0,pageSize:10});const ne=S=>{!S.disabled&&!g&&!j&&(b(S.key),C?.(S))},Ke=(S,H)=>{const me=i.includes(S.key),Ie=xe===S.key;return e.jsxs("li",{className:`nice-list__item ${me?"nice-list__item--selected":""} ${S.disabled?"nice-list__item--disabled":""} ${Ie?"nice-list__item--swiped":""}`,onClick:()=>ne(S),onKeyDown:he=>{he.target===he.currentTarget&&(he.key==="Enter"||he.key===" ")&&(he.preventDefault(),ne(S))},draggable:f&&!g&&!j,onDragStart:()=>Ce(H),onDragOver:he=>he.preventDefault(),onDrop:()=>de(H),onTouchStart:v?.length?he=>{R.current={x:he.touches[0].clientX,key:S.key}}:void 0,onTouchEnd:v?.length?he=>{if(!R.current)return;const Re=he.changedTouches[0].clientX-R.current.x;Re<-50&&R.current.key===S.key?oe(S.key):Re>50&&oe(null),R.current=null}:void 0,role:"option","aria-selected":s!=="none"?me:void 0,"aria-disabled":S.disabled||void 0,children:[e.jsxs("div",{className:"nice-list__item-content",children:[L&&s!=="none"&&e.jsx("input",{type:"checkbox",checked:me,readOnly:!0,tabIndex:-1,className:"nice-list__checkbox"}),w?w(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})]})]}),v&&Ie&&e.jsx("div",{className:"nice-list__swipe-actions",children:v.map(he=>e.jsx("button",{className:"nice-list__swipe-btn",style:he.color?{backgroundColor:he.color}:void 0,onClick:Re=>{Re.stopPropagation(),he.onClick(S),oe(null)},children:he.label},he.key))})]},S.key)};return pe?null:e.jsxs("div",{className:`nice-list nice-list--${P} ${O?"nice-list--bordered":""} ${g?"nice-list--disabled":""} ${j?"nice-list--readonly":""} ${x?"nice-list--error":""} ${K||""}`,style:Q,"aria-disabled":g||void 0,"aria-busy":D||void 0,children:[_&&e.jsx("div",{className:"nice-list__header",children:_}),l&&!D&&e.jsx("div",{className:"nice-list__search",children:e.jsx("input",{type:"text",value:ve,onChange:S=>U(S.target.value),placeholder:d||ee("controls.search","Search...")})}),D?e.jsx("div",{className:"nice-list__loading",role:"status","aria-live":"polite",children:e.jsx("div",{className:`nice-spinner nice-spinner--${P}`})}):x?e.jsx("div",{className:"nice-list__error",role:"alert",children:x}):W.length===0?e.jsx("div",{className:"nice-list__empty",children:I||ee("controls.noData","No data available")}):e.jsx("div",{role:"listbox",ref:z,"aria-multiselectable":s==="multiple"||void 0,children:A?Array.from(A.entries()).map(([S,H])=>e.jsxs("div",{className:"nice-list__group",role:"group","aria-label":S,children:[e.jsx("div",{className:"nice-list__group-header","aria-hidden":"true",children:S}),e.jsx("ul",{className:"nice-list__items",role:"presentation",children:H.map((me,Ie)=>Ke(me,Ie))})]},S)):e.jsx("ul",{className:"nice-list__items",role:"presentation",children:W.map((S,H)=>Ke(S,H))})})]})},pi=[],gi=[];function _i({columns:n=pi,data:i=gi,striped:a,compact:s,size:l="md",emptyText:d,className:o,style:c,accessMode:f,id:p,displayStyle:C}){const{t:w}=k.useNiceTranslation(),L=k.normalizeSize(l),I=k.useNiceAccessMode(f,p)==="hidden",P=k.useComponentDisplayStyle("table",C),_=k.useComponentDisplayClass("table",C),[g,j]=t.useState(null),x=t.useMemo(()=>g?[...i].sort((v,K)=>{const Q=v[g.field]??"",ue=K[g.field]??"",re=typeof Q=="number"?Q-ue:String(Q).localeCompare(String(ue));return g.dir==="desc"?-re:re}):i,[i,g]),O=v=>{j(K=>K?.field===v?K.dir==="asc"?{field:v,dir:"desc"}:null:{field:v,dir:"asc"})};return I?null:e.jsx("div",{className:`nice-table-wrapper ${o||""}`,style:{...P,...c},children:e.jsxs("table",{className:`nice-table nice-table--ds-${_} nice-table--${L} ${a?"nice-table--striped":""} ${s?"nice-table--compact":""}`,"aria-rowcount":x.length,"aria-colcount":n.length,children:[e.jsx("thead",{children:e.jsx("tr",{children:n.map(v=>{const K=v.sortable?g?.field===v.field?g.dir==="asc"?"ascending":"descending":"none":void 0;return e.jsxs("th",{style:{width:v.width,textAlign:v.align},className:v.sortable?"th--sortable":void 0,onClick:()=>v.sortable&&O(v.field),scope:"col","aria-sort":K,children:[v.header,v.sortable&&e.jsx("span",{className:"nice-table__sort-icon","aria-hidden":"true",children:e.jsx(k.NiceIcon,{name:g?.field===v.field?g.dir==="desc"?"chevron-down":"chevron-up":"sort",size:12})})]},v.field)})})}),e.jsx("tbody",{children:x.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:n.length,className:"nice-table__empty",children:d||w("table.noData","No data")})}):x.map((v,K)=>e.jsx("tr",{children:n.map(Q=>e.jsx("td",{style:{textAlign:Q.align},children:Q.render?Q.render(v[Q.field],v):String(v[Q.field]??"")},Q.field))},K))})]})})}const bi=[];function xi({items:n=bi,tileWidth:i=180,tileHeight:a=180,direction:s="horizontal",renderTile:l,onTileClick:d,loading:o,emptyText:c,className:f,style:p}){const{t:C}=k.useNiceTranslation();return e.jsx("div",{className:`nice-tileview nice-tileview--${s} ${f||""}`,style:p,children:o?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:c||C("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(w=>e.jsx("div",{role:d?"button":void 0,tabIndex:d?0:void 0,onKeyDown:d?k.clickOnActivationKey:void 0,className:"nice-tileview__tile",style:{width:i,height:a,cursor:d?"pointer":void 0},onClick:()=>d?.(w),children:l?l(w):e.jsxs(e.Fragment,{children:[w.image&&e.jsx("img",{src:w.image,alt:w.text||"",className:"nice-tileview__image"}),w.text&&e.jsx("div",{className:"nice-tileview__label",children:w.text})]})},w.key))})})}const yi=[],vi=[];function Ni({open:n}){return e.jsx(k.NiceIcon,{name:"chevron-down",size:14,style:{transition:"transform 160ms ease",transform:n?"rotate(0deg)":"rotate(-90deg)"}})}function ki(){return e.jsx(k.NiceIcon,{name:"plus",size:14})}const wi=[{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"}],ji=Object.assign(t.forwardRef(({columns:n=yi,cards:i=vi,onCardMove:a,onCardClick:s,renderCard:l,onAddCard:d,disabled:o=!1,size:c="md",collapsible:f=!1,collapseDirection:p="vertical",layoutMode:C="scroll",viewMode:w,onViewModeChange:L,collapsedColumns:D,onCollapsedColumnsChange:I,formItems:P,formColumns:_=1,formProps:g,editCardTitle:j,newCardTitle:x,onCardEdit:O,onCardCreate:v,onCardDelete:K,tutorial:Q,cookies:ue=!1,localStorage:re=!0,sessionStorage:_e=!1,storageMode:pe,storageKey:ee,className:ve,style:U,id:le,...Ce},xe)=>{const{t:oe}=k.useNiceTranslation(),[R,W]=t.useState(null),[A,b]=t.useState(null),[de,T]=t.useState(null),z=!!P&&(!!O||!!v),ne=t.useCallback(B=>{if(z&&O){T({key:B.key,data:{...B},column:B.column});return}s?.(B)},[z,s,O]),Ke=z&&!!O||!!s,S=t.useCallback(B=>{if(z&&v){T({key:null,data:{title:"",description:""},column:B});return}d?.(B)},[z,d,v]),H=Ot.useStorageAdapter(ee??"nice-kanban"),[me,Ie]=t.useState(()=>H.get("state")??{collapsedColumns:[],viewMode:"default"}),he=t.useMemo(()=>D??me.collapsedColumns??[],[D,me.collapsedColumns]),Re=w??me.viewMode??"default",be=t.useCallback(B=>{Ie(fe=>{const Ae={...fe,...B};return H.set("state",Ae),Ae})},[H]),Le=t.useCallback(B=>{const fe=he.includes(B)?he.filter(Ae=>Ae!==B):[...he,B];I?I(fe):be({collapsedColumns:fe})},[he,I,be]);t.useCallback(B=>{L?L(B):be({viewMode:B})},[L,be]);const Oe=t.useCallback(B=>i.filter(fe=>fe.column===B).sort((fe,Ae)=>(fe.order??0)-(Ae.order??0)),[i]),De=t.useCallback((B,fe)=>{o||(B.dataTransfer.effectAllowed="move",B.dataTransfer.setData("text/plain",String(fe.key)),W({cardKey:fe.key,fromColumn:fe.column}))},[o]),on=t.useCallback((B,fe)=>{B.preventDefault(),B.dataTransfer.dropEffect="move",b({column:fe})},[]),tn=t.useCallback(()=>{b(null)},[]),an=t.useCallback((B,fe)=>{if(B.preventDefault(),b(null),!R||o)return;const Ae=Oe(fe);a?.(R.cardKey,fe,Ae.length),W(null)},[R,o,Oe,a]),Se=t.useCallback(()=>{W(null),b(null)},[]);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{ref:xe,id:le,className:`nice-kanban nice-kanban--${c} nice-kanban--${Re} nice-kanban--layout-${C} ${o?"nice-kanban--disabled":""} ${ve||""}`,style:{position:"relative",...U},...Ce,children:[e.jsx("span",{style:{position:"absolute",top:6,right:6,zIndex:20},children:e.jsx(k.NiceTutorialButton,{steps:k.resolveTutorial(Q,wi)})}),n.map(B=>{const fe=Oe(B.key),Ae=A?.column===B.key,Ve=B.limit!=null&&fe.length>=B.limit,ze=f&&he.includes(B.key);return e.jsxs("div",{className:`nice-kanban__column ${Ae?"nice-kanban__column--dragover":""} ${ze?`nice-kanban__column--collapsed nice-kanban__column--collapse-${p}`:""}`,onDragOver:ce=>!ze&&on(ce,B.key),onDragLeave:tn,onDrop:ce=>!ze&&an(ce,B.key),children:[e.jsxs("div",{className:"nice-kanban__column-header",style:B.color?{borderTopColor:B.color}:void 0,onClick:f?()=>Le(B.key):void 0,role:f?"button":void 0,tabIndex:f?0:void 0,onKeyDown:f?ce=>{(ce.key==="Enter"||ce.key===" ")&&Le(B.key)}:void 0,children:[f&&e.jsx("span",{className:"nice-kanban__collapse-icon","aria-hidden":"true",children:e.jsx(Ni,{open:!ze})}),e.jsx("span",{className:"nice-kanban__column-title",children:B.title}),e.jsx("span",{className:"nice-kanban__column-count",children:B.limit!=null?e.jsxs("span",{className:"nice-kanban__count-frac",children:[e.jsx("span",{className:"nice-kanban__count-num",children:fe.length}),e.jsx("span",{className:"nice-kanban__count-slash",children:"/"}),e.jsx("span",{className:"nice-kanban__count-den",children:B.limit})]}):fe.length})]}),!ze&&e.jsxs("div",{className:"nice-kanban__column-body",children:[fe.map(ce=>e.jsx("div",{className:`nice-kanban__card nice-kanban__card--${Re} ${R?.cardKey===ce.key?"nice-kanban__card--dragging":""}`,draggable:!o,onDragStart:m=>De(m,ce),onDragEnd:Se,onClick:()=>ne(ce),role:Ke?"button":"article",tabIndex:Ke?0:void 0,onKeyDown:Ke?k.clickOnActivationKey:void 0,children:l?l(ce):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"nice-kanban__card-title",children:ce.title}),Re!=="compact"&&ce.description&&e.jsx("div",{className:"nice-kanban__card-desc",children:ce.description})]})},ce.key)),fe.length===0&&e.jsx("div",{className:"nice-kanban__empty",children:oe("kanban.empty","No cards")})]}),!ze&&(d||z&&v)&&!Ve&&e.jsxs("button",{type:"button",className:"nice-kanban__add",onClick:()=>S(B.key),disabled:o,children:[e.jsx(ki,{})," ",oe("kanban.addCard","Add card")]})]},B.key)})]}),z&&de&&e.jsxs(Pt.NiceModal,{open:!0,onClose:()=>T(null),title:de.key==null?x||oe("kanban.newCard","New card"):j||oe("kanban.editCard","Edit card"),children:[e.jsx(Lt.NiceForm,{items:P,data:de.data,columns:_,...g,onFieldChange:(B,fe)=>T(Ae=>Ae&&{...Ae,data:{...Ae.data,[B]:fe}})}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end",marginTop:16,flexWrap:"wrap"},children:[de.key!=null&&K&&e.jsx(Qe.NiceButton,{type:"button",size:"sm",variant:"error",style:{marginRight:"auto"},onClick:()=>{K(de.key),T(null)},children:oe("controls.delete","Delete")}),e.jsx(Qe.NiceButton,{type:"button",size:"sm",variant:"secondary",onClick:()=>T(null),children:oe("controls.cancel","Cancel")}),e.jsx(Qe.NiceButton,{type:"button",size:"sm",variant:"primary",onClick:()=>{if(de.key==null){const B={key:`card-${Date.now()}`,title:"",column:de.column,...de.data};v?.(B)}else O?.(de.key,{...de.data,key:de.key,column:de.column});T(null)},children:oe("controls.save","Save")})]})]})]})}),{displayName:"NiceKanbanBoard"}),Si=[];function Cn(...n){return n.filter(Boolean).map(i=>typeof i=="object"?Object.entries(i).filter(([,a])=>a).map(([a])=>a).join(" "):i).join(" ")}const Ci=50,Ii=[10,25,50,100,200],Di=40,Mi={compact:32,normal:Di,comfortable:48},Ei=10,Ai=768,Ti=500,Ri=10;function gn(n,i){return i.split(".").reduce((a,s)=>a?.[s],n)}function Ct(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 Bn(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(k.NiceIcon,{name:"check",size:14}):e.jsx(k.NiceIcon,{name:"close",size:14});case"enum":return i.enumOptions?.find(l=>l.value===n)?.label||String(n);default:return String(n)}}function zi(n,i,a,s){const[l,d]=t.useState(0),{startIndex:o,endIndex:c,totalHeight:f,offsetY:p}=t.useMemo(()=>{const L=n.length*a,D=Math.ceil(i/a),I=Math.max(0,Math.floor(l/a)-s),P=Math.min(n.length,Math.ceil(l/a)+D+s),_=I*a;return{startIndex:I,endIndex:P,totalHeight:L,offsetY:_}},[n.length,i,a,l,s]),C=t.useMemo(()=>n.slice(o,c),[n,o,c]),w=t.useCallback(L=>{d(L.currentTarget.scrollTop)},[]);return{visibleData:C,totalHeight:f,offsetY:p,handleScroll:w,startIndex:o}}function $i(n,i){const[a,s]=t.useState(()=>{if(n&&typeof window<"u"){const d=localStorage.getItem(`nice-module-grid-${n}`);if(d)return JSON.parse(d)}return i||{}}),l=t.useCallback(d=>{s(o=>{const c={...o,...d};return n&&typeof window<"u"&&localStorage.setItem(`nice-module-grid-${n}`,JSON.stringify(c)),c})},[n]);return[a,l]}function Li(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 Pi({column:n,sort:i,onSort:a,onResize:s,resizable:l,t:d}){const o=t.useRef(null),[c,f]=t.useState(!1),p=t.useCallback(L=>{if(!l||!s)return;L.preventDefault(),f(!0);const D=L.clientX,I=n.width||150,P=g=>{const j=g.clientX-D,x=Math.max(n.minWidth||50,I+j);s(n.field,Math.min(x,n.maxWidth||1/0))},_=()=>{f(!1),document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",_)};document.addEventListener("mousemove",P),document.addEventListener("mouseup",_)},[n,l,s]),C=i?.direction,w=C==="asc"?e.jsx(k.NiceIcon,{name:"sort-asc",size:12}):C==="desc"?e.jsx(k.NiceIcon,{name:"sort-desc",size:12}):null;return e.jsxs("div",{className:Cn("nice-module-grid__header-cell",n.sortable&&"nice-module-grid__header-cell--sortable",c&&"nice-module-grid__header-cell--resizing"),style:{...Ct(n),textAlign:n.align},onClick:()=>n.sortable&&a?.(n.field),role:"columnheader","aria-sort":C==="asc"?"ascending":C==="desc"?"descending":"none",title:n.headerTooltip,children:[e.jsx("span",{className:"nice-module-grid__header-text",children:n.header}),w&&e.jsx("span",{className:"nice-module-grid__sort-indicator",children:w}),l&&e.jsx("div",{ref:o,className:"nice-module-grid__resize-handle",onMouseDown:p})]})}function Oi({column:n,row:i,rowIndex:a,value:s,locale:l="pl-PL",onClick:d}){const{t:o}=k.useNiceTranslation(),c=k.useAccessibleClick({onClick:d}),f=d?c:{},p={...Ct(n),textAlign:n.align};if(n.render)return e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:n.render(s,i,a)});if((n.type==="enum"||n.type==="badge")&&n.enumOptions){const C=n.enumOptions.find(w=>w.value===s);if(C)return e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:e.jsxs("span",{className:Cn("nice-module-grid__badge",`nice-module-grid__badge--${C.color||"default"}`),children:[C.icon&&e.jsx("span",{className:"nice-module-grid__badge-icon",children:C.icon}),C.label]})})}if(n.type==="progress"){const C=Math.min(100,Math.max(0,Number(s)||0));return e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:e.jsxs("div",{className:"nice-module-grid__progress",children:[e.jsx("div",{className:"nice-module-grid__progress-bar",children:e.jsx("div",{className:Cn("nice-module-grid__progress-fill",`nice-module-grid__progress-fill--${n.progressColor||"primary"}`),style:{width:`${C}%`}})}),e.jsxs("span",{className:"nice-module-grid__progress-text",children:[C,"%"]})]})})}if(n.type==="rating"){const C=n.maxRating||5,w=Number(s)||0;return e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:e.jsx("span",{className:"nice-module-grid__rating","aria-label":o("pagination.outOfStars","{rating} out of {max} stars").replace("{rating}",String(w)).replace("{max}",String(C)),children:Array.from({length:C},(L,D)=>e.jsx("span",{className:Cn("nice-module-grid__rating-star",D<w&&"nice-module-grid__rating-star--filled"),children:e.jsx(k.NiceIcon,{name:"star",size:14})},D))})})}if(n.type==="link"&&n.linkTemplate){const C=n.linkTemplate.replace(/\{\{(\w+)\}\}/g,(w,L)=>String(gn(i,L)??""));return e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:e.jsx("a",{href:C,target:n.linkNewTab?"_blank":void 0,rel:n.linkNewTab?"noopener noreferrer":void 0,className:"nice-module-grid__link",children:Bn(s,n,l)})})}if(n.type==="image"){const w={xs:24,sm:32,md:48,lg:64}[n.imageSize||"sm"];return e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:s?e.jsx("img",{src:String(s),alt:"",className:"nice-module-grid__image",style:{width:w,height:w}}):e.jsx("div",{className:"nice-module-grid__image-placeholder",style:{width:w,height:w}})})}return n.type==="avatar"?e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,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:p,role:"gridcell",...f,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:{...p,textAlign:n.align||"center"},role:"gridcell",...f,children:e.jsx("span",{className:Cn("nice-module-grid__boolean",!!s&&"nice-module-grid__boolean--true"),children:e.jsx(k.NiceIcon,{name:s?"check":"close",size:14})})}):e.jsx("div",{className:"nice-module-grid__cell",style:p,role:"gridcell",...f,children:Bn(s,n,l)})}function Vi({row:n,index:i,columns:a,primaryField:s,secondaryField:l,customRender:d,selected:o,onClick:c,locale:f="pl-PL",t:p}){const C={role:"option","aria-selected":!!o,onClick:c,onKeyDown:D=>{D.target===D.currentTarget&&(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),c?.())}};if(d)return e.jsx("div",{className:Cn("nice-module-grid__mobile-card",o&&"nice-module-grid__mobile-card--selected"),...C,children:d(n,i)});const w=a.find(D=>D.field===s)||a[0],L=a.find(D=>D.field===l)||a[1];return e.jsxs("div",{className:Cn("nice-module-grid__mobile-card",o&&"nice-module-grid__mobile-card--selected"),...C,children:[e.jsxs("div",{className:"nice-module-grid__mobile-card-header",children:[e.jsx("div",{className:"nice-module-grid__mobile-card-title",children:Bn(gn(n,w?.field||""),w,f)}),L&&e.jsx("div",{className:"nice-module-grid__mobile-card-subtitle",children:Bn(gn(n,L.field),L,f)})]}),e.jsx("div",{className:"nice-module-grid__mobile-card-body",children:a.filter(D=>!D.hidden&&D.field!==s&&D.field!==l).slice(0,4).map(D=>e.jsxs("div",{className:"nice-module-grid__mobile-card-field",children:[e.jsx("span",{className:"nice-module-grid__mobile-card-label",children:D.header}),e.jsx("span",{className:"nice-module-grid__mobile-card-value",children:Bn(gn(n,D.field),D,f)})]},D.field))})]})}function Fi({page:n,pageSize:i,totalRows:a,pageSizeOptions:s,onPageChange:l,t:d}){const o=Math.ceil(a/i),c=(n-1)*i+1,f=Math.min(n*i,a);return e.jsxs("div",{className:"nice-module-grid__pagination",role:"navigation","aria-label":d("pagination.ariaLabel","Pagination"),children:[e.jsxs("div",{className:"nice-module-grid__pagination-info",children:[d("pagination.showing","Showing")," ",c,"–",f," ",d("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:p=>l(1,Number(p.target.value)),"aria-label":d("pagination.rowsPerPage","Rows per page"),children:s.map(p=>e.jsx("option",{value:p,children:p},p))}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(1,i),disabled:n===1,"aria-label":d("pagination.first","First"),children:e.jsx(k.NiceIcon,{name:"skip-back",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(n-1,i),disabled:n===1,"aria-label":d("pagination.previous","Previous"),children:e.jsx(k.NiceIcon,{name:"chevron-left",size:14})}),e.jsxs("span",{className:"nice-module-grid__pagination-page",children:[n," / ",o]}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(n+1,i),disabled:n>=o,"aria-label":d("pagination.next","Next"),children:e.jsx(k.NiceIcon,{name:"chevron-right",size:14})}),e.jsx("button",{className:"nice-module-grid__pagination-btn",onClick:()=>l(o,i),disabled:n>=o,"aria-label":d("pagination.last","Last"),children:e.jsx(k.NiceIcon,{name:"skip-forward",size:14})})]})]})}function Bi({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 Ki(n,i){const{columns:a=Si,data:s,keyField:l="id",dataSource:d,onFetch:o,sortable:c=!0,sort:f,onSortChange:p,multiSort:C=!1,filter:w,searchText:L,onSearchChange:D,searchPlaceholder:I,pagination:P=!0,page:_,pageSize:g,pageSizeOptions:j=Ii,totalRows:x,onPageChange:O,virtualScroll:v=!0,rowHeight:K,overscan:Q=Ei,selectionMode:ue="none",selectedKeys:re,onSelectionChange:_e,columnResize:pe=!0,onColumnWidthChange:ee,contextMenuItems:ve,onContextMenuAction:U,exportable:le=!0,exportFormats:Ce=["csv","excel"],onExport:xe,preferencesKey:oe,initialPreferences:R,density:W="normal",striped:A=!0,bordered:b=!1,hoverable:de=!0,loading:T=!1,emptyState:z,toolbar:ne,onRowClick:Ke,onRowDoubleClick:S,rowClassName:H,rowStyle:me,mobileCardView:Ie=!0,mobileBreakpoint:he=Ai,mobileCardRender:Re,mobilePrimaryField:be,mobileSecondaryField:Le,size:Oe="medium",skeletonLoading:De=!0,skeletonRows:on=Ri,"aria-label":tn,"aria-labelledby":an,"aria-describedby":Se,className:B,style:fe,id:Ae,testId:Ve}=n,ze=K??Mi[W],{t:ce,lang:m}=k.useNiceTranslation();k.useNiceAccessMode(),k.useComponentDisplayStyle("table");const X=Li(he),[we,q]=$i(oe,R),Ue=t.useRef(null),$e=t.useRef(null),[Te,sn]=t.useState([]),[M,Y]=t.useState(),[ae,Fe]=t.useState(""),[te,Ne]=t.useState(1),[ye,qe]=t.useState(g||Ci),[fn,He]=t.useState(new Set),[dn,kn]=t.useState([]),[se,Tn]=t.useState(0),[Rn,Be]=t.useState(!1),[cn,zn]=t.useState(new Set),[Ze,Xe]=t.useState(null),[In,Mn]=t.useState({}),Ge=f??Te,bn=w??M,en=L??ae,pn=_??te,h=g??ye,u=re??fn,N=!!(o||d),V=x??(N?se:s?.length??0),F=t.useMemo(()=>{const y=new Set(we.hiddenColumns||[]);return a.filter(ie=>!ie.hidden&&!y.has(ie.field))},[a,we.hiddenColumns]),E=t.useMemo(()=>{if(N)return dn;if(!s)return[];let y=[...s];if(en){const ie=en.toLowerCase(),ge=a.filter(Me=>Me.searchable!==!1).map(Me=>Me.field);y=y.filter(Me=>ge.some(mn=>{const xn=gn(Me,mn);return String(xn??"").toLowerCase().includes(ie)}))}return Ge.length>0&&y.sort((ie,ge)=>{for(const Me of Ge){const mn=gn(ie,Me.field),xn=gn(ge,Me.field),yn=mn<xn?-1:mn>xn?1:0;if(yn!==0)return Me.direction==="asc"?yn:-yn}return 0}),y},[N,dn,s,en,Ge,a]),$=t.useMemo(()=>{if(N||!P)return E;const y=(pn-1)*h;return E.slice(y,y+h)},[N,E,P,pn,h]),Z=Ue.current?.clientHeight||400,J=v&&$.length>Ti,{visibleData:Pe,totalHeight:ke,offsetY:We,handleScroll:ln,startIndex:wn}=zi($,Z,ze,Q),Ye=J?Pe:$,_n=t.useCallback(async()=>{if(o){Be(!0);try{const ie=await o({page:pn,pageSize:h,sort:Ge,filter:bn,search:en});kn(ie.data),Tn(ie.total)}catch(y){console.error("NiceModuleGrid fetch error:",y)}finally{Be(!1)}}},[o,pn,h,Ge,bn,en]);t.useEffect(()=>{N&&_n()},[N,_n]);const En=t.useCallback(y=>{const ie=Ge.find(Me=>Me.field===y);let ge;ie?ie.direction==="asc"?ge=Ge.map(Me=>Me.field===y?{...Me,direction:"desc"}:Me):ge=Ge.filter(Me=>Me.field!==y):ge=C?[...Ge,{field:y,direction:"asc"}]:[{field:y,direction:"asc"}],p?p(ge):sn(ge)},[Ge,C,p]),Jn=t.useCallback((y,ie)=>{O?O(y,ie):(Ne(y),qe(ie))},[O]),et=t.useCallback(y=>{D?D(y):Fe(y),O||Ne(1)},[D,O]),$n=t.useCallback((y,ie)=>{const ge=new Set(u);if(ue==="single"?(ge.clear(),ge.add(y)):(ue==="multiple"||ue==="checkbox")&&(ge.has(y)?ge.delete(y):ge.add(y)),_e){const Me=$.filter(mn=>ge.has(String(gn(mn,l))));_e(ge,Me)}else He(ge)},[u,ue,_e,$,l]),An=t.useCallback((y,ie)=>{Mn(ge=>({...ge,[y]:ie})),ee?.(y,ie),q({columnWidths:{...we.columnWidths,[y]:ie}})},[ee,q,we.columnWidths]),Kn=t.useCallback((y,ie)=>{if(ve?.length)if(y.preventDefault(),y.clientX===0&&y.clientY===0){const ge=y.currentTarget.getBoundingClientRect();Xe({x:ge.left,y:ge.bottom,row:ie})}else Xe({x:y.clientX,y:y.clientY,row:ie})},[ve]),rn=t.useRef(null);k.useOverlayFocus(rn,{open:Ze!=null,modal:!1,onClose:()=>Xe(null)}),k.useRovingFocus(rn,{orientation:"vertical",wrap:!0,typeahead:!0});const Ln=t.useCallback(y=>{Ze&&U?.(y,Ze.row),Xe(null)},[Ze,U]),Un=t.useCallback(async y=>{if(xe)await xe(y,{selectedOnly:u.size>0,columns:F.map(ie=>ie.field)});else if(y==="csv"){const ie=F.map(un=>un.header).join(","),ge=$.map(un=>F.map(Wn=>JSON.stringify(gn(un,Wn.field)??"")).join(",")),Me=[ie,...ge].join(`
|
|
7
|
+
`),mn=new Blob([Me],{type:"text/csv;charset=utf-8;"}),xn=URL.createObjectURL(mn),yn=document.createElement("a");yn.href=xn,yn.download=`export-${new Date().toISOString().slice(0,10)}.csv`,yn.click(),URL.revokeObjectURL(xn)}},[xe,u,F,$]);t.useEffect(()=>{if(!Ze)return;const y=()=>Xe(null);return document.addEventListener("click",y),()=>document.removeEventListener("click",y)},[Ze]),k.useGridFocus($e,{pageSize:10});const Gn=t.useRef(null);k.useRovingFocus(Gn,{orientation:"vertical",pageSize:10});const jn=T||Rn,Pn=!jn&&Ye.length===0,On=X&&Ie,Vn=Cn("nice-module-grid",`nice-module-grid--${W}`,`nice-module-grid--${Oe}`,A&&"nice-module-grid--striped",b&&"nice-module-grid--bordered",de&&"nice-module-grid--hoverable",jn&&"nice-module-grid--loading",On&&"nice-module-grid--mobile",B);return e.jsxs("div",{ref:i,id:Ae,"data-testid":Ve,className:Vn,style:fe,"aria-busy":jn,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:I??ce("moduleGrid.searchPlaceholder","Search…"),value:en,onChange:y=>et(y.target.value),"aria-label":ce("moduleGrid.searchAriaLabel","Search")})}),ne,le&&e.jsx("div",{className:"nice-module-grid__toolbar-export",children:Ce.map(y=>e.jsx("button",{className:"nice-module-grid__export-btn",onClick:()=>Un(y),"aria-label":ce(`moduleGrid.export.${y}`,`Export to ${y.toUpperCase()}`),children:y.toUpperCase()},y))})]}),e.jsx("div",{ref:Ue,className:"nice-module-grid__container",onScroll:J?ln:void 0,children:On?e.jsx("div",{ref:Gn,className:"nice-module-grid__mobile-list",role:"listbox","aria-label":tn,"aria-labelledby":an,"aria-describedby":Se,"aria-multiselectable":ue==="checkbox"||void 0,children:jn&&De?Array.from({length:on},(y,ie)=>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}})]},ie)):Pn?e.jsxs("div",{className:"nice-module-grid__empty",children:[z?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:z.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:z?.title||ce("moduleGrid.noData","No data")}),z?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:z.description}),z?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:z.action.onClick,children:[z.action.icon,z.action.label]})]}):Ye.map((y,ie)=>{const ge=String(gn(y,l));return e.jsx(Vi,{row:y,index:wn+ie,columns:F,primaryField:be,secondaryField:Le,customRender:Re,selected:u.has(ge),locale:m,onClick:()=>{ue!=="none"&&$n(ge,y),Ke?.(y,wn+ie)},t:ce},ge)})}):e.jsxs("div",{ref:$e,className:"nice-module-grid__table",role:"grid","aria-label":tn,"aria-labelledby":an,"aria-describedby":Se,"aria-rowcount":V,"aria-colcount":F.length,children:[e.jsxs("div",{className:"nice-module-grid__header",role:"row",children:[ue==="checkbox"&&e.jsx("div",{className:"nice-module-grid__header-cell nice-module-grid__header-cell--checkbox",role:"columnheader",children:e.jsx("input",{type:"checkbox",checked:u.size>0&&u.size===Ye.length,onChange:()=>{if(u.size===Ye.length)_e?.(new Set,[]),He(new Set);else{const y=new Set(Ye.map(ie=>String(gn(ie,l))));_e?.(y,Ye),He(y)}},"aria-label":ce("moduleGrid.selectAll","Select all")})}),F.map(y=>e.jsx(Pi,{column:{...y,width:In[y.field]||y.width},sort:Ge.find(ie=>ie.field===y.field),onSort:c?En:void 0,onResize:pe?An:void 0,resizable:pe,t:ce},y.field))]}),e.jsx("div",{className:"nice-module-grid__body",style:J?{height:ke,position:"relative"}:void 0,children:jn&&De?Array.from({length:on},(y,ie)=>e.jsx(Bi,{columns:F},ie)):Pn?e.jsxs("div",{className:"nice-module-grid__empty",children:[z?.icon&&e.jsx("div",{className:"nice-module-grid__empty-icon",children:z.icon}),e.jsx("div",{className:"nice-module-grid__empty-title",children:z?.title||ce("moduleGrid.noData","No data")}),z?.description&&e.jsx("div",{className:"nice-module-grid__empty-description",children:z.description}),z?.action&&e.jsxs("button",{className:"nice-module-grid__empty-action",onClick:z.action.onClick,children:[z.action.icon,z.action.label]})]}):e.jsx("div",{style:J?{transform:`translateY(${We}px)`}:void 0,children:Ye.map((y,ie)=>{const ge=String(gn(y,l)),Me=wn+ie,mn=u.has(ge),xn=typeof H=="function"?H(y,Me):H,yn=typeof me=="function"?me(y,Me):me;return e.jsxs("div",{className:Cn("nice-module-grid__row",mn&&"nice-module-grid__row--selected",xn),style:{...yn,height:ze},role:"row","aria-rowindex":Me+1,"aria-selected":mn,onClick:()=>{ue!=="none"&&$n(ge,y),Ke?.(y,Me)},onDoubleClick:()=>S?.(y,Me),onContextMenu:un=>Kn(un,y),children:[ue==="checkbox"&&e.jsx("div",{className:"nice-module-grid__cell nice-module-grid__cell--checkbox",role:"gridcell",children:e.jsx("input",{type:"checkbox",checked:mn,onChange:()=>$n(ge,y),onClick:un=>un.stopPropagation(),"aria-label":ce("moduleGrid.selectRow","Select row")})}),F.map(un=>e.jsx(Oi,{column:{...un,width:In[un.field]||un.width},row:y,rowIndex:Me,value:gn(y,un.field),locale:m},un.field))]},ge)})})})]})}),P&&V>0&&e.jsx(Fi,{page:pn,pageSize:h,totalRows:N?se:E.length,pageSizeOptions:j,onPageChange:Jn,t:ce}),Ze&&ve&&e.jsx("div",{ref:rn,className:"nice-module-grid__context-menu",style:{left:Ze.x,top:Ze.y},role:"menu",children:ve.filter(y=>typeof y.hidden=="function"?!y.hidden(Ze.row):!y.hidden).map(y=>{if(y.divider)return e.jsx("div",{className:"nice-module-grid__context-menu-divider"},y.key);const ie=typeof y.disabled=="function"?y.disabled(Ze.row):y.disabled;return e.jsxs("button",{className:Cn("nice-module-grid__context-menu-item",y.danger&&"nice-module-grid__context-menu-item--danger",ie&&"nice-module-grid__context-menu-item--disabled"),onClick:()=>{ie||(y.onClick?.(Ze.row),Ln(y.key))},disabled:ie,role:"menuitem",children:[y.icon&&e.jsx("span",{className:"nice-module-grid__context-menu-icon",children:y.icon}),y.label]},y.key)})}),jn&&!De&&e.jsx("div",{className:"nice-module-grid__loading-overlay",children:e.jsx("div",{className:"nice-module-grid__spinner","aria-label":ce("moduleGrid.loading","Loading")})})]})}const Ui=t.forwardRef(Ki),hn={width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0},Gi=()=>e.jsxs("svg",{...hn,children:[e.jsx("path",{d:"M3 7v6h6"}),e.jsx("path",{d:"M21 17a9 9 0 0 0-15-6.7L3 13"})]}),Wi=()=>e.jsxs("svg",{...hn,children:[e.jsx("path",{d:"M21 7v6h-6"}),e.jsx("path",{d:"M3 17a9 9 0 0 1 15-6.7L21 13"})]}),Qi=()=>e.jsxs("svg",{...hn,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"})]}),qi=()=>e.jsxs("svg",{...hn,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"})]}),Yi=()=>e.jsxs("svg",{...hn,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"})]}),Hi=()=>e.jsxs("svg",{...hn,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"})]}),Zi=()=>e.jsxs("svg",{...hn,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"})]}),Xi=()=>e.jsxs("svg",{...hn,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"})]}),Ji=()=>e.jsxs("svg",{...hn,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"})]}),ea=()=>e.jsx("svg",{...hn,children:e.jsx("polyline",{points:"6 9 12 4 18 9"})}),na=()=>e.jsx("svg",{...hn,children:e.jsx("polyline",{points:"6 15 12 20 18 15"})}),ta=()=>e.jsxs("svg",{...hn,style:{opacity:.55},children:[e.jsx("polyline",{points:"6 9 12 4 18 9"}),e.jsx("polyline",{points:"6 15 12 20 18 15"})]}),ia=()=>e.jsxs("svg",{...hn,children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),aa=()=>e.jsxs("svg",{...hn,children:[e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"}),e.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"})]});function It(n){let i="",a=n;for(;a>=0;)i=String.fromCharCode(65+a%26)+i,a=Math.floor(a/26)-1;return i}function Ee(n,i){return`${It(i)}${n+1}`}function nn(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 sa(n,i,a=new Set){const s=n.startsWith("=")?n.slice(1).trim():n,l=(_,g)=>{if(!_||!g)return[];const j=[];for(let x=_.row;x<=g.row;x++)for(let O=_.col;O<=g.col;O++){const v=Je(Ee(x,O),i,new Set(a));typeof v=="number"&&j.push(v)}return j},d=(_,g)=>{if(!_||!g)return[];const j=[];for(let x=_.row;x<=g.row;x++)for(let O=_.col;O<=g.col;O++)j.push(Je(Ee(x,O),i,new Set(a)));return j},o=s.match(/^(\w+)\(([A-Z]+\d+):([A-Z]+\d+)\)$/i);if(o){const _=o[1].toUpperCase(),g=nn(o[2].toUpperCase()),j=nn(o[3].toUpperCase());switch(_){case"SUM":return l(g,j).reduce((O,v)=>O+v,0);case"AVG":case"AVERAGE":{const x=l(g,j);return x.length>0?x.reduce((O,v)=>O+v,0)/x.length:0}case"COUNT":return l(g,j).length;case"COUNTA":return d(g,j).filter(x=>x!==null&&x!=="").length;case"COUNTBLANK":return d(g,j).filter(x=>x===null||x==="").length;case"MIN":{const x=l(g,j);return x.length?Math.min(...x):0}case"MAX":{const x=l(g,j);return x.length?Math.max(...x):0}case"MEDIAN":{const x=l(g,j).sort((v,K)=>v-K);if(!x.length)return 0;const O=Math.floor(x.length/2);return x.length%2?x[O]:(x[O-1]+x[O])/2}case"STDEV":{const x=l(g,j);if(x.length<2)return 0;const O=x.reduce((v,K)=>v+K,0)/x.length;return Math.sqrt(x.reduce((v,K)=>v+(K-O)**2,0)/(x.length-1))}case"PRODUCT":{const x=l(g,j);return x.length?x.reduce((O,v)=>O*v,1):0}}}const c=s.match(/^(SUMIF|COUNTIF)\(([A-Z]+\d+):([A-Z]+\d+)\s*,\s*"?([^"]*)"?\)$/i);if(c){const _=c[1].toUpperCase(),g=nn(c[2].toUpperCase()),j=nn(c[3].toUpperCase()),x=c[4];if(g&&j){let O=0;for(let v=g.row;v<=j.row;v++)for(let K=g.col;K<=j.col;K++){const Q=Je(Ee(v,K),i,new Set(a));(x.startsWith(">")?Number(Q)>Number(x.slice(1)):x.startsWith("<")?Number(Q)<Number(x.slice(1)):String(Q)===x||typeof Q=="number"&&Q===Number(x))&&(O+=_==="SUMIF"?typeof Q=="number"?Q:0:1)}return O}}const f=s.match(/^IF\(([^,]+),\s*([^,]+),\s*([^)]+)\)$/i);if(f){const _=f[1].trim(),g=f[2].trim(),j=f[3].trim(),x=_.match(/^([A-Z]+\d+)\s*([><=!]+)\s*(\S+)$/i);let O=!1;if(x){const Q=Je(x[1].toUpperCase(),i,new Set(a)),ue=isNaN(Number(x[3]))?x[3].replace(/^"|"$/g,""):Number(x[3]),re=x[2],_e=typeof Q=="number"?Q:Number(Q)||0,pe=typeof ue=="number"?ue:Number(ue)||0;switch(re){case">":O=_e>pe;break;case"<":O=_e<pe;break;case">=":O=_e>=pe;break;case"<=":O=_e<=pe;break;case"=":case"==":O=_e===pe;break;case"<>":case"!=":O=_e!==pe;break}}const v=O?g:j;if(nn(v.toUpperCase()))return Je(v.toUpperCase(),i,new Set(a));const K=Number(v);return isNaN(K)?v.replace(/^"|"$/g,""):K}const p=s.match(/^CONCAT\((.+)\)$/i);if(p)return p[1].split(",").map(g=>g.trim()).map(g=>{if(g.startsWith('"')&&g.endsWith('"'))return g.slice(1,-1);if(nn(g.toUpperCase())){const x=Je(g.toUpperCase(),i,new Set(a));return x!==null?String(x):""}return g}).join("");const C=s.match(/^VLOOKUP\(([^,]+),\s*([A-Z]+\d+):([A-Z]+\d+),\s*(\d+)\)$/i);if(C){let _;nn(C[1].trim().toUpperCase())?_=Je(C[1].trim().toUpperCase(),i,new Set(a)):_=isNaN(Number(C[1]))?C[1].replace(/^"|"$/g,""):Number(C[1]);const j=nn(C[2].toUpperCase()),x=nn(C[3].toUpperCase()),O=parseInt(C[4])-1;if(j&&x)for(let v=j.row;v<=x.row;v++){const K=Je(Ee(v,j.col),i,new Set(a));if(String(K)===String(_))return Je(Ee(v,j.col+O),i,new Set(a))}return null}const w=s.match(/^(ABS|ROUND|FLOOR|CEIL|CEILING|SQRT|LEN|UPPER|LOWER|TRIM|INT)\(([^)]+)\)$/i);if(w){const _=w[1].toUpperCase(),g=w[2].trim();let j;switch(nn(g.toUpperCase())?j=Je(g.toUpperCase(),i,new Set(a)):j=isNaN(Number(g))?g.replace(/^"|"$/g,""):Number(g),_){case"ABS":return Math.abs(Number(j)||0);case"ROUND":return Math.round(Number(j)||0);case"FLOOR":return Math.floor(Number(j)||0);case"CEIL":case"CEILING":return Math.ceil(Number(j)||0);case"SQRT":return Math.sqrt(Number(j)||0);case"INT":return Math.trunc(Number(j)||0);case"LEN":return String(j??"").length;case"UPPER":return String(j??"").toUpperCase();case"LOWER":return String(j??"").toLowerCase();case"TRIM":return String(j??"").trim()}}const L=s.match(/^POWER\(([^,]+),\s*([^)]+)\)$/i);if(L){const _=Number(nn(L[1].trim().toUpperCase())?Je(L[1].trim().toUpperCase(),i,new Set(a)):L[1].trim())||0,g=Number(nn(L[2].trim().toUpperCase())?Je(L[2].trim().toUpperCase(),i,new Set(a)):L[2].trim())||0;return Math.pow(_,g)}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 D=s.match(/^([A-Z]+\d+)$/i);if(D)return Je(D[1].toUpperCase(),i,a);const I=s.match(/^([A-Z]+\d+)\s*([+\-*/])\s*([A-Z]+\d+|\d+\.?\d*)$/i);if(I){const _=I[1].toUpperCase(),g=I[2],j=I[3],x=Je(_,i,a),v=nn(j.toUpperCase())?Je(j.toUpperCase(),i,a):parseFloat(j),K=typeof x=="number"?x:0,Q=typeof v=="number"?v:0;switch(g){case"+":return K+Q;case"-":return K-Q;case"*":return K*Q;case"/":return Q!==0?K/Q:null}}const P=parseFloat(s);return isNaN(P)?s:P}function Je(n,i,a){if(a.has(n))return null;a.add(n);const s=i[n];return s?s.formula?sa(s.formula,i,a):s.value:null}function yt(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 vt(n){return{name:n,data:{}}}const ra=Object.assign(t.forwardRef(({sheets:n,activeSheet:i,rows:a=50,cols:s=26,showToolbar:l=!0,showFormulaBar:d=!0,showSheetTabs:o=!0,readOnly:c=!1,disabled:f=!1,loading:p=!1,error:C,size:w="md",onChange:L,onActiveSheetChange:D,onCellSelect:I,onCopy:P,onPaste:_,onInsert:g,onRemove:j,maxUndo:x=50,sortable:O=!1,filterable:v=!1,rangeSelection:K=!0,className:Q,style:ue,id:re,..._e},pe)=>{const ee=c||f,ve=k.useControlId(re),{t:U}=k.useNiceTranslation(),[le,Ce]=t.useState(()=>n??[vt(U("spreadsheet.sheet","Sheet")+" 1")]),[xe,oe]=t.useState(0),R=n??le,W=i??xe,A=R[W]??R[0],[b,de]=t.useState(null),[T,z]=t.useState(null),[ne,Ke]=t.useState(!1),[S,H]=t.useState(null),[me,Ie]=t.useState(""),he=t.useRef(null),Re=t.useRef(null),[be,Le]=t.useState([]),[Oe,De]=t.useState([]),[on,tn]=t.useState(null),an=t.useRef({x:0,width:80}),[Se,B]=t.useState(null),[fe,Ae]=t.useState(null),Ve=t.useRef(null);k.useRovingFocus(Ve,{orientation:"horizontal",wrap:!0,activateOnMove:!0});const[ze,ce]=t.useState("");t.useEffect(()=>{S&&he.current&&he.current.focus()},[S]);const m=t.useMemo(()=>{if(!b)return null;const h=T??b;return{startRow:Math.min(b.row,h.row),startCol:Math.min(b.col,h.col),endRow:Math.max(b.row,h.row),endCol:Math.max(b.col,h.col)}},[b,T]),X=t.useCallback((h,u)=>m?h>=m.startRow&&h<=m.endRow&&u>=m.startCol&&u<=m.endCol:!1,[m]),we=t.useCallback(h=>{Le(u=>{const N=[...u,h.map(V=>({...V,data:{...V.data}}))];return N.length>x?N.slice(-x):N}),De([])},[x]),q=t.useCallback((h,u=!0)=>{u&&we(R);const N=h(R);n||Ce(N),L?.(N)},[R,n,L,we]),Ue=t.useCallback(()=>{if(be.length===0)return;const h=be[be.length-1];De(u=>[...u,R.map(N=>({...N,data:{...N.data}}))]),Le(u=>u.slice(0,-1)),n||Ce(h),L?.(h)},[be,R,n,L]),$e=t.useCallback(()=>{if(Oe.length===0)return;const h=Oe[Oe.length-1];Le(u=>[...u,R.map(N=>({...N,data:{...N.data}}))]),De(u=>u.slice(0,-1)),n||Ce(h),L?.(h)},[Oe,R,n,L]),Te=t.useCallback(h=>{i||oe(h),D?.(h),de(null),z(null),H(null)},[i,D]),sn=t.useCallback((h,u,N)=>{const V=Ee(h,u);q(F=>{const E=F.map((Z,J)=>J===W?{...Z,data:{...Z.data}}:Z),$=N.startsWith("=");return E[W].data[V]={...E[W].data[V]??{value:null},formula:$?N:void 0,value:$?null:isNaN(Number(N))?N:Number(N)},E})},[W,q]),M=t.useCallback((h,u,N)=>{N?.shiftKey&&K&&b?z({row:h,col:u}):(de({row:h,col:u}),z(null)),H(null),I?.(W,h,u)},[W,I,K,b]),Y=t.useCallback((h,u,N)=>{N.button===0&&(M(h,u,N),K&&!N.shiftKey&&Ke(!0))},[M,K]),ae=t.useCallback((h,u)=>{ne&&z({row:h,col:u})},[ne]);t.useEffect(()=>{if(!ne)return;const h=()=>Ke(!1);return document.addEventListener("mouseup",h),()=>document.removeEventListener("mouseup",h)},[ne]);const Fe=t.useCallback((h,u)=>{if(ee)return;const N=Ee(h,u),V=A.data[N];V?.readOnly||(H({row:h,col:u}),Ie(V?.formula??(V?.value!=null?String(V.value):"")))},[ee,A.data]),te=t.useCallback(()=>{S&&(sn(S.row,S.col,me),H(null))},[S,me,sn]),Ne=t.useCallback(h=>{if(h.key==="Enter")te();else if(h.key==="Escape")H(null);else if(h.key==="Tab"&&S&&(h.preventDefault(),te(),b)){const u=h.shiftKey?Math.max(0,b.col-1):Math.min(s-1,b.col+1);de({row:b.row,col:u})}},[te,b,s,S]),ye=t.useCallback((h,u)=>{if(!b)return;const N=m??{startRow:b.row,startCol:b.col,endRow:b.row,endCol:b.col};q(V=>{const F=V.map((E,$)=>$===W?{...E,data:{...E.data}}:E);for(let E=N.startRow;E<=N.endRow;E++)for(let $=N.startCol;$<=N.endCol;$++){const Z=Ee(E,$);F[W].data[Z]={...F[W].data[Z]??{value:null},[h]:u}}return F})},[b,m,W,q]),qe=t.useCallback(h=>{if(!m||P?.(m)===!1)return;const{startRow:u,startCol:N,endRow:V,endCol:F}=m,E=[];for(let $=u;$<=V;$++){const Z=[];for(let J=N;J<=F;J++){const Pe=Ee($,J),ke=A.data[Pe],We=ke?Je(Pe,A.data,new Set):null;Z.push(yt(We,ke?.format))}E.push(Z.join(" "))}h.clipboardData.setData("text/plain",E.join(`
|
|
8
|
+
`)),h.preventDefault()},[m,A.data,P]),fn=t.useCallback(h=>{if(ee||!b)return;const u=h.clipboardData.getData("text/plain");if(!u)return;const N=u.split(`
|
|
9
|
+
`).map(V=>V.split(" "));_?.(N,b.row,b.col)!==!1&&(q(V=>{const F=V.map((E,$)=>$===W?{...E,data:{...E.data}}:E);return N.forEach((E,$)=>{E.forEach((Z,J)=>{const Pe=Ee(b.row+$,b.col+J),ke=Z.startsWith("=");F[W].data[Pe]={...F[W].data[Pe]??{value:null},formula:ke?Z:void 0,value:ke?null:isNaN(Number(Z))?Z:Number(Z)}})}),F}),h.preventDefault())},[ee,b,W,q,_]),He=t.useCallback(h=>{q(u=>u.map((V,F)=>{if(F!==W)return V;const E={};for(const[$,Z]of Object.entries(V.data)){const J=nn($);J&&(J.row>h?E[Ee(J.row+1,J.col)]=Z:E[$]=Z)}return{...V,data:E}})),g?.("row",h)},[W,q,g]),dn=t.useCallback(h=>{q(u=>u.map((V,F)=>{if(F!==W)return V;const E={};for(const[$,Z]of Object.entries(V.data)){const J=nn($);J&&(J.col>h?E[Ee(J.row,J.col+1)]=Z:E[$]=Z)}return{...V,data:E}})),g?.("column",h)},[W,q,g]),kn=t.useCallback(h=>{q(u=>u.map((V,F)=>{if(F!==W)return V;const E={};for(const[$,Z]of Object.entries(V.data)){const J=nn($);J&&J.row!==h&&(J.row>h?E[Ee(J.row-1,J.col)]=Z:E[$]=Z)}return{...V,data:E}})),j?.("row",h)},[W,q,j]),se=t.useCallback(h=>{q(u=>u.map((V,F)=>{if(F!==W)return V;const E={};for(const[$,Z]of Object.entries(V.data)){const J=nn($);J&&J.col!==h&&(J.col>h?E[Ee(J.row,J.col-1)]=Z:E[$]=Z)}return{...V,data:E}})),j?.("column",h)},[W,q,j]),Tn=t.useCallback((h,u)=>{q(N=>N.map((F,E)=>{if(E!==W)return F;const $=new Map;for(const[Pe,ke]of Object.entries(F.data)){const We=nn(Pe);We&&($.has(We.row)||$.set(We.row,{}),$.get(We.row)[We.col]=ke)}const Z=Array.from($.entries()).sort((Pe,ke)=>{const We=Je(Ee(Pe[0],h),F.data,new Set),ln=Je(Ee(ke[0],h),F.data,new Set),wn=typeof We=="number"?We:Number(We),Ye=typeof ln=="number"?ln:Number(ln);if(!isNaN(wn)&&!isNaN(Ye))return u==="asc"?wn-Ye:Ye-wn;const _n=String(We??""),En=String(ln??"");return u==="asc"?_n.localeCompare(En):En.localeCompare(_n)}),J={};return Z.forEach(([,Pe],ke)=>{for(const[We,ln]of Object.entries(Pe))J[Ee(ke,Number(We))]=ln}),{...F,data:J,sortColumn:h,sortDirection:u}}))},[W,q]),Rn=t.useCallback((h,u)=>{const N=A.conditionalFormats;if(!N?.length)return;const V=Ee(h,u),F=Je(V,A.data,new Set),E=typeof F=="number"?F:Number(F);for(const $ of N){const Z=$.range.match(/^([A-Z]+\d+):([A-Z]+\d+)$/i);if(!Z)continue;const J=nn(Z[1].toUpperCase()),Pe=nn(Z[2].toUpperCase());if(!J||!Pe||h<J.row||h>Pe.row||u<J.col||u>Pe.col)continue;let ke=!1;switch($.type){case"greaterThan":ke=!isNaN(E)&&E>Number($.value);break;case"lessThan":ke=!isNaN(E)&&E<Number($.value);break;case"equalTo":ke=String(F)===String($.value);break;case"between":ke=!isNaN(E)&&E>=Number($.value)&&E<=Number($.value2);break;case"textContains":ke=String(F).includes(String($.value));break;case"isEmpty":ke=F===null||F==="";break;case"isNotEmpty":ke=F!==null&&F!=="";break}if(ke)return{backgroundColor:$.style.bgColor,color:$.style.color,fontWeight:$.style.bold?"bold":void 0,fontStyle:$.style.italic?"italic":void 0}}},[A.conditionalFormats,A.data]),Be=t.useCallback(()=>{const h=`${U("spreadsheet.sheet","Sheet")} ${R.length+1}`;q(u=>[...u,vt(h)]),Te(R.length)},[R.length,q,Te,U]),cn=t.useCallback(()=>{R.length<=1||(q(h=>h.filter((u,N)=>N!==W)),Te(Math.max(0,W-1)))},[R.length,W,q,Te]),zn=t.useCallback((h,u)=>{u.trim()&&(q(N=>N.map((V,F)=>F===h?{...V,name:u.trim()}:V),!1),Ae(null))},[q]),Ze=t.useMemo(()=>{if(!b)return"";const h=Ee(b.row,b.col),u=A.data[h];return u?.formula??(u?.value!=null?String(u.value):"")},[b,A.data]),Xe=t.useMemo(()=>{if(!m)return null;const{startRow:h,startCol:u,endRow:N,endCol:V}=m;if(h===N&&u===V)return null;const F=[];let E=0;for(let $=h;$<=N;$++)for(let Z=u;Z<=V;Z++){const J=Ee($,Z),Pe=Je(J,A.data,new Set);Pe!==null&&Pe!==""&&E++,typeof Pe=="number"&&F.push(Pe)}return F.length===0?{count:E}:{count:E,sum:F.reduce(($,Z)=>$+Z,0),avg:F.reduce(($,Z)=>$+Z,0)/F.length,min:Math.min(...F),max:Math.max(...F)}},[m,A.data]),In=t.useCallback((h,u)=>{u.preventDefault(),u.stopPropagation(),tn(h),an.current={x:u.clientX,width:A.colWidths?.[h]??80}},[A.colWidths]);t.useEffect(()=>{if(on===null)return;const h=N=>{const V=N.clientX-an.current.x,F=Math.max(30,an.current.width+V);q(E=>E.map((Z,J)=>J===W?{...Z,colWidths:{...Z.colWidths,[on]:F}}:Z),!1)},u=()=>tn(null);return document.addEventListener("mousemove",h),document.addEventListener("mouseup",u),()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",u)}},[on,W,q]);const Mn=t.useCallback((h,u,N)=>{h.preventDefault(),de({row:u,col:N}),B({x:h.clientX,y:h.clientY})},[]);t.useEffect(()=>{if(!Se)return;const h=()=>B(null);return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[Se]);const Ge=t.useCallback(h=>{if((h.ctrlKey||h.metaKey)&&!S){if(h.key==="z"){h.preventDefault(),Ue();return}if(h.key==="y"){h.preventDefault(),$e();return}}if(S||!b)return;let{row:u,col:N}=b;switch(h.key){case"ArrowUp":u=Math.max(0,u-1);break;case"ArrowDown":u=Math.min(a-1,u+1);break;case"ArrowLeft":N=Math.max(0,N-1);break;case"ArrowRight":N=Math.min(s-1,N+1);break;case"Home":N=0,u=h.ctrlKey||h.metaKey?0:u;break;case"End":N=s-1,u=h.ctrlKey||h.metaKey?a-1:u;break;case"PageUp":u=Math.max(0,u-10);break;case"PageDown":u=Math.min(a-1,u+10);break;case"Enter":Fe(u,N);return;case"Delete":case"Backspace":ee||(m&&(m.startRow!==m.endRow||m.startCol!==m.endCol)?q(V=>{const F=V.map((E,$)=>$===W?{...E,data:{...E.data}}:E);for(let E=m.startRow;E<=m.endRow;E++)for(let $=m.startCol;$<=m.endCol;$++)delete F[W].data[Ee(E,$)];return F}):sn(u,N,""));return;default:if(h.key.length===1&&!h.ctrlKey&&!h.metaKey&&!ee){H({row:u,col:N}),Ie(h.key);return}return}h.preventDefault(),h.shiftKey&&K?z({row:u,col:N}):(de({row:u,col:N}),z(null)),I?.(W,u,N)},[S,b,a,s,ee,Fe,sn,W,I,Ue,$e,m,q,K]),bn=A.frozenRows??0,en=A.frozenCols??0,pn=[{value:"text",label:U("spreadsheet.formatText","Text")},{value:"number",label:U("spreadsheet.formatNumber","Number")},{value:"percent",label:U("spreadsheet.formatPercent","Percent")},{value:"currency",label:U("spreadsheet.formatCurrency","Currency")},{value:"date",label:U("spreadsheet.formatDate","Date")}];return e.jsxs("div",{ref:pe,id:ve,className:`nice-spreadsheet nice-spreadsheet--${w} ${c&&!f?"nice-spreadsheet--readonly":""} ${f?"nice-spreadsheet--disabled":""} ${p?"nice-spreadsheet--loading":""} ${C?"nice-spreadsheet--error":""} ${Q??""}`,style:{...ue,position:p?"relative":ue?.position},onKeyDown:Ge,onCopy:qe,onPaste:fn,tabIndex:f?-1:0,role:"application","aria-label":U("spreadsheet.label","Spreadsheet"),"aria-disabled":f||void 0,"aria-busy":p||void 0,..._e,children:[C&&e.jsx("div",{className:"nice-spreadsheet__error",role:"alert",children:C}),p&&e.jsx("span",{className:"nice-spreadsheet__spinner","aria-hidden":"true",children:e.jsx("span",{className:"nice-spinner nice-spinner--sm"})}),l&&!ee&&e.jsxs("div",{className:"nice-spreadsheet__toolbar",role:"toolbar",children:[e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:Ue,disabled:be.length===0,title:U("spreadsheet.undo","Undo"),children:e.jsx(Gi,{})}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:$e,disabled:Oe.length===0,title:U("spreadsheet.redo","Redo"),children:e.jsx(Wi,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(Qe.NiceButton,{variant:A.data[b?Ee(b.row,b.col):""]?.bold?"primary":"ghost",size:"sm",onClick:()=>ye("bold",!A.data[b?Ee(b.row,b.col):""]?.bold),title:U("spreadsheet.bold","Bold"),children:e.jsx("strong",{children:"B"})}),e.jsx(Qe.NiceButton,{variant:A.data[b?Ee(b.row,b.col):""]?.italic?"primary":"ghost",size:"sm",onClick:()=>ye("italic",!A.data[b?Ee(b.row,b.col):""]?.italic),title:U("spreadsheet.italic","Italic"),children:e.jsx("em",{children:"I"})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>ye("align","left"),title:U("spreadsheet.alignLeft","Align left"),children:e.jsx(Qi,{})}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>ye("align","center"),title:U("spreadsheet.alignCenter","Center"),children:e.jsx(qi,{})}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>ye("align","right"),title:U("spreadsheet.alignRight","Align right"),children:e.jsx(Yi,{})}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(pt.NiceColorPicker,{value:A.data[b?Ee(b.row,b.col):""]?.bgColor??"var(--nice-bg-primary, #ffffff)",onChange:h=>ye("bgColor",h),title:U("spreadsheet.bgColor","Background color"),showInput:!1,showRandom:!1}),e.jsx(pt.NiceColorPicker,{value:A.data[b?Ee(b.row,b.col):""]?.color??"var(--nice-text-primary, #000000)",onChange:h=>ye("color",h),title:U("spreadsheet.textColor","Text color"),showInput:!1,showRandom:!1}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(Vt.NiceSelect,{size:"sm",value:A.data[b?Ee(b.row,b.col):""]?.format??"text",onChange:h=>ye("format",h),options:pn,"aria-label":U("spreadsheet.format","Cell format")}),e.jsx("span",{className:"nice-spreadsheet__separator"}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b&&He(b.row),title:U("spreadsheet.insertRow","Insert row"),children:e.jsx(Hi,{})}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b&&dn(b.col),title:U("spreadsheet.insertCol","Insert column"),children:e.jsx(Zi,{})}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b&&kn(b.row),title:U("spreadsheet.deleteRow","Delete row"),children:e.jsx(Xi,{})}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>b&&se(b.col),title:U("spreadsheet.deleteCol","Delete column"),children:e.jsx(Ji,{})})]}),d&&e.jsxs("div",{className:"nice-spreadsheet__formula-bar",children:[e.jsxs("span",{className:"nice-spreadsheet__cell-label",children:[b?Ee(b.row,b.col):"",m&&m.startRow!==m.endRow||m&&m.startCol!==m.endCol?`:${Ee(m.endRow,m.endCol)}`:""]}),e.jsx(ft.NiceTextInput,{className:"nice-spreadsheet__formula-input",value:S?me:Ze,onChange:h=>{S?Ie(h):b&&(H(b),Ie(h))},onKeyDown:Ne,readOnly:ee,"aria-label":U("spreadsheet.formulaBar","Formula bar")})]}),e.jsx("div",{className:"nice-spreadsheet__grid",ref:Re,children:e.jsxs("table",{role:"grid","aria-label":A.name,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"nice-spreadsheet__corner"}),Array.from({length:s},(h,u)=>e.jsxs("th",{className:`nice-spreadsheet__col-header ${u<en?"nice-spreadsheet__col-header--frozen":""}`,style:{width:A.colWidths?.[u]??80,position:u<en?"sticky":void 0,left:u<en?u*80+40:void 0,zIndex:u<en?3:void 0},children:[e.jsx("span",{children:It(u)}),O&&e.jsx("span",{role:"button",tabIndex:0,onKeyDown:k.clickOnActivationKey,className:"nice-spreadsheet__sort-trigger",onClick:()=>Tn(u,A.sortColumn===u&&A.sortDirection==="asc"?"desc":"asc"),title:U("spreadsheet.sort","Sort"),children:A.sortColumn===u?A.sortDirection==="asc"?e.jsx(ea,{}):e.jsx(na,{}):e.jsx(ta,{})}),!ee&&e.jsx("span",{className:"nice-spreadsheet__col-resize",onMouseDown:N=>In(u,N)})]},u))]})}),e.jsx("tbody",{children:Array.from({length:a},(h,u)=>e.jsxs("tr",{className:u<bn?"nice-spreadsheet__row--frozen":"",style:u<bn?{position:"sticky",top:u*24,zIndex:2}:void 0,children:[e.jsx("td",{className:"nice-spreadsheet__row-header",children:u+1}),Array.from({length:s},(N,V)=>{const F=Ee(u,V),E=A.data[F];if(E?.mergedInto)return null;const $=b?.row===u&&b?.col===V,Z=X(u,V),J=S?.row===u&&S?.col===V,Pe=E?Je(F,A.data,new Set):null,ke=Rn(u,V),We=u<bn||V<en;return e.jsxs("td",{className:`nice-spreadsheet__cell ${$?"nice-spreadsheet__cell--selected":""} ${Z&&!$?"nice-spreadsheet__cell--in-range":""} ${E?.readOnly?"nice-spreadsheet__cell--readonly":""} ${We?"nice-spreadsheet__cell--frozen":""}`,style:{textAlign:E?.align,fontWeight:E?.bold?"bold":void 0,fontStyle:E?.italic?"italic":void 0,backgroundColor:ke?.backgroundColor??E?.bgColor,color:ke?.color??E?.color,width:A.colWidths?.[V],height:A.rowHeights?.[u],position:We?"sticky":void 0,left:V<en?V*80+40:void 0,zIndex:We?1:void 0,...ke},colSpan:E?.colSpan,rowSpan:E?.rowSpan,onMouseDown:ln=>Y(u,V,ln),onMouseEnter:()=>ae(u,V),onDoubleClick:()=>Fe(u,V),onContextMenu:ln=>Mn(ln,u,V),role:"gridcell","aria-selected":$,title:E?.comment,children:[E?.comment&&e.jsx("span",{className:"nice-spreadsheet__comment-indicator"}),J?e.jsx("input",{ref:he,className:"nice-spreadsheet__cell-editor",value:me,onChange:ln=>Ie(ln.target.value),onKeyDown:Ne,onBlur:te}):yt(Pe,E?.format)]},V)})]},u))})]})}),Se&&!ee&&b&&e.jsxs("div",{className:"nice-spreadsheet__context-menu",style:{position:"fixed",left:Se.x,top:Se.y,zIndex:1e3},children:[e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{He(b.row),B(null)},children:U("spreadsheet.insertRowAbove","Insert row above")}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{He(b.row+1),B(null)},children:U("spreadsheet.insertRowBelow","Insert row below")}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{dn(b.col),B(null)},children:U("spreadsheet.insertColLeft","Insert column left")}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{dn(b.col+1),B(null)},children:U("spreadsheet.insertColRight","Insert column right")}),e.jsx("hr",{className:"nice-spreadsheet__context-sep"}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{kn(b.row),B(null)},children:U("spreadsheet.deleteRow","Delete row")}),e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:()=>{se(b.col),B(null)},children:U("spreadsheet.deleteCol","Delete column")})]}),Xe&&e.jsxs("div",{className:"nice-spreadsheet__status-bar",children:[e.jsxs("span",{children:[U("spreadsheet.count","Count"),": ",Xe.count]}),Xe.sum!==void 0&&e.jsxs("span",{children:[U("spreadsheet.sum","Sum"),": ",Xe.sum.toFixed(2)]}),Xe.avg!==void 0&&e.jsxs("span",{children:[U("spreadsheet.avg","Avg"),": ",Xe.avg.toFixed(2)]}),Xe.min!==void 0&&e.jsxs("span",{children:[U("spreadsheet.min","Min"),": ",Xe.min]}),Xe.max!==void 0&&e.jsxs("span",{children:[U("spreadsheet.max","Max"),": ",Xe.max]})]}),o&&e.jsxs("div",{className:"nice-spreadsheet__tabs",role:"tablist",ref:Ve,children:[R.map((h,u)=>e.jsx("span",{className:"nice-spreadsheet__tab-wrapper",children:fe===u?e.jsx(ft.NiceTextInput,{className:"nice-spreadsheet__tab-rename",value:ze,onChange:N=>ce(N),onBlur:()=>zn(u,ze),onKeyDown:N=>{N.key==="Enter"&&zn(u,ze),N.key==="Escape"&&Ae(null)},autoFocus:!0}):e.jsx("span",{onDoubleClick:()=>{ee||(Ae(u),ce(h.name))},children:e.jsx(Qe.NiceButton,{variant:u===W?"primary":"ghost",size:"sm",role:"tab","aria-selected":u===W,onClick:()=>Te(u),onKeyDown:N=>{N.key==="F2"&&!ee&&(N.preventDefault(),Ae(u),ce(h.name))},children:h.name})})},u)),!ee&&e.jsxs(e.Fragment,{children:[e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:Be,title:U("spreadsheet.addSheet","Add sheet"),children:e.jsx(ia,{})}),R.length>1&&e.jsx(Qe.NiceButton,{variant:"ghost",size:"sm",onClick:cn,title:U("spreadsheet.removeSheet","Remove sheet"),children:e.jsx(aa,{})})]})]})]})}),{displayName:"NiceSpreadsheet"}),ca=`
|
|
10
|
+
.nice-reconciliation {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
height: 100%;
|
|
14
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
15
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
16
|
+
border-radius: var(--nice-radius-lg, 0.5rem);
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.nice-reconciliation__toolbar {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
gap: 0.75rem;
|
|
24
|
+
padding: 0.75rem 1rem;
|
|
25
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
26
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
27
|
+
flex-wrap: wrap;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.nice-reconciliation__toolbar-group {
|
|
31
|
+
display: flex;
|
|
32
|
+
align-items: center;
|
|
33
|
+
gap: 0.5rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.nice-reconciliation__toolbar-group--end {
|
|
37
|
+
margin-inline-start: auto;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.nice-reconciliation__btn {
|
|
41
|
+
display: inline-flex;
|
|
42
|
+
align-items: center;
|
|
43
|
+
gap: 0.375rem;
|
|
44
|
+
padding: 0.375rem 0.75rem;
|
|
45
|
+
font-size: 0.8125rem;
|
|
46
|
+
font-weight: 500;
|
|
47
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
48
|
+
cursor: pointer;
|
|
49
|
+
transition: all 0.15s ease;
|
|
50
|
+
border: 1px solid var(--nice-border-color, #d1d5db);
|
|
51
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
52
|
+
color: var(--nice-text-primary);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.nice-reconciliation__btn:hover {
|
|
56
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.nice-reconciliation__btn--primary {
|
|
60
|
+
background: var(--nice-primary, #3b82f6);
|
|
61
|
+
border-color: var(--nice-primary, #3b82f6);
|
|
62
|
+
color: white;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.nice-reconciliation__btn--primary:hover {
|
|
66
|
+
background: var(--nice-primary-dark, #2563eb);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.nice-reconciliation__btn--success {
|
|
70
|
+
background: var(--nice-success, #10b981);
|
|
71
|
+
border-color: var(--nice-success, #10b981);
|
|
72
|
+
color: white;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.nice-reconciliation__btn:disabled {
|
|
76
|
+
opacity: 0.5;
|
|
77
|
+
cursor: not-allowed;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.nice-reconciliation__content {
|
|
81
|
+
display: flex;
|
|
82
|
+
flex: 1;
|
|
83
|
+
overflow: hidden;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.nice-reconciliation--vertical .nice-reconciliation__content {
|
|
87
|
+
flex-direction: column;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.nice-reconciliation__panel {
|
|
91
|
+
flex: 1;
|
|
92
|
+
display: flex;
|
|
93
|
+
flex-direction: column;
|
|
94
|
+
min-width: 0;
|
|
95
|
+
min-height: 0;
|
|
96
|
+
overflow: hidden;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.nice-reconciliation__panel--statements {
|
|
100
|
+
border-inline-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.nice-reconciliation--vertical .nice-reconciliation__panel--statements {
|
|
104
|
+
border-inline-end: none;
|
|
105
|
+
border-block-end: 1px solid var(--nice-border-color, #e5e7eb);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.nice-reconciliation__panel-header {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: space-between;
|
|
112
|
+
padding: 0.75rem 1rem;
|
|
113
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
114
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.nice-reconciliation__panel-title {
|
|
118
|
+
font-weight: 600;
|
|
119
|
+
font-size: 0.875rem;
|
|
120
|
+
color: var(--nice-text-primary);
|
|
121
|
+
display: flex;
|
|
122
|
+
align-items: center;
|
|
123
|
+
gap: 0.5rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
.nice-reconciliation__panel-badge {
|
|
127
|
+
font-size: 0.75rem;
|
|
128
|
+
font-weight: 500;
|
|
129
|
+
padding: 0.125rem 0.5rem;
|
|
130
|
+
border-radius: var(--nice-radius-full, 9999px);
|
|
131
|
+
background: var(--nice-bg-tertiary, #e5e7eb);
|
|
132
|
+
color: var(--nice-text-secondary);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.nice-reconciliation__panel-content {
|
|
136
|
+
flex: 1;
|
|
137
|
+
overflow: auto;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.nice-reconciliation__row {
|
|
141
|
+
display: flex;
|
|
142
|
+
align-items: center;
|
|
143
|
+
gap: 0.75rem;
|
|
144
|
+
padding: 0.625rem 1rem;
|
|
145
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
146
|
+
cursor: pointer;
|
|
147
|
+
user-select: none;
|
|
148
|
+
transition: background 0.1s ease;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.nice-reconciliation__row:hover {
|
|
152
|
+
background: var(--nice-bg-hover, rgba(0, 0, 0, 0.02));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.nice-reconciliation__row--selected {
|
|
156
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.1));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.nice-reconciliation__row--dragging {
|
|
160
|
+
opacity: 0.6;
|
|
161
|
+
background: var(--nice-primary-light, rgba(59, 130, 246, 0.15));
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.nice-reconciliation__row--drop-target {
|
|
165
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
166
|
+
box-shadow: inset 0 0 0 2px var(--nice-success, #10b981);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.nice-reconciliation__row--matched {
|
|
170
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.nice-reconciliation__row--partial {
|
|
174
|
+
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.08));
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.nice-reconciliation__row--unmatched {
|
|
178
|
+
background: transparent;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.nice-reconciliation__row--excluded {
|
|
182
|
+
opacity: 0.5;
|
|
183
|
+
background: var(--nice-bg-tertiary, #f3f4f6);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
.nice-reconciliation__status {
|
|
187
|
+
width: 0.5rem;
|
|
188
|
+
height: 0.5rem;
|
|
189
|
+
border-radius: var(--nice-radius-full, 50%);
|
|
190
|
+
flex-shrink: 0;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
.nice-reconciliation__status--matched {
|
|
194
|
+
background: var(--nice-success, #10b981);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
.nice-reconciliation__status--partial {
|
|
198
|
+
background: var(--nice-warning, #f59e0b);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.nice-reconciliation__status--unmatched {
|
|
202
|
+
background: var(--nice-danger, #ef4444);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.nice-reconciliation__status--excluded {
|
|
206
|
+
background: var(--nice-text-disabled, #9ca3af);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.nice-reconciliation__row-main {
|
|
210
|
+
flex: 1;
|
|
211
|
+
min-width: 0;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.nice-reconciliation__row-date {
|
|
215
|
+
font-size: 0.75rem;
|
|
216
|
+
color: var(--nice-text-secondary);
|
|
217
|
+
margin-bottom: 0.125rem;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.nice-reconciliation__row-description {
|
|
221
|
+
font-size: 0.8125rem;
|
|
222
|
+
color: var(--nice-text-primary);
|
|
223
|
+
white-space: nowrap;
|
|
224
|
+
overflow: hidden;
|
|
225
|
+
text-overflow: ellipsis;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
.nice-reconciliation__row-counterparty {
|
|
229
|
+
font-size: 0.75rem;
|
|
230
|
+
color: var(--nice-text-tertiary);
|
|
231
|
+
white-space: nowrap;
|
|
232
|
+
overflow: hidden;
|
|
233
|
+
text-overflow: ellipsis;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.nice-reconciliation__row-amount {
|
|
237
|
+
font-size: 0.875rem;
|
|
238
|
+
font-weight: 600;
|
|
239
|
+
font-variant-numeric: tabular-nums;
|
|
240
|
+
white-space: nowrap;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.nice-reconciliation__row-amount--positive {
|
|
244
|
+
color: var(--nice-success, #10b981);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
.nice-reconciliation__row-amount--negative {
|
|
248
|
+
color: var(--nice-danger, #ef4444);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.nice-reconciliation__confidence {
|
|
252
|
+
display: flex;
|
|
253
|
+
align-items: center;
|
|
254
|
+
gap: 0.25rem;
|
|
255
|
+
font-size: 0.6875rem;
|
|
256
|
+
padding: 0.125rem 0.375rem;
|
|
257
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
.nice-reconciliation__confidence--high {
|
|
261
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.15));
|
|
262
|
+
color: var(--nice-success-dark, #059669);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.nice-reconciliation__confidence--medium {
|
|
266
|
+
background: var(--nice-warning-bg, rgba(245, 158, 11, 0.15));
|
|
267
|
+
color: var(--nice-warning-dark, #d97706);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.nice-reconciliation__confidence--low {
|
|
271
|
+
background: var(--nice-danger-bg, rgba(239, 68, 68, 0.15));
|
|
272
|
+
color: var(--nice-danger-dark, #dc2626);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.nice-reconciliation__empty {
|
|
276
|
+
display: flex;
|
|
277
|
+
flex-direction: column;
|
|
278
|
+
align-items: center;
|
|
279
|
+
justify-content: center;
|
|
280
|
+
padding: 3rem 1rem;
|
|
281
|
+
color: var(--nice-text-secondary);
|
|
282
|
+
text-align: center;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.nice-reconciliation__empty-icon {
|
|
286
|
+
font-size: 2.5rem;
|
|
287
|
+
margin-bottom: 0.75rem;
|
|
288
|
+
opacity: 0.5;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.nice-reconciliation__summary {
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 1.5rem;
|
|
295
|
+
padding: 0.75rem 1rem;
|
|
296
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
297
|
+
border-top: 1px solid var(--nice-border-color, #e5e7eb);
|
|
298
|
+
font-size: 0.8125rem;
|
|
299
|
+
flex-wrap: wrap;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
.nice-reconciliation__summary-item {
|
|
303
|
+
display: flex;
|
|
304
|
+
align-items: center;
|
|
305
|
+
gap: 0.375rem;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
.nice-reconciliation__summary-label {
|
|
309
|
+
color: var(--nice-text-secondary);
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
.nice-reconciliation__summary-value {
|
|
313
|
+
font-weight: 600;
|
|
314
|
+
color: var(--nice-text-primary);
|
|
315
|
+
font-variant-numeric: tabular-nums;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
.nice-reconciliation__summary-value--success {
|
|
319
|
+
color: var(--nice-success, #10b981);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
.nice-reconciliation__summary-value--warning {
|
|
323
|
+
color: var(--nice-warning, #f59e0b);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.nice-reconciliation__summary-value--danger {
|
|
327
|
+
color: var(--nice-danger, #ef4444);
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
.nice-reconciliation__resizer {
|
|
331
|
+
width: 4px;
|
|
332
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
333
|
+
cursor: col-resize;
|
|
334
|
+
transition: background 0.15s ease;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
.nice-reconciliation__resizer:hover {
|
|
338
|
+
background: var(--nice-primary, #3b82f6);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
.nice-reconciliation--vertical .nice-reconciliation__resizer {
|
|
342
|
+
width: 100%;
|
|
343
|
+
height: 4px;
|
|
344
|
+
cursor: row-resize;
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
.nice-reconciliation__suggestions {
|
|
348
|
+
padding: 0.75rem 1rem;
|
|
349
|
+
background: var(--nice-info-bg, rgba(59, 130, 246, 0.08));
|
|
350
|
+
border-bottom: 1px solid var(--nice-info, #3b82f6);
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.nice-reconciliation__suggestion {
|
|
354
|
+
display: flex;
|
|
355
|
+
align-items: center;
|
|
356
|
+
gap: 0.75rem;
|
|
357
|
+
padding: 0.5rem;
|
|
358
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
359
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
360
|
+
margin-bottom: 0.5rem;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
.nice-reconciliation__suggestion:last-child {
|
|
364
|
+
margin-bottom: 0;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/* Dark mode */
|
|
368
|
+
.dark .nice-reconciliation {
|
|
369
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
370
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
.dark .nice-reconciliation__toolbar,
|
|
374
|
+
.dark .nice-reconciliation__panel-header,
|
|
375
|
+
.dark .nice-reconciliation__summary {
|
|
376
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
377
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
.dark .nice-reconciliation__row--selected {
|
|
381
|
+
background: var(--nice-primary-tint-20, rgba(59, 130, 246, 0.2));
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
/* RTL support */
|
|
385
|
+
[dir="rtl"] .nice-reconciliation__row-amount {
|
|
386
|
+
direction: ltr;
|
|
387
|
+
text-align: left;
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/* Detail Panel */
|
|
391
|
+
.nice-reconciliation__detail-panel {
|
|
392
|
+
position: fixed;
|
|
393
|
+
inset-inline-end: 0;
|
|
394
|
+
top: 0;
|
|
395
|
+
bottom: 0;
|
|
396
|
+
width: 420px;
|
|
397
|
+
max-width: 90vw;
|
|
398
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
399
|
+
box-shadow: -4px 0 24px var(--nice-overlay-15, rgba(0, 0, 0, 0.15));
|
|
400
|
+
z-index: 1000;
|
|
401
|
+
display: flex;
|
|
402
|
+
flex-direction: column;
|
|
403
|
+
transform: translateX(100%);
|
|
404
|
+
transition: transform 0.25s ease-out;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
.nice-reconciliation__detail-panel--open {
|
|
408
|
+
transform: translateX(0);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
.nice-reconciliation__detail-header {
|
|
412
|
+
display: flex;
|
|
413
|
+
align-items: center;
|
|
414
|
+
justify-content: space-between;
|
|
415
|
+
padding: 1rem;
|
|
416
|
+
border-bottom: 1px solid var(--nice-border-color, #e5e7eb);
|
|
417
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
.nice-reconciliation__detail-title {
|
|
421
|
+
font-weight: 600;
|
|
422
|
+
font-size: 1rem;
|
|
423
|
+
color: var(--nice-text-primary);
|
|
424
|
+
display: flex;
|
|
425
|
+
align-items: center;
|
|
426
|
+
gap: 0.5rem;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
.nice-reconciliation__detail-close {
|
|
430
|
+
width: 2rem;
|
|
431
|
+
height: 2rem;
|
|
432
|
+
display: flex;
|
|
433
|
+
align-items: center;
|
|
434
|
+
justify-content: center;
|
|
435
|
+
background: transparent;
|
|
436
|
+
border: none;
|
|
437
|
+
cursor: pointer;
|
|
438
|
+
font-size: 1.25rem;
|
|
439
|
+
color: var(--nice-text-secondary);
|
|
440
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
441
|
+
transition: all 0.15s ease;
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
.nice-reconciliation__detail-close:hover {
|
|
445
|
+
background: var(--nice-bg-hover, #f3f4f6);
|
|
446
|
+
color: var(--nice-text-primary);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
.nice-reconciliation__detail-content {
|
|
450
|
+
flex: 1;
|
|
451
|
+
overflow: auto;
|
|
452
|
+
padding: 1rem;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
.nice-reconciliation__detail-section {
|
|
456
|
+
margin-bottom: 1.5rem;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.nice-reconciliation__detail-section-title {
|
|
460
|
+
font-weight: 600;
|
|
461
|
+
font-size: 0.875rem;
|
|
462
|
+
color: var(--nice-text-primary);
|
|
463
|
+
margin-bottom: 0.75rem;
|
|
464
|
+
display: flex;
|
|
465
|
+
align-items: center;
|
|
466
|
+
gap: 0.375rem;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
.nice-reconciliation__detail-row {
|
|
470
|
+
display: flex;
|
|
471
|
+
justify-content: space-between;
|
|
472
|
+
align-items: flex-start;
|
|
473
|
+
padding: 0.5rem 0;
|
|
474
|
+
border-bottom: 1px solid var(--nice-border-divider, #f3f4f6);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
.nice-reconciliation__detail-row:last-child {
|
|
478
|
+
border-bottom: none;
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
.nice-reconciliation__detail-label {
|
|
482
|
+
font-size: 0.8125rem;
|
|
483
|
+
color: var(--nice-text-secondary);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.nice-reconciliation__detail-value {
|
|
487
|
+
font-size: 0.8125rem;
|
|
488
|
+
font-weight: 500;
|
|
489
|
+
color: var(--nice-text-primary);
|
|
490
|
+
text-align: end;
|
|
491
|
+
max-width: 60%;
|
|
492
|
+
word-break: break-word;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
.nice-reconciliation__detail-divider {
|
|
496
|
+
height: 1px;
|
|
497
|
+
background: var(--nice-border-color, #e5e7eb);
|
|
498
|
+
margin: 1rem 0;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
.nice-reconciliation__detail-match-info {
|
|
502
|
+
padding: 0.75rem;
|
|
503
|
+
background: var(--nice-success-bg, rgba(16, 185, 129, 0.08));
|
|
504
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
505
|
+
margin-bottom: 1rem;
|
|
506
|
+
}
|
|
507
|
+
|
|
508
|
+
.nice-reconciliation__detail-match-header {
|
|
509
|
+
display: flex;
|
|
510
|
+
align-items: center;
|
|
511
|
+
gap: 0.5rem;
|
|
512
|
+
font-weight: 600;
|
|
513
|
+
font-size: 0.8125rem;
|
|
514
|
+
color: var(--nice-success-dark, #059669);
|
|
515
|
+
margin-bottom: 0.5rem;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.nice-reconciliation__detail-match-detail {
|
|
519
|
+
font-size: 0.75rem;
|
|
520
|
+
color: var(--nice-text-secondary);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.nice-reconciliation__detail-side-by-side {
|
|
524
|
+
display: grid;
|
|
525
|
+
grid-template-columns: 1fr 1fr;
|
|
526
|
+
gap: 1rem;
|
|
527
|
+
padding: 0.75rem;
|
|
528
|
+
background: var(--nice-bg-secondary, #f9fafb);
|
|
529
|
+
border-radius: var(--nice-radius-md, 0.375rem);
|
|
530
|
+
margin-top: 0.75rem;
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
.nice-reconciliation__detail-side-item {
|
|
534
|
+
padding: 0.5rem;
|
|
535
|
+
background: var(--nice-bg-primary, #ffffff);
|
|
536
|
+
border-radius: var(--nice-radius-sm, 0.25rem);
|
|
537
|
+
border: 1px solid var(--nice-border-color, #e5e7eb);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
.nice-reconciliation__detail-side-label {
|
|
541
|
+
font-size: 0.6875rem;
|
|
542
|
+
font-weight: 500;
|
|
543
|
+
text-transform: uppercase;
|
|
544
|
+
color: var(--nice-text-tertiary);
|
|
545
|
+
margin-bottom: 0.375rem;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
.nice-reconciliation__detail-side-amount {
|
|
549
|
+
font-size: 1.125rem;
|
|
550
|
+
font-weight: 600;
|
|
551
|
+
font-variant-numeric: tabular-nums;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
.nice-reconciliation__detail-backdrop {
|
|
555
|
+
position: fixed;
|
|
556
|
+
inset: 0;
|
|
557
|
+
background: var(--nice-overlay-30, rgba(0, 0, 0, 0.3));
|
|
558
|
+
z-index: 999;
|
|
559
|
+
opacity: 0;
|
|
560
|
+
pointer-events: none;
|
|
561
|
+
transition: opacity 0.2s ease;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
.nice-reconciliation__detail-backdrop--visible {
|
|
565
|
+
opacity: 1;
|
|
566
|
+
pointer-events: auto;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
.dark .nice-reconciliation__detail-panel {
|
|
570
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
571
|
+
box-shadow: -4px 0 24px var(--nice-overlay-40, rgba(0, 0, 0, 0.4));
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
.dark .nice-reconciliation__detail-header {
|
|
575
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
576
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
.dark .nice-reconciliation__detail-side-by-side {
|
|
580
|
+
background: var(--nice-bg-secondary-dark, #1f2937);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
.dark .nice-reconciliation__detail-side-item {
|
|
584
|
+
background: var(--nice-bg-primary-dark, #111827);
|
|
585
|
+
border-color: var(--nice-border-color-dark, #374151);
|
|
586
|
+
}
|
|
587
|
+
`;function Sn(n,i="PLN",a="pl-PL"){return new Intl.NumberFormat(a,{style:"currency",currency:i,minimumFractionDigits:2,maximumFractionDigits:2}).format(n)}function Xn(n,i="pl-PL"){return n?(typeof n=="string"?new Date(n):n).toLocaleDateString(i,{year:"numeric",month:"2-digit",day:"2-digit"}):"-"}function la(n){return n>=80?"high":n>=50?"medium":"low"}function oa(){return`match-${Date.now()}-${Math.random().toString(36).slice(2,9)}`}function Nt(n){n?.querySelector('[role="option"][tabindex="0"]')?.focus()}function Dt(n,i,a){n.target===n.currentTarget&&(n.key===" "||n.key==="Enter"&&!a?(n.preventDefault(),i()):n.key==="Enter"&&a&&(n.preventDefault(),a()))}function da({item:n,isSelected:i,isDragging:a,isDropTarget:s,suggestion:l,currency:d,locale:o,onSelect:c,onDoubleClick:f,onDragStart:p,onDragEnd:C,onDrop:w,disabled:L}){const D=n.status??"unmatched",I=l?.confidence??n.confidence,P=g=>{g.dataTransfer.setData("text/plain",n.id),g.dataTransfer.setData("source","statement"),g.dataTransfer.effectAllowed="move",p()},_=g=>{g.dataTransfer.types.includes("source")&&g.dataTransfer.getData("source")!=="statement"&&g.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${D} ${i?"nice-reconciliation__row--selected":""} ${a?"nice-reconciliation__row--dragging":""} ${s?"nice-reconciliation__row--drop-target":""}`,draggable:!L&&D!=="matched",onDragStart:P,onDragEnd:C,onDragOver:_,onDrop:w,onClick:c,onDoubleClick:f,onKeyDown:g=>Dt(g,c,f),role:"option","aria-selected":i,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${D}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsx("div",{className:"nice-reconciliation__row-date",children:Xn(n.date,o)}),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})]}),I!=null&&e.jsxs("span",{className:`nice-reconciliation__confidence nice-reconciliation__confidence--${la(I)}`,children:[I,"%"]}),e.jsx("span",{className:`nice-reconciliation__row-amount ${n.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Sn(n.amount,d,o)})]})}function ua({item:n,isSelected:i,isDragging:a,isDropTarget:s,currency:l,locale:d,onSelect:o,onDoubleClick:c,onDragStart:f,onDragEnd:p,onDrop:C,disabled:w}){const L=n.status??"unmatched",D=P=>{P.dataTransfer.setData("text/plain",n.id),P.dataTransfer.setData("source","entry"),P.dataTransfer.effectAllowed="move",f()},I=P=>{P.dataTransfer.types.includes("source")&&P.dataTransfer.getData("source")!=="entry"&&P.preventDefault()};return e.jsxs("div",{className:`nice-reconciliation__row nice-reconciliation__row--${L} ${i?"nice-reconciliation__row--selected":""} ${a?"nice-reconciliation__row--dragging":""} ${s?"nice-reconciliation__row--drop-target":""}`,draggable:!w&&L!=="matched",onDragStart:D,onDragEnd:p,onDragOver:I,onDrop:C,onClick:o,onDoubleClick:c,onKeyDown:P=>Dt(P,o,c),role:"option","aria-selected":i,children:[e.jsx("span",{className:`nice-reconciliation__status nice-reconciliation__status--${L}`}),e.jsxs("div",{className:"nice-reconciliation__row-main",children:[e.jsxs("div",{className:"nice-reconciliation__row-date",children:[Xn(n.date,d),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:Sn(n.amount,l,d)})]})}const ma=t.forwardRef(function(i,a){const{t:s}=k.useNiceTranslation(),{statements:l,bankTransactions:d,entries:o,accountingEntries:c,matches:f,defaultMatches:p=[],suggestions:C=[],config:w={},currency:L,showConfidence:D,statementPanelConfig:I,entryPanelConfig:P,onMatch:_,onAutoMatch:g,onUnmatch:j,onBatchAction:x,onFilterChange:O,onRequestSuggestions:v,onSelectionChange:K,onComplete:Q,size:ue="medium",showToolbar:re=!0,showFilters:_e=!0,showSummary:pe=!0,showSuggestions:ee=!0,layout:ve="horizontal",enableDragDrop:U=!0,enableKeyboard:le=!0,enableDetailPanel:Ce=!0,loading:xe=!1,disabled:oe=!1,readOnly:R=!1,locale:W="pl-PL",labels:A={},className:b,style:de}=i,T=t.useMemo(()=>l??d??[],[l,d]),z=t.useMemo(()=>o??c??[],[o,c]),ne=L??w.currency??"PLN",[Ke,S]=t.useState(p),[H,me]=t.useState(new Set),[Ie,he]=t.useState(new Set),[Re,be]=t.useState(null),[Le,Oe]=t.useState(null),[De,on]=t.useState({}),[tn,an]=t.useState(null),Se=f??Ke,B=t.useRef(null),fe=t.useRef(null),Ae={orientation:"vertical",pageSize:10};k.useRovingFocus(B,Ae),k.useRovingFocus(fe,Ae),t.useEffect(()=>{const M="nice-reconciliation-styles";if(!document.getElementById(M)){const Y=document.createElement("style");Y.id=M,Y.textContent=ca,document.head.appendChild(Y)}},[]);const Ve=t.useMemo(()=>{const M=new Set;return Se.forEach(Y=>Y.statementIds.forEach(ae=>M.add(ae))),M},[Se]),ze=t.useMemo(()=>{const M=new Set;return Se.forEach(Y=>Y.entryIds.forEach(ae=>M.add(ae))),M},[Se]),ce=t.useMemo(()=>{const M=T.filter(Ne=>!Ve.has(Ne.id)),Y=z.filter(Ne=>!ze.has(Ne.id)),ae=T.reduce((Ne,ye)=>Ne+ye.amount,0),Fe=z.reduce((Ne,ye)=>Ne+ye.amount,0),te=T.filter(Ne=>Ve.has(Ne.id)).reduce((Ne,ye)=>Ne+ye.amount,0);return{totalStatements:T.length,totalEntries:z.length,matchedStatements:T.length-M.length,matchedEntries:z.length-Y.length,unmatchedStatements:M.length,unmatchedEntries:Y.length,statementTotal:ae,entryTotal:Fe,matchedAmount:te,unmatchedStatementAmount:M.reduce((Ne,ye)=>Ne+ye.amount,0),unmatchedEntryAmount:Y.reduce((Ne,ye)=>Ne+ye.amount,0),difference:ae-Fe,matchPercentage:T.length>0?Math.round((T.length-M.length)/T.length*100):0,matchCount:Se.length,partialMatchCount:Se.filter(Ne=>Ne.status==="partial").length,pendingSuggestions:C.length}},[T,z,Se,C,Ve,ze]),m=t.useCallback((M,Y)=>{const ae=T.filter(He=>M.includes(He.id)),Fe=z.filter(He=>Y.includes(He.id));if(ae.length===0||Fe.length===0)return null;const te=ae.reduce((He,dn)=>He+dn.amount,0),Ne=Fe.reduce((He,dn)=>He+dn.amount,0),ye=Math.abs(te-Ne),qe=w.amountTolerance??.01,fn={id:oa(),statementIds:M,entryIds:Y,status:ye<=qe?"matched":"partial",statementTotal:te,entryTotal:Ne,difference:ye,confidence:ye<=qe?100:Math.max(0,100-ye/Math.max(Math.abs(te),1)*100),matchedBy:"user",matchedAt:new Date};return f||S(He=>[...He,fn]),_?.(fn,ae,Fe),me(new Set),he(new Set),fn},[T,z,w.amountTolerance,f,_]),X=t.useCallback(M=>{const Y=Se.find(ae=>ae.id===M);Y&&(f||S(ae=>ae.filter(Fe=>Fe.id!==M)),j?.(M,Y.statementIds,Y.entryIds))},[Se,f,j]),we=t.useCallback(async()=>{const M=[],Y=new Set(Ve),ae=new Set(ze),Fe=w.amountTolerance??.01,te=w.dateTolerance??3;for(const Ne of T){if(Y.has(Ne.id))continue;const ye=z.filter(qe=>{if(ae.has(qe.id)||Math.abs(Ne.amount-qe.amount)>Fe)return!1;const He=new Date(Ne.date),dn=new Date(qe.date);return!(Math.abs(He.getTime()-dn.getTime())/(1e3*60*60*24)>te)});if(ye.length===1){const qe=ye[0],fn=m([Ne.id],[qe.id]);fn&&(M.push(fn),Y.add(Ne.id),ae.add(qe.id))}}return x?.("autoMatch",M),M},[T,z,Ve,ze,w,m,x]),q=t.useCallback((M,Y,ae,Fe)=>{Fe!==Y&&(Fe==="statement"?m([ae],[M]):m([M],[ae]),be(null),Oe(null))},[m]),Ue=t.useCallback(()=>{const M=Array.from(H),Y=Array.from(Ie);M.length>0&&Y.length>0&&m(M,Y)},[H,Ie,m]);t.useEffect(()=>{K?.(Array.from(H),Array.from(Ie))},[H,Ie,K]),t.useImperativeHandle(a,()=>({getMatches:()=>Se,getUnmatchedStatements:()=>T.filter(M=>!Ve.has(M.id)),getUnmatchedEntries:()=>z.filter(M=>!ze.has(M.id)),createMatch:m,removeMatch:X,autoMatch:we,getSuggestions:async M=>v?v(M??T.filter(Y=>!Ve.has(Y.id)).map(Y=>Y.id)):[],applySuggestion:M=>m([M.statementId],M.entryIds),approveAll:()=>{x?.("approveAll",Se)},clearAll:()=>{f||S([]),x?.("clearAll",[])},exportMatched:M=>{x?.("exportMatched",Se)},getSummary:()=>ce,reset:()=>{f||S([]),me(new Set),he(new Set),on({})},focusStatements:()=>Nt(B.current),focusEntries:()=>Nt(fe.current)}),[Se,T,z,Ve,ze,m,X,we,v,x,f,ce]);const $e=t.useMemo(()=>T.filter(M=>{if(De.status&&De.status.length>0){const Y=Ve.has(M.id)?"matched":"unmatched";if(!De.status.includes(Y))return!1}if(De.searchText){const Y=De.searchText.toLowerCase();if(!M.description?.toLowerCase().includes(Y)&&!M.counterparty?.toLowerCase().includes(Y))return!1}return!0}),[T,De,Ve]),Te=t.useMemo(()=>z.filter(M=>{if(De.status&&De.status.length>0){const Y=ze.has(M.id)?"matched":"unmatched";if(!De.status.includes(Y))return!1}if(De.searchText){const Y=De.searchText.toLowerCase();if(!M.description?.toLowerCase().includes(Y)&&!M.partyName?.toLowerCase().includes(Y))return!1}return!0}),[z,De,ze]),sn=H.size>0&&Ie.size>0&&!R&&!oe;return e.jsxs("div",{className:`nice-reconciliation nice-reconciliation--${ve} ${b??""}`,style:de,children:[re&&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:we,disabled:oe||R||xe,children:[e.jsx(k.NiceIcon,{name:"zap",size:14})," ",A.autoMatch??s("reconciliationView.autoMatch","Auto-match")]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn nice-reconciliation__btn--success",onClick:Ue,disabled:!sn||xe,children:[e.jsx(k.NiceIcon,{name:"link",size:14})," ",s("reconciliationView.matchSelected","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:()=>x?.("approveAll",Se),disabled:Se.length===0||oe||xe,children:[e.jsx(k.NiceIcon,{name:"check",size:14})," ",A.approveAll??s("reconciliationView.approveAll","Approve All")]}),e.jsxs("button",{type:"button",className:"nice-reconciliation__btn",onClick:()=>{f||S([]),x?.("clearAll",[])},disabled:Se.length===0||oe||R||xe,children:[e.jsx(k.NiceIcon,{name:"close",size:14})," ",A.clearAll??s("reconciliationView.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(k.NiceIcon,{name:"file",size:14})," ",A.statementPanelTitle??s("reconciliationView.bankStatement","Bank Statement"),e.jsx("span",{className:"nice-reconciliation__panel-badge",children:$e.length})]})}),e.jsx("div",{ref:B,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:$e.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(k.NiceIcon,{name:"clipboard",size:32})}),A.noStatements??s("reconciliationView.noStatementItems","No statement items")]}):$e.map(M=>e.jsx(da,{item:{...M,status:Ve.has(M.id)?"matched":"unmatched"},isSelected:H.has(M.id),isDragging:Re===M.id,isDropTarget:Le===M.id,suggestion:C.find(Y=>Y.statementId===M.id),currency:ne,locale:W,onSelect:()=>{oe||me(Y=>{const ae=new Set(Y);return ae.has(M.id)?ae.delete(M.id):ae.add(M.id),ae})},onDoubleClick:Ce?()=>an({type:"statement",id:M.id}):void 0,onDragStart:()=>be(M.id),onDragEnd:()=>{be(null),Oe(null)},onDrop:()=>{Re&&Re!==M.id&&q(M.id,"statement",Re,"entry")},disabled:oe||R||!U},M.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(k.NiceIcon,{name:"book",size:14})," ",A.entryPanelTitle??s("reconciliationView.bookEntries","Book Entries"),e.jsx("span",{className:"nice-reconciliation__panel-badge",children:Te.length})]})}),e.jsx("div",{ref:fe,className:"nice-reconciliation__panel-content",role:"listbox","aria-multiselectable":"true",children:Te.length===0?e.jsxs("div",{className:"nice-reconciliation__empty",children:[e.jsx("div",{className:"nice-reconciliation__empty-icon",children:e.jsx(k.NiceIcon,{name:"book",size:32})}),A.noEntries??s("reconciliationView.noBookEntries","No book entries")]}):Te.map(M=>e.jsx(ua,{item:{...M,status:ze.has(M.id)?"matched":"unmatched"},isSelected:Ie.has(M.id),isDragging:Re===M.id,isDropTarget:Le===M.id,currency:ne,locale:W,onSelect:()=>{oe||he(Y=>{const ae=new Set(Y);return ae.has(M.id)?ae.delete(M.id):ae.add(M.id),ae})},onDoubleClick:Ce?()=>an({type:"entry",id:M.id}):void 0,onDragStart:()=>be(M.id),onDragEnd:()=>{be(null),Oe(null)},onDrop:()=>{Re&&Re!==M.id&&q(M.id,"entry",Re,"statement")},disabled:oe||R||!U},M.id))})]})]}),pe&&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:s("reconciliationView.matched","Matched:")}),e.jsxs("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--success",children:[ce.matchedStatements,"/",ce.totalStatements," (",ce.matchPercentage,"%)"]})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:s("reconciliationView.matchedAmount","Matched Amount:")}),e.jsx("span",{className:"nice-reconciliation__summary-value",children:Sn(ce.matchedAmount,ne,W)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:s("reconciliationView.unmatched","Unmatched:")}),e.jsx("span",{className:"nice-reconciliation__summary-value nice-reconciliation__summary-value--warning",children:Sn(ce.unmatchedStatementAmount,ne,W)})]}),e.jsxs("div",{className:"nice-reconciliation__summary-item",children:[e.jsx("span",{className:"nice-reconciliation__summary-label",children:s("reconciliationView.difference","Difference:")}),e.jsx("span",{className:`nice-reconciliation__summary-value ${Math.abs(ce.difference)<.01?"nice-reconciliation__summary-value--success":"nice-reconciliation__summary-value--danger"}`,children:Sn(ce.difference,ne,W)})]})]}),Ce&&e.jsxs(e.Fragment,{children:[e.jsx("div",{role:"presentation",className:`nice-reconciliation__detail-backdrop ${tn?"nice-reconciliation__detail-backdrop--visible":""}`,onClick:()=>an(null)}),e.jsx("div",{className:`nice-reconciliation__detail-panel ${tn?"nice-reconciliation__detail-panel--open":""}`,children:tn&&e.jsx(ha,{type:tn.type,id:tn.id,statements:T,entries:z,matches:Se,currency:ne,locale:W,labels:A,onClose:()=>an(null)})})]})]})});function ha({type:n,id:i,statements:a,entries:s,matches:l,currency:d,locale:o,labels:c,onClose:f}){const{t:p}=k.useNiceTranslation(),C=n==="statement"?a.find(_=>_.id===i):s.find(_=>_.id===i),w=n==="statement"?l.find(_=>_.statementIds.includes(i)):l.find(_=>_.entryIds.includes(i)),L=w?n==="statement"?s.filter(_=>w.entryIds.includes(_.id)):a.filter(_=>w.statementIds.includes(_.id)):[];if(!C)return null;const D=n==="statement",I=D?C:null,P=D?null:C;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(k.NiceIcon,{name:D?"file":"book",size:14})," ",D?c.statementDetails??p("reconciliationView.transactionDetails","Transaction Details"):c.entryDetails??p("reconciliationView.entryDetails","Entry Details")]}),e.jsx("button",{type:"button",className:"nice-reconciliation__detail-close",onClick:f,"aria-label":p("reconciliationView.close","Close"),children:e.jsx(k.NiceIcon,{name:"close",size:14})})]}),e.jsxs("div",{className:"nice-reconciliation__detail-content",children:[w&&e.jsxs("div",{className:"nice-reconciliation__detail-match-info",children:[e.jsxs("div",{className:"nice-reconciliation__detail-match-header",children:[e.jsx(k.NiceIcon,{name:"check",size:14})," ",p("reconciliationView.matchedConfidence","{label} ({confidence}% confidence)").replace("{label}",c.matchedWith??p("reconciliationView.matched2","Matched")).replace("{confidence}",String(w.confidence?.toFixed(0)??100))]}),e.jsx("div",{className:"nice-reconciliation__detail-match-detail",children:w.matchedBy==="ai"?c.matchedByAI??p("reconciliationView.matchedAutomaticallyByAi","Matched automatically by AI"):c.matchedManually??p("reconciliationView.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:c.statementTotal??p("reconciliationView.statement","Statement")}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${w.statementTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Sn(w.statementTotal,d,o)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-side-item",children:[e.jsx("div",{className:"nice-reconciliation__detail-side-label",children:c.entryTotal??p("reconciliationView.bookEntry","Book Entry")}),e.jsx("div",{className:`nice-reconciliation__detail-side-amount ${w.entryTotal>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Sn(w.entryTotal,d,o)})]})]}),w.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:[c.difference??p("reconciliationView.difference2","Difference"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{color:"var(--nice-warning, #f59e0b)"},children:Sn(w.difference,d,o)})]})]}),e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(k.NiceIcon,{name:"clipboard",size:14})," ",D?c.transactionInfo??p("reconciliationView.transactionInformation","Transaction Information"):c.entryInfo??p("reconciliationView.entryInformation","Entry Information")]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.date??p("reconciliationView.date","Date"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:Xn(C.date,o)})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.description??p("reconciliationView.description","Description"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:C.description})]}),e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.amount??p("reconciliationView.amount","Amount"),":"]}),e.jsx("span",{className:`nice-reconciliation__detail-value ${C.amount>=0?"nice-reconciliation__row-amount--positive":"nice-reconciliation__row-amount--negative"}`,children:Sn(C.amount,d,o)})]}),D&&I?.counterparty&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.counterparty??p("reconciliationView.counterparty","Counterparty"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:I.counterparty})]}),D&&I?.counterpartyAccount&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.accountNumber??p("reconciliationView.account","Account"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",style:{fontFamily:"monospace",fontSize:"0.75rem"},children:I.counterpartyAccount})]}),!D&&P?.partyName&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.party??p("reconciliationView.party","Party"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:P.partyName})]}),!D&&P?.documentNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.documentRef??p("reconciliationView.documentRef","Document Ref"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:P.documentNumber})]}),D&&I?.referenceNumber&&e.jsxs("div",{className:"nice-reconciliation__detail-row",children:[e.jsxs("span",{className:"nice-reconciliation__detail-label",children:[c.reference??p("reconciliationView.reference","Reference"),":"]}),e.jsx("span",{className:"nice-reconciliation__detail-value",children:I.referenceNumber})]})]}),L.length>0&&e.jsxs("div",{className:"nice-reconciliation__detail-section",children:[e.jsxs("div",{className:"nice-reconciliation__detail-section-title",children:[e.jsx(k.NiceIcon,{name:"link",size:14})," ",D?c.matchedEntries??p("reconciliationView.matchedEntries","Matched Entries"):c.matchedStatements??p("reconciliationView.matchedStatements","Matched Statements")]}),L.map(_=>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:_.description}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",color:"var(--nice-text-secondary)"},children:[e.jsx("span",{children:Xn(_.date,o)}),e.jsx("span",{style:{fontWeight:600,color:_.amount>=0?"var(--nice-success)":"var(--nice-danger)"},children:Sn(_.amount,d,o)})]})]},_.id))]})]})]})}const fa=[],pa=({queries:n=fa,currentFilter:i,currentColumns:a,currentSort:s,onLoad:l,onSave:d,onUpdate:o,onDelete:c,onShare:f,onSetDefault:p,allowSharing:C=!0,allowPinning:w=!0,position:L="dropdown",className:D,style:I,"data-testid":P})=>{const{t:_}=k.useNiceTranslation(),[g,j]=t.useState(!1),[x,O]=t.useState(""),[v,K]=t.useState(!1),[Q,ue]=t.useState(""),[re,_e]=t.useState(""),[pe,ee]=t.useState(!1),ve=t.useRef(null);k.useOverlayFocus(ve,{open:g,modal:!1,onClose:()=>j(!1)});const U=n.filter(R=>R.name.toLowerCase().includes(x.toLowerCase())),le=U.filter(R=>!R.isShared),Ce=U.filter(R=>R.isShared),xe=async()=>{if(Q.trim()){K(!0);try{await d({name:Q,description:re||void 0,filter:i??{},columns:a,sort:s}),ee(!1),ue(""),_e("")}finally{K(!1)}}},oe=R=>e.jsxs("div",{className:"nice-saved-query__item",children:[R.icon&&e.jsx("span",{className:"nice-saved-query__icon","aria-hidden":"true",children:R.icon}),e.jsx("span",{className:"nice-saved-query__name",children:R.name}),R.isDefault&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--default",children:_("savedQuery.default","default")}),R.isShared&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--shared",children:_("savedQuery.shared","shared")}),R.isPinned&&e.jsx("span",{className:"nice-saved-query__badge nice-saved-query__badge--pinned",children:_("savedQuery.pinned","pinned")}),e.jsxs("div",{className:"nice-saved-query__actions",children:[e.jsx("button",{onClick:()=>{l(R),j(!1)},type:"button",children:_("savedQuery.load","Load")}),p&&e.jsx("button",{onClick:()=>p(R.id),type:"button",title:_("savedQuery.setDefault","Set as default"),"aria-label":_("savedQuery.setDefault","Set as default"),children:e.jsx(k.NiceIcon,{name:"star",size:14})}),C&&f&&e.jsx("button",{onClick:()=>f(R.id,[]),type:"button",title:_("savedQuery.share","Share"),"aria-label":_("savedQuery.share","Share"),children:e.jsx(k.NiceIcon,{name:"external-link",size:14})}),w&&e.jsx("button",{onClick:()=>o(R.id,{...R}),type:"button",title:_("savedQuery.pin","Pin"),"aria-label":_("savedQuery.pin","Pin"),children:e.jsx(k.NiceIcon,{name:"map-pin",size:14})}),e.jsx("button",{onClick:()=>c(R.id),type:"button",title:_("savedQuery.remove","Remove"),"aria-label":`${_("savedQuery.removeQuery","Remove query")} ${R.name}`,children:e.jsx(k.NiceIcon,{name:"close",size:14})})]})]},R.id);return e.jsxs("div",{className:`nice-saved-query nice-saved-query--${L} ${g?"nice-saved-query--open":""} ${D??""}`,style:I,"data-testid":P,children:[e.jsx("button",{className:"nice-saved-query__trigger",onClick:()=>j(R=>!R),"aria-expanded":g,"aria-haspopup":"dialog",type:"button",children:_("savedQuery.trigger","Views and queries")}),g&&e.jsxs("div",{ref:ve,className:"nice-saved-query__panel",role:"dialog","aria-label":_("savedQuery.manage","Manage saved queries"),children:[e.jsxs("div",{className:"nice-saved-query__search-row",children:[e.jsx("input",{type:"search",placeholder:_("savedQuery.searchPlaceholder","Search queries…"),value:x,onChange:R=>O(R.target.value),"aria-label":_("savedQuery.search","Search queries")}),e.jsxs("button",{onClick:()=>ee(R=>!R),type:"button",children:[e.jsx(k.NiceIcon,{name:"plus",size:12})," ",_("savedQuery.saveCurrent","Save current view")]})]}),pe&&e.jsxs("div",{className:"nice-saved-query__save-form",children:[e.jsx("input",{type:"text",placeholder:_("savedQuery.name","Query name"),value:Q,onChange:R=>ue(R.target.value),"aria-label":_("savedQuery.name","Query name")}),e.jsx("input",{type:"text",placeholder:_("savedQuery.descriptionPlaceholder","Description (optional)"),value:re,onChange:R=>_e(R.target.value),"aria-label":_("savedQuery.description","Query description")}),e.jsx("button",{onClick:xe,disabled:v||!Q.trim(),type:"button",children:v?_("savedQuery.saving","Saving…"):_("savedQuery.save","Save")}),e.jsx("button",{onClick:()=>ee(!1),type:"button",children:_("savedQuery.cancel","Cancel")})]}),le.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:_("savedQuery.mine","Mine")}),le.map(oe)]}),Ce.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:_("savedQuery.sharedSection","Shared")}),Ce.map(oe)]}),U.length===0&&e.jsx("p",{className:"nice-saved-query__empty",children:_("savedQuery.empty","No saved queries")})]})]})};exports.NiceDataGridAI=Gt;exports.NiceHighlight=st;exports.NiceKanbanBoard=ji;exports.NiceList=fi;exports.NiceModuleGrid=Ui;exports.NiceReconciliationView=ma;exports.NiceSavedQueryPanel=pa;exports.NiceSpreadsheet=ra;exports.NiceTable=_i;exports.NiceTileView=xi;exports.NiceTreeGrid=si;exports.NiceTreeList=di;exports.NiceTreeView=mi;
|