rowvia 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +1,120 @@
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
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} >>
1
+ (function(re,$e){typeof exports=="object"&&typeof module<"u"?$e(exports):typeof define=="function"&&define.amd?define(["exports"],$e):(re=typeof globalThis<"u"?globalThis:re||self,$e(re.Rowvia={}))})(this,function(re){"use strict";var fa=Object.defineProperty;var ma=(re,$e,rt)=>$e in re?fa(re,$e,{enumerable:!0,configurable:!0,writable:!0,value:rt}):re[$e]=rt;var v=(re,$e,rt)=>ma(re,typeof $e!="symbol"?$e+"":$e,rt);class $e{constructor(){v(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 n=i.indexOf(t);n>=0&&i.splice(n,1)}dispatchEvent(e,t){const i=this.listeners.get(e);if(!i||i.length===0)return;const n={type:e,...t||{}};for(const o of i.slice())o(n)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const rt=13,Dn=27,Ri=9,Mi=8,ki=46,An=36,Fn=35;function Et(s){return s==null?"":String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}let Pn=0;function ti(s="id"){return`${s}-${++Pn}`}function Ke(s,e){if(typeof s!="number"||isNaN(s))return String(s??"");const t=e??0,i=s.toFixed(t),[n,o]=i.split("."),a=n.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${a}.${o}`:a}function ii(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function $n(s,e){if(s===e)return 0;if(s==null)return-1;if(e==null)return 1;if(typeof s=="number"&&typeof e=="number")return s-e;if(s instanceof Date&&e instanceof Date)return s.getTime()-e.getTime();const t=String(s).toLowerCase(),i=String(e).toLowerCase();return t<i?-1:t>i?1:0}function Gn(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ge extends Error{constructor(e){super(e),this.code=e}}const Hn=/^\$?[A-Za-z]{1,3}\$?\d+$/;function Ti(s){const e=[];let t=0;for(;t<s.length;){const i=s[t];if(i===" "||i===" "||i===`
2
+ `||i==="\r"){t++;continue}if(i==='"'||i==="'"){const o=i;let a="";for(t++;t<s.length&&s[t]!==o;)a+=s[t++];t++,e.push({type:"string",value:a});continue}if(/[0-9]/.test(i)||i==="."&&/[0-9]/.test(s[t+1]||"")){let o="";for(;t<s.length&&/[0-9.]/.test(s[t]);)o+=s[t++];if(s[t]==="e"||s[t]==="E")for(o+=s[t++],(s[t]==="+"||s[t]==="-")&&(o+=s[t++]);t<s.length&&/[0-9]/.test(s[t]);)o+=s[t++];e.push({type:"number",value:o});continue}if(/[A-Za-z_$]/.test(i)){let o="";for(;t<s.length&&/[A-Za-z0-9_$.]/.test(s[t]);)o+=s[t++];Hn.test(o)?e.push({type:"cell",value:o.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:o});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 n=s.slice(t,t+2);if(["<=",">=","<>"].includes(n)){e.push({type:"op",value:n}),t+=2;continue}if("+-*/^%&=<>,:".includes(i)){e.push({type:"op",value:i}),t++;continue}throw new Ge("#NAME?")}return e}const Ni={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function Ii(s){let e=0;const t=()=>s[e],i=()=>s[e++];function n(l=0){let c=o();for(;t()&&t().type==="op"&&Ni[t().value]>=l;){const d=i().value,u=n(Ni[d]+1);c={type:"binary",operator:d,left:c,right:u}}return c}function o(){const l=t();if(l&&l.type==="op"&&(l.value==="-"||l.value==="+")){i();const c=o();return l.value==="-"?{type:"unary",operator:"-",operand:c}:c}return a()}function a(){const l=i();if(!l)throw new Ge("#ERROR!");if(l.type==="number")return{type:"number",value:Number(l.value)};if(l.type==="string")return{type:"string",value:l.value};if(l.type==="cell")return{type:"cell",value:l.value};if(l.type==="ident"){const c=l.value.toUpperCase();if(c==="TRUE")return{type:"boolean",value:!0};if(c==="FALSE")return{type:"boolean",value:!1};const d=t();if(d&&d.type==="lparen"){i();const u=[];if(t()&&t().type!=="rparen")for(u.push(n());t()&&t().type==="comma";)i(),u.push(n());if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return i(),{type:"call",name:c,args:u}}return{type:"ref",value:l.value}}if(l.type==="lparen"){const c=n();if(!t()||t().type!=="rparen")throw new Ge("#ERROR!");return i(),c}throw new Ge("#ERROR!")}const r=n();if(e<s.length)throw new Ge("#ERROR!");return r}function ce(s){if(s==null||s==="")return 0;if(typeof s=="number")return s;if(typeof s=="boolean")return s?1:0;if(s instanceof Date)return s.getTime();const e=Number(s);return isNaN(e)?0:e}function ft(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...ft(t));else if(t!=null&&t!==""){const i=typeof t=="number"?t:Number(t);isNaN(i)||e.push(i)}return e}const Gt={SUM:s=>ft(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=ft(s);return e.length?e.reduce((t,i)=>t+i,0)/e.length:0},AVG:s=>Gt.AVERAGE(s,{}),MIN:s=>{const e=ft(s);return e.length?Math.min(...e):0},MAX:s=>{const e=ft(s);return e.length?Math.max(...e):0},COUNT:s=>ft(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(ce(s[0])),ROUND:s=>{const e=s.length>1?ce(s[1]):0,t=Math.pow(10,e);return Math.round(ce(s[0])*t)/t},FLOOR:s=>Math.floor(ce(s[0])),CEIL:s=>Math.ceil(ce(s[0])),CEILING:s=>Math.ceil(ce(s[0])),SQRT:s=>{const e=ce(s[0]);return e<0?(()=>{throw new Ge("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(ce(s[0]),ce(s[1])),POW:s=>Math.pow(ce(s[0]),ce(s[1])),MOD:s=>{const e=ce(s[1]);if(e===0)throw new Ge("#DIV/0!");return ce(s[0])%e},CONCAT:s=>s.map(e=>e==null?"":String(e)).join(""),CONCATENATE:s=>s.map(e=>e==null?"":String(e)).join(""),UPPER:s=>String(s[0]??"").toUpperCase(),LOWER:s=>String(s[0]??"").toLowerCase(),LEN:s=>String(s[0]??"").length,LEFT:s=>String(s[0]??"").slice(0,s.length>1?ce(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?ce(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,ce(s[1])-1),i=s.length>2?ce(s[2]):e.length-t;return e.slice(t,t+i)},TRIM:s=>String(s[0]??"").trim(),IF:s=>s[0]?s[1]??!0:s[2]??!1,IFS:s=>{for(let e=0;e<s.length-1;e+=2)if(s[e])return s[e+1];return s.length%2===1?s[s.length-1]:!1},AND:s=>s.every(e=>!!e),OR:s=>s.some(e=>!!e),NOT:s=>!s[0],IFERROR:s=>{try{return s[0]===null||s[0]===void 0?s[1]:s[0]}catch{return s[1]}},ISNUMBER:s=>typeof s[0]=="number"||s[0]!==null&&s[0]!==""&&!isNaN(Number(s[0])),ISBLANK:s=>s[0]===null||s[0]===void 0||s[0]==="",ISTEXT:s=>typeof s[0]=="string",PI:()=>Math.PI,RAND:()=>Math.random(),TODAY:()=>new Date().toISOString().slice(0,10),NOW:()=>new Date().toISOString(),YEAR:s=>new Date(s[0]).getFullYear(),MONTH:s=>new Date(s[0]).getMonth()+1,DAY:s=>new Date(s[0]).getDate(),TEXT:s=>String(s[0]??""),VALUE:s=>ce(s[0]),NUMBER:s=>ce(s[0]),BETWEEN:s=>ce(s[0])>=ce(s[1])&&ce(s[0])<=ce(s[2])},Ht=Object.keys(Gt);function On(s,e){Gt[s.toUpperCase()]=e,Ht.includes(s.toUpperCase())||Ht.push(s.toUpperCase())}function Bn(s,e){const t=/^([A-Za-z]{1,3})(\d+)$/.exec(s);if(t&&e.a1Lookup)return e.a1Lookup(t[1].toUpperCase(),Number(t[2]))}function Vn(s,e){const t=e.data||{};if(s in t)return t[s];const i=s.toLowerCase();for(const n of Object.keys(t))if(n.toLowerCase()===i)return t[n]}function Rt(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return Vn(s.value,e);case"cell":return Bn(s.value,e);case"unary":return-ce(Rt(s.operand,e));case"call":{const t=Gt[s.name];if(!t)throw new Ge("#NAME?");const i=s.args.map(n=>Rt(n,e));return t(i,e)}case"binary":{const t=Rt(s.left,e),i=Rt(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:ce(t)+ce(i);case"-":return ce(t)-ce(i);case"*":return ce(t)*ce(i);case"/":{const n=ce(i);if(n===0)throw new Ge("#DIV/0!");return ce(t)/n}case"^":return Math.pow(ce(t),ce(i));case"%":{const n=ce(i);if(n===0)throw new Ge("#DIV/0!");return ce(t)%n}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return ce(t)<ce(i);case"<=":return ce(t)<=ce(i);case">":return ce(t)>ce(i);case">=":return ce(t)>=ce(i);default:throw new Ge("#ERROR!")}}default:throw new Ge("#ERROR!")}}function Mt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,i=Ii(Ti(t));return Rt(i,e)}function ni(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function oi(s,e){if(s==null)return;if(e in s)return s[e];const t=e.split(".");let i=s;for(const n of t){if(i==null)return;i=i[n]}return i}function de(s,e,t){const i=s.colDef,n=(e.group||e.footer)&&!!e.groupData&&e.groupData[s.colId]!==void 0,o=n?e.groupData:e.data,a=s.valueGetter??i.valueGetter;if(a)return(typeof a=="string"?l=>ni(a)?Mt(a,{data:l.data}):oi(l.data,a):a)({data:n?e.groupData:e.data,node:e,column:s,api:t,colDef:i,getValue:l=>oi(n?e.groupData:e.data,l)});if(s.field&&ni(s.field))return Mt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return Mt(`=${s.field}`,{data:e.data});if(s.field)return oi(o,s.field)}function Ot(s,e,t){var o;let i=de(s,e,t);const n=s.colDef;if(n.showValueAs&&typeof i=="number"&&t){const a=(o=t.__columnTotalCache)==null?void 0:o.get(s.colId);if(a!==void 0&&a!==0)return`${(n.showValueAs==="percentOfParent"?i/(a||1)*100:i/a*100).toFixed(1)}%`}return n.valueFormatter?(typeof n.valueFormatter=="string"?r=>zn(r.colDef.valueFormatter,r.value,r):n.valueFormatter)({value:i,data:e.data,node:e,column:s,api:t,colDef:n}):Wn(s,i)}function zn(s,e,t={}){var i,n,o;if(e==null)return"";switch(s){case"number":return Ke(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${Ke(e,((n=t.column)==null?void 0:n.decimals)??2)}`;case"percent":return`${Ke(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Li(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Li(s){const e=s instanceof Date?s:new Date(s);return isNaN(e.getTime())?String(s):`${e.getDate()} ${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][e.getMonth()]} ${e.getFullYear()}`}function Wn(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?Ke(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Li(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Di(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?i=>Ai(i.colDef.valueParser,i.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Ai(s.type,e)}function Ai(s,e){if(s==="numberColumn")return ii(e);if(s==="dateColumn"){if(e instanceof Date)return e;const t=new Date(e);return isNaN(t.getTime())?e:t}return s==="booleanColumn"?e===!0||e==="true":e}function Fi(s){const t=s.colDef.comparator,i=s.type;return(n,o)=>{const a=de(s,n,null),r=de(s,o,null);if(t)return t(a,r,n,o);if(i==="numberColumn"){const l=typeof a=="number"?a:ii(a),c=typeof r=="number"?r:ii(r);return l!==null&&c!==null?l-c:l===null&&c===null?0:l===null?-1:1}if(i==="dateColumn"){const l=a instanceof Date?a.getTime():new Date(a).getTime(),c=r instanceof Date?r.getTime():new Date(r).getTime();if(!isNaN(l)&&!isNaN(c))return l-c}return $n(a,r)}}function kt(s,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:s,rowNode:null,data:null});const i=t.filter(n=>typeof n=="number"&&!isNaN(n));switch(e){case"sum":return i.reduce((n,o)=>n+o,0);case"count":return t.length;case"avg":return i.length?i.reduce((n,o)=>n+o,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 Un={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 _n(s){if(s===void 0||s===!0)return"text";if(s===!1)return!1;switch(s){case"agTextColumnFilter":return"text";case"agNumberColumnFilter":return"number";case"agDateColumnFilter":case"agDateColumnFilterString":return"date";case"agSetColumnFilter":return"set";default:return s}}function qn(s){return!!s.treeData}function Kn(){return{applyAggregate:kt}}class Pi{constructor(e,t,i){v(this,"options");v(this,"eventService");v(this,"gridApi");v(this,"measureCtx",null);v(this,"gridColumnDefs",[]);v(this,"columns",[]);v(this,"displayOrder",[]);v(this,"autoGroupColumnDef");v(this,"pivotMode",!1);v(this,"columnGroups",[]);v(this,"openGroups",new Set);v(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=$i){if(!e||e.length===0)return[];const i=e[0];if(!i||typeof i!="object")return[];const n=new Set(["children","detail","__proto__"]),o=[];for(const a of Object.keys(i)){if(n.has(a)||a.startsWith("__"))continue;const r=i[a],l={field:a,headerName:t(a)};typeof r=="number"?(l.type="numberColumn",l.filter="number"):typeof r=="boolean"?l.type="booleanColumn":r instanceof Date&&(l.type="dateColumn"),o.push(l)}return o}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 d of e)t.set(d.colId,d);const i=this.options.defaultColDef||{},n={...Un,...this.options.columnTypes||{}},o=[],a=[];let r=0;const l=(d,u)=>{const f=d.colId||d.field||ti("col"),g={...i,...d};if(g.type&&n[g.type]){const p=n[g.type],C=new Set(Object.keys(d));for(const[h,m]of Object.entries(p))!C.has(h)&&!(h in i)&&(g[h]=m)}this.pushColumnInto(o,g,f,r++,t,u)},c=(d,u,f)=>{for(const g of d)if(g.children&&g.children.length){const p=g.groupId||ti("group"),C={id:p,headerName:g.headerName??"",openByDefault:g.openByDefault===!0||g.columnGroupShow==="open",parentId:u,depth:f,childColumnIds:[]};a.push(C),this.groupsInitialised||(C.openByDefault?this.openGroups.add(p):this.openGroups.delete(p)),c(g.children,p,f+1)}else l(g,u)};if(c(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,this.options.rowNumbers){const d={colId:"__rowNumber",headerName:"",width:60,pinned:"left",sortable:!1,filter:!1,resizable:!1,suppressMovable:!0,cellRenderer:"agRowNumberCellRenderer",cellClass:"ag-row-number-cell"};this.pushColumnInto(o,{...i,...d},"__rowNumber",-1,t,null)}for(const d of o){if(!d.groupId)continue;const u=a.find(f=>f.id===d.groupId);u&&u.childColumnIds.push(d.colId)}this.columns=o,this.displayOrder=o.map(d=>d.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,i,n,o){return this.buildColumn(e,t,i,n,o)}pushColumnInto(e,t,i,n,o,a){e.push(this.buildColumn(t,i,n,o,a))}buildColumn(e,t,i,n,o){const a=n.get(t),r=e.hide===!0||e.initialHide===!0,l={colId:t,field:e.field,headerName:e.headerName??(e.field?$i(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:r,visible:!r,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:_n(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:o};return a&&(l.pinned=a.pinned,l.visible=a.visible,l.width=a.width,l.flex=a.flex,l.sort=a.sort,l.sortIndex=a.sortIndex,l.rowGroup=a.rowGroup,l.rowGroupIndex=a.rowGroupIndex,l.pivot=a.pivot,l.pivotIndex=a.pivotIndex),l}updatePivotColumns(e){if(this.columns=this.columns.filter(l=>!l.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(l=>!l.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(l=>l.aggFunc&&!l.rowGroup&&!l.pivot),n=[];for(const l of t){const c=[],d=new Set;for(const u of e){const f=u==null?void 0:u[l.field],g=String(f);d.has(g)||(d.add(g),c.push(f))}c.sort((u,f)=>u===f?0:String(u)<String(f)?-1:1);for(const u of i){for(const p of c){const C=`__pivot_${l.colId}_${u.colId}_${p}`,h=this.createColumn({colId:C,headerName:`${String(p)}`,width:130,type:u.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:u.cellClass,cellDataType:u.cellDataType},C,-1,new Map,null);h.aggFunc=u.aggFunc,h.groupId=l.colId,h.__pivot={pivotColumnId:l.colId,pivotField:l.field,pivotValue:p,valueColumnId:u.colId,valueField:u.field},h.valueGetter=m=>this.evaluatePivotValue(h,m.node),n.push(h)}const f=`__pivot_${l.colId}_${u.colId}_total`,g=this.createColumn({colId:f,headerName:"Total",width:130,type:u.type,sortable:!1,filter:!1,cellDataType:u.cellDataType},f,-1,new Map,null);g.aggFunc=u.aggFunc,g.groupId=l.colId,g.__pivot={pivotColumnId:l.colId,pivotField:l.field,pivotValue:void 0,valueColumnId:u.colId,valueField:u.field},g.valueGetter=p=>this.evaluatePivotValue(g,p.node),n.push(g)}}const o=new Set(t.map(l=>l.colId)),a=this.columns.reduce((l,c,d)=>o.has(c.groupId??"")?l:d,0);this.columns.splice(a+1,0,...n);for(const l of n)this.displayOrder.push(l.colId);const r=new Set(this.columnGroups.map(l=>l.id));for(const l of t)r.has(l.colId)||this.columnGroups.push({id:l.colId,headerName:l.headerName||l.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const i=e.__pivot;if(!i||!t)return;const n=[],o=d=>{if(!d.children||d.children.length===0){n.push(d);return}for(const u of d.children)o(u)};o(t);const r=(i.pivotValue===void 0?n:n.filter(d=>{var u;return String((u=d.data)==null?void 0:u[i.pivotField])===String(i.pivotValue)})).map(d=>{var u;return(u=d.data)==null?void 0:u[i.valueField]}).filter(d=>typeof d=="number");if(r.length===0)return null;const l=this.columns.find(d=>d.colId===i.valueColumnId),{applyAggregate:c}=Kn();return c(l,e.aggFunc,r)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,i=this.getRowGroupColumns(),n=this.options.groupDisplayType||"singleColumn",o=t||i.length>0&&n!=="multipleColumns";for(const d of i)n==="multipleColumns"?(d.cellRenderer="agGroupCellRenderer",d.cellRendererParams={...d.cellRendererParams||{},suppressCount:!0}):d.cellRenderer==="agGroupCellRenderer"&&!d.colDef.cellRenderer&&(d.cellRenderer=void 0,d.cellRendererParams=void 0);const a=this.columns.find(d=>d.colId===e);if(!o){a&&(this.columns=this.columns.filter(d=>d.colId!==e),this.displayOrder=this.displayOrder.filter(d=>d!==e));return}const r={...this.autoGroupColumnDef};if(r.colId=e,a)a.headerName=r.headerName??"",a.colDef=r,a.cellRenderer=r.cellRenderer,a.cellRendererParams=r.cellRendererParams,a.width=r.width??a.width,a.minWidth=r.minWidth??a.minWidth,a.pinned=r.pinned??"left";else{const d=this.createColumn(r,e,-2,new Map,null);this.columns.unshift(d),this.displayOrder.unshift(e)}const l=this.columns.find(d=>d.colId===e),c=()=>this.getRowGroupColumns()[0];l.valueGetter=d=>{const u=d.node;if(!u)return"";if(u.key!==null&&u.key!==void 0)return u.key;if(qn(this.options))return"";const f=c();return f!=null&&f.field&&u.data?u.data[f.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(n=>n.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(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())i.includes(n)||(n.rowGroup=!1,n.rowGroupIndex=null);i.forEach((n,o)=>{n.rowGroup=!0,n.rowGroupIndex=o,n.pivot=!1,n.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 n=this.getRowGroupColumns();i.rowGroup=!0,i.rowGroupIndex=n.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((o,a)=>o.rowGroupIndex=a),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[i]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())i.includes(n)?n.aggFunc||(n.aggFunc="sum"):n.aggFunc&&!n.rowGroup&&(n.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:i}),this.refreshAll()}addValueColumn(e,t="sum",i="api"){const n=this.getColumn(e);n&&(n.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:i,columns:[n]}),this.refreshAll())}setPivotColumns(e,t="api"){const i=e.map(n=>this.getColumn(n)).filter(Boolean);for(const n of this.getColumns())n.pivot=i.includes(n),n.pivotIndex=i.includes(n)?i.indexOf(n):null;this.refreshAll()}setColumnVisible(e,t,i="api"){const n=this.getColumn(e);!n||n.visible===t||(n.hide=!t,n.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:n,visible:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll())}setColumnsVisible(e,t,i="api"){for(const n of e)this.setColumnVisible(n,t,i)}setColumnPinned(e,t,i="api"){const n=this.getColumn(e);n&&(n.lockPosition&&t!==n.pinned||(n.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:n,pinned:t,source:i}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:i}),this.refreshAll()))}setColumnsPinned(e,t,i="api"){for(const n of e)this.setColumnPinned(n,t,i)}moveColumn(e,t,i="api"){const n=this.getColumn(e);n&&this.moveColumnByIndex(this.displayOrder.indexOf(n.colId),t,i)}moveColumnByIndex(e,t,i="api"){const n=this.displayOrder.slice();if(e<0||e>=n.length)return;const[o]=n.splice(e,1);n.splice(Math.max(0,Math.min(n.length,t)),0,o),this.displayOrder=n;const a=this.getColumn(o);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:a,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 n=this.getColumn(i.colId);n&&(i.hide!==void 0&&(n.hide=i.hide,n.visible=!i.hide),i.pinned!==void 0&&(n.pinned=i.pinned),i.width!==void 0&&(n.width=i.width),i.flex!==void 0&&(n.flex=i.flex),i.sort!==void 0&&(n.sort=i.sort),i.sortIndex!==void 0&&(n.sortIndex=i.sortIndex),i.rowGroupIndex!==void 0&&(n.rowGroup=i.rowGroupIndex!==null,n.rowGroupIndex=i.rowGroupIndex),i.pivotIndex!==void 0&&(n.pivot=i.pivotIndex!==null,n.pivotIndex=i.pivotIndex),i.aggFunc!==void 0&&(n.aggFunc=i.aggFunc))}if(t){const i=new Map(e.map(o=>[o.colId,o.colId])),n=this.displayOrder.filter(o=>!i.has(o));this.displayOrder=[...e.map(o=>o.colId).filter(o=>this.getColumn(o)),...n]}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 n of i){let a=0,r=0;for(const c of n)t.includes(c.colId)?r+=c.width:c.flex!==null&&c.flex>0?a+=c.flex:r+=c.width;const l=Math.max(0,e-r-32);if(a>0){for(const c of n)if(c.flex!==null&&c.flex>0&&!t.includes(c.colId)){const d=Math.max(c.minWidth,Math.floor(l*c.flex/a));c.width=Math.min(c.maxWidth,d)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var r,l,c,d,u,f;const i=this.getColumn(e);if(!i)return;let n=this.measureTextWidth(i.headerName)+32;t||(n+=16);const o=((l=(r=this.gridApi)==null?void 0:r.getDisplayedRowCount)==null?void 0:l.call(r))??0,a=Math.min(o,300);for(let g=0;g<a;g++){const p=(d=(c=this.gridApi)==null?void 0:c.getDisplayedRowAtIndex)==null?void 0:d.call(c,g);if(!p)continue;const C=(f=(u=this.gridApi)==null?void 0:u.getCellText)==null?void 0:f.call(u,i,p);C&&(n=Math.max(n,this.measureTextWidth(C)+32))}i.width=Math.max(i.minWidth,Math.min(i.maxWidth,Math.ceil(n))),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 $i(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class tt{constructor(e,t,i){v(this,"id");v(this,"__id");v(this,"data");v(this,"parent",null);v(this,"children",null);v(this,"group",!1);v(this,"key",null);v(this,"level",0);v(this,"uiLevel",0);v(this,"rowGroupIndex");v(this,"expanded",!1);v(this,"selectable",!0);v(this,"selected",!1);v(this,"rowPinned",null);v(this,"detailNode",null);v(this,"masterNode",null);v(this,"footer",!1);v(this,"groupData",null);v(this,"rowHeight",null);v(this,"allChildrenCount",null);v(this,"stub",!1);v(this,"rowIndex",null);v(this,"__displayIndex");v(this,"services");v(this,"_id",null);v(this,"__passesFilter",!0);v(this,"__childCount",0);v(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=ti("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 n=i.split(".");let o=this.data;for(;n.length>1;){const a=n.shift();o[a]===void 0&&(o[a]={}),o=o[a]}o[n[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class jn{constructor(e){v(this,"options");v(this,"eventService");v(this,"columns");v(this,"getFilterModel");v(this,"getQuickFilter");v(this,"isPaginationEnabled");v(this,"getPageSize");v(this,"getCurrentPage");v(this,"rowHeightProvider");v(this,"rowNodeServices");v(this,"rowData",[]);v(this,"rootRowNodes",[]);v(this,"dataRows",[]);v(this,"rowsToDisplay",[]);v(this,"rowNodeMap",new Map);v(this,"expandedGroups",new Set);v(this,"groupDefaultExpandedApplied",!1);v(this,"pinnedTopRows",[]);v(this,"pinnedBottomRows",[]);v(this,"displayStartIndex",0);v(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=n=>{for(const o of n)o.group?o.children&&i(o.children):o.footer||e(o,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(n=>{n.group&&e.set(n.id,n.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,i=this.rowData;if(this.options.treeData){const n=this.buildTreeData(i,t);this.rootRowNodes=n,this.rowNodeMap.forEach(o=>{o.group&&e.has(o.id)&&(o.expanded=e.get(o.id))})}else{const n=[];for(let o=0;o<i.length;o++){const a=i[o],r=t?t({data:a,level:0}):void 0,l=this.createRowNode(a,r);l.rowIndex=o,n.push(l)}this.rootRowNodes=n,this.dataRows=n}if(this.options.masterDetail&&!this.options.treeData){const n=this.options.isRowMaster||(()=>!0);for(const o of this.rootRowNodes){if(o.detailNode||!n({data:o.data,node:o}))continue;const a=this.createRowNode(null,`${o.id}|detail`,o,1);a.masterNode=o,a.selectable=!1,o.detailNode=a,o.expanded=!1}}this.refreshModel(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.gridApi})}createRowNode(e,t,i=null,n=0){const o=new tt(e,this.rowNodeServices,t);return o.parent=i,o.level=n,o.uiLevel=n,o.__id=o.id,this.rowNodeMap.set(o.id,o),o}buildTreeData(e,t){const i=this.options.getDataPath||(c=>String(c.id??c.key).split("/")),n=this.options.treeDataChildrenField||"children",o=new Map,a=[],r=(c,d,u)=>{const f=i(c),g=f.join("/"),p=t?t({data:c,level:u}):g,C=this.createRowNode(c,p,d,u);C.key=f[f.length-1],o.set(g,C);const h=c[n];if(Array.isArray(h)&&h.length){C.children=[],C.group=!0,C.expanded=!0;for(const m of h){const y=r(m,C,u+1);C.children.push(y)}C.allChildrenCount=h.length}else d&&(d.children||(d.children=[],d.group=!0,d.expanded=!0),d.children.push(C),d.allChildrenCount=(d.allChildrenCount??0)+1);return d||a.push(C),C},l=c=>{if(!c.children||c.children.length===0)return 1;let d=0;for(const u of c.children)d+=l(u);return c.allChildrenCount=d,d};for(const c of a)l(c);for(const c of e){if(!c)continue;const u=i(c).slice(0,-1).join("/"),f=u&&o.get(u)||null;r(c,f??null,f?f.level+1:0)}return a}applyTransaction(e){const t=this.options.getRowId,i={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const n=new Set;for(const o of e.remove){const a=t?t({data:o,level:0}):o.id;a!==void 0?n.add(String(a)):n.add(o)}this.rowData=this.rowData.filter(o=>{const a=t?t({data:o,level:0}):o.id;return!n.has(String(a))&&!n.has(o)});for(const o of n){const a=this.rowNodeMap.get(String(o));a&&(this.rowNodeMap.delete(a.id),i.remove.push(a))}}if(e.update&&e.update.length)for(const n of e.update){const o=t?t({data:n,level:0}):n.id,a=o!==void 0?this.rowNodeMap.get(String(o)):void 0;if(a)this.rowData=this.rowData.map(r=>{const l=t?t({data:r,level:0}):r.id;return String(l)===String(o)?n:r}),a.data=n,i.update.push(a);else{const r=this.createRowNode(n,o!==void 0?String(o):void 0);this.rowData.push(n),i.add.push(r)}}if(e.add&&e.add.length){const n=e.addIndex;for(const o of e.add){const a=t?t({data:o,level:0}):void 0,r=this.createRowNode(o,a);i.add.push(r),n===void 0||n<0?this.rowData.push(o):this.rowData.splice(Math.min(n,this.rowData.length),0,o)}}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,n=t&&t.trim().length>0,o=this.columns(),a=!!this.options.treeData,r=p=>{for(const[C,h]of Object.entries(e)){const m=o.find(y=>y.colId===C);if(m&&!this.doesNodePassFilter(p,m,h))return!1}return!0},l=p=>{const C=this.options.__advancedFilterPass;return C?C(p):!0},c=Object.entries(e).some(([p,C])=>{const h=o.find(m=>m.colId===p);return!h||!h.aggFunc?!1:C.filterType==="multi"?(C.filterModels||[]).length>0:!0}),d=p=>{if(p.__passesFilter=!0,p.children)for(const C of p.children)d(C)},u=p=>{const C=this.options;return typeof C.isExternalFilterPresent!="function"||!C.isExternalFilterPresent()||typeof C.doesExternalFilterPass!="function"?!0:C.doesExternalFilterPass(p)},f=p=>{if(!n)return!0;const C=t.toLowerCase(),h=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of h){const y=de(m,p,null);if(Gn(C,y))return!0}return!1},g=p=>{let C=!0;if(!p.group||p.footer||a?C=(!i||r(p))&&f(p)&&u(p)&&l(p):c&&(C=(!i||r(p))&&l(p)),p.__passesFilter=C,p.children){let h=!1;for(const m of p.children)g(m)&&(h=!0);return p.group&&!p.footer&&(c?(p.__passesFilter=C,C&&d(p)):(p.__passesFilter=a?h||C:h,a&&C&&d(p))),p.__passesFilter}return C};for(const p of this.rootRowNodes)g(p)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let l;if(e.groupData&&e.groupData[t.colId]!==void 0)l=e.groupData[t.colId];else{const d=[];Vt(e,d);const u=d.map(f=>de(t,f,null));l=kt(t,t.aggFunc,u)}const c={...e,data:{[t.colId]:l},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(c,t,i)}if(i.filterType==="multi"){const l=i.filterModels||[];if(l.length===0)return!0;const c=i.operator||"AND",d=l.map(u=>this.doesNodePassFilter(e,t,u));return c==="OR"?d.some(Boolean):d.every(Boolean)}if(i.condition1||i.condition2){const{condition1:l,condition2:c,...d}=i,u=[this.doesNodePassFilter(e,t,{...d,...l||{}})];return c&&u.push(this.doesNodePassFilter(e,t,{...d,...c})),(i.operator||"AND")==="OR"?u.some(Boolean):u.every(Boolean)}const n=de(t,e,null),o=Yn(t,n),a=n,r=i.filterType||"text";if(r==="text"){const l=String(i.filter??"").toLowerCase();if(!l)return!0;const c=(a==null?"":String(a)).toLowerCase();switch(i.type){case"equals":return c===l;case"notEqual":return c!==l;case"startsWith":return c.startsWith(l);case"endsWith":return c.endsWith(l);case"contains":default:return c.includes(l)}}if(r==="number"){const l=typeof a=="number"?a:Number(a);if(isNaN(l))return!1;const c=Number(i.filter),d=i.filterTo!==void 0&&i.filterTo!==null&&i.filterTo!==""?Number(i.filterTo):null;switch(i.type){case"equals":return l===c;case"notEqual":return l!==c;case"lessThan":return l<c;case"lessThanOrEqual":return l<=c;case"greaterThan":return l>c;case"greaterThanOrEqual":return l>=c;case"inRange":return d!==null?l>=Math.min(c,d)&&l<=Math.max(c,d):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(r==="date"){const l=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(l))return!1;const c=i.dateFrom?new Date(i.dateFrom).getTime():null,d=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(c!==null&&l<c||d!==null&&l>d)}return r==="boolean"?!!a==!!i.filter:r==="set"?(i.values||[]).map(c=>String(c)).includes(String(a)):!0}doSort(e){const t=[],i=this.columns();for(const a of i)a.sort&&a.sortIndex!==null&&t.push({column:a,direction:a.sort});t.sort((a,r)=>(a.column.sortIndex??0)-(r.column.sortIndex??0));const n=(a,r)=>{for(const{column:d,direction:u}of t){const f=Fi(d)(a,r)*(u==="asc"?1:-1);if(f!==0)return f}const l=a.rowIndex??0,c=r.rowIndex??0;return l-c},o=a=>{a.sort(n);for(const r of a)r.children&&o(r.children)};if(e.length===0)o(this.rootRowNodes);else for(const a of this.rootRowNodes)a.children&&o(a.children)}doGroup(e){if(e.length===0)return;const t=this.columns().filter(c=>c.aggFunc&&!c.rowGroup),i=(c,d,u,f)=>{if(d>=e.length)return c;const g=e[d],p=new Map,C=[];for(const m of c){if(!m.__passesFilter)continue;const y=de(g,m,null),E=Xn(y);p.has(E)||(p.set(E,[]),C.push(E)),p.get(E).push(m)}const h=[];for(const m of C){const y=p.get(m),E=`${f}|${g.colId}:${m}`,R=this.rowNodeMap.get(E),S=R||new tt({[g.colId]:m},this.rowNodeServices,E);S.group=!0,S.key=m,S.level=u,S.uiLevel=u,S.parent=null,S.children=i(y,d+1,u+1,E);for(const L of S.children)L.parent=S;S.allChildrenCount=Gi(S),S.data={...S.data};const A=[];Vt(S,A);const B={};for(const L of t){const j=A.map(W=>de(L,W,null));B[L.colId]=kt(L,L.aggFunc,j)}B[g.colId]=m,S.groupData=B,R||this.rowNodeMap.set(E,S),h.push(S)}return h},n=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=i(o,0,0,""),r=c=>{for(const d of c){if(!d.group)continue;const u=Bt(d),f=this.expandedGroups.has(u);n===-1||f?d.expanded=!0:this.groupDefaultExpandedApplied?d.expanded=!1:d.expanded=d.level<n,d.expanded&&this.expandedGroups.add(u),d.children&&r(d.children)}};r(a),this.groupDefaultExpandedApplied=!0;const l=(c,d)=>{const u=e[d],f=u.sort==="desc"?-1:1,g=Fi(u);c.sort((p,C)=>{const h=de(u,p,null),m=de(u,C,null);return g({...p,data:{[u.colId]:h}},{...C,data:{[u.colId]:m}})*f})};e[0].sort&&l(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],i=!!this.options.treeData,n=(a,r)=>{if(a.uiLevel=r,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||i)){const l=a.group?a.children.filter(c=>c.__passesFilter||c.group):a.children;if(a.expanded){for(const c of l)n(c,r+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const c=this.createFooterNode(a,r+1);t.push(c)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&n(a,0);if(this.options.groupIncludeTotalFooter&&e.length>0){const a=this.createGrandTotalNode(e);t.push(a)}this.pinnedTopRows=t.filter(a=>a.rowPinned==="top"),this.pinnedBottomRows=t.filter(a=>a.rowPinned==="bottom");const o=t.filter(a=>a.rowPinned!=="top"&&a.rowPinned!=="bottom");if(this.totalRowCount=o.filter(a=>!a.masterNode).length,this.isPaginationEnabled()){const a=this.getPageSize(),r=this.getCurrentPage();let l=0,c=-1;for(let u=0;u<o.length;u++)if(!o[u].masterNode){if(l===r*a){c=u;break}l++}c<0&&(c=o.length);let d=c;for(l=0;d<o.length&&l<a;)o[d].masterNode||l++,d++;for(;d<o.length&&o[d].masterNode;)d++;this.displayStartIndex=c,this.rowsToDisplay=o.slice(c,d)}else this.displayStartIndex=0,this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,r)=>a.__displayIndex=r)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const i=`${e.id}|footer`;let n=this.rowNodeMap.get(i);return n||(n=new tt(e.data,this.rowNodeServices,i),this.rowNodeMap.set(i,n)),n.group=!1,n.footer=!0,n.level=e.level,n.uiLevel=t,n.parent=e,n.selected=!1,n.selectable=!1,n.groupData={...e.groupData,__footerFor:e.id},n}createGrandTotalNode(e){const t="ag-grid-grand-total";let i=this.rowNodeMap.get(t);i||(i=new tt(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 n=this.columns().filter(r=>r.aggFunc&&!r.rowGroup),o=[];for(const r of this.rootRowNodes)r.group?Vt(r,o):r.__passesFilter&&o.push(r);const a={};for(const r of n){const l=o.map(c=>de(r,c,null));a[r.colId]=kt(r,r.aggFunc,l)}return a.__grandTotal=!0,i.groupData=a,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Bt(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(Bt(e)):this.expandedGroups.delete(Bt(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 Xn(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Bt(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Gi(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Gi(t),0)}function Vt(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Vt(t,e)}function Yn(s,e){return e}const Hi={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:"散点图"},Qn={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 Jn{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Hi[e]??e}}function Zn(s){return new Jn(s??{})}function eo(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class to{constructor(e){v(this,"options");v(this,"eventService");v(this,"columns");v(this,"getSortModel");v(this,"getFilterModel");v(this,"rowHeightProvider");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"stores",new Map);v(this,"rowNodeMap",new Map);v(this,"displayRows",[]);v(this,"blockSize");v(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 n=this.getOrCreateStore(e);if(n.loading)return;for(let a=n.rows.length;a<i;a++)n.rows.push(null);n.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const o={startRow:t,endRow:i,rowGroupCols:this.columns().filter(a=>a.rowGroup),valueCols:this.columns().filter(a=>a.aggFunc&&!a.rowGroup),pivotCols:this.columns().filter(a=>a.pivot),groupKeys:e?e.split("|"):[],sortModel:this.getSortModel(),filterModel:this.getFilterModel(),successCallback:(a,r)=>{n.loading=!1,this.onBlockLoaded(e,a,r??null)},failCallback:()=>{n.loading=!1,n.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(o)}onBlockLoaded(e,t,i){const n=this.getOrCreateStore(e);n.lastRow=i,n.failed=!1;for(let o=0;o<t.length;o++){const a=t[o],r=(n.rows.length>0,o),l=this.createNode(a,e,o,r);n.rows[r]=l}for(;n.rows.length&&n.rows[n.rows.length-1]===null;)n.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,i,n){const o=eo(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${n}`,r=this.rowNodeMap.get(a),l=r instanceof tt?r:new tt(e,this.rowNodeServices,a);return l.data=e,l.rowIndex=i,o&&(l.group=!0,l.key=String(de(this.columns().find(c=>c.rowGroup),l,null)??""),l.level=t?t.split("|").length:0,l.uiLevel=l.level,l.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,l.expanded=this.stores.has(`${t?t+"|":""}${l.key}`)),this.rowNodeMap.set(a,l),l}buildDisplayRows(){const e=[],t=(i,n)=>{const o=this.stores.get(i);if(o){for(const a of o.rows)if(a&&(a.uiLevel=n,e.push(a),a.group&&a.expanded)){const r=`${i?i+"|":""}${a.key}`;t(r,n+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((i,n)=>i.__displayIndex=n)}ensureLoaded(e,t){let i=0;const n=a=>{const r=this.stores.get(a);if(r){for(const l of r.rows)if(l){if(i>=e&&i<=t){const c=Math.floor(i/this.blockSize)*this.blockSize,d=c+this.blockSize,u=r.lastRow,f=u!==null?Math.min(u,d):d;i<(r.rows.length||0)&&c<(r.rows.length||0)||(r.lastRow===null||d<=r.lastRow)&&this.loadBlock(a,c,f)}i++,l.group&&l.expanded&&n(`${a?a+"|":""}${l.key}`)}}};n("");const o=this.stores.get("");(!o||o.rows.length===0&&o.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 n=(i==null?void 0:i.id)!==void 0?String(i.id):void 0,o=n?this.rowNodeMap.get(n):void 0;o&&(o.data=i,t.update.push(o))}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 io{constructor(e){v(this,"options");v(this,"eventService");v(this,"getSortModel");v(this,"getFilterModel");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"nodes",[]);v(this,"rowNodeMap",new Map);v(this,"blockSize");v(this,"lastRow",null);v(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,n)=>{this.loading=!1,this.lastRow=n??null,i.forEach((o,a)=>{const r=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let l=this.rowNodeMap.get(r);l||(l=new tt(o,this.rowNodeServices,r),this.rowNodeMap.set(r,l)),l.data=o,l.rowIndex=e+a,this.nodes[e+a]=l}),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 no{constructor(e){v(this,"options");v(this,"eventService");v(this,"rowNodeServices");v(this,"datasource",null);v(this,"nodes",[]);v(this,"rowNodeMap",new Map);v(this,"firstRow",0);v(this,"lastRow",0);v(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,n)=>n>=e&&n<=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((n,o)=>{const a=(n==null?void 0:n.id)!==void 0?String(n.id):`vrow-${e+o}`;let r=this.rowNodeMap.get(a);r||(r=new tt(n,this.rowNodeServices,a),this.rowNodeMap.set(a,r)),r.data=n,r.rowIndex=e+o,this.nodes[e+o-e]=r}),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 oo{constructor(e){v(this,"eGui");var c,d,u;this.params=e;const t=e.node,i=!!t.group,n=!!t.detailNode,o=i||n,a=t.expanded,r=t.uiLevel*24,l=document.createElement("span");if(l.className="ag-group-cell-renderer",l.style.paddingLeft=`${r}px`,o){const f=document.createElement("span");f.className="ag-group-value-expanded-icon",f.classList.add(a?"ag-expanded":"ag-contracted"),f.innerHTML=a?xo:So,l.appendChild(f);const g=document.createElement("span");g.className="ag-group-value";const p=(c=e.colDef.cellRendererParams)==null?void 0:c.innerRenderer;if(typeof p=="function"){const C=p({...e,value:e.value,valueFormatted:e.valueFormatted});C instanceof HTMLElement?g.appendChild(C):typeof C=="string"&&(g.innerHTML=C)}else g.textContent=po(e.value);if(l.appendChild(g),i&&t.allChildrenCount!==null&&!((d=e.colDef.cellRendererParams)!=null&&d.suppressCount)){const C=document.createElement("span");C.className="ag-group-child-count",C.textContent=` (${t.allChildrenCount})`,l.appendChild(C)}}else{const f=document.createElement("span");f.className="ag-group-value";const g=(u=e.colDef.cellRendererParams)==null?void 0:u.innerRenderer;if(typeof g=="function"){const p=g({...e,value:e.value,valueFormatted:e.valueFormatted});p instanceof HTMLElement?f.appendChild(p):typeof p=="string"&&(f.innerHTML=p)}else f.textContent=e.valueFormatted??String(e.value??"");l.appendChild(f)}this.eGui=l}getGui(){return this.eGui}refresh(e){return!1}}class so{constructor(e){v(this,"eGui");v(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 ao='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',lo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class ro{constructor(e){v(this,"eGui");v(this,"eArrow");v(this,"eOld");v(this,"eNew");v(this,"lastValue");v(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),n=this.eNew.textContent??"";this.eArrow.innerHTML=i?ao:lo,this.eArrow.style.display="",this.eArrow.classList.add(i?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=n,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 co{constructor(e){v(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 uo{constructor(e){v(this,"eGui");var l,c;this.params=e;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],n=e.sparklineOptions||((c=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:c.sparklineOptions)||{},o=e.column.width||100,a=n.height||24,r=si(i,Math.max(20,o-16),a,n);t.appendChild(r),this.eGui=t}getGui(){return this.eGui}refresh(e){var r,l;const t=e.value||[],i=e.sparklineOptions||((l=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:l.sparklineOptions)||{},n=e.column.width||100,o=i.height||24;this.eGui.innerHTML="";const a=si(t,Math.max(20,n-16),o,{type:i.type,direction:i.direction});return this.eGui.appendChild(a),!0}}function si(s,e,t,i={}){var m,y,E;const n=document.createElementNS("http://www.w3.org/2000/svg","svg");n.setAttribute("width",String(Math.max(20,e))),n.setAttribute("height",String(t)),n.setAttribute("class","ag-sparkline");const o=(s||[]).map(R=>typeof R=="number"?R:Number((R==null?void 0:R.value)??0));if(!o||o.length<1)return n;const a=i.type||"line",r=Math.min(...o,0),c=Math.max(...o,0)-r||1,d=((m=i.tooltip)==null?void 0:m.enabled)===!0,u=((y=i.axis)==null?void 0:y.type)||"number",f=((E=i.pointsOfInterest)==null?void 0:E.show)===!0,g=(R,S)=>u==="category"?`${R+1}: ${S}`:String(S);if(f&&o.length>1){const R=o.indexOf(Math.min(...o)),S=o.indexOf(Math.max(...o)),A=e/Math.max(1,o.length-1),B=j=>t-2-(j-r)/c*(t-4),L=(j,W)=>{const M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(j*A)),M.setAttribute("cy",String(B(o[j]))),M.setAttribute("r","2.5"),M.setAttribute("fill",W),n.appendChild(M)};L(0,"#4caf50"),L(o.length-1,"#f44336"),L(R,"#2196f3"),L(S,"#ff9800")}if(d){const R=document.createElementNS("http://www.w3.org/2000/svg","title");R.textContent=o.map((S,A)=>g(A,S)).join(`
3
+ `),n.appendChild(R),n.style.cursor="default"}if(a==="bar"){const R=i.direction==="vertical",S=o.length;if(R){const A=Math.max(1,e/S-1),B=t-2-(0-r)/c*(t-4);o.forEach((L,j)=>{const W=j*(e/S),M=t-2-(L-r)/c*(t-4),D=document.createElementNS("http://www.w3.org/2000/svg","rect");D.setAttribute("x",String(W)),D.setAttribute("width",String(A)),D.setAttribute("y",String(Math.min(M,B))),D.setAttribute("height",String(Math.max(1,Math.abs(B-M)))),D.setAttribute("fill","currentColor"),n.appendChild(D)})}else{const A=Math.max(1,t/S-1),B=2+(0-r)/c*(e-4);o.forEach((L,j)=>{const W=j*(t/S),M=2+(L-r)/c*(e-4),D=document.createElementNS("http://www.w3.org/2000/svg","rect");D.setAttribute("y",String(W)),D.setAttribute("height",String(A)),D.setAttribute("x",String(Math.min(M,B))),D.setAttribute("width",String(Math.max(1,Math.abs(B-M)))),D.setAttribute("fill","currentColor"),n.appendChild(D)})}return n}const p=e/Math.max(1,o.length-1),C=o.map((R,S)=>{const A=S*p,B=t-2-(R-r)/c*(t-4);return`${A.toFixed(1)},${B.toFixed(1)}`});if(a==="area"){const R=document.createElementNS("http://www.w3.org/2000/svg","polygon");R.setAttribute("points",`0,${t} ${C.join(" ")} ${e},${t}`),R.setAttribute("fill","currentColor"),R.setAttribute("opacity","0.2"),n.appendChild(R)}const h=document.createElementNS("http://www.w3.org/2000/svg","polyline");return h.setAttribute("points",C.join(" ")),h.setAttribute("fill","none"),h.setAttribute("stroke","currentColor"),h.setAttribute("stroke-width","1.5"),n.appendChild(h),n}class ho{constructor(e){v(this,"eGui");this.params=e,this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Oi,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const zt={agGroupCellRenderer:s=>new oo(s),agCheckboxCellRenderer:s=>new so(s),agSparklineCellRenderer:s=>new uo(s),agAnimateShowChangeCellRenderer:s=>new ro(s),agRowNumberCellRenderer:s=>new co(s),agRowDragComp:s=>new ho(s)};function po(s){return s==null?"":String(s)}class go{constructor(e){v(this,"eGui");v(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 fo{constructor(e){v(this,"eGui");v(this,"eInput");v(this,"cancelled",!1);var n,o;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??"",(o=(n=e.column)==null?void 0:n.cellEditorParams)!=null&&o.showStepperButtons){const a=document.createElement("span");a.className="ag-cell-editor-stepper ag-cell-editor-stepper-up",a.innerHTML="▲",a.addEventListener("mousedown",l=>{var c,d;l.preventDefault(),l.preventDefault(),i.value=String(Number(i.value||0)+(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))});const r=document.createElement("span");r.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",r.innerHTML="▼",r.addEventListener("mousedown",l=>{var c,d;l.preventDefault(),i.value=String(Number(i.value||0)-(((d=(c=e.column)==null?void 0:c.cellEditorParams)==null?void 0:d.step)??1))}),t.appendChild(a),t.appendChild(i),t.appendChild(r)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",a=>{var r;return(r=e.onKeyDown)==null?void 0:r.call(e,a)})}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 mo{constructor(e){v(this,"eGui");v(this,"cancelled",!1);var i,n;this.params=e,this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((n=(i=e.column)==null?void 0:i.cellEditorParams)==null?void 0:n.values)||[];for(const o of t){const a=document.createElement("option");a.value=String(o),a.textContent=String(o),this.eGui.appendChild(a)}this.eGui.value=String(e.value??""),this.eGui.addEventListener("keydown",o=>{var a;return(a=e.onKeyDown)==null?void 0:a.call(e,o)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus()}}class vo{constructor(e){v(this,"eGui");v(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 Co{constructor(e){v(this,"eGui");v(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 wo(s,e){if(!e)return Et(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?Et(s):Et(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+Et(s.slice(t,t+e.length))+"</span>"+Et(s.slice(t+e.length))}class yo{constructor(e){v(this,"eGui");v(this,"eInput");v(this,"ePopup",null);v(this,"eList",null);v(this,"values",[]);v(this,"filtered",[]);v(this,"activeIndex",0);v(this,"selectedValue");v(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",n=>{n.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",n=>this.onKeyDown(n))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var a,r;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,bo(this.params)){const l=document.createElement("input");l.type="text",l.className="ag-rich-select-search",l.placeholder=((r=(a=this.params).t)==null?void 0:r.call(a,"search"))??"搜索…",l.value="",l.addEventListener("input",()=>this.renderList(l.value)),e.appendChild(l),setTimeout(()=>l.focus(),0)}const n=document.createElement("div");n.className="ag-rich-select-list",e.appendChild(n),this.eList=n,this.renderList();const o=l=>{!e.contains(l.target)&&!this.eGui.contains(l.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var i,n;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(o=>{if(!e)return!0;const a=String(o).toLowerCase(),r=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?r.every(l=>a.includes(l)):r.some(l=>a.includes(l))}),this.filtered.forEach((o,a)=>{const r=document.createElement("div");r.className="ag-rich-select-item",a===this.activeIndex&&r.classList.add("ag-active"),String(o)===String(this.selectedValue)&&r.classList.add("ag-selected");const l=this.params.cellRenderer;if(typeof l=="function"){const c=l({value:o,valueFormatted:String(o)});c instanceof HTMLElement?r.appendChild(c):r.textContent=String(c)}else r.innerHTML=wo(String(o),e);r.addEventListener("click",c=>{c.stopPropagation(),this.commit(o)}),r.addEventListener("mousedown",c=>c.preventDefault()),this.eList.appendChild(r)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((n=(i=this.params).t)==null?void 0:n.call(i,"noMatches"))??"无匹配项",this.eList.appendChild(o)}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 bo(s){var e,t;return(s==null?void 0:s.allowTyping)===!0||((t=(e=s==null?void 0:s.column)==null?void 0:e.cellEditorParams)==null?void 0:t.allowTyping)===!0}const it={agTextCellEditor:s=>new go(s),agNumberCellEditor:s=>new fo(s),agSelectCellEditor:s=>new mo(s),agDateCellEditor:s=>new vo(s),agLargeTextCellEditor:s=>new Co(s),agRichSelectCellEditor:s=>new yo(s)},So='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',xo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Oi='<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>',Eo='<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>',Ro='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Mo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',ko='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Bi='<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 Vi(s,e,t){const i=s.length;if(i===0||t<=0)return[];let n=0,o=i-1;for(;n<o;){const d=n+o>>1;s[d]>=t?o=d:n=d+1}const a=s[n]>=t?n:i-1,r=e[a];if(!r||r.level===0)return[];const l=[];let c=r.level;for(let d=a-1;d>=0;d--){const u=e[d];if(!(!u||u.level>=c)&&(c=u.level,u.group&&s[d]<t&&l.push(d),u.level===0))break}return l.reverse()}class To{constructor(e,t,i){v(this,"ctx");v(this,"eRoot");v(this,"eHeader");v(this,"eBody");v(this,"ePinnedLeft");v(this,"ePinnedRight");v(this,"ePinnedLeftInner");v(this,"ePinnedRightInner");v(this,"eViewport");v(this,"eContainer");v(this,"eFloatingTop");v(this,"eFloatingBottom");v(this,"eFloatingTopLeft");v(this,"eFloatingTopRight");v(this,"eFloatingBottomLeft");v(this,"eFloatingBottomRight");v(this,"eStickyTop");v(this,"eStickyLeft");v(this,"eStickyCenter");v(this,"eStickyRight");v(this,"eRangeOverlay",null);v(this,"rowComps",new Map);v(this,"stickyComps",new Map);v(this,"hoveredRowId",null);v(this,"rowOffsets",[]);v(this,"rowInfos",[]);v(this,"totalHeight",0);v(this,"lastScrollTop",-1);v(this,"lastRange",[-1,-1]);v(this,"firstRendered",!1);v(this,"heightVersion",0);v(this,"scrollFrame",null);v(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 n=e.deltaY,o=e.deltaX;e.deltaMode===1?(n*=33,o*=33):e.deltaMode===2&&(n*=i.clientHeight,o*=i.clientWidth),n&&(i.scrollTop+=n),o&&(i.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});v(this,"onBodyMouseOver",e=>{var o;const t=e.target,i=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,".ag-row"),n=(i==null?void 0:i.dataset.rowid)??null;if(n===this.hoveredRowId){n&&this.setRowHovered(n,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=n,n&&this.setRowHovered(n,!0)});v(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 n=document.createElement("div");n.className="ag-body-viewport-wrapper",this.eBody.appendChild(n),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",n.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",o=>this.ctx.onViewportKeyDown(o)),n.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",n.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 o of[this.eFloatingTopLeft,this.eFloatingTopRight,this.eFloatingBottomLeft,this.eFloatingBottomRight,this.eStickyLeft,this.eStickyCenter,this.eStickyRight])o.addEventListener("click",this.onClick.bind(this)),o.addEventListener("dblclick",this.onDoubleClick.bind(this)),o.addEventListener("mousedown",this.onMouseDown.bind(this)),o.addEventListener("contextmenu",this.onContextMenu.bind(this)),o.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 o of[this.eViewport,this.ePinnedLeft,this.ePinnedRight,this.eFloatingTop,this.eFloatingBottom,this.eHeader])o.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 n=0;if(this.hasVariableHeights()){for(let a=0;a<e;a++)t[a]=n,i[a]=this.rowInfoAt(a),n+=this.getRowHeightForIndex(a);this.totalHeight=n}else{const a=this.getFixedRowHeight();for(let r=0;r<e;r++)t[r]=r*a,i[r]=this.rowInfoAt(r);this.totalHeight=e*a}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((n,o)=>n+o.width,0),t=this.ctx.getColumns().left.reduce((n,o)=>n+o.width,0),i=this.ctx.getColumns().right.reduce((n,o)=>n+o.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,n;const e=(o,a,r,l,c)=>{o.innerHTML="",a.innerHTML="",r.innerHTML="";const{left:d,center:u,right:f}=this.ctx.getColumns();let g=0;for(let p=0;p<l;p++){const C=c(p);if(!C)continue;const h=this.ctx.getRowHeight(C),m=new Wt(this.ctx,C,d,u,f,h,this.heightVersion);m.appendTo(a,o,r),m.setTop(g),g+=h,this.rowComps.set(`${C.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${g}px`,o.style.display=l>0?"":"none",a.style.height=`${g}px`,r.style.height=`${g}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((i=t.getPinnedTopRowCount)==null?void 0:i.call(t))??0,o=>{var a;return(a=t.getPinnedTopRow)==null?void 0:a.call(t,o)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((n=t.getPinnedBottomRowCount)==null?void 0:n.call(t))??0,o=>{var a;return(a=t.getPinnedBottomRow)==null?void 0:a.call(t,o)})}refreshCells(e){const t=e==null?void 0:e.rowNodes;let i;e!=null&&e.columns&&(i=e.columns.map(n=>typeof n=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(o=>o.colId===n):n).filter(Boolean));for(const[n,o]of this.rowComps)t&&!t.includes(o.getNode())||o.refreshCells(i,e==null?void 0:e.force,e==null?void 0:e.flash);for(const n of this.stickyComps.values())t&&!t.includes(n.getNode())||n.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(),n=this.findRowIndex(i);if(t.destroy(),this.rowComps.delete(this.rowCompKey(i)),n>=0){const{left:o,center:a,right:r}=this.ctx.getColumns(),l=new Wt(this.ctx,i,o,a,r,this.getRowHeightForIndex(n),this.heightVersion);l.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),l.setTop(this.rowOffsets[n]??0),this.rowComps.set(this.rowCompKey(i),l)}}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 n of this.stickyComps.values()){const o=n.getCenterElement();o&&(o.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?[]:Vi(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:i,right:n}=this.ctx.getColumns(),o=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${o}px`;const a=new Set;let r=0;for(const c of e){const d=this.ctx.rowModel.getRow(c);if(!d||!d.group)continue;a.add(d.id);let u=this.stickyComps.get(d.id);if(!u){const f=this.rowComps.get(d.id);f&&(f.destroy(),this.rowComps.delete(d.id)),u=new Wt(this.ctx,d,t,i,n,this.getRowHeightForIndex(c),this.heightVersion),u.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),u.setSticky(!0),this.stickyComps.set(d.id,u)}u.setTop(r),r+=this.getRowHeightForIndex(c)}for(const[c,d]of this.stickyComps)a.has(c)||(d.destroy(),this.stickyComps.delete(c));const l=`${r}px`;return this.eStickyTop.style.height=l,this.eStickyLeft.style.height=l,this.eStickyCenter.style.height=l,this.eStickyRight.style.height=l,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),i=this.eViewport.scrollTop,n=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a=0,r=t-1;if(this.hasVariableHeights())a=this.findIndexAtPixel(i)-o,r=this.findIndexAtPixel(i+n)+o;else{const h=this.getFixedRowHeight();a=Math.floor(i/h)-o,r=Math.ceil((i+n)/h)+o}if(a=Math.max(0,a),r=Math.min(t-1,r),!e&&this.lastRange[0]===a&&this.lastRange[1]===r&&this.lastScrollTop===i)return;const l=this.lastRange[0]!==a||this.lastRange[1]!==r;this.lastRange=[a,r],this.lastScrollTop=i;const c=new Set(this.stickyComps.keys()),d=this.syncStickyGroupRows(),u=c.size!==d.size||[...c].some(h=>!d.has(h));if(!e&&!l&&!u)return;const f=new Set(d),{left:g,center:p,right:C}=this.ctx.getColumns();for(let h=a;h<=r;h++){const m=this.ctx.rowModel.getRow(h);if(!m||(f.add(m.id),d.has(m.id)))continue;let y=this.rowComps.get(m.id);y||(y=new Wt(this.ctx,m,g,p,C,this.getRowHeightForIndex(h),this.heightVersion),y.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,y)),y.setTop(this.rowOffsets[h]??h*this.getFixedRowHeight())}for(const[h,m]of this.rowComps)!f.has(h)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(h))}findIndexAtPixel(e){const t=this.rowOffsets;let i=0,n=t.length-1;for(;i<n;){const o=i+n+1>>1;t[o]<=e?i=o:n=o-1}return i}ensureIndexVisible(e,t="top"){const i=this.rowOffsets[e]??e*this.getFixedRowHeight(),n=this.getRowHeightForIndex(e),o=this.eViewport.clientHeight;let a=this.eViewport.scrollTop;t==="top"?a=i:t==="bottom"?a=i+n-o:a=i-(o-n)/2,this.eViewport.scrollTop=Math.max(0,a),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,n=this.eViewport.scrollLeft,o=e.left-this.ctx.getColumns().left.reduce((a,r)=>a+r.width,0);o<n?this.eViewport.scrollLeft=Math.max(0,t==="middle"?o-(i-e.width)/2:o):o+e.width>n+i&&(this.eViewport.scrollLeft=o+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 n=i.dataset.colid;if(!n)return null;const o=i.closest(".ag-row"),a=o==null?void 0:o.dataset.rowid;if(!a)return null;const r=this.ctx.rowModel.getRowNode(a);if(!r)return null;const c=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(d=>d.colId===n);return c?(this.ctx.rowModel.getRowCount(),{node:r,column:c,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:de(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 n=this.ctx.rowModel.getRowNode(i.dataset.rowid);n&&this.ctx.onRowClicked({event:e,node:n,data:n.data,rowIndex:this.getRowIndexForNode(n)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:de(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 n=this.ctx.rowModel.getRowNode(i.dataset.rowid);n&&this.ctx.onRowDoubleClicked({event:e,node:n,data:n.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:de(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:de(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 Wt{constructor(e,t,i,n,o,a,r){v(this,"eLeft",null);v(this,"eCenter",null);v(this,"eRight",null);v(this,"cellComps",[]);v(this,"pinned",!1);var l,c,d,u,f,g,p,C,h;if(this.ctx=e,this.node=t,this.rowHeight=a,this.heightVersion=r,t.masterNode){const m=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(m){const y=document.createElement("div");y.className="ag-row ag-row-detail-row",y.dataset.rowid=t.id,y.style.height=`${m.height}px`,y.style.width="100%",y.appendChild(m.eDetail),this.eCenter=y,this.eLeft=null,this.eRight=null}return}i.length&&(this.eLeft=this.createRowElement(t,i,"left"),this.eLeft.classList.add("ag-row-pinned")),(n.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,n,"center")),o.length&&(this.eRight=this.createRowElement(t,o,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((l=this.eCenter)==null||l.classList.add("ag-row-footer"),(c=this.eLeft)==null||c.classList.add("ag-row-footer"),(d=this.eRight)==null||d.classList.add("ag-row-footer")),t.group&&((u=this.eCenter)==null||u.classList.add("ag-row-group"),(f=this.eLeft)==null||f.classList.add("ag-row-group"),(g=this.eRight)==null||g.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((p=this.eCenter)==null||p.classList.add("ag-row-selected"),(C=this.eLeft)==null||C.classList.add("ag-row-selected"),(h=this.eRight)==null||h.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,i,n;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-sticky-group",e),(n=this.eRight)==null||n.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,i,n;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(i=this.eCenter)==null||i.classList.toggle("ag-row-hover",e),(n=this.eRight)==null||n.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,i){var l;const n=document.createElement("div");n.className="ag-row",n.dataset.rowid=e.id,n.setAttribute("role","row"),n.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),n.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&n.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&n.classList.add("ag-row-even"),n.style.height=`${this.rowHeight}px`,n.style.position="absolute",n.style.top="0px";const o=this.ctx.getRowClass(e);o&&n.classList.add(...o.split(" ").filter(Boolean));const a=this.ctx.getRowStyle(e);a&&Object.assign(n.style,a),e.footer&&((l=e.groupData)!=null&&l.__grandTotal)&&(n.classList.add("ag-row-full-width"),n.style.width="100%",n.style.right="0",n.style.left="0");let r=0;for(let c=0;c<t.length;c++){const d=t[c],u=this.createCell(d,e);let f=1;typeof d.colDef.colSpan=="function"&&(f=Math.max(1,Math.round(d.colDef.colSpan({value:de(d,e,null),data:e.data,node:e,column:d,rowIndex:e.__displayIndex??0,api:null}))));let g=d.width;for(let p=1;p<f&&c+p<t.length;p++)g+=t[c+p].width;u.eCell.style.left=`${r}px`,u.eCell.style.width=`${g}px`,u.eCell.style.position="absolute",u.eCell.style.top="0",u.eCell.style.height=`${this.rowHeight}px`,f>1&&u.eCell.classList.add("ag-cell-col-span"),r+=g,c+=f-1,n.appendChild(u.eCell),this.cellComps.push(u)}return n.style.width=`${r}px`,n}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 d,u;const i=document.createElement("div");i.className="ag-cell",i.dataset.colid=e.colId;const n=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");n&&i.classList.add(`ag-col-${n}`);const o={value:de(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const f=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof f=="string"?i.classList.add(...f.split(" ").filter(Boolean)):Array.isArray(f)&&i.classList.add(...f)}if(e.cellClassRules)for(const[f,g]of Object.entries(e.cellClassRules))g(o)&&i.classList.add(f);if(e.cellStyle){const f=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(i.style,f)}(e.type==="numberColumn"||e.cellDataType===!0)&&i.classList.add("ag-right-aligned-cell"),e.rowDrag&&i.classList.add("ag-cell-row-drag");const a=document.createElement("span");a.className="ag-cell-value",i.appendChild(a),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 r=(u=(d=this.ctx).getNote)==null?void 0:u.call(d,t.id,e.colId,e.colDef.note,{value:de(e,t,null),data:t.data,node:t,column:e,api:null});if(r){const f=document.createElement("span");f.className="ag-cell-note-marker",f.title=r,f.addEventListener("click",g=>{var p,C;g.stopPropagation(),(C=(p=this.ctx).onNoteClick)==null||C.call(p,t.id,e.colId,f)}),i.appendChild(f)}if(e.rowDrag){const f=document.createElement("span");f.className="ag-row-drag-handle",f.innerHTML=Oi,f.title=this.ctx.t("dragRow"),f.addEventListener("mousedown",g=>{var p,C;g.button===0&&(g.stopPropagation(),(C=(p=this.ctx).onRowDragStart)==null||C.call(p,t,f,g))}),i.appendChild(f)}const l=e.tooltipField;l&&t.data&&t.data[l]!==void 0?i.title=String(t.data[l]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:de(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const c={column:e,eCell:i,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(c),c}updateCellContent(e){var c;const{column:t,node:i}={column:e.column,node:this.node},n=de(t,i,null),o=Ot(t,i,null);e.lastValue=n,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,r=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||r){e.custom=!0;const d=a||"func";if(e.rendererKey!==d){e.eValue.innerHTML="",e.rendererKey=d;const u={value:n,valueFormatted:o,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 f=null;if(a&&zt[a]){const g=zt[a](u);g instanceof HTMLElement?f=g:(e.rendererInstance=g,f=g.getGui())}else if(r){const g=r(u);g instanceof HTMLElement?f=g:g&&typeof g.getGui=="function"?(e.rendererInstance=g,f=g.getGui()):typeof g=="string"&&(e.eValue.innerHTML=g)}f&&e.eValue.appendChild(f)}return}e.rendererKey="",e.custom=!1,(c=e.rendererInstance)!=null&&c.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let l=o??"";if((i.group||i.footer)&&i.groupData){const d=i.groupData[t.colId];l=d==null?"":String(d)}e.eValue.textContent!==l&&(e.eValue.textContent=l)}refreshCells(e,t,i){var a,r,l,c;const n=e&&e.length?new Set(e.map(d=>d.colId)):null;for(const d of this.cellComps){if(n&&!n.has(d.column.colId))continue;const u=de(d.column,this.node,null),f=t||u!==d.lastValue;if(!f&&!i)continue;const g=d.eValue.textContent;if(d.rendererInstance&&typeof d.rendererInstance.refresh=="function"){d.rendererInstance.refresh({value:u,valueFormatted:Ot(d.column,this.node,null),data:this.node.data,node:this.node,column:d.column,rowIndex:this.node.__displayIndex??0,api:null,colDef:d.column.colDef,eGridCell:d.eCell,...d.column.cellRendererParams||{}})===!1&&this.updateCellContent(d),d.lastValue=u,i&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"));continue}if(d.rendererKey){(f||i)&&(d.rendererKey="",this.updateCellContent(d)),d.lastValue=u,i&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(d),(i||f&&g!==d.eValue.textContent)&&(d.eCell.classList.remove("ag-cell-data-change"),d.eCell.offsetWidth,d.eCell.classList.add("ag-cell-data-change"))}const o=this.ctx.isNodeSelected(this.node);(a=this.eCenter)==null||a.classList.toggle("ag-row-selected",o),(r=this.eLeft)==null||r.classList.toggle("ag-row-selected",o),(l=this.eRight)==null||l.classList.toggle("ag-row-selected",o),this.node.group&&((c=this.eCenter)==null||c.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 n=this.ctx.renderDetailRow(this.node,this.eCenter);n&&t.appendChild(n.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,n;(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 o of this.cellComps)(n=o.rendererInstance)!=null&&n.destroy&&o.rendererInstance.destroy();this.cellComps=[]}}class No{constructor(e,t){v(this,"ctx");v(this,"eHeader");v(this,"ePinnedLeftHeader");v(this,"ePinnedRightHeader");v(this,"eHeaderViewport");v(this,"eHeaderContainer");v(this,"eHeaderRow");v(this,"eFloatingFiltersRow",null);v(this,"eGroupRows");v(this,"headerCells",new Map);v(this,"customHeaderComponents",new Map);v(this,"resizeState",null);v(this,"dragState",null);v(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 n=[...e,...t,...i].some(o=>o.floatingFilter);n&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!n&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var r;const e=this.ctx.getColumnModel(),t=((r=e==null?void 0:e.getColumnGroups)==null?void 0:r.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((l,c)=>Math.max(l,c.depth),0),n=this.ctx.options.groupHeaderHeight??30;let o=0;for(let l=1;l<=i;l++){const c=document.createElement("div");c.className="ag-header-row ag-group-header-row",c.style.height=`${n}px`;const d=this.ctx.getColumns().center;let u=0,f,g=0,p=0;const C=(m,y)=>{let E=m.groupId;for(;E;){const R=t.find(S=>S.id===E);if(!R)return null;if(R.depth===y)return R.id;E=R.parentId}return null},h=()=>{if(f==null)return;const m=t.find(S=>S.id===f);if(!m)return;const y=document.createElement("div");y.className="ag-header-group-cell",y.style.left=`${g}px`,y.style.width=`${p}px`,y.style.height=`${n}px`;const E=e.isGroupOpen(m.id),R=document.createElement("div");if(R.className="ag-header-group-cell-label",R.textContent=m.headerName,y.appendChild(R),!E){const S=document.createElement("span");S.className="ag-header-group-expand",S.textContent="▸",S.title=this.ctx.t("expandGroup"),y.appendChild(S)}y.addEventListener("click",()=>{e.setGroupOpen(m.id,!E)}),c.appendChild(y)};d.forEach(m=>{const y=C(m,l);y!==f&&(h(),f=y,g=u,p=0),p+=m.width,u+=m.width}),h(),c.style.width=`${u}px`,this.eGroupRows.appendChild(c),o+=n}this.eGroupRows.style.display=i>0?"":"none";const a=this.ctx.headerHeight;this.eHeader.style.height=`${o+a}px`}renderSection(e,t,i){e.innerHTML="";let n=0;for(const o of t){const a=this.createHeaderCell(o);if(a.style.left=`${n}px`,a.style.width=`${o.width}px`,a.style.height=`${this.ctx.headerHeight}px`,n+=o.width,e.appendChild(a),this.headerCells.set(o.colId,a),o.eHeaderCell=a,this.eFloatingFiltersRow&&e===this.eHeaderRow&&o.floatingFilter){const r=this.createFloatingFilter(o);r.style.left=`${n-o.width}px`,r.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(r)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${n}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${n}px`)}createHeaderCell(e){var a,r;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 l=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(l).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const l=i({column:e,colDef:e.colDef,api:((r=(a=this.ctx).getApi)==null?void 0:r.call(a))??null,displayName:e.headerName}),c=l&&typeof l.getGui=="function"?l.getGui():l;if(c instanceof HTMLElement)return c.classList.add("ag-header-component"),t.appendChild(c),typeof(l==null?void 0:l.refresh)=="function"&&this.customHeaderComponents.set(e.colId,l),t}const n=document.createElement("div");if(n.className="ag-header-cell-label",e.headerTooltip&&(n.title=e.headerTooltip),e.headerCheckboxSelection){const l=document.createElement("input");l.type="checkbox",l.className="ag-native-checkbox ag-header-select-all",l.addEventListener("change",()=>this.ctx.onHeaderCheckboxChanged(e,l.checked)),l.addEventListener("click",c=>c.stopPropagation()),n.appendChild(l)}const o=document.createElement("span");if(o.className="ag-header-cell-text",o.textContent=e.headerName,n.appendChild(o),t.appendChild(n),e.sortable){const l=document.createElement("span");l.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(l,e.sort,e.sortIndex),t.appendChild(l)}if(e.filter){const l=document.createElement("span");l.className="ag-header-icon ag-filter-icon";const c=this.ctx.isFilterActive(e);l.classList.toggle("ag-filter-active",c),l.innerHTML=Ro,l.title=this.ctx.t("openFilterTitle"),l.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onFilterOpened(e,l)}),t.appendChild(l)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const l=document.createElement("span");l.className="ag-header-icon ag-menu-icon",l.innerHTML=Eo,l.title=this.ctx.t("openMenuTitle"),l.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onColumnMenuClicked(e,l)}),t.appendChild(l)}if(t.addEventListener("click",l=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,l,l.shiftKey||l.ctrlKey||l.metaKey)}),t.addEventListener("contextmenu",l=>{l.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:l}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",l=>{const c=t.getBoundingClientRect();l.clientX>c.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const l=document.createElement("div");l.className="ag-header-cell-resize",l.addEventListener("mousedown",c=>{c.stopPropagation(),c.preventDefault(),this.resizeState={column:e,startX:c.clientX,startWidth:e.width};const d=f=>{if(!this.resizeState)return;const g=f.clientX-this.resizeState.startX;let p=this.resizeState.startWidth+g;p=Math.max(e.minWidth,Math.min(e.maxWidth,p)),this.ctx.onColumnResized(e,Math.round(p),!1)},u=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",u),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",d),document.addEventListener("mouseup",u)}),t.appendChild(l)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",l=>{if(!l.dataTransfer)return;l.dataTransfer.setData("text/plain",e.colId),l.dataTransfer.effectAllowed="move";const c=t.cloneNode(!0);c.classList.add("ag-header-cell-drag-ghost"),c.style.position="absolute",c.style.top="-1000px",c.style.width=`${e.width}px`,c.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(c),l.dataTransfer.setDragImage(c,20,20),this.dragState={colId:e.colId,ghost:c,startX:l.clientX,startY:l.clientY},setTimeout(()=>c.remove(),0)}),t.addEventListener("dragend",()=>{var l;(l=this.dragState)!=null&&l.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",l=>{l.preventDefault()}),t.addEventListener("drop",l=>{var d;l.preventDefault();const c=(d=l.dataTransfer)==null?void 0:d.getData("text/plain");c&&c!==e.colId&&this.ctx.onColumnMoved(c,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 n=document.createElement("select");return n.className="ag-floating-filter-input",n.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',n.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,n.value)),t.appendChild(n),e.floatingFilterComp=n,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=Mo):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=ko),t&&i!==null&&i>0){const n=document.createElement("span");n.className="ag-sort-order",n.textContent=String(i+1),e.appendChild(n)}}updateIndicators(){const{left:e,center:t,right:i}=this.ctx.getColumns();for(const n of[...e,...t,...i]){const o=this.headerCells.get(n.colId);if(!o)continue;const a=o.querySelector(".ag-sort-indicator");a&&this.updateSortIndicator(a,n.sort,n.sortIndex);const r=o.querySelector(".ag-filter-icon");r&&r.classList.toggle("ag-filter-active",this.ctx.isFilterActive(n)),o.style.width=`${n.width}px`,this.lastWidths.get(n.colId)!==n.width&&this.lastWidths.set(n.colId,n.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 n=0;for(const o of e){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}this.ePinnedLeftHeader.style.width=`${n}px`,n=0;for(const o of t){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}this.eHeaderContainer.style.width=`${n}px`,n=0;for(const o of i){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${n}px`),n+=o.width}if(this.ePinnedRightHeader.style.width=`${n}px`,this.eFloatingFiltersRow){n=0;for(const o of t){const a=this.eFloatingFiltersRow.querySelector(`[data-colid="${o.colId}"]`);a&&(a.style.left=`${n}px`,a.style.width=`${o.width}px`),n+=o.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 Io{constructor(e,t,i){v(this,"selectedNodes",new Set);v(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",n=t.ctrlKey||t.metaKey,o=t.shiftKey;return i?o&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):n?(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 n=-1,o=-1,a=0;if(i.forEachNode(c=>{c===e&&(n=a),c===t&&(o=a),a++}),n<0||o<0)return;const r=Math.min(n,o),l=Math.max(n,o);a=0,i.forEachNode(c=>{a>=r&&a<=l&&this.isNodeSelectable(c)&&!c.footer&&(this.selectedNodes.add(c),c.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(n=>t.add(n));let i=!1;for(const n of this.selectedNodes)t.has(n)?n.selected=!0:i=!0;if(i){for(const n of[...this.selectedNodes])t.has(n)||this.selectedNodes.delete(n);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(n=>{n.footer||!this.isNodeSelectable(n)||(t++,n.selected&&i++)}),{checked:t>0&&i===t,indeterminate:i>0&&i<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Lo{constructor(e,t){v(this,"editing",null);v(this,"fullRowEditors",null);v(this,"fullRowNode",null);v(this,"focusedCell",null);v(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 o=this.grid.getRowRenderer().getRowComps().get(i.id);return o&&o.getCellElements().find(a=>a.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 c;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 n=this.findCellElement(t,e.rowIndex);if(!n)return;const o=de(t,i,this.grid.getApi()),a={value:e.charPress!==void 0?e.charPress:o,oldValue:o,data:i.data,node:i,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(c=t.cellEditorParams)==null?void 0:c.values,...t.cellEditorParams};let r=null;if(typeof t.cellEditor=="string")r=(it[t.cellEditor]||it.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const d=t.cellEditor(a);r=d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}else{const d=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";r=it[d](a)}if(!r)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:n,editor:r,startedValue:o},n.classList.add("ag-cell-inline-editing");const l=r.getGui();l.classList.add("ag-cell-editor"),n.appendChild(l),n.classList.add("ag-cell-editing"),r.focusIn&&r.focusIn(),r.afterGuiAttached&&r.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:i,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,i){const n=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(o=>this.grid.isCellEditable(o,t));this.fullRowEditors=[],this.fullRowNode=t;for(const o of n){const a=this.findCellElement(o,e);if(!a)continue;const r=de(o,t,this.grid.getApi()),l=this.createEditor(o,t,e,r,i);if(!l)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const c=l.getGui();c.classList.add("ag-cell-editor"),a.appendChild(c),this.fullRowEditors.push({column:o,editor:l,eCell:a,startedValue:r})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,n,o){var l;const a={value:o!==void 0?o:n,oldValue:n,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:i,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(l=e.cellEditorParams)==null?void 0:l.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(it[e.cellEditor]||it.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const c=e.cellEditor(a);return c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}const r=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return it[r](a)}stopEditing(e=!1){var c,d,u,f;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:i,rowNode:n,eCell:o,editor:a,startedValue:r}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let l=e?r:a.getValue();if(l===void 0&&!e)return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!1;if(!e){l=Di(i,l);const g=this.applyValueSetter(i,n,l);if(g===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:i}),!1;l=g}return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!e&&!zi(l,r)&&(this.grid.setCellValue(i,n,l,"edit",r),this.eventService.dispatchEvent("cellValueChanged",{oldValue:r,newValue:l,value:l,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(f=(u=this.grid.getOptions()).onCellValueChanged)==null||f.call(u,{oldValue:r,newValue:l,value:l,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[n],columns:[i],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,i){if(e.valueSetter){if(e.valueSetter({oldValue:de(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 o,a,r;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const l of t)l.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=l.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),l.editor.destroy&&l.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const n=[];for(const l of t){if(!i)break;let c=l.editor.getValue();c!==void 0&&(c=Di(l.column,c),zi(c,l.startedValue)||n.push({column:l.column,rowNode:i,newValue:c,oldValue:l.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const l of n)this.grid.setCellValue(l.column,l.rowNode,l.newValue,"edit",l.oldValue),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l.oldValue,newValue:l.newValue,value:l.newValue,data:l.rowNode.data,node:l.rowNode,column:l.column,colDef:l.column.colDef,api:this.grid.getApi(),source:"edit"}),(r=(a=this.grid.getOptions()).onCellValueChanged)==null||r.call(a,{oldValue:l.oldValue,newValue:l.newValue,value:l.newValue,data:l.rowNode.data,node:l.rowNode,column:l.column,colDef:l.column.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[l.rowNode],columns:[l.column],flash:this.grid.getOptions().enableCellChangeFlash!==!1});return!0}onEditorKeyDown(e){if(e.key==="Enter"||e.keyCode===rt){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===Dn)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===Ri){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 rt:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case Ri:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case Mi:case ki: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 An:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case Fn: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 n=i.rowIndex;if(e===-1/0?n=0:e===1/0?n=this.grid.getDisplayedRowCount()-1:n=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,n+e)),t!==0){const o=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let r=o.findIndex(l=>l.colId===i.column.colId)+t;for(;r>=0&&r<o.length&&!o[r].visible;)r+=t;r<0&&(r=0),r>=o.length&&(r=o.length-1),this.setFocusedCell(n,o[r])}else this.setFocusedCell(n,i.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:i,event:n}=e;if(this.setFocusedCell(e.rowIndex,i),i.checkboxSelection)return;const o=this.grid.isCellEditable(i,t),a=i.singleClickEdit||this.grid.getOptions().singleClickEdit;o&&a&&!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 zi(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}class Do{constructor(e){v(this,"filterModel",{});v(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(),n=typeof i.doesNodePassFilterModel=="function"?i.doesNodePassFilterModel.bind(i):null,o=t.conditions.map(a=>{const r=this.grid.getColumn(a.colId);return!r||!n?!0:n(e,r,{...a,filterType:r.filter===!0?"text":r.filter})});return t.operator==="OR"?o.some(Boolean):o.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(n=>this.isModelMeaningful(n)):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,n;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(n=(i=this.grid.getOptions()).onFilterChanged)==null||n.call(i,{api:t,source:e})}}class Ao{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,i){const n=this.grid.getOptions().suppressMultiSort,o=i&&!n&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,a=this.getSortingOrder(),r=e.sort;let l=a.indexOf(r)+1;l>=a.length&&(l=0);const c=a[l];if(!o)for(const d of this.grid.getAllColumns())d.colId!==e.colId&&(d.sort=null,d.sortIndex=null);e.sort=c,c===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 n=this.grid.getColumn(t.colId);n&&(n.sort=t.sort,n.sortIndex=i)}),this.onSortChanged("api")}onSortChanged(e){var i,n;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(n=(i=this.grid.getOptions()).onSortChanged)==null||n.call(i,{api:t,source:e})}}class Wi{constructor(e,t){v(this,"enabled");v(this,"pageSize");v(this,"currentPage",0);v(this,"pageSizeSelector");v(this,"ePanel");v(this,"ePageInfo");v(this,"ePageInput");v(this,"ePageSizeSelect",null);v(this,"ePageSizeContainer");v(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 n=document.createElement("div");n.className="ag-pagination-buttons",this.ePanel.appendChild(n),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",n.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",n.appendChild(this.eFromToContainer);const o=document.createElement("span");if(o.className="ag-pagination-page-label",o.textContent=`${this.grid.translate("page","Page")}`,n.appendChild(o),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 a=parseInt(this.ePageInput.value,10);isNaN(a)||this.goToPage(a-1)}),n.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",n.appendChild(this.ePageInfo),this.pageSizeSelector){const a=this.ePageSizeContainer,r=document.createElement("span");r.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(r);const l=document.createElement("select");l.className="ag-pagination-page-size-select";const c=this.pageSizeSelector===!0?[20,50,100,500,1e3]:this.pageSizeSelector;for(const d of c){const u=document.createElement("option");u.value=String(d),u.textContent=String(d),d===this.pageSize&&(u.selected=!0),l.appendChild(u)}l.addEventListener("change",()=>this.setPageSize(parseInt(l.value,10))),a.appendChild(l),this.ePageSizeSelect=l}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 r,l;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(),n=i===0?0:this.currentPage*this.pageSize+1,o=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 a=this.grid.translate("rangeTo","至");this.eFromToContainer.textContent=i===0?`0 ${a} 0 ${this.grid.translate("of","/")} 0`:`${n.toLocaleString()} ${a} ${o.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}),(l=(r=this.grid.getOptions()).onPaginationChanged)==null||l.call(r,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Fo{constructor(e){v(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 n={ePopup:i},o=()=>{var c;this.openPopups.has(n)&&(this.openPopups.delete(n),i.remove(),document.removeEventListener("mousedown",r,!0),document.removeEventListener("keydown",l,!0),(c=n.onClose)==null||c.call(n))},a=c=>{n.onClose=c},r=c=>{if(!i.contains(c.target)&&!this.grid.getRootElement().contains(c.target)){o();return}i.contains(c.target)||o()},l=c=>{c.key==="Escape"&&(c.stopPropagation(),o())};return this.getParent().appendChild(i),this.openPopups.add(n),document.addEventListener("mousedown",r,!0),document.addEventListener("keydown",l,!0),{ePopup:i,close:o,onClose:a}}positionAt(e,t,i=0){const n=this.grid.getRootElement().getBoundingClientRect(),o=t.getBoundingClientRect(),a=e.offsetWidth||220;let r=o.left-n.left+i;const l=n.width-a-4;r>l&&(r=l),r<4&&(r=4);const c=o.bottom-n.top+2;e.style.left=`${r}px`,e.style.top=`${c}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}const Tt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],Nt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class Po{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var h,m;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,n=this.grid.getFilterService().getFilterInstance(e.colId),o=i==="set"?260:240,{ePopup:a,close:r}=this.popupService.createPopup(o,"ag-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=`Search ${e.headerName||e.field||""}`,a.appendChild(l);let c=n?{...n}:this.getDefaultModel(i),d=n?{...n}:null;const u=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),r()},f=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()};if(i==="set")a.appendChild(this.buildSetFilter(e,c,y=>{d=y}));else if(i==="boolean"){const y=this.buildConditionSelect(["true","false"],String(c.filter??""),E=>{d={filterType:"boolean",filter:E==="true"}});a.appendChild(y)}else{const y=i==="number"?Nt:Tt,E=this.buildConditionSelect(y,c.type||y[0],R=>{c.type=R,d={...c}});if(a.appendChild(E),c.type!=="blank"&&c.type!=="notBlank")if(i==="number"&&c.type==="inRange"){const R=document.createElement("div");R.className="ag-filter-inputs";const S=document.createElement("input");S.type="number",S.className="ag-filter-input",S.value=c.filter??"",S.placeholder=this.grid.t("from"),S.addEventListener("input",()=>{d={...c,filter:S.value,filterTo:A.value}});const A=document.createElement("input");A.type="number",A.className="ag-filter-input",A.value=c.filterTo??"",A.placeholder=this.grid.t("to"),A.addEventListener("input",()=>{d={...c,filter:S.value,filterTo:A.value}}),R.appendChild(S),R.appendChild(A),a.appendChild(R)}else if(i==="date"){const R=document.createElement("div");R.className="ag-filter-inputs";const S=document.createElement("input");S.type="date",S.className="ag-filter-input",S.value=c.dateFrom??"",S.addEventListener("input",()=>{d={...c,dateFrom:S.value,dateTo:A.value}});const A=document.createElement("input");A.type="date",A.className="ag-filter-input",A.value=c.dateTo??"",A.addEventListener("input",()=>{d={...c,dateFrom:S.value,dateTo:A.value}}),R.appendChild(S),R.appendChild(A),a.appendChild(R)}else{const R=document.createElement("input");R.type=i==="number"?"number":"text",R.className="ag-filter-input",R.value=c.filter??"",R.placeholder=this.grid.t("filterOoo"),R.addEventListener("input",()=>{d={...c,filter:R.value}}),R.addEventListener("keydown",S=>{S.key==="Enter"&&u()}),a.appendChild(R),setTimeout(()=>R.focus(),0)}else d={...c}}if(i==="text"||i==="number"){const y=document.createElement("div");y.className="ag-filter-second-condition";const E=document.createElement("select");E.className="ag-filter-condition",E.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,E.value=c.operator||"AND",y.appendChild(E);const R=this.buildConditionSelect(i==="number"?Nt:Tt,((h=c.condition2)==null?void 0:h.type)||(i==="number"?Nt:Tt)[0],A=>{d||(d={...c}),d.condition2={...d.condition2,type:A}});y.appendChild(R);const S=document.createElement("input");S.type=i==="number"?"number":"text",S.className="ag-filter-input",S.placeholder=this.grid.t("secondValue"),S.value=((m=c.condition2)==null?void 0:m.filter)??"",S.addEventListener("input",()=>{d||(d={...c}),d.condition2={...d.condition2,filter:S.value}}),y.appendChild(S),a.appendChild(y),E.addEventListener("change",()=>{d||(d={...c}),d.operator=E.value})}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",u);const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",f),g.appendChild(C),g.appendChild(p),a.appendChild(g),this.popupService.positionAt(a,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,i){const n=document.createElement("div");n.className="ag-set-filter";const o=document.createElement("input");o.type="text",o.className="ag-filter-input",o.placeholder=this.grid.t("search"),n.appendChild(o);const a=new Set;this.grid.getRowModel().forEachNode(C=>{!C.group&&!C.footer&&a.add(de(e,C,this.grid.getApi()))});let l=[...a].sort((C,h)=>C===h?0:C<h?-1:1);const c=document.createElement("div");c.className="ag-set-filter-list";const d=new Set((t.values||[]).map(C=>String(C))),u=()=>{c.innerHTML="";const C=o.value.toLowerCase();let h=0;for(const m of l){const y=m==null?"(Blanks)":String(m);if(C&&!y.toLowerCase().includes(C))continue;h++;const E=document.createElement("label");E.className="ag-set-filter-item";const R=document.createElement("input");R.type="checkbox",R.checked=d.has(String(m)),R.addEventListener("change",()=>{R.checked?d.add(String(m)):d.delete(String(m)),i({filterType:"set",values:[...d]})});const S=document.createElement("span");S.textContent=y,E.appendChild(R),E.appendChild(S),c.appendChild(E)}if(h===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),c.appendChild(m)}};o.addEventListener("input",u),u();const f=document.createElement("div");f.className="ag-set-filter-actions";const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent=this.grid.t("selectAll"),g.addEventListener("click",()=>{d.clear();for(const C of l)d.add(String(C));u(),i({filterType:"set",values:[...d]})});const p=document.createElement("button");return p.className="ag-button ag-button-small",p.textContent=this.grid.t("clearAll"),p.addEventListener("click",()=>{d.clear(),u(),i({filterType:"set",values:[]})}),f.appendChild(g),f.appendChild(p),n.appendChild(c),n.appendChild(f),i({filterType:"set",values:[...d]}),n}buildConditionSelect(e,t,i){const n=document.createElement("select");n.className="ag-filter-condition";for(const o of e){const a=document.createElement("option");a.value=o;const r=Qn[o];a.textContent=r?this.grid.t(r):o,o===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n}openMultiFilter(e,t){var E;const i=this.grid.getFilterService().getFilterInstance(e.colId),n=i&&i.filterType==="multi"?i:null,o=(E=n==null?void 0:n.filterModels)!=null&&E.length?n.filterModels.map(R=>({...R})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(n==null?void 0:n.operator)||"AND";const{ePopup:r,close:l}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");r.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`Filters for ${e.headerName||e.field||""}`,r.appendChild(c);const d=document.createElement("div");d.className="ag-multi-filter-operator";const u=document.createElement("span");u.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=a,f.addEventListener("change",()=>{a=f.value}),d.appendChild(u),d.appendChild(f),r.appendChild(d);const g=document.createElement("div");g.className="ag-multi-filter-list",r.appendChild(g);const p=()=>{g.innerHTML="",o.forEach((R,S)=>{const A=document.createElement("div");A.className="ag-multi-filter-row";const B=document.createElement("select");B.className="ag-filter-condition";const L=["text","number","date","set","boolean"];for(const D of L){const k=document.createElement("option");k.value=D,k.textContent=D.charAt(0).toUpperCase()+D.slice(1),D===R.filterType&&(k.selected=!0),B.appendChild(k)}B.addEventListener("change",()=>{o[S]={...this.getDefaultModel(B.value)},p()}),A.appendChild(B);const j=R.filterType==="number"?Nt:Tt,W=this.buildConditionSelect(j,R.type||j[0],D=>{o[S].type=D});if(A.appendChild(W),R.filterType!=="blank"&&R.type!=="blank"&&R.type!=="notBlank"){const D=document.createElement("input");D.type=R.filterType==="number"?"number":"text",D.className="ag-filter-input",D.value=R.filter??"",D.placeholder=this.grid.t("value"),D.addEventListener("input",()=>{o[S].filter=D.value}),A.appendChild(D)}const M=document.createElement("button");M.className="ag-button ag-button-small",M.textContent="×",M.title=this.grid.t("removeFilter"),M.addEventListener("click",()=>{o.splice(S,1),p()}),A.appendChild(M),g.appendChild(A)})};p();const C=document.createElement("button");C.className="ag-button ag-button-small",C.textContent="+ "+this.grid.t("addFilter"),C.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),p()}),r.appendChild(C);const h=document.createElement("div");h.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",()=>{o.filter(S=>S.filter!==void 0&&S.filter!==""||S.type==="blank"||S.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),l()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),l()}),h.appendChild(y),h.appendChild(m),r.appendChild(h),this.popupService.positionAt(r,t)}openAdvancedFilter(e){var E,R;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),n=(E=i==null?void 0:i.conditions)!=null&&E.length?i.conditions.map(S=>({...S})):[{colId:((R=this.grid.getColumns().center[0])==null?void 0:R.colId)??"",type:"contains",filter:""}];let o=(i==null?void 0:i.operator)||"AND";const{ePopup:a,close:r}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const l=document.createElement("div");l.className="ag-popup-title",l.textContent=this.grid.t("advancedFilter"),a.appendChild(l);const c=document.createElement("div");c.className="ag-advanced-filter-list",a.appendChild(c);const d=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(S=>S.filter),u=()=>{c.innerHTML="",n.forEach((S,A)=>{const B=document.createElement("div");B.className="ag-advanced-filter-row";const L=document.createElement("select");L.className="ag-filter-condition";for(const _ of d()){const Q=document.createElement("option");Q.value=_.colId,Q.textContent=_.headerName||_.field||_.colId,_.colId===S.colId&&(Q.selected=!0),L.appendChild(Q)}L.addEventListener("change",()=>{n[A].colId=L.value}),B.appendChild(L);const j=this.grid.getColumn(S.colId),W=j&&j.filter!==!1?String(j.filter):"text",M=W==="number"?Nt:Tt,D=this.buildConditionSelect(M,S.type||"contains",_=>{n[A].type=_});B.appendChild(D);const k=document.createElement("input");k.type=W==="number"?"number":"text",k.className="ag-filter-input",k.value=S.filter??"",k.placeholder=this.grid.t("value"),k.addEventListener("input",()=>{n[A].filter=k.value}),B.appendChild(k);const z=document.createElement("button");z.className="ag-button ag-button-small",z.textContent="×",z.addEventListener("click",()=>{n.splice(A,1),u()}),B.appendChild(z),c.appendChild(B)})};u();const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent="+ "+this.grid.t("addCondition"),f.addEventListener("click",()=>{var S;n.push({colId:((S=d()[0])==null?void 0:S.colId)??"",type:"contains",filter:""}),u()}),a.appendChild(f);const g=document.createElement("div");g.className="ag-multi-filter-operator";const p=document.createElement("span");p.textContent=this.grid.t("join");const C=document.createElement("select");C.className="ag-filter-condition",C.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',C.value=o,C.addEventListener("change",()=>{o=C.value}),g.appendChild(p),g.appendChild(C),a.appendChild(g);const h=document.createElement("div");h.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",()=>{const S=n.filter(A=>A.filter!==void 0&&A.filter!=="");S.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:S}):t.setAdvancedFilterModel(null),r()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{t.setAdvancedFilterModel(null),r()}),h.appendChild(y),h.appendChild(m),a.appendChild(h),this.popupService.positionAt(a,e)}openCustomFilter(e,t){const i=e.colDef.filterComponent;if(typeof i!="function")return;const n=this.grid.getFilterService(),o=i({column:e,colDef:e.colDef,api:this.grid.getApi(),model:n.getFilterInstance(e.colId)??null,onModelChange:c=>n.setColumnFilterModel(e,c),onGuiAttached:()=>{}}),{ePopup:a,close:r}=this.popupService.createPopup(260,"ag-filter-popup");a.innerHTML="";const l=typeof(o==null?void 0:o.getGui)=="function"?o.getGui():o;l instanceof HTMLElement&&a.appendChild(l),typeof(o==null?void 0:o.afterGuiAttached)=="function"&&o.afterGuiAttached(),this.popupService.positionAt(a,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 Ui={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 $o{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 n;typeof i=="function"?n=i({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(i)?n=i:n=this.getDefaultItems(t);const{ePopup:o,close:a}=this.popupService.createPopup(220,"ag-context-menu");o.innerHTML="",this.buildMenu(o,n,a),this.popupService.positionAt(o,e)}buildMenu(e,t,i){for(const n of t){if(typeof n=="string")continue;if(n.separator){const l=document.createElement("div");l.className="ag-menu-separator",e.appendChild(l);continue}const o=document.createElement("div");o.className="ag-menu-item",n.disabled&&o.classList.add("ag-menu-item-disabled"),n.cssClasses&&o.classList.add(...n.cssClasses);const a=document.createElement("span");a.className="ag-menu-item-icon",n.icon&&Ui[n.icon]&&(a.innerHTML=Ui[n.icon]),o.appendChild(a);const r=document.createElement("span");if(r.className="ag-menu-item-label",r.textContent=n.label??n.name,o.appendChild(r),n.shortcut){const l=document.createElement("span");l.className="ag-menu-item-shortcut",l.textContent=n.shortcut,o.appendChild(l)}if(n.subMenu){const l=document.createElement("span");l.className="ag-menu-item-arrow",l.textContent="›",o.appendChild(l),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(u=>u.remove());const d=document.createElement("div");d.className="ag-menu-popup-sub",this.buildMenu(d,n.subMenu,i),e.appendChild(d)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var d;o.matches(":hover")||((d=o.parentElement)==null?void 0:d.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(u=>u.remove())},200)})}else!n.disabled&&n.action&&o.addEventListener("click",()=>{n.action(),i()});e.appendChild(o)}}}class Go{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:i,close:n}=this.popupService.createPopup(220,"ag-column-menu");i.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=e.headerName||e.field||e.colId,i.appendChild(o);const a=(l,c)=>{const d=document.createElement("div");d.className="ag-menu-item",c.disabled&&d.classList.add("ag-menu-item-disabled"),c.checked&&d.classList.add("ag-menu-item-active");const u=document.createElement("span");u.className="ag-menu-item-check",c.checked&&(u.innerHTML=Bi),d.appendChild(u);const f=document.createElement("span");if(f.className="ag-menu-item-label",f.textContent=l,d.appendChild(f),c.shortcut){const g=document.createElement("span");g.className="ag-menu-item-shortcut",g.textContent=c.shortcut,d.appendChild(g)}return!c.disabled&&c.onClick&&d.addEventListener("click",()=>{c.onClick(),n()}),i.appendChild(d),d},r=l=>{const c=document.createElement("div");c.className="ag-menu-section",c.textContent=l,i.appendChild(c)};e.sortable&&(r(this.grid.t("sort")),a(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")}}),a(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&&(r(this.grid.t("columnSize")),a(this.grid.t("autosizeThisColumn"),{onClick:()=>this.grid.getColumnApi().autoSizeColumn(e)}),a(this.grid.t("autosizeAllColumns"),{onClick:()=>this.grid.getColumnApi().autoSizeAllColumns()})),e.lockPosition||(r(this.grid.t("pinColumn")),a(this.grid.t("pinLeft"),{checked:e.pinned==="left",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"left")}),a(this.grid.t("noPin"),{checked:e.pinned===null,onClick:()=>this.grid.getColumnApi().setColumnPinned(e,null)}),a(this.grid.t("pinRight"),{checked:e.pinned==="right",onClick:()=>this.grid.getColumnApi().setColumnPinned(e,"right")})),e.filter?(r(this.grid.t("filter")),a(this.grid.t("openFilter"),{onClick:()=>this.grid.getFilterGui().openFilter(e,t)}),e.filter!=="multi"&&a(this.grid.t("openMultiFilter"),{onClick:()=>this.grid.getFilterGui().openMultiFilter(e,t)}),this.grid.getOptions().enableAdvancedFilter&&a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)}),a(this.grid.t("clearFilter"),{disabled:!this.grid.getFilterService().isFilterActive(e),onClick:()=>this.grid.getFilterService().setColumnFilterModel(e,null)})):this.grid.getOptions().enableAdvancedFilter&&(r(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),r(this.grid.t("formula")),a(this.grid.getFormulaEditorService().isFormulaColumn(e)?this.grid.t("editFormula"):this.grid.t("addFormula"),{onClick:()=>this.grid.getFormulaEditorService().openFormulaEditor(e,t)}),r(this.grid.t("visibility")),a(this.grid.t("hideColumn"),{onClick:()=>this.grid.getColumnApi().setColumnVisible(e,!1)}),a(this.grid.t("chooseColumns"),{onClick:()=>{this.grid.getApi().openToolPanel("columns")}}),this.popupService.positionAt(i,t)}}class Ho{constructor(e,t){v(this,"eBar");v(this,"panels",[]);this.grid=e,this.eventService=t,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const n=e.getOptions().statusBar;(!n||!n.statusPanels||n.statusPanels.length===0)&&(this.eBar.style.display="none");const o=((n==null?void 0:n.statusPanels)||[]).map(a=>typeof a=="string"?{key:a,label:a}:{key:a.key||a.statusPanel,label:a.key||a.statusPanel,align:a.align});for(const a of o){const r=document.createElement("div");r.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(r);const l={def:a,ePanel:r,render:()=>this.renderPanel(a.key,r)};this.panels.push(l)}}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(),n=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,r=i.getSelectedNodes().length,l=[],c=this.grid.getColumnModel().getValueColumns().filter(d=>d.aggFunc);switch(this.grid.getRowModel().forEachNode(d=>{!d.footer&&d.group}),e){case"agTotalRowCountComponent":l.push(`${this.grid.translate("totalRows","Total Rows")} : ${Ke(a)}`);break;case"agTotalAndFilteredRowCountComponent":l.push(`${this.grid.translate("rows","Rows")} : ${Ke(n)}`);break;case"agFilteredRowCountComponent":l.push(`${this.grid.translate("filtered","Filtered")} : ${Ke(n)}`);break;case"agSelectedRowCountComponent":l.push(`${this.grid.translate("selected","Selected")} : ${Ke(r)}`);break;case"agAggregationComponent":{if(c.length===0)break;const d=i.getSelectedNodes().filter(f=>!f.group&&!f.footer),u=[];for(const f of c){const p=d.map(y=>de(f,y,i)).filter(y=>typeof y=="number"&&!isNaN(y)),C=p.reduce((y,E)=>y+E,0),h=y=>y===null?"":Ke(y,f.decimals),m=[[this.grid.translate("average","Average"),p.length?C/p.length:null],[this.grid.translate("count","Count"),p.length],[this.grid.translate("min","Min"),p.length?Math.min(...p):null],[this.grid.translate("max","Max"),p.length?Math.max(...p):null],[this.grid.translate("sum","Sum"),p.length?C:null]];for(const[y,E]of m)u.push(`${y}${f.headerName?` (${f.headerName})`:""} : ${h(E)}`)}u.length&&l.push(u.join(" "));break}default:l.push(e);break}t.textContent=l.join(" "),t.style.display=l.length?"":"none"}}class Oo{constructor(e){v(this,"eBar");v(this,"eButtons");v(this,"ePanel");v(this,"panels",[]);v(this,"activePanelId",null);v(this,"visible",!1);v(this,"position");var i,n;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 o=typeof t.sideBar=="object"?t.sideBar:null;o!=null&&o.toolPanels?this.panels=o.toolPanels.map(l=>typeof l=="string"?{id:l,label:this.defaultLabel(l)}:{id:l.id,label:l.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 a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const r=(o==null?void 0:o.defaultToolPanel)||((n=this.panels[0])==null?void 0:n.id)||"columns";this.buildButtons(),this.openPanel(r)}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 n=()=>{const c=t.value.toLowerCase();i.innerHTML="";const d=this.grid.getColumnModel().getColumns(),u=d.filter(f=>f.pinned!=="left"&&f.pinned!=="right").concat(d.filter(f=>f.pinned==="left"||f.pinned==="right"));for(const f of u)c&&!f.headerName.toLowerCase().includes(c)&&!f.colId.toLowerCase().includes(c)||i.appendChild(this.buildColumnItem(f));if(!i.children.length){const f=document.createElement("div");f.className="ag-side-bar-empty",f.textContent=this.grid.t("noMatchingColumns"),i.appendChild(f)}};t.addEventListener("input",n),n();const o=document.createElement("div");o.className="ag-column-panel-groups";const a=document.createElement("div");a.className="ag-column-panel-section-title",a.textContent=this.grid.t("rowGroups"),o.appendChild(a);const r=document.createElement("div");r.className="ag-column-group-list",o.appendChild(r);const l=()=>{r.innerHTML="";const c=this.grid.getColumnModel().getRowGroupColumns();if(c.length===0){const d=document.createElement("div");d.className="ag-column-group-hint",d.textContent=this.grid.t("dragColumnsHere"),r.appendChild(d)}for(const d of c){const u=document.createElement("div");u.className="ag-column-group-item",u.draggable=!0,u.addEventListener("dragstart",p=>{var C;(C=p.dataTransfer)==null||C.setData("text/plain",d.colId)}),u.addEventListener("dragover",p=>p.preventDefault()),u.addEventListener("drop",p=>{var h;p.preventDefault();const C=(h=p.dataTransfer)==null?void 0:h.getData("text/plain");C&&this.grid.getColumnModel().setRowGroupColumns([...c.map(m=>m.colId),C])});const f=document.createElement("span");f.textContent=d.headerName,u.appendChild(f);const g=document.createElement("button");g.className="ag-column-group-remove",g.textContent="×",g.title=this.grid.t("remove"),g.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(d)),u.appendChild(g),r.appendChild(u)}};return l(),r.addEventListener("dragover",c=>c.preventDefault()),r.addEventListener("drop",c=>{var u;c.preventDefault();const d=(u=c.dataTransfer)==null?void 0:u.getData("text/plain");d&&this.grid.getColumnModel().addRowGroupColumn(d)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&l()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&n()}),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 n=document.createElement("span");n.className="ag-column-select-label",n.textContent=e.headerName||e.colId,t.appendChild(n);const o=document.createElement("span");if(o.className="ag-column-select-actions",e.enableRowGroup&&e.field){const r=document.createElement("button");r.className="ag-column-select-action",r.title=this.grid.t("groupByThisColumn"),r.textContent="≡",r.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(r)}const a=document.createElement("button");return a.className="ag-column-select-action",a.title=this.grid.t("pinColumnTitle"),a.textContent="📌",a.addEventListener("click",()=>{this.grid.getColumnApi().setColumnPinned(e,e.pinned?null:"left")}),o.appendChild(a),t.appendChild(o),t}buildFiltersPanel(){const e=document.createElement("div");if(e.className="ag-filters-panel",this.grid.getOptions().enableAdvancedFilter){const o=document.createElement("button");o.className="ag-button ag-button-small",o.textContent=`${this.grid.t("advancedFilter")}…`,o.addEventListener("click",()=>this.grid.getFilterGui().openAdvancedFilter(o)),e.appendChild(o);const a=this.grid.getFilterService().getAdvancedFilterModel();if(a){const r=document.createElement("span");r.className="ag-filters-tool-panel-item-badge",r.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(r)}}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 n=()=>{const o=t.value.toLowerCase();i.innerHTML="";const a=this.grid.getColumns().center.filter(r=>r.filter);for(const r of a)o&&!r.headerName.toLowerCase().includes(o)||i.appendChild(this.buildFilterItem(r));if(!i.children.length){const r=document.createElement("div");r.className="ag-side-bar-empty",r.textContent=this.grid.t("noMatchingColumns"),i.appendChild(r)}};return t.addEventListener("input",n),n(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&n()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),i=document.createElement("div");i.className="ag-filters-tool-panel-item";const n=document.createElement("div");n.className="ag-filters-tool-panel-item-header";const o=document.createElement("span");o.className="ag-filters-tool-panel-item-label",o.textContent=e.headerName||e.colId,n.appendChild(o);const a=t.isFilterActive(e);if(a){const r=document.createElement("span");r.className="ag-filters-tool-panel-item-badge",r.innerHTML=Bi,n.appendChild(r)}if(i.appendChild(n),e.filter==="set"){const r=document.createElement("button");r.className="ag-button ag-button-small",r.textContent=a?"Edit filter":"Add filter",r.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,r)),i.appendChild(r)}else if(e.filter==="date"){const r=document.createElement("input");r.type="date",r.className="ag-filter-input";const l=t.getFilterInstance(e.colId);r.value=(l==null?void 0:l.dateFrom)??"",r.addEventListener("change",()=>{t.setColumnFilterModel(e,r.value?{filterType:"date",dateFrom:r.value,dateTo:r.value}:null)}),i.appendChild(r)}else{const r=document.createElement("input");r.type=e.filter==="number"?"number":"text",r.className="ag-filter-input",r.placeholder=this.grid.t("filterOoo");const l=t.getFilterInstance(e.colId);r.value=(l==null?void 0:l.filter)??"",r.addEventListener("input",()=>{t.handleFloatingFilterChange(e,r.value)}),i.appendChild(r)}if(a){const r=document.createElement("button");r.className="ag-button ag-button-small",r.textContent=this.grid.t("clear"),r.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(r)}return i}}class Bo{constructor(e,t){v(this,"matches",[]);v(this,"activeMatch",0);v(this,"searchText","");v(this,"matchCase",!1);v(this,"ePopup",null);v(this,"eCount",null);v(this,"eInput",null);v(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var l,c;if(this.ePopup){(l=this.eInput)==null||l.focus(),(c=this.eInput)==null||c.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 n=document.createElement("label");n.className="ag-find-case";const o=document.createElement("input");o.type="checkbox",o.checked=this.matchCase,o.addEventListener("change",()=>{this.matchCase=o.checked,this.find(this.searchText)}),n.appendChild(o),n.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(n);const a=document.createElement("span");a.className="ag-find-count",this.eCount=a,e.appendChild(a);const r=(d,u,f)=>{const g=document.createElement("button");return g.className="ag-button ag-button-small",g.textContent=d,g.title=u,g.addEventListener("click",f),e.appendChild(g),g};r("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),r("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),r("×",this.grid.translate("close","关闭"),()=>this.close()),i.addEventListener("input",()=>this.find(i.value)),i.addEventListener("keydown",d=>{d.key==="Enter"?(d.preventDefault(),d.shiftKey?this.findPrevious():this.findNext()):d.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,n)=>{if(!(i.group||i.footer))for(const o of t){de(o,i,this.grid.getApi());const a=Ot(o,i,this.grid.getApi())??"",r=this.matchCase?a:a.toLowerCase(),l=this.matchCase?e:e.toLowerCase();r.includes(l)&&this.matches.push({rowIndex:n,colId:o.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 o,a;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=(a=(o=this.grid).getPaginationService)==null?void 0:a.call(o);if(t!=null&&t.isEnabled()){const r=t.getPageSize(),l=Math.floor(e.rowIndex/r);l!==t.getCurrentPage()&&t.goToPage(l)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const i=this.grid.getDisplayedRowAtIndex(e.rowIndex),n=this.grid.getColumn(e.colId);i&&n&&this.grid.getEditService().setFocusedCell(e.rowIndex,n)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,i]of e){let n=-1;this.grid.getRowModel().forEachNode((o,a)=>{o.id===t&&(n=a)});for(const o of i.getCellElements()){const a=o.dataset.colid,r=this.matches.findIndex(l=>l.rowIndex===n&&l.colId===a);o.classList.toggle("ag-find-match",r>=0),o.classList.toggle("ag-find-active-match",r>=0&&r===this.activeMatch)}}}}class Vo{constructor(e,t){v(this,"ranges",[]);v(this,"currentRange",null);v(this,"eOverlay");v(this,"eHandle");v(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:n}=e;if(t.button!==0)return;if(t.shiftKey&&this.ranges.length>0){const a=this.ranges[this.ranges.length-1];this.currentRange={...a,rowEndIndex:n,colEndId:i.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const o={rowStartIndex:n,rowEndIndex:n,colStartId:i.colId,colEndId:i.colId};this.currentRange=o,this.dragState={startRange:o,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 n=i.closest(".ag-row");if(!(n!=null&&n.dataset.rowid))return;const o=this.grid.getRowModel().getRowNode(n.dataset.rowid);if(!o)return;let a=-1;if(this.grid.getRowModel().forEachNode((l,c)=>{l.id===o.id&&(a=c)}),a<0)return;const r=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(r.rowStartIndex,a),rowEndIndex:Math.max(r.rowStartIndex,a),colStartId:r.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(r.rowStartIndex,a),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(C=>C.colId===e.colStartId),n=t.findIndex(C=>C.colId===e.colEndId);if(i<0||n<0)return null;const o=Math.min(i,n),a=Math.max(i,n);let r=0,l=0;for(let C=0;C<=a;C++)C<o?r+=t[C].width:l+=t[C].width;const d=this.grid.getRowRenderer().getRowOffsets(),u=Math.min(e.rowStartIndex,e.rowEndIndex),f=Math.max(e.rowStartIndex,e.rowEndIndex),g=d[u]??u*(this.grid.getOptions().rowHeight??42);let p=0;for(let C=u;C<=f;C++){const h=this.grid.getDisplayedRowAtIndex(C);p+=h?this.grid.getRowHeight(h):this.grid.getOptions().rowHeight??42}return{top:g,left:r,width:l,height:p}}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[n,o]of t){let a=-1;if(this.grid.getRowModel().forEachNode((r,l)=>{r.id===n&&(a=l)}),!(a<0))for(const r of o.getCellElements()){const l=r.dataset.colid,c=i.findIndex(f=>f.colId===l);let d=!1,u=!1;for(const f of e){const g=i.findIndex(E=>E.colId===f.colStartId),p=i.findIndex(E=>E.colId===f.colEndId),C=Math.min(f.rowStartIndex,f.rowEndIndex),h=Math.max(f.rowStartIndex,f.rowEndIndex),m=Math.min(g,p),y=Math.max(g,p);a>=C&&a<=h&&c>=m&&c<=y&&(d=!0,a===f.rowStartIndex&&c===g&&(u=!0))}r.classList.toggle("ag-cell-range-selected",d),r.classList.toggle("ag-cell-range-anchor",u)}}}getRangeCells(e){const t=this.getCenterColumns(),i=t.findIndex(d=>d.colId===e.colStartId),n=t.findIndex(d=>d.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),r=Math.min(i,n),l=Math.max(i,n),c=[];for(let d=o;d<=a;d++){const u=this.grid.getDisplayedRowAtIndex(d);if(u)for(let f=r;f<=l;f++)t[f]&&c.push({node:u,column:t[f]})}return c}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===ki||e.keyCode===Mi)&&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 _i(s){return String(s).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}const nt=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class zo{constructor(e,t){v(this,"charts",new Map);v(this,"chartCounter",0);v(this,"currentType","line");v(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 n=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(l=>l.aggFunc),a=[],r=o.map(()=>[]);if(i.length>0)((c,d)=>{for(const u of c)if(u.group){const f=i[0]?String(de(i[0],u,this.grid.getApi())??""):u.key??"";a.push(f);for(let g=0;g<o.length;g++){const p=[];qi(u,o[g],p),r[g].push(Number(kt(o[g],o[g].aggFunc,p))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(n||(n=this.grid.getColumns().center.find(l=>l.field&&l.type!=="numberColumn")||this.grid.getColumns().center[0]),this.grid.getRowModel().forEachNode(l=>{if(l.group||l.footer)return;const c=n?de(n,l,this.grid.getApi()):"";a.push(String(c??""));for(let d=0;d<o.length;d++){const u=de(o[d],l,this.grid.getApi());r[d].push(typeof u=="number"?u:Number(u)||0)}}),a.length>200){const l=Math.ceil(a.length/200),c=[],d=r.map(()=>[]);for(let u=0;u<a.length;u+=l){c.push(a[u]);for(let f=0;f<r.length;f++)d[f].push(r[f][u])}return{categories:c,series:o.map((u,f)=>({title:u.headerName,data:d[f]}))}}return{categories:a,series:o.map((l,c)=>({title:l.headerName,data:r[c]}))}}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 n=document.createElement("select");n.className="ag-chart-panel-select";const o=[{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 h of o){const m=document.createElement("option");m.value=h.value,m.textContent=h.label,h.value===this.currentType&&(m.selected=!0),n.appendChild(m)}n.addEventListener("change",()=>{this.currentType=n.value}),e.appendChild(n);const a=document.createElement("div");a.className="ag-chart-panel-label",a.textContent=this.grid.t("chartCategory"),e.appendChild(a);const r=document.createElement("select");r.className="ag-chart-panel-select";const l=this.grid.getColumnModel().getRowGroupColumns(),c=l.length>0?l:this.grid.getColumns().center.filter(h=>h.field);for(const h of c){const m=document.createElement("option");m.value=h.colId,m.textContent=l.length>0?`${this.grid.t("chartGroup")}: ${h.headerName}`:h.headerName,r.appendChild(m)}e.appendChild(r);const d=document.createElement("div");d.className="ag-chart-panel-label",d.textContent=this.grid.t("chartSeries"),e.appendChild(d);const u=this.grid.getColumnModel().getValueColumns().filter(h=>h.aggFunc),f=document.createElement("div");f.className="ag-chart-panel-series";const g=new Set(u.slice(0,3).map(h=>h.colId));for(const h of this.grid.getColumns().center.filter(m=>m.field)){const m=document.createElement("label");m.className="ag-chart-panel-series-item";const y=document.createElement("input");y.type="checkbox",y.checked=g.has(h.colId),y.addEventListener("change",()=>{y.checked?g.add(h.colId):g.delete(h.colId)}),m.appendChild(y);const E=document.createElement("span");E.textContent=h.headerName,m.appendChild(E),f.appendChild(m)}e.appendChild(f);const p=document.createElement("button");p.className="ag-button ag-button-primary ag-chart-panel-create",p.textContent=this.grid.t("createChart"),p.addEventListener("click",()=>{const h=this.grid.getColumn(r.value)||void 0,m=[...g].map(y=>this.grid.getColumn(y)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:h,valueColumns:m})}),e.appendChild(p);const C=document.createElement("div");if(C.className="ag-chart-panel-list",this.charts.size===0){const h=document.createElement("div");h.className="ag-side-bar-empty",h.textContent=this.grid.t("noChartsCreated"),C.appendChild(h)}for(const[h,m]of this.charts){const y=document.createElement("div");y.className="ag-chart-panel-list-item";const E=document.createElement("span");E.textContent=m.title,y.appendChild(E);const R=document.createElement("button");R.className="ag-column-group-remove",R.textContent="×",R.addEventListener("click",()=>this.destroyChart(h)),y.appendChild(R),C.appendChild(y)}return e.appendChild(C),e}createChart(e={}){var h,m,y,E;const t=e.type||this.currentType,i=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),n=`chart-${++this.chartCounter}`,o=e.title||`${this.grid.t(`chart${t.charAt(0).toUpperCase()}${t.slice(1)}`)}`,{ePopup:a}=this.popupService.createPopup(640,"ag-chart-window");a.innerHTML="";const r=document.createElement("div");r.className="ag-chart-window-header";const l=document.createElement("span");l.className="ag-chart-window-title",l.textContent=o,r.appendChild(l);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent=this.grid.t("downloadPng"),r.appendChild(c);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent="×",d.title=this.grid.t("close"),d.addEventListener("click",()=>this.destroyChart(n)),r.appendChild(d),a.appendChild(r);const u=document.createElement("div");u.className="ag-chart-window-body";const f=document.createElement("canvas");f.className="ag-chart-canvas",f.width=600,f.height=360,u.appendChild(f);const g=document.createElement("div");g.className="ag-chart-tooltip",g.style.display="none",u.appendChild(g),f.addEventListener("mousemove",R=>this.onChartHover({id:n,ePopup:a,canvas:f,type:t,data:i,title:o},R,g)),f.addEventListener("mouseleave",()=>{g.style.display="none"});const p=document.createElement("div");p.className="ag-chart-legend",u.appendChild(p),a.appendChild(u),this.timeSeries=i.categories.length>0&&i.categories.every(R=>!isNaN(Date.parse(String(R)))&&isNaN(Number(R)));const C={id:n,ePopup:a,canvas:f,type:t,data:i,title:o};return this.charts.set(n,C),c.addEventListener("click",()=>{const R=f.toDataURL("image/png"),S=document.createElement("a");S.href=R,S.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,S.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(C),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:n,chartTitle:o,api:this.grid.getApi()}),(m=(h=this.grid.getOptions()).onChartCreated)==null||m.call(h,{chartId:n,chartTitle:o,api:this.grid.getApi()}),((y=this.grid.getSideBarService())==null?void 0:y.getActivePanel())==="charts"&&((E=this.grid.getSideBarService())==null||E.refresh()),n}destroyChart(e){var i,n,o,a;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()}),(n=(i=this.grid.getOptions()).onChartDestroyed)==null||n.call(i,{chartId:e,api:this.grid.getApi()}),((o=this.grid.getSideBarService())==null?void 0:o.getActivePanel())==="charts"&&((a=this.grid.getSideBarService())==null||a.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 o=e.canvas.getBoundingClientRect(),a=600/(o.width||1),r=360/(o.height||1),l=(t.clientX-o.left)*a,c=(t.clientY-o.top)*r,d={top:20,right:20,bottom:34,left:56},u=600-d.left-d.right,f=360-d.top-d.bottom;if(l<d.left||l>d.left+u||c<d.top||c>d.top+f){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const g=e.type==="bar",p=Math.max(1,e.data.categories.length),C=(g?f:u)/p,h=Math.floor((g?c-d.top:l-d.left)/C);if(h<0||h>=e.data.categories.length){i.style.display="none";return}const m=e.data.series.map(y=>`${y.title}: ${this.formatTick(y.data[h]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${_i(e.data.categories[h])}</div>`+m.map(y=>`<div>${_i(y)}</div>`).join(""),i.style.display="block",i.style.left=`${t.clientX-o.left+12}px`,i.style.top=`${t.clientY-o.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 n=document.createElement("div");n.className="ag-chart-window-header";const o=document.createElement("span");o.className="ag-chart-window-title",o.textContent=e.title||this.grid.t("chart"),n.appendChild(o);const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="×",a.addEventListener("click",()=>this.destroyChart(t)),n.appendChild(a),i.appendChild(n);const r=document.createElement("div");r.className="ag-chart-window-body";const l=document.createElement("canvas");l.className="ag-chart-canvas",l.width=600,l.height=360,r.appendChild(l);const c=document.createElement("div");c.className="ag-chart-legend",r.appendChild(c),i.appendChild(r);const d={id:t,ePopup:i,canvas:l,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,d),this.popupService.positionAt(i,this.grid.getRootElement()),i.style.top="60px",this.renderChart(d)}renderChart(e){var j;const t=e.canvas,i=t.getContext("2d");if(!i)return;const n=window.devicePixelRatio||1,o=t.width,a=t.height;t.width=o*n,t.height=a*n,t.style.width=`${o}px`,t.style.height=`${a}px`,i.scale(n,n),i.clearRect(0,0,o,a);const r=getComputedStyle(this.grid.getRootElement()),l=r.getPropertyValue("--ag-chart-text-color")||"#666",c=r.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",d={top:20,right:20,bottom:34,left:56},u=o-d.left-d.right,f=a-d.top-d.bottom;i.font="11px sans-serif",i.fillStyle=l,i.strokeStyle=c,i.lineWidth=1;const g=(j=e.canvas.parentElement)==null?void 0:j.querySelector(".ag-chart-legend");if(g&&(g.innerHTML="",e.data.series.forEach((W,M)=>{const D=document.createElement("span");D.className="ag-chart-legend-item";const k=document.createElement("span");k.className="ag-chart-legend-swatch",k.style.backgroundColor=nt[M%nt.length],D.appendChild(k),D.appendChild(document.createTextNode(W.title)),g.appendChild(D)})),e.type==="pie"){this.renderPie(i,e.data,o,a,l);return}const p=e.data.series.flatMap(W=>W.data);let C=Math.max(0,...p),h=Math.min(0,...p);e.type==="scatter"&&(h=Math.min(...p),C=Math.max(...p));const m=C-h||1;C+=m*.08,h-=h<0?m*.08:0;const y=C-h||1,E=W=>d.top+f-(W-h)/y*f,R=5;i.textAlign="right",i.textBaseline="middle";for(let W=0;W<=R;W++){const M=h+y*W/R,D=E(M);i.beginPath(),i.moveTo(d.left,D),i.lineTo(o-d.right,D),i.stroke(),i.fillText(this.formatTick(M),d.left-6,D)}const S=e.data.categories,A=e.type==="bar",B=Math.max(1,S.length),L=(A?f:u)/B;if(A){i.textAlign="left",S.forEach((M,D)=>{const k=d.top+D*L,z=Math.max(2,L*.7/e.data.series.length);e.data.series.forEach((_,Q)=>{const ne=_.data[D]||0,U=Math.abs(ne)/y*u,F=d.left+(0-h)/y*u;i.fillStyle=nt[Q%nt.length],i.fillRect(F,k+Q*z,Math.max(1,U),z-1)}),i.fillStyle=l,i.fillText(this.truncate(M,18),d.left+4,k+L/2)});const W=d.left+(0-h)/y*u;i.beginPath(),i.moveTo(W,d.top),i.lineTo(W,d.top+f),i.strokeStyle=l,i.stroke()}else{const W=Math.max(1,Math.ceil(B/12));i.textAlign="center",i.textBaseline="top",S.forEach((k,z)=>{if(z%W!==0)return;const _=d.left+L*(z+.5);i.fillStyle=l,i.fillText(this.truncate(k,10),_,d.top+f+6)});const M=e.data.series.length,D=Math.max(1,L*.7/Math.max(1,M));e.data.series.forEach((k,z)=>{const _=nt[z%nt.length];if(e.type==="column")i.fillStyle=_,k.data.forEach((Q,ne)=>{const U=d.left+L*ne+(L-D*M)/2+z*D,F=E(Q);i.fillRect(U,F,D-1,d.top+f-F)});else if(e.type==="area"){i.beginPath(),k.data.forEach((ne,U)=>{const F=d.left+L*(U+.5),q=E(ne);U===0?i.moveTo(F,q):i.lineTo(F,q)});const Q=d.left+L*(k.data.length-.5);i.lineTo(Q,d.top+f),i.lineTo(d.left+L*.5,d.top+f),i.closePath(),i.globalAlpha=.25,i.fillStyle=_,i.fill(),i.globalAlpha=1,i.beginPath(),k.data.forEach((ne,U)=>{const F=d.left+L*(U+.5),q=E(ne);U===0?i.moveTo(F,q):i.lineTo(F,q)}),i.strokeStyle=_,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=_,k.data.forEach((Q,ne)=>{const U=d.left+L*(ne+.5),F=E(Q);i.beginPath(),i.arc(U,F,3,0,Math.PI*2),i.fill()})):(i.beginPath(),k.data.forEach((Q,ne)=>{const U=d.left+L*(ne+.5),F=E(Q);ne===0?i.moveTo(U,F):i.lineTo(U,F)}),i.strokeStyle=_,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,n,o){const a=t.series[0];if(!a)return;const r=a.data.reduce((f,g)=>f+Math.abs(g),0)||1,l=i/2,c=n/2,d=Math.min(i,n)/2-30;let u=-Math.PI/2;a.data.forEach((f,g)=>{const p=Math.abs(f)/r*Math.PI*2;e.beginPath(),e.moveTo(l,c),e.arc(l,c,d,u,u+p),e.closePath(),e.fillStyle=nt[g%nt.length],e.fill();const C=u+p/2,h=l+Math.cos(C)*(d*.7),m=c+Math.sin(C)*(d*.7),y=Math.round(Math.abs(f)/r*100);y>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${y}%`,h,m)),u+=p}),e.fillStyle=o}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 qi(s,e,t){const i=s.children;if(!i||i.length===0){const n=de(e,s,null);typeof n=="number"&&!isNaN(n)&&t.push(n);return}for(const n of i)qi(n,e,t)}class Wo{constructor(e){v(this,"eOverlayWrapper");v(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 n=document.createElement("div");if(n.className="ag-overlay-text",n.textContent=t,e==="loading"){const o=document.createElement("div");o.className="ag-overlay-loading-spinner",i.appendChild(o)}i.appendChild(n),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(),n=this.grid.getOptions().rowData;Array.isArray(n)&&n.length>0,i===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}const Uo=(()=>{const s=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;s[e]=t>>>0}return s})();function _o(s){let e=4294967295;for(let t=0;t<s.length;t++)e=Uo[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Ki(s){return s.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function qo(s){let e="",t=s+1;for(;t>0;){const i=(t-1)%26;e=String.fromCharCode(65+i)+e,t=Math.floor((t-1)/26)}return e}function Ko(s){const e=new TextEncoder,t=[],i=[];let n=0;for(const u of s){const f=e.encode(u.name),g=_o(u.data),p=new Uint8Array(30+f.length),C=new DataView(p.buffer);C.setUint32(0,67324752,!0),C.setUint16(4,20,!0),C.setUint16(6,2048,!0),C.setUint16(8,0,!0),C.setUint16(10,0,!0),C.setUint16(12,8585,!0),C.setUint32(14,g,!0),C.setUint32(18,u.data.length,!0),C.setUint32(22,u.data.length,!0),C.setUint16(26,f.length,!0),C.setUint16(28,0,!0),p.set(f,30),t.push(p,u.data);const h=new Uint8Array(46+f.length),m=new DataView(h.buffer);m.setUint32(0,33639248,!0),m.setUint16(4,20,!0),m.setUint16(6,20,!0),m.setUint16(8,2048,!0),m.setUint16(10,0,!0),m.setUint16(12,0,!0),m.setUint16(14,0,!0),m.setUint32(16,g,!0),m.setUint32(20,u.data.length,!0),m.setUint32(24,u.data.length,!0),m.setUint16(28,f.length,!0),m.setUint32(42,n,!0),h.set(f,46),i.push(h),n+=p.length+u.data.length}const o=i.reduce((u,f)=>u+f.length,0),a=new Uint8Array(22),r=new DataView(a.buffer);r.setUint32(0,101010256,!0),r.setUint16(8,s.length,!0),r.setUint16(10,s.length,!0),r.setUint32(12,o,!0),r.setUint32(16,n,!0);const l=t.reduce((u,f)=>u+f.length,0)+o+a.length,c=new Uint8Array(l);let d=0;for(const u of t)c.set(u,d),d+=u.length;for(const u of i)c.set(u,d),d+=u.length;return c.set(a,d),c}function jo(s){let e='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';return e+='<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><sheetData>',s.forEach((t,i)=>{const n=i+1,a=t.some(r=>r.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${n}"${a}>`,t.forEach((r,l)=>{const c=`${qo(l)}${n}`,d=r.bold?' s="1"':"";if(r.value===null||r.value===void 0||r.value===""){e+=`<c r="${c}"${d}/>`;return}typeof r.value=="number"&&isFinite(r.value)?e+=`<c r="${c}"${d}><v>${r.value}</v></c>`:typeof r.value=="boolean"?e+=`<c r="${c}"${d} t="b"><v>${r.value?1:0}</v></c>`:e+=`<c r="${c}"${d} t="inlineStr"><is><t xml:space="preserve">${Ki(String(r.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const Xo='<?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 Yo(s){const e=new TextEncoder,t=(u,f)=>u.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${f+1}`;let i="",n="",o="";s.forEach((u,f)=>{const g=t(u.name,f),p=f+1;i+=`<sheet name="${Ki(g)}" sheetId="${p}" r:id="rId${p}"/>`,n+=`<Relationship Id="rId${p}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${p}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${p}.xml" ContentType="application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"/>`});const a='<?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"/>'+o+"</Types>",r='<?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>',l=`<?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>`,c='<?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"/>'+n+"</Relationships>",d=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(r)},{name:"xl/workbook.xml",data:e.encode(l)},{name:"xl/_rels/workbook.xml.rels",data:e.encode(c)},{name:"xl/styles.xml",data:e.encode(Xo)}];return s.forEach((u,f)=>{d.push({name:`xl/worksheets/sheet${f+1}.xml`,data:e.encode(jo(u.rows))})}),new Blob([Ko(d)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}const Qo={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function ji(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function Jo(s,e,t){const i=Math.max(1,Math.floor(e/(t*.5)));return s.length>i?`${s.slice(0,Math.max(1,i-1))}…`:s}function Zo(){return new TextEncoder}function es(s,e={}){const[t,i]=Qo[e.pageSize||"a4-landscape"],n=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,r=e.headerColor??[.94,.95,.97],l=e.borderColor??[.85,.87,.9],c=Zo(),d=[],u=y=>(d.push(y),d.length);u(""),u("");const f=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),g=u("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),p=[];for(const y of s){let E="";const R=y.columnWidths.reduce((k,z)=>k+z,0),S=Math.min(1,(t-n*2)/(R||1)),A=y.columnWidths.map(k=>k*S),B=n;let L=i-n-(e.title?24:0);e.title&&(E+=`BT /F2 ${o+4} Tf ${B} ${L} Td (${ji(e.title)}) Tj ET
4
+ `,L-=18),y.rows.forEach((k,z)=>{var U;const _=z===0,Q=((U=y.rowFill)==null?void 0:U[z])??(_?r:void 0);Q&&(E+=`${Q[0]} ${Q[1]} ${Q[2]} rg ${B} ${(L-a+4).toFixed(2)} ${R*S} ${a} re f
5
+ `);let ne=B;k.forEach((F,q)=>{const Z=A[q]??0,ie=ji(Jo(F.text??"",Z-6,o)),be=F.bold||_?g:f,fe=(F.text??"").length*o*.5;let ue=ne+3;F.align==="right"||!F.align&&q>0&&/^-?[\d,.%$£€\s]+$/.test(F.text??"")?ue=ne+Z-3-Math.min(fe,Z-6):F.align==="center"&&(ue=ne+(Z-Math.min(fe,Z-6))/2),E+=`BT /F${be===g?2:1} ${o} Tf ${ue.toFixed(2)} ${(L-o+2).toFixed(2)} Td (${ie}) Tj ET
6
+ `,ne+=Z}),E+=`${l[0]} ${l[1]} ${l[2]} RG 0.5 w ${B} ${(L-a+4).toFixed(2)} m ${(B+R*S).toFixed(2)} ${(L-a+4).toFixed(2)} l S
7
+ `,L-=a});const j=y.rows.length*a;E+=`${l[0]} ${l[1]} ${l[2]} RG 0.5 w ${B} ${(L+a-4).toFixed(2)} m ${B} ${(L+j+a-4).toFixed(2)} l ${(B+R*S).toFixed(2)} ${(L+j+a-4).toFixed(2)} l ${(B+R*S).toFixed(2)} ${(L+a-4).toFixed(2)} l S
8
+ `;const W=c.encode(E),M=u(`<< /Length ${W.length} >>
9
9
  stream
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
13
- ${w}
10
+ ${E}
11
+ endstream`),D=u(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${i}] /Resources << /Font << /F1 ${f} 0 R /F2 ${g} 0 R >> >> /Contents ${M} 0 R >>`);p.push(D)}d[0]="<< /Type /Catalog /Pages 2 0 R >>",d[1]=`<< /Type /Pages /Kids [${p.map(y=>`${y} 0 R`).join(" ")}] /Count ${p.length} >>`;let C=`%PDF-1.4
12
+ `;const h=[];d.forEach((y,E)=>{const R=E+1;h.push(c.encode(C).length),C+=`${R} 0 obj
13
+ ${y}
14
14
  endobj
15
- `});const C=d.encode(m).length;m+=`xref
16
- 0 ${c.length+1}
15
+ `});const m=c.encode(C).length;C+=`xref
16
+ 0 ${d.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
20
- << /Size ${c.length+1} /Root 1 0 R >>
18
+ `;for(const y of h)C+=`${String(y).padStart(10,"0")} 00000 n
19
+ `;return C+=`trailer
20
+ << /Size ${d.length+1} /Root 1 0 R >>
21
21
  startxref
22
- ${C}
22
+ ${m}
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([c.encode(C)],{type:"application/pdf"})}function mt(s,e){return s.getUint32(e,!0)}function ct(s,e){return s.getUint16(e,!0)}async function ts(s){var n;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(n=new Response(s).body)==null?void 0:n.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 is(s){const e=new DataView(s),t=new Uint8Array(s);let i=-1;for(let r=t.length-22;r>=0;r--)if(mt(e,r)===101010256){i=r;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const n=ct(e,i+10);let o=mt(e,i+16);const a=[];for(let r=0;r<n&&mt(e,o)===33639248;r++){const l=ct(e,o+10),c=mt(e,o+20),d=mt(e,o+24),u=ct(e,o+28),f=ct(e,o+30),g=ct(e,o+32),p=mt(e,o+42),C=new TextDecoder().decode(t.subarray(o+46,o+46+u));a.push({name:C,compressionMethod:l,compressedSize:c,uncompressedSize:d,localHeaderOffset:p}),o+=46+u+f+g}return a}async function ai(s,e){const t=new DataView(s),i=new Uint8Array(s),n=ct(t,e.localHeaderOffset+26),o=ct(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+n+o,r=i.subarray(a,a+e.compressedSize);return e.compressionMethod===0?r:ts(r)}function li(s){return new DOMParser().parseFromString(s,"application/xml")}function ns(s){const e=s.replace(/\d+/g,"");let t=0;for(const i of e)t=t*26+(i.charCodeAt(0)-64);return t-1}async function os(s){const e=is(s),t=e.find(c=>c.name==="xl/workbook.xml"),i=[];if(t){const d=li(new TextDecoder().decode(await ai(s,t))).getElementsByTagName("sheet");for(let u=0;u<d.length;u++)i.push(d[u].getAttribute("name")||`Sheet${u+1}`),d[u].getAttribute("r:id")||d[u].getAttribute("id")}const n=[],o=e.find(c=>c.name==="xl/sharedStrings.xml");if(o){const d=li(new TextDecoder().decode(await ai(s,o))).getElementsByTagName("si");for(let u=0;u<d.length;u++){const f=d[u].getElementsByTagName("t");let g="";for(let p=0;p<f.length;p++)g+=f[p].textContent||"";n.push(g)}}const r=e.filter(c=>/^xl\/worksheets\/sheet\d+\.xml$/.test(c.name)).sort((c,d)=>c.name.localeCompare(d.name,void 0,{numeric:!0})),l=[];for(let c=0;c<r.length;c++){const u=li(new TextDecoder().decode(await ai(s,r[c]))).getElementsByTagName("row"),f=[];for(let g=0;g<u.length;g++){const p=u[g],C=[],h=p.getElementsByTagName("c");for(let m=0;m<h.length;m++){const y=h[m],E=y.getAttribute("r")||"",R=y.getAttribute("t")||"";let S="";if(R==="s"){const B=y.getElementsByTagName("v")[0],L=Number((B==null?void 0:B.textContent)||"0");S=n[L]??""}else if(R==="inlineStr"){const B=y.getElementsByTagName("t");for(let L=0;L<B.length;L++)S+=B[L].textContent||""}else{const B=y.getElementsByTagName("v")[0];S=(B==null?void 0:B.textContent)??""}const A=E?ns(E):m;C[A]=S}f.push(C.map(m=>m??""))}l.push({name:i[c]||`Sheet${c+1}`,rows:f})}return l}class ss{constructor(e){v(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(n=>typeof n=="string"?this.grid.getColumn(n):n).filter(n=>!!n);if(e.allColumns)return t.filter(n=>n.field||n.valueGetter);const i=this.grid.getColumns();return[...i.center,...i.left,...i.right]}getExportRows(e){const t=this.grid.getRowModel(),i=[],n=e.onlySelected===!0,o=e.skipGroups!==!1,a=e.skipFooters!==!1;return t.forEachNode(r=>{r.rowPinned==="top"&&e.skipPinnedTop!==!1||r.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&r.group&&!r.footer||a&&r.footer||n&&!r.selected||i.push(r)}),n&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let n=de(e,t,this.grid.getApi()),o=Ot(e,t,this.grid.getApi());if(i.processCellCallback){const a=i.processCellCallback({value:n,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(a!=null)return String(a)}return t.footer&&t.groupData&&t.groupData[e.colId]!==void 0&&(n=t.groupData[e.colId],o=n===null?"":String(n)),t.group&&t.groupData&&t.groupData[e.colId]!==void 0&&(n=t.groupData[e.colId],o=n===null?"":String(n)),n instanceof Date?n.toISOString().slice(0,10):o??(n==null?"":String(n))}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),i=this.getExportRows(e),n=e.columnSeparator??",",o=[];if(!e.skipHeader){const r=t.map(l=>{const c=l.headerName||l.field||l.colId;return e.processHeaderCallback?e.processHeaderCallback({column:l,api:this.grid.getApi()}):c});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(l=>l.headerName),n,e.suppressQuotes)),o.push(this.csvRow(r,n,e.suppressQuotes))}for(const r of i){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:r,api:this.grid.getApi()}))continue;const l=t.map(c=>this.getCellValueForExport(c,r,e));o.push(this.csvRow(l,n,e.suppressQuotes))}return o.join(`\r
25
+ `)}csvRow(e,t,i){return e.map(n=>{const o=n==null?"":String(n);return!i&&(o.includes(t)||o.includes('"')||o.includes(`
26
+ `))?`"${o.replace(/"/g,'""')}"`:o}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),i=this.getExportRows(e),n=[];e.skipHeader||n.push(t.map(o=>({value:o.headerName||o.field||o.colId,bold:!0})));for(const o of i)n.push(t.map(a=>{let r=de(a,o,this.grid.getApi());return o.footer&&o.groupData&&o.groupData[a.colId]!==void 0&&(r=o.groupData[a.colId]),o.group&&o.groupData&&o.groupData[a.colId]!==void 0&&(r=o.groupData[a.colId]),r instanceof Date&&(r=r.toISOString().slice(0,10)),{value:r}}));return Yo([{name:e.sheetName||"Sheet1",rows:n}])}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 p;const t=this.getExportColumns(e),i=this.getExportRows(e),n=t.map(C=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(C.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(C=>({text:e.processHeaderCallback?e.processHeaderCallback({column:C,api:this.grid.getApi()}):C.headerName||C.field||C.colId,bold:!0,align:C.type==="numberColumn"||C.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const C of i)(p=e.shouldRowBeSkipped)!=null&&p.call(e,{node:C,api:this.grid.getApi()})||(o.push(t.map(h=>{let m=this.getCellValueForExport(h,C,e);if(e.processCellCallback){const y=e.processCellCallback({value:de(h,C,this.grid.getApi()),formattedValue:m,node:C,column:h,api:this.grid.getApi()});y!=null&&(m=String(y))}return{text:m,align:h.type==="numberColumn"||h.cellDataType===!0?"right":"left"}})),a.push(void 0));const r=18,l=e.pageSize||"a4-landscape",[c,d]=l.includes("portrait")?[595,842]:[842,595],u=d-64-(e.title?24:0),f=Math.max(5,Math.floor(u/r)),g=[];o.length===0&&g.push({columnWidths:n,rows:[],rowFill:[]});for(let C=0;C<o.length;C+=f)g.push({columnWidths:n,rows:o.slice(C,C+f),rowFill:a.slice(C,C+f)});return es(g,{pageSize:l,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(),o=(await os(i))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],r=o.rows.slice(1).map(l=>{const c={};return a.forEach((d,u)=>{const f=d||`col${u+1}`,g=l[u]??"",p=String(g).trim();c[f]=p!==""&&!isNaN(Number(p))&&!/^0\d/.test(p)?Number(p):g}),c});return t.onSuccess?t.onSuccess(r):this.grid.getApi().setRowData(r),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:r}),r}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),n=document.createElement("a");n.href=i,n.download=t,document.body.appendChild(n),n.click(),document.body.removeChild(n),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 n,o;if(i.length>0){const u=i[0];n=u.rowStartIndex;const f=this.grid.getColumns().center,g=f.findIndex(p=>p.colId===u.colStartId);o=f[g]??f[0]}else if(t)n=t.rowIndex,o=t.column;else return;const a=e.replace(/\r/g,"").split(`
27
+ `);a.length&&a[a.length-1]===""&&a.pop();const r=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],l=r.findIndex(u=>u.colId===o.colId),c=[],d=[];this.grid.getDisplayedRowCount(),a.forEach((u,f)=>{const g=u.split(" "),p=n+f;let C=this.grid.getDisplayedRowAtIndex(p);if(!C){const h={};g.forEach((m,y)=>{const E=r[l+y];E!=null&&E.field&&(h[E.field]=m)}),d.push(h);return}g.forEach((h,m)=>{const y=r[l+m];y&&this.grid.setCellValue(y,C,h,"paste")}),c.push(C)}),d.length&&this.grid.getApi().applyTransaction({add:d}),c.length&&this.grid.refreshCells({rowNodes:c,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 as{constructor(e){v(this,"ePanel");v(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",o=>{o.preventDefault(),this.eChips.classList.add("ag-drag-over")}),this.eChips.addEventListener("dragleave",()=>this.eChips.classList.remove("ag-drag-over")),this.eChips.addEventListener("drop",o=>{var r;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(r=o.dataTransfer)==null?void 0:r.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});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",a=>{var r;(r=a.dataTransfer)==null||r.setData("text/plain",t.colId)});const n=document.createElement("span");n.textContent=t.headerName,i.appendChild(n);const o=document.createElement("button");o.className="ag-row-group-chip-remove",o.textContent="×",o.title=this.grid.t("remove"),o.addEventListener("click",()=>this.grid.getColumnModel().removeRowGroupColumn(t)),i.appendChild(o),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 ls{constructor(e,t){v(this,"undoStack",[]);v(this,"redoStack",[]);v(this,"limit",50);v(this,"batchDepth",0);v(this,"batchBuffer",[]);v(this,"batchCounter",0);v(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 n=this.grid.getColumn(e.colId);n&&(this.grid.setCellValue(n,i,t,"undoRedo"),this.grid.refreshCells({rowNodes:[i],columns:[n],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 rs{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:n}=this.popupService.createPopup(460,"ag-formula-editor");i.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,i.appendChild(o);const a=document.createElement("textarea");a.className="ag-formula-input",a.rows=3,a.value=this.isFormulaColumn(e)?e.field:"=",a.placeholder=this.grid.t("formulaPlaceholder"),i.appendChild(a);const r=document.createElement("div");r.className="ag-formula-preview";const l=()=>{const C=this.grid.getDisplayedRowAtIndex(0);if(!C){r.textContent="";return}try{const h=Mt(a.value,{data:C.data});r.textContent=`${this.grid.t("formulaPreview")}: ${h==null?"":String(h)}`,r.classList.remove("ag-formula-error")}catch(h){r.textContent=`${this.grid.t("formulaError")}: ${(h==null?void 0:h.code)||(h==null?void 0:h.message)||this.grid.t("invalidFormula")}`,r.classList.add("ag-formula-error")}};a.addEventListener("input",l),i.appendChild(r);const c=document.createElement("div");c.className="ag-formula-functions";const d=document.createElement("div");d.className="ag-formula-functions-title",d.textContent=this.grid.t("functions"),c.appendChild(d);const u=document.createElement("div");u.className="ag-formula-functions-list";for(const C of Ht){const h=document.createElement("button");h.className="ag-button ag-button-small",h.textContent=C,h.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${C}()`,a.focus(),l()}),u.appendChild(h)}c.appendChild(u),i.appendChild(c);const f=document.createElement("div");f.className="ag-popup-buttons";const g=document.createElement("button");g.className="ag-button ag-button-primary",g.textContent=this.grid.t("apply"),g.addEventListener("click",()=>{const C=a.value.trim(),h=this.grid.getColumnModel(),m=h.getColumn(e.colId);m&&(m.field=C==="="||C===""?e.field:C,m.colDef={...m.colDef,field:m.field},C!=="="&&C!==""&&(m.editable=!1)),h.refreshAll(),this.grid.refreshCells({force:!0}),n()});const p=document.createElement("button");p.className="ag-button",p.textContent=this.grid.t("clear"),p.addEventListener("click",()=>{a.value="=",l()}),f.appendChild(p),f.appendChild(g),i.appendChild(f),this.popupService.positionAt(i,t),l()}}class cs{constructor(e,t){v(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,i,n){const o=this.runtimeNotes.get(this.keyOf(e,t));if(o!==void 0)return o;if(typeof i=="function")return i(n);if(typeof i=="string")return i}setNote(e,t,i){const n=this.keyOf(e,t);i==null||i===""?this.runtimeNotes.delete(n):this.runtimeNotes.set(n,i),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,i){const n=this.grid.getColumn(t),o=this.grid.getRowNode(e),a=this.getNote(e,t,n==null?void 0:n.colDef.note,{data:o==null?void 0:o.data,node:o,column:n,api:this.grid.getApi()})??"",{ePopup:r,close:l}=this.popupService.createPopup(280,"ag-note-editor");r.innerHTML="";const c=document.createElement("div");c.className="ag-popup-title",c.textContent=`${this.grid.t("note")} — ${(n==null?void 0:n.headerName)||t}`,r.appendChild(c);const d=document.createElement("textarea");d.className="ag-formula-input",d.rows=4,d.value=a,d.placeholder=this.grid.t("writeNote"),r.appendChild(d);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("save"),f.addEventListener("click",()=>{this.setNote(e,t,d.value.trim()||void 0),l()});const g=document.createElement("button");g.className="ag-button",g.textContent=this.grid.t("delete"),g.addEventListener("click",()=>{this.setNote(e,t,void 0),l()}),u.appendChild(g),u.appendChild(f),r.appendChild(u),this.popupService.positionAt(r,i),setTimeout(()=>d.focus(),0)}}class ds{constructor(e,t){v(this,"dragState",null);v(this,"onMouseMoveBind",e=>this.onMouseMove(e));v(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 n=document.createElement("div");n.className="ag-row-drop-indicator",n.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(n),this.dragState={rowNode:e,ghost:i,startY:t.clientY,overIndex:null,indicator:n},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var n;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],i=t!=null&&t.field?(n=e.data)==null?void 0:n[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),n=i==null?void 0:i.closest(".ag-row");if(!(n!=null&&n.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let o=-1;if(this.grid.getRowModel().forEachNode((a,r)=>{a.id===n.dataset.rowid&&(o=r)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),r=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),l=e.clientY>n.getBoundingClientRect().top+r/2,c=(a[o]??0)+(l?r:0);t.indicator.style.display="block",t.indicator.style.top=`${c-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(),n=this.grid.getOptions(),o=t.overIndex,a=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:i,node:t.rowNode,overIndex:o,overNode:o!==null?this.grid.getDisplayedRowAtIndex(o):void 0,y:e.clientY}),n.rowDragManaged&&a>=0&&o!==null&&o!==a&&this.moveRow(a,o,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((i,n)=>{i.id===e.id&&(t=n)}),t}moveRow(e,t,i){const n=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=n.length)return;const[o]=n.splice(e,1),a=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),n.splice(Math.max(0,Math.min(n.length,a+1)),0,o),this.grid.getApi().setRowData(n),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:o}})}}function us(s){const e={setRowData:i=>s.setRowData(i),applyTransaction:i=>s.applyTransaction(i),getRowNode:i=>s.getRowNode(i),getDisplayedRowCount:()=>s.getDisplayedRowCount(),getDisplayedRowAtIndex:i=>s.getDisplayedRowAtIndex(i),getFirstDisplayedRow:()=>s.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>s.getDisplayedRowAtIndex(s.getDisplayedRowCount()-1),forEachNode:i=>{const n=s.getRowModel();for(let o=0;o<n.getRowCount();o++){const a=n.getRow(o);a&&i(a,o)}},forEachLeafNode:i=>{s.getRowModel().forEachLeafNode(i)},getModel:()=>s.getRowModel(),getValue:(i,n)=>{const o=typeof i=="string"?s.getColumn(i):i;if(!(!o||!n))return de(o,n,s.getApi())},getSelectedRows:()=>s.getSelectionService().getSelectedRows(),getSelectedNodes:()=>s.getSelectionService().getSelectedNodes(),selectAll:()=>s.getSelectionService().selectAll(),deselectAll:()=>s.getSelectionService().deselectAll(),selectAllFiltered:()=>s.getSelectionService().selectAllFiltered(),deselectAllFiltered:()=>s.getSelectionService().deselectAll(),selectNode:(i,n)=>s.getSelectionService().selectNode(i,n??!1),deselectNode:i=>s.getSelectionService().deselectNode(i),setQuickFilter:i=>s.setQuickFilter(i),isQuickFilterPresent:()=>s.getQuickFilter().length>0,resetQuickFilter:()=>s.setQuickFilter(""),getSortModel:()=>s.getSortService().getSortModel(),setSortModel:i=>s.getSortService().setSortModel(i),getFilterModel:()=>s.getFilterService().getFilterModel(),setFilterModel:i=>s.getFilterService().setFilterModel(i),getColumnFilterModel:i=>{const n=typeof i=="string"?i:i.colId;return s.getFilterService().getFilterInstance(n)??null},setColumnFilterModel:(i,n)=>s.getFilterService().setColumnFilterModel(i,n),getAdvancedFilterModel:()=>s.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:i=>s.getFilterService().setAdvancedFilterModel(i),onFilterChanged:()=>s.getFilterService().onFilterChanged("api"),onSortChanged:()=>s.getSortService().onSortChanged("api"),expandAll:()=>s.getRowModel().expandAll(),collapseAll:()=>s.getRowModel().collapseAll(),onGroupExpandedOrCollapsed:()=>s.refreshModel("expand"),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),setRowNodePinned:(i,n)=>s.setRowNodePinned(i,n),getColumnDefs:()=>s.getColumnModel().getColumnDefs(),setColumnDefs:(i,n)=>{s.getColumnModel().setColumnDefs(i),s.onGridSizeChanged()},updateGridOptions:i=>s.updateGridOptions(i),setGridOption:(i,n)=>s.updateGridOptions({[i]:n}),sizeColumnsToFit:()=>{const i=s.getSideBarService().isVisible()?s.getSideBarService().getElement().offsetWidth:0;s.getColumnModel().sizeColumnsToFit(s.getGridDiv().clientWidth-i),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{s.getColumnModel().autoSizeAllColumns()},moveColumn:(i,n)=>s.getColumnModel().moveColumn(i,n),moveColumnByIndex:(i,n)=>s.getColumnModel().moveColumnByIndex(i,n),setColumnVisible:(i,n)=>s.getColumnApi().setColumnVisible(i,n),setColumnsPinned:(i,n)=>s.getColumnApi().setColumnsPinned(i,n),setColumnsVisible:(i,n)=>s.getColumnApi().setColumnsVisible(i,n),getAllColumns:()=>s.getAllColumns(),getColumns:()=>[...s.getColumns().left,...s.getColumns().center,...s.getColumns().right],getColumn:i=>s.getColumn(i)??null,getDisplayedLeftColumns:()=>s.getColumns().left,getDisplayedCenterColumns:()=>s.getColumns().center,getDisplayedRightColumns:()=>s.getColumns().right,getColumnState:()=>s.getColumnApi().getColumnState(),applyColumnState:(i,n)=>s.getColumnApi().applyColumnState(i,n),resetColumnState:()=>s.getColumnApi().resetColumnState(),openColumnMenu:i=>{const n=typeof i=="string"?s.getColumn(i):i;n!=null&&n.eHeaderCell&&s.getHeaderView().getHeaderCell(n)},setSideBarVisible:i=>{s.getSideBarService().setVisible(i),s.onGridSizeChanged()},isSideBarVisible:()=>s.getSideBarService().isVisible(),setSideBarPosition:i=>{s.getSideBarService().setPosition(i),s.onGridSizeChanged()},openToolPanel:i=>{s.getSideBarService().setVisible(!0),s.getSideBarService().openPanel(i),s.onGridSizeChanged()},closeToolPanel:()=>{s.getSideBarService().setVisible(!1),s.onGridSizeChanged()},getToolPanel:()=>s.getSideBarService().getActivePanel(),setStatusBarVisible:i=>s.getSideBarService()&&s.getOptions(),getSideBar:()=>s.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.isLastPageFound())??!0},paginationGetPageSize:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getPageSize())??0},paginationGetCurrentPage:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getCurrentPage())??0},paginationGetTotalPages:()=>{var i;return((i=s.getPaginationService())==null?void 0:i.getTotalPages())??1},paginationGetRowCount:()=>s.getDisplayedRowCount(),paginationGoToPage:i=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToPage(i)},paginationGoToNextPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToNextPage()},paginationGoToPreviousPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToPreviousPage()},paginationGoToFirstPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToFirstPage()},paginationGoToLastPage:()=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToLastPage()},paginationSetPageSize:i=>{var n;return(n=s.getPaginationService())==null?void 0:n.setPageSize(i)},startEditingCell:i=>s.getEditService().startEditingCell(i),stopEditing:i=>s.getEditService().stopEditing(i),getEditingCells:()=>s.getEditService().getEditingCells(),setFocusedCell:(i,n)=>{const o=typeof n=="string"?s.getColumn(n):n;o&&s.getEditService().setFocusedCell(i,o)},getFocusedCell:()=>{const i=s.getEditService().getFocusedCell();return i?{rowIndex:i.rowIndex,column:i.column,rowNode:i.rowNode}:null},clearFocusedCell:()=>s.getEditService().clearFocusedCell(),tabToNextCell:()=>s.getEditService().tabToNextCell(),tabToPreviousCell:()=>s.getEditService().tabToPreviousCell(),refreshCells:i=>s.getRowRenderer().refreshCells(i),redrawRows:i=>s.getRowRenderer().redrawRows(i),flashCells:i=>s.getRowRenderer().flashCells(i||{}),ensureIndexVisible:(i,n)=>s.getRowRenderer().ensureIndexVisible(i,n),ensureNodeVisible:i=>{let n=-1;s.getRowModel().forEachNode((o,a)=>{o.id===i.id&&(n=a)}),n>=0&&s.getRowRenderer().ensureIndexVisible(n)},ensureColumnVisible:i=>{const n=typeof i=="string"?s.getColumn(i):i;n&&s.getRowRenderer().ensureColumnVisible(n)},copyToClipboard:i=>s.getExportService().copyToClipboard(i),cutToClipboard:i=>s.getExportService().cutToClipboard(i),pasteFromClipboard:()=>s.getExportService().pasteFromClipboard(),exportToCsv:i=>s.getExportService().exportToCsv(i||{}),exportToExcel:i=>s.getExportService().exportToExcel(i||{}),exportToPdf:i=>s.getExportService().exportToPdf(i||{}),importExcel:(i,n)=>s.getExportService().importExcel(i,n||{}),getDataAsPdf:i=>s.getExportService().getDataAsPdf(i||{}),getDataAsCsv:i=>s.getExportService().getDataAsCsv(i||{}),getDataAsExcel:i=>s.getExportService().getDataAsExcel(i||{}),getChartData:i=>s.getChartService().getChartData(i||{}),getChartModels:()=>s.getChartService().getChartModels(),createChart:()=>s.getChartService().createChart(),getCellRanges:()=>s.getRangeSelectionService().getRanges(),clearRangeSelection:()=>s.getRangeSelectionService().clearRanges(),addCellRange:i=>{const n=s.getRangeSelectionService();n.ranges=[i],n.applyHighlight(),n.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>s.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>s.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>s.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>s.getOverlayService().hideOverlay(),setServerSideDatasource:i=>{const n=s.getServerSideRowModel();n&&n.setDatasource(i)},setDatasource:i=>{var o;const n=s.getInfiniteRowModel();n?n.setDatasource(i):(o=s.getServerSideRowModel())==null||o.setDatasource(i)},setViewportDatasource:i=>{var n;(n=s.getViewportRowModel())==null||n.setViewportDatasource(i)},setViewportRange:(i,n)=>{var o;(o=s.getViewportRowModel())==null||o.setViewportRange(i,n)},refreshServerSide:i=>{const n=s.getServerSideRowModel();n&&(i!=null&&i.purge?n.purgeCache():n.onSortOrFilterChanged())},purgeServerSideCache:()=>{var i,n;(i=s.getServerSideRowModel())==null||i.purgeCache(),(n=s.getInfiniteRowModel())==null||n.onSortOrFilterChanged()},getServerSideStoreState:()=>{const i=s.getServerSideRowModel();if(!i)return[];const n=[];for(const[o,a]of i.stores)n.push({groupPath:o,rowCount:a.rows.length,lastRow:a.lastRow,loading:a.loading});return n},setRowCount:(i,n)=>{const o=s.getServerSideRowModel();if(!o)return;const a=o.getStore("");if(a)for(a.lastRow=n?i:null;a.rows.length<i;)a.rows.push(null);o.refreshModel("everything")},isServerSideStoreLoading:()=>s.isRemoteLoading(),undoCellEditing:()=>s.getUndoRedoService().undo(),redoCellEditing:()=>s.getUndoRedoService().redo(),canUndo:()=>s.getUndoRedoService().canUndo(),canRedo:()=>s.getUndoRedoService().canRedo(),getUndoRedoStackSize:()=>({undo:s.getUndoRedoService().getUndoStackSize(),redo:s.getUndoRedoService().getRedoStackSize()}),startBatchEdit:()=>s.getUndoRedoService().startBatchEdit(),endBatchEdit:i=>s.getUndoRedoService().endBatchEdit(i),cancelBatchEdit:()=>s.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>s.getUndoRedoService().isBatchEditing(),getState:()=>{const i=s.getColumnApi(),n=s.getSelectionService(),o=s.getPaginationService();return{columns:i.getColumnState(),sort:s.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(s.getFilterService().getFilterModel())),quickFilter:s.getQuickFilter(),selectedRowIds:n.getSelectedNodes().map(a=>a.id),pagination:o!=null&&o.isEnabled()?{page:o.getCurrentPage(),pageSize:o.getPageSize()}:null,rowGroupColumns:s.getColumnModel().getRowGroupColumns().map(a=>a.colId),pivotMode:s.getColumnModel().isPivotMode()}},setState:i=>{if(!i)return;const n=s.getColumnApi();if(i.columns&&n.applyColumnState(i.columns,!0),i.sort&&s.getSortService().setSortModel(i.sort),i.filter&&s.getFilterService().setFilterModel(i.filter),i.quickFilter!==void 0&&s.setQuickFilter(i.quickFilter),i.rowGroupColumns&&s.getColumnModel().setRowGroupColumns(i.rowGroupColumns),i.pivotMode!==void 0&&s.getColumnModel().setPivotMode(i.pivotMode),i.selectedRowIds){s.getSelectionService().deselectAll();for(const a of i.selectedRowIds){const r=s.getRowNode(a);r&&s.getSelectionService().selectNode(r,!1)}}const o=s.getPaginationService();o&&i.pagination&&(o.setPageSize(i.pagination.pageSize),o.goToPage(i.pagination.page))},setNote:(i,n,o)=>{const a=typeof n=="string"?n:n.colId;s.getNotesService().setNote(i.id,a,o)},getNote:(i,n)=>{const o=typeof n=="string"?n:n.colId,a=s.getColumn(o);return s.getNotesService().getNote(i.id,o,a==null?void 0:a.colDef.note,{data:i.data,node:i,column:a,api:s.getApi()})},getGridId:()=>"rowvia",destroy:()=>s.destroy(),refreshClientSideRowModel:()=>s.refreshModel("everything"),setPivotMode:i=>s.getColumnModel().setPivotMode(i),isPivotMode:()=>s.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>s.getAllColumns(),getColumn:i=>s.getColumn(i)??null,getColumnState:()=>s.getColumnModel().getColumnState(),applyColumnState:(i,n)=>{s.getColumnModel().applyColumnState(i,n),s.refreshModel("group")},resetColumnState:()=>{s.getColumnModel().resetColumnState(),s.refreshModel("group")},setColumnVisible:(i,n)=>s.getColumnModel().setColumnVisible(i,n),setColumnsVisible:(i,n)=>s.getColumnModel().setColumnsVisible(i,n),setColumnPinned:(i,n)=>s.getColumnModel().setColumnPinned(i,n),setColumnsPinned:(i,n)=>s.getColumnModel().setColumnsPinned(i,n),moveColumn:(i,n)=>s.getColumnModel().moveColumn(i,n),moveColumnByIndex:(i,n)=>s.getColumnModel().moveColumnByIndex(i,n),autoSizeColumn:i=>{s.getColumnModel().autoSizeColumn(i),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:i=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(i,n)=>s.getColumnModel().setRowGroupColumns(i,n),removeRowGroupColumns:i=>{for(const n of i)s.getColumnModel().removeRowGroupColumn(n)},addRowGroupColumn:i=>s.getColumnModel().addRowGroupColumn(i),setPivotColumns:i=>s.getColumnModel().setPivotColumns(i),removePivotColumns:i=>s.getColumnModel().setPivotColumns(i.map(()=>"").filter(n=>n!=="")),setValueColumns:i=>s.getColumnModel().setValueColumns(i),removeValueColumn:i=>s.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),getValueColumns:()=>s.getColumnModel().getValueColumns(),getPivotColumns:()=>s.getColumnModel().getPivotColumns(),setPivotMode:(i,n)=>s.getColumnModel().setPivotMode(i,n),isPivotMode:()=>s.getColumnModel().isPivotMode()}}}const hs={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 vt{constructor(e,t){v(this,"options");v(this,"eventService",new $e);v(this,"columnModel");v(this,"rowModel");v(this,"clientSideRowModel",null);v(this,"serverSideRowModel",null);v(this,"infiniteRowModel",null);v(this,"viewportRowModel",null);v(this,"rowRenderer");v(this,"headerView");v(this,"selectionService");v(this,"editService");v(this,"filterService");v(this,"sortService");v(this,"paginationService",null);v(this,"popupService");v(this,"filterGui");v(this,"contextMenuService");v(this,"columnMenuService");v(this,"statusBarService");v(this,"sideBarService");v(this,"findService");v(this,"rangeSelectionService");v(this,"chartService");v(this,"overlayService");v(this,"exportService");v(this,"rowGroupPanel",null);v(this,"undoRedoService");v(this,"formulaEditorService");v(this,"notesService");v(this,"rowDragService");v(this,"api");v(this,"columnApi");v(this,"localeText");v(this,"rowNodeServices");v(this,"eGridDiv");v(this,"eRoot");v(this,"eMain");v(this,"eHeader");v(this,"quickFilter","");v(this,"resizeObserver",null);v(this,"destroyed",!1);v(this,"gridReadyDispatched",!1);v(this,"context");v(this,"onWindowResize",()=>{this.onGridSizeChanged()});v(this,"onDocumentMouseDown",e=>{var i;const t=e.target;if(t&&this.eRoot.contains(t)){const n=(i=t.closest)==null?void 0:i.call(t,".ag-cell");if(!n){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!n.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var c,d,u,f;this.eGridDiv=e,this.options={...hs,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Zn(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:(g,p)=>this.selectionService.selectNode(g,p),deselectNode:g=>this.selectionService.deselectNode(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g)},this.columnModel=new Pi(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new Io(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),g=>this.isNodeSelectable(g)),this.filterService=new Do(this),this.sortService=new Ao(this),this.popupService=new Fo(this),this.filterGui=new Po(this,this.popupService),this.contextMenuService=new $o(this,this.popupService),this.columnMenuService=new Go(this,this.popupService),this.editService=new Lo(this,this.eventService),this.undoRedoService=new ls(this,this.eventService),this.formulaEditorService=new rs(this,this.popupService),this.notesService=new cs(this,this.popupService),this.rowDragService=new ds(this,this.eventService),this.chartService=new zo(this,this.popupService),this.findService=new Bo(this,this.popupService),this.exportService=new ss(this);const n={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},o=this.options.rowModelType||"clientSide";o==="serverSide"?(this.serverSideRowModel=new to(n),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new io(n),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new no(n),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new jn({options:this.options,eventService:this.eventService,columns:()=>this.getAllColumns(),getFilterModel:()=>this.filterService.getFilterModel(),getQuickFilter:()=>this.quickFilter,isPaginationEnabled:()=>{var g;return!!((g=this.paginationService)!=null&&g.isEnabled())},getPageSize:()=>{var g;return((g=this.paginationService)==null?void 0:g.getPageSize())??100},getCurrentPage:()=>{var g;return((g=this.paginationService)==null?void 0:g.getCurrentPage())??0},rowHeight:()=>this.options.rowHeight??42,rowNodeServices:this.rowNodeServices}),this.rowModel=this.clientSideRowModel,(d=(c=this.rowModel).setGridApi)==null||d.call(c,null)),this.headerView=new No(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(g=>g.sort)}),onSortRequested:(g,p,C)=>this.sortService.onSortRequested(g,p,C),onColumnResized:(g,p,C)=>this.onColumnResized(g,p,C),onColumnMoved:(g,p)=>this.onColumnMoved(g,p),onColumnMenuClicked:(g,p)=>this.columnMenuService.openColumnMenu(g,p),onFilterOpened:(g,p)=>this.filterGui.openFilter(g,p),isFilterActive:g=>this.filterService.isFilterActive(g),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(g,p)=>this.filterService.handleFloatingFilterChange(g,p),onHeaderCheckboxChanged:(g,p)=>this.onHeaderCheckboxChanged(g,p),onColumnPinnedRequested:()=>{},isColumnMenuSuppressed:()=>!1,headerHeight:this.options.headerHeight??48,t:g=>this.t(g),getApi:()=>this.api,getFilterModel:g=>this.filterService.getFilterInstance(g)??null,onFilterModelChange:(g,p)=>this.filterService.setColumnFilterModel(g,p)}),this.rowRenderer=new To(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:g=>this.t(g),getColumns:()=>this.getColumns(),getRowHeight:g=>this.getRowHeight(g),isNodeSelected:g=>this.selectionService.isNodeSelected(g),isRowSelectable:g=>this.isNodeSelectable(g),getRowClass:g=>this.getRowClass(g),getRowStyle:g=>this.getRowStyle(g),onCellClicked:g=>this.onCellClicked(g),onCellDoubleClicked:g=>this.editService.onCellDoubleClicked(g),onCellMouseDown:g=>this.onCellMouseDown(g),onCellContextMenu:g=>this.onCellContextMenu(g),onRowClicked:g=>this.onRowClicked(g),onRowDoubleClicked:g=>this.onRowDoubleClicked(g),onRowGroupClicked:g=>this.onRowGroupClicked(g),onViewportKeyDown:g=>this.onViewportKeyDown(g),onViewportScroll:()=>{var C,h,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const g=this.rowRenderer.getFirstVisibleRowIndex(),p=this.rowRenderer.getLastVisibleRowIndex();(C=this.serverSideRowModel)==null||C.onViewportChanged(g,p),(h=this.infiniteRowModel)==null||h.onViewportChanged(g,p),(m=this.viewportRowModel)==null||m.onViewportChanged(g,p)},getCellText:(g,p)=>{const C=de(g,p,this.api);return C==null?"":String(C)},renderDetailRow:g=>this.renderDetailRow(g),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(g,p,C)=>this.rowDragService.startDrag(g,C),getNote:(g,p,C,h)=>this.notesService.getNote(g,p,C,h),onNoteClick:(g,p,C)=>this.notesService.openNoteEditor(g,p,C),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new Vo(this,this.eventService),this.statusBarService=new Ho(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Wo(this),this.sideBarService=new Oo(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 Wi(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new as(this));const{api:a,columnApi:r}=us(this);this.api=a,this.columnApi=r,this.columnModel.setGridApi(this.api),(f=(u=this.rowModel).setGridApi)==null||f.call(u,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=g=>this.filterService.doesNodePassAdvancedFilter(g),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 g,p;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(p=(g=this.options).onSelectionChanged)==null||p.call(g,{api:this.api}),this.updateHeaderCheckboxes()}),this.eventService.addEventListener("paginationChanged",()=>{this.statusBarService.update()});let l=this.options.columnDefs||[];(!l||l.length===0)&&this.options.autoGenerateColumns!==!1&&(this.options.rowData||[]).length>0&&(l=Pi.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(l),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,n;const e=new Map,t=this.getAllColumns().filter(o=>o.colDef.showValueAs);if(t.length>0){const o=new Map;(n=(i=this.rowModel).forEachLeafNode)==null||n.call(i,a=>{for(const r of t){const l=de(r,a,this.api);typeof l=="number"&&!isNaN(l)&&o.set(r.colId,(o.get(r.colId)??0)+l)}});for(const a of t)e.set(a.colId,o.get(a.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,n,o;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(),(o=(n=this.options).onRowDataChanged)==null||o.call(n,{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,n="api",o){const a=o!==void 0?o:de(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:de(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"),(n==="edit"||n==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:a,newValue:i,batchId:0}),n!=="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:n})}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 a,r,l,c;const{node:t,column:i,event:n}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(r=(a=this.options).onCellClicked)==null||r.call(a,{...e,api:this.api,colDef:i.colDef,value:de(i,t,this.api)});return}if(n.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,n),this.editService.onCellClicked(e),(c=(l=this.options).onCellClicked)==null||c.call(l,{...e,api:this.api,colDef:i.colDef,value:de(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,n;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(n=(i=this.options).onCellContextMenu)==null||n.call(i,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,i,n,o,a;if(e.group){const r=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);r&&r(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}),(n=(i=this.options).onRowGroupOpened)==null||n.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}),(a=(o=this.options).onRowGroupOpened)==null||a.call(o,{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 n=this.rowModel.getRowCount();if(t)for(let o=0;o<n;o++){const a=this.rowModel.getRow(o);a&&this.isNodeSelectable(a)&&this.selectionService.selectNode(a,!1)}else for(let o=0;o<n;o++){const a=this.rowModel.getRow(o);a&&this.selectionService.deselectNode(a)}}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 n=this.selectionService.getSelectAllState();i.checked=n.checked,i.indeterminate=n.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(),n=i.findIndex(a=>a.colId===e);if(n<0)return;let o=i.length;t&&(o=i.findIndex(a=>a.colId===t)),this.columnModel.moveColumnByIndex(n,o,"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,n,o,a,r;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})),(o=(n=this.options).onModelUpdated)==null||o.call(n,{api:this.api}),(r=(a=this.options).onRowDataChanged)==null||r.call(a,{api:this.api})}onGridSizeChanged(){var o,a,r;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(l=>l.flex!==null&&l.flex>0&&l.visible),i=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,n=Math.max(0,e-i);(t||((o=this.options.autoSizeStrategy)==null?void 0:o.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(n),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}),(r=(a=this.options).onGridSizeChanged)==null||r.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var c,d;const t=e.masterNode;if(!t)return null;const i=this.options.detailRowAutoHeight===!0,n=i?this.options.detailRowHeight??200:this.options.detailRowHeight??200,o=document.createElement("div");o.className="ag-row-detail",o.style.height=`${n}px`,o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0";const a=this.options.detailCellRenderer,r=(c=this.options.detailCellRendererParams)==null?void 0:c.detailGridOptions,l=(d=this.options.detailCellRendererParams)==null?void 0:d.getDetailRowData;if(r&&l){const u=l({data:t.data,node:t,api:this.api}),f=document.createElement("div");f.style.height="100%",f.style.padding="8px 16px",o.appendChild(f),setTimeout(()=>{new vt(f,{...r,rowData:u,theme:this.options.theme})},0)}else if(typeof a=="function"){const u=a({data:t.data,node:t,api:this.api,context:this.context});u instanceof HTMLElement?o.appendChild(u):o.textContent=String(u??"")}else typeof a=="string"&&(o.textContent=a);if(i){const u=Math.max(40,o.scrollHeight||n);return e.rowHeight=u,o.style.height=`${u}px`,{eDetail:o,height:u}}return e.rowHeight=n,{eDetail:o,height:n}}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,n=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),i&&this.setRowData(e.rowData),n&&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 Wi(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 Xi(s){const e=document.createElement("dialog");e.className="rowvia-detail-dialog";const t=document.createElement("h2"),i=document.createElement("dl"),n=document.createElement("button");n.type="button",n.textContent="关闭";const o=()=>e.close();return n.addEventListener("click",o),e.append(t,i,n),s.append(e),{open(a){t.textContent=a.title,e.setAttribute("aria-label",a.title),i.replaceChildren();for(const r of a.fields){const l=document.createElement("dt"),c=document.createElement("dd");l.textContent=r.label,c.textContent=r.value,i.append(l,c)}e.open||e.showModal()},close:o,destroy(){e.open&&e.close(),n.removeEventListener("click",o),e.remove()}}}const Yi=864e5;function Qe(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),i=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${i}`}function Pe(s){return new Date(`${s}T00:00:00`)}function De(s,e){return new Date(s.getTime()+e*Yi)}function je(s,e){const t=typeof s=="string"?Pe(s):s,i=typeof e=="string"?Pe(e):e;return Math.round((i.getTime()-t.getTime())/Yi)}function It(){return Qe(new Date)}function ps(s){return s.status!=="done"&&s.end&&s.end<It()&&s.progress<100?"delayed":s.status}function ri(s){const e=Pe(s);return`${e.getMonth()+1}月${e.getDate()}日`}const Qi=["day","week","biweek","month","bimonth","quarter","halfyear","year"],Ut={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},gs={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2},Ee={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)"},_t={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},fs=4,Ji=6,He=28;function ci(s){const e=(s.getDay()+6)%7;return De(s,-e)}function ms(s,e){const t=Math.max(1,je(s,e)+1);let i=0;for(let n=0;n<t;n++){const o=De(s,n).getDay();o!==0&&o!==6&&i++}return Math.max(1,i)}function vs(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function Zi(s,e,t){const i=[];if(s==="day"){let l=new Date(e);for(;l<t;){const c=De(l,1);i.push({start:new Date(l),end:c,primary:`${l.getDate()}`,secondary:""}),l=c}return i}if(s==="week"||s==="biweek"){let l=ci(e);for(;l<t;){const c=De(l,s==="biweek"?14:7);i.push({start:new Date(l),end:c,primary:`${l.getMonth()+1}/${l.getDate()}`,secondary:""}),l=c}return i}const n=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=l=>new Date(l.getFullYear(),Math.floor(l.getMonth()/n)*n,1),a=l=>s==="month"||s==="bimonth"?`${l.getMonth()+1}月`:s==="halfyear"?`${l.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(l.getMonth()/3)+1}`:`${l.getFullYear()}`;let r=o(e);for(;r<t;){const l=vs(r,n);i.push({start:new Date(r),end:l,primary:a(r),secondary:""}),r=l}return i}class en{constructor(e,t){v(this,"options");v(this,"eRoot");v(this,"eHeader");v(this,"eRuler");v(this,"rulerCtx");v(this,"eRulerTools");v(this,"eStepLabel");v(this,"eZoomValue");v(this,"eStepMenu",null);v(this,"eScroll");v(this,"eSpacer");v(this,"eCanvas");v(this,"ctx");v(this,"eTooltip");v(this,"eTodayBadge");v(this,"ePopup",null);v(this,"tasks",[]);v(this,"tasksById",new Map);v(this,"rows",[]);v(this,"selectedId",null);v(this,"hoverId",null);v(this,"unit","day");v(this,"zoom",1);v(this,"theme","content");v(this,"epochStart",new Date);v(this,"totalDays",1);v(this,"hits",[]);v(this,"hitsByRow",new Map);v(this,"drag",null);v(this,"ghost",null);v(this,"dirty",!0);v(this,"lastLeft",-1);v(this,"lastTop",-1);v(this,"timer");v(this,"observer",null);v(this,"resizeHandler",()=>this.resizeCanvases());v(this,"showChildren",!0);v(this,"milestonesOnly",!1);v(this,"locateHits",[]);v(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)});v(this,"onScroll",()=>{this.tick()});v(this,"todayLabelX",-1);v(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:i,onAvatar:n}=this.hitAt(e.clientX,e.clientY),o=this.rows[i];n?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 a=t?t.id:(o==null?void 0:o.id)??null;a!==this.hoverId&&(this.hoverId=a,this.options.onHover(a),this.markDirty())});v(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),i=this.locateHits.find(c=>Math.abs(c.x-(e.clientX-t.left))<12&&Math.abs(c.y-(e.clientY-t.top))<12);if(i){this.scrollToTask(i.id);return}const{hit:n,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),r=this.rows[o];if(n){const c=this.tasksById.get(n.id);if(!c)return;if(a){e.stopPropagation(),this.openAssigneePopup(n.id,n);return}if(c.kind!=="task"||c.milestone||!c.start||!c.end){this.options.onSelect(n.id);return}e.preventDefault(),this.drag={id:n.id,mode:n.mode,startX:e.clientX,startY:e.clientY,originStart:c.start,originEnd:c.end,start:c.start,end:c.end,moved:!1},window.addEventListener("mousemove",this.updateDrag),window.addEventListener("mouseup",this.endDrag),this.options.onSelect(n.id);return}if(!r)return;const l=this.tasksById.get(r.id);if(l){if(l.kind==="task"&&(!l.start||!l.end)){const c=this.pointAt(e.clientX,e.clientY),d=Math.floor(c.x/this.dayWidth),u=Qe(De(this.epochStart,d));this.options.onTaskChange({...l,start:u,end:Qe(De(Pe(u),4)),progress:0,status:"not-started"}),this.options.onSelect(r.id);return}this.options.onSelect(r.id)}});v(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)<fs)return;t.moved=!0;const n=this.dayWidth,o=Math.round((e.clientX-t.startX)/n),a=Pe(t.originStart),r=Pe(t.originEnd),l=je(a,r);let c,d;t.mode==="resize-l"?(c=De(a,Math.min(o,l)),d=r):t.mode==="resize-r"?(c=a,d=De(r,Math.max(o,-l))):(c=De(a,o),d=De(r,o)),i.milestone&&(c=d),t.start=Qe(c),t.end=Qe(d),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?ri(t.start):`${ri(t.start)} → ${ri(t.end)}`;const u=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-u.left+12}px`,this.eTooltip.style.top=`${e.clientY-u.top+16}px`});v(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})});v(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});v(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 gs[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(It()),i=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=i}computeDomain(){let e=null,t=null;for(const o of this.tasks)!o.start||!o.end||((!e||o.start<e)&&(e=o.start),(!t||o.end>t)&&(t=o.end));const i=It();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const n=ci(De(Pe(e),-7));this.epochStart=n,this.totalDays=Math.max(je(n,Pe(t))+730,1095)}dateX(e){return je(this.epochStart,e)*this.dayWidth}xToDate(e){return Qe(De(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 n=t===this.eRuler?this.eHeader.clientWidth:this.eScroll.clientWidth,o=t===this.eRuler?this.eHeader.clientHeight:this.eScroll.clientHeight;t.width=Math.max(1,Math.round(n*e)),t.height=Math.max(1,Math.round(o*e)),t.style.width=`${n}px`,t.style.height=`${o}px`,i.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,i=this.totalDays*e,n=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${i}px`,this.eSpacer.style.height=`${n}px`,this.drawRuler(e,i),this.drawBody(e,i,n,t)}drawRuler(e,t){const i=this.rulerCtx,n=this.eHeader.clientWidth,o=this.eHeader.clientHeight,a=this.eScroll.scrollLeft;i.clearRect(0,0,n,o),i.fillStyle="#fff",i.fillRect(0,0,n,o);const r=De(this.epochStart,this.totalDays),l=(u,f,g,p)=>{for(const C of u){const h=this.dateX(Qe(C.start))-a,m=je(C.start,C.end)*e;if(h+m<=0||h>=n)continue;const y=Math.max(0,Math.min(h+m,n)-Math.max(0,h));if(this.unit==="day"||this.unit==="week"){const S=C.start.getDay();(S===0||S===6)&&(i.fillStyle=Ee.weekend,i.fillRect(Math.max(0,h),f,y,g))}const E=i.measureText(C.primary).width;if(E+8<y){const S=Math.max(0,h)+y/2-E/2,A=f+g/2+5;i.fillStyle=Ee.text,i.font="11px "+Je,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(C.primary,S,A),C.secondary&&(i.fillStyle=Ee.textTertiary,i.font="10px "+Je,i.fillText(C.secondary,S,A+12))}}},c=40,d=De(this.epochStart,Math.floor(a/e));i.fillStyle=Ee.text,i.font="14px "+Je,i.textAlign="left",i.textBaseline="middle",i.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${d.getFullYear()}年${d.getMonth()+1}月`:`${d.getFullYear()} 年`,16,22),l(Zi(this.unit,this.epochStart,r),c+1,o-c-1),i.strokeStyle=Ee.border,i.beginPath(),i.moveTo(0,o-.5),i.lineTo(n,o-.5),i.stroke()}drawBody(e,t,i,n){const o=this.ctx,a=this.eScroll.clientWidth,r=this.eScroll.clientHeight,l=this.eScroll.scrollLeft,c=this.eScroll.scrollTop;o.clearRect(0,0,a,r),o.fillStyle="#fff",o.fillRect(0,0,a,r),o.save(),o.translate(-l,-c),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,c+r)),this.drawGridlines(e,t,Math.max(i,c+r)),this.drawRowBackgrounds(t,n);const d=this.rows.findIndex(f=>f.id===this.hoverId),u=this.hoverId?this.tasksById.get(this.hoverId):null;if(d>=0&&(u==null?void 0:u.kind)==="task"&&!u.start){const f=d*n+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,Ct(o,l+4,f,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Ee.textTertiary,o.font="14px "+Je,o.textAlign="center",o.fillText("新建排期",l+a/2,f+19)}this.drawDependencies(n),this.drawBars(n),this.drawTodayLine(t,Math.max(i,c+r)),o.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,i){if(this.unit!=="day"&&this.unit!=="week")return;const n=this.ctx;n.fillStyle=Ee.weekend;let o=ci(this.epochStart);for(;je(this.epochStart,o)<this.totalDays;){const a=this.dateX(Qe(o))+5*e;a<t&&n.fillRect(Math.max(0,a),0,e*2,i),o=De(o,7)}}drawGridlines(e,t,i){const n=this.ctx,o=De(this.epochStart,this.totalDays);for(const a of Zi(this.unit,this.epochStart,o)){const r=Math.round(this.dateX(Qe(a.start)))+.5;if(r<0||r>t)continue;const l=this.unit==="day"&&a.start.getDate()===1;n.strokeStyle=l?Ee.gridlineMonth:Ee.gridline,n.beginPath(),n.moveTo(r,0),n.lineTo(r,i),n.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=Ee.rowLine,i.lineWidth=1,i.beginPath();for(let n=1;n<this.rows.length;n++){const o=Math.round(n*t)+.5;i.moveTo(0,o),i.lineTo(e,o)}i.stroke(),this.rows.forEach((n,o)=>{const a=this.selectedId===n.id,r=this.hoverId===n.id;(a||r)&&(i.fillStyle=a?Ee.selected:r?Ee.hover:Ee.groupRow,i.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,n=Math.round(this.dateX(It())+this.dayWidth/2)+.5;n<0||n>e||(i.strokeStyle=Ee.accent,i.lineWidth=1.5,i.beginPath(),i.moveTo(n,0),i.lineTo(n,t),i.stroke(),this.todayLabelX=n-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=It().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((n,o)=>[n.id,o])),i=this.ctx;i.strokeStyle=Ee.accent,i.lineWidth=1.2;for(const n of this.rows){const o=this.tasksById.get(n.id);if(!o||o.kind!=="task"||!o.start||!o.end)continue;const a=t.get(n.id);if(a!==void 0)for(const r of o.dependsOn){const l=this.tasksById.get(r),c=t.get(r);if(!(l!=null&&l.start)||!l.end||c===void 0)continue;const d=this.dateX(l.start),u=l.milestone?this.dayWidth:Math.max(je(Pe(l.start),Pe(l.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),f=d+u,g=c*e+e/2,p=this.dateX(o.start),C=Math.max(je(Pe(o.start),Pe(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),h=a*e+e/2,m=f+10;if(p-4>m)tn(i,f,g,m,h,p-5,h);else{const y=p+C+10;tn(i,f,g,m,h,y,h)}ws(i,p-5,h)}}}drawBars(e){this.rows.forEach((t,i)=>{const n=this.tasksById.get(t.id);if(!n||!n.start||n.path.length>1&&(!this.showChildren||this.milestonesOnly&&!n.milestone))return;const o=i*e+(e-He)/2;if(t.group){this.drawSummaryBar(n,i,o);return}if(n.milestone){this.drawMilestone(n,i,o);return}n.end&&this.drawTaskBar(n,i,o)})}drawTaskBar(e,t,i){var g;const n=this.ctx,o=((g=this.ghost)==null?void 0:g.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,r=(o==null?void 0:o.end)??e.end,l=this.dateX(a),c=Math.max(28,(je(a,r)+1)*this.dayWidth),d=_t[e.status];n.save(),n.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,n.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",n.strokeStyle=this.selectedId===e.id?Ee.accent:"#dee0e3",n.lineWidth=1,Ct(n,l,i,c,He,4),n.fill(),n.stroke(),n.save(),Ct(n,l,i,c,He,4),n.clip(),n.beginPath(),n.arc(l+14,i+14,6,0,Math.PI*2),n.fillStyle=d,n.fill(),n.font="12px "+Je,n.textBaseline="middle",n.textAlign="left",n.fillStyle=Ee.text;const u=this.options.members.find(p=>p.id===e.owner),f=n.measureText(e.name).width;c>f+58?(n.fillText(e.name,l+26,i+14),u&&di(n,l+f+42,i+14,7,qt(u.id),u.name.slice(0,1))):u&&c>46&&di(n,l+38,i+14,7,qt(u.id),u.name.slice(0,1)),c>100&&(n.fillStyle=Ee.textTertiary,n.textAlign="right",n.fillText(String(ms(Pe(a),Pe(r))),l+c-8,i+14)),n.restore(),n.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:l,y:i,w:c,h:He,mode:"move",avatar:u?{x:l+(c>f+58?f+42:38),y:i+14,r:7}:void 0})}drawSummaryBar(e,t,i){if(!e.start||!e.end)return;const n=this.tasks.filter(d=>d.path.length===e.path.length+1&&d.path.slice(0,-1).join("/")===e.path.join("/")&&d.start),o=n[0],a=this.ctx,r=this.dateX(e.start),l=Math.max(92,(je(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?Ee.accent:"#dee0e3",a.lineWidth=1,Ct(a,r,i,l,He,4),a.fill(),a.stroke(),a.fillStyle=o?_t[o.status]:_t[e.status],a.beginPath(),a.arc(r+14,i+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Ee.text,a.font="11px "+Je,a.textAlign="left",a.textBaseline="middle";const c=((o==null?void 0:o.name)??e.name)+(n.length>1?` +${n.length-1}`:"");a.fillText(Cs(a,c,l-32),r+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:r,y:i,w:l,h:He,mode:"move"})}firstVisibleChildIndex(e,t){var n;const i=`${e.path.join("/")}/`;for(let o=t+1;o<this.rows.length;o++){const a=this.tasksById.get(((n=this.rows[o])==null?void 0:n.id)??"");if(a)return a.path.join("/").startsWith(i)?o:-1}return-1}drawMilestone(e,t,i){var h;const n=this.ctx,o=this.dayWidth,a=((h=this.ghost)==null?void 0:h.id)===e.id?this.ghost:null,r=a?a.start:e.start,l=ps(e),c=_t[l],d=this.dateX(r)+o/2;n.font="12px "+Je;const u=n.measureText(e.name).width,f=e.owner?24:0,g=19+u+f+14,p=d-g/2;n.fillStyle="#fff",n.strokeStyle=c,n.lineWidth=1.5,Ct(n,p,i,g,He,4),n.fill(),n.stroke(),n.fillStyle=c,n.beginPath(),n.arc(p+7+3,i+He/2,3,0,Math.PI*2),n.fill(),n.fillStyle=Ee.text,n.textAlign="left",n.textBaseline="middle",n.fillText(e.name,p+14+5,i+He/2+1);let C;if(e.owner){const m=this.options.members.find(y=>y.id===e.owner);m&&(di(n,p+g-12,i+He/2,9,qt(m.id),m.name.slice(0,1)),C={x:p+g-12,y:i+He/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:p,y:i,w:g,h:He,mode:"move",avatar:C})}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((n,o)=>{const a=this.tasksById.get(n.id);if(!(a!=null&&a.start)||!a.end||a.path.length>1&&(!this.showChildren||this.milestonesOnly&&!a.milestone))return;const r=this.dateX(a.start),l=this.dateX(a.end)+this.dayWidth;if(l>=t&&r<=t+i)return;const c=l<t?10:i-18,d=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;d<0||d>this.eScroll.clientHeight||(e.fillStyle="#8f959e",Ct(e,c-5,d-6,13,13,3),e.fill(),e.font="12px "+Je,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(l<t?"‹":"›",c+1,d),this.locateHits.push({id:a.id,x:c+1,y:d}))})}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),n=Math.floor(i.y/this.options.rowHeight),o=this.hitsByRow.get(n)??[];for(const a of o){if(a.avatar){const r=i.x-a.avatar.x,l=i.y-a.avatar.y;if(r*r+l*l<=a.avatar.r*a.avatar.r)return{hit:a,rowIndex:n,onAvatar:!0}}if(i.x>=a.x&&i.x<=a.x+a.w&&i.y>=a.y&&i.y<=a.y+a.h){const r=a.kind==="task"&&i.x<=a.x+Ji,l=a.kind==="task"&&i.x>=a.x+a.w-Ji;return{hit:{...a,mode:r?"resize-l":l?"resize-r":"move"},rowIndex:n,onAvatar:!1}}}return{hit:null,rowIndex:n,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=Ut[this.unit];const t=document.createElement("span");t.className="gt-ruler-caret",t.textContent="▾",e.append(this.eStepLabel,t),e.addEventListener("click",o=>{o.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 n=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(i,n),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,i){const n=document.createElement("button");return n.type="button",n.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(n.className="gt-ruler-btn gt-ruler-today"),n.textContent=e,n.title=t,n.addEventListener("click",o=>{o.stopPropagation(),i()}),n}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 n of Qi){const o=document.createElement("div");o.className="gt-step-item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(n===this.unit)),o.tabIndex=0,o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.setUnit(n),this.closeStepMenu())}),n===this.unit&&o.classList.add("gt-step-item-active"),o.textContent=Ut[n],o.addEventListener("click",a=>{a.stopPropagation(),this.setUnit(n),this.closeStepMenu()}),e.appendChild(o)}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=Ut[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 n=document.createElement("div");n.className="gt-popup";const o=document.createElement("div");o.className="gt-popup-title",o.textContent="更换负责人",n.appendChild(o);for(const c of this.options.members){const d=document.createElement("div");d.className="gt-popup-item",i.owner===c.id&&d.classList.add("gt-popup-item-active");const u=document.createElement("span");u.className="gt-avatar",u.textContent=c.name.slice(0,1),u.style.backgroundColor=qt(c.id);const f=document.createElement("span");f.textContent=c.name,d.append(u,f),d.addEventListener("click",g=>{g.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,c.id)}),n.appendChild(d)}if(i.owner){const c=document.createElement("div");c.className="gt-popup-item gt-popup-clear",c.textContent="取消负责人",c.addEventListener("click",d=>{d.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),n.appendChild(c)}const a=this.eRoot.getBoundingClientRect(),r=t.x+t.w-this.eScroll.scrollLeft,l=t.y-this.eScroll.scrollTop;n.style.left=`${Math.min(a.width-150,Math.max(0,r-40))}px`,n.style.top=`${l+t.h+6}px`,this.eRoot.appendChild(n),this.ePopup=n,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const Je="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function Ct(s,e,t,i,n,o){const a=Math.max(0,i),r=Math.max(0,n);if(a===0||r===0)return;const l=Math.max(0,Math.min(o,a/2,r/2));s.beginPath(),s.moveTo(e+l,t),s.lineTo(e+a-l,t),s.arcTo(e+a,t,e+a,t+l,l),s.lineTo(e+a,t+r-l),s.arcTo(e+a,t+r,e+a-l,t+r,l),s.lineTo(e+l,t+r),s.arcTo(e,t+r,e,t+r-l,l),s.lineTo(e,t+l),s.arcTo(e,t,e+l,t,l),s.closePath()}function di(s,e,t,i,n,o){s.beginPath(),s.arc(e,t,i,0,Math.PI*2),s.fillStyle=n,s.fill(),s.lineWidth=1.5,s.strokeStyle="#fff",s.stroke(),s.fillStyle="#fff",s.font=`10px ${Je}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function Cs(s,e,t){if(t<=0)return"";if(s.measureText(e).width<=t)return e;let i=e.length;for(;i>1;){i--;const n=`${e.slice(0,i)}…`;if(s.measureText(n).width<=t)return n}return"…"}function tn(s,e,t,i,n,o,a){const l=n>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(i-5,t),s.quadraticCurveTo(i,t,i,t+5*l),s.lineTo(i,n-5*l),s.quadraticCurveTo(i,n,i+5*l,n),s.lineTo(o,a),s.stroke()}function ws(s,e,t){s.fillStyle=Ee.accent,s.beginPath(),s.moveTo(e+5,t),s.lineTo(e-1,t-3.5),s.lineTo(e-1,t+3.5),s.closePath(),s.fill()}const nn=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function qt(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return nn[e%nn.length]}const ys=[{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:"介于"}],Ss=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Ae(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function wt(s,e,t){const i=document.createElement("button");return i.type="button",i.className=e,i.textContent=s,i.addEventListener("click",n=>{n.stopPropagation(),t()}),i}class xs{constructor(e,t,i,n){v(this,"filterFields");v(this,"sortFields");v(this,"filterRows",[]);v(this,"sorts",[]);v(this,"filterPanel",null);v(this,"sortPanel",null);v(this,"filterAnchor",null);v(this,"sortAnchor",null);v(this,"onDocumentMouseDown",e=>{var i,n;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)&&!((n=this.sortAnchor)!=null&&n.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=n,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=Ae("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",c=>c.stopPropagation());const i=Ae("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const n=Ae("div","gt-filter-rows");t.appendChild(n);const o=()=>{if(n.textContent="",!this.filterRows.length){const c=Ae("div","gt-panel-empty");c.textContent="点击下方字段添加筛选条件",n.appendChild(c)}for(const c of this.filterRows)n.appendChild(this.renderFilterRow(c,o))},a=Ae("div","gt-filter-add");for(const c of this.filterFields)a.appendChild(wt(c.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:c.colId,kind:c.kind,type:c.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const r=Ae("div","gt-panel-hint");r.textContent="多个条件同时满足(且)",t.appendChild(r);const l=Ae("div","gt-panel-actions");l.append(wt("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),wt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(l),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const i=Ae("div","gt-filter-row"),n=this.filterFields.find(c=>c.colId===e.colId),o=document.createElement("select");o.className="gt-panel-select";for(const c of this.filterFields){const d=document.createElement("option");d.value=c.colId,d.textContent=c.label,c.colId===e.colId&&(d.selected=!0),o.appendChild(d)}o.addEventListener("change",()=>{const c=this.filterFields.find(d=>d.colId===o.value);c&&(e.colId=c.colId,e.kind=c.kind,e.type=c.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),i.appendChild(o);const a=e.kind==="number"?bs:e.kind==="date"?Ss:ys,r=document.createElement("select");r.className="gt-panel-select gt-panel-select-cond";for(const c of a){const d=document.createElement("option");d.value=c.value,d.textContent=c.label,c.value===e.type&&(d.selected=!0),r.appendChild(d)}if(r.addEventListener("change",()=>{e.type=r.value,t()}),i.appendChild(r),e.type!=="blank")if(n!=null&&n.options){const c=document.createElement("select");c.className="gt-panel-select";const d=document.createElement("option");d.value="",d.textContent="请选择",c.appendChild(d);for(const u of n.options){const f=document.createElement("option");f.value=u.value,f.textContent=u.label,u.value===e.value&&(f.selected=!0),c.appendChild(f)}c.addEventListener("change",()=>{e.value=c.value}),i.appendChild(c)}else if(e.kind==="date"){const c=document.createElement("input");if(c.type="date",c.className="gt-panel-input",c.value=e.value,c.addEventListener("change",()=>{e.value=c.value}),i.appendChild(c),e.type==="inRange"){const d=document.createElement("input");d.type="date",d.className="gt-panel-input",d.value=e.valueTo,d.addEventListener("change",()=>{e.valueTo=d.value}),i.appendChild(d)}}else if(e.kind==="number"){const c=document.createElement("input");if(c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="数值",c.value=e.value,c.addEventListener("input",()=>{e.value=c.value}),i.appendChild(c),e.type==="inRange"){const d=document.createElement("input");d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="至",d.value=e.valueTo,d.addEventListener("input",()=>{e.valueTo=d.value}),i.appendChild(d)}}else{const c=document.createElement("input");c.type="text",c.className="gt-panel-input",c.placeholder="文本",c.value=e.value,c.addEventListener("input",()=>{e.value=c.value}),i.appendChild(c)}const l=wt("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(c=>c!==e),t()});return l.title="移除条件",i.appendChild(l),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),n=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:n||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=Ae("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",r=>r.stopPropagation());const i=Ae("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const n=Ae("div","gt-sort-list");t.appendChild(n);const o=()=>{var r;n.textContent="";for(const l of this.sortFields){const c=this.sorts.findIndex(g=>g.colId===l.colId),d=c>=0,u=Ae("div","gt-sort-item");d&&u.classList.add("gt-sort-item-active");const f=Ae("span","gt-sort-label");if(f.textContent=l.label,u.appendChild(f),d){const g=Ae("span","gt-sort-badge");g.textContent=String(c+1),u.appendChild(g);const p=Ae("span","gt-sort-dir");p.textContent=((r=this.sorts[c])==null?void 0:r.sort)==="asc"?"↑ 升序":"↓ 降序",u.appendChild(p)}u.addEventListener("click",()=>{var g;d?((g=this.sorts[c])==null?void 0:g.sort)==="asc"?this.sorts[c]={colId:l.colId,sort:"desc"}:this.sorts=this.sorts.filter(p=>p.colId!==l.colId):this.sorts.push({colId:l.colId,sort:"asc"}),o()}),n.appendChild(u)}},a=Ae("div","gt-panel-actions");a.append(wt("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),wt("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applySort(),this.closeSortPanel()})),t.appendChild(a),this.mount(t,e),this.sortPanel=t,this.sortAnchor=e,o()}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 n=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(i.left,n))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const Es={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 Rs(s,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>
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>
34
+ </div>`,s.append(t);const i=e.onTaskOpen?null:Xi(t),n=k=>t.querySelector(k);n(".gantt-title-name").textContent=e.title??"甘特图";let o=structuredClone(e.tasks),a=new Map(o.map(k=>[k.id,k])),r,l,c=!0,d=!1;const u=n(".gantt-left");u.style.width=`${e.tableWidth??280}px`;const f=new AbortController,g=f.signal,p=n(".gantt-status");function C(){if(!r||d)return;m.setTasks(o);const k=Array.from({length:r.getDisplayedRowCount()},(Q,ne)=>r.getDisplayedRowAtIndex(ne)).filter(Boolean);m.setRows(k.map(Q=>({id:Q.id,group:!!Q.group,expanded:!!Q.expanded})));const z=o.filter(Q=>Q.path.length===1),_=z.filter(Q=>Q.status==="done").length;p.textContent=`总工作项数 ${z.length} 完成进度 ${z.length?Math.round(_/z.length*100):0}%`}function h(k){var Q;o=o.map(ne=>ne.id===k.id?{...k}:ne),a=new Map(o.map(ne=>[ne.id,ne]));const z=[k];let _=k.path.slice(0,-1);for(;_.length;){const ne=o.find(Z=>Z.path.join("/")===_.join("/"));if(!ne)break;const U=o.filter(Z=>Z.path.length===_.length+1&&Z.path.slice(0,-1).join("/")===_.join("/")),F=U.flatMap(Z=>Z.start?[Z.start]:[]).sort(),q=U.flatMap(Z=>Z.end?[Z.end]:[]).sort();ne.start=F[0]??null,ne.end=q[q.length-1]??null,z.push(ne),_=_.slice(0,-1)}r.applyTransaction({update:z}),C(),(Q=e.onTaskChange)==null||Q.call(e,structuredClone(k))}const m=new en(n(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:k=>{var _;m.setSelected(k);const z=k?r==null?void 0:r.getRowNode(k):null;z&&((_=r.selectNode)==null||_.call(r,z,!0))},onHover:k=>{var z;t.querySelectorAll(".ag-row-hover").forEach(_=>_.classList.remove("ag-row-hover")),k&&((z=Array.from(t.querySelectorAll(".ag-row")).find(_=>_.dataset.rowid===k))==null||z.classList.add("ag-row-hover"))},onTaskChange:h,onAssign:(k,z)=>{const _=a.get(k);_&&h({..._,owner:z})}});function y(k){const z=k.data,_=document.createElement("span");if(_.className="gt-task-name",z.path.length>1?_.classList.add("gt-child-name"):k.node.group||_.classList.add("gt-root-leaf"),z.path.length>1){const ne=document.createElement("span");ne.className=`gt-node-dot gt-node-${z.status}`,_.append(ne)}const Q=document.createElement("button");return Q.className="gt-title-link",Q.textContent=z.name,Q.title=z.name,Q.addEventListener("click",()=>{m.scrollToTask(z.id),e.onTaskOpen?e.onTaskOpen(structuredClone(z)):i==null||i.open({title:z.name,fields:[{label:"排期",value:`${z.start??"未设置"} — ${z.end??"未设置"}`}]})}),_.append(Q),_}const E=document.createElement("button");E.className="gt-tree-toggle",E.textContent="▾",E.title="收起全部子层级",E.setAttribute("aria-label",E.title);function R(k){c=k,k?r.expandAll():r.collapseAll(),E.textContent=k?"▾":"▸",E.title=k?"收起全部子层级":"展开全部子层级",E.setAttribute("aria-label",E.title),C()}E.addEventListener("click",()=>R(!c));const S=["name","status","start","end","owner","progress"].map(k=>({field:k,hide:!0,filter:!0}));l=new vt(n(".grid"),{columnDefs:S,rowData:o,treeData:!0,getDataPath:k=>k.path,getRowId:k=>k.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:Es,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const k=document.createElement("div");return k.className="gt-title-header",k.append(E,document.createTextNode("标题")),k},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:y}},onGridReady:k=>{r=k.api,C()},onModelUpdated:k=>{r=k.api,C()},onRowGroupOpened:C,onRowClicked:k=>{var z;return m.setSelected(((z=k.node)==null?void 0:z.id)??null)}}),r=l.getApi();const A=n(".ag-body-viewport");let B=!1;const L=(k,z)=>{B||(B=!0,z.scrollTop=k.scrollTop,B=!1)};A.addEventListener("scroll",()=>L(A,m.scrollElement),{signal:g}),m.scrollElement.addEventListener("scroll",()=>L(m.scrollElement,A),{signal:g}),A.addEventListener("mousemove",k=>{const z=k.target.closest(".ag-row");m.setHover((z==null?void 0:z.dataset.rowid)??null)},{signal:g}),A.addEventListener("mouseleave",()=>m.setHover(null),{signal:g});const j=new xs(r,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:k=>n('[data-action="filter"]').classList.toggle("gt-btn-active",k),onSortButton:k=>n('[data-action="sort"]').classList.toggle("gt-btn-active",k)});n('[data-action="filter"]').addEventListener("click",k=>j.openFilterPanel(k.currentTarget),{signal:g}),n('[data-action="sort"]').addEventListener("click",k=>j.openSortPanel(k.currentTarget),{signal:g}),n('[type="search"]').addEventListener("input",k=>r.setQuickFilter(k.target.value),{signal:g});const W=n(".gt-settings"),M=n('[data-action="settings"]');M.addEventListener("click",()=>{W.hidden=!W.hidden,M.setAttribute("aria-expanded",String(!W.hidden))},{signal:g}),document.addEventListener("pointerdown",k=>{!W.contains(k.target)&&!M.contains(k.target)&&(W.hidden=!0,M.setAttribute("aria-expanded","false"))},{signal:g});const D=Math.random().toString(36).slice(2);return W.querySelectorAll('[type="radio"]').forEach(k=>{const z=k.name;k.name=z+D,k.addEventListener("change",()=>{z==="theme"?m.setTheme(k.value):m.setMilestonesOnly(k.value==="milestones")},{signal:g})}),n('[data-setting="children"]').addEventListener("change",k=>m.setShowChildren(k.target.checked),{signal:g}),t.addEventListener("keydown",k=>{k.key==="Escape"&&(W.hidden=!0,j.closeAll())},{signal:g}),C(),e.unit&&m.setUnit(e.unit),m.scrollToToday(.5),{grid:r,chart:m,expandAll:()=>R(!0),collapseAll:()=>R(!1),scrollToTask:k=>m.scrollToTask(k),setTasks(k){o=structuredClone(k),a=new Map(o.map(z=>[z.id,z])),r.setRowData(o),C()},destroy(){d||(d=!0,f.abort(),j.destroy(),i==null||i.destroy(),m.destroy(),l.destroy(),t.remove())}}}const Fe=s=>Date.parse(`${s}T00:00:00Z`)/864e5,Oe=s=>new Date(s*864e5).toISOString().slice(0,10),on=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Fe(s))&&Oe(Fe(s))===s,Lt=s=>!!s.start&&!!s.end;function ui(s,e){const t=new Set(s.map(i=>i.id));if(t.size!==s.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&&(!on(i.start)||!on(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function Ms(s,e=!1){const t=[];return s.filter(Lt).slice().sort((i,n)=>i.start.localeCompare(n.start)||i.id.localeCompare(n.id)).map(i=>{let n=e?t.length:t.findIndex(o=>o<Fe(i.start));return n<0&&(n=t.length),t[n]=Fe(i.end),{item:i,lane:n}})}function Kt(s){return{scheduled:s.filter(Lt).length,unscheduled:s.filter(e=>!Lt(e)).length,estimate:s.reduce((e,t)=>e+t.estimate,0)}}const we=s=>s.replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),sn=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function ks(s,e){ui(e.people,e.items);let t=structuredClone(e.people),i=structuredClone(e.items);const n=e.today??new Date().toISOString().slice(0,10);let o=new Set(t.map(K=>K.id)),a=!1,r="",l="",c="",d=!1,u=1,f=!1,g=!1,p=!1,C=!0,h=Fe(n)-new Date(`${n}T00:00:00Z`).getUTCDay(),m=90,y=`${n.slice(0,7)}-01`,E=Oe(Date.UTC(Number(n.slice(0,4)),Number(n.slice(5,7))+1,0)/864e5),R=!1,S=!1;const A=document.createElement("section");A.className="personnel-schedule",A.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${we(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
35
+ <div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${we(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>`,s.append(A);const B=K=>A.querySelector(K),L=B(".ps-scroll"),j=B(".ps-rows"),W=B(".ps-popover"),M=B(".ps-detail"),D=new AbortController,k=D.signal;let z;const _=()=>[22,43,64,86,120][u],Q=()=>i.filter(K=>(!r||K.name.includes(r))&&(!l||K.status===l)&&(g||!K.parentId)),ne=()=>{const K=Q();return t.filter(X=>o.has(X.id)&&(!a||K.some(J=>J.personId===X.id&&Lt(J)))).sort((X,J)=>{if(!c)return 0;const Y=Kt(K.filter(pe=>pe.personId===X.id)),oe=Kt(K.filter(pe=>pe.personId===J.id));return(c==="estimate"?Y.estimate-oe.estimate:Y.scheduled-oe.scheduled)*(d?-1:1)})};function U(K){const X=B(".ps-toast");X.textContent=K,X.hidden=!1,clearTimeout(z),z=setTimeout(()=>X.hidden=!0,2200)}function F(){if(R)return;const K=_(),X=m*K;B(".ps-table").style.width=`${X+200}px`;const J=`${y.slice(0,4)}年 第${Number(y.slice(5,7))}-${Number(E.slice(5,7))}月`;B(".ps-date-label").textContent=J,B('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,B(".ps-zoom").value=String(u);const Y=B(".ps-weeks");Y.replaceChildren();for(let ke=0;ke<m;ke+=7){const Be=document.createElement("span");Be.style.width=`${Math.min(7,m-ke)*K}px`,Be.textContent=`${Oe(h+ke).slice(5).replace("-","/")}~${Oe(h+ke+6).slice(5).replace("-","/")}`,Y.append(Be)}j.replaceChildren();const oe=Q(),pe=ne();for(const ke of pe){const Be=oe.filter(me=>me.personId===ke.id),Le=Kt(Be),bt=Ms(Be,f),ze=Math.max(0,...bt.map(me=>me.lane)),ei=Math.max(p?154:126,60+(ze+1)*(p?48:36)),ht=document.createElement("div");ht.className="ps-person-row",ht.style.height=`${ei}px`,ht.dataset.person=ke.id;const St=document.createElement("div");St.className="ps-person",St.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${we(ke.name)}</strong></div><div>已排期项 <b>${Le.scheduled}</b></div><div>总估分 <b>${Le.estimate.toFixed(2)}</b></div><div>未排期·${Le.unscheduled}<button data-action="unplanned" data-person="${we(ke.id)}">查看</button></div>`;const $t=St.querySelector(".ps-avatar");$t.textContent=ke.name.slice(-2),$t.style.background=ke.color||sn[t.indexOf(ke)%sn.length];const We=document.createElement("div");We.className="ps-timeline",We.style.width=`${X}px`,We.style.setProperty("--day",`${K}px`);for(let me=0;me<m;me++)if([0,6].includes(new Date((h+me)*864e5).getUTCDay())){const ot=document.createElement("i");ot.className="ps-weekend",ot.style.left=`${me*K}px`,ot.style.width=`${K}px`,We.append(ot)}const pt=Fe(n)-h;if(pt>=0&&pt<m){const me=document.createElement("i");me.className="ps-today",me.style.left=`${(pt+.5)*K}px`,We.append(me)}for(const{item:me,lane:ot}of bt){const st=Fe(me.start),Ue=Fe(me.end);if(Ue<h||st>=h+m)continue;const at=Math.max(0,st-h)*K,xt=Math.min(m,Ue-h+1)*K,Ve=document.createElement("button");Ve.className=`ps-bar ${C?"ps-color":"ps-content"}`,Ve.dataset.item=me.id,Ve.setAttribute("aria-label",`${me.name},${me.start} 至 ${me.end}`),Ve.style.left=`${at}px`,Ve.style.width=`${xt-at}px`,Ve.style.top=`${52+ot*(p?48:36)}px`,Ve.style.setProperty("--bar-color",me.color||"#8cafeb"),Ve.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${we(me.name)}</span><span class="ps-status">${we(me.status)}</span><span class="ps-node">● ${we(me.node)}</span><span class="ps-effort">${me.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,We.append(Ve)}if(!bt.length){const me=document.createElement("span");me.className="ps-no-schedule",me.textContent="暂无排期",We.append(me)}ht.append(St,We),j.append(ht)}pe.length||(j.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const Te=oe.filter(ke=>pe.some(Be=>Be.id===ke.personId));B(".ps-total").textContent=`ⓘ 总人数 ${pe.length} 总估分 ${Kt(Te).estimate.toFixed(2)} pd ···`}function q(K,X){if(!W.hidden&&W.dataset.kind===K){W.hidden=!0;return}W.dataset.kind=K,W.hidden=!1;const J=A.getBoundingClientRect(),Y=X==null?void 0:X.getBoundingClientRect();if(W.style.left=`${Math.max(12,Math.min(((Y==null?void 0:Y.left)??J.left)-J.left,A.clientWidth-(K==="unplanned"?760:420)-16))}px`,W.style.top=`${Y?Y.bottom-J.top+6:96}px`,W.className=`ps-popover ps-panel-${K}`,K==="people")W.innerHTML=`<div class="ps-panel-title">包含 ${o.size} 人<label><input type="checkbox" data-control="only" ${a?"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(oe=>`<label><input type="checkbox" data-person="${we(oe.id)}" ${o.has(oe.id)?"checked":""}>${we(oe.name)}</label>`).join("")}</div>`;else if(K==="sort")W.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="${d?"":"selected"}">小 → 大</button><button data-action="desc" class="${d?"selected":""}">大 → 小</button></div><button class="ps-link" data-action="clear-sort">清空全部条件</button>`,W.querySelector("select").value=c;else if(K==="filter")W.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${we(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${we(r)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(oe=>oe.status))].map(oe=>`<option>${we(oe)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,W.querySelector("select").value=l;else if(K==="settings")W.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${f?"checked":""}>展开全部排期项</label><label><input type="checkbox" data-control="children" ${g?"checked":""}>展示全部子项</label><div class="ps-panel-title">内容显示</div><div class="ps-segment"><button data-action="compact" class="${p?"":"selected"}">紧凑</button><button data-action="loose" class="${p?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${C?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${C?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(K==="date")be();else if(K==="save")W.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(K==="views"){const oe=ut();W.innerHTML=`<div class="ps-panel-title">视图列表</div>${oe.length?oe.map((pe,Te)=>`<button class="ps-view" data-view="${Te}">▦ ${we(pe.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let Z=new Date(`${y}T00:00:00Z`),ie=!1;function be(){let K=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${y}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${E}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let X=0;X<2;X++){const J=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+X,1));K+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${J.getUTCFullYear()}年 ${J.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(oe=>`<span>${oe}</span>`).join("")}`;for(let oe=0;oe<J.getUTCDay();oe++)K+="<span></span>";const Y=new Date(Date.UTC(J.getUTCFullYear(),J.getUTCMonth()+1,0)).getUTCDate();for(let oe=1;oe<=Y;oe++){const pe=Oe(Date.UTC(J.getUTCFullYear(),J.getUTCMonth(),oe)/864e5);K+=`<button data-date="${pe}" class="${pe>=y&&pe<=E?"in-range":""} ${pe===y||pe===E?"selected":""}">${oe}</button>`}K+="</div></div>"}W.innerHTML=K+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((X,J)=>`<button data-preset="${J}">${X}</button>`).join("")}</div>`}function fe(){E<y&&([y,E]=[E,y]),h=Fe(y),h-=new Date(h*864e5).getUTCDay(),m=Math.max(35,Fe(E)-h+8),L.scrollLeft=0,F()}function ue(K,X){var oe;if(!i.some(pe=>pe.id===K))throw new Error(`Unknown schedule item: ${K}`);const J=i.map(pe=>pe.id===K?{...pe,...X}:pe);ui(t,J),i=J,F();const Y=i.find(pe=>pe.id===K);Y&&((oe=e.onItemChange)==null||oe.call(e,structuredClone(Y)))}function Ne(K){var J;const X=i.find(Y=>Y.id===K);(J=e.onItemOpen)==null||J.call(e,structuredClone(X)),M.hidden=!1,M.dataset.item=K,M.innerHTML=`<header><strong>${we(X.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${we(X.status)}</span><h3>● ${we(X.node)}</h3><form><label>名称<input name="name" required value="${we(X.name)}"></label><label>负责人<select name="personId">${t.map(Y=>`<option value="${we(Y.id)}" ${Y.id===X.personId?"selected":""}>${we(Y.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${X.estimate}" required></label><label>开始日期<input type="date" name="start" value="${X.start||""}"></label><label>结束日期<input type="date" name="end" value="${X.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 dt(K,X){q("unplanned",X),W.hidden=!1;const J=t.find(Y=>Y.id===K);W.innerHTML=`<div class="ps-panel-title">未排期工作项 ${we(J.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(Y=>Y.personId===K&&!Lt(Y)).map(Y=>`<tr><td><button data-open="${we(Y.id)}">${we(Y.name)}</button></td><td>● ${we(Y.node)}</td><td><input type="number" min="0" step="0.1" value="${Y.estimate||""}" placeholder="待填" data-estimate="${we(Y.id)}" aria-label="${we(Y.name)}估分"></td><td><button class="ps-link" data-open="${we(Y.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const Zt=e.viewStorageKey??"rowvia-personnel-views-v1";function ut(){try{const K=JSON.parse(localStorage.getItem(Zt)||"[]");return Array.isArray(K)?K:[]}catch{return[]}}A.addEventListener("click",K=>{const X=K.target,J=X.closest("button");if(!J)return;if(J.dataset.open){W.hidden=!0,Ne(J.dataset.open);return}if(J.dataset.item){S||Ne(J.dataset.item);return}if(J.dataset.date){ie?(E=J.dataset.date,ie=!1,fe()):(y=J.dataset.date,E=y,ie=!0),be();return}if(J.dataset.preset){const oe=Number(J.dataset.preset),pe=Fe(n),Te=new Date(pe*864e5);y=Oe(oe<2?pe-Te.getUTCDay():oe<4?Date.UTC(Te.getUTCFullYear(),Te.getUTCMonth(),1)/864e5:pe),E=Oe(oe===2||oe===3?Date.UTC(Te.getUTCFullYear(),Te.getUTCMonth()+(oe===2?1:2),0)/864e5:Fe(y)+[6,13,29,60,13,59,364][oe]),ie=!1,fe(),W.hidden=!0;return}if(J.dataset.view){const oe=ut()[Number(J.dataset.view)];oe&&(o=new Set(oe.selected.filter(pe=>t.some(Te=>Te.id===pe))),{query:r,status:l,sort:c,descending:d,zoom:u,from:h,days:m,rangeStart:y,rangeEnd:E,expanded:f,children:g,loose:p,colorFirst:C,onlyScheduled:a}=oe,F(),W.hidden=!0,U(`已打开 ${oe.name}`));return}const Y=J.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(Y||"")){q(Y,J);return}if(Y==="unplanned"){dt(J.dataset.person,J);return}if(Y==="close-detail"&&(M.hidden=!0),Y==="unschedule"&&(ue(M.dataset.item,{start:null,end:null}),M.hidden=!0),(Y==="plus"||Y==="minus")&&(u=Math.max(0,Math.min(4,u+(Y==="plus"?1:-1))),F()),(Y==="prev"||Y==="next"||Y==="today")&&(h=Y==="today"?Fe(n)-new Date(`${n}T00:00:00Z`).getUTCDay():h+(Y==="prev"?-14:14),y=Oe(h),E=Oe(h+59),L.scrollLeft=0,F()),(Y==="asc"||Y==="desc"||Y==="clear-sort")&&(d=Y==="desc",Y==="clear-sort"&&(c=""),F(),W.hidden=!0),Y==="clear-filter"&&(r="",l="",F(),W.hidden=!0),["compact","loose","content","color"].includes(Y||"")&&(Y==="compact"||Y==="loose"?p=Y==="loose":C=Y==="color",F(),W.hidden=!0,q("settings",B('[data-action="settings"]'))),(Y==="cal-prev"||Y==="cal-next")&&(Z=new Date(Date.UTC(Z.getUTCFullYear(),Z.getUTCMonth()+(Y==="cal-prev"?-1:1),1)),be()),Y==="save-view"){const oe=W.querySelector("[data-view-name]").value.trim();if(!oe)return;const pe=ut();pe.push({name:oe,selected:[...o],query:r,status:l,sort:c,descending:d,zoom:u,from:h,days:m,rangeStart:y,rangeEnd:E,expanded:f,children:g,loose:p,colorFirst:C,onlyScheduled:a});try{localStorage.setItem(Zt,JSON.stringify(pe)),W.hidden=!0,U("视图已保存")}catch{U("浏览器存储不可用,视图未保存")}}Y==="schedule"&&(W.hidden=!0,M.hidden=!0)},{signal:k}),A.addEventListener("input",K=>{const X=K.target;X.classList.contains("ps-zoom")&&(u=Number(X.value),F()),X.classList.contains("ps-person-search")&&W.querySelectorAll(".ps-person-options label").forEach(J=>{var Y;return J.hidden=!((Y=J.textContent)!=null&&Y.includes(X.value))}),X.dataset.control==="query"&&(r=X.value,F())},{signal:k}),A.addEventListener("change",K=>{const X=K.target;if(X.dataset.person&&(X.checked?o.add(X.dataset.person):o.delete(X.dataset.person),F()),X.dataset.estimate){const J=Number(X.value);Number.isFinite(J)&&J>=0&&ue(X.dataset.estimate,{estimate:J});return}switch(X.dataset.control){case"only":a=X.checked;break;case"sort":c=X.value;break;case"status":l=X.value;break;case"expanded":f=X.checked;break;case"children":g=X.checked;break;case"range-start":X.value&&(y=X.value,fe(),be());return;case"range-end":X.value&&(E=X.value,fe(),be());return}F()},{signal:k}),M.addEventListener("submit",K=>{K.preventDefault();const X=new FormData(K.target),J=String(X.get("start")||"")||null,Y=String(X.get("end")||"")||null;if(!!J!=!!Y||J&&Y&&J>Y){M.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ue(M.dataset.item,{name:String(X.get("name")),personId:String(X.get("personId")),estimate:Number(X.get("estimate")),start:J,end:Y}),M.hidden=!0,U("排期已更新")},{signal:k}),document.addEventListener("pointerdown",K=>{A.contains(K.target)?!W.contains(K.target)&&!K.target.closest("[data-action]")&&(W.hidden=!0):W.hidden=!0},{signal:k}),A.addEventListener("keydown",K=>{K.key==="Escape"&&(W.hidden=!0,M.hidden=!0)},{signal:k});let Ce=null;return j.addEventListener("pointerdown",K=>{const X=K.target,J=X.closest(".ps-bar");if(!J||K.button!==0)return;const Y=i.find(oe=>oe.id===J.dataset.item);S=!1,Ce={id:Y.id,x:K.clientX,start:Fe(Y.start),end:Fe(Y.end),edge:X.dataset.edge||"move",bar:J,left:parseFloat(J.style.left),size:parseFloat(J.style.width),delta:0,scroll:L.scrollLeft}},{signal:k}),document.addEventListener("pointermove",K=>{if(!Ce)return;const X=Math.round((K.clientX-Ce.x+L.scrollLeft-Ce.scroll)/_());Ce.delta=Ce.edge==="start"?Math.min(X,Ce.end-Ce.start):Ce.edge==="end"?Math.max(X,Ce.start-Ce.end):X,Math.abs(K.clientX-Ce.x)>4&&(S=!0),S&&(Ce.bar.style.opacity=".8",Ce.edge==="move"?Ce.bar.style.transform=`translateX(${Ce.delta*_()}px)`:(Ce.bar.style.left=`${Ce.left+(Ce.edge==="start"?Ce.delta*_():0)}px`,Ce.bar.style.width=`${Ce.size+(Ce.edge==="start"?-1:1)*Ce.delta*_()}px`))},{signal:k}),document.addEventListener("pointerup",()=>{if(!Ce)return;const K=Ce;Ce=null,S&&(ue(K.id,{start:Oe(K.start+(K.edge==="end"?0:K.delta)),end:Oe(K.end+(K.edge==="start"?0:K.delta))}),U("排期已更新"))},{signal:k}),F(),{setData(K,X){ui(K,X),t=structuredClone(K),i=structuredClone(X),o=new Set(t.map(J=>J.id)),W.hidden=!0,M.hidden=!0,F()},getItems:()=>structuredClone(i),updateItem:ue,setPeople(K){o=new Set(K.filter(X=>t.some(J=>J.id===X))),F()},destroy(){R=!0,D.abort(),clearTimeout(z),A.remove()}}}function Dt(s,e,t,i){const n=document.createElement("section");n.className=`rowvia-${e}`,n.innerHTML=t,s.append(n);let o=null,a=!1;const r=new Set,l=[];return{host:n,handle:{get api(){return(o==null?void 0:o.api)??null},get columnApi(){return(o==null?void 0:o.columnApi)??null},destroy(){a||(a=!0,r.forEach(u=>{window.clearTimeout(u),window.clearInterval(u)}),l.forEach(u=>u()),o==null||o.grid.destroy(),o=null,n.remove())}},timeout:(u,f)=>{const g=window.setTimeout(()=>{r.delete(g),a||u()},f);return r.add(g),g},cleanup(u){l.push(u)},interval(u,f){const g=window.setInterval(()=>{a||u()},f);return r.add(g),g},createGrid(u,f){return o=xi(u,{...f,...i.gridOptions}),o}}}function hi(s=42){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}const Ts=["Michael","Emma","Daniel","Olivia","James","Sophia","William","Ava","Benjamin","Isabella","Lucas","Mia","Henry","Charlotte","Alexander","Amelia","Noah","Harper","Ethan","Evelyn","Jacob","Abigail","Leo","Emily","Nathan","Elizabeth","Aaron","Sofia","Caleb","Avery","Isaac","Ella","Owen","Scarlett","Wyatt","Grace","Julian","Chloe","Miles","Victoria"],Ns=["Bridges","Stone","Collins","Reyes","Fisher","Lambert","Walsh","Harper","Keller","Novak","Silva","Weaver","Grant","Holloway","Mercer","Draper","Whitfield","Calloway","Prescott","Vance","Ellington","Monroe","Sinclair","Barlow"],Is=[{name:"France",flag:"🇫🇷"},{name:"Spain",flag:"🇪🇸"},{name:"United Kingdom",flag:"🇬🇧"},{name:"Netherlands",flag:"🇳🇱"},{name:"Portugal",flag:"🇵🇹"},{name:"Italy",flag:"🇮🇹"},{name:"United States",flag:"🇺🇸"},{name:"Ireland",flag:"🇮🇪"}],jt={executiveManagement:"Executive Management",legal:"Legal",design:"Design",engineering:"Engineering",product:"Product",customerSupport:"Customer Support"},Ls=Object.keys(jt),Xe=hi(7);function At(s){return s[Math.floor(Xe()*s.length)]}function Ds(){return`${At(Ts)} ${At(Ns)}`}function As(){const s=2015+Math.floor(Xe()*10),e=1+Math.floor(Xe()*12),t=1+Math.floor(Xe()*28);return`${s}-${String(e).padStart(2,"0")}-${String(t).padStart(2,"0")}`}function yt(s,e,t){const i=s[s.length-1],n=At(Is);return{orgHierarchy:s,contact:i.replace(/\s+/g,"."),jobTitle:e,employmentType:Xe()<.7?"Permanent":"Contract",department:t,employeeId:0,location:n.name,joinDate:As(),basicMonthlySalary:2500+Math.floor(Xe()*60)*250,currency:At(["GBP","EUR","USD"]),paymentMethod:At(["Bank Transfer","Cash","Check"]),paymentStatus:Xe()<.65?"paid":"pending",image:String(1+Math.floor(Xe()*36)),flag:n.flag}}function Fs(){const s=[];let e=1001;const t="Will Bridges",i=["Michael Johnson","Sophie Turner","Ravi Patel"],n={engineering:"Nina Alvarez",design:"Tom Whitaker",product:"Grace Liu",legal:"Hannah Ford",customerSupport:"Marc Duval",executiveManagement:"Oliver Grant"},o=a=>{s.push({...a,employeeId:e++})};o(yt([t],"CEO","executiveManagement")),o(yt([t,i[0]],"COO","executiveManagement")),o(yt([t,i[1]],"CTO","executiveManagement")),o(yt([t,i[2]],"Exec. Vice President","executiveManagement"));for(const a of Ls){const r=n[a],l=a==="executiveManagement"?i[1]:i[Math.floor(Xe()*3)];o(yt([t,l,r],"Head of Department",a));const c=6+Math.floor(Xe()*4);for(let d=0;d<c;d++){const u=Ds();o(yt([t,l,r,u],"Employee",a))}}return s}const pi=hi(1337),Ps=[["US10Y","U.S. Treasury 10-Year Bond","Bond"],["MUB","iShares National Muni Bond ETF","ETF"],["BRK.B","Berkshire Hathaway Inc. Class B","Stock"],["VOO","Vanguard S&P 500 ETF","ETF"],["QQQ","Invesco QQQ Trust","ETF"],["AAPL","Apple Inc.","Stock"],["MSFT","Microsoft Corporation","Stock"],["GOOGL","Alphabet Inc. Class A","Stock"],["AMZN","Amazon.com Inc.","Stock"],["TSLA","Tesla Inc.","Stock"],["NVDA","NVIDIA Corporation","Stock"],["META","Meta Platforms Inc.","Stock"],["JPM","JPMorgan Chase & Co.","Stock"],["V","Visa Inc.","Stock"],["UNH","UnitedHealth Group Inc.","Stock"],["XOM","Exxon Mobil Corporation","Stock"],["JNJ","Johnson & Johnson","Stock"],["WMT","Walmart Inc.","Stock"],["MA","Mastercard Inc.","Stock"],["PG","Procter & Gamble Co.","Stock"],["CVX","Chevron Corporation","Stock"],["HD","Home Depot Inc.","Stock"],["ORCL","Oracle Corporation","Stock"],["MRK","Merck & Co. Inc.","Stock"],["ABBV","AbbVie Inc.","Stock"],["PEP","PepsiCo Inc.","Stock"],["KO","Coca-Cola Co.","Stock"],["COST","Costco Wholesale Corp.","Stock"],["BAC","Bank of America Corp.","Stock"],["MCD","McDonald's Corp.","Stock"],["CSCO","Cisco Systems Inc.","Stock"],["PFE","Pfizer Inc.","Stock"],["CRM","Salesforce Inc.","Stock"],["TMO","Thermo Fisher Scientific Inc.","Stock"],["AVGO","Broadcom Inc.","Stock"],["ACN","Accenture plc","Stock"],["LIN","Linde plc","Stock"],["AMD","Advanced Micro Devices Inc.","Stock"],["NFLX","Netflix Inc.","Stock"],["DIS","Walt Disney Co.","Stock"],["TXN","Texas Instruments Inc.","Stock"],["WFC","Wells Fargo & Co.","Stock"],["PM","Philip Morris International Inc.","Stock"],["VZ","Verizon Communications Inc.","Stock"],["INTC","Intel Corporation","Stock"],["CMCSA","Comcast Corp.","Stock"],["NKE","NIKE Inc.","Stock"],["DHR","Danaher Corporation","Stock"],["UNP","Union Pacific Corp.","Stock"],["MS","Morgan Stanley","Stock"],["RTX","RTX Corporation","Stock"],["LOW","Lowe's Companies Inc.","Stock"],["SPGI","S&P Global Inc.","Stock"],["INTU","Intuit Inc.","Stock"],["GS","Goldman Sachs Group Inc.","Stock"],["BDX","Becton Dickinson & Co.","Stock"],["SCHW","Charles Schwab Corp.","Stock"],["NOW","ServiceNow Inc.","Stock"],["ISRG","Intuitive Surgical Inc.","Stock"],["AMAT","Applied Materials Inc.","Stock"],["GE","GE Aerospace","Stock"],["CAT","Caterpillar Inc.","Stock"],["BLK","BlackRock Inc.","Stock"],["AXP","American Express Co.","Stock"],["TJX","TJX Companies Inc.","Stock"],["GILD","Gilead Sciences Inc.","Stock"],["SYK","Stryker Corporation","Stock"],["MDT","Medtronic plc","Stock"],["C","Citigroup Inc.","Stock"],["CB","Chubb Limited","Stock"],["ZTS","Zoetis Inc.","Stock"],["MMC","Marsh & McLennan Cos. Inc.","Stock"],["ADP","Automatic Data Processing Inc.","Stock"],["CI","Cigna Group","Stock"],["SO","Southern Co.","Stock"],["ETN","Eaton Corp. plc","Stock"],["BSX","Boston Scientific Corp.","Stock"],["PLD","Prologis Inc.","Stock"],["ITW","Illinois Tool Works Inc.","Stock"],["HON","Honeywell International Inc.","Stock"],["MU","Micron Technology Inc.","Stock"],["DE","Deere & Co.","Stock"],["AMT","American Tower Corp.","Stock"],["WM","Waste Management Inc.","Stock"],["LRCX","Lam Research Corp.","Stock"],["CSX","CSX Corporation","Stock"],["ICE","Intercontinental Exchange Inc.","Stock"],["CL","Colgate-Palmolive Co.","Stock"],["SHW","Sherwin-Williams Co.","Stock"],["FI","Fiserv Inc.","Stock"],["USB","U.S. Bancorp","Stock"],["PNC","PNC Financial Services Group Inc.","Stock"],["APH","Amphenol Corporation","Stock"],["NOC","Northrop Grumman Corp.","Stock"],["GD","General Dynamics Corp.","Stock"],["MSI","Motorola Solutions Inc.","Stock"],["TGT","Target Corporation","Stock"],["F","Ford Motor Co.","Stock"],["GM","General Motors Co.","Stock"],["BTC","Bitcoin","Crypto"],["ETH","Ethereum","Crypto"],["SOL","Solana","Crypto"],["USDC","USD Coin","Crypto"],["XRP","XRP","Crypto"],["ADA","Cardano","Crypto"],["DOT","Polkadot","Crypto"],["LINK","Chainlink","Crypto"],["AGG","iShares Core U.S. Aggregate Bond ETF","ETF"],["BND","Vanguard Total Bond Market ETF","ETF"],["LQD","iShares iBoxx $ Investment Grade Corp Bond ETF","ETF"],["HYG","iShares iBoxx $ High Yield Corp Bond ETF","ETF"],["TLT","iShares 20+ Year Treasury Bond ETF","ETF"],["IWM","iShares Russell 2000 ETF","ETF"],["EEM","iShares MSCI Emerging Markets ETF","ETF"],["VGK","Vanguard FTSE Europe ETF","ETF"],["VWO","Vanguard FTSE Emerging Markets ETF","ETF"],["XLE","Energy Select Sector SPDR Fund","ETF"],["XLF","Financial Select Sector SPDR Fund","ETF"],["XLK","Technology Select Sector SPDR Fund","ETF"],["XLV","Health Care Select Sector SPDR Fund","ETF"],["GLD","SPDR Gold Shares","ETF"],["SLV","iShares Silver Trust","ETF"],["USO","United States Oil Fund","ETF"],["VIXY","ProShares VIX Short-Term Futures ETF","ETF"],["ARKK","ARK Innovation ETF","ETF"],["SPY","SPDR S&P 500 ETF Trust","ETF"]],an=["#2196f3","#4caf50","#ff9800","#9c27b0","#f44336","#00bcd4","#795548","#607d8b","#e91e63","#3f51b5","#009688","#ffc107"];function $s(s){let e=0;for(let o=0;o<s.length;o++)e=e*31+s.charCodeAt(o)>>>0;const t=an[e%an.length],i=s.replace(/[^A-Za-z]/g,"").slice(0,2).toUpperCase()||s.slice(0,2).toUpperCase(),n=`<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40"><rect width="40" height="40" rx="20" fill="${t}"/><text x="20" y="26" font-family="Arial, sans-serif" font-size="16" font-weight="bold" fill="#fff" text-anchor="middle">${i}</text></svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(n)}`}function Gs(s){const e=[];let t=s*(.9+pi()*.2);for(let i=0;i<24;i++)t=t*(1+(pi()-.5)*.04),e.push(Number(t.toFixed(2)));return e}function Hs(){return Ps.map(([s,e,t])=>{const i=Number((Math.random()*40+10).toFixed(2)),n=Number((Math.random()*40+10).toFixed(2));return{ticker:s,name:e,instrument:t,quantity:10+Math.floor(pi()*500),purchaseDate:"2023-04-11",purchasePrice:i,price:n,timeline:Gs(n)}})}function Os(s){for(const e of s)if(Math.random()<.1){const t=Math.random()*.2,i=1-t+Math.random()*t*2;e.price<10?e.price=e.price*i:e.price=Math.random()*40+10,e.price=Number(e.price.toFixed(2)),e.timeline=e.timeline.slice(1,e.timeline.length).concat(e.price)}}function Bs(s,e={}){var C,h;const t=Dt(s,"finance",`<div id="app">
38
+ <div id="financeGrid" class="grid ag-theme-quartz gridHeight"></div>
39
+ </div>`,e),{host:i,createGrid:n}=t,o=new Intl.NumberFormat("en-US",{style:"decimal",maximumFractionDigits:2});function a(m){var A,B,L;const y=document.createElement("div");y.className="ticker-cell";const E=document.createElement("img");E.src=$s(String(((A=m.data)==null?void 0:A.ticker)??"")),E.alt=`${((B=m.data)==null?void 0:B.name)??""} logo`,y.appendChild(E);const R=document.createElement("b");R.className="custom-ticker",R.textContent=String(m.value??""),y.appendChild(R);const S=document.createElement("span");return S.className="ticker-name",S.textContent=` ${((L=m.data)==null?void 0:L.name)??""}`,y.appendChild(S),y}const r=[{field:"ticker",width:340,minWidth:340,cellRenderer:a,tooltipValueGetter:m=>{var y,E;return`${((y=m.data)==null?void 0:y.name)??""} (${((E=m.data)==null?void 0:E.instrument)??""})`}},{field:"timeline",headerName:"Timeline",width:140,minWidth:140,cellRenderer:"agSparklineCellRenderer",sortable:!1,filter:!1,cellRendererParams:{sparklineOptions:{type:"bar",direction:"vertical",axis:{strokeWidth:0}}}},{field:"instrument",width:100,minWidth:100,type:"rightAligned"},{colId:"p&l",headerName:"P&L",width:140,minWidth:140,type:"rightAligned",cellRenderer:"agAnimateShowChangeCellRenderer",filter:"number",valueGetter:m=>m.data&&m.data.quantity*(m.data.price/m.data.purchasePrice),aggFunc:"sum",valueFormatter:m=>m.value==null?"":o.format(m.value)},{colId:"totalValue",headerName:"Total Value",width:160,minWidth:160,type:"rightAligned",cellRenderer:"agAnimateShowChangeCellRenderer",filter:"number",valueGetter:m=>m.data&&m.data.quantity*m.data.price,aggFunc:"sum",valueFormatter:m=>m.value==null?"":o.format(m.value)},{field:"quantity",maxWidth:75,type:"rightAligned",valueFormatter:m=>m.value==null?"":o.format(m.value)},{field:"purchasePrice",headerName:"Price",maxWidth:75,type:"rightAligned",valueFormatter:m=>m.value==null?"":o.format(m.value)}],l=Hs(),c={columnDefs:r,rowData:l,defaultColDef:{flex:1,filter:!0,enableRowGroup:!1,enableValue:!0},rowGroupPanelShow:"never",groupDefaultExpanded:-1,getRowId:m=>m.data.ticker,enableRangeSelection:!0,enableCharts:!0,statusBar:{statusPanels:[{statusPanel:"agTotalAndFilteredRowCountComponent",align:"left"},{statusPanel:"agTotalRowCountComponent",align:"left"},{statusPanel:"agFilteredRowCountComponent",align:"left"},{statusPanel:"agSelectedRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},theme:"ag-theme-quartz",context:{}},{api:d}=n(i.querySelector("#financeGrid"),c),u=60;let f;function g(){f===void 0&&(f=t.interval(()=>{Os(l);const m=[];for(const y of l){const E=d.getRowNode(y.ticker);E&&(E.data=y,m.push(E))}d.refreshCells({rowNodes:m,force:!0})},u))}function p(){f!==void 0&&(window.clearInterval(f),f=void 0)}if(e.liveUpdates!==!1&&!((C=e.gridOptions)!=null&&C.rowData)&&g(),e.liveUpdates!==!1&&!((h=e.gridOptions)!=null&&h.rowData)&&typeof IntersectionObserver<"u"){const m=new IntersectionObserver(y=>{for(const E of y)E.isIntersecting?g():p()},{threshold:0});t.cleanup(()=>m.disconnect()),m.observe(i.querySelector("#financeGrid"))}return t.cleanup(p),t.handle}function Vs(s,e={}){const t=Dt(s,"hr",`<div class="wrapper">
40
+ <div class="container">
41
+ <div id="hrGrid" class="grid ag-theme-quartz"></div>
42
+ </div>
43
+ </div>`,e),{host:i,createGrid:n}=t,o=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function a(h){let m=0;for(let y=0;y<h.length;y++)m=m*31+h.charCodeAt(y)>>>0;return o[m%o.length]}function r(h){return h.split(/\s+/).map(m=>m[0]).join("").slice(0,2).toUpperCase()}function l(h){var L;const m=document.createElement("div");m.className="employeeCell";const y=h.data||{},E=h.node.group?h.value:((L=y.orgHierarchy)==null?void 0:L[y.orgHierarchy.length-1])??"",R=document.createElement("div");R.className="avatar",R.style.backgroundColor=a(String(E)),R.textContent=r(String(E));const S=document.createElement("div");S.className="employeeData";const A=document.createElement("span");A.className="name",A.textContent=String(E);const B=document.createElement("span");return B.className="description",B.textContent=y.jobTitle??"",S.appendChild(A),S.appendChild(B),m.appendChild(R),m.appendChild(S),m}function c(h){const m=String(h.valueFormatted??h.value??""),y=Object.keys(jt).find(A=>jt[A]===m)??"",E=document.createElement("div");E.className=`tag ${y}Tag`;const R=document.createElement("span");R.className=`circle ${y}Circle`,E.appendChild(R);const S=document.createElement("span");return S.textContent=m,E.appendChild(S),E}function d(h){var R;const m=document.createElement("div");m.className="flagCell";const y=document.createElement("span");y.textContent=String(h.value??""),m.appendChild(y);const E=document.createElement("span");return E.className="flagImage",E.textContent=((R=h.data)==null?void 0:R.flag)??"",m.appendChild(E),m}function u(h){const m=String(h.value??""),y=document.createElement("div");if(y.className=`tag ${m}Tag`,m==="paid"){const R=document.createElement("span");R.className="tick",R.innerHTML='<svg viewBox="0 0 16 16" width="16" height="16" fill="rgb(62,184,97)"><path d="M6 11.2L2.8 8l-1 1L6 13.2 14.6 4.6l-1-1L6 11.2z"/></svg>',y.appendChild(R)}const E=document.createElement("span");return E.textContent=m,y.appendChild(E),y}function f(h){var A;const m=document.createElement("div");m.className="contact-cell";const y=document.createElement("div");y.className="iconContainer",y.title="LinkedIn",y.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="#0a66c2"><path d="M4.98 3.5a2.5 2.5 0 1 1 0 5 2.5 2.5 0 0 1 0-5zM3 9h4v12H3V9zm7 0h3.8v1.7h.05c.53-1 1.83-2.05 3.77-2.05C21.4 8.65 22 11 22 14.1V21h-4v-6.1c0-1.5-.54-2.5-1.87-2.5-1.02 0-1.63.69-1.9 1.35-.1.23-.13.56-.13.9V21h-4V9z"/></svg>',y.addEventListener("click",()=>window.open("https://www.linkedin.com/company/ag-grid/","_blank")),m.appendChild(y);const E=((A=h.data)==null?void 0:A.orgHierarchy)??[],R=(E[E.length-1]??"").toLowerCase().replace(/\s+/g,"."),S=document.createElement("div");return S.className="iconContainer",S.title="Email",S.innerHTML='<svg viewBox="0 0 24 24" width="14" height="14" fill="#39485d"><path d="M2 5h20v14H2V5zm2 2v.7l8 5 8-5V7H4zm0 3.9V17h16v-6.1l-8 5-8-5z"/></svg>',S.addEventListener("click",()=>{window.location.href=`mailto:${R}@company.com`}),m.appendChild(S),m}const C={columnDefs:[{field:"employeeId",headerName:"ID",width:120},{field:"department",width:250,minWidth:250,flex:1,valueFormatter:h=>{const m=String(h.value??"");return jt[m]??m},cellRenderer:c},{field:"employmentType",editable:!0,width:180,minWidth:180,flex:1,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Permanent","Contract"]}},{field:"location",width:200,minWidth:200,flex:1,cellRenderer:d,editable:!0},{field:"joinDate",headerName:"Join Date",editable:!0,width:120},{field:"basicMonthlySalary",headerName:"Salary",valueFormatter:h=>h.value==null?"":`$${Math.round(h.value).toLocaleString()}`},{field:"paymentMethod",headerName:"Payment Method",editable:!0,width:180,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Cash","Check","Bank Transfer"]}},{field:"paymentStatus",headerName:"Status",editable:!0,width:100,cellRenderer:u,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:["Paid","Pending"]}},{field:"contact",headerName:"Contact",pinned:"right",cellRenderer:f,width:120}],rowData:Fs(),rowHeight:62,groupDefaultExpanded:-1,treeData:!0,getDataPath:h=>h.orgHierarchy,autoGroupColumnDef:{headerName:"Employee",width:330,pinned:"left",sort:"asc",cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:l}},theme:"ag-theme-quartz"};return n(i.querySelector("#hrGrid"),C),t.handle}const ln=[["#667eea","#764ba2"],["#f093fb","#f5576c"],["#4facfe","#00f2fe"],["#43e97b","#38f9d7"],["#fa709a","#fee140"],["#30cfd0","#330867"],["#a8edea","#fed6e3"],["#ff9a9e","#fecfef"],["#f6d365","#fda085"],["#5ee7df","#b490ca"]];function zs(s,e){const[t,i]=ln[e%ln.length],n=s.split(/\s+/).slice(0,2).map(a=>a[0]).join("").toUpperCase(),o=`<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120"><defs><linearGradient id="g" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="${t}"/><stop offset="1" stop-color="${i}"/></linearGradient></defs><rect width="120" height="120" rx="8" fill="url(#g)"/><text x="60" y="70" font-family="Arial, sans-serif" font-size="40" font-weight="bold" fill="rgba(255,255,255,0.85)" text-anchor="middle">${n}</text></svg>`;return`data:image/svg+xml;utf8,${encodeURIComponent(o)}`}const rn=["Vinyl, LP, Album",'Vinyl, 12", 45 RPM',"Vinyl, LP, Reissue","CD, Album"],cn=["Blue Note","Columbia","Motown","Def Jam","Sub Pop","4AD","Matador","Domino"],dn=["US","UK","Europe","Japan"];function Ws(s,e,t){return Array.from({length:s},(i,n)=>({title:e,available:Math.floor(Math.random()*40),format:rn[n%rn.length],label:cn[n%cn.length],cat:`NB ${1e3+n*7}`,country:dn[n%dn.length],year:t}))}const Us=[{product:"Dreams of You",artist:"David Nearing",category:"Pop",year:"1984",status:"active",available:32,incoming:12,price:24.99,sold:128,priceIncrease:5.2,variants:3},{product:"Blue Skies",artist:"Maya Allen",category:"Rock",year:"1991",status:"active",available:18,incoming:5,price:19.99,sold:76,priceIncrease:2.1,variants:2},{product:"Heaven",artist:"Velvet Wave",category:"Soft Rock",year:"1978",status:"paused",available:0,incoming:0,price:29.99,sold:214,priceIncrease:8.4,variants:4},{product:"Life Matters",artist:"Danielle James",category:"Synth-pop",year:"1986",status:"active",available:45,incoming:20,price:22.5,sold:189,priceIncrease:3.6,variants:3},{product:"Lonely Hearts",artist:"Emma Stone",category:"Electronic",year:"1995",status:"outOfStock",available:0,incoming:8,price:27,sold:92,priceIncrease:1.2,variants:2},{product:"Imaginary Groove",artist:"Leo Collins",category:"Jazz",year:"1972",status:"active",available:27,incoming:15,price:31.99,sold:145,priceIncrease:6.7,variants:3},{product:"Desert Bloom",artist:"Indigo Ray",category:"Trance",year:"2003",status:"active",available:12,incoming:25,price:18.75,sold:63,priceIncrease:.8,variants:2},{product:"Golden Daze",artist:"The Marlowe Sound",category:"Ambient",year:"2011",status:"paused",available:8,incoming:0,price:26.25,sold:41,priceIncrease:4.3,variants:2},{product:"Fragments",artist:"Nova Elle",category:"Alt-pop",year:"2018",status:"active",available:56,incoming:30,price:21,sold:210,priceIncrease:7.1,variants:4},{product:"Solstice City",artist:"Aurora Lines",category:"Rhythm & Blues",year:"1989",status:"active",available:22,incoming:10,price:23.99,sold:167,priceIncrease:2.9,variants:3}];function _s(){return Us.map((s,e)=>({...s,image:zs(s.product,e),variantDetails:Ws(s.variants,s.product,s.year)}))}function qs(s,e={}){const t=Dt(s,"inventory",`<div class="wrapper">
44
+ <div class="container">
45
+ <div class="exampleHeader">
46
+ <div class="tabs" id="tabs">
47
+ <button class="tab active" data-key="all">All</button>
48
+ <button class="tab" data-key="active">Active</button>
49
+ <button class="tab" data-key="paused">On Hold</button>
50
+ <button class="tab" data-key="outOfStock">Out of Stock</button>
51
+ </div>
52
+ <div class="inputWrapper">
53
+ <svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="#98a2b3" stroke-width="2">
54
+ <circle cx="11" cy="11" r="7" />
55
+ <path d="M20 20l-3.5-3.5" />
56
+ </svg>
57
+ <input id="filter-text-box" class="input" placeholder="Search product..." />
58
+ </div>
59
+ </div>
60
+ <div id="inventoryGrid" class="grid ag-theme-quartz"></div>
61
+ </div>
62
+ </div>`,e),{host:i,createGrid:n}=t,o={all:"All",active:"Active",paused:"On Hold",outOfStock:"Out of Stock"};function a(m){return o[String(m.value??"all")]??String(m.value??"")}function r(m){var B,L,j;const y=document.createElement("div");y.className="productCell";const E=document.createElement("img");E.src=((B=m.data)==null?void 0:B.image)??"",E.alt=((L=m.data)==null?void 0:L.product)??"",y.appendChild(E);const R=document.createElement("div"),S=document.createElement("div");S.textContent=String(m.value??"");const A=document.createElement("div");return A.className="stockCell",A.textContent=((j=m.data)==null?void 0:j.category)??"",R.appendChild(S),R.appendChild(A),y.appendChild(R),y}function l(m){const y=String(m.value??""),E=document.createElement("div");E.className=`tag ${y}Tag`;const R=document.createElement("span");R.className=`circle ${y}Circle`,E.appendChild(R);const S=document.createElement("span");return S.textContent=o[y]??y,E.appendChild(S),E}function c(m){var A,B;const y=document.createElement("div");y.className="stock";const E=document.createElement("span");E.textContent=String(((A=m.data)==null?void 0:A.available)??"");const R=document.createElement("span");R.className="stockText",R.textContent="Stock /";const S=document.createElement("span");return S.className="variantsText",S.textContent=`${((B=m.data)==null?void 0:B.variants)??0} Variants`,y.appendChild(E),y.appendChild(R),y.appendChild(S),y}function d(m){var S;const y=document.createElement("div");y.className="price";const E=document.createElement("span");E.className="priceAmount",E.textContent=`£${Number(m.value??0).toFixed(2)}`;const R=document.createElement("span");return R.className="increase",R.textContent=`${((S=m.data)==null?void 0:S.priceIncrease)??0}% increase`,y.appendChild(E),y.appendChild(R),y}function u(m){const y=document.createElement("div");y.className="buttonCell";const E=document.createElement("button");E.className="removeButton",E.title="Remove",E.innerHTML='<svg viewBox="0 0 24 24" width="20" height="20" fill="#98a2b3"><path d="M7 21q-.825 0-1.412-.587Q5 19.825 5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413Q17.825 21 17 21zM17 6H7v13h10zM9 17h2V8H9zm4 0h2V8h-2z"/></svg>',E.addEventListener("click",()=>{m.api.applyTransaction({remove:[m.node.data]})}),y.appendChild(E);const R=document.createElement("button");return R.className="buttonStopSelling",R.textContent="Hold Selling",R.addEventListener("click",()=>{const S={...m.node.data};S.status!=="paused"?S.status="paused":S.available<=0?S.status="outOfStock":S.status="active",m.api.applyTransaction({update:[S]})}),y.appendChild(R),y}const f=[{field:"product",headerName:"Album Name",minWidth:300,cellRenderer:"agGroupCellRenderer",cellRendererParams:{innerRenderer:r},headerClass:"header-product"},{field:"artist",headerName:"Artist"},{field:"year",headerName:"Year",width:150,headerClass:"header-sku"},{field:"status",headerName:"Status",minWidth:140,filter:"set",filterParams:{valueFormatter:a},cellRenderer:l,headerClass:"header-status"},{field:"inventory",headerName:"Inventory",cellRenderer:c,sortable:!1,headerClass:"header-inventory"},{field:"incoming",headerName:"Incoming",editable:!0,cellEditorParams:{precision:0,step:1,showStepperButtons:!0}},{field:"price",headerName:"Price",width:120,cellRenderer:d,headerClass:"header-price"},{field:"sold",headerName:"Sold",headerClass:"header-calendar"},{colId:"profit",headerName:"Est. Profit",cellDataType:!0,valueGetter:m=>m.data.price*m.data.sold/10,valueFormatter:m=>`£${m.value}`,width:150,headerClass:"header-percentage"},{field:"actions",headerName:"Actions",minWidth:194,cellRenderer:u,sortable:!1,filter:!1}],g={columnDefs:[{field:"title",headerName:"Title",flex:1.5},{field:"available",headerName:"Available",maxWidth:120},{field:"format",headerName:"Format",flex:2},{field:"label",headerName:"Label",flex:1},{field:"country",headerName:"Country",flex:.66},{field:"cat",headerName:"Cat#",type:"rightAligned",flex:.66},{field:"year",headerName:"Year",type:"rightAligned",maxWidth:80}],headerHeight:38,defaultColDef:{flex:1,resizable:!0}},{api:p}=n(i.querySelector("#inventoryGrid"),{columnDefs:f,rowData:_s(),rowHeight:80,defaultColDef:{resizable:!1},autoSizeStrategy:{type:"fitGridWidth"},pagination:!0,paginationPageSize:10,paginationPageSizeSelector:[5,10,20],masterDetail:!0,detailRowAutoHeight:!0,detailCellRendererParams:{detailGridOptions:g,getDetailRowData:m=>m.data.variantDetails},theme:"ag-theme-quartz"}),C=i.querySelector("#tabs");C.addEventListener("click",m=>{const E=m.target.closest(".tab");if(!E)return;for(const S of C.querySelectorAll(".tab"))S.classList.remove("active");E.classList.add("active");const R=E.dataset.key;p.setColumnFilterModel("status",R==="all"?null:{filterType:"set",values:[R]}),p.onFilterChanged()});const h=i.querySelector("#filter-text-box");return h.addEventListener("input",()=>{p.setQuickFilter(h.value)}),t.handle}const gi=["Ireland","Spain","United Kingdom","France","Germany","Italy","Netherlands","Portugal","Australia","Canada","Japan","Sweden"],fi=["English","Spanish","French","German","Italian","Portuguese","Dutch","Japanese","Swedish","Mandarin"],mi=["Chess","Go","Bridge","Poker","Backgammon","Checkers","Mahjong","Sudoku","Scrabble","Risk","Catan","Dungeons & Dragons"],vi=["jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"],un=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia","Kai","Lena","Milo","Nora","Omar","Petra","Quinn","Rosa","Sam","Tessa"],hn=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes","Ibarra","Jensen","Klein","Larsen","Moreau","Novak","Ortiz","Pavel","Quintero","Rossi","Silva","Turner"];function pn(s=12345){let e=s>>>0;return()=>(e=e*1664525+1013904223>>>0,e/4294967296)}let Ze=pn();function Ks(){Ze=pn(98765)}function js(s,e){const t={name:`${un[s%un.length]} ${hn[s%hn.length]}`,language:fi[Math.floor(Ze()*fi.length)],country:gi[Math.floor(Ze()*gi.length)],game:{name:mi[Math.floor(Ze()*mi.length)],bought:Ze()<.5},bankBalance:Math.round(Ze()*1e5)-3e3,rating:Math.round(Ze()*5)};let i=0;for(const n of vi){const o=Math.round(Ze()*1e5)-20;t[n]=o,i+=o}t.totalWinnings=i;for(let n=1;n<=e;n++)t[`col${n}`]=Math.round(Ze()*1e5)-500;return t}function Xs(s,e){const t=[];for(let i=0;i<s;i++)t.push(js(i,e));return t}const Ys=[{group:"Performance",count:10},{group:"Tournaments",count:8},{group:"Social",count:6},{group:"Financial",count:8},{group:"Game Details",count:8},{group:"Training",count:8},{group:"Seasonal",count:8},{group:"Equipment",count:6},{group:"Miscellaneous",count:7}],Xt=["currency","percent","rating","text","number"];function Qs(s){const e=[];let t=0;for(const i of Ys)for(let n=0;n<i.count&&t<s;n++,t++){const o=Xt[t%Xt.length],a=o==="currency"?160:o==="percent"?130:o==="rating"?120:o==="text"?160:140;e.push({field:`col${t+1}`,group:i.group,dataType:o,width:a})}for(;t<s;){t++;const i=Xt[(t+3)%Xt.length],n=i==="currency"?160:i==="percent"?130:i==="rating"?120:i==="text"?160:140;e.push({field:`col${t}`,group:"Miscellaneous",dataType:i,width:n})}return e}function Js(s,e={}){const t=Dt(s,"performance",`<div class="exampleWrapper">
63
+ <div class="toolbar">
64
+ <div class="controls">
65
+ <div class="group">
66
+ <label class="label" for="data-size">Data Size</label>
67
+ <select class="select" id="data-size">
68
+ <option value="100x24" selected>100 Rows, 24 Cols</option>
69
+ <option value="1000x24">1,000 Rows, 24 Cols</option>
70
+ <option value="10000x100">10,000 Rows, 100 Cols</option>
71
+ <option value="50000x100">50,000 Rows, 100 Cols</option>
72
+ <option value="100000x100">100,000 Rows, 100 Cols</option>
73
+ </select>
74
+ </div>
75
+ <div class="group">
76
+ <label class="label" for="theme-select">Theme</label>
77
+ <select class="select" id="theme-select">
78
+ <option value="ag-theme-quartz" selected>Quartz</option>
79
+ <option value="ag-theme-balham">Balham</option>
80
+ <option value="ag-theme-alpine">Alpine</option>
81
+ </select>
82
+ </div>
83
+ <div class="group">
84
+ <label class="label" for="global-filter">Filter</label>
85
+ <input class="input" id="global-filter" placeholder="Filter any column..." />
86
+ </div>
87
+ </div>
88
+ </div>
89
+ <section class="gridWrapper">
90
+ <div id="performanceGrid" class="gridSurface ag-theme-quartz"></div>
91
+ </section>
92
+ </div>`,e),{host:i,createGrid:n}=t,o={Ireland:"🇮🇪",Spain:"🇪🇸","United Kingdom":"🇬🇧",France:"🇫🇷",Germany:"🇩🇪",Italy:"🇮🇹",Netherlands:"🇳🇱",Portugal:"🇵🇹",Australia:"🇦🇺",Canada:"🇨🇦",Japan:"🇯🇵",Sweden:"🇸🇪"},a=S=>S.value==null?"":`$${Math.round(S.value).toLocaleString("en-US")}`;function r(S){const A=document.createElement("span");A.style.display="inline-flex",A.style.alignItems="center",A.style.gap="6px";const B=document.createElement("span");B.textContent=o[String(S.value)]??"🏳️",B.style.fontSize="15px";const L=document.createElement("span");return L.textContent=String(S.value??""),L.style.overflow="hidden",L.style.textOverflow="ellipsis",L.style.whiteSpace="nowrap",A.appendChild(B),A.appendChild(L),A}const l='<svg class="starIcon" viewBox="0 0 24 24" width="12" height="12" fill="#f59e0b"><path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"/></svg>';function c(S){const A=document.createElement("span");A.className="v-align";const B=Number(S.value??0);if(B===0&&S.isFilterRenderer)return A.textContent="(No stars)",A;for(let L=0;L<B;L++){const j=document.createElement("span");j.innerHTML=l,A.appendChild(j)}return A}function d(S){return S.value===null||S.value===void 0?null:S.value<0?{color:"#e11d48",fontWeight:"bold"}:null}function u(S){const A=[{headerName:"Participant",groupId:"participant",openByDefault:!0,children:[{field:"name",width:200,rowDrag:!0,enableRowGroup:!0,editable:!0},{field:"language",width:150,enableRowGroup:!0,enablePivot:!0,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:fi},filter:"set",editable:!0},{field:"country",width:150,cellRenderer:r,cellEditor:"agRichSelectCellEditor",cellEditorParams:{cellRenderer:r,values:gi},filter:"set",enableRowGroup:!0,enablePivot:!0,editable:!0}]},{headerName:"Game of Choice",groupId:"gameOfChoice",openByDefault:!0,children:[{field:"game.name",headerName:"Game",width:180,cellEditor:"agRichSelectCellEditor",cellEditorParams:{values:mi,allowTyping:!0,searchType:"matchAny",filterList:!0,highlightMatch:!0},filter:"set",enableRowGroup:!0,enablePivot:!0,cellClass:"alphabet",editable:!0},{field:"game.bought",headerName:"Bought",width:110,filter:"set",cellClass:"boolean-type",enableRowGroup:!0,enablePivot:!0,editable:!0}]},{headerName:"Performance",groupId:"performance",openByDefault:!0,children:[{field:"bankBalance",headerName:"Bank Balance",width:150,aggFunc:"avg",cellDataType:!0,filter:"number",cellClassRules:{"currency-cell":B=>typeof B.value=="number"},editable:!0},{field:"rating",headerName:"Rating",width:120,cellRenderer:c,cellEditor:"agNumberCellEditor",cellEditorParams:{min:0,max:5},filterParams:{cellRenderer:c,cellRendererParams:{isFilterRenderer:!0}},aggFunc:"avg",enableRowGroup:!0,enablePivot:!0,enableValue:!0,cellClass:"v-align",editable:!0},{field:"totalWinnings",headerName:"Total Winnings",width:200,aggFunc:"sum",cellDataType:!0,filter:"number",cellStyle:d,cellClassRules:{"currency-cell":B=>typeof B.value=="number"},editable:!0}]},{headerName:"Monthly Breakdown",groupId:"monthlyBreakdown",openByDefault:!0,children:[{colId:"winningTrends",headerName:"Winning Trends",width:200,sortable:!1,filter:!1,cellRenderer:"agSparklineCellRenderer",valueGetter:B=>vi.map(L=>({month:L,value:B.data[L]})),cellRendererParams:{sparklineOptions:{type:"area"}}},...vi.map(B=>({field:B,headerName:B.charAt(0).toUpperCase()+B.slice(1),width:120,enableValue:!0,aggFunc:"sum",cellDataType:!0,filter:"number",filterParams:{buttons:["reset"],inRangeInclusive:!0},cellClassRules:{"good-score":L=>typeof L.value=="number"&&L.value>5e4,"bad-score":L=>typeof L.value=="number"&&L.value<1e4,"currency-cell":L=>typeof L.value=="number"&&L.value>=1e4&&L.value<=5e4},editable:!0}))]}];if(S>0){const B=Qs(S),L=new Map;for(const j of B)L.has(j.group)||L.set(j.group,[]),L.get(j.group).push(j);for(const[j,W]of L)A.push({headerName:j,groupId:`extra-${j}`,openByDefault:!0,children:W.map(M=>({field:M.field,headerName:M.field,width:M.width,editable:!0,cellDataType:M.dataType!=="text",filter:M.dataType==="text"?"set":"number",valueFormatter:M.dataType==="percent"?D=>D.value==null?"":`${D.value.toFixed(1)}%`:M.dataType==="currency"?a:void 0,aggFunc:M.dataType==="text"?void 0:"sum"}))})}return A}const f=i.querySelector("#performanceGrid"),g=i.querySelector("#data-size"),p=i.querySelector("#theme-select"),C=i.querySelector("#global-filter");let h=null,m,y=0;function E(){m!==void 0&&window.clearTimeout(m),m=t.timeout(()=>R(),10)}function R(){var Q;const S=++y,[A,B]=g.value.split("x").map(Number),L=Math.max(0,B-24),j=p.value;if(h&&(h.destroy(),h=null,f.innerHTML=""),h=n(f,{columnDefs:u(L),rowData:[],theme:j,rowNumbers:!0,rowHeight:42,defaultColDef:{minWidth:50,editable:!0,filter:!0,floatingFilter:!0,enableCellChangeFlash:!0},rowGroupPanelShow:"always",autoGroupColumnDef:{headerName:"Group",width:250,field:"name"},sideBar:{toolPanels:["columns","filters","charts"],position:"right",defaultToolPanel:"columns"},statusBar:{statusPanels:[{statusPanel:"agTotalAndFilteredRowCountComponent",align:"left"},{statusPanel:"agSelectedRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},rowSelection:"multiple",enableRangeSelection:!0,enableCharts:!0}).api,(Q=e.gridOptions)!=null&&Q.rowData)return;h.showLoadingOverlay();const W=A>1e4?1e4:1e3,M=Math.ceil(A/W);let D=0;const k=[],z=Date.now();Ks();const _=()=>{if(S!==y)return;const ne=Xs(Math.min(W,A-D*W),L);if(k.push(...ne),D++,D<M)t.timeout(_,0);else{const U=Date.now()-z,F=Math.max(0,500-U);t.timeout(()=>{S===y&&(h==null||h.hideOverlay(),h==null||h.setRowData(k))},F)}};t.timeout(_,0)}return g.addEventListener("change",E),p.addEventListener("change",E),C.addEventListener("input",()=>{h==null||h.setQuickFilter(C.value)}),R(),t.handle}function Zs(s,e={}){const t=Dt(s,"server-side",`<div class="exampleWrapper">
93
+ <div class="toolbar">
94
+ <div class="controls">
95
+ <div class="group">
96
+ <label class="label">Server-Side Row Model</label>
97
+ <span class="hint">50,000 rows · sorting, filtering and grouping run on the server · 120 ms latency</span>
98
+ </div>
99
+ <div class="group">
100
+ <button class="button" id="refresh">Refresh Server Data</button>
101
+ <button class="button" id="purge">Purge Cache</button>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ <section class="gridWrapper">
106
+ <div id="serverSideGrid" class="gridSurface ag-theme-quartz"></div>
107
+ </section>
108
+ </div>`,e),{host:i,createGrid:n}=t,o=hi(2024),a=["Ireland","Spain","France","Germany","Italy","Portugal","Netherlands"],r=["Engineering","Design","Product","Sales","Support","Finance"],l=["Aiden","Bella","Caleb","Dana","Eli","Fiona","Gavin","Hana","Ivan","Julia"],c=["Anders","Bennett","Castillo","Duval","Ellis","Fischer","Grant","Hughes"],d=Array.from({length:5e4},(C,h)=>({id:h,name:`${l[h%l.length]} ${c[h*7%c.length]}`,country:a[h%a.length],department:r[h*3%r.length],salary:4e4+Math.floor(o()*8e4),rating:Math.floor(o()*6),started:`${2015+h%10}-0${1+h%9}-1${h%9}`})),u=120;function f(C){var S,A;let h=d.slice();const m=Object.entries(C.filterModel||{});if(m.length&&(h=h.filter(B=>m.every(([L,j])=>{const W=B[L],M=String(W).toLowerCase(),D=String(j.filter??"").toLowerCase();if(!D)return!0;switch(j.type){case"notEqual":return M!==D;case"startsWith":return M.startsWith(D);case"endsWith":return M.endsWith(D);default:return M.includes(D)}}))),(S=C.sortModel)!=null&&S.length){const{colId:B,sort:L}=C.sortModel[0];h=h.slice().sort((j,W)=>{const M=j[B]===W[B]?0:j[B]<W[B]?-1:1;return L==="asc"?M:-M})}const y=C.groupKeys||[],E=(A=C.rowGroupCols)==null?void 0:A[y.length];if(E){const B=h.filter(M=>y.every((D,k)=>{const z=C.rowGroupCols[k];return String(M[z.field])===D})),L=new Map,j=[];for(const M of B){const D=String(M[E.field]);L.has(D)||(L.set(D,{count:0,salary:[]}),j.push(D));const k=L.get(D);k.count++,k.salary.push(M.salary)}const W=j.map(M=>{const D=L.get(M),k={id:`group-${y.join("/")}-${E.field}-${M}`,__isGroup:!0,childCount:D.count};return k[E.field]=M,k.salary=Math.round(D.salary.reduce((z,_)=>z+_,0)/D.salary.length),k});return{rows:W,lastRow:W.length}}return{rows:h.slice(C.startRow,C.endRow),lastRow:h.length}}const g=[{field:"name",headerName:"Name",width:220,enableRowGroup:!0,filter:"text"},{field:"country",headerName:"Country",width:160,enableRowGroup:!0,filter:"text"},{field:"department",headerName:"Department",width:180,enableRowGroup:!0,filter:"text"},{field:"salary",headerName:"Avg Salary",width:160,aggFunc:"avg",type:"numberColumn",filter:"number"},{field:"rating",headerName:"Rating",width:120,type:"numberColumn",filter:"number"},{field:"started",headerName:"Started",width:140,filter:"text"}],{api:p}=n(i.querySelector("#serverSideGrid"),{columnDefs:g,rowData:[],rowModelType:"serverSide",serverSideDatasource:{getRows:C=>{t.timeout(()=>{const{rows:h,lastRow:m}=f(C);C.successCallback(h,m)},u)}},rowGroupPanelShow:"always",groupDefaultExpanded:-1,rowHeight:42,sideBar:{toolPanels:["columns","filters"],position:"right"},statusBar:{statusPanels:[{statusPanel:"agTotalRowCountComponent",align:"left"},{statusPanel:"agAggregationComponent",align:"right"}]},enableRangeSelection:!0,theme:"ag-theme-quartz"});return i.querySelector("#refresh").addEventListener("click",()=>{p.refreshServerSide({purge:!0})}),i.querySelector("#purge").addEventListener("click",()=>{p.purgeServerSideCache()}),t.handle}const ye=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},ea=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),gn=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function Ft(s){const e=document.createElement("template");e.innerHTML=String(s??"");const t=i=>{for(const n of[...i.childNodes]){if(n.nodeType!==1)continue;const o=n;if(["SCRIPT","STYLE","IFRAME","OBJECT","SVG","MATH"].includes(o.tagName)){o.remove();continue}if(t(o),!ea.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",r=o.hasAttribute("checked"),l=o.getAttribute("data-task")==="true",c=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(u=>[u,o.style.getPropertyValue(u)]),d=o.tagName==="FONT"?o.getAttribute("color"):null;for(const u of[...o.attributes])o.removeAttribute(u.name);for(const[u,f]of c)(u==="color"||u==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(f):u==="text-align"?/^(left|center|right|justify)$/.test(f):u==="margin-left"?/^\d{1,3}px$/.test(f):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(f))&&o.style.setProperty(u,f);d&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(d)&&(o.style.color=d),o.tagName==="A"&&gn(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),r&&o.setAttribute("checked","")),l&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const Ci={undo:'<path d="M9 5 4 10l5 5M4 10h10a6 6 0 0 1 0 12"/>',redo:'<path d="m15 5 5 5-5 5m5-5H10a6 6 0 0 0 0 12"/>',expand:'<path d="M14 3h7v7m0-7-7 7M10 21H3v-7m0 7 7-7"/>',collapse:'<path d="M21 3l-7 7m0-7v7h7M3 21l7-7m-7 0h7v7"/>',paint:'<path d="M3 3h14v7H3zM17 6h4v8h-9v7"/>',quote:'<path d="M4 12h5v7H2v-7l5-7m10 7h5v7h-7v-7l5-7"/>',table:'<rect x="3" y="3" width="18" height="18" rx="1"/><path d="M3 9h18M3 15h18M9 3v18M15 3v18"/>',link:'<path d="m10 14 4-4m-7 7-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0m2 10 5-5a4 4 0 0 0-6-6l-1 1"/>',task:'<rect x="3" y="3" width="18" height="18" rx="1"/><path d="m7 12 3 3 7-7"/>',indent:'<path d="M10 5h11M10 12h11M10 19h11M2 8l4 4-4 4"/>',line:'<path d="M3 12h18M3 5h3m3 0h3m3 0h3M3 19h3m3 0h3m3 0h3"/>'};function ta(s){const e=ye("div",`fc-rich${s.surface==="cell"?" fc-rich-compact":""}`),t=ye("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const i=ye("div","fc-rich-content");i.contentEditable=String(!s.readonly),i.setAttribute("role","textbox"),i.setAttribute("aria-multiline","true"),i.ariaLabel=s.field.label,i.tabIndex=s.readonly?-1:0,i.innerHTML=Ft(s.value);const n=ye("div","fc-rich-menu");n.hidden=!0;let o=null,a=!1,r=[i.innerHTML],l=0,c=!1,d=null;const u=()=>{const M=window.getSelection();M!=null&&M.rangeCount&&i.contains(M.anchorNode)&&i.contains(M.focusNode)&&(o=M.getRangeAt(0).cloneRange())},f=()=>{i.focus();const M=window.getSelection();if(!M)return;const D=o&&i.contains(o.commonAncestorContainer)?o:document.createRange();D!==o&&(D.selectNodeContents(i),D.collapse(!1)),M.removeAllRanges(),M.addRange(D),o=D},g=()=>{n.hidden=!0,n.replaceChildren()},p=new Map,C=()=>{var M;p.get("撤销").disabled=s.readonly||l===0,p.get("重做").disabled=s.readonly||l===r.length-1;for(const[D,k]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=p.get(D);if(!z)continue;const _=!!((M=document.queryCommandState)!=null&&M.call(document,k));z.classList.toggle("active",_),z.setAttribute("aria-pressed",String(_))}},h=()=>{c||(i.innerHTML!==r[l]&&(r=r.slice(0,l+1),r.push(i.innerHTML),r.length>100&&r.shift(),l=r.length-1),u(),C())},m=()=>{h(),i.dispatchEvent(new Event("change",{bubbles:!0}))},y=M=>{const D=l+M;D<0||D>=r.length||(l=D,c=!0,i.innerHTML=r[l],o=null,f(),c=!1,C(),i.dispatchEvent(new Event("change",{bubbles:!0})))},E=(M,D)=>{s.readonly||(f(),document.execCommand(M,!1,D),u(),g(),m())},R=M=>{if(s.readonly)return;f();const D=window.getSelection().getRangeAt(0);D.deleteContents(),D.insertNode(M),D.setStartAfter(M),D.collapse(!0),o=D.cloneRange(),g(),m()},S=(M,D,k,z=!0)=>{const _=ye("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return _.type="button",_.ariaLabel=M,_.title=M,_.disabled=s.readonly,Ci[D]?_.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Ci[D]}</svg>`:_.textContent=D,_.onmousedown=Q=>{Q.preventDefault(),u()},_.onclick=Q=>{Q.stopPropagation(),k()},t.append(_),p.set(M,_),_},A=(M,D)=>{if(u(),!n.hidden&&n.ariaLabel===M){g();return}n.replaceChildren(),n.className="fc-rich-menu",n.ariaLabel=M,D(),n.hidden=!1;const k=p.get(M);n.style.left=`${Math.max(4,Math.min(k.offsetLeft,e.clientWidth-280))}px`},B=(M,D)=>{const k=ye("button","fc-rich-menu-option",M);return k.type="button",k.onmousedown=z=>z.preventDefault(),k.onclick=z=>{z.stopPropagation(),D()},n.append(k),k};S("撤销","undo",()=>y(-1),!1),S("重做","redo",()=>y(1),!1),S("格式刷","paint",()=>{u();const M=o==null?void 0:o.startContainer,D=(M==null?void 0:M.nodeType)===1?M:M==null?void 0:M.parentElement;!D||!i.contains(D)||(d={tag:/^(B|STRONG|I|EM|U|S)$/.test(D.tagName)?D.tagName.toLowerCase():"span",css:D.getAttribute("style")||""},p.get("格式刷").classList.add("active"))}),S("正文样式","Aa⌄",()=>A("正文样式",()=>{for(const[M,D]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])B(M,()=>E("formatBlock",D))}));const L=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[M,D,k]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])S(M,D,()=>A(M,()=>{n.classList.add("fc-rich-colors");for(const z of L){const _=B(z,()=>E(k,z));_.textContent="",_.style.backgroundColor=z,_.ariaLabel=`${M} ${z}`}B("清除",()=>E(k,k==="foreColor"?"#1f2329":"transparent"))}));for(const[M,D,k]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])S(M,D,()=>E(k));S("对齐","☰⌄",()=>A("对齐",()=>{for(const[M,D]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])B(M,()=>E(D))})),S("有序列表","1≡",()=>E("insertOrderedList")),S("无序列表","•≡",()=>E("insertUnorderedList")),S("任务列表","task",()=>{f();const M=window.getSelection().getRangeAt(0),D=ye("ul"),k=ye("li");k.dataset.task="true";const z=ye("input");z.type="checkbox",z.contentEditable="false",k.append(z,M.extractContents()),k.textContent||k.append(document.createTextNode("待办事项")),D.append(k),R(D)}),S("引用","quote",()=>E("formatBlock","blockquote")),S("缩进","indent",()=>A("缩进",()=>{B("增加缩进",()=>E("indent")),B("减少缩进",()=>E("outdent"))})),S("分隔线","line",()=>R(ye("hr"))),S("表格","table",()=>A("表格",()=>{const M=ye("p","","选择行列"),D=ye("div","fc-rich-table-grid");n.append(M,D);for(let k=1;k<=6;k++)for(let z=1;z<=6;z++){const _=ye("button");_.type="button",_.ariaLabel=`${k}行${z}列表格`,_.dataset.row=String(k),_.dataset.col=String(z),_.onmousedown=Q=>Q.preventDefault(),_.onmouseenter=()=>{M.textContent=`${k} × ${z}`,D.querySelectorAll("button").forEach(Q=>Q.classList.toggle("active",Number(Q.dataset.row)<=k&&Number(Q.dataset.col)<=z))},_.onclick=()=>{const Q=ye("table"),ne=ye("tbody");for(let F=0;F<k;F++){const q=ye("tr");for(let Z=0;Z<z;Z++){const ie=ye("td");ie.append(ye("br")),q.append(ie)}ne.append(q)}Q.append(ne),R(Q);const U=document.createRange();U.selectNodeContents(Q.querySelector("td")),U.collapse(!0),o=U,f()},D.append(_)}}));const j=()=>A("链接",()=>{const M=ye("input","fc-input");M.ariaLabel="链接文本",M.placeholder="输入文本",M.value=(o==null?void 0:o.toString())||"";const D=ye("input","fc-input");D.ariaLabel="链接地址",D.placeholder="粘贴或输入超链接";const k=ye("div","fc-error"),z=ye("button","primary","确定");z.type="button",z.onclick=()=>{const _=D.value.trim();if(!gn(_)){k.textContent="请输入 http、https 或 mailto 链接";return}const Q=ye("a","",M.value||_);Q.href=_,Q.target="_blank",Q.rel="noopener noreferrer",R(Q)},n.append(ye("span","","文本"),M,ye("span","","链接"),D,k,z),M.focus()});S("链接","link",j),S("代码块","{ }",()=>E("formatBlock","pre")),S("表情","☺",()=>A("表情",()=>{n.classList.add("fc-rich-emojis");for(const M of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])B(M,()=>R(document.createTextNode(M)))}));const W=S("全屏编辑","expand",()=>{u(),a=!a,e.classList.toggle("is-fullscreen",a),g(),W.ariaLabel=W.title=a?"收起全屏":"全屏编辑",W.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${Ci[a?"collapse":"expand"]}</svg>`,f()},!1);return W.disabled=!1,W.classList.add("fc-rich-expand"),i.addEventListener("input",h),i.addEventListener("mouseup",()=>{if(u(),C(),d&&o&&!o.collapsed){const M=o,D=ye(d.tag);D.style.cssText=d.css,D.append(M.extractContents()),M.insertNode(D),d=null,p.get("格式刷").classList.remove("active"),m()}}),i.addEventListener("keyup",()=>{u(),C()}),i.addEventListener("click",M=>{const D=M.target;D.tagName==="A"&&M.preventDefault(),D instanceof HTMLInputElement&&D.type==="checkbox"&&(D.toggleAttribute("checked",D.checked),m()),g()}),i.addEventListener("drop",M=>M.preventDefault()),i.addEventListener("paste",M=>{var k,z;M.preventDefault(),u();const D=(k=M.clipboardData)==null?void 0:k.getData("text/html");if(D){const _=document.createElement("template");_.innerHTML=Ft(D);const Q=_.content,ne=document.createTextNode("");Q.append(ne),f();const U=window.getSelection().getRangeAt(0);U.deleteContents(),U.insertNode(Q),U.setStartAfter(ne),U.collapse(!0),o=U.cloneRange(),m()}else R(document.createTextNode(((z=M.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",M=>{M.key==="Escape"&&!n.hidden?(M.preventDefault(),M.stopPropagation(),g(),f()):M.key==="Escape"&&a?(M.preventDefault(),M.stopPropagation(),W.click()):(M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="z"?(M.preventDefault(),y(M.shiftKey?1:-1)):(M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="k"&&(M.preventDefault(),u(),j())}),e.append(t,i,n),C(),{element:e,read:()=>Ft(i.innerHTML),validate:()=>{var M;return s.field.required&&!((M=i.textContent)!=null&&M.trim())?"请填写内容":void 0},focus:()=>i.focus()}}const xe=(s,e,t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Pt=s=>String(s).padStart(2,"0"),wi=s=>`${s.getFullYear()}-${Pt(s.getMonth()+1)}-${Pt(s.getDate())}`;function Yt(s){if(!/^(\d{4})-(\d{2})-(\d{2})$/.exec(s))return!1;const t=new Date(`${s}T12:00:00`);return!Number.isNaN(t.getTime())&&wi(t)===s}const fn=s=>{var e,t;return{time:((e=s.field.dateOptions)==null?void 0:e.showTime)??s.field.kind!=="date",range:((t=s.field.dateOptions)==null?void 0:t.showRange)??!1}};function ia(s){const{time:e,range:t}=fn(s),n=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(o=>e?String(o).slice(0,16).replace("T"," "):String(o).slice(0,10)).join(" 至 ");return xe("div",`fc-value fc-${s.surface}${n?"":" fc-empty"}`,n||"待填")}function na(s){const{time:e,range:t}=fn(s),i=xe("div","fc-calendar"),n=Array.isArray(s.value)?s.value:[s.value],o=[0,1].map(U=>String(n[U]||"").slice(0,10)),a=[0,1].map(U=>String(n[U]||"").slice(11,16)||"00:00");let r=0,l=!1,c=Yt(o[0])?new Date(`${o[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const d=xe("div","fc-calendar-inputs"),u=[],f=()=>i.dispatchEvent(new Event("change",{bubbles:!0})),g=xe("div","fc-error");g.setAttribute("role","status");const p=()=>{if(o.some(U=>U&&!Yt(U)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!o[0])return"请选择日期";if(t&&!!o[0]!=!!o[1])return"请选择完整的日期范围";if(e&&a.slice(0,t?2:1).some(U=>!/^([01]\d|2[0-3]):[0-5]\d$/.test(U)))return"请输入有效时间";if(t&&o[0]&&`${o[0]}T${e?a[0]:""}`>`${o[1]}T${e?a[1]:""}`)return"结束日期时间不能早于开始日期时间"},C=()=>{g.textContent=p()||"",g.textContent||f()};for(let U=0;U<(t?2:1);U++){const F=xe("input","fc-input fc-calendar-date");F.type="text",F.value=o[U],F.placeholder=t?U?"结束日期":"开始日期":"YYYY-MM-DD",F.ariaLabel=t?F.placeholder:s.field.label,F.disabled=s.readonly,F.onfocus=()=>{if(r=U,l=U===1,Yt(o[U])){const q=new Date(`${o[U]}T12:00:00`);c=new Date(q.getFullYear(),q.getMonth(),1)}Q()},F.addEventListener("change",q=>{if(q.stopPropagation(),o[U]=F.value.trim(),Yt(o[U])){const Z=new Date(`${o[U]}T12:00:00`);c=new Date(Z.getFullYear(),Z.getMonth(),1)}Q(),C()}),d.append(F),u.push(F)}const h=xe("div","fc-calendar-header"),m=xe("button","fc-calendar-month");m.type="button",m.ariaLabel="选择年份和月份",m.setAttribute("aria-expanded","false"),m.setAttribute("aria-live","polite");const y=(U,F,q)=>{const Z=xe("button","fc-calendar-nav");return Z.type="button",Z.ariaLabel=U,Z.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${q?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,F>0&&Z.classList.add("next"),Z.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+F,1),Q()},Z};h.append(y("上一年",-12,!0),y("上个月",-1,!1),m,y("下个月",1,!1),y("下一年",12,!0));const E=xe("div","fc-calendar-weekdays");for(const U of["日","一","二","三","四","五","六"])E.append(xe("span","",U));const R=xe("div","fc-calendar-days");R.setAttribute("role","group"),R.ariaLabel="选择日期";const S=xe("div","fc-calendar-period");S.hidden=!0;const A=xe("button","fc-calendar-back","‹ 返回选择日期");A.type="button";const B=xe("div","fc-calendar-period-columns"),L=xe("div","fc-calendar-period-list");L.setAttribute("role","group"),L.ariaLabel="年份";const j=xe("div","fc-calendar-period-list");j.setAttribute("role","group"),j.ariaLabel="月份",B.append(L,j),S.append(A,B);let W="period",M=0;const D=[],k=(U=!1)=>{const F=a[M].split(":").map(Number),q=W==="period"?[[L,c.getFullYear(),"年"],[j,c.getMonth()+1,"月"]]:[[L,F[0],"时"],[j,F[1],"分"]];for(const[Z,ie,be]of q)for(const fe of Z.querySelectorAll("button")){const ue=Number(fe.dataset.value)===ie;fe.classList.toggle("selected",ue),fe.setAttribute("aria-pressed",String(ue)),fe.textContent=`${W==="time"?Pt(Number(fe.dataset.value)):fe.dataset.value}${ue?be:""}`,ue&&U&&(Z.scrollTop=Math.max(0,fe.offsetTop-108))}},z=(U,F)=>{const q=xe("button","fc-calendar-period-option",String(U));return q.type="button",q.dataset.value=String(U),q.ariaLabel=`${W==="time"?Pt(U):U}${W==="time"?F?"时":"分":F?"年":"月"}`,q.disabled=W==="time"&&s.readonly,q.onclick=()=>{if(W==="time"){const Z=a[M].split(":");Z[F?0:1]=Pt(U),a[M]=Z.join(":"),D[M].textContent=a[M],k(),C();return}c.setFullYear(F?U:c.getFullYear(),F?c.getMonth():U-1,1),k(),Q()},q},_=(U,F=0)=>{if(W=U,M=F,L.replaceChildren(),j.replaceChildren(),L.ariaLabel=U==="period"?"年份":"小时",j.ariaLabel=U==="period"?"月份":"分钟",U==="period"){for(let q=Math.max(1,c.getFullYear()-100);q<=Math.min(9999,c.getFullYear()+100);q++)L.append(z(q,!0));for(let q=1;q<=12;q++)j.append(z(q,!1))}else{for(let q=0;q<24;q++)L.append(z(q,!0));for(let q=0;q<60;q++)j.append(z(q,!1))}i.classList.add("choosing-period"),S.hidden=!1,(U==="period"?m:D[F]).setAttribute("aria-expanded","true"),k(!0),A.focus()};m.onclick=()=>_("period"),A.onclick=()=>{i.classList.remove("choosing-period"),S.hidden=!0;const U=W==="period"?m:D[M];U.setAttribute("aria-expanded","false"),Q(),U.focus()},S.addEventListener("keydown",U=>{if(U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),A.click()),!["ArrowUp","ArrowDown","Home","End"].includes(U.key))return;const F=U.target,q=F.closest(".fc-calendar-period-list");if(!q)return;const Z=[...q.querySelectorAll("button")],ie=Z.indexOf(F),be=U.key==="Home"?0:U.key==="End"?Z.length-1:Math.max(0,Math.min(Z.length-1,ie+(U.key==="ArrowDown"?1:-1)));U.preventDefault(),Z[be].focus()});function Q(){m.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((F,q)=>F.classList.toggle("active",q===r)),R.replaceChildren();for(let F=0;F<c.getDay();F++)R.append(xe("span","fc-calendar-blank"));const U=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let F=1;F<=U;F++){const q=wi(new Date(c.getFullYear(),c.getMonth(),F)),Z=xe("button","fc-calendar-day",String(F));Z.type="button",Z.ariaLabel=q,Z.disabled=s.readonly;const ie=o[0]===q||t&&o[1]===q;Z.classList.toggle("selected",ie),Z.setAttribute("aria-pressed",String(ie)),Z.classList.toggle("in-range",t&&!!o[0]&&!!o[1]&&q>o[0]&&q<o[1]),q===wi(new Date)&&(Z.classList.add("today"),Z.setAttribute("aria-current","date")),Z.onclick=()=>{var be;t?l?(o[1]=q,o[0]&&o[1]<o[0]&&([o[0],o[1]]=[o[1],o[0]]),r=0,l=!1):(o[0]=q,o[1]="",r=1,l=!0):o[0]=q,u.forEach((fe,ue)=>fe.value=o[ue]),Q(),!t||o[1]?C():g.textContent="",(be=R.querySelector(`[aria-label="${q}"]`))==null||be.focus()},R.append(Z)}}if(i.append(d,h,E,R,S),e){const U=xe("div","fc-calendar-time");for(let F=0;F<(t?2:1);F++){const q=xe("div","fc-calendar-time-field"),Z=t?F?"结束时间":"开始时间":"时间",ie=xe("button","fc-input fc-calendar-time-trigger",a[F]);ie.type="button",ie.disabled=s.readonly,ie.ariaLabel=Z,ie.setAttribute("aria-expanded","false"),ie.onclick=()=>_("time",F),D.push(ie),q.append(xe("span","",Z),ie),U.append(q)}i.append(U)}const ne=xe("button","fc-calendar-clear","清空");return ne.type="button",ne.disabled=s.readonly,ne.onclick=()=>{o.fill(""),u.forEach(U=>U.value=""),r=0,l=!1,Q(),C()},i.append(ne,g),Q(),{element:i,read:()=>{const U=o.slice(0,t?2:1).map((F,q)=>F?F+(e?`T${a[q]}`:""):"");return t?U.some(Boolean)?U:[]:U[0]},validate:p,focus:()=>u[0].focus()}}const Me=(s,e="",t)=>{const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i},Qt=s=>s==null?"":String(s);function yi(s){var t;const e=Me("div",`fc-value fc-${s.surface}`);return s.field.kind==="richText"||s.field.kind==="longText"?e.innerHTML=Ft(s.value):e.textContent=Qt(s.value).replace("T",s.field.kind==="dateTime"?" ":"T"),(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function bi(s,e){const t=Me("input","fc-input");return t.type=s,t.value=Qt(e.value),t.disabled=e.readonly,t.required=!!e.field.required,t.ariaLabel=e.field.label,t.placeholder=`请输入${e.field.label}`,s==="number"&&(t.step="any"),{element:t,read:()=>s==="number"?t.value===""?null:Number(t.value):t.value,validate:()=>t.checkValidity()?void 0:t.validationMessage||"请填写有效值",focus:()=>t.focus()}}const mn=["#dcf0d5","#d9eeec","#fce2ef","#e9e7fa","#fbe8d5"];function Si(s,e){var t;return((t=s.colors)==null?void 0:t[e])||mn[Math.max(0,(s.options||[]).indexOf(e))%mn.length]}function vn(s,e){const t=Me("div","fc-choice"),i=s&&Number.isInteger(e.field.maxSelections)&&e.field.maxSelections>0?e.field.maxSelections:1/0,n=Me("div","fc-error fc-choice-feedback");n.setAttribute("role","status");const o=Me("select","fc-select");o.hidden=!0,o.multiple=s,o.disabled=e.readonly,o.required=!!e.field.required,o.ariaLabel=e.field.label;const a=s?Array.isArray(e.value)?e.value.map(String):e.value?[String(e.value)]:[]:[Qt(e.value)],r=[...new Set([...e.field.options||[],...a.filter(Boolean)])];if(!s){const h=Me("option","","");h.value="",o.append(h)}for(const h of r){const m=Me("option","",h);m.value=h,m.selected=a.includes(h),o.append(m)}const l=Me("div","fc-choice-head"),c=Me("div","fc-choice-selection"),d=Me("input","fc-choice-search");d.placeholder="搜索",d.ariaLabel=`搜索${e.field.label}选项`,d.disabled=e.readonly;const u=Me("div","fc-option-list");u.setAttribute("role","group"),u.ariaLabel=e.field.label;const f=Me("p","fc-empty fc-choice-empty","暂无匹配选项"),g=()=>{const h=d.value.trim().toLocaleLowerCase();let m=0;for(const y of u.querySelectorAll("button"))y.hidden=!y.dataset.value.toLocaleLowerCase().includes(h),y.hidden||m++;f.hidden=m>0},p=()=>{n.textContent="",c.replaceChildren();for(const h of[...o.selectedOptions].filter(m=>m.value)){const m=Me("span","fc-tag",h.text);m.style.backgroundColor=Si(e.field,h.value);const y=Me("button","fc-choice-remove","×");y.type="button",y.ariaLabel=`移除${h.text}`,y.disabled=e.readonly,y.onclick=E=>{E.stopPropagation(),h.selected=!1,p(),o.dispatchEvent(new Event("change",{bubbles:!0}))},m.append(y),c.append(m)}for(const h of u.querySelectorAll("button")){const m=[...o.selectedOptions].some(y=>y.value===h.dataset.value);h.classList.toggle("selected",m),h.setAttribute("aria-pressed",String(m)),h.querySelector(".fc-option-mark").textContent=m?"✓":""}};for(const h of[...o.options].filter(m=>m.value)){const m=Me("button","fc-option");m.type="button",m.disabled=e.readonly,m.dataset.value=h.value;const y=Me("span","fc-option-mark");y.setAttribute("aria-hidden","true");const E=Me("span","fc-option-label fc-tag",h.text);E.style.backgroundColor=Si(e.field,h.value),m.append(E,y),m.onclick=R=>{if(R.stopPropagation(),s&&!h.selected&&o.selectedOptions.length>=i){n.textContent=`最多可选择 ${i} 项,无法继续选择`;return}s?h.selected=!h.selected:o.value=h.value,p(),o.dispatchEvent(new Event("change",{bubbles:!0}))},u.append(m)}const C=h=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(h.key))return;const m=[...u.querySelectorAll("button:not(:disabled):not([hidden])")];if(!m.length)return;h.preventDefault();const y=m.indexOf(document.activeElement),E=h.key==="Home"?0:h.key==="End"?m.length-1:(y+(h.key==="ArrowDown"?1:-1)+m.length)%m.length;m[E].focus()};return u.addEventListener("keydown",C),d.addEventListener("keydown",h=>{h.key==="ArrowDown"&&C(h)}),d.addEventListener("input",g),o.addEventListener("change",p),l.append(c,d),u.append(f),t.append(o,l,u,n),p(),g(),{element:t,read:()=>s?[...o.selectedOptions].map(h=>h.value):o.value,validate:()=>o.selectedOptions.length>i?`最多可选择 ${i} 项`:e.field.required&&![...o.selectedOptions].some(h=>h.value)?"请选择一个选项":void 0,focus:()=>d.focus()}}function Cn(s){const e=Me("div","fc-tags"),t=Array.isArray(s.value)?s.value:[s.value];for(const i of t.filter(n=>n!==""&&n!=null)){const n=Me("span","fc-tag",String(i));n.style.backgroundColor=Si(s.field,String(i)),e.append(n)}return e.children.length||e.append(Me("span","fc-empty","待填")),e}function wn(s=[]){const e=new Map,t=o=>{if(!/^[A-Za-z][\w-]*$/.test(o.id))throw new Error("Invalid control id");if(e.has(o.id))throw new Error(`Control already registered: ${o.id}`);e.set(o.id,o)};[{id:"text",label:"单行文本",glyph:"T",description:"单行输入,支持清空和必填校验",render:yi,createEditor:o=>bi("text",o)},{id:"richText",label:"富文本",glyph:"¶",description:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",render:yi,createEditor:ta},{id:"select",label:"单选",glyph:"◉",action:"select",description:"从字段配置中选择一个选项",render:Cn,createEditor:o=>vn(!1,o)},{id:"multiSelect",label:"多选",glyph:"☑",action:"select",description:"点击标签选择多项,保存为数组",render:Cn,createEditor:o=>vn(!0,o)},{id:"number",label:"数字",glyph:"#",description:"支持小数和负数,空值与零分别保存",render:yi,createEditor:o=>bi("number",o)},{id:"dateTime",label:"日期时间",glyph:"◷",description:"精简日历,可配置时间和日期范围",render:ia,createEditor:na},{id:"detail",label:"详情页查看",glyph:"↗",action:"view",description:"点击进入当前或关联工作项详情",render:o=>{const a=Me("button","fc-detail-link","查看详情 ↗");return a.type="button",a.onclick=r=>{r.stopPropagation(),o.openDetail(Qt(o.value)||o.item.id)},a},createEditor:o=>bi("text",{...o,field:{...o.field,label:"关联工作项 ID(留空查看当前项)"}})}].forEach(t),s.forEach(t);const n={title:"text",longText:"richText",status:"select",person:"select",relation:"text",vote:"text",date:"dateTime"};return{register:t,list:()=>[...e.values()],resolve:o=>{const a=o.control||n[o.kind||"text"]||o.kind||"text",r=e.get(a);if(!r)throw new Error(`Unknown control: ${a}`);return r}}}const oa=[["name","选题概要"],["description","选题描述"],["vote","选题投票"],["showVotes","是否展示投票结果"],["status","状态"],["selectedTopic","确定入选"],["format","内容形式"],["approved","选题是否通过"],["category","主题分类"],["owner","当前负责人"],["space","所属空间"],["created","创建时间"],["creator","创建者"]],sa={status:["入库","进入选题会","选题通过","废弃","已终止"],category:["产品相关","干货洞察","解决方案","客户案例"],format:["图文","视频","图文+视频"],approved:["是","待定","废弃"],showVotes:["是","否"],owner:["体验官"],creator:["体验官"],space:["内容制作全流程"]},yn=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1}),aa="rowvia:work-items:v2",la=["上班族月入过万副业案例集","城市咖啡地图探店","咖啡师教你在家做出咖啡厅品质","咖啡因含量实测排行榜","咖啡器具入门避坑指南","智能设备不联网真相:离线后还能用吗?","扫地机器人避坑指南:3000元vs5000元差在哪?","智能门锁必看!这5个功能千万别花冤枉钱","智能音箱大对比:某爱/某猫精灵/某度真实使用30天"],ra=["","特色独立咖啡馆推荐","器具和技巧分享","提神效果科学对比","新手该买什么设备","实测各类设备断网后的功能保留情况,避免被云端绑架","实测清扫能力、避障算法、噪音控制,告诉你钱该花在哪","揭秘过度营销的功能(如虹膜识别、人脸识别等),哪些真正实用",""],ca=["7105330334","7105330319","7105330315","7105330312","7105330311","7105330309","7105330300","7105330281","7105330263"],Jt=la.map((s,e)=>({id:ca[e],name:s,description:ra[e],vote:"",showVotes:"",status:e===0||e===4?"废弃":e===8?"进入选题会":"入库",selectedTopic:e===3?"10款平价咖…":e===8?"智能家居避…":"",format:e===0?"图文":e===8?"":"图文+视频",approved:e===0||e===4?"废弃":e===3?"是":"",category:e===0?"干货洞察":e===8?"":"产品相关",owner:"体验官",space:"内容制作全流程",created:"2026-09-03",creator:"体验官",source:e===0?"真实收入拆解":"",followed:!1,starred:!1,viewed:!1,comments:[],history:[]}));function bn(s,e){return e.every(t=>{const i=String(s[t.field]??"").toLocaleLowerCase(),n=t.value.toLocaleLowerCase();switch(t.operator){case"equals":return i===n;case"notEqual":return i!==n;case"blank":return!i;case"notBlank":return!!i;default:return i.includes(n)}})}function Sn(s=aa,e=Jt){try{const t=JSON.parse(localStorage.getItem(s)||"null");if(t&&Array.isArray(t.items)&&t.items.every(i=>i&&typeof i.id=="string"&&typeof i.name=="string"))return{items:t.items,views:Array.isArray(t.views)?t.views:[],drafts:t.drafts||[],customFields:Array.isArray(t.customFields)?t.customFields:[]}}catch{}return{items:structuredClone(e),views:[],drafts:[],customFields:[]}}const xn={pencil:'<path d="m15 3 6 6-12 12H3v-6ZM13 5l6 6"/>',transition:'<path d="M4 8h14l-4-4m4 4-4 4M20 16H6l4-4m-4 4 4 4"/>',expand:'<path d="M15 3h6v6m0-6-7 7M9 21H3v-6m0 6 7-7"/>',check:'<circle cx="12" cy="12" r="8"/><path d="m8 12 3 3 5-6"/>',plus:'<circle cx="12" cy="12" r="9"/><path d="M12 7v10M7 12h10"/>',add:'<path d="M12 4v16M4 12h16"/>',close:'<path d="m6 6 12 12M6 18 18 6"/>',filter:'<path d="M3 4h18l-7 8v7l-4 2v-9Z"/>',sort:'<path d="M4 5h16M4 11h11M4 17h6"/>',group:'<path d="m3 13 10-10h8v8L11 21Z"/><circle cx="17" cy="7" r="1"/>',color:'<path d="m10 3 10 10-8 8L2 11Z M4 13h14M10 3 7 0"/><path d="M21 17q4 5 0 5q-4 0 0-5"/>',search:'<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6M2 3h5M2 9h2M2 16h5"/>',save:'<path d="M4 3h13l4 4v14H3V3h1ZM8 3v7h8V3M7 21v-7h10v7"/>',down:'<path d="m6 9 6 6 6-6"/>',up:'<path d="m6 15 6-6 6 6"/>',link:'<path d="m10 14 4-4M8 16l-1 1a4 4 0 0 1-6-6l5-5a4 4 0 0 1 6 0M16 8l1-1a4 4 0 0 1 6 6l-5 5a4 4 0 0 1-6 0"/>',edit:'<rect x="3" y="3" width="7" height="7" rx="1"/><rect x="14" y="3" width="7" height="7" rx="1"/><rect x="3" y="14" width="7" height="7" rx="1"/><path d="M14 17h8m-4-4v8"/>',book:'<path d="M6 3h12v18l-6-4-6 4Z"/>',people:'<circle cx="9" cy="8" r="3"/><path d="M3 21v-3a6 6 0 0 1 12 0v3ZM17 4a3 3 0 0 1 0 6M18 14q4 1 4 7"/>',table:'<rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M3 14h18M9 9v11M15 9v11"/>',chart:'<circle cx="12" cy="12" r="9"/><path d="M12 3v9h9"/>',menu:'<path d="M4 6h16M4 12h12M4 18h16"/>',more:'<circle cx="5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="19" cy="12" r="1"/>',inbox:'<path d="m5 4-3 10v6h20v-6L19 4ZM2 14h6l2 3h4l2-3h6"/>'},Re=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${xn[s]||xn.check}</svg>`,ae=s=>String(s??"").replace(/[&<>"']/g,e=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[e]),se=(s,e,t="",i="")=>`<button type="button" data-action="${s}" class="${i}" aria-label="${ae(e)}">${t?Re(t):""}${e?`<span>${ae(e)}</span>`:""}</button>`;function da(s){s={...s,fields:s.fields.map(w=>({...w}))},s.container.classList.add("rowvia-work-items");const e=wn(s.controls);let t=[],i=null,n=null,o=null;const a=new Set(s.fields.map(w=>w.key));if(a.size!==s.fields.length)throw new Error("Field keys must be unique");if(!a.has("name"))throw new Error("A name field is required for the work-item title");for(const w of[s.createForm,s.detailForm])for(const b of w.fields)if(!a.has(b.field))throw new Error(`Unknown form field: ${b.field}`);const r=new AbortController;let l=!1;const c=Sn(s.storageKey,s.items).customFields;for(const w of c)s.fields.some(b=>b.key===w.key)||s.fields.push(w);const d=s.fields.map(w=>[w.key,w.label]),u=w=>s.fields.find(b=>b.key===w),f=Object.fromEntries(s.fields.filter(w=>w.options).map(w=>[w.key,w.options])),g=s.storageKey,p=(w,b=s.container)=>b.querySelector(`:scope ${w}`),C=Sn(g,s.items);for(const w of C.items)w.comments??(w.comments=[]),w.history??(w.history=[]),w.roles??(w.roles=[]),w.meetings??(w.meetings=[]);let h=yn(),m="全部",y="",E=!1,R=0,S=null,A=null,B=null,L=null,j=null,W="基本信息",M=0,D=0,k="",z=[];s.container.innerHTML=`<section class="content">
109
+ <div class="work-page"><section class="list-area"><div class="list-tabs" role="tablist">${["全部","最近浏览","我创建的","我参与的","我关注的","我收藏的"].map((w,b)=>`<button class="list-tab ${b===0?"active":""}" role="tab" aria-selected="${b===0}" data-tab="${w}">${w}</button>`).join("")}<div class="create-button">${se("create","新建","plus","primary")}${se("create-menu","","down","primary")}</div></div>
110
+ <div class="toolbar">${se("filter","筛选","filter")}${se("sort","排序","sort")}${se("group","分组","group")}${se("color","设置颜色","color")}<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${se("previous-match","","up")}${se("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${se("close-search","","close")}</div>${se("search","查找","search")}<div class="right">${se("reset","重置","","hidden")}${se("controls","控件管理","edit")}${se("saved-views","切换视图","down")}${se("save-view","存为视图","save","outline")}</div></div><div class="selection-bar hidden"></div><div class="grid-wrap"><div id="grid"></div></div></section></div></section>`;function _(w,b){var I,O;if(!w)return'<span class="placeholder">暂无</span>';let x=b==="status"?w==="废弃"||w==="选题通过"?"green":w==="进入选题会"?"cyan":"":b==="category"?w==="干货洞察"?"teal":"green":b==="format"&&w==="图文"?"purple":"pink";const T=(O=(I=u(b))==null?void 0:I.colors)==null?void 0:O[w];return`<span class="tag ${x}" ${T?`style="background:${ae(T)}"`:""}>${ae(w)}</span>`}const Q=w=>w?`<span class="person"><span class="avatar">体验官</span>${ae(w)}</span>`:'<span class="placeholder">暂无</span>';function ne(w){if(w.node.group)return"";const b=w.data,x=w.colDef.field,T=document.createElement("div");T.className="rendered-cell";const I=u(x);if(I&&(I.control||!["title","vote","status","person","relation"].includes(I.kind||"text")))T.append(e.resolve(I).render(ze(I,b,"cell")));else if((I==null?void 0:I.kind)==="title"){const O=document.createElement("a");O.className="item-name",O.href=`#item/${b.id}`,O.textContent=b[x],O.title=b[x],O.addEventListener("click",H=>{H.preventDefault(),clearTimeout(D),H.detail===0?Le(b):H.detail===1&&(D=window.setTimeout(()=>Le(b),280))}),T.append(O);const $=document.createElement("button");$.className="inline-edit",$.innerHTML=Re("pencil"),$.ariaLabel="编辑选题概要",$.onclick=H=>{H.stopPropagation(),Ue(T,x,b,w.rowIndex)},(I==null?void 0:I.editable)!==!1&&T.append($)}else(I==null?void 0:I.kind)==="vote"?(T.innerHTML=`<button class="vote ${b.vote?"voted":""}" aria-label="${b.vote?"取消投票":"投票"}">${Re("plus")}${b.vote?"1":"投票"}</button>`,p("button",T).onclick=O=>{O.stopPropagation(),be(b,"vote",b.vote?"":"体验官")}):(I==null?void 0:I.kind)==="person"?(T.innerHTML=Q(b[x]),I.editable!==!1&&(T.onclick=()=>Ue(T,x,b,w.rowIndex))):(I==null?void 0:I.kind)==="status"?(T.innerHTML=`${_(b.status,x)}<span class="status-days">20 天</span>`,(I==null?void 0:I.editable)!==!1&&(T.onclick=O=>{O.stopPropagation(),Ue(T,x,b,w.rowIndex)})):(I==null?void 0:I.kind)==="relation"?(T.innerHTML=b[x]?`<button class="relation-tag ${b.id==="7105330263"?"pink":""}" title="${ae(b[x])}">${ae(b[x])}</button>`:'<span class="placeholder">暂无</span>',(I==null?void 0:I.editable)!==!1&&(T.onclick=()=>Ue(T,x,b,w.rowIndex))):(I==null?void 0:I.kind)==="multiSelect"?T.innerHTML=(Array.isArray(b[x])?b[x]:[]).map(O=>_(O,x)).join("")||'<span class="placeholder">暂无</span>':f[x]?(T.innerHTML=["creator","owner","space"].includes(x)?ae(b[x]):_(b[x],x),(I==null?void 0:I.editable)!==!1&&(T.onclick=O=>{O.stopPropagation(),Ue(T,x,b,w.rowIndex)})):(T.innerHTML=`<span class="cell-text">${ae(b[x]||"暂无")}</span>`,b[x]||T.classList.add("placeholder"));if(I&&I.editable!==!1&&I.kind!=="vote"&&I.kind!=="title"){const O=document.createElement("button");O.className="inline-edit field-control",O.ariaLabel=`${I.kind==="status"?"流转":"编辑"}${I.label}`,O.innerHTML=Re(I.kind==="status"?"transition":["select","multiSelect","person"].includes(I.kind||"")?"down":"pencil"),O.onclick=$=>{$.stopPropagation(),Ue(T,x,b,w.rowIndex)},T.append(O)}return T.title=String(b[x]??""),T}function U(){return[{colId:"_select",headerName:"",width:64,minWidth:64,maxWidth:64,pinned:"left",sortable:!1,resizable:!1,suppressMovable:!0,suppressMenu:!0,checkboxSelection:!0,headerCheckboxSelection:!0,rowDrag:!0,cellRenderer:w=>{if(w.node.group)return"";const b=document.createElement("div");return b.className="row-controls",b.innerHTML=`<span class="row-number">${w.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${w.rowIndex+1} 行" ${w.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${Re("expand")}</button>`,p("input",b).onclick=x=>x.stopPropagation(),p("input",b).onchange=x=>w.node.setSelected(x.target.checked),p("button",b).onclick=x=>{x.stopPropagation(),Le(w.data)},b}},...s.fields.map(w=>({field:w.key,headerName:w.label,width:w.width??120,minWidth:w.minWidth??80,pinned:w.pinned,hide:w.hidden,enableRowGroup:!0,editable:!1,valueSetter:b=>w.required&&!String(b.newValue??"").trim()?!1:(b.data[w.key]=b.newValue,!0),comparator:w.options?(b,x)=>w.options.indexOf(b)-w.options.indexOf(x):void 0,sortable:!1,suppressMenu:!0,cellRenderer:ne,cellStyle:({data:b})=>{const x=b&&h.colors.find(T=>!!T.scope&&T.scope!=="row"&&T.field===w.key&&Ce(b,T));return x?{backgroundColor:x.color}:{}},tooltipField:w.key,cellClass:w.kind==="title"?"name-cell":void 0,...w.column})),...z,{colId:"_add",suppressMovable:!0,headerName:"+",width:60,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}const F=xi(p("#grid"),{columnDefs:U(),rowData:C.items,getRowId:({data:w})=>w.id,rowHeight:37,headerHeight:32,theme:"ag-theme-quartz",rowSelection:"multiple",defaultColDef:{resizable:!0,sortable:!1,filter:!1},suppressRowClickSelection:!0,groupDefaultExpanded:-1,autoGroupColumnDef:{headerName:"分组",width:180,pinned:"left"},suppressContextMenu:!0,enableRangeSelection:!1,undoRedoCellEditing:!0,stopEditingWhenCellsLoseFocus:!0,getRowStyle:({data:w})=>{const b=h.colors.find(x=>w&&(!x.scope||x.scope==="row")&&Ce(w,x));return b?{backgroundColor:b.color}:{}},onCellValueChanged:w=>{w.data.history.push(`更新${w.colDef.headerName}:${w.newValue}`),q(),queueMicrotask(()=>{l||ie()})},onSelectionChanged:()=>{oe(),F.api.refreshCells({force:!0})},onRowGroupOpened:()=>J(),localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"}});F.grid.getEventService().addEventListener("rowDragEnd",w=>{if(!w.overNode||w.overNode.group||w.node.id===w.overNode.id)return;const b=C.items.findIndex(I=>I.id===w.node.id),x=C.items.findIndex(I=>I.id===w.overNode.id);if(b<0||x<0)return;const[T]=C.items.splice(b,1);C.items.splice(x,0,T),h.sorts=[],q(),ie()}),F.grid.getEventService().addEventListener("columnHeaderClicked",w=>{w.column.colId==="_add"&&xt(p('.ag-header-cell[data-colid="_add"]'),"_add",!1)});function q(){var w;(w=s.onDataChange)==null||w.call(s,structuredClone(C.items));try{localStorage.setItem(g,JSON.stringify(C))}catch{fe("浏览器存储不可用,本次修改仅在当前页面保留")}}function Z(){return C.items.filter(w=>(h.showTerminated||w.status!=="已终止")&&bn(w,h.filters)&&(m!=="最近浏览"||w.viewed)&&(m!=="我关注的"||w.followed)&&(m!=="我收藏的"||w.starred)&&(m!=="我参与的"||w.owner===s.currentUser)&&(m!=="我创建的"||w.creator===s.currentUser)&&(!E||!y||w.name.toLowerCase().includes(y.toLowerCase())))}function ie(){o==null||o(),F.api.setRowData(Z()),F.api.setSortModel(h.sorts),F.columnApi.setRowGroupColumns(h.groups),F.api.redrawRows(),at();for(const[w,b]of[["filter",h.filters.length],["sort",h.sorts.length],["group",h.groups.length],["color",h.colors.length]]){const x=p(`[data-action="${w}"]`);x.classList.toggle("is-set",!!b);const T={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};p("span",x).textContent=T[w]+(b?` · ${b}`:"")}p('[data-action="reset"]').classList.toggle("hidden",!h.filters.length&&!h.sorts.length&&!h.groups.length&&!h.colors.length),oe(),Y(),J()}function be(w,b,x){var T;w[b]=x,w.history.push(`更新${((T=d.find(([I])=>I===b))==null?void 0:T[1])||b}:${String(x)}`),q(),ie()}function fe(w){var x;(x=p(".toast"))==null||x.remove(),clearTimeout(M);const b=document.createElement("div");b.className="toast",b.setAttribute("role","status"),b.innerHTML=Re("check")+ae(w),s.container.append(b),M=window.setTimeout(()=>b.remove(),2500)}function ue(w=!0){var b;w&&n&&!n()||(n=null,(b=i==null?void 0:i.destroy)==null||b.call(i),i=null,S==null||S.remove(),S=null,k="")}function Ne(w,b,x,T=460,I=""){ue(),S=document.createElement("section"),S.className=`popup ${I}`,S.setAttribute("role","dialog"),S.ariaLabel=b||"列操作",S.style.width=`${T}px`,S.innerHTML=`${b?`<div class="popup-head"><span>${ae(b)}</span>${se("close-popup","","close")}</div>`:""}${x}`,s.container.append(S);const O=w.getBoundingClientRect();return S.style.left=`${Math.max(12,Math.min(O.left,innerWidth-T-16))}px`,S.style.top=`${Math.min(O.bottom+8,Math.max(12,innerHeight-S.offsetHeight-16))}px`,S}function dt(w,b,x=""){return`<select ${x}>${w.map(([T,I])=>`<option value="${ae(T)}" ${T===b?"selected":""}>${ae(I)}</option>`).join("")}</select>`}function Zt(w,b,x){const T=Ne(w,d.find(([O])=>O===b)[1],'<input class="value-search" placeholder="搜索" aria-label="搜索选项"><div class="value-options"></div>',240),I=(O="")=>{p(".value-options",T).innerHTML=[...f[b]||[]].filter($=>$.includes(O)).map($=>`<button class="menu-option" data-value="${ae($)}">${_($,b)}<span class="spacer"></span>${(Array.isArray(x[b])?x[b].includes($):x[b]===$)?"✓":""}</button>`).join("")+'<button class="menu-option" data-value="">清空</button>'};I(),p("input",T).oninput=O=>I(O.target.value),T.onclick=O=>{var H;const $=O.target.closest("[data-value]");if($)if(O.stopPropagation(),((H=u(b))==null?void 0:H.kind)==="multiSelect"){const N=$.dataset.value,P=Array.isArray(x[b])?x[b]:[];be(x,b,N?P.includes(N)?P.filter(G=>G!==N):[...P,N]:[]),I(p("input",T).value)}else be(x,b,$.dataset.value),ue()}}function ut(w,b){const x=document.createElement("div");x.className="field-picker",x.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(O=>`<button data-kind="${O}">${O}</button>`).join("")}</div><div class="field-options"></div>`,s.container.append(x);const T=w.getBoundingClientRect();x.style.left=`${Math.min(T.left,innerWidth-410)}px`,x.style.top=`${Math.min(T.bottom+4,innerHeight-340)}px`;const I=(O="推荐",$="")=>{p(".field-options",x).innerHTML=d.filter(([H,N])=>{var P,G,V,ee,le,te;return N.includes($)&&(O==="推荐"||O==="文本"&&["title","text","longText"].includes(((P=u(H))==null?void 0:P.kind)||"text")||O==="选择"&&["status","select"].includes(((G=u(H))==null?void 0:G.kind)||"")||O==="人员"&&((V=u(H))==null?void 0:V.kind)==="person"||O==="时间"&&((ee=u(H))==null?void 0:ee.kind)==="date"||O==="关系"&&((le=u(H))==null?void 0:le.kind)==="relation"||O==="其他"&&((te=u(H))==null?void 0:te.kind)==="vote")}).map(([H,N])=>`<button data-field="${ae(H)}" class="menu-option">${Re("table")}${ae(N)}</button>`).join("")};I(),p("input",x).oninput=O=>I("推荐",O.target.value),x.onclick=O=>{const $=O.target.closest("button");$!=null&&$.dataset.kind&&I($.dataset.kind),$!=null&&$.dataset.field&&(x.remove(),b($.dataset.field))}}function Ce(w,b){return!!b.field&&(!!b.value||["blank","notBlank"].includes(b.operator))&&bn(w,[b])}function K(w){const b=h.colors.map((P,G)=>{var he;const V=(he=u(P.field))==null?void 0:he.label,ee=P.field?[["contains",f[P.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],le=!P.field||["blank","notBlank"].includes(P.operator),te=f[P.field]?dt([["","请选择目标值"],...f[P.field].map(ve=>[ve,ve])],P.value,`data-rule-value="${G}" aria-label="目标值" ${le?"disabled":""}`):`<input data-rule-value="${G}" aria-label="目标值" placeholder="请选择目标值" value="${ae(P.value)}" ${le?"disabled":""}>`;return`<div class="color-condition" data-color-row="${G}">
111
+ <button class="color-drag" draggable="true" title="拖动调整条件优先级" aria-label="拖动条件">⠿</button>
112
+ <button type="button" class="color-swatch" data-color="${G}" style="background-color:${ae(P.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
113
+ <button type="button" class="field-select" data-color-scope="${G}" aria-label="着色范围" aria-expanded="false">${!P.scope||P.scope==="row"?"整行":"单元格"}${Re("down")}</button>
114
+ <button class="field-select ${V?"":"empty"}" data-pick="${G}">${ae(V||"请选择筛选项")}${Re("down")}</button>
115
+ ${dt(ee,P.field?P.operator:"",`data-operator="${G}" aria-label="运算符" ${P.field?"":"disabled"}`)}
116
+ ${te}
117
+ <button class="color-remove" data-remove="${G}" aria-label="删除条件" title="删除条件">${Re("close")}</button>
118
+ <div class="color-more-wrap"><button class="color-more" data-color-more="${G}" aria-label="更多条件操作" aria-expanded="false">${Re("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${G}">复制条件</button><button data-color-up="${G}" ${G===0?"disabled":""}>上移</button><button data-color-down="${G}" ${G===h.colors.length-1?"disabled":""}>下移</button></div></div>
119
+ </div>`}).join(""),x=Ne(w,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${b}</div><div class="color-panel-footer"><button class="add-condition">${Re("plus")}添加着色条件</button><button class="clear-rules" ${h.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");x.ariaLabel="设置颜色条件",k="color";const T=()=>K(w),I=()=>{ie(),T()},O=["#ffe5e5","#ffe7d4","#f9e8d2","#fff5d6","#ecf3d3","#daf2d5","#d6f1ec","#d4efff","#e4eaff","#ebe9fe","#f2e8ff","#f7e4fb","#ffe3f2","#ffc8c8","#ffceaa","#f3d3a4","#ffeaa5","#d9e8a7","#b6e4af","#ace4db","#acdffc","#c9d8ff","#d7d5fb","#e3d0ff","#efc9f5","#fbc5e7"],$=()=>{var P;(P=x.querySelector(".color-palette"))==null||P.remove(),x.querySelectorAll("[data-color]").forEach(G=>G.setAttribute("aria-expanded","false"))},H=()=>{var P,G;(P=x.querySelector(".color-scope-picker"))==null||P.remove(),(G=i==null?void 0:i.destroy)==null||G.call(i),i=null,x.querySelectorAll("[data-color-scope]").forEach(V=>V.setAttribute("aria-expanded","false"))};let N=-1;x.querySelectorAll(".color-condition").forEach((P,G)=>{P.ondragstart=V=>{var ee;N=G,(ee=V.dataTransfer)==null||ee.setData("text/plain",String(G))},P.ondragover=V=>V.preventDefault(),P.ondrop=V=>{if(V.preventDefault(),N<0||N===G)return;const[ee]=h.colors.splice(N,1);h.colors.splice(G,0,ee),I()}}),x.onclick=P=>{var ee,le;P.stopPropagation();const G=P.target.closest("button");if(P.target.closest(".color-scope-picker"))return;const V=(G==null?void 0:G.getAttribute("aria-expanded"))==="true";if(H(),!G||G.disabled){$();return}if(G.dataset.colorScope!==void 0){if($(),V)return;const te=Number(G.dataset.colorScope),he=h.colors[te],ve={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},Ie=e.resolve(ve).createEditor({field:ve,value:!he.scope||he.scope==="row"?"整行":"单元格",item:We(),surface:"cell",readonly:!1,openDetail:()=>{}});i=Ie;const ge=document.createElement("div");ge.className="popup fc-popup fc-choice-popup color-scope-picker",ge.style.width="272px",ge.append(Ie.element),x.append(ge);const et=G.getBoundingClientRect();ge.style.left=`${Math.max(8,Math.min(et.left,innerWidth-280))}px`,ge.style.top=`${Math.max(8,Math.min(et.bottom+6,innerHeight-ge.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),Ie.element.addEventListener("change",Ye=>{var In,Ln;Ye.stopPropagation(),!((In=Ie.validate)!=null&&In.call(Ie))&&(he.scope=Ie.read()==="整行"?"row":"cell",I(),(Ln=S==null?void 0:S.querySelector(`[data-color-scope="${te}"]`))==null||Ln.focus())}),ge.onkeydown=Ye=>{Ye.key==="Escape"&&(Ye.stopPropagation(),H(),G.focus())},(ee=Ie.focus)==null||ee.call(Ie);return}if(G.dataset.paletteColor!==void 0){const te=Number(G.closest(".color-palette").dataset.ruleIndex);h.colors[te].color=G.dataset.paletteColor,I(),(le=S==null?void 0:S.querySelector(`[data-color="${te}"]`))==null||le.focus();return}if(G.dataset.color!==void 0){const te=G.getAttribute("aria-expanded")==="true";if($(),te)return;const he=Number(G.dataset.color),ve=document.createElement("div");ve.className="color-palette",ve.dataset.ruleIndex=String(he),ve.setAttribute("role","group"),ve.ariaLabel="选择着色颜色",ve.innerHTML=O.map(ge=>`<button type="button" class="color-palette-option" data-palette-color="${ge}" style="background-color:${ge}" aria-label="颜色 ${ge}" aria-pressed="${ge===h.colors[he].color.toLowerCase()}"></button>`).join(""),x.append(ve);const Ie=G.getBoundingClientRect();ve.style.left=`${Math.max(8,Math.min(Ie.left,innerWidth-ve.offsetWidth-8))}px`,ve.style.top=`${Math.max(8,Math.min(Ie.bottom+6,innerHeight-ve.offsetHeight-8))}px`,G.setAttribute("aria-expanded","true"),ve.onkeydown=ge=>{ge.key==="Escape"&&(ge.stopPropagation(),$(),G.focus())};return}if($(),G.classList.contains("add-condition"))h.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),I();else if(G.dataset.pick!==void 0){const te=+G.dataset.pick;ut(G,he=>{h.colors[te].field=he,h.colors[te].value="",h.colors[te].operator="contains",I()})}else if(G.dataset.remove!==void 0)h.colors.splice(+G.dataset.remove,1),I();else if(G.classList.contains("clear-rules"))h.colors=[],I();else if(G.dataset.colorMore!==void 0){const te=G.nextElementSibling,he=te.classList.contains("hidden");x.querySelectorAll(".color-rule-menu").forEach(ve=>ve.classList.add("hidden")),x.querySelectorAll("[data-color-more]").forEach(ve=>ve.setAttribute("aria-expanded","false")),te.classList.toggle("hidden",!he),G.setAttribute("aria-expanded",String(he))}else if(G.dataset.colorCopy!==void 0){const te=+G.dataset.colorCopy;h.colors.splice(te+1,0,structuredClone(h.colors[te])),I()}else if(G.dataset.colorUp!==void 0||G.dataset.colorDown!==void 0){const te=Number(G.dataset.colorUp??G.dataset.colorDown),[he]=h.colors.splice(te,1);h.colors.splice(te+(G.dataset.colorUp!==void 0?-1:1),0,he),I()}},x.onchange=P=>{const G=P.target;if(G.dataset.operator!==void 0){h.colors[+G.dataset.operator].operator=G.value,I();return}G.dataset.ruleValue!==void 0&&(h.colors[+G.dataset.ruleValue].value=G.value),ie()},x.oninput=P=>{const G=P.target;if(G.dataset.ruleValue!==void 0)h.colors[+G.dataset.ruleValue].value=G.value;else return;ie()}}function X(w,b){if(w==="color"){K(b);return}const x={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[w],T=w==="filter"?h.filters:w==="sort"?h.sorts:w==="group"?h.groups:h.colors,I=T.map((N,P)=>{var he;const G=w==="sort"?N.colId:w==="group"?N:N.field,V=((he=d.find(([ve])=>ve===G))==null?void 0:he[1])||G,ee=`<button class="field-select" data-pick="${P}">${ae(V)}${Re("down")}</button>`;if(w==="sort")return`<div class="condition">${ee}<button class="sort-direction ${N.sort==="asc"?"selected":""}" data-dir="asc" data-index="${P}">首项 → 末项</button><button class="sort-direction ${N.sort==="desc"?"selected":""}" data-dir="desc" data-index="${P}">末项 → 首项</button><button data-remove="${P}" aria-label="删除条件">${Re("close")}</button></div>`;if(w==="group")return`<div class="condition">${ee}<span class="spacer"></span><button data-remove="${P}" aria-label="删除条件">${Re("close")}</button></div>`;const le=dt([["contains",f[G]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],N.operator,`data-operator="${P}" aria-label="运算符"`),te=["blank","notBlank"].includes(N.operator)?"":f[G]?dt([["","请选择目标值"],...f[G].map(ve=>[ve,ve])],N.value,`data-rule-value="${P}" aria-label="目标值"`):`<input data-rule-value="${P}" aria-label="目标值" value="${ae(N.value)}" placeholder="请选择目标值">`;return`<div class="condition">${ee}${le}${te}${w==="color"?`<input type="color" data-color="${P}" value="${N.color}" aria-label="行颜色">`:""}<button data-remove="${P}" aria-label="删除条件">${Re("close")}</button></div>`}).join(""),O=Ne(b,`设置${x}条件`,`${w==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${h.showTerminated?"checked":""}>显示已终止数据</label>`:""}${I}<button class="add-condition">${Re("plus")}添加${w==="color"?"着色":x}条件</button>${T.length?'<button class="clear-rules">清空全部条件</button>':""}`,w==="color"?650:560);k=w;const $=()=>X(w,b);let H=-1;O.querySelectorAll(".condition").forEach((N,P)=>{N.draggable=!0,N.ondragstart=G=>{var V;H=P,(V=G.dataTransfer)==null||V.setData("text/plain",String(P))},N.ondragover=G=>G.preventDefault(),N.ondrop=G=>{if(G.preventDefault(),H<0||H===P)return;const[V]=T.splice(H,1);T.splice(P,0,V),ie(),$()}}),O.onclick=N=>{const P=N.target.closest("button");P&&(P.classList.contains("add-condition")&&ut(P,G=>{w==="filter"&&h.filters.push({field:G,operator:"contains",value:""}),w==="sort"&&h.sorts.push({colId:G,sort:"asc"}),w==="group"&&!h.groups.includes(G)&&h.groups.push(G),w==="color"&&h.colors.push({field:G,operator:"contains",value:"",color:"#e9f2ff"}),ie(),$()}),P.dataset.pick!==void 0&&ut(P,G=>{const V=+P.dataset.pick;w==="sort"?h.sorts[V].colId=G:w==="group"?h.groups[V]=G:(T[V].field=G,T[V].value=""),ie(),$()}),P.dataset.remove!==void 0&&(T.splice(+P.dataset.remove,1),ie(),$()),P.classList.contains("clear-rules")&&(T.splice(0),ie(),$()),P.dataset.dir&&(h.sorts[+P.dataset.index].sort=P.dataset.dir,ie(),$()))},O.onchange=N=>{const P=N.target;P.id==="terminated"&&(h.showTerminated=P.checked),P.dataset.operator!==void 0&&(T[+P.dataset.operator].operator=P.value,$()),P.dataset.ruleValue!==void 0&&(T[+P.dataset.ruleValue].value=P.value),P.dataset.color!==void 0&&(h.colors[+P.dataset.color].color=P.value),ie()},O.oninput=N=>{const P=N.target;P.tagName==="INPUT"&&P.dataset.ruleValue!==void 0&&(T[+P.dataset.ruleValue].value=P.value,ie())}}function J(){const w=F.api.getDisplayedRowCount(),b=F.api.getAllColumns().filter(P=>P.visible).reduce((P,G)=>P+G.width,0),x=p(".grid-wrap"),T=p(".list-area"),I=getComputedStyle(T),O=Math.max(0,T.clientWidth-parseFloat(I.paddingLeft||"0")-parseFloat(I.paddingRight||"0")),$=Math.max(0,T.clientHeight-x.offsetTop-parseFloat(I.paddingBottom||"0")),H=p(".ag-header-wrapper",x).getBoundingClientRect().height||33,N=Math.max(1,w)*37+H+1;x.style.width=`${Math.min(O,b+2)}px`,x.style.height=`${Math.min($,N)}px`}function Y(){var b;const w=Z().filter(x=>y&&x.name.toLowerCase().includes(y.toLowerCase())).map(x=>x.id);if(R=Math.max(0,Math.min(R,w.length-1)),p("#matches").textContent=y?`${w.length?R+1:0}/${w.length}`:"",s.container.querySelectorAll(".item-name").forEach(x=>{const T=x.hash.replace("#item/","");x.classList.toggle("find-match",w.includes(T)),x.classList.toggle("find-current",w[R]===T)}),w[R]){let x=-1;for(let T=0;T<F.api.getDisplayedRowCount();T++)((b=F.api.getDisplayedRowAtIndex(T))==null?void 0:b.id)===w[R]&&(x=T);x>=0&&F.api.ensureIndexVisible(x)}p('[data-action="previous-match"]').toggleAttribute("disabled",!w.length),p('[data-action="next-match"]').toggleAttribute("disabled",!w.length)}function oe(){const w=F.api.getSelectedRows(),b=p(".selection-bar");b.classList.toggle("hidden",!w.length),b.innerHTML=`${se("deselect","","close")}<span>已选择 ${w.length} 项</span>${se("batch-status","更新状态")}${se("batch-owner","更新负责人")}${se("batch-export","导出")}${se("batch-archive","终止")}${se("deselect","取消选择")}`}function pe(w){const b=Ne(w,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${F.api.getAllColumns().filter(x=>!x.colId.startsWith("_")).map(x=>`<label class="column-option"><input type="checkbox" data-column="${x.colId}" ${x.visible?"checked":""}><span>${ae(x.headerName)}</span><button type="button" data-pin="${x.colId}">${x.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);b.onchange=x=>{const T=x.target;T.dataset.column&&F.columnApi.setColumnVisible(T.dataset.column,T.checked)},b.onclick=x=>{const T=x.target.closest("[data-pin]");if(T){x.preventDefault();const I=F.columnApi.getColumn(T.dataset.pin);F.columnApi.setColumnPinned(I,I.pinned?null:"left"),pe(w)}},p("input",b).oninput=x=>{const T=x.target.value;b.querySelectorAll(".column-option").forEach(I=>I.hidden=!I.textContent.includes(T))}}function Te(){t.forEach(w=>{var b;return(b=w.destroy)==null?void 0:b.call(w)}),t=[],A==null||A.remove(),A=null,L=null,j=null,B==null||B.focus(),s.syncLocationHash&&location.hash.startsWith("#item/")&&history.replaceState(null,"",location.pathname+location.search)}function ke(w,b="dialog-overlay"){return ue(),s.container.querySelectorAll(".field-picker").forEach(x=>x.remove()),t.forEach(x=>{var T;return(T=x.destroy)==null?void 0:T.call(x)}),t=[],A==null||A.remove(),B=document.activeElement,A=document.createElement("div"),A.className=`overlay ${b}`,A.innerHTML=w,A.setAttribute("role","dialog"),A.setAttribute("aria-modal","true"),s.container.append(A),A.addEventListener("click",x=>{x.target===A&&Te()}),A}function Be(w,b,x){const T=ke(`<form class="dialog"><h2>${ae(w)}</h2><input aria-label="${ae(w)}" value="${ae(b)}" required><div class="actions">${se("close-overlay","取消","","outline")}<button class="primary" type="submit">确定</button></div></form>`);p("form",T).onsubmit=I=>{I.preventDefault();const O=p("input",T).value.trim();O&&(Te(),x(O))},p("input",T).focus()}function Le(w,b="基本信息"){var O,$;w.viewed=!0,q(),L=w,W=b,s.syncLocationHash&&history.replaceState(null,"",`#item/${w.id}`);const x=s.detailForm.fields,T=b==="基本信息"?`<div class="detail-fields">${x.map(H=>{var N,P;return`<div class="detail-row"><label for="detail-${H.field}">${ae(H.label||((N=u(H.field))==null?void 0:N.label)||H.field)}${H.required??((P=u(H.field))==null?void 0:P.required)?" *":""}</label>${bt(H,w,"detail")}</div>`}).join("")}<div class="detail-row" data-block="roles"><label>角色与人员</label><div>提报人  ${Q(w.owner)}<p>${se("add-role","添加角色","","outline")}</p><div class="extra-roles"></div></div></div></div><section class="detail-section" data-block="meetings"><p>进入选题会</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${se("add-meeting","添加一组进入选题会","add")}</div><div class="detail-row" data-block="approval"><label>选题是否通过</label><div class="radios">${["是","待定","废弃"].map(H=>`<label><input type="radio" name="approved" value="${H}" data-detail="approved" ${w.approved===H?"checked":""}>${H}</label>`).join("")}</div></div></section><section class="detail-section" data-block="votes"><div class="detail-row"><label>选题投票</label><div>${se("detail-vote",w.vote?"1":"投票","plus","vote")}</div></div><div class="detail-row"><label>是否展示投票结果</label><div class="radios">${["是","否"].map(H=>`<label><input type="radio" name="showVotes" value="${H}" data-detail="showVotes" ${w.showVotes===H?"checked":""}>${H}</label>`).join("")}</div></div></section><div class="detail-row muted"><label>父级工作项</label><span>暂无关联WBS 父工作项</span></div>`:b==="评论/备注"?`<div class="comment-list">${w.comments.length?w.comments.map(H=>`<article>${Q("体验官")}<p>${ae(H)}</p></article>`).join(""):'<p class="muted">暂无评论/备注</p>'}</div>`:b==="操作记录"?`<div class="history-list">${w.history.length?w.history.map(H=>`<p>${ae(H)}</p>`).join(""):'<p class="muted">暂无操作记录</p>'}</div>`:`<div class="muted">${(O=w.materials)!=null&&O.length?w.materials.map(H=>`<p>${ae(H)}</p>`).join(""):"暂无关联素材"}</div>${se("link-material","关联素材","add","outline")}`,I=ke(`<article class="drawer"><div class="drawer-header"><span class="page-logo">${Re("check")}</span><strong>${ae(w.name)}</strong>${_(w.status,"approved")}<span class="muted">已进行 20 天</span><div class="spacer"></div>${se("follow",w.followed?"已关注":"关注","people",w.followed?"is-set":"")}${se("star",w.starred?"已收藏":"收藏","book",w.starred?"is-set":"")}${se("detail-more","","more")}${se("close-overlay","","close","outline")}</div><div class="detail-navigation">${se("prev-item","","up")}${se("next-item","","down")}</div><div class="detail-tabs">${["基本信息","素材管理","评论/备注","操作记录"].map(H=>`<button data-detail-tab="${H}" class="detail-tab ${H===b?"active":""}">${H}</button>`).join("")}<div class="spacer"></div>${Q(w.owner)}${se("detail-status",w.status,"down","primary")}</div><div class="drawer-body">${T}</div><form class="comment-form"><span class="avatar">体验官</span><textarea aria-label="评论" placeholder="请输入评论(Enter 换行,⌘ + Enter 发送)"></textarea><button type="submit">发送</button></form></article>`,"detail-overlay");L=w,j=w,ei(I,w,s.detailForm.fields,"detail"),me();for(const[H,N]of[["roles",s.detailForm.showRoles],["meetings",s.detailForm.showMeetings],["approval",s.detailForm.showApproval],["votes",s.detailForm.showVotes]])N||($=I.querySelector(`[data-block="${H}"]`))==null||$.remove();I.onchange=H=>{var P;const N=H.target;if(N.dataset.detail){const G=s.detailForm.fields.find(V=>V.field===N.dataset.detail);if(G&&!(G.editable??((P=u(G.field))==null?void 0:P.editable)!==!1))return;if(N.dataset.detail==="name"&&!N.value.trim()){N.value=w.name;return}be(w,N.dataset.detail,N.value)}},p("form",I).onsubmit=H=>{H.preventDefault();const N=p("textarea",p("form",I)).value.trim();N&&(w.comments.push(N),q(),Le(w,"评论/备注"),fe("评论已添加到本地 demo"))},p("form textarea",I).onkeydown=H=>{H.key==="Enter"&&(H.metaKey||H.ctrlKey)&&(H.preventDefault(),p("form",I).requestSubmit())}}function bt(w,b,x){return u(w.field)?`<div class="fc-host" data-control-field="${ae(w.field)}" data-control-mode="${x}"></div>`:""}function ze(w,b,x){return{field:w,value:b[w.key]??w.defaultValue??"",item:b,surface:x,readonly:w.editable===!1,openDetail:T=>{const I=C.items.find(O=>O.id===T);I?Le(I):fe("未找到关联工作项")}}}function ei(w,b,x,T){const I=[];for(const O of w.querySelectorAll("[data-control-field]")){const $=x.find(ge=>ge.field===O.dataset.controlField),H=u($.field),N={...H,label:$.label||H.label,required:$.required??H.required,editable:H.editable!==!1&&$.editable!==!1},P=ze(N,b,T==="new"?"create":"detail"),G=e.resolve(N),V=G.createEditor(P);t.push(V),I.push({editor:V,field:N});const ee=V.element.matches("input,select,textarea,[role=textbox]")?V.element:V.element.querySelector("input,select,textarea,[role=textbox]");ee&&(ee.id=`${T}-${N.key}`);const le=document.createElement("div");le.className="fc-error",le.setAttribute("role","status");const te=document.createElement("div");te.className="fc-detail-editor",te.append(V.element,le),O.append(te);let he;T==="detail"&&(O.classList.add("fc-detail-host"),he=document.createElement("div"),he.className="fc-detail-preview",O.prepend(he));const ve=()=>{if(he&&(he.replaceChildren(G.render(ze(N,b,"detail"))),N.editable)){const ge=document.createElement("button");ge.type="button",ge.className="fc-detail-edit",ge.textContent="编辑",ge.ariaLabel=`编辑${N.label}`,ge.onclick=et=>{var Ye;et.stopPropagation(),O.classList.add("editing"),(Ye=V.focus)==null||Ye.call(V)},he.append(ge)}};ve();const Ie=()=>{var et;if(!N.editable)return!0;const ge=(et=V.validate)==null?void 0:et.call(V);if(le.textContent=ge||"",!ge&&T==="detail"){const Ye=V.read();JSON.stringify(b[N.key])!==JSON.stringify(Ye)&&be(b,N.key,Ye),ve()}return!ge};if(T==="detail"&&N.editable){const ge=document.createElement("button");ge.type="button",ge.className="fc-detail-done",ge.textContent="完成",ge.onclick=et=>{et.stopPropagation(),Ie()&&O.classList.remove("editing")},te.append(ge)}O.addEventListener("change",Ie),O.addEventListener("focusout",()=>{queueMicrotask(()=>{O.isConnected&&!O.contains(document.activeElement)&&Ie()&&O.classList.remove("editing")})})}return()=>{var O,$;for(const{editor:H,field:N}of I){if(!N.editable)continue;const P=(O=H.validate)==null?void 0:O.call(H);if(P)return fe(`${N.label}:${P}`),($=H.focus)==null||$.call(H),!1}for(const{editor:H,field:N}of I)N.editable&&(b[N.key]=H.read());return!0}}function ht(w,b,x){var G;o==null||o(),ue();const T=w.closest(".ag-cell")||w,I=[...T.childNodes],O=e.resolve(b).createEditor(ze(b,x,"cell")),$=document.createElement("div");$.className="fc-inline-error",$.setAttribute("role","status");const H=document.createElement("div");H.className="fc-inline-editor",H.append(O.element,$),T.replaceChildren(H),T.classList.add("fc-inline-editing");let N=!1;const P=V=>{var le,te;if(N)return;if(V){const he=(le=O.validate)==null?void 0:le.call(O);if(he){$.textContent=he,O.element.setAttribute("aria-invalid","true");return}}const ee=V?O.read():void 0;N=!0,o=null,(te=O.destroy)==null||te.call(O),T.classList.remove("fc-inline-editing"),T.replaceChildren(...I),V&&x[b.key]!==ee&&be(x,b.key,ee)};o=()=>P(!1),H.addEventListener("keydown",V=>{(V.key==="Enter"||V.key==="Escape")&&(V.preventDefault(),V.stopPropagation(),P(V.key==="Enter"))}),H.addEventListener("focusout",V=>{H.contains(V.relatedTarget)||P(!0)}),H.addEventListener("click",V=>V.stopPropagation()),(G=O.focus)==null||G.call(O),O.element instanceof HTMLInputElement&&O.element.select()}function St(w,b,x){var G;const T=e.resolve(b),I=T.id==="select"||T.id==="multiSelect",O=T.id==="dateTime",$=T.id==="richText",H=Ne(w,I||O||$?"":b.label,'<div class="fc-editor-host"></div><div class="fc-error" role="status"></div>'+(I||$?"":'<div class="actions"><button type="button" class="fc-cancel">取消</button><button type="button" class="primary fc-save">保存</button></div>'),$?240:I?272:320,$?"fc-popup fc-rich-popup":I?"fc-popup fc-choice-popup":"fc-popup");if(I||$){const V=w.getBoundingClientRect();H.style.top=`${Math.max(8,Math.min(V.top,innerHeight-360))}px`}const N=T.createEditor(ze(b,x,"cell"));i=N,p(".fc-editor-host",H).append(N.element);const P=(V=!0)=>{var te;const ee=(te=N.validate)==null?void 0:te.call(N);if(p(".fc-error",H).textContent=ee||"",ee)return;const le=N.read();V&&ue(),be(x,b.key,le)};$?n=()=>{var le;const V=(le=N.validate)==null?void 0:le.call(N);if(p(".fc-error",H).textContent=V||"",V)return!1;const ee=N.read();return x[b.key]!==ee&&be(x,b.key,ee),!0}:I?N.element.addEventListener("change",()=>P(T.id==="select")):(p(".fc-cancel",H).onclick=()=>ue(!1),p(".fc-save",H).onclick=()=>P(),H.addEventListener("keydown",V=>{V.key==="Enter"&&(V.ctrlKey||V.metaKey||V.target instanceof HTMLInputElement)&&(V.preventDefault(),P())})),(G=N.focus)==null||G.call(N)}function $t(w="text"){var G;const b=e.list(),x=b.find(V=>V.id===w)||b[0],T=ke(`<section class="control-manager"><header><div><h2>控件管理</h2><p>统一管理字段的展示和编辑方式</p></div>${se("close-overlay","关闭","close")}</header><div class="control-manager-body"><nav>${b.map(V=>`<button type="button" data-control-id="${ae(V.id)}" class="${V.id===x.id?"active":""}"><span>${ae(V.glyph)}</span>${ae(V.label)}</button>`).join("")}</nav><main><h3>${ae(x.label)}</h3><p>${ae(x.description)}</p><div class="fc-preview-grid"><section><h4>表格单元格</h4><div class="fc-preview-cell"></div><p class="hint">双击或点击编辑</p></section><section><h4>详情页</h4><div class="fc-preview-detail"></div></section></div><div class="fc-preview-edit"></div><div class="fc-error" role="status"></div><div class="actions"><button type="button" class="primary fc-preview-save">应用预览</button></div><p class="hint">在字段类型中选择控件。自定义控件通过 controls 配置或 registerControl() 注册,两处共用同一套展示与编辑接口。</p></main></div></section>`),I={key:"preview",label:x.label,kind:x.id,options:["待开始","进行中","已完成"],editable:!0},O={...C.items[0],preview:x.id==="number"?128:x.id==="multiSelect"?["进行中"]:x.id==="select"?"进行中":x.id==="dateTime"?"2026-09-23T10:30":x.id==="detail"?((G=C.items[0])==null?void 0:G.id)||"":"内容示例"};let $,H=x.createEditor(ze(I,O,"detail"));t.push(H),p(".fc-preview-detail",T).append(H.element);const N=()=>{const V=p(".fc-preview-cell",T);V.replaceChildren(x.render(ze(I,O,"cell")));const ee=document.createElement("button");ee.type="button",ee.textContent="编辑",ee.onclick=P,V.append(ee),V.ondblclick=P},P=()=>{var ee,le;(ee=$==null?void 0:$.destroy)==null||ee.call($),$=x.createEditor(ze(I,O,"cell")),p(x.id==="text"?".fc-preview-cell":".fc-preview-edit",T).replaceChildren($.element),(le=$.focus)==null||le.call($)};t.push({element:T,read:()=>{},destroy:()=>{var V;return(V=$==null?void 0:$.destroy)==null?void 0:V.call($)}}),N(),p(".fc-preview-save",T).onclick=()=>{var te,he,ve;const V=$||H,ee=(te=V.validate)==null?void 0:te.call(V);if(p(".fc-error",T).textContent=ee||"",ee)return;O.preview=V.read(),N(),(he=H.destroy)==null||he.call(H);const le=x.createEditor(ze(I,O,"detail"));t.splice(t.indexOf(H),1,le),p(".fc-preview-detail",T).replaceChildren(le.element),H=le,(ve=$==null?void 0:$.destroy)==null||ve.call($),$=void 0,p(".fc-preview-edit",T).replaceChildren()},T.querySelectorAll("[data-control-id]").forEach(V=>V.onclick=()=>$t(V.dataset.controlId))}function We(){return{id:crypto.randomUUID(),name:"",description:"",source:"",status:"入库",category:"",format:"",approved:"",selectedTopic:"",created:new Date().toISOString().slice(0,10),vote:"",showVotes:"",owner:s.currentUser,creator:s.currentUser,space:s.workspace,followed:!1,starred:!1,viewed:!1,comments:[],history:[],roles:[],meetings:[],...Object.fromEntries(s.fields.filter(w=>w.defaultValue!==void 0).map(w=>[w.key,w.defaultValue]))}}function pt(w){const b=w?structuredClone(w):We(),x=ke(`<form class="create-dialog"><div class="drawer-header"><span class="page-logo">${Re("check")}</span><strong>${ae(s.title)}</strong><div class="spacer"></div>${se("drafts","草稿箱","inbox","outline")}${se("close-overlay","","close")}</div><div class="create-body"><div class="simple-mode"><label><input type="checkbox" id="simple-mode">简洁模式</label></div>${s.createForm.fields.map(I=>{var O,$,H;return`<div class="create-field ${((O=u(I.field))==null?void 0:O.kind)==="longText"?"extended-field":""}"><label for="new-${I.field}">${ae(I.label||(($=u(I.field))==null?void 0:$.label)||I.field)} ${I.required??((H=u(I.field))==null?void 0:H.required)?"<em>*</em>":""}</label>${bt(I,b,"new")}</div>`}).join("")}${s.createForm.showRoles?`<div class="create-field extended-field"><label>角色与人员</label><div><div class="role-line">${dt([["提报人","提报人"]],"提报人",'aria-label="角色"')}<div class="role-person">${Q(s.currentUser)}</div></div>${se("add-role","添加角色","","outline")}<div class="extra-roles"></div></div></div>`:""}${s.createForm.showMeetings?`<section class="detail-section extended-field"><p>进入选题会</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${se("add-meeting","添加一组进入选题会","add")}</div></section>`:""}</div><div class="drawer-footer"><label class="continuous"><input id="continuous" type="checkbox">连续创建</label>${se("close-overlay","取消","","outline")}${se("save-draft","存草稿","","outline")}<button type="submit" class="primary">确认创建</button></div></form>`);j=b,me();const T=ei(x,b,s.createForm.fields,"new");p("#simple-mode",x).onchange=I=>x.querySelectorAll(".extended-field").forEach(O=>O.classList.toggle("hidden",I.target.checked)),p('[data-action="save-draft"]',x).onclick=()=>{if(!T())return;const I=C.drafts.findIndex(O=>O.id===b.id);I>=0?C.drafts[I]=b:C.drafts.push(b),q(),Te(),fe("已存入草稿箱")},p("form",x).onsubmit=I=>{if(I.preventDefault(),!T())return;if(!b.name.trim()){p("#new-name",x).focus();return}const O=p("#continuous",x).checked;C.items.unshift(b),C.drafts=C.drafts.filter($=>$.id!==b.id),q(),ie(),Te(),fe("创建成功"),O&&(pt(),p("#continuous").checked=!0)}}function me(){if(!A||!j)return;const w=j;for(const[b,x]of[["roles",".extra-roles"],["meetings",".meeting-rows"]]){const T=A.querySelector(x);if(!T)continue;const I=w[b]||[];T.innerHTML=I.map((O,$)=>`<div class="role-line"><input data-relation-index="${$}" data-relation-field="name" aria-label="${b==="roles"?"角色名称":"选题会"}" placeholder="${b==="roles"?"角色名称":"选择选题会"}" value="${ae(O.name)}"><input data-relation-index="${$}" data-relation-field="person" aria-label="人员" value="${ae(O.person)}"><button type="button" data-relation-remove="${$}" aria-label="移除">×</button></div>`).join(""),T.onchange=O=>{const $=O.target,H=Number($.dataset.relationIndex);$.dataset.relationField&&(I[H][$.dataset.relationField]=$.value,L&&q())},T.onclick=O=>{const $=O.target.closest("[data-relation-remove]");$&&(I.splice(Number($.dataset.relationRemove),1),me(),L&&q())}}}function ot(w){const b=Ne(w,"存为视图",`<form class="save-view-form"><label>视图名称 <em>*</em></label><input name="name" value="未命名视图" placeholder="请输入视图名称" required><label>协作者</label><input name="collaborators" placeholder="搜索人员" aria-label="协作者"><label>可见范围</label><label><input type="radio" name="visibility" value="public" checked>公开 <small>空间内所有成员可见</small></label><label><input type="radio" name="visibility" value="members">指定成员 <small>协作者、管理员和指定成员可见</small></label><div class="actions"><button type="submit" class="primary">保存</button>${se("close-popup","取消","","outline")}</div></form>`,380);p("form",b).onsubmit=x=>{x.preventDefault();const T=p('input[name="name"]',b).value.trim();T&&(C.views.push({name:T,state:structuredClone(h),columns:F.columnApi.getColumnState(),gridState:F.api.getState(),tab:m,search:y,filterSearch:E,collaborators:p('[name="collaborators"]',b).value,visibility:p('[name="visibility"]:checked',b).value}),q(),st(),ue(),fe("视图已保存"))}}function st(){p('[data-action="saved-views"]').classList.toggle("hidden",!C.views.length)}document.addEventListener("contextmenu",w=>{if(!s.container.contains(w.target))return;const b=w.target.closest("[data-view]");if(!b)return;w.preventDefault();const x=Number(b.dataset.view),T=C.views[x],I=Ne(b,T.name,'<button class="menu-option" data-view-menu="rename">重命名</button><button class="menu-option" data-view-menu="duplicate">复制视图</button><button class="menu-option" data-view-menu="remove">删除视图</button>',220);I.onclick=O=>{var H;const $=(H=O.target.closest("[data-view-menu]"))==null?void 0:H.dataset.viewMenu;if($){if(ue(),$==="rename"&&Be("重命名视图",T.name,N=>{T.name=N,q(),st()}),$==="duplicate"){const N=structuredClone(T);N.name+="(副本)",C.views.push(N),q(),st()}$==="remove"&&(C.views.splice(x,1),q(),st(),fe("视图已删除"))}}},{signal:r.signal});function Ue(w,b,x,T){const I=u(b);if(I){if(I.editable===!1){fe("系统字段,不支持修改");return}if(I.kind==="vote"){be(x,b,x[b]?"":s.currentUser);return}["text","number"].includes(e.resolve(I).id)?ht(w,I,x):St(w,I,x)}}p("#grid").addEventListener("keydown",w=>{if(!["Enter","F2"].includes(w.key)||w.target.closest("button,input,textarea,select"))return;const b=w.target.closest(".ag-cell[data-colid]"),x=b==null?void 0:b.closest("[data-rowid]"),T=C.items.find(I=>I.id===(x==null?void 0:x.dataset.rowid));b&&T&&(w.preventDefault(),Ue(b,b.dataset.colid,T))},{capture:!0,signal:r.signal});function at(){p("#grid").querySelectorAll(".ag-header-cell").forEach(w=>{var O,$;const b=w.dataset.colid;if(!u(b))return;if(!w.querySelector(".work-header-sort")){const H=document.createElement("span");H.className="work-header-sort",(O=w.querySelector(".ag-header-cell-label"))==null||O.append(H);const N=document.createElement("button");N.className="work-header-menu",N.ariaLabel=`${u(b).label}操作`,N.innerHTML=Re("more"),N.onclick=G=>{G.stopPropagation(),Ve(N,b)},N.onmousedown=G=>G.stopPropagation(),w.append(N);for(const G of["right","left"]){const V=document.createElement("button");V.className="work-header-add",V.dataset.insertSide=G,V.ariaLabel=`在${u(b).label}${G==="right"?"右":"左"}侧插入列`,V.title="插入列",V.innerHTML=Re("add"),V.onclick=ee=>{ee.stopPropagation(),xt(V,b,G==="right")},V.onmousedown=ee=>ee.stopPropagation(),w.append(V)}const P=()=>{const G=w.getBoundingClientRect(),V=p(".grid-wrap").getBoundingClientRect(),le=w.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();w.querySelectorAll(".work-header-add").forEach(te=>{const he=te.dataset.insertSide==="left"?G.left:G.right;te.style.left=`${he-12}px`,te.style.top=`${G.top-20}px`,te.style.setProperty("--insert-line-height",`${Math.max(0,V.bottom-G.top+8)}px`),te.style.display=he<Math.max(V.left,le.left)-1||he>Math.min(V.right,le.right)+1?"none":""}),w.classList.add("insert-points-ready")};w.addEventListener("mouseenter",P),w.addEventListener("focusin",P),w.addEventListener("click",G=>{var ee;if(G.target.closest("button,.ag-header-cell-resize"))return;G.stopImmediatePropagation();const V=(ee=h.sorts.find(le=>le.colId===b))==null?void 0:ee.sort;h.sorts=V==="desc"?[]:[{colId:b,sort:V==="asc"?"desc":"asc"}],ie()},{capture:!0})}const x=($=h.sorts.find(H=>H.colId===b))==null?void 0:$.sort,T=w.querySelector(".work-header-sort"),I=x==="asc"?"↑":x==="desc"?"↓":"↕";T.textContent!==I&&(T.textContent=I),T.classList.toggle("sorted",!!x),w.setAttribute("aria-sort",x==="asc"?"ascending":x==="desc"?"descending":"none")})}function xt(w,b,x){const T=Ne(w,"插入列",'<input class="insert-search" placeholder="搜索字段" aria-label="搜索插入字段"><div class="insert-options"></div><button class="menu-option new-field">+ 新建字段</button>',280),I=($="")=>{p(".insert-options",T).innerHTML=s.fields.filter(H=>{var N;return H.label.includes($)&&!((N=F.columnApi.getColumn(H.key))!=null&&N.visible)}).map(H=>`<button class="menu-option" data-insert="${ae(H.key)}">${ae(H.label)}</button>`).join("")||'<p class="muted">暂无未显示字段</p>'},O=$=>{var P;const N=F.columnApi.getColumnState().findIndex(G=>G.colId===b)+(x?1:0);F.columnApi.setColumnVisible($,!0),F.columnApi.setColumnPinned($,b==="_add"?null:((P=F.columnApi.getColumn(b))==null?void 0:P.pinned)??null),F.columnApi.moveColumn($,Math.max(1,N)),ue(),J(),at()};I(),p("input",T).oninput=$=>I($.target.value),T.onclick=$=>{const H=$.target.closest("[data-insert],.new-field");if(!H)return;if(H.dataset.insert){O(H.dataset.insert);return}const N=Ne(w,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${e.list().map(P=>`<option value="${ae(P.id)}">${ae(P.label)}</option>`).join("")}<option value="person">人员</option><option value="relation">关联</option></select></label><label>选项(每行一个)<textarea name="options" aria-label="字段选项"></textarea></label><label class="choice-limit hidden">最多可选数量<input name="maxSelections" type="number" min="1" step="1" placeholder="不限" aria-label="最多可选数量"></label><button class="primary" type="submit">确认创建</button></form>`,320);p('[name="kind"]',N).onchange=P=>{p(".choice-limit",N).classList.toggle("hidden",P.target.value!=="multiSelect")},p("form",N).onsubmit=P=>{P.preventDefault();const G=new FormData(P.target),V=String(G.get("label")||"").trim();if(!V)return;const ee=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,le=String(G.get("kind")),te={key:ee,label:V,kind:le,editable:!0,width:160};["select","multiSelect","person"].includes(le)&&(te.options=[...new Set(String(G.get("options")||"").split(`
120
+ `).map(Ie=>Ie.trim()).filter(Boolean))]);const he=Number(G.get("maxSelections"));le==="multiSelect"&&Number.isInteger(he)&&he>0&&(te.maxSelections=he),s.fields.push(te),d.push([ee,V]),te.options&&(f[ee]=te.options),C.customFields.push(te);const ve=F.columnApi.getColumnState();F.api.setColumnDefs(U()),F.columnApi.applyColumnState(ve,!0),O(ee),q(),ie()}}}function Ve(w,b){const x=F.columnApi.getColumn(b);if(!x||b==="_select")return;if(b==="_add"){xt(w,b,!1);return}const T=["向左插入列","向右插入列",f[b]?"以 首项 → 末项 排序":"以 A → Z 排序",f[b]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",x.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],I=Ne(w,"",[[0,1],[2,3],[4,8],[5,6,7]].map(O=>O.map($=>`<button class="menu-option${$===7?" destructive":""}" data-col-menu="${$}" ${$===7&&b==="name"?"disabled":""}>${T[$]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");I.dataset.headerMenu="true",I.onclick=O=>{const $=O.target.closest("[data-col-menu]");if(!$)return;const H=+$.dataset.colMenu;ue(),(H===0||H===1)&&xt(w,b,H===1),(H===2||H===3)&&(h.sorts=[{colId:b,sort:H===2?"asc":"desc"}],ie()),H===4&&(h.filters.push({field:b,operator:"contains",value:""}),X("filter",p('[data-action="filter"]'))),H===5&&F.columnApi.setColumnPinned(b,x.pinned?null:"left"),H===6&&Be("编辑列",x.headerName,N=>{const P=u(b);P&&(P.label=N);const G=F.api.getColumnDefs(),V=G.find(le=>le.field===b);V&&(V.headerName=N);const ee=F.columnApi.getColumnState();F.api.setColumnDefs(G),F.columnApi.applyColumnState(ee,!0),at()}),H===7&&F.columnApi.setColumnVisible(b,!1),H===8&&(h.groups.includes(b)||h.groups.push(b),ie())}}p("#grid").addEventListener("contextmenu",w=>{const b=w.target.closest(".ag-header-cell");if(b){w.preventDefault();const x=b.getAttribute("col-id")||b.dataset.colid||b.dataset.colId||"";Ve(b,x)}else{const x=w.target.closest(".ag-cell");if(x){w.preventDefault();const T=Ne(x,"单元格",se("copy-cell","复制")+se("paste-cell","粘贴")+se("export","导出表格"),200);p('[data-action="copy-cell"]',T).onclick=async()=>{try{await navigator.clipboard.writeText(x.textContent||""),fe("已复制")}catch{fe("复制失败,请使用 ⌘C")}ue()}}}}),p("#grid").addEventListener("dblclick",w=>{var $;const b=w.target.closest(".ag-cell");if(!b||w.target.closest("input,textarea,select,.ag-cell-edit-input"))return;const x=b.dataset.colid,T=C.items.find(H=>{var N;return H.id===((N=b.closest(".ag-row"))==null?void 0:N.dataset.rowid)});if(!T||!u(x))return;clearTimeout(D),w.stopImmediatePropagation(),w.preventDefault();const I=F.api.getDisplayedRowCount();let O=0;for(;O<I&&(($=F.api.getDisplayedRowAtIndex(O))==null?void 0:$.id)!==T.id;O++);Ue(b,x,T)},{capture:!0,signal:r.signal}),document.addEventListener("click",w=>{s.container.querySelectorAll(".field-picker").forEach(b=>{b.contains(w.target)||b.remove()}),p("#grid").contains(w.target)||(F.api.getCellRanges().length&&F.api.clearRangeSelection(),F.api.getFocusedCell()&&F.api.clearFocusedCell()),(S==null?void 0:S.dataset.headerMenu)==="true"&&!S.contains(w.target)&&ue()},{capture:!0,signal:r.signal}),document.addEventListener("click",async w=>{const b=w.target,x=N=>w.composedPath().some(P=>P instanceof Element&&P.matches(N));if(!w.composedPath().includes(s.container)){ue();return}x(".popup,.field-picker,.toolbar,.ag-cell,.ag-header-cell,.list-bottom,.create-button")||ue();const T=b.closest("[data-tab]");if(T){m=T.dataset.tab,s.container.querySelectorAll("[data-tab]").forEach(N=>{N.classList.toggle("active",N===T),N.setAttribute("aria-selected",String(N===T))}),ie();return}const I=b.closest("[data-view]");if(I){const N=C.views[+I.dataset.view];h=structuredClone(N.state),m=N.tab||"全部",y=N.search||"",E=!!N.filterSearch,s.container.querySelectorAll("[data-tab]").forEach(P=>{P.classList.toggle("active",P.dataset.tab===m),P.setAttribute("aria-selected",String(P.dataset.tab===m))}),p("#search").value=y,p("#filter-search").checked=E,p(".search-wrap").classList.toggle("hidden",!y),p('[data-action="search"]').classList.toggle("hidden",!!y),ue(),ie(),N.gridState?F.api.setState(N.gridState):N.columns&&F.columnApi.applyColumnState(N.columns,!0),Y();return}const O=b.closest("[data-detail-tab]");if(O&&L){Le(L,O.dataset.detailTab);return}const $=b.closest("[data-action]");if(!$)return;const H=$.dataset.action;if(["filter","sort","group","color"].includes(H)){k===H?ue():X(H,$);return}switch(H){case"controls":$t();break;case"close-popup":ue();break;case"create":pt();break;case"create-menu":Ne($,"新建",se("create","新建选题","plus","menu-option")+se("drafts","草稿箱","inbox","menu-option"),180);break;case"drafts":{const N=ke(`<section class="dialog"><h2>草稿箱</h2>${C.drafts.length?C.drafts.map((P,G)=>`<button class="menu-option" data-draft="${G}">${ae(P.name||"未命名选题")}</button>`).join(""):'<p class="muted">暂无草稿</p>'}<div class="actions">${se("close-overlay","关闭","","outline")}</div></section>`);N.onclick=P=>{const G=P.target.closest("[data-draft]");G&&pt(C.drafts[+G.dataset.draft])};break}case"close-overlay":Te();break;case"search":p(".search-wrap").classList.remove("hidden"),$.classList.add("hidden"),p("#search").focus();break;case"close-search":y="",E=!1,p("#search").value="",p("#filter-search").checked=!1,p(".search-wrap").classList.add("hidden"),p('[data-action="search"]').classList.remove("hidden"),ie();break;case"previous-match":R--,Y();break;case"next-match":R++,Y();break;case"reset":h=yn(),ie(),ue();break;case"columns":case"layout":pe($);break;case"save-view":case"pin-view":ot($);break;case"saved-views":Ne($,"切换视图",C.views.map((N,P)=>`<button class="menu-option" data-view="${P}">${Re("table")}<span>${ae(N.name)}</span></button>`).join(""),260);break;case"share":{const N=Ne($,"分享工作项列表",`<input readonly value="${ae(location.href.split("#")[0])}" aria-label="分享链接"><p class="hint">复制此 demo 的访问地址</p><button class="primary" id="copy-link">复制链接</button>`,380);p("#copy-link",N).onclick=async()=>{try{await navigator.clipboard.writeText(location.href.split("#")[0]),fe("链接已复制"),ue()}catch{p("input",N).select(),fe("请按 ⌘C 复制链接")}};break}case"deselect":F.api.deselectAll();break;case"batch-status":case"batch-owner":{const N=H==="batch-status"?"status":"owner",P=F.api.getSelectedRows(),G=Ne($,"批量更新",f[N].map(V=>`<button class="menu-option" data-batch-value="${V}">${V}</button>`).join(""),220);G.onclick=V=>{const ee=V.target.closest("[data-batch-value]");ee&&(P.forEach(le=>{le[N]=ee.dataset.batchValue,le.history.push(`批量更新${N}:${le[N]}`)}),q(),ie(),ue(),fe(`已更新 ${P.length} 项`))};break}case"batch-archive":{const N=F.api.getSelectedRows();N.forEach(P=>P.status="已终止"),q(),ie(),fe(`已终止 ${N.length} 项,可在筛选中显示`);break}case"batch-export":F.api.exportToCsv({fileName:"选题库.csv",onlySelected:!0,columnKeys:d.map(([N])=>N)});break;case"export":F.api.exportToCsv({fileName:"选题库.csv",columnKeys:d.map(([N])=>N)}),ue();break;case"paste-cell":F.api.pasteFromClipboard(),ue();break;case"follow":L&&(L.followed=!L.followed,q(),Le(L,W));break;case"star":L&&(L.starred=!L.starred,q(),Le(L,W));break;case"detail-vote":L&&(be(L,"vote",L.vote?"":"体验官"),Le(L));break;case"detail-status":L&&Zt($,"status",L);break;case"prev-item":case"next-item":if(L){const N=C.items.indexOf(L)+(H==="prev-item"?-1:1);C.items[N]&&Le(C.items[N],W)}break;case"detail-more":Ne($,"更多操作",se("duplicate","复制工作项","","menu-option")+se("terminate-item","终止工作项","","menu-option"),220);break;case"duplicate":if(L){const N=structuredClone(L);N.id=crypto.randomUUID(),N.name+="(副本)",N.comments=[],N.history=[],C.items.unshift(N),q(),ie(),Le(N)}break;case"terminate-item":L&&(be(L,"status","已终止"),Te(),fe("工作项已终止"));break;case"add-role":j&&(j.roles??(j.roles=[]),j.roles.push({name:"",person:s.currentUser}),me(),L&&q());break;case"add-meeting":j&&(j.meetings??(j.meetings=[]),j.meetings.push({name:"",person:s.currentUser}),me(),L&&q());break;case"link-material":{const N=L;N&&Be("关联素材","",P=>{N.materials??(N.materials=[]),N.materials.push(P),N.history.push(`关联素材:${P}`),q(),Le(N,"素材管理")});break}}},{signal:r.signal}),p("#search").oninput=w=>{y=w.target.value,R=0,E?ie():Y()},p("#filter-search").onchange=w=>{E=w.target.checked,ie()},document.addEventListener("keydown",w=>{if(s.container.contains(w.target)&&(w.key==="Escape"&&(s.container.querySelector(".field-picker")?s.container.querySelectorAll(".field-picker").forEach(b=>b.remove()):S?ue(!1):A&&Te()),w.key==="Tab"&&A)){const b=[...A.querySelectorAll('button:not([disabled]),input,select,textarea,[tabindex="0"]')].filter(I=>I.offsetParent!==null),x=b[0],T=b[b.length-1];w.shiftKey&&document.activeElement===x?(w.preventDefault(),T==null||T.focus()):!w.shiftKey&&document.activeElement===T&&(w.preventDefault(),x==null||x.focus())}},{signal:r.signal}),window.addEventListener("pagehide",()=>F.grid.destroy(),{once:!0,signal:r.signal});const Se=p("#grid .ag-body-viewport"),lt=p(".grid-wrap"),_e=document.createElement("div");_e.className="work-horizontal-scrollbar",_e.setAttribute("aria-label","横向滚动表格");const Rn=document.createElement("div");_e.append(Rn),lt.append(_e);const qe=document.createElement("div");qe.className="work-vertical-scrollbar",qe.setAttribute("aria-label","纵向滚动表格");const Mn=document.createElement("div");qe.append(Mn),lt.append(qe);const kn=()=>{const w=Se.getBoundingClientRect(),b=lt.getBoundingClientRect();_e.style.left=`${w.left-b.left-1}px`,_e.style.width=`${Se.clientWidth}px`,Rn.style.width=`${Se.scrollWidth}px`,_e.hidden=Se.scrollWidth<=Se.clientWidth,_e.scrollLeft=Se.scrollLeft,qe.style.top=`${w.top-b.top-1}px`,qe.style.height=`${Se.clientHeight}px`,Mn.style.height=`${Se.scrollHeight}px`,qe.hidden=Se.scrollHeight<=Se.clientHeight,qe.scrollTop=Se.scrollTop};_e.addEventListener("scroll",()=>{Se.scrollLeft=_e.scrollLeft},{passive:!0,signal:r.signal}),qe.addEventListener("scroll",()=>{Se.scrollTop=qe.scrollTop},{passive:!0,signal:r.signal});let Ei=0;Se.addEventListener("pointermove",w=>{const b=Se.getBoundingClientRect();Se.classList.toggle("scrollbar-near-right",b.right-w.clientX<=16),Se.classList.toggle("scrollbar-near-bottom",b.bottom-w.clientY<=16),lt.classList.toggle("scrollbar-near-right",b.right-w.clientX<=16),lt.classList.toggle("scrollbar-near-bottom",b.bottom-w.clientY<=16)},{signal:r.signal}),Se.addEventListener("pointerleave",()=>{Se.classList.remove("scrollbar-near-right","scrollbar-near-bottom"),lt.classList.remove("scrollbar-near-right","scrollbar-near-bottom")},{signal:r.signal}),Se.addEventListener("scroll",()=>{Se.classList.add("scrollbar-scrolling"),lt.classList.add("scrollbar-scrolling"),_e.scrollLeft=Se.scrollLeft,qe.scrollTop=Se.scrollTop,clearTimeout(Ei),Ei=window.setTimeout(()=>{Se.classList.remove("scrollbar-scrolling"),lt.classList.remove("scrollbar-scrolling")},900)},{passive:!0,signal:r.signal});const Tn=()=>{p("#grid").querySelectorAll(".insert-points-ready").forEach(w=>w.classList.remove("insert-points-ready"))};window.addEventListener("scroll",Tn,{capture:!0,signal:r.signal}),window.addEventListener("resize",Tn,{signal:r.signal});const gt=new ResizeObserver(()=>{J(),kn()});gt.observe(p(".list-area")),gt.observe(p(".toolbar")),gt.observe(p(".list-tabs")),gt.observe(p(".ag-header-wrapper")),gt.observe(Se),gt.observe(p(".ag-body-container")),kn();const Nn=new window.MutationObserver(()=>at());if(Nn.observe(p("#grid .ag-header"),{childList:!0,subtree:!0}),at(),st(),J(),s.syncLocationHash&&location.hash.startsWith("#item/")){const w=C.items.find(b=>b.id===location.hash.slice(6));w&&Le(w)}return{registerControl:w=>{e.register(w),F.api.refreshCells({force:!0})},getControls:()=>e.list(),api:F.api,columnApi:F.columnApi,getViewState:()=>({...structuredClone(h),columns:F.columnApi.getColumnState()}),getItems:()=>structuredClone(C.items),destroy:()=>{l=!0,o==null||o(),Nn.disconnect(),gt.disconnect(),r.abort(),clearTimeout(M),clearTimeout(D),clearTimeout(Ei),ue(),Te(),F.grid.destroy(),s.container.replaceChildren(),s.container.classList.remove("rowvia-work-items")}}}const ua={name:"title",description:"longText",vote:"vote",showVotes:"select",status:"status",selectedTopic:"relation",format:"multiSelect",approved:"select",category:"select",owner:"person",space:"text",created:"date",creator:"person",source:"longText"};function En(s){return{container:s,title:"选题库",workspace:"内容制作全流程",currentUser:"体验官",storageKey:"rowvia:work-items:v3",items:Jt,fields:[...oa.map(([e,t])=>({key:e,label:t,kind:ua[e],width:120,minWidth:80,pinned:e==="name"?"left":null,editable:!["created","creator","space"].includes(e),required:e==="name",options:sa[e]})),{key:"source",label:"参考来源",kind:"longText",hidden:!0,editable:!0}],createForm:{fields:["name","category","format","source","description"].map(e=>({field:e})),showRoles:!0,showMeetings:!0},detailForm:{fields:["name","description","category","format","source"].map(e=>({field:e})),showRoles:!0,showMeetings:!0,showApproval:!0,showVotes:!0}}}function ha(s){const e=En(s);e.storageKey="rowvia:work-items:date-1000:v1";const t=[{key:"singleDate",label:"单日期",kind:"date",width:150,editable:!0,dateOptions:{showTime:!1,showRange:!1}},{key:"dateTime",label:"日期时间",kind:"dateTime",width:190,editable:!0,dateOptions:{showTime:!0,showRange:!1}},{key:"dateRange",label:"日期范围",kind:"date",width:260,editable:!0,dateOptions:{showTime:!1,showRange:!0}}];e.fields.splice(1,0,...t),e.createForm.fields.push(...t.map(({key:n})=>({field:n}))),e.detailForm.fields.push(...t.map(({key:n})=>({field:n})));const i=n=>new Date(Date.UTC(2024,0,1+n)).toISOString().slice(0,10);return e.items=Array.from({length:1e3},(n,o)=>{const a=structuredClone(Jt[o%Jt.length]),r=i(o);return{...a,id:`date-demo-${String(o+1).padStart(4,"0")}`,name:`${a.name} · ${String(o+1).padStart(4,"0")}`,singleDate:r,dateTime:`${r}T${String(o%24).padStart(2,"0")}:${String(o%60).padStart(2,"0")}`,dateRange:[r,i(o+o%15)]}}),e}function xi(s,e){const t=new vt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function pa(s,e){zt[s]=e}function ga(s,e){it[s]=e}re.CELL_EDITORS=it,re.CELL_RENDERERS=zt,re.DEFAULT_LOCALE_TEXT=Hi,re.FORMULA_FUNCTIONS=Ht,re.GANTT_UNITS=Qi,re.GanttChart=en,re.Grid=vt,re.UNIT_LABEL=Ut,re.computeStickyGroupRows=Vi,re.createControlRegistry=wn,re.createDetailDialog=Xi,re.createFinancePage=Bs,re.createGantt=Rs,re.createGrid=xi,re.createHrPage=Vs,re.createInventoryPage=qs,re.createPerformancePage=Js,re.createPersonnelSchedule=ks,re.createServerSidePage=Zs,re.createSparklineSvg=si,re.createWorkItemPage=da,re.dateDemoConfig=ha,re.default=vt,re.evaluateFormula=Mt,re.formatNumberCommas=Ke,re.isFormula=ni,re.parse=Ii,re.registerEditor=ga,re.registerFormulaFunction=On,re.registerRenderer=pa,re.sanitizeRichText=Ft,re.tokenize=Ti,re.topicDemoConfig=En,Object.defineProperties(re,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});