@kanunilabs/pivotgrid-react 1.5.0 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.cts +41 -5
- package/dist/index.d.ts +41 -5
- package/dist/index.js +2 -2
- package/dist/styles.css +249 -15
- package/dist/themes/all.css +1064 -0
- package/dist/themes/amber.css +28 -0
- package/dist/themes/aubergine.css +32 -0
- package/dist/themes/azure.css +28 -0
- package/dist/themes/burgundy.css +32 -0
- package/dist/themes/charcoal.css +32 -0
- package/dist/themes/contrast-dark.css +32 -0
- package/dist/themes/contrast-light.css +28 -0
- package/dist/themes/coral.css +28 -0
- package/dist/themes/corporate.css +28 -0
- package/dist/themes/deep-sea.css +32 -0
- package/dist/themes/editorial.css +28 -0
- package/dist/themes/ember.css +32 -0
- package/dist/themes/emerald.css +28 -0
- package/dist/themes/forest.css +32 -0
- package/dist/themes/glacier.css +28 -0
- package/dist/themes/graphite.css +32 -0
- package/dist/themes/indigo-night.css +32 -0
- package/dist/themes/indigo.css +28 -0
- package/dist/themes/ivory.css +28 -0
- package/dist/themes/lagoon.css +28 -0
- package/dist/themes/linen.css +28 -0
- package/dist/themes/midnight.css +32 -0
- package/dist/themes/mist.css +28 -0
- package/dist/themes/monochrome.css +28 -0
- package/dist/themes/onyx.css +32 -0
- package/dist/themes/orchid.css +28 -0
- package/dist/themes/porcelain.css +28 -0
- package/dist/themes/rose.css +28 -0
- package/dist/themes/sandstone.css +28 -0
- package/dist/themes/slate-night.css +32 -0
- package/dist/themes/slate.css +28 -0
- package/dist/themes/steel.css +32 -0
- package/dist/themes/stone.css +28 -0
- package/dist/themes/taupe.css +28 -0
- package/dist/themes/teal.css +28 -0
- package/dist/themes/terminal.css +32 -0
- package/package.json +7 -4
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
'use strict';var dn=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime'),pivotgridCore=require('@kanunilabs/pivotgrid-core'),lucideReact=require('lucide-react'),core=require('@dnd-kit/core'),zustand=require('zustand');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var dn__default=/*#__PURE__*/_interopDefault(dn);var ho=dn.createContext(null);var Ar=dn.createContext({}),Hr=()=>dn.useContext(Ar);function Qo({theme:t,className:i="",style:d={},children:a}){let l=dn.useMemo(()=>{if(!t)return {};let e={};return t.background&&(e["--pivot-bg"]=t.background),t.surface&&(e["--pivot-surface"]=t.surface),t.surfaceHover&&(e["--pivot-surface-hover"]=t.surfaceHover),t.surfaceHeader&&(e["--pivot-surface-header"]=t.surfaceHeader),t.border&&(e["--pivot-border"]=t.border),t.text&&(e["--pivot-text"]=t.text),t.textMuted&&(e["--pivot-text-muted"]=t.textMuted),t.textHeader&&(e["--pivot-text-header"]=t.textHeader),t.primary&&(e["--pivot-primary"]=t.primary),t.primaryForeground&&(e["--pivot-primary-foreground"]=t.primaryForeground),t.success&&(e["--pivot-success"]=t.success),t.danger&&(e["--pivot-danger"]=t.danger),t.warning&&(e["--pivot-warning"]=t.warning),t.info&&(e["--pivot-info"]=t.info),t.totalBackground&&(e["--pivot-total-bg"]=t.totalBackground),t.stripeBackground&&(e["--pivot-stripe-bg"]=t.stripeBackground),t.groupBorder&&(e["--pivot-group-border"]=t.groupBorder),t.iconActive&&(e["--pivot-icon-active"]=t.iconActive),e},[t]);return jsxRuntime.jsx(Ar.Provider,{value:{theme:t,themeVariables:l},children:jsxRuntime.jsx("div",{className:`kanuni-pivot-root ${i}`,"data-theme":t?.id,style:{...l,...d},children:a})})}function ge({children:t}){let i=dn.useContext(ho),[d,a]=dn.useState(false),{theme:l,themeVariables:e}=Hr();if(dn.useEffect(()=>{a(true);},[]),!d)return null;let p=i||(typeof document<"u"?document.body:null);return p?reactDom.createPortal(jsxRuntime.jsx("div",{className:"kanuni-pivot-root kanuni-pivot-portal-container","data-theme":l?.id,style:e,children:t}),p):null}var Qi={locale:"en",dictionary:pivotgridCore.en,t:t=>pivotgridCore.en[t]||t,rtl:false},Or=dn.createContext(Qi),tr=({children:t,locale:i="en",dictionary:d,rtl:a})=>{let l=dn.useMemo(()=>{let e=pivotgridCore.en;i==="tr"?e=pivotgridCore.tr:i==="ar"?e=pivotgridCore.ar:i==="de"?e=pivotgridCore.de:i==="fr"?e=pivotgridCore.fr:i==="es"?e=pivotgridCore.es:i==="it"?e=pivotgridCore.it:i==="pt"?e=pivotgridCore.pt:i==="ru"?e=pivotgridCore.ru:i==="zh-CN"?e=pivotgridCore.zhCN:i==="ja"?e=pivotgridCore.ja:i==="ko"&&(e=pivotgridCore.ko);let p={...pivotgridCore.en,...e,...d};return {locale:i,dictionary:p,t:S=>p[S]||S,rtl:a!==void 0?a:i==="ar"}},[i,d,a]);return jsxRuntime.jsx(Or.Provider,{value:l,children:jsxRuntime.jsx("div",{dir:l.rtl?"rtl":"ltr",style:{width:"100%",height:"100%"},children:t})})},ut=()=>dn.useContext(Or);function Br(t,i){let[d,a]=dn.useState(t);return dn.useEffect(()=>{let l=setTimeout(()=>{a(t);},i);return ()=>clearTimeout(l)},[t,i]),d}function er(t,i,d,a={}){let l=Br(t,150),e=Br(d,150),{locale:p}=ut(),C=dn.useRef(false);return dn.useMemo(()=>a.transformer?!l||!l.cellMatrix?{chartData:[],chartSeries:[]}:a.transformer(l,i,e,p,a):(!C.current&&Object.keys(a).length>0&&(C.current=true,console.warn("[pivotgrid] chartIntegrationOptions has no `transformer`, so the chart stays empty. Pass ChartDataTransformer.transform (Enterprise) or your own transformer.")),{chartData:[],chartSeries:[]}),[l,e,i,a,p])}var le=zustand.create(t=>({activeId:null,targetId:null,targetArea:null,intent:null,setIntent:(i,d,a)=>t(l=>l.targetId===i&&l.targetArea===d&&l.intent===a?l:{targetId:i,targetArea:d,intent:a}),setActiveId:i=>t({activeId:i}),reset:()=>t({targetId:null,targetArea:null,intent:null,activeId:null})}));var rr=null;function bo(t,i){rr={id:t,root:i};}var vn={row:"rowArea",column:"columnArea",data:"dataArea",filter:"filterArea"};function Ao({area:t,title:i,icon:d,fields:a,onRemoveField:l,onFilterClick:e,onContextMenu:p,onSort:C,onMoveField:E}){let{setNodeRef:S}=core.useDroppable({id:t}),{setNodeRef:F}=core.useDroppable({id:`${t}-ghost-end`}),m=le(),c=m.targetArea===t&&m.intent==="append",{t:f}=ut();return jsxRuntime.jsxs("div",{ref:S,className:"kanuni-pivot-area-dropzone","data-drop-id":t,tabIndex:-1,children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-area-header",children:[d,i]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-area-content",children:[a.length===0&&jsxRuntime.jsx("span",{className:"pivot-text-xs pivot-text-muted",style:{fontStyle:"italic",padding:"0 8px"},children:f("dropHere")}),a.map(h=>jsxRuntime.jsx(Ho,{field:h,siblings:a,onMove:E,onRemove:l,onFilterClick:e,onContextMenu:p,onSort:C},h.id)),jsxRuntime.jsx("div",{ref:F,style:{flex:1,minWidth:"40px",minHeight:"24px",borderRadius:"var(--pivot-border-radius-sm)",transition:"background-color 0.2s",backgroundColor:c?"color-mix(in srgb, var(--pivot-primary) 10%, transparent)":"transparent",boxShadow:c?"inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)":"none"},children:c&&a.length>0&&jsxRuntime.jsx("div",{style:{width:"4px",height:"100%",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginLeft:"4px"}})})]})]})}function Ho({field:t,siblings:i,onMove:d,onRemove:a,onFilterClick:l,onContextMenu:e,onSort:p}){let{attributes:C,listeners:E,setNodeRef:S,transform:F,isDragging:m}=core.useDraggable({id:t.id}),{setNodeRef:y}=core.useDroppable({id:t.id}),{rtl:c,t:f}=ut(),h=dn.useRef(null),T=u=>{S(u),y(u),h.current=u;};dn.useLayoutEffect(()=>{let u=rr,Y=h.current;!u||u.id!==t.id||!Y||u.root&&!u.root.contains(Y)||(rr=null,Y.focus({preventScroll:true}));});let w=i??[t],M=Math.max(0,w.findIndex(u=>u.id===t.id)),O=f(vn[t.area??""]??"rowArea"),V=f("fieldChipLabel").replace("{0}",t.caption||t.id).replace("{1}",O).replace("{2}",String(M+1)).replace("{3}",String(w.length)),H=()=>{if(!p)return;let u=t.sortOrder==="asc"?"desc":t.sortOrder==="desc"?void 0:"asc";p(t.id,u);},I=()=>h.current?.closest(".kanuni-pivot-wrapper")??null,K=u=>{if(!u)return;(I()??document).querySelector(`.kanuni-pivot-field-chip[data-drop-id="${u}"]`)?.focus({preventScroll:true});},_=u=>{let Y=u.ctrlKey||u.metaKey,gt=c?"ArrowRight":"ArrowLeft",v=c?"ArrowLeft":"ArrowRight",z=!!d&&t.area!=="filter",nt=true;if(u.key==="Enter"||u.key===" ")H();else if(Y&&z&&(u.key===gt||u.key==="ArrowUp"))M>0&&(bo(t.id,I()),d(t.id,"left"));else if(Y&&z&&(u.key===v||u.key==="ArrowDown"))M<w.length-1&&(bo(t.id,I()),d(t.id,"right"));else if(Y&&z&&u.key==="Home")M>0&&(bo(t.id,I()),d(t.id,"start"));else if(Y&&z&&u.key==="End")M<w.length-1&&(bo(t.id,I()),d(t.id,"end"));else if(!Y&&(u.key===gt||u.key===v))K(w[M+(u.key===gt?-1:1)]?.id);else if(u.key==="Delete"||u.key==="Backspace"){let ot=w[M+1]??w[M-1];ot&&bo(ot.id,I()),a(t.id);}else if(u.key==="F10"&&u.shiftKey||u.key==="ContextMenu"){if(!e)return;let ot=u.currentTarget.getBoundingClientRect();e(c?ot.right:ot.left,ot.bottom,t.id,void 0);}else nt=false;nt&&(u.preventDefault(),u.stopPropagation());},X=le(),q=X.targetId===t.id,G=q&&X.intent==="before",k=q&&X.intent==="after",$={transform:F?`translate3d(${c?-F.x:F.x}px, ${F.y}px, 0)`:void 0,cursor:m?"grabbing":"pointer",position:"relative"},tt=!!t.filterValues&&t.filterValues.size>0||!!t.valueFilter||!!t.labelFilter,Q=u=>{if(u.stopPropagation(),!p)return;let Y=t.sortOrder==="asc"?"desc":t.sortOrder==="desc"?void 0:"asc";p(t.id,Y);};return jsxRuntime.jsxs("div",{ref:T,className:`kanuni-pivot-field-chip ${m?"is-dragging":""}`,style:$,...E,...C,role:"button",tabIndex:0,"aria-roledescription":void 0,"aria-label":V,"aria-keyshortcuts":"Control+ArrowLeft Control+ArrowRight Control+Home Control+End Delete Shift+F10","aria-description":f("fieldChipKeys"),"data-drop-id":t.id,onKeyDown:_,onClick:Q,onContextMenu:u=>{u.stopPropagation(),e&&(u.preventDefault(),e(u.clientX,u.clientY,t.id,void 0));},children:[G&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",insetInlineStart:-4,top:-4,bottom:-4,width:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,top:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderTop:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,bottom:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderBottom:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-1,top:0,bottom:0,width:2,backgroundColor:"var(--pivot-primary)"}})]}),k&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",insetInlineEnd:-4,top:-4,bottom:-4,width:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,top:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderTop:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,bottom:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderBottom:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-1,top:0,bottom:0,width:2,backgroundColor:"var(--pivot-primary)"}})]}),jsxRuntime.jsx("span",{className:"pivot-truncate",style:{maxWidth:"120px",userSelect:"none"},children:t.caption||t.id}),t.sortOrder==="asc"&&jsxRuntime.jsx(lucideReact.ArrowUp,{size:12,color:"var(--pivot-primary)"}),t.sortOrder==="desc"&&jsxRuntime.jsx(lucideReact.ArrowDown,{size:12,color:"var(--pivot-primary)"}),t.area==="data"&&t.summaryType&&jsxRuntime.jsx("span",{style:{fontSize:"10px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 10%, transparent)",color:"var(--pivot-primary)",padding:"0 4px",borderRadius:"4px",fontWeight:700,textTransform:"uppercase"},children:t.summaryType}),jsxRuntime.jsxs("div",{className:`kanuni-pivot-field-chip-actions ${tt?"is-filtered":""}`,children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn",onPointerDown:u=>u.stopPropagation(),onClick:u=>{u.stopPropagation(),l(u.clientX,u.clientY,t.id);},title:f("filterField"),style:{color:tt?"var(--pivot-danger)":"inherit"},children:jsxRuntime.jsx(lucideReact.Filter,{size:12,fill:tt?"currentColor":"none"})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger",onPointerDown:u=>u.stopPropagation(),onClick:u=>{u.stopPropagation(),a(t.id);},title:f("removeField"),children:jsxRuntime.jsx(lucideReact.X,{size:12})})]})]})}function ir({filterFields:t,onRemoveField:i,onFilterClick:d,onContextMenu:a,onSort:l,onGlobalContextMenu:e,onMoveField:p}){let{t:C,locale:E}=ut(),S=dn__default.default.useMemo(()=>{let F=new Map;return t.map(y=>{let c=y.caption||y.id||"";if(F.has(c)){let f=F.get(c)+1;return F.set(c,f),{...y,caption:`${c} (${f})`}}return F.set(c,1),y}).sort((y,c)=>{let f=(y.caption||"").toLowerCase(),h=(c.caption||"").toLowerCase();return f.localeCompare(h,E||"en")})},[t,E]);return jsxRuntime.jsx("div",{className:"pivot-flex pivot-flex-col",style:{padding:"8px",borderBottom:"1px solid var(--pivot-border)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)"},onContextMenu:F=>{e&&(F.preventDefault(),e(F.clientX,F.clientY));},children:jsxRuntime.jsx("div",{className:"pivot-flex",style:{width:"100%"},children:jsxRuntime.jsx(Ao,{area:"filter",title:C("filterArea"),icon:jsxRuntime.jsx(lucideReact.Filter,{size:13}),fields:S,onRemoveField:i,onFilterClick:d,onContextMenu:a,onSort:l,onMoveField:p})})})}function nr({menu:t,onClose:i,onToggleExpand:d,onToggleColExpand:a,onExpandPaths:l,onCollapsePaths:e,onExpandColPaths:p,onCollapseColPaths:C,rowTree:E,colTree:S,t:F}){let m=()=>{let h=[],T=t.depth,w=(M,O)=>{if(M)for(let V of M)O>=T&&h.push(V.key),V.children&&w(V.children,O+1);};return w(t.type==="row"?E:S,0),h},y=h=>{h.stopPropagation(),t.type==="row"?d(t.path):a(t.path),i();},c=h=>{h.stopPropagation();let T=m();t.type==="row"?l(T):p(T),i();},f=h=>{h.stopPropagation();let T=m();t.type==="row"?e(T):C(T),i();};return jsxRuntime.jsxs(ge,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-portal-root",style:{position:"fixed",inset:0,zIndex:9998},onClick:i,onContextMenu:h=>{h.preventDefault(),i();}}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",left:Math.min(t.x,window.innerWidth-180),top:Math.min(t.y,window.innerHeight-200),zIndex:9999,minWidth:160},onContextMenu:h=>h.preventDefault(),children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-dropdown-item pivot-state-hover",style:{paddingLeft:"32px",paddingRight:"24px"},onClick:y,children:t.isExpanded?F("collapse"):F("expand")}),jsxRuntime.jsx("div",{className:"kanuni-pivot-dropdown-divider"}),jsxRuntime.jsx("button",{className:"kanuni-pivot-dropdown-item pivot-state-hover",style:{paddingLeft:"32px",paddingRight:"24px"},onClick:c,children:F("expandAll")}),jsxRuntime.jsx("button",{className:"kanuni-pivot-dropdown-item pivot-state-hover",style:{paddingLeft:"32px",paddingRight:"24px"},onClick:f,children:F("collapseAll")})]})]})}function Kr({columnWidths:t,onColumnWidthsChange:i,rtl:d,leftPaneRef:a,rowHeaderLayout:l}){let e=dn.useRef(false),p=dn.useRef(null),C=dn.useRef(null),E=dn.useRef(0),S=dn.useRef(0),F=dn.useRef([]),m=dn.useRef(null),y=dn.useRef(-1),c=dn.useRef(t),f=dn.useRef(new Set),h=dn.useRef(null),T=dn.useRef(null),w=dn.useRef(0);dn.useEffect(()=>{let H=T.current;if(!H)return;let I=a.current;c.current={...t};let K=new Set;Object.entries(t).forEach(([q,G])=>{if(q.startsWith("row-"))I?.style.setProperty(`--col-width-${q}`,`${G}px`);else if(q.startsWith("leaf-")){let k=`--col-width-data-${q.replace("leaf-","")}`;H.style.setProperty(k,`${G}px`),K.add(k);}});for(let q of f.current)K.has(q)||H.style.removeProperty(q);f.current=K;let _=I?.querySelectorAll(".kanuni-pivot-header-corner[data-row-header-idx]"),X=0;_?.forEach(q=>{let G=q.getAttribute("data-row-header-idx");G!==null&&(I.style.setProperty(`--row-header-left-${G}`,`${X}px`),X+=q.getBoundingClientRect().width);}),I?.style.setProperty("--row-header-left-total",`${X}px`);},[t]);let M=dn.useCallback(H=>{if(!e.current||!h.current||!T.current)return;let I=T.current.getBoundingClientRect(),K=H.clientX-I.left;h.current.style.display="block",h.current.style.transform=`translateX(${K}px)`;},[]),O=dn.useCallback(H=>{if(!e.current||!p.current||!T.current)return;h.current&&(h.current.style.display="none");let I=H.clientX-E.current,K=d?-I:I,_=T.current;if(p.current.startsWith("row-")){let X=Math.max(20,S.current+K),q=m.current,G=q?pivotgridCore.invertRowHeaderWidth(q.configured,y.current,X,q.viewport):X;c.current[p.current]=G;let k=a.current;k?.style.setProperty(`--col-width-${p.current}`,`${X}px`);let $=k?.querySelectorAll(".kanuni-pivot-header-corner[data-row-header-idx]"),tt=0;$?.forEach(Q=>{let u=Q.getAttribute("data-row-header-idx");u!==null&&(k.style.setProperty(`--row-header-left-${u}`,`${tt}px`),tt+=Q.getBoundingClientRect().width);}),k?.style.setProperty("--row-header-left-total",`${tt}px`);}else if(p.current.startsWith("leaf-")){let X=p.current.split("-"),q=parseInt(X[1],10),G=parseInt(X[2],10),k=S.current,tt=Math.max(G*20,k+K)/k;for(let Q=0;Q<G;Q++){let u=F.current[Q],Y=Math.max(20,u*tt);c.current[`leaf-${q+Q}`]=Y,_.style.setProperty(`--col-width-data-${q+Q}`,`${Y}px`);}}e.current=false,w.current=Date.now(),p.current=null,document.body.style.cursor="",document.removeEventListener("mousemove",M),document.removeEventListener("mouseup",O),C.current=null,i&&i({...c.current});},[M,i,d]),V=dn.useCallback((H,I,K,_=1)=>{if(H.preventDefault(),H.stopPropagation(),!T.current||!h.current)return;if(e.current=true,p.current=I,E.current=H.clientX,I.startsWith("row-")){y.current=parseInt(I.slice(4),10),m.current=l?.()??null;let G=m.current,k=G?pivotgridCore.computeRowHeaderWidths(G.configured,G.viewport).widths[y.current]:void 0;S.current=k??c.current[I]??K;}else if(I.startsWith("leaf-")){let G=I.split("-"),k=parseInt(G[1],10),$=[],tt=0;for(let Q=0;Q<_;Q++){let u=c.current[`leaf-${k+Q}`]||K;$.push(u),tt+=u;}F.current=$,S.current=tt;}let X=T.current.getBoundingClientRect(),q=H.clientX-X.left;h.current.style.display="block",h.current.style.transform=`translateX(${q}px)`,document.body.style.cursor="col-resize",document.addEventListener("mousemove",M),document.addEventListener("mouseup",O),C.current={move:M,up:O};},[M,O]);return dn.useEffect(()=>()=>{let H=C.current;H&&(document.removeEventListener("mousemove",H.move),document.removeEventListener("mouseup",H.up),document.body.style.cursor="",C.current=null);},[]),{wrapperRef:T,dragLineRef:h,isResizingRef:e,lastResizeTimeRef:w,handleResizeStart:V}}var yo=null;function Ur({containerRef:t,isResizingRef:i,onSelectionStatsChange:d,cellValueAccessor:a,cellTextAccessor:l}){let[e,p]=dn.useState(null),C=dn.useRef({}),E=dn.useCallback((m,y,c,f)=>{c.button!==0||i.current||(yo=C.current,p({startR:m,startC:y,endR:m,endC:y,isSelecting:true,mode:f}));},[i]),S=dn.useCallback((m,y,c)=>{p(f=>!f||!f.isSelecting||f.mode!==c?f:{...f,endR:m,endC:y});},[]),F=dn.useCallback((m,y)=>{if(!e)return false;let c=Math.min(e.startR,e.endR),f=Math.max(e.startR,e.endR),h=Math.min(e.startC,e.endC),T=Math.max(e.startC,e.endC);return m>=c&&m<=f&&y>=h&&y<=T},[e]);return dn.useEffect(()=>{let m=()=>{p(y=>y?{...y,isSelecting:false}:null);};return document.addEventListener("mouseup",m),()=>document.removeEventListener("mouseup",m)},[]),dn.useEffect(()=>{if(!e||e.mode!=="data"||!d)return;let m=Math.min(e.startR,e.endR),y=Math.max(e.startR,e.endR),c=Math.min(e.startC,e.endC),f=Math.max(e.startC,e.endC),h=0,T=0,w=1/0,M=-1/0,O=setTimeout(()=>{if(a)for(let V=m;V<=y;V++)for(let H=c;H<=f;H++){let I=a(V,H);I!=null&&!isNaN(I)&&(h+=I,T++,I<w&&(w=I),I>M&&(M=I));}else for(let V=m;V<=y;V++)for(let H=c;H<=f;H++){let I=t.current?.querySelector(`[data-r="${V}"][data-c="${H}"]`);if(I){let K=I.getAttribute("data-val");if(K!==null&&K!==""){let _=parseFloat(K);isNaN(_)||(h+=_,T++,_<w&&(w=_),_>M&&(M=_));}}}T>0?d({sum:h,count:T,avg:h/T,min:w,max:M}):d(null);},10);return ()=>clearTimeout(O)},[e?.startR,e?.endR,e?.startC,e?.endC,e?.mode,d,a]),dn.useEffect(()=>{let m=y=>{if((y.ctrlKey||y.metaKey)&&y.key==="c"){if(!e||yo!==null&&yo!==C.current)return;let c=Math.min(e.startR,e.endR),f=Math.max(e.startR,e.endR),h=Math.min(e.startC,e.endC),T=Math.max(e.startC,e.endC),w="";for(let M=c;M<=f;M++){let O=[];for(let V=h;V<=T;V++)if(l)O.push(l(M,V));else {let H=t.current?.querySelector(`[data-r="${M}"][data-c="${V}"]`);H?O.push(H.innerText.trim().replace(/\n/g," ")):O.push("");}w+=O.join(" ")+`
|
|
2
|
-
`;}w&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(w).catch(()=>{});}};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[e,l,t]),dn.useEffect(()=>{let m=C.current;return ()=>{yo===m&&(yo=null);}},[]),{selection:e,handleCellMouseDown:E,handleCellMouseEnter:S,isCellSelected:F}}function Xr(t){let i=dn.useRef(null),d=dn.useRef(null),[a,l]=dn.useState(0),[e,p]=dn.useState(0),[C,E]=dn.useState(600),[S,F]=dn.useState(800),[m,y]=dn.useState(0),c=dn.useRef(t);return c.current=t,dn.useEffect(()=>{if(i.current){let f=new ResizeObserver(h=>{h[0]&&(E(h[0].contentRect.height),F(h[0].contentRect.width));});return f.observe(i.current),()=>f.disconnect()}},[]),dn.useEffect(()=>{let f=i.current,h=d.current;if(!f)return;let T,w=()=>{T&&cancelAnimationFrame(T),T=requestAnimationFrame(()=>{let O=c.current?.quantizeY??1,V=c.current?.quantizeX??1;l(O>1?Math.floor(f.scrollTop/O)*O:f.scrollTop),p(V>1?Math.floor(f.scrollLeft/V)*V:f.scrollLeft);let H=d.current;H&&(H.scrollTop=f.scrollTop);});},M=O=>{let V=i.current;V&&(V.scrollTop+=O.deltaY);};return f.addEventListener("scroll",w,{passive:true}),h&&h.addEventListener("wheel",M,{passive:true}),()=>{f.removeEventListener("scroll",w),h&&h.removeEventListener("wheel",M),T&&cancelAnimationFrame(T);}},[]),dn.useEffect(()=>{let f=i.current,h=d.current;if(!f||!h)return;let T=Math.max(0,f.offsetHeight-f.clientHeight);y(w=>w===T?w:T),h.scrollTop!==f.scrollTop&&(h.scrollTop=f.scrollTop);}),{containerRef:i,leftPaneRef:d,scrollTop:a,scrollLeft:e,containerHeight:C,containerWidth:S,bottomGutter:m}}var Pt=28,On=95,Bn=40,_r=8,Gn={"arrow-up":lucideReact.ArrowUp,"arrow-down":lucideReact.ArrowDown,minus:lucideReact.Minus,circle:lucideReact.Circle,check:lucideReact.Check,x:lucideReact.X,"alert-triangle":lucideReact.TriangleAlert};function Wn({name:t}){let i=Gn[t];return i?jsxRuntime.jsx("span",{style:{display:"inline-flex",verticalAlign:"middle",marginInlineEnd:4},children:jsxRuntime.jsx(i,{size:12})}):null}var Vn={style:{}};function cr({engineResult:t,isBuilding:i,buildProgress:d=0,rowFields:a,colFields:l,dataFields:e,layout:p,expandedPaths:C,allExpanded:E,onToggleExpand:S,onExpandPaths:F,onCollapsePaths:m,expandedColPaths:y,allColExpanded:c,onToggleColExpand:f,onExpandColPaths:h,onCollapseColPaths:T,onCellClick:w,onContextMenu:M,onFilterClick:O,onRemoveField:V,onSort:H,onMoveField:I,onGlobalContextMenu:K,columnWidths:_={},defaultColumnWidths:X,onColumnWidthsChange:q,onSelectionStatsChange:G,registry:k,keyboardNavigation:$,onCellPrepared:tt,renderNodeContextMenu:Q}){let{t:u,rtl:Y,locale:gt}=ut(),v=dn.useId(),z=X?.rowHeader,nt=X?.data,ot=dn.useMemo(()=>pivotgridCore.resolveColumnWidthDefaults({rowHeader:z,data:nt}),[z,nt]),{setNodeRef:At,isOver:P}=core.useDroppable({id:"row"}),{containerRef:N,leftPaneRef:Z,scrollTop:Mt,scrollLeft:Ht,containerHeight:$t,containerWidth:g,bottomGutter:ct}=Xr({quantizeY:Pt,quantizeX:On}),{wrapperRef:L,dragLineRef:pt,isResizingRef:dt,lastResizeTimeRef:Ct,handleResizeStart:St}=Kr({columnWidths:_,onColumnWidthsChange:q,rtl:Y,leftPaneRef:Z,rowHeaderLayout:()=>It.current}),It=dn.useRef({configured:[],viewport:0}),ue=dn.useRef(0),[Dt,Ot]=dn.useMemo(()=>{if(!p.hideEmptySummaryCells||!t)return [t.rowTree,t.colTree];let r=new Set;for(let s=0;s<t.cellMatrix.keys.length;s++)r.add(t.cellMatrix.keys[s]);let n=(s,b)=>{let x=[];for(let R of s){let U=b?t.rowIndexMap[R.key]:t.columnIndexMap[R.key];if(U===void 0){x.push(R);continue}if(b?r.has(U*pivotgridCore.MAX_C):r.has(U)){let st=R.children&&R.children.length>0?n(R.children,b):[];x.push({...R,children:st});}}return x};return [n(t.rowTree,true),n(t.colTree,false)]},[t,p.hideEmptySummaryCells]),Bt=dn.useMemo(()=>{let r=pivotgridCore.buildColumnHeaders(Ot,e,p,y,c,{grandTotal:u("grandTotal"),subTotal:u("subTotal")});return r.length>0?r:[[]]},[Ot,e,p,y,c,u]),lt=p.rowHeaderLayout==="tree"?1:a.length||1,it=p.dataFieldPosition==="rows"&&e.length>1,Ke=dn.useMemo(()=>p.rowHeaderLayout==="tree"?pivotgridCore.flattenRowTreeTree(Dt,C,E,a.length||1,p.showRowTotals??true,p.totalsPosition??"bottom"):pivotgridCore.flattenRowTreeTabular(Dt,C,E,lt,p.showRowTotals??true,p.totalsPosition??"bottom"),[Dt,C,E,lt,p.showRowTotals,p.totalsPosition,p.rowHeaderLayout,a.length]),yt=dn.useMemo(()=>{let r=[];for(let n of Ke)if(it&&!n.isSubtotal&&!n.hasChildren)for(let s=0;s<e.length;s++)r.push({flatRow:n,dfIndex:s,isDataRow:true,isGrandTotal:false});else r.push({flatRow:n,dfIndex:0,isDataRow:false,isGrandTotal:false});if(p.showColumnGrandTotals)if(it)for(let n=0;n<e.length;n++)r.push({flatRow:null,dfIndex:n,isDataRow:true,isGrandTotal:true});else r.push({flatRow:null,dfIndex:0,isDataRow:false,isGrandTotal:true});return r},[Ke,it,e,p.showColumnGrandTotals]),be=dn.useMemo(()=>t&&e.some(pivotgridCore.fieldNeedsRange)?pivotgridCore.computeFieldRanges(t,e):{},[t,e]),ee=dn.useMemo(()=>{let r=[],n=pivotgridCore.getVisibleColSlots(Ot,y,c,{subTotals:p.showColumnTotals!==false,totalsPosition:p.totalsPosition??"bottom"});for(let s of n)r.push({hash:s.node.key,isGrandTotal:s.node.isTotal,isSubtotal:s.isSubtotal});return p.showRowGrandTotals&&r.push({hash:"",isGrandTotal:true}),r},[Ot,p.showRowGrandTotals,p.showColumnTotals,p.totalsPosition,y,c]);dn.useEffect(()=>{let r=Z.current?.querySelector(".kanuni-pivot-table");if(!r||!L.current)return;let n=()=>{let R=Z.current;if(!R)return;let U=r.querySelectorAll("th[data-row-header-idx]");if(U.length===0)return;let j=0;Array.from(U).sort((et,W)=>Number(et.getAttribute("data-row-header-idx"))-Number(W.getAttribute("data-row-header-idx"))).forEach((et,W)=>{R.style.setProperty(`--row-header-left-${W}`,`${j}px`),j+=et.offsetWidth;}),R.style.setProperty("--row-header-left-total",`${j}px`);},s=new ResizeObserver(()=>n());s.observe(r),r.querySelectorAll("th[data-row-header-idx]").forEach(R=>s.observe(R)),n();let x=setTimeout(n,100);return ()=>{s.disconnect(),clearTimeout(x);}},[a,it,Bt,yt,ee]);let Ue=yt.length*Pt,ve=Bt.length*Pt,Te=Math.ceil($t/Pt),Xe=Math.max(0,Math.floor((Mt-ve)/Pt)-5),oe=Math.min(Xe,Math.max(0,yt.length-Te)),Ie=Math.min(yt.length,oe+Te+10),Gt=dn.useMemo(()=>yt.slice(oe,Ie),[yt,oe,Ie]),[zt,re]=dn.useState(null),me=dn.useMemo(()=>{let r=new Map;if(t?.cellMatrix?.keys){let n=t.cellMatrix.keys;for(let s=0;s<n.length;s++)r.set(n[s],s);}return r},[t?.cellMatrix]),{handleCellMouseDown:qe,handleCellMouseEnter:ze,isCellSelected:xe}=Ur({containerRef:N,isResizingRef:dt,onSelectionStatsChange:G,cellValueAccessor:dn.useCallback((r,n)=>{let s=lt+(it?1:0);if(n<s)return null;let b=n-s,x=it?1:e.length,R=Math.floor(b/x),U=b%x;if(R>=ee.length)return null;let j=yt[r];if(!j)return null;let st=j.isGrandTotal?"":j.flatRow?.key;if(st===void 0)return null;let et=ee[R]?.hash;if(et===void 0)return null;let W=t.rowIndexMap[st],ft=t.columnIndexMap[et];if(W===void 0||ft===void 0)return null;let Rt=W*pivotgridCore.MAX_C+ft,jt=me.get(Rt);if(jt===void 0)return null;let ie=it?j.dfIndex:U;return t.cellMatrix.sums[jt*e.length+ie]},[lt,it,e,ee,yt,t,me])}),Lt=ee.length*(it?1:e.length),Le=lt+(it?1:0),ye=Le+Lt,je=dn.useMemo(()=>`calc(${Array.from({length:Le},(n,s)=>{let b=it&&s===lt?100:ot.rowHeader;return `var(--col-width-row-${s}, ${b}px)`}).join(" + ")})`,[lt,Le,it,ot]),Ne=dn.useMemo(()=>Array.from({length:Le},(r,n)=>{let s=it&&n===lt?100:ot.rowHeader;return _[`row-${n}`]??s}),[_,lt,Le,it,ot]),uo=dn.useRef(Ne),_e=dn.useCallback(()=>{let r=uo.current,n=ue.current;It.current={configured:r,viewport:n};let s=Z.current;if(!s)return;let{widths:b}=pivotgridCore.computeRowHeaderWidths(r,n);for(let x=0;x<b.length;x++)s.style.setProperty(`--col-width-row-${x}`,`${b[x]}px`);},[]);dn.useLayoutEffect(()=>{uo.current=Ne,_e();},[Ne,_e]),dn.useLayoutEffect(()=>{let r=L.current;if(!r)return;let n=()=>{let b=r.clientWidth;b!==ue.current&&(ue.current=b,_e());};if(n(),typeof ResizeObserver>"u")return;let s=new ResizeObserver(n);return s.observe(r),()=>s.disconnect()},[L,_e]);let Ae=Lt>Bn,Ee=dn.useMemo(()=>{if(!Ae)return {start:0,end:Lt};let r=U=>_[`leaf-${U}`]??ot.data,n=Math.abs(Ht),s=0,b=0;for(;s<Lt&&b+r(s)<=n;)b+=r(s),s++;let x=s,R=b-n;for(;x<Lt&&R<g;)R+=r(x),x++;return {start:Math.max(0,s-_r),end:Math.min(Lt,x+_r)}},[Ae,Lt,Ht,g,_,ot]),So=dn.useCallback(r=>{if(!zt)return;let{rGlobal:n,cGlobal:s}=zt;switch(r.key){case "ArrowDown":r.preventDefault(),n=Math.min(yt.length-1,n+1);break;case "ArrowUp":r.preventDefault(),n=Math.max(0,n-1);break;case "ArrowRight":r.preventDefault(),s=Math.min(ye-1,s+1);break;case "ArrowLeft":r.preventDefault(),s=Math.max(0,s-1);break;case "Home":r.preventDefault(),(r.ctrlKey||r.metaKey)&&(n=0),s=0;break;case "End":r.preventDefault(),(r.ctrlKey||r.metaKey)&&(n=yt.length-1),s=ye-1;break;case "PageDown":r.preventDefault(),n=Math.min(yt.length-1,n+Te-1);break;case "PageUp":r.preventDefault(),n=Math.max(0,n-Te+1);break;case "Escape":r.preventDefault(),re(null);return;case " ":case "Enter":r.preventDefault();let x=document.getElementById(`${v}pivot-cell-${n}-${s}`);x&&(r.key===" "?x.click():x.dispatchEvent(new MouseEvent("dblclick",{bubbles:true})));return;default:return}re({rGlobal:n,cGlobal:s});let b=n*Pt;if(N.current){let x=N.current.scrollTop;b<x+ve?N.current.scrollTop=b-ve:b+Pt>x+$t&&(N.current.scrollTop=b+Pt-$t+ve);}},[zt,yt.length,ye,Te,$t,ve,v]),Me=dn.useMemo(()=>new Map,[gt]),Ye=dn.useCallback((r,n)=>{if(r==null)return "";if(n.format&&typeof r=="number"){if(typeof n.format=="function")return n.format(r);try{let s=n.format,b=Me.get(s);b||(b=new Intl.NumberFormat(gt,s),Me.set(s,b));let x=b.format(r);return s.isCustom&&(s.prefix||s.suffix)?`${s.prefix||""}${x}${s.suffix||""}`:x}catch{return String(r)}}return typeof r=="number"&&pivotgridCore.percentModeText(r,n,gt)||String(r)},[gt,Me]),Kt=dn.useRef(""),vo=dn.useRef(""),Je=dn.useCallback((r,n)=>{let s=lt+(it?1:0);if(n<s)return null;let b=n-s,x=it?1:e.length,R=Math.floor(b/x),U=b%x;if(R>=ee.length)return null;let j=yt[r];if(!j)return null;let st=j.isGrandTotal?"":j.flatRow?.key;if(st===void 0)return null;let et=ee[R],W=et?.hash;if(W===void 0)return null;let ft=t.rowIndexMap[st]??-1,Rt=t.columnIndexMap[W]??-1;if(ft===-1||Rt===-1)return null;let jt=ft*pivotgridCore.MAX_C+Rt,ie=me.get(jt);if(ie===void 0)return null;let Xt=j.flatRow?.isSubtotal,_t={isTotalCell:ft===0||Rt===0||Xt||et.isGrandTotal,rowPath:st?st.split("|"):[],colPath:W?W.split("|"):[],values:{}};for(let J=0;J<e.length;J++)_t.values[e[J].id]=t.cellMatrix.sums[ie*e.length+J],t.cellMatrix.displaySums&&(_t.values[`${e[J].id}_display`]=t.cellMatrix.displaySums[ie*e.length+J]);let Zt=it?j.dfIndex:U,Wt=e[Zt],o=_t.values[`${Wt?.id}_display`]??_t.values[Wt?.id],D=Xt||et.isGrandTotal||_t.isTotalCell;return {cell:_t,val:o,isTotal:D}},[lt,it,e,ee,yt,t,me]),Ze=dn.useCallback((r,n)=>{let s=yt[r];if(!s||s.isGrandTotal||!s.flatRow)return null;let b=s.flatRow,x=p.rowHeaderLayout==="tree",R=n,U=x?b.depth:R,j=U===b.depth,st=U<b.depth,et=j?b.hasChildren:st,W=j?b.isExpanded:st,ft=x?b.key:b.pathValues.slice(0,R+1).join("|");return {hasChildren:et,isExpanded:W,cellHashStr:ft,depth:U,flatRow:b,dIdx:R}},[yt,p.rowHeaderLayout]),Ko=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),b=Number(n.getAttribute("data-c"));if(N.current?.focus({preventScroll:true}),re({rGlobal:s,cGlobal:b}),w){let x=Je(s,b);x?.cell&&w({event:r,cellType:x.isTotal?"grandTotal":"data",value:x.val,rowPath:x.cell.rowPath,colPath:x.cell.colPath,records:x.cell.records});}},[w,Je]),Uo=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),b=Number(n.getAttribute("data-c"));if(w){let x=Je(s,b);x?.cell&&w({event:r,cellType:x.isTotal?"grandTotal":"data",value:x.val,rowPath:x.cell.rowPath,colPath:x.cell.colPath,records:x.cell.records});}},[w,Je]),Xo=dn.useCallback(r=>{r.target.closest("td[data-r][data-c]")&&(r.preventDefault(),K&&K(r.clientX,r.clientY));},[K]),Qe=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");n&&qe(Number(n.getAttribute("data-r")),Number(n.getAttribute("data-c")),r,"data");},[qe]),to=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),b=Number(n.getAttribute("data-c")),x=`${s},${b}`;x!==Kt.current&&(Kt.current=x,ze(s,b,"data"));},[ze]),Ro=dn.useCallback(r=>{if(r.target.closest(".kanuni-pivot-resize-handle"))return;let n=r.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),b=Number(n.getAttribute("data-c"));if(N.current?.focus({preventScroll:true}),re({rGlobal:s,cGlobal:b}),Date.now()-Ct.current<100)return;let x=Ze(s,b);x?.hasChildren&&S(x.cellHashStr);},[Ze,S,Ct]),To=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),b=Number(n.getAttribute("data-c")),x=Ze(s,b);if(!x){K&&(r.preventDefault(),K(r.clientX,r.clientY));return}let{flatRow:R,hasChildren:U,cellHashStr:j,isExpanded:st,depth:et,dIdx:W}=x,ft=p.rowHeaderLayout==="tree",Rt=W>R.depth?R.depth:et,jt=W>R.depth?R.hasChildren:U,ie=W>R.depth?ft?R.key:R.pathValues.slice(0,R.depth+1).join("|"):j,Xt=W>R.depth?R.isExpanded:st;jt?(r.preventDefault(),mo({x:r.clientX,y:r.clientY,path:ie,isExpanded:Xt,depth:Rt,type:"row"})):K&&(r.preventDefault(),K(r.clientX,r.clientY));},[Ze,K,p.rowHeaderLayout]),qo=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");n&&qe(Number(n.getAttribute("data-r")),Number(n.getAttribute("data-c")),r,"row");},[qe]),No=dn.useCallback(r=>{let n=r.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),b=Number(n.getAttribute("data-c")),x=`${s},${b}`;x!==vo.current&&(vo.current=x,ze(s,b,"row"));},[ze]),De=dn.useCallback((r,n,s,b)=>{let x=it?1:e.length,R=it?[e[n]]:e,U=lt+(it?1:0),j=e.length,st=t.cellMatrix.sums,et=t.cellMatrix.displaySums,W=t.rowIndexMap[r]??-1,ft=r?r.split("|"):[],Rt=k?k.getPluginsByType("cellRender"):null;return ee.map((jt,ie)=>{let Xt=jt.hash,_t=ie*x;if(Ae&&(_t+x<=Ee.start||_t>=Ee.end))return R.map((o,D)=>{let J=U+_t+D;return jsxRuntime.jsx("td",{id:`${v}pivot-cell-${b}-${J}`,role:"gridcell","data-r":b,"data-c":J,className:"kanuni-pivot-cell"},`cell-${r}-${Xt}-${o.id}-${D}`)});let Zt=t.columnIndexMap[Xt]??-1,Wt=null;if(W!==-1&&Zt!==-1){let o=W*pivotgridCore.MAX_C+Zt,D=me.get(o);if(D!==void 0){Wt={isTotalCell:W===0||Zt===0||s||jt.isGrandTotal,rowPath:ft.slice(),colPath:Xt?Xt.split("|"):[],values:{}};for(let J=0;J<j;J++)Wt.values[e[J].id]=st[D*j+J],et&&(Wt.values[`${e[J].id}_display`]=et[D*j+J]);}}return R.map((o,D)=>{let J=_t+D;if(Ae&&(J<Ee.start||J>=Ee.end)){let go=U+J;return jsxRuntime.jsx("td",{id:`${v}pivot-cell-${b}-${go}`,role:"gridcell","data-r":b,"data-c":go,className:"kanuni-pivot-cell"},`cell-${r}-${Xt}-${o.id}-${D}`)}let se=Wt?.values[`${o.id}_display`]??Wt?.values[o.id],_o=Ye(se,o),Yo=s||jt.isGrandTotal||Wt?.isTotalCell,no=U+J,Ni=zt?.rGlobal===b&&zt?.cGlobal===no,Ei=xe(b,no),zr={},He=o.conditionalFormatting?pivotgridCore.resolveConditionalVisual(Wt?.values[o.id],o,Wt??null,be[o.id]):Vn;zr=He.style;let Jo=_o;if(o.cellTemplate)Jo=o.cellTemplate({value:se,displayValue:_o,cell:Wt,field:o});else if(Rt){for(let go of Rt)if(go.renderCell){let Zo=go.renderCell(se,_o,Wt,o);if(Zo!=null){Jo=Zo;break}}}let zo={text:Jo,style:{textAlign:o.dataType==="number"?"right":"left",fontWeight:Yo?600:400,backgroundColor:Yo?"var(--pivot-bg)":"transparent",cursor:w&&Wt?"pointer":"default",...zr,...He.dataBar?{backgroundImage:`linear-gradient(to ${Y?"left":"right"}, ${He.dataBar.color} ${Math.round(He.dataBar.ratio*100)}%, transparent ${Math.round(He.dataBar.ratio*100)}%)`,backgroundRepeat:"no-repeat"}:null},className:`kanuni-pivot-cell ${Yo?"kanuni-pivot-cell-total":""} ${Ni?"kanuni-pivot-cell-focused":""} ${Ei?"kanuni-pivot-cell-selected":""}`};return tt&&tt({area:"data",cell:Wt,rowIndex:b,columnIndex:no,cellConfig:zo}),jsxRuntime.jsxs("td",{id:`${v}pivot-cell-${b}-${no}`,role:"gridcell","aria-colindex":no+1,"data-r":b,"data-c":no,"data-val":typeof se=="number"?se:"",className:zo.className,style:zo.style,children:[He.icon?jsxRuntime.jsx(Wn,{name:He.icon}):null,zo.text]},`cell-${r}-${Xt}-${o.id}-${D}`)})})},[ee,me,be,Y,t.cellMatrix,t.rowIndexMap,t.columnIndexMap,it,e,lt,Ye,zt,w,Ae,Ee.start,Ee.end,xe,k,tt,v]),[eo,mo]=dn.useState(null),oo=dn.useCallback((r,n)=>{let s=yt[r],b=s.flatRow,x=p.rowHeaderLayout==="tree",R=x?b.depth:n,U=b.pathValues[R],j=b.rowSpans[n]>0&&s.dfIndex===0,st=a[R],et=st&&U!==null&&U!==void 0?pivotgridCore.formatDimensionValue(U,st,"grid",gt):U,W=R===b.depth,ft=R<b.depth,Rt=W?b.hasChildren:ft,jt=W?b.isExpanded:ft,ie=xe(r,n),Xt=et;a[R]?.cellTemplate?Xt=a[R].cellTemplate({value:et,displayValue:et,field:a[R]}):Xt=jsxRuntime.jsx("span",{className:"truncate",children:et});let _t=r+1,Zt=_t<yt.length?yt[_t]:null,Wt=!x&&Zt&&!Zt.isGrandTotal&&!Zt.flatRow.isSubtotal&&(Zt.flatRow.rowSpans[n]===0||Zt.dfIndex>0)&&Zt.flatRow.pathValues[n]===U,o={text:Xt,style:{position:"sticky",insetInlineStart:`var(--row-header-left-${n}, 0px)`,backgroundColor:"var(--pivot-surface)",zIndex:40,cursor:Rt?"pointer":"default",fontWeight:et&&R<b.depth?600:400,verticalAlign:"middle",padding:0,borderBottom:Wt?"none":"1px solid var(--pivot-border)",borderInlineEnd:!x&&n>=b.depth&&n<lt-1?"none":void 0,height:Pt},className:`kanuni-pivot-cell kanuni-pivot-row-header ${Rt?"kanuni-pivot-row-expandable":""} ${ie?"kanuni-pivot-cell-selected":""} ${zt?.rGlobal===r&&zt?.cGlobal===n?"kanuni-pivot-cell-focused":""}`};if(tt&&tt({area:"row",cell:null,rowIndex:r,columnIndex:n,cellConfig:o}),!j&&!x)return jsxRuntime.jsx("td",{id:`${v}pivot-cell-${r}-${n}`,role:"rowheader","aria-expanded":Rt?jt:void 0,"data-r":r,"data-c":n,className:o.className,style:{...o.style,borderBottom:"none",cursor:Rt?"pointer":"default"},children:jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:J=>St(J,`row-${n}`,ot.rowHeader),onClick:J=>J.stopPropagation(),style:{[Y?"left":"right"]:-3}})},`row-hdr-${b.key}-${n}-empty`);let D=x?b.depth*20:0;return jsxRuntime.jsxs("td",{id:`${v}pivot-cell-${r}-${n}`,role:"rowheader","aria-expanded":Rt?jt:void 0,"aria-label":et,"data-r":r,"data-c":n,className:o.className,style:o.style,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 8px",paddingInlineStart:`${8+D}px`,height:"100%",position:"relative"},children:[x&&b.depth>0&&jsxRuntime.jsx("div",{className:"kanuni-pivot-tree-line",style:{position:"absolute",left:`${D}px`,top:"-14px",width:"12px",height:"28px",borderLeft:"1px dotted var(--pivot-border)",borderBottom:"1px dotted var(--pivot-border)"}}),et!=null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Rt?jsxRuntime.jsx("span",{className:"kanuni-pivot-expand-icon","aria-hidden":"true",style:{flexShrink:0,position:"relative",zIndex:2},children:jt?"\u2212":"+"}):jsxRuntime.jsx("span",{style:{width:14,flexShrink:0}}),a[R]?.cellTemplate?a[R].cellTemplate({value:et,displayValue:et,field:a[R]}):jsxRuntime.jsx("span",{className:"truncate",children:et})]}):null]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:J=>St(J,`row-${n}`,ot.rowHeader),onClick:J=>J.stopPropagation(),style:{[Y?"left":"right"]:-3}})]},`row-hdr-${b.key}-${n}`)},[yt,Pt,S,St,p.rowHeaderLayout,a,gt,lt,xe,zt,Y,v]),fe=dn.useCallback(r=>p.rowHeaderLayout!=="tree"?{}:r?r.isSubtotal||!r.hasChildren?{"aria-level":r.depth+1}:{"aria-level":r.depth+1,"aria-expanded":!!r.isExpanded}:{"aria-level":1},[p.rowHeaderLayout]),Eo=dn.useCallback((r,n,s)=>s==="left"?jsxRuntime.jsxs("tr",{role:"row","aria-rowindex":n+1,...fe(null),className:"kanuni-pivot-row kanuni-pivot-grand-total-row",style:{height:Pt},children:[Array.from({length:lt}).map((b,x)=>{let R=x===0,U=x===lt-1;return jsxRuntime.jsx("td",{className:`kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total${zt?.rGlobal===n&&zt?.cGlobal===x?" kanuni-pivot-cell-focused":""}`,id:`${v}pivot-cell-${n}-${x}`,role:R?"rowheader":"presentation",style:{fontWeight:700,backgroundColor:"var(--pivot-surface)",paddingLeft:R?8:0,paddingRight:0,borderRight:U?"1px solid var(--pivot-border)":"none",whiteSpace:R?"nowrap":"normal",overflow:R?"visible":"hidden"},children:R?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[u("grandTotal")," ",it?` \u2014 ${e[r]?.caption}`:""]}):null},`gt-hdr-${x}`)}),it&&jsxRuntime.jsx("td",{id:`${v}pivot-cell-${n}-${lt}`,role:"gridcell",className:"kanuni-pivot-cell kanuni-pivot-cell-total",style:{backgroundColor:"var(--pivot-surface)"},children:e[r]?.caption})]},`gt-${r}`):jsxRuntime.jsx("tr",{role:"row","aria-rowindex":n+1,...fe(null),className:"kanuni-pivot-row kanuni-pivot-grand-total-row",style:{height:Pt},children:De("",r,true,n)},`gt-${r}`),[lt,it,e,De,Pt,u,zt,v,fe]),Mo=dn.useCallback((r,n,s,b)=>{let x=r.key,R=`${u("subTotal")}: ${r.pathValues[r.depth]}`;return b==="left"?jsxRuntime.jsxs("tr",{role:"row","aria-rowindex":s+1,...fe(r),className:"kanuni-pivot-row kanuni-pivot-subtotal-row",style:{height:Pt},children:[p.rowHeaderLayout==="tree"?jsxRuntime.jsx("td",{id:`${v}pivot-cell-${s}-0`,role:"rowheader",className:"kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total",colSpan:1,style:{fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:`${8+r.depth*20}px`},children:R},`subtotal-hdr-${x}-tree`):Array.from({length:lt}).map((U,j)=>{if(j<r.depth)return oo(s,j);let st=j===r.depth,et=j===lt-1;return jsxRuntime.jsx("td",{id:`${v}pivot-cell-${s}-${j}`,role:st?"rowheader":"presentation",className:"kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total",style:{fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:st?8:0,paddingRight:0,borderRight:et?"1px solid var(--pivot-border)":"none",whiteSpace:st?"nowrap":"normal",overflow:st?"visible":"hidden"},children:st?R:null},`subtotal-hdr-${x}-${j}`)}),it&&jsxRuntime.jsx("td",{id:`${v}pivot-cell-${s}-${lt}`,role:"gridcell",className:"kanuni-pivot-cell kanuni-pivot-cell-total",style:{backgroundColor:"var(--pivot-surface)"},children:e[n]?.caption})]},`subtotal-${x}-${n}`):jsxRuntime.jsx("tr",{role:"row","aria-rowindex":s+1,...fe(r),className:"kanuni-pivot-row kanuni-pivot-subtotal-row",style:{height:Pt},children:De(x,n,true,s)},`subtotal-${x}-${n}`)},[lt,it,e,De,Pt,p.rowHeaderLayout,oo,u,v,fe]),Do=dn.useCallback((r,n,s,b,x)=>{let R=r.key;return x==="left"?jsxRuntime.jsxs("tr",{role:"row","aria-rowindex":b+1,...fe(r),className:`kanuni-pivot-row ${r.isSubtotal?"kanuni-pivot-subtotal-row":""}`,style:{height:Pt},children:[Array.from({length:lt}).map((U,j)=>oo(b,j)),it&&jsxRuntime.jsxs("td",{id:`${v}pivot-cell-${b}-${lt}`,role:"rowheader",className:"kanuni-pivot-cell kanuni-pivot-row-header",style:{backgroundColor:"var(--pivot-surface)"},children:[s&&jsxRuntime.jsx("span",{style:{color:"var(--pivot-text-muted)"},children:e[n].caption}),jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:U=>St(U,`row-${lt}`,100),onClick:U=>U.stopPropagation(),style:{[Y?"left":"right"]:-3}})]})]},`row-${R}-${n}`):jsxRuntime.jsx("tr",{role:"row","aria-rowindex":b+1,...fe(r),className:`kanuni-pivot-row ${r.isSubtotal?"kanuni-pivot-subtotal-row":""}`,style:{height:Pt},children:De(R,n,false,b)},`row-${R}-${n}`)},[lt,it,e,oo,De,Pt,St,Y,v,fe]),ro=dn.useRef(null),io=dn.useRef(null),Fo=dn.useRef(null),Io=dn.useRef(null);dn.useLayoutEffect(()=>{let r=()=>{let s=ro.current,b=io.current,x=Fo.current,R=Io.current;if(!s||!b||!x||!R)return;let U=ft=>parseFloat(ft.style.paddingBottom)||0,j=s.getBoundingClientRect().height-U(x),st=b.getBoundingClientRect().height-U(R);if(j<=0||st<=0)return;let et=Math.max(j,st),W=(ft,Rt)=>{Math.abs(Rt-U(ft))>.5&&(ft.style.paddingBottom=`${Rt}px`);};W(x,et-j),W(R,et-st);};r();let n=new ResizeObserver(r);return ro.current&&n.observe(ro.current),io.current&&n.observe(io.current),()=>n.disconnect()},[Bt,a,l,e,it]);let Fe=dn.useCallback(r=>Gt.map((n,s)=>{let b=oe+s;if(n.isGrandTotal)return Eo(n.dfIndex,b,r);let{flatRow:x,dfIndex:R,isDataRow:U}=n;return x.isSubtotal?Mo(x,R,b,r):Do(x,R,U,b,r)}),[Gt,oe,Eo,Mo,Do]),jo=dn.useMemo(()=>Fe("left"),[Fe]),fo=dn.useMemo(()=>Fe("right"),[Fe]),ae=$?.enabled!==false;return jsxRuntime.jsxs("div",{style:{position:"relative",height:"100%",width:"100%",outline:"none",display:"flex",flexDirection:"row"},ref:L,tabIndex:ae?0:void 0,role:ae?p.rowHeaderLayout==="tree"?"treegrid":"grid":void 0,"aria-rowcount":ae?yt.length+Bt.length+1:void 0,"aria-colcount":ae?ye:void 0,"aria-activedescendant":ae&&zt?`${v}pivot-cell-${zt.rGlobal}-${zt.cGlobal}`:void 0,onKeyDown:ae?So:void 0,onFocus:r=>{ae&&!zt&&r.target===r.currentTarget&&yt.length>0&&re({rGlobal:0,cGlobal:0});},onBlur:()=>{ae&&re(null);},children:[jsxRuntime.jsx("div",{ref:Z,className:"pivot-left-pane custom-scrollbar",style:{flex:"0 0 auto",width:je,overflow:"hidden",height:ct>0?`calc(100% - ${ct}px)`:"100%",position:"relative",zIndex:2,backgroundColor:"var(--pivot-surface)",borderRight:"1px solid var(--pivot-border)"},children:jsxRuntime.jsx("div",{style:{height:Ue+ve,width:je,position:"relative"},children:jsxRuntime.jsxs("table",{className:"kanuni-pivot-table",role:ae?"presentation":void 0,style:{borderCollapse:"separate",borderSpacing:0,tableLayout:"fixed",width:je},children:[jsxRuntime.jsxs("colgroup",{children:[Array.from({length:lt}).map((r,n)=>jsxRuntime.jsx("col",{style:{width:`var(--col-width-row-${n}, ${ot.rowHeader}px)`}},`col-row-${n}`)),it&&jsxRuntime.jsx("col",{style:{width:`var(--col-width-row-${lt}, 100px)`}},"col-row-measure")]}),jsxRuntime.jsxs("thead",{ref:ro,role:"rowgroup",style:{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"},children:[jsxRuntime.jsx("tr",{role:"row",style:{height:42},children:jsxRuntime.jsx("th",{ref:Fo,role:"columnheader",colSpan:lt+(it?1:0),style:{borderInlineEnd:"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",minWidth:50,backgroundColor:"var(--pivot-surface-header)"},children:jsxRuntime.jsx(Ao,{area:"data",title:u("dataArea"),icon:jsxRuntime.jsx(lucideReact.BarChart3,{size:13}),fields:e,onRemoveField:V,onFilterClick:O||(()=>{}),onContextMenu:M,onSort:H,onMoveField:I})})}),Bt.map((r,n)=>jsxRuntime.jsxs("tr",{role:"row",style:{height:Pt},children:[n===0&&a.length===0&&jsxRuntime.jsx("th",{ref:At,role:"columnheader",className:`kanuni-pivot-header-cell kanuni-pivot-header-corner ${P?"pivot-area-strip--over":""}`,rowSpan:Bt.length,colSpan:lt+(it?1:0),style:{borderInlineEnd:"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"8px",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 70%, transparent)",backgroundColor:"var(--pivot-surface-header)"},children:u("dropHere")}),n===0&&a.length>0&&p.rowHeaderLayout==="tree"&&jsxRuntime.jsx("th",{role:"columnheader",className:"kanuni-pivot-header-cell kanuni-pivot-header-corner",rowSpan:Bt.length,style:{borderInlineEnd:it?"none":"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)",backgroundColor:"var(--pivot-surface-header)",display:"flex",flexWrap:"wrap",gap:"4px",height:"100%"},children:a.map(s=>jsxRuntime.jsx(Ho,{field:s,siblings:a,onMove:I,onRemove:V,onFilterClick:O||(()=>{}),onContextMenu:M,onSort:H},s.id))}),n===0&&a.length>0&&p.rowHeaderLayout!=="tree"&&a.map((s,b)=>jsxRuntime.jsx("th",{role:"columnheader","data-row-header-idx":b,className:"kanuni-pivot-header-cell kanuni-pivot-header-corner",rowSpan:Bt.length,style:{borderInlineEnd:b===a.length-1&&!it?"1px solid var(--pivot-border)":"none",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)",backgroundColor:"var(--pivot-surface-header)"},children:jsxRuntime.jsx(Ho,{field:s,siblings:a,onMove:I,onRemove:V,onFilterClick:O||(()=>{}),onContextMenu:M,onSort:H})},s.id)),n===0&&a.length>0&&it&&jsxRuntime.jsx("th",{role:"columnheader","data-row-header-idx":a.length,className:"kanuni-pivot-header-cell kanuni-pivot-header-corner",rowSpan:Bt.length,style:{borderInlineEnd:"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)",backgroundColor:"var(--pivot-surface-header)"},children:jsxRuntime.jsx("div",{style:{fontSize:10,fontWeight:600,color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 80%, transparent)",textTransform:"uppercase",letterSpacing:"0.05em",textAlign:"center"},children:u("dataArea")})})]},`col-hdr-row-${n}`))]}),jsxRuntime.jsxs("tbody",{role:"rowgroup",onClick:Ro,onContextMenu:To,onMouseDown:qo,onMouseOver:No,children:[oe>0&&jsxRuntime.jsx("tr",{role:"row",style:{height:oe*Pt},children:jsxRuntime.jsx("td",{role:"gridcell",colSpan:lt+(it?1:0),style:{padding:0,border:"none"}})}),jo]})]})})}),jsxRuntime.jsxs("div",{ref:N,className:"datagrid-table-wrapper custom-scrollbar pivot-right-pane",style:{overflow:"auto",height:"100%",position:"relative",outline:"none",flex:1},children:[i&&jsxRuntime.jsxs("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center pivot-bg-surface backdrop-blur-[2px] transition-opacity duration-300 rounded",style:{gap:10},children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),jsxRuntime.jsx("span",{className:"text-sm font-semibold pivot-text-primary",children:u("initializing")}),jsxRuntime.jsxs("div",{style:{width:220,display:"flex",flexDirection:"column",gap:6,alignItems:"center"},children:[jsxRuntime.jsx("div",{style:{width:"100%",height:6,borderRadius:999,overflow:"hidden",backgroundColor:"color-mix(in srgb, var(--pivot-border) 60%, transparent)"},children:jsxRuntime.jsx("div",{style:{width:`${Math.max(0,Math.min(100,d))}%`,height:"100%",borderRadius:999,backgroundColor:"var(--pivot-primary)",transition:"width 160ms ease-out"}})}),jsxRuntime.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--pivot-text)"},children:[Math.round(d),"%"]})]})]}),jsxRuntime.jsx("div",{style:{height:Ue+ve,width:"max-content",position:"relative"},children:jsxRuntime.jsxs("table",{className:"kanuni-pivot-table",role:ae?"presentation":void 0,style:{borderCollapse:"separate",borderSpacing:0,width:0,minWidth:"100%",tableLayout:"fixed"},children:[jsxRuntime.jsx("colgroup",{children:Array.from({length:Lt||1}).map((r,n)=>jsxRuntime.jsx("col",{style:{width:`var(--col-width-data-${n}, ${ot.data}px)`}},`col-data-${n}`))}),jsxRuntime.jsxs("thead",{ref:io,role:"rowgroup",style:{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"},children:[jsxRuntime.jsx("tr",{role:"row",style:{height:42},children:jsxRuntime.jsx("th",{ref:Io,role:"columnheader",colSpan:Lt||1,style:{borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",backgroundColor:"var(--pivot-surface-header)",zIndex:1},children:jsxRuntime.jsx("div",{style:{position:"sticky",insetInlineStart:0,width:"max-content",maxWidth:"100%"},children:jsxRuntime.jsx(Ao,{area:"column",title:u("columnArea"),icon:jsxRuntime.jsx(lucideReact.Columns3,{size:13}),fields:l,onRemoveField:V,onFilterClick:O||(()=>{}),onContextMenu:M,onSort:H,onMoveField:I})})})}),Bt.map((r,n)=>jsxRuntime.jsxs("tr",{role:"row",style:{height:Pt},children:[r.map((s,b)=>{let x=s.fieldId?l.find(W=>W.id===s.fieldId):void 0,R=!!x?.filterValues&&x.filterValues.size>0,U=s.leafStart,j=x&&!s.isTotal?pivotgridCore.formatDimensionValue(s.caption,x,"grid",gt):s.caption,st=j;x?.cellTemplate?st=x.cellTemplate({value:s.caption,displayValue:j,field:x}):st=jsxRuntime.jsx("span",{className:"select-none",children:j});let et={text:st,style:{textAlign:"left",fontWeight:s.isTotal?600:500,borderBottom:"1px solid var(--pivot-border)",borderRight:"1px solid var(--pivot-border)",color:"var(--pivot-text-header, inherit)",backgroundColor:"var(--pivot-surface-header)",cursor:x?"pointer":"context-menu",position:"relative",zIndex:1,padding:"4px 6px"},className:`kanuni-pivot-header-cell group ${s.isTotal?"kanuni-pivot-header-total":""}`};return tt&&tt({area:"column",cell:null,rowIndex:n,columnIndex:U,cellConfig:et}),jsxRuntime.jsxs("th",{role:"columnheader","aria-expanded":s.hasChildren?!!s.isExpanded:void 0,className:et.className,colSpan:s.colSpan,rowSpan:s.rowSpan,style:et.style,onClick:()=>{if(Date.now()-Ct.current<100||!x)return;let W=a.find(ft=>ft.sortBySummaryField===s.fieldId&&(ft.sortBySummaryPath||"")===(s.colPath||""));if(W&&H){let ft=W.sortOrder==="asc"?"desc":"asc";H(W.id,ft);return}},onContextMenu:W=>{s.hasChildren?(W.preventDefault(),mo({x:W.clientX,y:W.clientY,path:s.colPath,isExpanded:!!s.isExpanded,depth:n,type:"col"})):M&&s.fieldId&&(W.preventDefault(),M(W.clientX,W.clientY,s.fieldId,s.colPath));},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:4},children:[s.hasChildren&&jsxRuntime.jsx("span",{className:"kanuni-pivot-expand-icon","aria-hidden":"true",style:{cursor:"pointer",marginRight:4,flexShrink:0},onClick:W=>{W.stopPropagation(),f(s.colPath);},children:s.isExpanded?"\u2212":"+"}),et.text,(()=>{let W=a.find(ft=>ft.sortBySummaryField===s.fieldId&&(ft.sortBySummaryPath||"")===(s.colPath||""));return W?W.sortOrder==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{size:12,className:"pivot-text-primary"}):jsxRuntime.jsx(lucideReact.ArrowDown,{size:12,className:"pivot-text-primary"}):null})(),s.fieldId&&jsxRuntime.jsx("span",{className:`cursor-pointer transition-opacity ${R?"opacity-100 pivot-text-danger":"opacity-0 group-hover:opacity-70"}`,onClick:W=>{W.stopPropagation(),O&&s.fieldId&&O(W.clientX,W.clientY,s.fieldId);},children:jsxRuntime.jsx(lucideReact.Filter,{size:10,fill:R?"currentColor":"none"})})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:W=>St(W,`leaf-${U}-${s.colSpan}`,ot.data,s.colSpan),onClick:W=>W.stopPropagation(),style:{right:-3}})]},`col-hdr-${n}-${b}`)}),r.length===0&&jsxRuntime.jsx("th",{role:"columnheader",colSpan:Lt||1,style:{borderBottom:"1px solid var(--pivot-border)",backgroundColor:"var(--pivot-surface-header)",padding:0}})]},`col-hdr-row-${n}`))]}),jsxRuntime.jsxs("tbody",{role:"rowgroup",onClick:Ko,onDoubleClick:Uo,onContextMenu:Xo,onMouseDown:Qe,onMouseOver:to,children:[oe>0&&jsxRuntime.jsx("tr",{role:"row",style:{height:oe*Pt},children:jsxRuntime.jsx("td",{role:"gridcell",colSpan:Lt||1,style:{padding:0,border:"none"}})}),fo]})]})})]}),eo&&(Q??(r=>jsxRuntime.jsx(nr,{...r})))({menu:eo,onClose:()=>mo(null),onToggleExpand:S,onToggleColExpand:f,onExpandPaths:F,onCollapsePaths:m,onExpandColPaths:h,onCollapseColPaths:T,rowTree:t.rowTree,colTree:t.colTree,t:u}),jsxRuntime.jsx("div",{ref:pt,style:{position:"absolute",top:0,bottom:0,left:0,width:2,backgroundColor:"var(--pivot-primary)",zIndex:100,display:"none",pointerEvents:"none"}})]})}function ur({reports:t,activeReportId:i,onSaveNew:d,onUpdateCurrent:a,onSaveAs:l,onLoadReport:e,onDeleteReport:p,onSetDefault:C}){let{t:E}=ut(),[S,F]=dn.useState(false),m=dn.useRef(null);dn.useEffect(()=>{let c=f=>{m.current&&!m.current.contains(f.target)&&F(false);};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[]);let y=t.find(c=>c.id===i);return jsxRuntime.jsxs("div",{className:"pivot-relative",ref:m,children:[jsxRuntime.jsxs("button",{className:`kanuni-pivot-report-btn ${S?"kanuni-pivot-report-btn--open":i?"kanuni-pivot-report-btn--active":"kanuni-pivot-report-btn--default"}`,title:E("viewsAndReports"),onClick:()=>F(!S),children:[jsxRuntime.jsx(lucideReact.Bookmark,{size:15}),jsxRuntime.jsx("span",{className:"pivot-truncate",style:{maxWidth:"120px"},children:y?y.name:E("views")})]}),S&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-report-dropdown pivot-animate-slide-up",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:E("actions")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-item",onClick:()=>{F(false),d();},children:[jsxRuntime.jsx(lucideReact.Save,{size:16,color:"var(--pivot-success)"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"pivot-font-medium",children:E("saveNewView")})})]}),i&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-item",onClick:()=>{F(false),a();},children:[jsxRuntime.jsx(lucideReact.SaveAll,{size:16,color:"var(--pivot-warning)"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"pivot-font-medium",children:E("saveChangesOverwrite")})})]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-item",onClick:()=>{F(false),l();},children:[jsxRuntime.jsx(lucideReact.Copy,{size:16,color:"var(--pivot-info)"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"pivot-font-medium",children:E("saveAsCopy")})})]})]}),t.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"8px",borderTop:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:E("savedViews")}),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-list pivot-custom-scrollbar",children:t.map(c=>jsxRuntime.jsxs("div",{className:`kanuni-pivot-report-list-item ${c.id===i?"kanuni-pivot-report-list-item--active":""}`,children:[jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-list-btn",onClick:()=>{F(false),e(c.id);},children:[c.id===i?jsxRuntime.jsx(lucideReact.Check,{size:14,color:"var(--pivot-primary)",style:{flexShrink:0}}):jsxRuntime.jsx(lucideReact.FolderOpen,{size:14,color:"var(--pivot-text-muted)",style:{flexShrink:0}}),jsxRuntime.jsx("span",{className:`pivot-text-sm pivot-truncate ${c.id===i?"pivot-text-primary pivot-font-medium":"pivot-text"}`,style:{color:c.id===i?"var(--pivot-primary)":"var(--pivot-text)"},children:c.name}),c.isDefault&&jsxRuntime.jsx(lucideReact.Star,{size:12,color:"var(--pivot-warning)",fill:"var(--pivot-warning)",style:{flexShrink:0}})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-report-actions",children:[!c.isDefault&&jsxRuntime.jsx("button",{className:"kanuni-pivot-action-btn kanuni-pivot-action-btn--warning",title:E("makeDefault"),onClick:f=>{f.stopPropagation(),C(c.id);},children:jsxRuntime.jsx(lucideReact.Star,{size:14})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-action-btn kanuni-pivot-action-btn--danger",title:E("deleteReport"),onClick:f=>{f.stopPropagation(),confirm(E("deleteReportConfirm").replace("{0}",c.name))&&(p(c.id),c.id===i&&F(false));},children:jsxRuntime.jsx(lucideReact.Trash2,{size:14})})]})]},c.id))})]})]})]})}function mr({onToggleFieldChooser:t,fieldChooserOpen:i,onRefresh:d,onExport:a,onImportFile:l,onImportFiles:e,onPasteImport:p,onExpandAll:C,onCollapseAll:E,onAddCalculatedField:S,onOpenPrefilter:F,onToggleChart:m,isFullscreen:y,onToggleFullscreen:c,reports:f=[],activeReportId:h=null,onSaveNewReport:T,onUpdateCurrentReport:w,onSaveAsReport:M,onLoadReport:O,onDeleteReport:V,onSetDefaultReport:H,onGlobalContextMenu:I,selectionStats:K,toolbarConfig:_={},registry:X,advancedExport:q=false,upgradeUrl:G}){let{t:k,locale:$}=ut(),[tt,Q]=dn.useState(false),[u,Y]=dn.useState(false),gt=dn.useRef(null),v=dn.useRef(null);dn.useEffect(()=>{let P=N=>{gt.current&&!gt.current.contains(N.target)&&Q(false),v.current&&!v.current.contains(N.target)&&Y(false);};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[]);let z=P=>{Q(false),a(P);},nt=(P,N,Z,Mt,Ht=false)=>{let $t=Ht&&!q,g=$t&&!!G;return jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px",...$t?{opacity:.6,cursor:g?"pointer":"not-allowed"}:{}},onClick:$t?g?()=>{Q(false),window.open(G,"_blank","noopener,noreferrer");}:void 0:()=>z(P),disabled:$t&&!g,title:g?k("enterpriseUpgradeHint"):void 0,children:[N,jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"pivot-font-medium pivot-flex pivot-items-center",style:{gap:"6px"},children:[Z,$t&&jsxRuntime.jsx("span",{style:{fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"1px 5px",borderRadius:"9999px",backgroundColor:"color-mix(in srgb, var(--pivot-warning) 18%, transparent)",color:"var(--pivot-warning)"},children:k("enterpriseBadge")})]}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:Mt})]})]})},ot=()=>{Y(false);let P=document.createElement("input");P.type="file",P.accept=".json,.csv,.tsv,.txt,.xml,.xlsx,.xls",P.multiple=!!e,P.onchange=N=>{let Z=Array.from(N.target.files??[]);Z.length!==0&&(e?e(Z):l&&l(Z[0]));},P.click();},At=()=>{Y(false),p?.();};return jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center pivot-justify-start",style:{padding:"4px 8px",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 50%, var(--pivot-surface))",borderTop:"1px solid var(--pivot-border)",gap:"4px"},onContextMenu:P=>{I&&(P.preventDefault(),I(P.clientX,P.clientY));},children:[_.showSaveReport!==false&&T&&O&&V&&H&&w&&M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(ur,{reports:f,activeReportId:h,onSaveNew:T,onUpdateCurrent:w,onSaveAs:M,onLoadReport:O,onDeleteReport:V,onSetDefault:H}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"})]}),_.showFieldChooserToggle!==false&&jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${i?"kanuni-pivot-footer-btn--active":""}`,title:k("showFieldList"),onClick:t,children:jsxRuntime.jsx(lucideReact.Settings,{size:15})}),F&&jsxRuntime.jsx("button",{onClick:F,className:"kanuni-pivot-footer-btn",title:k("filterBuilder"),children:jsxRuntime.jsx(lucideReact.Filter,{size:15})}),m&&jsxRuntime.jsx("button",{onClick:m,className:"kanuni-pivot-footer-btn",title:k("chartToggle"),children:jsxRuntime.jsx(lucideReact.BarChart,{size:15})}),_.showCalculatedFields!==false&&S&&jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:k("calculatedMeasureDesigner"),onClick:S,children:jsxRuntime.jsx(lucideReact.Calculator,{size:15})}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),_.showExpandCollapseAll!==false&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:k("expandAll"),onClick:C,children:jsxRuntime.jsx(lucideReact.Maximize2,{size:15})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:k("collapseAll"),onClick:E,children:jsxRuntime.jsx(lucideReact.Minimize2,{size:15})})]}),_.showRefreshButton!==false&&d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:k("refreshData"),onClick:d,children:jsxRuntime.jsx(lucideReact.RefreshCw,{size:15})})]}),_.showFullscreenToggle!==false&&c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${y?"kanuni-pivot-footer-btn--active":""}`,style:y?{backgroundColor:"color-mix(in srgb, var(--pivot-primary) 10%, transparent)",color:"var(--pivot-primary)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 30%, transparent)"}:{},title:k(y?"exitFullscreen":"enterFullscreen"),onClick:c,children:y?jsxRuntime.jsx(lucideReact.Shrink,{size:15}):jsxRuntime.jsx(lucideReact.Fullscreen,{size:15})})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),_.showImportFile!==false&&(l||e)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"pivot-relative",ref:v,children:[jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${u?"kanuni-pivot-footer-btn--active":""}`,title:k("importFile"),onClick:()=>Y(P=>!P),children:jsxRuntime.jsx(lucideReact.Upload,{size:15})}),u&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar",style:{bottom:"100%",left:0,marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"},children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:k("importFile")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:ot,children:[jsxRuntime.jsx(lucideReact.Upload,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:k("importFromFile")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:"CSV \xB7 Excel \xB7 JSON \xB7 XML"})]})]}),p&&jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:At,children:[jsxRuntime.jsx(lucideReact.ClipboardPaste,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:k("pasteImport")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:k("pasteImportHint")})]})]})]})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"})]}),_.showExportButton!==false&&jsxRuntime.jsxs("div",{className:"pivot-relative",ref:gt,children:[jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${tt?"kanuni-pivot-footer-btn--active":""}`,title:k("export"),onClick:()=>Q(!tt),children:jsxRuntime.jsx(lucideReact.Download,{size:15})}),tt&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar",style:{bottom:"100%",left:0,marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"},children:[X&&X.getPluginsByType("exporter").length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:k("customExports")}),X.getPluginsByType("exporter").map(P=>jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z(P.id),children:[jsxRuntime.jsx(lucideReact.Database,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"pivot-font-medium",children:[P.id.replace("exporter-","").toUpperCase()," ",k("export")]}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:k("customPlugin")})]})]},P.id)),jsxRuntime.jsx("div",{className:"kanuni-pivot-dropdown-divider"})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:k("excelExport")}),nt("excel-pivot",jsxRuntime.jsx(lucideReact.FileSpreadsheet,{size:16,color:"var(--pivot-success)"}),k("pivotView"),k("preservesGridLayout"),true),nt("excel-list",jsxRuntime.jsx(lucideReact.FileSpreadsheet,{size:16,color:"var(--pivot-success)"}),k("listView"),k("rawFlatData"),true),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"4px",borderTop:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:k("document")}),nt("pdf",jsxRuntime.jsx(lucideReact.FileText,{size:16,color:"var(--pivot-danger)"}),k("pdfDocument"),k("printReadyLayout"),true),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("print"),children:[jsxRuntime.jsx(lucideReact.Printer,{size:16,color:"var(--pivot-info)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:k("print")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:k("sendToPrinter")})]})]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("clipboard"),children:[jsxRuntime.jsx(lucideReact.Copy,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:k("copyToClipboard")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:k("tabSeparatedValues")})]})]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("json-snapshot"),children:[jsxRuntime.jsx(lucideReact.FileJson,{size:16,color:"var(--pivot-success)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:k("fullSnapshot")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:k("saveSessionState")})]})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"4px",borderTop:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:k("rawDataFormats")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("csv"),children:[jsxRuntime.jsx(lucideReact.File,{size:16,color:"var(--pivot-info)"})," CSV"]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("json-pivot"),children:[jsxRuntime.jsx(lucideReact.FileJson,{size:16,color:"var(--pivot-warning)"})," JSON (Tree)"]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("json"),children:[jsxRuntime.jsx(lucideReact.FileJson,{size:16,color:"var(--pivot-warning)"})," JSON (List)"]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>z("xml"),children:[jsxRuntime.jsx(lucideReact.Database,{size:16,color:"var(--pivot-text-muted)"})," XML"]})]})]}),K&&jsxRuntime.jsxs("div",{className:"pivot-text-muted pivot-font-medium pivot-flex pivot-items-center",style:{marginLeft:"auto",fontSize:"11px",gap:"8px",paddingRight:"8px",userSelect:"none"},children:[jsxRuntime.jsxs("span",{children:["(",k("count"),": ",K.count,")"]}),jsxRuntime.jsxs("span",{children:["(",k("sum"),": ",new Intl.NumberFormat($,{minimumFractionDigits:2,maximumFractionDigits:2}).format(K.sum),")"]}),jsxRuntime.jsxs("span",{children:["(",k("avg"),": ",new Intl.NumberFormat($,{minimumFractionDigits:2,maximumFractionDigits:2}).format(K.avg),")"]}),jsxRuntime.jsxs("span",{children:["(",k("min"),": ",new Intl.NumberFormat($,{minimumFractionDigits:2,maximumFractionDigits:2}).format(K.min),")"]}),jsxRuntime.jsxs("span",{children:["(",k("max"),": ",new Intl.NumberFormat($,{minimumFractionDigits:2,maximumFractionDigits:2}).format(K.max),")"]})]})]})}function Pa({type:t,isCalculated:i}){if(i)return jsxRuntime.jsx(lucideReact.Settings2,{size:12,color:"var(--pivot-primary)"});switch(t){case "number":return jsxRuntime.jsx(lucideReact.Hash,{size:12,color:"var(--pivot-primary)"});case "date":return jsxRuntime.jsx(lucideReact.Calendar,{size:12,color:"var(--pivot-primary)"});case "boolean":return jsxRuntime.jsx(lucideReact.Filter,{size:12,color:"var(--pivot-primary)"});default:return jsxRuntime.jsx(lucideReact.Type,{size:12,color:"var(--pivot-primary)"})}}function Sa({field:t,isFirst:i,onRemove:d,onDeleteField:a,showCheckbox:l,isChecked:e,onToggleCheckbox:p,onFilterClick:C}){let{t:E}=ut(),{attributes:S,listeners:F,setNodeRef:m,transform:y,isDragging:c}=core.useDraggable({id:`chooser-${t.id}`,data:{type:"Field",field:t}}),{setNodeRef:f}=core.useDroppable({id:`chooser-${t.id}`,data:{type:"Field",field:t}}),h=I=>{m(I),f(I);},T=le(),w=T.targetId===t.id,M=w&&T.intent==="before",O=w&&T.intent==="after",V={transform:y?`translate3d(${y.x}px, ${y.y}px, 0)`:void 0,position:"relative"},H=!!t.filterValues&&t.filterValues.size>0;return jsxRuntime.jsxs("div",{ref:h,style:V,className:`kanuni-pivot-field-chip ${c?"is-dragging":""}`,"data-drag-scope":"grip",children:[M&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",top:i?-4:-3,left:-4,right:-4,height:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,left:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderLeft:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,right:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderRight:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-1,left:0,right:0,height:2,backgroundColor:"var(--pivot-primary)"}})]}),O&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",bottom:-3,left:-4,right:-4,height:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,left:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderLeft:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,right:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderRight:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-1,left:0,right:0,height:2,backgroundColor:"var(--pivot-primary)"}})]}),jsxRuntime.jsx("div",{...S,...F,"data-drag-grip":"",style:{color:"var(--pivot-text-muted)",cursor:"grab",flexShrink:0,opacity:.5},children:jsxRuntime.jsx(lucideReact.GripVertical,{size:14})}),l&&jsxRuntime.jsx("input",{type:"checkbox",checked:e,onChange:I=>p&&p(t,I.target.checked),className:"kanuni-pivot-checkbox",style:{flexShrink:0}}),jsxRuntime.jsx(Pa,{type:t.dataType,isCalculated:t.isCalculated}),jsxRuntime.jsxs("span",{className:"pivot-truncate",style:{flex:1,color:"var(--pivot-text)",textAlign:"left"},children:[t.caption,t.area==="data"&&t.summaryType?jsxRuntime.jsx("span",{style:{fontSize:"10px",marginLeft:"4px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 10%, transparent)",color:"var(--pivot-primary)",padding:"0 4px",borderRadius:"4px",fontWeight:700,textTransform:"uppercase"},children:t.summaryType}):null]}),jsxRuntime.jsxs("div",{className:`kanuni-pivot-field-chip-actions${H?" is-filtered":""}`,children:[C&&t.area!=="data"&&jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn",style:H?{color:"var(--pivot-danger)",backgroundColor:"color-mix(in srgb, var(--pivot-danger) 10%, transparent)"}:{},onClick:I=>{I.stopPropagation(),C(I,t);},title:E("filterField"),children:jsxRuntime.jsx(lucideReact.Filter,{size:12,fill:H?"currentColor":"none"})}),!C&&H&&jsxRuntime.jsx(lucideReact.Filter,{size:12,color:"var(--pivot-danger)",fill:"currentColor"}),t.isCalculated&&a&&jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger",onClick:I=>{I.stopPropagation(),a(t.id);},title:E("deletePermanently"),children:jsxRuntime.jsx(lucideReact.Trash,{size:12})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger",onClick:I=>{I.stopPropagation(),d(t.id);},title:E("removeFromArea"),children:jsxRuntime.jsx(lucideReact.X,{size:12})})]})]})}function Be({area:t,fields:i,title:d,emptyText:a,onRemoveField:l,onDeleteField:e,maxHeight:p=150,showCheckboxes:C,onToggleCheckbox:E,onFilterClick:S}){let{setNodeRef:F,isOver:m}=core.useDroppable({id:`chooser-${t}`,data:{type:"Area",area:`chooser-${t}`}}),{setNodeRef:y}=core.useDroppable({id:`chooser-${t}-ghost-end`}),c=le(),h=(c.targetArea===`chooser-${t}`||c.targetArea===t)&&c.intent==="append";return jsxRuntime.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",transition:"background-color 0.2s",backgroundColor:m?"color-mix(in srgb, var(--pivot-primary) 5%, transparent)":"transparent",boxShadow:m?"inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)":"none"},children:[d&&jsxRuntime.jsx("div",{style:{fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--pivot-text-muted)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)",padding:"8px 12px",borderBottom:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:d}),jsxRuntime.jsxs("div",{ref:F,style:{maxHeight:typeof p=="number"?`${p}px`:p,flex:1,padding:"8px",minHeight:"80px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px",alignItems:i.length===0?"center":"stretch",justifyContent:i.length===0?"center":"flex-start"},className:"pivot-custom-scrollbar",children:[i.length===0&&a&&jsxRuntime.jsx("div",{style:{fontSize:"12px",color:"color-mix(in srgb, var(--pivot-text-muted) 70%, transparent)",fontStyle:"italic",textAlign:"center",width:"100%"},children:a}),i.map((T,w)=>jsxRuntime.jsx(Sa,{field:T,isFirst:w===0,onRemove:l,onDeleteField:e,showCheckbox:C,isChecked:T.area!=="chooser",onToggleCheckbox:E,onFilterClick:S},T.id)),jsxRuntime.jsx("div",{ref:y,style:{width:"100%",minHeight:"24px",transition:"background-color 0.2s",borderRadius:"var(--pivot-border-radius-sm)",backgroundColor:h?"color-mix(in srgb, var(--pivot-primary) 10%, transparent)":"transparent",boxShadow:h?"inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)":"none"},children:h&&i.length>0&&jsxRuntime.jsx("div",{style:{width:"100%",height:"4px",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginTop:"4px"}})})]})]})}function si({fields:t,onClose:i,onRemoveField:d,onDeleteField:a,onChangeFieldArea:l,onShowFields:e,onFilterClick:p}){let{t:C,locale:E}=ut(),[S,F]=dn.useState(""),[m,y]=dn.useState({x:0,y:0}),[c,f]=dn.useState({width:700,height:550}),[h,T]=dn.useState(false),[w,M]=dn.useState(null),[O,V]=dn.useState(window.innerWidth<=768),H=dn.useRef(false);dn.useEffect(()=>{if(!H.current&&!O){let v=Math.min(700,window.innerWidth-32),z=Math.min(550,window.innerHeight-32),nt=(window.innerWidth-v)/2,ot=(window.innerHeight-z)/2;f({width:v,height:z}),y({x:nt,y:ot}),H.current=true;}},[O]),dn.useEffect(()=>{let v=()=>{let z=window.innerWidth<=768;V(z),z||y(nt=>({x:Math.min(nt.x,window.innerWidth-c.width),y:Math.min(nt.y,window.innerHeight-c.height)}));};return window.addEventListener("resize",v),()=>window.removeEventListener("resize",v)},[c.width,c.height]);let I=v=>{O||v.target.closest(".dnd-draggable")||v.target.closest("button")||v.target.closest("input")||v.target.closest('input[type="checkbox"]')||(T(true),v.currentTarget.setPointerCapture(v.pointerId));},K=v=>{h&&y(z=>({x:Math.max(0,z.x+v.movementX),y:Math.max(0,z.y+v.movementY)}));},_=v=>{T(false),v.currentTarget.releasePointerCapture(v.pointerId);},X=(v,z)=>{v.stopPropagation(),M(z),v.currentTarget.setPointerCapture(v.pointerId);},q=v=>{if(!w)return;let z=v.movementX,nt=v.movementY;f(ot=>{let At=ot.width,P=ot.height,N=0,Z=0;return w.includes("e")&&(At+=z),w.includes("s")&&(P+=nt),w.includes("w")&&(At-=z,At>=400&&(N=z)),w.includes("n")&&(P-=nt,P>=400&&(Z=nt)),At=Math.max(400,At),P=Math.max(400,P),(N!==0||Z!==0)&&y(Mt=>({x:Math.max(0,Mt.x+N),y:Math.max(0,Mt.y+Z)})),{width:At,height:P}});},G=v=>{M(null),v.currentTarget.releasePointerCapture(v.pointerId);},k=dn.useMemo(()=>{let v=new Map;return t.map(z=>{let nt=z.caption||z.id||"";if(v.has(nt)){let ot=v.get(nt)+1;return v.set(nt,ot),{...z,caption:`${nt} (${ot})`}}return v.set(nt,1),z})},[t]),$=dn.useMemo(()=>{let v=[...k].sort((z,nt)=>{let ot=(z.caption||"").toLowerCase(),At=(nt.caption||"").toLowerCase();return ot.localeCompare(At,E||"en")});return S?v.filter(z=>(z.caption||"").toLowerCase().includes(S.toLowerCase())):v},[k,S,E]),tt=dn.useMemo(()=>k.filter(v=>v.area==="row").sort((v,z)=>(v.areaIndex||0)-(z.areaIndex||0)),[k]),Q=dn.useMemo(()=>k.filter(v=>v.area==="column").sort((v,z)=>(v.areaIndex||0)-(z.areaIndex||0)),[k]),u=dn.useMemo(()=>k.filter(v=>v.area==="data").sort((v,z)=>(v.areaIndex||0)-(z.areaIndex||0)),[k]),Y=dn.useMemo(()=>k.filter(v=>v.area==="filter").sort((v,z)=>(v.areaIndex||0)-(z.areaIndex||0)),[k]),gt=(v,z)=>{if(l)if(!z)d(v.id);else {let ot=v.dataType==="number"?"data":"row";l(v.id,ot);}};return jsxRuntime.jsx("div",{className:`fixed inset-0 z-[100] bg-black/40 overflow-auto pointer-events-auto ${O?"flex items-center justify-center":""}`,onClick:i,children:jsxRuntime.jsxs("div",{className:`flex flex-col bg-surface shadow-2xl border border-border overflow-hidden ${O?"w-[95vw] h-[95vh] rounded-xl":"rounded-lg"}`,style:O?{position:"fixed",inset:0,width:"100vw",height:"100vh",padding:0,zIndex:100,transform:"none",borderRadius:0}:{position:"fixed",left:m.x,top:m.y,width:c.width,height:c.height,maxWidth:"95vw",maxHeight:"95vh",transform:"none",padding:0,zIndex:100,boxShadow:"var(--pivot-shadow-lg)"},onClick:v=>v.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:`pivot-field-chooser__header flex items-center justify-between p-3 border-b border-border bg-surface-header/90 backdrop-blur-md ${O?"":"cursor-move"}`,onPointerDown:I,onPointerMove:K,onPointerUp:_,onPointerCancel:_,children:[jsxRuntime.jsxs("h3",{className:"text-[15px] font-semibold m-0 flex items-center gap-2 text-surface-header-fg select-none",children:[jsxRuntime.jsx(lucideReact.GripHorizontal,{size:18,className:"text-muted-fg opacity-60"}),C("allFields")]}),jsxRuntime.jsx("button",{className:"btn-icon hover:bg-danger/10 hover:text-danger transition-colors rounded-full p-1.5 focus:outline-none",onClick:i,onPointerDown:v=>v.stopPropagation(),children:jsxRuntime.jsx(lucideReact.X,{size:18})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 overflow-hidden flex-col md:flex-row bg-surface-sunken/30",children:[jsxRuntime.jsxs("div",{className:"w-full md:w-[40%] flex flex-col border-b md:border-b-0 md:border-r border-border bg-surface",children:[jsxRuntime.jsx("div",{className:"p-3 border-b border-border/60 bg-surface/80",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{size:16,className:"absolute start-3 top-1/2 transform -translate-y-1/2 text-muted-fg opacity-60"}),jsxRuntime.jsx("input",{type:"text",placeholder:C("search"),className:"input input-sm w-full ps-9 bg-surface-hover/50 border-border focus:border-primary focus:ring-1 focus:ring-primary/20 transition-all rounded-md text-[13px]",value:S,onChange:v=>F(v.target.value)})]})}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-hidden p-2",children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsxRuntime.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-fg/80 mb-2 px-1",children:C("allFields")}),jsxRuntime.jsx("button",{type:"button",className:"kanuni-pivot-popup-action-btn kanuni-pivot-chooser-select-all",style:{color:"var(--pivot-primary)"},disabled:!$.some(v=>v.area==="chooser"),onClick:()=>e?.($.filter(v=>v.area==="chooser").map(v=>v.id)),children:C("selectAll")})]}),jsxRuntime.jsx(Be,{area:"chooser",fields:$,emptyText:C("noItems"),onRemoveField:d,onDeleteField:a,maxHeight:"100%",showCheckboxes:true,onToggleCheckbox:gt,onFilterClick:p})]})]}),jsxRuntime.jsx("div",{className:"w-full md:w-[60%] flex-1 overflow-y-auto custom-scrollbar p-3 bg-surface-sunken/30",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 h-full auto-rows-fr",children:[jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Be,{area:"filter",title:C("filterArea"),fields:Y,emptyText:C("dropHere"),onRemoveField:d,onDeleteField:a,onFilterClick:p,maxHeight:"100%"})}),jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Be,{area:"column",title:C("columnArea"),fields:Q,emptyText:C("dropHere"),onRemoveField:d,onDeleteField:a,onFilterClick:p,maxHeight:"100%"})}),jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Be,{area:"row",title:C("rowArea"),fields:tt,emptyText:C("dropHere"),onRemoveField:d,onDeleteField:a,onFilterClick:p,maxHeight:"100%"})}),jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Be,{area:"data",title:C("dataArea"),fields:u,emptyText:C("dropHere"),onRemoveField:d,onDeleteField:a,maxHeight:"100%"})})]})})]}),!O&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-1.5 cursor-n-resize z-50",onPointerDown:v=>X(v,"n"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1.5 cursor-s-resize z-50",onPointerDown:v=>X(v,"s"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-1.5 cursor-w-resize z-50",onPointerDown:v=>X(v,"w"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-1.5 cursor-e-resize z-50",onPointerDown:v=>X(v,"e"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 cursor-nw-resize z-[51]",onPointerDown:v=>X(v,"nw"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize z-[51]",onPointerDown:v=>X(v,"ne"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 cursor-sw-resize z-[51]",onPointerDown:v=>X(v,"sw"),onPointerMove:q,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize z-[51] flex items-end justify-end p-0.5 opacity-50 hover:opacity-100",onPointerDown:v=>X(v,"se"),onPointerMove:q,onPointerUp:G,onPointerCancel:G,children:jsxRuntime.jsx("div",{className:"w-2 h-2 border-e-2 border-b-2 border-muted-fg rounded-sm pointer-events-none"})})]})]})})}function hr({field:t,onClose:i,onSave:d}){let{t:a}=ut(),[l,e]=dn.useState(t.caption),[p,C]=dn.useState(t.summaryType||"sum"),[E,S]=dn.useState(t.summaryDisplayMode||"absolute"),[F,m]=dn.useState(t.groupInterval||""),y=()=>{d({...t,caption:l,summaryType:p,summaryDisplayMode:E,groupInterval:F||void 0});},c=t.area==="data"||t.area==="chooser",f=t.area==="row"||t.area==="column"||t.area==="filter"||t.area==="chooser";return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in",onClick:i}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"400px"},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",children:[jsxRuntime.jsx("h2",{className:"kanuni-pivot-modal-title",children:a("fieldSettings")}),jsxRuntime.jsx("button",{onClick:i,className:"kanuni-pivot-modal-close","aria-label":"Close",children:jsxRuntime.jsx(lucideReact.X,{size:20})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("caption")}),jsxRuntime.jsx("input",{type:"text",className:"kanuni-pivot-input",value:l,onChange:h=>e(h.target.value)})]}),c&&t.dataType==="number"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("summaryType")}),jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",value:p,onChange:h=>C(h.target.value),children:[jsxRuntime.jsx("option",{value:"sum",children:a("sum")}),jsxRuntime.jsx("option",{value:"count",children:a("count")}),jsxRuntime.jsx("option",{value:"avg",children:a("avg")}),jsxRuntime.jsx("option",{value:"min",children:a("min")}),jsxRuntime.jsx("option",{value:"max",children:a("max")})]})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("displayMode")}),jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",value:E,onChange:h=>S(h.target.value),children:[jsxRuntime.jsx("option",{value:"absolute",children:a("absoluteValue")}),jsxRuntime.jsx("option",{value:"percentOfTotal",children:a("percentOfTotal")}),jsxRuntime.jsx("option",{value:"percentOfColumnTotal",children:a("percentOfColumnTotal")}),jsxRuntime.jsx("option",{value:"percentOfRowTotal",children:a("percentOfRowTotal")}),jsxRuntime.jsx("option",{value:"percentOfParentRowTotal",children:a("percentOfParentRowTotal")}),jsxRuntime.jsx("option",{value:"percentOfParentColumnTotal",children:a("percentOfParentColumnTotal")}),jsxRuntime.jsx("option",{value:"runningTotal",children:a("runningTotal")}),jsxRuntime.jsx("option",{value:"difference",children:a("difference")}),jsxRuntime.jsx("option",{value:"percentDifference",children:a("percentDifference")})]})]})]}),f&&t.dataType==="date"&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("groupInterval")}),jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",value:F,onChange:h=>m(h.target.value),children:[jsxRuntime.jsx("option",{value:"",children:a("none")}),jsxRuntime.jsx("option",{value:"year",children:a("year")}),jsxRuntime.jsx("option",{value:"quarter",children:a("quarter")}),jsxRuntime.jsx("option",{value:"month",children:a("month")}),jsxRuntime.jsx("option",{value:"week",children:a("week")}),jsxRuntime.jsx("option",{value:"day",children:a("day")})]})]})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",children:[jsxRuntime.jsx("button",{onClick:i,className:"kanuni-pivot-btn kanuni-pivot-btn--outline",children:a("cancel")}),jsxRuntime.jsxs("button",{onClick:y,className:"kanuni-pivot-btn kanuni-pivot-btn--primary",children:[jsxRuntime.jsx(lucideReact.Check,{size:16})," ",a("ok")]})]})]})]})}var Aa=[["equals","opEquals"],["notEquals","opNotEquals"],["contains","opContains"],["notContains","opNotContains"],["startsWith","opStartsWith"],["endsWith","opEndsWith"]],Ha=[[">","opGreater"],[">=","opGreaterOrEqual"],["<","opLess"],["<=","opLessOrEqual"],["=","opEquals"],["!=","opNotEquals"],["between","opBetween"],["notBetween","opNotBetween"]];function li({field:t,dataFields:i,onClose:d,onSave:a}){let{t:l}=ut(),e=t.labelFilter,p=t.valueFilter,[C,E]=dn.useState(e?.operator??""),[S,F]=dn.useState(e?.value??""),[m,y]=dn.useState(i.some($=>$.id===p?.dataField)?p.dataField:i[0]?.id??""),[c,f]=dn.useState(p?.operator??""),[h,T]=dn.useState(p?String(p.value):""),[w,M]=dn.useState(p?.value2!==void 0?String(p.value2):""),[O,V]=dn.useState(null),H=dn.useRef(null),I=dn.useRef(null),K=dn.useRef(null),_=c==="between"||c==="notBetween",X=`${l("conditionFilter")}: ${t.caption||t.id}`,q=()=>{let $=(u,Y)=>{V(u),Y.current?.focus();},tt;if(C){if(S==="")return $("label",H);tt={operator:C,value:S,...e?.caseSensitive?{caseSensitive:true}:{}};}let Q=i.length>0?void 0:p;if(c&&i.length>0){let u=h===""?NaN:Number(h),Y=w===""?NaN:Number(w);if(!Number.isFinite(u))return $("value",I);if(_&&!Number.isFinite(Y))return $("value2",K);Q={dataField:m,operator:c,value:u,..._?{value2:Y}:{}};}a({...t,labelFilter:tt,valueFilter:Q});},G={display:"flex",gap:"8px",marginTop:"6px"},k={flex:"1 1 0",minWidth:0};return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in",onClick:d}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"400px"},role:"dialog","aria-modal":"true","aria-label":X,onKeyDown:$=>{$.key==="Escape"&&($.stopPropagation(),d());},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",children:[jsxRuntime.jsx("h2",{className:"kanuni-pivot-modal-title",children:X}),jsxRuntime.jsx("button",{onClick:d,className:"kanuni-pivot-modal-close","aria-label":l("cancel"),children:jsxRuntime.jsx(lucideReact.X,{size:20})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:l("caption")}),jsxRuntime.jsxs("div",{style:G,children:[jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",style:k,"data-condition-label-op":"","aria-label":l("caption"),autoFocus:true,value:C,onChange:$=>E($.target.value),children:[jsxRuntime.jsx("option",{value:"",children:l("none")}),Aa.map(([$,tt])=>jsxRuntime.jsx("option",{value:$,children:l(tt)},$))]}),jsxRuntime.jsx("input",{ref:H,type:"text",className:"kanuni-pivot-input",style:k,"data-condition-label-value":"",placeholder:l("builderValuePlaceholder"),"aria-label":l("builderValuePlaceholder"),"aria-invalid":O==="label"||void 0,disabled:C==="",value:S,onChange:$=>F($.target.value)})]})]}),i.length>0&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:l("dataArea")}),jsxRuntime.jsx("select",{className:"kanuni-pivot-select","data-condition-value-field":"","aria-label":l("dataArea"),value:m,onChange:$=>y($.target.value),children:i.map($=>jsxRuntime.jsx("option",{value:$.id,children:$.caption||$.id},$.id))}),jsxRuntime.jsxs("div",{style:G,children:[jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",style:k,"data-condition-value-op":"","aria-label":l("dataArea"),value:c,onChange:$=>f($.target.value),children:[jsxRuntime.jsx("option",{value:"",children:l("none")}),Ha.map(([$,tt])=>jsxRuntime.jsx("option",{value:$,children:l(tt)},$))]}),jsxRuntime.jsx("input",{ref:I,type:"number",className:"kanuni-pivot-input",style:k,"data-condition-value":"","aria-label":l("builderValuePlaceholder"),"aria-invalid":O==="value"||void 0,disabled:c==="",value:h,onChange:$=>T($.target.value)}),_&&jsxRuntime.jsx("input",{ref:K,type:"number",className:"kanuni-pivot-input",style:k,"data-condition-value2":"","aria-label":l("builderValuePlaceholder"),"aria-invalid":O==="value2"||void 0,value:w,onChange:$=>M($.target.value)})]})]})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",children:[jsxRuntime.jsx("button",{onClick:d,className:"kanuni-pivot-btn kanuni-pivot-btn--outline",children:l("cancel")}),jsxRuntime.jsxs("button",{onClick:q,className:"kanuni-pivot-btn kanuni-pivot-btn--primary",children:[jsxRuntime.jsx(lucideReact.Check,{size:16})," ",l("ok")]})]})]})]})}function kr({x:t,y:i,field:d,colPath:a,rowFields:l,onClose:e,onSort:p,onSortBySummary:C,onClearAllSorting:E,onHide:S,onSettings:F,onMoveField:m,onMoveToArea:y,onShowFieldChooser:c,customContextMenuItems:f,onEditCalculatedField:h,onConditionFilter:T}){let{t:w,rtl:M}=ut(),[O,V]=dn.useState(null),H=O==="order",I=O==="area",K=dn.useRef(null),_=dn.useRef(null),X=dn.useRef(null),q=dn.useRef(null);dn.useLayoutEffect(()=>{let P=document.activeElement;return q.current=P?.closest(".kanuni-pivot-field-chip")??null,q.current&&K.current?.querySelector("button")?.focus(),()=>{let N=q.current;N&&N.isConnected&&N.focus({preventScroll:true});}},[]);let G=P=>{if(P.key==="Escape"){P.preventDefault(),e();return}let Z=[K.current,_.current].filter(Boolean).flatMap($t=>Array.from($t.querySelectorAll("button:not([disabled])")));if(Z.length===0)return;let Mt=Z.indexOf(document.activeElement),Ht=-1;P.key==="ArrowDown"?Ht=Mt<0?0:(Mt+1)%Z.length:P.key==="ArrowUp"?Ht=Mt<0?Z.length-1:(Mt-1+Z.length)%Z.length:P.key==="Home"?Ht=0:P.key==="End"&&(Ht=Z.length-1),!(Ht<0)&&(P.preventDefault(),Z[Ht].focus());};dn.useEffect(()=>{let P=N=>{let Z=N.target;K.current&&!K.current.contains(Z)&&(!_.current||!_.current.contains(Z))&&e();};return document.addEventListener("mousedown",P),()=>document.removeEventListener("mousedown",P)},[e]);let k=a!==void 0&&l&&l.length>0&&d.area==="data",[$,tt]=dn.useState({top:i,left:t,maxHeight:"calc(100vh - 16px)"}),[Q,u]=dn.useState({top:0,left:0}),Y=dn.useRef(null),gt=dn.useRef(null),v=()=>{clearTimeout(gt.current),V("order");},z=()=>{gt.current=setTimeout(()=>V(P=>P==="order"?null:P),200);},nt=()=>{clearTimeout(gt.current),V("area");},ot=()=>{gt.current=setTimeout(()=>V(P=>P==="area"?null:P),200);},At=[{area:"row",label:w("rowArea"),Icon:lucideReact.Rows3},{area:"column",label:w("columnArea"),Icon:lucideReact.Columns3},{area:"data",label:w("dataArea"),Icon:lucideReact.BarChart3},{area:"filter",label:w("filterArea"),Icon:lucideReact.Filter}].filter(P=>P.area!==d.area);return dn.useLayoutEffect(()=>{if(!K.current)return;let P=setTimeout(()=>{if(!K.current)return;let N=K.current.getBoundingClientRect(),Z=i,Mt=t;Mt+N.width>window.innerWidth&&(Mt=Math.max(8,window.innerWidth-N.width-8)),Z+N.height>window.innerHeight&&(Z=window.innerHeight-N.height-8,Z<8&&(Z=8)),tt({top:Z,left:Mt,maxHeight:`calc(100vh - ${Z+8}px)`});},0);return ()=>clearTimeout(P)},[t,i,k,l,f]),dn.useLayoutEffect(()=>{let P=H?Y.current:I?X.current:null;if(P){let N=P.getBoundingClientRect(),Z=N.right+4;Z+160>window.innerWidth&&(Z=N.left-160-4),u({top:N.top,left:Z});}},[H,I]),jsxRuntime.jsx(ge,{children:jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsxs("div",{ref:K,className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in pivot-flex-col",style:{position:"fixed",top:$.top,left:$.left,maxHeight:$.maxHeight,overflowY:"auto",overflowX:"hidden",width:"220px",zIndex:9999},onContextMenu:P=>P.preventDefault(),onKeyDown:G,children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{position:"sticky",top:0,zIndex:10},children:d.caption}),k?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"4px"},children:w("sortByThisColumn")}),l.map(P=>jsxRuntime.jsxs("button",{onClick:()=>{C?.(P.id,a),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ArrowDownAZ,{size:16})," ",w("sortFieldByThisColumn").replace("{0}",P.caption||P.id)]},P.id)),E&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),jsxRuntime.jsxs("button",{onClick:()=>{E(),e();},className:"kanuni-pivot-dropdown-item-danger pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.X,{size:16})," ",w("removeAllSorting")]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>{p("asc"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ArrowDownAZ,{size:16})," ",w("sortAsc")]}),jsxRuntime.jsxs("button",{onClick:()=>{p("desc"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ArrowUpZA,{size:16})," ",w("sortDesc")]}),d.sortOrder&&jsxRuntime.jsxs("button",{onClick:()=>{p(void 0),e();},className:"kanuni-pivot-dropdown-item-danger pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.X,{size:16})," ",w("clearSort")]}),T&&(d.area==="row"||d.area==="column")&&jsxRuntime.jsxs("button",{onClick:()=>{T(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.Filter,{size:16})," ",w("conditionFilter"),"\u2026"]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),m&&jsxRuntime.jsx("div",{className:"relative",onMouseEnter:v,onMouseLeave:z,children:jsxRuntime.jsxs("button",{ref:Y,className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between",onClick:()=>V(P=>P==="order"?null:"order"),children:[jsxRuntime.jsxs("span",{className:"pivot-flex pivot-items-center pivot-gap-2",children:[jsxRuntime.jsx(lucideReact.List,{size:16})," ",w("order")]}),M?jsxRuntime.jsx(lucideReact.ChevronLeft,{size:14}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:14})]})}),y&&At.length>0&&jsxRuntime.jsx("div",{className:"relative",onMouseEnter:nt,onMouseLeave:ot,children:jsxRuntime.jsxs("button",{ref:X,className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between",onClick:()=>V(P=>P==="area"?null:"area"),children:[jsxRuntime.jsxs("span",{className:"pivot-flex pivot-items-center pivot-gap-2",children:[jsxRuntime.jsx(lucideReact.Move,{size:16})," ",w("moveToArea")]}),M?jsxRuntime.jsx(lucideReact.ChevronLeft,{size:14}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:14})]})}),c&&jsxRuntime.jsxs("button",{onClick:()=>{c(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.List,{size:16})," ",w("showFieldList")]}),jsxRuntime.jsxs("button",{onClick:()=>{S(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.EyeOff,{size:16})," ",w("hide")]}),f&&f.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),f.map((P,N)=>jsxRuntime.jsxs("button",{onClick:()=>{P.action(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[P.icon&&jsxRuntime.jsx(P.icon,{size:16})," ",P.label]},N))]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),d.isCalculated&&h&&jsxRuntime.jsxs("button",{onClick:()=>{h(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.Calculator,{size:16})," ",w("editCalculation")]}),jsxRuntime.jsxs("button",{onClick:()=>{F(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.Settings,{size:16})," ",w("fieldSettings")]})]})]}),H&&m&&jsxRuntime.jsxs("div",{ref:_,className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",top:Q.top,left:Q.left,minWidth:"160px",zIndex:1e4},onMouseEnter:v,onMouseLeave:z,onContextMenu:P=>P.preventDefault(),onKeyDown:G,children:[jsxRuntime.jsxs("button",{onClick:()=>{m("start"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronsLeft,{size:16})," ",w("moveToStart")]}),jsxRuntime.jsxs("button",{onClick:()=>{m("left"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{size:16})," ",w("moveToLeft")]}),jsxRuntime.jsxs("button",{onClick:()=>{m("right"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronRight,{size:16})," ",w("moveToRight")]}),jsxRuntime.jsxs("button",{onClick:()=>{m("end"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronsRight,{size:16})," ",w("moveToEnd")]})]}),I&&y&&jsxRuntime.jsx("div",{ref:_,className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",top:Q.top,left:Q.left,minWidth:"160px",zIndex:1e4},onMouseEnter:nt,onMouseLeave:ot,onContextMenu:P=>P.preventDefault(),onKeyDown:G,children:At.map(({area:P,label:N,Icon:Z})=>jsxRuntime.jsxs("button",{onClick:()=>{y(P),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(Z,{size:16})," ",N]},P))})]})})}function mi({rootRef:t,initialFocusRef:i,onClose:d,onPrintableKey:a}){return dn.useEffect(()=>{i?.current?i.current.focus():t.current&&t.current.focus();},[i,t]),dn.useCallback(e=>{if(e.key==="Escape"){e.stopPropagation(),d();return}e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&a&&a(e.key,e);},[d,a])}var fi=new Map,gi=new Map;function hi(t,i,d,a="(Blanks)"){if(t==null)return a;if(i.format&&typeof t=="number")try{let l=i.format,e=JSON.stringify(l)+"_"+d,p=gi.get(e);p||(p=new Intl.NumberFormat(d,l),gi.set(e,p));let C=p.format(t);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${C}${l.suffix||""}`:C}catch{return String(t)}return String(t)}var bi=dn__default.default.memo(({id:t,label:i,checked:d,isActive:a,bold:l,index:e,itemHeight:p,onToggle:C,onFocus:E})=>jsxRuntime.jsxs("div",{id:t,className:["kanuni-pivot-popup-item",d?"kanuni-pivot-popup-item--checked":"",a?"kanuni-pivot-popup-item--active":""].filter(Boolean).join(" "),style:{position:"absolute",top:e*p,insetInlineStart:0,insetInlineEnd:0,height:p,fontWeight:l?600:400},onClick:C,onFocus:E,role:"checkbox","aria-checked":d,tabIndex:0,children:[jsxRuntime.jsx("input",{type:"checkbox",className:"kanuni-pivot-checkbox",checked:d,readOnly:true,tabIndex:-1}),jsxRuntime.jsx("span",{className:"pivot-truncate",children:i})]})),Pr=({field:t,data:i,onApply:d,onClear:a,onClose:l,x:e,y:p,gridId:C,onConditionFilter:E})=>{let{t:S,rtl:F,locale:m}=ut(),[y,c]=dn.useState(true),[f,h]=dn.useState([]),[T,w]=dn.useState(""),[M,O]=dn.useState(new Set),[V,H]=dn.useState(0),[I,K]=dn.useState(220),[_,X]=dn.useState(0),q=dn.useRef(null),G=dn.useRef(null),k=dn.useRef(null);dn.useEffect(()=>{c(true);let L=setTimeout(()=>{if(!t.dataField&&!t.isCalculated){h([]),c(false);return}let pt=pivotgridCore.getFieldDistinctValues(t.id,C),dt;if(pt)dt=pt.map(It=>({rawStr:It.rawStr==="null"||It.rawStr==="undefined"?S("blanks"):It.rawStr,rawVal:It.rawVal,label:hi(It.rawVal,t,m,S("blanks"))}));else {let It=new Map;for(let Dt=0;Dt<i.length;Dt++){let Ot=pivotgridCore.extractGroupValue(i[Dt],t);if(Ot==="(Blank)"&&t.calculateSummaryExpression)continue;let Bt=Ot==null?S("blanks"):String(Ot);It.has(Bt)||It.set(Bt,Ot);}let ue=Array.from(It.values());if(t.dataType==="number")ue.sort((Dt,Ot)=>Number(Dt)-Number(Ot));else {let Dt=pivotgridCore.collatorFor().compare;ue.sort((Ot,Bt)=>Dt(String(Ot),String(Bt)));}dt=ue.map(Dt=>({rawStr:Dt==null?S("blanks"):String(Dt),rawVal:Dt,label:hi(Dt,t,m,S("blanks"))}));}h(dt);let Ct=!!t.filterValues&&t.filterValues.size>0;O(Ct?new Set(Array.from(t.filterValues).map(String)):new Set),c(false);let St=fi.get(t.id)||0;St>0&&setTimeout(()=>{G.current&&(G.current.scrollTop=St);},50);},10);return ()=>clearTimeout(L)},[i,t]);let $=dn.useMemo(()=>{if(!T)return f;let L=T.toLowerCase(),pt=L.replace(/,/g,"."),dt=L.replace(/\./g,","),Ct=L.replace(/[.,\s]/g,"");return f.filter(St=>{let It=St.label.toLowerCase(),ue=It.replace(/[.,\s]/g,"");return It.includes(L)||It.includes(pt)||It.includes(dt)||Ct&&ue.includes(Ct)})},[f,T]),tt=M.size===0||M.size===f.length,Q=!T,u=$.length+(Q?1:0),Y=dn.useCallback(()=>{tt&&M.size>0?O(new Set):O(new Set(f.map(L=>L.rawStr)));},[f,tt,M.size]),gt=dn.useCallback(()=>{O(new Set);},[]),v=dn.useCallback(L=>{O(pt=>{let dt=new Set(pt);return dt.has(L)?dt.delete(L):dt.add(L),dt});},[]),z=u===0?-1:Math.min(_,u-1),nt=dn.useCallback(L=>{if(Q&&L===0)return "select-all";let pt=Q?L-1:L;return `value:${$[pt]?.rawStr}`},[$,Q]),ot=L=>{w(L.target.value),X(0);},At=dn.useCallback((L,pt)=>{pt.target!==k.current&&(pt.preventDefault(),k.current?.focus(),w(dt=>`${dt}${L}`),X(0));},[]),P=mi({rootRef:q,initialFocusRef:k,onClose:l,onPrintableKey:At}),N=L=>{let pt=Math.max(0,Math.min(u-1,_+L));X(pt);let dt=nt(pt),Ct=document.getElementById(dt);Ct&&(Ct.focus(),Ct.scrollIntoView({block:"nearest"}));},Z=L=>{if(L.key==="ArrowDown"||L.key==="ArrowUp"){if(L.preventDefault(),u===0)return;N(L.key==="ArrowDown"?1:-1);return}if(L.key==="Home"&&u>0){L.preventDefault(),X(0),document.getElementById(nt(0))?.focus();return}if(L.key==="End"&&u>0){L.preventDefault(),X(u-1),document.getElementById(nt(u-1))?.focus();return}if(L.key==="Backspace"&&L.target!==k.current){L.preventDefault(),k.current?.focus(),w(pt=>pt.slice(0,-1)),X(0);return}if(L.key===" "||L.code==="Space"){if(L.preventDefault(),u>0&&z>=0)if(Q&&z===0)Y();else {let pt=Q?z-1:z,dt=$[pt];dt&&v(dt.rawStr);}return}if(L.key==="Enter"){L.preventDefault(),Mt();return}P(L);},Mt=dn.useCallback(()=>{if(M.size===0||M.size===f.length)a(t.id);else {let L=new Set;f.forEach(pt=>{M.has(pt.rawStr)&&(L.add(pt.rawStr),L.add(pt.rawVal));}),d(t.id,L,t.filterType||"include");}l();},[M,f,t.id,t.filterType,d,a,l]);dn.useEffect(()=>{y||setTimeout(()=>{k.current?.focus();},50);},[y]),dn.useEffect(()=>{let L=pt=>{q.current&&!q.current.contains(pt.target)&&l();};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[l]),dn.useEffect(()=>{let L=pt=>{pt.key==="Escape"&&l();};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[l]),dn.useEffect(()=>{if(!G.current)return;let L=new ResizeObserver(pt=>{for(let dt of pt)K(dt.contentRect.height);});return L.observe(G.current),()=>L.disconnect()},[y]);let Ht=28,$t=Math.max(0,Math.floor(V/Ht)-2),g=Math.min(u,$t+Math.ceil(I/Ht)+4),ct=jsxRuntime.jsx("div",{className:"kanuni-pivot-portal-root",children:jsxRuntime.jsxs("div",{ref:q,className:"kanuni-pivot-popup pivot-animate-zoom-in",style:{left:Math.max(10,Math.min(e,window.innerWidth-270)),top:Math.max(10,Math.min(p,window.innerHeight-370)),width:250,height:350,minWidth:200,minHeight:250,maxWidth:Math.min(600,window.innerWidth-20),maxHeight:Math.min(350,window.innerHeight-20),resize:"both",direction:F?"rtl":"ltr"},onClick:L=>L.stopPropagation(),onKeyDown:Z,role:"dialog","aria-label":S("columnFilter"),"data-datagrid-keyboard-scope":"modal",tabIndex:-1,children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-header",children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-search",children:[jsxRuntime.jsx(lucideReact.Search,{className:"kanuni-pivot-popup-search-icon",size:14}),jsxRuntime.jsx("input",{ref:k,type:"text",className:"kanuni-pivot-popup-search-input",placeholder:S("search"),value:T,onChange:ot,"aria-controls":"pivot-filter-options","aria-activedescendant":z>=0?nt(z):void 0})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-actions",children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--primary",onClick:Y,children:S("selectAll")}),jsxRuntime.jsx("button",{className:"kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--danger",onClick:gt,children:S("clearAll")})]})]}),jsxRuntime.jsx("div",{ref:G,id:"pivot-filter-options",className:"kanuni-pivot-popup-list pivot-custom-scrollbar",onScroll:L=>{H(L.currentTarget.scrollTop),fi.set(t.id,L.currentTarget.scrollTop);},children:y?jsxRuntime.jsx("div",{className:"pivot-flex pivot-items-center pivot-justify-center pivot-h-full",children:jsxRuntime.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}})}):jsxRuntime.jsxs("div",{style:{height:u*Ht,position:"relative"},children:[Array.from({length:g-$t},(L,pt)=>{let dt=$t+pt;if(Q&&dt===0)return jsxRuntime.jsx(bi,{id:"select-all",label:`(${S("selectAll")})`,checked:tt,isActive:dt===z,bold:true,index:dt,itemHeight:Ht,onToggle:Y,onFocus:()=>X(dt)},"select-all");let Ct=Q?dt-1:dt,St=$[Ct];return St?jsxRuntime.jsx(bi,{id:`value:${St.rawStr}`,label:St.label,checked:M.has(St.rawStr),isActive:dt===z,bold:false,index:dt,itemHeight:Ht,onToggle:()=>v(St.rawStr),onFocus:()=>X(dt)},St.rawStr):null}),$.length===0&&jsxRuntime.jsx("div",{style:{padding:"12px",textAlign:"center",fontSize:"12px",color:"var(--pivot-text-muted)"},children:S("noItems")})]})}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-footer",children:[E&&(t.area==="row"||t.area==="column")&&jsxRuntime.jsx("button",{type:"button",className:"kanuni-pivot-btn kanuni-pivot-btn--outline",style:{height:"28px",padding:"0 7px",marginInlineEnd:"auto",color:t.valueFilter||t.labelFilter?"var(--pivot-danger)":void 0},"data-condition-filter":"",title:`${S("conditionFilter")}\u2026`,"aria-label":`${S("conditionFilter")}\u2026`,onClick:()=>{l(),E();},children:jsxRuntime.jsx(lucideReact.Settings2,{size:14})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--outline",style:{height:"28px",padding:"0 12px",fontSize:"12px"},onClick:l,children:S("cancel")}),jsxRuntime.jsx("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--primary",style:{height:"28px",padding:"0 12px",fontSize:"12px"},onClick:Mt,children:S("ok")})]})]})});return jsxRuntime.jsx(ge,{children:ct})};function Sr({fields:t,controller:i}){let[d,a]=dn.useState(null),l=le(f=>f.setIntent),e=()=>le.getState(),p=le(f=>f.reset),C=dn.useRef({x:0,y:0});dn.useEffect(()=>{let f=h=>{C.current={x:h.clientX,y:h.clientY};};return d&&window.addEventListener("pointermove",f),()=>window.removeEventListener("pointermove",f)},[d]);let E=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:8}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:200,tolerance:8}})),S=dn.useCallback(f=>{let h=String(f.active.id);a(h),i.setDragActive(h),le.getState().setActiveId(h);},[i]),F=dn.useCallback(f=>{let{over:h}=f;if(!h){l(null,null,null),i.setDragIntent(null,null,null);return}let T=String(h.id).replace("chooser-","");if(["row","column","data","filter","chooser"].includes(T)||T.endsWith("-ghost-end")){let M=T.replace("-ghost-end","");l(null,M,"append"),i.setDragIntent(null,M,"append");return}let w=t.find(M=>M.id===T);if(w&&h.rect){let O=w.area==="chooser"?"vertical":"horizontal",V=i.calculateDropIntent(C.current.x,C.current.y,h.rect,e().intent,false,O);l(T,w.area??null,V),i.setDragIntent(T,w.area??null,V);}},[i,t,l]),m=dn.useCallback(async f=>{let{active:h,over:T}=f;if(p(),a(null),le.getState().setActiveId(null),!T){i.resetDrag();return}await i.commitDrag(String(h.id),String(T.id));},[i,p]),y=dn.useCallback(f=>{i.removeField(f);},[i]),c=dn.useCallback((f,h)=>{i.moveField(f,h);},[i]);return {activeDragId:d,sensors:E,handleDragStart:S,handleDragMove:F,handleDragEnd:m,handleRemoveField:y,handleMoveField:c}}function Rr({isOpen:t,onClose:i,status:d,title:a,messages:l,progress:e,phase:p,cancellable:C,onCancel:E}){let{t:S}=ut();if(!t)return null;let F=d==="loading"&&typeof e=="number",m=Math.max(0,Math.min(100,Math.round(e??0)));return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in"}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"400px"},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center",style:{gap:"8px"},children:[d==="loading"&&jsxRuntime.jsx("div",{style:{width:"20px",height:"20px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}}),d==="success"&&jsxRuntime.jsx(lucideReact.CheckCircle,{size:20,color:"var(--pivot-success)"}),d==="error"&&jsxRuntime.jsx(lucideReact.XCircle,{size:20,color:"var(--pivot-danger)"}),d==="warning"&&jsxRuntime.jsx(lucideReact.AlertTriangle,{size:20,color:"var(--pivot-warning)"}),jsxRuntime.jsx("h3",{className:"kanuni-pivot-modal-title",style:{margin:0},children:a})]}),jsxRuntime.jsx("button",{className:"kanuni-pivot-modal-close",onClick:i,disabled:d==="loading",children:jsxRuntime.jsx(lucideReact.X,{size:18})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",style:{maxHeight:"60vh"},children:[F&&jsxRuntime.jsxs("div",{style:{marginBottom:l.length>0?"12px":0},children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px",fontSize:"12px",color:"var(--pivot-text-muted)"},children:[jsxRuntime.jsx("span",{children:S(p||"processing")}),jsxRuntime.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[m,"%"]})]}),jsxRuntime.jsx("div",{style:{width:"100%",height:"6px",background:"var(--pivot-border)",borderRadius:"999px",overflow:"hidden"},children:jsxRuntime.jsx("div",{style:{width:`${m}%`,height:"100%",background:"var(--pivot-primary)",borderRadius:"999px",transition:"width 0.2s ease"}})})]}),l.length===0?!F&&jsxRuntime.jsx("p",{className:"pivot-text-sm pivot-text-muted",children:S("processing")}):jsxRuntime.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:"8px"},children:l.map((y,c)=>jsxRuntime.jsxs("li",{className:"pivot-flex",style:{gap:"8px",fontSize:"13px",color:"var(--pivot-text)",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{color:"var(--pivot-text-muted)",marginTop:"2px"},children:"\u2022"}),jsxRuntime.jsx("span",{children:y})]},c))})]}),d==="loading"&&C&&E&&jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-footer",children:jsxRuntime.jsx("button",{className:"kanuni-pivot-btn",onClick:E,children:S("cancel")})}),d!=="loading"&&jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-footer",children:jsxRuntime.jsx("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--primary",onClick:i,children:S("ok")})})]})]})}var xs=["string","number","date","boolean"],ys=20;function yi({preview:t,onApply:i,onCancel:d}){let{t:a}=ut(),[l,e]=dn.useState(()=>t.fields.map(m=>({...m,include:true}))),p=dn.useMemo(()=>t.sample.slice(0,ys),[t.sample]),C=l.filter(m=>m.include).length,E=(m,y)=>e(c=>c.map((f,h)=>h===m?{...f,...y}:f)),S=m=>a(`type_${m}`)||m,F=m=>m==null?"":m instanceof Date?isNaN(m.getTime())?"":m.toLocaleDateString():typeof m=="boolean"?m?"\u2713":"\u2717":String(m);return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in"}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"min(880px, 94vw)",maxHeight:"88vh",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"kanuni-pivot-modal-title",style:{margin:0},children:a("importPreviewTitle")}),jsxRuntime.jsx("div",{className:"pivot-text-sm pivot-text-muted",style:{marginTop:"2px"},children:a("importPreviewSubtitle").replace("{rows}",t.rowCount.toLocaleString()).replace("{cols}",String(C))})]}),jsxRuntime.jsx("button",{className:"kanuni-pivot-modal-close",onClick:d,children:jsxRuntime.jsx(lucideReact.X,{size:18})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",style:{overflow:"auto",flex:1},children:[t.warnings.length>0&&jsxRuntime.jsx("div",{style:{marginBottom:"12px",padding:"8px 12px",borderRadius:"var(--pivot-radius-sm)",background:"color-mix(in srgb, var(--pivot-warning) 12%, transparent)",border:"1px solid var(--pivot-warning)",fontSize:"12px",color:"var(--pivot-text)"},children:t.warnings.map((m,y)=>jsxRuntime.jsxs("div",{children:["\u2022 ",m]},y))}),jsxRuntime.jsxs("div",{style:{marginBottom:"16px"},children:[jsxRuntime.jsx("div",{className:"pivot-text-sm pivot-font-medium",style:{marginBottom:"6px"},children:a("columns")}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:l.map((m,y)=>jsxRuntime.jsxs("div",{style:{display:"grid",gridTemplateColumns:"28px 1fr 150px",gap:"10px",alignItems:"center",padding:"6px 8px",borderRadius:"var(--pivot-radius-sm)",background:m.include?"var(--pivot-surface)":"transparent",opacity:m.include?1:.5,border:"1px solid var(--pivot-border)"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:m.include,title:a("includeColumn"),onChange:c=>E(y,{include:c.target.checked})}),jsxRuntime.jsx("input",{className:"kanuni-pivot-input",value:m.caption,disabled:!m.include,onChange:c=>E(y,{caption:c.target.value}),style:{fontSize:"13px",padding:"4px 8px"}}),jsxRuntime.jsx("select",{className:"kanuni-pivot-input",value:m.dataType,disabled:!m.include,onChange:c=>E(y,{dataType:c.target.value}),style:{fontSize:"13px",padding:"4px 8px"},children:xs.map(c=>jsxRuntime.jsx("option",{value:c,children:S(c)},c))})]},m.dataField))})]}),jsxRuntime.jsxs("div",{className:"pivot-text-sm pivot-font-medium",style:{marginBottom:"6px"},children:[a("dataPreview")," ",jsxRuntime.jsxs("span",{className:"pivot-text-muted",children:["(",p.length,"/",t.rowCount.toLocaleString(),")"]})]}),jsxRuntime.jsx("div",{style:{overflow:"auto",border:"1px solid var(--pivot-border)",borderRadius:"var(--pivot-radius-sm)"},children:jsxRuntime.jsxs("table",{style:{borderCollapse:"collapse",fontSize:"12px",width:"100%"},children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsx("tr",{children:l.filter(m=>m.include).map(m=>jsxRuntime.jsxs("th",{style:{position:"sticky",top:0,textAlign:"left",padding:"6px 10px",whiteSpace:"nowrap",background:"var(--pivot-surface-header)",borderBottom:"1px solid var(--pivot-border)",color:"var(--pivot-text-header)",fontWeight:600},children:[m.caption,jsxRuntime.jsx("span",{className:"pivot-text-muted",style:{fontWeight:400,marginLeft:"6px"},children:S(m.dataType)})]},m.dataField))})}),jsxRuntime.jsx("tbody",{children:p.map((m,y)=>jsxRuntime.jsx("tr",{style:{background:y%2?"var(--pivot-surface)":"transparent"},children:l.filter(c=>c.include).map(c=>jsxRuntime.jsx("td",{style:{padding:"4px 10px",whiteSpace:"nowrap",borderBottom:"1px solid var(--pivot-border)",color:"var(--pivot-text)"},children:F(m[c.dataField])},c.dataField))},y))})]})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-btn",onClick:d,children:a("cancel")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--primary",onClick:()=>i(l),disabled:C===0,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[jsxRuntime.jsx(lucideReact.Check,{size:15})," ",a("applyImport")]})]})]})]})}function Tr({isOpen:t,onClose:i,onSave:d,defaultName:a="",title:l}){let{t:e}=ut(),[p,C]=dn.useState(a),[E,S]=dn.useState(false);if(!t)return null;let F=m=>{m.preventDefault(),p.trim()&&(d(p.trim(),E),C(""),S(false));};return jsxRuntime.jsx(ge,{children:jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay",onClick:i}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{display:"flex",flexDirection:"column",gap:"16px",padding:"24px"},children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col",style:{gap:"6px"},children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center pivot-justify-between",children:[jsxRuntime.jsx("h3",{className:"kanuni-pivot-modal-title",children:l??e("saveReport")}),jsxRuntime.jsx("button",{onClick:i,className:"kanuni-pivot-modal-close",style:{padding:"6px"},children:jsxRuntime.jsx(lucideReact.X,{size:16})})]}),jsxRuntime.jsx("p",{className:"kanuni-pivot-modal-description",children:e("saveReportDescription")})]}),jsxRuntime.jsxs("form",{onSubmit:F,className:"pivot-flex pivot-flex-col pivot-gap-4",children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col pivot-gap-2",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:e("reportName")}),jsxRuntime.jsx("input",{type:"text",autoFocus:true,className:"kanuni-pivot-input",placeholder:e("reportNamePlaceholder"),value:p,onChange:m=>C(m.target.value),required:true})]}),jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center pivot-gap-2",children:[jsxRuntime.jsx("input",{type:"checkbox",id:"isDefault",className:"kanuni-pivot-input",style:{width:"16px",height:"16px"},checked:E,onChange:m=>S(m.target.checked)}),jsxRuntime.jsx("label",{htmlFor:"isDefault",className:"kanuni-pivot-form-label",style:{margin:0,cursor:"pointer"},children:e("setAsDefault")})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",style:{marginTop:"8px",paddingTop:"16px",borderTop:"1px solid var(--pivot-border)",display:"flex",justifyContent:"flex-end",gap:"8px"},children:[jsxRuntime.jsx("button",{type:"button",onClick:i,className:"kanuni-pivot-button",children:e("cancel")}),jsxRuntime.jsxs("button",{type:"submit",disabled:!p.trim(),className:"kanuni-pivot-button kanuni-pivot-button-primary",children:[jsxRuntime.jsx(lucideReact.Save,{size:16}),e("save")]})]})]})]})]})})}var Po=class extends dn.Component{state={hasError:false,error:null};static getDerivedStateFromError(i){return {hasError:true,error:i}}componentDidCatch(i,d){this.props.onError?.(i,d);}handleReset=()=>{this.setState({hasError:false,error:null});};render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsxRuntime.jsxs("div",{style:{padding:24,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,height:"100%",color:"var(--pivot-text, #333)",backgroundColor:"var(--pivot-bg, #fff)"},children:[jsxRuntime.jsx("div",{style:{fontSize:14,fontWeight:600},children:"PivotGrid encountered an error"}),jsxRuntime.jsx("div",{style:{fontSize:12,color:"var(--pivot-text-muted, #888)",maxWidth:400,textAlign:"center"},children:this.state.error?.message}),jsxRuntime.jsx("button",{onClick:this.handleReset,style:{padding:"6px 16px",fontSize:12,borderRadius:4,border:"1px solid var(--pivot-border, #ddd)",background:"var(--pivot-surface, #f5f5f5)",cursor:"pointer"},children:"Retry"})]}):this.props.children}};function Er(){let[t,i]=dn.useState(false),d=dn.useRef(null);dn.useEffect(()=>{let l=()=>{let e=document;i(!!(document.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement));};return document.addEventListener("fullscreenchange",l),document.addEventListener("webkitfullscreenchange",l),document.addEventListener("mozfullscreenchange",l),document.addEventListener("MSFullscreenChange",l),()=>{document.removeEventListener("fullscreenchange",l),document.removeEventListener("webkitfullscreenchange",l),document.removeEventListener("mozfullscreenchange",l),document.removeEventListener("MSFullscreenChange",l);}},[]);let a=dn.useCallback(()=>{let l=d.current,e=document;!!!(document.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement)&&!t?l?.requestFullscreen?l.requestFullscreen().catch(()=>i(true)):l?.webkitRequestFullscreen?l.webkitRequestFullscreen():l?.mozRequestFullScreen?l.mozRequestFullScreen():l?.msRequestFullscreen?l.msRequestFullscreen():i(true):document.exitFullscreen&&document.fullscreenElement?document.exitFullscreen().catch(()=>i(false)):e.webkitExitFullscreen&&e.webkitFullscreenElement?e.webkitExitFullscreen():e.mozCancelFullScreen&&e.mozFullScreenElement?e.mozCancelFullScreen():e.msExitFullscreen&&e.msFullscreenElement?e.msExitFullscreen():i(false);},[t]);return {isFullscreen:t,containerRef:d,toggleFullscreen:a}}function Mr(){let[t,i]=dn.useState(false),[d,a]=dn.useState(null),[l,e]=dn.useState(null),[p,C]=dn.useState(null),[E,S]=dn.useState(null),[F,m]=dn.useState(false),[y,c]=dn.useState(null),[f,h]=dn.useState(false),[T,w]=dn.useState(void 0);return {chooserOpen:t,setChooserOpen:i,settingsFieldId:d,setSettingsFieldId:a,conditionFieldId:l,setConditionFieldId:e,contextMenu:p,setContextMenu:C,filterPopup:E,setFilterPopup:S,isPrefilterOpen:F,setIsPrefilterOpen:m,globalContextMenu:y,setGlobalContextMenu:c,isCalcModalOpen:f,setIsCalcModalOpen:h,editingCalcField:T,setEditingCalcField:w}}var Dr="default-pivot-grid",Wo=new Map,Fr=new Set;function Fs(t){let i=Wo.get(t);if(i)return i;let d=Dr;for(let a=2;Fr.has(d);a++)d=`${Dr}-${a}`;return Fr.add(d),Wo.set(t,d),d!==Dr&&console.warn(`[pivotgrid] multiple grids without gridId on this page \u2014 this one got '${d}'. Give each grid an explicit gridId for stable state persistence.`),d}function Is(t){let i=Wo.get(t);i!==void 0&&(Wo.delete(t),Fr.delete(i));}function ki(t){let i=dn.useId(),[d]=dn.useState(()=>t?Fs(i):"");return dn.useEffect(()=>{if(t)return ()=>Is(i)},[t,i]),d}function Ir(t){let i=dn.useRef(null),d=dn.useMemo(()=>new pivotgridCore.PivotController(t),[t.gridId]);return dn.useEffect(()=>{d.updateOptions(t);}),dn.useEffect(()=>(i.current&&(clearTimeout(i.current),i.current=null),()=>{i.current=setTimeout(()=>{d.dispose(),i.current=null;},0);}),[d]),d}function Yt(t,i,d=Object.is){let a=dn.useRef(void 0),l=dn.useRef(false),e=dn.useCallback(()=>{let p=i(t.getSnapshot());return l.current&&d(a.current,p)?a.current:(l.current=true,a.current=p,p)},[t,d,i]);return dn.useSyncExternalStore(t.subscribe,e,e)}var qs=t=>{let i=core.rectIntersection(t);return i.sort((d,a)=>{let l=C=>["row","column","data","filter","chooser"].includes(C)||C.endsWith("-ghost-end"),e=l(String(d.id).replace("chooser-","")),p=l(String(a.id).replace("chooser-",""));return e&&!p?1:!e&&p?-1:0}),i},js=t=>t.fields,_s=t=>t.layout,Ys=t=>t.expandedPaths,Js=t=>t.expandedColPaths,Zs=t=>t.columnWidths,Qs=t=>t.engineResult,tl=t=>t.isBuilding,el=t=>t.buildProgress??0,ol=t=>t.engineError,rl=t=>t.selectionStats,il=t=>t.reports,nl=t=>t.activeReportId,al=t=>t.importStatus,sl=t=>t.importPreview,ll=function({gridId:i,workerUrl:d,previewImport:a,data:l,rowKey:e,asyncTransactionWait:p,initialFields:C,onRefresh:E,onImportData:S,onFieldsChange:F,onLayoutChange:m,customContextMenuItems:y,chartIntegrationOptions:c,onChartSync:f,onToggleChart:h,onChartStateLoaded:T,stateStoring:w,toolbar:M,registry:O,serverSource:V,onCellClick:H,onFieldMove:I,onBeforePivotCalculate:K,onAfterPivotCalculate:_,onExporting:X,onCellPrepared:q,onError:G,theme:k,striped:$,defaultColumnWidths:tt,keyboardNavigation:Q,disabled:u,renderCalculatedFieldModal:Y,renderPrefilterBuilder:gt,renderNodeContextMenu:v,advancedExport:z,upgradeUrl:nt,fields:ot,layout:At},P){let{t:N,locale:Z}=ut(),Mt=i||w?.storageKey,Ht=ki(!Mt),$t=Mt||Ht,g=Ir({gridId:$t,stateStoring:w,workerUrl:d,previewImport:a,data:l,rowKey:e,asyncTransactionWait:p,initialFields:C||ot||[],controlledFields:ot,controlledLayout:At,chartIntegrationOptions:c,registry:O,serverSource:V,locale:Z,onRefresh:E,onImportData:S,onFieldsChange:F,onLayoutChange:m,onFieldMove:I,onBeforePivotCalculate:K,onAfterPivotCalculate:_,onExporting:X,onError:G,onChartStateLoaded:T});g.setEnterpriseEdition(z===true);let ct=Yt(g,js),[L,pt]=dn.useState(""),dt=dn.useRef(ct);dn.useEffect(()=>{let o=dt.current;if(dt.current=ct,o===ct)return;let D=pivotgridCore.pivotChangeAnnouncement(o,ct,N);D&&pt(J=>pivotgridCore.nextLiveText(J,D));},[ct,N]);let Ct=Yt(g,_s),St=Yt(g,Ys),It=Yt(g,Js),ue=Yt(g,Zs),Dt=Yt(g,Qs),Ot=Yt(g,tl),Bt=Yt(g,el),lt=Yt(g,ol),it=Yt(g,rl),Ke=Yt(g,il),yt=Yt(g,nl),be=Yt(g,al),ee=Yt(g,sl),{chooserOpen:Ue,setChooserOpen:ve,settingsFieldId:Te,setSettingsFieldId:Xe,conditionFieldId:oe,setConditionFieldId:Ie,contextMenu:Gt,setContextMenu:zt,filterPopup:re,setFilterPopup:me,isPrefilterOpen:qe,setIsPrefilterOpen:ze,globalContextMenu:xe,setGlobalContextMenu:Lt,isCalcModalOpen:Le,setIsCalcModalOpen:ye,editingCalcField:je,setEditingCalcField:Ne}=Mr(),{activeDragId:uo,sensors:_e,handleDragStart:Ae,handleDragMove:Ee,handleDragEnd:So,handleRemoveField:Me,handleMoveField:Ye}=Sr({fields:ct,controller:g}),{isFullscreen:Kt,containerRef:vo,toggleFullscreen:Je}=Er(),[Ze,Ko]=dn.useState(null),Uo=dn.useCallback(o=>{vo.current=o,Ko(o);},[vo]),Xo=Kt?Ze:typeof document<"u"?document.body:null,[Qe,to]=dn.useState(null);dn.useImperativeHandle(P,()=>({exportData:(o,D)=>fo(o,D),expandAll:()=>g.expandAll(),collapseAll:()=>g.collapseAll(),getState:()=>g.getState(),setFields:o=>g.setFields(o),refreshEngine:()=>g.refreshEngine(),getRawData:()=>g.getRawData(),applyTransaction:o=>g.applyTransaction(o),applyTransactionAsync:(o,D)=>g.applyTransactionAsync(o,D),flushAsyncTransactions:()=>g.flushAsyncTransactions(),getEngineResult:()=>g.getEngineResult(),getCell:(o,D)=>g.getCell(o,D),setColumnWidths:o=>g.setColumnWidths(o),getController:()=>g}),[g]);let Ro=er(Dt,ct,St,c);dn.useEffect(()=>{f&&f(Ro);},[Ro,f]);let To=dn.useMemo(()=>ct.filter(o=>o.area==="row").sort((o,D)=>(o.areaIndex||0)-(D.areaIndex||0)),[ct]),qo=dn.useMemo(()=>ct.filter(o=>o.area==="column").sort((o,D)=>(o.areaIndex||0)-(D.areaIndex||0)),[ct]),No=dn.useMemo(()=>ct.filter(o=>o.area==="data").sort((o,D)=>(o.areaIndex||0)-(D.areaIndex||0)),[ct]),De=dn.useMemo(()=>ct.filter(o=>o.area==="filter").sort((o,D)=>(o.areaIndex||0)-(D.areaIndex||0)),[ct]),eo=dn.useCallback((o,D)=>{g.sortField(o,D);},[g]),mo=dn.useCallback((o,D)=>{Gt?.fieldId&&g.sortFieldBySummary(o,Gt.fieldId,D);},[g,Gt]),oo=dn.useCallback(()=>{g.clearAllSorting();},[g]),fe=dn.useCallback(o=>{g.updateField(o),Xe(null);},[g,Xe]),Eo=dn.useCallback(o=>{u||g.toggleExpanded(o);},[g,u]),Mo=dn.useMemo(()=>u?void 0:o=>{H&&H(g.resolveCellClick(o));},[g,u,H]),Do=dn.useMemo(()=>u?void 0:(o,D)=>Lt({x:o,y:D}),[u,Lt]),ro=dn.useMemo(()=>u?void 0:o=>g.setColumnWidths(o),[g,u]),io=dn.useCallback(o=>g.setSelectionStats(o),[g]),Fo=dn.useCallback((o,D,J)=>{g.applyFilter(o,D,J);},[g]),Io=dn.useCallback(o=>{g.clearFilter(o);},[g]),Fe=dn.useMemo(()=>re&&ct.find(o=>o.id===re.fieldId)||null,[re,ct]),jo=dn.useCallback(()=>{g.expandAll();},[g]),fo=dn.useCallback((o,D)=>g.exportData(o,D).catch(J=>{let se=J instanceof Error?J:new Error(String(J));G?G(se):console.error(se);}),[g,G]),ae=dn.useCallback(o=>{fo(o,{applyFilters:true});},[fo]),r=dn.useMemo(()=>({initializing:N("initializing"),processing:N("processing"),importError:N("importError"),importWarning:N("importWarning"),importSuccess:N("importSuccess"),cancelled:N("importCancelled"),cancel:N("cancel"),dataImportUnsupported:N("dataImportUnsupported")}),[N]),n=dn.useCallback(async o=>{await g.importFile(o,r);},[g,r]),s=dn.useCallback(async o=>{await g.importFiles(o,r);},[g,r]),b=dn.useCallback(async()=>{let o="";try{o=await navigator.clipboard.readText();}catch{g.showImportStatus("error",N("importError"),[N("clipboardDenied")]);return}if(!o||!o.trim()){g.showImportStatus("warning",N("importWarning"),[N("clipboardEmpty")]);return}await g.importText(o,r);},[g,r,N]),[x,R]=dn.useState(false),U=dn.useRef(0),j=o=>Array.from(o.dataTransfer?.types??[]).includes("Files"),st=dn.useCallback(o=>{j(o)&&(o.preventDefault(),U.current+=1,R(true));},[]),et=dn.useCallback(o=>{j(o)&&(o.preventDefault(),o.dataTransfer.dropEffect="copy");},[]),W=dn.useCallback(o=>{j(o)&&(U.current=Math.max(0,U.current-1),U.current===0&&R(false));},[]),ft=dn.useCallback(o=>{if(!j(o))return;o.preventDefault(),U.current=0,R(false);let D=Array.from(o.dataTransfer.files??[]);D.length>0&&g.importFiles(D,r);},[g,r]),Rt=dn.useCallback(()=>{to({isOpen:true,defaultName:"",title:N("saveNewView")});},[N]),jt=dn.useCallback((o,D)=>{g.saveReport(o,D),to(null);},[g]),ie=dn.useCallback(()=>{g.updateCurrentReport();},[g]),Xt=dn.useCallback(()=>{let o=Ke.find(D=>D.id===yt);o&&to({isOpen:true,defaultName:`${o.name} (Copy)`,title:N("saveAsView")});},[yt,Ke,N]),_t=dn.useCallback(o=>{g.loadReport(o);},[g]),Zt=dn.useCallback(o=>{g.deleteReport(o);},[g]),Wt=dn.useCallback(o=>{g.setDefaultReport(o);},[g]);return jsxRuntime.jsx(Qo,{theme:k,className:$?"kanuni-pivot-striped":"",style:{position:"relative",width:"100%",height:"100%"},children:jsxRuntime.jsx(core.DndContext,{sensors:u?[]:_e,collisionDetection:qs,autoScroll:false,accessibility:{screenReaderInstructions:{draggable:N("fieldChipKeys")}},onDragStart:Ae,onDragMove:Ee,onDragEnd:So,onDragCancel:o=>{So({...o,over:null});},children:jsxRuntime.jsx(ho.Provider,{value:Xo,children:jsxRuntime.jsxs("div",{ref:Uo,className:`kanuni-pivot-wrapper pivot-flex pivot-flex-col ${Kt?"pivot-is-fullscreen":""}`,onDragEnter:st,onDragOver:et,onDragLeave:W,onDrop:ft,style:{position:Kt?"fixed":"relative",inset:Kt?0:void 0,width:Kt?void 0:"100%",height:Kt?void 0:"100%",zIndex:Kt?99999:"auto",margin:Kt?0:"auto",padding:Kt?0:"auto",maxWidth:Kt?"none":"auto",maxHeight:Kt?"none":"auto",backgroundColor:Kt?"var(--pivot-bg)":"transparent"},children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-live",role:"status","aria-live":"polite",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:L}),jsxRuntime.jsxs("div",{className:"pivot-grid pivot-flex-1 pivot-flex pivot-flex-col pivot-relative",style:{height:"100%",minHeight:0,width:"100%",overflow:"hidden",backgroundColor:"var(--pivot-bg)",border:Kt?"none":"1px solid var(--pivot-border)",borderRadius:Kt?"0":"var(--pivot-radius-md)",userSelect:"none"},children:[x&&jsxRuntime.jsx("div",{className:"pivot-animate-fade-in",style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",background:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"2px dashed var(--pivot-primary)",borderRadius:"var(--pivot-radius-md)"},children:jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px 20px",borderRadius:"var(--pivot-radius-md)",background:"var(--pivot-surface)",color:"var(--pivot-text)",boxShadow:"var(--pivot-shadow-lg, 0 8px 24px rgba(0,0,0,0.18))",fontSize:"14px",fontWeight:600},children:[jsxRuntime.jsx(lucideReact.Upload,{size:18,color:"var(--pivot-primary)"}),N("dropToImport")]})}),Ct.showFilterArea!==false&&jsxRuntime.jsx(ir,{filterFields:De,onRemoveField:Me,onFilterClick:(o,D,J)=>me({x:o,y:D,fieldId:J}),onContextMenu:(o,D,J,se)=>zt({x:o,y:D,fieldId:J,colPath:se}),onSort:(o,D)=>eo(o,D),onGlobalContextMenu:(o,D)=>Lt({x:o,y:D}),onMoveField:u?void 0:Ye}),jsxRuntime.jsx("div",{className:"pivot-flex pivot-flex-1 pivot-overflow-hidden pivot-relative",style:{minHeight:0},children:jsxRuntime.jsx("div",{className:"pivot-flex-1 pivot-flex pivot-flex-col pivot-overflow-hidden pivot-relative",style:{minHeight:0},children:Dt?jsxRuntime.jsx(cr,{onMoveField:u?void 0:Ye,engineResult:Dt,isBuilding:Ot,buildProgress:Bt,rowFields:To,colFields:qo,dataFields:No,layout:Ct,expandedPaths:St,allExpanded:St.has("*"),onToggleExpand:Eo,onExpandPaths:u?()=>{}:o=>g.expandPaths(o),onCollapsePaths:u?()=>{}:o=>g.collapsePaths(o),expandedColPaths:It,allColExpanded:It.has("*"),onToggleColExpand:u?()=>{}:o=>g.toggleColExpanded(o),onExpandColPaths:u?()=>{}:o=>g.expandColPaths(o),onCollapseColPaths:u?()=>{}:o=>g.collapseColPaths(o),columnWidths:ue,defaultColumnWidths:tt,onColumnWidthsChange:ro,onSelectionStatsChange:io,registry:O,keyboardNavigation:Q,onCellPrepared:q,disabled:u,renderNodeContextMenu:v,onCellClick:Mo,onContextMenu:u?void 0:(o,D,J,se)=>zt({x:o,y:D,fieldId:J,colPath:se}),onFilterClick:u?void 0:(o,D,J)=>me({x:o,y:D,fieldId:J}),onRemoveField:u?()=>{}:Me,onSort:u?void 0:(o,D)=>eo(o,D),onGlobalContextMenu:Do}):lt?jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col pivot-items-center pivot-justify-center pivot-h-full pivot-gap-4 pivot-text-danger",style:{backgroundColor:"color-mix(in srgb, var(--pivot-danger) 5%, transparent)",padding:"16px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{backgroundColor:"color-mix(in srgb, var(--pivot-danger) 20%, transparent)",padding:"12px",borderRadius:"9999px"},children:jsxRuntime.jsx(lucideReact.X,{size:24,color:"var(--pivot-danger)"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"pivot-font-bold pivot-text-lg",style:{marginBottom:"4px"},children:N("error")}),jsxRuntime.jsx("p",{className:"pivot-text-sm",style:{opacity:.8,maxWidth:"28rem"},children:lt.message||N("systemError")})]})]}):jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col pivot-items-center pivot-justify-center pivot-h-full pivot-text-muted pivot-gap-4",children:[jsxRuntime.jsx("div",{style:{animation:"datagrid-spin 1s linear infinite",borderRadius:"50%",height:"32px",width:"32px",borderBottom:"2px solid var(--pivot-primary)",borderRight:"2px solid transparent",borderTop:"2px solid transparent",borderLeft:"2px solid transparent"}}),jsxRuntime.jsx("span",{className:"pivot-text-sm pivot-font-medium",children:N(Ot?"initializing":"loading")}),Ot&&jsxRuntime.jsxs("div",{style:{width:220,display:"flex",flexDirection:"column",gap:6,alignItems:"center"},children:[jsxRuntime.jsx("div",{style:{width:"100%",height:6,borderRadius:999,overflow:"hidden",backgroundColor:"color-mix(in srgb, var(--pivot-border) 60%, transparent)"},children:jsxRuntime.jsx("div",{style:{width:`${Math.max(0,Math.min(100,Bt))}%`,height:"100%",borderRadius:999,backgroundColor:"var(--pivot-primary)",transition:"width 160ms ease-out"}})}),jsxRuntime.jsxs("span",{className:"pivot-text-xs pivot-font-semibold",style:{color:"var(--pivot-text)"},children:[Math.round(Bt),"%"]})]})]})})}),Ct.showFooter!==false&&jsxRuntime.jsx(mr,{toolbarConfig:M,fieldChooserOpen:Ue,onToggleFieldChooser:()=>ve(!Ue),onAddCalculatedField:Y?()=>{Ne(void 0),ye(true);}:void 0,onOpenPrefilter:gt?()=>ze(true):void 0,onToggleChart:h,onExpandAll:jo,onCollapseAll:()=>g.collapseAll(),onRefresh:E,onExport:ae,onImportFile:n,onImportFiles:s,onPasteImport:b,reports:Ke,activeReportId:yt,onSaveNewReport:Rt,onUpdateCurrentReport:ie,onSaveAsReport:Xt,onLoadReport:_t,onDeleteReport:Zt,onSetDefaultReport:Wt,onGlobalContextMenu:(o,D)=>Lt({x:o,y:D}),selectionStats:it,advancedExport:z,upgradeUrl:nt,isFullscreen:Kt,onToggleFullscreen:Je})]}),Gt&&jsxRuntime.jsx(kr,{x:Gt.x,y:Gt.y,field:ct.find(o=>o.id===Gt.fieldId),colPath:Gt.colPath,rowFields:To,onClose:()=>zt(null),onSort:o=>eo(Gt.fieldId,o),onSortBySummary:mo,onClearAllSorting:oo,onHide:()=>Me(Gt.fieldId),onSettings:()=>{Xe(Gt.fieldId);},onMoveField:o=>Ye(Gt.fieldId,o),onMoveToArea:o=>g.changeFieldArea(Gt.fieldId,o),onShowFieldChooser:()=>ve(true),onEditCalculatedField:()=>{Ne(ct.find(o=>o.id===Gt.fieldId)),ye(true);},onConditionFilter:()=>Ie(Gt.fieldId),customContextMenuItems:y?y(ct.find(o=>o.id===Gt.fieldId)):void 0}),Te&&jsxRuntime.jsx(hr,{field:ct.find(o=>o.id===Te),onClose:()=>Xe(null),onSave:fe}),oe&&ct.some(o=>o.id===oe)&&jsxRuntime.jsx(li,{field:ct.find(o=>o.id===oe),dataFields:No,onClose:()=>Ie(null),onSave:o=>{g.updateField(o),Ie(null);}}),re&&Fe&&jsxRuntime.jsx(Pr,{field:Fe,data:g.getRawData(),onApply:Fo,onClear:Io,onClose:()=>me(null),x:re.x,y:re.y,gridId:$t,onConditionFilter:()=>Ie(Fe.id)}),Y&&Y({isOpen:Le,onClose:()=>{ye(false),Ne(void 0);},fields:ct,editingField:je,onSave:o=>{je?g.updateField(o):g.setFields([...ct,o]),ye(false),Ne(void 0);},onDeleteField:o=>g.deleteField(o)}),gt&>({isOpen:qe,onClose:()=>ze(false),fields:ct,initialPrefilter:Ct.prefilter,onApply:o=>g.setLayout({prefilter:o})}),jsxRuntime.jsx(Rr,{isOpen:be.isOpen,status:be.status,title:be.title,messages:be.messages,progress:be.progress,phase:be.phase,cancellable:be.cancellable,onCancel:()=>g.cancelImport(),onClose:()=>g.closeImportStatus()}),ee&&jsxRuntime.jsx(yi,{preview:ee,onApply:o=>g.commitImport(o,r),onCancel:()=>g.cancelImportPreview()}),Ue&&jsxRuntime.jsx(si,{fields:ct,onClose:()=>ve(false),onRemoveField:Me,onDeleteField:o=>g.deleteField(o),onChangeFieldArea:(o,D)=>{g.changeFieldArea(o,D);},onShowFields:o=>g.showFields(o),onFilterClick:(o,D)=>me({x:o.clientX,y:o.clientY,fieldId:D.id})}),jsxRuntime.jsx(core.DragOverlay,{dropAnimation:null,children:uo?jsxRuntime.jsx("div",{className:"pivot-flex pivot-items-center pivot-gap-2 pivot-font-semibold pivot-truncate",style:{padding:"8px 12px",backgroundColor:"var(--pivot-surface)",border:"2px solid var(--pivot-primary)",boxShadow:"var(--pivot-shadow-xl)",borderRadius:"var(--pivot-border-radius)",fontSize:"14px",opacity:.9,cursor:"grabbing",transform:"scale(1.05)",transformOrigin:"0 0",pointerEvents:"none"},children:jsxRuntime.jsx("span",{className:"pivot-truncate",style:{maxWidth:"150px",color:"var(--pivot-text)"},children:ct.find(o=>o.id===uo)?.caption||"Field"})}):null}),Qe&&jsxRuntime.jsx(Tr,{isOpen:Qe.isOpen,title:Qe.title,defaultName:Qe.defaultName,onClose:()=>to(null),onSave:jt}),xe&&jsxRuntime.jsx(ge,{children:jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"pivot-fixed",style:{position:"fixed",inset:0,zIndex:300},onPointerDown:()=>Lt(null),onContextMenu:o=>{o.preventDefault(),Lt(null);}}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",zIndex:301,width:"224px",fontSize:"14px",left:Math.min(xe.x,typeof window<"u"?window.innerWidth-224:xe.x),top:Math.min(xe.y,typeof window<"u"?window.innerHeight-200:xe.y)},children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:N("viewOptions")}),jsxRuntime.jsxs("button",{className:"pivot-w-full pivot-flex pivot-items-center pivot-justify-between",style:{padding:"6px 12px",textAlign:"left"},onMouseEnter:o=>o.currentTarget.style.backgroundColor="var(--pivot-surface-hover)",onMouseLeave:o=>o.currentTarget.style.backgroundColor="transparent",onClick:()=>{g.setLayout({showFilterArea:Ct.showFilterArea===false}),Lt(null);},children:[jsxRuntime.jsx("span",{children:N("filterArea")}),jsxRuntime.jsx("span",{className:"pivot-text-xs pivot-text-muted pivot-font-medium",children:Ct.showFilterArea===false?N("show"):N("hide")})]}),jsxRuntime.jsxs("button",{className:"pivot-w-full pivot-flex pivot-items-center pivot-justify-between",style:{padding:"6px 12px",textAlign:"left"},onMouseEnter:o=>o.currentTarget.style.backgroundColor="var(--pivot-surface-hover)",onMouseLeave:o=>o.currentTarget.style.backgroundColor="transparent",onClick:()=>{g.setLayout({showFooter:Ct.showFooter===false}),Lt(null);},children:[jsxRuntime.jsx("span",{children:N("footerArea")}),jsxRuntime.jsx("span",{className:"pivot-text-xs pivot-text-muted pivot-font-medium",children:Ct.showFooter===false?N("show"):N("hide")})]})]})]})})]})})})})},pl=dn.forwardRef(ll),dl=function(i,d){let{locale:a,dictionary:l,rtl:e,onError:p,...C}=i;return jsxRuntime.jsx(tr,{locale:a,dictionary:l,rtl:e,children:jsxRuntime.jsx(Po,{onError:p,children:jsxRuntime.jsx(pl,{...C,onError:p,ref:d})})})},cl=dn.forwardRef(dl);Object.defineProperty(exports,"defaultPivotLayout",{enumerable:true,get:function(){return pivotgridCore.defaultPivotLayout}});exports.BasePivotGrid=cl;exports.PivotAreaStrips=ir;exports.PivotConfigProvider=tr;exports.PivotContextMenu=kr;exports.PivotErrorBoundary=Po;exports.PivotFieldList=Be;exports.PivotFieldSettingsDialog=hr;exports.PivotFooter=mr;exports.PivotGridBody=cr;exports.PivotHeaderFilterPopup=Pr;exports.PivotImportStatusModal=Rr;exports.PivotNodeContextMenu=nr;exports.PivotPortal=ge;exports.PivotPortalContext=ho;exports.PivotReportMenu=ur;exports.PivotReportSaveModal=Tr;exports.PivotThemeProvider=Qo;exports.usePivotChartSync=er;exports.usePivotConfig=ut;exports.usePivotContextMenu=Mr;exports.usePivotController=Ir;exports.usePivotControllerStore=Yt;exports.usePivotDnD=Sr;exports.usePivotFullscreen=Er;
|
|
1
|
+
'use strict';var un=require('react'),reactDom=require('react-dom'),jsxRuntime=require('react/jsx-runtime'),pivotgridCore=require('@kanunilabs/pivotgrid-core'),lucideReact=require('lucide-react'),core=require('@dnd-kit/core'),zustand=require('zustand');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var un__default=/*#__PURE__*/_interopDefault(un);var xo=un.createContext(null);var Br=un.createContext({}),Gr=()=>un.useContext(Br);function er({theme:t,className:r="",style:c={},children:a}){let l=un.useMemo(()=>{if(!t)return {};let e={};t.background&&(e["--pivot-bg"]=t.background),t.surface&&(e["--pivot-surface"]=t.surface),t.surfaceHover&&(e["--pivot-surface-hover"]=t.surfaceHover),t.surfaceHeader&&(e["--pivot-surface-header"]=t.surfaceHeader);let p=t.headerBackground||t.surfaceHeader;return p&&(e["--pivot-header-bg"]=p),t.headerText&&(e["--pivot-header-text"]=t.headerText),t.border&&(e["--pivot-border"]=t.border),t.text&&(e["--pivot-text"]=t.text),t.textMuted&&(e["--pivot-text-muted"]=t.textMuted),t.textHeader&&(e["--pivot-text-header"]=t.textHeader),t.primary&&(e["--pivot-primary"]=t.primary),t.primaryForeground&&(e["--pivot-primary-foreground"]=t.primaryForeground),t.success&&(e["--pivot-success"]=t.success),t.danger&&(e["--pivot-danger"]=t.danger),t.warning&&(e["--pivot-warning"]=t.warning),t.info&&(e["--pivot-info"]=t.info),t.totalBackground&&(e["--pivot-total-bg"]=t.totalBackground),t.stripeBackground&&(e["--pivot-stripe-bg"]=t.stripeBackground),t.groupBorder&&(e["--pivot-group-border"]=t.groupBorder),t.iconActive&&(e["--pivot-icon-active"]=t.iconActive),e},[t]);return jsxRuntime.jsx(Br.Provider,{value:{theme:t,themeVariables:l},children:jsxRuntime.jsx("div",{className:`kanuni-pivot-root ${r}`,"data-theme":t?.id,style:{...l,...c},children:a})})}function be({children:t}){let r=un.useContext(xo),[c,a]=un.useState(false),{theme:l,themeVariables:e}=Gr();if(un.useEffect(()=>{a(true);},[]),!c)return null;let p=r||(typeof document<"u"?document.body:null);return p?reactDom.createPortal(jsxRuntime.jsx("div",{className:"kanuni-pivot-root kanuni-pivot-portal-container","data-theme":l?.id,style:e,children:t}),p):null}var en={locale:"en",dictionary:pivotgridCore.en,t:t=>pivotgridCore.en[t]||t,rtl:false},Vr=un.createContext(en),or=({children:t,locale:r="en",dictionary:c,rtl:a})=>{let l=un.useMemo(()=>{let e=pivotgridCore.en;r==="tr"?e=pivotgridCore.tr:r==="ar"?e=pivotgridCore.ar:r==="de"?e=pivotgridCore.de:r==="fr"?e=pivotgridCore.fr:r==="es"?e=pivotgridCore.es:r==="it"?e=pivotgridCore.it:r==="pt"?e=pivotgridCore.pt:r==="ru"?e=pivotgridCore.ru:r==="zh-CN"?e=pivotgridCore.zhCN:r==="ja"?e=pivotgridCore.ja:r==="ko"&&(e=pivotgridCore.ko);let p={...pivotgridCore.en,...e,...c};return {locale:r,dictionary:p,t:P=>p[P]||P,rtl:a!==void 0?a:r==="ar"}},[r,c,a]);return jsxRuntime.jsx(Vr.Provider,{value:l,children:jsxRuntime.jsx("div",{dir:l.rtl?"rtl":"ltr",style:{width:"100%",height:"100%"},children:t})})},mt=()=>un.useContext(Vr);function Kr(t,r){let[c,a]=un.useState(t);return un.useEffect(()=>{let l=setTimeout(()=>{a(t);},r);return ()=>clearTimeout(l)},[t,r]),c}function rr(t,r,c,a={}){let l=Kr(t,150),e=Kr(c,150),{locale:p}=mt(),C=un.useRef(false);return un.useMemo(()=>a.transformer?!l||!l.cellMatrix?{chartData:[],chartSeries:[]}:a.transformer(l,r,e,p,a):(!C.current&&Object.keys(a).length>0&&(C.current=true,console.warn("[pivotgrid] chartIntegrationOptions has no `transformer`, so the chart stays empty. Pass ChartDataTransformer.transform (Enterprise) or your own transformer.")),{chartData:[],chartSeries:[]}),[l,e,r,a,p])}var ue=zustand.create(t=>({activeId:null,targetId:null,targetArea:null,intent:null,setIntent:(r,c,a)=>t(l=>l.targetId===r&&l.targetArea===c&&l.intent===a?l:{targetId:r,targetArea:c,intent:a}),setActiveId:r=>t({activeId:r}),reset:()=>t({targetId:null,targetArea:null,intent:null,activeId:null})}));var nr=null;function yo(t,r){nr={id:t,root:r};}var fn={row:"rowArea",column:"columnArea",data:"dataArea",filter:"filterArea"};function Ho({area:t,title:r,icon:c,fields:a,onRemoveField:l,onFilterClick:e,onContextMenu:p,onSort:C,onMoveField:M}){let{setNodeRef:P}=core.useDroppable({id:t}),{setNodeRef:F}=core.useDroppable({id:`${t}-ghost-end`}),u=ue(),d=u.targetArea===t&&u.intent==="append",{t:v}=mt();return jsxRuntime.jsxs("div",{ref:P,className:"kanuni-pivot-area-dropzone","data-drop-id":t,tabIndex:-1,children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-area-header",children:[c,r]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-area-content",children:[a.length===0&&jsxRuntime.jsx("span",{className:"pivot-text-xs pivot-text-muted",style:{fontStyle:"italic",padding:"0 8px"},children:v("dropHere")}),a.map(h=>jsxRuntime.jsx($o,{field:h,siblings:a,onMove:M,onRemove:l,onFilterClick:e,onContextMenu:p,onSort:C},h.id)),jsxRuntime.jsx("div",{ref:F,style:{flex:1,minWidth:"40px",minHeight:"24px",borderRadius:"var(--pivot-border-radius-sm)",transition:"background-color 0.2s",backgroundColor:d?"color-mix(in srgb, var(--pivot-primary) 10%, transparent)":"transparent",boxShadow:d?"inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)":"none"},children:d&&a.length>0&&jsxRuntime.jsx("div",{style:{width:"4px",height:"100%",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginLeft:"4px"}})})]})]})}function $o({field:t,siblings:r,onMove:c,onRemove:a,onFilterClick:l,onContextMenu:e,onSort:p}){let{attributes:C,listeners:M,setNodeRef:P,transform:F,isDragging:u}=core.useDraggable({id:t.id}),{setNodeRef:y}=core.useDroppable({id:t.id}),{rtl:d,t:v}=mt(),h=un.useRef(null),S=w=>{P(w),y(w),h.current=w;};un.useLayoutEffect(()=>{let w=nr,D=h.current;!w||w.id!==t.id||!D||w.root&&!w.root.contains(D)||(nr=null,D.focus({preventScroll:true}));});let k=r??[t],I=Math.max(0,k.findIndex(w=>w.id===t.id)),O=v(fn[t.area??""]??"rowArea"),V=v("fieldChipLabel").replace("{0}",t.caption||t.id).replace("{1}",O).replace("{2}",String(I+1)).replace("{3}",String(k.length)),H=()=>{if(!p)return;let w=t.sortOrder==="asc"?"desc":t.sortOrder==="desc"?void 0:"asc";p(t.id,w);},z=()=>h.current?.closest(".kanuni-pivot-wrapper")??null,X=w=>{if(!w)return;(z()??document).querySelector(`.kanuni-pivot-field-chip[data-drop-id="${w}"]`)?.focus({preventScroll:true});},Y=w=>{let D=w.ctrlKey||w.metaKey,bt=d?"ArrowRight":"ArrowLeft",f=d?"ArrowLeft":"ArrowRight",T=!!c&&t.area!=="filter",K=true;if(w.key==="Enter"||w.key===" ")H();else if(D&&T&&(w.key===bt||w.key==="ArrowUp"))I>0&&(yo(t.id,z()),c(t.id,"left"));else if(D&&T&&(w.key===f||w.key==="ArrowDown"))I<k.length-1&&(yo(t.id,z()),c(t.id,"right"));else if(D&&T&&w.key==="Home")I>0&&(yo(t.id,z()),c(t.id,"start"));else if(D&&T&&w.key==="End")I<k.length-1&&(yo(t.id,z()),c(t.id,"end"));else if(!D&&(w.key===bt||w.key===f))X(k[I+(w.key===bt?-1:1)]?.id);else if(w.key==="Delete"||w.key==="Backspace"){let ot=k[I+1]??k[I-1];ot&&yo(ot.id,z()),a(t.id);}else if(w.altKey&&w.key==="ArrowDown"){let ot=w.currentTarget.getBoundingClientRect();l(d?ot.right:ot.left,ot.bottom,t.id);}else if(w.key==="F10"&&w.shiftKey||w.key==="ContextMenu"){if(!e)return;let ot=w.currentTarget.getBoundingClientRect();e(d?ot.right:ot.left,ot.bottom,t.id,void 0);}else K=false;K&&(w.preventDefault(),w.stopPropagation());},j=ue(),_=j.targetId===t.id,G=_&&j.intent==="before",U=_&&j.intent==="after",L={transform:F?`translate3d(${d?-F.x:F.x}px, ${F.y}px, 0)`:void 0,cursor:u?"grabbing":"pointer",position:"relative"},R=!!t.filterValues&&t.filterValues.size>0||!!t.valueFilter||!!t.labelFilter,et=w=>{if(w.stopPropagation(),!p)return;let D=t.sortOrder==="asc"?"desc":t.sortOrder==="desc"?void 0:"asc";p(t.id,D);};return jsxRuntime.jsxs("div",{ref:S,className:`kanuni-pivot-field-chip ${u?"is-dragging":""}`,style:L,...M,...C,role:"button",tabIndex:0,"aria-roledescription":void 0,"aria-label":V,"aria-keyshortcuts":"Control+ArrowLeft Control+ArrowRight Control+Home Control+End Delete Alt+ArrowDown Shift+F10","aria-description":v("fieldChipKeys"),"data-drop-id":t.id,onKeyDown:Y,onClick:et,onContextMenu:w=>{w.stopPropagation(),e&&(w.preventDefault(),e(w.clientX,w.clientY,t.id,void 0));},children:[G&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",insetInlineStart:-4,top:-4,bottom:-4,width:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,top:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderTop:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,bottom:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderBottom:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-1,top:0,bottom:0,width:2,backgroundColor:"var(--pivot-primary)"}})]}),U&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",insetInlineEnd:-4,top:-4,bottom:-4,width:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,top:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderTop:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-4,bottom:0,width:0,height:0,borderInlineStart:"4px solid transparent",borderInlineEnd:"4px solid transparent",borderBottom:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",insetInlineStart:-1,top:0,bottom:0,width:2,backgroundColor:"var(--pivot-primary)"}})]}),jsxRuntime.jsx("span",{className:"pivot-truncate",style:{maxWidth:"120px",userSelect:"none"},children:t.caption||t.id}),t.sortOrder==="asc"&&jsxRuntime.jsx(lucideReact.ArrowUp,{size:12,color:"var(--pivot-primary)"}),t.sortOrder==="desc"&&jsxRuntime.jsx(lucideReact.ArrowDown,{size:12,color:"var(--pivot-primary)"}),t.area==="data"&&t.summaryType&&jsxRuntime.jsx("span",{style:{fontSize:"10px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 45%, transparent)",color:"var(--pivot-text)",padding:"0 4px",borderRadius:"4px",fontWeight:700,textTransform:"uppercase"},children:t.summaryType}),jsxRuntime.jsxs("div",{className:`kanuni-pivot-field-chip-actions ${R?"is-filtered":""}`,"aria-hidden":"true",children:[jsxRuntime.jsx("span",{className:"kanuni-pivot-chip-btn",onPointerDown:w=>w.stopPropagation(),onClick:w=>{w.stopPropagation(),l(w.clientX,w.clientY,t.id);},title:v("filterField"),style:{color:R?"var(--pivot-danger)":"inherit"},children:jsxRuntime.jsx(lucideReact.Filter,{size:12,fill:R?"currentColor":"none"})}),jsxRuntime.jsx("span",{className:"kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger",onPointerDown:w=>w.stopPropagation(),onClick:w=>{w.stopPropagation(),a(t.id);},title:v("removeField"),children:jsxRuntime.jsx(lucideReact.X,{size:12})})]})]})}function ar({filterFields:t,onRemoveField:r,onFilterClick:c,onContextMenu:a,onSort:l,onGlobalContextMenu:e,onMoveField:p}){let{t:C,locale:M}=mt(),P=un__default.default.useMemo(()=>{let F=new Map;return t.map(y=>{let d=y.caption||y.id||"";if(F.has(d)){let v=F.get(d)+1;return F.set(d,v),{...y,caption:`${d} (${v})`}}return F.set(d,1),y}).sort((y,d)=>{let v=(y.caption||"").toLowerCase(),h=(d.caption||"").toLowerCase();return v.localeCompare(h,M||"en")})},[t,M]);return jsxRuntime.jsx("div",{className:"pivot-flex pivot-flex-col",style:{padding:"8px",borderBottom:"1px solid var(--pivot-border)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)"},onContextMenu:F=>{e&&(F.preventDefault(),e(F.clientX,F.clientY));},children:jsxRuntime.jsx("div",{className:"pivot-flex",style:{width:"100%"},children:jsxRuntime.jsx(Ho,{area:"filter",title:C("filterArea"),icon:jsxRuntime.jsx(lucideReact.Filter,{size:13}),fields:P,onRemoveField:r,onFilterClick:c,onContextMenu:a,onSort:l,onMoveField:p})})})}function sr({menu:t,onClose:r,onToggleExpand:c,onToggleColExpand:a,onExpandPaths:l,onCollapsePaths:e,onExpandColPaths:p,onCollapseColPaths:C,rowTree:M,colTree:P,t:F}){let u=()=>{let h=[],S=t.depth,k=(I,O)=>{if(I)for(let V of I)O>=S&&h.push(V.key),V.children&&k(V.children,O+1);};return k(t.type==="row"?M:P,0),h},y=h=>{h.stopPropagation(),t.type==="row"?c(t.path):a(t.path),r();},d=h=>{h.stopPropagation();let S=u();t.type==="row"?l(S):p(S),r();},v=h=>{h.stopPropagation();let S=u();t.type==="row"?e(S):C(S),r();};return jsxRuntime.jsxs(be,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-portal-root",style:{position:"fixed",inset:0,zIndex:9998},onClick:r,onContextMenu:h=>{h.preventDefault(),r();}}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",left:Math.min(t.x,window.innerWidth-180),top:Math.min(t.y,window.innerHeight-200),zIndex:9999,minWidth:160},onContextMenu:h=>h.preventDefault(),children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-dropdown-item pivot-state-hover",style:{paddingLeft:"32px",paddingRight:"24px"},onClick:y,children:t.isExpanded?F("collapse"):F("expand")}),jsxRuntime.jsx("div",{className:"kanuni-pivot-dropdown-divider"}),jsxRuntime.jsx("button",{className:"kanuni-pivot-dropdown-item pivot-state-hover",style:{paddingLeft:"32px",paddingRight:"24px"},onClick:d,children:F("expandAll")}),jsxRuntime.jsx("button",{className:"kanuni-pivot-dropdown-item pivot-state-hover",style:{paddingLeft:"32px",paddingRight:"24px"},onClick:v,children:F("collapseAll")})]})]})}function jr({columnWidths:t,onColumnWidthsChange:r,rtl:c,leftPaneRef:a,rowHeaderLayout:l}){let e=un.useRef(false),p=un.useRef(null),C=un.useRef(null),M=un.useRef(0),P=un.useRef(0),F=un.useRef([]),u=un.useRef(null),y=un.useRef(-1),d=un.useRef(t),v=un.useRef(new Set),h=un.useRef(null),S=un.useRef(null),k=un.useRef(0);un.useEffect(()=>{let H=S.current;if(!H)return;let z=a.current;d.current={...t};let X=new Set;Object.entries(t).forEach(([_,G])=>{if(_.startsWith("row-"))z?.style.setProperty(`--col-width-${_}`,`${G}px`);else if(_.startsWith("leaf-")){let U=`--col-width-data-${_.replace("leaf-","")}`;H.style.setProperty(U,`${G}px`),X.add(U);}});for(let _ of v.current)X.has(_)||H.style.removeProperty(_);v.current=X;let Y=z?.querySelectorAll(".kanuni-pivot-header-corner[data-row-header-idx]"),j=0;Y?.forEach(_=>{let G=_.getAttribute("data-row-header-idx");G!==null&&(z.style.setProperty(`--row-header-left-${G}`,`${j}px`),j+=_.getBoundingClientRect().width);}),z?.style.setProperty("--row-header-left-total",`${j}px`);},[t]);let I=un.useCallback(H=>{if(!e.current||!h.current||!S.current)return;let z=S.current.getBoundingClientRect(),X=H.clientX-z.left;h.current.style.display="block",h.current.style.transform=`translateX(${X}px)`;},[]),O=un.useCallback(H=>{if(!e.current||!p.current||!S.current)return;h.current&&(h.current.style.display="none");let z=H.clientX-M.current,X=c?-z:z,Y=S.current;if(p.current.startsWith("row-")){let j=Math.max(20,P.current+X),_=u.current,G=_?pivotgridCore.invertRowHeaderWidth(_.configured,y.current,j,_.viewport):j;d.current[p.current]=G;let U=a.current;U?.style.setProperty(`--col-width-${p.current}`,`${j}px`);let L=U?.querySelectorAll(".kanuni-pivot-header-corner[data-row-header-idx]"),R=0;L?.forEach(et=>{let w=et.getAttribute("data-row-header-idx");w!==null&&(U.style.setProperty(`--row-header-left-${w}`,`${R}px`),R+=et.getBoundingClientRect().width);}),U?.style.setProperty("--row-header-left-total",`${R}px`);}else if(p.current.startsWith("leaf-")){let j=p.current.split("-"),_=parseInt(j[1],10),G=parseInt(j[2],10),U=P.current,R=Math.max(G*20,U+X)/U;for(let et=0;et<G;et++){let w=F.current[et],D=Math.max(20,w*R);d.current[`leaf-${_+et}`]=D,Y.style.setProperty(`--col-width-data-${_+et}`,`${D}px`);}}e.current=false,k.current=Date.now(),p.current=null,document.body.style.cursor="",document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",O),C.current=null,r&&r({...d.current});},[I,r,c]),V=un.useCallback((H,z,X,Y=1)=>{if(H.preventDefault(),H.stopPropagation(),!S.current||!h.current)return;if(e.current=true,p.current=z,M.current=H.clientX,z.startsWith("row-")){y.current=parseInt(z.slice(4),10),u.current=l?.()??null;let G=u.current,U=G?pivotgridCore.computeRowHeaderWidths(G.configured,G.viewport).widths[y.current]:void 0;P.current=U??d.current[z]??X;}else if(z.startsWith("leaf-")){let G=z.split("-"),U=parseInt(G[1],10),L=[],R=0;for(let et=0;et<Y;et++){let w=d.current[`leaf-${U+et}`]||X;L.push(w),R+=w;}F.current=L,P.current=R;}let j=S.current.getBoundingClientRect(),_=H.clientX-j.left;h.current.style.display="block",h.current.style.transform=`translateX(${_}px)`,document.body.style.cursor="col-resize",document.addEventListener("mousemove",I),document.addEventListener("mouseup",O),C.current={move:I,up:O};},[I,O]);return un.useEffect(()=>()=>{let H=C.current;H&&(document.removeEventListener("mousemove",H.move),document.removeEventListener("mouseup",H.up),document.body.style.cursor="",C.current=null);},[]),{wrapperRef:S,dragLineRef:h,isResizingRef:e,lastResizeTimeRef:k,handleResizeStart:V}}var ko=null;function _r({containerRef:t,isResizingRef:r,onSelectionStatsChange:c,cellValueAccessor:a,cellTextAccessor:l}){let[e,p]=un.useState(null),C=un.useRef({}),M=un.useCallback((u,y,d,v)=>{d.button!==0||r.current||(ko=C.current,p({startR:u,startC:y,endR:u,endC:y,isSelecting:true,mode:v}));},[r]),P=un.useCallback((u,y,d)=>{p(v=>!v||!v.isSelecting||v.mode!==d?v:{...v,endR:u,endC:y});},[]),F=un.useCallback((u,y)=>{if(!e)return false;let d=Math.min(e.startR,e.endR),v=Math.max(e.startR,e.endR),h=Math.min(e.startC,e.endC),S=Math.max(e.startC,e.endC);return u>=d&&u<=v&&y>=h&&y<=S},[e]);return un.useEffect(()=>{let u=()=>{p(y=>y?{...y,isSelecting:false}:null);};return document.addEventListener("mouseup",u),()=>document.removeEventListener("mouseup",u)},[]),un.useEffect(()=>{if(!e||e.mode!=="data"||!c)return;let u=Math.min(e.startR,e.endR),y=Math.max(e.startR,e.endR),d=Math.min(e.startC,e.endC),v=Math.max(e.startC,e.endC),h=0,S=0,k=1/0,I=-1/0,O=setTimeout(()=>{if(a)for(let V=u;V<=y;V++)for(let H=d;H<=v;H++){let z=a(V,H);z!=null&&!isNaN(z)&&(h+=z,S++,z<k&&(k=z),z>I&&(I=z));}else for(let V=u;V<=y;V++)for(let H=d;H<=v;H++){let z=t.current?.querySelector(`[data-r="${V}"][data-c="${H}"]`);if(z){let X=z.getAttribute("data-val");if(X!==null&&X!==""){let Y=parseFloat(X);isNaN(Y)||(h+=Y,S++,Y<k&&(k=Y),Y>I&&(I=Y));}}}S>0?c({sum:h,count:S,avg:h/S,min:k,max:I}):c(null);},10);return ()=>clearTimeout(O)},[e?.startR,e?.endR,e?.startC,e?.endC,e?.mode,c,a]),un.useEffect(()=>{let u=y=>{if((y.ctrlKey||y.metaKey)&&y.key==="c"){if(!e||ko!==null&&ko!==C.current)return;let d=Math.min(e.startR,e.endR),v=Math.max(e.startR,e.endR),h=Math.min(e.startC,e.endC),S=Math.max(e.startC,e.endC),k="";for(let I=d;I<=v;I++){let O=[];for(let V=h;V<=S;V++)if(l)O.push(l(I,V));else {let H=t.current?.querySelector(`[data-r="${I}"][data-c="${V}"]`);H?O.push(H.innerText.trim().replace(/\n/g," ")):O.push("");}k+=O.join(" ")+`
|
|
2
|
+
`;}k&&navigator.clipboard?.writeText&&navigator.clipboard.writeText(k).catch(()=>{});}};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,l,t]),un.useEffect(()=>{let u=C.current;return ()=>{ko===u&&(ko=null);}},[]),{selection:e,handleCellMouseDown:M,handleCellMouseEnter:P,isCellSelected:F}}function Yr(t){let r=un.useRef(null),c=un.useRef(null),[a,l]=un.useState(0),[e,p]=un.useState(0),[C,M]=un.useState(600),[P,F]=un.useState(800),[u,y]=un.useState(0),d=un.useRef(t);return d.current=t,un.useEffect(()=>{if(r.current){let v=new ResizeObserver(h=>{h[0]&&(M(h[0].contentRect.height),F(h[0].contentRect.width));});return v.observe(r.current),()=>v.disconnect()}},[]),un.useEffect(()=>{let v=r.current,h=c.current;if(!v)return;let S,k=()=>{S&&cancelAnimationFrame(S),S=requestAnimationFrame(()=>{let O=d.current?.quantizeY??1,V=d.current?.quantizeX??1;l(O>1?Math.floor(v.scrollTop/O)*O:v.scrollTop),p(V>1?Math.floor(v.scrollLeft/V)*V:v.scrollLeft);let H=c.current;H&&(H.scrollTop=v.scrollTop);});},I=O=>{let V=r.current;V&&(V.scrollTop+=O.deltaY);};return v.addEventListener("scroll",k,{passive:true}),h&&h.addEventListener("wheel",I,{passive:true}),()=>{v.removeEventListener("scroll",k),h&&h.removeEventListener("wheel",I),S&&cancelAnimationFrame(S);}},[]),un.useEffect(()=>{let v=r.current,h=c.current;if(!v||!h)return;let S=Math.max(0,v.offsetHeight-v.clientHeight);y(k=>k===S?k:S),h.scrollTop!==v.scrollTop&&(h.scrollTop=v.scrollTop);}),{containerRef:r,leftPaneRef:c,scrollTop:a,scrollLeft:e,containerHeight:C,containerWidth:P,bottomGutter:u}}var Gn=28,Wn=95,Vn=40,Qr=8,Kn={"arrow-up":lucideReact.ArrowUp,"arrow-down":lucideReact.ArrowDown,minus:lucideReact.Minus,circle:lucideReact.Circle,check:lucideReact.Check,x:lucideReact.X,"alert-triangle":lucideReact.TriangleAlert};function Un({name:t}){let r=Kn[t];return r?jsxRuntime.jsx("span",{style:{display:"inline-flex",verticalAlign:"middle",marginInlineEnd:4},children:jsxRuntime.jsx(r,{size:12})}):null}var qn={style:{}};function vr({engineResult:t,isBuilding:r,buildProgress:c=0,rowFields:a,colFields:l,dataFields:e,layout:p,expandedPaths:C,allExpanded:M,onToggleExpand:P,onExpandPaths:F,onCollapsePaths:u,expandedColPaths:y,allColExpanded:d,onToggleColExpand:v,onExpandColPaths:h,onCollapseColPaths:S,onCellClick:k,onContextMenu:I,onFilterClick:O,onRemoveField:V,onSort:H,onMoveField:z,onGlobalContextMenu:X,columnWidths:Y={},defaultColumnWidths:j,onColumnWidthsChange:_,onSelectionStatsChange:G,registry:U,keyboardNavigation:L,onCellPrepared:R,renderNodeContextMenu:et,rowHeight:w}){let{t:D,rtl:bt,locale:f}=mt(),T=w??Gn,K=un.useId(),ot=j?.rowHeader,kt=j?.data,E=un.useMemo(()=>pivotgridCore.resolveColumnWidthDefaults({rowHeader:ot,data:kt}),[ot,kt]),{setNodeRef:dt,isOver:st}=core.useDroppable({id:"row"}),{containerRef:ct,leftPaneRef:q,scrollTop:de,scrollLeft:ne,containerHeight:rt,containerWidth:Wt,bottomGutter:m}=Yr({quantizeY:T,quantizeX:Wn}),{wrapperRef:x,dragLineRef:ut,isResizingRef:Q,lastResizeTimeRef:Pt,handleResizeStart:vt}=jr({columnWidths:Y,onColumnWidthsChange:_,rtl:bt,leftPaneRef:q,rowHeaderLayout:()=>Jt.current}),Jt=un.useRef({configured:[],viewport:0}),Et=un.useRef(0),[Xt,jt]=un.useMemo(()=>{if(!p.hideEmptySummaryCells||!t)return [t.rowTree,t.colTree];let i=new Set;for(let s=0;s<t.cellMatrix.keys.length;s++)i.add(t.cellMatrix.keys[s]);let n=(s,g)=>{let b=[];for(let N of s){let J=g?t.rowIndexMap[N.key]:t.columnIndexMap[N.key];if(J===void 0){b.push(N);continue}if(g?i.has(J*pivotgridCore.MAX_C):i.has(J)){let nt=N.children&&N.children.length>0?n(N.children,g):[];b.push({...N,children:nt});}}return b};return [n(t.rowTree,true),n(t.colTree,false)]},[t,p.hideEmptySummaryCells]),Qt=un.useMemo(()=>{let i=pivotgridCore.buildColumnHeaders(jt,e,p,y,d,{grandTotal:D("grandTotal"),subTotal:D("subTotal")});return i.length>0?i:[[]]},[jt,e,p,y,d,D]),pt=p.rowHeaderLayout==="tree"?1:a.length||1,it=p.dataFieldPosition==="rows"&&e.length>1,To=un.useMemo(()=>p.rowHeaderLayout==="tree"?pivotgridCore.flattenRowTreeTree(Xt,C,M,a.length||1,p.showRowTotals??true,p.totalsPosition??"bottom"):pivotgridCore.flattenRowTreeTabular(Xt,C,M,pt,p.showRowTotals??true,p.totalsPosition??"bottom"),[Xt,C,M,pt,p.showRowTotals,p.totalsPosition,p.rowHeaderLayout,a.length]),Rt=un.useMemo(()=>{let i=[];for(let n of To)if(it&&!n.isSubtotal&&!n.hasChildren)for(let s=0;s<e.length;s++)i.push({flatRow:n,dfIndex:s,isDataRow:true,isGrandTotal:false});else i.push({flatRow:n,dfIndex:0,isDataRow:false,isGrandTotal:false});if(p.showRowGrandTotals)if(it)for(let n=0;n<e.length;n++)i.push({flatRow:null,dfIndex:n,isDataRow:true,isGrandTotal:true});else i.push({flatRow:null,dfIndex:0,isDataRow:false,isGrandTotal:true});return i},[To,it,e,p.showRowGrandTotals]),_e=un.useMemo(()=>t&&e.some(pivotgridCore.fieldNeedsRange)?pivotgridCore.computeFieldRanges(t,e):{},[t,e]),Bt=un.useMemo(()=>{let i=[],n=pivotgridCore.getVisibleColSlots(jt,y,d,{subTotals:p.showColumnTotals!==false,totalsPosition:p.totalsPosition??"bottom"});for(let s of n)i.push({hash:s.node.key,isGrandTotal:s.node.isTotal,isSubtotal:s.isSubtotal});return (p.showColumnGrandTotals||n.length===0)&&i.push({hash:"",isGrandTotal:true}),i},[jt,p.showColumnGrandTotals,p.showColumnTotals,p.totalsPosition,y,d]);un.useEffect(()=>{let i=q.current?.querySelector(".kanuni-pivot-table");if(!i||!x.current)return;let n=()=>{let N=q.current;if(!N)return;let J=i.querySelectorAll("th[data-row-header-idx]");if(J.length===0)return;let Z=0;Array.from(J).sort((tt,W)=>Number(tt.getAttribute("data-row-header-idx"))-Number(W.getAttribute("data-row-header-idx"))).forEach((tt,W)=>{N.style.setProperty(`--row-header-left-${W}`,`${Z}px`),Z+=tt.offsetWidth;}),N.style.setProperty("--row-header-left-total",`${Z}px`);},s=new ResizeObserver(()=>n());s.observe(i),i.querySelectorAll("th[data-row-header-idx]").forEach(N=>s.observe(N)),n();let b=setTimeout(n,100);return ()=>{s.disconnect(),clearTimeout(b);}},[a,it,Qt,Rt,Bt]);let lo=Rt.length*T,Ce=Qt.length*T,Pe=Math.ceil(rt/T),po=Math.max(0,Math.floor((de-Ce)/T)-5),ce=Math.min(po,Math.max(0,Rt.length-Pe)),He=Math.min(Rt.length,ce+Pe+10),Ye=un.useMemo(()=>Rt.slice(ce,He),[Rt,ce,He]),[zt,Nt]=un.useState(null),ye=un.useMemo(()=>{let i=new Map;if(t?.cellMatrix?.keys){let n=t.cellMatrix.keys;for(let s=0;s<n.length;s++)i.set(n[s],s);}return i},[t?.cellMatrix]),{handleCellMouseDown:fe,handleCellMouseEnter:Re,isCellSelected:Je}=_r({containerRef:ct,isResizingRef:Q,onSelectionStatsChange:G,cellValueAccessor:un.useCallback((i,n)=>{let s=pt+(it?1:0);if(n<s)return null;let g=n-s,b=it?1:e.length,N=Math.floor(g/b),J=g%b;if(N>=Bt.length)return null;let Z=Rt[i];if(!Z)return null;let nt=Z.isGrandTotal?"":Z.flatRow?.key;if(nt===void 0)return null;let tt=Bt[N]?.hash;if(tt===void 0)return null;let W=t.rowIndexMap[nt],gt=t.columnIndexMap[tt];if(W===void 0||gt===void 0)return null;let Mt=W*pivotgridCore.MAX_C+gt,_t=ye.get(Mt);if(_t===void 0)return null;let se=it?Z.dfIndex:J;return t.cellMatrix.sums[_t*e.length+se]},[pt,it,e,Bt,Rt,t,ye])}),te=Bt.length*(it?1:e.length),he=pt+(it?1:0),ee=he+te,co=un.useMemo(()=>`calc(${Array.from({length:he},(n,s)=>{let g=it&&s===pt?100:E.rowHeader;return `var(--col-width-row-${s}, ${g}px)`}).join(" + ")})`,[pt,he,it,E]),Fe=un.useMemo(()=>Array.from({length:he},(i,n)=>{let s=it&&n===pt?100:E.rowHeader;return Y[`row-${n}`]??s}),[Y,pt,he,it,E]),uo=un.useRef(Fe),Se=un.useCallback(()=>{let i=uo.current,n=Et.current;Jt.current={configured:i,viewport:n};let s=q.current;if(!s)return;let{widths:g}=pivotgridCore.computeRowHeaderWidths(i,n);for(let b=0;b<g.length;b++)s.style.setProperty(`--col-width-row-${b}`,`${g[b]}px`);},[]);un.useLayoutEffect(()=>{uo.current=Fe,Se();},[Fe,Se]),un.useLayoutEffect(()=>{let i=x.current;if(!i)return;let n=()=>{let g=i.clientWidth;g!==Et.current&&(Et.current=g,Se());};if(n(),typeof ResizeObserver>"u")return;let s=new ResizeObserver(n);return s.observe(i),()=>s.disconnect()},[x,Se]);let Ie=te>Vn,ze=un.useMemo(()=>{if(!Ie)return {start:0,end:te};let i=J=>Y[`leaf-${J}`]??E.data,n=Math.abs(ne),s=0,g=0;for(;s<te&&g+i(s)<=n;)g+=i(s),s++;let b=s,N=g-n;for(;b<te&&N<Wt;)N+=i(b),b++;return {start:Math.max(0,s-Qr),end:Math.min(te,b+Qr)}},[Ie,te,ne,Wt,Y,E]),qo=un.useCallback(i=>{if(!zt)return;let{rGlobal:n,cGlobal:s}=zt;switch(i.key){case "ArrowDown":i.preventDefault(),n=Math.min(Rt.length-1,n+1);break;case "ArrowUp":i.preventDefault(),n=Math.max(0,n-1);break;case "ArrowRight":i.preventDefault(),s=Math.min(ee-1,s+1);break;case "ArrowLeft":i.preventDefault(),s=Math.max(0,s-1);break;case "Home":i.preventDefault(),(i.ctrlKey||i.metaKey)&&(n=0),s=0;break;case "End":i.preventDefault(),(i.ctrlKey||i.metaKey)&&(n=Rt.length-1),s=ee-1;break;case "PageDown":i.preventDefault(),n=Math.min(Rt.length-1,n+Pe-1);break;case "PageUp":i.preventDefault(),n=Math.max(0,n-Pe+1);break;case "Escape":i.preventDefault(),Nt(null);return;case " ":case "Enter":i.preventDefault();let b=document.getElementById(`${K}pivot-cell-${n}-${s}`);b&&(i.key===" "?b.click():b.dispatchEvent(new MouseEvent("dblclick",{bubbles:true})));return;default:return}Nt({rGlobal:n,cGlobal:s});let g=n*T;if(ct.current){let b=ct.current.scrollTop;g<b+Ce?ct.current.scrollTop=g-Ce:g+T>b+rt&&(ct.current.scrollTop=g+T-rt+Ce);}},[zt,Rt.length,ee,Pe,rt,Ce,K]),vo=un.useMemo(()=>new Map,[f]),mo=un.useCallback((i,n)=>{if(i==null)return "";if(n.format&&typeof i=="number"){if(typeof n.format=="function")return n.format(i);try{let s=n.format,g=vo.get(s);g||(g=new Intl.NumberFormat(f,s),vo.set(s,g));let b=g.format(i);return s.isCustom&&(s.prefix||s.suffix)?`${s.prefix||""}${b}${s.suffix||""}`:b}catch{return String(i)}}return typeof i=="number"&&pivotgridCore.percentModeText(i,n,f)||String(i)},[f,vo]),$e=un.useRef(""),Ze=un.useRef(""),At=un.useCallback((i,n)=>{let s=pt+(it?1:0);if(n<s)return null;let g=n-s,b=it?1:e.length,N=Math.floor(g/b),J=g%b;if(N>=Bt.length)return null;let Z=Rt[i];if(!Z)return null;let nt=Z.isGrandTotal?"":Z.flatRow?.key;if(nt===void 0)return null;let tt=Bt[N],W=tt?.hash;if(W===void 0)return null;let gt=t.rowIndexMap[nt]??-1,Mt=t.columnIndexMap[W]??-1;if(gt===-1||Mt===-1)return null;let _t=gt*pivotgridCore.MAX_C+Mt,se=ye.get(_t);if(se===void 0)return null;let Vt=Z.flatRow?.isSubtotal,Yt={isTotalCell:gt===0||Mt===0||Vt||tt.isGrandTotal,rowPath:nt?nt.split("|"):[],colPath:W?W.split("|"):[],values:{}};for(let o=0;o<e.length;o++)Yt.values[e[o].id]=t.cellMatrix.sums[se*e.length+o],t.cellMatrix.displaySums&&(Yt.values[`${e[o].id}_display`]=t.cellMatrix.displaySums[se*e.length+o]);let oe=it?Z.dfIndex:J,Ht=e[oe],xt=Yt.values[`${Ht?.id}_display`]??Yt.values[Ht?.id],Kt=Vt||tt.isGrandTotal||Yt.isTotalCell;return {cell:Yt,val:xt,isTotal:Kt}},[pt,it,e,Bt,Rt,t,ye]),Oe=un.useCallback((i,n)=>{let s=Rt[i];if(!s||s.isGrandTotal||!s.flatRow)return null;let g=s.flatRow,b=p.rowHeaderLayout==="tree",N=n,J=b?g.depth:N,Z=J===g.depth,nt=J<g.depth,tt=Z?g.hasChildren:nt,W=Z?g.isExpanded:nt,gt=b?g.key:g.pathValues.slice(0,N+1).join("|");return {hasChildren:tt,isExpanded:W,cellHashStr:gt,depth:J,flatRow:g,dIdx:N}},[Rt,p.rowHeaderLayout]),Xo=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),g=Number(n.getAttribute("data-c"));if(ct.current?.focus({preventScroll:true}),Nt({rGlobal:s,cGlobal:g}),k){let b=At(s,g);b?.cell&&k({event:i,cellType:b.isTotal?"grandTotal":"data",value:b.val,rowPath:b.cell.rowPath,colPath:b.cell.colPath,records:b.cell.records});}},[k,At]),jo=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),g=Number(n.getAttribute("data-c"));if(k){let b=At(s,g);b?.cell&&k({event:i,cellType:b.isTotal?"grandTotal":"data",value:b.val,rowPath:b.cell.rowPath,colPath:b.cell.colPath,records:b.cell.records});}},[k,At]),_o=un.useCallback(i=>{i.target.closest("td[data-r][data-c]")&&(i.preventDefault(),X&&X(i.clientX,i.clientY));},[X]),Yo=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");n&&fe(Number(n.getAttribute("data-r")),Number(n.getAttribute("data-c")),i,"data");},[fe]),Jo=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),g=Number(n.getAttribute("data-c")),b=`${s},${g}`;b!==$e.current&&($e.current=b,Re(s,g,"data"));},[Re]),Qe=un.useCallback(i=>{if(i.target.closest(".kanuni-pivot-resize-handle"))return;let n=i.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),g=Number(n.getAttribute("data-c"));if(ct.current?.focus({preventScroll:true}),Nt({rGlobal:s,cGlobal:g}),Date.now()-Pt.current<100)return;let b=Oe(s,g);b?.hasChildren&&P(b.cellHashStr);},[Oe,P,Pt]),to=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),g=Number(n.getAttribute("data-c")),b=Oe(s,g);if(!b){X&&(i.preventDefault(),X(i.clientX,i.clientY));return}let{flatRow:N,hasChildren:J,cellHashStr:Z,isExpanded:nt,depth:tt,dIdx:W}=b,gt=p.rowHeaderLayout==="tree",Mt=W>N.depth?N.depth:tt,_t=W>N.depth?N.hasChildren:J,se=W>N.depth?gt?N.key:N.pathValues.slice(0,N.depth+1).join("|"):Z,Vt=W>N.depth?N.isExpanded:nt;_t?(i.preventDefault(),ho({x:i.clientX,y:i.clientY,path:se,isExpanded:Vt,depth:Mt,type:"row"})):X&&(i.preventDefault(),X(i.clientX,i.clientY));},[Oe,X,p.rowHeaderLayout]),No=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");n&&fe(Number(n.getAttribute("data-r")),Number(n.getAttribute("data-c")),i,"row");},[fe]),Eo=un.useCallback(i=>{let n=i.target.closest("td[data-r][data-c]");if(!n)return;let s=Number(n.getAttribute("data-r")),g=Number(n.getAttribute("data-c")),b=`${s},${g}`;b!==Ze.current&&(Ze.current=b,Re(s,g,"row"));},[Re]),Le=un.useCallback((i,n,s,g)=>{let b=it?1:e.length,N=it?[e[n]]:e,J=pt+(it?1:0),Z=e.length,nt=t.cellMatrix.sums,tt=t.cellMatrix.displaySums,W=t.rowIndexMap[i]??-1,gt=i?i.split("|"):[],Mt=U?U.getPluginsByType("cellRender"):null;return Bt.map((_t,se)=>{let Vt=_t.hash,Yt=se*b;if(Ie&&(Yt+b<=ze.start||Yt>=ze.end))return N.map((xt,Kt)=>{let o=J+Yt+Kt;return jsxRuntime.jsx("td",{id:`${K}pivot-cell-${g}-${o}`,role:"gridcell","data-r":g,"data-c":o,className:"kanuni-pivot-cell"},`cell-${i}-${Vt}-${xt.id}-${Kt}`)});let oe=t.columnIndexMap[Vt]??-1,Ht=null;if(W!==-1&&oe!==-1){let xt=W*pivotgridCore.MAX_C+oe,Kt=ye.get(xt);if(Kt!==void 0){Ht={isTotalCell:W===0||oe===0||s||_t.isGrandTotal,rowPath:gt.slice(),colPath:Vt?Vt.split("|"):[],values:{}};for(let o=0;o<Z;o++)Ht.values[e[o].id]=nt[Kt*Z+o],tt&&(Ht.values[`${e[o].id}_display`]=tt[Kt*Z+o]);}}return N.map((xt,Kt)=>{let o=Yt+Kt;if(Ie&&(o<ze.start||o>=ze.end)){let bo=J+o;return jsxRuntime.jsx("td",{id:`${K}pivot-cell-${g}-${bo}`,role:"gridcell","data-r":g,"data-c":bo,className:"kanuni-pivot-cell"},`cell-${i}-${Vt}-${xt.id}-${Kt}`)}let B=Ht?.values[`${xt.id}_display`]??Ht?.values[xt.id],$t=mo(B,xt),we=s||_t.isGrandTotal||Ht?.isTotalCell,io=J+o,Mi=zt?.rGlobal===g&&zt?.cGlobal===io,Di=Je(g,io),$r={},Be=xt.conditionalFormatting?pivotgridCore.resolveConditionalVisual(Ht?.values[xt.id],xt,Ht??null,_e[xt.id]):qn;$r=Be.style;let Qo=$t;if(xt.cellTemplate)Qo=xt.cellTemplate({value:B,displayValue:$t,cell:Ht,field:xt});else if(Mt){for(let bo of Mt)if(bo.renderCell){let tr=bo.renderCell(B,$t,Ht,xt);if(tr!=null){Qo=tr;break}}}let Lo={text:Qo,style:{textAlign:xt.dataType==="number"?"right":"left",fontWeight:we?600:400,backgroundColor:we?"var(--pivot-bg)":"transparent",cursor:k&&Ht?"pointer":"default",...$r,...Be.dataBar?{backgroundImage:`linear-gradient(to ${bt?"left":"right"}, ${Be.dataBar.color} ${Math.round(Be.dataBar.ratio*100)}%, transparent ${Math.round(Be.dataBar.ratio*100)}%)`,backgroundRepeat:"no-repeat"}:null},className:`kanuni-pivot-cell ${we?"kanuni-pivot-cell-total":""} ${Mi?"kanuni-pivot-cell-focused":""} ${Di?"kanuni-pivot-cell-selected":""}`};return R&&R({area:"data",cell:Ht,rowIndex:g,columnIndex:io,cellConfig:Lo}),jsxRuntime.jsxs("td",{id:`${K}pivot-cell-${g}-${io}`,role:"gridcell","aria-colindex":io+1,"data-r":g,"data-c":io,"data-val":typeof B=="number"?B:"",className:Lo.className,style:Lo.style,children:[Be.icon?jsxRuntime.jsx(Un,{name:Be.icon}):null,Lo.text]},`cell-${i}-${Vt}-${xt.id}-${Kt}`)})})},[Bt,ye,_e,bt,t.cellMatrix,t.rowIndexMap,t.columnIndexMap,it,e,pt,mo,zt,k,Ie,ze.start,ze.end,Je,U,R,K]),[fo,ho]=un.useState(null),Ae=un.useCallback((i,n)=>{let s=Rt[i],g=s.flatRow,b=p.rowHeaderLayout==="tree",N=b?g.depth:n,J=g.pathValues[N],Z=g.rowSpans[n]>0&&s.dfIndex===0,nt=a[N],tt=nt&&J!==null&&J!==void 0?pivotgridCore.formatDimensionValue(J,nt,"grid",f):J,W=N===g.depth,gt=N<g.depth,Mt=W?g.hasChildren:gt,_t=W?g.isExpanded:gt,se=Je(i,n),Vt=tt;a[N]?.cellTemplate?Vt=a[N].cellTemplate({value:tt,displayValue:tt,field:a[N]}):Vt=jsxRuntime.jsx("span",{className:"truncate",children:tt});let Yt=i+1,oe=Yt<Rt.length?Rt[Yt]:null,Ht=!b&&oe&&!oe.isGrandTotal&&!oe.flatRow.isSubtotal&&(oe.flatRow.rowSpans[n]===0||oe.dfIndex>0)&&oe.flatRow.pathValues[n]===J,xt={text:Vt,style:{position:"sticky",insetInlineStart:`var(--row-header-left-${n}, 0px)`,backgroundColor:"var(--pivot-surface)",zIndex:40,cursor:Mt?"pointer":"default",fontWeight:tt&&N<g.depth?600:400,verticalAlign:"middle",padding:0,borderBottom:Ht?"none":"1px solid var(--pivot-border)",borderInlineEnd:!b&&n>=g.depth&&n<pt-1?"none":void 0,height:T},className:`kanuni-pivot-cell kanuni-pivot-row-header ${Mt?"kanuni-pivot-row-expandable":""} ${se?"kanuni-pivot-cell-selected":""} ${zt?.rGlobal===i&&zt?.cGlobal===n?"kanuni-pivot-cell-focused":""}`};if(R&&R({area:"row",cell:null,rowIndex:i,columnIndex:n,cellConfig:xt}),!Z&&!b)return jsxRuntime.jsx("td",{id:`${K}pivot-cell-${i}-${n}`,role:"rowheader","aria-expanded":Mt?_t:void 0,"data-r":i,"data-c":n,className:xt.className,style:{...xt.style,borderBottom:"none",cursor:Mt?"pointer":"default"},children:jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:o=>vt(o,`row-${n}`,E.rowHeader),onClick:o=>o.stopPropagation(),style:{[bt?"left":"right"]:-3}})},`row-hdr-${g.key}-${n}-empty`);let Kt=b?g.depth*20:0;return jsxRuntime.jsxs("td",{id:`${K}pivot-cell-${i}-${n}`,role:"rowheader","aria-expanded":Mt?_t:void 0,"aria-label":tt,"data-r":i,"data-c":n,className:xt.className,style:xt.style,children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,padding:"0 8px",paddingInlineStart:`${8+Kt}px`,height:"100%",position:"relative"},children:[b&&g.depth>0&&jsxRuntime.jsx("div",{className:"kanuni-pivot-tree-line",style:{position:"absolute",left:`${Kt}px`,top:`${-T/2}px`,width:"12px",height:`${T}px`,borderLeft:"1px dotted var(--pivot-border)",borderBottom:"1px dotted var(--pivot-border)"}}),tt!=null?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[Mt?jsxRuntime.jsx("span",{className:"kanuni-pivot-expand-icon","aria-hidden":"true",style:{flexShrink:0,position:"relative",zIndex:2},children:_t?"\u2212":"+"}):jsxRuntime.jsx("span",{style:{width:14,flexShrink:0}}),a[N]?.cellTemplate?a[N].cellTemplate({value:tt,displayValue:tt,field:a[N]}):jsxRuntime.jsx("span",{className:"truncate",children:tt})]}):null]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:o=>vt(o,`row-${n}`,E.rowHeader),onClick:o=>o.stopPropagation(),style:{[bt?"left":"right"]:-3}})]},`row-hdr-${g.key}-${n}`)},[Rt,T,P,vt,p.rowHeaderLayout,a,f,pt,Je,zt,bt,K]),ge=un.useCallback(i=>p.rowHeaderLayout!=="tree"?{}:i?i.isSubtotal||!i.hasChildren?{"aria-level":i.depth+1}:{"aria-level":i.depth+1,"aria-expanded":!!i.isExpanded}:{"aria-level":1},[p.rowHeaderLayout]),Mo=un.useCallback((i,n,s)=>s==="left"?jsxRuntime.jsxs("tr",{role:"row","aria-rowindex":n+1,...ge(null),className:"kanuni-pivot-row kanuni-pivot-grand-total-row",style:{height:T},children:[Array.from({length:pt}).map((g,b)=>{let N=b===0,J=b===pt-1;return jsxRuntime.jsx("td",{className:`kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total${zt?.rGlobal===n&&zt?.cGlobal===b?" kanuni-pivot-cell-focused":""}`,id:`${K}pivot-cell-${n}-${b}`,role:N?"rowheader":"presentation",style:{fontWeight:700,backgroundColor:"var(--pivot-surface)",paddingLeft:N?8:0,paddingRight:0,borderRight:J?"1px solid var(--pivot-border)":"none",whiteSpace:N?"nowrap":"normal",overflow:N?"visible":"hidden"},children:N?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[D("grandTotal")," ",it?` \u2014 ${e[i]?.caption}`:""]}):null},`gt-hdr-${b}`)}),it&&jsxRuntime.jsx("td",{id:`${K}pivot-cell-${n}-${pt}`,role:"gridcell",className:"kanuni-pivot-cell kanuni-pivot-cell-total",style:{backgroundColor:"var(--pivot-surface)"},children:e[i]?.caption})]},`gt-${i}`):jsxRuntime.jsx("tr",{role:"row","aria-rowindex":n+1,...ge(null),className:"kanuni-pivot-row kanuni-pivot-grand-total-row",style:{height:T},children:Le("",i,true,n)},`gt-${i}`),[pt,it,e,Le,T,D,zt,K,ge]),Do=un.useCallback((i,n,s,g)=>{let b=i.key,N=`${D("subTotal")}: ${i.pathValues[i.depth]}`;return g==="left"?jsxRuntime.jsxs("tr",{role:"row","aria-rowindex":s+1,...ge(i),className:"kanuni-pivot-row kanuni-pivot-subtotal-row",style:{height:T},children:[p.rowHeaderLayout==="tree"?jsxRuntime.jsx("td",{id:`${K}pivot-cell-${s}-0`,role:"rowheader",className:"kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total",colSpan:1,style:{fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:`${8+i.depth*20}px`},children:N},`subtotal-hdr-${b}-tree`):Array.from({length:pt}).map((J,Z)=>{if(Z<i.depth)return Ae(s,Z);let nt=Z===i.depth,tt=Z===pt-1;return jsxRuntime.jsx("td",{id:`${K}pivot-cell-${s}-${Z}`,role:nt?"rowheader":"presentation",className:"kanuni-pivot-cell kanuni-pivot-row-header kanuni-pivot-cell-total",style:{fontWeight:600,backgroundColor:"var(--pivot-surface)",paddingLeft:nt?8:0,paddingRight:0,borderRight:tt?"1px solid var(--pivot-border)":"none",whiteSpace:nt?"nowrap":"normal",overflow:nt?"visible":"hidden"},children:nt?N:null},`subtotal-hdr-${b}-${Z}`)}),it&&jsxRuntime.jsx("td",{id:`${K}pivot-cell-${s}-${pt}`,role:"gridcell",className:"kanuni-pivot-cell kanuni-pivot-cell-total",style:{backgroundColor:"var(--pivot-surface)"},children:e[n]?.caption})]},`subtotal-${b}-${n}`):jsxRuntime.jsx("tr",{role:"row","aria-rowindex":s+1,...ge(i),className:"kanuni-pivot-row kanuni-pivot-subtotal-row",style:{height:T},children:Le(b,n,true,s)},`subtotal-${b}-${n}`)},[pt,it,e,Le,T,p.rowHeaderLayout,Ae,D,K,ge]),Fo=un.useCallback((i,n,s,g,b)=>{let N=i.key;return b==="left"?jsxRuntime.jsxs("tr",{role:"row","aria-rowindex":g+1,...ge(i),className:`kanuni-pivot-row ${i.isSubtotal?"kanuni-pivot-subtotal-row":""}`,style:{height:T},children:[Array.from({length:pt}).map((J,Z)=>Ae(g,Z)),it&&jsxRuntime.jsxs("td",{id:`${K}pivot-cell-${g}-${pt}`,role:"rowheader",className:"kanuni-pivot-cell kanuni-pivot-row-header",style:{backgroundColor:"var(--pivot-surface)"},children:[s&&jsxRuntime.jsx("span",{style:{color:"var(--pivot-text-muted)"},children:e[n].caption}),jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:J=>vt(J,`row-${pt}`,100),onClick:J=>J.stopPropagation(),style:{[bt?"left":"right"]:-3}})]})]},`row-${N}-${n}`):jsxRuntime.jsx("tr",{role:"row","aria-rowindex":g+1,...ge(i),className:`kanuni-pivot-row ${i.isSubtotal?"kanuni-pivot-subtotal-row":""}`,style:{height:T},children:Le(N,n,false,g)},`row-${N}-${n}`)},[pt,it,e,Ae,Le,T,vt,bt,K,ge]),eo=un.useRef(null),oo=un.useRef(null),Io=un.useRef(null),zo=un.useRef(null);un.useLayoutEffect(()=>{let i=()=>{let s=eo.current,g=oo.current,b=Io.current,N=zo.current;if(!s||!g||!b||!N)return;let J=gt=>parseFloat(gt.style.paddingBottom)||0,Z=s.getBoundingClientRect().height-J(b),nt=g.getBoundingClientRect().height-J(N);if(Z<=0||nt<=0)return;let tt=Math.max(Z,nt),W=(gt,Mt)=>{Math.abs(Mt-J(gt))>.5&&(gt.style.paddingBottom=`${Mt}px`);};W(b,tt-Z),W(N,tt-nt);};i();let n=new ResizeObserver(i);return eo.current&&n.observe(eo.current),oo.current&&n.observe(oo.current),()=>n.disconnect()},[Qt,a,l,e,it]);let ro=un.useCallback(i=>Ye.map((n,s)=>{let g=ce+s;if(n.isGrandTotal)return Mo(n.dfIndex,g,i);let{flatRow:b,dfIndex:N,isDataRow:J}=n;return b.isSubtotal?Do(b,N,g,i):Fo(b,N,J,g,i)}),[Ye,ce,Mo,Do,Fo]),Zo=un.useMemo(()=>ro("left"),[ro]),go=un.useMemo(()=>ro("right"),[ro]),ae=L?.enabled!==false;return jsxRuntime.jsxs("div",{style:{position:"relative",height:"100%",width:"100%",outline:"none",display:"flex",flexDirection:"row"},ref:x,tabIndex:ae?0:void 0,role:ae?p.rowHeaderLayout==="tree"?"treegrid":"grid":void 0,"aria-rowcount":ae?Rt.length+Qt.length+1:void 0,"aria-colcount":ae?ee:void 0,"aria-label":ae?D("pivotView"):void 0,"aria-activedescendant":ae&&zt?`${K}pivot-cell-${zt.rGlobal}-${zt.cGlobal}`:void 0,onKeyDown:ae?qo:void 0,onFocus:i=>{ae&&!zt&&i.target===i.currentTarget&&Rt.length>0&&Nt({rGlobal:0,cGlobal:0});},onBlur:()=>{ae&&Nt(null);},children:[jsxRuntime.jsx("div",{ref:q,className:"pivot-left-pane custom-scrollbar",style:{flex:"0 0 auto",width:co,overflow:"hidden",height:m>0?`calc(100% - ${m}px)`:"100%",position:"relative",zIndex:2,backgroundColor:"var(--pivot-surface)",borderRight:"1px solid var(--pivot-border)"},children:jsxRuntime.jsx("div",{style:{height:lo+Ce,width:co,position:"relative"},children:jsxRuntime.jsxs("table",{className:"kanuni-pivot-table",role:ae?"presentation":void 0,style:{borderCollapse:"separate",borderSpacing:0,tableLayout:"fixed",width:co},children:[jsxRuntime.jsxs("colgroup",{children:[Array.from({length:pt}).map((i,n)=>jsxRuntime.jsx("col",{style:{width:`var(--col-width-row-${n}, ${E.rowHeader}px)`}},`col-row-${n}`)),it&&jsxRuntime.jsx("col",{style:{width:`var(--col-width-row-${pt}, 100px)`}},"col-row-measure")]}),jsxRuntime.jsxs("thead",{ref:eo,role:"rowgroup",style:{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"},children:[jsxRuntime.jsx("tr",{role:"row",style:{height:42},children:jsxRuntime.jsx("th",{ref:Io,role:"columnheader",colSpan:pt+(it?1:0),style:{borderInlineEnd:"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",minWidth:50,backgroundColor:"var(--pivot-surface-header)"},children:jsxRuntime.jsx(Ho,{area:"data",title:D("dataArea"),icon:jsxRuntime.jsx(lucideReact.BarChart3,{size:13}),fields:e,onRemoveField:V,onFilterClick:O||(()=>{}),onContextMenu:I,onSort:H,onMoveField:z})})}),Qt.map((i,n)=>jsxRuntime.jsxs("tr",{role:"row",style:{height:T},children:[n===0&&a.length===0&&jsxRuntime.jsx("th",{ref:dt,role:"columnheader",className:`kanuni-pivot-header-cell kanuni-pivot-header-corner ${st?"pivot-area-strip--over":""}`,rowSpan:Qt.length,colSpan:pt+(it?1:0),style:{borderInlineEnd:"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"8px",color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 70%, transparent)",backgroundColor:"var(--pivot-surface-header)"},children:D("dropHere")}),n===0&&a.length>0&&p.rowHeaderLayout==="tree"&&jsxRuntime.jsx("th",{role:"columnheader",className:"kanuni-pivot-header-cell kanuni-pivot-header-corner",rowSpan:Qt.length,style:{borderInlineEnd:it?"none":"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)",backgroundColor:"var(--pivot-surface-header)",display:"flex",flexWrap:"wrap",gap:"4px",height:"100%"},children:a.map(s=>jsxRuntime.jsx($o,{field:s,siblings:a,onMove:z,onRemove:V,onFilterClick:O||(()=>{}),onContextMenu:I,onSort:H},s.id))}),n===0&&a.length>0&&p.rowHeaderLayout!=="tree"&&a.map((s,g)=>jsxRuntime.jsx("th",{role:"columnheader","data-row-header-idx":g,className:"kanuni-pivot-header-cell kanuni-pivot-header-corner",rowSpan:Qt.length,style:{borderInlineEnd:g===a.length-1&&!it?"1px solid var(--pivot-border)":"none",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)",backgroundColor:"var(--pivot-surface-header)"},children:jsxRuntime.jsx($o,{field:s,siblings:a,onMove:z,onRemove:V,onFilterClick:O||(()=>{}),onContextMenu:I,onSort:H})},s.id)),n===0&&a.length>0&&it&&jsxRuntime.jsx("th",{role:"columnheader","data-row-header-idx":a.length,className:"kanuni-pivot-header-cell kanuni-pivot-header-corner",rowSpan:Qt.length,style:{borderInlineEnd:"1px solid var(--pivot-border)",borderBottom:"1px solid var(--pivot-border)",verticalAlign:"bottom",padding:"4px 8px",color:"var(--pivot-text-header)",backgroundColor:"var(--pivot-surface-header)"},children:jsxRuntime.jsx("div",{style:{fontSize:10,fontWeight:600,color:"color-mix(in srgb, var(--pivot-text-header, var(--pivot-text)) 80%, transparent)",textTransform:"uppercase",letterSpacing:"0.05em",textAlign:"center"},children:D("dataArea")})})]},`col-hdr-row-${n}`))]}),jsxRuntime.jsxs("tbody",{role:"rowgroup",onClick:Qe,onContextMenu:to,onMouseDown:No,onMouseOver:Eo,children:[ce>0&&jsxRuntime.jsx("tr",{role:"row",style:{height:ce*T},children:jsxRuntime.jsx("td",{role:"gridcell",colSpan:pt+(it?1:0),style:{padding:0,border:"none"}})}),Zo]})]})})}),jsxRuntime.jsxs("div",{ref:ct,className:"datagrid-table-wrapper custom-scrollbar pivot-right-pane",style:{overflow:"auto",height:"100%",position:"relative",outline:"none",flex:1},children:[r&&jsxRuntime.jsxs("div",{className:"absolute inset-0 z-50 flex flex-col items-center justify-center pivot-bg-surface backdrop-blur-[2px] transition-opacity duration-300 rounded",style:{gap:10},children:[jsxRuntime.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-primary"}),jsxRuntime.jsx("span",{className:"text-sm font-semibold pivot-text-primary",children:D("initializing")}),jsxRuntime.jsxs("div",{style:{width:220,display:"flex",flexDirection:"column",gap:6,alignItems:"center"},children:[jsxRuntime.jsx("div",{style:{width:"100%",height:6,borderRadius:999,overflow:"hidden",backgroundColor:"color-mix(in srgb, var(--pivot-border) 60%, transparent)"},children:jsxRuntime.jsx("div",{style:{width:`${Math.max(0,Math.min(100,c))}%`,height:"100%",borderRadius:999,backgroundColor:"var(--pivot-primary)",transition:"width 160ms ease-out"}})}),jsxRuntime.jsxs("span",{className:"text-xs font-semibold",style:{color:"var(--pivot-text)"},children:[Math.round(c),"%"]})]})]}),jsxRuntime.jsx("div",{style:{height:lo+Ce,width:"max-content",position:"relative"},children:jsxRuntime.jsxs("table",{className:"kanuni-pivot-table",role:ae?"presentation":void 0,style:{borderCollapse:"separate",borderSpacing:0,width:0,minWidth:"100%",tableLayout:"fixed"},children:[jsxRuntime.jsx("colgroup",{children:Array.from({length:te||1}).map((i,n)=>jsxRuntime.jsx("col",{style:{width:`var(--col-width-data-${n}, ${E.data}px)`}},`col-data-${n}`))}),jsxRuntime.jsxs("thead",{ref:oo,role:"rowgroup",style:{position:"sticky",top:0,zIndex:50,backgroundColor:"var(--pivot-surface-header)"},children:[jsxRuntime.jsx("tr",{role:"row",style:{height:42},children:jsxRuntime.jsx("th",{ref:zo,role:"columnheader",colSpan:te||1,style:{borderBottom:"1px solid var(--pivot-border)",padding:0,verticalAlign:"top",backgroundColor:"var(--pivot-surface-header)",zIndex:1},children:jsxRuntime.jsx("div",{style:{position:"sticky",insetInlineStart:0,width:"max-content",maxWidth:"100%"},children:jsxRuntime.jsx(Ho,{area:"column",title:D("columnArea"),icon:jsxRuntime.jsx(lucideReact.Columns3,{size:13}),fields:l,onRemoveField:V,onFilterClick:O||(()=>{}),onContextMenu:I,onSort:H,onMoveField:z})})})}),Qt.map((i,n)=>jsxRuntime.jsxs("tr",{role:"row",style:{height:T},children:[i.map((s,g)=>{let b=s.fieldId?l.find(W=>W.id===s.fieldId):void 0,N=!!b?.filterValues&&b.filterValues.size>0,J=s.leafStart,Z=b&&!s.isTotal?pivotgridCore.formatDimensionValue(s.caption,b,"grid",f):s.caption,nt=Z;b?.cellTemplate?nt=b.cellTemplate({value:s.caption,displayValue:Z,field:b}):nt=jsxRuntime.jsx("span",{className:"select-none",children:Z});let tt={text:nt,style:{textAlign:"left",fontWeight:s.isTotal?600:500,borderBottom:"1px solid var(--pivot-border)",borderRight:"1px solid var(--pivot-border)",color:"var(--pivot-text-header, inherit)",backgroundColor:"var(--pivot-surface-header)",cursor:b?"pointer":"context-menu",position:"relative",zIndex:1,padding:"4px 6px"},className:`kanuni-pivot-header-cell group ${s.isTotal?"kanuni-pivot-header-total":""}`};return R&&R({area:"column",cell:null,rowIndex:n,columnIndex:J,cellConfig:tt}),jsxRuntime.jsxs("th",{role:"columnheader","aria-expanded":s.hasChildren?!!s.isExpanded:void 0,className:tt.className,colSpan:s.colSpan,rowSpan:s.rowSpan,style:tt.style,onClick:()=>{if(Date.now()-Pt.current<100||!b)return;let W=a.find(gt=>gt.sortBySummaryField===s.fieldId&&(gt.sortBySummaryPath||"")===(s.colPath||""));if(W&&H){let gt=W.sortOrder==="asc"?"desc":"asc";H(W.id,gt);return}},onContextMenu:W=>{s.hasChildren?(W.preventDefault(),ho({x:W.clientX,y:W.clientY,path:s.colPath,isExpanded:!!s.isExpanded,depth:n,type:"col"})):I&&s.fieldId&&(W.preventDefault(),I(W.clientX,W.clientY,s.fieldId,s.colPath));},children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:4},children:[s.hasChildren&&jsxRuntime.jsx("span",{className:"kanuni-pivot-expand-icon","aria-hidden":"true",style:{cursor:"pointer",marginRight:4,flexShrink:0},onClick:W=>{W.stopPropagation(),v(s.colPath);},children:s.isExpanded?"\u2212":"+"}),tt.text,(()=>{let W=a.find(gt=>gt.sortBySummaryField===s.fieldId&&(gt.sortBySummaryPath||"")===(s.colPath||""));return W?W.sortOrder==="asc"?jsxRuntime.jsx(lucideReact.ArrowUp,{size:12,className:"pivot-text-primary"}):jsxRuntime.jsx(lucideReact.ArrowDown,{size:12,className:"pivot-text-primary"}):null})(),s.fieldId&&jsxRuntime.jsx("span",{className:`cursor-pointer transition-opacity ${N?"opacity-100 pivot-text-danger":"opacity-0 group-hover:opacity-70"}`,onClick:W=>{W.stopPropagation(),O&&s.fieldId&&O(W.clientX,W.clientY,s.fieldId);},children:jsxRuntime.jsx(lucideReact.Filter,{size:10,fill:N?"currentColor":"none"})})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-resize-handle",onMouseDown:W=>vt(W,`leaf-${J}-${s.colSpan}`,E.data,s.colSpan),onClick:W=>W.stopPropagation(),style:{right:-3}})]},`col-hdr-${n}-${g}`)}),i.length===0&&jsxRuntime.jsx("th",{role:"columnheader",colSpan:te||1,style:{borderBottom:"1px solid var(--pivot-border)",backgroundColor:"var(--pivot-surface-header)",padding:0}})]},`col-hdr-row-${n}`))]}),jsxRuntime.jsxs("tbody",{role:"rowgroup",onClick:Xo,onDoubleClick:jo,onContextMenu:_o,onMouseDown:Yo,onMouseOver:Jo,children:[ce>0&&jsxRuntime.jsx("tr",{role:"row",style:{height:ce*T},children:jsxRuntime.jsx("td",{role:"gridcell",colSpan:te||1,style:{padding:0,border:"none"}})}),go]})]})})]}),fo&&(et??(i=>jsxRuntime.jsx(sr,{...i})))({menu:fo,onClose:()=>ho(null),onToggleExpand:P,onToggleColExpand:v,onExpandPaths:F,onCollapsePaths:u,onExpandColPaths:h,onCollapseColPaths:S,rowTree:t.rowTree,colTree:t.colTree,t:D}),jsxRuntime.jsx("div",{ref:ut,style:{position:"absolute",top:0,bottom:0,left:0,width:2,backgroundColor:"var(--pivot-primary)",zIndex:100,display:"none",pointerEvents:"none"}})]})}function mr({reports:t,activeReportId:r,onSaveNew:c,onUpdateCurrent:a,onSaveAs:l,onLoadReport:e,onDeleteReport:p,onSetDefault:C}){let{t:M}=mt(),[P,F]=un.useState(false),u=un.useRef(null);un.useEffect(()=>{let d=v=>{u.current&&!u.current.contains(v.target)&&F(false);};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[]);let y=t.find(d=>d.id===r);return jsxRuntime.jsxs("div",{className:"pivot-relative",ref:u,children:[jsxRuntime.jsxs("button",{className:`kanuni-pivot-report-btn ${P?"kanuni-pivot-report-btn--open":r?"kanuni-pivot-report-btn--active":"kanuni-pivot-report-btn--default"}`,title:M("viewsAndReports"),onClick:()=>F(!P),children:[jsxRuntime.jsx(lucideReact.Bookmark,{size:15}),jsxRuntime.jsx("span",{className:"pivot-truncate",style:{maxWidth:"120px"},children:y?y.name:M("views")})]}),P&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-report-dropdown pivot-animate-slide-up",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:M("actions")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-item",onClick:()=>{F(false),c();},children:[jsxRuntime.jsx(lucideReact.Save,{size:16,color:"var(--pivot-success)"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"pivot-font-medium",children:M("saveNewView")})})]}),r&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-item",onClick:()=>{F(false),a();},children:[jsxRuntime.jsx(lucideReact.SaveAll,{size:16,color:"var(--pivot-warning)"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"pivot-font-medium",children:M("saveChangesOverwrite")})})]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-item",onClick:()=>{F(false),l();},children:[jsxRuntime.jsx(lucideReact.Copy,{size:16,color:"var(--pivot-info)"}),jsxRuntime.jsx("div",{children:jsxRuntime.jsx("div",{className:"pivot-font-medium",children:M("saveAsCopy")})})]})]}),t.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"8px",borderTop:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:M("savedViews")}),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-list pivot-custom-scrollbar",children:t.map(d=>jsxRuntime.jsxs("div",{className:`kanuni-pivot-report-list-item ${d.id===r?"kanuni-pivot-report-list-item--active":""}`,children:[jsxRuntime.jsxs("button",{className:"kanuni-pivot-report-list-btn",onClick:()=>{F(false),e(d.id);},children:[d.id===r?jsxRuntime.jsx(lucideReact.Check,{size:14,color:"var(--pivot-primary)",style:{flexShrink:0}}):jsxRuntime.jsx(lucideReact.FolderOpen,{size:14,color:"var(--pivot-text-muted)",style:{flexShrink:0}}),jsxRuntime.jsx("span",{className:`pivot-text-sm pivot-truncate ${d.id===r?"pivot-text-primary pivot-font-medium":"pivot-text"}`,style:{color:d.id===r?"var(--pivot-primary)":"var(--pivot-text)"},children:d.name}),d.isDefault&&jsxRuntime.jsx(lucideReact.Star,{size:12,color:"var(--pivot-warning)",fill:"var(--pivot-warning)",style:{flexShrink:0}})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-report-actions",children:[!d.isDefault&&jsxRuntime.jsx("button",{className:"kanuni-pivot-action-btn kanuni-pivot-action-btn--warning",title:M("makeDefault"),onClick:v=>{v.stopPropagation(),C(d.id);},children:jsxRuntime.jsx(lucideReact.Star,{size:14})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-action-btn kanuni-pivot-action-btn--danger",title:M("deleteReport"),onClick:v=>{v.stopPropagation(),confirm(M("deleteReportConfirm").replace("{0}",d.name))&&(p(d.id),d.id===r&&F(false));},children:jsxRuntime.jsx(lucideReact.Trash2,{size:14})})]})]},d.id))})]})]})]})}function br({onToggleFieldChooser:t,fieldChooserOpen:r,onRefresh:c,onExport:a,onImportFile:l,onImportFiles:e,onPasteImport:p,onExpandAll:C,onCollapseAll:M,onAddCalculatedField:P,onOpenPrefilter:F,onToggleChart:u,isFullscreen:y,onToggleFullscreen:d,reports:v=[],activeReportId:h=null,onSaveNewReport:S,onUpdateCurrentReport:k,onSaveAsReport:I,onLoadReport:O,onDeleteReport:V,onSetDefaultReport:H,onGlobalContextMenu:z,selectionStats:X,toolbarConfig:Y={},registry:j,advancedExport:_=false,upgradeUrl:G,onSearch:U,searchText:L=""}){let{t:R,locale:et}=mt(),[w,D]=un.useState(false),[bt,f]=un.useState(false),T=un.useRef(null),K=un.useRef(null),ot=un.useRef(null),kt=un.useRef(void 0),[E,dt]=un.useState(L);un.useEffect(()=>{document.activeElement!==ot.current&&dt(L);},[L]),un.useEffect(()=>()=>clearTimeout(kt.current),[]);let st=rt=>{clearTimeout(kt.current),U?.(rt);};un.useEffect(()=>{let rt=Wt=>{T.current&&!T.current.contains(Wt.target)&&D(false),K.current&&!K.current.contains(Wt.target)&&f(false);};return document.addEventListener("mousedown",rt),()=>document.removeEventListener("mousedown",rt)},[]);let ct=rt=>{D(false),a(rt);},q=(rt,Wt,m,x,ut=false)=>{let Q=ut&&!_,Pt=Q&&!!G;return jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px",...Q?{opacity:.6,cursor:Pt?"pointer":"not-allowed"}:{}},onClick:Q?Pt?()=>{D(false),window.open(G,"_blank","noopener,noreferrer");}:void 0:()=>ct(rt),disabled:Q&&!Pt,title:Pt?R("enterpriseUpgradeHint"):void 0,children:[Wt,jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"pivot-font-medium pivot-flex pivot-items-center",style:{gap:"6px"},children:[m,Q&&jsxRuntime.jsx("span",{style:{fontSize:"9px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"1px 5px",borderRadius:"9999px",backgroundColor:"color-mix(in srgb, var(--pivot-warning) 18%, transparent)",color:"var(--pivot-warning)"},children:R("enterpriseBadge")})]}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:x})]})]})},de=()=>{f(false);let rt=document.createElement("input");rt.type="file",rt.accept=".json,.csv,.tsv,.txt,.xml,.xlsx,.xls",rt.multiple=!!e,rt.onchange=Wt=>{let m=Array.from(Wt.target.files??[]);m.length!==0&&(e?e(m):l&&l(m[0]));},rt.click();},ne=()=>{f(false),p?.();};return jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center pivot-justify-start",style:{padding:"4px 8px",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 50%, var(--pivot-surface))",borderTop:"1px solid var(--pivot-border)",gap:"4px"},onContextMenu:rt=>{z&&(rt.preventDefault(),z(rt.clientX,rt.clientY));},children:[Y.showSaveReport!==false&&S&&O&&V&&H&&k&&I&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(mr,{reports:v,activeReportId:h,onSaveNew:S,onUpdateCurrent:k,onSaveAs:I,onLoadReport:O,onDeleteReport:V,onSetDefault:H}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"})]}),Y.showFieldChooserToggle!==false&&jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${r?"kanuni-pivot-footer-btn--active":""}`,title:R("showFieldList"),onClick:t,children:jsxRuntime.jsx(lucideReact.Settings,{size:15})}),F&&jsxRuntime.jsx("button",{onClick:F,className:"kanuni-pivot-footer-btn",title:R("filterBuilder"),children:jsxRuntime.jsx(lucideReact.Filter,{size:15})}),u&&jsxRuntime.jsx("button",{onClick:u,className:"kanuni-pivot-footer-btn",title:R("chartToggle"),children:jsxRuntime.jsx(lucideReact.BarChart,{size:15})}),Y.showCalculatedFields!==false&&P&&jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:R("calculatedMeasureDesigner"),onClick:P,children:jsxRuntime.jsx(lucideReact.Calculator,{size:15})}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),Y.showExpandCollapseAll!==false&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:R("expandAll"),onClick:C,children:jsxRuntime.jsx(lucideReact.Maximize2,{size:15})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:R("collapseAll"),onClick:M,children:jsxRuntime.jsx(lucideReact.Minimize2,{size:15})})]}),Y.showRefreshButton!==false&&c&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),jsxRuntime.jsx("button",{className:"kanuni-pivot-footer-btn",title:R("refreshData"),onClick:c,children:jsxRuntime.jsx(lucideReact.RefreshCw,{size:15})})]}),Y.showFullscreenToggle!==false&&d&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${y?"kanuni-pivot-footer-btn--active":""}`,style:y?{backgroundColor:"color-mix(in srgb, var(--pivot-primary) 10%, transparent)",color:"var(--pivot-primary)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 30%, transparent)"}:{},title:R(y?"exitFullscreen":"enterFullscreen"),onClick:d,children:y?jsxRuntime.jsx(lucideReact.Shrink,{size:15}):jsxRuntime.jsx(lucideReact.Fullscreen,{size:15})})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),Y.showImportFile!==false&&(l||e)&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"pivot-relative",ref:K,children:[jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${bt?"kanuni-pivot-footer-btn--active":""}`,title:R("importFile"),onClick:()=>f(rt=>!rt),children:jsxRuntime.jsx(lucideReact.Upload,{size:15})}),bt&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar",style:{bottom:"100%",left:0,marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"},children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:R("importFile")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:de,children:[jsxRuntime.jsx(lucideReact.Upload,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:R("importFromFile")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:"CSV \xB7 Excel \xB7 JSON \xB7 XML"})]})]}),p&&jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:ne,children:[jsxRuntime.jsx(lucideReact.ClipboardPaste,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:R("pasteImport")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:R("pasteImportHint")})]})]})]})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"})]}),Y.showExportButton!==false&&jsxRuntime.jsxs("div",{className:"pivot-relative",ref:T,children:[jsxRuntime.jsx("button",{className:`kanuni-pivot-footer-btn ${w?"kanuni-pivot-footer-btn--active":""}`,title:R("export"),onClick:()=>D(!w),children:jsxRuntime.jsx(lucideReact.Download,{size:15})}),w&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-slide-up pivot-custom-scrollbar",style:{bottom:"100%",left:0,marginBottom:"4px",width:"256px",maxHeight:"384px",overflowY:"auto"},children:[j&&j.getPluginsByType("exporter").length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:R("customExports")}),j.getPluginsByType("exporter").map(rt=>jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct(rt.id),children:[jsxRuntime.jsx(lucideReact.Database,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs("div",{className:"pivot-font-medium",children:[rt.id.replace("exporter-","").toUpperCase()," ",R("export")]}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:R("customPlugin")})]})]},rt.id)),jsxRuntime.jsx("div",{className:"kanuni-pivot-dropdown-divider"})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:R("excelExport")}),q("excel-pivot",jsxRuntime.jsx(lucideReact.FileSpreadsheet,{size:16,color:"var(--pivot-success)"}),R("pivotView"),R("preservesGridLayout"),true),q("excel-list",jsxRuntime.jsx(lucideReact.FileSpreadsheet,{size:16,color:"var(--pivot-success)"}),R("listView"),R("rawFlatData"),true),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"4px",borderTop:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:R("document")}),q("pdf",jsxRuntime.jsx(lucideReact.FileText,{size:16,color:"var(--pivot-danger)"}),R("pdfDocument"),R("printReadyLayout"),true),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("print"),children:[jsxRuntime.jsx(lucideReact.Printer,{size:16,color:"var(--pivot-info)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:R("print")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:R("sendToPrinter")})]})]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("clipboard"),children:[jsxRuntime.jsx(lucideReact.Copy,{size:16,color:"var(--pivot-primary)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:R("copyToClipboard")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:R("tabSeparatedValues")})]})]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("json-snapshot"),children:[jsxRuntime.jsx(lucideReact.FileJson,{size:16,color:"var(--pivot-success)"}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("div",{className:"pivot-font-medium",children:R("fullSnapshot")}),jsxRuntime.jsx("div",{className:"pivot-text-xs pivot-text-muted",children:R("saveSessionState")})]})]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"4px",borderTop:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:R("rawDataFormats")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("csv"),children:[jsxRuntime.jsx(lucideReact.File,{size:16,color:"var(--pivot-info)"})," CSV"]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("json-pivot"),children:[jsxRuntime.jsx(lucideReact.FileJson,{size:16,color:"var(--pivot-warning)"})," JSON (Tree)"]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("json"),children:[jsxRuntime.jsx(lucideReact.FileJson,{size:16,color:"var(--pivot-warning)"})," JSON (List)"]}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-dropdown-item pivot-flex",style:{gap:"12px"},onClick:()=>ct("xml"),children:[jsxRuntime.jsx(lucideReact.Database,{size:16,color:"var(--pivot-text-muted)"})," XML"]})]})]}),U&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-footer-divider"}),jsxRuntime.jsx("input",{ref:ot,type:"search",className:"kanuni-pivot-search",placeholder:R("search"),"aria-label":R("search").replace(/[.\u2026]+$/,""),value:E,onChange:rt=>{let Wt=rt.target.value;dt(Wt),clearTimeout(kt.current),kt.current=setTimeout(()=>st(Wt),250);},onKeyDown:rt=>{rt.stopPropagation(),rt.key==="Enter"?st(E):rt.key==="Escape"&&(dt(""),st(""));}})]}),X&&jsxRuntime.jsxs("div",{className:"pivot-text-muted pivot-font-medium pivot-flex pivot-items-center",style:{marginLeft:"auto",fontSize:"11px",gap:"8px",paddingRight:"8px",userSelect:"none"},children:[jsxRuntime.jsxs("span",{children:["(",R("count"),": ",X.count,")"]}),jsxRuntime.jsxs("span",{children:["(",R("sum"),": ",new Intl.NumberFormat(et,{minimumFractionDigits:2,maximumFractionDigits:2}).format(X.sum),")"]}),jsxRuntime.jsxs("span",{children:["(",R("avg"),": ",new Intl.NumberFormat(et,{minimumFractionDigits:2,maximumFractionDigits:2}).format(X.avg),")"]}),jsxRuntime.jsxs("span",{children:["(",R("min"),": ",new Intl.NumberFormat(et,{minimumFractionDigits:2,maximumFractionDigits:2}).format(X.min),")"]}),jsxRuntime.jsxs("span",{children:["(",R("max"),": ",new Intl.NumberFormat(et,{minimumFractionDigits:2,maximumFractionDigits:2}).format(X.max),")"]})]})]})}function Sa({type:t,isCalculated:r}){if(r)return jsxRuntime.jsx(lucideReact.Settings2,{size:12,color:"var(--pivot-primary)"});switch(t){case "number":return jsxRuntime.jsx(lucideReact.Hash,{size:12,color:"var(--pivot-primary)"});case "date":return jsxRuntime.jsx(lucideReact.Calendar,{size:12,color:"var(--pivot-primary)"});case "boolean":return jsxRuntime.jsx(lucideReact.Filter,{size:12,color:"var(--pivot-primary)"});default:return jsxRuntime.jsx(lucideReact.Type,{size:12,color:"var(--pivot-primary)"})}}function Ta({field:t,isFirst:r,onRemove:c,onDeleteField:a,showCheckbox:l,isChecked:e,onToggleCheckbox:p,onFilterClick:C}){let{t:M}=mt(),{attributes:P,listeners:F,setNodeRef:u,transform:y,isDragging:d}=core.useDraggable({id:`chooser-${t.id}`,data:{type:"Field",field:t}}),{setNodeRef:v}=core.useDroppable({id:`chooser-${t.id}`,data:{type:"Field",field:t}}),h=z=>{u(z),v(z);},S=ue(),k=S.targetId===t.id,I=k&&S.intent==="before",O=k&&S.intent==="after",V={transform:y?`translate3d(${y.x}px, ${y.y}px, 0)`:void 0,position:"relative"},H=!!t.filterValues&&t.filterValues.size>0;return jsxRuntime.jsxs("div",{ref:h,style:V,className:`kanuni-pivot-field-chip ${d?"is-dragging":""}`,"data-drag-scope":"grip",children:[I&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",top:r?-4:-3,left:-4,right:-4,height:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,left:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderLeft:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,right:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderRight:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-1,left:0,right:0,height:2,backgroundColor:"var(--pivot-primary)"}})]}),O&&jsxRuntime.jsxs("div",{style:{position:"absolute",zIndex:100,pointerEvents:"none",bottom:-3,left:-4,right:-4,height:0},children:[jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,left:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderLeft:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-4,right:0,width:0,height:0,borderTop:"4px solid transparent",borderBottom:"4px solid transparent",borderRight:"5px solid var(--pivot-primary)"}}),jsxRuntime.jsx("div",{style:{position:"absolute",top:-1,left:0,right:0,height:2,backgroundColor:"var(--pivot-primary)"}})]}),jsxRuntime.jsx("div",{...P,...F,"data-drag-grip":"",style:{color:"var(--pivot-text-muted)",cursor:"grab",flexShrink:0,opacity:.5},children:jsxRuntime.jsx(lucideReact.GripVertical,{size:14})}),l&&jsxRuntime.jsx("input",{type:"checkbox",checked:e,onChange:z=>p&&p(t,z.target.checked),className:"kanuni-pivot-checkbox",style:{flexShrink:0}}),jsxRuntime.jsx(Sa,{type:t.dataType,isCalculated:t.isCalculated}),jsxRuntime.jsxs("span",{className:"pivot-truncate",style:{flex:1,color:"var(--pivot-text)",textAlign:"left"},children:[t.caption,t.area==="data"&&t.summaryType?jsxRuntime.jsx("span",{style:{fontSize:"10px",marginLeft:"4px",backgroundColor:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--pivot-primary) 45%, transparent)",color:"var(--pivot-text)",padding:"0 4px",borderRadius:"4px",fontWeight:700,textTransform:"uppercase"},children:t.summaryType}):null]}),jsxRuntime.jsxs("div",{className:`kanuni-pivot-field-chip-actions${H?" is-filtered":""}`,children:[C&&t.area!=="data"&&jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn",style:H?{color:"var(--pivot-danger)",backgroundColor:"color-mix(in srgb, var(--pivot-danger) 10%, transparent)"}:{},onClick:z=>{z.stopPropagation(),C(z,t);},title:M("filterField"),children:jsxRuntime.jsx(lucideReact.Filter,{size:12,fill:H?"currentColor":"none"})}),!C&&H&&jsxRuntime.jsx(lucideReact.Filter,{size:12,color:"var(--pivot-danger)",fill:"currentColor"}),t.isCalculated&&a&&jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger",onClick:z=>{z.stopPropagation(),a(t.id);},title:M("deletePermanently"),children:jsxRuntime.jsx(lucideReact.Trash,{size:12})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-chip-btn kanuni-pivot-chip-btn--danger",onClick:z=>{z.stopPropagation(),c(t.id);},title:M("removeFromArea"),children:jsxRuntime.jsx(lucideReact.X,{size:12})})]})]})}function Ke({area:t,fields:r,title:c,emptyText:a,onRemoveField:l,onDeleteField:e,maxHeight:p=150,showCheckboxes:C,onToggleCheckbox:M,onFilterClick:P}){let{setNodeRef:F,isOver:u}=core.useDroppable({id:`chooser-${t}`,data:{type:"Area",area:`chooser-${t}`}}),{setNodeRef:y}=core.useDroppable({id:`chooser-${t}-ghost-end`}),d=ue(),h=(d.targetArea===`chooser-${t}`||d.targetArea===t)&&d.intent==="append";return jsxRuntime.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",transition:"background-color 0.2s",backgroundColor:u?"color-mix(in srgb, var(--pivot-primary) 5%, transparent)":"transparent",boxShadow:u?"inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)":"none"},children:[c&&jsxRuntime.jsx("div",{style:{fontSize:"12px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--pivot-text-muted)",backgroundColor:"color-mix(in srgb, var(--pivot-surface-header) 30%, transparent)",padding:"8px 12px",borderBottom:"1px solid color-mix(in srgb, var(--pivot-border) 50%, transparent)"},children:c}),jsxRuntime.jsxs("div",{ref:F,style:{maxHeight:typeof p=="number"?`${p}px`:p,flex:1,padding:"8px",minHeight:"80px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"6px",alignItems:r.length===0?"center":"stretch",justifyContent:r.length===0?"center":"flex-start"},className:"pivot-custom-scrollbar",children:[r.length===0&&a&&jsxRuntime.jsx("div",{style:{fontSize:"12px",color:"color-mix(in srgb, var(--pivot-text-muted) 70%, transparent)",fontStyle:"italic",textAlign:"center",width:"100%"},children:a}),r.map((S,k)=>jsxRuntime.jsx(Ta,{field:S,isFirst:k===0,onRemove:l,onDeleteField:e,showCheckbox:C,isChecked:S.area!=="chooser",onToggleCheckbox:M,onFilterClick:P},S.id)),jsxRuntime.jsx("div",{ref:y,style:{width:"100%",minHeight:"24px",transition:"background-color 0.2s",borderRadius:"var(--pivot-border-radius-sm)",backgroundColor:h?"color-mix(in srgb, var(--pivot-primary) 10%, transparent)":"transparent",boxShadow:h?"inset 0 0 0 1px color-mix(in srgb, var(--pivot-primary) 50%, transparent)":"none"},children:h&&r.length>0&&jsxRuntime.jsx("div",{style:{width:"100%",height:"4px",backgroundColor:"var(--pivot-primary)",borderRadius:"2px",marginTop:"4px"}})})]})]})}function pi({fields:t,onClose:r,onRemoveField:c,onDeleteField:a,onChangeFieldArea:l,onShowFields:e,onFilterClick:p}){let{t:C,locale:M}=mt(),[P,F]=un.useState(""),[u,y]=un.useState({x:0,y:0}),[d,v]=un.useState({width:700,height:550}),[h,S]=un.useState(false),[k,I]=un.useState(null),[O,V]=un.useState(window.innerWidth<=768),H=un.useRef(false);un.useEffect(()=>{if(!H.current&&!O){let f=Math.min(700,window.innerWidth-32),T=Math.min(550,window.innerHeight-32),K=(window.innerWidth-f)/2,ot=(window.innerHeight-T)/2;v({width:f,height:T}),y({x:K,y:ot}),H.current=true;}},[O]),un.useEffect(()=>{let f=()=>{let T=window.innerWidth<=768;V(T),T||y(K=>({x:Math.min(K.x,window.innerWidth-d.width),y:Math.min(K.y,window.innerHeight-d.height)}));};return window.addEventListener("resize",f),()=>window.removeEventListener("resize",f)},[d.width,d.height]);let z=f=>{O||f.target.closest(".dnd-draggable")||f.target.closest("button")||f.target.closest("input")||f.target.closest('input[type="checkbox"]')||(S(true),f.currentTarget.setPointerCapture(f.pointerId));},X=f=>{h&&y(T=>({x:Math.max(0,T.x+f.movementX),y:Math.max(0,T.y+f.movementY)}));},Y=f=>{S(false),f.currentTarget.releasePointerCapture(f.pointerId);},j=(f,T)=>{f.stopPropagation(),I(T),f.currentTarget.setPointerCapture(f.pointerId);},_=f=>{if(!k)return;let T=f.movementX,K=f.movementY;v(ot=>{let kt=ot.width,E=ot.height,dt=0,st=0;return k.includes("e")&&(kt+=T),k.includes("s")&&(E+=K),k.includes("w")&&(kt-=T,kt>=400&&(dt=T)),k.includes("n")&&(E-=K,E>=400&&(st=K)),kt=Math.max(400,kt),E=Math.max(400,E),(dt!==0||st!==0)&&y(ct=>({x:Math.max(0,ct.x+dt),y:Math.max(0,ct.y+st)})),{width:kt,height:E}});},G=f=>{I(null),f.currentTarget.releasePointerCapture(f.pointerId);},U=un.useMemo(()=>{let f=new Map;return t.map(T=>{let K=T.caption||T.id||"";if(f.has(K)){let ot=f.get(K)+1;return f.set(K,ot),{...T,caption:`${K} (${ot})`}}return f.set(K,1),T})},[t]),L=un.useMemo(()=>{let f=[...U].sort((T,K)=>{let ot=(T.caption||"").toLowerCase(),kt=(K.caption||"").toLowerCase();return ot.localeCompare(kt,M||"en")});return P?f.filter(T=>(T.caption||"").toLowerCase().includes(P.toLowerCase())):f},[U,P,M]),R=un.useMemo(()=>U.filter(f=>f.area==="row").sort((f,T)=>(f.areaIndex||0)-(T.areaIndex||0)),[U]),et=un.useMemo(()=>U.filter(f=>f.area==="column").sort((f,T)=>(f.areaIndex||0)-(T.areaIndex||0)),[U]),w=un.useMemo(()=>U.filter(f=>f.area==="data").sort((f,T)=>(f.areaIndex||0)-(T.areaIndex||0)),[U]),D=un.useMemo(()=>U.filter(f=>f.area==="filter").sort((f,T)=>(f.areaIndex||0)-(T.areaIndex||0)),[U]),bt=(f,T)=>{if(l)if(!T)c(f.id);else {let ot=f.dataType==="number"?"data":"row";l(f.id,ot);}};return jsxRuntime.jsx("div",{className:`fixed inset-0 z-[100] kanuni-pivot-chooser-backdrop overflow-auto pointer-events-auto ${O?"flex items-center justify-center":""}`,onClick:r,children:jsxRuntime.jsxs("div",{className:`flex flex-col bg-surface shadow-2xl border border-border overflow-hidden ${O?"w-[95vw] h-[95vh] rounded-xl":"rounded-lg"}`,style:O?{position:"fixed",inset:0,width:"100vw",height:"100vh",padding:0,zIndex:100,transform:"none",borderRadius:0}:{position:"fixed",left:u.x,top:u.y,width:d.width,height:d.height,maxWidth:"95vw",maxHeight:"95vh",transform:"none",padding:0,zIndex:100,boxShadow:"var(--pivot-shadow-lg)"},onClick:f=>f.stopPropagation(),children:[jsxRuntime.jsxs("div",{className:`pivot-field-chooser__header flex items-center justify-between p-3 border-b border-border bg-surface-header/90 backdrop-blur-md ${O?"":"cursor-move"}`,onPointerDown:z,onPointerMove:X,onPointerUp:Y,onPointerCancel:Y,children:[jsxRuntime.jsxs("h3",{className:"text-[15px] font-semibold m-0 flex items-center gap-2 text-surface-header-fg select-none",children:[jsxRuntime.jsx(lucideReact.GripHorizontal,{size:18,className:"text-muted-fg opacity-60"}),C("allFields")]}),jsxRuntime.jsx("button",{className:"btn-icon hover:bg-danger/10 hover:text-danger transition-colors rounded-full p-1.5 focus:outline-none",onClick:r,onPointerDown:f=>f.stopPropagation(),children:jsxRuntime.jsx(lucideReact.X,{size:18})})]}),jsxRuntime.jsxs("div",{className:"flex flex-1 overflow-hidden flex-col md:flex-row bg-surface-sunken/30",children:[jsxRuntime.jsxs("div",{className:"w-full md:w-[40%] flex flex-col border-b md:border-b-0 md:border-r border-border bg-surface",children:[jsxRuntime.jsx("div",{className:"p-3 border-b border-border/60 bg-surface/80",children:jsxRuntime.jsxs("div",{className:"relative",children:[jsxRuntime.jsx(lucideReact.Search,{size:16,className:"absolute start-3 top-1/2 transform -translate-y-1/2 text-muted-fg opacity-60"}),jsxRuntime.jsx("input",{type:"text",placeholder:C("search"),className:"input input-sm w-full ps-9 bg-surface-hover/50 border-border focus:border-primary focus:ring-1 focus:ring-primary/20 transition-all rounded-md text-[13px]",value:P,onChange:f=>F(f.target.value)})]})}),jsxRuntime.jsxs("div",{className:"flex-1 overflow-hidden p-2",children:[jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[jsxRuntime.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-muted-fg/80 mb-2 px-1",children:C("allFields")}),jsxRuntime.jsx("button",{type:"button",className:"kanuni-pivot-popup-action-btn kanuni-pivot-chooser-select-all",style:{color:"var(--pivot-primary)"},disabled:!L.some(f=>f.area==="chooser"),onClick:()=>e?.(L.filter(f=>f.area==="chooser").map(f=>f.id)),children:C("selectAll")})]}),jsxRuntime.jsx(Ke,{area:"chooser",fields:L,emptyText:C("noItems"),onRemoveField:c,onDeleteField:a,maxHeight:"100%",showCheckboxes:true,onToggleCheckbox:bt,onFilterClick:p})]})]}),jsxRuntime.jsx("div",{className:"w-full md:w-[60%] flex-1 overflow-y-auto custom-scrollbar p-3 bg-surface-sunken/30",children:jsxRuntime.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3 h-full auto-rows-fr",children:[jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Ke,{area:"filter",title:C("filterArea"),fields:D,emptyText:C("dropHere"),onRemoveField:c,onDeleteField:a,onFilterClick:p,maxHeight:"100%"})}),jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Ke,{area:"column",title:C("columnArea"),fields:et,emptyText:C("dropHere"),onRemoveField:c,onDeleteField:a,onFilterClick:p,maxHeight:"100%"})}),jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Ke,{area:"row",title:C("rowArea"),fields:R,emptyText:C("dropHere"),onRemoveField:c,onDeleteField:a,onFilterClick:p,maxHeight:"100%"})}),jsxRuntime.jsx("div",{className:"border border-border/80 rounded-md shadow-sm bg-surface overflow-hidden flex flex-col hover:border-primary/40 transition-colors",children:jsxRuntime.jsx(Ke,{area:"data",title:C("dataArea"),fields:w,emptyText:C("dropHere"),onRemoveField:c,onDeleteField:a,maxHeight:"100%"})})]})})]}),!O&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"absolute top-0 left-0 right-0 h-1.5 cursor-n-resize z-50",onPointerDown:f=>j(f,"n"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 right-0 h-1.5 cursor-s-resize z-50",onPointerDown:f=>j(f,"s"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 bottom-0 left-0 w-1.5 cursor-w-resize z-50",onPointerDown:f=>j(f,"w"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 bottom-0 right-0 w-1.5 cursor-e-resize z-50",onPointerDown:f=>j(f,"e"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 left-0 w-3 h-3 cursor-nw-resize z-[51]",onPointerDown:f=>j(f,"nw"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute top-0 right-0 w-3 h-3 cursor-ne-resize z-[51]",onPointerDown:f=>j(f,"ne"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute bottom-0 left-0 w-3 h-3 cursor-sw-resize z-[51]",onPointerDown:f=>j(f,"sw"),onPointerMove:_,onPointerUp:G,onPointerCancel:G}),jsxRuntime.jsx("div",{className:"absolute bottom-0 right-0 w-3 h-3 cursor-se-resize z-[51] flex items-end justify-end p-0.5 opacity-50 hover:opacity-100",onPointerDown:f=>j(f,"se"),onPointerMove:_,onPointerUp:G,onPointerCancel:G,children:jsxRuntime.jsx("div",{className:"w-2 h-2 border-e-2 border-b-2 border-muted-fg rounded-sm pointer-events-none"})})]})]})})}function wr({field:t,onClose:r,onSave:c}){let{t:a}=mt(),[l,e]=un.useState(t.caption),[p,C]=un.useState(t.summaryType||"sum"),[M,P]=un.useState(t.summaryDisplayMode||"absolute"),[F,u]=un.useState(t.groupInterval||""),y=()=>{c({...t,caption:l,summaryType:p,summaryDisplayMode:M,groupInterval:F||void 0});},d=t.area==="data"||t.area==="chooser",v=t.area==="row"||t.area==="column"||t.area==="filter"||t.area==="chooser";return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in",onClick:r}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"400px"},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",children:[jsxRuntime.jsx("h2",{className:"kanuni-pivot-modal-title",children:a("fieldSettings")}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:"kanuni-pivot-modal-close","aria-label":a("close"),children:jsxRuntime.jsx(lucideReact.X,{size:20})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("caption")}),jsxRuntime.jsx("input",{type:"text",className:"kanuni-pivot-input",value:l,onChange:h=>e(h.target.value)})]}),d&&t.dataType==="number"&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("summaryType")}),jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",value:p,onChange:h=>C(h.target.value),children:[jsxRuntime.jsx("option",{value:"sum",children:a("sum")}),jsxRuntime.jsx("option",{value:"count",children:a("count")}),jsxRuntime.jsx("option",{value:"avg",children:a("avg")}),jsxRuntime.jsx("option",{value:"min",children:a("min")}),jsxRuntime.jsx("option",{value:"max",children:a("max")})]})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("displayMode")}),jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",value:M,onChange:h=>P(h.target.value),children:[jsxRuntime.jsx("option",{value:"absolute",children:a("absoluteValue")}),jsxRuntime.jsx("option",{value:"percentOfTotal",children:a("percentOfTotal")}),jsxRuntime.jsx("option",{value:"percentOfColumnTotal",children:a("percentOfColumnTotal")}),jsxRuntime.jsx("option",{value:"percentOfRowTotal",children:a("percentOfRowTotal")}),jsxRuntime.jsx("option",{value:"percentOfParentRowTotal",children:a("percentOfParentRowTotal")}),jsxRuntime.jsx("option",{value:"percentOfParentColumnTotal",children:a("percentOfParentColumnTotal")}),jsxRuntime.jsx("option",{value:"runningTotal",children:a("runningTotal")}),jsxRuntime.jsx("option",{value:"difference",children:a("difference")}),jsxRuntime.jsx("option",{value:"percentDifference",children:a("percentDifference")})]})]})]}),v&&t.dataType==="date"&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:a("groupInterval")}),jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",value:F,onChange:h=>u(h.target.value),children:[jsxRuntime.jsx("option",{value:"",children:a("none")}),jsxRuntime.jsx("option",{value:"year",children:a("year")}),jsxRuntime.jsx("option",{value:"quarter",children:a("quarter")}),jsxRuntime.jsx("option",{value:"month",children:a("month")}),jsxRuntime.jsx("option",{value:"week",children:a("week")}),jsxRuntime.jsx("option",{value:"day",children:a("day")})]})]})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",children:[jsxRuntime.jsx("button",{onClick:r,className:"kanuni-pivot-btn kanuni-pivot-btn--outline",children:a("cancel")}),jsxRuntime.jsxs("button",{onClick:y,className:"kanuni-pivot-btn kanuni-pivot-btn--primary",children:[jsxRuntime.jsx(lucideReact.Check,{size:16})," ",a("ok")]})]})]})]})}var $a=[["equals","opEquals"],["notEquals","opNotEquals"],["contains","opContains"],["notContains","opNotContains"],["startsWith","opStartsWith"],["endsWith","opEndsWith"]],Oa=[[">","opGreater"],[">=","opGreaterOrEqual"],["<","opLess"],["<=","opLessOrEqual"],["=","opEquals"],["!=","opNotEquals"],["between","opBetween"],["notBetween","opNotBetween"]];function di({field:t,dataFields:r,onClose:c,onSave:a}){let{t:l}=mt(),e=t.labelFilter,p=t.valueFilter,[C,M]=un.useState(e?.operator??""),[P,F]=un.useState(e?.value??""),[u,y]=un.useState(r.some(L=>L.id===p?.dataField)?p.dataField:r[0]?.id??""),[d,v]=un.useState(p?.operator??""),[h,S]=un.useState(p?String(p.value):""),[k,I]=un.useState(p?.value2!==void 0?String(p.value2):""),[O,V]=un.useState(null),H=un.useRef(null),z=un.useRef(null),X=un.useRef(null),Y=d==="between"||d==="notBetween",j=`${l("conditionFilter")}: ${t.caption||t.id}`,_=()=>{let L=(w,D)=>{V(w),D.current?.focus();},R;if(C){if(P==="")return L("label",H);R={operator:C,value:P,...e?.caseSensitive?{caseSensitive:true}:{}};}let et=r.length>0?void 0:p;if(d&&r.length>0){let w=h===""?NaN:Number(h),D=k===""?NaN:Number(k);if(!Number.isFinite(w))return L("value",z);if(Y&&!Number.isFinite(D))return L("value2",X);et={dataField:u,operator:d,value:w,...Y?{value2:D}:{}};}a({...t,labelFilter:R,valueFilter:et});},G={display:"flex",gap:"8px",marginTop:"6px"},U={flex:"1 1 0",minWidth:0};return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in",onClick:c}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"400px"},role:"dialog","aria-modal":"true","aria-label":j,onKeyDown:L=>{L.key==="Escape"&&(L.stopPropagation(),c());},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",children:[jsxRuntime.jsx("h2",{className:"kanuni-pivot-modal-title",children:j}),jsxRuntime.jsx("button",{onClick:c,className:"kanuni-pivot-modal-close","aria-label":l("cancel"),children:jsxRuntime.jsx(lucideReact.X,{size:20})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:l("caption")}),jsxRuntime.jsxs("div",{style:G,children:[jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",style:U,"data-condition-label-op":"","aria-label":l("caption"),autoFocus:true,value:C,onChange:L=>M(L.target.value),children:[jsxRuntime.jsx("option",{value:"",children:l("none")}),$a.map(([L,R])=>jsxRuntime.jsx("option",{value:L,children:l(R)},L))]}),jsxRuntime.jsx("input",{ref:H,type:"text",className:"kanuni-pivot-input",style:U,"data-condition-label-value":"",placeholder:l("builderValuePlaceholder"),"aria-label":l("builderValuePlaceholder"),"aria-invalid":O==="label"||void 0,disabled:C==="",value:P,onChange:L=>F(L.target.value)})]})]}),r.length>0&&jsxRuntime.jsxs("div",{className:"kanuni-pivot-form-group",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:l("dataArea")}),jsxRuntime.jsx("select",{className:"kanuni-pivot-select","data-condition-value-field":"","aria-label":l("dataArea"),value:u,onChange:L=>y(L.target.value),children:r.map(L=>jsxRuntime.jsx("option",{value:L.id,children:L.caption||L.id},L.id))}),jsxRuntime.jsxs("div",{style:G,children:[jsxRuntime.jsxs("select",{className:"kanuni-pivot-select",style:U,"data-condition-value-op":"","aria-label":l("dataArea"),value:d,onChange:L=>v(L.target.value),children:[jsxRuntime.jsx("option",{value:"",children:l("none")}),Oa.map(([L,R])=>jsxRuntime.jsx("option",{value:L,children:l(R)},L))]}),jsxRuntime.jsx("input",{ref:z,type:"number",className:"kanuni-pivot-input",style:U,"data-condition-value":"","aria-label":l("builderValuePlaceholder"),"aria-invalid":O==="value"||void 0,disabled:d==="",value:h,onChange:L=>S(L.target.value)}),Y&&jsxRuntime.jsx("input",{ref:X,type:"number",className:"kanuni-pivot-input",style:U,"data-condition-value2":"","aria-label":l("builderValuePlaceholder"),"aria-invalid":O==="value2"||void 0,value:k,onChange:L=>I(L.target.value)})]})]})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",children:[jsxRuntime.jsx("button",{onClick:c,className:"kanuni-pivot-btn kanuni-pivot-btn--outline",children:l("cancel")}),jsxRuntime.jsxs("button",{onClick:_,className:"kanuni-pivot-btn kanuni-pivot-btn--primary",children:[jsxRuntime.jsx(lucideReact.Check,{size:16})," ",l("ok")]})]})]})]})}function Sr({x:t,y:r,field:c,colPath:a,rowFields:l,onClose:e,onSort:p,onSortBySummary:C,onClearAllSorting:M,onHide:P,onSettings:F,onMoveField:u,onMoveToArea:y,onShowFieldChooser:d,customContextMenuItems:v,onEditCalculatedField:h,onConditionFilter:S}){let{t:k,rtl:I}=mt(),[O,V]=un.useState(null),H=O==="order",z=O==="area",X=un.useRef(null),Y=un.useRef(null),j=un.useRef(null),_=un.useRef(null);un.useLayoutEffect(()=>{let E=document.activeElement;return _.current=E?.closest(".kanuni-pivot-field-chip")??null,_.current&&X.current?.querySelector("button")?.focus(),()=>{let dt=_.current;dt&&dt.isConnected&&dt.focus({preventScroll:true});}},[]);let G=E=>{if(E.key==="Escape"){E.preventDefault(),e();return}let st=[X.current,Y.current].filter(Boolean).flatMap(de=>Array.from(de.querySelectorAll("button:not([disabled])")));if(st.length===0)return;let ct=st.indexOf(document.activeElement),q=-1;E.key==="ArrowDown"?q=ct<0?0:(ct+1)%st.length:E.key==="ArrowUp"?q=ct<0?st.length-1:(ct-1+st.length)%st.length:E.key==="Home"?q=0:E.key==="End"&&(q=st.length-1),!(q<0)&&(E.preventDefault(),st[q].focus());};un.useEffect(()=>{let E=dt=>{let st=dt.target;X.current&&!X.current.contains(st)&&(!Y.current||!Y.current.contains(st))&&e();};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[e]);let U=a!==void 0&&l&&l.length>0&&c.area==="data",[L,R]=un.useState({top:r,left:t,maxHeight:"calc(100vh - 16px)"}),[et,w]=un.useState({top:0,left:0}),D=un.useRef(null),bt=un.useRef(null),f=()=>{clearTimeout(bt.current),V("order");},T=()=>{bt.current=setTimeout(()=>V(E=>E==="order"?null:E),200);},K=()=>{clearTimeout(bt.current),V("area");},ot=()=>{bt.current=setTimeout(()=>V(E=>E==="area"?null:E),200);},kt=[{area:"row",label:k("rowArea"),Icon:lucideReact.Rows3},{area:"column",label:k("columnArea"),Icon:lucideReact.Columns3},{area:"data",label:k("dataArea"),Icon:lucideReact.BarChart3},{area:"filter",label:k("filterArea"),Icon:lucideReact.Filter}].filter(E=>E.area!==c.area);return un.useLayoutEffect(()=>{if(!X.current)return;let E=setTimeout(()=>{if(!X.current)return;let dt=X.current.getBoundingClientRect(),st=r,ct=t;ct+dt.width>window.innerWidth&&(ct=Math.max(8,window.innerWidth-dt.width-8)),st+dt.height>window.innerHeight&&(st=window.innerHeight-dt.height-8,st<8&&(st=8)),R({top:st,left:ct,maxHeight:`calc(100vh - ${st+8}px)`});},0);return ()=>clearTimeout(E)},[t,r,U,l,v]),un.useLayoutEffect(()=>{let E=H?D.current:z?j.current:null;if(E){let dt=E.getBoundingClientRect(),st=dt.right+4;st+160>window.innerWidth&&(st=dt.left-160-4),w({top:dt.top,left:st});}},[H,z]),jsxRuntime.jsx(be,{children:jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsxs("div",{ref:X,className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in pivot-flex-col",style:{position:"fixed",top:L.top,left:L.left,maxHeight:L.maxHeight,overflowY:"auto",overflowX:"hidden",width:"220px",zIndex:9999},onContextMenu:E=>E.preventDefault(),onKeyDown:G,children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{position:"sticky",top:0,zIndex:10},children:c.caption}),U?jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",style:{marginTop:"4px"},children:k("sortByThisColumn")}),l.map(E=>jsxRuntime.jsxs("button",{onClick:()=>{C?.(E.id,a),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ArrowDownAZ,{size:16})," ",k("sortFieldByThisColumn").replace("{0}",E.caption||E.id)]},E.id)),M&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),jsxRuntime.jsxs("button",{onClick:()=>{M(),e();},className:"kanuni-pivot-dropdown-item-danger pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.X,{size:16})," ",k("removeAllSorting")]})]})]}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsxs("button",{onClick:()=>{p("asc"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ArrowDownAZ,{size:16})," ",k("sortAsc")]}),jsxRuntime.jsxs("button",{onClick:()=>{p("desc"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ArrowUpZA,{size:16})," ",k("sortDesc")]}),c.sortOrder&&jsxRuntime.jsxs("button",{onClick:()=>{p(void 0),e();},className:"kanuni-pivot-dropdown-item-danger pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.X,{size:16})," ",k("clearSort")]}),S&&(c.area==="row"||c.area==="column")&&jsxRuntime.jsxs("button",{onClick:()=>{S(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.Filter,{size:16})," ",k("conditionFilter"),"\u2026"]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),u&&jsxRuntime.jsx("div",{className:"relative",onMouseEnter:f,onMouseLeave:T,children:jsxRuntime.jsxs("button",{ref:D,className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between",onClick:()=>V(E=>E==="order"?null:"order"),children:[jsxRuntime.jsxs("span",{className:"pivot-flex pivot-items-center pivot-gap-2",children:[jsxRuntime.jsx(lucideReact.List,{size:16})," ",k("order")]}),I?jsxRuntime.jsx(lucideReact.ChevronLeft,{size:14}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:14})]})}),y&&kt.length>0&&jsxRuntime.jsx("div",{className:"relative",onMouseEnter:K,onMouseLeave:ot,children:jsxRuntime.jsxs("button",{ref:j,className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center pivot-justify-between",onClick:()=>V(E=>E==="area"?null:"area"),children:[jsxRuntime.jsxs("span",{className:"pivot-flex pivot-items-center pivot-gap-2",children:[jsxRuntime.jsx(lucideReact.Move,{size:16})," ",k("moveToArea")]}),I?jsxRuntime.jsx(lucideReact.ChevronLeft,{size:14}):jsxRuntime.jsx(lucideReact.ChevronRight,{size:14})]})}),d&&jsxRuntime.jsxs("button",{onClick:()=>{d(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.List,{size:16})," ",k("showFieldList")]}),jsxRuntime.jsxs("button",{onClick:()=>{P(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.EyeOff,{size:16})," ",k("hide")]}),v&&v.length>0&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),v.map((E,dt)=>jsxRuntime.jsxs("button",{onClick:()=>{E.action(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[E.icon&&jsxRuntime.jsx(E.icon,{size:16})," ",E.label]},dt))]}),jsxRuntime.jsx("div",{className:"kanuni-pivot-divider"}),c.isCalculated&&h&&jsxRuntime.jsxs("button",{onClick:()=>{h(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.Calculator,{size:16})," ",k("editCalculation")]}),jsxRuntime.jsxs("button",{onClick:()=>{F(),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.Settings,{size:16})," ",k("fieldSettings")]})]})]}),H&&u&&jsxRuntime.jsxs("div",{ref:Y,className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",top:et.top,left:et.left,minWidth:"160px",zIndex:1e4},onMouseEnter:f,onMouseLeave:T,onContextMenu:E=>E.preventDefault(),onKeyDown:G,children:[jsxRuntime.jsxs("button",{onClick:()=>{u("start"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronsLeft,{size:16})," ",k("moveToStart")]}),jsxRuntime.jsxs("button",{onClick:()=>{u("left"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronLeft,{size:16})," ",k("moveToLeft")]}),jsxRuntime.jsxs("button",{onClick:()=>{u("right"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronRight,{size:16})," ",k("moveToRight")]}),jsxRuntime.jsxs("button",{onClick:()=>{u("end"),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(lucideReact.ChevronsRight,{size:16})," ",k("moveToEnd")]})]}),z&&y&&jsxRuntime.jsx("div",{ref:Y,className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",top:et.top,left:et.left,minWidth:"160px",zIndex:1e4},onMouseEnter:K,onMouseLeave:ot,onContextMenu:E=>E.preventDefault(),onKeyDown:G,children:kt.map(({area:E,label:dt,Icon:st})=>jsxRuntime.jsxs("button",{onClick:()=>{y(E),e();},className:"kanuni-pivot-dropdown-item pivot-flex pivot-items-center",children:[jsxRuntime.jsx(st,{size:16})," ",dt]},E))})]})})}function hi({rootRef:t,initialFocusRef:r,onClose:c,onPrintableKey:a}){return un.useEffect(()=>{r?.current?r.current.focus():t.current&&t.current.focus();},[r,t]),un.useCallback(e=>{if(e.key==="Escape"){e.stopPropagation(),c();return}e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&a&&a(e.key,e);},[c,a])}var gi=new Map,bi=new Map;function xi(t,r,c,a="(Blanks)"){if(t==null)return a;if(r.format&&typeof t=="number")try{let l=r.format,e=JSON.stringify(l)+"_"+c,p=bi.get(e);p||(p=new Intl.NumberFormat(c,l),bi.set(e,p));let C=p.format(t);return l.isCustom&&(l.prefix||l.suffix)?`${l.prefix||""}${C}${l.suffix||""}`:C}catch{return String(t)}return String(t)}var yi=un__default.default.memo(({id:t,label:r,checked:c,isActive:a,bold:l,index:e,itemHeight:p,onToggle:C,onFocus:M})=>jsxRuntime.jsxs("div",{id:t,className:["kanuni-pivot-popup-item",c?"kanuni-pivot-popup-item--checked":"",a?"kanuni-pivot-popup-item--active":""].filter(Boolean).join(" "),style:{position:"absolute",top:e*p,insetInlineStart:0,insetInlineEnd:0,height:p,fontWeight:l?600:400},onClick:C,onFocus:M,role:"checkbox","aria-checked":c,tabIndex:0,children:[jsxRuntime.jsx("input",{type:"checkbox",className:"kanuni-pivot-checkbox",checked:c,readOnly:true,tabIndex:-1}),jsxRuntime.jsx("span",{className:"pivot-truncate",children:r})]})),Nr=({field:t,data:r,onApply:c,onClear:a,onClose:l,x:e,y:p,gridId:C,onConditionFilter:M})=>{let{t:P,rtl:F,locale:u}=mt(),[y,d]=un.useState(true),[v,h]=un.useState([]),[S,k]=un.useState(""),[I,O]=un.useState(new Set),[V,H]=un.useState(0),[z,X]=un.useState(220),[Y,j]=un.useState(0),_=un.useRef(null),G=un.useRef(null),U=un.useRef(null);un.useEffect(()=>{d(true);let x=setTimeout(()=>{if(!t.dataField&&!t.isCalculated){h([]),d(false);return}let ut=pivotgridCore.getFieldDistinctValues(t.id,C),Q;if(ut)Q=ut.map(vt=>({rawStr:vt.rawStr==="null"||vt.rawStr==="undefined"?P("blanks"):vt.rawStr,rawVal:vt.rawVal,label:xi(vt.rawVal,t,u,P("blanks"))}));else {let vt=new Map;for(let Et=0;Et<r.length;Et++){let Xt=pivotgridCore.extractGroupValue(r[Et],t);if(Xt==="(Blank)"&&t.calculateSummaryExpression)continue;let jt=Xt==null?P("blanks"):String(Xt);vt.has(jt)||vt.set(jt,Xt);}let Jt=Array.from(vt.values());if(t.dataType==="number")Jt.sort((Et,Xt)=>Number(Et)-Number(Xt));else {let Et=pivotgridCore.collatorFor().compare;Jt.sort((Xt,jt)=>Et(String(Xt),String(jt)));}Q=Jt.map(Et=>({rawStr:Et==null?P("blanks"):String(Et),rawVal:Et,label:xi(Et,t,u,P("blanks"))}));}h(Q),O(pivotgridCore.headerFilterShown(Q,t)),d(false);let Pt=gi.get(t.id)||0;Pt>0&&setTimeout(()=>{G.current&&(G.current.scrollTop=Pt);},50);},10);return ()=>clearTimeout(x)},[r,t]);let L=un.useMemo(()=>{if(!S)return v;let x=S.toLowerCase(),ut=x.replace(/,/g,"."),Q=x.replace(/\./g,","),Pt=x.replace(/[.,\s]/g,"");return v.filter(vt=>{let Jt=vt.label.toLowerCase(),Et=Jt.replace(/[.,\s]/g,"");return Jt.includes(x)||Jt.includes(ut)||Jt.includes(Q)||Pt&&Et.includes(Pt)})},[v,S]),R=I.size===v.length,et=!S,w=L.length+(et?1:0),D=!y&&v.length>0&&I.size===0,bt=un.useCallback(x=>{O(ut=>{let Q=new Set(ut);for(let Pt of L)x?Q.add(Pt.rawStr):Q.delete(Pt.rawStr);return Q});},[L]),f=un.useCallback(()=>{bt(!L.every(x=>I.has(x.rawStr)));},[L,I,bt]),T=un.useCallback(()=>bt(false),[bt]),K=un.useCallback(x=>{O(ut=>{let Q=new Set(ut);return Q.has(x)?Q.delete(x):Q.add(x),Q});},[]),ot=w===0?-1:Math.min(Y,w-1),kt=un.useCallback(x=>{if(et&&x===0)return "select-all";let ut=et?x-1:x;return `value:${L[ut]?.rawStr}`},[L,et]),E=x=>{k(x.target.value),j(0);},dt=un.useCallback((x,ut)=>{ut.target!==U.current&&(ut.preventDefault(),U.current?.focus(),k(Q=>`${Q}${x}`),j(0));},[]),st=hi({rootRef:_,initialFocusRef:U,onClose:l,onPrintableKey:dt}),ct=x=>{let ut=Math.max(0,Math.min(w-1,Y+x));j(ut);let Q=kt(ut),Pt=document.getElementById(Q);Pt&&(Pt.focus(),Pt.scrollIntoView({block:"nearest"}));},q=x=>{if(x.key==="ArrowDown"||x.key==="ArrowUp"){if(x.preventDefault(),w===0)return;ct(x.key==="ArrowDown"?1:-1);return}if(x.key==="Home"&&w>0){x.preventDefault(),j(0),document.getElementById(kt(0))?.focus();return}if(x.key==="End"&&w>0){x.preventDefault(),j(w-1),document.getElementById(kt(w-1))?.focus();return}if(x.key==="Backspace"&&x.target!==U.current){x.preventDefault(),U.current?.focus(),k(ut=>ut.slice(0,-1)),j(0);return}if(x.key===" "||x.code==="Space"){if(x.preventDefault(),w>0&&ot>=0)if(et&&ot===0)f();else {let ut=et?ot-1:ot,Q=L[ut];Q&&K(Q.rawStr);}return}if(x.key==="Enter"){x.preventDefault(),de();return}st(x);},de=un.useCallback(()=>{if(D)return;let x=pivotgridCore.headerFilterWrite(v,I,t);x.kind==="clear"?a(t.id):x.kind==="apply"&&c(t.id,x.values,x.filterType),l();},[D,I,v,t,c,a,l]);un.useEffect(()=>{y||setTimeout(()=>{U.current?.focus();},50);},[y]),un.useEffect(()=>{let x=ut=>{_.current&&!_.current.contains(ut.target)&&l();};return document.addEventListener("mousedown",x),()=>document.removeEventListener("mousedown",x)},[l]),un.useEffect(()=>{let x=ut=>{ut.key==="Escape"&&l();};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[l]),un.useEffect(()=>{if(!G.current)return;let x=new ResizeObserver(ut=>{for(let Q of ut)X(Q.contentRect.height);});return x.observe(G.current),()=>x.disconnect()},[y]);let ne=28,rt=Math.max(0,Math.floor(V/ne)-2),Wt=Math.min(w,rt+Math.ceil(z/ne)+4),m=jsxRuntime.jsx("div",{className:"kanuni-pivot-portal-root",children:jsxRuntime.jsxs("div",{ref:_,className:"kanuni-pivot-popup pivot-animate-zoom-in",style:{left:Math.max(10,Math.min(e,window.innerWidth-270)),top:Math.max(10,Math.min(p,window.innerHeight-370)),width:250,height:350,minWidth:200,minHeight:250,maxWidth:Math.min(600,window.innerWidth-20),maxHeight:Math.min(350,window.innerHeight-20),resize:"both",direction:F?"rtl":"ltr"},onClick:x=>x.stopPropagation(),onKeyDown:q,role:"dialog","aria-label":P("columnFilter"),"data-datagrid-keyboard-scope":"modal",tabIndex:-1,children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-header",children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-search",children:[jsxRuntime.jsx(lucideReact.Search,{className:"kanuni-pivot-popup-search-icon",size:14}),jsxRuntime.jsx("input",{ref:U,type:"text",className:"kanuni-pivot-popup-search-input",placeholder:P("search"),value:S,onChange:E,"aria-controls":"pivot-filter-options","aria-activedescendant":ot>=0?kt(ot):void 0})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-actions",children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--primary",onClick:f,children:P("selectAll")}),jsxRuntime.jsx("button",{className:"kanuni-pivot-popup-action-btn kanuni-pivot-popup-action-btn--danger",onClick:T,children:P("clearAll")})]})]}),jsxRuntime.jsx("div",{ref:G,id:"pivot-filter-options",className:"kanuni-pivot-popup-list pivot-custom-scrollbar",onScroll:x=>{H(x.currentTarget.scrollTop),gi.set(t.id,x.currentTarget.scrollTop);},children:y?jsxRuntime.jsx("div",{className:"pivot-flex pivot-items-center pivot-justify-center pivot-h-full",children:jsxRuntime.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}})}):jsxRuntime.jsxs("div",{style:{height:w*ne,position:"relative"},children:[Array.from({length:Wt-rt},(x,ut)=>{let Q=rt+ut;if(et&&Q===0)return jsxRuntime.jsx(yi,{id:"select-all",label:`(${P("selectAll")})`,checked:R,isActive:Q===ot,bold:true,index:Q,itemHeight:ne,onToggle:f,onFocus:()=>j(Q)},"select-all");let Pt=et?Q-1:Q,vt=L[Pt];return vt?jsxRuntime.jsx(yi,{id:`value:${vt.rawStr}`,label:vt.label,checked:I.has(vt.rawStr),isActive:Q===ot,bold:false,index:Q,itemHeight:ne,onToggle:()=>K(vt.rawStr),onFocus:()=>j(Q)},vt.rawStr):null}),L.length===0&&jsxRuntime.jsx("div",{style:{padding:"12px",textAlign:"center",fontSize:"12px",color:"var(--pivot-text-muted)"},children:P("noItems")})]})}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-popup-footer",children:[M&&(t.area==="row"||t.area==="column")&&jsxRuntime.jsx("button",{type:"button",className:"kanuni-pivot-btn kanuni-pivot-btn--outline",style:{height:"28px",padding:"0 7px",marginInlineEnd:"auto",color:t.valueFilter||t.labelFilter?"var(--pivot-danger)":void 0},"data-condition-filter":"",title:`${P("conditionFilter")}\u2026`,"aria-label":`${P("conditionFilter")}\u2026`,onClick:()=>{l(),M();},children:jsxRuntime.jsx(lucideReact.Settings2,{size:14})}),jsxRuntime.jsx("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--outline",style:{height:"28px",padding:"0 12px",fontSize:"12px"},onClick:l,children:P("cancel")}),jsxRuntime.jsx("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--primary",style:{height:"28px",padding:"0 12px",fontSize:"12px"},disabled:D,onClick:de,children:P("ok")})]})]})});return jsxRuntime.jsx(be,{children:m})};function Er({fields:t,controller:r}){let[c,a]=un.useState(null),l=ue(v=>v.setIntent),e=()=>ue.getState(),p=ue(v=>v.reset),C=un.useRef({x:0,y:0});un.useEffect(()=>{let v=h=>{C.current={x:h.clientX,y:h.clientY};};return c&&window.addEventListener("pointermove",v),()=>window.removeEventListener("pointermove",v)},[c]);let M=core.useSensors(core.useSensor(core.PointerSensor,{activationConstraint:{distance:8}}),core.useSensor(core.TouchSensor,{activationConstraint:{delay:200,tolerance:8}})),P=un.useCallback(v=>{let h=String(v.active.id);a(h),r.setDragActive(h),ue.getState().setActiveId(h);},[r]),F=un.useCallback(v=>{let{over:h}=v;if(!h){l(null,null,null),r.setDragIntent(null,null,null);return}let S=String(h.id).replace("chooser-","");if(["row","column","data","filter","chooser"].includes(S)||S.endsWith("-ghost-end")){let I=S.replace("-ghost-end","");l(null,I,"append"),r.setDragIntent(null,I,"append");return}let k=t.find(I=>I.id===S);if(k&&h.rect){let O=k.area==="chooser"?"vertical":"horizontal",V=r.calculateDropIntent(C.current.x,C.current.y,h.rect,e().intent,false,O);l(S,k.area??null,V),r.setDragIntent(S,k.area??null,V);}},[r,t,l]),u=un.useCallback(async v=>{let{active:h,over:S}=v;if(p(),a(null),ue.getState().setActiveId(null),!S){r.resetDrag();return}await r.commitDrag(String(h.id),String(S.id));},[r,p]),y=un.useCallback(v=>{r.removeField(v);},[r]),d=un.useCallback((v,h)=>{r.moveField(v,h);},[r]);return {activeDragId:c,sensors:M,handleDragStart:P,handleDragMove:F,handleDragEnd:u,handleRemoveField:y,handleMoveField:d}}function Mr({isOpen:t,onClose:r,status:c,title:a,messages:l,progress:e,phase:p,cancellable:C,onCancel:M}){let{t:P}=mt();if(!t)return null;let F=c==="loading"&&typeof e=="number",u=Math.max(0,Math.min(100,Math.round(e??0)));return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in"}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"400px"},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center",style:{gap:"8px"},children:[c==="loading"&&jsxRuntime.jsx("div",{style:{width:"20px",height:"20px",border:"2px solid var(--pivot-border)",borderTopColor:"var(--pivot-primary)",borderRadius:"50%",animation:"spin 1s linear infinite"}}),c==="success"&&jsxRuntime.jsx(lucideReact.CheckCircle,{size:20,color:"var(--pivot-success)"}),c==="error"&&jsxRuntime.jsx(lucideReact.XCircle,{size:20,color:"var(--pivot-danger)"}),c==="warning"&&jsxRuntime.jsx(lucideReact.AlertTriangle,{size:20,color:"var(--pivot-warning)"}),jsxRuntime.jsx("h3",{className:"kanuni-pivot-modal-title",style:{margin:0},children:a})]}),jsxRuntime.jsx("button",{className:"kanuni-pivot-modal-close",onClick:r,disabled:c==="loading",children:jsxRuntime.jsx(lucideReact.X,{size:18})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",style:{maxHeight:"60vh"},children:[F&&jsxRuntime.jsxs("div",{style:{marginBottom:l.length>0?"12px":0},children:[jsxRuntime.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"6px",fontSize:"12px",color:"var(--pivot-text-muted)"},children:[jsxRuntime.jsx("span",{children:P(p||"processing")}),jsxRuntime.jsxs("span",{style:{fontVariantNumeric:"tabular-nums"},children:[u,"%"]})]}),jsxRuntime.jsx("div",{style:{width:"100%",height:"6px",background:"var(--pivot-border)",borderRadius:"999px",overflow:"hidden"},children:jsxRuntime.jsx("div",{style:{width:`${u}%`,height:"100%",background:"var(--pivot-primary)",borderRadius:"999px",transition:"width 0.2s ease"}})})]}),l.length===0?!F&&jsxRuntime.jsx("p",{className:"pivot-text-sm pivot-text-muted",children:P("processing")}):jsxRuntime.jsx("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:"8px"},children:l.map((y,d)=>jsxRuntime.jsxs("li",{className:"pivot-flex",style:{gap:"8px",fontSize:"13px",color:"var(--pivot-text)",alignItems:"flex-start"},children:[jsxRuntime.jsx("span",{style:{color:"var(--pivot-text-muted)",marginTop:"2px"},children:"\u2022"}),jsxRuntime.jsx("span",{children:y})]},d))})]}),c==="loading"&&C&&M&&jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-footer",children:jsxRuntime.jsx("button",{className:"kanuni-pivot-btn",onClick:M,children:P("cancel")})}),c!=="loading"&&jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-footer",children:jsxRuntime.jsx("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--primary",onClick:r,children:P("ok")})})]})]})}var Cs=["string","number","date","boolean"],Ps=20;function ki({preview:t,onApply:r,onCancel:c}){let{t:a}=mt(),[l,e]=un.useState(()=>t.fields.map(u=>({...u,include:true}))),p=un.useMemo(()=>t.sample.slice(0,Ps),[t.sample]),C=l.filter(u=>u.include).length,M=(u,y)=>e(d=>d.map((v,h)=>h===u?{...v,...y}:v)),P=u=>a(`type_${u}`)||u,F=u=>u==null?"":u instanceof Date?isNaN(u.getTime())?"":u.toLocaleDateString():typeof u=="boolean"?u?"\u2713":"\u2717":String(u);return jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay pivot-animate-fade-in"}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{width:"min(880px, 94vw)",maxHeight:"88vh",display:"flex",flexDirection:"column"},children:[jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-header",style:{flexDirection:"row",justifyContent:"space-between",alignItems:"center"},children:[jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"kanuni-pivot-modal-title",style:{margin:0},children:a("importPreviewTitle")}),jsxRuntime.jsx("div",{className:"pivot-text-sm pivot-text-muted",style:{marginTop:"2px"},children:a("importPreviewSubtitle").replace("{rows}",t.rowCount.toLocaleString()).replace("{cols}",String(C))})]}),jsxRuntime.jsx("button",{className:"kanuni-pivot-modal-close",onClick:c,children:jsxRuntime.jsx(lucideReact.X,{size:18})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-body pivot-custom-scrollbar",style:{overflow:"auto",flex:1},children:[t.warnings.length>0&&jsxRuntime.jsx("div",{style:{marginBottom:"12px",padding:"8px 12px",borderRadius:"var(--pivot-radius-sm)",background:"color-mix(in srgb, var(--pivot-warning) 12%, transparent)",border:"1px solid var(--pivot-warning)",fontSize:"12px",color:"var(--pivot-text)"},children:t.warnings.map((u,y)=>jsxRuntime.jsxs("div",{children:["\u2022 ",u]},y))}),jsxRuntime.jsxs("div",{style:{marginBottom:"16px"},children:[jsxRuntime.jsx("div",{className:"pivot-text-sm pivot-font-medium",style:{marginBottom:"6px"},children:a("columns")}),jsxRuntime.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"6px"},children:l.map((u,y)=>jsxRuntime.jsxs("div",{style:{display:"grid",gridTemplateColumns:"28px 1fr 150px",gap:"10px",alignItems:"center",padding:"6px 8px",borderRadius:"var(--pivot-radius-sm)",background:u.include?"var(--pivot-surface)":"transparent",opacity:u.include?1:.5,border:"1px solid var(--pivot-border)"},children:[jsxRuntime.jsx("input",{type:"checkbox",checked:u.include,title:a("includeColumn"),onChange:d=>M(y,{include:d.target.checked})}),jsxRuntime.jsx("input",{className:"kanuni-pivot-input",value:u.caption,disabled:!u.include,onChange:d=>M(y,{caption:d.target.value}),style:{fontSize:"13px",padding:"4px 8px"}}),jsxRuntime.jsx("select",{className:"kanuni-pivot-input",value:u.dataType,disabled:!u.include,onChange:d=>M(y,{dataType:d.target.value}),style:{fontSize:"13px",padding:"4px 8px"},children:Cs.map(d=>jsxRuntime.jsx("option",{value:d,children:P(d)},d))})]},u.dataField))})]}),jsxRuntime.jsxs("div",{className:"pivot-text-sm pivot-font-medium",style:{marginBottom:"6px"},children:[a("dataPreview")," ",jsxRuntime.jsxs("span",{className:"pivot-text-muted",children:["(",p.length,"/",t.rowCount.toLocaleString(),")"]})]}),jsxRuntime.jsx("div",{style:{overflow:"auto",border:"1px solid var(--pivot-border)",borderRadius:"var(--pivot-radius-sm)"},children:jsxRuntime.jsxs("table",{style:{borderCollapse:"collapse",fontSize:"12px",width:"100%"},children:[jsxRuntime.jsx("thead",{children:jsxRuntime.jsx("tr",{children:l.filter(u=>u.include).map(u=>jsxRuntime.jsxs("th",{style:{position:"sticky",top:0,textAlign:"left",padding:"6px 10px",whiteSpace:"nowrap",background:"var(--pivot-surface-header)",borderBottom:"1px solid var(--pivot-border)",color:"var(--pivot-text-header)",fontWeight:600},children:[u.caption,jsxRuntime.jsx("span",{className:"pivot-text-muted",style:{fontWeight:400,marginLeft:"6px"},children:P(u.dataType)})]},u.dataField))})}),jsxRuntime.jsx("tbody",{children:p.map((u,y)=>jsxRuntime.jsx("tr",{style:{background:y%2?"var(--pivot-surface)":"transparent"},children:l.filter(d=>d.include).map(d=>jsxRuntime.jsx("td",{style:{padding:"4px 10px",whiteSpace:"nowrap",borderBottom:"1px solid var(--pivot-border)",color:"var(--pivot-text)"},children:F(u[d.dataField])},d.dataField))},y))})]})})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[jsxRuntime.jsx("button",{className:"kanuni-pivot-btn",onClick:c,children:a("cancel")}),jsxRuntime.jsxs("button",{className:"kanuni-pivot-btn kanuni-pivot-btn--primary",onClick:()=>r(l),disabled:C===0,style:{display:"inline-flex",alignItems:"center",gap:"6px"},children:[jsxRuntime.jsx(lucideReact.Check,{size:15})," ",a("applyImport")]})]})]})]})}function Dr({isOpen:t,onClose:r,onSave:c,defaultName:a="",title:l}){let{t:e}=mt(),[p,C]=un.useState(a),[M,P]=un.useState(false);if(!t)return null;let F=()=>{p.trim()&&(c(p.trim(),M),C(""),P(false));},u=d=>{d.preventDefault(),F();},y=d=>{d.key==="Escape"?(d.preventDefault(),d.stopPropagation(),r()):d.key==="Enter"&&d.target instanceof HTMLInputElement&&d.target.type==="text"&&(d.preventDefault(),F());};return jsxRuntime.jsx(be,{children:jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-modal-overlay",onClick:r}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal pivot-animate-zoom-in",style:{display:"flex",flexDirection:"column",gap:"16px",padding:"24px"},role:"dialog","aria-modal":"true","aria-label":l??e("saveReport"),onKeyDown:y,children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col",style:{gap:"6px"},children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center pivot-justify-between",children:[jsxRuntime.jsx("h3",{className:"kanuni-pivot-modal-title",children:l??e("saveReport")}),jsxRuntime.jsx("button",{type:"button",onClick:r,className:"kanuni-pivot-modal-close",style:{padding:"6px"},"aria-label":e("close"),children:jsxRuntime.jsx(lucideReact.X,{size:16})})]}),jsxRuntime.jsx("p",{className:"kanuni-pivot-modal-description",children:e("saveReportDescription")})]}),jsxRuntime.jsxs("form",{onSubmit:u,className:"pivot-flex pivot-flex-col pivot-gap-4",children:[jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col pivot-gap-2",children:[jsxRuntime.jsx("label",{className:"kanuni-pivot-form-label",children:e("reportName")}),jsxRuntime.jsx("input",{type:"text",autoFocus:true,className:"kanuni-pivot-input",placeholder:e("reportNamePlaceholder"),value:p,onChange:d=>C(d.target.value),required:true})]}),jsxRuntime.jsxs("div",{className:"pivot-flex pivot-items-center pivot-gap-2",children:[jsxRuntime.jsx("input",{type:"checkbox",id:"isDefault",className:"kanuni-pivot-input",style:{width:"16px",height:"16px"},checked:M,onChange:d=>P(d.target.checked)}),jsxRuntime.jsx("label",{htmlFor:"isDefault",className:"kanuni-pivot-form-label",style:{margin:0,cursor:"pointer"},children:e("setAsDefault")})]}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-modal-footer",style:{marginTop:"8px",paddingTop:"16px",borderTop:"1px solid var(--pivot-border)",display:"flex",justifyContent:"flex-end",gap:"8px"},children:[jsxRuntime.jsx("button",{type:"button",onClick:r,className:"kanuni-pivot-btn kanuni-pivot-btn--outline",children:e("cancel")}),jsxRuntime.jsxs("button",{type:"submit",disabled:!p.trim(),className:"kanuni-pivot-btn kanuni-pivot-btn--primary",children:[jsxRuntime.jsx(lucideReact.Save,{size:16}),e("save")]})]})]})]})]})})}var So=class extends un.Component{state={hasError:false,error:null};static getDerivedStateFromError(r){return {hasError:true,error:r}}componentDidCatch(r,c){this.props.onError?.(r,c);}handleReset=()=>{this.setState({hasError:false,error:null});};render(){return this.state.hasError?this.props.fallback?this.props.fallback:jsxRuntime.jsxs("div",{style:{padding:24,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,height:"100%",color:"var(--pivot-text, #333)",backgroundColor:"var(--pivot-bg, #fff)"},children:[jsxRuntime.jsx("div",{style:{fontSize:14,fontWeight:600},children:"PivotGrid encountered an error"}),jsxRuntime.jsx("div",{style:{fontSize:12,color:"var(--pivot-text-muted, #888)",maxWidth:400,textAlign:"center"},children:this.state.error?.message}),jsxRuntime.jsx("button",{onClick:this.handleReset,style:{padding:"6px 16px",fontSize:12,borderRadius:4,border:"1px solid var(--pivot-border, #ddd)",background:"var(--pivot-surface, #f5f5f5)",cursor:"pointer"},children:"Retry"})]}):this.props.children}};function Ir(){let[t,r]=un.useState(false),c=un.useRef(null);un.useEffect(()=>{let l=()=>{let e=document;r(!!(document.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement));};return document.addEventListener("fullscreenchange",l),document.addEventListener("webkitfullscreenchange",l),document.addEventListener("mozfullscreenchange",l),document.addEventListener("MSFullscreenChange",l),()=>{document.removeEventListener("fullscreenchange",l),document.removeEventListener("webkitfullscreenchange",l),document.removeEventListener("mozfullscreenchange",l),document.removeEventListener("MSFullscreenChange",l);}},[]);let a=un.useCallback(()=>{let l=c.current,e=document;!!!(document.fullscreenElement||e.webkitFullscreenElement||e.mozFullScreenElement||e.msFullscreenElement)&&!t?l?.requestFullscreen?l.requestFullscreen().catch(()=>r(true)):l?.webkitRequestFullscreen?l.webkitRequestFullscreen():l?.mozRequestFullScreen?l.mozRequestFullScreen():l?.msRequestFullscreen?l.msRequestFullscreen():r(true):document.exitFullscreen&&document.fullscreenElement?document.exitFullscreen().catch(()=>r(false)):e.webkitExitFullscreen&&e.webkitFullscreenElement?e.webkitExitFullscreen():e.mozCancelFullScreen&&e.mozFullScreenElement?e.mozCancelFullScreen():e.msExitFullscreen&&e.msFullscreenElement?e.msExitFullscreen():r(false);},[t]);return {isFullscreen:t,containerRef:c,toggleFullscreen:a}}function zr(){let[t,r]=un.useState(false),[c,a]=un.useState(null),[l,e]=un.useState(null),[p,C]=un.useState(null),[M,P]=un.useState(null),[F,u]=un.useState(false),[y,d]=un.useState(null),[v,h]=un.useState(false),[S,k]=un.useState(void 0);return {chooserOpen:t,setChooserOpen:r,settingsFieldId:c,setSettingsFieldId:a,conditionFieldId:l,setConditionFieldId:e,contextMenu:p,setContextMenu:C,filterPopup:M,setFilterPopup:P,isPrefilterOpen:F,setIsPrefilterOpen:u,globalContextMenu:y,setGlobalContextMenu:d,isCalcModalOpen:v,setIsCalcModalOpen:h,editingCalcField:S,setEditingCalcField:k}}var Lr="default-pivot-grid",Ko=new Map,Ar=new Set;function As(t){let r=Ko.get(t);if(r)return r;let c=Lr;for(let a=2;Ar.has(c);a++)c=`${Lr}-${a}`;return Ar.add(c),Ko.set(t,c),c!==Lr&&console.warn(`[pivotgrid] multiple grids without gridId on this page \u2014 this one got '${c}'. Give each grid an explicit gridId for stable state persistence.`),c}function Hs(t){let r=Ko.get(t);r!==void 0&&(Ko.delete(t),Ar.delete(r));}function Pi(t){let r=un.useId(),[c]=un.useState(()=>t?As(r):"");return un.useEffect(()=>{if(t)return ()=>Hs(r)},[t,r]),c}function Hr(t){let r=un.useRef(null),c=un.useMemo(()=>new pivotgridCore.PivotController(t),[t.gridId]);return un.useEffect(()=>{c.updateOptions(t);}),un.useEffect(()=>(r.current&&(clearTimeout(r.current),r.current=null),()=>{r.current=setTimeout(()=>{c.dispose(),r.current=null;},0);}),[c]),c}function qt(t,r,c=Object.is){let a=un.useRef(void 0),l=un.useRef(false),e=un.useCallback(()=>{let p=r(t.getSnapshot());return l.current&&c(a.current,p)?a.current:(l.current=true,a.current=p,p)},[t,c,r]);return un.useSyncExternalStore(t.subscribe,e,e)}var Qs=t=>{let r=core.rectIntersection(t);return r.sort((c,a)=>{let l=C=>["row","column","data","filter","chooser"].includes(C)||C.endsWith("-ghost-end"),e=l(String(c.id).replace("chooser-","")),p=l(String(a.id).replace("chooser-",""));return e&&!p?1:!e&&p?-1:0}),r},tl=t=>t.fields,el=t=>t.layout,ol=t=>t.expandedPaths,rl=t=>t.expandedColPaths,il=t=>t.columnWidths,nl=t=>t.engineResult,al=t=>t.isBuilding,sl=t=>t.buildProgress??0,ll=t=>t.engineError,pl=t=>t.selectionStats,dl=t=>t.reports,cl=t=>t.activeReportId,ul=t=>t.importStatus,vl=t=>t.importPreview,ml=t=>t.searchText??"",fl=function({gridId:r,workerUrl:c,previewImport:a,data:l,rowKey:e,asyncTransactionWait:p,initialFields:C,onRefresh:M,onImportData:P,onFieldsChange:F,onLayoutChange:u,customContextMenuItems:y,chartIntegrationOptions:d,onChartSync:v,onToggleChart:h,onChartStateLoaded:S,stateStoring:k,toolbar:I,registry:O,serverSource:V,onCellClick:H,onFieldMove:z,onBeforePivotCalculate:X,onAfterPivotCalculate:Y,onExporting:j,onCellPrepared:_,onError:G,theme:U,striped:L,density:R,defaultColumnWidths:et,keyboardNavigation:w,disabled:D,search:bt,maxColumns:f,renderCalculatedFieldModal:T,renderPrefilterBuilder:K,renderNodeContextMenu:ot,advancedExport:kt,upgradeUrl:E,fields:dt,layout:st},ct){let{t:q,locale:de}=mt(),ne=r||k?.storageKey,rt=Pi(!ne),Wt=ne||rt,m=Hr({gridId:Wt,stateStoring:k,workerUrl:c,previewImport:a,data:l,rowKey:e,asyncTransactionWait:p,maxColumns:f,initialFields:C||dt||[],controlledFields:dt,controlledLayout:st,chartIntegrationOptions:d,registry:O,serverSource:V,locale:de,onRefresh:M,onImportData:P,onFieldsChange:F,onLayoutChange:u,onFieldMove:z,onBeforePivotCalculate:X,onAfterPivotCalculate:Y,onExporting:j,onError:G,onChartStateLoaded:S});m.setEnterpriseEdition(kt===true);let x=qt(m,tl),[ut,Q]=un.useState(""),Pt=un.useRef(x);un.useEffect(()=>{let o=Pt.current;if(Pt.current=x,o===x)return;let B=pivotgridCore.pivotChangeAnnouncement(o,x,q);B&&Q($t=>pivotgridCore.nextLiveText($t,B));},[x,q]);let vt=qt(m,el),Jt=qt(m,ol),Et=qt(m,rl),Xt=qt(m,il),jt=qt(m,nl),Qt=qt(m,al),pt=qt(m,sl),it=qt(m,ll),To=qt(m,pl),Rt=qt(m,dl),_e=qt(m,cl),Bt=qt(m,ul),lo=qt(m,vl),Ce=qt(m,ml),{chooserOpen:Pe,setChooserOpen:po,settingsFieldId:ce,setSettingsFieldId:He,conditionFieldId:Ye,setConditionFieldId:zt,contextMenu:Nt,setContextMenu:ye,filterPopup:fe,setFilterPopup:Re,isPrefilterOpen:Je,setIsPrefilterOpen:te,globalContextMenu:he,setGlobalContextMenu:ee,isCalcModalOpen:co,setIsCalcModalOpen:Fe,editingCalcField:uo,setEditingCalcField:Se}=zr(),{activeDragId:Ie,sensors:ze,handleDragStart:qo,handleDragMove:vo,handleDragEnd:mo,handleRemoveField:$e,handleMoveField:Ze}=Er({fields:x,controller:m}),{isFullscreen:At,containerRef:Oe,toggleFullscreen:Xo}=Ir(),[jo,_o]=un.useState(null),Yo=un.useCallback(o=>{Oe.current=o,_o(o);},[Oe]),Jo=At?jo:typeof document<"u"?document.body:null,[Qe,to]=un.useState(null);un.useImperativeHandle(ct,()=>({exportData:(o,B)=>i(o,B),expandAll:()=>m.expandAll(),collapseAll:()=>m.collapseAll(),getState:()=>m.getState(),setFields:o=>m.setFields(o),refreshEngine:()=>m.refreshEngine(),getRawData:()=>m.getRawData(),applyTransaction:o=>m.applyTransaction(o),applyTransactionAsync:(o,B)=>m.applyTransactionAsync(o,B),flushAsyncTransactions:()=>m.flushAsyncTransactions(),getEngineResult:()=>m.getEngineResult(),getCell:(o,B)=>m.getCell(o,B),setColumnWidths:o=>m.setColumnWidths(o),setSearchText:o=>m.setSearchText(o),getController:()=>m}),[m]);let No=rr(jt,x,Jt,d);un.useEffect(()=>{v&&v(No);},[No,v]);let Eo=un.useMemo(()=>x.filter(o=>o.area==="row").sort((o,B)=>(o.areaIndex||0)-(B.areaIndex||0)),[x]),Le=un.useMemo(()=>x.filter(o=>o.area==="column").sort((o,B)=>(o.areaIndex||0)-(B.areaIndex||0)),[x]),fo=un.useMemo(()=>x.filter(o=>o.area==="data").sort((o,B)=>(o.areaIndex||0)-(B.areaIndex||0)),[x]),ho=un.useMemo(()=>x.filter(o=>o.area==="filter").sort((o,B)=>(o.areaIndex||0)-(B.areaIndex||0)),[x]),Ae=un.useCallback((o,B)=>{m.sortField(o,B);},[m]),ge=un.useCallback((o,B)=>{Nt?.fieldId&&m.sortFieldBySummary(o,Nt.fieldId,B);},[m,Nt]),Mo=un.useCallback(()=>{m.clearAllSorting();},[m]),Do=un.useCallback(o=>{m.updateField(o),He(null);},[m,He]),Fo=un.useCallback(o=>{D||m.toggleExpanded(o);},[m,D]),eo=un.useMemo(()=>D?void 0:o=>{H&&H(m.resolveCellClick(o));},[m,D,H]),oo=un.useMemo(()=>D?void 0:(o,B)=>ee({x:o,y:B}),[D,ee]),Io=un.useMemo(()=>D?void 0:o=>m.setColumnWidths(o),[m,D]),zo=un.useCallback(o=>m.setSelectionStats(o),[m]),ro=un.useCallback((o,B,$t)=>{m.applyFilter(o,B,$t);},[m]),Zo=un.useCallback(o=>{m.clearFilter(o);},[m]),go=un.useMemo(()=>fe&&x.find(o=>o.id===fe.fieldId)||null,[fe,x]),ae=un.useCallback(()=>{m.expandAll();},[m]),i=un.useCallback((o,B)=>m.exportData(o,B).catch($t=>{let we=$t instanceof Error?$t:new Error(String($t));G?G(we):console.error(we);}),[m,G]),n=un.useCallback(o=>{i(o,{applyFilters:true});},[i]),s=un.useMemo(()=>({initializing:q("initializing"),processing:q("processing"),importError:q("importError"),importWarning:q("importWarning"),importSuccess:q("importSuccess"),cancelled:q("importCancelled"),cancel:q("cancel"),dataImportUnsupported:q("dataImportUnsupported")}),[q]),g=un.useCallback(async o=>{await m.importFile(o,s);},[m,s]),b=un.useCallback(async o=>{await m.importFiles(o,s);},[m,s]),N=un.useCallback(async()=>{let o="";try{o=await navigator.clipboard.readText();}catch{m.showImportStatus("error",q("importError"),[q("clipboardDenied")]);return}if(!o||!o.trim()){m.showImportStatus("warning",q("importWarning"),[q("clipboardEmpty")]);return}await m.importText(o,s);},[m,s,q]),[J,Z]=un.useState(false),nt=un.useRef(0),tt=o=>Array.from(o.dataTransfer?.types??[]).includes("Files"),W=un.useCallback(o=>{tt(o)&&(o.preventDefault(),nt.current+=1,Z(true));},[]),gt=un.useCallback(o=>{tt(o)&&(o.preventDefault(),o.dataTransfer.dropEffect="copy");},[]),Mt=un.useCallback(o=>{tt(o)&&(nt.current=Math.max(0,nt.current-1),nt.current===0&&Z(false));},[]),_t=un.useCallback(o=>{if(!tt(o))return;o.preventDefault(),nt.current=0,Z(false);let B=Array.from(o.dataTransfer.files??[]);B.length>0&&m.importFiles(B,s);},[m,s]),se=un.useCallback(()=>{to({isOpen:true,defaultName:"",title:q("saveNewView")});},[q]),Vt=un.useCallback((o,B)=>{m.saveReport(o,B),to(null);},[m]),Yt=un.useCallback(()=>{m.updateCurrentReport();},[m]),oe=un.useCallback(()=>{let o=Rt.find(B=>B.id===_e);o&&to({isOpen:true,defaultName:`${o.name} (Copy)`,title:q("saveAsView")});},[_e,Rt,q]),Ht=un.useCallback(o=>{m.loadReport(o);},[m]),xt=un.useCallback(o=>{m.deleteReport(o);},[m]),Kt=un.useCallback(o=>{m.setDefaultReport(o);},[m]);return jsxRuntime.jsx(er,{theme:U,className:[L?"kanuni-pivot-striped":"",pivotgridCore.pivotDensityClass(R)].filter(Boolean).join(" "),style:{position:"relative",width:"100%",height:"100%"},children:jsxRuntime.jsx(core.DndContext,{sensors:D?[]:ze,collisionDetection:Qs,autoScroll:false,accessibility:{screenReaderInstructions:{draggable:q("fieldChipKeys")}},onDragStart:qo,onDragMove:vo,onDragEnd:mo,onDragCancel:o=>{mo({...o,over:null});},children:jsxRuntime.jsx(xo.Provider,{value:Jo,children:jsxRuntime.jsxs("div",{ref:Yo,className:`kanuni-pivot-wrapper pivot-flex pivot-flex-col ${At?"pivot-is-fullscreen":""}`,onDragEnter:W,onDragOver:gt,onDragLeave:Mt,onDrop:_t,style:{position:At?"fixed":"relative",inset:At?0:void 0,width:At?void 0:"100%",height:At?void 0:"100%",zIndex:At?99999:"auto",margin:At?0:"auto",padding:At?0:"auto",maxWidth:At?"none":"auto",maxHeight:At?"none":"auto",backgroundColor:At?"var(--pivot-bg)":"transparent"},children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-live",role:"status","aria-live":"polite",style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap"},children:ut}),jsxRuntime.jsxs("div",{className:"pivot-grid pivot-flex-1 pivot-flex pivot-flex-col pivot-relative",style:{height:"100%",minHeight:0,width:"100%",overflow:"hidden",backgroundColor:"var(--pivot-bg)",border:At?"none":"1px solid var(--pivot-border)",borderRadius:At?"0":"var(--pivot-radius-md)",userSelect:"none"},children:[J&&jsxRuntime.jsx("div",{className:"pivot-animate-fade-in",style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",background:"color-mix(in srgb, var(--pivot-primary) 12%, transparent)",border:"2px dashed var(--pivot-primary)",borderRadius:"var(--pivot-radius-md)"},children:jsxRuntime.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",padding:"12px 20px",borderRadius:"var(--pivot-radius-md)",background:"var(--pivot-surface)",color:"var(--pivot-text)",boxShadow:"var(--pivot-shadow-lg, 0 8px 24px rgba(0,0,0,0.18))",fontSize:"14px",fontWeight:600},children:[jsxRuntime.jsx(lucideReact.Upload,{size:18,color:"var(--pivot-primary)"}),q("dropToImport")]})}),vt.showFilterArea!==false&&jsxRuntime.jsx(ar,{filterFields:ho,onRemoveField:$e,onFilterClick:(o,B,$t)=>Re({x:o,y:B,fieldId:$t}),onContextMenu:(o,B,$t,we)=>ye({x:o,y:B,fieldId:$t,colPath:we}),onSort:(o,B)=>Ae(o,B),onGlobalContextMenu:(o,B)=>ee({x:o,y:B}),onMoveField:D?void 0:Ze}),jsxRuntime.jsx("div",{className:"pivot-flex pivot-flex-1 pivot-overflow-hidden pivot-relative",style:{minHeight:0},children:jsxRuntime.jsxs("div",{className:"pivot-flex-1 pivot-flex pivot-flex-col pivot-overflow-hidden pivot-relative",style:{minHeight:0},children:[jt?.columnsTruncated&&jsxRuntime.jsx("div",{className:"kanuni-pivot-notice",role:"status",children:q("columnsTruncated").replace("{shown}",new Intl.NumberFormat(de).format(jt.columnsTruncated.shown)).replace("{total}",new Intl.NumberFormat(de).format(jt.columnsTruncated.total))}),jt?jsxRuntime.jsx(vr,{onMoveField:D?void 0:Ze,engineResult:jt,isBuilding:Qt,buildProgress:pt,rowFields:Eo,colFields:Le,dataFields:fo,layout:vt,expandedPaths:Jt,allExpanded:Jt.has("*"),onToggleExpand:Fo,onExpandPaths:D?()=>{}:o=>m.expandPaths(o),onCollapsePaths:D?()=>{}:o=>m.collapsePaths(o),expandedColPaths:Et,allColExpanded:Et.has("*"),onToggleColExpand:D?()=>{}:o=>m.toggleColExpanded(o),onExpandColPaths:D?()=>{}:o=>m.expandColPaths(o),onCollapseColPaths:D?()=>{}:o=>m.collapseColPaths(o),columnWidths:Xt,defaultColumnWidths:et,rowHeight:pivotgridCore.pivotRowHeight(R),onColumnWidthsChange:Io,onSelectionStatsChange:zo,registry:O,keyboardNavigation:w,onCellPrepared:_,disabled:D,renderNodeContextMenu:ot,onCellClick:eo,onContextMenu:D?void 0:(o,B,$t,we)=>ye({x:o,y:B,fieldId:$t,colPath:we}),onFilterClick:D?void 0:(o,B,$t)=>Re({x:o,y:B,fieldId:$t}),onRemoveField:D?()=>{}:$e,onSort:D?void 0:(o,B)=>Ae(o,B),onGlobalContextMenu:oo}):it?jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col pivot-items-center pivot-justify-center pivot-h-full pivot-gap-4 pivot-text-danger",style:{backgroundColor:"color-mix(in srgb, var(--pivot-danger) 5%, transparent)",padding:"16px",textAlign:"center"},children:[jsxRuntime.jsx("div",{style:{backgroundColor:"color-mix(in srgb, var(--pivot-danger) 20%, transparent)",padding:"12px",borderRadius:"9999px"},children:jsxRuntime.jsx(lucideReact.X,{size:24,color:"var(--pivot-danger)"})}),jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx("h3",{className:"pivot-font-bold pivot-text-lg",style:{marginBottom:"4px"},children:q("error")}),jsxRuntime.jsx("p",{className:"pivot-text-sm",style:{opacity:.8,maxWidth:"28rem"},children:it.message||q("systemError")})]})]}):jsxRuntime.jsxs("div",{className:"pivot-flex pivot-flex-col pivot-items-center pivot-justify-center pivot-h-full pivot-text-muted pivot-gap-4",children:[jsxRuntime.jsx("div",{style:{animation:"datagrid-spin 1s linear infinite",borderRadius:"50%",height:"32px",width:"32px",borderBottom:"2px solid var(--pivot-primary)",borderRight:"2px solid transparent",borderTop:"2px solid transparent",borderLeft:"2px solid transparent"}}),jsxRuntime.jsx("span",{className:"pivot-text-sm pivot-font-medium",children:q(Qt?"initializing":"loading")}),Qt&&jsxRuntime.jsxs("div",{style:{width:220,display:"flex",flexDirection:"column",gap:6,alignItems:"center"},children:[jsxRuntime.jsx("div",{style:{width:"100%",height:6,borderRadius:999,overflow:"hidden",backgroundColor:"color-mix(in srgb, var(--pivot-border) 60%, transparent)"},children:jsxRuntime.jsx("div",{style:{width:`${Math.max(0,Math.min(100,pt))}%`,height:"100%",borderRadius:999,backgroundColor:"var(--pivot-primary)",transition:"width 160ms ease-out"}})}),jsxRuntime.jsxs("span",{className:"pivot-text-xs pivot-font-semibold",style:{color:"var(--pivot-text)"},children:[Math.round(pt),"%"]})]})]})]})}),vt.showFooter!==false&&jsxRuntime.jsx(br,{toolbarConfig:I,fieldChooserOpen:Pe,onToggleFieldChooser:()=>po(!Pe),onAddCalculatedField:T?()=>{Se(void 0),Fe(true);}:void 0,onOpenPrefilter:K?()=>te(true):void 0,onToggleChart:h,onExpandAll:ae,onCollapseAll:()=>m.collapseAll(),onRefresh:M,onExport:n,onImportFile:g,onImportFiles:b,onPasteImport:N,reports:Rt,activeReportId:_e,onSaveNewReport:se,onUpdateCurrentReport:Yt,onSaveAsReport:oe,onLoadReport:Ht,onDeleteReport:xt,onSetDefaultReport:Kt,onGlobalContextMenu:(o,B)=>ee({x:o,y:B}),selectionStats:To,advancedExport:kt,upgradeUrl:E,isFullscreen:At,onToggleFullscreen:Xo,onSearch:bt?o=>m.setSearchText(o):void 0,searchText:Ce})]}),Nt&&jsxRuntime.jsx(Sr,{x:Nt.x,y:Nt.y,field:x.find(o=>o.id===Nt.fieldId),colPath:Nt.colPath,rowFields:Eo,onClose:()=>ye(null),onSort:o=>Ae(Nt.fieldId,o),onSortBySummary:ge,onClearAllSorting:Mo,onHide:()=>$e(Nt.fieldId),onSettings:()=>{He(Nt.fieldId);},onMoveField:o=>Ze(Nt.fieldId,o),onMoveToArea:o=>m.changeFieldArea(Nt.fieldId,o),onShowFieldChooser:()=>po(true),onEditCalculatedField:()=>{Se(x.find(o=>o.id===Nt.fieldId)),Fe(true);},onConditionFilter:()=>zt(Nt.fieldId),customContextMenuItems:y?y(x.find(o=>o.id===Nt.fieldId)):void 0}),ce&&jsxRuntime.jsx(wr,{field:x.find(o=>o.id===ce),onClose:()=>He(null),onSave:Do}),Ye&&x.some(o=>o.id===Ye)&&jsxRuntime.jsx(di,{field:x.find(o=>o.id===Ye),dataFields:fo,onClose:()=>zt(null),onSave:o=>{m.updateField(o),zt(null);}}),fe&&go&&jsxRuntime.jsx(Nr,{field:go,data:m.getRawData(),onApply:ro,onClear:Zo,onClose:()=>Re(null),x:fe.x,y:fe.y,gridId:Wt,onConditionFilter:()=>zt(go.id)}),T&&T({isOpen:co,onClose:()=>{Fe(false),Se(void 0);},fields:x,editingField:uo,onSave:o=>{uo?m.updateField(o):m.setFields([...x,o]),Fe(false),Se(void 0);},onDeleteField:o=>m.deleteField(o)}),K&&K({isOpen:Je,onClose:()=>te(false),fields:x,initialPrefilter:vt.prefilter,onApply:o=>m.setLayout({prefilter:o})}),jsxRuntime.jsx(Mr,{isOpen:Bt.isOpen,status:Bt.status,title:Bt.title,messages:Bt.messages,progress:Bt.progress,phase:Bt.phase,cancellable:Bt.cancellable,onCancel:()=>m.cancelImport(),onClose:()=>m.closeImportStatus()}),lo&&jsxRuntime.jsx(ki,{preview:lo,onApply:o=>m.commitImport(o,s),onCancel:()=>m.cancelImportPreview()}),Pe&&jsxRuntime.jsx(pi,{fields:x,onClose:()=>po(false),onRemoveField:$e,onDeleteField:o=>m.deleteField(o),onChangeFieldArea:(o,B)=>{m.changeFieldArea(o,B);},onShowFields:o=>m.showFields(o),onFilterClick:(o,B)=>Re({x:o.clientX,y:o.clientY,fieldId:B.id})}),jsxRuntime.jsx(core.DragOverlay,{dropAnimation:null,children:Ie?jsxRuntime.jsx("div",{className:"pivot-flex pivot-items-center pivot-gap-2 pivot-font-semibold pivot-truncate",style:{padding:"8px 12px",backgroundColor:"var(--pivot-surface)",border:"2px solid var(--pivot-primary)",boxShadow:"var(--pivot-shadow-xl)",borderRadius:"var(--pivot-border-radius)",fontSize:"14px",opacity:.9,cursor:"grabbing",transform:"scale(1.05)",transformOrigin:"0 0",pointerEvents:"none"},children:jsxRuntime.jsx("span",{className:"pivot-truncate",style:{maxWidth:"150px",color:"var(--pivot-text)"},children:x.find(o=>o.id===Ie)?.caption||"Field"})}):null}),Qe&&jsxRuntime.jsx(Dr,{isOpen:Qe.isOpen,title:Qe.title,defaultName:Qe.defaultName,onClose:()=>to(null),onSave:Vt}),he&&jsxRuntime.jsx(be,{children:jsxRuntime.jsxs("div",{className:"kanuni-pivot-portal-root",children:[jsxRuntime.jsx("div",{className:"pivot-fixed",style:{position:"fixed",inset:0,zIndex:300},onPointerDown:()=>ee(null),onContextMenu:o=>{o.preventDefault(),ee(null);}}),jsxRuntime.jsxs("div",{className:"kanuni-pivot-dropdown-menu pivot-animate-zoom-in",style:{position:"fixed",zIndex:301,width:"224px",fontSize:"14px",left:Math.min(he.x,typeof window<"u"?window.innerWidth-224:he.x),top:Math.min(he.y,typeof window<"u"?window.innerHeight-200:he.y)},children:[jsxRuntime.jsx("div",{className:"kanuni-pivot-report-section-title",children:q("viewOptions")}),jsxRuntime.jsxs("button",{className:"pivot-w-full pivot-flex pivot-items-center pivot-justify-between",style:{padding:"6px 12px",textAlign:"left"},onMouseEnter:o=>o.currentTarget.style.backgroundColor="var(--pivot-surface-hover)",onMouseLeave:o=>o.currentTarget.style.backgroundColor="transparent",onClick:()=>{m.setLayout({showFilterArea:vt.showFilterArea===false}),ee(null);},children:[jsxRuntime.jsx("span",{children:q("filterArea")}),jsxRuntime.jsx("span",{className:"pivot-text-xs pivot-text-muted pivot-font-medium",children:vt.showFilterArea===false?q("show"):q("hide")})]}),jsxRuntime.jsxs("button",{className:"pivot-w-full pivot-flex pivot-items-center pivot-justify-between",style:{padding:"6px 12px",textAlign:"left"},onMouseEnter:o=>o.currentTarget.style.backgroundColor="var(--pivot-surface-hover)",onMouseLeave:o=>o.currentTarget.style.backgroundColor="transparent",onClick:()=>{m.setLayout({showFooter:vt.showFooter===false}),ee(null);},children:[jsxRuntime.jsx("span",{children:q("footerArea")}),jsxRuntime.jsx("span",{className:"pivot-text-xs pivot-text-muted pivot-font-medium",children:vt.showFooter===false?q("show"):q("hide")})]})]})]})})]})})})})},hl=un.forwardRef(fl),gl=function(r,c){let{locale:a,dictionary:l,rtl:e,onError:p,...C}=r;return jsxRuntime.jsx(or,{locale:a,dictionary:l,rtl:e,children:jsxRuntime.jsx(So,{onError:p,children:jsxRuntime.jsx(hl,{...C,onError:p,ref:c})})})},bl=un.forwardRef(gl);Object.defineProperty(exports,"defaultPivotLayout",{enumerable:true,get:function(){return pivotgridCore.defaultPivotLayout}});exports.BasePivotGrid=bl;exports.PivotAreaStrips=ar;exports.PivotConfigProvider=or;exports.PivotContextMenu=Sr;exports.PivotErrorBoundary=So;exports.PivotFieldList=Ke;exports.PivotFieldSettingsDialog=wr;exports.PivotFooter=br;exports.PivotGridBody=vr;exports.PivotHeaderFilterPopup=Nr;exports.PivotImportStatusModal=Mr;exports.PivotNodeContextMenu=sr;exports.PivotPortal=be;exports.PivotPortalContext=xo;exports.PivotReportMenu=mr;exports.PivotReportSaveModal=Dr;exports.PivotThemeProvider=er;exports.usePivotChartSync=rr;exports.usePivotConfig=mt;exports.usePivotContextMenu=zr;exports.usePivotController=Hr;exports.usePivotControllerStore=qt;exports.usePivotDnD=Er;exports.usePivotFullscreen=Ir;
|