rowvia 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,37 @@
1
- (function(z,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(z=typeof globalThis<"u"?globalThis:z||self,se(z.Rowvia={}))})(this,function(z){"use strict";var en=Object.defineProperty;var tn=(z,se,we)=>se in z?en(z,se,{enumerable:!0,configurable:!0,writable:!0,value:we}):z[se]=we;var p=(z,se,we)=>tn(z,typeof se!="symbol"?se+"":se,we);class se{constructor(){p(this,"listeners",new Map)}addEventListener(e,i){let t=this.listeners.get(e);t||(t=[],this.listeners.set(e,t)),t.push(i)}removeEventListener(e,i){const t=this.listeners.get(e);if(!t)return;const s=t.indexOf(i);s>=0&&t.splice(s,1)}dispatchEvent(e,i){const t=this.listeners.get(e);if(!t||t.length===0)return;const s={type:e,...i||{}};for(const n of t.slice())n(s)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const we=13,Zt=27,ut=9,pt=8,gt=46,Jt=36,ei=35;function ke(l){return l==null?"":String(l).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let ti=0;function Qe(l="id"){return`${l}-${++ti}`}function ae(l,e){if(typeof l!="number"||isNaN(l))return String(l??"");const i=e??0,t=l.toFixed(i),[s,n]=t.split("."),o=s.replace(/\B(?=(\d{3})+(?!\d))/g,",");return n?`${o}.${n}`:o}function Ze(l){if(l==null||l==="")return null;const e=Number(l);return isNaN(e)?null:e}function ii(l,e){if(l===e)return 0;if(l==null)return-1;if(e==null)return 1;if(typeof l=="number"&&typeof e=="number")return l-e;if(l instanceof Date&&e instanceof Date)return l.getTime()-e.getTime();const i=String(l).toLowerCase(),t=String(e).toLowerCase();return i<t?-1:i>t?1:0}function si(l,e){return e==null?!1:String(e).toLowerCase().includes(l.toLowerCase())}class ne extends Error{constructor(e){super(e),this.code=e}}const ni=/^\$?[A-Za-z]{1,3}\$?\d+$/;function ft(l){const e=[];let i=0;for(;i<l.length;){const t=l[i];if(t===" "||t===" "||t===`
2
- `||t==="\r"){i++;continue}if(t==='"'||t==="'"){const n=t;let o="";for(i++;i<l.length&&l[i]!==n;)o+=l[i++];i++,e.push({type:"string",value:o});continue}if(/[0-9]/.test(t)||t==="."&&/[0-9]/.test(l[i+1]||"")){let n="";for(;i<l.length&&/[0-9.]/.test(l[i]);)n+=l[i++];if(l[i]==="e"||l[i]==="E")for(n+=l[i++],(l[i]==="+"||l[i]==="-")&&(n+=l[i++]);i<l.length&&/[0-9]/.test(l[i]);)n+=l[i++];e.push({type:"number",value:n});continue}if(/[A-Za-z_$]/.test(t)){let n="";for(;i<l.length&&/[A-Za-z0-9_$.]/.test(l[i]);)n+=l[i++];ni.test(n)?e.push({type:"cell",value:n.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:n});continue}if(t==="("){e.push({type:"lparen",value:t}),i++;continue}if(t===")"){e.push({type:"rparen",value:t}),i++;continue}if(t===","||t===";"){e.push({type:"comma",value:","}),i++;continue}const s=l.slice(i,i+2);if(["<=",">=","<>"].includes(s)){e.push({type:"op",value:s}),i+=2;continue}if("+-*/^%&=<>,:".includes(t)){e.push({type:"op",value:t}),i++;continue}throw new ne("#NAME?")}return e}const mt={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function vt(l){let e=0;const i=()=>l[e],t=()=>l[e++];function s(r=0){let d=n();for(;i()&&i().type==="op"&&mt[i().value]>=r;){const c=t().value,h=s(mt[c]+1);d={type:"binary",operator:c,left:d,right:h}}return d}function n(){const r=i();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){t();const d=n();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return o()}function o(){const r=t();if(!r)throw new ne("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=i();if(c&&c.type==="lparen"){t();const h=[];if(i()&&i().type!=="rparen")for(h.push(s());i()&&i().type==="comma";)t(),h.push(s());if(!i()||i().type!=="rparen")throw new ne("#ERROR!");return t(),{type:"call",name:d,args:h}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=s();if(!i()||i().type!=="rparen")throw new ne("#ERROR!");return t(),d}throw new ne("#ERROR!")}const a=s();if(e<l.length)throw new ne("#ERROR!");return a}function $(l){if(l==null||l==="")return 0;if(typeof l=="number")return l;if(typeof l=="boolean")return l?1:0;if(l instanceof Date)return l.getTime();const e=Number(l);return isNaN(e)?0:e}function be(l){const e=[];for(const i of l)if(Array.isArray(i))e.push(...be(i));else if(i!=null&&i!==""){const t=typeof i=="number"?i:Number(i);isNaN(t)||e.push(t)}return e}const Oe={SUM:l=>be(l).reduce((e,i)=>e+i,0),AVERAGE:l=>{const e=be(l);return e.length?e.reduce((i,t)=>i+t,0)/e.length:0},AVG:l=>Oe.AVERAGE(l,{}),MIN:l=>{const e=be(l);return e.length?Math.min(...e):0},MAX:l=>{const e=be(l);return e.length?Math.max(...e):0},COUNT:l=>be(l).length,COUNTA:l=>l.filter(e=>e!=null&&e!=="").length,ABS:l=>Math.abs($(l[0])),ROUND:l=>{const e=l.length>1?$(l[1]):0,i=Math.pow(10,e);return Math.round($(l[0])*i)/i},FLOOR:l=>Math.floor($(l[0])),CEIL:l=>Math.ceil($(l[0])),CEILING:l=>Math.ceil($(l[0])),SQRT:l=>{const e=$(l[0]);return e<0?(()=>{throw new ne("#NUM!")})():Math.sqrt(e)},POWER:l=>Math.pow($(l[0]),$(l[1])),POW:l=>Math.pow($(l[0]),$(l[1])),MOD:l=>{const e=$(l[1]);if(e===0)throw new ne("#DIV/0!");return $(l[0])%e},CONCAT:l=>l.map(e=>e==null?"":String(e)).join(""),CONCATENATE:l=>l.map(e=>e==null?"":String(e)).join(""),UPPER:l=>String(l[0]??"").toUpperCase(),LOWER:l=>String(l[0]??"").toLowerCase(),LEN:l=>String(l[0]??"").length,LEFT:l=>String(l[0]??"").slice(0,l.length>1?$(l[1]):1),RIGHT:l=>{const e=String(l[0]??""),i=l.length>1?$(l[1]):1;return i<=0?"":e.slice(-i)},MID:l=>{const e=String(l[0]??""),i=Math.max(0,$(l[1])-1),t=l.length>2?$(l[2]):e.length-i;return e.slice(i,i+t)},TRIM:l=>String(l[0]??"").trim(),IF:l=>l[0]?l[1]??!0:l[2]??!1,IFS:l=>{for(let e=0;e<l.length-1;e+=2)if(l[e])return l[e+1];return l.length%2===1?l[l.length-1]:!1},AND:l=>l.every(e=>!!e),OR:l=>l.some(e=>!!e),NOT:l=>!l[0],IFERROR:l=>{try{return l[0]===null||l[0]===void 0?l[1]:l[0]}catch{return l[1]}},ISNUMBER:l=>typeof l[0]=="number"||l[0]!==null&&l[0]!==""&&!isNaN(Number(l[0])),ISBLANK:l=>l[0]===null||l[0]===void 0||l[0]==="",ISTEXT:l=>typeof l[0]=="string",PI:()=>Math.PI,RAND:()=>Math.random(),TODAY:()=>new Date().toISOString().slice(0,10),NOW:()=>new Date().toISOString(),YEAR:l=>new Date(l[0]).getFullYear(),MONTH:l=>new Date(l[0]).getMonth()+1,DAY:l=>new Date(l[0]).getDate(),TEXT:l=>String(l[0]??""),VALUE:l=>$(l[0]),NUMBER:l=>$(l[0]),BETWEEN:l=>$(l[0])>=$(l[1])&&$(l[0])<=$(l[2])},Be=Object.keys(Oe);function oi(l,e){Oe[l.toUpperCase()]=e,Be.includes(l.toUpperCase())||Be.push(l.toUpperCase())}function li(l,e){const i=/^([A-Za-z]{1,3})(\d+)$/.exec(l);if(i&&e.a1Lookup)return e.a1Lookup(i[1].toUpperCase(),Number(i[2]))}function ri(l,e){const i=e.data||{};if(l in i)return i[l];const t=l.toLowerCase();for(const s of Object.keys(i))if(s.toLowerCase()===t)return i[s]}function Le(l,e){switch(l.type){case"number":return l.value;case"string":return l.value;case"boolean":return l.value;case"ref":return ri(l.value,e);case"cell":return li(l.value,e);case"unary":return-$(Le(l.operand,e));case"call":{const i=Oe[l.name];if(!i)throw new ne("#NAME?");const t=l.args.map(s=>Le(s,e));return i(t,e)}case"binary":{const i=Le(l.left,e),t=Le(l.right,e);switch(l.operator){case"+":return typeof i=="string"||typeof t=="string"?`${i??""}${t??""}`:$(i)+$(t);case"-":return $(i)-$(t);case"*":return $(i)*$(t);case"/":{const s=$(t);if(s===0)throw new ne("#DIV/0!");return $(i)/s}case"^":return Math.pow($(i),$(t));case"%":{const s=$(t);if(s===0)throw new ne("#DIV/0!");return $(i)%s}case"&":return`${i??""}${t??""}`;case"=":return i===t;case"<>":return i!==t;case"<":return $(i)<$(t);case"<=":return $(i)<=$(t);case">":return $(i)>$(t);case">=":return $(i)>=$(t);default:throw new ne("#ERROR!")}}default:throw new ne("#ERROR!")}}function De(l,e={}){const i=l.startsWith("=")?l.slice(1):l,t=vt(ft(i));return Le(t,e)}function Je(l){return typeof l=="string"&&l.trimStart().startsWith("=")}function et(l,e){if(l==null)return;if(e in l)return l[e];const i=e.split(".");let t=l;for(const s of i){if(t==null)return;t=t[s]}return t}function H(l,e,i){const t=l.colDef,s=(e.group||e.footer)&&!!e.groupData&&e.groupData[l.colId]!==void 0,n=s?e.groupData:e.data,o=l.valueGetter??t.valueGetter;if(o)return(typeof o=="string"?r=>Je(o)?De(o,{data:r.data}):et(r.data,o):o)({data:s?e.groupData:e.data,node:e,column:l,api:i,colDef:t,getValue:r=>et(s?e.groupData:e.data,r)});if(l.field&&Je(l.field))return De(l.field,{data:e.data});if(l.field&&l.colDef.expression&&/[+*/^-]/.test(l.field))return De(`=${l.field}`,{data:e.data});if(l.field)return et(n,l.field)}function Ve(l,e,i){var n;let t=H(l,e,i);const s=l.colDef;if(s.showValueAs&&typeof t=="number"&&i){const o=(n=i.__columnTotalCache)==null?void 0:n.get(l.colId);if(o!==void 0&&o!==0)return`${(s.showValueAs==="percentOfParent"?t/(o||1)*100:t/o*100).toFixed(1)}%`}return s.valueFormatter?(typeof s.valueFormatter=="string"?a=>ai(a.colDef.valueFormatter,a.value,a):s.valueFormatter)({value:t,data:e.data,node:e,column:l,api:i,colDef:s}):di(l,t)}function ai(l,e,i={}){var t,s,n;if(e==null)return"";switch(l){case"number":return ae(e,((t=i.column)==null?void 0:t.decimals)??0);case"currency":return`$${ae(e,((s=i.column)==null?void 0:s.decimals)??2)}`;case"percent":return`${ae(e,((n=i.column)==null?void 0:n.decimals)??2)}%`;case"date":return Ct(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Ct(l){const e=l instanceof Date?l:new Date(l);return isNaN(e.getTime())?String(l):`${e.getDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()]} ${e.getFullYear()}`}function di(l,e){if(e==null)return"";const i=l.type;return i==="numberColumn"&&typeof e=="number"&&!isNaN(e)?ae(e,l.decimals):i==="dateColumn"||i==="dateStringColumn"?Ct(e):i==="booleanColumn"?e?"✓":"✗":String(e)}function wt(l,e){return l.colDef.valueParser?(typeof l.colDef.valueParser=="string"?t=>yt(t.colDef.valueParser,t.newValue):l.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:l,colDef:l.colDef,api:null}):yt(l.type,e)}function yt(l,e){if(l==="numberColumn")return Ze(e);if(l==="dateColumn"){if(e instanceof Date)return e;const i=new Date(e);return isNaN(i.getTime())?e:i}return l==="booleanColumn"?e===!0||e==="true":e}function St(l){const i=l.colDef.comparator,t=l.type;return(s,n)=>{const o=H(l,s,null),a=H(l,n,null);if(i)return i(o,a,s,n);if(t==="numberColumn"){const r=typeof o=="number"?o:Ze(o),d=typeof a=="number"?a:Ze(a);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(t==="dateColumn"){const r=o instanceof Date?o.getTime():new Date(o).getTime(),d=a instanceof Date?a.getTime():new Date(a).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return ii(o,a)}}function Fe(l,e,i){if(!e)return null;if(typeof e=="function")return e({values:i,column:l,rowNode:null,data:null});const t=i.filter(s=>typeof s=="number"&&!isNaN(s));switch(e){case"sum":return t.reduce((s,n)=>s+n,0);case"count":return i.length;case"avg":return t.length?t.reduce((s,n)=>s+n,0)/t.length:null;case"min":return t.length?Math.min(...t):null;case"max":return t.length?Math.max(...t):null;case"first":return i.length?i[0]:null;case"last":return i.length?i[i.length-1]:null;default:return null}}const ci={textColumn:{filter:"text",editable:!0},numberColumn:{filter:"number",editable:!0,headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},dateColumn:{filter:"date",editable:!0},dateStringColumn:{filter:"date"},booleanColumn:{filter:"boolean",cellRenderer:"agCheckboxCellRenderer"},rightAligned:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},numericColumn:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"}};function hi(l){if(l===void 0||l===!0)return"text";if(l===!1)return!1;switch(l){case"agTextColumnFilter":return"text";case"agNumberColumnFilter":return"number";case"agDateColumnFilter":case"agDateColumnFilterString":return"date";case"agSetColumnFilter":return"set";default:return l}}function ui(l){return!!l.treeData}function pi(){return{applyAggregate:Fe}}class xt{constructor(e,i,t){p(this,"options");p(this,"eventService");p(this,"gridApi");p(this,"measureCtx",null);p(this,"gridColumnDefs",[]);p(this,"columns",[]);p(this,"displayOrder",[]);p(this,"autoGroupColumnDef");p(this,"pivotMode",!1);p(this,"columnGroups",[]);p(this,"openGroups",new Set);p(this,"groupsInitialised",!1);this.options=e,this.eventService=i,this.gridApi=t,this.autoGroupColumnDef={headerName:"",minWidth:200,width:250,sortable:!1,filter:!1,resizable:!0,suppressMovable:!0,cellRenderer:"agGroupCellRenderer",...e.autoGroupColumnDef||{}}}setGridApi(e){this.gridApi=e}getAutoGroupColumnDef(){return this.autoGroupColumnDef}getOptions(){return this.options}setPivotMode(e,i="api"){this.pivotMode!==e&&(this.pivotMode=e,this.eventService.dispatchEvent("columnPivotModeChanged",{api:this.gridApi,source:i}),this.refreshAll())}isPivotMode(){return this.pivotMode}setColumnDefs(e){this.gridColumnDefs=e||[],this.buildColumns()}static generateColumnDefs(e,i=bt){if(!e||e.length===0)return[];const t=e[0];if(!t||typeof t!="object")return[];const s=new Set(["children","detail","__proto__"]),n=[];for(const o of Object.keys(t)){if(s.has(o)||o.startsWith("__"))continue;const a=t[o],r={field:o,headerName:i(o)};typeof a=="number"?(r.type="numberColumn",r.filter="number"):typeof a=="boolean"?r.type="booleanColumn":a instanceof Date&&(r.type="dateColumn"),n.push(r)}return n}getColumnGroups(){return this.columnGroups}getGroupDepth(){return this.columnGroups.reduce((e,i)=>Math.max(e,i.depth),0)}isGroupOpen(e){return this.openGroups.has(e)}setGroupOpen(e,i){i?this.openGroups.add(e):this.openGroups.delete(e),this.updateVisible(),this.refreshAll()}getColumnDefs(){return this.gridColumnDefs}buildColumns(){const e=this.columns,i=new Map;for(const c of e)i.set(c.colId,c);const t=this.options.defaultColDef||{},s={...ci,...this.options.columnTypes||{}},n=[],o=[];let a=0;const r=(c,h)=>{const g=c.colId||c.field||Qe("col"),u={...t,...c};if(u.type&&s[u.type]){const f=s[u.type],m=new Set(Object.keys(c));for(const[v,C]of Object.entries(f))!m.has(v)&&!(v in t)&&(u[v]=C)}this.pushColumnInto(n,u,g,a++,i,h)},d=(c,h,g)=>{for(const u of c)if(u.children&&u.children.length){const f=u.groupId||Qe("group"),m={id:f,headerName:u.headerName??"",openByDefault:u.openByDefault===!0||u.columnGroupShow==="open",parentId:h,depth:g,childColumnIds:[]};o.push(m),this.groupsInitialised||(m.openByDefault?this.openGroups.add(f):this.openGroups.delete(f)),d(u.children,f,g+1)}else r(u,h)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=o,this.options.rowNumbers){const c={colId:"__rowNumber",headerName:"",width:60,pinned:"left",sortable:!1,filter:!1,resizable:!1,suppressMovable:!0,cellRenderer:"agRowNumberCellRenderer",cellClass:"ag-row-number-cell"};this.pushColumnInto(n,{...t,...c},"__rowNumber",-1,i,null)}for(const c of n){if(!c.groupId)continue;const h=o.find(g=>g.id===c.groupId);h&&h.childColumnIds.push(c.colId)}this.columns=n,this.displayOrder=n.map(c=>c.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,i,t,s,n){return this.buildColumn(e,i,t,s,n)}pushColumnInto(e,i,t,s,n,o){e.push(this.buildColumn(i,t,s,n,o))}buildColumn(e,i,t,s,n){const o=s.get(i),a=e.hide===!0||e.initialHide===!0,r={colId:i,field:e.field,headerName:e.headerName??(e.field?bt(e.field):""),headerTooltip:e.headerTooltip,colDef:e,width:e.width??e.minWidth??(e.flex?200:100),minWidth:e.minWidth??20,maxWidth:e.maxWidth??Number.MAX_SAFE_INTEGER,flex:e.flex??null,pinned:e.pinned??null,hide:a,visible:!a,lockPosition:e.lockPosition??!1,type:e.type,sortable:e.sortable??!!e.field,sort:e.sort??null,sortIndex:e.sortIndex??null,resizable:e.resizable??!0,filter:hi(e.filter),floatingFilter:e.floatingFilter??!1,filterParams:e.filterParams||{},editable:e.editable??!1,cellEditor:e.cellEditor,cellEditorParams:e.cellEditorParams||{},singleClickEdit:e.singleClickEdit??this.options.singleClickEdit??!1,valueSetter:e.valueSetter,valueGetter:e.valueGetter,valueFormatter:e.valueFormatter,valueParser:e.valueParser,comparator:e.comparator,aggFunc:e.aggFunc,allowedAggFuncs:e.allowedAggFuncs??["sum","min","max","count","avg"],rowGroup:e.rowGroup??!1,rowGroupIndex:e.rowGroupIndex??null,pivot:e.pivot??!1,pivotIndex:e.pivotIndex??null,enableRowGroup:e.enableRowGroup??!0,enablePivot:e.enablePivot??!0,enableValue:e.enableValue??!0,cellRenderer:e.cellRenderer,cellRendererParams:e.cellRendererParams,cellClass:e.cellClass,cellStyle:e.cellStyle,cellDataType:e.cellDataType===!0,cellClassRules:e.cellClassRules,rowDrag:e.rowDrag===!0,headerClass:e.headerClass,checkboxSelection:e.checkboxSelection??!1,headerCheckboxSelection:e.headerCheckboxSelection??!1,headerCheckboxSelectionFilteredOnly:e.headerCheckboxSelectionFilteredOnly??!1,headerCheckboxSelectionCurrentPageOnly:e.headerCheckboxSelectionCurrentPageOnly??!1,menuTabs:e.menuTabs??["filterMenuTab","generalMenuTab","columnsMenuTab"],suppressMenu:e.suppressMenu??this.options.suppressMenu??!1,suppressMovable:e.suppressMovable??this.options.suppressMovableColumns??!1,wrapText:e.wrapText??!1,autoHeight:e.autoHeight??!1,tooltipField:e.tooltipField,tooltipValueGetter:e.tooltipValueGetter,decimals:e.decimals??0,defIndex:t,filterActive:!1,left:0,groupId:n};return o&&(r.pinned=o.pinned,r.visible=o.visible,r.width=o.width,r.flex=o.flex,r.sort=o.sort,r.sortIndex=o.sortIndex,r.rowGroup=o.rowGroup,r.rowGroupIndex=o.rowGroupIndex,r.pivot=o.pivot,r.pivotIndex=o.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const i=this.getPivotColumns();if(i.length===0||!e||e.length===0){this.refreshAll();return}const t=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),s=[];for(const r of i){const d=[],c=new Set;for(const h of e){const g=h==null?void 0:h[r.field],u=String(g);c.has(u)||(c.add(u),d.push(g))}d.sort((h,g)=>h===g?0:String(h)<String(g)?-1:1);for(const h of t){for(const f of d){const m=`__pivot_${r.colId}_${h.colId}_${f}`,v=this.createColumn({colId:m,headerName:`${String(f)}`,width:130,type:h.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:h.cellClass,cellDataType:h.cellDataType},m,-1,new Map,null);v.aggFunc=h.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:f,valueColumnId:h.colId,valueField:h.field},v.valueGetter=C=>this.evaluatePivotValue(v,C.node),s.push(v)}const g=`__pivot_${r.colId}_${h.colId}_total`,u=this.createColumn({colId:g,headerName:"Total",width:130,type:h.type,sortable:!1,filter:!1,cellDataType:h.cellDataType},g,-1,new Map,null);u.aggFunc=h.aggFunc,u.groupId=r.colId,u.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:h.colId,valueField:h.field},u.valueGetter=f=>this.evaluatePivotValue(u,f.node),s.push(u)}}const n=new Set(i.map(r=>r.colId)),o=this.columns.reduce((r,d,c)=>n.has(d.groupId??"")?r:c,0);this.columns.splice(o+1,0,...s);for(const r of s)this.displayOrder.push(r.colId);const a=new Set(this.columnGroups.map(r=>r.id));for(const r of i)a.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,i){const t=e.__pivot;if(!t||!i)return;const s=[],n=c=>{if(!c.children||c.children.length===0){s.push(c);return}for(const h of c.children)n(h)};n(i);const a=(t.pivotValue===void 0?s:s.filter(c=>{var h;return String((h=c.data)==null?void 0:h[t.pivotField])===String(t.pivotValue)})).map(c=>{var h;return(h=c.data)==null?void 0:h[t.valueField]}).filter(c=>typeof c=="number");if(a.length===0)return null;const r=this.columns.find(c=>c.colId===t.valueColumnId),{applyAggregate:d}=pi();return d(r,e.aggFunc,a)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",i=!!this.options.treeData,t=this.getRowGroupColumns(),s=this.options.groupDisplayType||"singleColumn",n=i||t.length>0&&s!=="multipleColumns";for(const c of t)s==="multipleColumns"?(c.cellRenderer="agGroupCellRenderer",c.cellRendererParams={...c.cellRendererParams||{},suppressCount:!0}):c.cellRenderer==="agGroupCellRenderer"&&!c.colDef.cellRenderer&&(c.cellRenderer=void 0,c.cellRendererParams=void 0);const o=this.columns.find(c=>c.colId===e);if(!n){o&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const a={...this.autoGroupColumnDef};if(a.colId=e,o)o.headerName=a.headerName??"",o.colDef=a,o.cellRenderer=a.cellRenderer,o.cellRendererParams=a.cellRendererParams,o.width=a.width??o.width,o.minWidth=a.minWidth??o.minWidth,o.pinned=a.pinned??"left";else{const c=this.createColumn(a,e,-2,new Map,null);this.columns.unshift(c),this.displayOrder.unshift(e)}const r=this.columns.find(c=>c.colId===e),d=()=>this.getRowGroupColumns()[0];r.valueGetter=c=>{const h=c.node;if(!h)return"";if(h.key!==null&&h.key!==void 0)return h.key;if(ui(this.options))return"";const g=d();return g!=null&&g.field&&h.data?h.data[g.field]??"":""}}updateVisible(){for(const e of this.columns)e.visible=!e.hide&&this.isGroupChainOpen(e.groupId)}isGroupChainOpen(e){let i=e;for(;i;){if(!this.openGroups.has(i))return!1;const t=this.columnGroups.find(s=>s.id===i);i=(t==null?void 0:t.parentId)??null}return!0}refreshAll(){this.eventService.dispatchEvent("columnEverythingChanged",{api:this.gridApi,source:"gridOptionsChanged"}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi})}getAllColumns(){return this.columns.slice()}getColumn(e){const i=typeof e=="string"?e:e.colId;return this.columns.find(t=>t.colId===i)}getColumns(){return this.displayOrder.map(e=>this.getColumn(e)).filter(Boolean)}getDisplayedColumns(){return this.getColumns().filter(e=>e.visible)}getDisplayedLeftColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="left")}getDisplayedCenterColumns(){return this.getDisplayedColumns().filter(e=>e.pinned!=="left"&&e.pinned!=="right")}getDisplayedRightColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="right")}getDisplayedColumnsByType(){return{left:this.getDisplayedLeftColumns(),center:this.getDisplayedCenterColumns(),right:this.getDisplayedRightColumns()}}getRowGroupColumns(){return this.getColumns().filter(e=>e.rowGroup).sort((e,i)=>(e.rowGroupIndex??0)-(i.rowGroupIndex??0))}getPivotColumns(){return this.getColumns().filter(e=>e.pivot).sort((e,i)=>(e.pivotIndex??0)-(i.pivotIndex??0))}getValueColumns(){return this.pivotMode?this.getColumns().filter(e=>e.aggFunc&&!e.rowGroup&&!e.pivot):this.getColumns().filter(e=>!!e.aggFunc)}isRowGroupActive(){return this.getRowGroupColumns().length>0}setRowGroupColumns(e,i="api"){const t=e.map(s=>this.getColumn(s)).filter(Boolean);for(const s of this.getColumns())t.includes(s)||(s.rowGroup=!1,s.rowGroupIndex=null);t.forEach((s,n)=>{s.rowGroup=!0,s.rowGroupIndex=n,s.pivot=!1,s.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:i,columns:t}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,i="api"){const t=this.getColumn(e);if(!t)return;const s=this.getRowGroupColumns();t.rowGroup=!0,t.rowGroupIndex=s.length,t.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:i,columns:[t]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,i="api"){const t=this.getColumn(e);if(!t)return;t.rowGroup=!1,t.rowGroupIndex=null,this.getRowGroupColumns().forEach((n,o)=>n.rowGroupIndex=o),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:i,columns:[t]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,i="api"){const t=e.map(s=>this.getColumn(s)).filter(Boolean);for(const s of this.getColumns())t.includes(s)?s.aggFunc||(s.aggFunc="sum"):s.aggFunc&&!s.rowGroup&&(s.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:i,columns:t}),this.refreshAll()}addValueColumn(e,i="sum",t="api"){const s=this.getColumn(e);s&&(s.aggFunc=i,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:[s]}),this.refreshAll())}setPivotColumns(e,i="api"){const t=e.map(s=>this.getColumn(s)).filter(Boolean);for(const s of this.getColumns())s.pivot=t.includes(s),s.pivotIndex=t.includes(s)?t.indexOf(s):null;this.refreshAll()}setColumnVisible(e,i,t="api"){const s=this.getColumn(e);!s||s.visible===i||(s.hide=!i,s.visible=i,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:s,visible:i,source:t}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:t}),this.refreshAll())}setColumnsVisible(e,i,t="api"){for(const s of e)this.setColumnVisible(s,i,t)}setColumnPinned(e,i,t="api"){const s=this.getColumn(e);s&&(s.lockPosition&&i!==s.pinned||(s.pinned=i,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:s,pinned:i,source:t}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:t}),this.refreshAll()))}setColumnsPinned(e,i,t="api"){for(const s of e)this.setColumnPinned(s,i,t)}moveColumn(e,i,t="api"){const s=this.getColumn(e);s&&this.moveColumnByIndex(this.displayOrder.indexOf(s.colId),i,t)}moveColumnByIndex(e,i,t="api"){const s=this.displayOrder.slice();if(e<0||e>=s.length)return;const[n]=s.splice(e,1);s.splice(Math.max(0,Math.min(s.length,i)),0,n),this.displayOrder=s;const o=this.getColumn(n);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:o,toIndex:i,source:t}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:t}),this.refreshAll()}getColumnState(){return this.getColumns().map(e=>({colId:e.colId,hide:e.hide,pinned:e.pinned,width:e.width,flex:e.flex??void 0,sort:e.sort,sortIndex:e.sortIndex,rowGroupIndex:e.rowGroupIndex,pivotIndex:e.pivotIndex,aggFunc:e.aggFunc}))}applyColumnState(e,i=!1){for(const t of e){const s=this.getColumn(t.colId);s&&(t.hide!==void 0&&(s.hide=t.hide,s.visible=!t.hide),t.pinned!==void 0&&(s.pinned=t.pinned),t.width!==void 0&&(s.width=t.width),t.flex!==void 0&&(s.flex=t.flex),t.sort!==void 0&&(s.sort=t.sort),t.sortIndex!==void 0&&(s.sortIndex=t.sortIndex),t.rowGroupIndex!==void 0&&(s.rowGroup=t.rowGroupIndex!==null,s.rowGroupIndex=t.rowGroupIndex),t.pivotIndex!==void 0&&(s.pivot=t.pivotIndex!==null,s.pivotIndex=t.pivotIndex),t.aggFunc!==void 0&&(s.aggFunc=t.aggFunc))}if(i){const t=new Map(e.map(n=>[n.colId,n.colId])),s=this.displayOrder.filter(n=>!t.has(n));this.displayOrder=[...e.map(n=>n.colId).filter(n=>this.getColumn(n)),...s]}this.refreshAll()}resetColumnState(){this.buildColumns()}getMeasureContext(){if(this.measureCtx)return this.measureCtx;const e=document.createElement("canvas");return this.measureCtx=e.getContext("2d"),this.measureCtx&&(this.measureCtx.font='400 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'),this.measureCtx}measureTextWidth(e){const i=this.getMeasureContext();return i?i.measureText(e).width:e.length*8}sizeColumnsToFit(e,i=[]){const t=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const s of t){let o=0,a=0;for(const d of s)i.includes(d.colId)?a+=d.width:d.flex!==null&&d.flex>0?o+=d.flex:a+=d.width;const r=Math.max(0,e-a-32);if(o>0){for(const d of s)if(d.flex!==null&&d.flex>0&&!i.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/o));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,i=!1){var a,r,d,c,h,g;const t=this.getColumn(e);if(!t)return;let s=this.measureTextWidth(t.headerName)+32;i||(s+=16);const n=((r=(a=this.gridApi)==null?void 0:a.getDisplayedRowCount)==null?void 0:r.call(a))??0,o=Math.min(n,300);for(let u=0;u<o;u++){const f=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,u);if(!f)continue;const m=(g=(h=this.gridApi)==null?void 0:h.getCellText)==null?void 0:g.call(h,t,f);m&&(s=Math.max(s,this.measureTextWidth(m)+32))}t.width=Math.max(t.minWidth,Math.min(t.maxWidth,Math.ceil(s))),t.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:t,finished:!0})}autoSizeAllColumns(e=!1){for(const i of this.getDisplayedColumns())this.autoSizeColumn(i,e)}}function bt(l){const e=l.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class ge{constructor(e,i,t){p(this,"id");p(this,"__id");p(this,"data");p(this,"parent",null);p(this,"children",null);p(this,"group",!1);p(this,"key",null);p(this,"level",0);p(this,"uiLevel",0);p(this,"rowGroupIndex");p(this,"expanded",!1);p(this,"selectable",!0);p(this,"selected",!1);p(this,"rowPinned",null);p(this,"detailNode",null);p(this,"masterNode",null);p(this,"footer",!1);p(this,"groupData",null);p(this,"rowHeight",null);p(this,"allChildrenCount",null);p(this,"stub",!1);p(this,"rowIndex",null);p(this,"__displayIndex");p(this,"services");p(this,"_id",null);p(this,"__passesFilter",!0);p(this,"__childCount",0);p(this,"__childrenLoaded",!1);this.data=e,this.services=i,this.__id=Qe("row"),this.id=t??this.__id,t&&(this._id=t)}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,i=!1,t="api"){return e?this.services.selectNode(this,i):this.services.deselectNode(this),0}isSelected(){return this.selected}setData(e){this.data=e}setDataValue(e,i){const t=typeof e=="string"?e:e.field;if(t&&this.data){const s=t.split(".");let n=this.data;for(;s.length>1;){const o=s.shift();n[o]===void 0&&(n[o]={}),n=n[o]}n[s[0]]=i}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class gi{constructor(e){p(this,"options");p(this,"eventService");p(this,"columns");p(this,"getFilterModel");p(this,"getQuickFilter");p(this,"isPaginationEnabled");p(this,"getPageSize");p(this,"getCurrentPage");p(this,"rowHeightProvider");p(this,"rowNodeServices");p(this,"rowData",[]);p(this,"rootRowNodes",[]);p(this,"dataRows",[]);p(this,"rowsToDisplay",[]);p(this,"rowNodeMap",new Map);p(this,"expandedGroups",new Set);p(this,"groupDefaultExpandedApplied",!1);p(this,"pinnedTopRows",[]);p(this,"pinnedBottomRows",[]);p(this,"displayStartIndex",0);p(this,"totalRowCount",0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getFilterModel=e.getFilterModel,this.getQuickFilter=e.getQuickFilter,this.isPaginationEnabled=e.isPaginationEnabled,this.getPageSize=e.getPageSize,this.getCurrentPage=e.getCurrentPage,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices}getType(){return"clientSide"}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.rootRowNodes}getRowCount(){return this.rowsToDisplay.length}getTotalRowCount(){return this.totalRowCount}getRow(e){return this.rowsToDisplay[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.rowsToDisplay.forEach((i,t)=>e(i,t))}forEachLeafNode(e){let i=0;const t=s=>{for(const n of s)n.group?n.children&&t(n.children):n.footer||e(n,i++)};t(this.rootRowNodes)}getPinnedTopRowCount(){return this.pinnedTopRows.length}getPinnedBottomRowCount(){return this.pinnedBottomRows.length}getPinnedTopRow(e){return this.pinnedTopRows[e]}getPinnedBottomRow(e){return this.pinnedBottomRows[e]}getRowIndexAtPixel(e){return Math.floor(e/this.rowHeightProvider())}updateRowData(e){this.rowData=e||[],this.rebuildRows()}rebuildRows(){const e=new Map;this.options.treeData&&this.rowNodeMap.forEach(s=>{s.group&&e.set(s.id,s.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const i=this.options.getRowId,t=this.rowData;if(this.options.treeData){const s=this.buildTreeData(t,i);this.rootRowNodes=s,this.rowNodeMap.forEach(n=>{n.group&&e.has(n.id)&&(n.expanded=e.get(n.id))})}else{const s=[];for(let n=0;n<t.length;n++){const o=t[n],a=i?i({data:o,level:0}):void 0,r=this.createRowNode(o,a);r.rowIndex=n,s.push(r)}this.rootRowNodes=s,this.dataRows=s}if(this.options.masterDetail&&!this.options.treeData){const s=this.options.isRowMaster||(()=>!0);for(const n of this.rootRowNodes){if(n.detailNode||!s({data:n.data,node:n}))continue;const o=this.createRowNode(null,`${n.id}|detail`,n,1);o.masterNode=n,o.selectable=!1,n.detailNode=o,n.expanded=!1}}this.refreshModel(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.gridApi})}createRowNode(e,i,t=null,s=0){const n=new ge(e,this.rowNodeServices,i);return n.parent=t,n.level=s,n.uiLevel=s,n.__id=n.id,this.rowNodeMap.set(n.id,n),n}buildTreeData(e,i){const t=this.options.getDataPath||(d=>String(d.id??d.key).split("/")),s=this.options.treeDataChildrenField||"children",n=new Map,o=[],a=(d,c,h)=>{const g=t(d),u=g.join("/"),f=i?i({data:d,level:h}):u,m=this.createRowNode(d,f,c,h);m.key=g[g.length-1],n.set(u,m);const v=d[s];if(Array.isArray(v)&&v.length){m.children=[],m.group=!0,m.expanded=!0;for(const C of v){const w=a(C,m,h+1);m.children.push(w)}m.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(m),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||o.push(m),m},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const h of d.children)c+=r(h);return d.allChildrenCount=c,c};for(const d of o)r(d);for(const d of e){if(!d)continue;const h=t(d).slice(0,-1).join("/"),g=h&&n.get(h)||null;a(d,g??null,g?g.level+1:0)}return o}applyTransaction(e){const i=this.options.getRowId,t={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const s=new Set;for(const n of e.remove){const o=i?i({data:n,level:0}):n.id;o!==void 0?s.add(String(o)):s.add(n)}this.rowData=this.rowData.filter(n=>{const o=i?i({data:n,level:0}):n.id;return!s.has(String(o))&&!s.has(n)});for(const n of s){const o=this.rowNodeMap.get(String(n));o&&(this.rowNodeMap.delete(o.id),t.remove.push(o))}}if(e.update&&e.update.length)for(const s of e.update){const n=i?i({data:s,level:0}):s.id,o=n!==void 0?this.rowNodeMap.get(String(n)):void 0;if(o)this.rowData=this.rowData.map(a=>{const r=i?i({data:a,level:0}):a.id;return String(r)===String(n)?s:a}),o.data=s,t.update.push(o);else{const a=this.createRowNode(s,n!==void 0?String(n):void 0);this.rowData.push(s),t.add.push(a)}}if(e.add&&e.add.length){const s=e.addIndex;for(const n of e.add){const o=i?i({data:n,level:0}):void 0,a=this.createRowNode(n,o);t.add.push(a),s===void 0||s<0?this.rowData.push(n):this.rowData.splice(Math.min(s,this.rowData.length),0,n)}}return this.rebuildRows(),t}refreshModel(e){const i=this.columns().filter(t=>t.rowGroup);(!e||e==="everything"||e==="filter"||e==="group")&&this.doFilter(),(!e||e==="everything"||e==="sort"||e==="group")&&this.doSort(i),(!e||e==="everything"||e==="group")&&this.doGroup(i),this.buildDisplayRows(i),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}doFilter(){const e=this.getFilterModel(),i=this.getQuickFilter(),t=Object.keys(e).length>0,s=i&&i.trim().length>0,n=this.columns(),o=!!this.options.treeData,a=f=>{for(const[m,v]of Object.entries(e)){const C=n.find(w=>w.colId===m);if(C&&!this.doesNodePassFilter(f,C,v))return!1}return!0},r=f=>{const m=this.options.__advancedFilterPass;return m?m(f):!0},d=Object.entries(e).some(([f,m])=>{const v=n.find(C=>C.colId===f);return!v||!v.aggFunc?!1:m.filterType==="multi"?(m.filterModels||[]).length>0:!0}),c=f=>{if(f.__passesFilter=!0,f.children)for(const m of f.children)c(m)},h=f=>{const m=this.options;return typeof m.isExternalFilterPresent!="function"||!m.isExternalFilterPresent()||typeof m.doesExternalFilterPass!="function"?!0:m.doesExternalFilterPass(f)},g=f=>{if(!s)return!0;const m=i.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?n:n.filter(C=>C.visible);for(const C of v){const w=H(C,f,null);if(si(m,w))return!0}return!1},u=f=>{let m=!0;if(!f.group||f.footer||o?m=(!t||a(f))&&g(f)&&h(f)&&r(f):d&&(m=(!t||a(f))&&r(f)),f.__passesFilter=m,f.children){let v=!1;for(const C of f.children)u(C)&&(v=!0);return f.group&&!f.footer&&(d?(f.__passesFilter=m,m&&c(f)):(f.__passesFilter=o?v||m:v,o&&m&&c(f))),f.__passesFilter}return m};for(const f of this.rootRowNodes)u(f)}doesNodePassFilterModel(e,i,t){return this.doesNodePassFilter(e,i,t)}doesNodePassFilter(e,i,t){if(e.group&&i.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[i.colId]!==void 0)r=e.groupData[i.colId];else{const c=[];_e(e,c);const h=c.map(g=>H(i,g,null));r=Fe(i,i.aggFunc,h)}const d={...e,data:{[i.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,i,t)}if(t.filterType==="multi"){const r=t.filterModels||[];if(r.length===0)return!0;const d=t.operator||"AND",c=r.map(h=>this.doesNodePassFilter(e,i,h));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(t.condition1||t.condition2){const{condition1:r,condition2:d,...c}=t,h=[this.doesNodePassFilter(e,i,{...c,...r||{}})];return d&&h.push(this.doesNodePassFilter(e,i,{...c,...d})),(t.operator||"AND")==="OR"?h.some(Boolean):h.every(Boolean)}const s=H(i,e,null),n=mi(i,s),o=s,a=t.filterType||"text";if(a==="text"){const r=String(t.filter??"").toLowerCase();if(!r)return!0;const d=(o==null?"":String(o)).toLowerCase();switch(t.type){case"equals":return d===r;case"notEqual":return d!==r;case"startsWith":return d.startsWith(r);case"endsWith":return d.endsWith(r);case"contains":default:return d.includes(r)}}if(a==="number"){const r=typeof o=="number"?o:Number(o);if(isNaN(r))return!1;const d=Number(t.filter),c=t.filterTo!==void 0&&t.filterTo!==null&&t.filterTo!==""?Number(t.filterTo):null;switch(t.type){case"equals":return r===d;case"notEqual":return r!==d;case"lessThan":return r<d;case"lessThanOrEqual":return r<=d;case"greaterThan":return r>d;case"greaterThanOrEqual":return r>=d;case"inRange":return c!==null?r>=Math.min(d,c)&&r<=Math.max(d,c):!0;case"blank":return o==null||o==="";case"notBlank":return!(o==null||o==="");default:return!0}}if(a==="date"){const r=o instanceof Date?o.getTime():new Date(o).getTime();if(isNaN(r))return!1;const d=t.dateFrom?new Date(t.dateFrom).getTime():null,c=t.dateTo?new Date(t.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return a==="boolean"?!!o==!!t.filter:a==="set"?(t.values||[]).map(d=>String(d)).includes(String(o)):!0}doSort(e){const i=[],t=this.columns();for(const o of t)o.sort&&o.sortIndex!==null&&i.push({column:o,direction:o.sort});i.sort((o,a)=>(o.column.sortIndex??0)-(a.column.sortIndex??0));const s=(o,a)=>{for(const{column:c,direction:h}of i){const g=St(c)(o,a)*(h==="asc"?1:-1);if(g!==0)return g}const r=o.rowIndex??0,d=a.rowIndex??0;return r-d},n=o=>{o.sort(s);for(const a of o)a.children&&n(a.children)};if(e.length===0)n(this.rootRowNodes);else for(const o of this.rootRowNodes)o.children&&n(o.children)}doGroup(e){if(e.length===0)return;const i=this.columns().filter(d=>d.aggFunc&&!d.rowGroup),t=(d,c,h,g)=>{if(c>=e.length)return d;const u=e[c],f=new Map,m=[];for(const C of d){if(!C.__passesFilter)continue;const w=H(u,C,null),x=fi(w);f.has(x)||(f.set(x,[]),m.push(x)),f.get(x).push(C)}const v=[];for(const C of m){const w=f.get(C),x=`${g}|${u.colId}:${C}`,b=this.rowNodeMap.get(x),y=b||new ge({[u.colId]:C},this.rowNodeServices,x);y.group=!0,y.key=C,y.level=h,y.uiLevel=h,y.parent=null,y.children=t(w,c+1,h+1,x);for(const D of y.children)D.parent=y;y.allChildrenCount=Et(y),y.data={...y.data};const N=[];_e(y,N);const I={};for(const D of i){const _=N.map(T=>H(D,T,null));I[D.colId]=Fe(D,D.aggFunc,_)}I[u.colId]=C,y.groupData=I,b||this.rowNodeMap.set(x,y),v.push(y)}return v},s=this.options.groupDefaultExpanded??0,n=this.dataRows.length>0?this.dataRows:this.rootRowNodes,o=t(n,0,0,""),a=d=>{for(const c of d){if(!c.group)continue;const h=ze(c),g=this.expandedGroups.has(h);s===-1||g?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<s,c.expanded&&this.expandedGroups.add(h),c.children&&a(c.children)}};a(o),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const h=e[c],g=h.sort==="desc"?-1:1,u=St(h);d.sort((f,m)=>{const v=H(h,f,null),C=H(h,m,null);return u({...f,data:{[h.colId]:v}},{...m,data:{[h.colId]:C}})*g})};e[0].sort&&r(o,0),this.rootRowNodes=o}buildDisplayRows(e){const i=[],t=!!this.options.treeData,s=(o,a)=>{if(o.uiLevel=a,i.push(o),o.detailNode&&o.expanded&&i.push(o.detailNode),o.children&&(o.group||t)){const r=o.group?o.children.filter(d=>d.__passesFilter||d.group):o.children;if(o.expanded){for(const d of r)s(d,a+1);if(o.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(o)){const d=this.createFooterNode(o,a+1);i.push(d)}}}};for(const o of this.rootRowNodes)o.__passesFilter&&s(o,0);if(this.options.groupIncludeTotalFooter&&e.length>0){const o=this.createGrandTotalNode(e);i.push(o)}this.pinnedTopRows=i.filter(o=>o.rowPinned==="top"),this.pinnedBottomRows=i.filter(o=>o.rowPinned==="bottom");const n=i.filter(o=>o.rowPinned!=="top"&&o.rowPinned!=="bottom");if(this.totalRowCount=n.filter(o=>!o.masterNode).length,this.isPaginationEnabled()){const o=this.getPageSize(),a=this.getCurrentPage();let r=0,d=-1;for(let h=0;h<n.length;h++)if(!n[h].masterNode){if(r===a*o){d=h;break}r++}d<0&&(d=n.length);let c=d;for(r=0;c<n.length&&r<o;)n[c].masterNode||r++,c++;for(;c<n.length&&n[c].masterNode;)c++;this.displayStartIndex=d,this.rowsToDisplay=n.slice(d,c)}else this.displayStartIndex=0,this.rowsToDisplay=n;this.rowsToDisplay.forEach((o,a)=>o.__displayIndex=a)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,i){const t=`${e.id}|footer`;let s=this.rowNodeMap.get(t);return s||(s=new ge(e.data,this.rowNodeServices,t),this.rowNodeMap.set(t,s)),s.group=!1,s.footer=!0,s.level=e.level,s.uiLevel=i,s.parent=e,s.selected=!1,s.selectable=!1,s.groupData={...e.groupData,__footerFor:e.id},s}createGrandTotalNode(e){const i="ag-grid-grand-total";let t=this.rowNodeMap.get(i);t||(t=new ge(null,this.rowNodeServices,i),this.rowNodeMap.set(i,t)),t.group=!1,t.footer=!0,t.level=0,t.uiLevel=0,t.selected=!1,t.selectable=!1;const s=this.columns().filter(a=>a.aggFunc&&!a.rowGroup),n=[];for(const a of this.rootRowNodes)a.group?_e(a,n):a.__passesFilter&&n.push(a);const o={};for(const a of s){const r=n.map(d=>H(a,d,null));o[a.colId]=Fe(a,a.aggFunc,r)}return o.__grandTotal=!0,t.groupData=o,t}expandAll(){const e=i=>{i.group&&(i.expanded=!0,this.expandedGroups.add(ze(i)),i.children&&i.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(i=>i.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}collapseAll(){this.expandedGroups.clear();const e=i=>{i.group&&(i.expanded=!1,i.children&&i.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(i=>i.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}setNodeExpanded(e,i){e.group&&(e.expanded=i,i?this.expandedGroups.add(ze(e)):this.expandedGroups.delete(ze(e)),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function fi(l){return l==null?"":l instanceof Date?l.toISOString():String(l)}function ze(l){const e=[];let i=l;for(;i;)e.unshift(i.id),i=i.parent;return e.join(">")}function Et(l){return!l.children||l.children.length===0?1:l.children.reduce((e,i)=>e+Et(i),0)}function _e(l,e){if(!l.children||l.children.length===0){e.push(l);return}for(const i of l.children)_e(i,e)}function mi(l,e){return e}const Rt={sort:"Sort",sortAscending:"Sort Ascending",sortDescending:"Sort Descending",columnSize:"Column Size",autosizeThisColumn:"Autosize This Column",autosizeAllColumns:"Autosize All Columns",pinColumn:"Pin Column",pinLeft:"Pin Left",noPin:"No Pin",pinRight:"Pin Right",filter:"Filter",openFilter:"Open Filter",openMultiFilter:"Open Multi Filter",openAdvancedFilter:"Open Advanced Filter",clearFilter:"Clear Filter",formula:"Formula",addFormula:"Add Formula…",editFormula:"Edit Formula…",visibility:"Visibility",hideColumn:"Hide Column",chooseColumns:"Choose Columns...",openFilterTitle:"Open filter",openMenuTitle:"Open menu",sortAsc:"ascending",sortDesc:"descending",sortNone:"none",copy:"Copy",copyWithHeaders:"Copy with Headers",paste:"Paste",export:"Export",csvExport:"CSV Export",excelExport:"Excel Export",resetColumns:"Reset Columns",sizeToFit:"Size to Fit",expandAll:"Expand All",collapseAll:"Collapse All",pinRow:"Pin Row",pinToTop:"Pin to Top",pinToBottom:"Pin to Bottom",unpin:"Unpin",filterOoo:"Filter...",apply:"Apply",clear:"Clear",searchOoo:"Search...",noMatches:"No matches",selectAll:"Select all",clearAll:"Clear all",join:"Join:",and:"AND",or:"OR",from:"From",to:"To",secondValue:"Second value",value:"Value",removeFilter:"Remove filter",addFilter:"+ Add filter",advancedFilter:"Advanced Filter",addCondition:"+ Add condition",condTrue:"True",condFalse:"False",contains:"Contains",notEqual:"Not equal",startsWith:"Starts with",endsWith:"Ends with",equals:"Equals",blank:"Blank",notBlank:"Not blank",greaterThan:"Greater than",greaterThanOrEqual:"Greater than or equal",lessThan:"Less than",lessThanOrEqual:"Less than or equal",inRange:"In range",columns:"Columns",filters:"Filters",charts:"Charts",rowGroups:"Row Groups",dragColumnsHere:"Drag columns here to group",searchColumns:"Search columns...",noMatchingColumns:"No matching columns",groupByThisColumn:"Group by this column",pinColumnTitle:"Pin column",remove:"Remove",page:"Page",pageSize:"Page Size:",find:"Find in grid...",matchCase:"Match case",of:"of",loadingOoo:"Loading...",noRowsToShow:"No Rows To Show",formulaPlaceholder:"e.g. =price * quantity"},vi={contains:"contains",notEqual:"notEqual",startsWith:"startsWith",endsWith:"endsWith",equals:"equals",blank:"blank",notBlank:"notBlank",greaterThan:"greaterThan",greaterThanOrEqual:"greaterThanOrEqual",lessThan:"lessThan",lessThanOrEqual:"lessThanOrEqual",inRange:"inRange",true:"condTrue",false:"condFalse"};class Ci{constructor(e){this.overrides=e}t(e){const i=this.overrides[e];return typeof i=="string"&&i.length?i:Rt[e]??e}}function wi(l){return new Ci(l??{})}function yi(l){return!l||typeof l!="object"?!1:l.__isGroup===!0?!0:typeof l.childCount=="number"&&l.childCount>=0}class Si{constructor(e){p(this,"options");p(this,"eventService");p(this,"columns");p(this,"getSortModel");p(this,"getFilterModel");p(this,"rowHeightProvider");p(this,"rowNodeServices");p(this,"datasource",null);p(this,"stores",new Map);p(this,"rowNodeMap",new Map);p(this,"displayRows",[]);p(this,"blockSize");p(this,"pureLoad",!0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100,this.pureLoad=e.options.serverSideStoreType!=="partial"}getType(){return"serverSide"}setDatasource(e){this.datasource=e,this.purgeCache()}getStore(e){return this.stores.get(e)}getOrCreateStore(e){let i=this.stores.get(e);return i||(i={rows:[],lastRow:null,loading:!1,failed:!1},this.stores.set(e,i)),i}isLoading(){for(const e of this.stores.values())if(e.loading)return!0;return!1}loadBlock(e,i,t){if(!this.datasource)return;const s=this.getOrCreateStore(e);if(s.loading)return;for(let o=s.rows.length;o<t;o++)s.rows.push(null);s.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const n={startRow:i,endRow:t,rowGroupCols:this.columns().filter(o=>o.rowGroup),valueCols:this.columns().filter(o=>o.aggFunc&&!o.rowGroup),pivotCols:this.columns().filter(o=>o.pivot),groupKeys:e?e.split("|"):[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(o,a)=>{s.loading=!1,this.onBlockLoaded(e,o,a??null)},failCallback:()=>{s.loading=!1,s.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(n)}onBlockLoaded(e,i,t){const s=this.getOrCreateStore(e);s.lastRow=t,s.failed=!1;for(let n=0;n<i.length;n++){const o=i[n],a=(s.rows.length>0,n),r=this.createNode(o,e,n,a);s.rows[a]=r}for(;s.rows.length&&s.rows[s.rows.length-1]===null;)s.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,i,t,s){const n=yi(e),o=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${i}#${s}`,a=this.rowNodeMap.get(o),r=a instanceof ge?a:new ge(e,this.rowNodeServices,o);return r.data=e,r.rowIndex=t,n&&(r.group=!0,r.key=String(H(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=i?i.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${i?i+"|":""}${r.key}`)),this.rowNodeMap.set(o,r),r}buildDisplayRows(){const e=[],i=(t,s)=>{const n=this.stores.get(t);if(n){for(const o of n.rows)if(o&&(o.uiLevel=s,e.push(o),o.group&&o.expanded)){const a=`${t?t+"|":""}${o.key}`;i(a,s+1)}}};i("",0),this.displayRows=e,this.displayRows.forEach((t,s)=>t.__displayIndex=s)}ensureLoaded(e,i){let t=0;const s=o=>{const a=this.stores.get(o);if(a){for(const r of a.rows)if(r){if(t>=e&&t<=i){const d=Math.floor(t/this.blockSize)*this.blockSize,c=d+this.blockSize,h=a.lastRow,g=h!==null?Math.min(h,c):c;t<(a.rows.length||0)&&d<(a.rows.length||0)||(a.lastRow===null||c<=a.lastRow)&&this.loadBlock(o,d,g)}t++,r.group&&r.expanded&&s(`${o?o+"|":""}${r.key}`)}}};s("");const n=this.stores.get("");(!n||n.rows.length===0&&n.lastRow===null)&&this.loadBlock("",0,this.blockSize)}refreshModel(e){this.ensureLoaded(0,this.blockSize),this.eventService.dispatchEvent("modelUpdated",{})}onViewportChanged(e,i){this.ensureLoaded(e,i)}setNodeExpanded(e,i){if(e.group){if(e.expanded=i,i){const t=this.groupPathFor(e);this.stores.has(t)||this.loadBlock(t,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const i=[];let t=e;for(;t&&t.group;)i.unshift(t.key??""),t=t.parent??null;return i.join("|")}purgeCache(){this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[],this.refreshModel("everything")}onSortOrFilterChanged(){this.purgeCache()}getRowCount(){return this.displayRows.length}getTotalRowCount(){const e=this.stores.get("");return(e==null?void 0:e.lastRow)??0}getRow(e){return this.displayRows[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.displayRows.forEach((i,t)=>e(i,t))}forEachLeafNode(e){let i=0;for(const t of this.displayRows)!t.group&&!t.footer&&e(t,i++)}isEmpty(){return this.displayRows.length===0}getTopLevelRows(){const e=this.stores.get("");return(e==null?void 0:e.rows.filter(Boolean))||[]}updateRowData(e){this.refreshModel("everything")}applyTransaction(e){const i={add:[],remove:[],update:[]};for(const t of e.update||[]){const s=(t==null?void 0:t.id)!==void 0?String(t.id):void 0,n=s?this.rowNodeMap.get(s):void 0;n&&(n.data=t,i.update.push(n))}return this.eventService.dispatchEvent("modelUpdated",{}),i}destroy(){var e,i;(i=(e=this.datasource)==null?void 0:e.destroy)==null||i.call(e),this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[]}expandAll(){for(const e of this.rowNodeMap.values())if(e.group){e.expanded=!0;const i=this.groupPathFor(e);this.stores.has(i)||this.loadBlock(i,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}collapseAll(){for(const e of this.rowNodeMap.values())e.group&&(e.expanded=!1);this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class xi{constructor(e){p(this,"options");p(this,"eventService");p(this,"getSortModel");p(this,"getFilterModel");p(this,"rowNodeServices");p(this,"datasource",null);p(this,"nodes",[]);p(this,"rowNodeMap",new Map);p(this,"blockSize");p(this,"lastRow",null);p(this,"loading",!1);this.options=e.options,this.eventService=e.eventService,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"infinite"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.lastRow=null,this.loadBlock(0,this.blockSize)}loadBlock(e,i){if(!(!this.datasource||this.loading)){for(let t=this.nodes.length;t<i;t++)this.nodes.push(null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:i,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(t,s)=>{this.loading=!1,this.lastRow=s??null,t.forEach((n,o)=>{const a=(n==null?void 0:n.id)!==void 0?String(n.id):`row-${e+o}`;let r=this.rowNodeMap.get(a);r||(r=new ge(n,this.rowNodeServices,a),this.rowNodeMap.set(a,r)),r.data=n,r.rowIndex=e+o,this.nodes[e+o]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,i){const t=Math.floor(e/this.blockSize)*this.blockSize;t+this.blockSize>this.nodes.length&&this.loadBlock(t,t+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.lastRow=null,this.loadBlock(0,this.blockSize)}isLoading(){return this.loading}getRowCount(){return this.nodes.length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((i,t)=>{i&&e(i,t)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.nodes.filter(Boolean).length===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){this.onSortOrFilterChanged()}applyTransaction(){return null}destroy(){var e,i;(i=(e=this.datasource)==null?void 0:e.destroy)==null||i.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class bi{constructor(e){p(this,"options");p(this,"eventService");p(this,"rowNodeServices");p(this,"datasource",null);p(this,"nodes",[]);p(this,"rowNodeMap",new Map);p(this,"firstRow",0);p(this,"lastRow",0);p(this,"loading",!1);this.options=e.options,this.eventService=e.eventService,this.rowNodeServices=e.rowNodeServices}getType(){return"viewport"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}setViewportRange(e,i){if(this.firstRow=e,this.lastRow=i,!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((t,s)=>s>=e&&s<=i);for(let t=e;t<=i;t++)this.nodes[t-e]||(this.nodes[t-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:i,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:t=>{this.loading=!1,t.forEach((s,n)=>{const o=(s==null?void 0:s.id)!==void 0?String(s.id):`vrow-${e+n}`;let a=this.rowNodeMap.get(o);a||(a=new ge(s,this.rowNodeServices,o),this.rowNodeMap.set(o,a)),a.data=s,a.rowIndex=e+n,this.nodes[e+n-e]=a}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}setViewportDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}onViewportChanged(e,i){this.setViewportRange(e,i)}isLoading(){return this.loading}getRowCount(){return this.nodes.filter(Boolean).length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((i,t)=>{i&&e(i,t)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){}applyTransaction(){return null}destroy(){var e,i;(i=(e=this.datasource)==null?void 0:e.destroy)==null||i.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class Ei{constructor(e){p(this,"eGui");var d,c,h;this.params=e;const i=e.node,t=!!i.group,s=!!i.detailNode,n=t||s,o=i.expanded,a=i.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${a}px`,n){const g=document.createElement("span");g.className="ag-group-value-expanded-icon",g.classList.add(o?"ag-expanded":"ag-contracted"),g.innerHTML=o?zi:Vi,r.appendChild(g);const u=document.createElement("span");u.className="ag-group-value";const f=(d=e.colDef.cellRendererParams)==null?void 0:d.innerRenderer;if(typeof f=="function"){const m=f({...e,value:e.value,valueFormatted:e.valueFormatted});m instanceof HTMLElement?u.appendChild(m):typeof m=="string"&&(u.innerHTML=m)}else u.textContent=Di(e.value);if(r.appendChild(u),t&&i.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const m=document.createElement("span");m.className="ag-group-child-count",m.textContent=` (${i.allChildrenCount})`,r.appendChild(m)}}else{const g=document.createElement("span");g.className="ag-group-value";const u=(h=e.colDef.cellRendererParams)==null?void 0:h.innerRenderer;if(typeof u=="function"){const f=u({...e,value:e.value,valueFormatted:e.valueFormatted});f instanceof HTMLElement?g.appendChild(f):typeof f=="string"&&(g.innerHTML=f)}else g.textContent=e.valueFormatted??String(e.value??"");r.appendChild(g)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Ri{constructor(e){p(this,"eGui");p(this,"eCheckbox");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-cell-checkbox";const i=document.createElement("input");i.type="checkbox",i.className="ag-native-checkbox",i.checked=!!e.node.selected,i.addEventListener("click",t=>t.stopPropagation()),i.addEventListener("change",()=>{e.node.setSelected(i.checked,!1,"uiSelectChanged")}),this.eCheckbox=i,this.eGui.appendChild(i)}getGui(){return this.eGui}refresh(e){return this.params=e,this.eCheckbox.checked=!!e.node.selected,!0}}const Mi='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',Ni='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class Ti{constructor(e){p(this,"eGui");p(this,"eArrow");p(this,"eOld");p(this,"eNew");p(this,"lastValue");p(this,"flashTimer",null);this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-animate-show-change-cell-renderer",this.eArrow=document.createElement("span"),this.eArrow.className="ag-value-change-arrow",this.eArrow.style.display="none",this.eOld=document.createElement("span"),this.eOld.className="ag-value-change-old",this.eOld.style.display="none",this.eNew=document.createElement("span"),this.eNew.className="ag-value-change-new",this.eGui.appendChild(this.eArrow),this.eGui.appendChild(this.eOld),this.eGui.appendChild(this.eNew),this.eNew.textContent=this.formatValue(e),this.lastValue=e.value}formatValue(e){const i=e.valueFormatted??e.value;return i==null?"":String(i)}getGui(){return this.eGui}refresh(e){const i=e.value;if(i!==this.lastValue){const t=typeof i=="number"&&typeof this.lastValue=="number"?i>this.lastValue:String(i)>String(this.lastValue),s=this.eNew.textContent??"";this.eArrow.innerHTML=t?Mi:Ni,this.eArrow.style.display="",this.eArrow.classList.add(t?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=s,this.eOld.style.display="",this.eNew.textContent=this.formatValue(e),this.lastValue=i,this.eGui.classList.remove("ag-value-change-value-highlight"),this.eGui.offsetWidth,this.eGui.classList.add("ag-value-change-value-highlight",t?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.flashTimer&&clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this.eGui.classList.remove("ag-value-change-value-highlight","ag-value-change-delta-up","ag-value-change-delta-down"),this.eArrow.style.display="none",this.eOld.style.display="none"},1e3)}return!0}destroy(){this.flashTimer&&clearTimeout(this.flashTimer)}}class Ii{constructor(e){p(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-number-cell",this.eGui.textContent=String(e.rowIndex+1)}getGui(){return this.eGui}refresh(e){return this.params=e,this.eGui.textContent=String(e.rowIndex+1),!0}}class ki{constructor(e){p(this,"eGui");var r,d;this.params=e;const i=document.createElement("span");i.className="ag-sparkline-cell";const t=e.value||[],s=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},n=e.column.width||100,o=s.height||24,a=tt(t,Math.max(20,n-16),o,s);i.appendChild(a),this.eGui=i}getGui(){return this.eGui}refresh(e){var a,r;const i=e.value||[],t=e.sparklineOptions||((r=(a=e.column)==null?void 0:a.cellRendererParams)==null?void 0:r.sparklineOptions)||{},s=e.column.width||100,n=t.height||24;this.eGui.innerHTML="";const o=tt(i,Math.max(20,s-16),n,{type:t.type,direction:t.direction});return this.eGui.appendChild(o),!0}}function tt(l,e,i,t={}){var C,w,x;const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",String(Math.max(20,e))),s.setAttribute("height",String(i)),s.setAttribute("class","ag-sparkline");const n=(l||[]).map(b=>typeof b=="number"?b:Number((b==null?void 0:b.value)??0));if(!n||n.length<1)return s;const o=t.type||"line",a=Math.min(...n,0),d=Math.max(...n,0)-a||1,c=((C=t.tooltip)==null?void 0:C.enabled)===!0,h=((w=t.axis)==null?void 0:w.type)||"number",g=((x=t.pointsOfInterest)==null?void 0:x.show)===!0,u=(b,y)=>h==="category"?`${b+1}: ${y}`:String(y);if(g&&n.length>1){const b=n.indexOf(Math.min(...n)),y=n.indexOf(Math.max(...n)),N=e/Math.max(1,n.length-1),I=_=>i-2-(_-a)/d*(i-4),D=(_,T)=>{const P=document.createElementNS("http://www.w3.org/2000/svg","circle");P.setAttribute("cx",String(_*N)),P.setAttribute("cy",String(I(n[_]))),P.setAttribute("r","2.5"),P.setAttribute("fill",T),s.appendChild(P)};D(0,"#4caf50"),D(n.length-1,"#f44336"),D(b,"#2196f3"),D(y,"#ff9800")}if(c){const b=document.createElementNS("http://www.w3.org/2000/svg","title");b.textContent=n.map((y,N)=>u(N,y)).join(`
3
- `),s.appendChild(b),s.style.cursor="default"}if(o==="bar"){const b=t.direction==="vertical",y=n.length;if(b){const N=Math.max(1,e/y-1),I=i-2-(0-a)/d*(i-4);n.forEach((D,_)=>{const T=_*(e/y),P=i-2-(D-a)/d*(i-4),F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("x",String(T)),F.setAttribute("width",String(N)),F.setAttribute("y",String(Math.min(P,I))),F.setAttribute("height",String(Math.max(1,Math.abs(I-P)))),F.setAttribute("fill","currentColor"),s.appendChild(F)})}else{const N=Math.max(1,i/y-1),I=2+(0-a)/d*(e-4);n.forEach((D,_)=>{const T=_*(i/y),P=2+(D-a)/d*(e-4),F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("y",String(T)),F.setAttribute("height",String(N)),F.setAttribute("x",String(Math.min(P,I))),F.setAttribute("width",String(Math.max(1,Math.abs(I-P)))),F.setAttribute("fill","currentColor"),s.appendChild(F)})}return s}const f=e/Math.max(1,n.length-1),m=n.map((b,y)=>{const N=y*f,I=i-2-(b-a)/d*(i-4);return`${N.toFixed(1)},${I.toFixed(1)}`});if(o==="area"){const b=document.createElementNS("http://www.w3.org/2000/svg","polygon");b.setAttribute("points",`0,${i} ${m.join(" ")} ${e},${i}`),b.setAttribute("fill","currentColor"),b.setAttribute("opacity","0.2"),s.appendChild(b)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",m.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),s.appendChild(v),s}class Li{constructor(e){p(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Mt,e.registerRowDragger&&e.registerRowDragger(i=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:i.clientX,clientY:i.clientY}))})}getGui(){return this.eGui}}const We={agGroupCellRenderer:l=>new Ei(l),agCheckboxCellRenderer:l=>new Ri(l),agSparklineCellRenderer:l=>new ki(l),agAnimateShowChangeCellRenderer:l=>new Ti(l),agRowNumberCellRenderer:l=>new Ii(l),agRowDragComp:l=>new Li(l)};function Di(l){return l==null?"":String(l)}class Fi{constructor(e){p(this,"eGui");p(this,"cancelled",!1);this.params=e,this.eGui=document.createElement("input"),this.eGui.type="text",this.eGui.className="ag-cell-editor-input",this.eGui.value=e.value??"",this.eGui.addEventListener("keydown",i=>{var t;return(t=e.onKeyDown)==null?void 0:t.call(e,i)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class Ai{constructor(e){p(this,"eGui");p(this,"eInput");p(this,"cancelled",!1);var s,n;this.params=e;const i=document.createElement("div");i.className="ag-cell-editor-number";const t=document.createElement("input");if(t.type="text",t.className="ag-cell-editor-input",t.value=e.value??"",(n=(s=e.column)==null?void 0:s.cellEditorParams)!=null&&n.showStepperButtons){const o=document.createElement("span");o.className="ag-cell-editor-stepper ag-cell-editor-stepper-up",o.innerHTML="▲",o.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),r.preventDefault(),t.value=String(Number(t.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const a=document.createElement("span");a.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",a.innerHTML="▼",a.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),t.value=String(Number(t.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),i.appendChild(o),i.appendChild(t),i.appendChild(a)}else i.appendChild(t);this.eGui=i,this.eInput=t,this.eInput.addEventListener("keydown",o=>{var a;return(a=e.onKeyDown)==null?void 0:a.call(e,o)})}getGui(){return this.eGui}getValue(){if(this.cancelled)return;const e=Number(this.eInput.value);return isNaN(e)?null:e}focusIn(){this.eInput.focus(),this.eInput.select()}}class Pi{constructor(e){p(this,"eGui");p(this,"cancelled",!1);var t,s;this.params=e,this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const i=e.values||((s=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:s.values)||[];for(const n of i){const o=document.createElement("option");o.value=String(n),o.textContent=String(n),this.eGui.appendChild(o)}this.eGui.value=String(e.value??""),this.eGui.addEventListener("keydown",n=>{var o;return(o=e.onKeyDown)==null?void 0:o.call(e,n)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus()}}class Gi{constructor(e){p(this,"eGui");p(this,"cancelled",!1);this.params=e,this.eGui=document.createElement("input"),this.eGui.type="date",this.eGui.className="ag-cell-editor-input";const i=e.value instanceof Date?e.value:e.value?new Date(e.value):null;i&&!isNaN(i.getTime())&&(this.eGui.value=i.toISOString().slice(0,10))}getGui(){return this.eGui}getValue(){if(!this.cancelled)return this.eGui.value?new Date(this.eGui.value):null}focusIn(){this.eGui.focus()}}class $i{constructor(e){p(this,"eGui");p(this,"cancelled",!1);this.params=e,this.eGui=document.createElement("textarea"),this.eGui.className="ag-cell-editor-textarea",this.eGui.value=e.value??""}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}function Hi(l,e){if(!e)return ke(l);const i=l.toLowerCase().indexOf(e.toLowerCase());return i<0?ke(l):ke(l.slice(0,i))+'<span class="ag-rich-select-highlight">'+ke(l.slice(i,i+e.length))+"</span>"+ke(l.slice(i+e.length))}class Oi{constructor(e){p(this,"eGui");p(this,"eInput");p(this,"ePopup",null);p(this,"eList",null);p(this,"values",[]);p(this,"filtered",[]);p(this,"activeIndex",0);p(this,"selectedValue");p(this,"cancelled",!1);var i,t;this.params=e,this.values=e.values||((t=(i=e.column)==null?void 0:i.cellEditorParams)==null?void 0:t.values)||[],this.selectedValue=e.value,this.eGui=document.createElement("div"),this.eGui.className="ag-rich-select",this.eInput=document.createElement("input"),this.eInput.type="text",this.eInput.className="ag-rich-select-input",this.eInput.value=e.value===null||e.value===void 0?"":String(e.value),this.eInput.readOnly=e.allowTyping!==!0,this.eGui.appendChild(this.eInput),this.eGui.addEventListener("mousedown",s=>{s.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",s=>this.onKeyDown(s))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){if(this.ePopup)return;const e=document.createElement("div");e.className="ag-rich-select-popup";const i=this.eGui.getBoundingClientRect();if(e.style.position="fixed",e.style.left=`${i.left}px`,e.style.top=`${i.bottom}px`,e.style.minWidth=`${Math.max(i.width,180)}px`,e.style.zIndex="1000",(this.eGui.closest(".ag-root")||document.body).appendChild(e),this.ePopup=e,Bi(this.params)){const o=document.createElement("input");o.type="text",o.className="ag-rich-select-search",o.placeholder="Search...",o.value="",o.addEventListener("input",()=>this.renderList(o.value)),e.appendChild(o),setTimeout(()=>o.focus(),0)}const s=document.createElement("div");s.className="ag-rich-select-list",e.appendChild(s),this.eList=s,this.renderList();const n=o=>{!e.contains(o.target)&&!this.eGui.contains(o.target)&&(this.closePopup(),document.removeEventListener("mousedown",n,!0))};document.addEventListener("mousedown",n,!0)}renderList(e=""){if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(t=>{if(!e)return!0;const s=String(t).toLowerCase(),n=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?n.every(o=>s.includes(o)):n.some(o=>s.includes(o))}),this.filtered.forEach((t,s)=>{const n=document.createElement("div");n.className="ag-rich-select-item",s===this.activeIndex&&n.classList.add("ag-active"),String(t)===String(this.selectedValue)&&n.classList.add("ag-selected");const o=this.params.cellRenderer;if(typeof o=="function"){const a=o({value:t,valueFormatted:String(t)});a instanceof HTMLElement?n.appendChild(a):n.textContent=String(a)}else n.innerHTML=Hi(String(t),e);n.addEventListener("click",a=>{a.stopPropagation(),this.commit(t)}),n.addEventListener("mousedown",a=>a.preventDefault()),this.eList.appendChild(n)}),this.filtered.length===0){const t=document.createElement("div");t.className="ag-rich-select-empty",t.textContent="No matches",this.eList.appendChild(t)}const i=this.eList.children[this.activeIndex];i&&typeof i.scrollIntoView=="function"&&i.scrollIntoView({block:"nearest"})}onKeyDown(e){if(e.key==="ArrowDown")e.preventDefault(),this.activeIndex=Math.min(this.filtered.length-1,this.activeIndex+1),this.renderList();else if(e.key==="ArrowUp")e.preventDefault(),this.activeIndex=Math.max(0,this.activeIndex-1),this.renderList();else if(e.key==="Enter"){e.preventDefault();const i=this.filtered[this.activeIndex];i!==void 0?this.commit(i):this.closePopup()}else if(e.key==="Escape")e.preventDefault(),this.cancelled=!0,this.closePopup();else if(e.key==="Tab"){e.preventDefault();const i=this.filtered[this.activeIndex];i!==void 0?this.commit(i):this.closePopup()}}commit(e){this.selectedValue=e,this.eInput.value=String(e),this.closePopup(),setTimeout(()=>{var i,t;return(t=(i=this.params).onKeyDown)==null?void 0:t.call(i,{key:"Enter",preventDefault:()=>{},keyCode:13})},0)}closePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,this.eList=null}getValue(){return this.cancelled?void 0:this.selectedValue}isCancelAfterEnd(){return this.cancelled}destroy(){this.closePopup()}}function Bi(l){var e,i;return(l==null?void 0:l.allowTyping)===!0||((i=(e=l==null?void 0:l.column)==null?void 0:e.cellEditorParams)==null?void 0:i.allowTyping)===!0}const fe={agTextCellEditor:l=>new Fi(l),agNumberCellEditor:l=>new Ai(l),agSelectCellEditor:l=>new Pi(l),agDateCellEditor:l=>new Gi(l),agLargeTextCellEditor:l=>new $i(l),agRichSelectCellEditor:l=>new Oi(l)},Vi='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',zi='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Mt='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="5" cy="3" r="1.4"/><circle cx="11" cy="3" r="1.4"/><circle cx="5" cy="8" r="1.4"/><circle cx="11" cy="8" r="1.4"/><circle cx="5" cy="13" r="1.4"/><circle cx="11" cy="13" r="1.4"/></svg>',_i='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="3" cy="8" r="1.4"/><circle cx="8" cy="8" r="1.4"/><circle cx="13" cy="8" r="1.4"/></svg>',Wi='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Ui='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',qi='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Nt='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>';function Tt(l,e,i){const t=l.length;if(t===0||i<=0)return[];let s=0,n=t-1;for(;s<n;){const c=s+n>>1;l[c]>=i?n=c:s=c+1}const o=l[s]>=i?s:t-1,a=e[o];if(!a)return[];const r=[];let d=a.level;for(let c=o-1;c>=0;c--){const h=e[c];if(!(!h||h.level>=d)&&(d=h.level,h.group&&l[c]<i&&r.push(c),h.level===0))break}return r.reverse()}class Ki{constructor(e,i,t){p(this,"ctx");p(this,"eRoot");p(this,"eHeader");p(this,"eBody");p(this,"ePinnedLeft");p(this,"ePinnedRight");p(this,"ePinnedLeftInner");p(this,"ePinnedRightInner");p(this,"eViewport");p(this,"eContainer");p(this,"eFloatingTop");p(this,"eFloatingBottom");p(this,"eFloatingTopLeft");p(this,"eFloatingTopRight");p(this,"eFloatingBottomLeft");p(this,"eFloatingBottomRight");p(this,"eStickyTop");p(this,"eStickyLeft");p(this,"eStickyCenter");p(this,"eStickyRight");p(this,"eRangeOverlay",null);p(this,"rowComps",new Map);p(this,"stickyComps",new Map);p(this,"hoveredRowId",null);p(this,"rowOffsets",[]);p(this,"rowInfos",[]);p(this,"totalHeight",0);p(this,"lastScrollTop",-1);p(this,"lastRange",[-1,-1]);p(this,"firstRendered",!1);p(this,"heightVersion",0);p(this,"onSectionWheel",e=>{const i=this.eViewport;let t=e.deltaY,s=e.deltaX;e.deltaMode===1?(t*=33,s*=33):e.deltaMode===2&&(t*=i.clientHeight,s*=i.clientWidth),t&&(i.scrollTop+=t),s&&(i.scrollLeft+=s),e.preventDefault()});p(this,"onBodyMouseOver",e=>{var n;const i=e.target,t=(n=i==null?void 0:i.closest)==null?void 0:n.call(i,".ag-row"),s=(t==null?void 0:t.dataset.rowid)??null;if(s===this.hoveredRowId){s&&this.setRowHovered(s,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=s,s&&this.setRowHovered(s,!0)});p(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=t,this.eRoot=e,this.eHeader=i,this.eBody=document.createElement("div"),this.eBody.className="ag-body",this.eRoot.appendChild(this.eBody),this.ePinnedLeft=document.createElement("div"),this.ePinnedLeft.className="ag-pinned-left-cols-viewport",this.eBody.appendChild(this.ePinnedLeft),this.ePinnedLeftInner=document.createElement("div"),this.ePinnedLeftInner.className="ag-pinned-cols-inner",this.ePinnedLeft.appendChild(this.ePinnedLeftInner);const s=document.createElement("div");s.className="ag-body-viewport-wrapper",this.eBody.appendChild(s),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",s.appendChild(this.eFloatingTop),this.eViewport=document.createElement("div"),this.eViewport.className="ag-body-viewport",this.eViewport.tabIndex=0,this.eViewport.addEventListener("scroll",this.onScroll.bind(this)),this.eViewport.addEventListener("keydown",n=>this.ctx.onViewportKeyDown(n)),s.appendChild(this.eViewport),this.eContainer=document.createElement("div"),this.eContainer.className="ag-body-container",this.eViewport.appendChild(this.eContainer),this.eFloatingBottom=document.createElement("div"),this.eFloatingBottom.className="ag-floating-bottom",s.appendChild(this.eFloatingBottom),this.ePinnedRight=document.createElement("div"),this.ePinnedRight.className="ag-pinned-right-cols-viewport",this.eBody.appendChild(this.ePinnedRight),this.ePinnedRightInner=document.createElement("div"),this.ePinnedRightInner.className="ag-pinned-cols-inner",this.ePinnedRight.appendChild(this.ePinnedRightInner),this.eFloatingTopLeft=document.createElement("div"),this.eFloatingTopLeft.className="ag-floating-pinned-cols ag-floating-pinned-left",this.eBody.appendChild(this.eFloatingTopLeft),this.eFloatingTopRight=document.createElement("div"),this.eFloatingTopRight.className="ag-floating-pinned-cols ag-floating-pinned-right",this.eBody.appendChild(this.eFloatingTopRight),this.eFloatingBottomLeft=document.createElement("div"),this.eFloatingBottomLeft.className="ag-floating-pinned-cols ag-floating-pinned-bottom-left",this.eBody.appendChild(this.eFloatingBottomLeft),this.eFloatingBottomRight=document.createElement("div"),this.eFloatingBottomRight.className="ag-floating-pinned-cols ag-floating-pinned-bottom-right",this.eBody.appendChild(this.eFloatingBottomRight),this.eStickyTop=document.createElement("div"),this.eStickyTop.className="ag-sticky-group-rows",this.eBody.appendChild(this.eStickyTop),this.eStickyLeft=document.createElement("div"),this.eStickyLeft.className="ag-sticky-group-rows-left",this.eStickyTop.appendChild(this.eStickyLeft),this.eStickyCenter=document.createElement("div"),this.eStickyCenter.className="ag-sticky-group-rows-center",this.eStickyTop.appendChild(this.eStickyCenter),this.eStickyRight=document.createElement("div"),this.eStickyRight.className="ag-sticky-group-rows-right",this.eStickyTop.appendChild(this.eStickyRight);for(const n of[this.eFloatingTopLeft,this.eFloatingTopRight,this.eFloatingBottomLeft,this.eFloatingBottomRight,this.eStickyLeft,this.eStickyCenter,this.eStickyRight])n.addEventListener("click",this.onClick.bind(this)),n.addEventListener("dblclick",this.onDoubleClick.bind(this)),n.addEventListener("mousedown",this.onMouseDown.bind(this)),n.addEventListener("contextmenu",this.onContextMenu.bind(this)),n.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.ePinnedLeft.addEventListener("click",this.onClick.bind(this)),this.ePinnedLeft.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedLeft.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedLeft.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eContainer.addEventListener("click",this.onClick.bind(this)),this.eContainer.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eContainer.addEventListener("mousedown",this.onMouseDown.bind(this)),this.eContainer.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.ePinnedRight.addEventListener("click",this.onClick.bind(this)),this.ePinnedRight.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedRight.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedRight.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingTop.addEventListener("click",this.onClick.bind(this)),this.eFloatingTop.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingTop.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingBottom.addEventListener("click",this.onClick.bind(this)),this.eFloatingBottom.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingBottom.addEventListener("contextmenu",this.onContextMenu.bind(this));for(const n of[this.ePinnedLeft,this.ePinnedRight,this.eFloatingTop,this.eFloatingBottom,this.eHeader])n.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.eBody.addEventListener("mouseover",this.onBodyMouseOver),this.eBody.addEventListener("mouseleave",this.onBodyMouseLeave)}setRowHovered(e,i){for(const t of this.rowComps.values())t.getNode().id===e&&t.setHovered(i);for(const t of this.stickyComps.values())t.getNode().id===e&&t.setHovered(i)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}setRangeOverlay(e){this.eRangeOverlay=e}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount(),i=new Array(e),t=new Array(e);let s=0;if(this.hasVariableHeights()){for(let o=0;o<e;o++)i[o]=s,t[o]=this.rowInfoAt(o),s+=this.getRowHeightForIndex(o);this.totalHeight=s}else{const o=this.getFixedRowHeight();for(let a=0;a<e;a++)i[a]=a*o,t[a]=this.rowInfoAt(a);this.totalHeight=e*o}this.rowOffsets=i,this.rowInfos=t}rowInfoAt(e){const i=this.ctx.rowModel.getRow(e);return i?{level:i.uiLevel??i.level??0,group:!!i.group}:{level:0,group:!1}}hasVariableHeights(){return!!(this.ctx.options.detailRowAutoHeight||this.ctx.options.getRowHeight)}getFixedRowHeight(){return this.ctx.options.rowHeight??42}getRowHeightForIndex(e){const i=this.ctx.rowModel.getRow(e);return i?this.ctx.getRowHeight(i):this.getFixedRowHeight()}refreshRows(){this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`;const e=this.ctx.getColumns().center.reduce((s,n)=>s+n.width,0),i=this.ctx.getColumns().left.reduce((s,n)=>s+n.width,0),t=this.ctx.getColumns().right.reduce((s,n)=>s+n.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${i}px`,this.ePinnedRight.style.width=`${t}px`,this.ePinnedLeft.style.height=`${this.totalHeight}px`,this.ePinnedRight.style.height=`${this.totalHeight}px`,this.eFloatingTopLeft.style.width=`${i}px`,this.eFloatingTopRight.style.width=`${t}px`,this.eFloatingBottomLeft.style.width=`${i}px`,this.eFloatingBottomRight.style.width=`${t}px`,this.eStickyLeft.style.width=`${i}px`,this.eStickyRight.style.width=`${t}px`,this.eStickyCenter.style.left=`${i}px`,this.eStickyCenter.style.right=`${t}px`,this.redrawAllRows()}invalidateRowHeights(){this.heightVersion++,this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`,this.redrawAllRows()}redrawAllRows(){for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear(),this.lastRange=[-1,-1],this.renderPinnedRows(),this.renderVisibleRows(!0)}renderPinnedRows(){var t,s;const e=(n,o,a,r,d)=>{n.innerHTML="",o.innerHTML="",a.innerHTML="";const{left:c,center:h,right:g}=this.ctx.getColumns();let u=0;for(let f=0;f<r;f++){const m=d(f);if(!m)continue;const v=this.ctx.getRowHeight(m),C=new Ue(this.ctx,m,c,h,g,v,this.heightVersion);C.appendTo(o,n,a),C.setTop(u),u+=v,this.rowComps.set(`${m.id}|${n===this.eFloatingTop?"top":"bottom"}`,C)}n.style.height=`${u}px`,n.style.display=r>0?"":"none",o.style.height=`${u}px`,a.style.height=`${u}px`},i=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((t=i.getPinnedTopRowCount)==null?void 0:t.call(i))??0,n=>{var o;return(o=i.getPinnedTopRow)==null?void 0:o.call(i,n)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((s=i.getPinnedBottomRowCount)==null?void 0:s.call(i))??0,n=>{var o;return(o=i.getPinnedBottomRow)==null?void 0:o.call(i,n)})}refreshCells(e){const i=e==null?void 0:e.rowNodes;let t;e!=null&&e.columns&&(t=e.columns.map(s=>typeof s=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(n=>n.colId===s):s).filter(Boolean));for(const[s,n]of this.rowComps)i&&!i.includes(n.getNode())||n.refreshCells(t,e==null?void 0:e.force,e==null?void 0:e.flash);for(const s of this.stickyComps.values())i&&!i.includes(s.getNode())||s.refreshCells(t,e==null?void 0:e.force,e==null?void 0:e.flash)}flashCells(e){this.refreshCells({...e,force:!0,flash:!0})}redrawRows(e){if(!(e!=null&&e.rowNodes)){this.redrawAllRows();return}for(const i of this.rowComps.values())if(e.rowNodes.includes(i.getNode())){const t=i.getNode(),s=this.findRowIndex(t);if(i.destroy(),this.rowComps.delete(this.rowCompKey(t)),s>=0){const{left:n,center:o,right:a}=this.ctx.getColumns(),r=new Ue(this.ctx,t,n,o,a,this.getRowHeightForIndex(s),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[s]??0),this.rowComps.set(this.rowCompKey(t),r)}}for(const i of this.stickyComps.values())e.rowNodes.includes(i.getNode())&&(i.destroy(),this.stickyComps.delete(i.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){var i;for(let t=0;t<this.ctx.rowModel.getRowCount();t++)if(((i=this.ctx.rowModel.getRow(t))==null?void 0:i.id)===e.id)return t;return-1}onScroll(){this.syncPinnedScroll(),this.renderVisibleRows(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),this.ctx.eventService.dispatchEvent("bodyScroll",{direction:"vertical",top:this.eViewport.scrollTop,left:this.eViewport.scrollLeft})}syncPinnedScroll(){const e=`translateY(${-this.eViewport.scrollTop}px)`;this.ePinnedLeftInner.style.transform=e,this.ePinnedRightInner.style.transform=e,this.ePinnedLeft.scrollTop=this.eViewport.scrollTop,this.ePinnedRight.scrollTop=this.eViewport.scrollTop,this.syncStickyHorizontal()}syncStickyHorizontal(){const t=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const s of this.stickyComps.values()){const n=s.getCenterElement();n&&(n.style.transform=t)}}getVerticalScrollTop(){return this.eViewport.scrollTop}setVerticalScrollTop(e){this.eViewport.scrollTop=e,this.syncPinnedScroll(),this.renderVisibleRows()}getHorizontalScrollLeft(){return this.eViewport.scrollLeft}setHorizontalScrollLeft(e){this.eViewport.scrollLeft=e,this.eHeader.scrollLeft=e,this.syncPinnedScroll()}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Tt(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:i,center:t,right:s}=this.ctx.getColumns(),n=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${n}px`;const o=new Set;let a=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;o.add(c.id);let h=this.stickyComps.get(c.id);if(!h){const g=this.rowComps.get(c.id);g&&(g.destroy(),this.rowComps.delete(c.id)),h=new Ue(this.ctx,c,i,t,s,this.getRowHeightForIndex(d),this.heightVersion),h.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),h.setSticky(!0),this.stickyComps.set(c.id,h)}h.setTop(a),h.ensureVisibleCells(),a+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)o.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${a}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),o}renderVisibleRows(e=!1){const i=this.ctx.rowModel.getRowCount(),t=this.eViewport.scrollTop,s=this.eViewport.clientHeight,n=this.ctx.options.rowBuffer??10;let o=0,a=i-1;if(this.hasVariableHeights())o=this.findIndexAtPixel(t)-n,a=this.findIndexAtPixel(t+s)+n;else{const u=this.getFixedRowHeight();o=Math.floor(t/u)-n,a=Math.ceil((t+s)/u)+n}if(o=Math.max(0,o),a=Math.min(i-1,a),!e&&this.lastRange[0]===o&&this.lastRange[1]===a&&this.lastScrollTop===t)return;this.lastRange=[o,a],this.lastScrollTop=t;const r=this.syncStickyGroupRows(),d=new Set(r),{left:c,center:h,right:g}=this.ctx.getColumns();for(let u=o;u<=a;u++){const f=this.ctx.rowModel.getRow(u);if(!f||(d.add(f.id),r.has(f.id)))continue;let m=this.rowComps.get(f.id);m||(m=new Ue(this.ctx,f,c,h,g,this.getRowHeightForIndex(u),this.heightVersion),m.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(f.id,m)),m.setTop(this.rowOffsets[u]??u*this.getFixedRowHeight()),m.ensureVisibleCells()}for(const[u,f]of this.rowComps)!d.has(u)&&!f.isPinned()&&(f.destroy(),this.rowComps.delete(u))}findIndexAtPixel(e){const i=this.rowOffsets;let t=0,s=i.length-1;for(;t<s;){const n=t+s+1>>1;i[n]<=e?t=n:s=n-1}return t}ensureIndexVisible(e,i="top"){const t=this.rowOffsets[e]??e*this.getFixedRowHeight(),s=this.getRowHeightForIndex(e),n=this.eViewport.clientHeight;let o=this.eViewport.scrollTop;i==="top"?o=t:i==="bottom"?o=t+s-n:o=t-(n-s)/2,this.eViewport.scrollTop=Math.max(0,o),this.renderVisibleRows()}getFirstVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop))}getLastVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop+this.eViewport.clientHeight))}ensureColumnVisible(e,i="end"){const t=this.eViewport.clientWidth,s=this.eViewport.scrollLeft,n=e.left-this.ctx.getColumns().left.reduce((o,a)=>o+a.width,0);n<s?this.eViewport.scrollLeft=Math.max(0,i==="middle"?n-(t-e.width)/2:n):n+e.width>s+t&&(this.eViewport.scrollLeft=n+e.width-t),this.renderVisibleRows()}getCellPosition(e,i){return{top:this.rowOffsets[e]??e*this.getFixedRowHeight(),left:i.left,height:this.getRowHeightForIndex(e),width:i.width}}getRowOffsets(){return this.rowOffsets}getTotalHeight(){return this.totalHeight}findCellFromEvent(e){const t=e.target.closest(".ag-cell");if(!t)return null;const s=t.dataset.colid;if(!s)return null;const n=t.closest(".ag-row"),o=n==null?void 0:n.dataset.rowid;if(!o)return null;const a=this.ctx.rowModel.getRowNode(o);if(!a)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===s);return d?(this.ctx.rowModel.getRowCount(),{node:a,column:d,eCell:t,rowIndex:0}):null}getRowIndexForNode(e){var i;for(let t=0;t<this.ctx.rowModel.getRowCount();t++)if(((i=this.ctx.rowModel.getRow(t))==null?void 0:i.id)===e.id)return t;return-1}onClick(e){const i=this.findCellFromEvent(e);if(i){this.ctx.onCellClicked({event:e,node:i.node,column:i.column,value:H(i.column,i.node,null),rowIndex:this.getRowIndexForNode(i.node),colDef:i.column.colDef});return}const t=e.target.closest(".ag-row");if(t!=null&&t.dataset.rowid){const s=this.ctx.rowModel.getRowNode(t.dataset.rowid);s&&this.ctx.onRowClicked({event:e,node:s,data:s.data,rowIndex:this.getRowIndexForNode(s)})}}onDoubleClick(e){const i=this.findCellFromEvent(e);if(i){this.ctx.onCellDoubleClicked({event:e,node:i.node,column:i.column,value:H(i.column,i.node,null),rowIndex:this.getRowIndexForNode(i.node),colDef:i.column.colDef});return}const t=e.target.closest(".ag-row");if(t!=null&&t.dataset.rowid){const s=this.ctx.rowModel.getRowNode(t.dataset.rowid);s&&this.ctx.onRowDoubleClicked({event:e,node:s,data:s.data})}}onMouseDown(e){const i=this.findCellFromEvent(e);i&&this.ctx.onCellMouseDown({event:e,node:i.node,column:i.column,value:H(i.column,i.node,null),rowIndex:this.getRowIndexForNode(i.node)})}onContextMenu(e){const i=this.findCellFromEvent(e);i&&this.ctx.onCellContextMenu({event:e,node:i.node,column:i.column,value:H(i.column,i.node,null),rowIndex:this.getRowIndexForNode(i.node)})}destroy(){for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear()}}class Ue{constructor(e,i,t,s,n,o,a){p(this,"eLeft",null);p(this,"eCenter",null);p(this,"eRight",null);p(this,"cellComps",[]);p(this,"pinned",!1);var r,d,c,h,g,u,f,m,v;if(this.ctx=e,this.node=i,this.rowHeight=o,this.heightVersion=a,i.masterNode){const C=e.renderDetailRow?e.renderDetailRow(i,this.eCenter):null;if(C){const w=document.createElement("div");w.className="ag-row ag-row-detail-row",w.dataset.rowid=i.id,w.style.height=`${C.height}px`,w.style.width="100%",w.appendChild(C.eDetail),this.eCenter=w,this.eLeft=null,this.eRight=null}return}t.length&&(this.eLeft=this.createRowElement(i,t,"left"),this.eLeft.classList.add("ag-row-pinned")),(s.length||i.footer||i.detailNode)&&(this.eCenter=this.createRowElement(i,s,"center")),n.length&&(this.eRight=this.createRowElement(i,n,"right"),this.eRight.classList.add("ag-row-pinned")),i.footer&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),i.group&&((h=this.eCenter)==null||h.classList.add("ag-row-group"),(g=this.eLeft)==null||g.classList.add("ag-row-group"),(u=this.eRight)==null||u.classList.add("ag-row-group")),(i.rowPinned==="top"||i.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(i)&&((f=this.eCenter)==null||f.classList.add("ag-row-selected"),(m=this.eLeft)==null||m.classList.add("ag-row-selected"),(v=this.eRight)==null||v.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var i,t,s;(i=this.eLeft)==null||i.classList.toggle("ag-row-sticky-group",e),(t=this.eCenter)==null||t.classList.toggle("ag-row-sticky-group",e),(s=this.eRight)==null||s.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var i,t,s;(i=this.eLeft)==null||i.classList.toggle("ag-row-hover",e),(t=this.eCenter)==null||t.classList.toggle("ag-row-hover",e),(s=this.eRight)==null||s.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,i,t){var r;const s=document.createElement("div");s.className="ag-row",s.dataset.rowid=e.id,s.setAttribute("role","row"),s.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),s.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&(s.classList.add("ag-row-draggable"),s.addEventListener("mousedown",d=>{var h,g;d.button!==0||d.target.closest("input, select, textarea, button, .ag-cell-editor")||(g=(h=this.ctx).onRowDragStart)==null||g.call(h,e,s,d)})),(e.__displayIndex??0)%2===1&&s.classList.add("ag-row-even"),s.style.height=`${this.rowHeight}px`,s.style.position="absolute",s.style.top="0px";const n=this.ctx.getRowClass(e);n&&s.classList.add(...n.split(" ").filter(Boolean));const o=this.ctx.getRowStyle(e);o&&Object.assign(s.style,o),e.footer&&((r=e.groupData)!=null&&r.__grandTotal)&&(s.classList.add("ag-row-full-width"),s.style.width="100%",s.style.right="0",s.style.left="0");let a=0;for(let d=0;d<i.length;d++){const c=i[d],h=this.createCell(c,e);let g=1;typeof c.colDef.colSpan=="function"&&(g=Math.max(1,Math.round(c.colDef.colSpan({value:H(c,e,null),data:e.data,node:e,column:c,rowIndex:e.__displayIndex??0,api:null}))));let u=c.width;for(let f=1;f<g&&d+f<i.length;f++)u+=i[d+f].width;h.eCell.style.left=`${a}px`,h.eCell.style.width=`${u}px`,h.eCell.style.position="absolute",h.eCell.style.top="0",h.eCell.style.height=`${this.rowHeight}px`,g>1&&h.eCell.classList.add("ag-cell-col-span"),a+=u,d+=g-1,s.appendChild(h.eCell),this.cellComps.push(h)}return s.style.width=`${a}px`,s}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(t=>t.colId===e.colId)+1}createCell(e,i){var c,h;const t=document.createElement("div");t.className="ag-cell",t.dataset.colid=e.colId;const s=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");s&&t.classList.add(`ag-col-${s}`);const n={value:H(e,i,null),data:i.data,node:i,column:e,rowIndex:i.__displayIndex??0,api:null};if(e.cellClass){const g=typeof e.cellClass=="function"?e.cellClass(n):e.cellClass;typeof g=="string"?t.classList.add(...g.split(" ").filter(Boolean)):Array.isArray(g)&&t.classList.add(...g)}if(e.cellClassRules)for(const[g,u]of Object.entries(e.cellClassRules))u(n)&&t.classList.add(g);if(e.cellStyle){const g=typeof e.cellStyle=="function"?e.cellStyle(n):e.cellStyle;Object.assign(t.style,g)}(e.type==="numberColumn"||e.cellDataType===!0)&&t.classList.add("ag-right-aligned-cell"),e.rowDrag&&t.classList.add("ag-cell-row-drag");const o=document.createElement("span");o.className="ag-cell-value",t.appendChild(o),this.ctx.options.enableCellTextSelection&&(t.style.userSelect="text",t.style.cursor="text"),t.setAttribute("role","gridcell"),t.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const a=(h=(c=this.ctx).getNote)==null?void 0:h.call(c,i.id,e.colId,e.colDef.note,{value:H(e,i,null),data:i.data,node:i,column:e,api:null});if(a){const g=document.createElement("span");g.className="ag-cell-note-marker",g.title=a,g.addEventListener("click",u=>{var f,m;u.stopPropagation(),(m=(f=this.ctx).onNoteClick)==null||m.call(f,i.id,e.colId,g)}),t.appendChild(g)}if(e.rowDrag){const g=document.createElement("span");g.className="ag-row-drag-handle",g.innerHTML=Mt,g.title="Drag row",g.addEventListener("mousedown",u=>{var f,m;u.stopPropagation(),(m=(f=this.ctx).onRowDragStart)==null||m.call(f,i,g,u)}),t.appendChild(g)}const r=e.tooltipField;r&&i.data&&i.data[r]!==void 0?t.title=String(i.data[r]):e.tooltipValueGetter&&(t.title=String(e.tooltipValueGetter({value:H(e,i,null),valueFormatted:null,data:i.data,node:i,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:t,eValue:o,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:i,node:t}={column:e.column,node:this.node},s=H(i,t,null),n=Ve(i,t,null);e.lastValue=s,e.lastFormatted=n;const o=typeof i.cellRenderer=="string"?i.cellRenderer:null,a=typeof i.cellRenderer=="function"?i.cellRenderer:null;if(o||a){e.custom=!0;const c=o||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const h={value:s,valueFormatted:n,data:t.data,node:t,column:i,rowIndex:0,api:null,colDef:i.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...i.cellRendererParams||{}};let g=null;if(o&&We[o]){const u=We[o](h);u instanceof HTMLElement?g=u:(e.rendererInstance=u,g=u.getGui())}else if(a){const u=a(h);u instanceof HTMLElement?g=u:u&&typeof u.getGui=="function"?(e.rendererInstance=u,g=u.getGui()):typeof u=="string"&&(e.eValue.innerHTML=u)}g&&e.eValue.appendChild(g)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=n??"";if((t.group||t.footer)&&t.groupData){const c=t.groupData[i.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,i,t){var o,a,r,d;const s=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(s&&!s.has(c.column.colId))continue;const h=H(c.column,this.node,null),g=i||h!==c.lastValue;if(!g&&!t)continue;const u=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:h,valueFormatted:Ve(c.column,this.node,null),data:this.node.data,node:this.node,column:c.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:c.column.colDef,eGridCell:c.eCell,...c.column.cellRendererParams||{}})===!1&&this.updateCellContent(c),c.lastValue=h,t&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(g||t)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=h,t&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(t||g&&u!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"))}const n=this.ctx.isNodeSelected(this.node);(o=this.eCenter)==null||o.classList.toggle("ag-row-selected",n),(a=this.eLeft)==null||a.classList.toggle("ag-row-selected",n),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",n),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,i,t){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&i.appendChild(this.eCenter),this.eRight&&t.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const s=this.ctx.renderDetailRow(this.node,this.eCenter);s&&i.appendChild(s.eDetail)}}ensureVisibleCells(){this.refreshCells(void 0,!0)}setTop(e){const i=`${e}px`;this.eLeft&&(this.eLeft.style.top=i),this.eCenter&&(this.eCenter.style.top=i),this.eRight&&(this.eRight.style.top=i)}getCenterElement(){return this.eCenter}getCellElements(){return this.cellComps.map(e=>e.eCell)}destroy(){var e,i,t,s;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(i=this.eCenter)!=null&&i.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(t=this.eRight)!=null&&t.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const n of this.cellComps)(s=n.rendererInstance)!=null&&s.destroy&&n.rendererInstance.destroy();this.cellComps=[]}}class Xi{constructor(e,i){p(this,"ctx");p(this,"eHeader");p(this,"ePinnedLeftHeader");p(this,"ePinnedRightHeader");p(this,"eHeaderViewport");p(this,"eHeaderContainer");p(this,"eHeaderRow");p(this,"eFloatingFiltersRow",null);p(this,"eGroupRows");p(this,"headerCells",new Map);p(this,"customHeaderComponents",new Map);p(this,"resizeState",null);p(this,"dragState",null);p(this,"lastWidths",new Map);this.ctx=i,this.eHeader=e,e.classList.add("ag-header"),e.style.height=`${i.headerHeight}px`,this.ePinnedLeftHeader=document.createElement("div"),this.ePinnedLeftHeader.className="ag-pinned-left-header",e.appendChild(this.ePinnedLeftHeader),this.eHeaderViewport=document.createElement("div"),this.eHeaderViewport.className="ag-header-viewport",e.appendChild(this.eHeaderViewport),this.eHeaderContainer=document.createElement("div"),this.eHeaderContainer.className="ag-header-container",this.eHeaderViewport.appendChild(this.eHeaderContainer),this.eGroupRows=document.createElement("div"),this.eGroupRows.className="ag-group-header-rows",this.eHeaderContainer.appendChild(this.eGroupRows),this.eHeaderRow=document.createElement("div"),this.eHeaderRow.className="ag-header-row",this.eHeaderContainer.appendChild(this.eHeaderRow),this.ePinnedRightHeader=document.createElement("div"),this.ePinnedRightHeader.className="ag-pinned-right-header",e.appendChild(this.ePinnedRightHeader),this.refresh()}refresh(){this.headerCells.clear(),this.renderGroupRows();const{left:e,center:i,right:t}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,i,"center"),this.renderSection(this.ePinnedRightHeader,t,"right");const s=[...e,...i,...t].some(n=>n.floatingFilter);s&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!s&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,i,"center"))}renderGroupRows(){var a;const e=this.ctx.getColumnModel(),i=((a=e==null?void 0:e.getColumnGroups)==null?void 0:a.call(e))||[];this.eGroupRows.innerHTML="";const t=i.reduce((r,d)=>Math.max(r,d.depth),0),s=this.ctx.options.groupHeaderHeight??30;let n=0;for(let r=1;r<=t;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${s}px`;const c=this.ctx.getColumns().center;let h=0,g,u=0,f=0;const m=(C,w)=>{let x=C.groupId;for(;x;){const b=i.find(y=>y.id===x);if(!b)return null;if(b.depth===w)return b.id;x=b.parentId}return null},v=()=>{if(g==null)return;const C=i.find(y=>y.id===g);if(!C)return;const w=document.createElement("div");w.className="ag-header-group-cell",w.style.left=`${u}px`,w.style.width=`${f}px`,w.style.height=`${s}px`;const x=e.isGroupOpen(C.id),b=document.createElement("div");if(b.className="ag-header-group-cell-label",b.textContent=C.headerName,w.appendChild(b),!x){const y=document.createElement("span");y.className="ag-header-group-expand",y.textContent="▸",y.title="Expand group",w.appendChild(y)}w.addEventListener("click",()=>{e.setGroupOpen(C.id,!x)}),d.appendChild(w)};c.forEach(C=>{const w=m(C,r);w!==g&&(v(),g=w,u=h,f=0),f+=C.width,h+=C.width}),v(),d.style.width=`${h}px`,this.eGroupRows.appendChild(d),n+=s}this.eGroupRows.style.display=t>0?"":"none";const o=this.ctx.headerHeight;this.eHeader.style.height=`${n+o}px`}renderSection(e,i,t){e.innerHTML="";let s=0;for(const n of i){const o=this.createHeaderCell(n);if(o.style.left=`${s}px`,o.style.width=`${n.width}px`,o.style.height=`${this.ctx.headerHeight}px`,s+=n.width,e.appendChild(o),this.headerCells.set(n.colId,o),n.eHeaderCell=o,this.eFloatingFiltersRow&&e===this.eHeaderRow&&n.floatingFilter){const a=this.createFloatingFilter(n);a.style.left=`${s-n.width}px`,a.style.width=`${n.width}px`,this.eFloatingFiltersRow.appendChild(a)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${s}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${s}px`)}createHeaderCell(e){var o,a;const i=document.createElement("div");if(i.className="ag-header-cell",i.dataset.colid=e.colId,i.setAttribute("role","columnheader"),i.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?i.setAttribute("aria-sort","ascending"):e.sort==="desc"?i.setAttribute("aria-sort","descending"):i.setAttribute("aria-sort","none"),i.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;i.classList.add(...String(r).split(" ").filter(Boolean))}const t=e.colDef.headerComponent;if(typeof t=="function"){const r=t({column:e,colDef:e.colDef,api:((a=(o=this.ctx).getApi)==null?void 0:a.call(o))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),i.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),i}const s=document.createElement("div");if(s.className="ag-header-cell-label",e.headerTooltip&&(s.title=e.headerTooltip),e.headerCheckboxSelection){const r=document.createElement("input");r.type="checkbox",r.className="ag-native-checkbox ag-header-select-all",r.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,r.checked)),r.addEventListener("click",d=>d.stopPropagation()),s.appendChild(r)}const n=document.createElement("span");if(n.className="ag-header-cell-text",n.textContent=e.headerName,s.appendChild(n),i.appendChild(s),e.sortable){const r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),i.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=Wi,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),i.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=_i,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),i.appendChild(r)}if(i.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),i.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,i)}),i.addEventListener("dblclick",r=>{const d=i.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=g=>{if(!this.resizeState)return;const u=g.clientX-this.resizeState.startX;let f=this.resizeState.startWidth+u;f=Math.max(e.minWidth,Math.min(e.maxWidth,f)),this.ctx.onColumnResized(e,Math.round(f),!1)},h=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",h)}),i.appendChild(r)}return e.suppressMovable||(i.draggable=!0,i.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=i.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),i.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),i.addEventListener("dragover",r=>{r.preventDefault()}),i.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),i}createFloatingFilter(e){const i=document.createElement("div");if(i.className="ag-header-cell ag-floating-filter-cell",i.dataset.colid=e.colId,i.style.position="absolute",i.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const s=document.createElement("select");return s.className="ag-floating-filter-input",s.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',s.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,s.value)),i.appendChild(s),e.floatingFilterComp=s,i}const t=document.createElement("input");return t.className="ag-floating-filter-input",t.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",t.placeholder="Filter...",t.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),t.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,t.value)),i.appendChild(t),e.floatingFilterComp=t,i}updateSortIndicator(e,i,t){if(e.innerHTML="",i==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=Ui):i==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=qi),i&&t!==null&&t>0){const s=document.createElement("span");s.className="ag-sort-order",s.textContent=String(t+1),e.appendChild(s)}}updateIndicators(){const{left:e,center:i,right:t}=this.ctx.getColumns();for(const s of[...e,...i,...t]){const n=this.headerCells.get(s.colId);if(!n)continue;const o=n.querySelector(".ag-sort-indicator");o&&this.updateSortIndicator(o,s.sort,s.sortIndex);const a=n.querySelector(".ag-filter-icon");a&&a.classList.toggle("ag-filter-active",this.ctx.isFilterActive(s)),n.style.width=`${s.width}px`,this.lastWidths.get(s.colId)!==s.width&&this.lastWidths.set(s.colId,s.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(t=>t.colId===e.colId)+1}layoutPositions(){const{left:e,center:i,right:t}=this.ctx.getColumns();let s=0;for(const n of e){const o=this.headerCells.get(n.colId);o&&(o.style.left=`${s}px`),s+=n.width}this.ePinnedLeftHeader.style.width=`${s}px`,s=0;for(const n of i){const o=this.headerCells.get(n.colId);o&&(o.style.left=`${s}px`),s+=n.width}this.eHeaderContainer.style.width=`${s}px`,s=0;for(const n of t){const o=this.headerCells.get(n.colId);o&&(o.style.left=`${s}px`),s+=n.width}if(this.ePinnedRightHeader.style.width=`${s}px`,this.eFloatingFiltersRow){s=0;for(const n of i){const o=this.eFloatingFiltersRow.querySelector(`[data-colid="${n.colId}"]`);o&&(o.style.left=`${s}px`,o.style.width=`${n.width}px`),s+=n.width}}}setScrollLeft(e){this.eHeaderViewport.scrollLeft=e}getHeaderCell(e){return this.headerCells.get(e.colId)}getHeaderRow(){return this.eHeaderRow}}class ji{constructor(e,i,t){p(this,"selectedNodes",new Set);p(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=i,this.isNodeSelectable=t}isEnabled(){return!!this.getOptions().rowSelection}getSelectedNodes(){return[...this.selectedNodes]}getSelectedRows(){return[...this.selectedNodes].map(e=>e.data)}getSelectedCount(){return this.selectedNodes.size}isNodeSelected(e){return this.selectedNodes.has(e)}selectNode(e,i=!1){this.isEnabled()&&this.isNodeSelectable(e)&&(i&&this.getOptions().rowSelection==="multiple"?this.deselectAll():i&&this.deselectAll(),!this.selectedNodes.has(e)&&(this.selectedNodes.add(e),e.selected=!0,this.lastSelectedNode=e,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!0),this.dispatchChanged()))}deselectNode(e){this.selectedNodes.has(e)&&(this.selectedNodes.delete(e),e.selected=!1,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!1),this.dispatchChanged())}selectChildrenRecursively(e,i){if(e.children)for(const t of e.children)t.footer||t.detailNode||(i?this.isNodeSelectable(t)&&(this.selectedNodes.add(t),t.selected=!0):(this.selectedNodes.delete(t),t.selected=!1),this.selectChildrenRecursively(t,i))}selectAll(){!this.isEnabled()||this.getOptions().rowSelection!=="multiple"||this.selectAllFiltered()}selectAllFiltered(){if(!this.isEnabled())return;const e=this.getOptions().__rowModel;e!=null&&e.forEachNode&&e.forEachNode(i=>{this.isNodeSelectable(i)&&!i.footer&&(this.selectedNodes.add(i),i.selected=!0)}),this.dispatchChanged()}deselectAll(){for(const e of this.selectedNodes)e.selected=!1;this.selectedNodes.clear(),this.lastSelectedNode=null,this.dispatchChanged()}toggleNode(e){this.selectedNodes.has(e)?this.deselectNode(e):this.selectNode(e,!1)}handleRowClick(e,i){if(!this.isEnabled()||this.getOptions().suppressRowClickSelection)return!1;const t=this.getOptions().rowSelection==="multiple",s=i.ctrlKey||i.metaKey,n=i.shiftKey;return t?n&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):s?(this.toggleNode(e),!0):(this.getOptions().rowMultiSelectWithClick?this.selectNode(e,!1):this.selectNode(e,!0),!0):(this.selectNode(e,!0),!0)}selectRange(e,i){const t=this.getOptions().__rowModel;if(!(t!=null&&t.forEachNode))return;let s=-1,n=-1,o=0;if(t.forEachNode(d=>{d===e&&(s=o),d===i&&(n=o),o++}),s<0||n<0)return;const a=Math.min(s,n),r=Math.max(s,n);o=0,t.forEachNode(d=>{o>=a&&o<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.selected=!0),o++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const i=new Set;e.forEachNode(s=>i.add(s));let t=!1;for(const s of this.selectedNodes)i.has(s)?s.selected=!0:t=!0;if(t){for(const s of[...this.selectedNodes])i.has(s)||this.selectedNodes.delete(s);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let i=0,t=0;return e!=null&&e.forEachNode&&e.forEachNode(s=>{s.footer||!this.isNodeSelectable(s)||(i++,s.selected&&t++)}),{checked:i>0&&t===i,indeterminate:t>0&&t<i}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Yi{constructor(e,i){p(this,"editing",null);p(this,"fullRowEditors",null);p(this,"fullRowNode",null);p(this,"focusedCell",null);p(this,"suppressClickEdit",!1);this.grid=e,this.eventService=i}getFocusedCell(){return this.focusedCell}setFocusedCell(e,i){this.focusedCell={rowIndex:e,column:i,rowNode:this.grid.getDisplayedRowAtIndex(e)},this.grid.getRowRenderer().refreshCells({force:!0}),this.clearFocusClass();const t=this.findCellElement(i,e);t==null||t.classList.add("ag-cell-focus"),t&&typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"nearest",inline:"nearest"}),this.eventService.dispatchEvent("cellFocused",{rowIndex:e,column:i,api:this.grid.getApi(),forceBrowserFocus:!0})}clearFocusedCell(){this.focusedCell=null,this.clearFocusClass(),this.grid.getRowRenderer().refreshCells({force:!0})}clearFocusClass(){const e=this.grid.getRootElement();for(const i of e.querySelectorAll(".ag-cell-focus"))i.classList.remove("ag-cell-focus")}findCellElement(e,i){const t=this.grid.getDisplayedRowAtIndex(i);if(!t)return null;const n=this.grid.getRowRenderer().getRowComps().get(t.id);return n&&n.getCellElements().find(o=>o.dataset.colid===e.colId)||null}isEditing(){return this.editing!==null||this.fullRowEditors!==null}getEditingCells(){return this.editing?[{rowIndex:this.editing.rowIndex,colId:this.editing.column.colId}]:[]}startEditingCell(e){var d;const i=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!i)return;const t=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!t||!this.grid.isCellEditable(i,t))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,t,e.charPress);return}const s=this.findCellElement(i,e.rowIndex);if(!s)return;const n=H(i,t,this.grid.getApi()),o={value:e.charPress!==void 0?e.charPress:n,oldValue:n,data:t.data,node:t,column:i,colDef:i.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=i.cellEditorParams)==null?void 0:d.values,...i.cellEditorParams};let a=null;if(typeof i.cellEditor=="string")a=(fe[i.cellEditor]||fe.agTextCellEditor)(o);else if(typeof i.cellEditor=="function"){const c=i.cellEditor(o);a=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=i.type==="numberColumn"?"agNumberCellEditor":i.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";a=fe[c](o)}if(!a)return;this.editing={rowIndex:e.rowIndex,column:i,rowNode:t,eCell:s,editor:a,startedValue:n},s.classList.add("ag-cell-inline-editing");const r=a.getGui();r.classList.add("ag-cell-editor"),s.appendChild(r),s.classList.add("ag-cell-editing"),a.focusIn&&a.focusIn(),a.afterGuiAttached&&a.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:i,node:t,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,i,t){const s=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(n=>this.grid.isCellEditable(n,i));this.fullRowEditors=[],this.fullRowNode=i;for(const n of s){const o=this.findCellElement(n,e);if(!o)continue;const a=H(n,i,this.grid.getApi()),r=this.createEditor(n,i,e,a,t);if(!r)continue;o.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),o.appendChild(d),this.fullRowEditors.push({column:n,editor:r,eCell:o,startedValue:a})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:i,api:this.grid.getApi(),data:i.data})}createEditor(e,i,t,s,n){var r;const o={value:n!==void 0?n:s,oldValue:s,data:i.data,node:i,column:e,colDef:e.colDef,rowIndex:t,api:this.grid.getApi(),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(fe[e.cellEditor]||fe.agTextCellEditor)(o);if(typeof e.cellEditor=="function"){const d=e.cellEditor(o);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const a=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return fe[a](o)}stopEditing(e=!1){var d,c,h,g;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:i,column:t,rowNode:s,eCell:n,editor:o,startedValue:a}=this.editing;this.editing=null,n.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?a:o.getValue();if(r===void 0&&!e)return(d=n.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:i,column:t,node:s,api:this.grid.getApi()}),!1;if(!e){r=wt(t,r);const u=this.applyValueSetter(t,s,r);if(u===!1)return n.classList.add("ag-cell-invalid"),setTimeout(()=>n.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:i,colKey:t}),!1;r=u}return(c=n.querySelector(".ag-cell-editor"))==null||c.remove(),o.destroy&&o.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:i,column:t,node:s,api:this.grid.getApi()}),!e&&!It(r,a)&&(this.grid.setCellValue(t,s,r,"edit",a),this.eventService.dispatchEvent("cellValueChanged",{oldValue:a,newValue:r,value:r,data:s.data,node:s,column:t,colDef:t.colDef,api:this.grid.getApi(),source:"edit"}),(g=(h=this.grid.getOptions()).onCellValueChanged)==null||g.call(h,{oldValue:a,newValue:r,value:r,data:s.data,node:s,column:t,colDef:t.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[s],columns:[t],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,i,t){if(e.valueSetter){if(e.valueSetter({oldValue:H(e,i,this.grid.getApi()),newValue:t,data:i.data,node:i,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else i.setDataValue(e.colId,t);return t}stopFullRowEditing(e){var n,o,a;const i=this.fullRowEditors,t=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!i)return!1;for(const r of i)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(n=r.eCell.querySelector(".ag-cell-editor"))==null||n.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const s=[];for(const r of i){if(!t)break;let d=r.editor.getValue();d!==void 0&&(d=wt(r.column,d),It(d,r.startedValue)||s.push({column:r.column,rowNode:t,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:t==null?void 0:t.data});for(const r of s)this.grid.setCellValue(r.column,r.rowNode,r.newValue,"edit",r.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi(),source:"edit"}),(a=(o=this.grid.getOptions()).onCellValueChanged)==null||a.call(o,{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[r.rowNode],columns:[r.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===we){e.preventDefault();const i=this.editing;this.stopEditing(),i&&this.grid.getOptions().enterNavigatesVerticallyAfterEdit!==!1&&this.moveFocus(1,0)}else if(e.key==="Escape"||e.keyCode===Zt)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===ut){e.preventDefault(),this.stopEditing(),this.moveFocus(0,e.shiftKey?-1:1);const i=this.focusedCell;i&&this.grid.isCellEditable(i.column,i.rowNode)&&this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column})}}onGridKeyDown(e){const i=e.key;if(this.editing){i==="Escape"&&this.stopEditing(!0);return}const t=this.focusedCell;switch(e.keyCode){case we:e.preventDefault(),t&&(this.grid.isCellEditable(t.column,t.rowNode)?this.startEditingCell({rowIndex:t.rowIndex,colKey:t.column}):this.moveFocus(1,0));break;case ut:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case pt:case gt:t&&this.grid.isCellEditable(t.column,t.rowNode)&&(e.preventDefault(),this.grid.setCellValue(t.column,t.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[t.rowNode],columns:[t.column],flash:!0}));break;case 37:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,-1));break;case 39:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,1));break;case 38:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1,0));break;case 40:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1,0));break;case Jt:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case ei:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1/0,0));break;case 33:e.preventDefault(),this.moveFocus(-this.getPageJump(),0);break;case 34:e.preventDefault(),this.moveFocus(this.getPageJump(),0);break;case 70:(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.grid.openFind());break;default:if((i==="f"||i==="F")&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.grid.openFind();return}t&&i.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(t.column,t.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:t.rowIndex,colKey:t.column,charPress:i}));break}}isTextInput(e){if(!e)return!1;const i=e;return i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.tagName==="SELECT"||i.isContentEditable}getPageJump(){const e=this.grid.getRowRenderer().getViewport();return Math.max(1,Math.floor(e.clientHeight/(this.grid.getOptions().rowHeight??42))-1)}moveFocus(e,i){const t=this.focusedCell;if(!t){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let s=t.rowIndex;if(e===-1/0?s=0:e===1/0?s=this.grid.getDisplayedRowCount()-1:s=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,s+e)),i!==0){const n=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let a=n.findIndex(r=>r.colId===t.column.colId)+i;for(;a>=0&&a<n.length&&!n[a].visible;)a+=i;a<0&&(a=0),a>=n.length&&(a=n.length-1),this.setFocusedCell(s,n[a])}else this.setFocusedCell(s,t.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:i,column:t,event:s}=e;if(this.setFocusedCell(e.rowIndex,t),t.checkboxSelection)return;const n=this.grid.isCellEditable(t,i),o=t.singleClickEdit||this.grid.getOptions().singleClickEdit;n&&o&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:t})}onCellDoubleClicked(e){const{node:i,column:t}=e;this.setFocusedCell(e.rowIndex,t),this.grid.isCellEditable(t,i)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:t})}destroy(){this.editing=null,this.focusedCell=null}}function It(l,e){return l===e?!0:l instanceof Date&&e instanceof Date?l.getTime()===e.getTime():!1}class Qi{constructor(e){p(this,"filterModel",{});p(this,"advancedFilterModel",null);this.grid=e}getAdvancedFilterModel(){return this.advancedFilterModel}setAdvancedFilterModel(e){this.advancedFilterModel=e,this.onFilterChanged("api")}isAdvancedFilterEnabled(){return!!this.grid.getOptions().enableAdvancedFilter}doesNodePassAdvancedFilter(e){const i=this.advancedFilterModel;if(!i||!i.conditions||i.conditions.length===0)return!0;const t=this.grid.getRowModel(),s=typeof t.doesNodePassFilterModel=="function"?t.doesNodePassFilterModel.bind(t):null,n=i.conditions.map(o=>{const a=this.grid.getColumn(o.colId);return!a||!s?!0:s(e,a,{...o,filterType:a.filter===!0?"text":a.filter})});return i.operator==="OR"?n.some(Boolean):n.every(Boolean)}getFilterModel(){return this.filterModel}getFilterInstance(e){return this.filterModel[e]}setFilterModel(e){this.filterModel=e||{},this.onFilterChanged("api")}setColumnFilterModel(e,i){const t=typeof e=="string"?e:e.colId;i==null?delete this.filterModel[t]:this.filterModel[t]=i,this.onFilterChanged("api")}isFilterActive(e){const i=this.filterModel[e.colId];return i?i.filterType==="multi"?(i.filterModels||[]).some(s=>this.isModelMeaningful(s)):this.isModelMeaningful(i):!1}isModelMeaningful(e){return e.filterType==="text"?!!e.filter:e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":!1}handleFloatingFilterChange(e,i){if(i===""||i===null||i===void 0){delete this.filterModel[e.colId],this.onFilterChanged("uiFilterModified");return}switch(e.filter){case"number":this.filterModel[e.colId]={filterType:"number",type:"equals",filter:i};break;case"date":this.filterModel[e.colId]={filterType:"date",dateFrom:i,dateTo:i};break;case"boolean":this.filterModel[e.colId]={filterType:"boolean",filter:i==="true"};break;case"set":this.filterModel[e.colId]={filterType:"set",values:[i]};break;default:this.filterModel[e.colId]={filterType:"text",type:"contains",filter:i};break}this.onFilterChanged("uiFilterModified")}resetFilters(){this.filterModel={},this.onFilterChanged("api")}onFilterChanged(e){var t,s;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const i=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:i,source:e}),(s=(t=this.grid.getOptions()).onFilterChanged)==null||s.call(t,{api:i,source:e})}}class Zi{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,i,t){const s=this.grid.getOptions().suppressMultiSort,n=t&&!s&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,o=this.getSortingOrder(),a=e.sort;let r=o.indexOf(a)+1;r>=o.length&&(r=0);const d=o[r];if(!n)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(i=>i.sort).sort((i,t)=>(i.sortIndex??99)-(t.sortIndex??99)).forEach((i,t)=>i.sortIndex=t)}getSortModel(){return this.grid.getAllColumns().filter(e=>e.sort).sort((e,i)=>(e.sortIndex??0)-(i.sortIndex??0)).map(e=>({colId:e.colId,sort:e.sort}))}setSortModel(e){for(const i of this.grid.getAllColumns())i.sort=null,i.sortIndex=null;e.forEach((i,t)=>{const s=this.grid.getColumn(i.colId);s&&(s.sort=i.sort,s.sortIndex=t)}),this.onSortChanged("api")}onSortChanged(e){var t,s;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const i=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:i,source:e}),(s=(t=this.grid.getOptions()).onSortChanged)==null||s.call(t,{api:i,source:e})}}class kt{constructor(e,i){p(this,"enabled");p(this,"pageSize");p(this,"currentPage",0);p(this,"pageSizeSelector");p(this,"ePanel");p(this,"ePageInfo");p(this,"ePageInput");p(this,"ePageSizeSelect",null);p(this,"ePageSizeContainer");p(this,"eFromToContainer");this.grid=e,this.eventService=i;const t=e.getOptions();this.enabled=t.pagination===!0,this.pageSize=t.paginationPageSize??100,this.pageSizeSelector=t.paginationPageSizeSelector??[20,50,100,500,1e3],this.ePanel=document.createElement("div"),this.ePanel.className="ag-pagination-panel",this.enabled||(this.ePanel.style.display="none");const s=document.createElement("div");s.className="ag-pagination-buttons",this.ePanel.appendChild(s),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",s.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",s.appendChild(this.eFromToContainer);const n=document.createElement("span");if(n.className="ag-pagination-page-label",n.textContent=`${this.grid.translate("page","Page")}`,s.appendChild(n),this.ePageInput=document.createElement("input"),this.ePageInput.className="ag-pagination-page-input",this.ePageInput.type="number",this.ePageInput.min="1",this.ePageInput.value="1",this.ePageInput.title="Page number",this.ePageInput.addEventListener("change",()=>{const o=parseInt(this.ePageInput.value,10);isNaN(o)||this.goToPage(o-1)}),s.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",s.appendChild(this.ePageInfo),this.pageSizeSelector){const o=this.ePageSizeContainer,a=document.createElement("span");a.textContent=`${this.grid.translate("pageSize","Page Size:")}`,o.appendChild(a);const r=document.createElement("select");r.className="ag-pagination-page-size-select";const d=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const c of d){const h=document.createElement("option");h.value=String(c),h.textContent=String(c),c===this.pageSize&&(h.selected=!0),r.appendChild(h)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),o.appendChild(r),this.ePageSizeSelect=r}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const i=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(i/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),i=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(i/this.pageSize))}goToPage(e){const i=this.getTotalPages(),t=Math.max(0,Math.min(i-1,e));if(t===this.currentPage){this.update();return}this.currentPage=t,this.grid.refreshModel("everything"),this.update(),this.grid.getRowRenderer().setVerticalScrollTop(0)}goToNextPage(){this.goToPage(this.currentPage+1)}goToPreviousPage(){this.goToPage(this.currentPage-1)}goToFirstPage(){this.goToPage(0)}goToLastPage(){this.goToPage(this.getTotalPages()-1)}update(){var o,a;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const i=this.grid.getRowModel(),t=i.getTotalRowCount?i.getTotalRowCount():i.getRowCount(),s=t===0?0:this.currentPage*this.pageSize+1,n=Math.min(t,(this.currentPage+1)*this.pageSize);this.ePageInfo.textContent=`of ${e}`,this.ePageInput.value=String(this.currentPage+1),this.ePageInput.max=String(e),this.eFromToContainer.textContent=t===0?"0 to 0 of 0":`${s.toLocaleString()} to ${n.toLocaleString()} of ${t.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:t}),(a=(o=this.grid.getOptions()).onPaginationChanged)==null||a.call(o,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Ji{constructor(e){p(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,i=""){const t=document.createElement("div");t.className=`ag-popup ${i}`.trim(),t.style.width=`${e}px`,t.style.display="none";const s={ePopup:t},n=()=>{var d;this.openPopups.has(s)&&(this.openPopups.delete(s),t.remove(),document.removeEventListener("mousedown",a,!0),document.removeEventListener("keydown",r,!0),(d=s.onClose)==null||d.call(s))},o=d=>{s.onClose=d},a=d=>{if(!t.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){n();return}t.contains(d.target)||n()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),n())};return this.getParent().appendChild(t),this.openPopups.add(s),document.addEventListener("mousedown",a,!0),document.addEventListener("keydown",r,!0),{ePopup:t,close:n,onClose:o}}positionAt(e,i,t=0){const s=this.grid.getRootElement().getBoundingClientRect(),n=i.getBoundingClientRect(),o=e.offsetWidth||220;let a=n.left-s.left+t;const r=s.width-o-4;a>r&&(a=r),a<4&&(a=4);const d=n.bottom-s.top+2;e.style.left=`${a}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}const Ae=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Pe=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class es{constructor(e,i){this.grid=e,this.popupService=i}openFilter(e,i){var v,C;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,i);return}if(e.filter==="multi"){this.openMultiFilter(e,i);return}const t=e.filter===!0?"text":e.filter,s=this.grid.getFilterService().getFilterInstance(e.colId),n=t==="set"?260:240,{ePopup:o,close:a}=this.popupService.createPopup(n,"ag-filter-popup");o.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=`Search ${e.headerName||e.field||""}`,o.appendChild(r);let d=s?{...s}:this.getDefaultModel(t),c=s?{...s}:null;const h=()=>{c&&this.isMeaningful(c)?this.grid.getFilterService().setColumnFilterModel(e,c):this.grid.getFilterService().setColumnFilterModel(e,null),a()},g=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),a()};if(t==="set")o.appendChild(this.buildSetFilter(e,d,w=>{c=w}));else if(t==="boolean"){const w=this.buildConditionSelect(["true","false"],String(d.filter??""),x=>{c={filterType:"boolean",filter:x==="true"}});o.appendChild(w)}else{const w=t==="number"?Pe:Ae,x=this.buildConditionSelect(w,d.type||w[0],b=>{d.type=b,c={...d}});if(o.appendChild(x),d.type!=="blank"&&d.type!=="notBlank")if(t==="number"&&d.type==="inRange"){const b=document.createElement("div");b.className="ag-filter-inputs";const y=document.createElement("input");y.type="number",y.className="ag-filter-input",y.value=d.filter??"",y.placeholder=this.grid.t("from"),y.addEventListener("input",()=>{c={...d,filter:y.value,filterTo:N.value}});const N=document.createElement("input");N.type="number",N.className="ag-filter-input",N.value=d.filterTo??"",N.placeholder=this.grid.t("to"),N.addEventListener("input",()=>{c={...d,filter:y.value,filterTo:N.value}}),b.appendChild(y),b.appendChild(N),o.appendChild(b)}else if(t==="date"){const b=document.createElement("div");b.className="ag-filter-inputs";const y=document.createElement("input");y.type="date",y.className="ag-filter-input",y.value=d.dateFrom??"",y.addEventListener("input",()=>{c={...d,dateFrom:y.value,dateTo:N.value}});const N=document.createElement("input");N.type="date",N.className="ag-filter-input",N.value=d.dateTo??"",N.addEventListener("input",()=>{c={...d,dateFrom:y.value,dateTo:N.value}}),b.appendChild(y),b.appendChild(N),o.appendChild(b)}else{const b=document.createElement("input");b.type=t==="number"?"number":"text",b.className="ag-filter-input",b.value=d.filter??"",b.placeholder=this.grid.t("filterOoo"),b.addEventListener("input",()=>{c={...d,filter:b.value}}),b.addEventListener("keydown",y=>{y.key==="Enter"&&h()}),o.appendChild(b),setTimeout(()=>b.focus(),0)}else c={...d}}if(t==="text"||t==="number"){const w=document.createElement("div");w.className="ag-filter-second-condition";const x=document.createElement("select");x.className="ag-filter-condition",x.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,x.value=d.operator||"AND",w.appendChild(x);const b=this.buildConditionSelect(t==="number"?Pe:Ae,((v=d.condition2)==null?void 0:v.type)||(t==="number"?Pe:Ae)[0],N=>{c||(c={...d}),c.condition2={...c.condition2,type:N}});w.appendChild(b);const y=document.createElement("input");y.type=t==="number"?"number":"text",y.className="ag-filter-input",y.placeholder=this.grid.t("secondValue"),y.value=((C=d.condition2)==null?void 0:C.filter)??"",y.addEventListener("input",()=>{c||(c={...d}),c.condition2={...c.condition2,filter:y.value}}),w.appendChild(y),o.appendChild(w),x.addEventListener("change",()=>{c||(c={...d}),c.operator=x.value})}const u=document.createElement("div");u.className="ag-popup-buttons";const f=document.createElement("button");f.className="ag-button ag-button-primary",f.textContent=this.grid.t("apply"),f.addEventListener("click",h);const m=document.createElement("button");m.className="ag-button",m.textContent=this.grid.t("clear"),m.addEventListener("click",g),u.appendChild(m),u.appendChild(f),o.appendChild(u),this.popupService.positionAt(o,i),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,i,t){const s=document.createElement("div");s.className="ag-set-filter";const n=document.createElement("input");n.type="text",n.className="ag-filter-input",n.placeholder=this.grid.t("search"),s.appendChild(n);const o=new Set;this.grid.getRowModel().forEachNode(m=>{!m.group&&!m.footer&&o.add(H(e,m,this.grid.getApi()))});let r=[...o].sort((m,v)=>m===v?0:m<v?-1:1);const d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((i.values||[]).map(m=>String(m))),h=()=>{d.innerHTML="";const m=n.value.toLowerCase();let v=0;for(const C of r){const w=C==null?"(Blanks)":String(C);if(m&&!w.toLowerCase().includes(m))continue;v++;const x=document.createElement("label");x.className="ag-set-filter-item";const b=document.createElement("input");b.type="checkbox",b.checked=c.has(String(C)),b.addEventListener("change",()=>{b.checked?c.add(String(C)):c.delete(String(C)),t({filterType:"set",values:[...c]})});const y=document.createElement("span");y.textContent=w,x.appendChild(b),x.appendChild(y),d.appendChild(x)}if(v===0){const C=document.createElement("div");C.className="ag-set-filter-empty",C.textContent=this.grid.t("noMatches"),d.appendChild(C)}};n.addEventListener("input",h),h();const g=document.createElement("div");g.className="ag-set-filter-actions";const u=document.createElement("button");u.className="ag-button ag-button-small",u.textContent=this.grid.t("selectAll"),u.addEventListener("click",()=>{c.clear();for(const m of r)c.add(String(m));h(),t({filterType:"set",values:[...c]})});const f=document.createElement("button");return f.className="ag-button ag-button-small",f.textContent=this.grid.t("clearAll"),f.addEventListener("click",()=>{c.clear(),h(),t({filterType:"set",values:[]})}),g.appendChild(u),g.appendChild(f),s.appendChild(d),s.appendChild(g),t({filterType:"set",values:[...c]}),s}buildConditionSelect(e,i,t){const s=document.createElement("select");s.className="ag-filter-condition";for(const n of e){const o=document.createElement("option");o.value=n;const a=vi[n];o.textContent=a?this.grid.t(a):n,n===i&&(o.selected=!0),s.appendChild(o)}return s.addEventListener("change",()=>t(s.value)),s}openMultiFilter(e,i){var x;const t=this.grid.getFilterService().getFilterInstance(e.colId),s=t&&t.filterType==="multi"?t:null,n=(x=s==null?void 0:s.filterModels)!=null&&x.length?s.filterModels.map(b=>({...b})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let o=(s==null?void 0:s.operator)||"AND";const{ePopup:a,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");a.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,a.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const h=document.createElement("span");h.textContent=this.grid.t("join");const g=document.createElement("select");g.className="ag-filter-condition",g.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',g.value=o,g.addEventListener("change",()=>{o=g.value}),c.appendChild(h),c.appendChild(g),a.appendChild(c);const u=document.createElement("div");u.className="ag-multi-filter-list",a.appendChild(u);const f=()=>{u.innerHTML="",n.forEach((b,y)=>{const N=document.createElement("div");N.className="ag-multi-filter-row";const I=document.createElement("select");I.className="ag-filter-condition";const D=["text","number","date","set","boolean"];for(const F of D){const S=document.createElement("option");S.value=F,S.textContent=F.charAt(0).toUpperCase()+F.slice(1),F===b.filterType&&(S.selected=!0),I.appendChild(S)}I.addEventListener("change",()=>{n[y]={...this.getDefaultModel(I.value)},f()}),N.appendChild(I);const _=b.filterType==="number"?Pe:Ae,T=this.buildConditionSelect(_,b.type||_[0],F=>{n[y].type=F});if(N.appendChild(T),b.filterType!=="blank"&&b.type!=="blank"&&b.type!=="notBlank"){const F=document.createElement("input");F.type=b.filterType==="number"?"number":"text",F.className="ag-filter-input",F.value=b.filter??"",F.placeholder=this.grid.t("value"),F.addEventListener("input",()=>{n[y].filter=F.value}),N.appendChild(F)}const P=document.createElement("button");P.className="ag-button ag-button-small",P.textContent="×",P.title=this.grid.t("removeFilter"),P.addEventListener("click",()=>{n.splice(y,1),f()}),N.appendChild(P),u.appendChild(N)})};f();const m=document.createElement("button");m.className="ag-button ag-button-small",m.textContent="+ "+this.grid.t("addFilter"),m.addEventListener("click",()=>{n.push(this.getDefaultModel("text")),f()}),a.appendChild(m);const v=document.createElement("div");v.className="ag-popup-buttons";const C=document.createElement("button");C.className="ag-button ag-button-primary",C.textContent=this.grid.t("apply"),C.addEventListener("click",()=>{n.filter(y=>y.filter!==void 0&&y.filter!==""||y.type==="blank"||y.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:o,filterModels:n}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(w),v.appendChild(C),a.appendChild(v),this.popupService.positionAt(a,i)}openAdvancedFilter(e){var x,b;const i=this.grid.getFilterService(),t=i.getAdvancedFilterModel(),s=(x=t==null?void 0:t.conditions)!=null&&x.length?t.conditions.map(y=>({...y})):[{colId:((b=this.grid.getColumns().center[0])==null?void 0:b.colId)??"",type:"contains",filter:""}];let n=(t==null?void 0:t.operator)||"AND";const{ePopup:o,close:a}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");o.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),o.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",o.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(y=>y.filter),h=()=>{d.innerHTML="",s.forEach((y,N)=>{const I=document.createElement("div");I.className="ag-advanced-filter-row";const D=document.createElement("select");D.className="ag-filter-condition";for(const A of c()){const O=document.createElement("option");O.value=A.colId,O.textContent=A.headerName||A.field||A.colId,A.colId===y.colId&&(O.selected=!0),D.appendChild(O)}D.addEventListener("change",()=>{s[N].colId=D.value}),I.appendChild(D);const _=this.grid.getColumn(y.colId),T=_&&_.filter!==!1?String(_.filter):"text",P=T==="number"?Pe:Ae,F=this.buildConditionSelect(P,y.type||"contains",A=>{s[N].type=A});I.appendChild(F);const S=document.createElement("input");S.type=T==="number"?"number":"text",S.className="ag-filter-input",S.value=y.filter??"",S.placeholder=this.grid.t("value"),S.addEventListener("input",()=>{s[N].filter=S.value}),I.appendChild(S);const L=document.createElement("button");L.className="ag-button ag-button-small",L.textContent="×",L.addEventListener("click",()=>{s.splice(N,1),h()}),I.appendChild(L),d.appendChild(I)})};h();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addCondition"),g.addEventListener("click",()=>{var y;s.push({colId:((y=c()[0])==null?void 0:y.colId)??"",type:"contains",filter:""}),h()}),o.appendChild(g);const u=document.createElement("div");u.className="ag-multi-filter-operator";const f=document.createElement("span");f.textContent=this.grid.t("join");const m=document.createElement("select");m.className="ag-filter-condition",m.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',m.value=n,m.addEventListener("change",()=>{n=m.value}),u.appendChild(f),u.appendChild(m),o.appendChild(u);const v=document.createElement("div");v.className="ag-popup-buttons";const C=document.createElement("button");C.className="ag-button ag-button-primary",C.textContent=this.grid.t("apply"),C.addEventListener("click",()=>{const y=s.filter(N=>N.filter!==void 0&&N.filter!=="");y.length?i.setAdvancedFilterModel({filterType:"advanced",operator:n,conditions:y}):i.setAdvancedFilterModel(null),a()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{i.setAdvancedFilterModel(null),a()}),v.appendChild(w),v.appendChild(C),o.appendChild(v),this.popupService.positionAt(o,e)}openCustomFilter(e,i){const t=e.colDef.filterComponent;if(typeof t!="function")return;const s=this.grid.getFilterService(),n=t({column:e,colDef:e.colDef,api:this.grid.getApi(),model:s.getFilterInstance(e.colId)??null,onModelChange:d=>s.setColumnFilterModel(e,d),onGuiAttached:()=>{}}),{ePopup:o,close:a}=this.popupService.createPopup(260,"ag-filter-popup");o.innerHTML="";const r=typeof(n==null?void 0:n.getGui)=="function"?n.getGui():n;r instanceof HTMLElement&&o.appendChild(r),typeof(n==null?void 0:n.afterGuiAttached)=="function"&&n.afterGuiAttached(),this.popupService.positionAt(o,i)}getDefaultModel(e){return e==="number"?{filterType:"number",type:"equals",filter:""}:e==="date"?{filterType:"date",dateFrom:"",dateTo:""}:e==="set"?{filterType:"set",values:[]}:e==="boolean"?{filterType:"boolean",filter:!0}:{filterType:"text",type:"contains",filter:""}}isMeaningful(e){return e.filterType==="text"?!!e.filter||e.type==="blank"||e.type==="notBlank":e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0:!1}}const Lt={copy:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 2h7v2h2v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-2H3V4a2 2 0 0 1 1-2zm1 2v8h1V4H5z"/></svg>',copyWithHeaders:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M2 1h12v2H2V1zm2 3h8v9H4V4z"/></svg>',paste:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M5 2h6v2H5V2zM3 4h10v10H3V4z"/></svg>',csv:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',excel:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',reset:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 2a6 6 0 1 0 5.7 4H11l3 3 3-3h-2.3A7 7 0 1 1 8 1v1z"/></svg>',pin:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M9 1l6 6-2 1-1 4-3-3-4 4v-3l3-3-1-3 4-1z"/></svg>'};class ts{constructor(e,i){this.grid=e,this.popupService=i}getDefaultItems(e){return[{name:"copy",label:this.grid.t("copy"),icon:"copy",shortcut:"Ctrl+C",action:()=>this.grid.getApi().copyToClipboard()},{name:"copyWithHeaders",label:this.grid.t("copyWithHeaders"),icon:"copyWithHeaders",action:()=>this.grid.getApi().copyToClipboard({includeHeaders:!0})},{name:"paste",label:this.grid.t("paste"),icon:"paste",shortcut:"Ctrl+V",action:()=>this.grid.getApi().pasteFromClipboard()},{name:"sep1",separator:!0},{name:"export",label:this.grid.t("export"),icon:"excel",subMenu:[{name:"csvExport",label:this.grid.t("csvExport"),icon:"csv",action:()=>this.grid.getApi().exportToCsv({fileName:"export.csv"})},{name:"excelExport",label:this.grid.t("excelExport"),icon:"excel",action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx"})},{name:"excelExportSelected",label:"Excel Export (Selected)",icon:"excel",disabled:!this.hasSelection(),action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx",onlySelected:!0})}]},{name:"sep2",separator:!0},{name:"resetColumns",label:this.grid.t("resetColumns"),icon:"reset",action:()=>this.grid.getColumnApi().resetColumnState()},{name:"autoSizeAll",label:"Auto-size All Columns",action:()=>this.grid.getColumnApi().autoSizeAllColumns()},{name:"sizeToFit",label:this.grid.t("sizeToFit"),action:()=>this.grid.getApi().sizeColumnsToFit()},{name:"sep3",separator:!0},{name:"expandAll",label:this.grid.t("expandAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().expandAll()},{name:"collapseAll",label:this.grid.t("collapseAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().collapseAll()},{name:"pinRow",label:this.grid.t("pinRow"),icon:"pin",disabled:!e.node||e.node.group===!0,subMenu:[{name:"pinTop",label:this.grid.t("pinToTop"),action:()=>this.grid.setRowNodePinned(e.node,"top")},{name:"pinBottom",label:this.grid.t("pinToBottom"),action:()=>this.grid.setRowNodePinned(e.node,"bottom")},{name:"unpin",label:this.grid.t("unpin"),action:()=>this.grid.setRowNodePinned(e.node,null)}]}]}hasSelection(){return this.grid.getApi().getSelectedNodes().length>0}isGroupActive(){return this.grid.getColumnModel().isRowGroupActive()}openContextMenu(e,i){if(this.grid.getOptions().suppressContextMenu)return;const t=this.grid.getOptions().contextMenuItems;let s;typeof t=="function"?s=t({column:i.column,node:i.node,api:this.grid.getApi()}):Array.isArray(t)?s=t:s=this.getDefaultItems(i);const{ePopup:n,close:o}=this.popupService.createPopup(220,"ag-context-menu");n.innerHTML="",this.buildMenu(n,s,o),this.popupService.positionAt(n,e)}buildMenu(e,i,t){for(const s of i){if(typeof s=="string")continue;if(s.separator){const r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);continue}const n=document.createElement("div");n.className="ag-menu-item",s.disabled&&n.classList.add("ag-menu-item-disabled"),s.cssClasses&&n.classList.add(...s.cssClasses);const o=document.createElement("span");o.className="ag-menu-item-icon",s.icon&&Lt[s.icon]&&(o.innerHTML=Lt[s.icon]),n.appendChild(o);const a=document.createElement("span");if(a.className="ag-menu-item-label",a.textContent=s.label??s.name,n.appendChild(a),s.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=s.shortcut,n.appendChild(r)}if(s.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",n.appendChild(r),n.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(h=>h.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,s.subMenu,t),e.appendChild(c)}),n.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;n.matches(":hover")||((c=n.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(h=>h.remove())},200)})}else!s.disabled&&s.action&&n.addEventListener("click",()=>{s.action(),t()});e.appendChild(n)}}}class is{constructor(e,i){this.grid=e,this.popupService=i}openColumnMenu(e,i){const{ePopup:t,close:s}=this.popupService.createPopup(220,"ag-column-menu");t.innerHTML="";const n=document.createElement("div");n.className="ag-popup-title",n.textContent=e.headerName||e.field||e.colId,t.appendChild(n);const o=(r,d)=>{const c=document.createElement("div");c.className="ag-menu-item",d.disabled&&c.classList.add("ag-menu-item-disabled"),d.checked&&c.classList.add("ag-menu-item-active");const h=document.createElement("span");h.className="ag-menu-item-check",d.checked&&(h.innerHTML=Nt),c.appendChild(h);const g=document.createElement("span");if(g.className="ag-menu-item-label",g.textContent=r,c.appendChild(g),d.shortcut){const u=document.createElement("span");u.className="ag-menu-item-shortcut",u.textContent=d.shortcut,c.appendChild(u)}return!d.disabled&&d.onClick&&c.addEventListener("click",()=>{d.onClick(),s()}),t.appendChild(c),c},a=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,t.appendChild(d)};e.sortable&&(a(this.grid.t("sort")),o(this.grid.t("sortAscending"),{checked:e.sort==="asc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"asc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}}),o(this.grid.t("sortDescending"),{checked:e.sort==="desc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"desc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}})),e.resizable&&(a(this.grid.t("columnSize")),o(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),o(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(a(this.grid.t("pinColumn")),o(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),o(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),o(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(a(this.grid.t("filter")),o(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,i)}),e.filter!=="multi"&&o(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,i)}),this.grid.getOptions().enableAdvancedFilter&&o(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(i)}),o(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(a(this.grid.t("filter")),o(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(i)})),a(this.grid.t("formula")),o(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,i)}),a(this.grid.t("visibility")),o(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),o(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(t,i)}}class ss{constructor(e,i){p(this,"eBar");p(this,"panels",[]);this.grid=e,this.eventService=i,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const s=e.getOptions().statusBar;(!s||!s.statusPanels||s.statusPanels.length===0)&&(this.eBar.style.display="none");const n=((s==null?void 0:s.statusPanels)||[]).map(o=>typeof o=="string"?{key:o,label:o}:{key:o.key||o.statusPanel,label:o.key||o.statusPanel,align:o.align});for(const o of n){const a=document.createElement("div");a.className=`ag-status-panel ag-status-panel-${o.align||"left"}`,this.eBar.appendChild(a);const r={def:o,ePanel:a,render:()=>this.renderPanel(o.key,a)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,i){const t=this.grid.getApi(),s=this.grid.getRowModel().getRowCount(),n=this.grid.getRowModel(),o=typeof n.getTotalRowCount=="function"&&n.getType()!=="clientSide"?n.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,a=t.getSelectedNodes().length,r=[],d=this.grid.getColumnModel().getValueColumns().filter(c=>c.aggFunc);switch(this.grid.getRowModel().forEachNode(c=>{!c.footer&&c.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${ae(o)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${ae(s)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${ae(s)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${ae(a)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=t.getSelectedNodes().filter(g=>!g.group&&!g.footer),h=[];for(const g of d){const f=c.map(w=>H(g,w,t)).filter(w=>typeof w=="number"&&!isNaN(w)),m=f.reduce((w,x)=>w+x,0),v=w=>w===null?"":ae(w,g.decimals),C=[[this.grid.translate("average","Average"),f.length?m/f.length:null],[this.grid.translate("count","Count"),f.length],[this.grid.translate("min","Min"),f.length?Math.min(...f):null],[this.grid.translate("max","Max"),f.length?Math.max(...f):null],[this.grid.translate("sum","Sum"),f.length?m:null]];for(const[w,x]of C)h.push(`${w}${g.headerName?` (${g.headerName})`:""} : ${v(x)}`)}h.length&&r.push(h.join(" "));break}default:r.push(e);break}i.textContent=r.join(" "),i.style.display=r.length?"":"none"}}class ns{constructor(e){p(this,"eBar");p(this,"eButtons");p(this,"ePanel");p(this,"panels",[]);p(this,"activePanelId",null);p(this,"visible",!1);p(this,"position");var t,s;this.grid=e;const i=e.getOptions();if(this.position=typeof i.sideBar=="object"&&((t=i.sideBar)!=null&&t.position)?i.sideBar.position:"right",this.eBar=document.createElement("div"),this.eBar.className=`ag-side-bar ag-side-bar-${this.position}`,this.eButtons=document.createElement("div"),this.eButtons.className="ag-side-buttons",this.ePanel=document.createElement("div"),this.ePanel.className="ag-side-bar-panel",this.eBar.appendChild(this.eButtons),this.eBar.appendChild(this.ePanel),i.sideBar){const n=typeof i.sideBar=="object"?i.sideBar:null;n!=null&&n.toolPanels?this.panels=n.toolPanels.map(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:"Columns"},{id:"filters",label:"Filters"}],i.enableCharts&&this.panels.push({id:"charts",label:"Charts"}));const o=(n==null?void 0:n.hiddenByDefault)===!0;this.visible=!o,this.eBar.style.display=this.visible?"":"none";const a=(n==null?void 0:n.defaultToolPanel)||((s=this.panels[0])==null?void 0:s.id)||"columns";this.buildButtons(),this.openPanel(a)}else this.eBar.style.display="none"}defaultLabel(e){switch(e){case"columns":return this.grid.t("columns");case"filters":return this.grid.t("filters");case"charts":return this.grid.t("charts");default:return e}}buildButtons(){this.eButtons.innerHTML="";for(const e of this.panels){const i=document.createElement("button");i.className="ag-side-button",i.textContent=e.label,i.title=e.label,i.dataset.panelId=e.id,e.id===this.activePanelId&&i.classList.add("ag-selected"),i.addEventListener("click",()=>{this.activePanelId===e.id&&this.visible?this.setVisible(!1):(this.visible=!0,this.eBar.style.display="",this.openPanel(e.id)),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"sideBarButtonClicked",api:this.grid.getApi()})}),this.eButtons.appendChild(i)}}getElement(){return this.eBar}setPosition(e){this.position=e,this.eBar.classList.remove("ag-side-bar-left","ag-side-bar-right"),this.eBar.classList.add(`ag-side-bar-${e}`)}setVisible(e){this.visible=e,this.eBar.style.display=e?"":"none",this.grid.onGridSizeChanged(),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"api",api:this.grid.getApi()})}isVisible(){return this.visible}openPanel(e){this.activePanelId=e;for(const i of this.eButtons.querySelectorAll(".ag-side-button"))i.classList.toggle("ag-selected",i.dataset.panelId===e);switch(this.ePanel.innerHTML="",e){case"columns":this.ePanel.appendChild(this.buildColumnsPanel());break;case"filters":this.ePanel.appendChild(this.buildFiltersPanel());break;case"charts":this.ePanel.appendChild(this.grid.getChartService().buildChartPanel());break;default:{const i=document.createElement("div");i.className="ag-side-bar-empty",i.textContent=e,this.ePanel.appendChild(i)}}}getActivePanel(){return this.activePanelId}refresh(){this.activePanelId&&this.openPanel(this.activePanelId)}buildColumnsPanel(){const e=document.createElement("div");e.className="ag-column-panel";const i=document.createElement("input");i.type="text",i.className="ag-column-panel-search",i.placeholder=this.grid.t("searchColumns"),e.appendChild(i);const t=document.createElement("div");t.className="ag-column-panel-columns",e.appendChild(t);const s=()=>{const d=i.value.toLowerCase();t.innerHTML="";const c=this.grid.getColumnModel().getColumns(),h=c.filter(g=>g.pinned!=="left"&&g.pinned!=="right").concat(c.filter(g=>g.pinned==="left"||g.pinned==="right"));for(const g of h)d&&!g.headerName.toLowerCase().includes(d)&&!g.colId.toLowerCase().includes(d)||t.appendChild(this.buildColumnItem(g));if(!t.children.length){const g=document.createElement("div");g.className="ag-side-bar-empty",g.textContent=this.grid.t("noMatchingColumns"),t.appendChild(g)}};i.addEventListener("input",s),s();const n=document.createElement("div");n.className="ag-column-panel-groups";const o=document.createElement("div");o.className="ag-column-panel-section-title",o.textContent=this.grid.t("rowGroups"),n.appendChild(o);const a=document.createElement("div");a.className="ag-column-group-list",n.appendChild(a);const r=()=>{a.innerHTML="";const d=this.grid.getColumnModel().getRowGroupColumns();if(d.length===0){const c=document.createElement("div");c.className="ag-column-group-hint",c.textContent=this.grid.t("dragColumnsHere"),a.appendChild(c)}for(const c of d){const h=document.createElement("div");h.className="ag-column-group-item",h.draggable=!0,h.addEventListener("dragstart",f=>{var m;(m=f.dataTransfer)==null||m.setData("text/plain",c.colId)}),h.addEventListener("dragover",f=>f.preventDefault()),h.addEventListener("drop",f=>{var v;f.preventDefault();const m=(v=f.dataTransfer)==null?void 0:v.getData("text/plain");m&&this.grid.getColumnModel().setRowGroupColumns([...d.map(C=>C.colId),m])});const g=document.createElement("span");g.textContent=c.headerName,h.appendChild(g);const u=document.createElement("button");u.className="ag-column-group-remove",u.textContent="×",u.title=this.grid.t("remove"),u.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(c)),h.appendChild(u),a.appendChild(h)}};return r(),a.addEventListener("dragover",d=>d.preventDefault()),a.addEventListener("drop",d=>{var h;d.preventDefault();const c=(h=d.dataTransfer)==null?void 0:h.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(n),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&s()}),e}buildColumnItem(e){const i=document.createElement("div");i.className="ag-column-select-column",i.draggable=!0,i.dataset.colid=e.colId;const t=document.createElement("input");t.type="checkbox",t.className="ag-column-select-checkbox",t.checked=e.visible,t.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,t.checked)}),i.appendChild(t);const s=document.createElement("span");s.className="ag-column-select-label",s.textContent=e.headerName||e.colId,i.appendChild(s);const n=document.createElement("span");if(n.className="ag-column-select-actions",e.enableRowGroup&&e.field){const a=document.createElement("button");a.className="ag-column-select-action",a.title=this.grid.t("groupByThisColumn"),a.textContent="≡",a.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),n.appendChild(a)}const o=document.createElement("button");return o.className="ag-column-select-action",o.title=this.grid.t("pinColumnTitle"),o.textContent="📌",o.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),n.appendChild(o),i.appendChild(n),i}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const n=document.createElement("button");n.className="ag-button ag-button-small",n.textContent="Advanced Filter…",n.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(n)),e.appendChild(n);const o=this.grid.getFilterService().getAdvancedFilterModel();if(o){const a=document.createElement("span");a.className="ag-filters-tool-panel-item-badge",a.textContent=`${o.conditions.length} condition${o.conditions.length===1?"":"s"}`,e.appendChild(a)}}const i=document.createElement("input");i.type="text",i.className="ag-column-panel-search",i.placeholder=this.grid.t("searchColumns"),e.appendChild(i);const t=document.createElement("div");t.className="ag-filters-panel-list",e.appendChild(t);const s=()=>{const n=i.value.toLowerCase();t.innerHTML="";const o=this.grid.getColumns().center.filter(a=>a.filter);for(const a of o)n&&!a.headerName.toLowerCase().includes(n)||t.appendChild(this.buildFilterItem(a));if(!t.children.length){const a=document.createElement("div");a.className="ag-side-bar-empty",a.textContent=this.grid.t("noMatchingColumns"),t.appendChild(a)}};return i.addEventListener("input",s),s(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&s()}),e}buildFilterItem(e){const i=this.grid.getFilterService(),t=document.createElement("div");t.className="ag-filters-tool-panel-item";const s=document.createElement("div");s.className="ag-filters-tool-panel-item-header";const n=document.createElement("span");n.className="ag-filters-tool-panel-item-label",n.textContent=e.headerName||e.colId,s.appendChild(n);const o=i.isFilterActive(e);if(o){const a=document.createElement("span");a.className="ag-filters-tool-panel-item-badge",a.innerHTML=Nt,s.appendChild(a)}if(t.appendChild(s),e.filter==="set"){const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent=o?"Edit filter":"Add filter",a.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,a)),t.appendChild(a)}else if(e.filter==="date"){const a=document.createElement("input");a.type="date",a.className="ag-filter-input";const r=i.getFilterInstance(e.colId);a.value=(r==null?void 0:r.dateFrom)??"",a.addEventListener("change",()=>{i.setColumnFilterModel(e,a.value?{filterType:"date",dateFrom:a.value,dateTo:a.value}:null)}),t.appendChild(a)}else{const a=document.createElement("input");a.type=e.filter==="number"?"number":"text",a.className="ag-filter-input",a.placeholder="Filter...";const r=i.getFilterInstance(e.colId);a.value=(r==null?void 0:r.filter)??"",a.addEventListener("input",()=>{i.handleFloatingFilterChange(e,a.value)}),t.appendChild(a)}if(o){const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="Clear",a.addEventListener("click",()=>i.setColumnFilterModel(e,null)),t.appendChild(a)}return t}}class os{constructor(e,i){p(this,"matches",[]);p(this,"activeMatch",0);p(this,"searchText","");p(this,"matchCase",!1);p(this,"ePopup",null);p(this,"eCount",null);p(this,"eInput",null);p(this,"closePopup",null);this.grid=e,this.popupService=i}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:i}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=i,e.innerHTML="";const t=document.createElement("input");t.type="text",t.className="ag-find-input",t.placeholder=this.grid.translate("find","Find in grid..."),t.value=this.searchText,this.eInput=t,e.appendChild(t);const s=document.createElement("label");s.className="ag-find-case";const n=document.createElement("input");n.type="checkbox",n.checked=this.matchCase,n.addEventListener("change",()=>{this.matchCase=n.checked,this.find(this.searchText)}),s.appendChild(n),s.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(s);const o=document.createElement("span");o.className="ag-find-count",this.eCount=o,e.appendChild(o);const a=(c,h,g)=>{const u=document.createElement("button");return u.className="ag-button ag-button-small",u.textContent=c,u.title=h,u.addEventListener("click",g),e.appendChild(u),u};a("‹","Previous match",()=>this.findPrevious()),a("›","Next match",()=>this.findNext()),a("×","Close",()=>this.close()),t.addEventListener("input",()=>this.find(t.value)),t.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),c.shiftKey?this.findPrevious():this.findNext()):c.key==="Escape"&&this.close()}),this.grid.getRootElement(),e.style.position="absolute",e.style.left="50%",e.style.top="8px",e.style.transform="translateX(-50%)",e.style.display="flex",setTimeout(()=>t.focus(),0)}close(){var e;(e=this.closePopup)==null||e.call(this),this.ePopup=null,this.closePopup=null,this.eInput=null,this.eCount=null,this.matches=[],this.applyHighlight()}setFindText(e){this.searchText=e,this.eInput&&(this.eInput.value=e),this.find(e)}getFindText(){return this.searchText}getNumMatches(){return this.matches.length}getActiveMatch(){return this.activeMatch}find(e){if(this.searchText=e,this.matches=[],this.activeMatch=0,e){const i=this.grid.getColumns().center;this.grid.getRowModel().forEachNode((t,s)=>{if(!(t.group||t.footer))for(const n of i){H(n,t,this.grid.getApi());const o=Ve(n,t,this.grid.getApi())??"",a=this.matchCase?o:o.toLowerCase(),r=this.matchCase?e:e.toLowerCase();a.includes(r)&&this.matches.push({rowIndex:s,colId:n.colId})}})}this.eCount&&(this.eCount.textContent=this.matches.length?`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`:this.grid.translate("noMatches","No matches")),this.applyHighlight()}findNext(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch+1)%this.matches.length,this.goToActive(),!0)}findPrevious(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch-1+this.matches.length)%this.matches.length,this.goToActive(),!0)}goToActive(){var n,o;const e=this.matches[this.activeMatch];if(!e)return;this.eCount&&(this.eCount.textContent=`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`);const i=(o=(n=this.grid).getPaginationService)==null?void 0:o.call(n);if(i!=null&&i.isEnabled()){const a=i.getPageSize(),r=Math.floor(e.rowIndex/a);r!==i.getCurrentPage()&&i.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const t=this.grid.getDisplayedRowAtIndex(e.rowIndex),s=this.grid.getColumn(e.colId);t&&s&&this.grid.getEditService().setFocusedCell(e.rowIndex,s)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[i,t]of e){let s=-1;this.grid.getRowModel().forEachNode((n,o)=>{n.id===i&&(s=o)});for(const n of t.getCellElements()){const o=n.dataset.colid,a=this.matches.findIndex(r=>r.rowIndex===s&&r.colId===o);n.classList.toggle("ag-find-match",a>=0),n.classList.toggle("ag-find-active-match",a>=0&&a===this.activeMatch)}}}}class ls{constructor(e,i){p(this,"ranges",[]);p(this,"currentRange",null);p(this,"eOverlay");p(this,"eHandle");p(this,"dragState",null);this.grid=e,this.eventService=i;const t=e.getRowRenderer().getContainer();t.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",t.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",t.appendChild(this.eHandle),document.addEventListener("mousemove",this.onMouseMove.bind(this)),document.addEventListener("mouseup",this.onMouseUp.bind(this)),i.addEventListener("bodyScroll",()=>this.updateOverlay())}isEnabled(){return!!this.grid.getOptions().enableRangeSelection}getRanges(){return this.ranges}clearRanges(){this.ranges=[],this.currentRange=null,this.updateOverlay(),this.applyHighlight(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0})}onCellMouseDown(e){if(!this.isEnabled())return;const{event:i,column:t,rowIndex:s}=e;if(i.button!==0)return;if(i.shiftKey&&this.ranges.length>0){const o=this.ranges[this.ranges.length-1];this.currentRange={...o,rowEndIndex:s,colEndId:t.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const n={rowStartIndex:s,rowEndIndex:s,colStartId:t.colId,colEndId:t.colId};this.currentRange=n,this.dragState={startRange:n,mode:"create"},this.updateOverlay()}onHandleMouseDown(e){this.currentRange&&(e.stopPropagation(),this.dragState={startRange:{...this.currentRange},mode:"handle"})}onMouseMove(e){if(!this.dragState||!this.currentRange)return;const i=document.elementFromPoint(e.clientX,e.clientY);if(!i)return;const t=i.closest(".ag-cell");if(!(t!=null&&t.dataset.colid))return;const s=t.closest(".ag-row");if(!(s!=null&&s.dataset.rowid))return;const n=this.grid.getRowModel().getRowNode(s.dataset.rowid);if(!n)return;let o=-1;if(this.grid.getRowModel().forEachNode((r,d)=>{r.id===n.id&&(o=d)}),o<0)return;const a=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(a.rowStartIndex,o),rowEndIndex:Math.max(a.rowStartIndex,o),colStartId:a.colStartId,colEndId:t.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(a.rowStartIndex,o),this.currentRange.colEndId=t.dataset.colid),this.updateOverlay()}onMouseUp(){!this.dragState||!this.currentRange||(this.dragState=null,this.ranges=[this.currentRange],this.applyHighlight(),this.updateOverlay(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0}))}getCenterColumns(){return this.grid.getColumns().center}getRangeBounds(e){const i=this.getCenterColumns(),t=i.findIndex(m=>m.colId===e.colStartId),s=i.findIndex(m=>m.colId===e.colEndId);if(t<0||s<0)return null;const n=Math.min(t,s),o=Math.max(t,s);let a=0,r=0;for(let m=0;m<=o;m++)m<n?a+=i[m].width:r+=i[m].width;const c=this.grid.getRowRenderer().getRowOffsets(),h=Math.min(e.rowStartIndex,e.rowEndIndex),g=Math.max(e.rowStartIndex,e.rowEndIndex),u=c[h]??h*(this.grid.getOptions().rowHeight??42);let f=0;for(let m=h;m<=g;m++){const v=this.grid.getDisplayedRowAtIndex(m);f+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:u,left:a,width:r,height:f}}updateOverlay(){const e=this.currentRange;if(!e||!this.isEnabled()){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}const i=this.getRangeBounds(e);if(!i){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}this.eOverlay.style.display="block",this.eOverlay.style.top=`${i.top}px`,this.eOverlay.style.left=`${i.left}px`,this.eOverlay.style.width=`${i.width}px`,this.eOverlay.style.height=`${i.height}px`,this.eHandle.style.display="block",this.eHandle.style.top=`${i.top+i.height-4}px`,this.eHandle.style.left=`${i.left+i.width-4}px`,this.eHandle.onmousedown=t=>this.onHandleMouseDown(t)}applyHighlight(){const e=this.ranges,i=this.grid.getRowRenderer().getRowComps(),t=this.getCenterColumns();for(const[s,n]of i){let o=-1;if(this.grid.getRowModel().forEachNode((a,r)=>{a.id===s&&(o=r)}),!(o<0))for(const a of n.getCellElements()){const r=a.dataset.colid,d=t.findIndex(g=>g.colId===r);let c=!1,h=!1;for(const g of e){const u=t.findIndex(x=>x.colId===g.colStartId),f=t.findIndex(x=>x.colId===g.colEndId),m=Math.min(g.rowStartIndex,g.rowEndIndex),v=Math.max(g.rowStartIndex,g.rowEndIndex),C=Math.min(u,f),w=Math.max(u,f);o>=m&&o<=v&&d>=C&&d<=w&&(c=!0,o===g.rowStartIndex&&d===u&&(h=!0))}a.classList.toggle("ag-cell-range-selected",c),a.classList.toggle("ag-cell-range-anchor",h)}}}getRangeCells(e){const i=this.getCenterColumns(),t=i.findIndex(c=>c.colId===e.colStartId),s=i.findIndex(c=>c.colId===e.colEndId),n=Math.min(e.rowStartIndex,e.rowEndIndex),o=Math.max(e.rowStartIndex,e.rowEndIndex),a=Math.min(t,s),r=Math.max(t,s),d=[];for(let c=n;c<=o;c++){const h=this.grid.getDisplayedRowAtIndex(c);if(h)for(let g=a;g<=r;g++)i[g]&&d.push({node:h,column:i[g]})}return d}getCurrentRange(){return this.currentRange}onGridKeyDown(e){if(this.isEnabled()){if((e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().copyToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="x"||e.key==="X")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().cutToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().pasteFromClipboard());return}if((e.keyCode===gt||e.keyCode===pt)&&this.ranges.length){e.preventDefault();for(const i of this.ranges)for(const t of this.getRangeCells(i))this.grid.setCellValue(t.column,t.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}function Dt(l){return String(l).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const me=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class rs{constructor(e,i){p(this,"charts",new Map);p(this,"chartCounter",0);p(this,"currentType","line");p(this,"timeSeries",!1);this.grid=e,this.popupService=i}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const i=this.grid.getColumnModel(),t=i.getRowGroupColumns();let s=e.categoryColumn;const n=e.valueColumns&&e.valueColumns.length?e.valueColumns:i.getValueColumns().filter(r=>r.aggFunc),o=[],a=n.map(()=>[]);if(t.length>0)((d,c)=>{for(const h of d)if(h.group){const g=t[0]?String(H(t[0],h,this.grid.getApi())??""):h.key??"";o.push(g);for(let u=0;u<n.length;u++){const f=[];Ft(h,n[u],f),a[u].push(Number(Fe(n[u],n[u].aggFunc,f))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(s||(s=this.grid.getColumns().center.find(r=>r.field&&r.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(r=>{if(r.group||r.footer)return;const d=s?H(s,r,this.grid.getApi()):"";o.push(String(d??""));for(let c=0;c<n.length;c++){const h=H(n[c],r,this.grid.getApi());a[c].push(typeof h=="number"?h:Number(h)||0)}}),o.length>200){const r=Math.ceil(o.length/200),d=[],c=a.map(()=>[]);for(let h=0;h<o.length;h+=r){d.push(o[h]);for(let g=0;g<a.length;g++)c[g].push(a[g][h])}return{categories:d,series:n.map((h,g)=>({title:h.headerName,data:c[g]}))}}return{categories:o,series:n.map((r,d)=>({title:r.headerName,data:a[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const i=document.createElement("div");i.className="ag-side-bar-section-title",i.textContent="Integrated Charts",e.appendChild(i);const t=document.createElement("div");t.className="ag-chart-panel-label",t.textContent="Chart Type",e.appendChild(t);const s=document.createElement("select");s.className="ag-chart-panel-select";const n=[{value:"line",label:"Line"},{value:"area",label:"Area"},{value:"column",label:"Column"},{value:"bar",label:"Bar"},{value:"pie",label:"Pie"},{value:"scatter",label:"Scatter"}];for(const v of n){const C=document.createElement("option");C.value=v.value,C.textContent=v.label,v.value===this.currentType&&(C.selected=!0),s.appendChild(C)}s.addEventListener("change",()=>{this.currentType=s.value}),e.appendChild(s);const o=document.createElement("div");o.className="ag-chart-panel-label",o.textContent="Category",e.appendChild(o);const a=document.createElement("select");a.className="ag-chart-panel-select";const r=this.grid.getColumnModel().getRowGroupColumns(),d=r.length>0?r:this.grid.getColumns().center.filter(v=>v.field);for(const v of d){const C=document.createElement("option");C.value=v.colId,C.textContent=r.length>0?`Group: ${v.headerName}`:v.headerName,a.appendChild(C)}e.appendChild(a);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent="Series",e.appendChild(c);const h=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),g=document.createElement("div");g.className="ag-chart-panel-series";const u=new Set(h.slice(0,3).map(v=>v.colId));for(const v of this.grid.getColumns().center.filter(C=>C.field)){const C=document.createElement("label");C.className="ag-chart-panel-series-item";const w=document.createElement("input");w.type="checkbox",w.checked=u.has(v.colId),w.addEventListener("change",()=>{w.checked?u.add(v.colId):u.delete(v.colId)}),C.appendChild(w);const x=document.createElement("span");x.textContent=v.headerName,C.appendChild(x),g.appendChild(C)}e.appendChild(g);const f=document.createElement("button");f.className="ag-button ag-button-primary ag-chart-panel-create",f.textContent="Create Chart",f.addEventListener("click",()=>{const v=this.grid.getColumn(a.value)||void 0,C=[...u].map(w=>this.grid.getColumn(w)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:C})}),e.appendChild(f);const m=document.createElement("div");if(m.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent="No charts created",m.appendChild(v)}for(const[v,C]of this.charts){const w=document.createElement("div");w.className="ag-chart-panel-list-item";const x=document.createElement("span");x.textContent=C.title,w.appendChild(x);const b=document.createElement("button");b.className="ag-column-group-remove",b.textContent="×",b.addEventListener("click",()=>this.destroyChart(v)),w.appendChild(b),m.appendChild(w)}return e.appendChild(m),e}createChart(e={}){var v,C,w,x;const i=e.type||this.currentType,t=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),s=`chart-${++this.chartCounter}`,n=e.title||`${i.charAt(0).toUpperCase()+i.slice(1)} Chart`,{ePopup:o}=this.popupService.createPopup(640,"ag-chart-window");o.innerHTML="";const a=document.createElement("div");a.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=n,a.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent="Download PNG",a.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title="Close",c.addEventListener("click",()=>this.destroyChart(s)),a.appendChild(c),o.appendChild(a);const h=document.createElement("div");h.className="ag-chart-window-body";const g=document.createElement("canvas");g.className="ag-chart-canvas",g.width=600,g.height=360,h.appendChild(g);const u=document.createElement("div");u.className="ag-chart-tooltip",u.style.display="none",h.appendChild(u),g.addEventListener("mousemove",b=>this.onChartHover({id:s,ePopup:o,canvas:g,type:i,data:t,title:n},b,u)),g.addEventListener("mouseleave",()=>{u.style.display="none"});const f=document.createElement("div");f.className="ag-chart-legend",h.appendChild(f),o.appendChild(h),this.timeSeries=t.categories.length>0&&t.categories.every(b=>!isNaN(Date.parse(String(b)))&&isNaN(Number(b)));const m={id:s,ePopup:o,canvas:g,type:i,data:t,title:n};return this.charts.set(s,m),d.addEventListener("click",()=>{const b=g.toDataURL("image/png"),y=document.createElement("a");y.href=b,y.download=`${n.replace(/\s+/g,"-").toLowerCase()}.png`,y.click()}),this.popupService.positionAt(o,this.grid.getRootElement()),o.style.top="60px",this.renderChart(m),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:s,chartTitle:n,api:this.grid.getApi()}),(C=(v=this.grid.getOptions()).onChartCreated)==null||C.call(v,{chartId:s,chartTitle:n,api:this.grid.getApi()}),((w=this.grid.getSideBarService())==null?void 0:w.getActivePanel())==="charts"&&((x=this.grid.getSideBarService())==null||x.refresh()),s}destroyChart(e){var t,s,n,o;const i=this.charts.get(e);i&&(i.ePopup.remove(),this.charts.delete(e),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartDestroyed",{chartId:e,api:this.grid.getApi()}),(s=(t=this.grid.getOptions()).onChartDestroyed)==null||s.call(t,{chartId:e,api:this.grid.getApi()}),((n=this.grid.getSideBarService())==null?void 0:n.getActivePanel())==="charts"&&((o=this.grid.getSideBarService())==null||o.refresh()))}getChartModels(){return[...this.charts.values()].map(e=>({chartId:e.id,chartType:e.type,title:e.title}))}refreshCharts(){for(const e of this.charts.values())e.data=this.getChartData(),this.renderChart(e)}onChartHover(e,i,t){const n=e.canvas.getBoundingClientRect(),o=600/(n.width||1),a=360/(n.height||1),r=(i.clientX-n.left)*o,d=(i.clientY-n.top)*a,c={top:20,right:20,bottom:34,left:56},h=600-c.left-c.right,g=360-c.top-c.bottom;if(r<c.left||r>c.left+h||d<c.top||d>c.top+g){t.style.display="none";return}if(e.type==="pie"){t.style.display="none";return}const u=e.type==="bar",f=Math.max(1,e.data.categories.length),m=(u?g:h)/f,v=Math.floor((u?d-c.top:r-c.left)/m);if(v<0||v>=e.data.categories.length){t.style.display="none";return}const C=e.data.series.map(w=>`${w.title}: ${this.formatTick(w.data[v]??0)}`);t.innerHTML=`<div class="ag-chart-tooltip-title">${Dt(e.data.categories[v])}</div>`+C.map(w=>`<div>${Dt(w)}</div>`).join(""),t.style.display="block",t.style.left=`${i.clientX-n.left+12}px`,t.style.top=`${i.clientY-n.top+12}px`}storageKey(){const i=this.grid.getOptions().chartStorageKey;return i?`rowvia-charts:${i}`:null}saveCharts(){const e=this.storageKey();if(!e)return;const i=[...this.charts.values()].map(t=>({id:t.id,type:t.type,title:t.title,data:t.data}));try{localStorage.setItem(e,JSON.stringify(i))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let i=[];try{const t=localStorage.getItem(e);t&&(i=JSON.parse(t))}catch{return}for(const t of i)this.restoreChart(t)}restoreChart(e){const i=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(i))return;const{ePopup:t}=this.popupService.createPopup(640,"ag-chart-window");t.innerHTML="";const s=document.createElement("div");s.className="ag-chart-window-header";const n=document.createElement("span");n.className="ag-chart-window-title",n.textContent=e.title||"Chart",s.appendChild(n);const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent="×",o.addEventListener("click",()=>this.destroyChart(i)),s.appendChild(o),t.appendChild(s);const a=document.createElement("div");a.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,a.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",a.appendChild(d),t.appendChild(a);const c={id:i,ePopup:t,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(i,c),this.popupService.positionAt(t,this.grid.getRootElement()),t.style.top="60px",this.renderChart(c)}renderChart(e){var _;const i=e.canvas,t=i.getContext("2d");if(!t)return;const s=window.devicePixelRatio||1,n=i.width,o=i.height;i.width=n*s,i.height=o*s,i.style.width=`${n}px`,i.style.height=`${o}px`,t.scale(s,s),t.clearRect(0,0,n,o);const a=getComputedStyle(this.grid.getRootElement()),r=a.getPropertyValue("--ag-chart-text-color")||"#666",d=a.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},h=n-c.left-c.right,g=o-c.top-c.bottom;t.font="11px sans-serif",t.fillStyle=r,t.strokeStyle=d,t.lineWidth=1;const u=(_=e.canvas.parentElement)==null?void 0:_.querySelector(".ag-chart-legend");if(u&&(u.innerHTML="",e.data.series.forEach((T,P)=>{const F=document.createElement("span");F.className="ag-chart-legend-item";const S=document.createElement("span");S.className="ag-chart-legend-swatch",S.style.backgroundColor=me[P%me.length],F.appendChild(S),F.appendChild(document.createTextNode(T.title)),u.appendChild(F)})),e.type==="pie"){this.renderPie(t,e.data,n,o,r);return}const f=e.data.series.flatMap(T=>T.data);let m=Math.max(0,...f),v=Math.min(0,...f);e.type==="scatter"&&(v=Math.min(...f),m=Math.max(...f));const C=m-v||1;m+=C*.08,v-=v<0?C*.08:0;const w=m-v||1,x=T=>c.top+g-(T-v)/w*g,b=5;t.textAlign="right",t.textBaseline="middle";for(let T=0;T<=b;T++){const P=v+w*T/b,F=x(P);t.beginPath(),t.moveTo(c.left,F),t.lineTo(n-c.right,F),t.stroke(),t.fillText(this.formatTick(P),c.left-6,F)}const y=e.data.categories,N=e.type==="bar",I=Math.max(1,y.length),D=(N?g:h)/I;if(N){t.textAlign="left",y.forEach((P,F)=>{const S=c.top+F*D,L=Math.max(2,D*.7/e.data.series.length);e.data.series.forEach((A,O)=>{const V=A.data[F]||0,X=Math.abs(V)/w*h,B=c.left+(0-v)/w*h;t.fillStyle=me[O%me.length],t.fillRect(B,S+O*L,Math.max(1,X),L-1)}),t.fillStyle=r,t.fillText(this.truncate(P,18),c.left+4,S+D/2)});const T=c.left+(0-v)/w*h;t.beginPath(),t.moveTo(T,c.top),t.lineTo(T,c.top+g),t.strokeStyle=r,t.stroke()}else{const T=Math.max(1,Math.ceil(I/12));t.textAlign="center",t.textBaseline="top",y.forEach((S,L)=>{if(L%T!==0)return;const A=c.left+D*(L+.5);t.fillStyle=r,t.fillText(this.truncate(S,10),A,c.top+g+6)});const P=e.data.series.length,F=Math.max(1,D*.7/Math.max(1,P));e.data.series.forEach((S,L)=>{const A=me[L%me.length];if(e.type==="column")t.fillStyle=A,S.data.forEach((O,V)=>{const X=c.left+D*V+(D-F*P)/2+L*F,B=x(O);t.fillRect(X,B,F-1,c.top+g-B)});else if(e.type==="area"){t.beginPath(),S.data.forEach((V,X)=>{const B=c.left+D*(X+.5),ee=x(V);X===0?t.moveTo(B,ee):t.lineTo(B,ee)});const O=c.left+D*(S.data.length-.5);t.lineTo(O,c.top+g),t.lineTo(c.left+D*.5,c.top+g),t.closePath(),t.globalAlpha=.25,t.fillStyle=A,t.fill(),t.globalAlpha=1,t.beginPath(),S.data.forEach((V,X)=>{const B=c.left+D*(X+.5),ee=x(V);X===0?t.moveTo(B,ee):t.lineTo(B,ee)}),t.strokeStyle=A,t.lineWidth=2,t.stroke()}else e.type==="scatter"?(t.fillStyle=A,S.data.forEach((O,V)=>{const X=c.left+D*(V+.5),B=x(O);t.beginPath(),t.arc(X,B,3,0,Math.PI*2),t.fill()})):(t.beginPath(),S.data.forEach((O,V)=>{const X=c.left+D*(V+.5),B=x(O);V===0?t.moveTo(X,B):t.lineTo(X,B)}),t.strokeStyle=A,t.lineWidth=2,t.stroke())})}}renderPie(e,i,t,s,n){const o=i.series[0];if(!o)return;const a=o.data.reduce((g,u)=>g+Math.abs(u),0)||1,r=t/2,d=s/2,c=Math.min(t,s)/2-30;let h=-Math.PI/2;o.data.forEach((g,u)=>{const f=Math.abs(g)/a*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,h,h+f),e.closePath(),e.fillStyle=me[u%me.length],e.fill();const m=h+f/2,v=r+Math.cos(m)*(c*.7),C=d+Math.sin(m)*(c*.7),w=Math.round(Math.abs(g)/a*100);w>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${w}%`,v,C)),h+=f}),e.fillStyle=n}formatTick(e){if(this.timeSeries){const t=new Date(e);if(!isNaN(t.getTime()))return t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}const i=Math.abs(e);return i>=1e9?`${(e/1e9).toFixed(1)}B`:i>=1e6?`${(e/1e6).toFixed(1)}M`:i>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(1)}truncate(e,i){return e.length>i?`${e.slice(0,i-1)}…`:e}}function Ft(l,e,i){const t=l.children;if(!t||t.length===0){const s=H(e,l,null);typeof s=="number"&&!isNaN(s)&&i.push(s);return}for(const s of t)Ft(s,e,i)}class as{constructor(e){p(this,"eOverlayWrapper");p(this,"current",null);this.grid=e,this.eOverlayWrapper=document.createElement("div"),this.eOverlayWrapper.className="ag-overlay",this.eOverlayWrapper.style.display="none";const i=e.getRowRenderer().getViewport();i.style.position="relative",this.eOverlayWrapper.style.position="absolute",this.eOverlayWrapper.style.inset="0",this.eOverlayWrapper.style.zIndex="10",i.appendChild(this.eOverlayWrapper)}show(e,i){this.current=e,this.eOverlayWrapper.innerHTML="";const t=document.createElement("div");t.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const s=document.createElement("div");if(s.className="ag-overlay-text",s.textContent=i,e==="loading"){const n=document.createElement("div");n.className="ag-overlay-loading-spinner",t.appendChild(n)}t.appendChild(s),this.eOverlayWrapper.appendChild(t),this.eOverlayWrapper.style.display="flex"}showLoadingOverlay(){this.show("loading",this.grid.translate("loadingOoo","Loading..."))}showNoRowsOverlay(){this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show"))}hideOverlay(){this.current=null,this.eOverlayWrapper.style.display="none",this.eOverlayWrapper.innerHTML=""}updateAuto(){const e=this.grid.getRowModel();if(!!this.grid.getOptions().__loadingRows){this.showLoadingOverlay();return}const t=e.getRowCount(),s=this.grid.getOptions().rowData;Array.isArray(s)&&s.length>0,t===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}const ds=(()=>{const l=new Uint32Array(256);for(let e=0;e<256;e++){let i=e;for(let t=0;t<8;t++)i=i&1?3988292384^i>>>1:i>>>1;l[e]=i>>>0}return l})();function cs(l){let e=4294967295;for(let i=0;i<l.length;i++)e=ds[(e^l[i])&255]^e>>>8;return(e^4294967295)>>>0}function At(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function hs(l){let e="",i=l+1;for(;i>0;){const t=(i-1)%26;e=String.fromCharCode(65+t)+e,i=Math.floor((i-1)/26)}return e}function us(l){const e=new TextEncoder,i=[],t=[];let s=0;for(const h of l){const g=e.encode(h.name),u=cs(h.data),f=new Uint8Array(30+g.length),m=new DataView(f.buffer);m.setUint32(0,67324752,!0),m.setUint16(4,20,!0),m.setUint16(6,2048,!0),m.setUint16(8,0,!0),m.setUint16(10,0,!0),m.setUint16(12,8585,!0),m.setUint32(14,u,!0),m.setUint32(18,h.data.length,!0),m.setUint32(22,h.data.length,!0),m.setUint16(26,g.length,!0),m.setUint16(28,0,!0),f.set(g,30),i.push(f,h.data);const v=new Uint8Array(46+g.length),C=new DataView(v.buffer);C.setUint32(0,33639248,!0),C.setUint16(4,20,!0),C.setUint16(6,20,!0),C.setUint16(8,2048,!0),C.setUint16(10,0,!0),C.setUint16(12,0,!0),C.setUint16(14,0,!0),C.setUint32(16,u,!0),C.setUint32(20,h.data.length,!0),C.setUint32(24,h.data.length,!0),C.setUint16(28,g.length,!0),C.setUint32(42,s,!0),v.set(g,46),t.push(v),s+=f.length+h.data.length}const n=t.reduce((h,g)=>h+g.length,0),o=new Uint8Array(22),a=new DataView(o.buffer);a.setUint32(0,101010256,!0),a.setUint16(8,l.length,!0),a.setUint16(10,l.length,!0),a.setUint32(12,n,!0),a.setUint32(16,s,!0);const r=i.reduce((h,g)=>h+g.length,0)+n+o.length,d=new Uint8Array(r);let c=0;for(const h of i)d.set(h,c),c+=h.length;for(const h of t)d.set(h,c),c+=h.length;return d.set(o,c),d}function ps(l){let e='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';return e+='<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>',l.forEach((i,t)=>{const s=t+1,o=i.some(a=>a.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${s}"${o}>`,i.forEach((a,r)=>{const d=`${hs(r)}${s}`,c=a.bold?' s="1"':"";if(a.value===null||a.value===void 0||a.value===""){e+=`<c r="${d}"${c}/>`;return}typeof a.value=="number"&&isFinite(a.value)?e+=`<c r="${d}"${c}><v>${a.value}</v></c>`:typeof a.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${a.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${At(String(a.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const gs='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>';function fs(l){const e=new TextEncoder,i=(h,g)=>h.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${g+1}`;let t="",s="",n="";l.forEach((h,g)=>{const u=i(h.name,g),f=g+1;t+=`<sheet name="${At(u)}" sheetId="${f}" r:id="rId${f}"/>`,s+=`<Relationship Id="rId${f}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${f}.xml"/>`,n+=`<Override PartName="/xl/worksheets/sheet${f}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const o='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+n+"</Types>",a='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${t}</sheets></workbook>`,d='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+s+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(o)},{name:"_rels/.rels",data:e.encode(a)},{name:"xl/workbook.xml",data:e.encode(r)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(d)},{name:"xl/styles.xml",data:e.encode(gs)}];return l.forEach((h,g)=>{c.push({name:`xl/worksheets/sheet${g+1}.xml`,data:e.encode(ps(h.rows))})}),new Blob([us(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const ms={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function Pt(l){return l.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function vs(l,e,i){const t=Math.max(1,Math.floor(e/(i*.5)));return l.length>t?`${l.slice(0,Math.max(1,t-1))}…`:l}function Cs(){return new TextEncoder}function ws(l,e={}){const[i,t]=ms[e.pageSize||"a4-landscape"],s=e.margin??32,n=e.fontSize??9,o=e.rowHeight??18,a=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=Cs(),c=[],h=w=>(c.push(w),c.length);h(""),h("");const g=h("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),u=h("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),f=[];for(const w of l){let x="";const b=w.columnWidths.reduce((S,L)=>S+L,0),y=Math.min(1,(i-s*2)/(b||1)),N=w.columnWidths.map(S=>S*y),I=s;let D=t-s-(e.title?24:0);e.title&&(x+=`BT /F2 ${n+4} Tf ${I} ${D} Td (${Pt(e.title)}) Tj ET
4
- `,D-=18),w.rows.forEach((S,L)=>{var X;const A=L===0,O=((X=w.rowFill)==null?void 0:X[L])??(A?a:void 0);O&&(x+=`${O[0]} ${O[1]} ${O[2]} rg ${I} ${(D-o+4).toFixed(2)} ${b*y} ${o} re f
5
- `);let V=I;S.forEach((B,ee)=>{const j=N[ee]??0,Te=Pt(vs(B.text??"",j-6,n)),Se=B.bold||A?u:g,xe=(B.text??"").length*n*.5;let ue=V+3;B.align==="right"||!B.align&&ee>0&&/^-?[\d,.%$£€\s]+$/.test(B.text??"")?ue=V+j-3-Math.min(xe,j-6):B.align==="center"&&(ue=V+(j-Math.min(xe,j-6))/2),x+=`BT /F${Se===u?2:1} ${n} Tf ${ue.toFixed(2)} ${(D-n+2).toFixed(2)} Td (${Te}) Tj ET
1
+ (function(z,se){typeof exports=="object"&&typeof module<"u"?se(exports):typeof define=="function"&&define.amd?define(["exports"],se):(z=typeof globalThis<"u"?globalThis:z||self,se(z.Rowvia={}))})(this,function(z){"use strict";var en=Object.defineProperty;var tn=(z,se,we)=>se in z?en(z,se,{enumerable:!0,configurable:!0,writable:!0,value:we}):z[se]=we;var u=(z,se,we)=>tn(z,typeof se!="symbol"?se+"":se,we);class se{constructor(){u(this,"listeners",new Map)}addEventListener(e,t){let i=this.listeners.get(e);i||(i=[],this.listeners.set(e,i)),i.push(t)}removeEventListener(e,t){const i=this.listeners.get(e);if(!i)return;const s=i.indexOf(t);s>=0&&i.splice(s,1)}dispatchEvent(e,t){const i=this.listeners.get(e);if(!i||i.length===0)return;const s={type:e,...t||{}};for(const n of i.slice())n(s)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const we=13,Zt=27,ut=9,pt=8,gt=46,Jt=36,ei=35;function ke(l){return l==null?"":String(l).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let ti=0;function Qe(l="id"){return`${l}-${++ti}`}function ae(l,e){if(typeof l!="number"||isNaN(l))return String(l??"");const t=e??0,i=l.toFixed(t),[s,n]=i.split("."),o=s.replace(/\B(?=(\d{3})+(?!\d))/g,",");return n?`${o}.${n}`:o}function Ze(l){if(l==null||l==="")return null;const e=Number(l);return isNaN(e)?null:e}function ii(l,e){if(l===e)return 0;if(l==null)return-1;if(e==null)return 1;if(typeof l=="number"&&typeof e=="number")return l-e;if(l instanceof Date&&e instanceof Date)return l.getTime()-e.getTime();const t=String(l).toLowerCase(),i=String(e).toLowerCase();return t<i?-1:t>i?1:0}function si(l,e){return e==null?!1:String(e).toLowerCase().includes(l.toLowerCase())}class ne extends Error{constructor(e){super(e),this.code=e}}const ni=/^\$?[A-Za-z]{1,3}\$?\d+$/;function ft(l){const e=[];let t=0;for(;t<l.length;){const i=l[t];if(i===" "||i===" "||i===`
2
+ `||i==="\r"){t++;continue}if(i==='"'||i==="'"){const n=i;let o="";for(t++;t<l.length&&l[t]!==n;)o+=l[t++];t++,e.push({type:"string",value:o});continue}if(/[0-9]/.test(i)||i==="."&&/[0-9]/.test(l[t+1]||"")){let n="";for(;t<l.length&&/[0-9.]/.test(l[t]);)n+=l[t++];if(l[t]==="e"||l[t]==="E")for(n+=l[t++],(l[t]==="+"||l[t]==="-")&&(n+=l[t++]);t<l.length&&/[0-9]/.test(l[t]);)n+=l[t++];e.push({type:"number",value:n});continue}if(/[A-Za-z_$]/.test(i)){let n="";for(;t<l.length&&/[A-Za-z0-9_$.]/.test(l[t]);)n+=l[t++];ni.test(n)?e.push({type:"cell",value:n.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:n});continue}if(i==="("){e.push({type:"lparen",value:i}),t++;continue}if(i===")"){e.push({type:"rparen",value:i}),t++;continue}if(i===","||i===";"){e.push({type:"comma",value:","}),t++;continue}const s=l.slice(t,t+2);if(["<=",">=","<>"].includes(s)){e.push({type:"op",value:s}),t+=2;continue}if("+-*/^%&=<>,:".includes(i)){e.push({type:"op",value:i}),t++;continue}throw new ne("#NAME?")}return e}const mt={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function vt(l){let e=0;const t=()=>l[e],i=()=>l[e++];function s(r=0){let d=n();for(;t()&&t().type==="op"&&mt[t().value]>=r;){const c=i().value,h=s(mt[c]+1);d={type:"binary",operator:c,left:d,right:h}}return d}function n(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){i();const d=n();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return o()}function o(){const r=i();if(!r)throw new ne("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=t();if(c&&c.type==="lparen"){i();const h=[];if(t()&&t().type!=="rparen")for(h.push(s());t()&&t().type==="comma";)i(),h.push(s());if(!t()||t().type!=="rparen")throw new ne("#ERROR!");return i(),{type:"call",name:d,args:h}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=s();if(!t()||t().type!=="rparen")throw new ne("#ERROR!");return i(),d}throw new ne("#ERROR!")}const a=s();if(e<l.length)throw new ne("#ERROR!");return a}function $(l){if(l==null||l==="")return 0;if(typeof l=="number")return l;if(typeof l=="boolean")return l?1:0;if(l instanceof Date)return l.getTime();const e=Number(l);return isNaN(e)?0:e}function be(l){const e=[];for(const t of l)if(Array.isArray(t))e.push(...be(t));else if(t!=null&&t!==""){const i=typeof t=="number"?t:Number(t);isNaN(i)||e.push(i)}return e}const Oe={SUM:l=>be(l).reduce((e,t)=>e+t,0),AVERAGE:l=>{const e=be(l);return e.length?e.reduce((t,i)=>t+i,0)/e.length:0},AVG:l=>Oe.AVERAGE(l,{}),MIN:l=>{const e=be(l);return e.length?Math.min(...e):0},MAX:l=>{const e=be(l);return e.length?Math.max(...e):0},COUNT:l=>be(l).length,COUNTA:l=>l.filter(e=>e!=null&&e!=="").length,ABS:l=>Math.abs($(l[0])),ROUND:l=>{const e=l.length>1?$(l[1]):0,t=Math.pow(10,e);return Math.round($(l[0])*t)/t},FLOOR:l=>Math.floor($(l[0])),CEIL:l=>Math.ceil($(l[0])),CEILING:l=>Math.ceil($(l[0])),SQRT:l=>{const e=$(l[0]);return e<0?(()=>{throw new ne("#NUM!")})():Math.sqrt(e)},POWER:l=>Math.pow($(l[0]),$(l[1])),POW:l=>Math.pow($(l[0]),$(l[1])),MOD:l=>{const e=$(l[1]);if(e===0)throw new ne("#DIV/0!");return $(l[0])%e},CONCAT:l=>l.map(e=>e==null?"":String(e)).join(""),CONCATENATE:l=>l.map(e=>e==null?"":String(e)).join(""),UPPER:l=>String(l[0]??"").toUpperCase(),LOWER:l=>String(l[0]??"").toLowerCase(),LEN:l=>String(l[0]??"").length,LEFT:l=>String(l[0]??"").slice(0,l.length>1?$(l[1]):1),RIGHT:l=>{const e=String(l[0]??""),t=l.length>1?$(l[1]):1;return t<=0?"":e.slice(-t)},MID:l=>{const e=String(l[0]??""),t=Math.max(0,$(l[1])-1),i=l.length>2?$(l[2]):e.length-t;return e.slice(t,t+i)},TRIM:l=>String(l[0]??"").trim(),IF:l=>l[0]?l[1]??!0:l[2]??!1,IFS:l=>{for(let e=0;e<l.length-1;e+=2)if(l[e])return l[e+1];return l.length%2===1?l[l.length-1]:!1},AND:l=>l.every(e=>!!e),OR:l=>l.some(e=>!!e),NOT:l=>!l[0],IFERROR:l=>{try{return l[0]===null||l[0]===void 0?l[1]:l[0]}catch{return l[1]}},ISNUMBER:l=>typeof l[0]=="number"||l[0]!==null&&l[0]!==""&&!isNaN(Number(l[0])),ISBLANK:l=>l[0]===null||l[0]===void 0||l[0]==="",ISTEXT:l=>typeof l[0]=="string",PI:()=>Math.PI,RAND:()=>Math.random(),TODAY:()=>new Date().toISOString().slice(0,10),NOW:()=>new Date().toISOString(),YEAR:l=>new Date(l[0]).getFullYear(),MONTH:l=>new Date(l[0]).getMonth()+1,DAY:l=>new Date(l[0]).getDate(),TEXT:l=>String(l[0]??""),VALUE:l=>$(l[0]),NUMBER:l=>$(l[0]),BETWEEN:l=>$(l[0])>=$(l[1])&&$(l[0])<=$(l[2])},Be=Object.keys(Oe);function oi(l,e){Oe[l.toUpperCase()]=e,Be.includes(l.toUpperCase())||Be.push(l.toUpperCase())}function li(l,e){const t=/^([A-Za-z]{1,3})(\d+)$/.exec(l);if(t&&e.a1Lookup)return e.a1Lookup(t[1].toUpperCase(),Number(t[2]))}function ri(l,e){const t=e.data||{};if(l in t)return t[l];const i=l.toLowerCase();for(const s of Object.keys(t))if(s.toLowerCase()===i)return t[s]}function Le(l,e){switch(l.type){case"number":return l.value;case"string":return l.value;case"boolean":return l.value;case"ref":return ri(l.value,e);case"cell":return li(l.value,e);case"unary":return-$(Le(l.operand,e));case"call":{const t=Oe[l.name];if(!t)throw new ne("#NAME?");const i=l.args.map(s=>Le(s,e));return t(i,e)}case"binary":{const t=Le(l.left,e),i=Le(l.right,e);switch(l.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:$(t)+$(i);case"-":return $(t)-$(i);case"*":return $(t)*$(i);case"/":{const s=$(i);if(s===0)throw new ne("#DIV/0!");return $(t)/s}case"^":return Math.pow($(t),$(i));case"%":{const s=$(i);if(s===0)throw new ne("#DIV/0!");return $(t)%s}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return $(t)<$(i);case"<=":return $(t)<=$(i);case">":return $(t)>$(i);case">=":return $(t)>=$(i);default:throw new ne("#ERROR!")}}default:throw new ne("#ERROR!")}}function De(l,e={}){const t=l.startsWith("=")?l.slice(1):l,i=vt(ft(t));return Le(i,e)}function Je(l){return typeof l=="string"&&l.trimStart().startsWith("=")}function et(l,e){if(l==null)return;if(e in l)return l[e];const t=e.split(".");let i=l;for(const s of t){if(i==null)return;i=i[s]}return i}function H(l,e,t){const i=l.colDef,s=(e.group||e.footer)&&!!e.groupData&&e.groupData[l.colId]!==void 0,n=s?e.groupData:e.data,o=l.valueGetter??i.valueGetter;if(o)return(typeof o=="string"?r=>Je(o)?De(o,{data:r.data}):et(r.data,o):o)({data:s?e.groupData:e.data,node:e,column:l,api:t,colDef:i,getValue:r=>et(s?e.groupData:e.data,r)});if(l.field&&Je(l.field))return De(l.field,{data:e.data});if(l.field&&l.colDef.expression&&/[+*/^-]/.test(l.field))return De(`=${l.field}`,{data:e.data});if(l.field)return et(n,l.field)}function Ve(l,e,t){var n;let i=H(l,e,t);const s=l.colDef;if(s.showValueAs&&typeof i=="number"&&t){const o=(n=t.__columnTotalCache)==null?void 0:n.get(l.colId);if(o!==void 0&&o!==0)return`${(s.showValueAs==="percentOfParent"?i/(o||1)*100:i/o*100).toFixed(1)}%`}return s.valueFormatter?(typeof s.valueFormatter=="string"?a=>ai(a.colDef.valueFormatter,a.value,a):s.valueFormatter)({value:i,data:e.data,node:e,column:l,api:t,colDef:s}):di(l,i)}function ai(l,e,t={}){var i,s,n;if(e==null)return"";switch(l){case"number":return ae(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${ae(e,((s=t.column)==null?void 0:s.decimals)??2)}`;case"percent":return`${ae(e,((n=t.column)==null?void 0:n.decimals)??2)}%`;case"date":return Ct(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Ct(l){const e=l instanceof Date?l:new Date(l);return isNaN(e.getTime())?String(l):`${e.getDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()]} ${e.getFullYear()}`}function di(l,e){if(e==null)return"";const t=l.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?ae(e,l.decimals):t==="dateColumn"||t==="dateStringColumn"?Ct(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function wt(l,e){return l.colDef.valueParser?(typeof l.colDef.valueParser=="string"?i=>yt(i.colDef.valueParser,i.newValue):l.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:l,colDef:l.colDef,api:null}):yt(l.type,e)}function yt(l,e){if(l==="numberColumn")return Ze(e);if(l==="dateColumn"){if(e instanceof Date)return e;const t=new Date(e);return isNaN(t.getTime())?e:t}return l==="booleanColumn"?e===!0||e==="true":e}function St(l){const t=l.colDef.comparator,i=l.type;return(s,n)=>{const o=H(l,s,null),a=H(l,n,null);if(t)return t(o,a,s,n);if(i==="numberColumn"){const r=typeof o=="number"?o:Ze(o),d=typeof a=="number"?a:Ze(a);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(i==="dateColumn"){const r=o instanceof Date?o.getTime():new Date(o).getTime(),d=a instanceof Date?a.getTime():new Date(a).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return ii(o,a)}}function Fe(l,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:l,rowNode:null,data:null});const i=t.filter(s=>typeof s=="number"&&!isNaN(s));switch(e){case"sum":return i.reduce((s,n)=>s+n,0);case"count":return t.length;case"avg":return i.length?i.reduce((s,n)=>s+n,0)/i.length:null;case"min":return i.length?Math.min(...i):null;case"max":return i.length?Math.max(...i):null;case"first":return t.length?t[0]:null;case"last":return t.length?t[t.length-1]:null;default:return null}}const ci={textColumn:{filter:"text",editable:!0},numberColumn:{filter:"number",editable:!0,headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},dateColumn:{filter:"date",editable:!0},dateStringColumn:{filter:"date"},booleanColumn:{filter:"boolean",cellRenderer:"agCheckboxCellRenderer"},rightAligned:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"},numericColumn:{headerClass:"ag-right-aligned-header",cellClass:"ag-right-aligned-cell"}};function hi(l){if(l===void 0||l===!0)return"text";if(l===!1)return!1;switch(l){case"agTextColumnFilter":return"text";case"agNumberColumnFilter":return"number";case"agDateColumnFilter":case"agDateColumnFilterString":return"date";case"agSetColumnFilter":return"set";default:return l}}function ui(l){return!!l.treeData}function pi(){return{applyAggregate:Fe}}class xt{constructor(e,t,i){u(this,"options");u(this,"eventService");u(this,"gridApi");u(this,"measureCtx",null);u(this,"gridColumnDefs",[]);u(this,"columns",[]);u(this,"displayOrder",[]);u(this,"autoGroupColumnDef");u(this,"pivotMode",!1);u(this,"columnGroups",[]);u(this,"openGroups",new Set);u(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=i,this.autoGroupColumnDef={headerName:"",minWidth:200,width:250,sortable:!1,filter:!1,resizable:!0,suppressMovable:!0,cellRenderer:"agGroupCellRenderer",...e.autoGroupColumnDef||{}}}setGridApi(e){this.gridApi=e}getAutoGroupColumnDef(){return this.autoGroupColumnDef}getOptions(){return this.options}setPivotMode(e,t="api"){this.pivotMode!==e&&(this.pivotMode=e,this.eventService.dispatchEvent("columnPivotModeChanged",{api:this.gridApi,source:t}),this.refreshAll())}isPivotMode(){return this.pivotMode}setColumnDefs(e){this.gridColumnDefs=e||[],this.buildColumns()}static generateColumnDefs(e,t=bt){if(!e||e.length===0)return[];const i=e[0];if(!i||typeof i!="object")return[];const s=new Set(["children","detail","__proto__"]),n=[];for(const o of Object.keys(i)){if(s.has(o)||o.startsWith("__"))continue;const a=i[o],r={field:o,headerName:t(o)};typeof a=="number"?(r.type="numberColumn",r.filter="number"):typeof a=="boolean"?r.type="booleanColumn":a instanceof Date&&(r.type="dateColumn"),n.push(r)}return n}getColumnGroups(){return this.columnGroups}getGroupDepth(){return this.columnGroups.reduce((e,t)=>Math.max(e,t.depth),0)}isGroupOpen(e){return this.openGroups.has(e)}setGroupOpen(e,t){t?this.openGroups.add(e):this.openGroups.delete(e),this.updateVisible(),this.refreshAll()}getColumnDefs(){return this.gridColumnDefs}buildColumns(){const e=this.columns,t=new Map;for(const c of e)t.set(c.colId,c);const i=this.options.defaultColDef||{},s={...ci,...this.options.columnTypes||{}},n=[],o=[];let a=0;const r=(c,h)=>{const g=c.colId||c.field||Qe("col"),p={...i,...c};if(p.type&&s[p.type]){const m=s[p.type],f=new Set(Object.keys(c));for(const[v,C]of Object.entries(m))!f.has(v)&&!(v in i)&&(p[v]=C)}this.pushColumnInto(n,p,g,a++,t,h)},d=(c,h,g)=>{for(const p of c)if(p.children&&p.children.length){const m=p.groupId||Qe("group"),f={id:m,headerName:p.headerName??"",openByDefault:p.openByDefault===!0||p.columnGroupShow==="open",parentId:h,depth:g,childColumnIds:[]};o.push(f),this.groupsInitialised||(f.openByDefault?this.openGroups.add(m):this.openGroups.delete(m)),d(p.children,m,g+1)}else r(p,h)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=o,this.options.rowNumbers){const c={colId:"__rowNumber",headerName:"",width:60,pinned:"left",sortable:!1,filter:!1,resizable:!1,suppressMovable:!0,cellRenderer:"agRowNumberCellRenderer",cellClass:"ag-row-number-cell"};this.pushColumnInto(n,{...i,...c},"__rowNumber",-1,t,null)}for(const c of n){if(!c.groupId)continue;const h=o.find(g=>g.id===c.groupId);h&&h.childColumnIds.push(c.colId)}this.columns=n,this.displayOrder=n.map(c=>c.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,i,s,n){return this.buildColumn(e,t,i,s,n)}pushColumnInto(e,t,i,s,n,o){e.push(this.buildColumn(t,i,s,n,o))}buildColumn(e,t,i,s,n){const o=s.get(t),a=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?bt(e.field):""),headerTooltip:e.headerTooltip,colDef:e,width:e.width??e.minWidth??(e.flex?200:100),minWidth:e.minWidth??20,maxWidth:e.maxWidth??Number.MAX_SAFE_INTEGER,flex:e.flex??null,pinned:e.pinned??null,hide:a,visible:!a,lockPosition:e.lockPosition??!1,type:e.type,sortable:e.sortable??!!e.field,sort:e.sort??null,sortIndex:e.sortIndex??null,resizable:e.resizable??!0,filter:hi(e.filter),floatingFilter:e.floatingFilter??!1,filterParams:e.filterParams||{},editable:e.editable??!1,cellEditor:e.cellEditor,cellEditorParams:e.cellEditorParams||{},singleClickEdit:e.singleClickEdit??this.options.singleClickEdit??!1,valueSetter:e.valueSetter,valueGetter:e.valueGetter,valueFormatter:e.valueFormatter,valueParser:e.valueParser,comparator:e.comparator,aggFunc:e.aggFunc,allowedAggFuncs:e.allowedAggFuncs??["sum","min","max","count","avg"],rowGroup:e.rowGroup??!1,rowGroupIndex:e.rowGroupIndex??null,pivot:e.pivot??!1,pivotIndex:e.pivotIndex??null,enableRowGroup:e.enableRowGroup??!0,enablePivot:e.enablePivot??!0,enableValue:e.enableValue??!0,cellRenderer:e.cellRenderer,cellRendererParams:e.cellRendererParams,cellClass:e.cellClass,cellStyle:e.cellStyle,cellDataType:e.cellDataType===!0,cellClassRules:e.cellClassRules,rowDrag:e.rowDrag===!0,headerClass:e.headerClass,checkboxSelection:e.checkboxSelection??!1,headerCheckboxSelection:e.headerCheckboxSelection??!1,headerCheckboxSelectionFilteredOnly:e.headerCheckboxSelectionFilteredOnly??!1,headerCheckboxSelectionCurrentPageOnly:e.headerCheckboxSelectionCurrentPageOnly??!1,menuTabs:e.menuTabs??["filterMenuTab","generalMenuTab","columnsMenuTab"],suppressMenu:e.suppressMenu??this.options.suppressMenu??!1,suppressMovable:e.suppressMovable??this.options.suppressMovableColumns??!1,wrapText:e.wrapText??!1,autoHeight:e.autoHeight??!1,tooltipField:e.tooltipField,tooltipValueGetter:e.tooltipValueGetter,decimals:e.decimals??0,defIndex:i,filterActive:!1,left:0,groupId:n};return o&&(r.pinned=o.pinned,r.visible=o.visible,r.width=o.width,r.flex=o.flex,r.sort=o.sort,r.sortIndex=o.sortIndex,r.rowGroup=o.rowGroup,r.rowGroupIndex=o.rowGroupIndex,r.pivot=o.pivot,r.pivotIndex=o.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const i=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),s=[];for(const r of t){const d=[],c=new Set;for(const h of e){const g=h==null?void 0:h[r.field],p=String(g);c.has(p)||(c.add(p),d.push(g))}d.sort((h,g)=>h===g?0:String(h)<String(g)?-1:1);for(const h of i){for(const m of d){const f=`__pivot_${r.colId}_${h.colId}_${m}`,v=this.createColumn({colId:f,headerName:`${String(m)}`,width:130,type:h.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:h.cellClass,cellDataType:h.cellDataType},f,-1,new Map,null);v.aggFunc=h.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:m,valueColumnId:h.colId,valueField:h.field},v.valueGetter=C=>this.evaluatePivotValue(v,C.node),s.push(v)}const g=`__pivot_${r.colId}_${h.colId}_total`,p=this.createColumn({colId:g,headerName:"Total",width:130,type:h.type,sortable:!1,filter:!1,cellDataType:h.cellDataType},g,-1,new Map,null);p.aggFunc=h.aggFunc,p.groupId=r.colId,p.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:h.colId,valueField:h.field},p.valueGetter=m=>this.evaluatePivotValue(p,m.node),s.push(p)}}const n=new Set(t.map(r=>r.colId)),o=this.columns.reduce((r,d,c)=>n.has(d.groupId??"")?r:c,0);this.columns.splice(o+1,0,...s);for(const r of s)this.displayOrder.push(r.colId);const a=new Set(this.columnGroups.map(r=>r.id));for(const r of t)a.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const i=e.__pivot;if(!i||!t)return;const s=[],n=c=>{if(!c.children||c.children.length===0){s.push(c);return}for(const h of c.children)n(h)};n(t);const a=(i.pivotValue===void 0?s:s.filter(c=>{var h;return String((h=c.data)==null?void 0:h[i.pivotField])===String(i.pivotValue)})).map(c=>{var h;return(h=c.data)==null?void 0:h[i.valueField]}).filter(c=>typeof c=="number");if(a.length===0)return null;const r=this.columns.find(c=>c.colId===i.valueColumnId),{applyAggregate:d}=pi();return d(r,e.aggFunc,a)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,i=this.getRowGroupColumns(),s=this.options.groupDisplayType||"singleColumn",n=t||i.length>0&&s!=="multipleColumns";for(const c of i)s==="multipleColumns"?(c.cellRenderer="agGroupCellRenderer",c.cellRendererParams={...c.cellRendererParams||{},suppressCount:!0}):c.cellRenderer==="agGroupCellRenderer"&&!c.colDef.cellRenderer&&(c.cellRenderer=void 0,c.cellRendererParams=void 0);const o=this.columns.find(c=>c.colId===e);if(!n){o&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const a={...this.autoGroupColumnDef};if(a.colId=e,o)o.headerName=a.headerName??"",o.colDef=a,o.cellRenderer=a.cellRenderer,o.cellRendererParams=a.cellRendererParams,o.width=a.width??o.width,o.minWidth=a.minWidth??o.minWidth,o.pinned=a.pinned??"left";else{const c=this.createColumn(a,e,-2,new Map,null);this.columns.unshift(c),this.displayOrder.unshift(e)}const r=this.columns.find(c=>c.colId===e),d=()=>this.getRowGroupColumns()[0];r.valueGetter=c=>{const h=c.node;if(!h)return"";if(h.key!==null&&h.key!==void 0)return h.key;if(ui(this.options))return"";const g=d();return g!=null&&g.field&&h.data?h.data[g.field]??"":""}}updateVisible(){for(const e of this.columns)e.visible=!e.hide&&this.isGroupChainOpen(e.groupId)}isGroupChainOpen(e){let t=e;for(;t;){if(!this.openGroups.has(t))return!1;const i=this.columnGroups.find(s=>s.id===t);t=(i==null?void 0:i.parentId)??null}return!0}refreshAll(){this.eventService.dispatchEvent("columnEverythingChanged",{api:this.gridApi,source:"gridOptionsChanged"}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi})}getAllColumns(){return this.columns.slice()}getColumn(e){const t=typeof e=="string"?e:e.colId;return this.columns.find(i=>i.colId===t)}getColumns(){return this.displayOrder.map(e=>this.getColumn(e)).filter(Boolean)}getDisplayedColumns(){return this.getColumns().filter(e=>e.visible)}getDisplayedLeftColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="left")}getDisplayedCenterColumns(){return this.getDisplayedColumns().filter(e=>e.pinned!=="left"&&e.pinned!=="right")}getDisplayedRightColumns(){return this.getDisplayedColumns().filter(e=>e.pinned==="right")}getDisplayedColumnsByType(){return{left:this.getDisplayedLeftColumns(),center:this.getDisplayedCenterColumns(),right:this.getDisplayedRightColumns()}}getRowGroupColumns(){return this.getColumns().filter(e=>e.rowGroup).sort((e,t)=>(e.rowGroupIndex??0)-(t.rowGroupIndex??0))}getPivotColumns(){return this.getColumns().filter(e=>e.pivot).sort((e,t)=>(e.pivotIndex??0)-(t.pivotIndex??0))}getValueColumns(){return this.pivotMode?this.getColumns().filter(e=>e.aggFunc&&!e.rowGroup&&!e.pivot):this.getColumns().filter(e=>!!e.aggFunc)}isRowGroupActive(){return this.getRowGroupColumns().length>0}setRowGroupColumns(e,t="api"){const i=e.map(s=>this.getColumn(s)).filter(Boolean);for(const s of this.getColumns())i.includes(s)||(s.rowGroup=!1,s.rowGroupIndex=null);i.forEach((s,n)=>{s.rowGroup=!0,s.rowGroupIndex=n,s.pivot=!1,s.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:i}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,t="api"){const i=this.getColumn(e);if(!i)return;const s=this.getRowGroupColumns();i.rowGroup=!0,i.rowGroupIndex=s.length,i.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,t="api"){const i=this.getColumn(e);if(!i)return;i.rowGroup=!1,i.rowGroupIndex=null,this.getRowGroupColumns().forEach((n,o)=>n.rowGroupIndex=o),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const i=e.map(s=>this.getColumn(s)).filter(Boolean);for(const s of this.getColumns())i.includes(s)?s.aggFunc||(s.aggFunc="sum"):s.aggFunc&&!s.rowGroup&&(s.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:i}),this.refreshAll()}addValueColumn(e,t="sum",i="api"){const s=this.getColumn(e);s&&(s.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:i,columns:[s]}),this.refreshAll())}setPivotColumns(e,t="api"){const i=e.map(s=>this.getColumn(s)).filter(Boolean);for(const s of this.getColumns())s.pivot=i.includes(s),s.pivotIndex=i.includes(s)?i.indexOf(s):null;this.refreshAll()}setColumnVisible(e,t,i="api"){const s=this.getColumn(e);!s||s.visible===t||(s.hide=!t,s.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:s,visible:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll())}setColumnsVisible(e,t,i="api"){for(const s of e)this.setColumnVisible(s,t,i)}setColumnPinned(e,t,i="api"){const s=this.getColumn(e);s&&(s.lockPosition&&t!==s.pinned||(s.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:s,pinned:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll()))}setColumnsPinned(e,t,i="api"){for(const s of e)this.setColumnPinned(s,t,i)}moveColumn(e,t,i="api"){const s=this.getColumn(e);s&&this.moveColumnByIndex(this.displayOrder.indexOf(s.colId),t,i)}moveColumnByIndex(e,t,i="api"){const s=this.displayOrder.slice();if(e<0||e>=s.length)return;const[n]=s.splice(e,1);s.splice(Math.max(0,Math.min(s.length,t)),0,n),this.displayOrder=s;const o=this.getColumn(n);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:o,toIndex:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll()}getColumnState(){return this.getColumns().map(e=>({colId:e.colId,hide:e.hide,pinned:e.pinned,width:e.width,flex:e.flex??void 0,sort:e.sort,sortIndex:e.sortIndex,rowGroupIndex:e.rowGroupIndex,pivotIndex:e.pivotIndex,aggFunc:e.aggFunc}))}applyColumnState(e,t=!1){for(const i of e){const s=this.getColumn(i.colId);s&&(i.hide!==void 0&&(s.hide=i.hide,s.visible=!i.hide),i.pinned!==void 0&&(s.pinned=i.pinned),i.width!==void 0&&(s.width=i.width),i.flex!==void 0&&(s.flex=i.flex),i.sort!==void 0&&(s.sort=i.sort),i.sortIndex!==void 0&&(s.sortIndex=i.sortIndex),i.rowGroupIndex!==void 0&&(s.rowGroup=i.rowGroupIndex!==null,s.rowGroupIndex=i.rowGroupIndex),i.pivotIndex!==void 0&&(s.pivot=i.pivotIndex!==null,s.pivotIndex=i.pivotIndex),i.aggFunc!==void 0&&(s.aggFunc=i.aggFunc))}if(t){const i=new Map(e.map(n=>[n.colId,n.colId])),s=this.displayOrder.filter(n=>!i.has(n));this.displayOrder=[...e.map(n=>n.colId).filter(n=>this.getColumn(n)),...s]}this.refreshAll()}resetColumnState(){this.buildColumns()}getMeasureContext(){if(this.measureCtx)return this.measureCtx;const e=document.createElement("canvas");return this.measureCtx=e.getContext("2d"),this.measureCtx&&(this.measureCtx.font='400 13px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'),this.measureCtx}measureTextWidth(e){const t=this.getMeasureContext();return t?t.measureText(e).width:e.length*8}sizeColumnsToFit(e,t=[]){const i=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const s of i){let o=0,a=0;for(const d of s)t.includes(d.colId)?a+=d.width:d.flex!==null&&d.flex>0?o+=d.flex:a+=d.width;const r=Math.max(0,e-a-32);if(o>0){for(const d of s)if(d.flex!==null&&d.flex>0&&!t.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/o));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var a,r,d,c,h,g;const i=this.getColumn(e);if(!i)return;let s=this.measureTextWidth(i.headerName)+32;t||(s+=16);const n=((r=(a=this.gridApi)==null?void 0:a.getDisplayedRowCount)==null?void 0:r.call(a))??0,o=Math.min(n,300);for(let p=0;p<o;p++){const m=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,p);if(!m)continue;const f=(g=(h=this.gridApi)==null?void 0:h.getCellText)==null?void 0:g.call(h,i,m);f&&(s=Math.max(s,this.measureTextWidth(f)+32))}i.width=Math.max(i.minWidth,Math.min(i.maxWidth,Math.ceil(s))),i.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:i,finished:!0})}autoSizeAllColumns(e=!1){for(const t of this.getDisplayedColumns())this.autoSizeColumn(t,e)}}function bt(l){const e=l.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class ge{constructor(e,t,i){u(this,"id");u(this,"__id");u(this,"data");u(this,"parent",null);u(this,"children",null);u(this,"group",!1);u(this,"key",null);u(this,"level",0);u(this,"uiLevel",0);u(this,"rowGroupIndex");u(this,"expanded",!1);u(this,"selectable",!0);u(this,"selected",!1);u(this,"rowPinned",null);u(this,"detailNode",null);u(this,"masterNode",null);u(this,"footer",!1);u(this,"groupData",null);u(this,"rowHeight",null);u(this,"allChildrenCount",null);u(this,"stub",!1);u(this,"rowIndex",null);u(this,"__displayIndex");u(this,"services");u(this,"_id",null);u(this,"__passesFilter",!0);u(this,"__childCount",0);u(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=Qe("row"),this.id=i??this.__id,i&&(this._id=i)}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,t=!1,i="api"){return e?this.services.selectNode(this,t):this.services.deselectNode(this),0}isSelected(){return this.selected}setData(e){this.data=e}setDataValue(e,t){const i=typeof e=="string"?e:e.field;if(i&&this.data){const s=i.split(".");let n=this.data;for(;s.length>1;){const o=s.shift();n[o]===void 0&&(n[o]={}),n=n[o]}n[s[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class gi{constructor(e){u(this,"options");u(this,"eventService");u(this,"columns");u(this,"getFilterModel");u(this,"getQuickFilter");u(this,"isPaginationEnabled");u(this,"getPageSize");u(this,"getCurrentPage");u(this,"rowHeightProvider");u(this,"rowNodeServices");u(this,"rowData",[]);u(this,"rootRowNodes",[]);u(this,"dataRows",[]);u(this,"rowsToDisplay",[]);u(this,"rowNodeMap",new Map);u(this,"expandedGroups",new Set);u(this,"groupDefaultExpandedApplied",!1);u(this,"pinnedTopRows",[]);u(this,"pinnedBottomRows",[]);u(this,"displayStartIndex",0);u(this,"totalRowCount",0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getFilterModel=e.getFilterModel,this.getQuickFilter=e.getQuickFilter,this.isPaginationEnabled=e.isPaginationEnabled,this.getPageSize=e.getPageSize,this.getCurrentPage=e.getCurrentPage,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices}getType(){return"clientSide"}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.rootRowNodes}getRowCount(){return this.rowsToDisplay.length}getTotalRowCount(){return this.totalRowCount}getRow(e){return this.rowsToDisplay[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.rowsToDisplay.forEach((t,i)=>e(t,i))}forEachLeafNode(e){let t=0;const i=s=>{for(const n of s)n.group?n.children&&i(n.children):n.footer||e(n,t++)};i(this.rootRowNodes)}getPinnedTopRowCount(){return this.pinnedTopRows.length}getPinnedBottomRowCount(){return this.pinnedBottomRows.length}getPinnedTopRow(e){return this.pinnedTopRows[e]}getPinnedBottomRow(e){return this.pinnedBottomRows[e]}getRowIndexAtPixel(e){return Math.floor(e/this.rowHeightProvider())}updateRowData(e){this.rowData=e||[],this.rebuildRows()}rebuildRows(){const e=new Map;this.options.treeData&&this.rowNodeMap.forEach(s=>{s.group&&e.set(s.id,s.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,i=this.rowData;if(this.options.treeData){const s=this.buildTreeData(i,t);this.rootRowNodes=s,this.rowNodeMap.forEach(n=>{n.group&&e.has(n.id)&&(n.expanded=e.get(n.id))})}else{const s=[];for(let n=0;n<i.length;n++){const o=i[n],a=t?t({data:o,level:0}):void 0,r=this.createRowNode(o,a);r.rowIndex=n,s.push(r)}this.rootRowNodes=s,this.dataRows=s}if(this.options.masterDetail&&!this.options.treeData){const s=this.options.isRowMaster||(()=>!0);for(const n of this.rootRowNodes){if(n.detailNode||!s({data:n.data,node:n}))continue;const o=this.createRowNode(null,`${n.id}|detail`,n,1);o.masterNode=n,o.selectable=!1,n.detailNode=o,n.expanded=!1}}this.refreshModel(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.gridApi})}createRowNode(e,t,i=null,s=0){const n=new ge(e,this.rowNodeServices,t);return n.parent=i,n.level=s,n.uiLevel=s,n.__id=n.id,this.rowNodeMap.set(n.id,n),n}buildTreeData(e,t){const i=this.options.getDataPath||(d=>String(d.id??d.key).split("/")),s=this.options.treeDataChildrenField||"children",n=new Map,o=[],a=(d,c,h)=>{const g=i(d),p=g.join("/"),m=t?t({data:d,level:h}):p,f=this.createRowNode(d,m,c,h);f.key=g[g.length-1],n.set(p,f);const v=d[s];if(Array.isArray(v)&&v.length){f.children=[],f.group=!0,f.expanded=!0;for(const C of v){const w=a(C,f,h+1);f.children.push(w)}f.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(f),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||o.push(f),f},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const h of d.children)c+=r(h);return d.allChildrenCount=c,c};for(const d of o)r(d);for(const d of e){if(!d)continue;const h=i(d).slice(0,-1).join("/"),g=h&&n.get(h)||null;a(d,g??null,g?g.level+1:0)}return o}applyTransaction(e){const t=this.options.getRowId,i={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const s=new Set;for(const n of e.remove){const o=t?t({data:n,level:0}):n.id;o!==void 0?s.add(String(o)):s.add(n)}this.rowData=this.rowData.filter(n=>{const o=t?t({data:n,level:0}):n.id;return!s.has(String(o))&&!s.has(n)});for(const n of s){const o=this.rowNodeMap.get(String(n));o&&(this.rowNodeMap.delete(o.id),i.remove.push(o))}}if(e.update&&e.update.length)for(const s of e.update){const n=t?t({data:s,level:0}):s.id,o=n!==void 0?this.rowNodeMap.get(String(n)):void 0;if(o)this.rowData=this.rowData.map(a=>{const r=t?t({data:a,level:0}):a.id;return String(r)===String(n)?s:a}),o.data=s,i.update.push(o);else{const a=this.createRowNode(s,n!==void 0?String(n):void 0);this.rowData.push(s),i.add.push(a)}}if(e.add&&e.add.length){const s=e.addIndex;for(const n of e.add){const o=t?t({data:n,level:0}):void 0,a=this.createRowNode(n,o);i.add.push(a),s===void 0||s<0?this.rowData.push(n):this.rowData.splice(Math.min(s,this.rowData.length),0,n)}}return this.rebuildRows(),i}refreshModel(e){const t=this.columns().filter(i=>i.rowGroup);(!e||e==="everything"||e==="filter"||e==="group")&&this.doFilter(),(!e||e==="everything"||e==="sort"||e==="group")&&this.doSort(t),(!e||e==="everything"||e==="group")&&this.doGroup(t),this.buildDisplayRows(t),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}doFilter(){const e=this.getFilterModel(),t=this.getQuickFilter(),i=Object.keys(e).length>0,s=t&&t.trim().length>0,n=this.columns(),o=!!this.options.treeData,a=m=>{for(const[f,v]of Object.entries(e)){const C=n.find(w=>w.colId===f);if(C&&!this.doesNodePassFilter(m,C,v))return!1}return!0},r=m=>{const f=this.options.__advancedFilterPass;return f?f(m):!0},d=Object.entries(e).some(([m,f])=>{const v=n.find(C=>C.colId===m);return!v||!v.aggFunc?!1:f.filterType==="multi"?(f.filterModels||[]).length>0:!0}),c=m=>{if(m.__passesFilter=!0,m.children)for(const f of m.children)c(f)},h=m=>{const f=this.options;return typeof f.isExternalFilterPresent!="function"||!f.isExternalFilterPresent()||typeof f.doesExternalFilterPass!="function"?!0:f.doesExternalFilterPass(m)},g=m=>{if(!s)return!0;const f=t.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?n:n.filter(C=>C.visible);for(const C of v){const w=H(C,m,null);if(si(f,w))return!0}return!1},p=m=>{let f=!0;if(!m.group||m.footer||o?f=(!i||a(m))&&g(m)&&h(m)&&r(m):d&&(f=(!i||a(m))&&r(m)),m.__passesFilter=f,m.children){let v=!1;for(const C of m.children)p(C)&&(v=!0);return m.group&&!m.footer&&(d?(m.__passesFilter=f,f&&c(m)):(m.__passesFilter=o?v||f:v,o&&f&&c(m))),m.__passesFilter}return f};for(const m of this.rootRowNodes)p(m)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const c=[];We(e,c);const h=c.map(g=>H(t,g,null));r=Fe(t,t.aggFunc,h)}const d={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,t,i)}if(i.filterType==="multi"){const r=i.filterModels||[];if(r.length===0)return!0;const d=i.operator||"AND",c=r.map(h=>this.doesNodePassFilter(e,t,h));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(i.condition1||i.condition2){const{condition1:r,condition2:d,...c}=i,h=[this.doesNodePassFilter(e,t,{...c,...r||{}})];return d&&h.push(this.doesNodePassFilter(e,t,{...c,...d})),(i.operator||"AND")==="OR"?h.some(Boolean):h.every(Boolean)}const s=H(t,e,null),n=mi(t,s),o=s,a=i.filterType||"text";if(a==="text"){const r=String(i.filter??"").toLowerCase();if(!r)return!0;const d=(o==null?"":String(o)).toLowerCase();switch(i.type){case"equals":return d===r;case"notEqual":return d!==r;case"startsWith":return d.startsWith(r);case"endsWith":return d.endsWith(r);case"contains":default:return d.includes(r)}}if(a==="number"){const r=typeof o=="number"?o:Number(o);if(isNaN(r))return!1;const d=Number(i.filter),c=i.filterTo!==void 0&&i.filterTo!==null&&i.filterTo!==""?Number(i.filterTo):null;switch(i.type){case"equals":return r===d;case"notEqual":return r!==d;case"lessThan":return r<d;case"lessThanOrEqual":return r<=d;case"greaterThan":return r>d;case"greaterThanOrEqual":return r>=d;case"inRange":return c!==null?r>=Math.min(d,c)&&r<=Math.max(d,c):!0;case"blank":return o==null||o==="";case"notBlank":return!(o==null||o==="");default:return!0}}if(a==="date"){const r=o instanceof Date?o.getTime():new Date(o).getTime();if(isNaN(r))return!1;const d=i.dateFrom?new Date(i.dateFrom).getTime():null,c=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return a==="boolean"?!!o==!!i.filter:a==="set"?(i.values||[]).map(d=>String(d)).includes(String(o)):!0}doSort(e){const t=[],i=this.columns();for(const o of i)o.sort&&o.sortIndex!==null&&t.push({column:o,direction:o.sort});t.sort((o,a)=>(o.column.sortIndex??0)-(a.column.sortIndex??0));const s=(o,a)=>{for(const{column:c,direction:h}of t){const g=St(c)(o,a)*(h==="asc"?1:-1);if(g!==0)return g}const r=o.rowIndex??0,d=a.rowIndex??0;return r-d},n=o=>{o.sort(s);for(const a of o)a.children&&n(a.children)};if(e.length===0)n(this.rootRowNodes);else for(const o of this.rootRowNodes)o.children&&n(o.children)}doGroup(e){if(e.length===0)return;const t=this.columns().filter(d=>d.aggFunc&&!d.rowGroup),i=(d,c,h,g)=>{if(c>=e.length)return d;const p=e[c],m=new Map,f=[];for(const C of d){if(!C.__passesFilter)continue;const w=H(p,C,null),x=fi(w);m.has(x)||(m.set(x,[]),f.push(x)),m.get(x).push(C)}const v=[];for(const C of f){const w=m.get(C),x=`${g}|${p.colId}:${C}`,b=this.rowNodeMap.get(x),y=b||new ge({[p.colId]:C},this.rowNodeServices,x);y.group=!0,y.key=C,y.level=h,y.uiLevel=h,y.parent=null,y.children=i(w,c+1,h+1,x);for(const D of y.children)D.parent=y;y.allChildrenCount=Et(y),y.data={...y.data};const N=[];We(y,N);const I={};for(const D of t){const W=N.map(T=>H(D,T,null));I[D.colId]=Fe(D,D.aggFunc,W)}I[p.colId]=C,y.groupData=I,b||this.rowNodeMap.set(x,y),v.push(y)}return v},s=this.options.groupDefaultExpanded??0,n=this.dataRows.length>0?this.dataRows:this.rootRowNodes,o=i(n,0,0,""),a=d=>{for(const c of d){if(!c.group)continue;const h=ze(c),g=this.expandedGroups.has(h);s===-1||g?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<s,c.expanded&&this.expandedGroups.add(h),c.children&&a(c.children)}};a(o),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const h=e[c],g=h.sort==="desc"?-1:1,p=St(h);d.sort((m,f)=>{const v=H(h,m,null),C=H(h,f,null);return p({...m,data:{[h.colId]:v}},{...f,data:{[h.colId]:C}})*g})};e[0].sort&&r(o,0),this.rootRowNodes=o}buildDisplayRows(e){const t=[],i=!!this.options.treeData,s=(o,a)=>{if(o.uiLevel=a,t.push(o),o.detailNode&&o.expanded&&t.push(o.detailNode),o.children&&(o.group||i)){const r=o.group?o.children.filter(d=>d.__passesFilter||d.group):o.children;if(o.expanded){for(const d of r)s(d,a+1);if(o.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(o)){const d=this.createFooterNode(o,a+1);t.push(d)}}}};for(const o of this.rootRowNodes)o.__passesFilter&&s(o,0);if(this.options.groupIncludeTotalFooter&&e.length>0){const o=this.createGrandTotalNode(e);t.push(o)}this.pinnedTopRows=t.filter(o=>o.rowPinned==="top"),this.pinnedBottomRows=t.filter(o=>o.rowPinned==="bottom");const n=t.filter(o=>o.rowPinned!=="top"&&o.rowPinned!=="bottom");if(this.totalRowCount=n.filter(o=>!o.masterNode).length,this.isPaginationEnabled()){const o=this.getPageSize(),a=this.getCurrentPage();let r=0,d=-1;for(let h=0;h<n.length;h++)if(!n[h].masterNode){if(r===a*o){d=h;break}r++}d<0&&(d=n.length);let c=d;for(r=0;c<n.length&&r<o;)n[c].masterNode||r++,c++;for(;c<n.length&&n[c].masterNode;)c++;this.displayStartIndex=d,this.rowsToDisplay=n.slice(d,c)}else this.displayStartIndex=0,this.rowsToDisplay=n;this.rowsToDisplay.forEach((o,a)=>o.__displayIndex=a)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const i=`${e.id}|footer`;let s=this.rowNodeMap.get(i);return s||(s=new ge(e.data,this.rowNodeServices,i),this.rowNodeMap.set(i,s)),s.group=!1,s.footer=!0,s.level=e.level,s.uiLevel=t,s.parent=e,s.selected=!1,s.selectable=!1,s.groupData={...e.groupData,__footerFor:e.id},s}createGrandTotalNode(e){const t="ag-grid-grand-total";let i=this.rowNodeMap.get(t);i||(i=new ge(null,this.rowNodeServices,t),this.rowNodeMap.set(t,i)),i.group=!1,i.footer=!0,i.level=0,i.uiLevel=0,i.selected=!1,i.selectable=!1;const s=this.columns().filter(a=>a.aggFunc&&!a.rowGroup),n=[];for(const a of this.rootRowNodes)a.group?We(a,n):a.__passesFilter&&n.push(a);const o={};for(const a of s){const r=n.map(d=>H(a,d,null));o[a.colId]=Fe(a,a.aggFunc,r)}return o.__grandTotal=!0,i.groupData=o,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(ze(t)),t.children&&t.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}collapseAll(){this.expandedGroups.clear();const e=t=>{t.group&&(t.expanded=!1,t.children&&t.children.forEach(e))};this.rootRowNodes.forEach(e),this.buildDisplayRows(this.columns().filter(t=>t.rowGroup)),this.eventService.dispatchEvent("expandOrCollapseAll",{}),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi})}setNodeExpanded(e,t){e.group&&(e.expanded=t,t?this.expandedGroups.add(ze(e)):this.expandedGroups.delete(ze(e)),this.buildDisplayRows(this.columns().filter(i=>i.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function fi(l){return l==null?"":l instanceof Date?l.toISOString():String(l)}function ze(l){const e=[];let t=l;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Et(l){return!l.children||l.children.length===0?1:l.children.reduce((e,t)=>e+Et(t),0)}function We(l,e){if(!l.children||l.children.length===0){e.push(l);return}for(const t of l.children)We(t,e)}function mi(l,e){return e}const Rt={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应本列宽度",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多条件筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"显示/隐藏",hideColumn:"隐藏本列",chooseColumns:"选择列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",sortAsc:"升序",sortDesc:"降序",sortNone:"无",copy:"复制",copyWithHeaders:"连同表头复制",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应容器宽度",expandAll:"展开全部",collapseAll:"折叠全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",search:"搜索…",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"全部清除",join:"条件组合:",and:"并且",or:"或者",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",conditionsUnit:"个条件",addCondition:"+ 添加条件",condTrue:"真",condFalse:"假",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"页码",pageSize:"每页行数:",pageNumber:"输入页码",find:"在表格中查找…",matchCase:"区分大小写",prevMatch:"上一个匹配",nextMatch:"下一个匹配",of:"/",rangeTo:"至",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity",dataGrid:"数据表格",dragRow:"拖拽行",expandGroup:"展开分组",close:"关闭",save:"保存",delete:"删除",totalRows:"总行数",rows:"行数",filtered:"筛选后",selected:"已选中",average:"平均",count:"计数",min:"最小",max:"最大",sum:"合计",note:"便签",writeNote:"写便签…",formulaPreview:"预览(第 1 行)",formulaError:"错误",invalidFormula:"公式无效",functions:"函数",integratedCharts:"集成图表",chart:"图表",chartType:"图表类型",chartCategory:"类目",chartSeries:"数据系列",chartGroup:"分组",createChart:"创建图表",noChartsCreated:"暂无图表",downloadPng:"下载 PNG",chartLine:"折线图",chartArea:"面积图",chartColumn:"柱状图",chartBar:"条形图",chartPie:"饼图",chartScatter:"散点图"},vi={contains:"contains",notEqual:"notEqual",startsWith:"startsWith",endsWith:"endsWith",equals:"equals",blank:"blank",notBlank:"notBlank",greaterThan:"greaterThan",greaterThanOrEqual:"greaterThanOrEqual",lessThan:"lessThan",lessThanOrEqual:"lessThanOrEqual",inRange:"inRange",true:"condTrue",false:"condFalse"};class Ci{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Rt[e]??e}}function wi(l){return new Ci(l??{})}function yi(l){return!l||typeof l!="object"?!1:l.__isGroup===!0?!0:typeof l.childCount=="number"&&l.childCount>=0}class Si{constructor(e){u(this,"options");u(this,"eventService");u(this,"columns");u(this,"getSortModel");u(this,"getFilterModel");u(this,"rowHeightProvider");u(this,"rowNodeServices");u(this,"datasource",null);u(this,"stores",new Map);u(this,"rowNodeMap",new Map);u(this,"displayRows",[]);u(this,"blockSize");u(this,"pureLoad",!0);this.options=e.options,this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowHeightProvider=e.rowHeight,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100,this.pureLoad=e.options.serverSideStoreType!=="partial"}getType(){return"serverSide"}setDatasource(e){this.datasource=e,this.purgeCache()}getStore(e){return this.stores.get(e)}getOrCreateStore(e){let t=this.stores.get(e);return t||(t={rows:[],lastRow:null,loading:!1,failed:!1},this.stores.set(e,t)),t}isLoading(){for(const e of this.stores.values())if(e.loading)return!0;return!1}loadBlock(e,t,i){if(!this.datasource)return;const s=this.getOrCreateStore(e);if(s.loading)return;for(let o=s.rows.length;o<i;o++)s.rows.push(null);s.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const n={startRow:t,endRow:i,rowGroupCols:this.columns().filter(o=>o.rowGroup),valueCols:this.columns().filter(o=>o.aggFunc&&!o.rowGroup),pivotCols:this.columns().filter(o=>o.pivot),groupKeys:e?e.split("|"):[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(o,a)=>{s.loading=!1,this.onBlockLoaded(e,o,a??null)},failCallback:()=>{s.loading=!1,s.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(n)}onBlockLoaded(e,t,i){const s=this.getOrCreateStore(e);s.lastRow=i,s.failed=!1;for(let n=0;n<t.length;n++){const o=t[n],a=(s.rows.length>0,n),r=this.createNode(o,e,n,a);s.rows[a]=r}for(;s.rows.length&&s.rows[s.rows.length-1]===null;)s.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,i,s){const n=yi(e),o=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${s}`,a=this.rowNodeMap.get(o),r=a instanceof ge?a:new ge(e,this.rowNodeServices,o);return r.data=e,r.rowIndex=i,n&&(r.group=!0,r.key=String(H(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(o,r),r}buildDisplayRows(){const e=[],t=(i,s)=>{const n=this.stores.get(i);if(n){for(const o of n.rows)if(o&&(o.uiLevel=s,e.push(o),o.group&&o.expanded)){const a=`${i?i+"|":""}${o.key}`;t(a,s+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((i,s)=>i.__displayIndex=s)}ensureLoaded(e,t){let i=0;const s=o=>{const a=this.stores.get(o);if(a){for(const r of a.rows)if(r){if(i>=e&&i<=t){const d=Math.floor(i/this.blockSize)*this.blockSize,c=d+this.blockSize,h=a.lastRow,g=h!==null?Math.min(h,c):c;i<(a.rows.length||0)&&d<(a.rows.length||0)||(a.lastRow===null||c<=a.lastRow)&&this.loadBlock(o,d,g)}i++,r.group&&r.expanded&&s(`${o?o+"|":""}${r.key}`)}}};s("");const n=this.stores.get("");(!n||n.rows.length===0&&n.lastRow===null)&&this.loadBlock("",0,this.blockSize)}refreshModel(e){this.ensureLoaded(0,this.blockSize),this.eventService.dispatchEvent("modelUpdated",{})}onViewportChanged(e,t){this.ensureLoaded(e,t)}setNodeExpanded(e,t){if(e.group){if(e.expanded=t,t){const i=this.groupPathFor(e);this.stores.has(i)||this.loadBlock(i,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const t=[];let i=e;for(;i&&i.group;)t.unshift(i.key??""),i=i.parent??null;return t.join("|")}purgeCache(){this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[],this.refreshModel("everything")}onSortOrFilterChanged(){this.purgeCache()}getRowCount(){return this.displayRows.length}getTotalRowCount(){const e=this.stores.get("");return(e==null?void 0:e.lastRow)??0}getRow(e){return this.displayRows[e]}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.displayRows.forEach((t,i)=>e(t,i))}forEachLeafNode(e){let t=0;for(const i of this.displayRows)!i.group&&!i.footer&&e(i,t++)}isEmpty(){return this.displayRows.length===0}getTopLevelRows(){const e=this.stores.get("");return(e==null?void 0:e.rows.filter(Boolean))||[]}updateRowData(e){this.refreshModel("everything")}applyTransaction(e){const t={add:[],remove:[],update:[]};for(const i of e.update||[]){const s=(i==null?void 0:i.id)!==void 0?String(i.id):void 0,n=s?this.rowNodeMap.get(s):void 0;n&&(n.data=i,t.update.push(n))}return this.eventService.dispatchEvent("modelUpdated",{}),t}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.stores.clear(),this.rowNodeMap.clear(),this.displayRows=[]}expandAll(){for(const e of this.rowNodeMap.values())if(e.group){e.expanded=!0;const t=this.groupPathFor(e);this.stores.has(t)||this.loadBlock(t,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}collapseAll(){for(const e of this.rowNodeMap.values())e.group&&(e.expanded=!1);this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class xi{constructor(e){u(this,"options");u(this,"eventService");u(this,"getSortModel");u(this,"getFilterModel");u(this,"rowNodeServices");u(this,"datasource",null);u(this,"nodes",[]);u(this,"rowNodeMap",new Map);u(this,"blockSize");u(this,"lastRow",null);u(this,"loading",!1);this.options=e.options,this.eventService=e.eventService,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}getType(){return"infinite"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.lastRow=null,this.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let i=this.nodes.length;i<t;i++)this.nodes.push(null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(i,s)=>{this.loading=!1,this.lastRow=s??null,i.forEach((n,o)=>{const a=(n==null?void 0:n.id)!==void 0?String(n.id):`row-${e+o}`;let r=this.rowNodeMap.get(a);r||(r=new ge(n,this.rowNodeServices,a),this.rowNodeMap.set(a,r)),r.data=n,r.rowIndex=e+o,this.nodes[e+o]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const i=Math.floor(e/this.blockSize)*this.blockSize;i+this.blockSize>this.nodes.length&&this.loadBlock(i,i+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.lastRow=null,this.loadBlock(0,this.blockSize)}isLoading(){return this.loading}getRowCount(){return this.nodes.length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,i)=>{t&&e(t,i)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.nodes.filter(Boolean).length===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){this.onSortOrFilterChanged()}applyTransaction(){return null}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class bi{constructor(e){u(this,"options");u(this,"eventService");u(this,"rowNodeServices");u(this,"datasource",null);u(this,"nodes",[]);u(this,"rowNodeMap",new Map);u(this,"firstRow",0);u(this,"lastRow",0);u(this,"loading",!1);this.options=e.options,this.eventService=e.eventService,this.rowNodeServices=e.rowNodeServices}getType(){return"viewport"}setDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}setViewportRange(e,t){if(this.firstRow=e,this.lastRow=t,!(!this.datasource||this.loading)){this.nodes=this.nodes.filter((i,s)=>s>=e&&s<=t);for(let i=e;i<=t;i++)this.nodes[i-e]||(this.nodes[i-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:i=>{this.loading=!1,i.forEach((s,n)=>{const o=(s==null?void 0:s.id)!==void 0?String(s.id):`vrow-${e+n}`;let a=this.rowNodeMap.get(o);a||(a=new ge(s,this.rowNodeServices,o),this.rowNodeMap.set(o,a)),a.data=s,a.rowIndex=e+n,this.nodes[e+n-e]=a}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}setViewportDatasource(e){this.datasource=e,this.nodes=[],this.rowNodeMap.clear(),this.setViewportRange(0,50)}onViewportChanged(e,t){this.setViewportRange(e,t)}isLoading(){return this.loading}getRowCount(){return this.nodes.filter(Boolean).length}getRow(e){return this.nodes[e]??void 0}getRowNode(e){return this.rowNodeMap.get(e)}forEachNode(e){this.nodes.forEach((t,i)=>{t&&e(t,i)})}forEachLeafNode(e){this.forEachNode(e)}isEmpty(){return this.getRowCount()===0}getTopLevelRows(){return this.nodes.filter(Boolean)}updateRowData(){}applyTransaction(){return null}destroy(){var e,t;(t=(e=this.datasource)==null?void 0:e.destroy)==null||t.call(e),this.nodes=[],this.rowNodeMap.clear()}refreshModel(){this.eventService.dispatchEvent("modelUpdated",{})}expandAll(){}collapseAll(){}getPinnedTopRowCount(){return 0}getPinnedBottomRowCount(){return 0}}class Ei{constructor(e){u(this,"eGui");var d,c,h;this.params=e;const t=e.node,i=!!t.group,s=!!t.detailNode,n=i||s,o=t.expanded,a=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${a}px`,n){const g=document.createElement("span");g.className="ag-group-value-expanded-icon",g.classList.add(o?"ag-expanded":"ag-contracted"),g.innerHTML=o?zi:Vi,r.appendChild(g);const p=document.createElement("span");p.className="ag-group-value";const m=(d=e.colDef.cellRendererParams)==null?void 0:d.innerRenderer;if(typeof m=="function"){const f=m({...e,value:e.value,valueFormatted:e.valueFormatted});f instanceof HTMLElement?p.appendChild(f):typeof f=="string"&&(p.innerHTML=f)}else p.textContent=Di(e.value);if(r.appendChild(p),i&&t.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const f=document.createElement("span");f.className="ag-group-child-count",f.textContent=` (${t.allChildrenCount})`,r.appendChild(f)}}else{const g=document.createElement("span");g.className="ag-group-value";const p=(h=e.colDef.cellRendererParams)==null?void 0:h.innerRenderer;if(typeof p=="function"){const m=p({...e,value:e.value,valueFormatted:e.valueFormatted});m instanceof HTMLElement?g.appendChild(m):typeof m=="string"&&(g.innerHTML=m)}else g.textContent=e.valueFormatted??String(e.value??"");r.appendChild(g)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Ri{constructor(e){u(this,"eGui");u(this,"eCheckbox");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-cell-checkbox";const t=document.createElement("input");t.type="checkbox",t.className="ag-native-checkbox",t.checked=!!e.node.selected,t.addEventListener("click",i=>i.stopPropagation()),t.addEventListener("change",()=>{e.node.setSelected(t.checked,!1,"uiSelectChanged")}),this.eCheckbox=t,this.eGui.appendChild(t)}getGui(){return this.eGui}refresh(e){return this.params=e,this.eCheckbox.checked=!!e.node.selected,!0}}const Mi='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',Ni='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class Ti{constructor(e){u(this,"eGui");u(this,"eArrow");u(this,"eOld");u(this,"eNew");u(this,"lastValue");u(this,"flashTimer",null);this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-animate-show-change-cell-renderer",this.eArrow=document.createElement("span"),this.eArrow.className="ag-value-change-arrow",this.eArrow.style.display="none",this.eOld=document.createElement("span"),this.eOld.className="ag-value-change-old",this.eOld.style.display="none",this.eNew=document.createElement("span"),this.eNew.className="ag-value-change-new",this.eGui.appendChild(this.eArrow),this.eGui.appendChild(this.eOld),this.eGui.appendChild(this.eNew),this.eNew.textContent=this.formatValue(e),this.lastValue=e.value}formatValue(e){const t=e.valueFormatted??e.value;return t==null?"":String(t)}getGui(){return this.eGui}refresh(e){const t=e.value;if(t!==this.lastValue){const i=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),s=this.eNew.textContent??"";this.eArrow.innerHTML=i?Mi:Ni,this.eArrow.style.display="",this.eArrow.classList.add(i?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=s,this.eOld.style.display="",this.eNew.textContent=this.formatValue(e),this.lastValue=t,this.eGui.classList.remove("ag-value-change-value-highlight"),this.eGui.offsetWidth,this.eGui.classList.add("ag-value-change-value-highlight",i?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.flashTimer&&clearTimeout(this.flashTimer),this.flashTimer=setTimeout(()=>{this.eGui.classList.remove("ag-value-change-value-highlight","ag-value-change-delta-up","ag-value-change-delta-down"),this.eArrow.style.display="none",this.eOld.style.display="none"},1e3)}return!0}destroy(){this.flashTimer&&clearTimeout(this.flashTimer)}}class Ii{constructor(e){u(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-number-cell",this.eGui.textContent=String(e.rowIndex+1)}getGui(){return this.eGui}refresh(e){return this.params=e,this.eGui.textContent=String(e.rowIndex+1),!0}}class ki{constructor(e){u(this,"eGui");var r,d;this.params=e;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],s=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},n=e.column.width||100,o=s.height||24,a=tt(i,Math.max(20,n-16),o,s);t.appendChild(a),this.eGui=t}getGui(){return this.eGui}refresh(e){var a,r;const t=e.value||[],i=e.sparklineOptions||((r=(a=e.column)==null?void 0:a.cellRendererParams)==null?void 0:r.sparklineOptions)||{},s=e.column.width||100,n=i.height||24;this.eGui.innerHTML="";const o=tt(t,Math.max(20,s-16),n,{type:i.type,direction:i.direction});return this.eGui.appendChild(o),!0}}function tt(l,e,t,i={}){var C,w,x;const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("width",String(Math.max(20,e))),s.setAttribute("height",String(t)),s.setAttribute("class","ag-sparkline");const n=(l||[]).map(b=>typeof b=="number"?b:Number((b==null?void 0:b.value)??0));if(!n||n.length<1)return s;const o=i.type||"line",a=Math.min(...n,0),d=Math.max(...n,0)-a||1,c=((C=i.tooltip)==null?void 0:C.enabled)===!0,h=((w=i.axis)==null?void 0:w.type)||"number",g=((x=i.pointsOfInterest)==null?void 0:x.show)===!0,p=(b,y)=>h==="category"?`${b+1}: ${y}`:String(y);if(g&&n.length>1){const b=n.indexOf(Math.min(...n)),y=n.indexOf(Math.max(...n)),N=e/Math.max(1,n.length-1),I=W=>t-2-(W-a)/d*(t-4),D=(W,T)=>{const A=document.createElementNS("http://www.w3.org/2000/svg","circle");A.setAttribute("cx",String(W*N)),A.setAttribute("cy",String(I(n[W]))),A.setAttribute("r","2.5"),A.setAttribute("fill",T),s.appendChild(A)};D(0,"#4caf50"),D(n.length-1,"#f44336"),D(b,"#2196f3"),D(y,"#ff9800")}if(c){const b=document.createElementNS("http://www.w3.org/2000/svg","title");b.textContent=n.map((y,N)=>p(N,y)).join(`
3
+ `),s.appendChild(b),s.style.cursor="default"}if(o==="bar"){const b=i.direction==="vertical",y=n.length;if(b){const N=Math.max(1,e/y-1),I=t-2-(0-a)/d*(t-4);n.forEach((D,W)=>{const T=W*(e/y),A=t-2-(D-a)/d*(t-4),F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("x",String(T)),F.setAttribute("width",String(N)),F.setAttribute("y",String(Math.min(A,I))),F.setAttribute("height",String(Math.max(1,Math.abs(I-A)))),F.setAttribute("fill","currentColor"),s.appendChild(F)})}else{const N=Math.max(1,t/y-1),I=2+(0-a)/d*(e-4);n.forEach((D,W)=>{const T=W*(t/y),A=2+(D-a)/d*(e-4),F=document.createElementNS("http://www.w3.org/2000/svg","rect");F.setAttribute("y",String(T)),F.setAttribute("height",String(N)),F.setAttribute("x",String(Math.min(A,I))),F.setAttribute("width",String(Math.max(1,Math.abs(I-A)))),F.setAttribute("fill","currentColor"),s.appendChild(F)})}return s}const m=e/Math.max(1,n.length-1),f=n.map((b,y)=>{const N=y*m,I=t-2-(b-a)/d*(t-4);return`${N.toFixed(1)},${I.toFixed(1)}`});if(o==="area"){const b=document.createElementNS("http://www.w3.org/2000/svg","polygon");b.setAttribute("points",`0,${t} ${f.join(" ")} ${e},${t}`),b.setAttribute("fill","currentColor"),b.setAttribute("opacity","0.2"),s.appendChild(b)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",f.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),s.appendChild(v),s}class Li{constructor(e){u(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Mt,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const _e={agGroupCellRenderer:l=>new Ei(l),agCheckboxCellRenderer:l=>new Ri(l),agSparklineCellRenderer:l=>new ki(l),agAnimateShowChangeCellRenderer:l=>new Ti(l),agRowNumberCellRenderer:l=>new Ii(l),agRowDragComp:l=>new Li(l)};function Di(l){return l==null?"":String(l)}class Fi{constructor(e){u(this,"eGui");u(this,"cancelled",!1);this.params=e,this.eGui=document.createElement("input"),this.eGui.type="text",this.eGui.className="ag-cell-editor-input",this.eGui.value=e.value??"",this.eGui.addEventListener("keydown",t=>{var i;return(i=e.onKeyDown)==null?void 0:i.call(e,t)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class Pi{constructor(e){u(this,"eGui");u(this,"eInput");u(this,"cancelled",!1);var s,n;this.params=e;const t=document.createElement("div");t.className="ag-cell-editor-number";const i=document.createElement("input");if(i.type="text",i.className="ag-cell-editor-input",i.value=e.value??"",(n=(s=e.column)==null?void 0:s.cellEditorParams)!=null&&n.showStepperButtons){const o=document.createElement("span");o.className="ag-cell-editor-stepper ag-cell-editor-stepper-up",o.innerHTML="▲",o.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),r.preventDefault(),i.value=String(Number(i.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const a=document.createElement("span");a.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",a.innerHTML="▼",a.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),i.value=String(Number(i.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),t.appendChild(o),t.appendChild(i),t.appendChild(a)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",o=>{var a;return(a=e.onKeyDown)==null?void 0:a.call(e,o)})}getGui(){return this.eGui}getValue(){if(this.cancelled)return;const e=Number(this.eInput.value);return isNaN(e)?null:e}focusIn(){this.eInput.focus(),this.eInput.select()}}class Ai{constructor(e){u(this,"eGui");u(this,"cancelled",!1);var i,s;this.params=e,this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((s=(i=e.column)==null?void 0:i.cellEditorParams)==null?void 0:s.values)||[];for(const n of t){const o=document.createElement("option");o.value=String(n),o.textContent=String(n),this.eGui.appendChild(o)}this.eGui.value=String(e.value??""),this.eGui.addEventListener("keydown",n=>{var o;return(o=e.onKeyDown)==null?void 0:o.call(e,n)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus()}}class Gi{constructor(e){u(this,"eGui");u(this,"cancelled",!1);this.params=e,this.eGui=document.createElement("input"),this.eGui.type="date",this.eGui.className="ag-cell-editor-input";const t=e.value instanceof Date?e.value:e.value?new Date(e.value):null;t&&!isNaN(t.getTime())&&(this.eGui.value=t.toISOString().slice(0,10))}getGui(){return this.eGui}getValue(){if(!this.cancelled)return this.eGui.value?new Date(this.eGui.value):null}focusIn(){this.eGui.focus()}}class $i{constructor(e){u(this,"eGui");u(this,"cancelled",!1);this.params=e,this.eGui=document.createElement("textarea"),this.eGui.className="ag-cell-editor-textarea",this.eGui.value=e.value??""}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}function Hi(l,e){if(!e)return ke(l);const t=l.toLowerCase().indexOf(e.toLowerCase());return t<0?ke(l):ke(l.slice(0,t))+'<span class="ag-rich-select-highlight">'+ke(l.slice(t,t+e.length))+"</span>"+ke(l.slice(t+e.length))}class Oi{constructor(e){u(this,"eGui");u(this,"eInput");u(this,"ePopup",null);u(this,"eList",null);u(this,"values",[]);u(this,"filtered",[]);u(this,"activeIndex",0);u(this,"selectedValue");u(this,"cancelled",!1);var t,i;this.params=e,this.values=e.values||((i=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:i.values)||[],this.selectedValue=e.value,this.eGui=document.createElement("div"),this.eGui.className="ag-rich-select",this.eInput=document.createElement("input"),this.eInput.type="text",this.eInput.className="ag-rich-select-input",this.eInput.value=e.value===null||e.value===void 0?"":String(e.value),this.eInput.readOnly=e.allowTyping!==!0,this.eGui.appendChild(this.eInput),this.eGui.addEventListener("mousedown",s=>{s.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",s=>this.onKeyDown(s))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var o,a;if(this.ePopup)return;const e=document.createElement("div");e.className="ag-rich-select-popup";const t=this.eGui.getBoundingClientRect();if(e.style.position="fixed",e.style.left=`${t.left}px`,e.style.top=`${t.bottom}px`,e.style.minWidth=`${Math.max(t.width,180)}px`,e.style.zIndex="1000",(this.eGui.closest(".ag-root")||document.body).appendChild(e),this.ePopup=e,Bi(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((a=(o=this.params).t)==null?void 0:a.call(o,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const s=document.createElement("div");s.className="ag-rich-select-list",e.appendChild(s),this.eList=s,this.renderList();const n=r=>{!e.contains(r.target)&&!this.eGui.contains(r.target)&&(this.closePopup(),document.removeEventListener("mousedown",n,!0))};document.addEventListener("mousedown",n,!0)}renderList(e=""){var i,s;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(n=>{if(!e)return!0;const o=String(n).toLowerCase(),a=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?a.every(r=>o.includes(r)):a.some(r=>o.includes(r))}),this.filtered.forEach((n,o)=>{const a=document.createElement("div");a.className="ag-rich-select-item",o===this.activeIndex&&a.classList.add("ag-active"),String(n)===String(this.selectedValue)&&a.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const d=r({value:n,valueFormatted:String(n)});d instanceof HTMLElement?a.appendChild(d):a.textContent=String(d)}else a.innerHTML=Hi(String(n),e);a.addEventListener("click",d=>{d.stopPropagation(),this.commit(n)}),a.addEventListener("mousedown",d=>d.preventDefault()),this.eList.appendChild(a)}),this.filtered.length===0){const n=document.createElement("div");n.className="ag-rich-select-empty",n.textContent=((s=(i=this.params).t)==null?void 0:s.call(i,"noMatches"))??"无匹配项",this.eList.appendChild(n)}const t=this.eList.children[this.activeIndex];t&&typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"nearest"})}onKeyDown(e){if(e.key==="ArrowDown")e.preventDefault(),this.activeIndex=Math.min(this.filtered.length-1,this.activeIndex+1),this.renderList();else if(e.key==="ArrowUp")e.preventDefault(),this.activeIndex=Math.max(0,this.activeIndex-1),this.renderList();else if(e.key==="Enter"){e.preventDefault();const t=this.filtered[this.activeIndex];t!==void 0?this.commit(t):this.closePopup()}else if(e.key==="Escape")e.preventDefault(),this.cancelled=!0,this.closePopup();else if(e.key==="Tab"){e.preventDefault();const t=this.filtered[this.activeIndex];t!==void 0?this.commit(t):this.closePopup()}}commit(e){this.selectedValue=e,this.eInput.value=String(e),this.closePopup(),setTimeout(()=>{var t,i;return(i=(t=this.params).onKeyDown)==null?void 0:i.call(t,{key:"Enter",preventDefault:()=>{},keyCode:13})},0)}closePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,this.eList=null}getValue(){return this.cancelled?void 0:this.selectedValue}isCancelAfterEnd(){return this.cancelled}destroy(){this.closePopup()}}function Bi(l){var e,t;return(l==null?void 0:l.allowTyping)===!0||((t=(e=l==null?void 0:l.column)==null?void 0:e.cellEditorParams)==null?void 0:t.allowTyping)===!0}const fe={agTextCellEditor:l=>new Fi(l),agNumberCellEditor:l=>new Pi(l),agSelectCellEditor:l=>new Ai(l),agDateCellEditor:l=>new Gi(l),agLargeTextCellEditor:l=>new $i(l),agRichSelectCellEditor:l=>new Oi(l)},Vi='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',zi='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Mt='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="5" cy="3" r="1.4"/><circle cx="11" cy="3" r="1.4"/><circle cx="5" cy="8" r="1.4"/><circle cx="11" cy="8" r="1.4"/><circle cx="5" cy="13" r="1.4"/><circle cx="11" cy="13" r="1.4"/></svg>',Wi='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><circle cx="3" cy="8" r="1.4"/><circle cx="8" cy="8" r="1.4"/><circle cx="13" cy="8" r="1.4"/></svg>',_i='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Ui='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',qi='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Nt='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>';function Tt(l,e,t){const i=l.length;if(i===0||t<=0)return[];let s=0,n=i-1;for(;s<n;){const c=s+n>>1;l[c]>=t?n=c:s=c+1}const o=l[s]>=t?s:i-1,a=e[o];if(!a||a.level===0)return[];const r=[];let d=a.level;for(let c=o-1;c>=0;c--){const h=e[c];if(!(!h||h.level>=d)&&(d=h.level,h.group&&l[c]<t&&r.push(c),h.level===0))break}return r.reverse()}class Ki{constructor(e,t,i){u(this,"ctx");u(this,"eRoot");u(this,"eHeader");u(this,"eBody");u(this,"ePinnedLeft");u(this,"ePinnedRight");u(this,"ePinnedLeftInner");u(this,"ePinnedRightInner");u(this,"eViewport");u(this,"eContainer");u(this,"eFloatingTop");u(this,"eFloatingBottom");u(this,"eFloatingTopLeft");u(this,"eFloatingTopRight");u(this,"eFloatingBottomLeft");u(this,"eFloatingBottomRight");u(this,"eStickyTop");u(this,"eStickyLeft");u(this,"eStickyCenter");u(this,"eStickyRight");u(this,"eRangeOverlay",null);u(this,"rowComps",new Map);u(this,"stickyComps",new Map);u(this,"hoveredRowId",null);u(this,"rowOffsets",[]);u(this,"rowInfos",[]);u(this,"totalHeight",0);u(this,"lastScrollTop",-1);u(this,"lastRange",[-1,-1]);u(this,"firstRendered",!1);u(this,"heightVersion",0);u(this,"scrollFrame",null);u(this,"onSectionWheel",e=>{if(e.ctrlKey||!e.cancelable)return;const t=e.target;if(t!=null&&t.closest('input, textarea, select, [contenteditable="true"]'))return;const i=this.eViewport;let s=e.deltaY,n=e.deltaX;e.deltaMode===1?(s*=33,n*=33):e.deltaMode===2&&(s*=i.clientHeight,n*=i.clientWidth),s&&(i.scrollTop+=s),n&&(i.scrollLeft+=n),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});u(this,"onBodyMouseOver",e=>{var n;const t=e.target,i=(n=t==null?void 0:t.closest)==null?void 0:n.call(t,".ag-row"),s=(i==null?void 0:i.dataset.rowid)??null;if(s===this.hoveredRowId){s&&this.setRowHovered(s,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=s,s&&this.setRowHovered(s,!0)});u(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=i,this.eRoot=e,this.eHeader=t,this.eBody=document.createElement("div"),this.eBody.className="ag-body",this.eRoot.appendChild(this.eBody),this.ePinnedLeft=document.createElement("div"),this.ePinnedLeft.className="ag-pinned-left-cols-viewport",this.eBody.appendChild(this.ePinnedLeft),this.ePinnedLeftInner=document.createElement("div"),this.ePinnedLeftInner.className="ag-pinned-cols-inner",this.ePinnedLeft.appendChild(this.ePinnedLeftInner);const s=document.createElement("div");s.className="ag-body-viewport-wrapper",this.eBody.appendChild(s),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",s.appendChild(this.eFloatingTop),this.eViewport=document.createElement("div"),this.eViewport.className="ag-body-viewport",this.eViewport.tabIndex=0,this.eViewport.addEventListener("scroll",this.onScroll.bind(this)),this.eViewport.addEventListener("keydown",n=>this.ctx.onViewportKeyDown(n)),s.appendChild(this.eViewport),this.eContainer=document.createElement("div"),this.eContainer.className="ag-body-container",this.eViewport.appendChild(this.eContainer),this.eFloatingBottom=document.createElement("div"),this.eFloatingBottom.className="ag-floating-bottom",s.appendChild(this.eFloatingBottom),this.ePinnedRight=document.createElement("div"),this.ePinnedRight.className="ag-pinned-right-cols-viewport",this.eBody.appendChild(this.ePinnedRight),this.ePinnedRightInner=document.createElement("div"),this.ePinnedRightInner.className="ag-pinned-cols-inner",this.ePinnedRight.appendChild(this.ePinnedRightInner),this.eFloatingTopLeft=document.createElement("div"),this.eFloatingTopLeft.className="ag-floating-pinned-cols ag-floating-pinned-left",this.eBody.appendChild(this.eFloatingTopLeft),this.eFloatingTopRight=document.createElement("div"),this.eFloatingTopRight.className="ag-floating-pinned-cols ag-floating-pinned-right",this.eBody.appendChild(this.eFloatingTopRight),this.eFloatingBottomLeft=document.createElement("div"),this.eFloatingBottomLeft.className="ag-floating-pinned-cols ag-floating-pinned-bottom-left",this.eBody.appendChild(this.eFloatingBottomLeft),this.eFloatingBottomRight=document.createElement("div"),this.eFloatingBottomRight.className="ag-floating-pinned-cols ag-floating-pinned-bottom-right",this.eBody.appendChild(this.eFloatingBottomRight),this.eStickyTop=document.createElement("div"),this.eStickyTop.className="ag-sticky-group-rows",this.eBody.appendChild(this.eStickyTop),this.eStickyLeft=document.createElement("div"),this.eStickyLeft.className="ag-sticky-group-rows-left",this.eStickyTop.appendChild(this.eStickyLeft),this.eStickyCenter=document.createElement("div"),this.eStickyCenter.className="ag-sticky-group-rows-center",this.eStickyTop.appendChild(this.eStickyCenter),this.eStickyRight=document.createElement("div"),this.eStickyRight.className="ag-sticky-group-rows-right",this.eStickyTop.appendChild(this.eStickyRight);for(const n of[this.eFloatingTopLeft,this.eFloatingTopRight,this.eFloatingBottomLeft,this.eFloatingBottomRight,this.eStickyLeft,this.eStickyCenter,this.eStickyRight])n.addEventListener("click",this.onClick.bind(this)),n.addEventListener("dblclick",this.onDoubleClick.bind(this)),n.addEventListener("mousedown",this.onMouseDown.bind(this)),n.addEventListener("contextmenu",this.onContextMenu.bind(this)),n.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.ePinnedLeft.addEventListener("click",this.onClick.bind(this)),this.ePinnedLeft.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedLeft.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedLeft.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eContainer.addEventListener("click",this.onClick.bind(this)),this.eContainer.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eContainer.addEventListener("mousedown",this.onMouseDown.bind(this)),this.eContainer.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.ePinnedRight.addEventListener("click",this.onClick.bind(this)),this.ePinnedRight.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.ePinnedRight.addEventListener("mousedown",this.onMouseDown.bind(this)),this.ePinnedRight.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingTop.addEventListener("click",this.onClick.bind(this)),this.eFloatingTop.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingTop.addEventListener("contextmenu",this.onContextMenu.bind(this)),this.eFloatingBottom.addEventListener("click",this.onClick.bind(this)),this.eFloatingBottom.addEventListener("dblclick",this.onDoubleClick.bind(this)),this.eFloatingBottom.addEventListener("contextmenu",this.onContextMenu.bind(this));for(const n of[this.eViewport,this.ePinnedLeft,this.ePinnedRight,this.eFloatingTop,this.eFloatingBottom,this.eHeader])n.addEventListener("wheel",this.onSectionWheel,{passive:!1});this.eBody.addEventListener("mouseover",this.onBodyMouseOver),this.eBody.addEventListener("mouseleave",this.onBodyMouseLeave)}setRowHovered(e,t){for(const i of this.rowComps.values())i.getNode().id===e&&i.setHovered(t);for(const i of this.stickyComps.values())i.getNode().id===e&&i.setHovered(t)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}setRangeOverlay(e){this.eRangeOverlay=e}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount(),t=new Array(e),i=new Array(e);let s=0;if(this.hasVariableHeights()){for(let o=0;o<e;o++)t[o]=s,i[o]=this.rowInfoAt(o),s+=this.getRowHeightForIndex(o);this.totalHeight=s}else{const o=this.getFixedRowHeight();for(let a=0;a<e;a++)t[a]=a*o,i[a]=this.rowInfoAt(a);this.totalHeight=e*o}this.rowOffsets=t,this.rowInfos=i}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?{level:t.uiLevel??t.level??0,group:!!t.group}:{level:0,group:!1}}hasVariableHeights(){return!!(this.ctx.options.detailRowAutoHeight||this.ctx.options.getRowHeight)}getFixedRowHeight(){return this.ctx.options.rowHeight??42}getRowHeightForIndex(e){const t=this.ctx.rowModel.getRow(e);return t?this.ctx.getRowHeight(t):this.getFixedRowHeight()}refreshRows(){this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`;const e=this.ctx.getColumns().center.reduce((s,n)=>s+n.width,0),t=this.ctx.getColumns().left.reduce((s,n)=>s+n.width,0),i=this.ctx.getColumns().right.reduce((s,n)=>s+n.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${t}px`,this.ePinnedRight.style.width=`${i}px`,this.ePinnedLeft.style.height=`${this.totalHeight}px`,this.ePinnedRight.style.height=`${this.totalHeight}px`,this.eFloatingTopLeft.style.width=`${t}px`,this.eFloatingTopRight.style.width=`${i}px`,this.eFloatingBottomLeft.style.width=`${t}px`,this.eFloatingBottomRight.style.width=`${i}px`,this.eStickyLeft.style.width=`${t}px`,this.eStickyRight.style.width=`${i}px`,this.eStickyCenter.style.left=`${t}px`,this.eStickyCenter.style.right=`${i}px`,this.redrawAllRows()}invalidateRowHeights(){this.heightVersion++,this.recomputeOffsets(),this.eContainer.style.height=`${this.totalHeight}px`,this.redrawAllRows()}redrawAllRows(){for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear(),this.lastRange=[-1,-1],this.renderPinnedRows(),this.renderVisibleRows(!0)}renderPinnedRows(){var i,s;const e=(n,o,a,r,d)=>{n.innerHTML="",o.innerHTML="",a.innerHTML="";const{left:c,center:h,right:g}=this.ctx.getColumns();let p=0;for(let m=0;m<r;m++){const f=d(m);if(!f)continue;const v=this.ctx.getRowHeight(f),C=new Ue(this.ctx,f,c,h,g,v,this.heightVersion);C.appendTo(o,n,a),C.setTop(p),p+=v,this.rowComps.set(`${f.id}|${n===this.eFloatingTop?"top":"bottom"}`,C)}n.style.height=`${p}px`,n.style.display=r>0?"":"none",o.style.height=`${p}px`,a.style.height=`${p}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((i=t.getPinnedTopRowCount)==null?void 0:i.call(t))??0,n=>{var o;return(o=t.getPinnedTopRow)==null?void 0:o.call(t,n)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((s=t.getPinnedBottomRowCount)==null?void 0:s.call(t))??0,n=>{var o;return(o=t.getPinnedBottomRow)==null?void 0:o.call(t,n)})}refreshCells(e){const t=e==null?void 0:e.rowNodes;let i;e!=null&&e.columns&&(i=e.columns.map(s=>typeof s=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(n=>n.colId===s):s).filter(Boolean));for(const[s,n]of this.rowComps)t&&!t.includes(n.getNode())||n.refreshCells(i,e==null?void 0:e.force,e==null?void 0:e.flash);for(const s of this.stickyComps.values())t&&!t.includes(s.getNode())||s.refreshCells(i,e==null?void 0:e.force,e==null?void 0:e.flash)}flashCells(e){this.refreshCells({...e,force:!0,flash:!0})}redrawRows(e){if(!(e!=null&&e.rowNodes)){this.redrawAllRows();return}for(const t of this.rowComps.values())if(e.rowNodes.includes(t.getNode())){const i=t.getNode(),s=this.findRowIndex(i);if(t.destroy(),this.rowComps.delete(this.rowCompKey(i)),s>=0){const{left:n,center:o,right:a}=this.ctx.getColumns(),r=new Ue(this.ctx,i,n,o,a,this.getRowHeightForIndex(s),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[s]??0),this.rowComps.set(this.rowCompKey(i),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){var t;for(let i=0;i<this.ctx.rowModel.getRowCount();i++)if(((t=this.ctx.rowModel.getRow(i))==null?void 0:t.id)===e.id)return i;return-1}scheduleScrollRender(){this.scrollFrame===null&&(this.scrollFrame=requestAnimationFrame(()=>{this.scrollFrame=null,this.renderVisibleRows()}))}onScroll(){this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),this.ctx.eventService.dispatchEvent("bodyScroll",{direction:"vertical",top:this.eViewport.scrollTop,left:this.eViewport.scrollLeft})}syncPinnedScroll(){const e=`translateY(${-this.eViewport.scrollTop}px)`;this.ePinnedLeftInner.style.transform=e,this.ePinnedRightInner.style.transform=e,this.ePinnedLeft.scrollTop=this.eViewport.scrollTop,this.ePinnedRight.scrollTop=this.eViewport.scrollTop,this.syncStickyHorizontal()}syncStickyHorizontal(){const i=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const s of this.stickyComps.values()){const n=s.getCenterElement();n&&(n.style.transform=i)}}getVerticalScrollTop(){return this.eViewport.scrollTop}setVerticalScrollTop(e){this.eViewport.scrollTop=e,this.syncPinnedScroll(),this.renderVisibleRows()}getHorizontalScrollLeft(){return this.eViewport.scrollLeft}getVerticalScrollbarWidth(){return Math.max(0,this.eViewport.offsetWidth-this.eViewport.clientWidth)}setHorizontalScrollLeft(e){this.eViewport.scrollLeft=e,this.eHeader.scrollLeft=e,this.syncPinnedScroll()}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Tt(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:i,right:s}=this.ctx.getColumns(),n=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${n}px`;const o=new Set;let a=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;o.add(c.id);let h=this.stickyComps.get(c.id);if(!h){const g=this.rowComps.get(c.id);g&&(g.destroy(),this.rowComps.delete(c.id)),h=new Ue(this.ctx,c,t,i,s,this.getRowHeightForIndex(d),this.heightVersion),h.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),h.setSticky(!0),this.stickyComps.set(c.id,h)}h.setTop(a),a+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)o.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${a}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),o}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),i=this.eViewport.scrollTop,s=this.eViewport.clientHeight,n=this.ctx.options.rowBuffer??10;let o=0,a=t-1;if(this.hasVariableHeights())o=this.findIndexAtPixel(i)-n,a=this.findIndexAtPixel(i+s)+n;else{const v=this.getFixedRowHeight();o=Math.floor(i/v)-n,a=Math.ceil((i+s)/v)+n}if(o=Math.max(0,o),a=Math.min(t-1,a),!e&&this.lastRange[0]===o&&this.lastRange[1]===a&&this.lastScrollTop===i)return;const r=this.lastRange[0]!==o||this.lastRange[1]!==a;this.lastRange=[o,a],this.lastScrollTop=i;const d=new Set(this.stickyComps.keys()),c=this.syncStickyGroupRows(),h=d.size!==c.size||[...d].some(v=>!c.has(v));if(!e&&!r&&!h)return;const g=new Set(c),{left:p,center:m,right:f}=this.ctx.getColumns();for(let v=o;v<=a;v++){const C=this.ctx.rowModel.getRow(v);if(!C||(g.add(C.id),c.has(C.id)))continue;let w=this.rowComps.get(C.id);w||(w=new Ue(this.ctx,C,p,m,f,this.getRowHeightForIndex(v),this.heightVersion),w.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(C.id,w)),w.setTop(this.rowOffsets[v]??v*this.getFixedRowHeight())}for(const[v,C]of this.rowComps)!g.has(v)&&!C.isPinned()&&(C.destroy(),this.rowComps.delete(v))}findIndexAtPixel(e){const t=this.rowOffsets;let i=0,s=t.length-1;for(;i<s;){const n=i+s+1>>1;t[n]<=e?i=n:s=n-1}return i}ensureIndexVisible(e,t="top"){const i=this.rowOffsets[e]??e*this.getFixedRowHeight(),s=this.getRowHeightForIndex(e),n=this.eViewport.clientHeight;let o=this.eViewport.scrollTop;t==="top"?o=i:t==="bottom"?o=i+s-n:o=i-(n-s)/2,this.eViewport.scrollTop=Math.max(0,o),this.renderVisibleRows()}getFirstVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop))}getLastVisibleRowIndex(){return Math.max(0,this.findIndexAtPixel(this.eViewport.scrollTop+this.eViewport.clientHeight))}ensureColumnVisible(e,t="end"){const i=this.eViewport.clientWidth,s=this.eViewport.scrollLeft,n=e.left-this.ctx.getColumns().left.reduce((o,a)=>o+a.width,0);n<s?this.eViewport.scrollLeft=Math.max(0,t==="middle"?n-(i-e.width)/2:n):n+e.width>s+i&&(this.eViewport.scrollLeft=n+e.width-i),this.renderVisibleRows()}getCellPosition(e,t){return{top:this.rowOffsets[e]??e*this.getFixedRowHeight(),left:t.left,height:this.getRowHeightForIndex(e),width:t.width}}getRowOffsets(){return this.rowOffsets}getTotalHeight(){return this.totalHeight}findCellFromEvent(e){const i=e.target.closest(".ag-cell");if(!i)return null;const s=i.dataset.colid;if(!s)return null;const n=i.closest(".ag-row"),o=n==null?void 0:n.dataset.rowid;if(!o)return null;const a=this.ctx.rowModel.getRowNode(o);if(!a)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===s);return d?(this.ctx.rowModel.getRowCount(),{node:a,column:d,eCell:i,rowIndex:0}):null}getRowIndexForNode(e){var t;for(let i=0;i<this.ctx.rowModel.getRowCount();i++)if(((t=this.ctx.rowModel.getRow(i))==null?void 0:t.id)===e.id)return i;return-1}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:H(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node),colDef:t.column.colDef});return}const i=e.target.closest(".ag-row");if(i!=null&&i.dataset.rowid){const s=this.ctx.rowModel.getRowNode(i.dataset.rowid);s&&this.ctx.onRowClicked({event:e,node:s,data:s.data,rowIndex:this.getRowIndexForNode(s)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:H(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node),colDef:t.column.colDef});return}const i=e.target.closest(".ag-row");if(i!=null&&i.dataset.rowid){const s=this.ctx.rowModel.getRowNode(i.dataset.rowid);s&&this.ctx.onRowDoubleClicked({event:e,node:s,data:s.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:H(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:H(t.column,t.node,null),rowIndex:this.getRowIndexForNode(t.node)})}destroy(){this.scrollFrame!==null&&cancelAnimationFrame(this.scrollFrame),this.scrollFrame=null;for(const e of this.rowComps.values())e.destroy();this.rowComps.clear();for(const e of this.stickyComps.values())e.destroy();this.stickyComps.clear()}}class Ue{constructor(e,t,i,s,n,o,a){u(this,"eLeft",null);u(this,"eCenter",null);u(this,"eRight",null);u(this,"cellComps",[]);u(this,"pinned",!1);var r,d,c,h,g,p,m,f,v;if(this.ctx=e,this.node=t,this.rowHeight=o,this.heightVersion=a,t.masterNode){const C=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(C){const w=document.createElement("div");w.className="ag-row ag-row-detail-row",w.dataset.rowid=t.id,w.style.height=`${C.height}px`,w.style.width="100%",w.appendChild(C.eDetail),this.eCenter=w,this.eLeft=null,this.eRight=null}return}i.length&&(this.eLeft=this.createRowElement(t,i,"left"),this.eLeft.classList.add("ag-row-pinned")),(s.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,s,"center")),n.length&&(this.eRight=this.createRowElement(t,n,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),t.group&&((h=this.eCenter)==null||h.classList.add("ag-row-group"),(g=this.eLeft)==null||g.classList.add("ag-row-group"),(p=this.eRight)==null||p.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((m=this.eCenter)==null||m.classList.add("ag-row-selected"),(f=this.eLeft)==null||f.classList.add("ag-row-selected"),(v=this.eRight)==null||v.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,i,s;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-sticky-group",e),(s=this.eRight)==null||s.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,i,s;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-hover",e),(s=this.eRight)==null||s.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,i){var r;const s=document.createElement("div");s.className="ag-row",s.dataset.rowid=e.id,s.setAttribute("role","row"),s.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),s.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&s.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&s.classList.add("ag-row-even"),s.style.height=`${this.rowHeight}px`,s.style.position="absolute",s.style.top="0px";const n=this.ctx.getRowClass(e);n&&s.classList.add(...n.split(" ").filter(Boolean));const o=this.ctx.getRowStyle(e);o&&Object.assign(s.style,o),e.footer&&((r=e.groupData)!=null&&r.__grandTotal)&&(s.classList.add("ag-row-full-width"),s.style.width="100%",s.style.right="0",s.style.left="0");let a=0;for(let d=0;d<t.length;d++){const c=t[d],h=this.createCell(c,e);let g=1;typeof c.colDef.colSpan=="function"&&(g=Math.max(1,Math.round(c.colDef.colSpan({value:H(c,e,null),data:e.data,node:e,column:c,rowIndex:e.__displayIndex??0,api:null}))));let p=c.width;for(let m=1;m<g&&d+m<t.length;m++)p+=t[d+m].width;h.eCell.style.left=`${a}px`,h.eCell.style.width=`${p}px`,h.eCell.style.position="absolute",h.eCell.style.top="0",h.eCell.style.height=`${this.rowHeight}px`,g>1&&h.eCell.classList.add("ag-cell-col-span"),a+=p,d+=g-1,s.appendChild(h.eCell),this.cellComps.push(h)}return s.style.width=`${a}px`,s}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(i=>i.colId===e.colId)+1}createCell(e,t){var c,h;const i=document.createElement("div");i.className="ag-cell",i.dataset.colid=e.colId;const s=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");s&&i.classList.add(`ag-col-${s}`);const n={value:H(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const g=typeof e.cellClass=="function"?e.cellClass(n):e.cellClass;typeof g=="string"?i.classList.add(...g.split(" ").filter(Boolean)):Array.isArray(g)&&i.classList.add(...g)}if(e.cellClassRules)for(const[g,p]of Object.entries(e.cellClassRules))p(n)&&i.classList.add(g);if(e.cellStyle){const g=typeof e.cellStyle=="function"?e.cellStyle(n):e.cellStyle;Object.assign(i.style,g)}(e.type==="numberColumn"||e.cellDataType===!0)&&i.classList.add("ag-right-aligned-cell"),e.rowDrag&&i.classList.add("ag-cell-row-drag");const o=document.createElement("span");o.className="ag-cell-value",i.appendChild(o),this.ctx.options.enableCellTextSelection&&(i.style.userSelect="text",i.style.cursor="text"),i.setAttribute("role","gridcell"),i.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const a=(h=(c=this.ctx).getNote)==null?void 0:h.call(c,t.id,e.colId,e.colDef.note,{value:H(e,t,null),data:t.data,node:t,column:e,api:null});if(a){const g=document.createElement("span");g.className="ag-cell-note-marker",g.title=a,g.addEventListener("click",p=>{var m,f;p.stopPropagation(),(f=(m=this.ctx).onNoteClick)==null||f.call(m,t.id,e.colId,g)}),i.appendChild(g)}if(e.rowDrag){const g=document.createElement("span");g.className="ag-row-drag-handle",g.innerHTML=Mt,g.title=this.ctx.t("dragRow"),g.addEventListener("mousedown",p=>{var m,f;p.button===0&&(p.stopPropagation(),(f=(m=this.ctx).onRowDragStart)==null||f.call(m,t,g,p))}),i.appendChild(g)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?i.title=String(t.data[r]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:H(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:i,eValue:o,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:t,node:i}={column:e.column,node:this.node},s=H(t,i,null),n=Ve(t,i,null);e.lastValue=s,e.lastFormatted=n;const o=typeof t.cellRenderer=="string"?t.cellRenderer:null,a=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(o||a){e.custom=!0;const c=o||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const h={value:s,valueFormatted:n,data:i.data,node:i,column:t,rowIndex:i.__displayIndex??0,api:null,colDef:t.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...t.cellRendererParams||{}};let g=null;if(o&&_e[o]){const p=_e[o](h);p instanceof HTMLElement?g=p:(e.rendererInstance=p,g=p.getGui())}else if(a){const p=a(h);p instanceof HTMLElement?g=p:p&&typeof p.getGui=="function"?(e.rendererInstance=p,g=p.getGui()):typeof p=="string"&&(e.eValue.innerHTML=p)}g&&e.eValue.appendChild(g)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=n??"";if((i.group||i.footer)&&i.groupData){const c=i.groupData[t.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,i){var o,a,r,d;const s=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(s&&!s.has(c.column.colId))continue;const h=H(c.column,this.node,null),g=t||h!==c.lastValue;if(!g&&!i)continue;const p=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:h,valueFormatted:Ve(c.column,this.node,null),data:this.node.data,node:this.node,column:c.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:c.column.colDef,eGridCell:c.eCell,...c.column.cellRendererParams||{}})===!1&&this.updateCellContent(c),c.lastValue=h,i&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(g||i)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=h,i&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(i||g&&p!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"))}const n=this.ctx.isNodeSelected(this.node);(o=this.eCenter)==null||o.classList.toggle("ag-row-selected",n),(a=this.eLeft)==null||a.classList.toggle("ag-row-selected",n),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",n),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,i){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&i.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const s=this.ctx.renderDetailRow(this.node,this.eCenter);s&&t.appendChild(s.eDetail)}}setTop(e){const t=`${e}px`;this.eLeft&&this.eLeft.style.top!==t&&(this.eLeft.style.top=t),this.eCenter&&this.eCenter.style.top!==t&&(this.eCenter.style.top=t),this.eRight&&this.eRight.style.top!==t&&(this.eRight.style.top=t)}getCenterElement(){return this.eCenter}getCellElements(){return this.cellComps.map(e=>e.eCell)}destroy(){var e,t,i,s;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(t=this.eCenter)!=null&&t.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(i=this.eRight)!=null&&i.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const n of this.cellComps)(s=n.rendererInstance)!=null&&s.destroy&&n.rendererInstance.destroy();this.cellComps=[]}}class Xi{constructor(e,t){u(this,"ctx");u(this,"eHeader");u(this,"ePinnedLeftHeader");u(this,"ePinnedRightHeader");u(this,"eHeaderViewport");u(this,"eHeaderContainer");u(this,"eHeaderRow");u(this,"eFloatingFiltersRow",null);u(this,"eGroupRows");u(this,"headerCells",new Map);u(this,"customHeaderComponents",new Map);u(this,"resizeState",null);u(this,"dragState",null);u(this,"lastWidths",new Map);this.ctx=t,this.eHeader=e,e.classList.add("ag-header"),e.style.height=`${t.headerHeight}px`,this.ePinnedLeftHeader=document.createElement("div"),this.ePinnedLeftHeader.className="ag-pinned-left-header",e.appendChild(this.ePinnedLeftHeader),this.eHeaderViewport=document.createElement("div"),this.eHeaderViewport.className="ag-header-viewport",e.appendChild(this.eHeaderViewport),this.eHeaderContainer=document.createElement("div"),this.eHeaderContainer.className="ag-header-container",this.eHeaderViewport.appendChild(this.eHeaderContainer),this.eGroupRows=document.createElement("div"),this.eGroupRows.className="ag-group-header-rows",this.eHeaderContainer.appendChild(this.eGroupRows),this.eHeaderRow=document.createElement("div"),this.eHeaderRow.className="ag-header-row",this.eHeaderContainer.appendChild(this.eHeaderRow),this.ePinnedRightHeader=document.createElement("div"),this.ePinnedRightHeader.className="ag-pinned-right-header",e.appendChild(this.ePinnedRightHeader),this.refresh()}refresh(){this.headerCells.clear(),this.renderGroupRows();const{left:e,center:t,right:i}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,t,"center"),this.renderSection(this.ePinnedRightHeader,i,"right");const s=[...e,...t,...i].some(n=>n.floatingFilter);s&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!s&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var a;const e=this.ctx.getColumnModel(),t=((a=e==null?void 0:e.getColumnGroups)==null?void 0:a.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((r,d)=>Math.max(r,d.depth),0),s=this.ctx.options.groupHeaderHeight??30;let n=0;for(let r=1;r<=i;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${s}px`;const c=this.ctx.getColumns().center;let h=0,g,p=0,m=0;const f=(C,w)=>{let x=C.groupId;for(;x;){const b=t.find(y=>y.id===x);if(!b)return null;if(b.depth===w)return b.id;x=b.parentId}return null},v=()=>{if(g==null)return;const C=t.find(y=>y.id===g);if(!C)return;const w=document.createElement("div");w.className="ag-header-group-cell",w.style.left=`${p}px`,w.style.width=`${m}px`,w.style.height=`${s}px`;const x=e.isGroupOpen(C.id),b=document.createElement("div");if(b.className="ag-header-group-cell-label",b.textContent=C.headerName,w.appendChild(b),!x){const y=document.createElement("span");y.className="ag-header-group-expand",y.textContent="▸",y.title=this.ctx.t("expandGroup"),w.appendChild(y)}w.addEventListener("click",()=>{e.setGroupOpen(C.id,!x)}),d.appendChild(w)};c.forEach(C=>{const w=f(C,r);w!==g&&(v(),g=w,p=h,m=0),m+=C.width,h+=C.width}),v(),d.style.width=`${h}px`,this.eGroupRows.appendChild(d),n+=s}this.eGroupRows.style.display=i>0?"":"none";const o=this.ctx.headerHeight;this.eHeader.style.height=`${n+o}px`}renderSection(e,t,i){e.innerHTML="";let s=0;for(const n of t){const o=this.createHeaderCell(n);if(o.style.left=`${s}px`,o.style.width=`${n.width}px`,o.style.height=`${this.ctx.headerHeight}px`,s+=n.width,e.appendChild(o),this.headerCells.set(n.colId,o),n.eHeaderCell=o,this.eFloatingFiltersRow&&e===this.eHeaderRow&&n.floatingFilter){const a=this.createFloatingFilter(n);a.style.left=`${s-n.width}px`,a.style.width=`${n.width}px`,this.eFloatingFiltersRow.appendChild(a)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${s}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${s}px`)}createHeaderCell(e){var o,a;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const r=i({column:e,colDef:e.colDef,api:((a=(o=this.ctx).getApi)==null?void 0:a.call(o))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),t.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const s=document.createElement("div");if(s.className="ag-header-cell-label",e.headerTooltip&&(s.title=e.headerTooltip),e.headerCheckboxSelection){const r=document.createElement("input");r.type="checkbox",r.className="ag-native-checkbox ag-header-select-all",r.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,r.checked)),r.addEventListener("click",d=>d.stopPropagation()),s.appendChild(r)}const n=document.createElement("span");if(n.className="ag-header-cell-text",n.textContent=e.headerName,s.appendChild(n),t.appendChild(s),e.sortable){const r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=_i,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=Wi,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const d=t.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=g=>{if(!this.resizeState)return;const p=g.clientX-this.resizeState.startX;let m=this.resizeState.startWidth+p;m=Math.max(e.minWidth,Math.min(e.maxWidth,m)),this.ctx.onColumnResized(e,Math.round(m),!1)},h=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",h),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",h)}),t.appendChild(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=t.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),t}createFloatingFilter(e){const t=document.createElement("div");if(t.className="ag-header-cell ag-floating-filter-cell",t.dataset.colid=e.colId,t.style.position="absolute",t.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const s=document.createElement("select");return s.className="ag-floating-filter-input",s.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',s.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,s.value)),t.appendChild(s),e.floatingFilterComp=s,t}const i=document.createElement("input");return i.className="ag-floating-filter-input",i.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",i.placeholder=this.ctx.t("filterOoo"),i.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),i.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,i.value)),t.appendChild(i),e.floatingFilterComp=i,t}updateSortIndicator(e,t,i){if(e.innerHTML="",t==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=Ui):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=qi),t&&i!==null&&i>0){const s=document.createElement("span");s.className="ag-sort-order",s.textContent=String(i+1),e.appendChild(s)}}updateIndicators(){const{left:e,center:t,right:i}=this.ctx.getColumns();for(const s of[...e,...t,...i]){const n=this.headerCells.get(s.colId);if(!n)continue;const o=n.querySelector(".ag-sort-indicator");o&&this.updateSortIndicator(o,s.sort,s.sortIndex);const a=n.querySelector(".ag-filter-icon");a&&a.classList.toggle("ag-filter-active",this.ctx.isFilterActive(s)),n.style.width=`${s.width}px`,this.lastWidths.get(s.colId)!==s.width&&this.lastWidths.set(s.colId,s.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(i=>i.colId===e.colId)+1}layoutPositions(){const{left:e,center:t,right:i}=this.ctx.getColumns();let s=0;for(const n of e){const o=this.headerCells.get(n.colId);o&&(o.style.left=`${s}px`),s+=n.width}this.ePinnedLeftHeader.style.width=`${s}px`,s=0;for(const n of t){const o=this.headerCells.get(n.colId);o&&(o.style.left=`${s}px`),s+=n.width}this.eHeaderContainer.style.width=`${s}px`,s=0;for(const n of i){const o=this.headerCells.get(n.colId);o&&(o.style.left=`${s}px`),s+=n.width}if(this.ePinnedRightHeader.style.width=`${s}px`,this.eFloatingFiltersRow){s=0;for(const n of t){const o=this.eFloatingFiltersRow.querySelector(`[data-colid="${n.colId}"]`);o&&(o.style.left=`${s}px`,o.style.width=`${n.width}px`),s+=n.width}}}setScrollLeft(e,t=0){this.eHeaderViewport.style.marginInlineEnd=`${t}px`,this.eHeaderViewport.scrollLeft=e}getHeaderCell(e){return this.headerCells.get(e.colId)}getHeaderRow(){return this.eHeaderRow}}class ji{constructor(e,t,i){u(this,"selectedNodes",new Set);u(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=t,this.isNodeSelectable=i}isEnabled(){return!!this.getOptions().rowSelection}getSelectedNodes(){return[...this.selectedNodes]}getSelectedRows(){return[...this.selectedNodes].map(e=>e.data)}getSelectedCount(){return this.selectedNodes.size}isNodeSelected(e){return this.selectedNodes.has(e)}selectNode(e,t=!1){this.isEnabled()&&this.isNodeSelectable(e)&&(t&&this.getOptions().rowSelection==="multiple"?this.deselectAll():t&&this.deselectAll(),!this.selectedNodes.has(e)&&(this.selectedNodes.add(e),e.selected=!0,this.lastSelectedNode=e,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!0),this.dispatchChanged()))}deselectNode(e){this.selectedNodes.has(e)&&(this.selectedNodes.delete(e),e.selected=!1,this.getOptions().groupSelectsChildren&&e.children&&this.selectChildrenRecursively(e,!1),this.dispatchChanged())}selectChildrenRecursively(e,t){if(e.children)for(const i of e.children)i.footer||i.detailNode||(t?this.isNodeSelectable(i)&&(this.selectedNodes.add(i),i.selected=!0):(this.selectedNodes.delete(i),i.selected=!1),this.selectChildrenRecursively(i,t))}selectAll(){!this.isEnabled()||this.getOptions().rowSelection!=="multiple"||this.selectAllFiltered()}selectAllFiltered(){if(!this.isEnabled())return;const e=this.getOptions().__rowModel;e!=null&&e.forEachNode&&e.forEachNode(t=>{this.isNodeSelectable(t)&&!t.footer&&(this.selectedNodes.add(t),t.selected=!0)}),this.dispatchChanged()}deselectAll(){for(const e of this.selectedNodes)e.selected=!1;this.selectedNodes.clear(),this.lastSelectedNode=null,this.dispatchChanged()}toggleNode(e){this.selectedNodes.has(e)?this.deselectNode(e):this.selectNode(e,!1)}handleRowClick(e,t){if(!this.isEnabled()||this.getOptions().suppressRowClickSelection)return!1;const i=this.getOptions().rowSelection==="multiple",s=t.ctrlKey||t.metaKey,n=t.shiftKey;return i?n&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):s?(this.toggleNode(e),!0):(this.getOptions().rowMultiSelectWithClick?this.selectNode(e,!1):this.selectNode(e,!0),!0):(this.selectNode(e,!0),!0)}selectRange(e,t){const i=this.getOptions().__rowModel;if(!(i!=null&&i.forEachNode))return;let s=-1,n=-1,o=0;if(i.forEachNode(d=>{d===e&&(s=o),d===t&&(n=o),o++}),s<0||n<0)return;const a=Math.min(s,n),r=Math.max(s,n);o=0,i.forEachNode(d=>{o>=a&&o<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.selected=!0),o++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(s=>t.add(s));let i=!1;for(const s of this.selectedNodes)t.has(s)?s.selected=!0:i=!0;if(i){for(const s of[...this.selectedNodes])t.has(s)||this.selectedNodes.delete(s);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let t=0,i=0;return e!=null&&e.forEachNode&&e.forEachNode(s=>{s.footer||!this.isNodeSelectable(s)||(t++,s.selected&&i++)}),{checked:t>0&&i===t,indeterminate:i>0&&i<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Yi{constructor(e,t){u(this,"editing",null);u(this,"fullRowEditors",null);u(this,"fullRowNode",null);u(this,"focusedCell",null);u(this,"suppressClickEdit",!1);this.grid=e,this.eventService=t}getFocusedCell(){return this.focusedCell}setFocusedCell(e,t){this.focusedCell={rowIndex:e,column:t,rowNode:this.grid.getDisplayedRowAtIndex(e)},this.grid.getRowRenderer().refreshCells({force:!0}),this.clearFocusClass();const i=this.findCellElement(t,e);i==null||i.classList.add("ag-cell-focus"),i&&typeof i.scrollIntoView=="function"&&i.scrollIntoView({block:"nearest",inline:"nearest"}),this.eventService.dispatchEvent("cellFocused",{rowIndex:e,column:t,api:this.grid.getApi(),forceBrowserFocus:!0})}clearFocusedCell(){this.focusedCell=null,this.clearFocusClass(),this.grid.getRowRenderer().refreshCells({force:!0})}clearFocusClass(){const e=this.grid.getRootElement();for(const t of e.querySelectorAll(".ag-cell-focus"))t.classList.remove("ag-cell-focus")}findCellElement(e,t){const i=this.grid.getDisplayedRowAtIndex(t);if(!i)return null;const n=this.grid.getRowRenderer().getRowComps().get(i.id);return n&&n.getCellElements().find(o=>o.dataset.colid===e.colId)||null}isEditing(){return this.editing!==null||this.fullRowEditors!==null}getEditingCells(){return this.editing?[{rowIndex:this.editing.rowIndex,colId:this.editing.column.colId}]:[]}startEditingCell(e){var d;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const i=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!i||!this.grid.isCellEditable(t,i))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,i,e.charPress);return}const s=this.findCellElement(t,e.rowIndex);if(!s)return;const n=H(t,i,this.grid.getApi()),o={value:e.charPress!==void 0?e.charPress:n,oldValue:n,data:i.data,node:i,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=t.cellEditorParams)==null?void 0:d.values,...t.cellEditorParams};let a=null;if(typeof t.cellEditor=="string")a=(fe[t.cellEditor]||fe.agTextCellEditor)(o);else if(typeof t.cellEditor=="function"){const c=t.cellEditor(o);a=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";a=fe[c](o)}if(!a)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:s,editor:a,startedValue:n},s.classList.add("ag-cell-inline-editing");const r=a.getGui();r.classList.add("ag-cell-editor"),s.appendChild(r),s.classList.add("ag-cell-editing"),a.focusIn&&a.focusIn(),a.afterGuiAttached&&a.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:i,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,i){const s=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(n=>this.grid.isCellEditable(n,t));this.fullRowEditors=[],this.fullRowNode=t;for(const n of s){const o=this.findCellElement(n,e);if(!o)continue;const a=H(n,t,this.grid.getApi()),r=this.createEditor(n,t,e,a,i);if(!r)continue;o.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),o.appendChild(d),this.fullRowEditors.push({column:n,editor:r,eCell:o,startedValue:a})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,s,n){var r;const o={value:n!==void 0?n:s,oldValue:s,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:i,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(fe[e.cellEditor]||fe.agTextCellEditor)(o);if(typeof e.cellEditor=="function"){const d=e.cellEditor(o);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const a=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return fe[a](o)}stopEditing(e=!1){var d,c,h,g;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:i,rowNode:s,eCell:n,editor:o,startedValue:a}=this.editing;this.editing=null,n.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?a:o.getValue();if(r===void 0&&!e)return(d=n.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:s,api:this.grid.getApi()}),!1;if(!e){r=wt(i,r);const p=this.applyValueSetter(i,s,r);if(p===!1)return n.classList.add("ag-cell-invalid"),setTimeout(()=>n.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:i}),!1;r=p}return(c=n.querySelector(".ag-cell-editor"))==null||c.remove(),o.destroy&&o.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:s,api:this.grid.getApi()}),!e&&!It(r,a)&&(this.grid.setCellValue(i,s,r,"edit",a),this.eventService.dispatchEvent("cellValueChanged",{oldValue:a,newValue:r,value:r,data:s.data,node:s,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(g=(h=this.grid.getOptions()).onCellValueChanged)==null||g.call(h,{oldValue:a,newValue:r,value:r,data:s.data,node:s,column:i,colDef:i.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[s],columns:[i],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,i){if(e.valueSetter){if(e.valueSetter({oldValue:H(e,t,this.grid.getApi()),newValue:i,data:t.data,node:t,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else t.setDataValue(e.colId,i);return i}stopFullRowEditing(e){var n,o,a;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(n=r.eCell.querySelector(".ag-cell-editor"))==null||n.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const s=[];for(const r of t){if(!i)break;let d=r.editor.getValue();d!==void 0&&(d=wt(r.column,d),It(d,r.startedValue)||s.push({column:r.column,rowNode:i,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const r of s)this.grid.setCellValue(r.column,r.rowNode,r.newValue,"edit",r.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi(),source:"edit"}),(a=(o=this.grid.getOptions()).onCellValueChanged)==null||a.call(o,{oldValue:r.oldValue,newValue:r.newValue,value:r.newValue,data:r.rowNode.data,node:r.rowNode,column:r.column,colDef:r.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[r.rowNode],columns:[r.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===we){e.preventDefault();const t=this.editing;this.stopEditing(),t&&this.grid.getOptions().enterNavigatesVerticallyAfterEdit!==!1&&this.moveFocus(1,0)}else if(e.key==="Escape"||e.keyCode===Zt)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===ut){e.preventDefault(),this.stopEditing(),this.moveFocus(0,e.shiftKey?-1:1);const t=this.focusedCell;t&&this.grid.isCellEditable(t.column,t.rowNode)&&this.startEditingCell({rowIndex:t.rowIndex,colKey:t.column})}}onGridKeyDown(e){const t=e.key;if(this.editing){t==="Escape"&&this.stopEditing(!0);return}const i=this.focusedCell;switch(e.keyCode){case we:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case ut:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case pt:case gt:i&&this.grid.isCellEditable(i.column,i.rowNode)&&(e.preventDefault(),this.grid.setCellValue(i.column,i.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[i.rowNode],columns:[i.column],flash:!0}));break;case 37:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,-1));break;case 39:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(0,1));break;case 38:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1,0));break;case 40:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1,0));break;case Jt:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case ei:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(1/0,0));break;case 33:e.preventDefault(),this.moveFocus(-this.getPageJump(),0);break;case 34:e.preventDefault(),this.moveFocus(this.getPageJump(),0);break;case 70:(e.ctrlKey||e.metaKey)&&(e.preventDefault(),this.grid.openFind());break;default:if((t==="f"||t==="F")&&(e.ctrlKey||e.metaKey)){e.preventDefault(),this.grid.openFind();return}i&&t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(i.column,i.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column,charPress:t}));break}}isTextInput(e){if(!e)return!1;const t=e;return t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable}getPageJump(){const e=this.grid.getRowRenderer().getViewport();return Math.max(1,Math.floor(e.clientHeight/(this.grid.getOptions().rowHeight??42))-1)}moveFocus(e,t){const i=this.focusedCell;if(!i){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let s=i.rowIndex;if(e===-1/0?s=0:e===1/0?s=this.grid.getDisplayedRowCount()-1:s=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,s+e)),t!==0){const n=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let a=n.findIndex(r=>r.colId===i.column.colId)+t;for(;a>=0&&a<n.length&&!n[a].visible;)a+=t;a<0&&(a=0),a>=n.length&&(a=n.length-1),this.setFocusedCell(s,n[a])}else this.setFocusedCell(s,i.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:i,event:s}=e;if(this.setFocusedCell(e.rowIndex,i),i.checkboxSelection)return;const n=this.grid.isCellEditable(i,t),o=i.singleClickEdit||this.grid.getOptions().singleClickEdit;n&&o&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}onCellDoubleClicked(e){const{node:t,column:i}=e;this.setFocusedCell(e.rowIndex,i),this.grid.isCellEditable(i,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}destroy(){this.editing=null,this.focusedCell=null}}function It(l,e){return l===e?!0:l instanceof Date&&e instanceof Date?l.getTime()===e.getTime():!1}class Qi{constructor(e){u(this,"filterModel",{});u(this,"advancedFilterModel",null);this.grid=e}getAdvancedFilterModel(){return this.advancedFilterModel}setAdvancedFilterModel(e){this.advancedFilterModel=e,this.onFilterChanged("api")}isAdvancedFilterEnabled(){return!!this.grid.getOptions().enableAdvancedFilter}doesNodePassAdvancedFilter(e){const t=this.advancedFilterModel;if(!t||!t.conditions||t.conditions.length===0)return!0;const i=this.grid.getRowModel(),s=typeof i.doesNodePassFilterModel=="function"?i.doesNodePassFilterModel.bind(i):null,n=t.conditions.map(o=>{const a=this.grid.getColumn(o.colId);return!a||!s?!0:s(e,a,{...o,filterType:a.filter===!0?"text":a.filter})});return t.operator==="OR"?n.some(Boolean):n.every(Boolean)}getFilterModel(){return this.filterModel}getFilterInstance(e){return this.filterModel[e]}setFilterModel(e){this.filterModel=e||{},this.onFilterChanged("api")}setColumnFilterModel(e,t){const i=typeof e=="string"?e:e.colId;t==null?delete this.filterModel[i]:this.filterModel[i]=t,this.onFilterChanged("api")}isFilterActive(e){const t=this.filterModel[e.colId];return t?t.filterType==="multi"?(t.filterModels||[]).some(s=>this.isModelMeaningful(s)):this.isModelMeaningful(t):!1}isModelMeaningful(e){return e.filterType==="text"?!!e.filter:e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":!1}handleFloatingFilterChange(e,t){if(t===""||t===null||t===void 0){delete this.filterModel[e.colId],this.onFilterChanged("uiFilterModified");return}switch(e.filter){case"number":this.filterModel[e.colId]={filterType:"number",type:"equals",filter:t};break;case"date":this.filterModel[e.colId]={filterType:"date",dateFrom:t,dateTo:t};break;case"boolean":this.filterModel[e.colId]={filterType:"boolean",filter:t==="true"};break;case"set":this.filterModel[e.colId]={filterType:"set",values:[t]};break;default:this.filterModel[e.colId]={filterType:"text",type:"contains",filter:t};break}this.onFilterChanged("uiFilterModified")}resetFilters(){this.filterModel={},this.onFilterChanged("api")}onFilterChanged(e){var i,s;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(s=(i=this.grid.getOptions()).onFilterChanged)==null||s.call(i,{api:t,source:e})}}class Zi{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,i){const s=this.grid.getOptions().suppressMultiSort,n=i&&!s&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,o=this.getSortingOrder(),a=e.sort;let r=o.indexOf(a)+1;r>=o.length&&(r=0);const d=o[r];if(!n)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,i)=>(t.sortIndex??99)-(i.sortIndex??99)).forEach((t,i)=>t.sortIndex=i)}getSortModel(){return this.grid.getAllColumns().filter(e=>e.sort).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).map(e=>({colId:e.colId,sort:e.sort}))}setSortModel(e){for(const t of this.grid.getAllColumns())t.sort=null,t.sortIndex=null;e.forEach((t,i)=>{const s=this.grid.getColumn(t.colId);s&&(s.sort=t.sort,s.sortIndex=i)}),this.onSortChanged("api")}onSortChanged(e){var i,s;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(s=(i=this.grid.getOptions()).onSortChanged)==null||s.call(i,{api:t,source:e})}}class kt{constructor(e,t){u(this,"enabled");u(this,"pageSize");u(this,"currentPage",0);u(this,"pageSizeSelector");u(this,"ePanel");u(this,"ePageInfo");u(this,"ePageInput");u(this,"ePageSizeSelect",null);u(this,"ePageSizeContainer");u(this,"eFromToContainer");this.grid=e,this.eventService=t;const i=e.getOptions();this.enabled=i.pagination===!0,this.pageSize=i.paginationPageSize??100,this.pageSizeSelector=i.paginationPageSizeSelector??[20,50,100,500,1e3],this.ePanel=document.createElement("div"),this.ePanel.className="ag-pagination-panel",this.enabled||(this.ePanel.style.display="none");const s=document.createElement("div");s.className="ag-pagination-buttons",this.ePanel.appendChild(s),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",s.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",s.appendChild(this.eFromToContainer);const n=document.createElement("span");if(n.className="ag-pagination-page-label",n.textContent=`${this.grid.translate("page","Page")}`,s.appendChild(n),this.ePageInput=document.createElement("input"),this.ePageInput.className="ag-pagination-page-input",this.ePageInput.type="number",this.ePageInput.min="1",this.ePageInput.value="1",this.ePageInput.title=this.grid.translate("pageNumber","输入页码"),this.ePageInput.addEventListener("change",()=>{const o=parseInt(this.ePageInput.value,10);isNaN(o)||this.goToPage(o-1)}),s.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",s.appendChild(this.ePageInfo),this.pageSizeSelector){const o=this.ePageSizeContainer,a=document.createElement("span");a.textContent=`${this.grid.translate("pageSize","Page Size:")}`,o.appendChild(a);const r=document.createElement("select");r.className="ag-pagination-page-size-select";const d=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const c of d){const h=document.createElement("option");h.value=String(c),h.textContent=String(c),c===this.pageSize&&(h.selected=!0),r.appendChild(h)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),o.appendChild(r),this.ePageSizeSelect=r}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),i=Math.max(0,Math.min(t-1,e));if(i===this.currentPage){this.update();return}this.currentPage=i,this.grid.refreshModel("everything"),this.update(),this.grid.getRowRenderer().setVerticalScrollTop(0)}goToNextPage(){this.goToPage(this.currentPage+1)}goToPreviousPage(){this.goToPage(this.currentPage-1)}goToFirstPage(){this.goToPage(0)}goToLastPage(){this.goToPage(this.getTotalPages()-1)}update(){var a,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),i=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),s=i===0?0:this.currentPage*this.pageSize+1,n=Math.min(i,(this.currentPage+1)*this.pageSize);this.ePageInfo.textContent=`${this.grid.translate("of","/")} ${e}`,this.ePageInput.value=String(this.currentPage+1),this.ePageInput.max=String(e);const o=this.grid.translate("rangeTo","至");this.eFromToContainer.textContent=i===0?`0 ${o} 0 ${this.grid.translate("of","/")} 0`:`${s.toLocaleString()} ${o} ${n.toLocaleString()} ${this.grid.translate("of","/")} ${i.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:i}),(r=(a=this.grid.getOptions()).onPaginationChanged)==null||r.call(a,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Ji{constructor(e){u(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,t=""){const i=document.createElement("div");i.className=`ag-popup ${t}`.trim(),i.style.width=`${e}px`,i.style.display="none";const s={ePopup:i},n=()=>{var d;this.openPopups.has(s)&&(this.openPopups.delete(s),i.remove(),document.removeEventListener("mousedown",a,!0),document.removeEventListener("keydown",r,!0),(d=s.onClose)==null||d.call(s))},o=d=>{s.onClose=d},a=d=>{if(!i.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){n();return}i.contains(d.target)||n()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),n())};return this.getParent().appendChild(i),this.openPopups.add(s),document.addEventListener("mousedown",a,!0),document.addEventListener("keydown",r,!0),{ePopup:i,close:n,onClose:o}}positionAt(e,t,i=0){const s=this.grid.getRootElement().getBoundingClientRect(),n=t.getBoundingClientRect(),o=e.offsetWidth||220;let a=n.left-s.left+i;const r=s.width-o-4;a>r&&(a=r),a<4&&(a=4);const d=n.bottom-s.top+2;e.style.left=`${a}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}const Pe=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Ae=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class es{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var v,C;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const i=e.filter===!0?"text":e.filter,s=this.grid.getFilterService().getFilterInstance(e.colId),n=i==="set"?260:240,{ePopup:o,close:a}=this.popupService.createPopup(n,"ag-filter-popup");o.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=`Search ${e.headerName||e.field||""}`,o.appendChild(r);let d=s?{...s}:this.getDefaultModel(i),c=s?{...s}:null;const h=()=>{c&&this.isMeaningful(c)?this.grid.getFilterService().setColumnFilterModel(e,c):this.grid.getFilterService().setColumnFilterModel(e,null),a()},g=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),a()};if(i==="set")o.appendChild(this.buildSetFilter(e,d,w=>{c=w}));else if(i==="boolean"){const w=this.buildConditionSelect(["true","false"],String(d.filter??""),x=>{c={filterType:"boolean",filter:x==="true"}});o.appendChild(w)}else{const w=i==="number"?Ae:Pe,x=this.buildConditionSelect(w,d.type||w[0],b=>{d.type=b,c={...d}});if(o.appendChild(x),d.type!=="blank"&&d.type!=="notBlank")if(i==="number"&&d.type==="inRange"){const b=document.createElement("div");b.className="ag-filter-inputs";const y=document.createElement("input");y.type="number",y.className="ag-filter-input",y.value=d.filter??"",y.placeholder=this.grid.t("from"),y.addEventListener("input",()=>{c={...d,filter:y.value,filterTo:N.value}});const N=document.createElement("input");N.type="number",N.className="ag-filter-input",N.value=d.filterTo??"",N.placeholder=this.grid.t("to"),N.addEventListener("input",()=>{c={...d,filter:y.value,filterTo:N.value}}),b.appendChild(y),b.appendChild(N),o.appendChild(b)}else if(i==="date"){const b=document.createElement("div");b.className="ag-filter-inputs";const y=document.createElement("input");y.type="date",y.className="ag-filter-input",y.value=d.dateFrom??"",y.addEventListener("input",()=>{c={...d,dateFrom:y.value,dateTo:N.value}});const N=document.createElement("input");N.type="date",N.className="ag-filter-input",N.value=d.dateTo??"",N.addEventListener("input",()=>{c={...d,dateFrom:y.value,dateTo:N.value}}),b.appendChild(y),b.appendChild(N),o.appendChild(b)}else{const b=document.createElement("input");b.type=i==="number"?"number":"text",b.className="ag-filter-input",b.value=d.filter??"",b.placeholder=this.grid.t("filterOoo"),b.addEventListener("input",()=>{c={...d,filter:b.value}}),b.addEventListener("keydown",y=>{y.key==="Enter"&&h()}),o.appendChild(b),setTimeout(()=>b.focus(),0)}else c={...d}}if(i==="text"||i==="number"){const w=document.createElement("div");w.className="ag-filter-second-condition";const x=document.createElement("select");x.className="ag-filter-condition",x.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,x.value=d.operator||"AND",w.appendChild(x);const b=this.buildConditionSelect(i==="number"?Ae:Pe,((v=d.condition2)==null?void 0:v.type)||(i==="number"?Ae:Pe)[0],N=>{c||(c={...d}),c.condition2={...c.condition2,type:N}});w.appendChild(b);const y=document.createElement("input");y.type=i==="number"?"number":"text",y.className="ag-filter-input",y.placeholder=this.grid.t("secondValue"),y.value=((C=d.condition2)==null?void 0:C.filter)??"",y.addEventListener("input",()=>{c||(c={...d}),c.condition2={...c.condition2,filter:y.value}}),w.appendChild(y),o.appendChild(w),x.addEventListener("change",()=>{c||(c={...d}),c.operator=x.value})}const p=document.createElement("div");p.className="ag-popup-buttons";const m=document.createElement("button");m.className="ag-button ag-button-primary",m.textContent=this.grid.t("apply"),m.addEventListener("click",h);const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",g),p.appendChild(f),p.appendChild(m),o.appendChild(p),this.popupService.positionAt(o,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,i){const s=document.createElement("div");s.className="ag-set-filter";const n=document.createElement("input");n.type="text",n.className="ag-filter-input",n.placeholder=this.grid.t("search"),s.appendChild(n);const o=new Set;this.grid.getRowModel().forEachNode(f=>{!f.group&&!f.footer&&o.add(H(e,f,this.grid.getApi()))});let r=[...o].sort((f,v)=>f===v?0:f<v?-1:1);const d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((t.values||[]).map(f=>String(f))),h=()=>{d.innerHTML="";const f=n.value.toLowerCase();let v=0;for(const C of r){const w=C==null?"(Blanks)":String(C);if(f&&!w.toLowerCase().includes(f))continue;v++;const x=document.createElement("label");x.className="ag-set-filter-item";const b=document.createElement("input");b.type="checkbox",b.checked=c.has(String(C)),b.addEventListener("change",()=>{b.checked?c.add(String(C)):c.delete(String(C)),i({filterType:"set",values:[...c]})});const y=document.createElement("span");y.textContent=w,x.appendChild(b),x.appendChild(y),d.appendChild(x)}if(v===0){const C=document.createElement("div");C.className="ag-set-filter-empty",C.textContent=this.grid.t("noMatches"),d.appendChild(C)}};n.addEventListener("input",h),h();const g=document.createElement("div");g.className="ag-set-filter-actions";const p=document.createElement("button");p.className="ag-button ag-button-small",p.textContent=this.grid.t("selectAll"),p.addEventListener("click",()=>{c.clear();for(const f of r)c.add(String(f));h(),i({filterType:"set",values:[...c]})});const m=document.createElement("button");return m.className="ag-button ag-button-small",m.textContent=this.grid.t("clearAll"),m.addEventListener("click",()=>{c.clear(),h(),i({filterType:"set",values:[]})}),g.appendChild(p),g.appendChild(m),s.appendChild(d),s.appendChild(g),i({filterType:"set",values:[...c]}),s}buildConditionSelect(e,t,i){const s=document.createElement("select");s.className="ag-filter-condition";for(const n of e){const o=document.createElement("option");o.value=n;const a=vi[n];o.textContent=a?this.grid.t(a):n,n===t&&(o.selected=!0),s.appendChild(o)}return s.addEventListener("change",()=>i(s.value)),s}openMultiFilter(e,t){var x;const i=this.grid.getFilterService().getFilterInstance(e.colId),s=i&&i.filterType==="multi"?i:null,n=(x=s==null?void 0:s.filterModels)!=null&&x.length?s.filterModels.map(b=>({...b})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let o=(s==null?void 0:s.operator)||"AND";const{ePopup:a,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");a.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,a.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const h=document.createElement("span");h.textContent=this.grid.t("join");const g=document.createElement("select");g.className="ag-filter-condition",g.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',g.value=o,g.addEventListener("change",()=>{o=g.value}),c.appendChild(h),c.appendChild(g),a.appendChild(c);const p=document.createElement("div");p.className="ag-multi-filter-list",a.appendChild(p);const m=()=>{p.innerHTML="",n.forEach((b,y)=>{const N=document.createElement("div");N.className="ag-multi-filter-row";const I=document.createElement("select");I.className="ag-filter-condition";const D=["text","number","date","set","boolean"];for(const F of D){const S=document.createElement("option");S.value=F,S.textContent=F.charAt(0).toUpperCase()+F.slice(1),F===b.filterType&&(S.selected=!0),I.appendChild(S)}I.addEventListener("change",()=>{n[y]={...this.getDefaultModel(I.value)},m()}),N.appendChild(I);const W=b.filterType==="number"?Ae:Pe,T=this.buildConditionSelect(W,b.type||W[0],F=>{n[y].type=F});if(N.appendChild(T),b.filterType!=="blank"&&b.type!=="blank"&&b.type!=="notBlank"){const F=document.createElement("input");F.type=b.filterType==="number"?"number":"text",F.className="ag-filter-input",F.value=b.filter??"",F.placeholder=this.grid.t("value"),F.addEventListener("input",()=>{n[y].filter=F.value}),N.appendChild(F)}const A=document.createElement("button");A.className="ag-button ag-button-small",A.textContent="×",A.title=this.grid.t("removeFilter"),A.addEventListener("click",()=>{n.splice(y,1),m()}),N.appendChild(A),p.appendChild(N)})};m();const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent="+ "+this.grid.t("addFilter"),f.addEventListener("click",()=>{n.push(this.getDefaultModel("text")),m()}),a.appendChild(f);const v=document.createElement("div");v.className="ag-popup-buttons";const C=document.createElement("button");C.className="ag-button ag-button-primary",C.textContent=this.grid.t("apply"),C.addEventListener("click",()=>{n.filter(y=>y.filter!==void 0&&y.filter!==""||y.type==="blank"||y.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:o,filterModels:n}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(w),v.appendChild(C),a.appendChild(v),this.popupService.positionAt(a,t)}openAdvancedFilter(e){var x,b;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),s=(x=i==null?void 0:i.conditions)!=null&&x.length?i.conditions.map(y=>({...y})):[{colId:((b=this.grid.getColumns().center[0])==null?void 0:b.colId)??"",type:"contains",filter:""}];let n=(i==null?void 0:i.operator)||"AND";const{ePopup:o,close:a}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");o.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),o.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",o.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(y=>y.filter),h=()=>{d.innerHTML="",s.forEach((y,N)=>{const I=document.createElement("div");I.className="ag-advanced-filter-row";const D=document.createElement("select");D.className="ag-filter-condition";for(const P of c()){const O=document.createElement("option");O.value=P.colId,O.textContent=P.headerName||P.field||P.colId,P.colId===y.colId&&(O.selected=!0),D.appendChild(O)}D.addEventListener("change",()=>{s[N].colId=D.value}),I.appendChild(D);const W=this.grid.getColumn(y.colId),T=W&&W.filter!==!1?String(W.filter):"text",A=T==="number"?Ae:Pe,F=this.buildConditionSelect(A,y.type||"contains",P=>{s[N].type=P});I.appendChild(F);const S=document.createElement("input");S.type=T==="number"?"number":"text",S.className="ag-filter-input",S.value=y.filter??"",S.placeholder=this.grid.t("value"),S.addEventListener("input",()=>{s[N].filter=S.value}),I.appendChild(S);const L=document.createElement("button");L.className="ag-button ag-button-small",L.textContent="×",L.addEventListener("click",()=>{s.splice(N,1),h()}),I.appendChild(L),d.appendChild(I)})};h();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addCondition"),g.addEventListener("click",()=>{var y;s.push({colId:((y=c()[0])==null?void 0:y.colId)??"",type:"contains",filter:""}),h()}),o.appendChild(g);const p=document.createElement("div");p.className="ag-multi-filter-operator";const m=document.createElement("span");m.textContent=this.grid.t("join");const f=document.createElement("select");f.className="ag-filter-condition",f.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',f.value=n,f.addEventListener("change",()=>{n=f.value}),p.appendChild(m),p.appendChild(f),o.appendChild(p);const v=document.createElement("div");v.className="ag-popup-buttons";const C=document.createElement("button");C.className="ag-button ag-button-primary",C.textContent=this.grid.t("apply"),C.addEventListener("click",()=>{const y=s.filter(N=>N.filter!==void 0&&N.filter!=="");y.length?t.setAdvancedFilterModel({filterType:"advanced",operator:n,conditions:y}):t.setAdvancedFilterModel(null),a()});const w=document.createElement("button");w.className="ag-button",w.textContent=this.grid.t("clear"),w.addEventListener("click",()=>{t.setAdvancedFilterModel(null),a()}),v.appendChild(w),v.appendChild(C),o.appendChild(v),this.popupService.positionAt(o,e)}openCustomFilter(e,t){const i=e.colDef.filterComponent;if(typeof i!="function")return;const s=this.grid.getFilterService(),n=i({column:e,colDef:e.colDef,api:this.grid.getApi(),model:s.getFilterInstance(e.colId)??null,onModelChange:d=>s.setColumnFilterModel(e,d),onGuiAttached:()=>{}}),{ePopup:o,close:a}=this.popupService.createPopup(260,"ag-filter-popup");o.innerHTML="";const r=typeof(n==null?void 0:n.getGui)=="function"?n.getGui():n;r instanceof HTMLElement&&o.appendChild(r),typeof(n==null?void 0:n.afterGuiAttached)=="function"&&n.afterGuiAttached(),this.popupService.positionAt(o,t)}getDefaultModel(e){return e==="number"?{filterType:"number",type:"equals",filter:""}:e==="date"?{filterType:"date",dateFrom:"",dateTo:""}:e==="set"?{filterType:"set",values:[]}:e==="boolean"?{filterType:"boolean",filter:!0}:{filterType:"text",type:"contains",filter:""}}isMeaningful(e){return e.filterType==="text"?!!e.filter||e.type==="blank"||e.type==="notBlank":e.filterType==="number"?e.filter!==void 0&&e.filter!==null&&e.filter!=="":e.filterType==="date"?!!(e.dateFrom||e.dateTo):e.filterType==="set"?!!e.values&&e.values.length>0:e.filterType==="boolean"?e.filter!==void 0:!1}}const Lt={copy:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 2h7v2h2v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-2H3V4a2 2 0 0 1 1-2zm1 2v8h1V4H5z"/></svg>',copyWithHeaders:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M2 1h12v2H2V1zm2 3h8v9H4V4z"/></svg>',paste:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M5 2h6v2H5V2zM3 4h10v10H3V4z"/></svg>',csv:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',excel:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M3 1h7l3 3v11H3V1zm6 1v3h3v9H4V2h5z"/></svg>',reset:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M8 2a6 6 0 1 0 5.7 4H11l3 3 3-3h-2.3A7 7 0 1 1 8 1v1z"/></svg>',pin:'<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M9 1l6 6-2 1-1 4-3-3-4 4v-3l3-3-1-3 4-1z"/></svg>'};class ts{constructor(e,t){this.grid=e,this.popupService=t}getDefaultItems(e){return[{name:"copy",label:this.grid.t("copy"),icon:"copy",shortcut:"Ctrl+C",action:()=>this.grid.getApi().copyToClipboard()},{name:"copyWithHeaders",label:this.grid.t("copyWithHeaders"),icon:"copyWithHeaders",action:()=>this.grid.getApi().copyToClipboard({includeHeaders:!0})},{name:"paste",label:this.grid.t("paste"),icon:"paste",shortcut:"Ctrl+V",action:()=>this.grid.getApi().pasteFromClipboard()},{name:"sep1",separator:!0},{name:"export",label:this.grid.t("export"),icon:"excel",subMenu:[{name:"csvExport",label:this.grid.t("csvExport"),icon:"csv",action:()=>this.grid.getApi().exportToCsv({fileName:"export.csv"})},{name:"excelExport",label:this.grid.t("excelExport"),icon:"excel",action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx"})},{name:"excelExportSelected",label:"Excel Export (Selected)",icon:"excel",disabled:!this.hasSelection(),action:()=>this.grid.getApi().exportToExcel({fileName:"export.xlsx",onlySelected:!0})}]},{name:"sep2",separator:!0},{name:"resetColumns",label:this.grid.t("resetColumns"),icon:"reset",action:()=>this.grid.getColumnApi().resetColumnState()},{name:"autoSizeAll",label:"Auto-size All Columns",action:()=>this.grid.getColumnApi().autoSizeAllColumns()},{name:"sizeToFit",label:this.grid.t("sizeToFit"),action:()=>this.grid.getApi().sizeColumnsToFit()},{name:"sep3",separator:!0},{name:"expandAll",label:this.grid.t("expandAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().expandAll()},{name:"collapseAll",label:this.grid.t("collapseAll"),disabled:!this.isGroupActive(),action:()=>this.grid.getApi().collapseAll()},{name:"pinRow",label:this.grid.t("pinRow"),icon:"pin",disabled:!e.node||e.node.group===!0,subMenu:[{name:"pinTop",label:this.grid.t("pinToTop"),action:()=>this.grid.setRowNodePinned(e.node,"top")},{name:"pinBottom",label:this.grid.t("pinToBottom"),action:()=>this.grid.setRowNodePinned(e.node,"bottom")},{name:"unpin",label:this.grid.t("unpin"),action:()=>this.grid.setRowNodePinned(e.node,null)}]}]}hasSelection(){return this.grid.getApi().getSelectedNodes().length>0}isGroupActive(){return this.grid.getColumnModel().isRowGroupActive()}openContextMenu(e,t){if(this.grid.getOptions().suppressContextMenu)return;const i=this.grid.getOptions().contextMenuItems;let s;typeof i=="function"?s=i({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(i)?s=i:s=this.getDefaultItems(t);const{ePopup:n,close:o}=this.popupService.createPopup(220,"ag-context-menu");n.innerHTML="",this.buildMenu(n,s,o),this.popupService.positionAt(n,e)}buildMenu(e,t,i){for(const s of t){if(typeof s=="string")continue;if(s.separator){const r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);continue}const n=document.createElement("div");n.className="ag-menu-item",s.disabled&&n.classList.add("ag-menu-item-disabled"),s.cssClasses&&n.classList.add(...s.cssClasses);const o=document.createElement("span");o.className="ag-menu-item-icon",s.icon&&Lt[s.icon]&&(o.innerHTML=Lt[s.icon]),n.appendChild(o);const a=document.createElement("span");if(a.className="ag-menu-item-label",a.textContent=s.label??s.name,n.appendChild(a),s.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=s.shortcut,n.appendChild(r)}if(s.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",n.appendChild(r),n.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(h=>h.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,s.subMenu,i),e.appendChild(c)}),n.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;n.matches(":hover")||((c=n.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(h=>h.remove())},200)})}else!s.disabled&&s.action&&n.addEventListener("click",()=>{s.action(),i()});e.appendChild(n)}}}class is{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:i,close:s}=this.popupService.createPopup(220,"ag-column-menu");i.innerHTML="";const n=document.createElement("div");n.className="ag-popup-title",n.textContent=e.headerName||e.field||e.colId,i.appendChild(n);const o=(r,d)=>{const c=document.createElement("div");c.className="ag-menu-item",d.disabled&&c.classList.add("ag-menu-item-disabled"),d.checked&&c.classList.add("ag-menu-item-active");const h=document.createElement("span");h.className="ag-menu-item-check",d.checked&&(h.innerHTML=Nt),c.appendChild(h);const g=document.createElement("span");if(g.className="ag-menu-item-label",g.textContent=r,c.appendChild(g),d.shortcut){const p=document.createElement("span");p.className="ag-menu-item-shortcut",p.textContent=d.shortcut,c.appendChild(p)}return!d.disabled&&d.onClick&&c.addEventListener("click",()=>{d.onClick(),s()}),i.appendChild(c),c},a=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,i.appendChild(d)};e.sortable&&(a(this.grid.t("sort")),o(this.grid.t("sortAscending"),{checked:e.sort==="asc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"asc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}}),o(this.grid.t("sortDescending"),{checked:e.sort==="desc",onClick:()=>{this.grid.getColumnApi().applyColumnState([{colId:e.colId,sort:"desc",sortIndex:0}]),this.grid.getSortService().onSortChanged("uiColumnSorted")}})),e.resizable&&(a(this.grid.t("columnSize")),o(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),o(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(a(this.grid.t("pinColumn")),o(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),o(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),o(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(a(this.grid.t("filter")),o(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,t)}),e.filter!=="multi"&&o(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,t)}),this.grid.getOptions().enableAdvancedFilter&&o(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)}),o(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(a(this.grid.t("filter")),o(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),a(this.grid.t("formula")),o(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,t)}),a(this.grid.t("visibility")),o(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),o(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(i,t)}}class ss{constructor(e,t){u(this,"eBar");u(this,"panels",[]);this.grid=e,this.eventService=t,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const s=e.getOptions().statusBar;(!s||!s.statusPanels||s.statusPanels.length===0)&&(this.eBar.style.display="none");const n=((s==null?void 0:s.statusPanels)||[]).map(o=>typeof o=="string"?{key:o,label:o}:{key:o.key||o.statusPanel,label:o.key||o.statusPanel,align:o.align});for(const o of n){const a=document.createElement("div");a.className=`ag-status-panel ag-status-panel-${o.align||"left"}`,this.eBar.appendChild(a);const r={def:o,ePanel:a,render:()=>this.renderPanel(o.key,a)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const i=this.grid.getApi(),s=this.grid.getRowModel().getRowCount(),n=this.grid.getRowModel(),o=typeof n.getTotalRowCount=="function"&&n.getType()!=="clientSide"?n.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,a=i.getSelectedNodes().length,r=[],d=this.grid.getColumnModel().getValueColumns().filter(c=>c.aggFunc);switch(this.grid.getRowModel().forEachNode(c=>{!c.footer&&c.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${ae(o)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${ae(s)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${ae(s)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${ae(a)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=i.getSelectedNodes().filter(g=>!g.group&&!g.footer),h=[];for(const g of d){const m=c.map(w=>H(g,w,i)).filter(w=>typeof w=="number"&&!isNaN(w)),f=m.reduce((w,x)=>w+x,0),v=w=>w===null?"":ae(w,g.decimals),C=[[this.grid.translate("average","Average"),m.length?f/m.length:null],[this.grid.translate("count","Count"),m.length],[this.grid.translate("min","Min"),m.length?Math.min(...m):null],[this.grid.translate("max","Max"),m.length?Math.max(...m):null],[this.grid.translate("sum","Sum"),m.length?f:null]];for(const[w,x]of C)h.push(`${w}${g.headerName?` (${g.headerName})`:""} : ${v(x)}`)}h.length&&r.push(h.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class ns{constructor(e){u(this,"eBar");u(this,"eButtons");u(this,"ePanel");u(this,"panels",[]);u(this,"activePanelId",null);u(this,"visible",!1);u(this,"position");var i,s;this.grid=e;const t=e.getOptions();if(this.position=typeof t.sideBar=="object"&&((i=t.sideBar)!=null&&i.position)?t.sideBar.position:"right",this.eBar=document.createElement("div"),this.eBar.className=`ag-side-bar ag-side-bar-${this.position}`,this.eButtons=document.createElement("div"),this.eButtons.className="ag-side-buttons",this.ePanel=document.createElement("div"),this.ePanel.className="ag-side-bar-panel",this.eBar.appendChild(this.eButtons),this.eBar.appendChild(this.ePanel),t.sideBar){const n=typeof t.sideBar=="object"?t.sideBar:null;n!=null&&n.toolPanels?this.panels=n.toolPanels.map(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const o=(n==null?void 0:n.hiddenByDefault)===!0;this.visible=!o,this.eBar.style.display=this.visible?"":"none";const a=(n==null?void 0:n.defaultToolPanel)||((s=this.panels[0])==null?void 0:s.id)||"columns";this.buildButtons(),this.openPanel(a)}else this.eBar.style.display="none"}defaultLabel(e){switch(e){case"columns":return this.grid.t("columns");case"filters":return this.grid.t("filters");case"charts":return this.grid.t("charts");default:return e}}buildButtons(){this.eButtons.innerHTML="";for(const e of this.panels){const t=document.createElement("button");t.className="ag-side-button",t.textContent=e.label,t.title=e.label,t.dataset.panelId=e.id,e.id===this.activePanelId&&t.classList.add("ag-selected"),t.addEventListener("click",()=>{this.activePanelId===e.id&&this.visible?this.setVisible(!1):(this.visible=!0,this.eBar.style.display="",this.openPanel(e.id)),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"sideBarButtonClicked",api:this.grid.getApi()})}),this.eButtons.appendChild(t)}}getElement(){return this.eBar}setPosition(e){this.position=e,this.eBar.classList.remove("ag-side-bar-left","ag-side-bar-right"),this.eBar.classList.add(`ag-side-bar-${e}`)}setVisible(e){this.visible=e,this.eBar.style.display=e?"":"none",this.grid.onGridSizeChanged(),this.grid.getEventService().dispatchEvent("toolPanelVisibleChanged",{source:"api",api:this.grid.getApi()})}isVisible(){return this.visible}openPanel(e){this.activePanelId=e;for(const t of this.eButtons.querySelectorAll(".ag-side-button"))t.classList.toggle("ag-selected",t.dataset.panelId===e);switch(this.ePanel.innerHTML="",e){case"columns":this.ePanel.appendChild(this.buildColumnsPanel());break;case"filters":this.ePanel.appendChild(this.buildFiltersPanel());break;case"charts":this.ePanel.appendChild(this.grid.getChartService().buildChartPanel());break;default:{const t=document.createElement("div");t.className="ag-side-bar-empty",t.textContent=e,this.ePanel.appendChild(t)}}}getActivePanel(){return this.activePanelId}refresh(){this.activePanelId&&this.openPanel(this.activePanelId)}buildColumnsPanel(){const e=document.createElement("div");e.className="ag-column-panel";const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const i=document.createElement("div");i.className="ag-column-panel-columns",e.appendChild(i);const s=()=>{const d=t.value.toLowerCase();i.innerHTML="";const c=this.grid.getColumnModel().getColumns(),h=c.filter(g=>g.pinned!=="left"&&g.pinned!=="right").concat(c.filter(g=>g.pinned==="left"||g.pinned==="right"));for(const g of h)d&&!g.headerName.toLowerCase().includes(d)&&!g.colId.toLowerCase().includes(d)||i.appendChild(this.buildColumnItem(g));if(!i.children.length){const g=document.createElement("div");g.className="ag-side-bar-empty",g.textContent=this.grid.t("noMatchingColumns"),i.appendChild(g)}};t.addEventListener("input",s),s();const n=document.createElement("div");n.className="ag-column-panel-groups";const o=document.createElement("div");o.className="ag-column-panel-section-title",o.textContent=this.grid.t("rowGroups"),n.appendChild(o);const a=document.createElement("div");a.className="ag-column-group-list",n.appendChild(a);const r=()=>{a.innerHTML="";const d=this.grid.getColumnModel().getRowGroupColumns();if(d.length===0){const c=document.createElement("div");c.className="ag-column-group-hint",c.textContent=this.grid.t("dragColumnsHere"),a.appendChild(c)}for(const c of d){const h=document.createElement("div");h.className="ag-column-group-item",h.draggable=!0,h.addEventListener("dragstart",m=>{var f;(f=m.dataTransfer)==null||f.setData("text/plain",c.colId)}),h.addEventListener("dragover",m=>m.preventDefault()),h.addEventListener("drop",m=>{var v;m.preventDefault();const f=(v=m.dataTransfer)==null?void 0:v.getData("text/plain");f&&this.grid.getColumnModel().setRowGroupColumns([...d.map(C=>C.colId),f])});const g=document.createElement("span");g.textContent=c.headerName,h.appendChild(g);const p=document.createElement("button");p.className="ag-column-group-remove",p.textContent="×",p.title=this.grid.t("remove"),p.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(c)),h.appendChild(p),a.appendChild(h)}};return r(),a.addEventListener("dragover",d=>d.preventDefault()),a.addEventListener("drop",d=>{var h;d.preventDefault();const c=(h=d.dataTransfer)==null?void 0:h.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(n),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&s()}),e}buildColumnItem(e){const t=document.createElement("div");t.className="ag-column-select-column",t.draggable=!0,t.dataset.colid=e.colId;const i=document.createElement("input");i.type="checkbox",i.className="ag-column-select-checkbox",i.checked=e.visible,i.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,i.checked)}),t.appendChild(i);const s=document.createElement("span");s.className="ag-column-select-label",s.textContent=e.headerName||e.colId,t.appendChild(s);const n=document.createElement("span");if(n.className="ag-column-select-actions",e.enableRowGroup&&e.field){const a=document.createElement("button");a.className="ag-column-select-action",a.title=this.grid.t("groupByThisColumn"),a.textContent="≡",a.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),n.appendChild(a)}const o=document.createElement("button");return o.className="ag-column-select-action",o.title=this.grid.t("pinColumnTitle"),o.textContent="📌",o.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),n.appendChild(o),t.appendChild(n),t}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const n=document.createElement("button");n.className="ag-button ag-button-small",n.textContent=`${this.grid.t("advancedFilter")}…`,n.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(n)),e.appendChild(n);const o=this.grid.getFilterService().getAdvancedFilterModel();if(o){const a=document.createElement("span");a.className="ag-filters-tool-panel-item-badge",a.textContent=`${o.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(a)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const i=document.createElement("div");i.className="ag-filters-panel-list",e.appendChild(i);const s=()=>{const n=t.value.toLowerCase();i.innerHTML="";const o=this.grid.getColumns().center.filter(a=>a.filter);for(const a of o)n&&!a.headerName.toLowerCase().includes(n)||i.appendChild(this.buildFilterItem(a));if(!i.children.length){const a=document.createElement("div");a.className="ag-side-bar-empty",a.textContent=this.grid.t("noMatchingColumns"),i.appendChild(a)}};return t.addEventListener("input",s),s(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&s()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),i=document.createElement("div");i.className="ag-filters-tool-panel-item";const s=document.createElement("div");s.className="ag-filters-tool-panel-item-header";const n=document.createElement("span");n.className="ag-filters-tool-panel-item-label",n.textContent=e.headerName||e.colId,s.appendChild(n);const o=t.isFilterActive(e);if(o){const a=document.createElement("span");a.className="ag-filters-tool-panel-item-badge",a.innerHTML=Nt,s.appendChild(a)}if(i.appendChild(s),e.filter==="set"){const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent=o?"Edit filter":"Add filter",a.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,a)),i.appendChild(a)}else if(e.filter==="date"){const a=document.createElement("input");a.type="date",a.className="ag-filter-input";const r=t.getFilterInstance(e.colId);a.value=(r==null?void 0:r.dateFrom)??"",a.addEventListener("change",()=>{t.setColumnFilterModel(e,a.value?{filterType:"date",dateFrom:a.value,dateTo:a.value}:null)}),i.appendChild(a)}else{const a=document.createElement("input");a.type=e.filter==="number"?"number":"text",a.className="ag-filter-input",a.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);a.value=(r==null?void 0:r.filter)??"",a.addEventListener("input",()=>{t.handleFloatingFilterChange(e,a.value)}),i.appendChild(a)}if(o){const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent=this.grid.t("clear"),a.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(a)}return i}}class os{constructor(e,t){u(this,"matches",[]);u(this,"activeMatch",0);u(this,"searchText","");u(this,"matchCase",!1);u(this,"ePopup",null);u(this,"eCount",null);u(this,"eInput",null);u(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const i=document.createElement("input");i.type="text",i.className="ag-find-input",i.placeholder=this.grid.translate("find","Find in grid..."),i.value=this.searchText,this.eInput=i,e.appendChild(i);const s=document.createElement("label");s.className="ag-find-case";const n=document.createElement("input");n.type="checkbox",n.checked=this.matchCase,n.addEventListener("change",()=>{this.matchCase=n.checked,this.find(this.searchText)}),s.appendChild(n),s.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(s);const o=document.createElement("span");o.className="ag-find-count",this.eCount=o,e.appendChild(o);const a=(c,h,g)=>{const p=document.createElement("button");return p.className="ag-button ag-button-small",p.textContent=c,p.title=h,p.addEventListener("click",g),e.appendChild(p),p};a("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),a("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),a("×",this.grid.translate("close","关闭"),()=>this.close()),i.addEventListener("input",()=>this.find(i.value)),i.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),c.shiftKey?this.findPrevious():this.findNext()):c.key==="Escape"&&this.close()}),this.grid.getRootElement(),e.style.position="absolute",e.style.left="50%",e.style.top="8px",e.style.transform="translateX(-50%)",e.style.display="flex",setTimeout(()=>i.focus(),0)}close(){var e;(e=this.closePopup)==null||e.call(this),this.ePopup=null,this.closePopup=null,this.eInput=null,this.eCount=null,this.matches=[],this.applyHighlight()}setFindText(e){this.searchText=e,this.eInput&&(this.eInput.value=e),this.find(e)}getFindText(){return this.searchText}getNumMatches(){return this.matches.length}getActiveMatch(){return this.activeMatch}find(e){if(this.searchText=e,this.matches=[],this.activeMatch=0,e){const t=this.grid.getColumns().center;this.grid.getRowModel().forEachNode((i,s)=>{if(!(i.group||i.footer))for(const n of t){H(n,i,this.grid.getApi());const o=Ve(n,i,this.grid.getApi())??"",a=this.matchCase?o:o.toLowerCase(),r=this.matchCase?e:e.toLowerCase();a.includes(r)&&this.matches.push({rowIndex:s,colId:n.colId})}})}this.eCount&&(this.eCount.textContent=this.matches.length?`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`:this.grid.translate("noMatches","No matches")),this.applyHighlight()}findNext(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch+1)%this.matches.length,this.goToActive(),!0)}findPrevious(){return this.matches.length===0?!1:(this.activeMatch=(this.activeMatch-1+this.matches.length)%this.matches.length,this.goToActive(),!0)}goToActive(){var n,o;const e=this.matches[this.activeMatch];if(!e)return;this.eCount&&(this.eCount.textContent=`${this.activeMatch+1} ${this.grid.translate("of","of")} ${this.matches.length}`);const t=(o=(n=this.grid).getPaginationService)==null?void 0:o.call(n);if(t!=null&&t.isEnabled()){const a=t.getPageSize(),r=Math.floor(e.rowIndex/a);r!==t.getCurrentPage()&&t.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const i=this.grid.getDisplayedRowAtIndex(e.rowIndex),s=this.grid.getColumn(e.colId);i&&s&&this.grid.getEditService().setFocusedCell(e.rowIndex,s)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,i]of e){let s=-1;this.grid.getRowModel().forEachNode((n,o)=>{n.id===t&&(s=o)});for(const n of i.getCellElements()){const o=n.dataset.colid,a=this.matches.findIndex(r=>r.rowIndex===s&&r.colId===o);n.classList.toggle("ag-find-match",a>=0),n.classList.toggle("ag-find-active-match",a>=0&&a===this.activeMatch)}}}}class ls{constructor(e,t){u(this,"ranges",[]);u(this,"currentRange",null);u(this,"eOverlay");u(this,"eHandle");u(this,"dragState",null);this.grid=e,this.eventService=t;const i=e.getRowRenderer().getContainer();i.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",i.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",i.appendChild(this.eHandle),document.addEventListener("mousemove",this.onMouseMove.bind(this)),document.addEventListener("mouseup",this.onMouseUp.bind(this)),t.addEventListener("bodyScroll",()=>this.updateOverlay())}isEnabled(){return!!this.grid.getOptions().enableRangeSelection}getRanges(){return this.ranges}clearRanges(){this.ranges=[],this.currentRange=null,this.updateOverlay(),this.applyHighlight(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0})}onCellMouseDown(e){if(!this.isEnabled())return;const{event:t,column:i,rowIndex:s}=e;if(t.button!==0)return;if(t.shiftKey&&this.ranges.length>0){const o=this.ranges[this.ranges.length-1];this.currentRange={...o,rowEndIndex:s,colEndId:i.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const n={rowStartIndex:s,rowEndIndex:s,colStartId:i.colId,colEndId:i.colId};this.currentRange=n,this.dragState={startRange:n,mode:"create"},this.updateOverlay()}onHandleMouseDown(e){this.currentRange&&(e.stopPropagation(),this.dragState={startRange:{...this.currentRange},mode:"handle"})}onMouseMove(e){if(!this.dragState||!this.currentRange)return;const t=document.elementFromPoint(e.clientX,e.clientY);if(!t)return;const i=t.closest(".ag-cell");if(!(i!=null&&i.dataset.colid))return;const s=i.closest(".ag-row");if(!(s!=null&&s.dataset.rowid))return;const n=this.grid.getRowModel().getRowNode(s.dataset.rowid);if(!n)return;let o=-1;if(this.grid.getRowModel().forEachNode((r,d)=>{r.id===n.id&&(o=d)}),o<0)return;const a=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(a.rowStartIndex,o),rowEndIndex:Math.max(a.rowStartIndex,o),colStartId:a.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(a.rowStartIndex,o),this.currentRange.colEndId=i.dataset.colid),this.updateOverlay()}onMouseUp(){!this.dragState||!this.currentRange||(this.dragState=null,this.ranges=[this.currentRange],this.applyHighlight(),this.updateOverlay(),this.eventService.dispatchEvent("rangeSelectionChanged",{api:this.grid.getApi(),finished:!0}))}getCenterColumns(){return this.grid.getColumns().center}getRangeBounds(e){const t=this.getCenterColumns(),i=t.findIndex(f=>f.colId===e.colStartId),s=t.findIndex(f=>f.colId===e.colEndId);if(i<0||s<0)return null;const n=Math.min(i,s),o=Math.max(i,s);let a=0,r=0;for(let f=0;f<=o;f++)f<n?a+=t[f].width:r+=t[f].width;const c=this.grid.getRowRenderer().getRowOffsets(),h=Math.min(e.rowStartIndex,e.rowEndIndex),g=Math.max(e.rowStartIndex,e.rowEndIndex),p=c[h]??h*(this.grid.getOptions().rowHeight??42);let m=0;for(let f=h;f<=g;f++){const v=this.grid.getDisplayedRowAtIndex(f);m+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:p,left:a,width:r,height:m}}updateOverlay(){const e=this.currentRange;if(!e||!this.isEnabled()){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}const t=this.getRangeBounds(e);if(!t){this.eOverlay.style.display="none",this.eHandle.style.display="none";return}this.eOverlay.style.display="block",this.eOverlay.style.top=`${t.top}px`,this.eOverlay.style.left=`${t.left}px`,this.eOverlay.style.width=`${t.width}px`,this.eOverlay.style.height=`${t.height}px`,this.eHandle.style.display="block",this.eHandle.style.top=`${t.top+t.height-4}px`,this.eHandle.style.left=`${t.left+t.width-4}px`,this.eHandle.onmousedown=i=>this.onHandleMouseDown(i)}applyHighlight(){const e=this.ranges,t=this.grid.getRowRenderer().getRowComps(),i=this.getCenterColumns();for(const[s,n]of t){let o=-1;if(this.grid.getRowModel().forEachNode((a,r)=>{a.id===s&&(o=r)}),!(o<0))for(const a of n.getCellElements()){const r=a.dataset.colid,d=i.findIndex(g=>g.colId===r);let c=!1,h=!1;for(const g of e){const p=i.findIndex(x=>x.colId===g.colStartId),m=i.findIndex(x=>x.colId===g.colEndId),f=Math.min(g.rowStartIndex,g.rowEndIndex),v=Math.max(g.rowStartIndex,g.rowEndIndex),C=Math.min(p,m),w=Math.max(p,m);o>=f&&o<=v&&d>=C&&d<=w&&(c=!0,o===g.rowStartIndex&&d===p&&(h=!0))}a.classList.toggle("ag-cell-range-selected",c),a.classList.toggle("ag-cell-range-anchor",h)}}}getRangeCells(e){const t=this.getCenterColumns(),i=t.findIndex(c=>c.colId===e.colStartId),s=t.findIndex(c=>c.colId===e.colEndId),n=Math.min(e.rowStartIndex,e.rowEndIndex),o=Math.max(e.rowStartIndex,e.rowEndIndex),a=Math.min(i,s),r=Math.max(i,s),d=[];for(let c=n;c<=o;c++){const h=this.grid.getDisplayedRowAtIndex(c);if(h)for(let g=a;g<=r;g++)t[g]&&d.push({node:h,column:t[g]})}return d}getCurrentRange(){return this.currentRange}onGridKeyDown(e){if(this.isEnabled()){if((e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().copyToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="x"||e.key==="X")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().cutToClipboard());return}if((e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")){this.ranges.length&&(e.preventDefault(),this.grid.getApi().pasteFromClipboard());return}if((e.keyCode===gt||e.keyCode===pt)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const i of this.getRangeCells(t))this.grid.setCellValue(i.column,i.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}function Dt(l){return String(l).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const me=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class rs{constructor(e,t){u(this,"charts",new Map);u(this,"chartCounter",0);u(this,"currentType","line");u(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),i=t.getRowGroupColumns();let s=e.categoryColumn;const n=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(r=>r.aggFunc),o=[],a=n.map(()=>[]);if(i.length>0)((d,c)=>{for(const h of d)if(h.group){const g=i[0]?String(H(i[0],h,this.grid.getApi())??""):h.key??"";o.push(g);for(let p=0;p<n.length;p++){const m=[];Ft(h,n[p],m),a[p].push(Number(Fe(n[p],n[p].aggFunc,m))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(s||(s=this.grid.getColumns().center.find(r=>r.field&&r.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(r=>{if(r.group||r.footer)return;const d=s?H(s,r,this.grid.getApi()):"";o.push(String(d??""));for(let c=0;c<n.length;c++){const h=H(n[c],r,this.grid.getApi());a[c].push(typeof h=="number"?h:Number(h)||0)}}),o.length>200){const r=Math.ceil(o.length/200),d=[],c=a.map(()=>[]);for(let h=0;h<o.length;h+=r){d.push(o[h]);for(let g=0;g<a.length;g++)c[g].push(a[g][h])}return{categories:d,series:n.map((h,g)=>({title:h.headerName,data:c[g]}))}}return{categories:o,series:n.map((r,d)=>({title:r.headerName,data:a[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const t=document.createElement("div");t.className="ag-side-bar-section-title",t.textContent=this.grid.t("integratedCharts"),e.appendChild(t);const i=document.createElement("div");i.className="ag-chart-panel-label",i.textContent=this.grid.t("chartType"),e.appendChild(i);const s=document.createElement("select");s.className="ag-chart-panel-select";const n=[{value:"line",label:this.grid.t("chartLine")},{value:"area",label:this.grid.t("chartArea")},{value:"column",label:this.grid.t("chartColumn")},{value:"bar",label:this.grid.t("chartBar")},{value:"pie",label:this.grid.t("chartPie")},{value:"scatter",label:this.grid.t("chartScatter")}];for(const v of n){const C=document.createElement("option");C.value=v.value,C.textContent=v.label,v.value===this.currentType&&(C.selected=!0),s.appendChild(C)}s.addEventListener("change",()=>{this.currentType=s.value}),e.appendChild(s);const o=document.createElement("div");o.className="ag-chart-panel-label",o.textContent=this.grid.t("chartCategory"),e.appendChild(o);const a=document.createElement("select");a.className="ag-chart-panel-select";const r=this.grid.getColumnModel().getRowGroupColumns(),d=r.length>0?r:this.grid.getColumns().center.filter(v=>v.field);for(const v of d){const C=document.createElement("option");C.value=v.colId,C.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${v.headerName}`:v.headerName,a.appendChild(C)}e.appendChild(a);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent=this.grid.t("chartSeries"),e.appendChild(c);const h=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),g=document.createElement("div");g.className="ag-chart-panel-series";const p=new Set(h.slice(0,3).map(v=>v.colId));for(const v of this.grid.getColumns().center.filter(C=>C.field)){const C=document.createElement("label");C.className="ag-chart-panel-series-item";const w=document.createElement("input");w.type="checkbox",w.checked=p.has(v.colId),w.addEventListener("change",()=>{w.checked?p.add(v.colId):p.delete(v.colId)}),C.appendChild(w);const x=document.createElement("span");x.textContent=v.headerName,C.appendChild(x),g.appendChild(C)}e.appendChild(g);const m=document.createElement("button");m.className="ag-button ag-button-primary ag-chart-panel-create",m.textContent=this.grid.t("createChart"),m.addEventListener("click",()=>{const v=this.grid.getColumn(a.value)||void 0,C=[...p].map(w=>this.grid.getColumn(w)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:C})}),e.appendChild(m);const f=document.createElement("div");if(f.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent=this.grid.t("noChartsCreated"),f.appendChild(v)}for(const[v,C]of this.charts){const w=document.createElement("div");w.className="ag-chart-panel-list-item";const x=document.createElement("span");x.textContent=C.title,w.appendChild(x);const b=document.createElement("button");b.className="ag-column-group-remove",b.textContent="×",b.addEventListener("click",()=>this.destroyChart(v)),w.appendChild(b),f.appendChild(w)}return e.appendChild(f),e}createChart(e={}){var v,C,w,x;const t=e.type||this.currentType,i=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),s=`chart-${++this.chartCounter}`,n=e.title||`${this.grid.t(`chart${t.charAt(0).toUpperCase()}${t.slice(1)}`)}`,{ePopup:o}=this.popupService.createPopup(640,"ag-chart-window");o.innerHTML="";const a=document.createElement("div");a.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=n,a.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent=this.grid.t("downloadPng"),a.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title=this.grid.t("close"),c.addEventListener("click",()=>this.destroyChart(s)),a.appendChild(c),o.appendChild(a);const h=document.createElement("div");h.className="ag-chart-window-body";const g=document.createElement("canvas");g.className="ag-chart-canvas",g.width=600,g.height=360,h.appendChild(g);const p=document.createElement("div");p.className="ag-chart-tooltip",p.style.display="none",h.appendChild(p),g.addEventListener("mousemove",b=>this.onChartHover({id:s,ePopup:o,canvas:g,type:t,data:i,title:n},b,p)),g.addEventListener("mouseleave",()=>{p.style.display="none"});const m=document.createElement("div");m.className="ag-chart-legend",h.appendChild(m),o.appendChild(h),this.timeSeries=i.categories.length>0&&i.categories.every(b=>!isNaN(Date.parse(String(b)))&&isNaN(Number(b)));const f={id:s,ePopup:o,canvas:g,type:t,data:i,title:n};return this.charts.set(s,f),d.addEventListener("click",()=>{const b=g.toDataURL("image/png"),y=document.createElement("a");y.href=b,y.download=`${n.replace(/\s+/g,"-").toLowerCase()}.png`,y.click()}),this.popupService.positionAt(o,this.grid.getRootElement()),o.style.top="60px",this.renderChart(f),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:s,chartTitle:n,api:this.grid.getApi()}),(C=(v=this.grid.getOptions()).onChartCreated)==null||C.call(v,{chartId:s,chartTitle:n,api:this.grid.getApi()}),((w=this.grid.getSideBarService())==null?void 0:w.getActivePanel())==="charts"&&((x=this.grid.getSideBarService())==null||x.refresh()),s}destroyChart(e){var i,s,n,o;const t=this.charts.get(e);t&&(t.ePopup.remove(),this.charts.delete(e),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartDestroyed",{chartId:e,api:this.grid.getApi()}),(s=(i=this.grid.getOptions()).onChartDestroyed)==null||s.call(i,{chartId:e,api:this.grid.getApi()}),((n=this.grid.getSideBarService())==null?void 0:n.getActivePanel())==="charts"&&((o=this.grid.getSideBarService())==null||o.refresh()))}getChartModels(){return[...this.charts.values()].map(e=>({chartId:e.id,chartType:e.type,title:e.title}))}refreshCharts(){for(const e of this.charts.values())e.data=this.getChartData(),this.renderChart(e)}onChartHover(e,t,i){const n=e.canvas.getBoundingClientRect(),o=600/(n.width||1),a=360/(n.height||1),r=(t.clientX-n.left)*o,d=(t.clientY-n.top)*a,c={top:20,right:20,bottom:34,left:56},h=600-c.left-c.right,g=360-c.top-c.bottom;if(r<c.left||r>c.left+h||d<c.top||d>c.top+g){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const p=e.type==="bar",m=Math.max(1,e.data.categories.length),f=(p?g:h)/m,v=Math.floor((p?d-c.top:r-c.left)/f);if(v<0||v>=e.data.categories.length){i.style.display="none";return}const C=e.data.series.map(w=>`${w.title}: ${this.formatTick(w.data[v]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${Dt(e.data.categories[v])}</div>`+C.map(w=>`<div>${Dt(w)}</div>`).join(""),i.style.display="block",i.style.left=`${t.clientX-n.left+12}px`,i.style.top=`${t.clientY-n.top+12}px`}storageKey(){const t=this.grid.getOptions().chartStorageKey;return t?`rowvia-charts:${t}`:null}saveCharts(){const e=this.storageKey();if(!e)return;const t=[...this.charts.values()].map(i=>({id:i.id,type:i.type,title:i.title,data:i.data}));try{localStorage.setItem(e,JSON.stringify(t))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let t=[];try{const i=localStorage.getItem(e);i&&(t=JSON.parse(i))}catch{return}for(const i of t)this.restoreChart(i)}restoreChart(e){const t=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(t))return;const{ePopup:i}=this.popupService.createPopup(640,"ag-chart-window");i.innerHTML="";const s=document.createElement("div");s.className="ag-chart-window-header";const n=document.createElement("span");n.className="ag-chart-window-title",n.textContent=e.title||this.grid.t("chart"),s.appendChild(n);const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent="×",o.addEventListener("click",()=>this.destroyChart(t)),s.appendChild(o),i.appendChild(s);const a=document.createElement("div");a.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,a.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",a.appendChild(d),i.appendChild(a);const c={id:t,ePopup:i,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,c),this.popupService.positionAt(i,this.grid.getRootElement()),i.style.top="60px",this.renderChart(c)}renderChart(e){var W;const t=e.canvas,i=t.getContext("2d");if(!i)return;const s=window.devicePixelRatio||1,n=t.width,o=t.height;t.width=n*s,t.height=o*s,t.style.width=`${n}px`,t.style.height=`${o}px`,i.scale(s,s),i.clearRect(0,0,n,o);const a=getComputedStyle(this.grid.getRootElement()),r=a.getPropertyValue("--ag-chart-text-color")||"#666",d=a.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},h=n-c.left-c.right,g=o-c.top-c.bottom;i.font="11px sans-serif",i.fillStyle=r,i.strokeStyle=d,i.lineWidth=1;const p=(W=e.canvas.parentElement)==null?void 0:W.querySelector(".ag-chart-legend");if(p&&(p.innerHTML="",e.data.series.forEach((T,A)=>{const F=document.createElement("span");F.className="ag-chart-legend-item";const S=document.createElement("span");S.className="ag-chart-legend-swatch",S.style.backgroundColor=me[A%me.length],F.appendChild(S),F.appendChild(document.createTextNode(T.title)),p.appendChild(F)})),e.type==="pie"){this.renderPie(i,e.data,n,o,r);return}const m=e.data.series.flatMap(T=>T.data);let f=Math.max(0,...m),v=Math.min(0,...m);e.type==="scatter"&&(v=Math.min(...m),f=Math.max(...m));const C=f-v||1;f+=C*.08,v-=v<0?C*.08:0;const w=f-v||1,x=T=>c.top+g-(T-v)/w*g,b=5;i.textAlign="right",i.textBaseline="middle";for(let T=0;T<=b;T++){const A=v+w*T/b,F=x(A);i.beginPath(),i.moveTo(c.left,F),i.lineTo(n-c.right,F),i.stroke(),i.fillText(this.formatTick(A),c.left-6,F)}const y=e.data.categories,N=e.type==="bar",I=Math.max(1,y.length),D=(N?g:h)/I;if(N){i.textAlign="left",y.forEach((A,F)=>{const S=c.top+F*D,L=Math.max(2,D*.7/e.data.series.length);e.data.series.forEach((P,O)=>{const V=P.data[F]||0,X=Math.abs(V)/w*h,B=c.left+(0-v)/w*h;i.fillStyle=me[O%me.length],i.fillRect(B,S+O*L,Math.max(1,X),L-1)}),i.fillStyle=r,i.fillText(this.truncate(A,18),c.left+4,S+D/2)});const T=c.left+(0-v)/w*h;i.beginPath(),i.moveTo(T,c.top),i.lineTo(T,c.top+g),i.strokeStyle=r,i.stroke()}else{const T=Math.max(1,Math.ceil(I/12));i.textAlign="center",i.textBaseline="top",y.forEach((S,L)=>{if(L%T!==0)return;const P=c.left+D*(L+.5);i.fillStyle=r,i.fillText(this.truncate(S,10),P,c.top+g+6)});const A=e.data.series.length,F=Math.max(1,D*.7/Math.max(1,A));e.data.series.forEach((S,L)=>{const P=me[L%me.length];if(e.type==="column")i.fillStyle=P,S.data.forEach((O,V)=>{const X=c.left+D*V+(D-F*A)/2+L*F,B=x(O);i.fillRect(X,B,F-1,c.top+g-B)});else if(e.type==="area"){i.beginPath(),S.data.forEach((V,X)=>{const B=c.left+D*(X+.5),ee=x(V);X===0?i.moveTo(B,ee):i.lineTo(B,ee)});const O=c.left+D*(S.data.length-.5);i.lineTo(O,c.top+g),i.lineTo(c.left+D*.5,c.top+g),i.closePath(),i.globalAlpha=.25,i.fillStyle=P,i.fill(),i.globalAlpha=1,i.beginPath(),S.data.forEach((V,X)=>{const B=c.left+D*(X+.5),ee=x(V);X===0?i.moveTo(B,ee):i.lineTo(B,ee)}),i.strokeStyle=P,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=P,S.data.forEach((O,V)=>{const X=c.left+D*(V+.5),B=x(O);i.beginPath(),i.arc(X,B,3,0,Math.PI*2),i.fill()})):(i.beginPath(),S.data.forEach((O,V)=>{const X=c.left+D*(V+.5),B=x(O);V===0?i.moveTo(X,B):i.lineTo(X,B)}),i.strokeStyle=P,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,s,n){const o=t.series[0];if(!o)return;const a=o.data.reduce((g,p)=>g+Math.abs(p),0)||1,r=i/2,d=s/2,c=Math.min(i,s)/2-30;let h=-Math.PI/2;o.data.forEach((g,p)=>{const m=Math.abs(g)/a*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,h,h+m),e.closePath(),e.fillStyle=me[p%me.length],e.fill();const f=h+m/2,v=r+Math.cos(f)*(c*.7),C=d+Math.sin(f)*(c*.7),w=Math.round(Math.abs(g)/a*100);w>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${w}%`,v,C)),h+=m}),e.fillStyle=n}formatTick(e){if(this.timeSeries){const i=new Date(e);if(!isNaN(i.getTime()))return i.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}const t=Math.abs(e);return t>=1e9?`${(e/1e9).toFixed(1)}B`:t>=1e6?`${(e/1e6).toFixed(1)}M`:t>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):e.toFixed(1)}truncate(e,t){return e.length>t?`${e.slice(0,t-1)}…`:e}}function Ft(l,e,t){const i=l.children;if(!i||i.length===0){const s=H(e,l,null);typeof s=="number"&&!isNaN(s)&&t.push(s);return}for(const s of i)Ft(s,e,t)}class as{constructor(e){u(this,"eOverlayWrapper");u(this,"current",null);this.grid=e,this.eOverlayWrapper=document.createElement("div"),this.eOverlayWrapper.className="ag-overlay",this.eOverlayWrapper.style.display="none";const t=e.getRowRenderer().getViewport();t.style.position="relative",this.eOverlayWrapper.style.position="absolute",this.eOverlayWrapper.style.inset="0",this.eOverlayWrapper.style.zIndex="10",t.appendChild(this.eOverlayWrapper)}show(e,t){this.current=e,this.eOverlayWrapper.innerHTML="";const i=document.createElement("div");i.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const s=document.createElement("div");if(s.className="ag-overlay-text",s.textContent=t,e==="loading"){const n=document.createElement("div");n.className="ag-overlay-loading-spinner",i.appendChild(n)}i.appendChild(s),this.eOverlayWrapper.appendChild(i),this.eOverlayWrapper.style.display="flex"}showLoadingOverlay(){this.show("loading",this.grid.translate("loadingOoo","Loading..."))}showNoRowsOverlay(){this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show"))}hideOverlay(){this.current=null,this.eOverlayWrapper.style.display="none",this.eOverlayWrapper.innerHTML=""}updateAuto(){const e=this.grid.getRowModel();if(!!this.grid.getOptions().__loadingRows){this.showLoadingOverlay();return}const i=e.getRowCount(),s=this.grid.getOptions().rowData;Array.isArray(s)&&s.length>0,i===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}const ds=(()=>{const l=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let i=0;i<8;i++)t=t&1?3988292384^t>>>1:t>>>1;l[e]=t>>>0}return l})();function cs(l){let e=4294967295;for(let t=0;t<l.length;t++)e=ds[(e^l[t])&255]^e>>>8;return(e^4294967295)>>>0}function Pt(l){return l.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function hs(l){let e="",t=l+1;for(;t>0;){const i=(t-1)%26;e=String.fromCharCode(65+i)+e,t=Math.floor((t-1)/26)}return e}function us(l){const e=new TextEncoder,t=[],i=[];let s=0;for(const h of l){const g=e.encode(h.name),p=cs(h.data),m=new Uint8Array(30+g.length),f=new DataView(m.buffer);f.setUint32(0,67324752,!0),f.setUint16(4,20,!0),f.setUint16(6,2048,!0),f.setUint16(8,0,!0),f.setUint16(10,0,!0),f.setUint16(12,8585,!0),f.setUint32(14,p,!0),f.setUint32(18,h.data.length,!0),f.setUint32(22,h.data.length,!0),f.setUint16(26,g.length,!0),f.setUint16(28,0,!0),m.set(g,30),t.push(m,h.data);const v=new Uint8Array(46+g.length),C=new DataView(v.buffer);C.setUint32(0,33639248,!0),C.setUint16(4,20,!0),C.setUint16(6,20,!0),C.setUint16(8,2048,!0),C.setUint16(10,0,!0),C.setUint16(12,0,!0),C.setUint16(14,0,!0),C.setUint32(16,p,!0),C.setUint32(20,h.data.length,!0),C.setUint32(24,h.data.length,!0),C.setUint16(28,g.length,!0),C.setUint32(42,s,!0),v.set(g,46),i.push(v),s+=m.length+h.data.length}const n=i.reduce((h,g)=>h+g.length,0),o=new Uint8Array(22),a=new DataView(o.buffer);a.setUint32(0,101010256,!0),a.setUint16(8,l.length,!0),a.setUint16(10,l.length,!0),a.setUint32(12,n,!0),a.setUint32(16,s,!0);const r=t.reduce((h,g)=>h+g.length,0)+n+o.length,d=new Uint8Array(r);let c=0;for(const h of t)d.set(h,c),c+=h.length;for(const h of i)d.set(h,c),c+=h.length;return d.set(o,c),d}function ps(l){let e='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';return e+='<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>',l.forEach((t,i)=>{const s=i+1,o=t.some(a=>a.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${s}"${o}>`,t.forEach((a,r)=>{const d=`${hs(r)}${s}`,c=a.bold?' s="1"':"";if(a.value===null||a.value===void 0||a.value===""){e+=`<c r="${d}"${c}/>`;return}typeof a.value=="number"&&isFinite(a.value)?e+=`<c r="${d}"${c}><v>${a.value}</v></c>`:typeof a.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${a.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${Pt(String(a.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const gs='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><fonts count="2"><font><sz val="11"/><name val="Calibri"/></font><font><b/><sz val="11"/><name val="Calibri"/></font></fonts><fills count="2"><fill><patternFill patternType="none"/></fill><fill><patternFill patternType="gray125"/></fill></fills><borders count="1"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="2"><xf numFmtId="0" fontId="0" fillId="0" borderId="0" xfId="0"/><xf numFmtId="0" fontId="1" fillId="0" borderId="0" xfId="0" applyFont="1"/></cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>';function fs(l){const e=new TextEncoder,t=(h,g)=>h.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${g+1}`;let i="",s="",n="";l.forEach((h,g)=>{const p=t(h.name,g),m=g+1;i+=`<sheet name="${Pt(p)}" sheetId="${m}" r:id="rId${m}"/>`,s+=`<Relationship Id="rId${m}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${m}.xml"/>`,n+=`<Override PartName="/xl/worksheets/sheet${m}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const o='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Override PartName="/xl/workbook.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml"/><Override PartName="/xl/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml"/>'+n+"</Types>",a='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${i}</sheets></workbook>`,d='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+s+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(o)},{name:"_rels/.rels",data:e.encode(a)},{name:"xl/workbook.xml",data:e.encode(r)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(d)},{name:"xl/styles.xml",data:e.encode(gs)}];return l.forEach((h,g)=>{c.push({name:`xl/worksheets/sheet${g+1}.xml`,data:e.encode(ps(h.rows))})}),new Blob([us(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const ms={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function At(l){return l.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function vs(l,e,t){const i=Math.max(1,Math.floor(e/(t*.5)));return l.length>i?`${l.slice(0,Math.max(1,i-1))}…`:l}function Cs(){return new TextEncoder}function ws(l,e={}){const[t,i]=ms[e.pageSize||"a4-landscape"],s=e.margin??32,n=e.fontSize??9,o=e.rowHeight??18,a=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=Cs(),c=[],h=w=>(c.push(w),c.length);h(""),h("");const g=h("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),p=h("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),m=[];for(const w of l){let x="";const b=w.columnWidths.reduce((S,L)=>S+L,0),y=Math.min(1,(t-s*2)/(b||1)),N=w.columnWidths.map(S=>S*y),I=s;let D=i-s-(e.title?24:0);e.title&&(x+=`BT /F2 ${n+4} Tf ${I} ${D} Td (${At(e.title)}) Tj ET
4
+ `,D-=18),w.rows.forEach((S,L)=>{var X;const P=L===0,O=((X=w.rowFill)==null?void 0:X[L])??(P?a:void 0);O&&(x+=`${O[0]} ${O[1]} ${O[2]} rg ${I} ${(D-o+4).toFixed(2)} ${b*y} ${o} re f
5
+ `);let V=I;S.forEach((B,ee)=>{const j=N[ee]??0,Te=At(vs(B.text??"",j-6,n)),Se=B.bold||P?p:g,xe=(B.text??"").length*n*.5;let ue=V+3;B.align==="right"||!B.align&&ee>0&&/^-?[\d,.%$£€\s]+$/.test(B.text??"")?ue=V+j-3-Math.min(xe,j-6):B.align==="center"&&(ue=V+(j-Math.min(xe,j-6))/2),x+=`BT /F${Se===p?2:1} ${n} Tf ${ue.toFixed(2)} ${(D-n+2).toFixed(2)} Td (${Te}) Tj ET
6
6
  `,V+=j}),x+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${I} ${(D-o+4).toFixed(2)} m ${(I+b*y).toFixed(2)} ${(D-o+4).toFixed(2)} l S
7
- `,D-=o});const _=w.rows.length*o;x+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${I} ${(D+o-4).toFixed(2)} m ${I} ${(D+_+o-4).toFixed(2)} l ${(I+b*y).toFixed(2)} ${(D+_+o-4).toFixed(2)} l ${(I+b*y).toFixed(2)} ${(D+o-4).toFixed(2)} l S
8
- `;const T=d.encode(x),P=h(`<< /Length ${T.length} >>
7
+ `,D-=o});const W=w.rows.length*o;x+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${I} ${(D+o-4).toFixed(2)} m ${I} ${(D+W+o-4).toFixed(2)} l ${(I+b*y).toFixed(2)} ${(D+W+o-4).toFixed(2)} l ${(I+b*y).toFixed(2)} ${(D+o-4).toFixed(2)} l S
8
+ `;const T=d.encode(x),A=h(`<< /Length ${T.length} >>
9
9
  stream
10
10
  ${x}
11
- endstream`),F=h(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${i} ${t}] /Resources << /Font << /F1 ${g} 0 R /F2 ${u} 0 R >> >> /Contents ${P} 0 R >>`);f.push(F)}c[0]="<< /Type /Catalog /Pages 2 0 R >>",c[1]=`<< /Type /Pages /Kids [${f.map(w=>`${w} 0 R`).join(" ")}] /Count ${f.length} >>`;let m=`%PDF-1.4
12
- `;const v=[];c.forEach((w,x)=>{const b=x+1;v.push(d.encode(m).length),m+=`${b} 0 obj
11
+ endstream`),F=h(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${i}] /Resources << /Font << /F1 ${g} 0 R /F2 ${p} 0 R >> >> /Contents ${A} 0 R >>`);m.push(F)}c[0]="<< /Type /Catalog /Pages 2 0 R >>",c[1]=`<< /Type /Pages /Kids [${m.map(w=>`${w} 0 R`).join(" ")}] /Count ${m.length} >>`;let f=`%PDF-1.4
12
+ `;const v=[];c.forEach((w,x)=>{const b=x+1;v.push(d.encode(f).length),f+=`${b} 0 obj
13
13
  ${w}
14
14
  endobj
15
- `});const C=d.encode(m).length;m+=`xref
15
+ `});const C=d.encode(f).length;f+=`xref
16
16
  0 ${c.length+1}
17
17
  0000000000 65535 f
18
- `;for(const w of v)m+=`${String(w).padStart(10,"0")} 00000 n
19
- `;return m+=`trailer
18
+ `;for(const w of v)f+=`${String(w).padStart(10,"0")} 00000 n
19
+ `;return f+=`trailer
20
20
  << /Size ${c.length+1} /Root 1 0 R >>
21
21
  startxref
22
22
  ${C}
23
23
  %%EOF
24
- `,new Blob([d.encode(m)],{type:"application/pdf"})}function Ee(l,e){return l.getUint32(e,!0)}function ye(l,e){return l.getUint16(e,!0)}async function ys(l){var s;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const i=(s=new Response(l).body)==null?void 0:s.pipeThrough(new DecompressionStream("deflate-raw"));if(!i)throw new Error("Failed to create a decompression stream");const t=await new Response(i).arrayBuffer();return new Uint8Array(t)}function Ss(l){const e=new DataView(l),i=new Uint8Array(l);let t=-1;for(let a=i.length-22;a>=0;a--)if(Ee(e,a)===101010256){t=a;break}if(t<0)throw new Error("Not a valid XLSX (ZIP) file");const s=ye(e,t+10);let n=Ee(e,t+16);const o=[];for(let a=0;a<s&&Ee(e,n)===33639248;a++){const r=ye(e,n+10),d=Ee(e,n+20),c=Ee(e,n+24),h=ye(e,n+28),g=ye(e,n+30),u=ye(e,n+32),f=Ee(e,n+42),m=new TextDecoder().decode(i.subarray(n+46,n+46+h));o.push({name:m,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:f}),n+=46+h+g+u}return o}async function it(l,e){const i=new DataView(l),t=new Uint8Array(l),s=ye(i,e.localHeaderOffset+26),n=ye(i,e.localHeaderOffset+28),o=e.localHeaderOffset+30+s+n,a=t.subarray(o,o+e.compressedSize);return e.compressionMethod===0?a:ys(a)}function st(l){return new DOMParser().parseFromString(l,"application/xml")}function xs(l){const e=l.replace(/\d+/g,"");let i=0;for(const t of e)i=i*26+(t.charCodeAt(0)-64);return i-1}async function bs(l){const e=Ss(l),i=e.find(d=>d.name==="xl/workbook.xml"),t=[];if(i){const c=st(new TextDecoder().decode(await it(l,i))).getElementsByTagName("sheet");for(let h=0;h<c.length;h++)t.push(c[h].getAttribute("name")||`Sheet${h+1}`),c[h].getAttribute("r:id")||c[h].getAttribute("id")}const s=[],n=e.find(d=>d.name==="xl/sharedStrings.xml");if(n){const c=st(new TextDecoder().decode(await it(l,n))).getElementsByTagName("si");for(let h=0;h<c.length;h++){const g=c[h].getElementsByTagName("t");let u="";for(let f=0;f<g.length;f++)u+=g[f].textContent||"";s.push(u)}}const a=e.filter(d=>/^xl\/worksheets\/sheet\d+\.xml$/.test(d.name)).sort((d,c)=>d.name.localeCompare(c.name,void 0,{numeric:!0})),r=[];for(let d=0;d<a.length;d++){const h=st(new TextDecoder().decode(await it(l,a[d]))).getElementsByTagName("row"),g=[];for(let u=0;u<h.length;u++){const f=h[u],m=[],v=f.getElementsByTagName("c");for(let C=0;C<v.length;C++){const w=v[C],x=w.getAttribute("r")||"",b=w.getAttribute("t")||"";let y="";if(b==="s"){const I=w.getElementsByTagName("v")[0],D=Number((I==null?void 0:I.textContent)||"0");y=s[D]??""}else if(b==="inlineStr"){const I=w.getElementsByTagName("t");for(let D=0;D<I.length;D++)y+=I[D].textContent||""}else{const I=w.getElementsByTagName("v")[0];y=(I==null?void 0:I.textContent)??""}const N=x?xs(x):C;m[N]=y}g.push(m.map(C=>C??""))}r.push({name:t[d]||`Sheet${d+1}`,rows:g})}return r}class Es{constructor(e){p(this,"lastCopied",null);this.grid=e}getExportColumns(e){const i=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(s=>typeof s=="string"?this.grid.getColumn(s):s).filter(s=>!!s);if(e.allColumns)return i.filter(s=>s.field||s.valueGetter);const t=this.grid.getColumns();return[...t.center,...t.left,...t.right]}getExportRows(e){const i=this.grid.getRowModel(),t=[],s=e.onlySelected===!0,n=e.skipGroups!==!1,o=e.skipFooters!==!1;return i.forEachNode(a=>{a.rowPinned==="top"&&e.skipPinnedTop!==!1||a.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||n&&a.group&&!a.footer||o&&a.footer||s&&!a.selected||t.push(a)}),s&&t.length===0?this.getExportRows({...e,onlySelected:!1}):t}getCellValueForExport(e,i,t){let s=H(e,i,this.grid.getApi()),n=Ve(e,i,this.grid.getApi());if(t.processCellCallback){const o=t.processCellCallback({value:s,formattedValue:n,node:i,column:e,api:this.grid.getApi()});if(o!=null)return String(o)}return i.footer&&i.groupData&&i.groupData[e.colId]!==void 0&&(s=i.groupData[e.colId],n=s===null?"":String(s)),i.group&&i.groupData&&i.groupData[e.colId]!==void 0&&(s=i.groupData[e.colId],n=s===null?"":String(s)),s instanceof Date?s.toISOString().slice(0,10):n??(s==null?"":String(s))}getDataAsCsv(e={}){var o;const i=this.getExportColumns(e),t=this.getExportRows(e),s=e.columnSeparator??",",n=[];if(!e.skipHeader){const a=i.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&n.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),s,e.suppressQuotes)),n.push(this.csvRow(a,s,e.suppressQuotes))}for(const a of t){if((o=e.shouldRowBeSkipped)!=null&&o.call(e,{node:a,api:this.grid.getApi()}))continue;const r=i.map(d=>this.getCellValueForExport(d,a,e));n.push(this.csvRow(r,s,e.suppressQuotes))}return n.join(`\r
25
- `)}csvRow(e,i,t){return e.map(s=>{const n=s==null?"":String(s);return!t&&(n.includes(i)||n.includes('"')||n.includes(`
26
- `))?`"${n.replace(/"/g,'""')}"`:n}).join(i)}getDataAsExcel(e={}){const i=this.getExportColumns(e),t=this.getExportRows(e),s=[];e.skipHeader||s.push(i.map(n=>({value:n.headerName||n.field||n.colId,bold:!0})));for(const n of t)s.push(i.map(o=>{let a=H(o,n,this.grid.getApi());return n.footer&&n.groupData&&n.groupData[o.colId]!==void 0&&(a=n.groupData[o.colId]),n.group&&n.groupData&&n.groupData[o.colId]!==void 0&&(a=n.groupData[o.colId]),a instanceof Date&&(a=a.toISOString().slice(0,10)),{value:a}}));return fs([{name:e.sheetName||"Sheet1",rows:s}])}exportToCsv(e={}){const i=this.getDataAsCsv(e);this.download(new Blob([i],{type:"text/csv;charset=utf-8;"}),this.fileName(e,"csv"))}exportToExcel(e={}){const i=this.getDataAsExcel(e);this.download(i,this.fileName(e,"xlsx"))}getDataAsPdf(e={}){var f;const i=this.getExportColumns(e),t=this.getExportRows(e),s=i.map(m=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(m.headerName)+24))),n=[],o=[];e.skipHeader||(n.push(i.map(m=>({text:e.processHeaderCallback?e.processHeaderCallback({column:m,api:this.grid.getApi()}):m.headerName||m.field||m.colId,bold:!0,align:m.type==="numberColumn"||m.cellDataType===!0?"right":"left"}))),o.push([.94,.95,.97]));for(const m of t)(f=e.shouldRowBeSkipped)!=null&&f.call(e,{node:m,api:this.grid.getApi()})||(n.push(i.map(v=>{let C=this.getCellValueForExport(v,m,e);if(e.processCellCallback){const w=e.processCellCallback({value:H(v,m,this.grid.getApi()),formattedValue:C,node:m,column:v,api:this.grid.getApi()});w!=null&&(C=String(w))}return{text:C,align:v.type==="numberColumn"||v.cellDataType===!0?"right":"left"}})),o.push(void 0));const a=18,r=e.pageSize||"a4-landscape",[d,c]=r.includes("portrait")?[595,842]:[842,595],h=c-64-(e.title?24:0),g=Math.max(5,Math.floor(h/a)),u=[];n.length===0&&u.push({columnWidths:s,rows:[],rowFill:[]});for(let m=0;m<n.length;m+=g)u.push({columnWidths:s,rows:n.slice(m,m+g),rowFill:o.slice(m,m+g)});return ws(u,{pageSize:r,title:e.title})}exportToPdf(e={}){const i=this.getDataAsPdf(e);this.download(i,this.fileName(e,"pdf"))}async importExcel(e,i={}){const t=e instanceof ArrayBuffer?e:await e.arrayBuffer(),n=(await bs(t))[i.sheetIndex??0];if(!n||n.rows.length===0)return[];const o=n.rows[0],a=n.rows.slice(1).map(r=>{const d={};return o.forEach((c,h)=>{const g=c||`col${h+1}`,u=r[h]??"",f=String(u).trim();d[g]=f!==""&&!isNaN(Number(f))&&!/^0\d/.test(f)?Number(f):u}),d});return i.onSuccess?i.onSuccess(a):this.grid.getApi().setRowData(a),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:a}),a}fileName(e,i){const t=e.fileName||this.grid.getOptions().fileName||"export";return t.endsWith(`.${i}`)?t:`${t}.${i}`}download(e,i){const t=URL.createObjectURL(e),s=document.createElement("a");s.href=t,s.download=i,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(t),1e3)}copyToClipboard(e={}){const i={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},t=this.getDataAsCsv(i);this.lastCopied=t,this.writeToClipboard(t),this.grid.getEventService().dispatchEvent("pasteStart",{}),this.grid.getEventService().dispatchEvent("pasteEnd",{})}cutToClipboard(e={}){this.copyToClipboard(e);const i=this.getExportRows({onlySelected:!0,skipGroups:!0,skipFooters:!0,...e});i.length&&this.grid.getApi().applyTransaction({remove:i.map(t=>t.data)})}pasteFromClipboard(){navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(e=>this.pasteText(e),()=>{this.lastCopied&&this.pasteText(this.lastCopied)}):this.lastCopied&&this.pasteText(this.lastCopied)}pasteText(e){const i=this.grid.getEditService().getFocusedCell(),t=this.grid.getRangeSelectionService().getRanges();let s,n;if(t.length>0){const h=t[0];s=h.rowStartIndex;const g=this.grid.getColumns().center,u=g.findIndex(f=>f.colId===h.colStartId);n=g[u]??g[0]}else if(i)s=i.rowIndex,n=i.column;else return;const o=e.replace(/\r/g,"").split(`
27
- `);o.length&&o[o.length-1]===""&&o.pop();const a=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=a.findIndex(h=>h.colId===n.colId),d=[],c=[];this.grid.getDisplayedRowCount(),o.forEach((h,g)=>{const u=h.split(" "),f=s+g;let m=this.grid.getDisplayedRowAtIndex(f);if(!m){const v={};u.forEach((C,w)=>{const x=a[r+w];x!=null&&x.field&&(v[x.field]=C)}),c.push(v);return}u.forEach((v,C)=>{const w=a[r+C];w&&this.grid.setCellValue(w,m,v,"paste")}),d.push(m)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const i=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(i,()=>this.fallbackCopy(e,i)):this.fallbackCopy(e,i)}fallbackCopy(e,i){const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();try{document.execCommand("copy")}catch{}document.body.removeChild(t),i()}}class Rs{constructor(e){p(this,"ePanel");p(this,"eChips");this.grid=e,this.ePanel=document.createElement("div"),this.ePanel.className="ag-row-group-panel";const i=document.createElement("span");i.className="ag-row-group-panel-label",i.textContent=this.grid.t("rowGroups"),this.ePanel.appendChild(i),this.eChips=document.createElement("div"),this.eChips.className="ag-row-group-panel-chips",this.ePanel.appendChild(this.eChips),this.eChips.addEventListener("dragover",n=>{n.preventDefault(),this.eChips.classList.add("ag-drag-over")}),this.eChips.addEventListener("dragleave",()=>this.eChips.classList.remove("ag-drag-over")),this.eChips.addEventListener("drop",n=>{var a;n.preventDefault(),this.eChips.classList.remove("ag-drag-over");const o=(a=n.dataTransfer)==null?void 0:a.getData("text/plain");o&&this.grid.getColumnModel().addRowGroupColumn(o)});const t=e.getOptions();(t.rowGroupPanelShow==="always"||t.rowGroupPanelShow==="onlyWhenGrouping")&&e.getMainElement().insertBefore(this.ePanel,e.getHeaderElement()),this.refresh(),e.getEventService().addEventListener("columnRowGroupChanged",()=>this.refresh()),e.getEventService().addEventListener("modelUpdated",()=>this.refreshVisibility())}refresh(){this.eChips.innerHTML="";const e=this.grid.getColumnModel().getRowGroupColumns();for(const i of e){const t=document.createElement("div");t.className="ag-row-group-chip",t.draggable=!0,t.addEventListener("dragstart",o=>{var a;(a=o.dataTransfer)==null||a.setData("text/plain",i.colId)});const s=document.createElement("span");s.textContent=i.headerName,t.appendChild(s);const n=document.createElement("button");n.className="ag-row-group-chip-remove",n.textContent="×",n.title=this.grid.t("remove"),n.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(i)),t.appendChild(n),this.eChips.appendChild(t)}if(e.length===0){const i=document.createElement("span");i.className="ag-column-group-hint",i.textContent=this.grid.t("dragColumnsHere"),this.eChips.appendChild(i)}this.refreshVisibility()}refreshVisibility(){const e=this.grid.getOptions().rowGroupPanelShow;if(e==="always")this.ePanel.style.display="";else if(e==="onlyWhenGrouping"){const i=this.grid.getColumnModel().isRowGroupActive();this.ePanel.style.display=i?"":"none"}}}class Ms{constructor(e,i){p(this,"undoStack",[]);p(this,"redoStack",[]);p(this,"limit",50);p(this,"batchDepth",0);p(this,"batchBuffer",[]);p(this,"batchCounter",0);p(this,"currentBatchId",0);this.grid=e,this.eventService=i;const t=e.getOptions();t.undoRedoCellEditing&&(this.limit=typeof t.undoRedoCellEditing=="number"?t.undoRedoCellEditing:50)}isEnabled(){return!!this.grid.getOptions().undoRedoCellEditing}pushAction(e){if(this.isEnabled()){if(this.batchDepth>0){this.batchBuffer.push(e);return}this.undoStack.push({...e,batchId:this.currentBatchId}),this.undoStack.length>this.limit&&this.undoStack.shift(),this.redoStack=[]}}canUndo(){return this.isEnabled()&&this.undoStack.length>0}canRedo(){return this.isEnabled()&&this.redoStack.length>0}getUndoStackSize(){return this.undoStack.length}getRedoStackSize(){return this.redoStack.length}undo(){if(!this.canUndo())return 0;const e=[this.undoStack.pop()];for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].rowNodeId===e[0].rowNodeId&&this.undoStack[this.undoStack.length-1].colId===e[0].colId;)e.push(this.undoStack.pop());if(e[0].batchId!==0)for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].batchId===e[0].batchId;)e.push(this.undoStack.pop());let i=0;for(const t of e)this.applyValue(t,t.oldValue),this.redoStack.push(t),i++;return this.eventService.dispatchEvent("undoEnded",{api:this.grid.getApi(),numberOfActions:i}),i}redo(){if(!this.canRedo())return 0;let e=0;for(;this.redoStack.length>0;){const i=this.redoStack.pop();if(this.applyValue(i,i.newValue),this.undoStack.push(i),e++,this.redoStack.length===0||this.redoStack[this.redoStack.length-1].colId!==i.colId)break}return this.eventService.dispatchEvent("redoEnded",{api:this.grid.getApi(),numberOfActions:e}),e}applyValue(e,i){const t=this.grid.getRowNode(e.rowNodeId);if(!t)return;const s=this.grid.getColumn(e.colId);s&&(this.grid.setCellValue(s,t,i,"undoRedo"),this.grid.refreshCells({rowNodes:[t],columns:[s],flash:!0}))}startBatchEdit(){this.batchDepth++,this.batchDepth===1&&(this.currentBatchId=++this.batchCounter)}endBatchEdit(e=!1){if(this.batchDepth=Math.max(0,this.batchDepth-1),this.batchDepth>0)return;if(e){this.batchBuffer=[];return}const i=this.currentBatchId;for(const t of this.batchBuffer)this.undoStack.push({...t,batchId:i}),this.undoStack.length>this.limit&&this.undoStack.shift();this.redoStack=[],this.batchBuffer=[],this.eventService.dispatchEvent("batchEditEnded",{api:this.grid.getApi()})}isBatchEditing(){return this.batchDepth>0}clear(){this.undoStack=[],this.redoStack=[],this.batchBuffer=[]}}class Ns{constructor(e,i){this.grid=e,this.popupService=i}isFormulaColumn(e){return typeof e.field=="string"&&e.field.trimStart().startsWith("=")}openFormulaEditor(e,i){const{ePopup:t,close:s}=this.popupService.createPopup(460,"ag-formula-editor");t.innerHTML="";const n=document.createElement("div");n.className="ag-popup-title",n.textContent=`Formula - ${e.headerName||e.field}`,t.appendChild(n);const o=document.createElement("textarea");o.className="ag-formula-input",o.rows=3,o.value=this.isFormulaColumn(e)?e.field:"=",o.placeholder=this.grid.t("formulaPlaceholder"),t.appendChild(o);const a=document.createElement("div");a.className="ag-formula-preview";const r=()=>{const m=this.grid.getDisplayedRowAtIndex(0);if(!m){a.textContent="";return}try{const v=De(o.value,{data:m.data});a.textContent=`Preview (row 1): ${v==null?"":String(v)}`,a.classList.remove("ag-formula-error")}catch(v){a.textContent=`Error: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||"invalid formula"}`,a.classList.add("ag-formula-error")}};o.addEventListener("input",r),t.appendChild(a);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent="Functions",d.appendChild(c);const h=document.createElement("div");h.className="ag-formula-functions-list";for(const m of Be){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=m,v.addEventListener("click",()=>{o.value+=`${o.value.endsWith("(")||o.value==="="?"":" "}${m}()`,o.focus(),r()}),h.appendChild(v)}d.appendChild(h),t.appendChild(d);const g=document.createElement("div");g.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent="Apply",u.addEventListener("click",()=>{const m=o.value.trim(),v=this.grid.getColumnModel(),C=v.getColumn(e.colId);C&&(C.field=m==="="||m===""?e.field:m,C.colDef={...C.colDef,field:C.field},m!=="="&&m!==""&&(C.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),s()});const f=document.createElement("button");f.className="ag-button",f.textContent="Clear",f.addEventListener("click",()=>{o.value="=",r()}),g.appendChild(f),g.appendChild(u),t.appendChild(g),this.popupService.positionAt(t,i),r()}}class Ts{constructor(e,i){p(this,"runtimeNotes",new Map);this.grid=e,this.popupService=i}keyOf(e,i){return`${e}::${i}`}getNote(e,i,t,s){const n=this.runtimeNotes.get(this.keyOf(e,i));if(n!==void 0)return n;if(typeof t=="function")return t(s);if(typeof t=="string")return t}setNote(e,i,t){const s=this.keyOf(e,i);t==null||t===""?this.runtimeNotes.delete(s):this.runtimeNotes.set(s,t),this.grid.refreshCells({force:!0})}openNoteEditor(e,i,t){const s=this.grid.getColumn(i),n=this.grid.getRowNode(e),o=this.getNote(e,i,s==null?void 0:s.colDef.note,{data:n==null?void 0:n.data,node:n,column:s,api:this.grid.getApi()})??"",{ePopup:a,close:r}=this.popupService.createPopup(280,"ag-note-editor");a.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Note — ${(s==null?void 0:s.headerName)||i}`,a.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=o,c.placeholder="Write a note…",a.appendChild(c);const h=document.createElement("div");h.className="ag-popup-buttons";const g=document.createElement("button");g.className="ag-button ag-button-primary",g.textContent="Save",g.addEventListener("click",()=>{this.setNote(e,i,c.value.trim()||void 0),r()});const u=document.createElement("button");u.className="ag-button",u.textContent="Delete",u.addEventListener("click",()=>{this.setNote(e,i,void 0),r()}),h.appendChild(u),h.appendChild(g),a.appendChild(h),this.popupService.positionAt(a,t),setTimeout(()=>c.focus(),0)}}class Is{constructor(e,i){p(this,"dragState",null);p(this,"onMouseMoveBind",e=>this.onMouseMove(e));p(this,"onMouseUpBind",e=>this.onMouseUp(e));this.grid=e,this.eventService=i}isEnabled(){const e=this.grid.getOptions();return!!e.rowDragManaged||!!e.rowDragEnt||this.hasDragHandle()}hasDragHandle(){return this.grid.getAllColumns().some(e=>e.rowDrag)}startDrag(e,i){if(!this.isEnabled()||this.dragState)return;i.preventDefault();const t=document.createElement("div");t.className="ag-row-drag-ghost",t.textContent=this.rowLabel(e),document.body.appendChild(t);const s=document.createElement("div");s.className="ag-row-drop-indicator",s.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(s),this.dragState={rowNode:e,ghost:t,startY:i.clientY,overIndex:null,indicator:s},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var s;const i=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],t=i!=null&&i.field?(s=e.data)==null?void 0:s[i.field]:"";return String(t??e.id)}onMouseMove(e){const i=this.dragState;if(!i)return;i.ghost.style.left=`${e.clientX+8}px`,i.ghost.style.top=`${e.clientY+8}px`;const t=document.elementFromPoint(e.clientX,e.clientY),s=t==null?void 0:t.closest(".ag-row");if(!(s!=null&&s.dataset.rowid)){i.overIndex=null,i.indicator.style.display="none";return}let n=-1;if(this.grid.getRowModel().forEachNode((o,a)=>{o.id===s.dataset.rowid&&(n=a)}),i.overIndex=n,n>=0){const o=this.grid.getRowRenderer().getRowOffsets(),a=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(n)),r=e.clientY>s.getBoundingClientRect().top+a/2,d=(o[n]??0)+(r?a:0);i.indicator.style.display="block",i.indicator.style.top=`${d-1}px`}else i.indicator.style.display="none"}onMouseUp(e){const i=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!i)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),i.ghost.remove(),i.indicator.remove();const t=this.grid.getApi(),s=this.grid.getOptions(),n=i.overIndex,o=this.indexOf(i.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:t,node:i.rowNode,overIndex:n,overNode:n!==null?this.grid.getDisplayedRowAtIndex(n):void 0,y:e.clientY}),s.rowDragManaged&&o>=0&&n!==null&&n!==o&&this.moveRow(o,n,e.clientY)}indexOf(e){let i=-1;return this.grid.getRowModel().forEachNode((t,s)=>{t.id===e.id&&(i=s)}),i}moveRow(e,i,t){const s=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=s.length)return;const[n]=s.splice(e,1),o=i>e?i-1:i;this.grid.getDisplayedRowAtIndex(i),s.splice(Math.max(0,Math.min(s.length,o+1)),0,n),this.grid.getApi().setRowData(s),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:n}})}}function ks(l){const e={setRowData:t=>l.setRowData(t),applyTransaction:t=>l.applyTransaction(t),getRowNode:t=>l.getRowNode(t),getDisplayedRowCount:()=>l.getDisplayedRowCount(),getDisplayedRowAtIndex:t=>l.getDisplayedRowAtIndex(t),getFirstDisplayedRow:()=>l.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>l.getDisplayedRowAtIndex(l.getDisplayedRowCount()-1),forEachNode:t=>{const s=l.getRowModel();for(let n=0;n<s.getRowCount();n++){const o=s.getRow(n);o&&t(o,n)}},forEachLeafNode:t=>{l.getRowModel().forEachLeafNode(t)},getModel:()=>l.getRowModel(),getValue:(t,s)=>{const n=typeof t=="string"?l.getColumn(t):t;if(!(!n||!s))return H(n,s,l.getApi())},getSelectedRows:()=>l.getSelectionService().getSelectedRows(),getSelectedNodes:()=>l.getSelectionService().getSelectedNodes(),selectAll:()=>l.getSelectionService().selectAll(),deselectAll:()=>l.getSelectionService().deselectAll(),selectAllFiltered:()=>l.getSelectionService().selectAllFiltered(),deselectAllFiltered:()=>l.getSelectionService().deselectAll(),selectNode:(t,s)=>l.getSelectionService().selectNode(t,s??!1),deselectNode:t=>l.getSelectionService().deselectNode(t),setQuickFilter:t=>l.setQuickFilter(t),isQuickFilterPresent:()=>l.getQuickFilter().length>0,resetQuickFilter:()=>l.setQuickFilter(""),getSortModel:()=>l.getSortService().getSortModel(),setSortModel:t=>l.getSortService().setSortModel(t),getFilterModel:()=>l.getFilterService().getFilterModel(),setFilterModel:t=>l.getFilterService().setFilterModel(t),getColumnFilterModel:t=>{const s=typeof t=="string"?t:t.colId;return l.getFilterService().getFilterInstance(s)??null},setColumnFilterModel:(t,s)=>l.getFilterService().setColumnFilterModel(t,s),getAdvancedFilterModel:()=>l.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:t=>l.getFilterService().setAdvancedFilterModel(t),onFilterChanged:()=>l.getFilterService().onFilterChanged("api"),onSortChanged:()=>l.getSortService().onSortChanged("api"),expandAll:()=>l.getRowModel().expandAll(),collapseAll:()=>l.getRowModel().collapseAll(),onGroupExpandedOrCollapsed:()=>l.refreshModel("expand"),getRowGroupColumns:()=>l.getColumnModel().getRowGroupColumns(),setRowNodePinned:(t,s)=>l.setRowNodePinned(t,s),getColumnDefs:()=>l.getColumnModel().getColumnDefs(),setColumnDefs:(t,s)=>{l.getColumnModel().setColumnDefs(t),l.onGridSizeChanged()},updateGridOptions:t=>l.updateGridOptions(t),setGridOption:(t,s)=>l.updateGridOptions({[t]:s}),sizeColumnsToFit:()=>{const t=l.getSideBarService().isVisible()?l.getSideBarService().getElement().offsetWidth:0;l.getColumnModel().sizeColumnsToFit(l.getGridDiv().clientWidth-t),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{l.getColumnModel().autoSizeAllColumns(),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeColumns:t=>{l.getColumnModel().autoSizeAllColumns()},moveColumn:(t,s)=>l.getColumnModel().moveColumn(t,s),moveColumnByIndex:(t,s)=>l.getColumnModel().moveColumnByIndex(t,s),setColumnVisible:(t,s)=>l.getColumnApi().setColumnVisible(t,s),setColumnsPinned:(t,s)=>l.getColumnApi().setColumnsPinned(t,s),setColumnsVisible:(t,s)=>l.getColumnApi().setColumnsVisible(t,s),getAllColumns:()=>l.getAllColumns(),getColumns:()=>[...l.getColumns().left,...l.getColumns().center,...l.getColumns().right],getColumn:t=>l.getColumn(t)??null,getDisplayedLeftColumns:()=>l.getColumns().left,getDisplayedCenterColumns:()=>l.getColumns().center,getDisplayedRightColumns:()=>l.getColumns().right,getColumnState:()=>l.getColumnApi().getColumnState(),applyColumnState:(t,s)=>l.getColumnApi().applyColumnState(t,s),resetColumnState:()=>l.getColumnApi().resetColumnState(),openColumnMenu:t=>{const s=typeof t=="string"?l.getColumn(t):t;s!=null&&s.eHeaderCell&&l.getHeaderView().getHeaderCell(s)},setSideBarVisible:t=>{l.getSideBarService().setVisible(t),l.onGridSizeChanged()},isSideBarVisible:()=>l.getSideBarService().isVisible(),setSideBarPosition:t=>{l.getSideBarService().setPosition(t),l.onGridSizeChanged()},openToolPanel:t=>{l.getSideBarService().setVisible(!0),l.getSideBarService().openPanel(t),l.onGridSizeChanged()},closeToolPanel:()=>{l.getSideBarService().setVisible(!1),l.onGridSizeChanged()},getToolPanel:()=>l.getSideBarService().getActivePanel(),setStatusBarVisible:t=>l.getSideBarService()&&l.getOptions(),getSideBar:()=>l.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var t;return((t=l.getPaginationService())==null?void 0:t.isLastPageFound())??!0},paginationGetPageSize:()=>{var t;return((t=l.getPaginationService())==null?void 0:t.getPageSize())??0},paginationGetCurrentPage:()=>{var t;return((t=l.getPaginationService())==null?void 0:t.getCurrentPage())??0},paginationGetTotalPages:()=>{var t;return((t=l.getPaginationService())==null?void 0:t.getTotalPages())??1},paginationGetRowCount:()=>l.getDisplayedRowCount(),paginationGoToPage:t=>{var s;return(s=l.getPaginationService())==null?void 0:s.goToPage(t)},paginationGoToNextPage:()=>{var t;return(t=l.getPaginationService())==null?void 0:t.goToNextPage()},paginationGoToPreviousPage:()=>{var t;return(t=l.getPaginationService())==null?void 0:t.goToPreviousPage()},paginationGoToFirstPage:()=>{var t;return(t=l.getPaginationService())==null?void 0:t.goToFirstPage()},paginationGoToLastPage:()=>{var t;return(t=l.getPaginationService())==null?void 0:t.goToLastPage()},paginationSetPageSize:t=>{var s;return(s=l.getPaginationService())==null?void 0:s.setPageSize(t)},startEditingCell:t=>l.getEditService().startEditingCell(t),stopEditing:t=>l.getEditService().stopEditing(t),getEditingCells:()=>l.getEditService().getEditingCells(),setFocusedCell:(t,s)=>{const n=typeof s=="string"?l.getColumn(s):s;n&&l.getEditService().setFocusedCell(t,n)},getFocusedCell:()=>{const t=l.getEditService().getFocusedCell();return t?{rowIndex:t.rowIndex,column:t.column,rowNode:t.rowNode}:null},clearFocusedCell:()=>l.getEditService().clearFocusedCell(),tabToNextCell:()=>l.getEditService().tabToNextCell(),tabToPreviousCell:()=>l.getEditService().tabToPreviousCell(),refreshCells:t=>l.getRowRenderer().refreshCells(t),redrawRows:t=>l.getRowRenderer().redrawRows(t),flashCells:t=>l.getRowRenderer().flashCells(t||{}),ensureIndexVisible:(t,s)=>l.getRowRenderer().ensureIndexVisible(t,s),ensureNodeVisible:t=>{let s=-1;l.getRowModel().forEachNode((n,o)=>{n.id===t.id&&(s=o)}),s>=0&&l.getRowRenderer().ensureIndexVisible(s)},ensureColumnVisible:t=>{const s=typeof t=="string"?l.getColumn(t):t;s&&l.getRowRenderer().ensureColumnVisible(s)},copyToClipboard:t=>l.getExportService().copyToClipboard(t),cutToClipboard:t=>l.getExportService().cutToClipboard(t),pasteFromClipboard:()=>l.getExportService().pasteFromClipboard(),exportToCsv:t=>l.getExportService().exportToCsv(t||{}),exportToExcel:t=>l.getExportService().exportToExcel(t||{}),exportToPdf:t=>l.getExportService().exportToPdf(t||{}),importExcel:(t,s)=>l.getExportService().importExcel(t,s||{}),getDataAsPdf:t=>l.getExportService().getDataAsPdf(t||{}),getDataAsCsv:t=>l.getExportService().getDataAsCsv(t||{}),getDataAsExcel:t=>l.getExportService().getDataAsExcel(t||{}),getChartData:t=>l.getChartService().getChartData(t||{}),getChartModels:()=>l.getChartService().getChartModels(),createChart:()=>l.getChartService().createChart(),getCellRanges:()=>l.getRangeSelectionService().getRanges(),clearRangeSelection:()=>l.getRangeSelectionService().clearRanges(),addCellRange:t=>{const s=l.getRangeSelectionService();s.ranges=[t],s.applyHighlight(),s.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>l.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>l.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>l.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>l.getOverlayService().hideOverlay(),setServerSideDatasource:t=>{const s=l.getServerSideRowModel();s&&s.setDatasource(t)},setDatasource:t=>{var n;const s=l.getInfiniteRowModel();s?s.setDatasource(t):(n=l.getServerSideRowModel())==null||n.setDatasource(t)},setViewportDatasource:t=>{var s;(s=l.getViewportRowModel())==null||s.setViewportDatasource(t)},setViewportRange:(t,s)=>{var n;(n=l.getViewportRowModel())==null||n.setViewportRange(t,s)},refreshServerSide:t=>{const s=l.getServerSideRowModel();s&&(t!=null&&t.purge?s.purgeCache():s.onSortOrFilterChanged())},purgeServerSideCache:()=>{var t,s;(t=l.getServerSideRowModel())==null||t.purgeCache(),(s=l.getInfiniteRowModel())==null||s.onSortOrFilterChanged()},getServerSideStoreState:()=>{const t=l.getServerSideRowModel();if(!t)return[];const s=[];for(const[n,o]of t.stores)s.push({groupPath:n,rowCount:o.rows.length,lastRow:o.lastRow,loading:o.loading});return s},setRowCount:(t,s)=>{const n=l.getServerSideRowModel();if(!n)return;const o=n.getStore("");if(o)for(o.lastRow=s?t:null;o.rows.length<t;)o.rows.push(null);n.refreshModel("everything")},isServerSideStoreLoading:()=>l.isRemoteLoading(),undoCellEditing:()=>l.getUndoRedoService().undo(),redoCellEditing:()=>l.getUndoRedoService().redo(),canUndo:()=>l.getUndoRedoService().canUndo(),canRedo:()=>l.getUndoRedoService().canRedo(),getUndoRedoStackSize:()=>({undo:l.getUndoRedoService().getUndoStackSize(),redo:l.getUndoRedoService().getRedoStackSize()}),startBatchEdit:()=>l.getUndoRedoService().startBatchEdit(),endBatchEdit:t=>l.getUndoRedoService().endBatchEdit(t),cancelBatchEdit:()=>l.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>l.getUndoRedoService().isBatchEditing(),getState:()=>{const t=l.getColumnApi(),s=l.getSelectionService(),n=l.getPaginationService();return{columns:t.getColumnState(),sort:l.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(l.getFilterService().getFilterModel())),quickFilter:l.getQuickFilter(),selectedRowIds:s.getSelectedNodes().map(o=>o.id),pagination:n!=null&&n.isEnabled()?{page:n.getCurrentPage(),pageSize:n.getPageSize()}:null,rowGroupColumns:l.getColumnModel().getRowGroupColumns().map(o=>o.colId),pivotMode:l.getColumnModel().isPivotMode()}},setState:t=>{if(!t)return;const s=l.getColumnApi();if(t.columns&&s.applyColumnState(t.columns,!0),t.sort&&l.getSortService().setSortModel(t.sort),t.filter&&l.getFilterService().setFilterModel(t.filter),t.quickFilter!==void 0&&l.setQuickFilter(t.quickFilter),t.rowGroupColumns&&l.getColumnModel().setRowGroupColumns(t.rowGroupColumns),t.pivotMode!==void 0&&l.getColumnModel().setPivotMode(t.pivotMode),t.selectedRowIds){l.getSelectionService().deselectAll();for(const o of t.selectedRowIds){const a=l.getRowNode(o);a&&l.getSelectionService().selectNode(a,!1)}}const n=l.getPaginationService();n&&t.pagination&&(n.setPageSize(t.pagination.pageSize),n.goToPage(t.pagination.page))},setNote:(t,s,n)=>{const o=typeof s=="string"?s:s.colId;l.getNotesService().setNote(t.id,o,n)},getNote:(t,s)=>{const n=typeof s=="string"?s:s.colId,o=l.getColumn(n);return l.getNotesService().getNote(t.id,n,o==null?void 0:o.colDef.note,{data:t.data,node:t,column:o,api:l.getApi()})},getGridId:()=>"rowvia",destroy:()=>l.destroy(),refreshClientSideRowModel:()=>l.refreshModel("everything"),setPivotMode:t=>l.getColumnModel().setPivotMode(t),isPivotMode:()=>l.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>l.getAllColumns(),getColumn:t=>l.getColumn(t)??null,getColumnState:()=>l.getColumnModel().getColumnState(),applyColumnState:(t,s)=>{l.getColumnModel().applyColumnState(t,s),l.refreshModel("group")},resetColumnState:()=>{l.getColumnModel().resetColumnState(),l.refreshModel("group")},setColumnVisible:(t,s)=>l.getColumnModel().setColumnVisible(t,s),setColumnsVisible:(t,s)=>l.getColumnModel().setColumnsVisible(t,s),setColumnPinned:(t,s)=>l.getColumnModel().setColumnPinned(t,s),setColumnsPinned:(t,s)=>l.getColumnModel().setColumnsPinned(t,s),moveColumn:(t,s)=>l.getColumnModel().moveColumn(t,s),moveColumnByIndex:(t,s)=>l.getColumnModel().moveColumnByIndex(t,s),autoSizeColumn:t=>{l.getColumnModel().autoSizeColumn(t),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeColumns:t=>{l.getColumnModel().autoSizeAllColumns(),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(t,s)=>l.getColumnModel().setRowGroupColumns(t,s),removeRowGroupColumns:t=>{for(const s of t)l.getColumnModel().removeRowGroupColumn(s)},addRowGroupColumn:t=>l.getColumnModel().addRowGroupColumn(t),setPivotColumns:t=>l.getColumnModel().setPivotColumns(t),removePivotColumns:t=>l.getColumnModel().setPivotColumns(t.map(()=>"").filter(s=>s!=="")),setValueColumns:t=>l.getColumnModel().setValueColumns(t),removeValueColumn:t=>l.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>l.getColumnModel().getRowGroupColumns(),getValueColumns:()=>l.getColumnModel().getValueColumns(),getPivotColumns:()=>l.getColumnModel().getPivotColumns(),setPivotMode:(t,s)=>l.getColumnModel().setPivotMode(t,s),isPivotMode:()=>l.getColumnModel().isPivotMode()}}}const Ls={rowHeight:42,headerHeight:48,floatingFiltersHeight:24,groupHeaderHeight:48,pivotHeaderHeight:48,rowBuffer:10,detailRowHeight:200,animateRows:!0,enableCellChangeFlash:!0,rowSelection:void 0,sortingOrder:["asc","desc",null],enterNavigatesVerticallyAfterEdit:!0,treeDataChildrenField:"children",suppressClickEdit:!1};class Re{constructor(e,i){p(this,"options");p(this,"eventService",new se);p(this,"columnModel");p(this,"rowModel");p(this,"clientSideRowModel",null);p(this,"serverSideRowModel",null);p(this,"infiniteRowModel",null);p(this,"viewportRowModel",null);p(this,"rowRenderer");p(this,"headerView");p(this,"selectionService");p(this,"editService");p(this,"filterService");p(this,"sortService");p(this,"paginationService",null);p(this,"popupService");p(this,"filterGui");p(this,"contextMenuService");p(this,"columnMenuService");p(this,"statusBarService");p(this,"sideBarService");p(this,"findService");p(this,"rangeSelectionService");p(this,"chartService");p(this,"overlayService");p(this,"exportService");p(this,"rowGroupPanel",null);p(this,"undoRedoService");p(this,"formulaEditorService");p(this,"notesService");p(this,"rowDragService");p(this,"api");p(this,"columnApi");p(this,"localeText");p(this,"rowNodeServices");p(this,"eGridDiv");p(this,"eRoot");p(this,"eMain");p(this,"eHeader");p(this,"quickFilter","");p(this,"resizeObserver",null);p(this,"destroyed",!1);p(this,"gridReadyDispatched",!1);p(this,"context");p(this,"onWindowResize",()=>{this.onGridSizeChanged()});p(this,"onDocumentMouseDown",e=>{var t;const i=e.target;if(i&&this.eRoot.contains(i)){const s=(t=i.closest)==null?void 0:t.call(i,".ag-cell");if(!s){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!s.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var d,c,h,g;this.eGridDiv=e,this.options={...Ls,...i},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=wi(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const t=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(t),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),this.eMain=document.createElement("div"),this.eMain.className="ag-main",this.eRoot.appendChild(this.eMain),this.eHeader=document.createElement("div"),this.eHeader.className="ag-header-wrapper",this.eMain.appendChild(this.eHeader),this.rowNodeServices={selectNode:(u,f)=>this.selectionService.selectNode(u,f),deselectNode:u=>this.selectionService.deselectNode(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u)},this.columnModel=new xt(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new ji(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),u=>this.isNodeSelectable(u)),this.filterService=new Qi(this),this.sortService=new Zi(this),this.popupService=new Ji(this),this.filterGui=new es(this,this.popupService),this.contextMenuService=new ts(this,this.popupService),this.columnMenuService=new is(this,this.popupService),this.editService=new Yi(this,this.eventService),this.undoRedoService=new Ms(this,this.eventService),this.formulaEditorService=new Ns(this,this.popupService),this.notesService=new Ts(this,this.popupService),this.rowDragService=new Is(this,this.eventService),this.chartService=new rs(this,this.popupService),this.findService=new os(this,this.popupService),this.exportService=new Es(this);const s={options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getSortModel:()=>this.sortService.getSortModel(),getFilterModel:()=>this.filterService.getFilterModel(),rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices},n=this.options.rowModelType||"clientSide";n==="serverSide"?(this.serverSideRowModel=new Si(s),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):n==="infinite"?(this.infiniteRowModel=new xi(s),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):n==="viewport"?(this.viewportRowModel=new bi(s),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new gi({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var u;return!!((u=this.paginationService)!=null&&u.isEnabled())},getPageSize:()=>{var u;return((u=this.paginationService)==null?void 0:u.getPageSize())??100},getCurrentPage:()=>{var u;return((u=this.paginationService)==null?void 0:u.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(c=(d=this.rowModel).setGridApi)==null||c.call(d,null)),this.headerView=new Xi(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(u=>u.sort)}),onSortRequested:(u,f,m)=>this.sortService.onSortRequested(u,f,m),onColumnResized:(u,f,m)=>this.onColumnResized(u,f,m),onColumnMoved:(u,f)=>this.onColumnMoved(u,f),onColumnMenuClicked:(u,f)=>this.columnMenuService.openColumnMenu(u,f),onFilterOpened:(u,f)=>this.filterGui.openFilter(u,f),isFilterActive:u=>this.filterService.isFilterActive(u),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(u,f)=>this.filterService.handleFloatingFilterChange(u,f),onHeaderCheckboxChanged:(u,f)=>this.onHeaderCheckboxChanged(u,f),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:u=>this.t(u),getApi:()=>this.api,getFilterModel:u=>this.filterService.getFilterInstance(u)??null,onFilterModelChange:(u,f)=>this.filterService.setColumnFilterModel(u,f)}),this.rowRenderer=new Ki(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,getColumns:()=>this.getColumns(),getRowHeight:u=>this.getRowHeight(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u),isRowSelectable:u=>this.isNodeSelectable(u),getRowClass:u=>this.getRowClass(u),getRowStyle:u=>this.getRowStyle(u),onCellClicked:u=>this.onCellClicked(u),onCellDoubleClicked:u=>this.editService.onCellDoubleClicked(u),onCellMouseDown:u=>this.onCellMouseDown(u),onCellContextMenu:u=>this.onCellContextMenu(u),onRowClicked:u=>this.onRowClicked(u),onRowDoubleClicked:u=>this.onRowDoubleClicked(u),onRowGroupClicked:u=>this.onRowGroupClicked(u),onViewportKeyDown:u=>this.onViewportKeyDown(u),onViewportScroll:()=>{var m,v,C;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft());const u=this.rowRenderer.getFirstVisibleRowIndex(),f=this.rowRenderer.getLastVisibleRowIndex();(m=this.serverSideRowModel)==null||m.onViewportChanged(u,f),(v=this.infiniteRowModel)==null||v.onViewportChanged(u,f),(C=this.viewportRowModel)==null||C.onViewportChanged(u,f)},getCellText:(u,f)=>{const m=H(u,f,this.api);return m==null?"":String(m)},renderDetailRow:u=>this.renderDetailRow(u),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(u,f,m)=>this.rowDragService.startDrag(u,m),getNote:(u,f,m,v)=>this.notesService.getNote(u,f,m,v),onNoteClick:(u,f,m)=>this.notesService.openNoteEditor(u,f,m),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new ls(this,this.eventService),this.statusBarService=new ss(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new as(this),this.sideBarService=new ns(this),this.sideBarService.getElement().classList.contains("ag-side-bar-left")?this.eRoot.insertBefore(this.sideBarService.getElement(),this.eMain):this.eRoot.appendChild(this.sideBarService.getElement()),this.options.pagination&&(this.paginationService=new kt(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Rs(this));const{api:o,columnApi:a}=ks(this);this.api=o,this.columnApi=a,this.columnModel.setGridApi(this.api),(g=(h=this.rowModel).setGridApi)==null||g.call(h,this.api),this.selectionService.gridApiRef=this.api,this.eventService.addEventListener("columnEverythingChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("displayedColumnsChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("columnRowGroupChanged",()=>{this.serverSideRowModel||this.infiniteRowModel?this.onRemoteModelChanged():this.rowModel.refreshModel("group")}),this.options.__advancedFilterPass=u=>this.filterService.doesNodePassAdvancedFilter(u),this.eventService.addEventListener("columnPivotModeChanged",()=>this.refreshPivotColumns()),this.eventService.addEventListener("modelUpdated",()=>{this.columnModel.isPivotMode()&&this.refreshPivotColumns()}),this.eventService.addEventListener("sortChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("filterChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("columnValueChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("columnPivotModeChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("modelUpdated",()=>this.onModelUpdated()),this.eventService.addEventListener("selectionChanged",()=>{var u,f;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(f=(u=this.options).onSelectionChanged)==null||f.call(u,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let r=this.options.columnDefs||[];(!r||r.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(r=xt.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label","Data grid"),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,i){const t=this.localeText.t(e);return t===e?i:t}getContext(){return this.context}getEventService(){return this.eventService}getColumnModel(){return this.columnModel}getRowModel(){return this.rowModel}getRowRenderer(){return this.rowRenderer}getHeaderView(){return this.headerView}getSelectionService(){return this.selectionService}getEditService(){return this.editService}getFilterService(){return this.filterService}getSortService(){return this.sortService}getFilterGui(){return this.filterGui}getPaginationService(){return this.paginationService}getSideBarService(){return this.sideBarService}getChartService(){return this.chartService}getFindService(){return this.findService}getRangeSelectionService(){return this.rangeSelectionService}getExportService(){return this.exportService}getPopupService(){return this.popupService}getOverlayService(){return this.overlayService}getRowGroupPanel(){return this.rowGroupPanel}getUndoRedoService(){return this.undoRedoService}getFormulaEditorService(){return this.formulaEditorService}getNotesService(){return this.notesService}getRowDragService(){return this.rowDragService}getServerSideRowModel(){return this.serverSideRowModel}getInfiniteRowModel(){return this.infiniteRowModel}getViewportRowModel(){return this.viewportRowModel}updateColumnTotalCache(){var t,s;const e=new Map,i=this.getAllColumns().filter(n=>n.colDef.showValueAs);if(i.length>0){const n=new Map;(s=(t=this.rowModel).forEachLeafNode)==null||s.call(t,o=>{for(const a of i){const r=H(a,o,this.api);typeof r=="number"&&!isNaN(r)&&n.set(a.colId,(n.get(a.colId)??0)+r)}});for(const o of i)e.set(o.colId,n.get(o.colId)??0)}this.api.__columnTotalCache=e}refreshPivotColumns(){this.columnModel.updatePivotColumns(this.options.rowData||[])}onRemoteModelChanged(){this.serverSideRowModel?this.serverSideRowModel.onSortOrFilterChanged():this.infiniteRowModel?this.infiniteRowModel.onSortOrFilterChanged():this.viewportRowModel&&this.viewportRowModel.setViewportDatasource(this.viewportRowModel.datasource)}isRemoteLoading(){var e,i,t;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(i=this.infiniteRowModel)!=null&&i.isLoading()||(t=this.viewportRowModel)!=null&&t.isLoading())}getApi(){return this.api}getColumnApi(){return this.columnApi}getRootElement(){return this.eRoot}getMainElement(){return this.eMain}getHeaderElement(){return this.eHeader}getGridDiv(){return this.eGridDiv}getColumns(){return this.columnModel.getDisplayedColumnsByType()}getAllColumns(){return this.columnModel.getAllColumns()}getColumn(e){return this.columnModel.getColumn(e)}getDisplayedRowCount(){return this.rowModel.getRowCount()}getDisplayedRowAtIndex(e){return this.rowModel.getRow(e)}getRowNode(e){return this.rowModel.getRowNode(e)}getRowHeight(e){if(e.rowHeight!==null)return e.rowHeight;const i=this.options.getRowHeight;if(typeof i=="function"){const t=i({data:e.data,node:e,api:this.api});if(t)return t}return this.options.rowHeight??42}getRowClass(e){const i=[];if(this.options.rowClass&&i.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const t=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof t=="string"?i.push(t):Array.isArray(t)&&i.push(...t)}return e.footer&&i.push("ag-row-footer"),i.join(" ")}getRowStyle(e){const i={};return this.options.rowStyle&&Object.assign(i,this.options.rowStyle),typeof this.options.getRowStyle=="function"&&Object.assign(i,this.options.getRowStyle({data:e.data,node:e,api:this.api})),i}isNodeSelectable(e){if(e.footer||e.masterNode)return!1;const i=this.options.isRowSelectable;return!(i&&!i(e))}isCellEditable(e,i){return this.options.readOnlyEdit||i.group||i.footer||i.masterNode?!1:typeof e.editable=="function"?e.editable({data:i.data,node:i,column:e,colDef:e.colDef,api:this.api}):e.editable===!0}setRowData(e,i=!1){var t,s,n;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),i||(this.overlayService.updateAuto(),this.statusBarService.update(),(t=this.paginationService)==null||t.update(),this.chartService.refreshCharts(),(n=(s=this.options).onRowDataChanged)==null||n.call(s,{api:this.api}))}applyTransaction(e){var t;const i=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(t=this.paginationService)==null||t.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),i}setCellValue(e,i,t,s="api",n){const o=n!==void 0?n:H(e,i,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:H(e,i,this.api),newValue:t,data:i.data,node:i,column:e,api:this.api,colDef:e.colDef})===!1)return}else i.setDataValue(e.colId,t);e.rowGroup&&this.rowModel.refreshModel("group"),(s==="edit"||s==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:i.id,colId:e.colId,oldValue:o,newValue:t,batchId:0}),s!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:t,value:t,data:i.data,node:i,column:e,colDef:e.colDef,api:this.api,source:s})}refreshModel(e){var i;this.rowModel.refreshModel(e),(i=this.paginationService)==null||i.update()}refreshCells(e){this.rowRenderer.refreshCells(e)}setQuickFilter(e){this.quickFilter=e||"",this.refreshModel("filter"),this.findService.applyHighlight()}getQuickFilter(){return this.quickFilter}setRowNodePinned(e,i){e.rowPinned=i,this.rowModel.refreshModel("everything")}openFind(){this.findService.open()}closeFind(){this.findService.close()}onCellClicked(e){var o,a,r,d;const{node:i,column:t,event:s}=e;if(this.options.enableRangeSelection,t.checkboxSelection){this.selectionService.toggleNode(i),this.rowRenderer.refreshCells({rowNodes:[i]}),(a=(o=this.options).onCellClicked)==null||a.call(o,{...e,api:this.api,colDef:t.colDef,value:H(t,i,this.api)});return}if(s.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(i);return}this.selectionService.handleRowClick(i,s),this.editService.onCellClicked(e),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:t.colDef,value:H(t,i,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var i,t;this.selectionService.handleRowClick(e.node,e.event),(t=(i=this.options).onRowClicked)==null||t.call(i,{...e,api:this.api})}onRowDoubleClicked(e){var i,t;(t=(i=this.options).onRowDoubleClicked)==null||t.call(i,{...e,api:this.api})}onCellContextMenu(e){var t,s;const i=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(i,{column:e.column,node:e.node}),(s=(t=this.options).onCellContextMenu)==null||s.call(t,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var i,t,s,n,o;if(e.group){const a=(i=this.rowModel.setNodeExpanded)==null?void 0:i.bind(this.rowModel);a&&a(e,!e.expanded),globalThis.__dbgLogs.push(["after-toggle",e.id,"expanded=",e.expanded]),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(s=(t=this.options).onRowGroupOpened)==null||s.call(t,{node:e,expanded:e.expanded,api:this.api})}else e.detailNode?(e.expanded=!e.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(o=(n=this.options).onRowGroupOpened)==null||o.call(n,{node:e,expanded:e.expanded,api:this.api})):e.masterNode&&(e.masterNode.expanded=!e.masterNode.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e.masterNode,expanded:e.masterNode.expanded,api:this.api}))}onHeaderCheckboxChanged(e,i){var t;if(e.headerCheckboxSelectionCurrentPageOnly&&((t=this.paginationService)!=null&&t.isEnabled())){const s=this.rowModel.getRowCount();if(i)for(let n=0;n<s;n++){const o=this.rowModel.getRow(n);o&&this.isNodeSelectable(o)&&this.selectionService.selectNode(o,!1)}else for(let n=0;n<s;n++){const o=this.rowModel.getRow(n);o&&this.selectionService.deselectNode(o)}}else this.selectionService.setSelectAllCheckboxState(i);this.updateHeaderCheckboxes()}updateHeaderCheckboxes(){for(const e of this.getAllColumns()){if(!e.headerCheckboxSelection)continue;const i=e.eHeaderCell;if(!i)continue;const t=i.querySelector(".ag-header-select-all");if(!t)continue;const s=this.selectionService.getSelectAllState();t.checked=s.checked,t.indeterminate=s.indeterminate}}onViewportKeyDown(e){if(this.editService.onGridKeyDown(e),this.rangeSelectionService.onGridKeyDown(e),(e.ctrlKey||e.metaKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?this.undoRedoService.redo():this.undoRedoService.undo();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),this.undoRedoService.redo();return}(e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")&&this.rangeSelectionService.getRanges().length===0&&this.selectionService.getSelectedNodes().length>0&&(e.preventDefault(),this.api.copyToClipboard()),(e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")&&this.rangeSelectionService.getRanges().length===0&&(e.preventDefault(),this.api.pasteFromClipboard())}onColumnResized(e,i,t){e.width=i,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),t&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,i){const t=this.columnModel.getColumns(),s=t.findIndex(o=>o.colId===e);if(s<0)return;let n=t.length;i&&(n=t.findIndex(o=>o.colId===i)),this.columnModel.moveColumnByIndex(s,n,"uiColumnMoved")}onColumnsChanged(){var e,i;this.headerView.refresh(),this.rowRenderer.redrawAllRows(),this.updateHeaderCheckboxes(),(i=(e=this.options).onDisplayedColumnsChanged)==null||i.call(e,{api:this.api})}onModelUpdated(){var e,i,t,s,n,o,a;this.updateColumnTotalCache(),this.rowRenderer.refreshRows(),this.options.__loadingRows=this.isRemoteLoading(),this.overlayService.updateAuto(),this.statusBarService.update(),(e=this.paginationService)==null||e.update(),this.rangeSelectionService.applyHighlight(),this.findService.applyHighlight(),this.chartService.refreshCharts(),this.gridReadyDispatched||(this.gridReadyDispatched=!0,this.eventService.dispatchEvent("firstDataRendered",{api:this.api}),(t=(i=this.options).onFirstDataRendered)==null||t.call(i,{api:this.api})),(n=(s=this.options).onModelUpdated)==null||n.call(s,{api:this.api}),(a=(o=this.options).onRowDataChanged)==null||a.call(o,{api:this.api})}onGridSizeChanged(){var n,o,a;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,i=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),t=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,s=Math.max(0,e-t);(i||((n=this.options.autoSizeStrategy)==null?void 0:n.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(s),this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows()),this.eventService.dispatchEvent("gridSizeChanged",{clientWidth:this.eGridDiv.clientWidth,clientHeight:this.eGridDiv.clientHeight,api:this.api}),(a=(o=this.options).onGridSizeChanged)==null||a.call(o,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const i=e.masterNode;if(!i)return null;const t=this.options.detailRowAutoHeight===!0,s=t?this.options.detailRowHeight??200:this.options.detailRowHeight??200,n=document.createElement("div");n.className="ag-row-detail",n.style.height=`${s}px`,n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.right="0";const o=this.options.detailCellRenderer,a=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(a&&r){const h=r({data:i.data,node:i,api:this.api}),g=document.createElement("div");g.style.height="100%",g.style.padding="8px 16px",n.appendChild(g),setTimeout(()=>{new Re(g,{...a,rowData:h,theme:this.options.theme})},0)}else if(typeof o=="function"){const h=o({data:i.data,node:i,api:this.api,context:this.context});h instanceof HTMLElement?n.appendChild(h):n.textContent=String(h??"")}else typeof o=="string"&&(n.textContent=o);if(t){const h=Math.max(40,n.scrollHeight||s);return e.rowHeight=h,n.style.height=`${h}px`,{eDetail:n,height:h}}return e.rowHeight=s,{eDetail:n,height:s}}dispatchGridReady(){var e,i;this.eventService.dispatchEvent("gridReady",{api:this.api,columnApi:this.columnApi}),(i=(e=this.options).onGridReady)==null||i.call(e,{api:this.api,columnApi:this.columnApi,context:this.context})}updateGridOptions(e){const i=this.options.theme,t=e.rowData!==void 0&&e.rowData!==this.options.rowData,s=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),t&&this.setRowData(e.rowData),s&&this.columnModel.setColumnDefs(this.options.columnDefs||[]),e.sideBar!==void 0&&(this.sideBarService.setVisible(!!e.sideBar),this.onGridSizeChanged()),e.quickFilterText!==void 0&&this.setQuickFilter(e.quickFilterText),e.theme!==void 0&&e.theme!==i&&(this.eGridDiv.classList.remove(i||"ag-theme-alpine"),this.eGridDiv.classList.add(e.theme)),e.pagination!==void 0&&(e.pagination&&!this.paginationService?this.paginationService=new kt(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,window.removeEventListener("resize",this.onWindowResize),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0),(e=this.resizeObserver)==null||e.disconnect(),this.rowRenderer.destroy(),this.editService.destroy(),this.popupService.closeAll(),this.eRoot.remove(),this.eGridDiv.classList.remove("ag-grid-root","ag-theme-alpine","ag-theme-quartz","ag-theme-balham"),this.eventService.dispatchEvent("gridReady",{}))}}function Gt(l){const e=document.createElement("dialog");e.className="rowvia-detail-dialog";const i=document.createElement("h2"),t=document.createElement("dl"),s=document.createElement("button");s.type="button",s.textContent="关闭";const n=()=>e.close();return s.addEventListener("click",n),e.append(i,t,s),l.append(e),{open(o){i.textContent=o.title,e.setAttribute("aria-label",o.title),t.replaceChildren();for(const a of o.fields){const r=document.createElement("dt"),d=document.createElement("dd");r.textContent=a.label,d.textContent=a.value,t.append(r,d)}e.open||e.showModal()},close:n,destroy(){e.open&&e.close(),s.removeEventListener("click",n),e.remove()}}}const $t=864e5;function ce(l){const e=l.getFullYear(),i=String(l.getMonth()+1).padStart(2,"0"),t=String(l.getDate()).padStart(2,"0");return`${e}-${i}-${t}`}function ie(l){return new Date(`${l}T00:00:00`)}function Q(l,e){return new Date(l.getTime()+e*$t)}function de(l,e){const i=typeof l=="string"?ie(l):l,t=typeof e=="string"?ie(e):e;return Math.round((t.getTime()-i.getTime())/$t)}function Ge(){return ce(new Date)}function Ds(l){return l.status!=="done"&&l.end&&l.end<Ge()&&l.progress<100?"delayed":l.status}function nt(l){const e=ie(l);return`${e.getMonth()+1}月${e.getDate()}日`}const Ht=["day","week","biweek","month","bimonth","quarter","halfyear","year"],qe={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Fs={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2},Y={accent:"#4555e5",text:"#1f2329",textTertiary:"#8f959e",border:"#dee0e3",groupRow:"transparent",weekend:"rgba(31, 35, 41, 0.04)",gridline:"rgba(31, 35, 41, 0.10)",gridlineMonth:"rgba(31, 35, 41, 0.12)",rowLine:"transparent",hover:"rgba(51, 112, 255, 0.05)",selected:"rgba(51, 112, 255, 0.09)"},Ke={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},As=4,Ot=6,oe=28;function ot(l){const e=(l.getDay()+6)%7;return Q(l,-e)}function Ps(l,e){const i=Math.max(1,de(l,e)+1);let t=0;for(let s=0;s<i;s++){const n=Q(l,s).getDay();n!==0&&n!==6&&t++}return Math.max(1,t)}function Gs(l,e){return new Date(l.getFullYear(),l.getMonth()+e,1)}function Bt(l,e,i){const t=[];if(l==="day"){let r=new Date(e);for(;r<i;){const d=Q(r,1);t.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return t}if(l==="week"||l==="biweek"){let r=ot(e);for(;r<i;){const d=Q(r,l==="biweek"?14:7);t.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return t}const s=l==="month"?1:l==="bimonth"?2:l==="quarter"?3:l==="halfyear"?6:12,n=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/s)*s,1),o=r=>l==="month"||l==="bimonth"?`${r.getMonth()+1}月`:l==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:l==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let a=n(e);for(;a<i;){const r=Gs(a,s);t.push({start:new Date(a),end:r,primary:o(a),secondary:""}),a=r}return t}class Vt{constructor(e,i){p(this,"options");p(this,"eRoot");p(this,"eHeader");p(this,"eRuler");p(this,"rulerCtx");p(this,"eRulerTools");p(this,"eStepLabel");p(this,"eZoomValue");p(this,"eStepMenu",null);p(this,"eScroll");p(this,"eSpacer");p(this,"eCanvas");p(this,"ctx");p(this,"eTooltip");p(this,"eTodayBadge");p(this,"ePopup",null);p(this,"tasks",[]);p(this,"tasksById",new Map);p(this,"rows",[]);p(this,"selectedId",null);p(this,"hoverId",null);p(this,"unit","day");p(this,"zoom",1);p(this,"theme","content");p(this,"epochStart",new Date);p(this,"totalDays",1);p(this,"hits",[]);p(this,"hitsByRow",new Map);p(this,"drag",null);p(this,"ghost",null);p(this,"dirty",!0);p(this,"lastLeft",-1);p(this,"lastTop",-1);p(this,"timer");p(this,"observer",null);p(this,"resizeHandler",()=>this.resizeCanvases());p(this,"showChildren",!0);p(this,"milestonesOnly",!1);p(this,"locateHits",[]);p(this,"tick",()=>{const e=this.eScroll.scrollLeft,i=this.eScroll.scrollTop;(e!==this.lastLeft||i!==this.lastTop||this.dirty)&&(this.lastLeft=e,this.lastTop=i,this.eCanvas.style.transform=`translate(${e}px, ${i}px)`,this.draw(),this.dirty=!1)});p(this,"onScroll",()=>{this.tick()});p(this,"todayLabelX",-1);p(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:i,rowIndex:t,onAvatar:s}=this.hitAt(e.clientX,e.clientY),n=this.rows[t];s?this.eCanvas.style.cursor="pointer":i&&i.mode!=="move"?this.eCanvas.style.cursor="ew-resize":i?this.eCanvas.style.cursor="grab":this.eCanvas.style.cursor="default";const o=i?i.id:(n==null?void 0:n.id)??null;o!==this.hoverId&&(this.hoverId=o,this.options.onHover(o),this.markDirty())});p(this,"onCanvasMouseDown",e=>{const i=this.eCanvas.getBoundingClientRect(),t=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-i.left))<12&&Math.abs(d.y-(e.clientY-i.top))<12);if(t){this.scrollToTask(t.id);return}const{hit:s,rowIndex:n,onAvatar:o}=this.hitAt(e.clientX,e.clientY),a=this.rows[n];if(s){const d=this.tasksById.get(s.id);if(!d)return;if(o){e.stopPropagation(),this.openAssigneePopup(s.id,s);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(s.id);return}e.preventDefault(),this.drag={id:s.id,mode:s.mode,startX:e.clientX,startY:e.clientY,originStart:d.start,originEnd:d.end,start:d.start,end:d.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(s.id);return}if(!a)return;const r=this.tasksById.get(a.id);if(r){if(r.kind==="task"&&(!r.start||!r.end)){const d=this.pointAt(e.clientX,e.clientY),c=Math.floor(d.x/this.dayWidth),h=ce(Q(this.epochStart,c));this.options.onTaskChange({...r,start:h,end:ce(Q(ie(h),4)),progress:0,status:"not-started"}),this.options.onSelect(a.id);return}this.options.onSelect(a.id)}});p(this,"updateDrag",e=>{const i=this.drag;if(!i)return;const t=this.tasksById.get(i.id);if(!t||!i.moved&&Math.abs(e.clientX-i.startX)<As)return;i.moved=!0;const s=this.dayWidth,n=Math.round((e.clientX-i.startX)/s),o=ie(i.originStart),a=ie(i.originEnd),r=de(o,a);let d,c;i.mode==="resize-l"?(d=Q(o,Math.min(n,r)),c=a):i.mode==="resize-r"?(d=o,c=Q(a,Math.max(n,-r))):(d=Q(o,n),c=Q(a,n)),t.milestone&&(d=c),i.start=ce(d),i.end=ce(c),this.ghost={id:i.id,start:i.start,end:i.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=t.milestone?nt(i.start):`${nt(i.start)} → ${nt(i.end)}`;const h=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-h.left+12}px`,this.eTooltip.style.top=`${e.clientY-h.top+16}px`});p(this,"endDrag",()=>{window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.eTooltip.style.display="none";const e=this.drag;if(this.drag=null,this.ghost=null,this.markDirty(),!(e!=null&&e.moved)||e.start===e.originStart&&e.end===e.originEnd)return;const i=this.tasksById.get(e.id);i&&this.options.onTaskChange({...i,start:e.start,end:e.end})});p(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});p(this,"onDocumentMouseDown",e=>{const i=e.target;this.ePopup&&!this.ePopup.contains(i)&&this.closeAssigneePopup(),this.eStepMenu&&!this.eStepMenu.contains(i)&&!this.eRulerTools.contains(i)&&this.closeStepMenu()});this.options=i,this.eRoot=document.createElement("div"),this.eRoot.className="gt-root",e.appendChild(this.eRoot),this.eHeader=document.createElement("div"),this.eHeader.className="gt-header",this.eRuler=document.createElement("canvas"),this.eRuler.className="gt-ruler",this.eHeader.appendChild(this.eRuler),this.eRoot.appendChild(this.eHeader),this.rulerCtx=this.eRuler.getContext("2d"),this.buildRulerTools(),this.eScroll=document.createElement("div"),this.eScroll.className="gt-scroll",this.eSpacer=document.createElement("div"),this.eSpacer.className="gt-spacer",this.eCanvas=document.createElement("canvas"),this.eCanvas.className="gt-canvas",this.eScroll.append(this.eSpacer,this.eCanvas),this.eRoot.appendChild(this.eScroll),this.ctx=this.eCanvas.getContext("2d"),this.eTooltip=document.createElement("div"),this.eTooltip.className="gt-tooltip",this.eTooltip.style.display="none",this.eRoot.appendChild(this.eTooltip),this.eTodayBadge=document.createElement("div"),this.eTodayBadge.className="gt-today-badge",this.eRoot.appendChild(this.eTodayBadge),this.eScroll.addEventListener("scroll",this.onScroll),this.eCanvas.addEventListener("mousedown",this.onCanvasMouseDown),this.eCanvas.addEventListener("mousemove",this.onCanvasMouseMove),this.eRoot.addEventListener("mouseleave",this.onRootMouseLeave);const t=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(t),this.observer.observe(this.eScroll),this.observer.observe(this.eHeader)),window.addEventListener("resize",this.resizeHandler),this.timer=setInterval(this.tick,40),this.resizeCanvases()}destroy(){var e;clearInterval(this.timer),(e=this.observer)==null||e.disconnect(),window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.closeAssigneePopup(),this.closeStepMenu(),this.eRoot.remove()}setHover(e){this.hoverId=e,this.markDirty()}setShowChildren(e){this.showChildren=e,this.markDirty()}setMilestonesOnly(e){this.milestonesOnly=e,this.markDirty()}scrollToTask(e){const i=this.tasksById.get(e);i!=null&&i.start&&(this.eScroll.scrollLeft=Math.max(0,this.dateX(i.start)-this.eScroll.clientWidth*.12),this.markDirty())}setTasks(e){this.tasks=e,this.tasksById=new Map(e.map(i=>[i.id,i])),this.computeDomain(),this.markDirty()}setRows(e){this.rows=e,this.markDirty()}setSelected(e){this.selectedId=e,this.markDirty()}setUnit(e){const i=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.unit=e,this.markDirty(),this.eScroll.scrollLeft=Math.max(0,i*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setZoom(e){const i=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.zoom=Math.max(.5,Math.min(3,e)),this.markDirty(),this.eScroll.scrollLeft=Math.max(0,i*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setTheme(e){this.theme=e,this.markDirty()}get dayWidth(){return Fs[this.unit]*this.zoom}get scrollElement(){return this.eScroll}setScrollTop(e){this.eScroll.scrollTop=e}redraw(){this.markDirty()}markDirty(){this.dirty=!0,this.tick()}scrollToToday(e=.32){const i=this.dateX(Ge()),t=Math.max(0,i-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=t}computeDomain(){let e=null,i=null;for(const n of this.tasks)!n.start||!n.end||((!e||n.start<e)&&(e=n.start),(!i||n.end>i)&&(i=n.end));const t=Ge();(!e||e>t)&&(e=t),(!i||i<t)&&(i=t);const s=ot(Q(ie(e),-7));this.epochStart=s,this.totalDays=Math.max(de(s,ie(i))+730,1095)}dateX(e){return de(this.epochStart,e)*this.dayWidth}xToDate(e){return ce(Q(this.epochStart,Math.round(e/this.dayWidth)))}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[i,t]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const s=i===this.eRuler?this.eHeader.clientWidth:this.eScroll.clientWidth,n=i===this.eRuler?this.eHeader.clientHeight:this.eScroll.clientHeight;i.width=Math.max(1,Math.round(s*e)),i.height=Math.max(1,Math.round(n*e)),i.style.width=`${s}px`,i.style.height=`${n}px`,t.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,i=this.options.rowHeight,t=this.totalDays*e,s=Math.max(this.rows.length*i,1);this.eSpacer.style.width=`${t}px`,this.eSpacer.style.height=`${s}px`,this.drawRuler(e,t),this.drawBody(e,t,s,i)}drawRuler(e,i){const t=this.rulerCtx,s=this.eHeader.clientWidth,n=this.eHeader.clientHeight,o=this.eScroll.scrollLeft;t.clearRect(0,0,s,n),t.fillStyle="#fff",t.fillRect(0,0,s,n);const a=Q(this.epochStart,this.totalDays),r=(h,g,u,f)=>{for(const m of h){const v=this.dateX(ce(m.start))-o,C=de(m.start,m.end)*e;if(v+C<=0||v>=s)continue;const w=Math.max(0,Math.min(v+C,s)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const y=m.start.getDay();(y===0||y===6)&&(t.fillStyle=Y.weekend,t.fillRect(Math.max(0,v),g,w,u))}const x=t.measureText(m.primary).width;if(x+8<w){const y=Math.max(0,v)+w/2-x/2,N=g+u/2+5;t.fillStyle=Y.text,t.font="11px "+he,t.textAlign="left",t.textBaseline="alphabetic",t.fillText(m.primary,y,N),m.secondary&&(t.fillStyle=Y.textTertiary,t.font="10px "+he,t.fillText(m.secondary,y,N+12))}}},d=40,c=Q(this.epochStart,Math.floor(o/e));t.fillStyle=Y.text,t.font="14px "+he,t.textAlign="left",t.textBaseline="middle",t.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(Bt(this.unit,this.epochStart,a),d+1,n-d-1),t.strokeStyle=Y.border,t.beginPath(),t.moveTo(0,n-.5),t.lineTo(s,n-.5),t.stroke()}drawBody(e,i,t,s){const n=this.ctx,o=this.eScroll.clientWidth,a=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;n.clearRect(0,0,o,a),n.fillStyle="#fff",n.fillRect(0,0,o,a),n.save(),n.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,i,Math.max(t,d+a)),this.drawGridlines(e,i,Math.max(t,d+a)),this.drawRowBackgrounds(i,s);const c=this.rows.findIndex(g=>g.id===this.hoverId),h=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(h==null?void 0:h.kind)==="task"&&!h.start){const g=c*s+6;n.fillStyle="#fff",n.strokeStyle="#dee0e3",n.lineWidth=1,Me(n,r+4,g,Math.max(0,o-8),28,4),n.fill(),n.stroke(),n.fillStyle=Y.textTertiary,n.font="14px "+he,n.textAlign="center",n.fillText("新建排期",r+o/2,g+19)}this.drawDependencies(s),this.drawBars(s),this.drawTodayLine(i,Math.max(t,d+a)),n.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,i,t){if(this.unit!=="day"&&this.unit!=="week")return;const s=this.ctx;s.fillStyle=Y.weekend;let n=ot(this.epochStart);for(;de(this.epochStart,n)<this.totalDays;){const o=this.dateX(ce(n))+5*e;o<i&&s.fillRect(Math.max(0,o),0,e*2,t),n=Q(n,7)}}drawGridlines(e,i,t){const s=this.ctx,n=Q(this.epochStart,this.totalDays);for(const o of Bt(this.unit,this.epochStart,n)){const a=Math.round(this.dateX(ce(o.start)))+.5;if(a<0||a>i)continue;const r=this.unit==="day"&&o.start.getDate()===1;s.strokeStyle=r?Y.gridlineMonth:Y.gridline,s.beginPath(),s.moveTo(a,0),s.lineTo(a,t),s.stroke()}}drawRowBackgrounds(e,i){const t=this.ctx;t.strokeStyle=Y.rowLine,t.lineWidth=1,t.beginPath();for(let s=1;s<this.rows.length;s++){const n=Math.round(s*i)+.5;t.moveTo(0,n),t.lineTo(e,n)}t.stroke(),this.rows.forEach((s,n)=>{const o=this.selectedId===s.id,a=this.hoverId===s.id;(o||a)&&(t.fillStyle=o?Y.selected:a?Y.hover:Y.groupRow,t.fillRect(0,n*i,e,i))})}drawTodayLine(e,i){const t=this.ctx,s=Math.round(this.dateX(Ge())+this.dayWidth/2)+.5;s<0||s>e||(t.strokeStyle=Y.accent,t.lineWidth=1.5,t.beginPath(),t.moveTo(s,0),t.lineTo(s,i),t.stroke(),this.todayLabelX=s-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=Ge().slice(5),this.eTodayBadge.style.left=`${this.todayLabelX-25}px`,this.eTodayBadge.style.top=`${this.eHeader.clientHeight-10}px`}drawDependencies(e){const i=new Map(this.rows.map((s,n)=>[s.id,n])),t=this.ctx;t.strokeStyle=Y.accent,t.lineWidth=1.2;for(const s of this.rows){const n=this.tasksById.get(s.id);if(!n||n.kind!=="task"||!n.start||!n.end)continue;const o=i.get(s.id);if(o!==void 0)for(const a of n.dependsOn){const r=this.tasksById.get(a),d=i.get(a);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),h=r.milestone?this.dayWidth:Math.max(de(ie(r.start),ie(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),g=c+h,u=d*e+e/2,f=this.dateX(n.start),m=Math.max(de(ie(n.start),ie(n.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=o*e+e/2,C=g+10;if(f-4>C)zt(t,g,u,C,v,f-5,v);else{const w=f+m+10;zt(t,g,u,C,v,w,v)}Hs(t,f-5,v)}}}drawBars(e){this.rows.forEach((i,t)=>{const s=this.tasksById.get(i.id);if(!s||!s.start||s.path.length>1&&(!this.showChildren||this.milestonesOnly&&!s.milestone))return;const n=t*e+(e-oe)/2;if(i.group){this.drawSummaryBar(s,t,n);return}if(s.milestone){this.drawMilestone(s,t,n);return}s.end&&this.drawTaskBar(s,t,n)})}drawTaskBar(e,i,t){var u;const s=this.ctx,n=((u=this.ghost)==null?void 0:u.id)===e.id?this.ghost:null,o=(n==null?void 0:n.start)??e.start,a=(n==null?void 0:n.end)??e.end,r=this.dateX(o),d=Math.max(28,(de(o,a)+1)*this.dayWidth),c=Ke[e.status];s.save(),s.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,s.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",s.strokeStyle=this.selectedId===e.id?Y.accent:"#dee0e3",s.lineWidth=1,Me(s,r,t,d,oe,4),s.fill(),s.stroke(),s.save(),Me(s,r,t,d,oe,4),s.clip(),s.beginPath(),s.arc(r+14,t+14,6,0,Math.PI*2),s.fillStyle=c,s.fill(),s.font="12px "+he,s.textBaseline="middle",s.textAlign="left",s.fillStyle=Y.text;const h=this.options.members.find(f=>f.id===e.owner),g=s.measureText(e.name).width;d>g+58?(s.fillText(e.name,r+26,t+14),h&&lt(s,r+g+42,t+14,7,Xe(h.id),h.name.slice(0,1))):h&&d>46&&lt(s,r+38,t+14,7,Xe(h.id),h.name.slice(0,1)),d>100&&(s.fillStyle=Y.textTertiary,s.textAlign="right",s.fillText(String(Ps(ie(o),ie(a))),r+d-8,t+14)),s.restore(),s.restore(),this.pushHit({id:e.id,rowIndex:i,kind:"task",x:r,y:t,w:d,h:oe,mode:"move",avatar:h?{x:r+(d>g+58?g+42:38),y:t+14,r:7}:void 0})}drawSummaryBar(e,i,t){if(!e.start||!e.end)return;const s=this.tasks.filter(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),n=s[0],o=this.ctx,a=this.dateX(e.start),r=Math.max(92,(de(e.start,e.end)+1)*this.dayWidth);o.fillStyle=this.theme==="color"?"#0565db":"#fff",o.strokeStyle=this.selectedId===e.id?Y.accent:"#dee0e3",o.lineWidth=1,Me(o,a,t,r,oe,4),o.fill(),o.stroke(),o.fillStyle=n?Ke[n.status]:Ke[e.status],o.beginPath(),o.arc(a+14,t+14,5,0,Math.PI*2),o.fill(),o.fillStyle=this.theme==="color"?"#fff":Y.text,o.font="11px "+he,o.textAlign="left",o.textBaseline="middle";const d=((n==null?void 0:n.name)??e.name)+(s.length>1?` +${s.length-1}`:"");o.fillText($s(o,d,r-32),a+25,t+14),this.pushHit({id:e.id,rowIndex:i,kind:"summary",x:a,y:t,w:r,h:oe,mode:"move"})}firstVisibleChildIndex(e,i){var s;const t=`${e.path.join("/")}/`;for(let n=i+1;n<this.rows.length;n++){const o=this.tasksById.get(((s=this.rows[n])==null?void 0:s.id)??"");if(o)return o.path.join("/").startsWith(t)?n:-1}return-1}drawMilestone(e,i,t){var v;const s=this.ctx,n=this.dayWidth,o=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,a=o?o.start:e.start,r=Ds(e),d=Ke[r],c=this.dateX(a)+n/2;s.font="12px "+he;const h=s.measureText(e.name).width,g=e.owner?24:0,u=19+h+g+14,f=c-u/2;s.fillStyle="#fff",s.strokeStyle=d,s.lineWidth=1.5,Me(s,f,t,u,oe,4),s.fill(),s.stroke(),s.fillStyle=d,s.beginPath(),s.arc(f+7+3,t+oe/2,3,0,Math.PI*2),s.fill(),s.fillStyle=Y.text,s.textAlign="left",s.textBaseline="middle",s.fillText(e.name,f+14+5,t+oe/2+1);let m;if(e.owner){const C=this.options.members.find(w=>w.id===e.owner);C&&(lt(s,f+u-12,t+oe/2,9,Xe(C.id),C.name.slice(0,1)),m={x:f+u-12,y:t+oe/2,r:9})}this.pushHit({id:e.id,rowIndex:i,kind:"milestone",x:f,y:t,w:u,h:oe,mode:"move",avatar:m})}pushHit(e){this.hits.push(e);const i=this.hitsByRow.get(e.rowIndex);i?i.push(e):this.hitsByRow.set(e.rowIndex,[e])}drawLocateButtons(){this.locateHits=[];const e=this.ctx,i=this.eScroll.scrollLeft,t=this.eScroll.clientWidth;this.rows.forEach((s,n)=>{const o=this.tasksById.get(s.id);if(!(o!=null&&o.start)||!o.end||o.path.length>1&&(!this.showChildren||this.milestonesOnly&&!o.milestone))return;const a=this.dateX(o.start),r=this.dateX(o.end)+this.dayWidth;if(r>=i&&a<=i+t)return;const d=r<i?10:t-18,c=n*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",Me(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+he,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<i?"‹":"›",d+1,c),this.locateHits.push({id:o.id,x:d+1,y:c}))})}pointAt(e,i){const t=this.eScroll.getBoundingClientRect();return{x:e-t.left+this.eScroll.scrollLeft,y:i-t.top+this.eScroll.scrollTop}}hitAt(e,i){const t=this.pointAt(e,i),s=Math.floor(t.y/this.options.rowHeight),n=this.hitsByRow.get(s)??[];for(const o of n){if(o.avatar){const a=t.x-o.avatar.x,r=t.y-o.avatar.y;if(a*a+r*r<=o.avatar.r*o.avatar.r)return{hit:o,rowIndex:s,onAvatar:!0}}if(t.x>=o.x&&t.x<=o.x+o.w&&t.y>=o.y&&t.y<=o.y+o.h){const a=o.kind==="task"&&t.x<=o.x+Ot,r=o.kind==="task"&&t.x>=o.x+o.w-Ot;return{hit:{...o,mode:a?"resize-l":r?"resize-r":"move"},rowIndex:s,onAvatar:!1}}}return{hit:null,rowIndex:s,onAvatar:!1}}buildRulerTools(){this.eRulerTools=document.createElement("div"),this.eRulerTools.className="gt-ruler-tools",this.eHeader.appendChild(this.eRulerTools);const e=document.createElement("button");e.type="button",e.className="gt-ruler-btn gt-ruler-step",this.eStepLabel=document.createElement("span"),this.eStepLabel.className="gt-ruler-step-label",this.eStepLabel.textContent=qe[this.unit];const i=document.createElement("span");i.className="gt-ruler-caret",i.textContent="▾",e.append(this.eStepLabel,i),e.addEventListener("click",n=>{n.stopPropagation(),this.toggleStepMenu()}),this.eRulerTools.appendChild(e);const t=this.toolButton("−","缩小",()=>this.zoomBy(-.25));this.eZoomValue=document.createElement("span"),this.eZoomValue.className="gt-ruler-zoom-value",this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`;const s=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(t,s),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,i,t){const s=document.createElement("button");return s.type="button",s.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(s.className="gt-ruler-btn gt-ruler-today"),s.textContent=e,s.title=i,s.addEventListener("click",n=>{n.stopPropagation(),t()}),s}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const i=this.totalDays*this.dayWidth-this.eScroll.clientWidth,t=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(i,t))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const s of Ht){const n=document.createElement("div");n.className="gt-step-item",n.setAttribute("role","menuitemradio"),n.setAttribute("aria-checked",String(s===this.unit)),n.tabIndex=0,n.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),this.setUnit(s),this.closeStepMenu())}),s===this.unit&&n.classList.add("gt-step-item-active"),n.textContent=qe[s],n.addEventListener("click",o=>{o.stopPropagation(),this.setUnit(s),this.closeStepMenu()}),e.appendChild(n)}const i=this.eRulerTools.getBoundingClientRect(),t=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,t.right-i.right)}px`,e.style.top=`${i.bottom-t.top+4}px`,this.eRoot.appendChild(e),this.eStepMenu=e,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeStepMenu(){var e;(e=this.eStepMenu)==null||e.remove(),this.eStepMenu=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}updateRulerTools(){this.eStepLabel.textContent=qe[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,i){this.closeAssigneePopup();const t=this.tasksById.get(e);if(!t)return;const s=document.createElement("div");s.className="gt-popup";const n=document.createElement("div");n.className="gt-popup-title",n.textContent="更换负责人",s.appendChild(n);for(const d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",t.owner===d.id&&c.classList.add("gt-popup-item-active");const h=document.createElement("span");h.className="gt-avatar",h.textContent=d.name.slice(0,1),h.style.backgroundColor=Xe(d.id);const g=document.createElement("span");g.textContent=d.name,c.append(h,g),c.addEventListener("click",u=>{u.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),s.appendChild(c)}if(t.owner){const d=document.createElement("div");d.className="gt-popup-item gt-popup-clear",d.textContent="取消负责人",d.addEventListener("click",c=>{c.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),s.appendChild(d)}const o=this.eRoot.getBoundingClientRect(),a=i.x+i.w-this.eScroll.scrollLeft,r=i.y-this.eScroll.scrollTop;s.style.left=`${Math.min(o.width-150,Math.max(0,a-40))}px`,s.style.top=`${r+i.h+6}px`,this.eRoot.appendChild(s),this.ePopup=s,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const he="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function Me(l,e,i,t,s,n){const o=Math.max(0,t),a=Math.max(0,s);if(o===0||a===0)return;const r=Math.max(0,Math.min(n,o/2,a/2));l.beginPath(),l.moveTo(e+r,i),l.lineTo(e+o-r,i),l.arcTo(e+o,i,e+o,i+r,r),l.lineTo(e+o,i+a-r),l.arcTo(e+o,i+a,e+o-r,i+a,r),l.lineTo(e+r,i+a),l.arcTo(e,i+a,e,i+a-r,r),l.lineTo(e,i+r),l.arcTo(e,i,e+r,i,r),l.closePath()}function lt(l,e,i,t,s,n){l.beginPath(),l.arc(e,i,t,0,Math.PI*2),l.fillStyle=s,l.fill(),l.lineWidth=1.5,l.strokeStyle="#fff",l.stroke(),l.fillStyle="#fff",l.font=`10px ${he}`,l.textAlign="center",l.textBaseline="middle",l.fillText(n,e,i+1)}function $s(l,e,i){if(i<=0)return"";if(l.measureText(e).width<=i)return e;let t=e.length;for(;t>1;){t--;const s=`${e.slice(0,t)}…`;if(l.measureText(s).width<=i)return s}return"…"}function zt(l,e,i,t,s,n,o){const r=s>i?1:-1;l.beginPath(),l.moveTo(e,i),l.lineTo(t-5,i),l.quadraticCurveTo(t,i,t,i+5*r),l.lineTo(t,s-5*r),l.quadraticCurveTo(t,s,t+5*r,s),l.lineTo(n,o),l.stroke()}function Hs(l,e,i){l.fillStyle=Y.accent,l.beginPath(),l.moveTo(e+5,i),l.lineTo(e-1,i-3.5),l.lineTo(e-1,i+3.5),l.closePath(),l.fill()}const _t=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function Xe(l){let e=0;for(let i=0;i<l.length;i++)e=e*31+l.charCodeAt(i)>>>0;return _t[e%_t.length]}const Os=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Bs=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Vs=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Z(l,e){const i=document.createElement(l);return e&&(i.className=e),i}function Ne(l,e,i){const t=document.createElement("button");return t.type="button",t.className=e,t.textContent=l,t.addEventListener("click",s=>{s.stopPropagation(),i()}),t}class zs{constructor(e,i,t,s){p(this,"filterFields");p(this,"sortFields");p(this,"filterRows",[]);p(this,"sorts",[]);p(this,"filterPanel",null);p(this,"sortPanel",null);p(this,"filterAnchor",null);p(this,"sortAnchor",null);p(this,"onDocumentMouseDown",e=>{var t,s;const i=e.target;this.filterPanel&&!this.filterPanel.contains(i)&&!((t=this.filterAnchor)!=null&&t.contains(i))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(i)&&!((s=this.sortAnchor)!=null&&s.contains(i))&&this.closeSortPanel()});this.api=e,this.host=i,this.hooks=s,this.filterFields=t.filter,this.sortFields=t.sort,document.addEventListener("mousedown",this.onDocumentMouseDown,!0)}openFilterPanel(e){if(this.filterPanel){this.closeFilterPanel();return}this.closeSortPanel();const i=Z("div","gt-panel gt-filter-panel");i.addEventListener("mousedown",d=>d.stopPropagation());const t=Z("div","gt-panel-title");t.textContent="筛选",i.appendChild(t);const s=Z("div","gt-filter-rows");i.appendChild(s);const n=()=>{if(s.textContent="",!this.filterRows.length){const d=Z("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",s.appendChild(d)}for(const d of this.filterRows)s.appendChild(this.renderFilterRow(d,n))},o=Z("div","gt-filter-add");for(const d of this.filterFields)o.appendChild(Ne(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),n()}));i.appendChild(o);const a=Z("div","gt-panel-hint");a.textContent="多个条件同时满足(且)",i.appendChild(a);const r=Z("div","gt-panel-actions");r.append(Ne("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),Ne("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),i.appendChild(r),this.mount(i,e),this.filterPanel=i,this.filterAnchor=e,n()}renderFilterRow(e,i){const t=Z("div","gt-filter-row"),s=this.filterFields.find(d=>d.colId===e.colId),n=document.createElement("select");n.className="gt-panel-select";for(const d of this.filterFields){const c=document.createElement("option");c.value=d.colId,c.textContent=d.label,d.colId===e.colId&&(c.selected=!0),n.appendChild(c)}n.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===n.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",i())}),t.appendChild(n);const o=e.kind==="number"?Bs:e.kind==="date"?Vs:Os,a=document.createElement("select");a.className="gt-panel-select gt-panel-select-cond";for(const d of o){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),a.appendChild(c)}if(a.addEventListener("change",()=>{e.type=a.value,i()}),t.appendChild(a),e.type!=="blank")if(s!=null&&s.options){const d=document.createElement("select");d.className="gt-panel-select";const c=document.createElement("option");c.value="",c.textContent="请选择",d.appendChild(c);for(const h of s.options){const g=document.createElement("option");g.value=h.value,g.textContent=h.label,h.value===e.value&&(g.selected=!0),d.appendChild(g)}d.addEventListener("change",()=>{e.value=d.value}),t.appendChild(d)}else if(e.kind==="date"){const d=document.createElement("input");if(d.type="date",d.className="gt-panel-input",d.value=e.value,d.addEventListener("change",()=>{e.value=d.value}),t.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="date",c.className="gt-panel-input",c.value=e.valueTo,c.addEventListener("change",()=>{e.valueTo=c.value}),t.appendChild(c)}}else if(e.kind==="number"){const d=document.createElement("input");if(d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="数值",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),t.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="至",c.value=e.valueTo,c.addEventListener("input",()=>{e.valueTo=c.value}),t.appendChild(c)}}else{const d=document.createElement("input");d.type="text",d.className="gt-panel-input",d.placeholder="文本",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),t.appendChild(d)}const r=Ne("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),i()});return r.title="移除条件",t.appendChild(r),t}applyFilter(){const e={};for(const i of this.filterRows){if(i.type==="blank"){e[i.colId]={filterType:i.kind==="number"?"number":"text",type:"blank",filter:""};continue}if(i.kind==="date"){const t=(i.type==="after",i.value),s=i.type==="before"?i.value:i.valueTo;if(i.type==="before"&&!i.value||i.type==="after"&&!i.value||i.type==="inRange"&&!i.value&&!i.valueTo)continue;e[i.colId]={filterType:"date",dateFrom:t||void 0,dateTo:s||void 0};continue}if(i.value)if(i.kind==="number"){const t={filterType:"number",type:i.type,filter:Number(i.value)};i.type==="inRange"&&(t.filterTo=Number(i.valueTo||i.value)),e[i.colId]=t}else e[i.colId]={filterType:"text",type:i.type,filter:i.value}}this.api.setFilterModel(e),this.hooks.onFilterButton(Object.keys(e).length>0,Object.keys(e).length)}closeFilterPanel(){var e;(e=this.filterPanel)==null||e.remove(),this.filterPanel=null}openSortPanel(e){if(this.sortPanel){this.closeSortPanel();return}this.closeFilterPanel();const i=Z("div","gt-panel gt-sort-panel");i.addEventListener("mousedown",a=>a.stopPropagation());const t=Z("div","gt-panel-title");t.textContent="排序",i.appendChild(t);const s=Z("div","gt-sort-list");i.appendChild(s);const n=()=>{var a;s.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(u=>u.colId===r.colId),c=d>=0,h=Z("div","gt-sort-item");c&&h.classList.add("gt-sort-item-active");const g=Z("span","gt-sort-label");if(g.textContent=r.label,h.appendChild(g),c){const u=Z("span","gt-sort-badge");u.textContent=String(d+1),h.appendChild(u);const f=Z("span","gt-sort-dir");f.textContent=((a=this.sorts[d])==null?void 0:a.sort)==="asc"?"↑ 升序":"↓ 降序",h.appendChild(f)}h.addEventListener("click",()=>{var u;c?((u=this.sorts[d])==null?void 0:u.sort)==="asc"?this.sorts[d]={colId:r.colId,sort:"desc"}:this.sorts=this.sorts.filter(f=>f.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),n()}),s.appendChild(h)}},o=Z("div","gt-panel-actions");o.append(Ne("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),Ne("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applySort(),this.closeSortPanel()})),i.appendChild(o),this.mount(i,e),this.sortPanel=i,this.sortAnchor=e,n()}applySort(){this.api.setSortModel(this.sorts.map(e=>({colId:e.colId,sort:e.sort}))),this.hooks.onSortButton(this.sorts.length>0,this.sorts.length)}closeSortPanel(){var e;(e=this.sortPanel)==null||e.remove(),this.sortPanel=null}mount(e,i){this.host.appendChild(e);const t=i.getBoundingClientRect();e.style.top=`${t.bottom+6}px`;const s=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(t.left,s))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const _s={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应列宽",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多选筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"列显示",hideColumn:"隐藏此列",chooseColumns:"选择显示的列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",copy:"复制",copyWithHeaders:"复制(含表头)",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应宽度",expandAll:"展开全部",collapseAll:"收起全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"清除全部",join:"组合方式:",and:"且",or:"或",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",addCondition:"+ 添加条件",condTrue:"是",condFalse:"否",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"第",pageSize:"每页条数:",find:"在表格中查找…",matchCase:"区分大小写",of:"/",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity"};function Ws(l,e){const i=document.createElement("section");i.className="rowvia-gantt",i.innerHTML=`<div class="gantt-app">
24
+ `,new Blob([d.encode(f)],{type:"application/pdf"})}function Ee(l,e){return l.getUint32(e,!0)}function ye(l,e){return l.getUint16(e,!0)}async function ys(l){var s;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(s=new Response(l).body)==null?void 0:s.pipeThrough(new DecompressionStream("deflate-raw"));if(!t)throw new Error("Failed to create a decompression stream");const i=await new Response(t).arrayBuffer();return new Uint8Array(i)}function Ss(l){const e=new DataView(l),t=new Uint8Array(l);let i=-1;for(let a=t.length-22;a>=0;a--)if(Ee(e,a)===101010256){i=a;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const s=ye(e,i+10);let n=Ee(e,i+16);const o=[];for(let a=0;a<s&&Ee(e,n)===33639248;a++){const r=ye(e,n+10),d=Ee(e,n+20),c=Ee(e,n+24),h=ye(e,n+28),g=ye(e,n+30),p=ye(e,n+32),m=Ee(e,n+42),f=new TextDecoder().decode(t.subarray(n+46,n+46+h));o.push({name:f,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:m}),n+=46+h+g+p}return o}async function it(l,e){const t=new DataView(l),i=new Uint8Array(l),s=ye(t,e.localHeaderOffset+26),n=ye(t,e.localHeaderOffset+28),o=e.localHeaderOffset+30+s+n,a=i.subarray(o,o+e.compressedSize);return e.compressionMethod===0?a:ys(a)}function st(l){return new DOMParser().parseFromString(l,"application/xml")}function xs(l){const e=l.replace(/\d+/g,"");let t=0;for(const i of e)t=t*26+(i.charCodeAt(0)-64);return t-1}async function bs(l){const e=Ss(l),t=e.find(d=>d.name==="xl/workbook.xml"),i=[];if(t){const c=st(new TextDecoder().decode(await it(l,t))).getElementsByTagName("sheet");for(let h=0;h<c.length;h++)i.push(c[h].getAttribute("name")||`Sheet${h+1}`),c[h].getAttribute("r:id")||c[h].getAttribute("id")}const s=[],n=e.find(d=>d.name==="xl/sharedStrings.xml");if(n){const c=st(new TextDecoder().decode(await it(l,n))).getElementsByTagName("si");for(let h=0;h<c.length;h++){const g=c[h].getElementsByTagName("t");let p="";for(let m=0;m<g.length;m++)p+=g[m].textContent||"";s.push(p)}}const a=e.filter(d=>/^xl\/worksheets\/sheet\d+\.xml$/.test(d.name)).sort((d,c)=>d.name.localeCompare(c.name,void 0,{numeric:!0})),r=[];for(let d=0;d<a.length;d++){const h=st(new TextDecoder().decode(await it(l,a[d]))).getElementsByTagName("row"),g=[];for(let p=0;p<h.length;p++){const m=h[p],f=[],v=m.getElementsByTagName("c");for(let C=0;C<v.length;C++){const w=v[C],x=w.getAttribute("r")||"",b=w.getAttribute("t")||"";let y="";if(b==="s"){const I=w.getElementsByTagName("v")[0],D=Number((I==null?void 0:I.textContent)||"0");y=s[D]??""}else if(b==="inlineStr"){const I=w.getElementsByTagName("t");for(let D=0;D<I.length;D++)y+=I[D].textContent||""}else{const I=w.getElementsByTagName("v")[0];y=(I==null?void 0:I.textContent)??""}const N=x?xs(x):C;f[N]=y}g.push(f.map(C=>C??""))}r.push({name:i[d]||`Sheet${d+1}`,rows:g})}return r}class Es{constructor(e){u(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(s=>typeof s=="string"?this.grid.getColumn(s):s).filter(s=>!!s);if(e.allColumns)return t.filter(s=>s.field||s.valueGetter);const i=this.grid.getColumns();return[...i.center,...i.left,...i.right]}getExportRows(e){const t=this.grid.getRowModel(),i=[],s=e.onlySelected===!0,n=e.skipGroups!==!1,o=e.skipFooters!==!1;return t.forEachNode(a=>{a.rowPinned==="top"&&e.skipPinnedTop!==!1||a.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||n&&a.group&&!a.footer||o&&a.footer||s&&!a.selected||i.push(a)}),s&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let s=H(e,t,this.grid.getApi()),n=Ve(e,t,this.grid.getApi());if(i.processCellCallback){const o=i.processCellCallback({value:s,formattedValue:n,node:t,column:e,api:this.grid.getApi()});if(o!=null)return String(o)}return t.footer&&t.groupData&&t.groupData[e.colId]!==void 0&&(s=t.groupData[e.colId],n=s===null?"":String(s)),t.group&&t.groupData&&t.groupData[e.colId]!==void 0&&(s=t.groupData[e.colId],n=s===null?"":String(s)),s instanceof Date?s.toISOString().slice(0,10):n??(s==null?"":String(s))}getDataAsCsv(e={}){var o;const t=this.getExportColumns(e),i=this.getExportRows(e),s=e.columnSeparator??",",n=[];if(!e.skipHeader){const a=t.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&n.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),s,e.suppressQuotes)),n.push(this.csvRow(a,s,e.suppressQuotes))}for(const a of i){if((o=e.shouldRowBeSkipped)!=null&&o.call(e,{node:a,api:this.grid.getApi()}))continue;const r=t.map(d=>this.getCellValueForExport(d,a,e));n.push(this.csvRow(r,s,e.suppressQuotes))}return n.join(`\r
25
+ `)}csvRow(e,t,i){return e.map(s=>{const n=s==null?"":String(s);return!i&&(n.includes(t)||n.includes('"')||n.includes(`
26
+ `))?`"${n.replace(/"/g,'""')}"`:n}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),i=this.getExportRows(e),s=[];e.skipHeader||s.push(t.map(n=>({value:n.headerName||n.field||n.colId,bold:!0})));for(const n of i)s.push(t.map(o=>{let a=H(o,n,this.grid.getApi());return n.footer&&n.groupData&&n.groupData[o.colId]!==void 0&&(a=n.groupData[o.colId]),n.group&&n.groupData&&n.groupData[o.colId]!==void 0&&(a=n.groupData[o.colId]),a instanceof Date&&(a=a.toISOString().slice(0,10)),{value:a}}));return fs([{name:e.sheetName||"Sheet1",rows:s}])}exportToCsv(e={}){const t=this.getDataAsCsv(e);this.download(new Blob([t],{type:"text/csv;charset=utf-8;"}),this.fileName(e,"csv"))}exportToExcel(e={}){const t=this.getDataAsExcel(e);this.download(t,this.fileName(e,"xlsx"))}getDataAsPdf(e={}){var m;const t=this.getExportColumns(e),i=this.getExportRows(e),s=t.map(f=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(f.headerName)+24))),n=[],o=[];e.skipHeader||(n.push(t.map(f=>({text:e.processHeaderCallback?e.processHeaderCallback({column:f,api:this.grid.getApi()}):f.headerName||f.field||f.colId,bold:!0,align:f.type==="numberColumn"||f.cellDataType===!0?"right":"left"}))),o.push([.94,.95,.97]));for(const f of i)(m=e.shouldRowBeSkipped)!=null&&m.call(e,{node:f,api:this.grid.getApi()})||(n.push(t.map(v=>{let C=this.getCellValueForExport(v,f,e);if(e.processCellCallback){const w=e.processCellCallback({value:H(v,f,this.grid.getApi()),formattedValue:C,node:f,column:v,api:this.grid.getApi()});w!=null&&(C=String(w))}return{text:C,align:v.type==="numberColumn"||v.cellDataType===!0?"right":"left"}})),o.push(void 0));const a=18,r=e.pageSize||"a4-landscape",[d,c]=r.includes("portrait")?[595,842]:[842,595],h=c-64-(e.title?24:0),g=Math.max(5,Math.floor(h/a)),p=[];n.length===0&&p.push({columnWidths:s,rows:[],rowFill:[]});for(let f=0;f<n.length;f+=g)p.push({columnWidths:s,rows:n.slice(f,f+g),rowFill:o.slice(f,f+g)});return ws(p,{pageSize:r,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const i=e instanceof ArrayBuffer?e:await e.arrayBuffer(),n=(await bs(i))[t.sheetIndex??0];if(!n||n.rows.length===0)return[];const o=n.rows[0],a=n.rows.slice(1).map(r=>{const d={};return o.forEach((c,h)=>{const g=c||`col${h+1}`,p=r[h]??"",m=String(p).trim();d[g]=m!==""&&!isNaN(Number(m))&&!/^0\d/.test(m)?Number(m):p}),d});return t.onSuccess?t.onSuccess(a):this.grid.getApi().setRowData(a),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:a}),a}fileName(e,t){const i=e.fileName||this.grid.getOptions().fileName||"export";return i.endsWith(`.${t}`)?i:`${i}.${t}`}download(e,t){const i=URL.createObjectURL(e),s=document.createElement("a");s.href=i,s.download=t,document.body.appendChild(s),s.click(),document.body.removeChild(s),setTimeout(()=>URL.revokeObjectURL(i),1e3)}copyToClipboard(e={}){const t={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},i=this.getDataAsCsv(t);this.lastCopied=i,this.writeToClipboard(i),this.grid.getEventService().dispatchEvent("pasteStart",{}),this.grid.getEventService().dispatchEvent("pasteEnd",{})}cutToClipboard(e={}){this.copyToClipboard(e);const t=this.getExportRows({onlySelected:!0,skipGroups:!0,skipFooters:!0,...e});t.length&&this.grid.getApi().applyTransaction({remove:t.map(i=>i.data)})}pasteFromClipboard(){navigator.clipboard&&navigator.clipboard.readText?navigator.clipboard.readText().then(e=>this.pasteText(e),()=>{this.lastCopied&&this.pasteText(this.lastCopied)}):this.lastCopied&&this.pasteText(this.lastCopied)}pasteText(e){const t=this.grid.getEditService().getFocusedCell(),i=this.grid.getRangeSelectionService().getRanges();let s,n;if(i.length>0){const h=i[0];s=h.rowStartIndex;const g=this.grid.getColumns().center,p=g.findIndex(m=>m.colId===h.colStartId);n=g[p]??g[0]}else if(t)s=t.rowIndex,n=t.column;else return;const o=e.replace(/\r/g,"").split(`
27
+ `);o.length&&o[o.length-1]===""&&o.pop();const a=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=a.findIndex(h=>h.colId===n.colId),d=[],c=[];this.grid.getDisplayedRowCount(),o.forEach((h,g)=>{const p=h.split(" "),m=s+g;let f=this.grid.getDisplayedRowAtIndex(m);if(!f){const v={};p.forEach((C,w)=>{const x=a[r+w];x!=null&&x.field&&(v[x.field]=C)}),c.push(v);return}p.forEach((v,C)=>{const w=a[r+C];w&&this.grid.setCellValue(w,f,v,"paste")}),d.push(f)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const t=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t,()=>this.fallbackCopy(e,t)):this.fallbackCopy(e,t)}fallbackCopy(e,t){const i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();try{document.execCommand("copy")}catch{}document.body.removeChild(i),t()}}class Rs{constructor(e){u(this,"ePanel");u(this,"eChips");this.grid=e,this.ePanel=document.createElement("div"),this.ePanel.className="ag-row-group-panel";const t=document.createElement("span");t.className="ag-row-group-panel-label",t.textContent=this.grid.t("rowGroups"),this.ePanel.appendChild(t),this.eChips=document.createElement("div"),this.eChips.className="ag-row-group-panel-chips",this.ePanel.appendChild(this.eChips),this.eChips.addEventListener("dragover",n=>{n.preventDefault(),this.eChips.classList.add("ag-drag-over")}),this.eChips.addEventListener("dragleave",()=>this.eChips.classList.remove("ag-drag-over")),this.eChips.addEventListener("drop",n=>{var a;n.preventDefault(),this.eChips.classList.remove("ag-drag-over");const o=(a=n.dataTransfer)==null?void 0:a.getData("text/plain");o&&this.grid.getColumnModel().addRowGroupColumn(o)});const i=e.getOptions();(i.rowGroupPanelShow==="always"||i.rowGroupPanelShow==="onlyWhenGrouping")&&e.getMainElement().insertBefore(this.ePanel,e.getHeaderElement()),this.refresh(),e.getEventService().addEventListener("columnRowGroupChanged",()=>this.refresh()),e.getEventService().addEventListener("modelUpdated",()=>this.refreshVisibility())}refresh(){this.eChips.innerHTML="";const e=this.grid.getColumnModel().getRowGroupColumns();for(const t of e){const i=document.createElement("div");i.className="ag-row-group-chip",i.draggable=!0,i.addEventListener("dragstart",o=>{var a;(a=o.dataTransfer)==null||a.setData("text/plain",t.colId)});const s=document.createElement("span");s.textContent=t.headerName,i.appendChild(s);const n=document.createElement("button");n.className="ag-row-group-chip-remove",n.textContent="×",n.title=this.grid.t("remove"),n.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(t)),i.appendChild(n),this.eChips.appendChild(i)}if(e.length===0){const t=document.createElement("span");t.className="ag-column-group-hint",t.textContent=this.grid.t("dragColumnsHere"),this.eChips.appendChild(t)}this.refreshVisibility()}refreshVisibility(){const e=this.grid.getOptions().rowGroupPanelShow;if(e==="always")this.ePanel.style.display="";else if(e==="onlyWhenGrouping"){const t=this.grid.getColumnModel().isRowGroupActive();this.ePanel.style.display=t?"":"none"}}}class Ms{constructor(e,t){u(this,"undoStack",[]);u(this,"redoStack",[]);u(this,"limit",50);u(this,"batchDepth",0);u(this,"batchBuffer",[]);u(this,"batchCounter",0);u(this,"currentBatchId",0);this.grid=e,this.eventService=t;const i=e.getOptions();i.undoRedoCellEditing&&(this.limit=typeof i.undoRedoCellEditing=="number"?i.undoRedoCellEditing:50)}isEnabled(){return!!this.grid.getOptions().undoRedoCellEditing}pushAction(e){if(this.isEnabled()){if(this.batchDepth>0){this.batchBuffer.push(e);return}this.undoStack.push({...e,batchId:this.currentBatchId}),this.undoStack.length>this.limit&&this.undoStack.shift(),this.redoStack=[]}}canUndo(){return this.isEnabled()&&this.undoStack.length>0}canRedo(){return this.isEnabled()&&this.redoStack.length>0}getUndoStackSize(){return this.undoStack.length}getRedoStackSize(){return this.redoStack.length}undo(){if(!this.canUndo())return 0;const e=[this.undoStack.pop()];for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].rowNodeId===e[0].rowNodeId&&this.undoStack[this.undoStack.length-1].colId===e[0].colId;)e.push(this.undoStack.pop());if(e[0].batchId!==0)for(;this.undoStack.length>0&&this.undoStack[this.undoStack.length-1].batchId===e[0].batchId;)e.push(this.undoStack.pop());let t=0;for(const i of e)this.applyValue(i,i.oldValue),this.redoStack.push(i),t++;return this.eventService.dispatchEvent("undoEnded",{api:this.grid.getApi(),numberOfActions:t}),t}redo(){if(!this.canRedo())return 0;let e=0;for(;this.redoStack.length>0;){const t=this.redoStack.pop();if(this.applyValue(t,t.newValue),this.undoStack.push(t),e++,this.redoStack.length===0||this.redoStack[this.redoStack.length-1].colId!==t.colId)break}return this.eventService.dispatchEvent("redoEnded",{api:this.grid.getApi(),numberOfActions:e}),e}applyValue(e,t){const i=this.grid.getRowNode(e.rowNodeId);if(!i)return;const s=this.grid.getColumn(e.colId);s&&(this.grid.setCellValue(s,i,t,"undoRedo"),this.grid.refreshCells({rowNodes:[i],columns:[s],flash:!0}))}startBatchEdit(){this.batchDepth++,this.batchDepth===1&&(this.currentBatchId=++this.batchCounter)}endBatchEdit(e=!1){if(this.batchDepth=Math.max(0,this.batchDepth-1),this.batchDepth>0)return;if(e){this.batchBuffer=[];return}const t=this.currentBatchId;for(const i of this.batchBuffer)this.undoStack.push({...i,batchId:t}),this.undoStack.length>this.limit&&this.undoStack.shift();this.redoStack=[],this.batchBuffer=[],this.eventService.dispatchEvent("batchEditEnded",{api:this.grid.getApi()})}isBatchEditing(){return this.batchDepth>0}clear(){this.undoStack=[],this.redoStack=[],this.batchBuffer=[]}}class Ns{constructor(e,t){this.grid=e,this.popupService=t}isFormulaColumn(e){return typeof e.field=="string"&&e.field.trimStart().startsWith("=")}openFormulaEditor(e,t){const{ePopup:i,close:s}=this.popupService.createPopup(460,"ag-formula-editor");i.innerHTML="";const n=document.createElement("div");n.className="ag-popup-title",n.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,i.appendChild(n);const o=document.createElement("textarea");o.className="ag-formula-input",o.rows=3,o.value=this.isFormulaColumn(e)?e.field:"=",o.placeholder=this.grid.t("formulaPlaceholder"),i.appendChild(o);const a=document.createElement("div");a.className="ag-formula-preview";const r=()=>{const f=this.grid.getDisplayedRowAtIndex(0);if(!f){a.textContent="";return}try{const v=De(o.value,{data:f.data});a.textContent=`${this.grid.t("formulaPreview")}: ${v==null?"":String(v)}`,a.classList.remove("ag-formula-error")}catch(v){a.textContent=`${this.grid.t("formulaError")}: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||this.grid.t("invalidFormula")}`,a.classList.add("ag-formula-error")}};o.addEventListener("input",r),i.appendChild(a);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent=this.grid.t("functions"),d.appendChild(c);const h=document.createElement("div");h.className="ag-formula-functions-list";for(const f of Be){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=f,v.addEventListener("click",()=>{o.value+=`${o.value.endsWith("(")||o.value==="="?"":" "}${f}()`,o.focus(),r()}),h.appendChild(v)}d.appendChild(h),i.appendChild(d);const g=document.createElement("div");g.className="ag-popup-buttons";const p=document.createElement("button");p.className="ag-button ag-button-primary",p.textContent=this.grid.t("apply"),p.addEventListener("click",()=>{const f=o.value.trim(),v=this.grid.getColumnModel(),C=v.getColumn(e.colId);C&&(C.field=f==="="||f===""?e.field:f,C.colDef={...C.colDef,field:C.field},f!=="="&&f!==""&&(C.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),s()});const m=document.createElement("button");m.className="ag-button",m.textContent=this.grid.t("clear"),m.addEventListener("click",()=>{o.value="=",r()}),g.appendChild(m),g.appendChild(p),i.appendChild(g),this.popupService.positionAt(i,t),r()}}class Ts{constructor(e,t){u(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,i,s){const n=this.runtimeNotes.get(this.keyOf(e,t));if(n!==void 0)return n;if(typeof i=="function")return i(s);if(typeof i=="string")return i}setNote(e,t,i){const s=this.keyOf(e,t);i==null||i===""?this.runtimeNotes.delete(s):this.runtimeNotes.set(s,i),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,i){const s=this.grid.getColumn(t),n=this.grid.getRowNode(e),o=this.getNote(e,t,s==null?void 0:s.colDef.note,{data:n==null?void 0:n.data,node:n,column:s,api:this.grid.getApi()})??"",{ePopup:a,close:r}=this.popupService.createPopup(280,"ag-note-editor");a.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`${this.grid.t("note")} — ${(s==null?void 0:s.headerName)||t}`,a.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=o,c.placeholder=this.grid.t("writeNote"),a.appendChild(c);const h=document.createElement("div");h.className="ag-popup-buttons";const g=document.createElement("button");g.className="ag-button ag-button-primary",g.textContent=this.grid.t("save"),g.addEventListener("click",()=>{this.setNote(e,t,c.value.trim()||void 0),r()});const p=document.createElement("button");p.className="ag-button",p.textContent=this.grid.t("delete"),p.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),h.appendChild(p),h.appendChild(g),a.appendChild(h),this.popupService.positionAt(a,i),setTimeout(()=>c.focus(),0)}}class Is{constructor(e,t){u(this,"dragState",null);u(this,"onMouseMoveBind",e=>this.onMouseMove(e));u(this,"onMouseUpBind",e=>this.onMouseUp(e));this.grid=e,this.eventService=t}isEnabled(){const e=this.grid.getOptions();return!!e.rowDragManaged||!!e.rowDragEnt||this.hasDragHandle()}hasDragHandle(){return this.grid.getAllColumns().some(e=>e.rowDrag)}startDrag(e,t){if(!this.isEnabled()||this.dragState)return;t.preventDefault();const i=document.createElement("div");i.className="ag-row-drag-ghost",i.textContent=this.rowLabel(e),document.body.appendChild(i);const s=document.createElement("div");s.className="ag-row-drop-indicator",s.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(s),this.dragState={rowNode:e,ghost:i,startY:t.clientY,overIndex:null,indicator:s},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var s;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],i=t!=null&&t.field?(s=e.data)==null?void 0:s[t.field]:"";return String(i??e.id)}onMouseMove(e){const t=this.dragState;if(!t)return;t.ghost.style.left=`${e.clientX+8}px`,t.ghost.style.top=`${e.clientY+8}px`;const i=document.elementFromPoint(e.clientX,e.clientY),s=i==null?void 0:i.closest(".ag-row");if(!(s!=null&&s.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let n=-1;if(this.grid.getRowModel().forEachNode((o,a)=>{o.id===s.dataset.rowid&&(n=a)}),t.overIndex=n,n>=0){const o=this.grid.getRowRenderer().getRowOffsets(),a=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(n)),r=e.clientY>s.getBoundingClientRect().top+a/2,d=(o[n]??0)+(r?a:0);t.indicator.style.display="block",t.indicator.style.top=`${d-1}px`}else t.indicator.style.display="none"}onMouseUp(e){const t=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!t)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),t.ghost.remove(),t.indicator.remove();const i=this.grid.getApi(),s=this.grid.getOptions(),n=t.overIndex,o=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:i,node:t.rowNode,overIndex:n,overNode:n!==null?this.grid.getDisplayedRowAtIndex(n):void 0,y:e.clientY}),s.rowDragManaged&&o>=0&&n!==null&&n!==o&&this.moveRow(o,n,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((i,s)=>{i.id===e.id&&(t=s)}),t}moveRow(e,t,i){const s=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=s.length)return;const[n]=s.splice(e,1),o=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),s.splice(Math.max(0,Math.min(s.length,o+1)),0,n),this.grid.getApi().setRowData(s),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:n}})}}function ks(l){const e={setRowData:i=>l.setRowData(i),applyTransaction:i=>l.applyTransaction(i),getRowNode:i=>l.getRowNode(i),getDisplayedRowCount:()=>l.getDisplayedRowCount(),getDisplayedRowAtIndex:i=>l.getDisplayedRowAtIndex(i),getFirstDisplayedRow:()=>l.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>l.getDisplayedRowAtIndex(l.getDisplayedRowCount()-1),forEachNode:i=>{const s=l.getRowModel();for(let n=0;n<s.getRowCount();n++){const o=s.getRow(n);o&&i(o,n)}},forEachLeafNode:i=>{l.getRowModel().forEachLeafNode(i)},getModel:()=>l.getRowModel(),getValue:(i,s)=>{const n=typeof i=="string"?l.getColumn(i):i;if(!(!n||!s))return H(n,s,l.getApi())},getSelectedRows:()=>l.getSelectionService().getSelectedRows(),getSelectedNodes:()=>l.getSelectionService().getSelectedNodes(),selectAll:()=>l.getSelectionService().selectAll(),deselectAll:()=>l.getSelectionService().deselectAll(),selectAllFiltered:()=>l.getSelectionService().selectAllFiltered(),deselectAllFiltered:()=>l.getSelectionService().deselectAll(),selectNode:(i,s)=>l.getSelectionService().selectNode(i,s??!1),deselectNode:i=>l.getSelectionService().deselectNode(i),setQuickFilter:i=>l.setQuickFilter(i),isQuickFilterPresent:()=>l.getQuickFilter().length>0,resetQuickFilter:()=>l.setQuickFilter(""),getSortModel:()=>l.getSortService().getSortModel(),setSortModel:i=>l.getSortService().setSortModel(i),getFilterModel:()=>l.getFilterService().getFilterModel(),setFilterModel:i=>l.getFilterService().setFilterModel(i),getColumnFilterModel:i=>{const s=typeof i=="string"?i:i.colId;return l.getFilterService().getFilterInstance(s)??null},setColumnFilterModel:(i,s)=>l.getFilterService().setColumnFilterModel(i,s),getAdvancedFilterModel:()=>l.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:i=>l.getFilterService().setAdvancedFilterModel(i),onFilterChanged:()=>l.getFilterService().onFilterChanged("api"),onSortChanged:()=>l.getSortService().onSortChanged("api"),expandAll:()=>l.getRowModel().expandAll(),collapseAll:()=>l.getRowModel().collapseAll(),onGroupExpandedOrCollapsed:()=>l.refreshModel("expand"),getRowGroupColumns:()=>l.getColumnModel().getRowGroupColumns(),setRowNodePinned:(i,s)=>l.setRowNodePinned(i,s),getColumnDefs:()=>l.getColumnModel().getColumnDefs(),setColumnDefs:(i,s)=>{l.getColumnModel().setColumnDefs(i),l.onGridSizeChanged()},updateGridOptions:i=>l.updateGridOptions(i),setGridOption:(i,s)=>l.updateGridOptions({[i]:s}),sizeColumnsToFit:()=>{const i=l.getSideBarService().isVisible()?l.getSideBarService().getElement().offsetWidth:0;l.getColumnModel().sizeColumnsToFit(l.getGridDiv().clientWidth-i),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{l.getColumnModel().autoSizeAllColumns(),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{l.getColumnModel().autoSizeAllColumns()},moveColumn:(i,s)=>l.getColumnModel().moveColumn(i,s),moveColumnByIndex:(i,s)=>l.getColumnModel().moveColumnByIndex(i,s),setColumnVisible:(i,s)=>l.getColumnApi().setColumnVisible(i,s),setColumnsPinned:(i,s)=>l.getColumnApi().setColumnsPinned(i,s),setColumnsVisible:(i,s)=>l.getColumnApi().setColumnsVisible(i,s),getAllColumns:()=>l.getAllColumns(),getColumns:()=>[...l.getColumns().left,...l.getColumns().center,...l.getColumns().right],getColumn:i=>l.getColumn(i)??null,getDisplayedLeftColumns:()=>l.getColumns().left,getDisplayedCenterColumns:()=>l.getColumns().center,getDisplayedRightColumns:()=>l.getColumns().right,getColumnState:()=>l.getColumnApi().getColumnState(),applyColumnState:(i,s)=>l.getColumnApi().applyColumnState(i,s),resetColumnState:()=>l.getColumnApi().resetColumnState(),openColumnMenu:i=>{const s=typeof i=="string"?l.getColumn(i):i;s!=null&&s.eHeaderCell&&l.getHeaderView().getHeaderCell(s)},setSideBarVisible:i=>{l.getSideBarService().setVisible(i),l.onGridSizeChanged()},isSideBarVisible:()=>l.getSideBarService().isVisible(),setSideBarPosition:i=>{l.getSideBarService().setPosition(i),l.onGridSizeChanged()},openToolPanel:i=>{l.getSideBarService().setVisible(!0),l.getSideBarService().openPanel(i),l.onGridSizeChanged()},closeToolPanel:()=>{l.getSideBarService().setVisible(!1),l.onGridSizeChanged()},getToolPanel:()=>l.getSideBarService().getActivePanel(),setStatusBarVisible:i=>l.getSideBarService()&&l.getOptions(),getSideBar:()=>l.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var i;return((i=l.getPaginationService())==null?void 0:i.isLastPageFound())??!0},paginationGetPageSize:()=>{var i;return((i=l.getPaginationService())==null?void 0:i.getPageSize())??0},paginationGetCurrentPage:()=>{var i;return((i=l.getPaginationService())==null?void 0:i.getCurrentPage())??0},paginationGetTotalPages:()=>{var i;return((i=l.getPaginationService())==null?void 0:i.getTotalPages())??1},paginationGetRowCount:()=>l.getDisplayedRowCount(),paginationGoToPage:i=>{var s;return(s=l.getPaginationService())==null?void 0:s.goToPage(i)},paginationGoToNextPage:()=>{var i;return(i=l.getPaginationService())==null?void 0:i.goToNextPage()},paginationGoToPreviousPage:()=>{var i;return(i=l.getPaginationService())==null?void 0:i.goToPreviousPage()},paginationGoToFirstPage:()=>{var i;return(i=l.getPaginationService())==null?void 0:i.goToFirstPage()},paginationGoToLastPage:()=>{var i;return(i=l.getPaginationService())==null?void 0:i.goToLastPage()},paginationSetPageSize:i=>{var s;return(s=l.getPaginationService())==null?void 0:s.setPageSize(i)},startEditingCell:i=>l.getEditService().startEditingCell(i),stopEditing:i=>l.getEditService().stopEditing(i),getEditingCells:()=>l.getEditService().getEditingCells(),setFocusedCell:(i,s)=>{const n=typeof s=="string"?l.getColumn(s):s;n&&l.getEditService().setFocusedCell(i,n)},getFocusedCell:()=>{const i=l.getEditService().getFocusedCell();return i?{rowIndex:i.rowIndex,column:i.column,rowNode:i.rowNode}:null},clearFocusedCell:()=>l.getEditService().clearFocusedCell(),tabToNextCell:()=>l.getEditService().tabToNextCell(),tabToPreviousCell:()=>l.getEditService().tabToPreviousCell(),refreshCells:i=>l.getRowRenderer().refreshCells(i),redrawRows:i=>l.getRowRenderer().redrawRows(i),flashCells:i=>l.getRowRenderer().flashCells(i||{}),ensureIndexVisible:(i,s)=>l.getRowRenderer().ensureIndexVisible(i,s),ensureNodeVisible:i=>{let s=-1;l.getRowModel().forEachNode((n,o)=>{n.id===i.id&&(s=o)}),s>=0&&l.getRowRenderer().ensureIndexVisible(s)},ensureColumnVisible:i=>{const s=typeof i=="string"?l.getColumn(i):i;s&&l.getRowRenderer().ensureColumnVisible(s)},copyToClipboard:i=>l.getExportService().copyToClipboard(i),cutToClipboard:i=>l.getExportService().cutToClipboard(i),pasteFromClipboard:()=>l.getExportService().pasteFromClipboard(),exportToCsv:i=>l.getExportService().exportToCsv(i||{}),exportToExcel:i=>l.getExportService().exportToExcel(i||{}),exportToPdf:i=>l.getExportService().exportToPdf(i||{}),importExcel:(i,s)=>l.getExportService().importExcel(i,s||{}),getDataAsPdf:i=>l.getExportService().getDataAsPdf(i||{}),getDataAsCsv:i=>l.getExportService().getDataAsCsv(i||{}),getDataAsExcel:i=>l.getExportService().getDataAsExcel(i||{}),getChartData:i=>l.getChartService().getChartData(i||{}),getChartModels:()=>l.getChartService().getChartModels(),createChart:()=>l.getChartService().createChart(),getCellRanges:()=>l.getRangeSelectionService().getRanges(),clearRangeSelection:()=>l.getRangeSelectionService().clearRanges(),addCellRange:i=>{const s=l.getRangeSelectionService();s.ranges=[i],s.applyHighlight(),s.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>l.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>l.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>l.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>l.getOverlayService().hideOverlay(),setServerSideDatasource:i=>{const s=l.getServerSideRowModel();s&&s.setDatasource(i)},setDatasource:i=>{var n;const s=l.getInfiniteRowModel();s?s.setDatasource(i):(n=l.getServerSideRowModel())==null||n.setDatasource(i)},setViewportDatasource:i=>{var s;(s=l.getViewportRowModel())==null||s.setViewportDatasource(i)},setViewportRange:(i,s)=>{var n;(n=l.getViewportRowModel())==null||n.setViewportRange(i,s)},refreshServerSide:i=>{const s=l.getServerSideRowModel();s&&(i!=null&&i.purge?s.purgeCache():s.onSortOrFilterChanged())},purgeServerSideCache:()=>{var i,s;(i=l.getServerSideRowModel())==null||i.purgeCache(),(s=l.getInfiniteRowModel())==null||s.onSortOrFilterChanged()},getServerSideStoreState:()=>{const i=l.getServerSideRowModel();if(!i)return[];const s=[];for(const[n,o]of i.stores)s.push({groupPath:n,rowCount:o.rows.length,lastRow:o.lastRow,loading:o.loading});return s},setRowCount:(i,s)=>{const n=l.getServerSideRowModel();if(!n)return;const o=n.getStore("");if(o)for(o.lastRow=s?i:null;o.rows.length<i;)o.rows.push(null);n.refreshModel("everything")},isServerSideStoreLoading:()=>l.isRemoteLoading(),undoCellEditing:()=>l.getUndoRedoService().undo(),redoCellEditing:()=>l.getUndoRedoService().redo(),canUndo:()=>l.getUndoRedoService().canUndo(),canRedo:()=>l.getUndoRedoService().canRedo(),getUndoRedoStackSize:()=>({undo:l.getUndoRedoService().getUndoStackSize(),redo:l.getUndoRedoService().getRedoStackSize()}),startBatchEdit:()=>l.getUndoRedoService().startBatchEdit(),endBatchEdit:i=>l.getUndoRedoService().endBatchEdit(i),cancelBatchEdit:()=>l.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>l.getUndoRedoService().isBatchEditing(),getState:()=>{const i=l.getColumnApi(),s=l.getSelectionService(),n=l.getPaginationService();return{columns:i.getColumnState(),sort:l.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(l.getFilterService().getFilterModel())),quickFilter:l.getQuickFilter(),selectedRowIds:s.getSelectedNodes().map(o=>o.id),pagination:n!=null&&n.isEnabled()?{page:n.getCurrentPage(),pageSize:n.getPageSize()}:null,rowGroupColumns:l.getColumnModel().getRowGroupColumns().map(o=>o.colId),pivotMode:l.getColumnModel().isPivotMode()}},setState:i=>{if(!i)return;const s=l.getColumnApi();if(i.columns&&s.applyColumnState(i.columns,!0),i.sort&&l.getSortService().setSortModel(i.sort),i.filter&&l.getFilterService().setFilterModel(i.filter),i.quickFilter!==void 0&&l.setQuickFilter(i.quickFilter),i.rowGroupColumns&&l.getColumnModel().setRowGroupColumns(i.rowGroupColumns),i.pivotMode!==void 0&&l.getColumnModel().setPivotMode(i.pivotMode),i.selectedRowIds){l.getSelectionService().deselectAll();for(const o of i.selectedRowIds){const a=l.getRowNode(o);a&&l.getSelectionService().selectNode(a,!1)}}const n=l.getPaginationService();n&&i.pagination&&(n.setPageSize(i.pagination.pageSize),n.goToPage(i.pagination.page))},setNote:(i,s,n)=>{const o=typeof s=="string"?s:s.colId;l.getNotesService().setNote(i.id,o,n)},getNote:(i,s)=>{const n=typeof s=="string"?s:s.colId,o=l.getColumn(n);return l.getNotesService().getNote(i.id,n,o==null?void 0:o.colDef.note,{data:i.data,node:i,column:o,api:l.getApi()})},getGridId:()=>"rowvia",destroy:()=>l.destroy(),refreshClientSideRowModel:()=>l.refreshModel("everything"),setPivotMode:i=>l.getColumnModel().setPivotMode(i),isPivotMode:()=>l.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>l.getAllColumns(),getColumn:i=>l.getColumn(i)??null,getColumnState:()=>l.getColumnModel().getColumnState(),applyColumnState:(i,s)=>{l.getColumnModel().applyColumnState(i,s),l.refreshModel("group")},resetColumnState:()=>{l.getColumnModel().resetColumnState(),l.refreshModel("group")},setColumnVisible:(i,s)=>l.getColumnModel().setColumnVisible(i,s),setColumnsVisible:(i,s)=>l.getColumnModel().setColumnsVisible(i,s),setColumnPinned:(i,s)=>l.getColumnModel().setColumnPinned(i,s),setColumnsPinned:(i,s)=>l.getColumnModel().setColumnsPinned(i,s),moveColumn:(i,s)=>l.getColumnModel().moveColumn(i,s),moveColumnByIndex:(i,s)=>l.getColumnModel().moveColumnByIndex(i,s),autoSizeColumn:i=>{l.getColumnModel().autoSizeColumn(i),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{l.getColumnModel().autoSizeAllColumns(),l.getHeaderView().updateIndicators(),l.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(i,s)=>l.getColumnModel().setRowGroupColumns(i,s),removeRowGroupColumns:i=>{for(const s of i)l.getColumnModel().removeRowGroupColumn(s)},addRowGroupColumn:i=>l.getColumnModel().addRowGroupColumn(i),setPivotColumns:i=>l.getColumnModel().setPivotColumns(i),removePivotColumns:i=>l.getColumnModel().setPivotColumns(i.map(()=>"").filter(s=>s!=="")),setValueColumns:i=>l.getColumnModel().setValueColumns(i),removeValueColumn:i=>l.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>l.getColumnModel().getRowGroupColumns(),getValueColumns:()=>l.getColumnModel().getValueColumns(),getPivotColumns:()=>l.getColumnModel().getPivotColumns(),setPivotMode:(i,s)=>l.getColumnModel().setPivotMode(i,s),isPivotMode:()=>l.getColumnModel().isPivotMode()}}}const Ls={rowHeight:42,headerHeight:48,floatingFiltersHeight:24,groupHeaderHeight:48,pivotHeaderHeight:48,rowBuffer:10,detailRowHeight:200,animateRows:!0,enableCellChangeFlash:!0,rowSelection:void 0,sortingOrder:["asc","desc",null],enterNavigatesVerticallyAfterEdit:!0,treeDataChildrenField:"children",suppressClickEdit:!1};class Re{constructor(e,t){u(this,"options");u(this,"eventService",new se);u(this,"columnModel");u(this,"rowModel");u(this,"clientSideRowModel",null);u(this,"serverSideRowModel",null);u(this,"infiniteRowModel",null);u(this,"viewportRowModel",null);u(this,"rowRenderer");u(this,"headerView");u(this,"selectionService");u(this,"editService");u(this,"filterService");u(this,"sortService");u(this,"paginationService",null);u(this,"popupService");u(this,"filterGui");u(this,"contextMenuService");u(this,"columnMenuService");u(this,"statusBarService");u(this,"sideBarService");u(this,"findService");u(this,"rangeSelectionService");u(this,"chartService");u(this,"overlayService");u(this,"exportService");u(this,"rowGroupPanel",null);u(this,"undoRedoService");u(this,"formulaEditorService");u(this,"notesService");u(this,"rowDragService");u(this,"api");u(this,"columnApi");u(this,"localeText");u(this,"rowNodeServices");u(this,"eGridDiv");u(this,"eRoot");u(this,"eMain");u(this,"eHeader");u(this,"quickFilter","");u(this,"resizeObserver",null);u(this,"destroyed",!1);u(this,"gridReadyDispatched",!1);u(this,"context");u(this,"onWindowResize",()=>{this.onGridSizeChanged()});u(this,"onDocumentMouseDown",e=>{var i;const t=e.target;if(t&&this.eRoot.contains(t)){const s=(i=t.closest)==null?void 0:i.call(t,".ag-cell");if(!s){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!s.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var d,c,h,g;this.eGridDiv=e,this.options={...Ls,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=wi(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const i=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(i),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),this.eMain=document.createElement("div"),this.eMain.className="ag-main",this.eRoot.appendChild(this.eMain),this.eHeader=document.createElement("div"),this.eHeader.className="ag-header-wrapper",this.eMain.appendChild(this.eHeader),this.rowNodeServices={selectNode:(p,m)=>this.selectionService.selectNode(p,m),deselectNode:p=>this.selectionService.deselectNode(p),isNodeSelected:p=>this.selectionService.isNodeSelected(p)},this.columnModel=new xt(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new ji(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),p=>this.isNodeSelectable(p)),this.filterService=new Qi(this),this.sortService=new Zi(this),this.popupService=new Ji(this),this.filterGui=new es(this,this.popupService),this.contextMenuService=new ts(this,this.popupService),this.columnMenuService=new is(this,this.popupService),this.editService=new Yi(this,this.eventService),this.undoRedoService=new Ms(this,this.eventService),this.formulaEditorService=new Ns(this,this.popupService),this.notesService=new Ts(this,this.popupService),this.rowDragService=new Is(this,this.eventService),this.chartService=new rs(this,this.popupService),this.findService=new os(this,this.popupService),this.exportService=new Es(this);const s={options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getSortModel:()=>this.sortService.getSortModel(),getFilterModel:()=>this.filterService.getFilterModel(),rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices},n=this.options.rowModelType||"clientSide";n==="serverSide"?(this.serverSideRowModel=new Si(s),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):n==="infinite"?(this.infiniteRowModel=new xi(s),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):n==="viewport"?(this.viewportRowModel=new bi(s),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new gi({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var p;return!!((p=this.paginationService)!=null&&p.isEnabled())},getPageSize:()=>{var p;return((p=this.paginationService)==null?void 0:p.getPageSize())??100},getCurrentPage:()=>{var p;return((p=this.paginationService)==null?void 0:p.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(c=(d=this.rowModel).setGridApi)==null||c.call(d,null)),this.headerView=new Xi(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(p=>p.sort)}),onSortRequested:(p,m,f)=>this.sortService.onSortRequested(p,m,f),onColumnResized:(p,m,f)=>this.onColumnResized(p,m,f),onColumnMoved:(p,m)=>this.onColumnMoved(p,m),onColumnMenuClicked:(p,m)=>this.columnMenuService.openColumnMenu(p,m),onFilterOpened:(p,m)=>this.filterGui.openFilter(p,m),isFilterActive:p=>this.filterService.isFilterActive(p),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(p,m)=>this.filterService.handleFloatingFilterChange(p,m),onHeaderCheckboxChanged:(p,m)=>this.onHeaderCheckboxChanged(p,m),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:p=>this.t(p),getApi:()=>this.api,getFilterModel:p=>this.filterService.getFilterInstance(p)??null,onFilterModelChange:(p,m)=>this.filterService.setColumnFilterModel(p,m)}),this.rowRenderer=new Ki(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:p=>this.t(p),getColumns:()=>this.getColumns(),getRowHeight:p=>this.getRowHeight(p),isNodeSelected:p=>this.selectionService.isNodeSelected(p),isRowSelectable:p=>this.isNodeSelectable(p),getRowClass:p=>this.getRowClass(p),getRowStyle:p=>this.getRowStyle(p),onCellClicked:p=>this.onCellClicked(p),onCellDoubleClicked:p=>this.editService.onCellDoubleClicked(p),onCellMouseDown:p=>this.onCellMouseDown(p),onCellContextMenu:p=>this.onCellContextMenu(p),onRowClicked:p=>this.onRowClicked(p),onRowDoubleClicked:p=>this.onRowDoubleClicked(p),onRowGroupClicked:p=>this.onRowGroupClicked(p),onViewportKeyDown:p=>this.onViewportKeyDown(p),onViewportScroll:()=>{var f,v,C;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const p=this.rowRenderer.getFirstVisibleRowIndex(),m=this.rowRenderer.getLastVisibleRowIndex();(f=this.serverSideRowModel)==null||f.onViewportChanged(p,m),(v=this.infiniteRowModel)==null||v.onViewportChanged(p,m),(C=this.viewportRowModel)==null||C.onViewportChanged(p,m)},getCellText:(p,m)=>{const f=H(p,m,this.api);return f==null?"":String(f)},renderDetailRow:p=>this.renderDetailRow(p),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(p,m,f)=>this.rowDragService.startDrag(p,f),getNote:(p,m,f,v)=>this.notesService.getNote(p,m,f,v),onNoteClick:(p,m,f)=>this.notesService.openNoteEditor(p,m,f),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new ls(this,this.eventService),this.statusBarService=new ss(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new as(this),this.sideBarService=new ns(this),this.sideBarService.getElement().classList.contains("ag-side-bar-left")?this.eRoot.insertBefore(this.sideBarService.getElement(),this.eMain):this.eRoot.appendChild(this.sideBarService.getElement()),this.options.pagination&&(this.paginationService=new kt(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Rs(this));const{api:o,columnApi:a}=ks(this);this.api=o,this.columnApi=a,this.columnModel.setGridApi(this.api),(g=(h=this.rowModel).setGridApi)==null||g.call(h,this.api),this.selectionService.gridApiRef=this.api,this.eventService.addEventListener("columnEverythingChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("displayedColumnsChanged",()=>this.onColumnsChanged()),this.eventService.addEventListener("columnRowGroupChanged",()=>{this.serverSideRowModel||this.infiniteRowModel?this.onRemoteModelChanged():this.rowModel.refreshModel("group")}),this.options.__advancedFilterPass=p=>this.filterService.doesNodePassAdvancedFilter(p),this.eventService.addEventListener("columnPivotModeChanged",()=>this.refreshPivotColumns()),this.eventService.addEventListener("modelUpdated",()=>{this.columnModel.isPivotMode()&&this.refreshPivotColumns()}),this.eventService.addEventListener("sortChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("filterChanged",()=>this.onRemoteModelChanged()),this.eventService.addEventListener("columnValueChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("columnPivotModeChanged",()=>this.rowModel.refreshModel("group")),this.eventService.addEventListener("modelUpdated",()=>this.onModelUpdated()),this.eventService.addEventListener("selectionChanged",()=>{var p,m;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(m=(p=this.options).onSelectionChanged)==null||m.call(p,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let r=this.options.columnDefs||[];(!r||r.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(r=xt.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const i=this.localeText.t(e);return i===e?t:i}getContext(){return this.context}getEventService(){return this.eventService}getColumnModel(){return this.columnModel}getRowModel(){return this.rowModel}getRowRenderer(){return this.rowRenderer}getHeaderView(){return this.headerView}getSelectionService(){return this.selectionService}getEditService(){return this.editService}getFilterService(){return this.filterService}getSortService(){return this.sortService}getFilterGui(){return this.filterGui}getPaginationService(){return this.paginationService}getSideBarService(){return this.sideBarService}getChartService(){return this.chartService}getFindService(){return this.findService}getRangeSelectionService(){return this.rangeSelectionService}getExportService(){return this.exportService}getPopupService(){return this.popupService}getOverlayService(){return this.overlayService}getRowGroupPanel(){return this.rowGroupPanel}getUndoRedoService(){return this.undoRedoService}getFormulaEditorService(){return this.formulaEditorService}getNotesService(){return this.notesService}getRowDragService(){return this.rowDragService}getServerSideRowModel(){return this.serverSideRowModel}getInfiniteRowModel(){return this.infiniteRowModel}getViewportRowModel(){return this.viewportRowModel}updateColumnTotalCache(){var i,s;const e=new Map,t=this.getAllColumns().filter(n=>n.colDef.showValueAs);if(t.length>0){const n=new Map;(s=(i=this.rowModel).forEachLeafNode)==null||s.call(i,o=>{for(const a of t){const r=H(a,o,this.api);typeof r=="number"&&!isNaN(r)&&n.set(a.colId,(n.get(a.colId)??0)+r)}});for(const o of t)e.set(o.colId,n.get(o.colId)??0)}this.api.__columnTotalCache=e}refreshPivotColumns(){this.columnModel.updatePivotColumns(this.options.rowData||[])}onRemoteModelChanged(){this.serverSideRowModel?this.serverSideRowModel.onSortOrFilterChanged():this.infiniteRowModel?this.infiniteRowModel.onSortOrFilterChanged():this.viewportRowModel&&this.viewportRowModel.setViewportDatasource(this.viewportRowModel.datasource)}isRemoteLoading(){var e,t,i;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(t=this.infiniteRowModel)!=null&&t.isLoading()||(i=this.viewportRowModel)!=null&&i.isLoading())}getApi(){return this.api}getColumnApi(){return this.columnApi}getRootElement(){return this.eRoot}getMainElement(){return this.eMain}getHeaderElement(){return this.eHeader}getGridDiv(){return this.eGridDiv}getColumns(){return this.columnModel.getDisplayedColumnsByType()}getAllColumns(){return this.columnModel.getAllColumns()}getColumn(e){return this.columnModel.getColumn(e)}getDisplayedRowCount(){return this.rowModel.getRowCount()}getDisplayedRowAtIndex(e){return this.rowModel.getRow(e)}getRowNode(e){return this.rowModel.getRowNode(e)}getRowHeight(e){if(e.rowHeight!==null)return e.rowHeight;const t=this.options.getRowHeight;if(typeof t=="function"){const i=t({data:e.data,node:e,api:this.api});if(i)return i}return this.options.rowHeight??42}getRowClass(e){const t=[];if(this.options.rowClass&&t.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const i=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof i=="string"?t.push(i):Array.isArray(i)&&t.push(...i)}return e.footer&&t.push("ag-row-footer"),t.join(" ")}getRowStyle(e){const t={};return this.options.rowStyle&&Object.assign(t,this.options.rowStyle),typeof this.options.getRowStyle=="function"&&Object.assign(t,this.options.getRowStyle({data:e.data,node:e,api:this.api})),t}isNodeSelectable(e){if(e.footer||e.masterNode)return!1;const t=this.options.isRowSelectable;return!(t&&!t(e))}isCellEditable(e,t){return this.options.readOnlyEdit||t.group||t.footer||t.masterNode?!1:typeof e.editable=="function"?e.editable({data:t.data,node:t,column:e,colDef:e.colDef,api:this.api}):e.editable===!0}setRowData(e,t=!1){var i,s,n;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),t||(this.overlayService.updateAuto(),this.statusBarService.update(),(i=this.paginationService)==null||i.update(),this.chartService.refreshCharts(),(n=(s=this.options).onRowDataChanged)==null||n.call(s,{api:this.api}))}applyTransaction(e){var i;const t=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(i=this.paginationService)==null||i.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),t}setCellValue(e,t,i,s="api",n){const o=n!==void 0?n:H(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:H(e,t,this.api),newValue:i,data:t.data,node:t,column:e,api:this.api,colDef:e.colDef})===!1)return}else t.setDataValue(e.colId,i);e.rowGroup&&this.rowModel.refreshModel("group"),(s==="edit"||s==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:o,newValue:i,batchId:0}),s!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:i,value:i,data:t.data,node:t,column:e,colDef:e.colDef,api:this.api,source:s})}refreshModel(e){var t;this.rowModel.refreshModel(e),(t=this.paginationService)==null||t.update()}refreshCells(e){this.rowRenderer.refreshCells(e)}setQuickFilter(e){this.quickFilter=e||"",this.refreshModel("filter"),this.findService.applyHighlight()}getQuickFilter(){return this.quickFilter}setRowNodePinned(e,t){e.rowPinned=t,this.rowModel.refreshModel("everything")}openFind(){this.findService.open()}closeFind(){this.findService.close()}onCellClicked(e){var o,a,r,d;const{node:t,column:i,event:s}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(a=(o=this.options).onCellClicked)==null||a.call(o,{...e,api:this.api,colDef:i.colDef,value:H(i,t,this.api)});return}if(s.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,s),this.editService.onCellClicked(e),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:i.colDef,value:H(i,t,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var t,i;this.selectionService.handleRowClick(e.node,e.event),(i=(t=this.options).onRowClicked)==null||i.call(t,{...e,api:this.api})}onRowDoubleClicked(e){var t,i;(i=(t=this.options).onRowDoubleClicked)==null||i.call(t,{...e,api:this.api})}onCellContextMenu(e){var i,s;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(s=(i=this.options).onCellContextMenu)==null||s.call(i,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,i,s,n,o;if(e.group){const a=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);a&&a(e,!e.expanded),globalThis.__dbgLogs.push(["after-toggle",e.id,"expanded=",e.expanded]),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(s=(i=this.options).onRowGroupOpened)==null||s.call(i,{node:e,expanded:e.expanded,api:this.api})}else e.detailNode?(e.expanded=!e.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e,expanded:e.expanded,api:this.api}),(o=(n=this.options).onRowGroupOpened)==null||o.call(n,{node:e,expanded:e.expanded,api:this.api})):e.masterNode&&(e.masterNode.expanded=!e.masterNode.expanded,this.rowModel.refreshModel("expand"),this.eventService.dispatchEvent("rowGroupOpened",{node:e.masterNode,expanded:e.masterNode.expanded,api:this.api}))}onHeaderCheckboxChanged(e,t){var i;if(e.headerCheckboxSelectionCurrentPageOnly&&((i=this.paginationService)!=null&&i.isEnabled())){const s=this.rowModel.getRowCount();if(t)for(let n=0;n<s;n++){const o=this.rowModel.getRow(n);o&&this.isNodeSelectable(o)&&this.selectionService.selectNode(o,!1)}else for(let n=0;n<s;n++){const o=this.rowModel.getRow(n);o&&this.selectionService.deselectNode(o)}}else this.selectionService.setSelectAllCheckboxState(t);this.updateHeaderCheckboxes()}updateHeaderCheckboxes(){for(const e of this.getAllColumns()){if(!e.headerCheckboxSelection)continue;const t=e.eHeaderCell;if(!t)continue;const i=t.querySelector(".ag-header-select-all");if(!i)continue;const s=this.selectionService.getSelectAllState();i.checked=s.checked,i.indeterminate=s.indeterminate}}onViewportKeyDown(e){if(this.editService.onGridKeyDown(e),this.rangeSelectionService.onGridKeyDown(e),(e.ctrlKey||e.metaKey)&&(e.key==="z"||e.key==="Z")){e.preventDefault(),e.shiftKey?this.undoRedoService.redo():this.undoRedoService.undo();return}if((e.ctrlKey||e.metaKey)&&(e.key==="y"||e.key==="Y")){e.preventDefault(),this.undoRedoService.redo();return}(e.ctrlKey||e.metaKey)&&(e.key==="c"||e.key==="C")&&this.rangeSelectionService.getRanges().length===0&&this.selectionService.getSelectedNodes().length>0&&(e.preventDefault(),this.api.copyToClipboard()),(e.ctrlKey||e.metaKey)&&(e.key==="v"||e.key==="V")&&this.rangeSelectionService.getRanges().length===0&&(e.preventDefault(),this.api.pasteFromClipboard())}onColumnResized(e,t,i){e.width=t,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),i&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,t){const i=this.columnModel.getColumns(),s=i.findIndex(o=>o.colId===e);if(s<0)return;let n=i.length;t&&(n=i.findIndex(o=>o.colId===t)),this.columnModel.moveColumnByIndex(s,n,"uiColumnMoved")}onColumnsChanged(){var e,t;this.headerView.refresh(),this.rowRenderer.refreshRows(),this.updateHeaderCheckboxes(),(t=(e=this.options).onDisplayedColumnsChanged)==null||t.call(e,{api:this.api})}onModelUpdated(){var e,t,i,s,n,o,a;this.updateColumnTotalCache(),this.rowRenderer.refreshRows(),this.options.__loadingRows=this.isRemoteLoading(),this.overlayService.updateAuto(),this.statusBarService.update(),(e=this.paginationService)==null||e.update(),this.rangeSelectionService.applyHighlight(),this.findService.applyHighlight(),this.chartService.refreshCharts(),this.gridReadyDispatched||(this.gridReadyDispatched=!0,this.eventService.dispatchEvent("firstDataRendered",{api:this.api}),(i=(t=this.options).onFirstDataRendered)==null||i.call(t,{api:this.api})),(n=(s=this.options).onModelUpdated)==null||n.call(s,{api:this.api}),(a=(o=this.options).onRowDataChanged)==null||a.call(o,{api:this.api})}onGridSizeChanged(){var n,o,a;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),i=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,s=Math.max(0,e-i);(t||((n=this.options.autoSizeStrategy)==null?void 0:n.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(s),this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows()),this.rowRenderer.renderVisibleRows(!0),this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth()),this.eventService.dispatchEvent("gridSizeChanged",{clientWidth:this.eGridDiv.clientWidth,clientHeight:this.eGridDiv.clientHeight,api:this.api}),(a=(o=this.options).onGridSizeChanged)==null||a.call(o,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const t=e.masterNode;if(!t)return null;const i=this.options.detailRowAutoHeight===!0,s=i?this.options.detailRowHeight??200:this.options.detailRowHeight??200,n=document.createElement("div");n.className="ag-row-detail",n.style.height=`${s}px`,n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.right="0";const o=this.options.detailCellRenderer,a=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(a&&r){const h=r({data:t.data,node:t,api:this.api}),g=document.createElement("div");g.style.height="100%",g.style.padding="8px 16px",n.appendChild(g),setTimeout(()=>{new Re(g,{...a,rowData:h,theme:this.options.theme})},0)}else if(typeof o=="function"){const h=o({data:t.data,node:t,api:this.api,context:this.context});h instanceof HTMLElement?n.appendChild(h):n.textContent=String(h??"")}else typeof o=="string"&&(n.textContent=o);if(i){const h=Math.max(40,n.scrollHeight||s);return e.rowHeight=h,n.style.height=`${h}px`,{eDetail:n,height:h}}return e.rowHeight=s,{eDetail:n,height:s}}dispatchGridReady(){var e,t;this.eventService.dispatchEvent("gridReady",{api:this.api,columnApi:this.columnApi}),(t=(e=this.options).onGridReady)==null||t.call(e,{api:this.api,columnApi:this.columnApi,context:this.context})}updateGridOptions(e){const t=this.options.theme,i=e.rowData!==void 0&&e.rowData!==this.options.rowData,s=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),i&&this.setRowData(e.rowData),s&&this.columnModel.setColumnDefs(this.options.columnDefs||[]),e.sideBar!==void 0&&(this.sideBarService.setVisible(!!e.sideBar),this.onGridSizeChanged()),e.quickFilterText!==void 0&&this.setQuickFilter(e.quickFilterText),e.theme!==void 0&&e.theme!==t&&(this.eGridDiv.classList.remove(t||"ag-theme-alpine"),this.eGridDiv.classList.add(e.theme)),e.pagination!==void 0&&(e.pagination&&!this.paginationService?this.paginationService=new kt(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,window.removeEventListener("resize",this.onWindowResize),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0),(e=this.resizeObserver)==null||e.disconnect(),this.rowRenderer.destroy(),this.editService.destroy(),this.popupService.closeAll(),this.eRoot.remove(),this.eGridDiv.classList.remove("ag-grid-root","ag-theme-alpine","ag-theme-quartz","ag-theme-balham"),this.eventService.dispatchEvent("gridReady",{}))}}function Gt(l){const e=document.createElement("dialog");e.className="rowvia-detail-dialog";const t=document.createElement("h2"),i=document.createElement("dl"),s=document.createElement("button");s.type="button",s.textContent="关闭";const n=()=>e.close();return s.addEventListener("click",n),e.append(t,i,s),l.append(e),{open(o){t.textContent=o.title,e.setAttribute("aria-label",o.title),i.replaceChildren();for(const a of o.fields){const r=document.createElement("dt"),d=document.createElement("dd");r.textContent=a.label,d.textContent=a.value,i.append(r,d)}e.open||e.showModal()},close:n,destroy(){e.open&&e.close(),s.removeEventListener("click",n),e.remove()}}}const $t=864e5;function ce(l){const e=l.getFullYear(),t=String(l.getMonth()+1).padStart(2,"0"),i=String(l.getDate()).padStart(2,"0");return`${e}-${t}-${i}`}function ie(l){return new Date(`${l}T00:00:00`)}function Q(l,e){return new Date(l.getTime()+e*$t)}function de(l,e){const t=typeof l=="string"?ie(l):l,i=typeof e=="string"?ie(e):e;return Math.round((i.getTime()-t.getTime())/$t)}function Ge(){return ce(new Date)}function Ds(l){return l.status!=="done"&&l.end&&l.end<Ge()&&l.progress<100?"delayed":l.status}function nt(l){const e=ie(l);return`${e.getMonth()+1}月${e.getDate()}日`}const Ht=["day","week","biweek","month","bimonth","quarter","halfyear","year"],qe={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Fs={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2},Y={accent:"#4555e5",text:"#1f2329",textTertiary:"#8f959e",border:"#dee0e3",groupRow:"transparent",weekend:"rgba(31, 35, 41, 0.04)",gridline:"rgba(31, 35, 41, 0.10)",gridlineMonth:"rgba(31, 35, 41, 0.12)",rowLine:"transparent",hover:"rgba(51, 112, 255, 0.05)",selected:"rgba(51, 112, 255, 0.09)"},Ke={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},Ps=4,Ot=6,oe=28;function ot(l){const e=(l.getDay()+6)%7;return Q(l,-e)}function As(l,e){const t=Math.max(1,de(l,e)+1);let i=0;for(let s=0;s<t;s++){const n=Q(l,s).getDay();n!==0&&n!==6&&i++}return Math.max(1,i)}function Gs(l,e){return new Date(l.getFullYear(),l.getMonth()+e,1)}function Bt(l,e,t){const i=[];if(l==="day"){let r=new Date(e);for(;r<t;){const d=Q(r,1);i.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return i}if(l==="week"||l==="biweek"){let r=ot(e);for(;r<t;){const d=Q(r,l==="biweek"?14:7);i.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return i}const s=l==="month"?1:l==="bimonth"?2:l==="quarter"?3:l==="halfyear"?6:12,n=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/s)*s,1),o=r=>l==="month"||l==="bimonth"?`${r.getMonth()+1}月`:l==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:l==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let a=n(e);for(;a<t;){const r=Gs(a,s);i.push({start:new Date(a),end:r,primary:o(a),secondary:""}),a=r}return i}class Vt{constructor(e,t){u(this,"options");u(this,"eRoot");u(this,"eHeader");u(this,"eRuler");u(this,"rulerCtx");u(this,"eRulerTools");u(this,"eStepLabel");u(this,"eZoomValue");u(this,"eStepMenu",null);u(this,"eScroll");u(this,"eSpacer");u(this,"eCanvas");u(this,"ctx");u(this,"eTooltip");u(this,"eTodayBadge");u(this,"ePopup",null);u(this,"tasks",[]);u(this,"tasksById",new Map);u(this,"rows",[]);u(this,"selectedId",null);u(this,"hoverId",null);u(this,"unit","day");u(this,"zoom",1);u(this,"theme","content");u(this,"epochStart",new Date);u(this,"totalDays",1);u(this,"hits",[]);u(this,"hitsByRow",new Map);u(this,"drag",null);u(this,"ghost",null);u(this,"dirty",!0);u(this,"lastLeft",-1);u(this,"lastTop",-1);u(this,"timer");u(this,"observer",null);u(this,"resizeHandler",()=>this.resizeCanvases());u(this,"showChildren",!0);u(this,"milestonesOnly",!1);u(this,"locateHits",[]);u(this,"tick",()=>{const e=this.eScroll.scrollLeft,t=this.eScroll.scrollTop;(e!==this.lastLeft||t!==this.lastTop||this.dirty)&&(this.lastLeft=e,this.lastTop=t,this.eCanvas.style.transform=`translate(${e}px, ${t}px)`,this.draw(),this.dirty=!1)});u(this,"onScroll",()=>{this.tick()});u(this,"todayLabelX",-1);u(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:i,onAvatar:s}=this.hitAt(e.clientX,e.clientY),n=this.rows[i];s?this.eCanvas.style.cursor="pointer":t&&t.mode!=="move"?this.eCanvas.style.cursor="ew-resize":t?this.eCanvas.style.cursor="grab":this.eCanvas.style.cursor="default";const o=t?t.id:(n==null?void 0:n.id)??null;o!==this.hoverId&&(this.hoverId=o,this.options.onHover(o),this.markDirty())});u(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),i=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-t.left))<12&&Math.abs(d.y-(e.clientY-t.top))<12);if(i){this.scrollToTask(i.id);return}const{hit:s,rowIndex:n,onAvatar:o}=this.hitAt(e.clientX,e.clientY),a=this.rows[n];if(s){const d=this.tasksById.get(s.id);if(!d)return;if(o){e.stopPropagation(),this.openAssigneePopup(s.id,s);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(s.id);return}e.preventDefault(),this.drag={id:s.id,mode:s.mode,startX:e.clientX,startY:e.clientY,originStart:d.start,originEnd:d.end,start:d.start,end:d.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(s.id);return}if(!a)return;const r=this.tasksById.get(a.id);if(r){if(r.kind==="task"&&(!r.start||!r.end)){const d=this.pointAt(e.clientX,e.clientY),c=Math.floor(d.x/this.dayWidth),h=ce(Q(this.epochStart,c));this.options.onTaskChange({...r,start:h,end:ce(Q(ie(h),4)),progress:0,status:"not-started"}),this.options.onSelect(a.id);return}this.options.onSelect(a.id)}});u(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const i=this.tasksById.get(t.id);if(!i||!t.moved&&Math.abs(e.clientX-t.startX)<Ps)return;t.moved=!0;const s=this.dayWidth,n=Math.round((e.clientX-t.startX)/s),o=ie(t.originStart),a=ie(t.originEnd),r=de(o,a);let d,c;t.mode==="resize-l"?(d=Q(o,Math.min(n,r)),c=a):t.mode==="resize-r"?(d=o,c=Q(a,Math.max(n,-r))):(d=Q(o,n),c=Q(a,n)),i.milestone&&(d=c),t.start=ce(d),t.end=ce(c),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?nt(t.start):`${nt(t.start)} → ${nt(t.end)}`;const h=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-h.left+12}px`,this.eTooltip.style.top=`${e.clientY-h.top+16}px`});u(this,"endDrag",()=>{window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.eTooltip.style.display="none";const e=this.drag;if(this.drag=null,this.ghost=null,this.markDirty(),!(e!=null&&e.moved)||e.start===e.originStart&&e.end===e.originEnd)return;const t=this.tasksById.get(e.id);t&&this.options.onTaskChange({...t,start:e.start,end:e.end})});u(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});u(this,"onDocumentMouseDown",e=>{const t=e.target;this.ePopup&&!this.ePopup.contains(t)&&this.closeAssigneePopup(),this.eStepMenu&&!this.eStepMenu.contains(t)&&!this.eRulerTools.contains(t)&&this.closeStepMenu()});this.options=t,this.eRoot=document.createElement("div"),this.eRoot.className="gt-root",e.appendChild(this.eRoot),this.eHeader=document.createElement("div"),this.eHeader.className="gt-header",this.eRuler=document.createElement("canvas"),this.eRuler.className="gt-ruler",this.eHeader.appendChild(this.eRuler),this.eRoot.appendChild(this.eHeader),this.rulerCtx=this.eRuler.getContext("2d"),this.buildRulerTools(),this.eScroll=document.createElement("div"),this.eScroll.className="gt-scroll",this.eSpacer=document.createElement("div"),this.eSpacer.className="gt-spacer",this.eCanvas=document.createElement("canvas"),this.eCanvas.className="gt-canvas",this.eScroll.append(this.eSpacer,this.eCanvas),this.eRoot.appendChild(this.eScroll),this.ctx=this.eCanvas.getContext("2d"),this.eTooltip=document.createElement("div"),this.eTooltip.className="gt-tooltip",this.eTooltip.style.display="none",this.eRoot.appendChild(this.eTooltip),this.eTodayBadge=document.createElement("div"),this.eTodayBadge.className="gt-today-badge",this.eRoot.appendChild(this.eTodayBadge),this.eScroll.addEventListener("scroll",this.onScroll),this.eCanvas.addEventListener("mousedown",this.onCanvasMouseDown),this.eCanvas.addEventListener("mousemove",this.onCanvasMouseMove),this.eRoot.addEventListener("mouseleave",this.onRootMouseLeave);const i=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(i),this.observer.observe(this.eScroll),this.observer.observe(this.eHeader)),window.addEventListener("resize",this.resizeHandler),this.timer=setInterval(this.tick,40),this.resizeCanvases()}destroy(){var e;clearInterval(this.timer),(e=this.observer)==null||e.disconnect(),window.removeEventListener("resize",this.resizeHandler),window.removeEventListener("mousemove",this.updateDrag),window.removeEventListener("mouseup",this.endDrag),this.closeAssigneePopup(),this.closeStepMenu(),this.eRoot.remove()}setHover(e){this.hoverId=e,this.markDirty()}setShowChildren(e){this.showChildren=e,this.markDirty()}setMilestonesOnly(e){this.milestonesOnly=e,this.markDirty()}scrollToTask(e){const t=this.tasksById.get(e);t!=null&&t.start&&(this.eScroll.scrollLeft=Math.max(0,this.dateX(t.start)-this.eScroll.clientWidth*.12),this.markDirty())}setTasks(e){this.tasks=e,this.tasksById=new Map(e.map(t=>[t.id,t])),this.computeDomain(),this.markDirty()}setRows(e){this.rows=e,this.markDirty()}setSelected(e){this.selectedId=e,this.markDirty()}setUnit(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.unit=e,this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setZoom(e){const t=(this.eScroll.scrollLeft+this.eScroll.clientWidth/2)/this.dayWidth;this.zoom=Math.max(.5,Math.min(3,e)),this.markDirty(),this.eScroll.scrollLeft=Math.max(0,t*this.dayWidth-this.eScroll.clientWidth/2),this.tick()}setTheme(e){this.theme=e,this.markDirty()}get dayWidth(){return Fs[this.unit]*this.zoom}get scrollElement(){return this.eScroll}setScrollTop(e){this.eScroll.scrollTop=e}redraw(){this.markDirty()}markDirty(){this.dirty=!0,this.tick()}scrollToToday(e=.32){const t=this.dateX(Ge()),i=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=i}computeDomain(){let e=null,t=null;for(const n of this.tasks)!n.start||!n.end||((!e||n.start<e)&&(e=n.start),(!t||n.end>t)&&(t=n.end));const i=Ge();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const s=ot(Q(ie(e),-7));this.epochStart=s,this.totalDays=Math.max(de(s,ie(t))+730,1095)}dateX(e){return de(this.epochStart,e)*this.dayWidth}xToDate(e){return ce(Q(this.epochStart,Math.round(e/this.dayWidth)))}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[t,i]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const s=t===this.eRuler?this.eHeader.clientWidth:this.eScroll.clientWidth,n=t===this.eRuler?this.eHeader.clientHeight:this.eScroll.clientHeight;t.width=Math.max(1,Math.round(s*e)),t.height=Math.max(1,Math.round(n*e)),t.style.width=`${s}px`,t.style.height=`${n}px`,i.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,i=this.totalDays*e,s=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${i}px`,this.eSpacer.style.height=`${s}px`,this.drawRuler(e,i),this.drawBody(e,i,s,t)}drawRuler(e,t){const i=this.rulerCtx,s=this.eHeader.clientWidth,n=this.eHeader.clientHeight,o=this.eScroll.scrollLeft;i.clearRect(0,0,s,n),i.fillStyle="#fff",i.fillRect(0,0,s,n);const a=Q(this.epochStart,this.totalDays),r=(h,g,p,m)=>{for(const f of h){const v=this.dateX(ce(f.start))-o,C=de(f.start,f.end)*e;if(v+C<=0||v>=s)continue;const w=Math.max(0,Math.min(v+C,s)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const y=f.start.getDay();(y===0||y===6)&&(i.fillStyle=Y.weekend,i.fillRect(Math.max(0,v),g,w,p))}const x=i.measureText(f.primary).width;if(x+8<w){const y=Math.max(0,v)+w/2-x/2,N=g+p/2+5;i.fillStyle=Y.text,i.font="11px "+he,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(f.primary,y,N),f.secondary&&(i.fillStyle=Y.textTertiary,i.font="10px "+he,i.fillText(f.secondary,y,N+12))}}},d=40,c=Q(this.epochStart,Math.floor(o/e));i.fillStyle=Y.text,i.font="14px "+he,i.textAlign="left",i.textBaseline="middle",i.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(Bt(this.unit,this.epochStart,a),d+1,n-d-1),i.strokeStyle=Y.border,i.beginPath(),i.moveTo(0,n-.5),i.lineTo(s,n-.5),i.stroke()}drawBody(e,t,i,s){const n=this.ctx,o=this.eScroll.clientWidth,a=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;n.clearRect(0,0,o,a),n.fillStyle="#fff",n.fillRect(0,0,o,a),n.save(),n.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,d+a)),this.drawGridlines(e,t,Math.max(i,d+a)),this.drawRowBackgrounds(t,s);const c=this.rows.findIndex(g=>g.id===this.hoverId),h=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(h==null?void 0:h.kind)==="task"&&!h.start){const g=c*s+6;n.fillStyle="#fff",n.strokeStyle="#dee0e3",n.lineWidth=1,Me(n,r+4,g,Math.max(0,o-8),28,4),n.fill(),n.stroke(),n.fillStyle=Y.textTertiary,n.font="14px "+he,n.textAlign="center",n.fillText("新建排期",r+o/2,g+19)}this.drawDependencies(s),this.drawBars(s),this.drawTodayLine(t,Math.max(i,d+a)),n.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,i){if(this.unit!=="day"&&this.unit!=="week")return;const s=this.ctx;s.fillStyle=Y.weekend;let n=ot(this.epochStart);for(;de(this.epochStart,n)<this.totalDays;){const o=this.dateX(ce(n))+5*e;o<t&&s.fillRect(Math.max(0,o),0,e*2,i),n=Q(n,7)}}drawGridlines(e,t,i){const s=this.ctx,n=Q(this.epochStart,this.totalDays);for(const o of Bt(this.unit,this.epochStart,n)){const a=Math.round(this.dateX(ce(o.start)))+.5;if(a<0||a>t)continue;const r=this.unit==="day"&&o.start.getDate()===1;s.strokeStyle=r?Y.gridlineMonth:Y.gridline,s.beginPath(),s.moveTo(a,0),s.lineTo(a,i),s.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=Y.rowLine,i.lineWidth=1,i.beginPath();for(let s=1;s<this.rows.length;s++){const n=Math.round(s*t)+.5;i.moveTo(0,n),i.lineTo(e,n)}i.stroke(),this.rows.forEach((s,n)=>{const o=this.selectedId===s.id,a=this.hoverId===s.id;(o||a)&&(i.fillStyle=o?Y.selected:a?Y.hover:Y.groupRow,i.fillRect(0,n*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,s=Math.round(this.dateX(Ge())+this.dayWidth/2)+.5;s<0||s>e||(i.strokeStyle=Y.accent,i.lineWidth=1.5,i.beginPath(),i.moveTo(s,0),i.lineTo(s,t),i.stroke(),this.todayLabelX=s-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=Ge().slice(5),this.eTodayBadge.style.left=`${this.todayLabelX-25}px`,this.eTodayBadge.style.top=`${this.eHeader.clientHeight-10}px`}drawDependencies(e){const t=new Map(this.rows.map((s,n)=>[s.id,n])),i=this.ctx;i.strokeStyle=Y.accent,i.lineWidth=1.2;for(const s of this.rows){const n=this.tasksById.get(s.id);if(!n||n.kind!=="task"||!n.start||!n.end)continue;const o=t.get(s.id);if(o!==void 0)for(const a of n.dependsOn){const r=this.tasksById.get(a),d=t.get(a);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),h=r.milestone?this.dayWidth:Math.max(de(ie(r.start),ie(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),g=c+h,p=d*e+e/2,m=this.dateX(n.start),f=Math.max(de(ie(n.start),ie(n.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=o*e+e/2,C=g+10;if(m-4>C)zt(i,g,p,C,v,m-5,v);else{const w=m+f+10;zt(i,g,p,C,v,w,v)}Hs(i,m-5,v)}}}drawBars(e){this.rows.forEach((t,i)=>{const s=this.tasksById.get(t.id);if(!s||!s.start||s.path.length>1&&(!this.showChildren||this.milestonesOnly&&!s.milestone))return;const n=i*e+(e-oe)/2;if(t.group){this.drawSummaryBar(s,i,n);return}if(s.milestone){this.drawMilestone(s,i,n);return}s.end&&this.drawTaskBar(s,i,n)})}drawTaskBar(e,t,i){var p;const s=this.ctx,n=((p=this.ghost)==null?void 0:p.id)===e.id?this.ghost:null,o=(n==null?void 0:n.start)??e.start,a=(n==null?void 0:n.end)??e.end,r=this.dateX(o),d=Math.max(28,(de(o,a)+1)*this.dayWidth),c=Ke[e.status];s.save(),s.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,s.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",s.strokeStyle=this.selectedId===e.id?Y.accent:"#dee0e3",s.lineWidth=1,Me(s,r,i,d,oe,4),s.fill(),s.stroke(),s.save(),Me(s,r,i,d,oe,4),s.clip(),s.beginPath(),s.arc(r+14,i+14,6,0,Math.PI*2),s.fillStyle=c,s.fill(),s.font="12px "+he,s.textBaseline="middle",s.textAlign="left",s.fillStyle=Y.text;const h=this.options.members.find(m=>m.id===e.owner),g=s.measureText(e.name).width;d>g+58?(s.fillText(e.name,r+26,i+14),h&&lt(s,r+g+42,i+14,7,Xe(h.id),h.name.slice(0,1))):h&&d>46&&lt(s,r+38,i+14,7,Xe(h.id),h.name.slice(0,1)),d>100&&(s.fillStyle=Y.textTertiary,s.textAlign="right",s.fillText(String(As(ie(o),ie(a))),r+d-8,i+14)),s.restore(),s.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:i,w:d,h:oe,mode:"move",avatar:h?{x:r+(d>g+58?g+42:38),y:i+14,r:7}:void 0})}drawSummaryBar(e,t,i){if(!e.start||!e.end)return;const s=this.tasks.filter(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),n=s[0],o=this.ctx,a=this.dateX(e.start),r=Math.max(92,(de(e.start,e.end)+1)*this.dayWidth);o.fillStyle=this.theme==="color"?"#0565db":"#fff",o.strokeStyle=this.selectedId===e.id?Y.accent:"#dee0e3",o.lineWidth=1,Me(o,a,i,r,oe,4),o.fill(),o.stroke(),o.fillStyle=n?Ke[n.status]:Ke[e.status],o.beginPath(),o.arc(a+14,i+14,5,0,Math.PI*2),o.fill(),o.fillStyle=this.theme==="color"?"#fff":Y.text,o.font="11px "+he,o.textAlign="left",o.textBaseline="middle";const d=((n==null?void 0:n.name)??e.name)+(s.length>1?` +${s.length-1}`:"");o.fillText($s(o,d,r-32),a+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:a,y:i,w:r,h:oe,mode:"move"})}firstVisibleChildIndex(e,t){var s;const i=`${e.path.join("/")}/`;for(let n=t+1;n<this.rows.length;n++){const o=this.tasksById.get(((s=this.rows[n])==null?void 0:s.id)??"");if(o)return o.path.join("/").startsWith(i)?n:-1}return-1}drawMilestone(e,t,i){var v;const s=this.ctx,n=this.dayWidth,o=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,a=o?o.start:e.start,r=Ds(e),d=Ke[r],c=this.dateX(a)+n/2;s.font="12px "+he;const h=s.measureText(e.name).width,g=e.owner?24:0,p=19+h+g+14,m=c-p/2;s.fillStyle="#fff",s.strokeStyle=d,s.lineWidth=1.5,Me(s,m,i,p,oe,4),s.fill(),s.stroke(),s.fillStyle=d,s.beginPath(),s.arc(m+7+3,i+oe/2,3,0,Math.PI*2),s.fill(),s.fillStyle=Y.text,s.textAlign="left",s.textBaseline="middle",s.fillText(e.name,m+14+5,i+oe/2+1);let f;if(e.owner){const C=this.options.members.find(w=>w.id===e.owner);C&&(lt(s,m+p-12,i+oe/2,9,Xe(C.id),C.name.slice(0,1)),f={x:m+p-12,y:i+oe/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:m,y:i,w:p,h:oe,mode:"move",avatar:f})}pushHit(e){this.hits.push(e);const t=this.hitsByRow.get(e.rowIndex);t?t.push(e):this.hitsByRow.set(e.rowIndex,[e])}drawLocateButtons(){this.locateHits=[];const e=this.ctx,t=this.eScroll.scrollLeft,i=this.eScroll.clientWidth;this.rows.forEach((s,n)=>{const o=this.tasksById.get(s.id);if(!(o!=null&&o.start)||!o.end||o.path.length>1&&(!this.showChildren||this.milestonesOnly&&!o.milestone))return;const a=this.dateX(o.start),r=this.dateX(o.end)+this.dayWidth;if(r>=t&&a<=t+i)return;const d=r<t?10:i-18,c=n*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",Me(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+he,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<t?"‹":"›",d+1,c),this.locateHits.push({id:o.id,x:d+1,y:c}))})}pointAt(e,t){const i=this.eScroll.getBoundingClientRect();return{x:e-i.left+this.eScroll.scrollLeft,y:t-i.top+this.eScroll.scrollTop}}hitAt(e,t){const i=this.pointAt(e,t),s=Math.floor(i.y/this.options.rowHeight),n=this.hitsByRow.get(s)??[];for(const o of n){if(o.avatar){const a=i.x-o.avatar.x,r=i.y-o.avatar.y;if(a*a+r*r<=o.avatar.r*o.avatar.r)return{hit:o,rowIndex:s,onAvatar:!0}}if(i.x>=o.x&&i.x<=o.x+o.w&&i.y>=o.y&&i.y<=o.y+o.h){const a=o.kind==="task"&&i.x<=o.x+Ot,r=o.kind==="task"&&i.x>=o.x+o.w-Ot;return{hit:{...o,mode:a?"resize-l":r?"resize-r":"move"},rowIndex:s,onAvatar:!1}}}return{hit:null,rowIndex:s,onAvatar:!1}}buildRulerTools(){this.eRulerTools=document.createElement("div"),this.eRulerTools.className="gt-ruler-tools",this.eHeader.appendChild(this.eRulerTools);const e=document.createElement("button");e.type="button",e.className="gt-ruler-btn gt-ruler-step",this.eStepLabel=document.createElement("span"),this.eStepLabel.className="gt-ruler-step-label",this.eStepLabel.textContent=qe[this.unit];const t=document.createElement("span");t.className="gt-ruler-caret",t.textContent="▾",e.append(this.eStepLabel,t),e.addEventListener("click",n=>{n.stopPropagation(),this.toggleStepMenu()}),this.eRulerTools.appendChild(e);const i=this.toolButton("−","缩小",()=>this.zoomBy(-.25));this.eZoomValue=document.createElement("span"),this.eZoomValue.className="gt-ruler-zoom-value",this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`;const s=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(i,s),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,i){const s=document.createElement("button");return s.type="button",s.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(s.className="gt-ruler-btn gt-ruler-today"),s.textContent=e,s.title=t,s.addEventListener("click",n=>{n.stopPropagation(),i()}),s}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const t=this.totalDays*this.dayWidth-this.eScroll.clientWidth,i=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(t,i))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const s of Ht){const n=document.createElement("div");n.className="gt-step-item",n.setAttribute("role","menuitemradio"),n.setAttribute("aria-checked",String(s===this.unit)),n.tabIndex=0,n.addEventListener("keydown",o=>{(o.key==="Enter"||o.key===" ")&&(o.preventDefault(),this.setUnit(s),this.closeStepMenu())}),s===this.unit&&n.classList.add("gt-step-item-active"),n.textContent=qe[s],n.addEventListener("click",o=>{o.stopPropagation(),this.setUnit(s),this.closeStepMenu()}),e.appendChild(n)}const t=this.eRulerTools.getBoundingClientRect(),i=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,i.right-t.right)}px`,e.style.top=`${t.bottom-i.top+4}px`,this.eRoot.appendChild(e),this.eStepMenu=e,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeStepMenu(){var e;(e=this.eStepMenu)==null||e.remove(),this.eStepMenu=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}updateRulerTools(){this.eStepLabel.textContent=qe[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,t){this.closeAssigneePopup();const i=this.tasksById.get(e);if(!i)return;const s=document.createElement("div");s.className="gt-popup";const n=document.createElement("div");n.className="gt-popup-title",n.textContent="更换负责人",s.appendChild(n);for(const d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",i.owner===d.id&&c.classList.add("gt-popup-item-active");const h=document.createElement("span");h.className="gt-avatar",h.textContent=d.name.slice(0,1),h.style.backgroundColor=Xe(d.id);const g=document.createElement("span");g.textContent=d.name,c.append(h,g),c.addEventListener("click",p=>{p.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),s.appendChild(c)}if(i.owner){const d=document.createElement("div");d.className="gt-popup-item gt-popup-clear",d.textContent="取消负责人",d.addEventListener("click",c=>{c.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),s.appendChild(d)}const o=this.eRoot.getBoundingClientRect(),a=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;s.style.left=`${Math.min(o.width-150,Math.max(0,a-40))}px`,s.style.top=`${r+t.h+6}px`,this.eRoot.appendChild(s),this.ePopup=s,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const he="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function Me(l,e,t,i,s,n){const o=Math.max(0,i),a=Math.max(0,s);if(o===0||a===0)return;const r=Math.max(0,Math.min(n,o/2,a/2));l.beginPath(),l.moveTo(e+r,t),l.lineTo(e+o-r,t),l.arcTo(e+o,t,e+o,t+r,r),l.lineTo(e+o,t+a-r),l.arcTo(e+o,t+a,e+o-r,t+a,r),l.lineTo(e+r,t+a),l.arcTo(e,t+a,e,t+a-r,r),l.lineTo(e,t+r),l.arcTo(e,t,e+r,t,r),l.closePath()}function lt(l,e,t,i,s,n){l.beginPath(),l.arc(e,t,i,0,Math.PI*2),l.fillStyle=s,l.fill(),l.lineWidth=1.5,l.strokeStyle="#fff",l.stroke(),l.fillStyle="#fff",l.font=`10px ${he}`,l.textAlign="center",l.textBaseline="middle",l.fillText(n,e,t+1)}function $s(l,e,t){if(t<=0)return"";if(l.measureText(e).width<=t)return e;let i=e.length;for(;i>1;){i--;const s=`${e.slice(0,i)}…`;if(l.measureText(s).width<=t)return s}return"…"}function zt(l,e,t,i,s,n,o){const r=s>t?1:-1;l.beginPath(),l.moveTo(e,t),l.lineTo(i-5,t),l.quadraticCurveTo(i,t,i,t+5*r),l.lineTo(i,s-5*r),l.quadraticCurveTo(i,s,i+5*r,s),l.lineTo(n,o),l.stroke()}function Hs(l,e,t){l.fillStyle=Y.accent,l.beginPath(),l.moveTo(e+5,t),l.lineTo(e-1,t-3.5),l.lineTo(e-1,t+3.5),l.closePath(),l.fill()}const Wt=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function Xe(l){let e=0;for(let t=0;t<l.length;t++)e=e*31+l.charCodeAt(t)>>>0;return Wt[e%Wt.length]}const Os=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Bs=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Vs=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Z(l,e){const t=document.createElement(l);return e&&(t.className=e),t}function Ne(l,e,t){const i=document.createElement("button");return i.type="button",i.className=e,i.textContent=l,i.addEventListener("click",s=>{s.stopPropagation(),t()}),i}class zs{constructor(e,t,i,s){u(this,"filterFields");u(this,"sortFields");u(this,"filterRows",[]);u(this,"sorts",[]);u(this,"filterPanel",null);u(this,"sortPanel",null);u(this,"filterAnchor",null);u(this,"sortAnchor",null);u(this,"onDocumentMouseDown",e=>{var i,s;const t=e.target;this.filterPanel&&!this.filterPanel.contains(t)&&!((i=this.filterAnchor)!=null&&i.contains(t))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(t)&&!((s=this.sortAnchor)!=null&&s.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=s,this.filterFields=i.filter,this.sortFields=i.sort,document.addEventListener("mousedown",this.onDocumentMouseDown,!0)}openFilterPanel(e){if(this.filterPanel){this.closeFilterPanel();return}this.closeSortPanel();const t=Z("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",d=>d.stopPropagation());const i=Z("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const s=Z("div","gt-filter-rows");t.appendChild(s);const n=()=>{if(s.textContent="",!this.filterRows.length){const d=Z("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",s.appendChild(d)}for(const d of this.filterRows)s.appendChild(this.renderFilterRow(d,n))},o=Z("div","gt-filter-add");for(const d of this.filterFields)o.appendChild(Ne(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),n()}));t.appendChild(o);const a=Z("div","gt-panel-hint");a.textContent="多个条件同时满足(且)",t.appendChild(a);const r=Z("div","gt-panel-actions");r.append(Ne("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),Ne("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,n()}renderFilterRow(e,t){const i=Z("div","gt-filter-row"),s=this.filterFields.find(d=>d.colId===e.colId),n=document.createElement("select");n.className="gt-panel-select";for(const d of this.filterFields){const c=document.createElement("option");c.value=d.colId,c.textContent=d.label,d.colId===e.colId&&(c.selected=!0),n.appendChild(c)}n.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===n.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),i.appendChild(n);const o=e.kind==="number"?Bs:e.kind==="date"?Vs:Os,a=document.createElement("select");a.className="gt-panel-select gt-panel-select-cond";for(const d of o){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),a.appendChild(c)}if(a.addEventListener("change",()=>{e.type=a.value,t()}),i.appendChild(a),e.type!=="blank")if(s!=null&&s.options){const d=document.createElement("select");d.className="gt-panel-select";const c=document.createElement("option");c.value="",c.textContent="请选择",d.appendChild(c);for(const h of s.options){const g=document.createElement("option");g.value=h.value,g.textContent=h.label,h.value===e.value&&(g.selected=!0),d.appendChild(g)}d.addEventListener("change",()=>{e.value=d.value}),i.appendChild(d)}else if(e.kind==="date"){const d=document.createElement("input");if(d.type="date",d.className="gt-panel-input",d.value=e.value,d.addEventListener("change",()=>{e.value=d.value}),i.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="date",c.className="gt-panel-input",c.value=e.valueTo,c.addEventListener("change",()=>{e.valueTo=c.value}),i.appendChild(c)}}else if(e.kind==="number"){const d=document.createElement("input");if(d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="数值",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),i.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="至",c.value=e.valueTo,c.addEventListener("input",()=>{e.valueTo=c.value}),i.appendChild(c)}}else{const d=document.createElement("input");d.type="text",d.className="gt-panel-input",d.placeholder="文本",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),i.appendChild(d)}const r=Ne("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),t()});return r.title="移除条件",i.appendChild(r),i}applyFilter(){const e={};for(const t of this.filterRows){if(t.type==="blank"){e[t.colId]={filterType:t.kind==="number"?"number":"text",type:"blank",filter:""};continue}if(t.kind==="date"){const i=(t.type==="after",t.value),s=t.type==="before"?t.value:t.valueTo;if(t.type==="before"&&!t.value||t.type==="after"&&!t.value||t.type==="inRange"&&!t.value&&!t.valueTo)continue;e[t.colId]={filterType:"date",dateFrom:i||void 0,dateTo:s||void 0};continue}if(t.value)if(t.kind==="number"){const i={filterType:"number",type:t.type,filter:Number(t.value)};t.type==="inRange"&&(i.filterTo=Number(t.valueTo||t.value)),e[t.colId]=i}else e[t.colId]={filterType:"text",type:t.type,filter:t.value}}this.api.setFilterModel(e),this.hooks.onFilterButton(Object.keys(e).length>0,Object.keys(e).length)}closeFilterPanel(){var e;(e=this.filterPanel)==null||e.remove(),this.filterPanel=null}openSortPanel(e){if(this.sortPanel){this.closeSortPanel();return}this.closeFilterPanel();const t=Z("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",a=>a.stopPropagation());const i=Z("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const s=Z("div","gt-sort-list");t.appendChild(s);const n=()=>{var a;s.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(p=>p.colId===r.colId),c=d>=0,h=Z("div","gt-sort-item");c&&h.classList.add("gt-sort-item-active");const g=Z("span","gt-sort-label");if(g.textContent=r.label,h.appendChild(g),c){const p=Z("span","gt-sort-badge");p.textContent=String(d+1),h.appendChild(p);const m=Z("span","gt-sort-dir");m.textContent=((a=this.sorts[d])==null?void 0:a.sort)==="asc"?"↑ 升序":"↓ 降序",h.appendChild(m)}h.addEventListener("click",()=>{var p;c?((p=this.sorts[d])==null?void 0:p.sort)==="asc"?this.sorts[d]={colId:r.colId,sort:"desc"}:this.sorts=this.sorts.filter(m=>m.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),n()}),s.appendChild(h)}},o=Z("div","gt-panel-actions");o.append(Ne("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),Ne("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applySort(),this.closeSortPanel()})),t.appendChild(o),this.mount(t,e),this.sortPanel=t,this.sortAnchor=e,n()}applySort(){this.api.setSortModel(this.sorts.map(e=>({colId:e.colId,sort:e.sort}))),this.hooks.onSortButton(this.sorts.length>0,this.sorts.length)}closeSortPanel(){var e;(e=this.sortPanel)==null||e.remove(),this.sortPanel=null}mount(e,t){this.host.appendChild(e);const i=t.getBoundingClientRect();e.style.top=`${i.bottom+6}px`;const s=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(i.left,s))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const Ws={sort:"排序",sortAscending:"升序排列",sortDescending:"降序排列",columnSize:"列宽",autosizeThisColumn:"自适应列宽",autosizeAllColumns:"自适应所有列宽",pinColumn:"固定列",pinLeft:"固定到左侧",noPin:"取消固定",pinRight:"固定到右侧",filter:"筛选",openFilter:"打开筛选",openMultiFilter:"打开多选筛选",openAdvancedFilter:"打开高级筛选",clearFilter:"清除筛选",formula:"公式",addFormula:"添加公式…",editFormula:"编辑公式…",visibility:"列显示",hideColumn:"隐藏此列",chooseColumns:"选择显示的列…",openFilterTitle:"打开筛选",openMenuTitle:"打开菜单",copy:"复制",copyWithHeaders:"复制(含表头)",paste:"粘贴",export:"导出",csvExport:"导出 CSV",excelExport:"导出 Excel",resetColumns:"重置列",sizeToFit:"适应宽度",expandAll:"展开全部",collapseAll:"收起全部",pinRow:"固定行",pinToTop:"固定到顶部",pinToBottom:"固定到底部",unpin:"取消固定",filterOoo:"筛选…",apply:"应用",clear:"清除",searchOoo:"搜索…",noMatches:"无匹配项",selectAll:"全选",clearAll:"清除全部",join:"组合方式:",and:"且",or:"或",from:"从",to:"到",secondValue:"第二个值",value:"值",removeFilter:"移除筛选",addFilter:"+ 添加筛选",advancedFilter:"高级筛选",addCondition:"+ 添加条件",condTrue:"是",condFalse:"否",contains:"包含",notEqual:"不等于",startsWith:"开头是",endsWith:"结尾是",equals:"等于",blank:"为空",notBlank:"不为空",greaterThan:"大于",greaterThanOrEqual:"大于等于",lessThan:"小于",lessThanOrEqual:"小于等于",inRange:"介于",columns:"列",filters:"筛选",charts:"图表",rowGroups:"行分组",dragColumnsHere:"拖拽列到此处进行分组",searchColumns:"搜索列…",noMatchingColumns:"没有匹配的列",groupByThisColumn:"按此列分组",pinColumnTitle:"固定列",remove:"移除",page:"第",pageSize:"每页条数:",find:"在表格中查找…",matchCase:"区分大小写",of:"/",loadingOoo:"加载中…",noRowsToShow:"暂无数据",formulaPlaceholder:"例如 =price * quantity"};function _s(l,e){const t=document.createElement("section");t.className="rowvia-gantt",t.innerHTML=`<div class="gantt-app">
28
28
  <header class="gantt-toolbar"><div class="gantt-title"><span class="gantt-title-name"></span><span class="gantt-title-sub">条件视图</span></div></header>
29
29
  <div class="gt-view-toolbar"><button class="gt-btn" data-action="filter">筛选</button><button class="gt-btn" data-action="sort">排序</button><span class="gt-toolbar-spacer"></span><span>甘特图</span><button class="gt-btn" data-action="settings" aria-label="甘特图设置" aria-expanded="false">设置</button></div>
30
30
  <div class="gt-quick"><input aria-label="搜索工作项" placeholder="搜索工作项" type="search"></div>
31
31
  <div class="gantt-body"><div class="gantt-left"><div class="grid ag-theme-quartz"></div></div><div class="gantt-right"></div></div>
32
32
  <div class="gantt-status" aria-live="polite"></div>
33
33
  <div class="gt-settings" hidden><div class="gt-settings-title">甘特条样式</div><label><input type="checkbox" data-setting="children" checked>甘特条显示子节点</label><label class="gt-indented"><input type="radio" name="nodes" value="all" checked>显示全部节点</label><label class="gt-indented"><input type="radio" name="nodes" value="milestones">显示里程碑节点</label><div class="gt-theme-options"><label><input type="radio" name="theme" value="content" checked>内容优先</label><label><input type="radio" name="theme" value="color">颜色优先</label></div></div>
34
- </div>`,l.append(i);const t=e.onTaskOpen?null:Gt(i),s=S=>i.querySelector(S);s(".gantt-title-name").textContent=e.title??"甘特图";let n=structuredClone(e.tasks),o=new Map(n.map(S=>[S.id,S])),a,r,d=!0,c=!1;const h=s(".gantt-left");h.style.width=`${e.tableWidth??280}px`;const g=new AbortController,u=g.signal,f=s(".gantt-status");function m(){if(!a||c)return;C.setTasks(n);const S=Array.from({length:a.getDisplayedRowCount()},(O,V)=>a.getDisplayedRowAtIndex(V)).filter(Boolean);C.setRows(S.map(O=>({id:O.id,group:!!O.group,expanded:!!O.expanded})));const L=n.filter(O=>O.path.length===1),A=L.filter(O=>O.status==="done").length;f.textContent=`总工作项数 ${L.length} 完成进度 ${L.length?Math.round(A/L.length*100):0}%`}function v(S){var O;n=n.map(V=>V.id===S.id?{...S}:V),o=new Map(n.map(V=>[V.id,V]));const L=[S];let A=S.path.slice(0,-1);for(;A.length;){const V=n.find(j=>j.path.join("/")===A.join("/"));if(!V)break;const X=n.filter(j=>j.path.length===A.length+1&&j.path.slice(0,-1).join("/")===A.join("/")),B=X.flatMap(j=>j.start?[j.start]:[]).sort(),ee=X.flatMap(j=>j.end?[j.end]:[]).sort();V.start=B[0]??null,V.end=ee[ee.length-1]??null,L.push(V),A=A.slice(0,-1)}a.applyTransaction({update:L}),m(),(O=e.onTaskChange)==null||O.call(e,structuredClone(S))}const C=new Vt(s(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:S=>{var A;C.setSelected(S);const L=S?a==null?void 0:a.getRowNode(S):null;L&&((A=a.selectNode)==null||A.call(a,L,!0))},onHover:S=>{var L;i.querySelectorAll(".ag-row-hover").forEach(A=>A.classList.remove("ag-row-hover")),S&&((L=Array.from(i.querySelectorAll(".ag-row")).find(A=>A.dataset.rowid===S))==null||L.classList.add("ag-row-hover"))},onTaskChange:v,onAssign:(S,L)=>{const A=o.get(S);A&&v({...A,owner:L})}});function w(S){const L=S.data,A=document.createElement("span");if(A.className="gt-task-name",L.path.length>1?A.classList.add("gt-child-name"):S.node.group||A.classList.add("gt-root-leaf"),L.path.length>1){const V=document.createElement("span");V.className=`gt-node-dot gt-node-${L.status}`,A.append(V)}const O=document.createElement("button");return O.className="gt-title-link",O.textContent=L.name,O.title=L.name,O.addEventListener("click",()=>{C.scrollToTask(L.id),e.onTaskOpen?e.onTaskOpen(structuredClone(L)):t==null||t.open({title:L.name,fields:[{label:"排期",value:`${L.start??"未设置"} — ${L.end??"未设置"}`}]})}),A.append(O),A}const x=document.createElement("button");x.className="gt-tree-toggle",x.textContent="▾",x.title="收起全部子层级",x.setAttribute("aria-label",x.title);function b(S){d=S,S?a.expandAll():a.collapseAll(),x.textContent=S?"▾":"▸",x.title=S?"收起全部子层级":"展开全部子层级",x.setAttribute("aria-label",x.title),m()}x.addEventListener("click",()=>b(!d));const y=["name","status","start","end","owner","progress"].map(S=>({field:S,hide:!0,filter:!0}));r=new Re(s(".grid"),{columnDefs:y,rowData:n,treeData:!0,getDataPath:S=>S.path,getRowId:S=>S.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:_s,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const S=document.createElement("div");return S.className="gt-title-header",S.append(x,document.createTextNode("标题")),S},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:w}},onGridReady:S=>{a=S.api,m()},onModelUpdated:S=>{a=S.api,m()},onRowGroupOpened:m,onRowClicked:S=>{var L;return C.setSelected(((L=S.node)==null?void 0:L.id)??null)}}),a=r.getApi();const N=s(".ag-body-viewport");let I=!1;const D=(S,L)=>{I||(I=!0,L.scrollTop=S.scrollTop,I=!1)};N.addEventListener("scroll",()=>D(N,C.scrollElement),{signal:u}),C.scrollElement.addEventListener("scroll",()=>D(C.scrollElement,N),{signal:u}),N.addEventListener("mousemove",S=>{const L=S.target.closest(".ag-row");C.setHover((L==null?void 0:L.dataset.rowid)??null)},{signal:u}),N.addEventListener("mouseleave",()=>C.setHover(null),{signal:u});const _=new zs(a,i,{filter:[{colId:"name",label:"标题",kind:"text"},{colId:"status",label:"状态",kind:"text",options:[{value:"not-started",label:"未开始"},{value:"in-progress",label:"进行中"},{value:"done",label:"已完成"}]},{colId:"start",label:"开始日期",kind:"date"}],sort:[{colId:"name",label:"标题"},{colId:"start",label:"开始日期"},{colId:"end",label:"结束日期"}]},{onFilterButton:S=>s('[data-action="filter"]').classList.toggle("gt-btn-active",S),onSortButton:S=>s('[data-action="sort"]').classList.toggle("gt-btn-active",S)});s('[data-action="filter"]').addEventListener("click",S=>_.openFilterPanel(S.currentTarget),{signal:u}),s('[data-action="sort"]').addEventListener("click",S=>_.openSortPanel(S.currentTarget),{signal:u}),s('[type="search"]').addEventListener("input",S=>a.setQuickFilter(S.target.value),{signal:u});const T=s(".gt-settings"),P=s('[data-action="settings"]');P.addEventListener("click",()=>{T.hidden=!T.hidden,P.setAttribute("aria-expanded",String(!T.hidden))},{signal:u}),document.addEventListener("pointerdown",S=>{!T.contains(S.target)&&!P.contains(S.target)&&(T.hidden=!0,P.setAttribute("aria-expanded","false"))},{signal:u});const F=Math.random().toString(36).slice(2);return T.querySelectorAll('[type="radio"]').forEach(S=>{const L=S.name;S.name=L+F,S.addEventListener("change",()=>{L==="theme"?C.setTheme(S.value):C.setMilestonesOnly(S.value==="milestones")},{signal:u})}),s('[data-setting="children"]').addEventListener("change",S=>C.setShowChildren(S.target.checked),{signal:u}),i.addEventListener("keydown",S=>{S.key==="Escape"&&(T.hidden=!0,_.closeAll())},{signal:u}),m(),e.unit&&C.setUnit(e.unit),C.scrollToToday(.5),{grid:a,chart:C,expandAll:()=>b(!0),collapseAll:()=>b(!1),scrollToTask:S=>C.scrollToTask(S),setTasks(S){n=structuredClone(S),o=new Map(n.map(L=>[L.id,L])),a.setRowData(n),m()},destroy(){c||(c=!0,g.abort(),_.destroy(),t==null||t.destroy(),C.destroy(),r.destroy(),i.remove())}}}const J=l=>Date.parse(`${l}T00:00:00Z`)/864e5,le=l=>new Date(l*864e5).toISOString().slice(0,10),Wt=l=>/^\d{4}-\d{2}-\d{2}$/.test(l)&&Number.isFinite(J(l))&&le(J(l))===l,$e=l=>!!l.start&&!!l.end;function rt(l,e){const i=new Set(l.map(t=>t.id));if(i.size!==l.length||new Set(e.map(t=>t.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const t of e){if(!i.has(t.personId))throw new Error(`Unknown person: ${t.personId}`);if(!Number.isFinite(t.estimate)||t.estimate<0)throw new Error("Invalid estimate");if(!!t.start!=!!t.end||t.start&&t.end&&(!Wt(t.start)||!Wt(t.end)||t.end<t.start))throw new Error("Invalid date range")}}function Us(l,e=!1){const i=[];return l.filter($e).slice().sort((t,s)=>t.start.localeCompare(s.start)||t.id.localeCompare(s.id)).map(t=>{let s=e?i.length:i.findIndex(n=>n<J(t.start));return s<0&&(s=i.length),i[s]=J(t.end),{item:t,lane:s}})}function je(l){return{scheduled:l.filter($e).length,unscheduled:l.filter(e=>!$e(e)).length,estimate:l.reduce((e,i)=>e+i.estimate,0)}}const K=l=>l.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),Ut=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function qs(l,e){rt(e.people,e.items);let i=structuredClone(e.people),t=structuredClone(e.items);const s=e.today??new Date().toISOString().slice(0,10);let n=new Set(i.map(E=>E.id)),o=!1,a="",r="",d="",c=!1,h=1,g=!1,u=!1,f=!1,m=!0,v=J(s)-new Date(`${s}T00:00:00Z`).getUTCDay(),C=90,w=`${s.slice(0,7)}-01`,x=le(Date.UTC(Number(s.slice(0,4)),Number(s.slice(5,7))+1,0)/864e5),b=!1,y=!1;const N=document.createElement("section");N.className="personnel-schedule",N.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${K(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
34
+ </div>`,l.append(t);const i=e.onTaskOpen?null:Gt(t),s=S=>t.querySelector(S);s(".gantt-title-name").textContent=e.title??"甘特图";let n=structuredClone(e.tasks),o=new Map(n.map(S=>[S.id,S])),a,r,d=!0,c=!1;const h=s(".gantt-left");h.style.width=`${e.tableWidth??280}px`;const g=new AbortController,p=g.signal,m=s(".gantt-status");function f(){if(!a||c)return;C.setTasks(n);const S=Array.from({length:a.getDisplayedRowCount()},(O,V)=>a.getDisplayedRowAtIndex(V)).filter(Boolean);C.setRows(S.map(O=>({id:O.id,group:!!O.group,expanded:!!O.expanded})));const L=n.filter(O=>O.path.length===1),P=L.filter(O=>O.status==="done").length;m.textContent=`总工作项数 ${L.length} 完成进度 ${L.length?Math.round(P/L.length*100):0}%`}function v(S){var O;n=n.map(V=>V.id===S.id?{...S}:V),o=new Map(n.map(V=>[V.id,V]));const L=[S];let P=S.path.slice(0,-1);for(;P.length;){const V=n.find(j=>j.path.join("/")===P.join("/"));if(!V)break;const X=n.filter(j=>j.path.length===P.length+1&&j.path.slice(0,-1).join("/")===P.join("/")),B=X.flatMap(j=>j.start?[j.start]:[]).sort(),ee=X.flatMap(j=>j.end?[j.end]:[]).sort();V.start=B[0]??null,V.end=ee[ee.length-1]??null,L.push(V),P=P.slice(0,-1)}a.applyTransaction({update:L}),f(),(O=e.onTaskChange)==null||O.call(e,structuredClone(S))}const C=new Vt(s(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:S=>{var P;C.setSelected(S);const L=S?a==null?void 0:a.getRowNode(S):null;L&&((P=a.selectNode)==null||P.call(a,L,!0))},onHover:S=>{var L;t.querySelectorAll(".ag-row-hover").forEach(P=>P.classList.remove("ag-row-hover")),S&&((L=Array.from(t.querySelectorAll(".ag-row")).find(P=>P.dataset.rowid===S))==null||L.classList.add("ag-row-hover"))},onTaskChange:v,onAssign:(S,L)=>{const P=o.get(S);P&&v({...P,owner:L})}});function w(S){const L=S.data,P=document.createElement("span");if(P.className="gt-task-name",L.path.length>1?P.classList.add("gt-child-name"):S.node.group||P.classList.add("gt-root-leaf"),L.path.length>1){const V=document.createElement("span");V.className=`gt-node-dot gt-node-${L.status}`,P.append(V)}const O=document.createElement("button");return O.className="gt-title-link",O.textContent=L.name,O.title=L.name,O.addEventListener("click",()=>{C.scrollToTask(L.id),e.onTaskOpen?e.onTaskOpen(structuredClone(L)):i==null||i.open({title:L.name,fields:[{label:"排期",value:`${L.start??"未设置"} — ${L.end??"未设置"}`}]})}),P.append(O),P}const x=document.createElement("button");x.className="gt-tree-toggle",x.textContent="▾",x.title="收起全部子层级",x.setAttribute("aria-label",x.title);function b(S){d=S,S?a.expandAll():a.collapseAll(),x.textContent=S?"▾":"▸",x.title=S?"收起全部子层级":"展开全部子层级",x.setAttribute("aria-label",x.title),f()}x.addEventListener("click",()=>b(!d));const y=["name","status","start","end","owner","progress"].map(S=>({field:S,hide:!0,filter:!0}));r=new Re(s(".grid"),{columnDefs:y,rowData:n,treeData:!0,getDataPath:S=>S.path,getRowId:S=>S.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:Ws,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const S=document.createElement("div");return S.className="gt-title-header",S.append(x,document.createTextNode("标题")),S},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:w}},onGridReady:S=>{a=S.api,f()},onModelUpdated:S=>{a=S.api,f()},onRowGroupOpened:f,onRowClicked:S=>{var L;return C.setSelected(((L=S.node)==null?void 0:L.id)??null)}}),a=r.getApi();const N=s(".ag-body-viewport");let I=!1;const D=(S,L)=>{I||(I=!0,L.scrollTop=S.scrollTop,I=!1)};N.addEventListener("scroll",()=>D(N,C.scrollElement),{signal:p}),C.scrollElement.addEventListener("scroll",()=>D(C.scrollElement,N),{signal:p}),N.addEventListener("mousemove",S=>{const L=S.target.closest(".ag-row");C.setHover((L==null?void 0:L.dataset.rowid)??null)},{signal:p}),N.addEventListener("mouseleave",()=>C.setHover(null),{signal:p});const W=new zs(a,t,{filter:[{colId:"name",label:"标题",kind:"text"},{colId:"status",label:"状态",kind:"text",options:[{value:"not-started",label:"未开始"},{value:"in-progress",label:"进行中"},{value:"done",label:"已完成"}]},{colId:"start",label:"开始日期",kind:"date"}],sort:[{colId:"name",label:"标题"},{colId:"start",label:"开始日期"},{colId:"end",label:"结束日期"}]},{onFilterButton:S=>s('[data-action="filter"]').classList.toggle("gt-btn-active",S),onSortButton:S=>s('[data-action="sort"]').classList.toggle("gt-btn-active",S)});s('[data-action="filter"]').addEventListener("click",S=>W.openFilterPanel(S.currentTarget),{signal:p}),s('[data-action="sort"]').addEventListener("click",S=>W.openSortPanel(S.currentTarget),{signal:p}),s('[type="search"]').addEventListener("input",S=>a.setQuickFilter(S.target.value),{signal:p});const T=s(".gt-settings"),A=s('[data-action="settings"]');A.addEventListener("click",()=>{T.hidden=!T.hidden,A.setAttribute("aria-expanded",String(!T.hidden))},{signal:p}),document.addEventListener("pointerdown",S=>{!T.contains(S.target)&&!A.contains(S.target)&&(T.hidden=!0,A.setAttribute("aria-expanded","false"))},{signal:p});const F=Math.random().toString(36).slice(2);return T.querySelectorAll('[type="radio"]').forEach(S=>{const L=S.name;S.name=L+F,S.addEventListener("change",()=>{L==="theme"?C.setTheme(S.value):C.setMilestonesOnly(S.value==="milestones")},{signal:p})}),s('[data-setting="children"]').addEventListener("change",S=>C.setShowChildren(S.target.checked),{signal:p}),t.addEventListener("keydown",S=>{S.key==="Escape"&&(T.hidden=!0,W.closeAll())},{signal:p}),f(),e.unit&&C.setUnit(e.unit),C.scrollToToday(.5),{grid:a,chart:C,expandAll:()=>b(!0),collapseAll:()=>b(!1),scrollToTask:S=>C.scrollToTask(S),setTasks(S){n=structuredClone(S),o=new Map(n.map(L=>[L.id,L])),a.setRowData(n),f()},destroy(){c||(c=!0,g.abort(),W.destroy(),i==null||i.destroy(),C.destroy(),r.destroy(),t.remove())}}}const J=l=>Date.parse(`${l}T00:00:00Z`)/864e5,le=l=>new Date(l*864e5).toISOString().slice(0,10),_t=l=>/^\d{4}-\d{2}-\d{2}$/.test(l)&&Number.isFinite(J(l))&&le(J(l))===l,$e=l=>!!l.start&&!!l.end;function rt(l,e){const t=new Set(l.map(i=>i.id));if(t.size!==l.length||new Set(e.map(i=>i.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const i of e){if(!t.has(i.personId))throw new Error(`Unknown person: ${i.personId}`);if(!Number.isFinite(i.estimate)||i.estimate<0)throw new Error("Invalid estimate");if(!!i.start!=!!i.end||i.start&&i.end&&(!_t(i.start)||!_t(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function Us(l,e=!1){const t=[];return l.filter($e).slice().sort((i,s)=>i.start.localeCompare(s.start)||i.id.localeCompare(s.id)).map(i=>{let s=e?t.length:t.findIndex(n=>n<J(i.start));return s<0&&(s=t.length),t[s]=J(i.end),{item:i,lane:s}})}function je(l){return{scheduled:l.filter($e).length,unscheduled:l.filter(e=>!$e(e)).length,estimate:l.reduce((e,t)=>e+t.estimate,0)}}const K=l=>l.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),Ut=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function qs(l,e){rt(e.people,e.items);let t=structuredClone(e.people),i=structuredClone(e.items);const s=e.today??new Date().toISOString().slice(0,10);let n=new Set(t.map(E=>E.id)),o=!1,a="",r="",d="",c=!1,h=1,g=!1,p=!1,m=!1,f=!0,v=J(s)-new Date(`${s}T00:00:00Z`).getUTCDay(),C=90,w=`${s.slice(0,7)}-01`,x=le(Date.UTC(Number(s.slice(0,4)),Number(s.slice(5,7))+1,0)/864e5),b=!1,y=!1;const N=document.createElement("section");N.className="personnel-schedule",N.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${K(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
35
35
  <div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${K(e.workItemLabel??"工作项")}</button><button data-action="sort">☷ 人员排序</button><span class="ps-space"></span><button class="ps-round" data-action="minus" aria-label="缩小">−</button><input class="ps-zoom" type="range" min="0" max="4" step="1" value="1" aria-label="时间缩放"><button class="ps-round" data-action="plus" aria-label="放大">+</button><button class="ps-save" data-action="save">▣ 存为视图</button><button data-action="settings" aria-label="显示设置">⚙</button></div>
36
36
  <div class="ps-scroll"><div class="ps-table"><div class="ps-time-header"><div class="ps-date-nav"><button data-action="date" class="ps-date-label"></button><button data-action="prev" aria-label="上一时间段">‹</button><button data-action="today" aria-label="回到今天">•</button><button data-action="next" aria-label="下一时间段">›</button></div><div class="ps-weeks"></div></div><div class="ps-rows"></div></div></div>
37
- <footer class="ps-total"></footer><div class="ps-popover" hidden></div><aside class="ps-detail" hidden></aside><div class="ps-toast" role="status" hidden></div>`,l.append(N);const I=E=>N.querySelector(E),D=I(".ps-scroll"),_=I(".ps-rows"),T=I(".ps-popover"),P=I(".ps-detail"),F=new AbortController,S=F.signal;let L;const A=()=>[22,43,64,86,120][h],O=()=>t.filter(E=>(!a||E.name.includes(a))&&(!r||E.status===r)&&(u||!E.parentId)),V=()=>{const E=O();return i.filter(R=>n.has(R.id)&&(!o||E.some(k=>k.personId===R.id&&$e(k)))).sort((R,k)=>{if(!d)return 0;const M=je(E.filter(W=>W.personId===R.id)),G=je(E.filter(W=>W.personId===k.id));return(d==="estimate"?M.estimate-G.estimate:M.scheduled-G.scheduled)*(c?-1:1)})};function X(E){const R=I(".ps-toast");R.textContent=E,R.hidden=!1,clearTimeout(L),L=setTimeout(()=>R.hidden=!0,2200)}function B(){if(b)return;const E=A(),R=C*E;I(".ps-table").style.width=`${R+200}px`;const k=`${w.slice(0,4)}年 第${Number(w.slice(5,7))}-${Number(x.slice(5,7))}月`;I(".ps-date-label").textContent=k,I('[data-action="people"]').textContent=`◎ 人员筛选 · ${n.size}人`,I(".ps-zoom").value=String(h);const M=I(".ps-weeks");M.replaceChildren();for(let te=0;te<C;te+=7){const ve=document.createElement("span");ve.style.width=`${Math.min(7,C-te)*E}px`,ve.textContent=`${le(v+te).slice(5).replace("-","/")}~${le(v+te+6).slice(5).replace("-","/")}`,M.append(ve)}_.replaceChildren();const G=O(),W=V();for(const te of W){const ve=G.filter(U=>U.personId===te.id),dt=je(ve),ct=Us(ve,g),Qs=Math.max(0,...ct.map(U=>U.lane)),Zs=Math.max(f?154:126,60+(Qs+1)*(f?48:36)),He=document.createElement("div");He.className="ps-person-row",He.style.height=`${Zs}px`,He.dataset.person=te.id;const Ye=document.createElement("div");Ye.className="ps-person",Ye.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${K(te.name)}</strong></div><div>已排期项 <b>${dt.scheduled}</b></div><div>总估分 <b>${dt.estimate.toFixed(2)}</b></div><div>未排期·${dt.unscheduled}<button data-action="unplanned" data-person="${K(te.id)}">查看</button></div>`;const Xt=Ye.querySelector(".ps-avatar");Xt.textContent=te.name.slice(-2),Xt.style.background=te.color||Ut[i.indexOf(te)%Ut.length];const Ce=document.createElement("div");Ce.className="ps-timeline",Ce.style.width=`${R}px`,Ce.style.setProperty("--day",`${E}px`);for(let U=0;U<C;U++)if([0,6].includes(new Date((v+U)*864e5).getUTCDay())){const Ie=document.createElement("i");Ie.className="ps-weekend",Ie.style.left=`${U*E}px`,Ie.style.width=`${E}px`,Ce.append(Ie)}const ht=J(s)-v;if(ht>=0&&ht<C){const U=document.createElement("i");U.className="ps-today",U.style.left=`${(ht+.5)*E}px`,Ce.append(U)}for(const{item:U,lane:Ie}of ct){const jt=J(U.start),Yt=J(U.end);if(Yt<v||jt>=v+C)continue;const Qt=Math.max(0,jt-v)*E,Js=Math.min(C,Yt-v+1)*E,pe=document.createElement("button");pe.className=`ps-bar ${m?"ps-color":"ps-content"}`,pe.dataset.item=U.id,pe.setAttribute("aria-label",`${U.name},${U.start} 至 ${U.end}`),pe.style.left=`${Qt}px`,pe.style.width=`${Js-Qt}px`,pe.style.top=`${52+Ie*(f?48:36)}px`,pe.style.setProperty("--bar-color",U.color||"#8cafeb"),pe.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${K(U.name)}</span><span class="ps-status">${K(U.status)}</span><span class="ps-node">● ${K(U.node)}</span><span class="ps-effort">${U.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,Ce.append(pe)}if(!ct.length){const U=document.createElement("span");U.className="ps-no-schedule",U.textContent="暂无排期",Ce.append(U)}He.append(Ye,Ce),_.append(He)}W.length||(_.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const re=G.filter(te=>W.some(ve=>ve.id===te.personId));I(".ps-total").textContent=`ⓘ 总人数 ${W.length} 总估分 ${je(re).estimate.toFixed(2)} pd ···`}function ee(E,R){if(!T.hidden&&T.dataset.kind===E){T.hidden=!0;return}T.dataset.kind=E,T.hidden=!1;const k=N.getBoundingClientRect(),M=R==null?void 0:R.getBoundingClientRect();if(T.style.left=`${Math.max(12,Math.min(((M==null?void 0:M.left)??k.left)-k.left,N.clientWidth-(E==="unplanned"?760:420)-16))}px`,T.style.top=`${M?M.bottom-k.top+6:96}px`,T.className=`ps-popover ps-panel-${E}`,E==="people")T.innerHTML=`<div class="ps-panel-title">包含 ${n.size} 人<label><input type="checkbox" data-control="only" ${o?"checked":""}>仅查看有排期的用户</label></div><div class="ps-person-filter"><span>甘特图显示人员</span><span>包含</span><span>全部排期人员</span></div><input class="ps-person-search" placeholder="搜索人员" aria-label="搜索人员"><div class="ps-person-options">${i.map(G=>`<label><input type="checkbox" data-person="${K(G.id)}" ${n.has(G.id)?"checked":""}>${K(G.name)}</label>`).join("")}</div>`;else if(E==="sort")T.innerHTML=`<div class="ps-panel-title">设置排序条件 ⓘ</div><div class="ps-sort-fields"><select aria-label="排序字段" data-control="sort"><option value="">请选择排序项</option><option value="estimate">总估分</option><option value="scheduled">已排期项</option></select><button data-action="asc" class="${c?"":"selected"}">小 → 大</button><button data-action="desc" class="${c?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,T.querySelector("select").value=d;else if(E==="filter")T.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${K(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${K(a)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(t.map(G=>G.status))].map(G=>`<option>${K(G)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,T.querySelector("select").value=r;else if(E==="settings")T.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${g?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${u?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${f?"":"selected"}">紧凑</button><button data-action="loose" class="${f?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${m?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${m?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(E==="date")Se();else if(E==="save")T.innerHTML='<div class="ps-panel-title">存为视图</div><input data-view-name placeholder="视图名称" aria-label="视图名称"><button class="ps-primary" data-action="save-view">保存</button>';else if(E==="views"){const G=at();T.innerHTML=`<div class="ps-panel-title">视图列表</div>${G.length?G.map((W,re)=>`<button class="ps-view" data-view="${re}">▦ ${K(W.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let j=new Date(`${w}T00:00:00Z`),Te=!1;function Se(){let E=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${w}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${x}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let R=0;R<2;R++){const k=new Date(Date.UTC(j.getUTCFullYear(),j.getUTCMonth()+R,1));E+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${k.getUTCFullYear()}年 ${k.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(G=>`<span>${G}</span>`).join("")}`;for(let G=0;G<k.getUTCDay();G++)E+="<span></span>";const M=new Date(Date.UTC(k.getUTCFullYear(),k.getUTCMonth()+1,0)).getUTCDate();for(let G=1;G<=M;G++){const W=le(Date.UTC(k.getUTCFullYear(),k.getUTCMonth(),G)/864e5);E+=`<button data-date="${W}" class="${W>=w&&W<=x?"in-range":""} ${W===w||W===x?"selected":""}">${G}</button>`}E+="</div></div>"}T.innerHTML=E+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((R,k)=>`<button data-preset="${k}">${R}</button>`).join("")}</div>`}function xe(){x<w&&([w,x]=[x,w]),v=J(w),v-=new Date(v*864e5).getUTCDay(),C=Math.max(35,J(x)-v+8),D.scrollLeft=0,B()}function ue(E,R){var G;if(!t.some(W=>W.id===E))throw new Error(`Unknown schedule item: ${E}`);const k=t.map(W=>W.id===E?{...W,...R}:W);rt(i,k),t=k,B();const M=t.find(W=>W.id===E);M&&((G=e.onItemChange)==null||G.call(e,structuredClone(M)))}function qt(E){var k;const R=t.find(M=>M.id===E);(k=e.onItemOpen)==null||k.call(e,structuredClone(R)),P.hidden=!1,P.dataset.item=E,P.innerHTML=`<header><strong>${K(R.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${K(R.status)}</span><h3>● ${K(R.node)}</h3><form><label>名称<input name="name" required value="${K(R.name)}"></label><label>负责人<select name="personId">${i.map(M=>`<option value="${K(M.id)}" ${M.id===R.personId?"selected":""}>${K(M.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${R.estimate}" required></label><label>开始日期<input type="date" name="start" value="${R.start||""}"></label><label>结束日期<input type="date" name="end" value="${R.end||""}"></label><p class="ps-error" role="alert"></p><button class="ps-primary" type="submit">保存排期</button><button type="button" data-action="unschedule">移至未排期</button></form></div>`}function Ys(E,R){ee("unplanned",R),T.hidden=!1;const k=i.find(M=>M.id===E);T.innerHTML=`<div class="ps-panel-title">未排期工作项 ${K(k.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${t.filter(M=>M.personId===E&&!$e(M)).map(M=>`<tr><td><button data-open="${K(M.id)}">${K(M.name)}</button></td><td>● ${K(M.node)}</td><td><input type="number" min="0" step="0.1" value="${M.estimate||""}" placeholder="待填" data-estimate="${K(M.id)}" aria-label="${K(M.name)}估分"></td><td><button class="ps-link" data-open="${K(M.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const Kt=e.viewStorageKey??"rowvia-personnel-views-v1";function at(){try{const E=JSON.parse(localStorage.getItem(Kt)||"[]");return Array.isArray(E)?E:[]}catch{return[]}}N.addEventListener("click",E=>{const R=E.target,k=R.closest("button");if(!k)return;if(k.dataset.open){T.hidden=!0,qt(k.dataset.open);return}if(k.dataset.item){y||qt(k.dataset.item);return}if(k.dataset.date){Te?(x=k.dataset.date,Te=!1,xe()):(w=k.dataset.date,x=w,Te=!0),Se();return}if(k.dataset.preset){const G=Number(k.dataset.preset),W=J(s),re=new Date(W*864e5);w=le(G<2?W-re.getUTCDay():G<4?Date.UTC(re.getUTCFullYear(),re.getUTCMonth(),1)/864e5:W),x=le(G===2||G===3?Date.UTC(re.getUTCFullYear(),re.getUTCMonth()+(G===2?1:2),0)/864e5:J(w)+[6,13,29,60,13,59,364][G]),Te=!1,xe(),T.hidden=!0;return}if(k.dataset.view){const G=at()[Number(k.dataset.view)];G&&(n=new Set(G.selected.filter(W=>i.some(re=>re.id===W))),{query:a,status:r,sort:d,descending:c,zoom:h,from:v,days:C,rangeStart:w,rangeEnd:x,expanded:g,children:u,loose:f,colorFirst:m,onlyScheduled:o}=G,B(),T.hidden=!0,X(`已打开 ${G.name}`));return}const M=k.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(M||"")){ee(M,k);return}if(M==="unplanned"){Ys(k.dataset.person,k);return}if(M==="close-detail"&&(P.hidden=!0),M==="unschedule"&&(ue(P.dataset.item,{start:null,end:null}),P.hidden=!0),(M==="plus"||M==="minus")&&(h=Math.max(0,Math.min(4,h+(M==="plus"?1:-1))),B()),(M==="prev"||M==="next"||M==="today")&&(v=M==="today"?J(s)-new Date(`${s}T00:00:00Z`).getUTCDay():v+(M==="prev"?-14:14),w=le(v),x=le(v+59),D.scrollLeft=0,B()),(M==="asc"||M==="desc"||M==="clear-sort")&&(c=M==="desc",M==="clear-sort"&&(d=""),B(),T.hidden=!0),M==="clear-filter"&&(a="",r="",B(),T.hidden=!0),["compact","loose","content","color"].includes(M||"")&&(M==="compact"||M==="loose"?f=M==="loose":m=M==="color",B(),T.hidden=!0,ee("settings",I('[data-action="settings"]'))),(M==="cal-prev"||M==="cal-next")&&(j=new Date(Date.UTC(j.getUTCFullYear(),j.getUTCMonth()+(M==="cal-prev"?-1:1),1)),Se()),M==="save-view"){const G=T.querySelector("[data-view-name]").value.trim();if(!G)return;const W=at();W.push({name:G,selected:[...n],query:a,status:r,sort:d,descending:c,zoom:h,from:v,days:C,rangeStart:w,rangeEnd:x,expanded:g,children:u,loose:f,colorFirst:m,onlyScheduled:o});try{localStorage.setItem(Kt,JSON.stringify(W)),T.hidden=!0,X("视图已保存")}catch{X("浏览器存储不可用,视图未保存")}}M==="schedule"&&(T.hidden=!0,P.hidden=!0)},{signal:S}),N.addEventListener("input",E=>{const R=E.target;R.classList.contains("ps-zoom")&&(h=Number(R.value),B()),R.classList.contains("ps-person-search")&&T.querySelectorAll(".ps-person-options label").forEach(k=>{var M;return k.hidden=!((M=k.textContent)!=null&&M.includes(R.value))}),R.dataset.control==="query"&&(a=R.value,B())},{signal:S}),N.addEventListener("change",E=>{const R=E.target;if(R.dataset.person&&(R.checked?n.add(R.dataset.person):n.delete(R.dataset.person),B()),R.dataset.estimate){const k=Number(R.value);Number.isFinite(k)&&k>=0&&ue(R.dataset.estimate,{estimate:k});return}switch(R.dataset.control){case"only":o=R.checked;break;case"sort":d=R.value;break;case"status":r=R.value;break;case"expanded":g=R.checked;break;case"children":u=R.checked;break;case"range-start":R.value&&(w=R.value,xe(),Se());return;case"range-end":R.value&&(x=R.value,xe(),Se());return}B()},{signal:S}),P.addEventListener("submit",E=>{E.preventDefault();const R=new FormData(E.target),k=String(R.get("start")||"")||null,M=String(R.get("end")||"")||null;if(!!k!=!!M||k&&M&&k>M){P.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ue(P.dataset.item,{name:String(R.get("name")),personId:String(R.get("personId")),estimate:Number(R.get("estimate")),start:k,end:M}),P.hidden=!0,X("排期已更新")},{signal:S}),document.addEventListener("pointerdown",E=>{N.contains(E.target)?!T.contains(E.target)&&!E.target.closest("[data-action]")&&(T.hidden=!0):T.hidden=!0},{signal:S}),N.addEventListener("keydown",E=>{E.key==="Escape"&&(T.hidden=!0,P.hidden=!0)},{signal:S});let q=null;return _.addEventListener("pointerdown",E=>{const R=E.target,k=R.closest(".ps-bar");if(!k||E.button!==0)return;const M=t.find(G=>G.id===k.dataset.item);y=!1,q={id:M.id,x:E.clientX,start:J(M.start),end:J(M.end),edge:R.dataset.edge||"move",bar:k,left:parseFloat(k.style.left),size:parseFloat(k.style.width),delta:0,scroll:D.scrollLeft}},{signal:S}),document.addEventListener("pointermove",E=>{if(!q)return;const R=Math.round((E.clientX-q.x+D.scrollLeft-q.scroll)/A());q.delta=q.edge==="start"?Math.min(R,q.end-q.start):q.edge==="end"?Math.max(R,q.start-q.end):R,Math.abs(E.clientX-q.x)>4&&(y=!0),y&&(q.bar.style.opacity=".8",q.edge==="move"?q.bar.style.transform=`translateX(${q.delta*A()}px)`:(q.bar.style.left=`${q.left+(q.edge==="start"?q.delta*A():0)}px`,q.bar.style.width=`${q.size+(q.edge==="start"?-1:1)*q.delta*A()}px`))},{signal:S}),document.addEventListener("pointerup",()=>{if(!q)return;const E=q;q=null,y&&(ue(E.id,{start:le(E.start+(E.edge==="end"?0:E.delta)),end:le(E.end+(E.edge==="start"?0:E.delta))}),X("排期已更新"))},{signal:S}),B(),{setData(E,R){rt(E,R),i=structuredClone(E),t=structuredClone(R),n=new Set(i.map(k=>k.id)),T.hidden=!0,P.hidden=!0,B()},getItems:()=>structuredClone(t),updateItem:ue,setPeople(E){n=new Set(E.filter(R=>i.some(k=>k.id===R))),B()},destroy(){b=!0,F.abort(),clearTimeout(L),N.remove()}}}function Ks(l,e){const i=new Re(l,e);return{api:i.getApi(),columnApi:i.getColumnApi(),grid:i}}function Xs(l,e){We[l]=e}function js(l,e){fe[l]=e}z.CELL_EDITORS=fe,z.CELL_RENDERERS=We,z.DEFAULT_LOCALE_TEXT=Rt,z.FORMULA_FUNCTIONS=Be,z.GANTT_UNITS=Ht,z.GanttChart=Vt,z.Grid=Re,z.UNIT_LABEL=qe,z.computeStickyGroupRows=Tt,z.createDetailDialog=Gt,z.createGantt=Ws,z.createGrid=Ks,z.createPersonnelSchedule=qs,z.createSparklineSvg=tt,z.default=Re,z.evaluateFormula=De,z.formatNumberCommas=ae,z.isFormula=Je,z.parse=vt,z.registerEditor=js,z.registerFormulaFunction=oi,z.registerRenderer=Xs,z.tokenize=ft,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
37
+ <footer class="ps-total"></footer><div class="ps-popover" hidden></div><aside class="ps-detail" hidden></aside><div class="ps-toast" role="status" hidden></div>`,l.append(N);const I=E=>N.querySelector(E),D=I(".ps-scroll"),W=I(".ps-rows"),T=I(".ps-popover"),A=I(".ps-detail"),F=new AbortController,S=F.signal;let L;const P=()=>[22,43,64,86,120][h],O=()=>i.filter(E=>(!a||E.name.includes(a))&&(!r||E.status===r)&&(p||!E.parentId)),V=()=>{const E=O();return t.filter(R=>n.has(R.id)&&(!o||E.some(k=>k.personId===R.id&&$e(k)))).sort((R,k)=>{if(!d)return 0;const M=je(E.filter(_=>_.personId===R.id)),G=je(E.filter(_=>_.personId===k.id));return(d==="estimate"?M.estimate-G.estimate:M.scheduled-G.scheduled)*(c?-1:1)})};function X(E){const R=I(".ps-toast");R.textContent=E,R.hidden=!1,clearTimeout(L),L=setTimeout(()=>R.hidden=!0,2200)}function B(){if(b)return;const E=P(),R=C*E;I(".ps-table").style.width=`${R+200}px`;const k=`${w.slice(0,4)}年 第${Number(w.slice(5,7))}-${Number(x.slice(5,7))}月`;I(".ps-date-label").textContent=k,I('[data-action="people"]').textContent=`◎ 人员筛选 · ${n.size}人`,I(".ps-zoom").value=String(h);const M=I(".ps-weeks");M.replaceChildren();for(let te=0;te<C;te+=7){const ve=document.createElement("span");ve.style.width=`${Math.min(7,C-te)*E}px`,ve.textContent=`${le(v+te).slice(5).replace("-","/")}~${le(v+te+6).slice(5).replace("-","/")}`,M.append(ve)}W.replaceChildren();const G=O(),_=V();for(const te of _){const ve=G.filter(U=>U.personId===te.id),dt=je(ve),ct=Us(ve,g),Qs=Math.max(0,...ct.map(U=>U.lane)),Zs=Math.max(m?154:126,60+(Qs+1)*(m?48:36)),He=document.createElement("div");He.className="ps-person-row",He.style.height=`${Zs}px`,He.dataset.person=te.id;const Ye=document.createElement("div");Ye.className="ps-person",Ye.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${K(te.name)}</strong></div><div>已排期项 <b>${dt.scheduled}</b></div><div>总估分 <b>${dt.estimate.toFixed(2)}</b></div><div>未排期·${dt.unscheduled}<button data-action="unplanned" data-person="${K(te.id)}">查看</button></div>`;const Xt=Ye.querySelector(".ps-avatar");Xt.textContent=te.name.slice(-2),Xt.style.background=te.color||Ut[t.indexOf(te)%Ut.length];const Ce=document.createElement("div");Ce.className="ps-timeline",Ce.style.width=`${R}px`,Ce.style.setProperty("--day",`${E}px`);for(let U=0;U<C;U++)if([0,6].includes(new Date((v+U)*864e5).getUTCDay())){const Ie=document.createElement("i");Ie.className="ps-weekend",Ie.style.left=`${U*E}px`,Ie.style.width=`${E}px`,Ce.append(Ie)}const ht=J(s)-v;if(ht>=0&&ht<C){const U=document.createElement("i");U.className="ps-today",U.style.left=`${(ht+.5)*E}px`,Ce.append(U)}for(const{item:U,lane:Ie}of ct){const jt=J(U.start),Yt=J(U.end);if(Yt<v||jt>=v+C)continue;const Qt=Math.max(0,jt-v)*E,Js=Math.min(C,Yt-v+1)*E,pe=document.createElement("button");pe.className=`ps-bar ${f?"ps-color":"ps-content"}`,pe.dataset.item=U.id,pe.setAttribute("aria-label",`${U.name},${U.start} 至 ${U.end}`),pe.style.left=`${Qt}px`,pe.style.width=`${Js-Qt}px`,pe.style.top=`${52+Ie*(m?48:36)}px`,pe.style.setProperty("--bar-color",U.color||"#8cafeb"),pe.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${K(U.name)}</span><span class="ps-status">${K(U.status)}</span><span class="ps-node">● ${K(U.node)}</span><span class="ps-effort">${U.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,Ce.append(pe)}if(!ct.length){const U=document.createElement("span");U.className="ps-no-schedule",U.textContent="暂无排期",Ce.append(U)}He.append(Ye,Ce),W.append(He)}_.length||(W.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const re=G.filter(te=>_.some(ve=>ve.id===te.personId));I(".ps-total").textContent=`ⓘ 总人数 ${_.length} 总估分 ${je(re).estimate.toFixed(2)} pd ···`}function ee(E,R){if(!T.hidden&&T.dataset.kind===E){T.hidden=!0;return}T.dataset.kind=E,T.hidden=!1;const k=N.getBoundingClientRect(),M=R==null?void 0:R.getBoundingClientRect();if(T.style.left=`${Math.max(12,Math.min(((M==null?void 0:M.left)??k.left)-k.left,N.clientWidth-(E==="unplanned"?760:420)-16))}px`,T.style.top=`${M?M.bottom-k.top+6:96}px`,T.className=`ps-popover ps-panel-${E}`,E==="people")T.innerHTML=`<div class="ps-panel-title">包含 ${n.size} 人<label><input type="checkbox" data-control="only" ${o?"checked":""}>仅查看有排期的用户</label></div><div class="ps-person-filter"><span>甘特图显示人员</span><span>包含</span><span>全部排期人员</span></div><input class="ps-person-search" placeholder="搜索人员" aria-label="搜索人员"><div class="ps-person-options">${t.map(G=>`<label><input type="checkbox" data-person="${K(G.id)}" ${n.has(G.id)?"checked":""}>${K(G.name)}</label>`).join("")}</div>`;else if(E==="sort")T.innerHTML=`<div class="ps-panel-title">设置排序条件 ⓘ</div><div class="ps-sort-fields"><select aria-label="排序字段" data-control="sort"><option value="">请选择排序项</option><option value="estimate">总估分</option><option value="scheduled">已排期项</option></select><button data-action="asc" class="${c?"":"selected"}">小 → 大</button><button data-action="desc" class="${c?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,T.querySelector("select").value=d;else if(E==="filter")T.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${K(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${K(a)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(G=>G.status))].map(G=>`<option>${K(G)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,T.querySelector("select").value=r;else if(E==="settings")T.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${g?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${p?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${m?"":"selected"}">紧凑</button><button data-action="loose" class="${m?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${f?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${f?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(E==="date")Se();else if(E==="save")T.innerHTML='<div class="ps-panel-title">存为视图</div><input data-view-name placeholder="视图名称" aria-label="视图名称"><button class="ps-primary" data-action="save-view">保存</button>';else if(E==="views"){const G=at();T.innerHTML=`<div class="ps-panel-title">视图列表</div>${G.length?G.map((_,re)=>`<button class="ps-view" data-view="${re}">▦ ${K(_.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let j=new Date(`${w}T00:00:00Z`),Te=!1;function Se(){let E=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${w}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${x}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let R=0;R<2;R++){const k=new Date(Date.UTC(j.getUTCFullYear(),j.getUTCMonth()+R,1));E+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${k.getUTCFullYear()}年 ${k.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(G=>`<span>${G}</span>`).join("")}`;for(let G=0;G<k.getUTCDay();G++)E+="<span></span>";const M=new Date(Date.UTC(k.getUTCFullYear(),k.getUTCMonth()+1,0)).getUTCDate();for(let G=1;G<=M;G++){const _=le(Date.UTC(k.getUTCFullYear(),k.getUTCMonth(),G)/864e5);E+=`<button data-date="${_}" class="${_>=w&&_<=x?"in-range":""} ${_===w||_===x?"selected":""}">${G}</button>`}E+="</div></div>"}T.innerHTML=E+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((R,k)=>`<button data-preset="${k}">${R}</button>`).join("")}</div>`}function xe(){x<w&&([w,x]=[x,w]),v=J(w),v-=new Date(v*864e5).getUTCDay(),C=Math.max(35,J(x)-v+8),D.scrollLeft=0,B()}function ue(E,R){var G;if(!i.some(_=>_.id===E))throw new Error(`Unknown schedule item: ${E}`);const k=i.map(_=>_.id===E?{..._,...R}:_);rt(t,k),i=k,B();const M=i.find(_=>_.id===E);M&&((G=e.onItemChange)==null||G.call(e,structuredClone(M)))}function qt(E){var k;const R=i.find(M=>M.id===E);(k=e.onItemOpen)==null||k.call(e,structuredClone(R)),A.hidden=!1,A.dataset.item=E,A.innerHTML=`<header><strong>${K(R.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${K(R.status)}</span><h3>● ${K(R.node)}</h3><form><label>名称<input name="name" required value="${K(R.name)}"></label><label>负责人<select name="personId">${t.map(M=>`<option value="${K(M.id)}" ${M.id===R.personId?"selected":""}>${K(M.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${R.estimate}" required></label><label>开始日期<input type="date" name="start" value="${R.start||""}"></label><label>结束日期<input type="date" name="end" value="${R.end||""}"></label><p class="ps-error" role="alert"></p><button class="ps-primary" type="submit">保存排期</button><button type="button" data-action="unschedule">移至未排期</button></form></div>`}function Ys(E,R){ee("unplanned",R),T.hidden=!1;const k=t.find(M=>M.id===E);T.innerHTML=`<div class="ps-panel-title">未排期工作项 ${K(k.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(M=>M.personId===E&&!$e(M)).map(M=>`<tr><td><button data-open="${K(M.id)}">${K(M.name)}</button></td><td>● ${K(M.node)}</td><td><input type="number" min="0" step="0.1" value="${M.estimate||""}" placeholder="待填" data-estimate="${K(M.id)}" aria-label="${K(M.name)}估分"></td><td><button class="ps-link" data-open="${K(M.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const Kt=e.viewStorageKey??"rowvia-personnel-views-v1";function at(){try{const E=JSON.parse(localStorage.getItem(Kt)||"[]");return Array.isArray(E)?E:[]}catch{return[]}}N.addEventListener("click",E=>{const R=E.target,k=R.closest("button");if(!k)return;if(k.dataset.open){T.hidden=!0,qt(k.dataset.open);return}if(k.dataset.item){y||qt(k.dataset.item);return}if(k.dataset.date){Te?(x=k.dataset.date,Te=!1,xe()):(w=k.dataset.date,x=w,Te=!0),Se();return}if(k.dataset.preset){const G=Number(k.dataset.preset),_=J(s),re=new Date(_*864e5);w=le(G<2?_-re.getUTCDay():G<4?Date.UTC(re.getUTCFullYear(),re.getUTCMonth(),1)/864e5:_),x=le(G===2||G===3?Date.UTC(re.getUTCFullYear(),re.getUTCMonth()+(G===2?1:2),0)/864e5:J(w)+[6,13,29,60,13,59,364][G]),Te=!1,xe(),T.hidden=!0;return}if(k.dataset.view){const G=at()[Number(k.dataset.view)];G&&(n=new Set(G.selected.filter(_=>t.some(re=>re.id===_))),{query:a,status:r,sort:d,descending:c,zoom:h,from:v,days:C,rangeStart:w,rangeEnd:x,expanded:g,children:p,loose:m,colorFirst:f,onlyScheduled:o}=G,B(),T.hidden=!0,X(`已打开 ${G.name}`));return}const M=k.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(M||"")){ee(M,k);return}if(M==="unplanned"){Ys(k.dataset.person,k);return}if(M==="close-detail"&&(A.hidden=!0),M==="unschedule"&&(ue(A.dataset.item,{start:null,end:null}),A.hidden=!0),(M==="plus"||M==="minus")&&(h=Math.max(0,Math.min(4,h+(M==="plus"?1:-1))),B()),(M==="prev"||M==="next"||M==="today")&&(v=M==="today"?J(s)-new Date(`${s}T00:00:00Z`).getUTCDay():v+(M==="prev"?-14:14),w=le(v),x=le(v+59),D.scrollLeft=0,B()),(M==="asc"||M==="desc"||M==="clear-sort")&&(c=M==="desc",M==="clear-sort"&&(d=""),B(),T.hidden=!0),M==="clear-filter"&&(a="",r="",B(),T.hidden=!0),["compact","loose","content","color"].includes(M||"")&&(M==="compact"||M==="loose"?m=M==="loose":f=M==="color",B(),T.hidden=!0,ee("settings",I('[data-action="settings"]'))),(M==="cal-prev"||M==="cal-next")&&(j=new Date(Date.UTC(j.getUTCFullYear(),j.getUTCMonth()+(M==="cal-prev"?-1:1),1)),Se()),M==="save-view"){const G=T.querySelector("[data-view-name]").value.trim();if(!G)return;const _=at();_.push({name:G,selected:[...n],query:a,status:r,sort:d,descending:c,zoom:h,from:v,days:C,rangeStart:w,rangeEnd:x,expanded:g,children:p,loose:m,colorFirst:f,onlyScheduled:o});try{localStorage.setItem(Kt,JSON.stringify(_)),T.hidden=!0,X("视图已保存")}catch{X("浏览器存储不可用,视图未保存")}}M==="schedule"&&(T.hidden=!0,A.hidden=!0)},{signal:S}),N.addEventListener("input",E=>{const R=E.target;R.classList.contains("ps-zoom")&&(h=Number(R.value),B()),R.classList.contains("ps-person-search")&&T.querySelectorAll(".ps-person-options label").forEach(k=>{var M;return k.hidden=!((M=k.textContent)!=null&&M.includes(R.value))}),R.dataset.control==="query"&&(a=R.value,B())},{signal:S}),N.addEventListener("change",E=>{const R=E.target;if(R.dataset.person&&(R.checked?n.add(R.dataset.person):n.delete(R.dataset.person),B()),R.dataset.estimate){const k=Number(R.value);Number.isFinite(k)&&k>=0&&ue(R.dataset.estimate,{estimate:k});return}switch(R.dataset.control){case"only":o=R.checked;break;case"sort":d=R.value;break;case"status":r=R.value;break;case"expanded":g=R.checked;break;case"children":p=R.checked;break;case"range-start":R.value&&(w=R.value,xe(),Se());return;case"range-end":R.value&&(x=R.value,xe(),Se());return}B()},{signal:S}),A.addEventListener("submit",E=>{E.preventDefault();const R=new FormData(E.target),k=String(R.get("start")||"")||null,M=String(R.get("end")||"")||null;if(!!k!=!!M||k&&M&&k>M){A.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ue(A.dataset.item,{name:String(R.get("name")),personId:String(R.get("personId")),estimate:Number(R.get("estimate")),start:k,end:M}),A.hidden=!0,X("排期已更新")},{signal:S}),document.addEventListener("pointerdown",E=>{N.contains(E.target)?!T.contains(E.target)&&!E.target.closest("[data-action]")&&(T.hidden=!0):T.hidden=!0},{signal:S}),N.addEventListener("keydown",E=>{E.key==="Escape"&&(T.hidden=!0,A.hidden=!0)},{signal:S});let q=null;return W.addEventListener("pointerdown",E=>{const R=E.target,k=R.closest(".ps-bar");if(!k||E.button!==0)return;const M=i.find(G=>G.id===k.dataset.item);y=!1,q={id:M.id,x:E.clientX,start:J(M.start),end:J(M.end),edge:R.dataset.edge||"move",bar:k,left:parseFloat(k.style.left),size:parseFloat(k.style.width),delta:0,scroll:D.scrollLeft}},{signal:S}),document.addEventListener("pointermove",E=>{if(!q)return;const R=Math.round((E.clientX-q.x+D.scrollLeft-q.scroll)/P());q.delta=q.edge==="start"?Math.min(R,q.end-q.start):q.edge==="end"?Math.max(R,q.start-q.end):R,Math.abs(E.clientX-q.x)>4&&(y=!0),y&&(q.bar.style.opacity=".8",q.edge==="move"?q.bar.style.transform=`translateX(${q.delta*P()}px)`:(q.bar.style.left=`${q.left+(q.edge==="start"?q.delta*P():0)}px`,q.bar.style.width=`${q.size+(q.edge==="start"?-1:1)*q.delta*P()}px`))},{signal:S}),document.addEventListener("pointerup",()=>{if(!q)return;const E=q;q=null,y&&(ue(E.id,{start:le(E.start+(E.edge==="end"?0:E.delta)),end:le(E.end+(E.edge==="start"?0:E.delta))}),X("排期已更新"))},{signal:S}),B(),{setData(E,R){rt(E,R),t=structuredClone(E),i=structuredClone(R),n=new Set(t.map(k=>k.id)),T.hidden=!0,A.hidden=!0,B()},getItems:()=>structuredClone(i),updateItem:ue,setPeople(E){n=new Set(E.filter(R=>t.some(k=>k.id===R))),B()},destroy(){b=!0,F.abort(),clearTimeout(L),N.remove()}}}function Ks(l,e){const t=new Re(l,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function Xs(l,e){_e[l]=e}function js(l,e){fe[l]=e}z.CELL_EDITORS=fe,z.CELL_RENDERERS=_e,z.DEFAULT_LOCALE_TEXT=Rt,z.FORMULA_FUNCTIONS=Be,z.GANTT_UNITS=Ht,z.GanttChart=Vt,z.Grid=Re,z.UNIT_LABEL=qe,z.computeStickyGroupRows=Tt,z.createDetailDialog=Gt,z.createGantt=_s,z.createGrid=Ks,z.createPersonnelSchedule=qs,z.createSparklineSvg=tt,z.default=Re,z.evaluateFormula=De,z.formatNumberCommas=ae,z.isFormula=Je,z.parse=vt,z.registerEditor=js,z.registerFormulaFunction=oi,z.registerRenderer=Xs,z.tokenize=ft,Object.defineProperties(z,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});