rowvia 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fields.es.js +1 -1
- package/dist/fields.umd.cjs +1 -1
- package/dist/rowvia.css +1 -1
- package/dist/rowvia.es.js +6192 -5239
- package/dist/rowvia.umd.cjs +63 -53
- package/dist/types/contracts/work-item.d.ts +7 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/personnel/component.d.ts +14 -0
- package/dist/types/work-items/detail/detail-comments.d.ts +44 -0
- package/dist/types/work-items/detail/detail-history.d.ts +38 -0
- package/dist/types/work-items/detail/history-model.d.ts +48 -0
- package/dist/types/work-items/index.d.ts +8 -0
- package/dist/types/work-items/workflow-detail-model.d.ts +51 -0
- package/dist/types/work-items/workflow-detail-types.d.ts +102 -0
- package/dist/types/work-items/workflow-detail.d.ts +3 -0
- package/package.json +1 -1
package/dist/rowvia.umd.cjs
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
(function(
|
|
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++];is.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 Ie("#NAME?")}return e}const yi={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function bi(s){let e=0;const t=()=>s[e],i=()=>s[e++];function n(r=0){let d=o();for(;t()&&t().type==="op"&&yi[t().value]>=r;){const c=i().value,p=n(yi[c]+1);d={type:"binary",operator:c,left:d,right:p}}return d}function o(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){i();const d=o();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return a()}function a(){const r=i();if(!r)throw new Ie("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=t();if(c&&c.type==="lparen"){i();const p=[];if(t()&&t().type!=="rparen")for(p.push(n());t()&&t().type==="comma";)i(),p.push(n());if(!t()||t().type!=="rparen")throw new Ie("#ERROR!");return i(),{type:"call",name:d,args:p}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=n();if(!t()||t().type!=="rparen")throw new Ie("#ERROR!");return i(),d}throw new Ie("#ERROR!")}const l=n();if(e<s.length)throw new Ie("#ERROR!");return l}function te(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 tt(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...tt(t));else if(t!=null&&t!==""){const i=typeof t=="number"?t:Number(t);isNaN(i)||e.push(i)}return e}const Rt={SUM:s=>tt(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=tt(s);return e.length?e.reduce((t,i)=>t+i,0)/e.length:0},AVG:s=>Rt.AVERAGE(s,{}),MIN:s=>{const e=tt(s);return e.length?Math.min(...e):0},MAX:s=>{const e=tt(s);return e.length?Math.max(...e):0},COUNT:s=>tt(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(te(s[0])),ROUND:s=>{const e=s.length>1?te(s[1]):0,t=Math.pow(10,e);return Math.round(te(s[0])*t)/t},FLOOR:s=>Math.floor(te(s[0])),CEIL:s=>Math.ceil(te(s[0])),CEILING:s=>Math.ceil(te(s[0])),SQRT:s=>{const e=te(s[0]);return e<0?(()=>{throw new Ie("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(te(s[0]),te(s[1])),POW:s=>Math.pow(te(s[0]),te(s[1])),MOD:s=>{const e=te(s[1]);if(e===0)throw new Ie("#DIV/0!");return te(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?te(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?te(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,te(s[1])-1),i=s.length>2?te(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=>te(s[0]),NUMBER:s=>te(s[0]),BETWEEN:s=>te(s[0])>=te(s[1])&&te(s[0])<=te(s[2])},Mt=Object.keys(Rt);function ns(s,e){Rt[s.toUpperCase()]=e,Mt.includes(s.toUpperCase())||Mt.push(s.toUpperCase())}function ss(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 os(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 ft(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return os(s.value,e);case"cell":return ss(s.value,e);case"unary":return-te(ft(s.operand,e));case"call":{const t=Rt[s.name];if(!t)throw new Ie("#NAME?");const i=s.args.map(n=>ft(n,e));return t(i,e)}case"binary":{const t=ft(s.left,e),i=ft(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof i=="string"?`${t??""}${i??""}`:te(t)+te(i);case"-":return te(t)-te(i);case"*":return te(t)*te(i);case"/":{const n=te(i);if(n===0)throw new Ie("#DIV/0!");return te(t)/n}case"^":return Math.pow(te(t),te(i));case"%":{const n=te(i);if(n===0)throw new Ie("#DIV/0!");return te(t)%n}case"&":return`${t??""}${i??""}`;case"=":return t===i;case"<>":return t!==i;case"<":return te(t)<te(i);case"<=":return te(t)<=te(i);case">":return te(t)>te(i);case">=":return te(t)>=te(i);default:throw new Ie("#ERROR!")}}default:throw new Ie("#ERROR!")}}function gt(s,e={}){const t=s.startsWith("=")?s.slice(1):s,i=bi(Ci(t));return ft(i,e)}function _t(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function Wt(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 oe(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"?r=>_t(a)?gt(a,{data:r.data}):Wt(r.data,a):a)({data:n?e.groupData:e.data,node:e,column:s,api:t,colDef:i,getValue:r=>Wt(n?e.groupData:e.data,r)});if(s.field&&_t(s.field))return gt(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return gt(`=${s.field}`,{data:e.data});if(s.field)return Wt(o,s.field)}function kt(s,e,t){var o;const i=oe(s,e,t),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"?l=>as(l.colDef.valueFormatter,l.value,l):n.valueFormatter)({value:i,data:e.data,node:e,column:s,api:t,colDef:n}):rs(s,i)}function as(s,e,t={}){var i,n,o;if(e==null)return"";switch(s){case"number":return He(e,((i=t.column)==null?void 0:i.decimals)??0);case"currency":return`$${He(e,((n=t.column)==null?void 0:n.decimals)??2)}`;case"percent":return`${He(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Si(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Si(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 rs(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?He(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Si(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Ei(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?i=>xi(i.colDef.valueParser,i.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):xi(s.type,e)}function xi(s,e){if(s==="numberColumn")return zt(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 Ri(s){const t=s.colDef.comparator,i=s.type;return(n,o)=>{const a=oe(s,n,null),l=oe(s,o,null);if(t)return t(a,l,n,o);if(i==="numberColumn"){const r=typeof a=="number"?a:zt(a),d=typeof l=="number"?l:zt(l);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(i==="dateColumn"){const r=a instanceof Date?a.getTime():new Date(a).getTime(),d=l instanceof Date?l.getTime():new Date(l).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return es(a,l)}}function mt(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}}function ls(s){const e={onInteraction:s.onInteraction,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 oe(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 l=s.getRowNode(a);l&&s.getSelectionService().selectNode(l,!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()}}}class We{constructor(e,t,i){w(this,"id");w(this,"__id");w(this,"data");w(this,"parent",null);w(this,"children",null);w(this,"group",!1);w(this,"key",null);w(this,"level",0);w(this,"uiLevel",0);w(this,"rowGroupIndex");w(this,"expanded",!1);w(this,"selectable",!0);w(this,"selected",!1);w(this,"rowPinned",null);w(this,"detailNode",null);w(this,"masterNode",null);w(this,"footer",!1);w(this,"groupData",null);w(this,"rowHeight",null);w(this,"allChildrenCount",null);w(this,"stub",!1);w(this,"rowIndex",null);w(this,"__displayIndex");w(this,"services");w(this,"__passesFilter",!0);w(this,"__childCount",0);w(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=Gt("row"),this.id=i??this.__id}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 ds{constructor(e){w(this,"options");w(this,"eventService");w(this,"columns");w(this,"getFilterModel");w(this,"getQuickFilter");w(this,"isPaginationEnabled");w(this,"getPageSize");w(this,"getCurrentPage");w(this,"rowHeightProvider");w(this,"rowNodeServices");w(this,"rowData",[]);w(this,"rootRowNodes",[]);w(this,"dataRows",[]);w(this,"rowsToDisplay",[]);w(this,"rowNodeMap",new Map);w(this,"expandedGroups",new Set);w(this,"groupDefaultExpandedApplied",!1);w(this,"pinnedTopRows",[]);w(this,"pinnedBottomRows",[]);w(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],l=t?t({data:a,level:0}):void 0,r=this.createRowNode(a,l);r.rowIndex=o,n.push(r)}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 We(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||(d=>String(d.id??d.key).split("/")),n=this.options.treeDataChildrenField||"children",o=new Map,a=[],l=(d,c,p)=>{const f=i(d),u=f.join("/"),h=t?t({data:d,level:p}):u,g=this.createRowNode(d,h,c,p);g.key=f[f.length-1],o.set(u,g);const v=d[n];if(Array.isArray(v)&&v.length){g.children=[],g.group=!0,g.expanded=!0;for(const m of v){const C=l(m,g,p+1);g.children.push(C)}g.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(g),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||a.push(g),g},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const p of d.children)c+=r(p);return d.allChildrenCount=c,c};for(const d of a)r(d);for(const d of e){if(!d)continue;const p=i(d).slice(0,-1).join("/"),f=p&&o.get(p)||null;l(d,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(l=>{const r=t?t({data:l,level:0}):l.id;return String(r)===String(o)?n:l}),a.data=n,i.update.push(a);else{const l=this.createRowNode(n,o!==void 0?String(o):void 0);this.rowData.push(n),i.add.push(l)}}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,l=this.createRowNode(o,a);i.add.push(l),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,l=h=>{for(const[g,v]of Object.entries(e)){const m=o.find(C=>C.colId===g);if(m&&!this.doesNodePassFilter(h,m,v))return!1}return!0},r=h=>{const g=this.options.__advancedFilterPass;return g?g(h):!0},d=Object.entries(e).some(([h,g])=>{const v=o.find(m=>m.colId===h);return!v||!v.aggFunc?!1:g.filterType==="multi"?(g.filterModels||[]).length>0:!0}),c=h=>{if(h.__passesFilter=!0,h.children)for(const g of h.children)c(g)},p=h=>{const g=this.options;return typeof g.isExternalFilterPresent!="function"||!g.isExternalFilterPresent()||typeof g.doesExternalFilterPass!="function"?!0:g.doesExternalFilterPass(h)},f=h=>{if(!n)return!0;const g=t.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of v){const C=oe(m,h,null);if(ts(g,C))return!0}return!1},u=h=>{let g=!0;if(!h.group||h.footer||a?g=(!i||l(h))&&f(h)&&p(h)&&r(h):d&&(g=(!i||l(h))&&r(h)),h.__passesFilter=g,h.children){let v=!1;for(const m of h.children)u(m)&&(v=!0);return h.group&&!h.footer&&(d?(h.__passesFilter=g,g&&c(h)):(h.__passesFilter=a?v||g:v,a&&g&&c(h))),h.__passesFilter}return g};for(const h of this.rootRowNodes)u(h)}doesNodePassFilterModel(e,t,i){return this.doesNodePassFilter(e,t,i)}doesNodePassFilter(e,t,i){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const c=[];Lt(e,c);const p=c.map(f=>oe(t,f,null));r=mt(t,t.aggFunc,p)}const d={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,t,i)}if(i.filterType==="multi"){const r=i.filterModels||[];if(r.length===0)return!0;const d=i.operator||"AND",c=r.map(p=>this.doesNodePassFilter(e,t,p));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(i.condition1||i.condition2){const{condition1:r,condition2:d,...c}=i,p=[this.doesNodePassFilter(e,t,{...c,...r||{}})];return d&&p.push(this.doesNodePassFilter(e,t,{...c,...d})),(i.operator||"AND")==="OR"?p.some(Boolean):p.every(Boolean)}const n=oe(t,e,null),o=us(t,n),a=n,l=i.filterType||"text";if(l==="text"){const r=String(i.filter??"").toLowerCase();if(!r)return!0;const d=(a==null?"":String(a)).toLowerCase();switch(i.type){case"equals":return d===r;case"notEqual":return d!==r;case"startsWith":return d.startsWith(r);case"endsWith":return d.endsWith(r);case"contains":default:return d.includes(r)}}if(l==="number"){const r=typeof a=="number"?a:Number(a);if(isNaN(r))return!1;const d=Number(i.filter),c=i.filterTo!==void 0&&i.filterTo!==null&&i.filterTo!==""?Number(i.filterTo):null;switch(i.type){case"equals":return r===d;case"notEqual":return r!==d;case"lessThan":return r<d;case"lessThanOrEqual":return r<=d;case"greaterThan":return r>d;case"greaterThanOrEqual":return r>=d;case"inRange":return c!==null?r>=Math.min(d,c)&&r<=Math.max(d,c):!0;case"blank":return a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(l==="date"){const r=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(r))return!1;const d=i.dateFrom?new Date(i.dateFrom).getTime():null,c=i.dateTo?new Date(i.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return l==="boolean"?!!a==!!i.filter:l==="set"?(i.values||[]).map(d=>String(d)).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,l)=>(a.column.sortIndex??0)-(l.column.sortIndex??0));const n=(a,l)=>{for(const{column:c,direction:p}of t){const f=Ri(c)(a,l)*(p==="asc"?1:-1);if(f!==0)return f}const r=a.rowIndex??0,d=l.rowIndex??0;return r-d},o=a=>{a.sort(n);for(const l of a)l.children&&o(l.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(d=>d.aggFunc&&!d.rowGroup),i=(d,c,p,f)=>{if(c>=e.length)return d;const u=e[c],h=new Map,g=[];for(const m of d){if(!m.__passesFilter)continue;const C=oe(u,m,null),S=cs(C);h.has(S)||(h.set(S,[]),g.push(S)),h.get(S).push(m)}const v=[];for(const m of g){const C=h.get(m),S=`${f}|${u.colId}:${m}`,b=this.rowNodeMap.get(S),y=b||new We({[u.colId]:m},this.rowNodeServices,S);y.group=!0,y.key=m,y.level=p,y.uiLevel=p,y.parent=null,y.children=i(C,c+1,p+1,S);for(const T of y.children)T.parent=y;y.allChildrenCount=Mi(y),y.data={...y.data};const R=[];Lt(y,R);const M={};for(const T of t){const W=R.map(E=>oe(T,E,null));M[T.colId]=mt(T,T.aggFunc,W)}M[u.colId]=m,y.groupData=M,b||this.rowNodeMap.set(S,y),v.push(y)}return v},n=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=i(o,0,0,""),l=d=>{for(const c of d){if(!c.group)continue;const p=Tt(c),f=this.expandedGroups.has(p);n===-1||f?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<n,c.expanded&&this.expandedGroups.add(p),c.children&&l(c.children)}};l(a),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const p=e[c],f=p.sort==="desc"?-1:1,u=Ri(p);d.sort((h,g)=>{const v=oe(p,h,null),m=oe(p,g,null);return u({...h,data:{[p.colId]:v}},{...g,data:{[p.colId]:m}})*f})};e[0].sort&&r(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],i=!!this.options.treeData,n=(a,l)=>{if(a.uiLevel=l,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||i)){const r=a.group?a.children.filter(d=>d.__passesFilter||d.group):a.children;if(a.expanded){for(const d of r)n(d,l+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const d=this.createFooterNode(a,l+1);t.push(d)}}}};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(),l=this.getCurrentPage();let r=0,d=-1;for(let p=0;p<o.length;p++)if(!o[p].masterNode){if(r===l*a){d=p;break}r++}d<0&&(d=o.length);let c=d;for(r=0;c<o.length&&r<a;)o[c].masterNode||r++,c++;for(;c<o.length&&o[c].masterNode;)c++;this.rowsToDisplay=o.slice(d,c)}else this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,l)=>a.__displayIndex=l)}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 We(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 We(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(l=>l.aggFunc&&!l.rowGroup),o=[];for(const l of this.rootRowNodes)l.group?Lt(l,o):l.__passesFilter&&o.push(l);const a={};for(const l of n){const r=o.map(d=>oe(l,d,null));a[l.colId]=mt(l,l.aggFunc,r)}return a.__grandTotal=!0,i.groupData=a,i}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Tt(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(Tt(e)):this.expandedGroups.delete(Tt(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 cs(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Tt(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Mi(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Mi(t),0)}function Lt(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Lt(t,e)}function us(s,e){return e}const hs={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 ps(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 fs(s){return!!s.treeData}function gs(){return{applyAggregate:mt}}class ki{constructor(e,t,i){w(this,"options");w(this,"eventService");w(this,"gridApi");w(this,"measureCtx",null);w(this,"gridColumnDefs",[]);w(this,"columns",[]);w(this,"displayOrder",[]);w(this,"autoGroupColumnDef");w(this,"pivotMode",!1);w(this,"columnGroups",[]);w(this,"openGroups",new Set);w(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=Ti){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 l=i[a],r={field:a,headerName:t(a)};typeof l=="number"?(r.type="numberColumn",r.filter="number"):typeof l=="boolean"?r.type="booleanColumn":l instanceof Date&&(r.type="dateColumn"),o.push(r)}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 c of e)t.set(c.colId,c);const i=this.options.defaultColDef||{},n={...hs,...this.options.columnTypes||{}},o=[],a=[];let l=0;const r=(c,p)=>{const f=c.colId||c.field||Gt("col"),u={...i,...c};if(u.type&&n[u.type]){const h=n[u.type],g=new Set(Object.keys(c));for(const[v,m]of Object.entries(h))!g.has(v)&&!(v in i)&&(u[v]=m)}this.pushColumnInto(o,u,f,l++,t,p)},d=(c,p,f)=>{for(const u of c)if(u.children&&u.children.length){const h=u.groupId||Gt("group"),g={id:h,headerName:u.headerName??"",openByDefault:u.openByDefault===!0||u.columnGroupShow==="open",parentId:p,depth:f,childColumnIds:[]};a.push(g),this.groupsInitialised||(g.openByDefault?this.openGroups.add(h):this.openGroups.delete(h)),d(u.children,h,f+1)}else r(u,p)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,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(o,{...i,...c},"__rowNumber",-1,t,null)}for(const c of o){if(!c.groupId)continue;const p=a.find(f=>f.id===c.groupId);p&&p.childColumnIds.push(c.colId)}this.columns=o,this.displayOrder=o.map(c=>c.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),l=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?Ti(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:l,visible:!l,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:ps(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&&(r.pinned=a.pinned,r.visible=a.visible,r.width=a.width,r.flex=a.flex,r.sort=a.sort,r.sortIndex=a.sortIndex,r.rowGroup=a.rowGroup,r.rowGroupIndex=a.rowGroupIndex,r.pivot=a.pivot,r.pivotIndex=a.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const i=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),n=[];for(const r of t){const d=[],c=new Set;for(const p of e){const f=p==null?void 0:p[r.field],u=String(f);c.has(u)||(c.add(u),d.push(f))}d.sort((p,f)=>p===f?0:String(p)<String(f)?-1:1);for(const p of i){for(const h of d){const g=`__pivot_${r.colId}_${p.colId}_${h}`,v=this.createColumn({colId:g,headerName:`${String(h)}`,width:130,type:p.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:p.cellClass,cellDataType:p.cellDataType},g,-1,new Map,null);v.aggFunc=p.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:h,valueColumnId:p.colId,valueField:p.field},v.valueGetter=m=>this.evaluatePivotValue(v,m.node),n.push(v)}const f=`__pivot_${r.colId}_${p.colId}_total`,u=this.createColumn({colId:f,headerName:"Total",width:130,type:p.type,sortable:!1,filter:!1,cellDataType:p.cellDataType},f,-1,new Map,null);u.aggFunc=p.aggFunc,u.groupId=r.colId,u.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:p.colId,valueField:p.field},u.valueGetter=h=>this.evaluatePivotValue(u,h.node),n.push(u)}}const o=new Set(t.map(r=>r.colId)),a=this.columns.reduce((r,d,c)=>o.has(d.groupId??"")?r:c,0);this.columns.splice(a+1,0,...n);for(const r of n)this.displayOrder.push(r.colId);const l=new Set(this.columnGroups.map(r=>r.id));for(const r of t)l.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const i=e.__pivot;if(!i||!t)return;const n=[],o=c=>{if(!c.children||c.children.length===0){n.push(c);return}for(const p of c.children)o(p)};o(t);const l=(i.pivotValue===void 0?n:n.filter(c=>{var p;return String((p=c.data)==null?void 0:p[i.pivotField])===String(i.pivotValue)})).map(c=>{var p;return(p=c.data)==null?void 0:p[i.valueField]}).filter(c=>typeof c=="number");if(l.length===0)return null;const r=this.columns.find(c=>c.colId===i.valueColumnId),{applyAggregate:d}=gs();return d(r,e.aggFunc,l)}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 c of i)n==="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 a=this.columns.find(c=>c.colId===e);if(!o){a&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const l={...this.autoGroupColumnDef};if(l.colId=e,a)a.headerName=l.headerName??"",a.colDef=l,a.cellRenderer=l.cellRenderer,a.cellRendererParams=l.cellRendererParams,a.width=l.width??a.width,a.minWidth=l.minWidth??a.minWidth,a.pinned=l.pinned??"left";else{const c=this.createColumn(l,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 p=c.node;if(!p)return"";if(p.key!==null&&p.key!==void 0)return p.key;if(fs(this.options))return"";const f=d();return f!=null&&f.field&&p.data?p.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,l=0;for(const d of n)t.includes(d.colId)?l+=d.width:d.flex!==null&&d.flex>0?a+=d.flex:l+=d.width;const r=Math.max(0,e-l-32);if(a>0){for(const d of n)if(d.flex!==null&&d.flex>0&&!t.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/a));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var l,r,d,c,p,f;const i=this.getColumn(e);if(!i)return;let n=this.measureTextWidth(i.headerName)+32;t||(n+=16);const o=((r=(l=this.gridApi)==null?void 0:l.getDisplayedRowCount)==null?void 0:r.call(l))??0,a=Math.min(o,300);for(let u=0;u<a;u++){const h=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,u);if(!h)continue;const g=(f=(p=this.gridApi)==null?void 0:p.getCellText)==null?void 0:f.call(p,i,h);g&&(n=Math.max(n,this.measureTextWidth(g)+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 Ti(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class ms{constructor(){w(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 Li={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:"散点图"},vs={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 ws{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:Li[e]??e}}function Cs(s){return new ws(s??{})}function ys(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class bs{constructor(e){w(this,"eventService");w(this,"columns");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"stores",new Map);w(this,"rowNodeMap",new Map);w(this,"displayRows",[]);w(this,"blockSize");this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}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,l)=>{n.loading=!1,this.onBlockLoaded(e,a,l??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],l=(n.rows.length>0,o),r=this.createNode(a,e,o,l);n.rows[l]=r}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=ys(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${n}`,l=this.rowNodeMap.get(a),r=l instanceof We?l:new We(e,this.rowNodeServices,a);return r.data=e,r.rowIndex=i,o&&(r.group=!0,r.key=String(oe(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(a,r),r}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 l=`${i?i+"|":""}${a.key}`;t(l,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 l=this.stores.get(a);if(l){for(const r of l.rows)if(r){if(i>=e&&i<=t){const d=Math.floor(i/this.blockSize)*this.blockSize,c=d+this.blockSize,p=l.lastRow,f=p!==null?Math.min(p,c):c;i<(l.rows.length||0)&&d<(l.rows.length||0)||(l.lastRow===null||c<=l.lastRow)&&this.loadBlock(a,d,f)}i++,r.group&&r.expanded&&n(`${a?a+"|":""}${r.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 Ss{constructor(e){w(this,"eventService");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"blockSize");w(this,"loading",!1);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.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,i.forEach((o,a)=>{const l=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let r=this.rowNodeMap.get(l);r||(r=new We(o,this.rowNodeServices,l),this.rowNodeMap.set(l,r)),r.data=o,r.rowIndex=e+a,this.nodes[e+a]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const i=Math.floor(e/this.blockSize)*this.blockSize;i+this.blockSize>this.nodes.length&&this.loadBlock(i,i+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),this.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 Es{constructor(e){w(this,"eventService");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"loading",!1);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.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 l=this.rowNodeMap.get(a);l||(l=new We(n,this.rowNodeServices,a),this.rowNodeMap.set(a,l)),l.data=n,l.rowIndex=e+o,this.nodes[e+o-e]=l}),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}}function Ni(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const qe=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class xs{constructor(e,t){w(this,"charts",new Map);w(this,"chartCounter",0);w(this,"currentType","line");w(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(r=>r.aggFunc),a=[],l=o.map(()=>[]);if(i.length>0)((d,c)=>{for(const p of d)if(p.group){const f=i[0]?String(oe(i[0],p,this.grid.getApi())??""):p.key??"";a.push(f);for(let u=0;u<o.length;u++){const h=[];Ii(p,o[u],h),l[u].push(Number(mt(o[u],o[u].aggFunc,h))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(n||(n=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=n?oe(n,r,this.grid.getApi()):"";a.push(String(d??""));for(let c=0;c<o.length;c++){const p=oe(o[c],r,this.grid.getApi());l[c].push(typeof p=="number"?p:Number(p)||0)}}),a.length>200){const r=Math.ceil(a.length/200),d=[],c=l.map(()=>[]);for(let p=0;p<a.length;p+=r){d.push(a[p]);for(let f=0;f<l.length;f++)c[f].push(l[f][p])}return{categories:d,series:o.map((p,f)=>({title:p.headerName,data:c[f]}))}}return{categories:a,series:o.map((r,d)=>({title:r.headerName,data:l[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const t=document.createElement("div");t.className="ag-side-bar-section-title",t.textContent=this.grid.t("integratedCharts"),e.appendChild(t);const i=document.createElement("div");i.className="ag-chart-panel-label",i.textContent=this.grid.t("chartType"),e.appendChild(i);const 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 v of o){const m=document.createElement("option");m.value=v.value,m.textContent=v.label,v.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 l=document.createElement("select");l.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 m=document.createElement("option");m.value=v.colId,m.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${v.headerName}`:v.headerName,l.appendChild(m)}e.appendChild(l);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent=this.grid.t("chartSeries"),e.appendChild(c);const p=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),f=document.createElement("div");f.className="ag-chart-panel-series";const u=new Set(p.slice(0,3).map(v=>v.colId));for(const v of this.grid.getColumns().center.filter(m=>m.field)){const m=document.createElement("label");m.className="ag-chart-panel-series-item";const C=document.createElement("input");C.type="checkbox",C.checked=u.has(v.colId),C.addEventListener("change",()=>{C.checked?u.add(v.colId):u.delete(v.colId)}),m.appendChild(C);const S=document.createElement("span");S.textContent=v.headerName,m.appendChild(S),f.appendChild(m)}e.appendChild(f);const h=document.createElement("button");h.className="ag-button ag-button-primary ag-chart-panel-create",h.textContent=this.grid.t("createChart"),h.addEventListener("click",()=>{const v=this.grid.getColumn(l.value)||void 0,m=[...u].map(C=>this.grid.getColumn(C)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:m})}),e.appendChild(h);const g=document.createElement("div");if(g.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent=this.grid.t("noChartsCreated"),g.appendChild(v)}for(const[v,m]of this.charts){const C=document.createElement("div");C.className="ag-chart-panel-list-item";const S=document.createElement("span");S.textContent=m.title,C.appendChild(S);const b=document.createElement("button");b.className="ag-column-group-remove",b.textContent="×",b.addEventListener("click",()=>this.destroyChart(v)),C.appendChild(b),g.appendChild(C)}return e.appendChild(g),e}createChart(e={}){var v,m,C,S;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 l=document.createElement("div");l.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=o,l.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent=this.grid.t("downloadPng"),l.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title=this.grid.t("close"),c.addEventListener("click",()=>this.destroyChart(n)),l.appendChild(c),a.appendChild(l);const p=document.createElement("div");p.className="ag-chart-window-body";const f=document.createElement("canvas");f.className="ag-chart-canvas",f.width=600,f.height=360,p.appendChild(f);const u=document.createElement("div");u.className="ag-chart-tooltip",u.style.display="none",p.appendChild(u),f.addEventListener("mousemove",b=>this.onChartHover({id:n,ePopup:a,canvas:f,type:t,data:i,title:o},b,u)),f.addEventListener("mouseleave",()=>{u.style.display="none"});const h=document.createElement("div");h.className="ag-chart-legend",p.appendChild(h),a.appendChild(p),this.timeSeries=i.categories.length>0&&i.categories.every(b=>!isNaN(Date.parse(String(b)))&&isNaN(Number(b)));const g={id:n,ePopup:a,canvas:f,type:t,data:i,title:o};return this.charts.set(n,g),d.addEventListener("click",()=>{const b=f.toDataURL("image/png"),y=document.createElement("a");y.href=b,y.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,y.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(g),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:n,chartTitle:o,api:this.grid.getApi()}),(m=(v=this.grid.getOptions()).onChartCreated)==null||m.call(v,{chartId:n,chartTitle:o,api:this.grid.getApi()}),((C=this.grid.getSideBarService())==null?void 0:C.getActivePanel())==="charts"&&((S=this.grid.getSideBarService())==null||S.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),l=360/(o.height||1),r=(t.clientX-o.left)*a,d=(t.clientY-o.top)*l,c={top:20,right:20,bottom:34,left:56},p=600-c.left-c.right,f=360-c.top-c.bottom;if(r<c.left||r>c.left+p||d<c.top||d>c.top+f){i.style.display="none";return}if(e.type==="pie"){i.style.display="none";return}const u=e.type==="bar",h=Math.max(1,e.data.categories.length),g=(u?f:p)/h,v=Math.floor((u?d-c.top:r-c.left)/g);if(v<0||v>=e.data.categories.length){i.style.display="none";return}const m=e.data.series.map(C=>`${C.title}: ${this.formatTick(C.data[v]??0)}`);i.innerHTML=`<div class="ag-chart-tooltip-title">${Ni(e.data.categories[v])}</div>`+m.map(C=>`<div>${Ni(C)}</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 l=document.createElement("div");l.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,l.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",l.appendChild(d),i.appendChild(l);const c={id:t,ePopup:i,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,c),this.popupService.positionAt(i,this.grid.getRootElement()),i.style.top="60px",this.renderChart(c)}renderChart(e){var W;const t=e.canvas,i=t.getContext("2d");if(!i)return;const 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 l=getComputedStyle(this.grid.getRootElement()),r=l.getPropertyValue("--ag-chart-text-color")||"#666",d=l.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},p=o-c.left-c.right,f=a-c.top-c.bottom;i.font="11px sans-serif",i.fillStyle=r,i.strokeStyle=d,i.lineWidth=1;const u=(W=e.canvas.parentElement)==null?void 0:W.querySelector(".ag-chart-legend");if(u&&(u.innerHTML="",e.data.series.forEach((E,x)=>{const k=document.createElement("span");k.className="ag-chart-legend-item";const $=document.createElement("span");$.className="ag-chart-legend-swatch",$.style.backgroundColor=qe[x%qe.length],k.appendChild($),k.appendChild(document.createTextNode(E.title)),u.appendChild(k)})),e.type==="pie"){this.renderPie(i,e.data,o,a,r);return}const h=e.data.series.flatMap(E=>E.data);let g=Math.max(0,...h),v=Math.min(0,...h);e.type==="scatter"&&(v=Math.min(...h),g=Math.max(...h));const m=g-v||1;g+=m*.08,v-=v<0?m*.08:0;const C=g-v||1,S=E=>c.top+f-(E-v)/C*f,b=5;i.textAlign="right",i.textBaseline="middle";for(let E=0;E<=b;E++){const x=v+C*E/b,k=S(x);i.beginPath(),i.moveTo(c.left,k),i.lineTo(o-c.right,k),i.stroke(),i.fillText(this.formatTick(x),c.left-6,k)}const y=e.data.categories,R=e.type==="bar",M=Math.max(1,y.length),T=(R?f:p)/M;if(R){i.textAlign="left",y.forEach((x,k)=>{const $=c.top+k*T,q=Math.max(2,T*.7/e.data.series.length);e.data.series.forEach((F,G)=>{const I=F.data[k]||0,L=Math.abs(I)/C*p,D=c.left+(0-v)/C*p;i.fillStyle=qe[G%qe.length],i.fillRect(D,$+G*q,Math.max(1,L),q-1)}),i.fillStyle=r,i.fillText(this.truncate(x,18),c.left+4,$+T/2)});const E=c.left+(0-v)/C*p;i.beginPath(),i.moveTo(E,c.top),i.lineTo(E,c.top+f),i.strokeStyle=r,i.stroke()}else{const E=Math.max(1,Math.ceil(M/12));i.textAlign="center",i.textBaseline="top",y.forEach(($,q)=>{if(q%E!==0)return;const F=c.left+T*(q+.5);i.fillStyle=r,i.fillText(this.truncate($,10),F,c.top+f+6)});const x=e.data.series.length,k=Math.max(1,T*.7/Math.max(1,x));e.data.series.forEach(($,q)=>{const F=qe[q%qe.length];if(e.type==="column")i.fillStyle=F,$.data.forEach((G,I)=>{const L=c.left+T*I+(T-k*x)/2+q*k,D=S(G);i.fillRect(L,D,k-1,c.top+f-D)});else if(e.type==="area"){i.beginPath(),$.data.forEach((I,L)=>{const D=c.left+T*(L+.5),z=S(I);L===0?i.moveTo(D,z):i.lineTo(D,z)});const G=c.left+T*($.data.length-.5);i.lineTo(G,c.top+f),i.lineTo(c.left+T*.5,c.top+f),i.closePath(),i.globalAlpha=.25,i.fillStyle=F,i.fill(),i.globalAlpha=1,i.beginPath(),$.data.forEach((I,L)=>{const D=c.left+T*(L+.5),z=S(I);L===0?i.moveTo(D,z):i.lineTo(D,z)}),i.strokeStyle=F,i.lineWidth=2,i.stroke()}else e.type==="scatter"?(i.fillStyle=F,$.data.forEach((G,I)=>{const L=c.left+T*(I+.5),D=S(G);i.beginPath(),i.arc(L,D,3,0,Math.PI*2),i.fill()})):(i.beginPath(),$.data.forEach((G,I)=>{const L=c.left+T*(I+.5),D=S(G);I===0?i.moveTo(L,D):i.lineTo(L,D)}),i.strokeStyle=F,i.lineWidth=2,i.stroke())})}}renderPie(e,t,i,n,o){const a=t.series[0];if(!a)return;const l=a.data.reduce((f,u)=>f+Math.abs(u),0)||1,r=i/2,d=n/2,c=Math.min(i,n)/2-30;let p=-Math.PI/2;a.data.forEach((f,u)=>{const h=Math.abs(f)/l*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,p,p+h),e.closePath(),e.fillStyle=qe[u%qe.length],e.fill();const g=p+h/2,v=r+Math.cos(g)*(c*.7),m=d+Math.sin(g)*(c*.7),C=Math.round(Math.abs(f)/l*100);C>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${C}%`,v,m)),p+=h}),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 Ii(s,e,t){const i=s.children;if(!i||i.length===0){const n=oe(e,s,null);typeof n=="number"&&!isNaN(n)&&t.push(n);return}for(const n of i)Ii(n,e,t)}class Rs{constructor(e){w(this,"eGui");var d,c,p;const t=e.node,i=!!t.group,n=!!t.detailNode,o=i||n,a=t.expanded,l=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${l}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?_s:zs,r.appendChild(f);const u=document.createElement("span");u.className="ag-group-value";const h=(d=e.colDef.cellRendererParams)==null?void 0:d.innerRenderer;if(typeof h=="function"){const g=h({...e,value:e.value,valueFormatted:e.valueFormatted});g instanceof HTMLElement?u.appendChild(g):typeof g=="string"&&(u.innerHTML=g)}else u.textContent=Ds(e.value);if(r.appendChild(u),i&&t.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const g=document.createElement("span");g.className="ag-group-child-count",g.textContent=` (${t.allChildrenCount})`,r.appendChild(g)}}else{const f=document.createElement("span");f.className="ag-group-value";const u=(p=e.colDef.cellRendererParams)==null?void 0:p.innerRenderer;if(typeof u=="function"){const h=u({...e,value:e.value,valueFormatted:e.valueFormatted});h instanceof HTMLElement?f.appendChild(h):typeof h=="string"&&(f.innerHTML=h)}else f.textContent=e.valueFormatted??String(e.value??"");r.appendChild(f)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class Ms{constructor(e){w(this,"eGui");w(this,"eCheckbox");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.eCheckbox.checked=!!e.node.selected,!0}}const ks='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',Ts='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class Ls{constructor(e){w(this,"eGui");w(this,"eArrow");w(this,"eOld");w(this,"eNew");w(this,"lastValue");w(this,"flashTimer",null);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?ks:Ts,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 Ns{constructor(e){w(this,"eGui");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.eGui.textContent=String(e.rowIndex+1),!0}}class Is{constructor(e){w(this,"eGui");var r,d;const t=document.createElement("span");t.className="ag-sparkline-cell";const i=e.value||[],n=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},o=e.column.width||100,a=n.height||24,l=qt(i,Math.max(20,o-16),a,n);t.appendChild(l),this.eGui=t}getGui(){return this.eGui}refresh(e){var l,r;const t=e.value||[],i=e.sparklineOptions||((r=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:r.sparklineOptions)||{},n=e.column.width||100,o=i.height||24;this.eGui.innerHTML="";const a=qt(t,Math.max(20,n-16),o,{type:i.type,direction:i.direction});return this.eGui.appendChild(a),!0}}function qt(s,e,t,i={}){var m,C,S;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(b=>typeof b=="number"?b:Number((b==null?void 0:b.value)??0));if(!o||o.length<1)return n;const a=i.type||"line",l=Math.min(...o,0),d=Math.max(...o,0)-l||1,c=((m=i.tooltip)==null?void 0:m.enabled)===!0,p=((C=i.axis)==null?void 0:C.type)||"number",f=((S=i.pointsOfInterest)==null?void 0:S.show)===!0,u=(b,y)=>p==="category"?`${b+1}: ${y}`:String(y);if(f&&o.length>1){const b=o.indexOf(Math.min(...o)),y=o.indexOf(Math.max(...o)),R=e/Math.max(1,o.length-1),M=W=>t-2-(W-l)/d*(t-4),T=(W,E)=>{const x=document.createElementNS("http://www.w3.org/2000/svg","circle");x.setAttribute("cx",String(W*R)),x.setAttribute("cy",String(M(o[W]))),x.setAttribute("r","2.5"),x.setAttribute("fill",E),n.appendChild(x)};T(0,"#4caf50"),T(o.length-1,"#f44336"),T(b,"#2196f3"),T(y,"#ff9800")}if(c){const b=document.createElementNS("http://www.w3.org/2000/svg","title");b.textContent=o.map((y,R)=>u(R,y)).join(`
|
|
3
|
-
`),n.appendChild(b),n.style.cursor="default"}if(a==="bar"){const b=i.direction==="vertical",y=o.length;if(b){const R=Math.max(1,e/y-1),M=t-2-(0-l)/d*(t-4);o.forEach((T,W)=>{const E=W*(e/y),x=t-2-(T-l)/d*(t-4),k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("x",String(E)),k.setAttribute("width",String(R)),k.setAttribute("y",String(Math.min(x,M))),k.setAttribute("height",String(Math.max(1,Math.abs(M-x)))),k.setAttribute("fill","currentColor"),n.appendChild(k)})}else{const R=Math.max(1,t/y-1),M=2+(0-l)/d*(e-4);o.forEach((T,W)=>{const E=W*(t/y),x=2+(T-l)/d*(e-4),k=document.createElementNS("http://www.w3.org/2000/svg","rect");k.setAttribute("y",String(E)),k.setAttribute("height",String(R)),k.setAttribute("x",String(Math.min(x,M))),k.setAttribute("width",String(Math.max(1,Math.abs(M-x)))),k.setAttribute("fill","currentColor"),n.appendChild(k)})}return n}const h=e/Math.max(1,o.length-1),g=o.map((b,y)=>{const R=y*h,M=t-2-(b-l)/d*(t-4);return`${R.toFixed(1)},${M.toFixed(1)}`});if(a==="area"){const b=document.createElementNS("http://www.w3.org/2000/svg","polygon");b.setAttribute("points",`0,${t} ${g.join(" ")} ${e},${t}`),b.setAttribute("fill","currentColor"),b.setAttribute("opacity","0.2"),n.appendChild(b)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",g.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),n.appendChild(v),n}class As{constructor(e){w(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Ai,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const Nt={agGroupCellRenderer:s=>new Rs(s),agCheckboxCellRenderer:s=>new Ms(s),agSparklineCellRenderer:s=>new Is(s),agAnimateShowChangeCellRenderer:s=>new Ls(s),agRowNumberCellRenderer:s=>new Ns(s),agRowDragComp:s=>new As(s)};function Ds(s){return s==null?"":String(s)}class Fs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);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 Ps{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"cancelled",!1);var n,o;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",r=>{var d,c;r.preventDefault(),r.preventDefault(),i.value=String(Number(i.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const l=document.createElement("span");l.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",l.innerHTML="▼",l.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),i.value=String(Number(i.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),t.appendChild(a),t.appendChild(i),t.appendChild(l)}else t.appendChild(i);this.eGui=t,this.eInput=i,this.eInput.addEventListener("keydown",a=>{var l;return(l=e.onKeyDown)==null?void 0:l.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 $s{constructor(e){w(this,"eGui");w(this,"cancelled",!1);var i,n;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 Hs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);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 Os{constructor(e){w(this,"eGui");w(this,"cancelled",!1);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 Bs(s,e){if(!e)return H(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?H(s):H(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+H(s.slice(t,t+e.length))+"</span>"+H(s.slice(t+e.length))}class Vs{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"ePopup",null);w(this,"eList",null);w(this,"values",[]);w(this,"filtered",[]);w(this,"activeIndex",0);w(this,"selectedValue");w(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,l;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,Gs(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((l=(a=this.params).t)==null?void 0:l.call(a,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const n=document.createElement("div");n.className="ag-rich-select-list",e.appendChild(n),this.eList=n,this.renderList();const o=r=>{!e.contains(r.target)&&!this.eGui.contains(r.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(),l=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?l.every(r=>a.includes(r)):l.some(r=>a.includes(r))}),this.filtered.forEach((o,a)=>{const l=document.createElement("div");l.className="ag-rich-select-item",a===this.activeIndex&&l.classList.add("ag-active"),String(o)===String(this.selectedValue)&&l.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const d=r({value:o,valueFormatted:String(o)});d instanceof HTMLElement?l.appendChild(d):l.textContent=String(d)}else l.innerHTML=Bs(String(o),e);l.addEventListener("click",d=>{d.stopPropagation(),this.commit(o)}),l.addEventListener("mousedown",d=>d.preventDefault()),this.eList.appendChild(l)}),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 Gs(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 Ue={agTextCellEditor:s=>new Fs(s),agNumberCellEditor:s=>new Ps(s),agSelectCellEditor:s=>new $s(s),agDateCellEditor:s=>new Hs(s),agLargeTextCellEditor:s=>new Os(s),agRichSelectCellEditor:s=>new Vs(s)},zs='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',_s='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Ai='<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>',Ws='<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>',qs='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M1 2h14l-5.2 6v5.3L6.2 15V8L1 2z"/></svg>',Us='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',js='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Di='<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>';class Ks{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=(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 p=document.createElement("span");p.className="ag-menu-item-check",d.checked&&(p.innerHTML=Di),c.appendChild(p);const f=document.createElement("span");if(f.className="ag-menu-item-label",f.textContent=r,c.appendChild(f),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(),n()}),i.appendChild(c),c},l=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,i.appendChild(d)};e.sortable&&(l(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&&(l(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||(l(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?(l(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&&(l(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),l(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)}),l(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)}}const Fi={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 Ys{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 r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);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&&Fi[n.icon]&&(a.innerHTML=Fi[n.icon]),o.appendChild(a);const l=document.createElement("span");if(l.className="ag-menu-item-label",l.textContent=n.label??n.name,o.appendChild(l),n.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=n.shortcut,o.appendChild(r)}if(n.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",o.appendChild(r),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,n.subMenu,i),e.appendChild(c)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;o.matches(":hover")||((c=o.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove())},200)})}else!n.disabled&&n.action&&o.addEventListener("click",()=>{n.action(),i()});e.appendChild(o)}}}class Xs{constructor(e,t){w(this,"editing",null);w(this,"fullRowEditors",null);w(this,"fullRowNode",null);w(this,"focusedCell",null);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.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 d;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const i=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!i||!this.grid.isCellEditable(t,i))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,i,e.charPress);return}const n=this.findCellElement(t,e.rowIndex);if(!n)return;const o=oe(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:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=t.cellEditorParams)==null?void 0:d.values,...t.cellEditorParams};let l;if(typeof t.cellEditor=="string")l=(Ue[t.cellEditor]||Ue.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const c=t.cellEditor(a);l=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";l=Ue[c](a)}if(!l)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:i,eCell:n,editor:l,startedValue:o},n.classList.add("ag-cell-inline-editing");const r=l.getGui();r.classList.add("ag-cell-editor"),n.appendChild(r),n.classList.add("ag-cell-editing"),l.focusIn&&l.focusIn(),l.afterGuiAttached&&l.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 l=oe(o,t,this.grid.getApi()),r=this.createEditor(o,t,e,l,i);if(!r)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),a.appendChild(d),this.fullRowEditors.push({column:o,editor:r,eCell:a,startedValue:l})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,i,n,o){var r;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:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(Ue[e.cellEditor]||Ue.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const d=e.cellEditor(a);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const l=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return Ue[l](a)}stopEditing(e=!1){var d,c,p,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:l}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?l:a.getValue();if(r===void 0&&!e)return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!1;if(!e){r=Ei(i,r);const u=this.applyValueSetter(i,n,r);if(u===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:i}),!1;r=u}return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:i,node:n,api:this.grid.getApi()}),!e&&!Pi(r,l)&&(this.grid.setCellValue(i,n,r,"edit",l),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l,newValue:r,value:r,data:n.data,node:n,column:i,colDef:i.colDef,api:this.grid.getApi(),source:"edit"}),(f=(p=this.grid.getOptions()).onCellValueChanged)==null||f.call(p,{oldValue:l,newValue:r,value:r,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:oe(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,l;const t=this.fullRowEditors,i=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=r.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const n=[];for(const r of t){if(!i)break;let d=r.editor.getValue();d!==void 0&&(d=Ei(r.column,d),Pi(d,r.startedValue)||n.push({column:r.column,rowNode:i,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:i==null?void 0:i.data});for(const r of n)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"}),(l=(a=this.grid.getOptions()).onCellValueChanged)==null||l.call(a,{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===13){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===27)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===9){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 13:e.preventDefault(),i&&(this.grid.isCellEditable(i.column,i.rowNode)?this.startEditingCell({rowIndex:i.rowIndex,colKey:i.column}):this.moveFocus(1,0));break;case 9:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case 8:case 46: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 36:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case 35: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 l=o.findIndex(r=>r.colId===i.column.colId)+t;for(;l>=0&&l<o.length&&!o[l].visible;)l+=t;l<0&&(l=0),l>=o.length&&(l=o.length-1),this.setFocusedCell(n,o[l])}else this.setFocusedCell(n,i.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:i}=e;if(this.setFocusedCell(e.rowIndex,i),i.checkboxSelection)return;const n=this.grid.isCellEditable(i,t),o=i.singleClickEdit||this.grid.getOptions().singleClickEdit;n&&o&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}onCellDoubleClicked(e){const{node:t,column:i}=e;this.setFocusedCell(e.rowIndex,i),this.grid.isCellEditable(i,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:i})}destroy(){this.editing=null,this.focusedCell=null}}function Pi(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}const Zs={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function $i(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function Qs(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 Js(){return new TextEncoder}function eo(s,e={}){const[t,i]=Zs[e.pageSize||"a4-landscape"],n=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,l=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=Js(),c=[],p=C=>(c.push(C),c.length);p(""),p("");const f=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),u=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),h=[];for(const C of s){let S="";const b=C.columnWidths.reduce(($,q)=>$+q,0),y=Math.min(1,(t-n*2)/(b||1)),R=C.columnWidths.map($=>$*y),M=n;let T=i-n-(e.title?24:0);e.title&&(S+=`BT /F2 ${o+4} Tf ${M} ${T} Td (${$i(e.title)}) Tj ET
|
|
4
|
-
`,
|
|
5
|
-
`);let
|
|
6
|
-
`,
|
|
7
|
-
`,
|
|
8
|
-
`;const
|
|
1
|
+
(function(Y,qe){typeof exports=="object"&&typeof module<"u"?qe(exports):typeof define=="function"&&define.amd?define(["exports"],qe):(Y=typeof globalThis<"u"?globalThis:Y||self,qe(Y.Rowvia={}))})(this,function(Y){"use strict";var br=Object.defineProperty;var Cr=(Y,qe,bt)=>qe in Y?br(Y,qe,{enumerable:!0,configurable:!0,writable:!0,value:bt}):Y[qe]=bt;var w=(Y,qe,bt)=>Cr(Y,typeof qe!="symbol"?qe+"":qe,bt);function D(s){return s==null?"":String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}let gs=0;function Yt(s="id"){return`${s}-${++gs}`}function _e(s,e){if(typeof s!="number"||isNaN(s))return String(s??"");const t=e??0,n=s.toFixed(t),[i,o]=n.split("."),a=i.replace(/\B(?=(\d{3})+(?!\d))/g,",");return o?`${a}.${o}`:a}function Xt(s){if(s==null||s==="")return null;const e=Number(s);return isNaN(e)?null:e}function ms(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(),n=String(e).toLowerCase();return t<n?-1:t>n?1:0}function vs(s,e){return e==null?!1:String(e).toLowerCase().includes(s.toLowerCase())}class Ve extends Error{constructor(e){super(e),this.code=e}}const ws=/^\$?[A-Za-z]{1,3}\$?\d+$/;function An(s){const e=[];let t=0;for(;t<s.length;){const n=s[t];if(n===" "||n===" "||n===`
|
|
2
|
+
`||n==="\r"){t++;continue}if(n==='"'||n==="'"){const o=n;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(n)||n==="."&&/[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(n)){let o="";for(;t<s.length&&/[A-Za-z0-9_$.]/.test(s[t]);)o+=s[t++];ws.test(o)?e.push({type:"cell",value:o.toUpperCase().replace(/\$/g,"")}):e.push({type:"ident",value:o});continue}if(n==="("){e.push({type:"lparen",value:n}),t++;continue}if(n===")"){e.push({type:"rparen",value:n}),t++;continue}if(n===","||n===";"){e.push({type:"comma",value:","}),t++;continue}const i=s.slice(t,t+2);if(["<=",">=","<>"].includes(i)){e.push({type:"op",value:i}),t+=2;continue}if("+-*/^%&=<>,:".includes(n)){e.push({type:"op",value:n}),t++;continue}throw new Ve("#NAME?")}return e}const $n={"&":1,"=":2,"<>":2,"<":2,"<=":2,">":2,">=":2,"+":4,"-":4,"*":5,"/":5,"%":6,"^":7};function Fn(s){let e=0;const t=()=>s[e],n=()=>s[e++];function i(r=0){let d=o();for(;t()&&t().type==="op"&&$n[t().value]>=r;){const c=n().value,p=i($n[c]+1);d={type:"binary",operator:c,left:d,right:p}}return d}function o(){const r=t();if(r&&r.type==="op"&&(r.value==="-"||r.value==="+")){n();const d=o();return r.value==="-"?{type:"unary",operator:"-",operand:d}:d}return a()}function a(){const r=n();if(!r)throw new Ve("#ERROR!");if(r.type==="number")return{type:"number",value:Number(r.value)};if(r.type==="string")return{type:"string",value:r.value};if(r.type==="cell")return{type:"cell",value:r.value};if(r.type==="ident"){const d=r.value.toUpperCase();if(d==="TRUE")return{type:"boolean",value:!0};if(d==="FALSE")return{type:"boolean",value:!1};const c=t();if(c&&c.type==="lparen"){n();const p=[];if(t()&&t().type!=="rparen")for(p.push(i());t()&&t().type==="comma";)n(),p.push(i());if(!t()||t().type!=="rparen")throw new Ve("#ERROR!");return n(),{type:"call",name:d,args:p}}return{type:"ref",value:r.value}}if(r.type==="lparen"){const d=i();if(!t()||t().type!=="rparen")throw new Ve("#ERROR!");return n(),d}throw new Ve("#ERROR!")}const l=i();if(e<s.length)throw new Ve("#ERROR!");return l}function ye(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 rt(s){const e=[];for(const t of s)if(Array.isArray(t))e.push(...rt(t));else if(t!=null&&t!==""){const n=typeof t=="number"?t:Number(t);isNaN(n)||e.push(n)}return e}const $t={SUM:s=>rt(s).reduce((e,t)=>e+t,0),AVERAGE:s=>{const e=rt(s);return e.length?e.reduce((t,n)=>t+n,0)/e.length:0},AVG:s=>$t.AVERAGE(s,{}),MIN:s=>{const e=rt(s);return e.length?Math.min(...e):0},MAX:s=>{const e=rt(s);return e.length?Math.max(...e):0},COUNT:s=>rt(s).length,COUNTA:s=>s.filter(e=>e!=null&&e!=="").length,ABS:s=>Math.abs(ye(s[0])),ROUND:s=>{const e=s.length>1?ye(s[1]):0,t=Math.pow(10,e);return Math.round(ye(s[0])*t)/t},FLOOR:s=>Math.floor(ye(s[0])),CEIL:s=>Math.ceil(ye(s[0])),CEILING:s=>Math.ceil(ye(s[0])),SQRT:s=>{const e=ye(s[0]);return e<0?(()=>{throw new Ve("#NUM!")})():Math.sqrt(e)},POWER:s=>Math.pow(ye(s[0]),ye(s[1])),POW:s=>Math.pow(ye(s[0]),ye(s[1])),MOD:s=>{const e=ye(s[1]);if(e===0)throw new Ve("#DIV/0!");return ye(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?ye(s[1]):1),RIGHT:s=>{const e=String(s[0]??""),t=s.length>1?ye(s[1]):1;return t<=0?"":e.slice(-t)},MID:s=>{const e=String(s[0]??""),t=Math.max(0,ye(s[1])-1),n=s.length>2?ye(s[2]):e.length-t;return e.slice(t,t+n)},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=>ye(s[0]),NUMBER:s=>ye(s[0]),BETWEEN:s=>ye(s[0])>=ye(s[1])&&ye(s[0])<=ye(s[2])},Ft=Object.keys($t);function ys(s,e){$t[s.toUpperCase()]=e,Ft.includes(s.toUpperCase())||Ft.push(s.toUpperCase())}function bs(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 Cs(s,e){const t=e.data||{};if(s in t)return t[s];const n=s.toLowerCase();for(const i of Object.keys(t))if(i.toLowerCase()===n)return t[i]}function Ct(s,e){switch(s.type){case"number":return s.value;case"string":return s.value;case"boolean":return s.value;case"ref":return Cs(s.value,e);case"cell":return bs(s.value,e);case"unary":return-ye(Ct(s.operand,e));case"call":{const t=$t[s.name];if(!t)throw new Ve("#NAME?");const n=s.args.map(i=>Ct(i,e));return t(n,e)}case"binary":{const t=Ct(s.left,e),n=Ct(s.right,e);switch(s.operator){case"+":return typeof t=="string"||typeof n=="string"?`${t??""}${n??""}`:ye(t)+ye(n);case"-":return ye(t)-ye(n);case"*":return ye(t)*ye(n);case"/":{const i=ye(n);if(i===0)throw new Ve("#DIV/0!");return ye(t)/i}case"^":return Math.pow(ye(t),ye(n));case"%":{const i=ye(n);if(i===0)throw new Ve("#DIV/0!");return ye(t)%i}case"&":return`${t??""}${n??""}`;case"=":return t===n;case"<>":return t!==n;case"<":return ye(t)<ye(n);case"<=":return ye(t)<=ye(n);case">":return ye(t)>ye(n);case">=":return ye(t)>=ye(n);default:throw new Ve("#ERROR!")}}default:throw new Ve("#ERROR!")}}function St(s,e={}){const t=s.startsWith("=")?s.slice(1):s,n=Fn(An(t));return Ct(n,e)}function Zt(s){return typeof s=="string"&&s.trimStart().startsWith("=")}function Qt(s,e){if(s==null)return;if(e in s)return s[e];const t=e.split(".");let n=s;for(const i of t){if(n==null)return;n=n[i]}return n}function Se(s,e,t){const n=s.colDef,i=(e.group||e.footer)&&!!e.groupData&&e.groupData[s.colId]!==void 0,o=i?e.groupData:e.data,a=s.valueGetter??n.valueGetter;if(a)return(typeof a=="string"?r=>Zt(a)?St(a,{data:r.data}):Qt(r.data,a):a)({data:i?e.groupData:e.data,node:e,column:s,api:t,colDef:n,getValue:r=>Qt(i?e.groupData:e.data,r)});if(s.field&&Zt(s.field))return St(s.field,{data:e.data});if(s.field&&s.colDef.expression&&/[+*/^-]/.test(s.field))return St(`=${s.field}`,{data:e.data});if(s.field)return Qt(o,s.field)}function Dt(s,e,t){var o;const n=Se(s,e,t),i=s.colDef;if(i.showValueAs&&typeof n=="number"&&t){const a=(o=t.__columnTotalCache)==null?void 0:o.get(s.colId);if(a!==void 0&&a!==0)return`${(i.showValueAs==="percentOfParent"?n/(a||1)*100:n/a*100).toFixed(1)}%`}return i.valueFormatter?(typeof i.valueFormatter=="string"?l=>Ss(l.colDef.valueFormatter,l.value,l):i.valueFormatter)({value:n,data:e.data,node:e,column:s,api:t,colDef:i}):Es(s,n)}function Ss(s,e,t={}){var n,i,o;if(e==null)return"";switch(s){case"number":return _e(e,((n=t.column)==null?void 0:n.decimals)??0);case"currency":return`$${_e(e,((i=t.column)==null?void 0:i.decimals)??2)}`;case"percent":return`${_e(e,((o=t.column)==null?void 0:o.decimals)??2)}%`;case"date":return Dn(e);case"boolean":return e?"✓":"✗";default:return String(e)}}function Dn(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 Es(s,e){if(e==null)return"";const t=s.type;return t==="numberColumn"&&typeof e=="number"&&!isNaN(e)?_e(e,s.decimals):t==="dateColumn"||t==="dateStringColumn"?Dn(e):t==="booleanColumn"?e?"✓":"✗":String(e)}function Pn(s,e){return s.colDef.valueParser?(typeof s.colDef.valueParser=="string"?n=>Hn(n.colDef.valueParser,n.newValue):s.colDef.valueParser)({newValue:e,oldValue:e,data:null,node:null,column:s,colDef:s.colDef,api:null}):Hn(s.type,e)}function Hn(s,e){if(s==="numberColumn")return Xt(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 On(s){const t=s.colDef.comparator,n=s.type;return(i,o)=>{const a=Se(s,i,null),l=Se(s,o,null);if(t)return t(a,l,i,o);if(n==="numberColumn"){const r=typeof a=="number"?a:Xt(a),d=typeof l=="number"?l:Xt(l);return r!==null&&d!==null?r-d:r===null&&d===null?0:r===null?-1:1}if(n==="dateColumn"){const r=a instanceof Date?a.getTime():new Date(a).getTime(),d=l instanceof Date?l.getTime():new Date(l).getTime();if(!isNaN(r)&&!isNaN(d))return r-d}return ms(a,l)}}function Et(s,e,t){if(!e)return null;if(typeof e=="function")return e({values:t,column:s,rowNode:null,data:null});const n=t.filter(i=>typeof i=="number"&&!isNaN(i));switch(e){case"sum":return n.reduce((i,o)=>i+o,0);case"count":return t.length;case"avg":return n.length?n.reduce((i,o)=>i+o,0)/n.length:null;case"min":return n.length?Math.min(...n):null;case"max":return n.length?Math.max(...n):null;case"first":return t.length?t[0]:null;case"last":return t.length?t[t.length-1]:null;default:return null}}function xs(s){const e={onInteraction:s.onInteraction,setRowData:n=>s.setRowData(n),applyTransaction:n=>s.applyTransaction(n),getRowNode:n=>s.getRowNode(n),getDisplayedRowCount:()=>s.getDisplayedRowCount(),getDisplayedRowAtIndex:n=>s.getDisplayedRowAtIndex(n),getFirstDisplayedRow:()=>s.getDisplayedRowAtIndex(0),getLastDisplayedRow:()=>s.getDisplayedRowAtIndex(s.getDisplayedRowCount()-1),forEachNode:n=>{const i=s.getRowModel();for(let o=0;o<i.getRowCount();o++){const a=i.getRow(o);a&&n(a,o)}},forEachLeafNode:n=>{s.getRowModel().forEachLeafNode(n)},getModel:()=>s.getRowModel(),getValue:(n,i)=>{const o=typeof n=="string"?s.getColumn(n):n;if(!(!o||!i))return Se(o,i,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:(n,i)=>s.getSelectionService().selectNode(n,i??!1),deselectNode:n=>s.getSelectionService().deselectNode(n),setQuickFilter:n=>s.setQuickFilter(n),isQuickFilterPresent:()=>s.getQuickFilter().length>0,resetQuickFilter:()=>s.setQuickFilter(""),getSortModel:()=>s.getSortService().getSortModel(),setSortModel:n=>s.getSortService().setSortModel(n),getFilterModel:()=>s.getFilterService().getFilterModel(),setFilterModel:n=>s.getFilterService().setFilterModel(n),getColumnFilterModel:n=>{const i=typeof n=="string"?n:n.colId;return s.getFilterService().getFilterInstance(i)??null},setColumnFilterModel:(n,i)=>s.getFilterService().setColumnFilterModel(n,i),getAdvancedFilterModel:()=>s.getFilterService().getAdvancedFilterModel(),setAdvancedFilterModel:n=>s.getFilterService().setAdvancedFilterModel(n),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:(n,i)=>s.setRowNodePinned(n,i),getColumnDefs:()=>s.getColumnModel().getColumnDefs(),setColumnDefs:(n,i)=>{s.getColumnModel().setColumnDefs(n),s.onGridSizeChanged()},updateGridOptions:n=>s.updateGridOptions(n),setGridOption:(n,i)=>s.updateGridOptions({[n]:i}),sizeColumnsToFit:()=>{const n=s.getSideBarService().isVisible()?s.getSideBarService().getElement().offsetWidth:0;s.getColumnModel().sizeColumnsToFit(s.getGridDiv().clientWidth-n),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:n=>{s.getColumnModel().autoSizeAllColumns()},moveColumn:(n,i)=>s.getColumnModel().moveColumn(n,i),moveColumnByIndex:(n,i)=>s.getColumnModel().moveColumnByIndex(n,i),setColumnVisible:(n,i)=>s.getColumnApi().setColumnVisible(n,i),setColumnsPinned:(n,i)=>s.getColumnApi().setColumnsPinned(n,i),setColumnsVisible:(n,i)=>s.getColumnApi().setColumnsVisible(n,i),getAllColumns:()=>s.getAllColumns(),getColumns:()=>[...s.getColumns().left,...s.getColumns().center,...s.getColumns().right],getColumn:n=>s.getColumn(n)??null,getDisplayedLeftColumns:()=>s.getColumns().left,getDisplayedCenterColumns:()=>s.getColumns().center,getDisplayedRightColumns:()=>s.getColumns().right,getColumnState:()=>s.getColumnApi().getColumnState(),applyColumnState:(n,i)=>s.getColumnApi().applyColumnState(n,i),resetColumnState:()=>s.getColumnApi().resetColumnState(),openColumnMenu:n=>{const i=typeof n=="string"?s.getColumn(n):n;i!=null&&i.eHeaderCell&&s.getHeaderView().getHeaderCell(i)},setSideBarVisible:n=>{s.getSideBarService().setVisible(n),s.onGridSizeChanged()},isSideBarVisible:()=>s.getSideBarService().isVisible(),setSideBarPosition:n=>{s.getSideBarService().setPosition(n),s.onGridSizeChanged()},openToolPanel:n=>{s.getSideBarService().setVisible(!0),s.getSideBarService().openPanel(n),s.onGridSizeChanged()},closeToolPanel:()=>{s.getSideBarService().setVisible(!1),s.onGridSizeChanged()},getToolPanel:()=>s.getSideBarService().getActivePanel(),setStatusBarVisible:n=>s.getSideBarService()&&s.getOptions(),getSideBar:()=>s.getSideBarService(),getStatusPanel:()=>null,paginationIsLastPageFound:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.isLastPageFound())??!0},paginationGetPageSize:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getPageSize())??0},paginationGetCurrentPage:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getCurrentPage())??0},paginationGetTotalPages:()=>{var n;return((n=s.getPaginationService())==null?void 0:n.getTotalPages())??1},paginationGetRowCount:()=>s.getDisplayedRowCount(),paginationGoToPage:n=>{var i;return(i=s.getPaginationService())==null?void 0:i.goToPage(n)},paginationGoToNextPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToNextPage()},paginationGoToPreviousPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToPreviousPage()},paginationGoToFirstPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToFirstPage()},paginationGoToLastPage:()=>{var n;return(n=s.getPaginationService())==null?void 0:n.goToLastPage()},paginationSetPageSize:n=>{var i;return(i=s.getPaginationService())==null?void 0:i.setPageSize(n)},startEditingCell:n=>s.getEditService().startEditingCell(n),stopEditing:n=>s.getEditService().stopEditing(n),getEditingCells:()=>s.getEditService().getEditingCells(),setFocusedCell:(n,i)=>{const o=typeof i=="string"?s.getColumn(i):i;o&&s.getEditService().setFocusedCell(n,o)},getFocusedCell:()=>{const n=s.getEditService().getFocusedCell();return n?{rowIndex:n.rowIndex,column:n.column,rowNode:n.rowNode}:null},clearFocusedCell:()=>s.getEditService().clearFocusedCell(),tabToNextCell:()=>s.getEditService().tabToNextCell(),tabToPreviousCell:()=>s.getEditService().tabToPreviousCell(),refreshCells:n=>s.getRowRenderer().refreshCells(n),redrawRows:n=>s.getRowRenderer().redrawRows(n),flashCells:n=>s.getRowRenderer().flashCells(n||{}),ensureIndexVisible:(n,i)=>s.getRowRenderer().ensureIndexVisible(n,i),ensureNodeVisible:n=>{let i=-1;s.getRowModel().forEachNode((o,a)=>{o.id===n.id&&(i=a)}),i>=0&&s.getRowRenderer().ensureIndexVisible(i)},ensureColumnVisible:n=>{const i=typeof n=="string"?s.getColumn(n):n;i&&s.getRowRenderer().ensureColumnVisible(i)},copyToClipboard:n=>s.getExportService().copyToClipboard(n),cutToClipboard:n=>s.getExportService().cutToClipboard(n),pasteFromClipboard:()=>s.getExportService().pasteFromClipboard(),exportToCsv:n=>s.getExportService().exportToCsv(n||{}),exportToExcel:n=>s.getExportService().exportToExcel(n||{}),exportToPdf:n=>s.getExportService().exportToPdf(n||{}),importExcel:(n,i)=>s.getExportService().importExcel(n,i||{}),getDataAsPdf:n=>s.getExportService().getDataAsPdf(n||{}),getDataAsCsv:n=>s.getExportService().getDataAsCsv(n||{}),getDataAsExcel:n=>s.getExportService().getDataAsExcel(n||{}),getChartData:n=>s.getChartService().getChartData(n||{}),getChartModels:()=>s.getChartService().getChartModels(),createChart:()=>s.getChartService().createChart(),getCellRanges:()=>s.getRangeSelectionService().getRanges(),clearRangeSelection:()=>s.getRangeSelectionService().clearRanges(),addCellRange:n=>{const i=s.getRangeSelectionService();i.ranges=[n],i.applyHighlight(),i.updateOverlay()},onRangeSelectionChanged:()=>{},getRangeSelections:()=>s.getRangeSelectionService().getRanges(),showLoadingOverlay:()=>s.getOverlayService().showLoadingOverlay(),showNoRowsOverlay:()=>s.getOverlayService().showNoRowsOverlay(),hideOverlay:()=>s.getOverlayService().hideOverlay(),setServerSideDatasource:n=>{const i=s.getServerSideRowModel();i&&i.setDatasource(n)},setDatasource:n=>{var o;const i=s.getInfiniteRowModel();i?i.setDatasource(n):(o=s.getServerSideRowModel())==null||o.setDatasource(n)},setViewportDatasource:n=>{var i;(i=s.getViewportRowModel())==null||i.setViewportDatasource(n)},setViewportRange:(n,i)=>{var o;(o=s.getViewportRowModel())==null||o.setViewportRange(n,i)},refreshServerSide:n=>{const i=s.getServerSideRowModel();i&&(n!=null&&n.purge?i.purgeCache():i.onSortOrFilterChanged())},purgeServerSideCache:()=>{var n,i;(n=s.getServerSideRowModel())==null||n.purgeCache(),(i=s.getInfiniteRowModel())==null||i.onSortOrFilterChanged()},getServerSideStoreState:()=>{const n=s.getServerSideRowModel();if(!n)return[];const i=[];for(const[o,a]of n.stores)i.push({groupPath:o,rowCount:a.rows.length,lastRow:a.lastRow,loading:a.loading});return i},setRowCount:(n,i)=>{const o=s.getServerSideRowModel();if(!o)return;const a=o.getStore("");if(a)for(a.lastRow=i?n:null;a.rows.length<n;)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:n=>s.getUndoRedoService().endBatchEdit(n),cancelBatchEdit:()=>s.getUndoRedoService().endBatchEdit(!0),isBatchEditing:()=>s.getUndoRedoService().isBatchEditing(),getState:()=>{const n=s.getColumnApi(),i=s.getSelectionService(),o=s.getPaginationService();return{columns:n.getColumnState(),sort:s.getSortService().getSortModel(),filter:JSON.parse(JSON.stringify(s.getFilterService().getFilterModel())),quickFilter:s.getQuickFilter(),selectedRowIds:i.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:n=>{if(!n)return;const i=s.getColumnApi();if(n.columns&&i.applyColumnState(n.columns,!0),n.sort&&s.getSortService().setSortModel(n.sort),n.filter&&s.getFilterService().setFilterModel(n.filter),n.quickFilter!==void 0&&s.setQuickFilter(n.quickFilter),n.rowGroupColumns&&s.getColumnModel().setRowGroupColumns(n.rowGroupColumns),n.pivotMode!==void 0&&s.getColumnModel().setPivotMode(n.pivotMode),n.selectedRowIds){s.getSelectionService().deselectAll();for(const a of n.selectedRowIds){const l=s.getRowNode(a);l&&s.getSelectionService().selectNode(l,!1)}}const o=s.getPaginationService();o&&n.pagination&&(o.setPageSize(n.pagination.pageSize),o.goToPage(n.pagination.page))},setNote:(n,i,o)=>{const a=typeof i=="string"?i:i.colId;s.getNotesService().setNote(n.id,a,o)},getNote:(n,i)=>{const o=typeof i=="string"?i:i.colId,a=s.getColumn(o);return s.getNotesService().getNote(n.id,o,a==null?void 0:a.colDef.note,{data:n.data,node:n,column:a,api:s.getApi()})},getGridId:()=>"rowvia",destroy:()=>s.destroy(),refreshClientSideRowModel:()=>s.refreshModel("everything"),setPivotMode:n=>s.getColumnModel().setPivotMode(n),isPivotMode:()=>s.getColumnModel().isPivotMode(),showColumnMenuAfterButtonClick:()=>{}};return{api:e,columnApi:{getAllColumns:()=>s.getAllColumns(),getColumn:n=>s.getColumn(n)??null,getColumnState:()=>s.getColumnModel().getColumnState(),applyColumnState:(n,i)=>{s.getColumnModel().applyColumnState(n,i),s.refreshModel("group")},resetColumnState:()=>{s.getColumnModel().resetColumnState(),s.refreshModel("group")},setColumnVisible:(n,i)=>s.getColumnModel().setColumnVisible(n,i),setColumnsVisible:(n,i)=>s.getColumnModel().setColumnsVisible(n,i),setColumnPinned:(n,i)=>s.getColumnModel().setColumnPinned(n,i),setColumnsPinned:(n,i)=>s.getColumnModel().setColumnsPinned(n,i),moveColumn:(n,i)=>s.getColumnModel().moveColumn(n,i),moveColumnByIndex:(n,i)=>s.getColumnModel().moveColumnByIndex(n,i),autoSizeColumn:n=>{s.getColumnModel().autoSizeColumn(n),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeColumns:n=>{s.getColumnModel().autoSizeAllColumns(),s.getHeaderView().updateIndicators(),s.getRowRenderer().redrawAllRows()},autoSizeAllColumns:()=>e.autoSizeAllColumns(),sizeColumnsToFit:()=>e.sizeColumnsToFit(),setRowGroupColumns:(n,i)=>s.getColumnModel().setRowGroupColumns(n,i),removeRowGroupColumns:n=>{for(const i of n)s.getColumnModel().removeRowGroupColumn(i)},addRowGroupColumn:n=>s.getColumnModel().addRowGroupColumn(n),setPivotColumns:n=>s.getColumnModel().setPivotColumns(n),removePivotColumns:n=>s.getColumnModel().setPivotColumns(n.map(()=>"").filter(i=>i!=="")),setValueColumns:n=>s.getColumnModel().setValueColumns(n),removeValueColumn:n=>s.getColumnModel().setValueColumns([]),getRowGroupColumns:()=>s.getColumnModel().getRowGroupColumns(),getValueColumns:()=>s.getColumnModel().getValueColumns(),getPivotColumns:()=>s.getColumnModel().getPivotColumns(),setPivotMode:(n,i)=>s.getColumnModel().setPivotMode(n,i),isPivotMode:()=>s.getColumnModel().isPivotMode()}}}class Ze{constructor(e,t,n){w(this,"id");w(this,"__id");w(this,"data");w(this,"parent",null);w(this,"children",null);w(this,"group",!1);w(this,"key",null);w(this,"level",0);w(this,"uiLevel",0);w(this,"rowGroupIndex");w(this,"expanded",!1);w(this,"selectable",!0);w(this,"selected",!1);w(this,"rowPinned",null);w(this,"detailNode",null);w(this,"masterNode",null);w(this,"footer",!1);w(this,"groupData",null);w(this,"rowHeight",null);w(this,"allChildrenCount",null);w(this,"stub",!1);w(this,"rowIndex",null);w(this,"__displayIndex");w(this,"services");w(this,"__passesFilter",!0);w(this,"__childCount",0);w(this,"__childrenLoaded",!1);this.data=e,this.services=t,this.__id=Yt("row"),this.id=n??this.__id}get isGroup(){return this.group}get isMaster(){return this.masterNode!==null}setSelected(e,t=!1,n="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 n=typeof e=="string"?e:e.field;if(n&&this.data){const i=n.split(".");let o=this.data;for(;i.length>1;){const a=i.shift();o[a]===void 0&&(o[a]={}),o=o[a]}o[i[0]]=t}}setExpanded(e){this.expanded!==e&&(this.expanded=e)}setPinned(e){this.rowPinned=e}}class ks{constructor(e){w(this,"options");w(this,"eventService");w(this,"columns");w(this,"getFilterModel");w(this,"getQuickFilter");w(this,"isPaginationEnabled");w(this,"getPageSize");w(this,"getCurrentPage");w(this,"rowHeightProvider");w(this,"rowNodeServices");w(this,"rowData",[]);w(this,"rootRowNodes",[]);w(this,"dataRows",[]);w(this,"rowsToDisplay",[]);w(this,"rowNodeMap",new Map);w(this,"expandedGroups",new Set);w(this,"groupDefaultExpandedApplied",!1);w(this,"pinnedTopRows",[]);w(this,"pinnedBottomRows",[]);w(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,n)=>e(t,n))}forEachLeafNode(e){let t=0;const n=i=>{for(const o of i)o.group?o.children&&n(o.children):o.footer||e(o,t++)};n(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(i=>{i.group&&e.set(i.id,i.expanded)}),this.rowNodeMap.clear(),this.rootRowNodes=[];const t=this.options.getRowId,n=this.rowData;if(this.options.treeData){const i=this.buildTreeData(n,t);this.rootRowNodes=i,this.rowNodeMap.forEach(o=>{o.group&&e.has(o.id)&&(o.expanded=e.get(o.id))})}else{const i=[];for(let o=0;o<n.length;o++){const a=n[o],l=t?t({data:a,level:0}):void 0,r=this.createRowNode(a,l);r.rowIndex=o,i.push(r)}this.rootRowNodes=i,this.dataRows=i}if(this.options.masterDetail&&!this.options.treeData){const i=this.options.isRowMaster||(()=>!0);for(const o of this.rootRowNodes){if(o.detailNode||!i({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,n=null,i=0){const o=new Ze(e,this.rowNodeServices,t);return o.parent=n,o.level=i,o.uiLevel=i,o.__id=o.id,this.rowNodeMap.set(o.id,o),o}buildTreeData(e,t){const n=this.options.getDataPath||(d=>String(d.id??d.key).split("/")),i=this.options.treeDataChildrenField||"children",o=new Map,a=[],l=(d,c,p)=>{const h=n(d),u=h.join("/"),f=t?t({data:d,level:p}):u,g=this.createRowNode(d,f,c,p);g.key=h[h.length-1],o.set(u,g);const v=d[i];if(Array.isArray(v)&&v.length){g.children=[],g.group=!0,g.expanded=!0;for(const m of v){const y=l(m,g,p+1);g.children.push(y)}g.allChildrenCount=v.length}else c&&(c.children||(c.children=[],c.group=!0,c.expanded=!0),c.children.push(g),c.allChildrenCount=(c.allChildrenCount??0)+1);return c||a.push(g),g},r=d=>{if(!d.children||d.children.length===0)return 1;let c=0;for(const p of d.children)c+=r(p);return d.allChildrenCount=c,c};for(const d of a)r(d);for(const d of e){if(!d)continue;const p=n(d).slice(0,-1).join("/"),h=p&&o.get(p)||null;l(d,h??null,h?h.level+1:0)}return a}applyTransaction(e){const t=this.options.getRowId,n={add:[],remove:[],update:[]};if(e.remove&&e.remove.length){const i=new Set;for(const o of e.remove){const a=t?t({data:o,level:0}):o.id;a!==void 0?i.add(String(a)):i.add(o)}this.rowData=this.rowData.filter(o=>{const a=t?t({data:o,level:0}):o.id;return!i.has(String(a))&&!i.has(o)});for(const o of i){const a=this.rowNodeMap.get(String(o));a&&(this.rowNodeMap.delete(a.id),n.remove.push(a))}}if(e.update&&e.update.length)for(const i of e.update){const o=t?t({data:i,level:0}):i.id,a=o!==void 0?this.rowNodeMap.get(String(o)):void 0;if(a)this.rowData=this.rowData.map(l=>{const r=t?t({data:l,level:0}):l.id;return String(r)===String(o)?i:l}),a.data=i,n.update.push(a);else{const l=this.createRowNode(i,o!==void 0?String(o):void 0);this.rowData.push(i),n.add.push(l)}}if(e.add&&e.add.length){const i=e.addIndex;for(const o of e.add){const a=t?t({data:o,level:0}):void 0,l=this.createRowNode(o,a);n.add.push(l),i===void 0||i<0?this.rowData.push(o):this.rowData.splice(Math.min(i,this.rowData.length),0,o)}}return this.rebuildRows(),n}refreshModel(e){const t=this.columns().filter(n=>n.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(),n=Object.keys(e).length>0,i=t&&t.trim().length>0,o=this.columns(),a=!!this.options.treeData,l=f=>{for(const[g,v]of Object.entries(e)){const m=o.find(y=>y.colId===g);if(m&&!this.doesNodePassFilter(f,m,v))return!1}return!0},r=f=>{const g=this.options.__advancedFilterPass;return g?g(f):!0},d=Object.entries(e).some(([f,g])=>{const v=o.find(m=>m.colId===f);return!v||!v.aggFunc?!1:g.filterType==="multi"?(g.filterModels||[]).length>0:!0}),c=f=>{if(f.__passesFilter=!0,f.children)for(const g of f.children)c(g)},p=f=>{const g=this.options;return typeof g.isExternalFilterPresent!="function"||!g.isExternalFilterPresent()||typeof g.doesExternalFilterPass!="function"?!0:g.doesExternalFilterPass(f)},h=f=>{if(!i)return!0;const g=t.toLowerCase(),v=this.options.includeHiddenColumnsInQuickFilter?o:o.filter(m=>m.visible);for(const m of v){const y=Se(m,f,null);if(vs(g,y))return!0}return!1},u=f=>{let g=!0;if(!f.group||f.footer||a?g=(!n||l(f))&&h(f)&&p(f)&&r(f):d&&(g=(!n||l(f))&&r(f)),f.__passesFilter=g,f.children){let v=!1;for(const m of f.children)u(m)&&(v=!0);return f.group&&!f.footer&&(d?(f.__passesFilter=g,g&&c(f)):(f.__passesFilter=a?v||g:v,a&&g&&c(f))),f.__passesFilter}return g};for(const f of this.rootRowNodes)u(f)}doesNodePassFilterModel(e,t,n){return this.doesNodePassFilter(e,t,n)}doesNodePassFilter(e,t,n){if(e.group&&t.aggFunc&&!e.footer&&!e.__aggregationTest){let r;if(e.groupData&&e.groupData[t.colId]!==void 0)r=e.groupData[t.colId];else{const c=[];Ht(e,c);const p=c.map(h=>Se(t,h,null));r=Et(t,t.aggFunc,p)}const d={...e,data:{[t.colId]:r},groupData:null,__aggregationTest:!0};return this.doesNodePassFilter(d,t,n)}if(n.filterType==="multi"){const r=n.filterModels||[];if(r.length===0)return!0;const d=n.operator||"AND",c=r.map(p=>this.doesNodePassFilter(e,t,p));return d==="OR"?c.some(Boolean):c.every(Boolean)}if(n.condition1||n.condition2){const{condition1:r,condition2:d,...c}=n,p=[this.doesNodePassFilter(e,t,{...c,...r||{}})];return d&&p.push(this.doesNodePassFilter(e,t,{...c,...d})),(n.operator||"AND")==="OR"?p.some(Boolean):p.every(Boolean)}const i=Se(t,e,null),o=Rs(t,i),a=i,l=n.filterType||"text";if(l==="text"){const r=String(n.filter??"").toLowerCase();if(!r)return!0;const d=(a==null?"":String(a)).toLowerCase();switch(n.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(l==="number"){const r=typeof a=="number"?a:Number(a);if(isNaN(r))return!1;const d=Number(n.filter),c=n.filterTo!==void 0&&n.filterTo!==null&&n.filterTo!==""?Number(n.filterTo):null;switch(n.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 a==null||a==="";case"notBlank":return!(a==null||a==="");default:return!0}}if(l==="date"){const r=a instanceof Date?a.getTime():new Date(a).getTime();if(isNaN(r))return!1;const d=n.dateFrom?new Date(n.dateFrom).getTime():null,c=n.dateTo?new Date(n.dateTo+"T23:59:59").getTime():null;return!(d!==null&&r<d||c!==null&&r>c)}return l==="boolean"?!!a==!!n.filter:l==="set"?(n.values||[]).map(d=>String(d)).includes(String(a)):!0}doSort(e){const t=[],n=this.columns();for(const a of n)a.sort&&a.sortIndex!==null&&t.push({column:a,direction:a.sort});t.sort((a,l)=>(a.column.sortIndex??0)-(l.column.sortIndex??0));const i=(a,l)=>{for(const{column:c,direction:p}of t){const h=On(c)(a,l)*(p==="asc"?1:-1);if(h!==0)return h}const r=a.rowIndex??0,d=l.rowIndex??0;return r-d},o=a=>{a.sort(i);for(const l of a)l.children&&o(l.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(d=>d.aggFunc&&!d.rowGroup),n=(d,c,p,h)=>{if(c>=e.length)return d;const u=e[c],f=new Map,g=[];for(const m of d){if(!m.__passesFilter)continue;const y=Se(u,m,null),k=Ms(y);f.has(k)||(f.set(k,[]),g.push(k)),f.get(k).push(m)}const v=[];for(const m of g){const y=f.get(m),k=`${h}|${u.colId}:${m}`,C=this.rowNodeMap.get(k),b=C||new Ze({[u.colId]:m},this.rowNodeServices,k);b.group=!0,b.key=m,b.level=p,b.uiLevel=p,b.parent=null,b.children=n(y,c+1,p+1,k);for(const E of b.children)E.parent=b;b.allChildrenCount=Bn(b),b.data={...b.data};const I=[];Ht(b,I);const A={};for(const E of t){const G=I.map(x=>Se(E,x,null));A[E.colId]=Et(E,E.aggFunc,G)}A[u.colId]=m,b.groupData=A,C||this.rowNodeMap.set(k,b),v.push(b)}return v},i=this.options.groupDefaultExpanded??0,o=this.dataRows.length>0?this.dataRows:this.rootRowNodes,a=n(o,0,0,""),l=d=>{for(const c of d){if(!c.group)continue;const p=Pt(c),h=this.expandedGroups.has(p);i===-1||h?c.expanded=!0:this.groupDefaultExpandedApplied?c.expanded=!1:c.expanded=c.level<i,c.expanded&&this.expandedGroups.add(p),c.children&&l(c.children)}};l(a),this.groupDefaultExpandedApplied=!0;const r=(d,c)=>{const p=e[c],h=p.sort==="desc"?-1:1,u=On(p);d.sort((f,g)=>{const v=Se(p,f,null),m=Se(p,g,null);return u({...f,data:{[p.colId]:v}},{...g,data:{[p.colId]:m}})*h})};e[0].sort&&r(a,0),this.rootRowNodes=a}buildDisplayRows(e){const t=[],n=!!this.options.treeData,i=(a,l)=>{if(a.uiLevel=l,t.push(a),a.detailNode&&a.expanded&&t.push(a.detailNode),a.children&&(a.group||n)){const r=a.group?a.children.filter(d=>d.__passesFilter||d.group):a.children;if(a.expanded){for(const d of r)i(d,l+1);if(a.group&&this.options.groupIncludeFooter&&!this.isGrandTotal(a)){const d=this.createFooterNode(a,l+1);t.push(d)}}}};for(const a of this.rootRowNodes)a.__passesFilter&&i(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(),l=this.getCurrentPage();let r=0,d=-1;for(let p=0;p<o.length;p++)if(!o[p].masterNode){if(r===l*a){d=p;break}r++}d<0&&(d=o.length);let c=d;for(r=0;c<o.length&&r<a;)o[c].masterNode||r++,c++;for(;c<o.length&&o[c].masterNode;)c++;this.rowsToDisplay=o.slice(d,c)}else this.rowsToDisplay=o;this.rowsToDisplay.forEach((a,l)=>a.__displayIndex=l)}isGrandTotal(e){return e.parent===null&&!!this.options.groupIncludeTotalFooter}createFooterNode(e,t){const n=`${e.id}|footer`;let i=this.rowNodeMap.get(n);return i||(i=new Ze(e.data,this.rowNodeServices,n),this.rowNodeMap.set(n,i)),i.group=!1,i.footer=!0,i.level=e.level,i.uiLevel=t,i.parent=e,i.selected=!1,i.selectable=!1,i.groupData={...e.groupData,__footerFor:e.id},i}createGrandTotalNode(e){const t="ag-grid-grand-total";let n=this.rowNodeMap.get(t);n||(n=new Ze(null,this.rowNodeServices,t),this.rowNodeMap.set(t,n)),n.group=!1,n.footer=!0,n.level=0,n.uiLevel=0,n.selected=!1,n.selectable=!1;const i=this.columns().filter(l=>l.aggFunc&&!l.rowGroup),o=[];for(const l of this.rootRowNodes)l.group?Ht(l,o):l.__passesFilter&&o.push(l);const a={};for(const l of i){const r=o.map(d=>Se(l,d,null));a[l.colId]=Et(l,l.aggFunc,r)}return a.__grandTotal=!0,n.groupData=a,n}expandAll(){const e=t=>{t.group&&(t.expanded=!0,this.expandedGroups.add(Pt(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(Pt(e)):this.expandedGroups.delete(Pt(e)),this.buildDisplayRows(this.columns().filter(n=>n.rowGroup)),this.eventService.dispatchEvent("modelUpdated",{api:this.gridApi}))}setGridApi(e){this.gridApi=e}destroy(){this.rowNodeMap.clear(),this.rowsToDisplay=[],this.rootRowNodes=[]}}function Ms(s){return s==null?"":s instanceof Date?s.toISOString():String(s)}function Pt(s){const e=[];let t=s;for(;t;)e.unshift(t.id),t=t.parent;return e.join(">")}function Bn(s){return!s.children||s.children.length===0?1:s.children.reduce((e,t)=>e+Bn(t),0)}function Ht(s,e){if(!s.children||s.children.length===0){e.push(s);return}for(const t of s.children)Ht(t,e)}function Rs(s,e){return e}const Ls={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 Ts(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 Ns(s){return!!s.treeData}function Is(){return{applyAggregate:Et}}class Vn{constructor(e,t,n){w(this,"options");w(this,"eventService");w(this,"gridApi");w(this,"measureCtx",null);w(this,"gridColumnDefs",[]);w(this,"columns",[]);w(this,"displayOrder",[]);w(this,"autoGroupColumnDef");w(this,"pivotMode",!1);w(this,"columnGroups",[]);w(this,"openGroups",new Set);w(this,"groupsInitialised",!1);this.options=e,this.eventService=t,this.gridApi=n,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=Gn){if(!e||e.length===0)return[];const n=e[0];if(!n||typeof n!="object")return[];const i=new Set(["children","detail","__proto__"]),o=[];for(const a of Object.keys(n)){if(i.has(a)||a.startsWith("__"))continue;const l=n[a],r={field:a,headerName:t(a)};typeof l=="number"?(r.type="numberColumn",r.filter="number"):typeof l=="boolean"?r.type="booleanColumn":l instanceof Date&&(r.type="dateColumn"),o.push(r)}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 c of e)t.set(c.colId,c);const n=this.options.defaultColDef||{},i={...Ls,...this.options.columnTypes||{}},o=[],a=[];let l=0;const r=(c,p)=>{const h=c.colId||c.field||Yt("col"),u={...n,...c};if(u.type&&i[u.type]){const f=i[u.type],g=new Set(Object.keys(c));for(const[v,m]of Object.entries(f))!g.has(v)&&!(v in n)&&(u[v]=m)}this.pushColumnInto(o,u,h,l++,t,p)},d=(c,p,h)=>{for(const u of c)if(u.children&&u.children.length){const f=u.groupId||Yt("group"),g={id:f,headerName:u.headerName??"",openByDefault:u.openByDefault===!0||u.columnGroupShow==="open",parentId:p,depth:h,childColumnIds:[]};a.push(g),this.groupsInitialised||(g.openByDefault?this.openGroups.add(f):this.openGroups.delete(f)),d(u.children,f,h+1)}else r(u,p)};if(d(this.gridColumnDefs||[],null,1),this.groupsInitialised=!0,this.columnGroups=a,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(o,{...n,...c},"__rowNumber",-1,t,null)}for(const c of o){if(!c.groupId)continue;const p=a.find(h=>h.id===c.groupId);p&&p.childColumnIds.push(c.colId)}this.columns=o,this.displayOrder=o.map(c=>c.colId),this.updateVisible(),this.updateAutoGroupColumn(),this.refreshAll()}createColumn(e,t,n,i,o){return this.buildColumn(e,t,n,i,o)}pushColumnInto(e,t,n,i,o,a){e.push(this.buildColumn(t,n,i,o,a))}buildColumn(e,t,n,i,o){const a=i.get(t),l=e.hide===!0||e.initialHide===!0,r={colId:t,field:e.field,headerName:e.headerName??(e.field?Gn(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:l,visible:!l,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:Ts(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:n,filterActive:!1,left:0,groupId:o};return a&&(r.pinned=a.pinned,r.visible=a.visible,r.width=a.width,r.flex=a.flex,r.sort=a.sort,r.sortIndex=a.sortIndex,r.rowGroup=a.rowGroup,r.rowGroupIndex=a.rowGroupIndex,r.pivot=a.pivot,r.pivotIndex=a.pivotIndex),r}updatePivotColumns(e){if(this.columns=this.columns.filter(r=>!r.colId.startsWith("__pivot_")),this.displayOrder=this.displayOrder.filter(r=>!r.startsWith("__pivot_")),!this.pivotMode){this.refreshAll();return}const t=this.getPivotColumns();if(t.length===0||!e||e.length===0){this.refreshAll();return}const n=this.getColumns().filter(r=>r.aggFunc&&!r.rowGroup&&!r.pivot),i=[];for(const r of t){const d=[],c=new Set;for(const p of e){const h=p==null?void 0:p[r.field],u=String(h);c.has(u)||(c.add(u),d.push(h))}d.sort((p,h)=>p===h?0:String(p)<String(h)?-1:1);for(const p of n){for(const f of d){const g=`__pivot_${r.colId}_${p.colId}_${f}`,v=this.createColumn({colId:g,headerName:`${String(f)}`,width:130,type:p.type,sortable:!1,filter:!1,enableRowGroup:!1,cellClass:p.cellClass,cellDataType:p.cellDataType},g,-1,new Map,null);v.aggFunc=p.aggFunc,v.groupId=r.colId,v.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:f,valueColumnId:p.colId,valueField:p.field},v.valueGetter=m=>this.evaluatePivotValue(v,m.node),i.push(v)}const h=`__pivot_${r.colId}_${p.colId}_total`,u=this.createColumn({colId:h,headerName:"Total",width:130,type:p.type,sortable:!1,filter:!1,cellDataType:p.cellDataType},h,-1,new Map,null);u.aggFunc=p.aggFunc,u.groupId=r.colId,u.__pivot={pivotColumnId:r.colId,pivotField:r.field,pivotValue:void 0,valueColumnId:p.colId,valueField:p.field},u.valueGetter=f=>this.evaluatePivotValue(u,f.node),i.push(u)}}const o=new Set(t.map(r=>r.colId)),a=this.columns.reduce((r,d,c)=>o.has(d.groupId??"")?r:c,0);this.columns.splice(a+1,0,...i);for(const r of i)this.displayOrder.push(r.colId);const l=new Set(this.columnGroups.map(r=>r.id));for(const r of t)l.has(r.colId)||this.columnGroups.push({id:r.colId,headerName:r.headerName||r.field||"",openByDefault:!0,parentId:null,depth:1,childColumnIds:[]});this.refreshAll()}evaluatePivotValue(e,t){const n=e.__pivot;if(!n||!t)return;const i=[],o=c=>{if(!c.children||c.children.length===0){i.push(c);return}for(const p of c.children)o(p)};o(t);const l=(n.pivotValue===void 0?i:i.filter(c=>{var p;return String((p=c.data)==null?void 0:p[n.pivotField])===String(n.pivotValue)})).map(c=>{var p;return(p=c.data)==null?void 0:p[n.valueField]}).filter(c=>typeof c=="number");if(l.length===0)return null;const r=this.columns.find(c=>c.colId===n.valueColumnId),{applyAggregate:d}=Is();return d(r,e.aggFunc,l)}updateAutoGroupColumn(){const e="ag-Grid-AutoColumn",t=!!this.options.treeData,n=this.getRowGroupColumns(),i=this.options.groupDisplayType||"singleColumn",o=t||n.length>0&&i!=="multipleColumns";for(const c of n)i==="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 a=this.columns.find(c=>c.colId===e);if(!o){a&&(this.columns=this.columns.filter(c=>c.colId!==e),this.displayOrder=this.displayOrder.filter(c=>c!==e));return}const l={...this.autoGroupColumnDef};if(l.colId=e,a)a.headerName=l.headerName??"",a.colDef=l,a.cellRenderer=l.cellRenderer,a.cellRendererParams=l.cellRendererParams,a.width=l.width??a.width,a.minWidth=l.minWidth??a.minWidth,a.pinned=l.pinned??"left";else{const c=this.createColumn(l,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 p=c.node;if(!p)return"";if(p.key!==null&&p.key!==void 0)return p.key;if(Ns(this.options))return"";const h=d();return h!=null&&h.field&&p.data?p.data[h.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 n=this.columnGroups.find(i=>i.id===t);t=(n==null?void 0:n.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(n=>n.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 n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())n.includes(i)||(i.rowGroup=!1,i.rowGroupIndex=null);n.forEach((i,o)=>{i.rowGroup=!0,i.rowGroupIndex=o,i.pivot=!1,i.pivotIndex=null}),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:n}),this.updateAutoGroupColumn(),this.refreshAll()}addRowGroupColumn(e,t="api"){const n=this.getColumn(e);if(!n)return;const i=this.getRowGroupColumns();n.rowGroup=!0,n.rowGroupIndex=i.length,n.pivot=!1,this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[n]}),this.updateAutoGroupColumn(),this.refreshAll()}removeRowGroupColumn(e,t="api"){const n=this.getColumn(e);if(!n)return;n.rowGroup=!1,n.rowGroupIndex=null,this.getRowGroupColumns().forEach((o,a)=>o.rowGroupIndex=a),this.eventService.dispatchEvent("columnRowGroupChanged",{api:this.gridApi,source:t,columns:[n]}),this.updateAutoGroupColumn(),this.refreshAll()}setValueColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())n.includes(i)?i.aggFunc||(i.aggFunc="sum"):i.aggFunc&&!i.rowGroup&&(i.aggFunc=void 0);this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:t,columns:n}),this.refreshAll()}addValueColumn(e,t="sum",n="api"){const i=this.getColumn(e);i&&(i.aggFunc=t,this.eventService.dispatchEvent("columnValueChanged",{api:this.gridApi,source:n,columns:[i]}),this.refreshAll())}setPivotColumns(e,t="api"){const n=e.map(i=>this.getColumn(i)).filter(Boolean);for(const i of this.getColumns())i.pivot=n.includes(i),i.pivotIndex=n.includes(i)?n.indexOf(i):null;this.refreshAll()}setColumnVisible(e,t,n="api"){const i=this.getColumn(e);!i||i.visible===t||(i.hide=!t,i.visible=t,this.eventService.dispatchEvent("columnVisible",{api:this.gridApi,column:i,visible:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll())}setColumnsVisible(e,t,n="api"){for(const i of e)this.setColumnVisible(i,t,n)}setColumnPinned(e,t,n="api"){const i=this.getColumn(e);i&&(i.lockPosition&&t!==i.pinned||(i.pinned=t,this.eventService.dispatchEvent("columnPinned",{api:this.gridApi,column:i,pinned:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),this.refreshAll()))}setColumnsPinned(e,t,n="api"){for(const i of e)this.setColumnPinned(i,t,n)}moveColumn(e,t,n="api"){const i=this.getColumn(e);i&&this.moveColumnByIndex(this.displayOrder.indexOf(i.colId),t,n)}moveColumnByIndex(e,t,n="api"){const i=this.displayOrder.slice();if(e<0||e>=i.length)return;const[o]=i.splice(e,1);i.splice(Math.max(0,Math.min(i.length,t)),0,o),this.displayOrder=i;const a=this.getColumn(o);this.eventService.dispatchEvent("columnMoved",{api:this.gridApi,column:a,toIndex:t,source:n}),this.eventService.dispatchEvent("displayedColumnsChanged",{api:this.gridApi,source:n}),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 n of e){const i=this.getColumn(n.colId);i&&(n.hide!==void 0&&(i.hide=n.hide,i.visible=!n.hide),n.pinned!==void 0&&(i.pinned=n.pinned),n.width!==void 0&&(i.width=n.width),n.flex!==void 0&&(i.flex=n.flex),n.sort!==void 0&&(i.sort=n.sort),n.sortIndex!==void 0&&(i.sortIndex=n.sortIndex),n.rowGroupIndex!==void 0&&(i.rowGroup=n.rowGroupIndex!==null,i.rowGroupIndex=n.rowGroupIndex),n.pivotIndex!==void 0&&(i.pivot=n.pivotIndex!==null,i.pivotIndex=n.pivotIndex),n.aggFunc!==void 0&&(i.aggFunc=n.aggFunc))}if(t){const n=new Map(e.map(o=>[o.colId,o.colId])),i=this.displayOrder.filter(o=>!n.has(o));this.displayOrder=[...e.map(o=>o.colId).filter(o=>this.getColumn(o)),...i]}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 n=[this.getDisplayedLeftColumns(),this.getDisplayedCenterColumns(),this.getDisplayedRightColumns()];for(const i of n){let a=0,l=0;for(const d of i)t.includes(d.colId)?l+=d.width:d.flex!==null&&d.flex>0?a+=d.flex:l+=d.width;const r=Math.max(0,e-l-32);if(a>0){for(const d of i)if(d.flex!==null&&d.flex>0&&!t.includes(d.colId)){const c=Math.max(d.minWidth,Math.floor(r*d.flex/a));d.width=Math.min(d.maxWidth,c)}}}this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"sizeColumnsToFit",finished:!0})}autoSizeColumn(e,t=!1){var l,r,d,c,p,h;const n=this.getColumn(e);if(!n)return;let i=this.measureTextWidth(n.headerName)+32;t||(i+=16);const o=((r=(l=this.gridApi)==null?void 0:l.getDisplayedRowCount)==null?void 0:r.call(l))??0,a=Math.min(o,300);for(let u=0;u<a;u++){const f=(c=(d=this.gridApi)==null?void 0:d.getDisplayedRowAtIndex)==null?void 0:c.call(d,u);if(!f)continue;const g=(h=(p=this.gridApi)==null?void 0:p.getCellText)==null?void 0:h.call(p,n,f);g&&(i=Math.max(i,this.measureTextWidth(g)+32))}n.width=Math.max(n.minWidth,Math.min(n.maxWidth,Math.ceil(i))),n.flex=null,this.eventService.dispatchEvent("columnResized",{api:this.gridApi,source:"autoSizeColumn",column:n,finished:!0})}autoSizeAllColumns(e=!1){for(const t of this.getDisplayedColumns())this.autoSizeColumn(t,e)}}function Gn(s){const e=s.replace(/([A-Z])/g," $1").replace(/[_-]/g," ").trim();return e.charAt(0).toUpperCase()+e.slice(1)}class As{constructor(){w(this,"listeners",new Map)}addEventListener(e,t){let n=this.listeners.get(e);n||(n=[],this.listeners.set(e,n)),n.push(t)}removeEventListener(e,t){const n=this.listeners.get(e);if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}dispatchEvent(e,t){const n=this.listeners.get(e);if(!n||n.length===0)return;const i={type:e,...t||{}};for(const o of n.slice())o(i)}hasListener(e){return(this.listeners.get(e)||[]).length>0}}const qn={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:"散点图"},$s={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 Fs{constructor(e){this.overrides=e}t(e){const t=this.overrides[e];return typeof t=="string"&&t.length?t:qn[e]??e}}function Ds(s){return new Fs(s??{})}function Ps(s){return!s||typeof s!="object"?!1:s.__isGroup===!0?!0:typeof s.childCount=="number"&&s.childCount>=0}class Hs{constructor(e){w(this,"eventService");w(this,"columns");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"stores",new Map);w(this,"rowNodeMap",new Map);w(this,"displayRows",[]);w(this,"blockSize");this.eventService=e.eventService,this.columns=e.columns,this.getSortModel=e.getSortModel,this.getFilterModel=e.getFilterModel,this.rowNodeServices=e.rowNodeServices,this.blockSize=e.options.cacheBlockSize??100}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,n){if(!this.datasource)return;const i=this.getOrCreateStore(e);if(i.loading)return;for(let a=i.rows.length;a<n;a++)i.rows.push(null);i.loading=!0,this.eventService.dispatchEvent("modelUpdated",{});const o={startRow:t,endRow:n,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,l)=>{i.loading=!1,this.onBlockLoaded(e,a,l??null)},failCallback:()=>{i.loading=!1,i.failed=!0,this.eventService.dispatchEvent("modelUpdated",{})}};this.datasource.getRows(o)}onBlockLoaded(e,t,n){const i=this.getOrCreateStore(e);i.lastRow=n,i.failed=!1;for(let o=0;o<t.length;o++){const a=t[o],l=(i.rows.length>0,o),r=this.createNode(a,e,o,l);i.rows[l]=r}for(;i.rows.length&&i.rows[i.rows.length-1]===null;)i.rows.pop();this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}createNode(e,t,n,i){const o=Ps(e),a=(e==null?void 0:e.id)!==void 0&&(e==null?void 0:e.id)!==null?String(e.id):`${t}#${i}`,l=this.rowNodeMap.get(a),r=l instanceof Ze?l:new Ze(e,this.rowNodeServices,a);return r.data=e,r.rowIndex=n,o&&(r.group=!0,r.key=String(Se(this.columns().find(d=>d.rowGroup),r,null)??""),r.level=t?t.split("|").length:0,r.uiLevel=r.level,r.allChildrenCount=typeof e.childCount=="number"?e.childCount:null,r.expanded=this.stores.has(`${t?t+"|":""}${r.key}`)),this.rowNodeMap.set(a,r),r}buildDisplayRows(){const e=[],t=(n,i)=>{const o=this.stores.get(n);if(o){for(const a of o.rows)if(a&&(a.uiLevel=i,e.push(a),a.group&&a.expanded)){const l=`${n?n+"|":""}${a.key}`;t(l,i+1)}}};t("",0),this.displayRows=e,this.displayRows.forEach((n,i)=>n.__displayIndex=i)}ensureLoaded(e,t){let n=0;const i=a=>{const l=this.stores.get(a);if(l){for(const r of l.rows)if(r){if(n>=e&&n<=t){const d=Math.floor(n/this.blockSize)*this.blockSize,c=d+this.blockSize,p=l.lastRow,h=p!==null?Math.min(p,c):c;n<(l.rows.length||0)&&d<(l.rows.length||0)||(l.lastRow===null||c<=l.lastRow)&&this.loadBlock(a,d,h)}n++,r.group&&r.expanded&&i(`${a?a+"|":""}${r.key}`)}}};i("");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 n=this.groupPathFor(e);this.stores.has(n)||this.loadBlock(n,0,this.blockSize)}this.buildDisplayRows(),this.eventService.dispatchEvent("modelUpdated",{})}}groupPathFor(e){const t=[];let n=e;for(;n&&n.group;)t.unshift(n.key??""),n=n.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,n)=>e(t,n))}forEachLeafNode(e){let t=0;for(const n of this.displayRows)!n.group&&!n.footer&&e(n,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 n of e.update||[]){const i=(n==null?void 0:n.id)!==void 0?String(n.id):void 0,o=i?this.rowNodeMap.get(i):void 0;o&&(o.data=n,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 Os{constructor(e){w(this,"eventService");w(this,"getSortModel");w(this,"getFilterModel");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"blockSize");w(this,"loading",!1);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.loadBlock(0,this.blockSize)}loadBlock(e,t){if(!(!this.datasource||this.loading)){for(let n=this.nodes.length;n<t;n++)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:(n,i)=>{this.loading=!1,n.forEach((o,a)=>{const l=(o==null?void 0:o.id)!==void 0?String(o.id):`row-${e+a}`;let r=this.rowNodeMap.get(l);r||(r=new Ze(o,this.rowNodeServices,l),this.rowNodeMap.set(l,r)),r.data=o,r.rowIndex=e+a,this.nodes[e+a]=r}),this.eventService.dispatchEvent("modelUpdated",{})},failCallback:()=>{this.loading=!1,this.eventService.dispatchEvent("modelUpdated",{})}})}}onViewportChanged(e,t){const n=Math.floor(e/this.blockSize)*this.blockSize;n+this.blockSize>this.nodes.length&&this.loadBlock(n,n+this.blockSize)}onSortOrFilterChanged(){this.nodes=[],this.rowNodeMap.clear(),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,n)=>{t&&e(t,n)})}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 Bs{constructor(e){w(this,"eventService");w(this,"rowNodeServices");w(this,"datasource",null);w(this,"nodes",[]);w(this,"rowNodeMap",new Map);w(this,"loading",!1);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.datasource||this.loading)){this.nodes=this.nodes.filter((n,i)=>i>=e&&i<=t);for(let n=e;n<=t;n++)this.nodes[n-e]||(this.nodes[n-e]=null);this.loading=!0,this.eventService.dispatchEvent("modelUpdated",{}),this.datasource.getRows({startRow:e,endRow:t,rowGroupCols:[],valueCols:[],pivotCols:[],groupKeys:[],sortModel:[],filterModel:{},successCallback:n=>{this.loading=!1,n.forEach((i,o)=>{const a=(i==null?void 0:i.id)!==void 0?String(i.id):`vrow-${e+o}`;let l=this.rowNodeMap.get(a);l||(l=new Ze(i,this.rowNodeServices,a),this.rowNodeMap.set(a,l)),l.data=i,l.rowIndex=e+o,this.nodes[e+o-e]=l}),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,n)=>{t&&e(t,n)})}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}}function zn(s){return String(s).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}const Qe=["#3ba1ff","#47cf7c","#ffb700","#ff6b6b","#a86dd7","#00c2c7"];class Vs{constructor(e,t){w(this,"charts",new Map);w(this,"chartCounter",0);w(this,"currentType","line");w(this,"timeSeries",!1);this.grid=e,this.popupService=t}isEnabled(){return!!this.grid.getOptions().enableCharts}getChartData(e={}){const t=this.grid.getColumnModel(),n=t.getRowGroupColumns();let i=e.categoryColumn;const o=e.valueColumns&&e.valueColumns.length?e.valueColumns:t.getValueColumns().filter(r=>r.aggFunc),a=[],l=o.map(()=>[]);if(n.length>0)((d,c)=>{for(const p of d)if(p.group){const h=n[0]?String(Se(n[0],p,this.grid.getApi())??""):p.key??"";a.push(h);for(let u=0;u<o.length;u++){const f=[];_n(p,o[u],f),l[u].push(Number(Et(o[u],o[u].aggFunc,f))||0)}}})(this.grid.getRowModel().getTopLevelRows());else if(i||(i=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=i?Se(i,r,this.grid.getApi()):"";a.push(String(d??""));for(let c=0;c<o.length;c++){const p=Se(o[c],r,this.grid.getApi());l[c].push(typeof p=="number"?p:Number(p)||0)}}),a.length>200){const r=Math.ceil(a.length/200),d=[],c=l.map(()=>[]);for(let p=0;p<a.length;p+=r){d.push(a[p]);for(let h=0;h<l.length;h++)c[h].push(l[h][p])}return{categories:d,series:o.map((p,h)=>({title:p.headerName,data:c[h]}))}}return{categories:a,series:o.map((r,d)=>({title:r.headerName,data:l[d]}))}}buildChartPanel(){const e=document.createElement("div");e.className="ag-chart-panel";const t=document.createElement("div");t.className="ag-side-bar-section-title",t.textContent=this.grid.t("integratedCharts"),e.appendChild(t);const n=document.createElement("div");n.className="ag-chart-panel-label",n.textContent=this.grid.t("chartType"),e.appendChild(n);const i=document.createElement("select");i.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 v of o){const m=document.createElement("option");m.value=v.value,m.textContent=v.label,v.value===this.currentType&&(m.selected=!0),i.appendChild(m)}i.addEventListener("change",()=>{this.currentType=i.value}),e.appendChild(i);const a=document.createElement("div");a.className="ag-chart-panel-label",a.textContent=this.grid.t("chartCategory"),e.appendChild(a);const l=document.createElement("select");l.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 m=document.createElement("option");m.value=v.colId,m.textContent=r.length>0?`${this.grid.t("chartGroup")}: ${v.headerName}`:v.headerName,l.appendChild(m)}e.appendChild(l);const c=document.createElement("div");c.className="ag-chart-panel-label",c.textContent=this.grid.t("chartSeries"),e.appendChild(c);const p=this.grid.getColumnModel().getValueColumns().filter(v=>v.aggFunc),h=document.createElement("div");h.className="ag-chart-panel-series";const u=new Set(p.slice(0,3).map(v=>v.colId));for(const v 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=u.has(v.colId),y.addEventListener("change",()=>{y.checked?u.add(v.colId):u.delete(v.colId)}),m.appendChild(y);const k=document.createElement("span");k.textContent=v.headerName,m.appendChild(k),h.appendChild(m)}e.appendChild(h);const f=document.createElement("button");f.className="ag-button ag-button-primary ag-chart-panel-create",f.textContent=this.grid.t("createChart"),f.addEventListener("click",()=>{const v=this.grid.getColumn(l.value)||void 0,m=[...u].map(y=>this.grid.getColumn(y)).filter(Boolean);this.createChart({type:this.currentType,categoryColumn:v,valueColumns:m})}),e.appendChild(f);const g=document.createElement("div");if(g.className="ag-chart-panel-list",this.charts.size===0){const v=document.createElement("div");v.className="ag-side-bar-empty",v.textContent=this.grid.t("noChartsCreated"),g.appendChild(v)}for(const[v,m]of this.charts){const y=document.createElement("div");y.className="ag-chart-panel-list-item";const k=document.createElement("span");k.textContent=m.title,y.appendChild(k);const C=document.createElement("button");C.className="ag-column-group-remove",C.textContent="×",C.addEventListener("click",()=>this.destroyChart(v)),y.appendChild(C),g.appendChild(y)}return e.appendChild(g),e}createChart(e={}){var v,m,y,k;const t=e.type||this.currentType,n=this.getChartData({categoryColumn:e.categoryColumn,valueColumns:e.valueColumns}),i=`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 l=document.createElement("div");l.className="ag-chart-window-header";const r=document.createElement("span");r.className="ag-chart-window-title",r.textContent=o,l.appendChild(r);const d=document.createElement("button");d.className="ag-button ag-button-small",d.textContent=this.grid.t("downloadPng"),l.appendChild(d);const c=document.createElement("button");c.className="ag-button ag-button-small",c.textContent="×",c.title=this.grid.t("close"),c.addEventListener("click",()=>this.destroyChart(i)),l.appendChild(c),a.appendChild(l);const p=document.createElement("div");p.className="ag-chart-window-body";const h=document.createElement("canvas");h.className="ag-chart-canvas",h.width=600,h.height=360,p.appendChild(h);const u=document.createElement("div");u.className="ag-chart-tooltip",u.style.display="none",p.appendChild(u),h.addEventListener("mousemove",C=>this.onChartHover({id:i,ePopup:a,canvas:h,type:t,data:n,title:o},C,u)),h.addEventListener("mouseleave",()=>{u.style.display="none"});const f=document.createElement("div");f.className="ag-chart-legend",p.appendChild(f),a.appendChild(p),this.timeSeries=n.categories.length>0&&n.categories.every(C=>!isNaN(Date.parse(String(C)))&&isNaN(Number(C)));const g={id:i,ePopup:a,canvas:h,type:t,data:n,title:o};return this.charts.set(i,g),d.addEventListener("click",()=>{const C=h.toDataURL("image/png"),b=document.createElement("a");b.href=C,b.download=`${o.replace(/\s+/g,"-").toLowerCase()}.png`,b.click()}),this.popupService.positionAt(a,this.grid.getRootElement()),a.style.top="60px",this.renderChart(g),this.saveCharts(),this.grid.getEventService().dispatchEvent("chartCreated",{chartId:i,chartTitle:o,api:this.grid.getApi()}),(m=(v=this.grid.getOptions()).onChartCreated)==null||m.call(v,{chartId:i,chartTitle:o,api:this.grid.getApi()}),((y=this.grid.getSideBarService())==null?void 0:y.getActivePanel())==="charts"&&((k=this.grid.getSideBarService())==null||k.refresh()),i}destroyChart(e){var n,i,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()}),(i=(n=this.grid.getOptions()).onChartDestroyed)==null||i.call(n,{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,n){const o=e.canvas.getBoundingClientRect(),a=600/(o.width||1),l=360/(o.height||1),r=(t.clientX-o.left)*a,d=(t.clientY-o.top)*l,c={top:20,right:20,bottom:34,left:56},p=600-c.left-c.right,h=360-c.top-c.bottom;if(r<c.left||r>c.left+p||d<c.top||d>c.top+h){n.style.display="none";return}if(e.type==="pie"){n.style.display="none";return}const u=e.type==="bar",f=Math.max(1,e.data.categories.length),g=(u?h:p)/f,v=Math.floor((u?d-c.top:r-c.left)/g);if(v<0||v>=e.data.categories.length){n.style.display="none";return}const m=e.data.series.map(y=>`${y.title}: ${this.formatTick(y.data[v]??0)}`);n.innerHTML=`<div class="ag-chart-tooltip-title">${zn(e.data.categories[v])}</div>`+m.map(y=>`<div>${zn(y)}</div>`).join(""),n.style.display="block",n.style.left=`${t.clientX-o.left+12}px`,n.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(n=>({id:n.id,type:n.type,title:n.title,data:n.data}));try{localStorage.setItem(e,JSON.stringify(t))}catch{}}loadCharts(){const e=this.storageKey();if(!e)return;let t=[];try{const n=localStorage.getItem(e);n&&(t=JSON.parse(n))}catch{return}for(const n of t)this.restoreChart(n)}restoreChart(e){const t=e.id||`chart-${++this.chartCounter}`;if(this.charts.has(t))return;const{ePopup:n}=this.popupService.createPopup(640,"ag-chart-window");n.innerHTML="";const i=document.createElement("div");i.className="ag-chart-window-header";const o=document.createElement("span");o.className="ag-chart-window-title",o.textContent=e.title||this.grid.t("chart"),i.appendChild(o);const a=document.createElement("button");a.className="ag-button ag-button-small",a.textContent="×",a.addEventListener("click",()=>this.destroyChart(t)),i.appendChild(a),n.appendChild(i);const l=document.createElement("div");l.className="ag-chart-window-body";const r=document.createElement("canvas");r.className="ag-chart-canvas",r.width=600,r.height=360,l.appendChild(r);const d=document.createElement("div");d.className="ag-chart-legend",l.appendChild(d),n.appendChild(l);const c={id:t,ePopup:n,canvas:r,type:e.type||"line",data:e.data||{categories:[],series:[]},title:e.title||"Chart"};this.charts.set(t,c),this.popupService.positionAt(n,this.grid.getRootElement()),n.style.top="60px",this.renderChart(c)}renderChart(e){var G;const t=e.canvas,n=t.getContext("2d");if(!n)return;const i=window.devicePixelRatio||1,o=t.width,a=t.height;t.width=o*i,t.height=a*i,t.style.width=`${o}px`,t.style.height=`${a}px`,n.scale(i,i),n.clearRect(0,0,o,a);const l=getComputedStyle(this.grid.getRootElement()),r=l.getPropertyValue("--ag-chart-text-color")||"#666",d=l.getPropertyValue("--ag-border-color")||"rgba(128,128,128,0.25)",c={top:20,right:20,bottom:34,left:56},p=o-c.left-c.right,h=a-c.top-c.bottom;n.font="11px sans-serif",n.fillStyle=r,n.strokeStyle=d,n.lineWidth=1;const u=(G=e.canvas.parentElement)==null?void 0:G.querySelector(".ag-chart-legend");if(u&&(u.innerHTML="",e.data.series.forEach((x,M)=>{const N=document.createElement("span");N.className="ag-chart-legend-item";const P=document.createElement("span");P.className="ag-chart-legend-swatch",P.style.backgroundColor=Qe[M%Qe.length],N.appendChild(P),N.appendChild(document.createTextNode(x.title)),u.appendChild(N)})),e.type==="pie"){this.renderPie(n,e.data,o,a,r);return}const f=e.data.series.flatMap(x=>x.data);let g=Math.max(0,...f),v=Math.min(0,...f);e.type==="scatter"&&(v=Math.min(...f),g=Math.max(...f));const m=g-v||1;g+=m*.08,v-=v<0?m*.08:0;const y=g-v||1,k=x=>c.top+h-(x-v)/y*h,C=5;n.textAlign="right",n.textBaseline="middle";for(let x=0;x<=C;x++){const M=v+y*x/C,N=k(M);n.beginPath(),n.moveTo(c.left,N),n.lineTo(o-c.right,N),n.stroke(),n.fillText(this.formatTick(M),c.left-6,N)}const b=e.data.categories,I=e.type==="bar",A=Math.max(1,b.length),E=(I?h:p)/A;if(I){n.textAlign="left",b.forEach((M,N)=>{const P=c.top+N*E,_=Math.max(2,E*.7/e.data.series.length);e.data.series.forEach((L,H)=>{const T=L.data[N]||0,R=Math.abs(T)/y*p,$=c.left+(0-v)/y*p;n.fillStyle=Qe[H%Qe.length],n.fillRect($,P+H*_,Math.max(1,R),_-1)}),n.fillStyle=r,n.fillText(this.truncate(M,18),c.left+4,P+E/2)});const x=c.left+(0-v)/y*p;n.beginPath(),n.moveTo(x,c.top),n.lineTo(x,c.top+h),n.strokeStyle=r,n.stroke()}else{const x=Math.max(1,Math.ceil(A/12));n.textAlign="center",n.textBaseline="top",b.forEach((P,_)=>{if(_%x!==0)return;const L=c.left+E*(_+.5);n.fillStyle=r,n.fillText(this.truncate(P,10),L,c.top+h+6)});const M=e.data.series.length,N=Math.max(1,E*.7/Math.max(1,M));e.data.series.forEach((P,_)=>{const L=Qe[_%Qe.length];if(e.type==="column")n.fillStyle=L,P.data.forEach((H,T)=>{const R=c.left+E*T+(E-N*M)/2+_*N,$=k(H);n.fillRect(R,$,N-1,c.top+h-$)});else if(e.type==="area"){n.beginPath(),P.data.forEach((T,R)=>{const $=c.left+E*(R+.5),z=k(T);R===0?n.moveTo($,z):n.lineTo($,z)});const H=c.left+E*(P.data.length-.5);n.lineTo(H,c.top+h),n.lineTo(c.left+E*.5,c.top+h),n.closePath(),n.globalAlpha=.25,n.fillStyle=L,n.fill(),n.globalAlpha=1,n.beginPath(),P.data.forEach((T,R)=>{const $=c.left+E*(R+.5),z=k(T);R===0?n.moveTo($,z):n.lineTo($,z)}),n.strokeStyle=L,n.lineWidth=2,n.stroke()}else e.type==="scatter"?(n.fillStyle=L,P.data.forEach((H,T)=>{const R=c.left+E*(T+.5),$=k(H);n.beginPath(),n.arc(R,$,3,0,Math.PI*2),n.fill()})):(n.beginPath(),P.data.forEach((H,T)=>{const R=c.left+E*(T+.5),$=k(H);T===0?n.moveTo(R,$):n.lineTo(R,$)}),n.strokeStyle=L,n.lineWidth=2,n.stroke())})}}renderPie(e,t,n,i,o){const a=t.series[0];if(!a)return;const l=a.data.reduce((h,u)=>h+Math.abs(u),0)||1,r=n/2,d=i/2,c=Math.min(n,i)/2-30;let p=-Math.PI/2;a.data.forEach((h,u)=>{const f=Math.abs(h)/l*Math.PI*2;e.beginPath(),e.moveTo(r,d),e.arc(r,d,c,p,p+f),e.closePath(),e.fillStyle=Qe[u%Qe.length],e.fill();const g=p+f/2,v=r+Math.cos(g)*(c*.7),m=d+Math.sin(g)*(c*.7),y=Math.round(Math.abs(h)/l*100);y>=5&&(e.fillStyle="#fff",e.font="bold 11px sans-serif",e.textAlign="center",e.textBaseline="middle",e.fillText(`${y}%`,v,m)),p+=f}),e.fillStyle=o}formatTick(e){if(this.timeSeries){const n=new Date(e);if(!isNaN(n.getTime()))return n.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 _n(s,e,t){const n=s.children;if(!n||n.length===0){const i=Se(e,s,null);typeof i=="number"&&!isNaN(i)&&t.push(i);return}for(const i of n)_n(i,e,t)}class Gs{constructor(e){w(this,"eGui");var d,c,p;const t=e.node,n=!!t.group,i=!!t.detailNode,o=n||i,a=t.expanded,l=t.uiLevel*24,r=document.createElement("span");if(r.className="ag-group-cell-renderer",r.style.paddingLeft=`${l}px`,o){const h=document.createElement("span");h.className="ag-group-value-expanded-icon",h.classList.add(a?"ag-expanded":"ag-contracted"),h.innerHTML=a?oo:so,r.appendChild(h);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 g=f({...e,value:e.value,valueFormatted:e.valueFormatted});g instanceof HTMLElement?u.appendChild(g):typeof g=="string"&&(u.innerHTML=g)}else u.textContent=Ys(e.value);if(r.appendChild(u),n&&t.allChildrenCount!==null&&!((c=e.colDef.cellRendererParams)!=null&&c.suppressCount)){const g=document.createElement("span");g.className="ag-group-child-count",g.textContent=` (${t.allChildrenCount})`,r.appendChild(g)}}else{const h=document.createElement("span");h.className="ag-group-value";const u=(p=e.colDef.cellRendererParams)==null?void 0:p.innerRenderer;if(typeof u=="function"){const f=u({...e,value:e.value,valueFormatted:e.valueFormatted});f instanceof HTMLElement?h.appendChild(f):typeof f=="string"&&(h.innerHTML=f)}else h.textContent=e.valueFormatted??String(e.value??"");r.appendChild(h)}this.eGui=r}getGui(){return this.eGui}refresh(e){return!1}}class qs{constructor(e){w(this,"eGui");w(this,"eCheckbox");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",n=>n.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.eCheckbox.checked=!!e.node.selected,!0}}const zs='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l5 7H3l5-7z"/></svg>',_s='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3 6h10L8 13z"/></svg>';class Ws{constructor(e){w(this,"eGui");w(this,"eArrow");w(this,"eOld");w(this,"eNew");w(this,"lastValue");w(this,"flashTimer",null);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 n=typeof t=="number"&&typeof this.lastValue=="number"?t>this.lastValue:String(t)>String(this.lastValue),i=this.eNew.textContent??"";this.eArrow.innerHTML=n?zs:_s,this.eArrow.style.display="",this.eArrow.classList.add(n?"ag-value-change-delta-up":"ag-value-change-delta-down"),this.eOld.textContent=i,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",n?"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 Us{constructor(e){w(this,"eGui");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.eGui.textContent=String(e.rowIndex+1),!0}}class js{constructor(e){w(this,"eGui");var r,d;const t=document.createElement("span");t.className="ag-sparkline-cell";const n=e.value||[],i=e.sparklineOptions||((d=(r=e.column)==null?void 0:r.cellRendererParams)==null?void 0:d.sparklineOptions)||{},o=e.column.width||100,a=i.height||24,l=Jt(n,Math.max(20,o-16),a,i);t.appendChild(l),this.eGui=t}getGui(){return this.eGui}refresh(e){var l,r;const t=e.value||[],n=e.sparklineOptions||((r=(l=e.column)==null?void 0:l.cellRendererParams)==null?void 0:r.sparklineOptions)||{},i=e.column.width||100,o=n.height||24;this.eGui.innerHTML="";const a=Jt(t,Math.max(20,i-16),o,{type:n.type,direction:n.direction});return this.eGui.appendChild(a),!0}}function Jt(s,e,t,n={}){var m,y,k;const i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",String(Math.max(20,e))),i.setAttribute("height",String(t)),i.setAttribute("class","ag-sparkline");const o=(s||[]).map(C=>typeof C=="number"?C:Number((C==null?void 0:C.value)??0));if(!o||o.length<1)return i;const a=n.type||"line",l=Math.min(...o,0),d=Math.max(...o,0)-l||1,c=((m=n.tooltip)==null?void 0:m.enabled)===!0,p=((y=n.axis)==null?void 0:y.type)||"number",h=((k=n.pointsOfInterest)==null?void 0:k.show)===!0,u=(C,b)=>p==="category"?`${C+1}: ${b}`:String(b);if(h&&o.length>1){const C=o.indexOf(Math.min(...o)),b=o.indexOf(Math.max(...o)),I=e/Math.max(1,o.length-1),A=G=>t-2-(G-l)/d*(t-4),E=(G,x)=>{const M=document.createElementNS("http://www.w3.org/2000/svg","circle");M.setAttribute("cx",String(G*I)),M.setAttribute("cy",String(A(o[G]))),M.setAttribute("r","2.5"),M.setAttribute("fill",x),i.appendChild(M)};E(0,"#4caf50"),E(o.length-1,"#f44336"),E(C,"#2196f3"),E(b,"#ff9800")}if(c){const C=document.createElementNS("http://www.w3.org/2000/svg","title");C.textContent=o.map((b,I)=>u(I,b)).join(`
|
|
3
|
+
`),i.appendChild(C),i.style.cursor="default"}if(a==="bar"){const C=n.direction==="vertical",b=o.length;if(C){const I=Math.max(1,e/b-1),A=t-2-(0-l)/d*(t-4);o.forEach((E,G)=>{const x=G*(e/b),M=t-2-(E-l)/d*(t-4),N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("x",String(x)),N.setAttribute("width",String(I)),N.setAttribute("y",String(Math.min(M,A))),N.setAttribute("height",String(Math.max(1,Math.abs(A-M)))),N.setAttribute("fill","currentColor"),i.appendChild(N)})}else{const I=Math.max(1,t/b-1),A=2+(0-l)/d*(e-4);o.forEach((E,G)=>{const x=G*(t/b),M=2+(E-l)/d*(e-4),N=document.createElementNS("http://www.w3.org/2000/svg","rect");N.setAttribute("y",String(x)),N.setAttribute("height",String(I)),N.setAttribute("x",String(Math.min(M,A))),N.setAttribute("width",String(Math.max(1,Math.abs(A-M)))),N.setAttribute("fill","currentColor"),i.appendChild(N)})}return i}const f=e/Math.max(1,o.length-1),g=o.map((C,b)=>{const I=b*f,A=t-2-(C-l)/d*(t-4);return`${I.toFixed(1)},${A.toFixed(1)}`});if(a==="area"){const C=document.createElementNS("http://www.w3.org/2000/svg","polygon");C.setAttribute("points",`0,${t} ${g.join(" ")} ${e},${t}`),C.setAttribute("fill","currentColor"),C.setAttribute("opacity","0.2"),i.appendChild(C)}const v=document.createElementNS("http://www.w3.org/2000/svg","polyline");return v.setAttribute("points",g.join(" ")),v.setAttribute("fill","none"),v.setAttribute("stroke","currentColor"),v.setAttribute("stroke-width","1.5"),i.appendChild(v),i}class Ks{constructor(e){w(this,"eGui");this.eGui=document.createElement("span"),this.eGui.className="ag-row-drag",this.eGui.innerHTML=Wn,e.registerRowDragger&&e.registerRowDragger(t=>{this.eGui.dispatchEvent(new MouseEvent("mousedown",{bubbles:!0,clientX:t.clientX,clientY:t.clientY}))})}getGui(){return this.eGui}}const Ot={agGroupCellRenderer:s=>new Gs(s),agCheckboxCellRenderer:s=>new qs(s),agSparklineCellRenderer:s=>new js(s),agAnimateShowChangeCellRenderer:s=>new Ws(s),agRowNumberCellRenderer:s=>new Us(s),agRowDragComp:s=>new Ks(s)};function Ys(s){return s==null?"":String(s)}class Xs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);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 n;return(n=e.onKeyDown)==null?void 0:n.call(e,t)})}getGui(){return this.eGui}getValue(){return this.cancelled?void 0:this.eGui.value}focusIn(){this.eGui.focus(),this.eGui.select()}}class Zs{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"cancelled",!1);var i,o;const t=document.createElement("div");t.className="ag-cell-editor-number";const n=document.createElement("input");if(n.type="text",n.className="ag-cell-editor-input",n.value=e.value??"",(o=(i=e.column)==null?void 0:i.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",r=>{var d,c;r.preventDefault(),r.preventDefault(),n.value=String(Number(n.value||0)+(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))});const l=document.createElement("span");l.className="ag-cell-editor-stepper ag-cell-editor-stepper-down",l.innerHTML="▼",l.addEventListener("mousedown",r=>{var d,c;r.preventDefault(),n.value=String(Number(n.value||0)-(((c=(d=e.column)==null?void 0:d.cellEditorParams)==null?void 0:c.step)??1))}),t.appendChild(a),t.appendChild(n),t.appendChild(l)}else t.appendChild(n);this.eGui=t,this.eInput=n,this.eInput.addEventListener("keydown",a=>{var l;return(l=e.onKeyDown)==null?void 0:l.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 Qs{constructor(e){w(this,"eGui");w(this,"cancelled",!1);var n,i;this.eGui=document.createElement("select"),this.eGui.className="ag-cell-editor-select";const t=e.values||((i=(n=e.column)==null?void 0:n.cellEditorParams)==null?void 0:i.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 Js{constructor(e){w(this,"eGui");w(this,"cancelled",!1);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 eo{constructor(e){w(this,"eGui");w(this,"cancelled",!1);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 to(s,e){if(!e)return D(s);const t=s.toLowerCase().indexOf(e.toLowerCase());return t<0?D(s):D(s.slice(0,t))+'<span class="ag-rich-select-highlight">'+D(s.slice(t,t+e.length))+"</span>"+D(s.slice(t+e.length))}class no{constructor(e){w(this,"eGui");w(this,"eInput");w(this,"ePopup",null);w(this,"eList",null);w(this,"values",[]);w(this,"filtered",[]);w(this,"activeIndex",0);w(this,"selectedValue");w(this,"cancelled",!1);var t,n;this.params=e,this.values=e.values||((n=(t=e.column)==null?void 0:t.cellEditorParams)==null?void 0:n.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",i=>{i.stopPropagation()}),this.eInput.addEventListener("input",()=>{e.allowTyping===!0&&(this.selectedValue=this.eInput.value,this.renderList())}),this.eInput.addEventListener("keydown",i=>this.onKeyDown(i))}getGui(){return this.eGui}focusIn(){this.eInput.focus(),this.eInput.select(),this.openPopup()}afterGuiAttached(){this.openPopup()}openPopup(){var a,l;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,io(this.params)){const r=document.createElement("input");r.type="text",r.className="ag-rich-select-search",r.placeholder=((l=(a=this.params).t)==null?void 0:l.call(a,"search"))??"搜索…",r.value="",r.addEventListener("input",()=>this.renderList(r.value)),e.appendChild(r),setTimeout(()=>r.focus(),0)}const i=document.createElement("div");i.className="ag-rich-select-list",e.appendChild(i),this.eList=i,this.renderList();const o=r=>{!e.contains(r.target)&&!this.eGui.contains(r.target)&&(this.closePopup(),document.removeEventListener("mousedown",o,!0))};document.addEventListener("mousedown",o,!0)}renderList(e=""){var n,i;if(!this.eList)return;if(this.eList.innerHTML="",this.filtered=this.values.filter(o=>{if(!e)return!0;const a=String(o).toLowerCase(),l=e.toLowerCase().split(/\s+/).filter(Boolean);return this.params.searchType==="matchAll"?l.every(r=>a.includes(r)):l.some(r=>a.includes(r))}),this.filtered.forEach((o,a)=>{const l=document.createElement("div");l.className="ag-rich-select-item",a===this.activeIndex&&l.classList.add("ag-active"),String(o)===String(this.selectedValue)&&l.classList.add("ag-selected");const r=this.params.cellRenderer;if(typeof r=="function"){const d=r({value:o,valueFormatted:String(o)});d instanceof HTMLElement?l.appendChild(d):l.textContent=String(d)}else l.innerHTML=to(String(o),e);l.addEventListener("click",d=>{d.stopPropagation(),this.commit(o)}),l.addEventListener("mousedown",d=>d.preventDefault()),this.eList.appendChild(l)}),this.filtered.length===0){const o=document.createElement("div");o.className="ag-rich-select-empty",o.textContent=((i=(n=this.params).t)==null?void 0:i.call(n,"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,n;return(n=(t=this.params).onKeyDown)==null?void 0:n.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 io(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 Je={agTextCellEditor:s=>new Xs(s),agNumberCellEditor:s=>new Zs(s),agSelectCellEditor:s=>new Qs(s),agDateCellEditor:s=>new Js(s),agLargeTextCellEditor:s=>new eo(s),agRichSelectCellEditor:s=>new no(s)},so='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M6 4l4 4-4 4V4z"/></svg>',oo='<svg viewBox="0 0 16 16" width="14" height="14" fill="currentColor"><path d="M4 6l4 4 4-4H4z"/></svg>',Wn='<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>',ao='<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>',lo='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 3l4.5 7h-9L8 3z"/></svg>',co='<svg viewBox="0 0 16 16" width="12" height="12" fill="currentColor"><path d="M8 13L3.5 6h9L8 13z"/></svg>',Un='<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>';class uo{constructor(e,t){this.grid=e,this.popupService=t}openColumnMenu(e,t){const{ePopup:n,close:i}=this.popupService.createPopup(220,"ag-column-menu");n.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=e.headerName||e.field||e.colId,n.appendChild(o);const a=(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 p=document.createElement("span");p.className="ag-menu-item-check",d.checked&&(p.innerHTML=Un),c.appendChild(p);const h=document.createElement("span");if(h.className="ag-menu-item-label",h.textContent=r,c.appendChild(h),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(),i()}),n.appendChild(c),c},l=r=>{const d=document.createElement("div");d.className="ag-menu-section",d.textContent=r,n.appendChild(d)};e.sortable&&(l(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&&(l(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||(l(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?(l(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&&(l(this.grid.t("filter")),a(this.grid.t("openAdvancedFilter"),{onClick:()=>this.grid.getFilterGui().openAdvancedFilter(t)})),l(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)}),l(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(n,t)}}const jn={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 ho{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 n=this.grid.getOptions().contextMenuItems;let i;typeof n=="function"?i=n({column:t.column,node:t.node,api:this.grid.getApi()}):Array.isArray(n)?i=n:i=this.getDefaultItems(t);const{ePopup:o,close:a}=this.popupService.createPopup(220,"ag-context-menu");o.innerHTML="",this.buildMenu(o,i,a),this.popupService.positionAt(o,e)}buildMenu(e,t,n){for(const i of t){if(typeof i=="string")continue;if(i.separator){const r=document.createElement("div");r.className="ag-menu-separator",e.appendChild(r);continue}const o=document.createElement("div");o.className="ag-menu-item",i.disabled&&o.classList.add("ag-menu-item-disabled"),i.cssClasses&&o.classList.add(...i.cssClasses);const a=document.createElement("span");a.className="ag-menu-item-icon",i.icon&&jn[i.icon]&&(a.innerHTML=jn[i.icon]),o.appendChild(a);const l=document.createElement("span");if(l.className="ag-menu-item-label",l.textContent=i.label??i.name,o.appendChild(l),i.shortcut){const r=document.createElement("span");r.className="ag-menu-item-shortcut",r.textContent=i.shortcut,o.appendChild(r)}if(i.subMenu){const r=document.createElement("span");r.className="ag-menu-item-arrow",r.textContent="›",o.appendChild(r),o.addEventListener("mouseenter",()=>{e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove());const c=document.createElement("div");c.className="ag-menu-popup-sub",this.buildMenu(c,i.subMenu,n),e.appendChild(c)}),o.addEventListener("mouseleave",()=>{setTimeout(()=>{var c;o.matches(":hover")||((c=o.parentElement)==null?void 0:c.querySelector(":hover"))||e.querySelectorAll(".ag-menu-popup-sub").forEach(p=>p.remove())},200)})}else!i.disabled&&i.action&&o.addEventListener("click",()=>{i.action(),n()});e.appendChild(o)}}}class po{constructor(e,t){w(this,"editing",null);w(this,"fullRowEditors",null);w(this,"fullRowNode",null);w(this,"focusedCell",null);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.clearFocusClass();const n=this.findCellElement(t,e);n==null||n.classList.add("ag-cell-focus"),n&&typeof n.scrollIntoView=="function"&&n.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 n=this.grid.getDisplayedRowAtIndex(t);if(!n)return null;const o=this.grid.getRowRenderer().getRowComps().get(n.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 d;const t=typeof e.colKey=="string"?this.grid.getColumn(e.colKey):e.colKey;if(!t)return;const n=this.grid.getDisplayedRowAtIndex(e.rowIndex);if(!n||!this.grid.isCellEditable(t,n))return;if(this.stopEditing(!1),this.grid.getOptions().editType==="fullRow"){this.startFullRowEditing(e.rowIndex,n,e.charPress);return}const i=this.findCellElement(t,e.rowIndex);if(!i)return;const o=Se(t,n,this.grid.getApi()),a={value:e.charPress!==void 0?e.charPress:o,oldValue:o,data:n.data,node:n,column:t,colDef:t.colDef,rowIndex:e.rowIndex,api:this.grid.getApi(),t:c=>this.grid.t(c),onKeyDown:c=>this.onEditorKeyDown(c),values:(d=t.cellEditorParams)==null?void 0:d.values,...t.cellEditorParams};let l;if(typeof t.cellEditor=="string")l=(Je[t.cellEditor]||Je.agTextCellEditor)(a);else if(typeof t.cellEditor=="function"){const c=t.cellEditor(a);l=c&&typeof c.getGui=="function"?c:{getGui:()=>c,getValue:()=>c==null?void 0:c.value}}else{const c=t.type==="numberColumn"?"agNumberCellEditor":t.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";l=Je[c](a)}if(!l)return;this.editing={rowIndex:e.rowIndex,column:t,rowNode:n,eCell:i,editor:l,startedValue:o},i.classList.add("ag-cell-inline-editing");const r=l.getGui();r.classList.add("ag-cell-editor"),i.appendChild(r),i.classList.add("ag-cell-editing"),l.focusIn&&l.focusIn(),l.afterGuiAttached&&l.afterGuiAttached(),this.eventService.dispatchEvent("cellEditingStarted",{rowIndex:e.rowIndex,column:t,node:n,api:this.grid.getApi()}),this.eventService}startFullRowEditing(e,t,n){const i=[...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 i){const a=this.findCellElement(o,e);if(!a)continue;const l=Se(o,t,this.grid.getApi()),r=this.createEditor(o,t,e,l,n);if(!r)continue;a.classList.add("ag-cell-inline-editing","ag-cell-editing");const d=r.getGui();d.classList.add("ag-cell-editor"),a.appendChild(d),this.fullRowEditors.push({column:o,editor:r,eCell:a,startedValue:l})}this.eventService.dispatchEvent("rowEditingStarted",{rowIndex:e,node:t,api:this.grid.getApi(),data:t.data})}createEditor(e,t,n,i,o){var r;const a={value:o!==void 0?o:i,oldValue:i,data:t.data,node:t,column:e,colDef:e.colDef,rowIndex:n,api:this.grid.getApi(),t:d=>this.grid.t(d),onKeyDown:d=>this.onEditorKeyDown(d),values:(r=e.cellEditorParams)==null?void 0:r.values,...e.cellEditorParams};if(typeof e.cellEditor=="string")return(Je[e.cellEditor]||Je.agTextCellEditor)(a);if(typeof e.cellEditor=="function"){const d=e.cellEditor(a);return d&&typeof d.getGui=="function"?d:{getGui:()=>d,getValue:()=>d==null?void 0:d.value}}const l=e.type==="numberColumn"?"agNumberCellEditor":e.type==="dateColumn"?"agDateCellEditor":"agTextCellEditor";return Je[l](a)}stopEditing(e=!1){var d,c,p,h;if(this.fullRowEditors)return this.stopFullRowEditing(e);if(!this.editing)return!1;const{rowIndex:t,column:n,rowNode:i,eCell:o,editor:a,startedValue:l}=this.editing;this.editing=null,o.classList.remove("ag-cell-inline-editing","ag-cell-editing");let r=e?l:a.getValue();if(r===void 0&&!e)return(d=o.querySelector(".ag-cell-editor"))==null||d.remove(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:n,node:i,api:this.grid.getApi()}),!1;if(!e){r=Pn(n,r);const u=this.applyValueSetter(n,i,r);if(u===!1)return o.classList.add("ag-cell-invalid"),setTimeout(()=>o.classList.remove("ag-cell-invalid"),1500),this.startEditingCell({rowIndex:t,colKey:n}),!1;r=u}return(c=o.querySelector(".ag-cell-editor"))==null||c.remove(),a.destroy&&a.destroy(),this.eventService.dispatchEvent("cellEditingStopped",{rowIndex:t,column:n,node:i,api:this.grid.getApi()}),!e&&!Kn(r,l)&&(this.grid.setCellValue(n,i,r,"edit",l),this.eventService.dispatchEvent("cellValueChanged",{oldValue:l,newValue:r,value:r,data:i.data,node:i,column:n,colDef:n.colDef,api:this.grid.getApi(),source:"edit"}),(h=(p=this.grid.getOptions()).onCellValueChanged)==null||h.call(p,{oldValue:l,newValue:r,value:r,data:i.data,node:i,column:n,colDef:n.colDef,api:this.grid.getApi()}),this.grid.refreshCells({rowNodes:[i],columns:[n],flash:this.grid.getOptions().enableCellChangeFlash!==!1})),!0}applyValueSetter(e,t,n){if(e.valueSetter){if(e.valueSetter({oldValue:Se(e,t,this.grid.getApi()),newValue:n,data:t.data,node:t,column:e,api:this.grid.getApi(),colDef:e.colDef})===!1)return!1}else t.setDataValue(e.colId,n);return n}stopFullRowEditing(e){var o,a,l;const t=this.fullRowEditors,n=this.fullRowNode;if(this.fullRowEditors=null,this.fullRowNode=null,!t)return!1;for(const r of t)r.eCell.classList.remove("ag-cell-inline-editing","ag-cell-editing"),(o=r.eCell.querySelector(".ag-cell-editor"))==null||o.remove(),r.editor.destroy&&r.editor.destroy();if(e)return this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi()}),!1;const i=[];for(const r of t){if(!n)break;let d=r.editor.getValue();d!==void 0&&(d=Pn(r.column,d),Kn(d,r.startedValue)||i.push({column:r.column,rowNode:n,newValue:d,oldValue:r.startedValue}))}this.eventService.dispatchEvent("rowEditingStopped",{api:this.grid.getApi(),data:n==null?void 0:n.data});for(const r of i)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"}),(l=(a=this.grid.getOptions()).onCellValueChanged)==null||l.call(a,{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===13){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===27)e.preventDefault(),this.stopEditing(!0);else if(e.key==="Tab"||e.keyCode===9){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 n=this.focusedCell;switch(e.keyCode){case 13:e.preventDefault(),n&&(this.grid.isCellEditable(n.column,n.rowNode)?this.startEditingCell({rowIndex:n.rowIndex,colKey:n.column}):this.moveFocus(1,0));break;case 9:e.preventDefault(),this.moveFocus(0,e.shiftKey?-1:1);break;case 8:case 46:n&&this.grid.isCellEditable(n.column,n.rowNode)&&(e.preventDefault(),this.grid.setCellValue(n.column,n.rowNode,null,"deleteKey"),this.grid.refreshCells({rowNodes:[n.rowNode],columns:[n.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 36:this.isTextInput(e.target)||(e.preventDefault(),this.moveFocus(-1/0,0));break;case 35: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}n&&t.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&this.grid.isCellEditable(n.column,n.rowNode)&&(e.preventDefault(),this.startEditingCell({rowIndex:n.rowIndex,colKey:n.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 n=this.focusedCell;if(!n){this.setFocusedCell(0,this.grid.getColumns().center[0]??this.grid.getColumns().left[0]);return}let i=n.rowIndex;if(e===-1/0?i=0:e===1/0?i=this.grid.getDisplayedRowCount()-1:i=Math.max(0,Math.min(this.grid.getDisplayedRowCount()-1,i+e)),t!==0){const o=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right];let l=o.findIndex(r=>r.colId===n.column.colId)+t;for(;l>=0&&l<o.length&&!o[l].visible;)l+=t;l<0&&(l=0),l>=o.length&&(l=o.length-1),this.setFocusedCell(i,o[l])}else this.setFocusedCell(i,n.column)}tabToNextCell(){this.moveFocus(0,1)}tabToPreviousCell(){this.moveFocus(0,-1)}onCellClicked(e){const{node:t,column:n}=e;if(this.setFocusedCell(e.rowIndex,n),n.checkboxSelection)return;const i=this.grid.isCellEditable(n,t),o=n.singleClickEdit||this.grid.getOptions().singleClickEdit;i&&o&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:n})}onCellDoubleClicked(e){const{node:t,column:n}=e;this.setFocusedCell(e.rowIndex,n),this.grid.isCellEditable(n,t)&&!this.grid.getOptions().suppressClickEdit&&this.startEditingCell({rowIndex:e.rowIndex,colKey:n})}destroy(){this.editing=null,this.focusedCell=null}}function Kn(s,e){return s===e?!0:s instanceof Date&&e instanceof Date?s.getTime()===e.getTime():!1}const fo={"a4-landscape":[842,595],"a4-portrait":[595,842],"letter-landscape":[792,612],"letter-portrait":[612,792]};function Yn(s){return s.replace(/\\/g,"\\\\").replace(/\(/g,"\\(").replace(/\)/g,"\\)").replace(/[\r\n]/g," ")}function go(s,e,t){const n=Math.max(1,Math.floor(e/(t*.5)));return s.length>n?`${s.slice(0,Math.max(1,n-1))}…`:s}function mo(){return new TextEncoder}function vo(s,e={}){const[t,n]=fo[e.pageSize||"a4-landscape"],i=e.margin??32,o=e.fontSize??9,a=e.rowHeight??18,l=e.headerColor??[.94,.95,.97],r=e.borderColor??[.85,.87,.9],d=mo(),c=[],p=y=>(c.push(y),c.length);p(""),p("");const h=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica >>"),u=p("<< /Type /Font /Subtype /Type1 /BaseFont /Helvetica-Bold >>"),f=[];for(const y of s){let k="";const C=y.columnWidths.reduce((P,_)=>P+_,0),b=Math.min(1,(t-i*2)/(C||1)),I=y.columnWidths.map(P=>P*b),A=i;let E=n-i-(e.title?24:0);e.title&&(k+=`BT /F2 ${o+4} Tf ${A} ${E} Td (${Yn(e.title)}) Tj ET
|
|
4
|
+
`,E-=18),y.rows.forEach((P,_)=>{var R;const L=_===0,H=((R=y.rowFill)==null?void 0:R[_])??(L?l:void 0);H&&(k+=`${H[0]} ${H[1]} ${H[2]} rg ${A} ${(E-a+4).toFixed(2)} ${C*b} ${a} re f
|
|
5
|
+
`);let T=A;P.forEach(($,z)=>{const j=I[z]??0,te=Yn(go($.text??"",j-6,o)),he=$.bold||L?u:h,ge=($.text??"").length*o*.5;let be=T+3;$.align==="right"||!$.align&&z>0&&/^-?[\d,.%$£€\s]+$/.test($.text??"")?be=T+j-3-Math.min(ge,j-6):$.align==="center"&&(be=T+(j-Math.min(ge,j-6))/2),k+=`BT /F${he===u?2:1} ${o} Tf ${be.toFixed(2)} ${(E-o+2).toFixed(2)} Td (${te}) Tj ET
|
|
6
|
+
`,T+=j}),k+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${A} ${(E-a+4).toFixed(2)} m ${(A+C*b).toFixed(2)} ${(E-a+4).toFixed(2)} l S
|
|
7
|
+
`,E-=a});const G=y.rows.length*a;k+=`${r[0]} ${r[1]} ${r[2]} RG 0.5 w ${A} ${(E+a-4).toFixed(2)} m ${A} ${(E+G+a-4).toFixed(2)} l ${(A+C*b).toFixed(2)} ${(E+G+a-4).toFixed(2)} l ${(A+C*b).toFixed(2)} ${(E+a-4).toFixed(2)} l S
|
|
8
|
+
`;const x=d.encode(k),M=p(`<< /Length ${x.length} >>
|
|
9
9
|
stream
|
|
10
|
-
${
|
|
11
|
-
endstream`),
|
|
12
|
-
`;const v=[];c.forEach((
|
|
13
|
-
${
|
|
10
|
+
${k}
|
|
11
|
+
endstream`),N=p(`<< /Type /Page /Parent 2 0 R /MediaBox [0 0 ${t} ${n}] /Resources << /Font << /F1 ${h} 0 R /F2 ${u} 0 R >> >> /Contents ${M} 0 R >>`);f.push(N)}c[0]="<< /Type /Catalog /Pages 2 0 R >>",c[1]=`<< /Type /Pages /Kids [${f.map(y=>`${y} 0 R`).join(" ")}] /Count ${f.length} >>`;let g=`%PDF-1.4
|
|
12
|
+
`;const v=[];c.forEach((y,k)=>{const C=k+1;v.push(d.encode(g).length),g+=`${C} 0 obj
|
|
13
|
+
${y}
|
|
14
14
|
endobj
|
|
15
15
|
`});const m=d.encode(g).length;g+=`xref
|
|
16
16
|
0 ${c.length+1}
|
|
17
17
|
0000000000 65535 f
|
|
18
|
-
`;for(const
|
|
18
|
+
`;for(const y of v)g+=`${String(y).padStart(10,"0")} 00000 n
|
|
19
19
|
`;return g+=`trailer
|
|
20
20
|
<< /Size ${c.length+1} /Root 1 0 R >>
|
|
21
21
|
startxref
|
|
22
22
|
${m}
|
|
23
23
|
%%EOF
|
|
24
|
-
`,new Blob([d.encode(g)],{type:"application/pdf"})}function it(s,e){return s.getUint32(e,!0)}function Qe(s,e){return s.getUint16(e,!0)}async function to(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 io(s){const e=new DataView(s),t=new Uint8Array(s);let i=-1;for(let l=t.length-22;l>=0;l--)if(it(e,l)===101010256){i=l;break}if(i<0)throw new Error("Not a valid XLSX (ZIP) file");const n=Qe(e,i+10);let o=it(e,i+16);const a=[];for(let l=0;l<n&&it(e,o)===33639248;l++){const r=Qe(e,o+10),d=it(e,o+20),c=it(e,o+24),p=Qe(e,o+28),f=Qe(e,o+30),u=Qe(e,o+32),h=it(e,o+42),g=new TextDecoder().decode(t.subarray(o+46,o+46+p));a.push({name:g,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:h}),o+=46+p+f+u}return a}async function Ut(s,e){const t=new DataView(s),i=new Uint8Array(s),n=Qe(t,e.localHeaderOffset+26),o=Qe(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+n+o,l=i.subarray(a,a+e.compressedSize);return e.compressionMethod===0?l:to(l)}function jt(s){return new DOMParser().parseFromString(s,"application/xml")}function no(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 so(s){const e=io(s),t=e.find(d=>d.name==="xl/workbook.xml"),i=[];if(t){const c=jt(new TextDecoder().decode(await Ut(s,t))).getElementsByTagName("sheet");for(let p=0;p<c.length;p++)i.push(c[p].getAttribute("name")||`Sheet${p+1}`),c[p].getAttribute("r:id")||c[p].getAttribute("id")}const n=[],o=e.find(d=>d.name==="xl/sharedStrings.xml");if(o){const c=jt(new TextDecoder().decode(await Ut(s,o))).getElementsByTagName("si");for(let p=0;p<c.length;p++){const f=c[p].getElementsByTagName("t");let u="";for(let h=0;h<f.length;h++)u+=f[h].textContent||"";n.push(u)}}const l=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<l.length;d++){const p=jt(new TextDecoder().decode(await Ut(s,l[d]))).getElementsByTagName("row"),f=[];for(let u=0;u<p.length;u++){const h=p[u],g=[],v=h.getElementsByTagName("c");for(let m=0;m<v.length;m++){const C=v[m],S=C.getAttribute("r")||"",b=C.getAttribute("t")||"";let y="";if(b==="s"){const M=C.getElementsByTagName("v")[0],T=Number((M==null?void 0:M.textContent)||"0");y=n[T]??""}else if(b==="inlineStr"){const M=C.getElementsByTagName("t");for(let T=0;T<M.length;T++)y+=M[T].textContent||""}else{const M=C.getElementsByTagName("v")[0];y=(M==null?void 0:M.textContent)??""}const R=S?no(S):m;g[R]=y}f.push(g.map(m=>m??""))}r.push({name:i[d]||`Sheet${d+1}`,rows:f})}return r}const oo=(()=>{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 ao(s){let e=4294967295;for(let t=0;t<s.length;t++)e=oo[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Hi(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function ro(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 lo(s){const e=new TextEncoder,t=[],i=[];let n=0;for(const p of s){const f=e.encode(p.name),u=ao(p.data),h=new Uint8Array(30+f.length),g=new DataView(h.buffer);g.setUint32(0,67324752,!0),g.setUint16(4,20,!0),g.setUint16(6,2048,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,8585,!0),g.setUint32(14,u,!0),g.setUint32(18,p.data.length,!0),g.setUint32(22,p.data.length,!0),g.setUint16(26,f.length,!0),g.setUint16(28,0,!0),h.set(f,30),t.push(h,p.data);const v=new Uint8Array(46+f.length),m=new DataView(v.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,u,!0),m.setUint32(20,p.data.length,!0),m.setUint32(24,p.data.length,!0),m.setUint16(28,f.length,!0),m.setUint32(42,n,!0),v.set(f,46),i.push(v),n+=h.length+p.data.length}const o=i.reduce((p,f)=>p+f.length,0),a=new Uint8Array(22),l=new DataView(a.buffer);l.setUint32(0,101010256,!0),l.setUint16(8,s.length,!0),l.setUint16(10,s.length,!0),l.setUint32(12,o,!0),l.setUint32(16,n,!0);const r=t.reduce((p,f)=>p+f.length,0)+o+a.length,d=new Uint8Array(r);let c=0;for(const p of t)d.set(p,c),c+=p.length;for(const p of i)d.set(p,c),c+=p.length;return d.set(a,c),d}function co(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(l=>l.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${n}"${a}>`,t.forEach((l,r)=>{const d=`${ro(r)}${n}`,c=l.bold?' s="1"':"";if(l.value===null||l.value===void 0||l.value===""){e+=`<c r="${d}"${c}/>`;return}typeof l.value=="number"&&isFinite(l.value)?e+=`<c r="${d}"${c}><v>${l.value}</v></c>`:typeof l.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${l.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${Hi(String(l.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const uo='<?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 ho(s){const e=new TextEncoder,t=(p,f)=>p.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${f+1}`;let i="",n="",o="";s.forEach((p,f)=>{const u=t(p.name,f),h=f+1;i+=`<sheet name="${Hi(u)}" sheetId="${h}" r:id="rId${h}"/>`,n+=`<Relationship Id="rId${h}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${h}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${h}.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>",l='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="xl/workbook.xml"/></Relationships>',r=`<?xml version="1.0" encoding="UTF-8" standalone="yes"?><workbook xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><sheets>${i}</sheets></workbook>`,d='<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rIdStyles" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/>'+n+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(l)},{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(uo)}];return s.forEach((p,f)=>{c.push({name:`xl/worksheets/sheet${f+1}.xml`,data:e.encode(co(p.rows))})}),new Blob([lo(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}class po{constructor(e){w(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(l=>{l.rowPinned==="top"&&e.skipPinnedTop!==!1||l.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&l.group&&!l.footer||a&&l.footer||n&&!l.selected||i.push(l)}),n&&i.length===0?this.getExportRows({...e,onlySelected:!1}):i}getCellValueForExport(e,t,i){let n=oe(e,t,this.grid.getApi()),o=kt(e,t,this.grid.getApi());if(i.processCellCallback){const l=i.processCellCallback({value:n,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(l!=null)return String(l)}const a=this.groupValue(e,t);return a!==void 0&&(n=a,o=n===null?"":String(n)),n instanceof Date?n.toISOString().slice(0,10):o??(n==null?"":String(n))}groupValue(e,t){var i;return t.group||t.footer?(i=t.groupData)==null?void 0:i[e.colId]:void 0}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),i=this.getExportRows(e),n=e.columnSeparator??",",o=[];if(!e.skipHeader){const l=t.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),n,e.suppressQuotes)),o.push(this.csvRow(l,n,e.suppressQuotes))}for(const l of i){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:l,api:this.grid.getApi()}))continue;const r=t.map(d=>this.getCellValueForExport(d,l,e));o.push(this.csvRow(r,n,e.suppressQuotes))}return o.join(`\r
|
|
25
|
-
`)}csvRow(e,t,
|
|
26
|
-
`))?`"${o.replace(/"/g,'""')}"`:o}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),
|
|
27
|
-
`);a.length&&a[a.length-1]===""&&a.pop();const l=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=l.findIndex(p=>p.colId===o.colId),d=[],c=[];a.forEach((p,f)=>{const u=p.split(" "),h=n+f,g=this.grid.getDisplayedRowAtIndex(h);if(!g){const v={};u.forEach((m,C)=>{const S=l[r+C];S!=null&&S.field&&(v[S.field]=m)}),c.push(v);return}u.forEach((v,m)=>{const C=l[r+m];C&&this.grid.setCellValue(C,g,v,"paste")}),d.push(g)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const t=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t,()=>this.fallbackCopy(e,t)):this.fallbackCopy(e,t)}fallbackCopy(e,t){const i=document.createElement("textarea");i.value=e,i.style.position="fixed",i.style.opacity="0",document.body.appendChild(i),i.select();try{document.execCommand("copy")}catch{}document.body.removeChild(i),t()}}const vt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],wt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class fo{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var g,v;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}=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);const r=n?{...n}:this.getDefaultModel(i);let d=n?{...n}:null;const c=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),close()},p=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),close()};if(i==="set")a.appendChild(this.buildSetFilter(e,r,m=>{d=m}));else if(i==="boolean"){const m=this.buildConditionSelect(["true","false"],String(r.filter??""),C=>{d={filterType:"boolean",filter:C==="true"}});a.appendChild(m)}else{const m=i==="number"?wt:vt,C=this.buildConditionSelect(m,r.type||m[0],S=>{r.type=S,d={...r}});if(a.appendChild(C),r.type!=="blank"&&r.type!=="notBlank")if(i==="number"&&r.type==="inRange"){const S=document.createElement("div");S.className="ag-filter-inputs";const b=document.createElement("input");b.type="number",b.className="ag-filter-input",b.value=r.filter??"",b.placeholder=this.grid.t("from"),b.addEventListener("input",()=>{d={...r,filter:b.value,filterTo:y.value}});const y=document.createElement("input");y.type="number",y.className="ag-filter-input",y.value=r.filterTo??"",y.placeholder=this.grid.t("to"),y.addEventListener("input",()=>{d={...r,filter:b.value,filterTo:y.value}}),S.appendChild(b),S.appendChild(y),a.appendChild(S)}else if(i==="date"){const S=document.createElement("div");S.className="ag-filter-inputs";const b=document.createElement("input");b.type="date",b.className="ag-filter-input",b.value=r.dateFrom??"",b.addEventListener("input",()=>{d={...r,dateFrom:b.value,dateTo:y.value}});const y=document.createElement("input");y.type="date",y.className="ag-filter-input",y.value=r.dateTo??"",y.addEventListener("input",()=>{d={...r,dateFrom:b.value,dateTo:y.value}}),S.appendChild(b),S.appendChild(y),a.appendChild(S)}else{const S=document.createElement("input");S.type=i==="number"?"number":"text",S.className="ag-filter-input",S.value=r.filter??"",S.placeholder=this.grid.t("filterOoo"),S.addEventListener("input",()=>{d={...r,filter:S.value}}),S.addEventListener("keydown",b=>{b.key==="Enter"&&c()}),a.appendChild(S),setTimeout(()=>S.focus(),0)}else d={...r}}if(i==="text"||i==="number"){const m=document.createElement("div");m.className="ag-filter-second-condition";const C=document.createElement("select");C.className="ag-filter-condition",C.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,C.value=r.operator||"AND",m.appendChild(C);const S=this.buildConditionSelect(i==="number"?wt:vt,((g=r.condition2)==null?void 0:g.type)||(i==="number"?wt:vt)[0],y=>{d||(d={...r}),d.condition2={...d.condition2,type:y}});m.appendChild(S);const b=document.createElement("input");b.type=i==="number"?"number":"text",b.className="ag-filter-input",b.placeholder=this.grid.t("secondValue"),b.value=((v=r.condition2)==null?void 0:v.filter)??"",b.addEventListener("input",()=>{d||(d={...r}),d.condition2={...d.condition2,filter:b.value}}),m.appendChild(b),a.appendChild(m),C.addEventListener("change",()=>{d||(d={...r}),d.operator=C.value})}const f=document.createElement("div");f.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",c);const h=document.createElement("button");h.className="ag-button",h.textContent=this.grid.t("clear"),h.addEventListener("click",p),f.appendChild(h),f.appendChild(u),a.appendChild(f),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(g=>{!g.group&&!g.footer&&a.add(oe(e,g,this.grid.getApi()))});const r=[...a].sort((g,v)=>g===v?0:g<v?-1:1),d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((t.values||[]).map(g=>String(g))),p=()=>{d.innerHTML="";const g=o.value.toLowerCase();let v=0;for(const m of r){const C=m==null?"(Blanks)":String(m);if(g&&!C.toLowerCase().includes(g))continue;v++;const S=document.createElement("label");S.className="ag-set-filter-item";const b=document.createElement("input");b.type="checkbox",b.checked=c.has(String(m)),b.addEventListener("change",()=>{b.checked?c.add(String(m)):c.delete(String(m)),i({filterType:"set",values:[...c]})});const y=document.createElement("span");y.textContent=C,S.appendChild(b),S.appendChild(y),d.appendChild(S)}if(v===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),d.appendChild(m)}};o.addEventListener("input",p),p();const f=document.createElement("div");f.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 g of r)c.add(String(g));p(),i({filterType:"set",values:[...c]})});const h=document.createElement("button");return h.className="ag-button ag-button-small",h.textContent=this.grid.t("clearAll"),h.addEventListener("click",()=>{c.clear(),p(),i({filterType:"set",values:[]})}),f.appendChild(u),f.appendChild(h),n.appendChild(d),n.appendChild(f),i({filterType:"set",values:[...c]}),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 l=vs[o];a.textContent=l?this.grid.t(l):o,o===t&&(a.selected=!0),n.appendChild(a)}return n.addEventListener("change",()=>i(n.value)),n}openMultiFilter(e,t){var S;const i=this.grid.getFilterService().getFilterInstance(e.colId),n=i&&i.filterType==="multi"?i:null,o=(S=n==null?void 0:n.filterModels)!=null&&S.length?n.filterModels.map(b=>({...b})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(n==null?void 0:n.operator)||"AND";const{ePopup:l,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,l.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const p=document.createElement("span");p.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}),c.appendChild(p),c.appendChild(f),l.appendChild(c);const u=document.createElement("div");u.className="ag-multi-filter-list",l.appendChild(u);const h=()=>{u.innerHTML="",o.forEach((b,y)=>{const R=document.createElement("div");R.className="ag-multi-filter-row";const M=document.createElement("select");M.className="ag-filter-condition";const T=["text","number","date","set","boolean"];for(const k of T){const $=document.createElement("option");$.value=k,$.textContent=k.charAt(0).toUpperCase()+k.slice(1),k===b.filterType&&($.selected=!0),M.appendChild($)}M.addEventListener("change",()=>{o[y]={...this.getDefaultModel(M.value)},h()}),R.appendChild(M);const W=b.filterType==="number"?wt:vt,E=this.buildConditionSelect(W,b.type||W[0],k=>{o[y].type=k});if(R.appendChild(E),b.filterType!=="blank"&&b.type!=="blank"&&b.type!=="notBlank"){const k=document.createElement("input");k.type=b.filterType==="number"?"number":"text",k.className="ag-filter-input",k.value=b.filter??"",k.placeholder=this.grid.t("value"),k.addEventListener("input",()=>{o[y].filter=k.value}),R.appendChild(k)}const x=document.createElement("button");x.className="ag-button ag-button-small",x.textContent="×",x.title=this.grid.t("removeFilter"),x.addEventListener("click",()=>{o.splice(y,1),h()}),R.appendChild(x),u.appendChild(R)})};h();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addFilter"),g.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),h()}),l.appendChild(g);const v=document.createElement("div");v.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(y=>y.filter!==void 0&&y.filter!==""||y.type==="blank"||y.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(C),v.appendChild(m),l.appendChild(v),this.popupService.positionAt(l,t)}openAdvancedFilter(e){var S,b;const t=this.grid.getFilterService(),i=t.getAdvancedFilterModel(),n=(S=i==null?void 0:i.conditions)!=null&&S.length?i.conditions.map(y=>({...y})):[{colId:((b=this.grid.getColumns().center[0])==null?void 0:b.colId)??"",type:"contains",filter:""}];let o=(i==null?void 0:i.operator)||"AND";const{ePopup:a,close:l}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),a.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",a.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(y=>y.filter),p=()=>{d.innerHTML="",n.forEach((y,R)=>{const M=document.createElement("div");M.className="ag-advanced-filter-row";const T=document.createElement("select");T.className="ag-filter-condition";for(const F of c()){const G=document.createElement("option");G.value=F.colId,G.textContent=F.headerName||F.field||F.colId,F.colId===y.colId&&(G.selected=!0),T.appendChild(G)}T.addEventListener("change",()=>{n[R].colId=T.value}),M.appendChild(T);const W=this.grid.getColumn(y.colId),E=W&&W.filter!==!1?String(W.filter):"text",x=E==="number"?wt:vt,k=this.buildConditionSelect(x,y.type||"contains",F=>{n[R].type=F});M.appendChild(k);const $=document.createElement("input");$.type=E==="number"?"number":"text",$.className="ag-filter-input",$.value=y.filter??"",$.placeholder=this.grid.t("value"),$.addEventListener("input",()=>{n[R].filter=$.value}),M.appendChild($);const q=document.createElement("button");q.className="ag-button ag-button-small",q.textContent="×",q.addEventListener("click",()=>{n.splice(R,1),p()}),M.appendChild(q),d.appendChild(M)})};p();const f=document.createElement("button");f.className="ag-button ag-button-small",f.textContent="+ "+this.grid.t("addCondition"),f.addEventListener("click",()=>{var y;n.push({colId:((y=c()[0])==null?void 0:y.colId)??"",type:"contains",filter:""}),p()}),a.appendChild(f);const u=document.createElement("div");u.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}),u.appendChild(h),u.appendChild(g),a.appendChild(u);const v=document.createElement("div");v.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 y=n.filter(R=>R.filter!==void 0&&R.filter!=="");y.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:y}):t.setAdvancedFilterModel(null),l()});const C=document.createElement("button");C.className="ag-button",C.textContent=this.grid.t("clear"),C.addEventListener("click",()=>{t.setAdvancedFilterModel(null),l()}),v.appendChild(C),v.appendChild(m),a.appendChild(v),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:r=>n.setColumnFilterModel(e,r),onGuiAttached:()=>{}}),{ePopup:a}=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}}class go{constructor(e){w(this,"filterModel",{});w(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 l=this.grid.getColumn(a.colId);return!l||!n?!0:n(e,l,{...a,filterType:l.filter===!0?"text":l.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 mo{constructor(e,t){w(this,"matches",[]);w(this,"activeMatch",0);w(this,"searchText","");w(this,"matchCase",!1);w(this,"ePopup",null);w(this,"eCount",null);w(this,"eInput",null);w(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const i=document.createElement("input");i.type="text",i.className="ag-find-input",i.placeholder=this.grid.translate("find","Find in grid..."),i.value=this.searchText,this.eInput=i,e.appendChild(i);const 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 l=(c,p,f)=>{const u=document.createElement("button");return u.className="ag-button ag-button-small",u.textContent=c,u.title=p,u.addEventListener("click",f),e.appendChild(u),u};l("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),l("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),l("×",this.grid.translate("close","关闭"),()=>this.close()),i.addEventListener("input",()=>this.find(i.value)),i.addEventListener("keydown",c=>{c.key==="Enter"?(c.preventDefault(),c.shiftKey?this.findPrevious():this.findNext()):c.key==="Escape"&&this.close()}),this.grid.getRootElement(),e.style.position="absolute",e.style.left="50%",e.style.top="8px",e.style.transform="translateX(-50%)",e.style.display="flex",setTimeout(()=>i.focus(),0)}close(){var e;(e=this.closePopup)==null||e.call(this),this.ePopup=null,this.closePopup=null,this.eInput=null,this.eCount=null,this.matches=[],this.applyHighlight()}setFindText(e){this.searchText=e,this.eInput&&(this.eInput.value=e),this.find(e)}getFindText(){return this.searchText}getNumMatches(){return this.matches.length}getActiveMatch(){return this.activeMatch}find(e){if(this.searchText=e,this.matches=[],this.activeMatch=0,e){const t=this.grid.getColumns().center;this.grid.getRowModel().forEachNode((i,n)=>{if(!(i.group||i.footer))for(const o of t){const a=kt(o,i,this.grid.getApi())??"",l=this.matchCase?a:a.toLowerCase(),r=this.matchCase?e:e.toLowerCase();l.includes(r)&&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 l=t.getPageSize(),r=Math.floor(e.rowIndex/l);r!==t.getCurrentPage()&&t.goToPage(r)}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,l=this.matches.findIndex(r=>r.rowIndex===n&&r.colId===a);o.classList.toggle("ag-find-match",l>=0),o.classList.toggle("ag-find-active-match",l>=0&&l===this.activeMatch)}}}}class vo{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 l=document.createElement("div");l.className="ag-formula-preview";const r=()=>{const g=this.grid.getDisplayedRowAtIndex(0);if(!g){l.textContent="";return}try{const v=gt(a.value,{data:g.data});l.textContent=`${this.grid.t("formulaPreview")}: ${v==null?"":String(v)}`,l.classList.remove("ag-formula-error")}catch(v){l.textContent=`${this.grid.t("formulaError")}: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||this.grid.t("invalidFormula")}`,l.classList.add("ag-formula-error")}};a.addEventListener("input",r),i.appendChild(l);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent=this.grid.t("functions"),d.appendChild(c);const p=document.createElement("div");p.className="ag-formula-functions-list";for(const g of Mt){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=g,v.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${g}()`,a.focus(),r()}),p.appendChild(v)}d.appendChild(p),i.appendChild(d);const f=document.createElement("div");f.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",()=>{const g=a.value.trim(),v=this.grid.getColumnModel(),m=v.getColumn(e.colId);m&&(m.field=g==="="||g===""?e.field:g,m.colDef={...m.colDef,field:m.field},g!=="="&&g!==""&&(m.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),n()});const h=document.createElement("button");h.className="ag-button",h.textContent=this.grid.t("clear"),h.addEventListener("click",()=>{a.value="=",r()}),f.appendChild(h),f.appendChild(u),i.appendChild(f),this.popupService.positionAt(i,t),r()}}class wo{constructor(e,t){w(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:l,close:r}=this.popupService.createPopup(280,"ag-note-editor");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`${this.grid.t("note")} — ${(n==null?void 0:n.headerName)||t}`,l.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=a,c.placeholder=this.grid.t("writeNote"),l.appendChild(c);const p=document.createElement("div");p.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,c.value.trim()||void 0),r()});const u=document.createElement("button");u.className="ag-button",u.textContent=this.grid.t("delete"),u.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),p.appendChild(u),p.appendChild(f),l.appendChild(p),this.popupService.positionAt(l,i),setTimeout(()=>c.focus(),0)}}class Co{constructor(e){w(this,"eOverlayWrapper");w(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}e.getRowCount()===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}class Oi{constructor(e,t){w(this,"enabled");w(this,"pageSize");w(this,"currentPage",0);w(this,"pageSizeSelector");w(this,"ePanel");w(this,"ePageInfo");w(this,"ePageInput");w(this,"ePageSizeContainer");w(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,l=document.createElement("span");l.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(l);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 p=document.createElement("option");p.value=String(c),p.textContent=String(c),c===this.pageSize&&(p.selected=!0),r.appendChild(p)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),a.appendChild(r)}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),i=Math.max(0,Math.min(t-1,e));if(i===this.currentPage){this.update();return}this.currentPage=i,this.grid.refreshModel("everything"),this.update(),this.grid.getRowRenderer().setVerticalScrollTop(0)}goToNextPage(){this.goToPage(this.currentPage+1)}goToPreviousPage(){this.goToPage(this.currentPage-1)}goToFirstPage(){this.goToPage(0)}goToLastPage(){this.goToPage(this.getTotalPages()-1)}update(){var l,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),i=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),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}),(r=(l=this.grid.getOptions()).onPaginationChanged)==null||r.call(l,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class yo{constructor(e){w(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 d;this.openPopups.has(n)&&(this.openPopups.delete(n),i.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",r,!0),(d=n.onClose)==null||d.call(n))},a=d=>{n.onClose=d},l=d=>{if(!i.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){o();return}i.contains(d.target)||o()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),o())};return this.getParent().appendChild(i),this.openPopups.add(n),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",r,!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 l=o.left-n.left+i;const r=n.width-a-4;l>r&&(l=r),l<4&&(l=4);const d=o.bottom-n.top+2;e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}class bo{constructor(e,t){w(this,"ranges",[]);w(this,"currentRange",null);w(this,"eOverlay");w(this,"eHandle");w(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((r,d)=>{r.id===o.id&&(a=d)}),a<0)return;const l=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(l.rowStartIndex,a),rowEndIndex:Math.max(l.rowStartIndex,a),colStartId:l.colStartId,colEndId:i.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(l.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(g=>g.colId===e.colStartId),n=t.findIndex(g=>g.colId===e.colEndId);if(i<0||n<0)return null;const o=Math.min(i,n),a=Math.max(i,n);let l=0,r=0;for(let g=0;g<=a;g++)g<o?l+=t[g].width:r+=t[g].width;const c=this.grid.getRowRenderer().getRowOffsets(),p=Math.min(e.rowStartIndex,e.rowEndIndex),f=Math.max(e.rowStartIndex,e.rowEndIndex),u=c[p]??p*(this.grid.getOptions().rowHeight??42);let h=0;for(let g=p;g<=f;g++){const v=this.grid.getDisplayedRowAtIndex(g);h+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:u,left:l,width:r,height:h}}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((l,r)=>{l.id===n&&(a=r)}),!(a<0))for(const l of o.getCellElements()){const r=l.dataset.colid,d=i.findIndex(f=>f.colId===r);let c=!1,p=!1;for(const f of e){const u=i.findIndex(S=>S.colId===f.colStartId),h=i.findIndex(S=>S.colId===f.colEndId),g=Math.min(f.rowStartIndex,f.rowEndIndex),v=Math.max(f.rowStartIndex,f.rowEndIndex),m=Math.min(u,h),C=Math.max(u,h);a>=g&&a<=v&&d>=m&&d<=C&&(c=!0,a===f.rowStartIndex&&d===u&&(p=!0))}l.classList.toggle("ag-cell-range-selected",c),l.classList.toggle("ag-cell-range-anchor",p)}}}getRangeCells(e){const t=this.getCenterColumns(),i=t.findIndex(c=>c.colId===e.colStartId),n=t.findIndex(c=>c.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),l=Math.min(i,n),r=Math.max(i,n),d=[];for(let c=o;c<=a;c++){const p=this.grid.getDisplayedRowAtIndex(c);if(p)for(let f=l;f<=r;f++)t[f]&&d.push({node:p,column:t[f]})}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===46||e.keyCode===8)&&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})}}}}class So{constructor(e,t){w(this,"dragState",null);w(this,"onMouseMoveBind",e=>this.onMouseMove(e));w(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,l)=>{a.id===n.dataset.rowid&&(o=l)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),l=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),r=e.clientY>n.getBoundingClientRect().top+l/2,d=(a[o]??0)+(r?l:0);t.indicator.style.display="block",t.indicator.style.top=`${d-1}px`}else t.indicator.style.display="none"}onMouseUp(e){const t=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!t)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),t.ghost.remove(),t.indicator.remove();const i=this.grid.getApi(),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}})}}class Eo{constructor(e){w(this,"ePanel");w(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 l;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(l=o.dataTransfer)==null?void 0:l.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 l;(l=a.dataTransfer)==null||l.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 xo{constructor(e,t,i){w(this,"selectedNodes",new Set);w(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(d=>{d===e&&(n=a),d===t&&(o=a),a++}),n<0||o<0)return;const l=Math.min(n,o),r=Math.max(n,o);a=0,i.forEachNode(d=>{a>=l&&a<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.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 Ro{constructor(e){w(this,"eBar");w(this,"eButtons");w(this,"ePanel");w(this,"panels",[]);w(this,"activePanelId",null);w(this,"visible",!1);w(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(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const l=(o==null?void 0:o.defaultToolPanel)||((n=this.panels[0])==null?void 0:n.id)||"columns";this.buildButtons(),this.openPanel(l)}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 d=t.value.toLowerCase();i.innerHTML="";const c=this.grid.getColumnModel().getColumns(),p=c.filter(f=>f.pinned!=="left"&&f.pinned!=="right").concat(c.filter(f=>f.pinned==="left"||f.pinned==="right"));for(const f of p)d&&!f.headerName.toLowerCase().includes(d)&&!f.colId.toLowerCase().includes(d)||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 l=document.createElement("div");l.className="ag-column-group-list",o.appendChild(l);const r=()=>{l.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"),l.appendChild(c)}for(const c of d){const p=document.createElement("div");p.className="ag-column-group-item",p.draggable=!0,p.addEventListener("dragstart",h=>{var g;(g=h.dataTransfer)==null||g.setData("text/plain",c.colId)}),p.addEventListener("dragover",h=>h.preventDefault()),p.addEventListener("drop",h=>{var v;h.preventDefault();const g=(v=h.dataTransfer)==null?void 0:v.getData("text/plain");g&&this.grid.getColumnModel().setRowGroupColumns([...d.map(m=>m.colId),g])});const f=document.createElement("span");f.textContent=c.headerName,p.appendChild(f);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)),p.appendChild(u),l.appendChild(p)}};return r(),l.addEventListener("dragover",d=>d.preventDefault()),l.addEventListener("drop",d=>{var p;d.preventDefault();const c=(p=d.dataTransfer)==null?void 0:p.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),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 l=document.createElement("button");l.className="ag-column-select-action",l.title=this.grid.t("groupByThisColumn"),l.textContent="≡",l.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(l)}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 l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(l)}}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(l=>l.filter);for(const l of a)o&&!l.headerName.toLowerCase().includes(o)||i.appendChild(this.buildFilterItem(l));if(!i.children.length){const l=document.createElement("div");l.className="ag-side-bar-empty",l.textContent=this.grid.t("noMatchingColumns"),i.appendChild(l)}};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 l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.innerHTML=Di,n.appendChild(l)}if(i.appendChild(n),e.filter==="set"){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=a?"Edit filter":"Add filter",l.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,l)),i.appendChild(l)}else if(e.filter==="date"){const l=document.createElement("input");l.type="date",l.className="ag-filter-input";const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.dateFrom)??"",l.addEventListener("change",()=>{t.setColumnFilterModel(e,l.value?{filterType:"date",dateFrom:l.value,dateTo:l.value}:null)}),i.appendChild(l)}else{const l=document.createElement("input");l.type=e.filter==="number"?"number":"text",l.className="ag-filter-input",l.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.filter)??"",l.addEventListener("input",()=>{t.handleFloatingFilterChange(e,l.value)}),i.appendChild(l)}if(a){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=this.grid.t("clear"),l.addEventListener("click",()=>t.setColumnFilterModel(e,null)),i.appendChild(l)}return i}}class Mo{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(),l=e.sort;let r=a.indexOf(l)+1;r>=a.length&&(r=0);const d=a[r];if(!o)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,i)=>(t.sortIndex??99)-(i.sortIndex??99)).forEach((t,i)=>t.sortIndex=i)}getSortModel(){return this.grid.getAllColumns().filter(e=>e.sort).sort((e,t)=>(e.sortIndex??0)-(t.sortIndex??0)).map(e=>({colId:e.colId,sort:e.sort}))}setSortModel(e){for(const t of this.grid.getAllColumns())t.sort=null,t.sortIndex=null;e.forEach((t,i)=>{const 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 ko{constructor(e,t){w(this,"eBar");w(this,"panels",[]);this.grid=e,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 l=document.createElement("div");l.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(l);const r={def:a,ePanel:l,render:()=>this.renderPanel(a.key,l)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const i=this.grid.getApi(),n=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,l=i.getSelectedNodes().length,r=[],d=this.grid.getColumnModel().getValueColumns().filter(c=>c.aggFunc);switch(this.grid.getRowModel().forEachNode(c=>{!c.footer&&c.group}),e){case"agTotalRowCountComponent":r.push(`${this.grid.translate("totalRows","Total Rows")} : ${He(a)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${He(n)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${He(n)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${He(l)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=i.getSelectedNodes().filter(f=>!f.group&&!f.footer),p=[];for(const f of d){const h=c.map(C=>oe(f,C,i)).filter(C=>typeof C=="number"&&!isNaN(C)),g=h.reduce((C,S)=>C+S,0),v=C=>C===null?"":He(C,f.decimals),m=[[this.grid.translate("average","Average"),h.length?g/h.length:null],[this.grid.translate("count","Count"),h.length],[this.grid.translate("min","Min"),h.length?Math.min(...h):null],[this.grid.translate("max","Max"),h.length?Math.max(...h):null],[this.grid.translate("sum","Sum"),h.length?g:null]];for(const[C,S]of m)p.push(`${C}${f.headerName?` (${f.headerName})`:""} : ${v(S)}`)}p.length&&r.push(p.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class To{constructor(e,t){w(this,"undoStack",[]);w(this,"redoStack",[]);w(this,"limit",50);w(this,"batchDepth",0);w(this,"batchBuffer",[]);w(this,"batchCounter",0);w(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 Lo{constructor(e,t){w(this,"ctx");w(this,"eHeader");w(this,"ePinnedLeftHeader");w(this,"ePinnedRightHeader");w(this,"eHeaderViewport");w(this,"eHeaderContainer");w(this,"eHeaderRow");w(this,"eFloatingFiltersRow",null);w(this,"eGroupRows");w(this,"headerCells",new Map);w(this,"customHeaderComponents",new Map);w(this,"resizeState",null);w(this,"dragState",null);w(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 l;const e=this.ctx.getColumnModel(),t=((l=e==null?void 0:e.getColumnGroups)==null?void 0:l.call(e))||[];this.eGroupRows.innerHTML="";const i=t.reduce((r,d)=>Math.max(r,d.depth),0),n=this.ctx.options.groupHeaderHeight??30;let o=0;for(let r=1;r<=i;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${n}px`;const c=this.ctx.getColumns().center;let p=0,f,u=0,h=0;const g=(m,C)=>{let S=m.groupId;for(;S;){const b=t.find(y=>y.id===S);if(!b)return null;if(b.depth===C)return b.id;S=b.parentId}return null},v=()=>{if(f==null)return;const m=t.find(y=>y.id===f);if(!m)return;const C=document.createElement("div");C.className="ag-header-group-cell",C.style.left=`${u}px`,C.style.width=`${h}px`,C.style.height=`${n}px`;const S=e.isGroupOpen(m.id),b=document.createElement("div");if(b.className="ag-header-group-cell-label",b.textContent=m.headerName,C.appendChild(b),!S){const y=document.createElement("span");y.className="ag-header-group-expand",y.textContent="▸",y.title=this.ctx.t("expandGroup"),C.appendChild(y)}C.addEventListener("click",()=>{e.setGroupOpen(m.id,!S)}),d.appendChild(C)};c.forEach(m=>{const C=g(m,r);C!==f&&(v(),f=C,u=p,h=0),h+=m.width,p+=m.width}),v(),d.style.width=`${p}px`,this.eGroupRows.appendChild(d),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 l=this.createFloatingFilter(o);l.style.left=`${n-o.width}px`,l.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(l)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${n}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${n}px`)}createHeaderCell(e){var a,l;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const i=e.colDef.headerComponent;if(typeof i=="function"){const r=i({column:e,colDef:e.colDef,api:((l=(a=this.ctx).getApi)==null?void 0:l.call(a))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),t.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const n=document.createElement("div");if(n.className="ag-header-cell-label",e.headerTooltip&&(n.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()),n.appendChild(r)}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 r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=qs,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=Ws,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const d=t.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=f=>{if(!this.resizeState)return;const u=f.clientX-this.resizeState.startX;let h=this.resizeState.startWidth+u;h=Math.max(e.minWidth,Math.min(e.maxWidth,h)),this.ctx.onColumnResized(e,Math.round(h),!1)},p=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",p),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",p)}),t.appendChild(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=t.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),t}createFloatingFilter(e){const t=document.createElement("div");if(t.className="ag-header-cell ag-floating-filter-cell",t.dataset.colid=e.colId,t.style.position="absolute",t.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const 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=Us):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=js),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 l=o.querySelector(".ag-filter-icon");l&&l.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 It{constructor(e,t,i,n,o,a,l){w(this,"eLeft",null);w(this,"eCenter",null);w(this,"eRight",null);w(this,"cellComps",[]);w(this,"pinned",!1);var r,d,c,p,f,u,h,g,v;if(this.ctx=e,this.node=t,this.rowHeight=a,t.masterNode){const m=e.renderDetailRow?e.renderDetailRow(t,this.eCenter):null;if(m){const C=document.createElement("div");C.className="ag-row ag-row-detail-row",C.dataset.rowid=t.id,C.style.height=`${m.height}px`,C.style.width="100%",C.appendChild(m.eDetail),this.eCenter=C,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&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),t.group&&((p=this.eCenter)==null||p.classList.add("ag-row-group"),(f=this.eLeft)==null||f.classList.add("ag-row-group"),(u=this.eRight)==null||u.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((h=this.eCenter)==null||h.classList.add("ag-row-selected"),(g=this.eLeft)==null||g.classList.add("ag-row-selected"),(v=this.eRight)==null||v.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 r;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&&((r=e.groupData)!=null&&r.__grandTotal)&&(n.classList.add("ag-row-full-width"),n.style.width="100%",n.style.right="0",n.style.left="0");let l=0;for(let d=0;d<t.length;d++){const c=t[d],p=this.createCell(c,e);let f=1;typeof c.colDef.colSpan=="function"&&(f=Math.max(1,Math.round(c.colDef.colSpan({value:oe(c,e,null),data:e.data,node:e,column:c,rowIndex:e.__displayIndex??0,api:null}))));let u=c.width;for(let h=1;h<f&&d+h<t.length;h++)u+=t[d+h].width;p.eCell.style.left=`${l}px`,p.eCell.style.width=`${u}px`,p.eCell.style.position="absolute",p.eCell.style.top="0",p.eCell.style.height=`${this.rowHeight}px`,f>1&&p.eCell.classList.add("ag-cell-col-span"),l+=u,d+=f-1,n.appendChild(p.eCell),this.cellComps.push(p)}return n.style.width=`${l}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 c,p;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:oe(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,u]of Object.entries(e.cellClassRules))u(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 l=(p=(c=this.ctx).getNote)==null?void 0:p.call(c,t.id,e.colId,e.colDef.note,{value:oe(e,t,null),data:t.data,node:t,column:e,api:null});if(l){const f=document.createElement("span");f.className="ag-cell-note-marker",f.title=l,f.addEventListener("click",u=>{var h,g;u.stopPropagation(),(g=(h=this.ctx).onNoteClick)==null||g.call(h,t.id,e.colId,f)}),i.appendChild(f)}if(e.rowDrag){const f=document.createElement("span");f.className="ag-row-drag-handle",f.innerHTML=Ai,f.title=this.ctx.t("dragRow"),f.addEventListener("mousedown",u=>{var h,g;u.button===0&&(u.stopPropagation(),(g=(h=this.ctx).onRowDragStart)==null||g.call(h,t,f,u))}),i.appendChild(f)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?i.title=String(t.data[r]):e.tooltipValueGetter&&(i.title=String(e.tooltipValueGetter({value:oe(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:i,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:t,node:i}={column:e.column,node:this.node},n=oe(t,i,null),o=kt(t,i,null);e.lastValue=n,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,l=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||l){e.custom=!0;const c=a||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const p={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&&Nt[a]){const u=Nt[a](p);u instanceof HTMLElement?f=u:(e.rendererInstance=u,f=u.getGui())}else if(l){const u=l(p);u instanceof HTMLElement?f=u:u&&typeof u.getGui=="function"?(e.rendererInstance=u,f=u.getGui()):typeof u=="string"&&(e.eValue.innerHTML=u)}f&&e.eValue.appendChild(f)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=o??"";if((i.group||i.footer)&&i.groupData){const c=i.groupData[t.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,i){var a,l,r,d;const n=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(n&&!n.has(c.column.colId))continue;const p=oe(c.column,this.node,null),f=t||p!==c.lastValue;if(!f&&!i)continue;const u=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:p,valueFormatted:kt(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=p,i&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(f||i)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=p,i&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(i||f&&u!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.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),(l=this.eLeft)==null||l.classList.toggle("ag-row-selected",o),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",o),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,i){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&i.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const 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=[]}}function Bi(s,e,t){const i=s.length;if(i===0||t<=0)return[];let n=0,o=i-1;for(;n<o;){const c=n+o>>1;s[c]>=t?o=c:n=c+1}const a=s[n]>=t?n:i-1,l=e[a];if(!l||l.level===0)return[];const r=[];let d=l.level;for(let c=a-1;c>=0;c--){const p=e[c];if(!(!p||p.level>=d)&&(d=p.level,p.group&&s[c]<t&&r.push(c),p.level===0))break}return r.reverse()}class No{constructor(e,t,i){w(this,"ctx");w(this,"eRoot");w(this,"eHeader");w(this,"eBody");w(this,"ePinnedLeft");w(this,"ePinnedRight");w(this,"ePinnedLeftInner");w(this,"ePinnedRightInner");w(this,"eViewport");w(this,"eContainer");w(this,"eFloatingTop");w(this,"eFloatingBottom");w(this,"eFloatingTopLeft");w(this,"eFloatingTopRight");w(this,"eFloatingBottomLeft");w(this,"eFloatingBottomRight");w(this,"eStickyTop");w(this,"eStickyLeft");w(this,"eStickyCenter");w(this,"eStickyRight");w(this,"rowComps",new Map);w(this,"stickyComps",new Map);w(this,"hoveredRowId",null);w(this,"rowOffsets",[]);w(this,"rowIndices",new Map);w(this,"rowInfos",[]);w(this,"totalHeight",0);w(this,"lastScrollTop",-1);w(this,"lastRange",[-1,-1]);w(this,"heightVersion",0);w(this,"scrollFrame",null);w(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),e.shiftKey&&!o&&(o=n,n=0),n&&(i.scrollTop+=n),o&&(i.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});w(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)});w(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}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount();this.rowIndices.clear();const 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 l=0;l<e;l++)t[l]=l*a,i[l]=this.rowInfoAt(l);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=i}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?(this.rowIndices.set(t.id,e),{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,l,r,d)=>{o.innerHTML="",a.innerHTML="",l.innerHTML="";const{left:c,center:p,right:f}=this.ctx.getColumns();let u=0;for(let h=0;h<r;h++){const g=d(h);if(!g)continue;const v=this.ctx.getRowHeight(g),m=new It(this.ctx,g,c,p,f,v,this.heightVersion);m.appendTo(a,o,l),m.setTop(u),u+=v,this.rowComps.set(`${g.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${u}px`,o.style.display=r>0?"":"none",a.style.height=`${u}px`,l.style.height=`${u}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:l}=this.ctx.getColumns(),r=new It(this.ctx,i,o,a,l,this.getRowHeightForIndex(n),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[n]??0),this.rowComps.set(this.rowCompKey(i),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){return this.rowIndices.get(e.id)??-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){var t,i;this.eViewport.scrollLeft=e,this.syncPinnedScroll(),(i=(t=this.ctx).onViewportScroll)==null||i.call(t)}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Bi(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 l=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;a.add(c.id);let p=this.stickyComps.get(c.id);if(!p){const f=this.rowComps.get(c.id);f&&(f.destroy(),this.rowComps.delete(c.id)),p=new It(this.ctx,c,t,i,n,this.getRowHeightForIndex(d),this.heightVersion),p.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),p.setSticky(!0),this.stickyComps.set(c.id,p)}p.setTop(l),l+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)a.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${l}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,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,l;if(this.hasVariableHeights())a=this.findIndexAtPixel(i)-o,l=this.findIndexAtPixel(i+n)+o;else{const v=this.getFixedRowHeight();a=Math.floor(i/v)-o,l=Math.ceil((i+n)/v)+o}if(a=Math.max(0,a),l=Math.min(t-1,l),!e&&this.lastRange[0]===a&&this.lastRange[1]===l&&this.lastScrollTop===i)return;const r=this.lastRange[0]!==a||this.lastRange[1]!==l;this.lastRange=[a,l],this.lastScrollTop=i;const d=new Set(this.stickyComps.keys()),c=this.syncStickyGroupRows(),p=d.size!==c.size||[...d].some(v=>!c.has(v));if(!e&&!r&&!p)return;const f=new Set(c),{left:u,center:h,right:g}=this.ctx.getColumns();for(let v=a;v<=l;v++){const m=this.ctx.rowModel.getRow(v);if(!m||(f.add(m.id),c.has(m.id)))continue;let C=this.rowComps.get(m.id);C||(C=new It(this.ctx,m,u,h,g,this.getRowHeightForIndex(v),this.heightVersion),C.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,C)),C.setTop(this.rowOffsets[v]??v*this.getFixedRowHeight())}for(const[v,m]of this.rowComps)!f.has(v)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(v))}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;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,l)=>a+l.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 l=this.ctx.rowModel.getRowNode(a);if(!l)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===n);return d?{node:l,column:d,eCell:i,rowIndex:this.findRowIndex(l)}:null}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:oe(t.column,t.node,null),rowIndex:this.findRowIndex(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.findRowIndex(n)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:oe(t.column,t.node,null),rowIndex:this.findRowIndex(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:oe(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:oe(t.column,t.node,null),rowIndex:this.findRowIndex(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 Ge{constructor(){w(this,"cleanups",new Set);w(this,"stopped",!1)}get destroyed(){return this.stopped}add(e){return this.stopped?e():this.cleanups.add(e),()=>{this.cleanups.delete(e)&&e()}}listen(e,t,i,n){return e.addEventListener(t,i,n),this.add(()=>e.removeEventListener(t,i,n))}timeout(e,t){if(this.stopped)return 0;const i=window.setTimeout(()=>{n(),this.stopped||e()},t),n=this.add(()=>window.clearTimeout(i));return i}interval(e,t){if(this.stopped)return 0;const i=window.setInterval(()=>{this.stopped||e()},t);return this.add(()=>window.clearInterval(i)),i}destroy(){if(this.stopped)return;this.stopped=!0;const e=[...this.cleanups].reverse();this.cleanups.clear();let t;for(const i of e)try{i()}catch(n){t??(t=n)}if(t!==void 0)throw t}}function xe(s,e,t={},i=[]){const n=new Ge,o=new Set,a=f=>[...o].some(u=>u.contains(f)),l=new Set,r=new WeakMap,d=f=>{const u=f.target;if(!(u!=null&&u.closest))return;const h=u.closest('button,input,select,textarea,a,[data-action],[contenteditable],[role="button"],[role="tab"],[data-node-id],[data-rowid],[data-viewport],canvas');if(!h||!a(h))return;const g={};for(let m=h;m&&a(m);m=m.parentElement)for(const[C,S]of Object.entries(m.dataset))S!==void 0&&!(C in g)&&(g[C]=S);const v=h;r.has(f)||(r.set(f,{component:e,type:f.type,action:g.action??g.control,value:"value"in h?v.value:void 0,checked:v.type==="checkbox"||v.type==="radio"?v.checked:void 0,data:g,originalEvent:f}),queueMicrotask(()=>c(f)))},c=f=>{var g;const u=r.get(f);if(!u||n.destroyed)return;r.delete(f),(g=t.onInteraction)==null||g.call(t,u);for(const v of[...l])v(u);const h=s.ownerDocument.defaultView.CustomEvent;s.dispatchEvent(new h("rowvia:interaction",{detail:u,bubbles:!0}))},p=f=>{if(n.destroyed||o.has(f))return()=>{};o.add(f);const u=[];for(const h of["click","dblclick","contextmenu","input","change","submit","keydown","pointerdown","pointerup","wheel"])u.push(n.listen(f,h,d,{capture:!0,passive:!0}));return()=>{o.delete(f),u.forEach(h=>h())}};for(const f of[s,...i])p(f);return{addRoot:p,onInteraction(f){return n.destroyed?()=>{}:(l.add(f),()=>{l.delete(f)})},destroy(){n.destroy(),l.clear(),o.clear()}}}const Io={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 nt{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eventService",new ms);w(this,"columnModel");w(this,"rowModel");w(this,"clientSideRowModel",null);w(this,"serverSideRowModel",null);w(this,"infiniteRowModel",null);w(this,"viewportRowModel",null);w(this,"rowRenderer");w(this,"headerView");w(this,"selectionService");w(this,"editService");w(this,"filterService");w(this,"sortService");w(this,"paginationService",null);w(this,"popupService");w(this,"filterGui");w(this,"contextMenuService");w(this,"columnMenuService");w(this,"statusBarService");w(this,"sideBarService");w(this,"findService");w(this,"rangeSelectionService");w(this,"chartService");w(this,"overlayService");w(this,"exportService");w(this,"rowGroupPanel",null);w(this,"undoRedoService");w(this,"formulaEditorService");w(this,"notesService");w(this,"rowDragService");w(this,"api");w(this,"columnApi");w(this,"localeText");w(this,"rowNodeServices");w(this,"eGridDiv");w(this,"eRoot");w(this,"eMain");w(this,"eHeader");w(this,"quickFilter","");w(this,"resizeObserver",null);w(this,"destroyed",!1);w(this,"gridReadyDispatched",!1);w(this,"context");w(this,"onWindowResize",()=>{this.onGridSizeChanged()});w(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 d,c,p,f;this.eGridDiv=e,this.options={...Io,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Cs(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.interactions=xe(this.eRoot,"grid",this.options),this.onInteraction=this.interactions.onInteraction,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,h)=>this.selectionService.selectNode(u,h),deselectNode:u=>this.selectionService.deselectNode(u),isNodeSelected:u=>this.selectionService.isNodeSelected(u)},this.columnModel=new ki(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new xo(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),u=>this.isNodeSelectable(u)),this.filterService=new go(this),this.sortService=new Mo(this),this.popupService=new yo(this),this.filterGui=new fo(this,this.popupService),this.contextMenuService=new Ys(this,this.popupService),this.columnMenuService=new Ks(this,this.popupService),this.editService=new Xs(this,this.eventService),this.undoRedoService=new To(this,this.eventService),this.formulaEditorService=new vo(this,this.popupService),this.notesService=new wo(this,this.popupService),this.rowDragService=new So(this,this.eventService),this.chartService=new xs(this,this.popupService),this.findService=new mo(this,this.popupService),this.exportService=new po(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 bs(n),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new Ss(n),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new Es(n),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new ds({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 Lo(this.eHeader,{options:this.options,eventService:this.eventService,getColumns:()=>this.getColumns(),getColumnModel:()=>this.columnModel,getSortState:()=>({sortColumns:this.getAllColumns().filter(u=>u.sort)}),onSortRequested:(u,h,g)=>this.sortService.onSortRequested(u,h,g),onColumnResized:(u,h,g)=>this.onColumnResized(u,h,g),onColumnMoved:(u,h)=>this.onColumnMoved(u,h),onColumnMenuClicked:(u,h)=>this.columnMenuService.openColumnMenu(u,h),onFilterOpened:(u,h)=>this.filterGui.openFilter(u,h),isFilterActive:u=>this.filterService.isFilterActive(u),getQuickFilterText:()=>this.quickFilter,onFloatingFilterChanged:(u,h)=>this.filterService.handleFloatingFilterChange(u,h),onHeaderCheckboxChanged:(u,h)=>this.onHeaderCheckboxChanged(u,h),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,h)=>this.filterService.setColumnFilterModel(u,h)}),this.rowRenderer=new No(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:u=>this.t(u),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 g,v,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const u=this.rowRenderer.getFirstVisibleRowIndex(),h=this.rowRenderer.getLastVisibleRowIndex();(g=this.serverSideRowModel)==null||g.onViewportChanged(u,h),(v=this.infiniteRowModel)==null||v.onViewportChanged(u,h),(m=this.viewportRowModel)==null||m.onViewportChanged(u,h)},getCellText:(u,h)=>{const g=oe(u,h,this.api);return g==null?"":String(g)},renderDetailRow:u=>this.renderDetailRow(u),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(u,h,g)=>this.rowDragService.startDrag(u,g),getNote:(u,h,g,v)=>this.notesService.getNote(u,h,g,v),onNoteClick:(u,h,g)=>this.notesService.openNoteEditor(u,h,g),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new bo(this,this.eventService),this.statusBarService=new ko(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Co(this),this.sideBarService=new Ro(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 Oi(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Eo(this));const{api:a,columnApi:l}=ls(this);this.api=a,this.columnApi=l,this.columnModel.setGridApi(this.api),(f=(p=this.rowModel).setGridApi)==null||f.call(p,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,h;this.statusBarService.update(),this.rowRenderer.refreshCells({force:!0}),(h=(u=this.options).onSelectionChanged)==null||h.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=ki.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const i=this.localeText.t(e);return i===e?t:i}getContext(){return this.context}getEventService(){return this.eventService}getColumnModel(){return this.columnModel}getRowModel(){return this.rowModel}getRowRenderer(){return this.rowRenderer}getHeaderView(){return this.headerView}getSelectionService(){return this.selectionService}getEditService(){return this.editService}getFilterService(){return this.filterService}getSortService(){return this.sortService}getFilterGui(){return this.filterGui}getPaginationService(){return this.paginationService}getSideBarService(){return this.sideBarService}getChartService(){return this.chartService}getFindService(){return this.findService}getRangeSelectionService(){return this.rangeSelectionService}getExportService(){return this.exportService}getPopupService(){return this.popupService}getOverlayService(){return this.overlayService}getRowGroupPanel(){return this.rowGroupPanel}getUndoRedoService(){return this.undoRedoService}getFormulaEditorService(){return this.formulaEditorService}getNotesService(){return this.notesService}getRowDragService(){return this.rowDragService}getServerSideRowModel(){return this.serverSideRowModel}getInfiniteRowModel(){return this.infiniteRowModel}getViewportRowModel(){return this.viewportRowModel}updateColumnTotalCache(){var i,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 l of t){const r=oe(l,a,this.api);typeof r=="number"&&!isNaN(r)&&o.set(l.colId,(o.get(l.colId)??0)+r)}});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:oe(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:oe(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,l,r,d;const{node:t,column:i,event:n}=e;if(this.options.enableRangeSelection,i.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(l=(a=this.options).onCellClicked)==null||l.call(a,{...e,api:this.api,colDef:i.colDef,value:oe(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),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:i.colDef,value:oe(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 l=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);l&&l(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,l;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}),(l=(a=this.options).onRowDataChanged)==null||l.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,l;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),i=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,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}),(l=(a=this.options).onGridSizeChanged)==null||l.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const t=e.masterNode;if(!t)return null;const i=this.options.detailRowAutoHeight===!0,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,l=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(l&&r){const p=r({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 nt(f,{...l,rowData:p,theme:this.options.theme})},0)}else if(typeof a=="function"){const p=a({data:t.data,node:t,api:this.api,context:this.context});p instanceof HTMLElement?o.appendChild(p):o.textContent=String(p??"")}else typeof a=="string"&&(o.textContent=a);if(i){const p=Math.max(40,o.scrollHeight||n);return e.rowHeight=p,o.style.height=`${p}px`,{eDetail:o,height:p}}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 Oi(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,this.interactions.destroy(),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 Vi(s,e){const t=new nt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function Gi(s,e={}){const t=document.createElement("dialog");t.className="rowvia-detail-dialog";const i=xe(t,"detail-dialog",e),n=()=>{var d;return(d=e.onClose)==null?void 0:d.call(e)};t.addEventListener("close",n);const o=document.createElement("h2"),a=document.createElement("dl"),l=document.createElement("button");l.type="button",l.textContent="关闭";const r=()=>t.close();return l.addEventListener("click",r),t.append(o,a,l),s.append(t),{onInteraction:i.onInteraction,open(d){var c;o.textContent=d.title,t.setAttribute("aria-label",d.title),a.replaceChildren();for(const p of d.fields){const f=document.createElement("dt"),u=document.createElement("dd");f.textContent=p.label,u.textContent=p.value,a.append(f,u)}t.open||t.showModal(),(c=e.onOpen)==null||c.call(e,d)},close:r,destroy(){t.open&&t.close(),l.removeEventListener("click",r),t.removeEventListener("close",n),i.destroy(),t.remove()}}}const Ao=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Do=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Fo=[{value:"inRange",label:"介于"},{value:"before",label:"早于"},{value:"after",label:"晚于"}];function Ee(s,e){const t=document.createElement(s);return e&&(t.className=e),t}function st(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 Po{constructor(e,t,i,n){w(this,"filterFields");w(this,"sortFields");w(this,"filterRows",[]);w(this,"sorts",[]);w(this,"filterPanel",null);w(this,"sortPanel",null);w(this,"filterAnchor",null);w(this,"sortAnchor",null);w(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=Ee("div","gt-panel gt-filter-panel");t.addEventListener("mousedown",d=>d.stopPropagation());const i=Ee("div","gt-panel-title");i.textContent="筛选",t.appendChild(i);const n=Ee("div","gt-filter-rows");t.appendChild(n);const o=()=>{if(n.textContent="",!this.filterRows.length){const d=Ee("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",n.appendChild(d)}for(const d of this.filterRows)n.appendChild(this.renderFilterRow(d,o))},a=Ee("div","gt-filter-add");for(const d of this.filterFields)a.appendChild(st(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const l=Ee("div","gt-panel-hint");l.textContent="多个条件同时满足(且)",t.appendChild(l);const r=Ee("div","gt-panel-actions");r.append(st("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),st("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const i=Ee("div","gt-filter-row"),n=this.filterFields.find(d=>d.colId===e.colId),o=document.createElement("select");o.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),o.appendChild(c)}o.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===o.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),i.appendChild(o);const a=e.kind==="number"?Do:e.kind==="date"?Fo:Ao,l=document.createElement("select");l.className="gt-panel-select gt-panel-select-cond";for(const d of a){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),l.appendChild(c)}if(l.addEventListener("change",()=>{e.type=l.value,t()}),i.appendChild(l),e.type!=="blank")if(n!=null&&n.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 p of n.options){const f=document.createElement("option");f.value=p.value,f.textContent=p.label,p.value===e.value&&(f.selected=!0),d.appendChild(f)}d.addEventListener("change",()=>{e.value=d.value}),i.appendChild(d)}else if(e.kind==="date"){const d=document.createElement("input");if(d.type="date",d.className="gt-panel-input",d.value=e.value,d.addEventListener("change",()=>{e.value=d.value}),i.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="date",c.className="gt-panel-input",c.value=e.valueTo,c.addEventListener("change",()=>{e.valueTo=c.value}),i.appendChild(c)}}else if(e.kind==="number"){const d=document.createElement("input");if(d.type="number",d.className="gt-panel-input gt-panel-input-num",d.placeholder="数值",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),i.appendChild(d),e.type==="inRange"){const c=document.createElement("input");c.type="number",c.className="gt-panel-input gt-panel-input-num",c.placeholder="至",c.value=e.valueTo,c.addEventListener("input",()=>{e.valueTo=c.value}),i.appendChild(c)}}else{const d=document.createElement("input");d.type="text",d.className="gt-panel-input",d.placeholder="文本",d.value=e.value,d.addEventListener("input",()=>{e.value=d.value}),i.appendChild(d)}const r=st("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),t()});return r.title="移除条件",i.appendChild(r),i}applyFilter(){const e={};for(const t of this.filterRows){if(t.type==="blank"){e[t.colId]={filterType:t.kind==="number"?"number":"text",type:"blank",filter:""};continue}if(t.kind==="date"){const i=(t.type==="after",t.value),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=Ee("div","gt-panel gt-sort-panel");t.addEventListener("mousedown",l=>l.stopPropagation());const i=Ee("div","gt-panel-title");i.textContent="排序",t.appendChild(i);const n=Ee("div","gt-sort-list");t.appendChild(n);const o=()=>{var l;n.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(u=>u.colId===r.colId),c=d>=0,p=Ee("div","gt-sort-item");c&&p.classList.add("gt-sort-item-active");const f=Ee("span","gt-sort-label");if(f.textContent=r.label,p.appendChild(f),c){const u=Ee("span","gt-sort-badge");u.textContent=String(d+1),p.appendChild(u);const h=Ee("span","gt-sort-dir");h.textContent=((l=this.sorts[d])==null?void 0:l.sort)==="asc"?"↑ 升序":"↓ 降序",p.appendChild(h)}p.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(h=>h.colId!==r.colId):this.sorts.push({colId:r.colId,sort:"asc"}),o()}),n.appendChild(p)}},a=Ee("div","gt-panel-actions");a.append(st("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),st("应用","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 zi=864e5;function je(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 ke(s){return new Date(`${s}T00:00:00`)}function Re(s,e){return new Date(s.getTime()+e*zi)}function Oe(s,e){const t=typeof s=="string"?ke(s):s,i=typeof e=="string"?ke(e):e;return Math.round((i.getTime()-t.getTime())/zi)}function Ct(){return je(new Date)}function $o(s){return s.status!=="done"&&s.end&&s.end<Ct()&&s.progress<100?"delayed":s.status}function Kt(s){const e=ke(s);return`${e.getMonth()+1}月${e.getDate()}日`}const _i=["day","week","biweek","month","bimonth","quarter","halfyear","year"],At={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Ho={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2};function Yt(s){const e=(s.getDay()+6)%7;return Re(s,-e)}function Oo(s,e){const t=Math.max(1,Oe(s,e)+1);let i=0;for(let n=0;n<t;n++){const o=Re(s,n).getDay();o!==0&&o!==6&&i++}return Math.max(1,i)}function Bo(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function Wi(s,e,t){const i=[];if(s==="day"){let r=new Date(e);for(;r<t;){const d=Re(r,1);i.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return i}if(s==="week"||s==="biweek"){let r=Yt(e);for(;r<t;){const d=Re(r,s==="biweek"?14:7);i.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return i}const n=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/n)*n,1),a=r=>s==="month"||s==="bimonth"?`${r.getMonth()+1}月`:s==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let l=o(e);for(;l<t;){const r=Bo(l,n);i.push({start:new Date(l),end:r,primary:a(l),secondary:""}),l=r}return i}const ve={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)"},Dt={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},Vo=4,qi=6,De=28;class Ui{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eRoot");w(this,"eHeader");w(this,"eRuler");w(this,"rulerCtx");w(this,"eRulerTools");w(this,"eStepLabel");w(this,"eZoomValue");w(this,"eStepMenu",null);w(this,"eScroll");w(this,"eSpacer");w(this,"eCanvas");w(this,"ctx");w(this,"eTooltip");w(this,"eTodayBadge");w(this,"ePopup",null);w(this,"tasks",[]);w(this,"tasksById",new Map);w(this,"rows",[]);w(this,"selectedId",null);w(this,"hoverId",null);w(this,"unit","day");w(this,"zoom",1);w(this,"theme","content");w(this,"epochStart",new Date);w(this,"totalDays",1);w(this,"hits",[]);w(this,"hitsByRow",new Map);w(this,"drag",null);w(this,"ghost",null);w(this,"dirty",!0);w(this,"lastLeft",-1);w(this,"lastTop",-1);w(this,"timer");w(this,"observer",null);w(this,"resizeHandler",()=>this.resizeCanvases());w(this,"showChildren",!0);w(this,"milestonesOnly",!1);w(this,"locateHits",[]);w(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)});w(this,"onScroll",()=>{this.tick()});w(this,"todayLabelX",-1);w(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())});w(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),i=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-t.left))<12&&Math.abs(d.y-(e.clientY-t.top))<12);if(i){this.scrollToTask(i.id);return}const{hit:n,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),l=this.rows[o];if(n){const d=this.tasksById.get(n.id);if(!d)return;if(a){e.stopPropagation(),this.openAssigneePopup(n.id,n);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(n.id);return}e.preventDefault(),this.drag={id:n.id,mode:n.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(n.id);return}if(!l)return;const r=this.tasksById.get(l.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),p=je(Re(this.epochStart,c));this.options.onTaskChange({...r,start:p,end:je(Re(ke(p),4)),progress:0,status:"not-started"}),this.options.onSelect(l.id);return}this.options.onSelect(l.id)}});w(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)<Vo)return;t.moved=!0;const n=this.dayWidth,o=Math.round((e.clientX-t.startX)/n),a=ke(t.originStart),l=ke(t.originEnd),r=Oe(a,l);let d,c;t.mode==="resize-l"?(d=Re(a,Math.min(o,r)),c=l):t.mode==="resize-r"?(d=a,c=Re(l,Math.max(o,-r))):(d=Re(a,o),c=Re(l,o)),i.milestone&&(d=c),t.start=je(d),t.end=je(c),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=i.milestone?Kt(t.start):`${Kt(t.start)} → ${Kt(t.end)}`;const p=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-p.left+12}px`,this.eTooltip.style.top=`${e.clientY-p.top+16}px`});w(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})});w(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});w(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.interactions=xe(this.eRoot,"gantt-chart",t),this.onInteraction=this.interactions.onInteraction,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;this.interactions.destroy(),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.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){e.length===this.rows.length&&e.every((t,i)=>{const n=this.rows[i];return t.id===n.id&&t.group===n.group&&t.expanded===n.expanded})||(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 Ho[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(Ct()),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=Ct();(!e||e>i)&&(e=i),(!t||t<i)&&(t=i);const n=Yt(Re(ke(e),-7));this.epochStart=n,this.totalDays=Math.max(Oe(n,ke(t))+730,1095)}dateX(e){return Oe(this.epochStart,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 l=Re(this.epochStart,this.totalDays),r=(p,f,u,h)=>{for(const g of p){const v=this.dateX(je(g.start))-a,m=Oe(g.start,g.end)*e;if(v+m<=0||v>=n)continue;const C=Math.max(0,Math.min(v+m,n)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const y=g.start.getDay();(y===0||y===6)&&(i.fillStyle=ve.weekend,i.fillRect(Math.max(0,v),f,C,u))}const S=i.measureText(g.primary).width;if(S+8<C){const y=Math.max(0,v)+C/2-S/2,R=f+u/2+5;i.fillStyle=ve.text,i.font="11px "+ze,i.textAlign="left",i.textBaseline="alphabetic",i.fillText(g.primary,y,R),g.secondary&&(i.fillStyle=ve.textTertiary,i.font="10px "+ze,i.fillText(g.secondary,y,R+12))}}},d=40,c=Re(this.epochStart,Math.floor(a/e));i.fillStyle=ve.text,i.font="14px "+ze,i.textAlign="left",i.textBaseline="middle",i.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(Wi(this.unit,this.epochStart,l),d+1,o-d-1),i.strokeStyle=ve.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,l=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;o.clearRect(0,0,a,l),o.fillStyle="#fff",o.fillRect(0,0,a,l),o.save(),o.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(i,d+l)),this.drawGridlines(e,t,Math.max(i,d+l)),this.drawRowBackgrounds(t,n);const c=this.rows.findIndex(f=>f.id===this.hoverId),p=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(p==null?void 0:p.kind)==="task"&&!p.start){const f=c*n+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,ot(o,r+4,f,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=ve.textTertiary,o.font="14px "+ze,o.textAlign="center",o.fillText("新建排期",r+a/2,f+19)}this.drawDependencies(n),this.drawBars(n),this.drawTodayLine(t,Math.max(i,d+l)),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=ve.weekend;let o=Yt(this.epochStart);for(;Oe(this.epochStart,o)<this.totalDays;){const a=this.dateX(je(o))+5*e;a<t&&n.fillRect(Math.max(0,a),0,e*2,i),o=Re(o,7)}}drawGridlines(e,t,i){const n=this.ctx,o=Re(this.epochStart,this.totalDays);for(const a of Wi(this.unit,this.epochStart,o)){const l=Math.round(this.dateX(je(a.start)))+.5;if(l<0||l>t)continue;const r=this.unit==="day"&&a.start.getDate()===1;n.strokeStyle=r?ve.gridlineMonth:ve.gridline,n.beginPath(),n.moveTo(l,0),n.lineTo(l,i),n.stroke()}}drawRowBackgrounds(e,t){const i=this.ctx;i.strokeStyle=ve.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,l=this.hoverId===n.id;(a||l)&&(i.fillStyle=a?ve.selected:l?ve.hover:ve.groupRow,i.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const i=this.ctx,n=Math.round(this.dateX(Ct())+this.dayWidth/2)+.5;n<0||n>e||(i.strokeStyle=ve.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=Ct().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=ve.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 l of o.dependsOn){const r=this.tasksById.get(l),d=t.get(l);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),p=r.milestone?this.dayWidth:Math.max(Oe(ke(r.start),ke(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),f=c+p,u=d*e+e/2,h=this.dateX(o.start),g=Math.max(Oe(ke(o.start),ke(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=a*e+e/2,m=f+10;if(h-4>m)ji(i,f,u,m,v,h-5,v);else{const C=h+g+10;ji(i,f,u,m,v,C,v)}zo(i,h-5,v)}}}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-De)/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 u;const n=this.ctx,o=((u=this.ghost)==null?void 0:u.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,l=(o==null?void 0:o.end)??e.end,r=this.dateX(a),d=Math.max(28,(Oe(a,l)+1)*this.dayWidth),c=Dt[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?ve.accent:"#dee0e3",n.lineWidth=1,ot(n,r,i,d,De,4),n.fill(),n.stroke(),n.save(),ot(n,r,i,d,De,4),n.clip(),n.beginPath(),n.arc(r+14,i+14,6,0,Math.PI*2),n.fillStyle=c,n.fill(),n.font="12px "+ze,n.textBaseline="middle",n.textAlign="left",n.fillStyle=ve.text;const p=this.options.members.find(h=>h.id===e.owner),f=n.measureText(e.name).width;d>f+58?(n.fillText(e.name,r+26,i+14),p&&Xt(n,r+f+42,i+14,7,Ft(p.id),p.name.slice(0,1))):p&&d>46&&Xt(n,r+38,i+14,7,Ft(p.id),p.name.slice(0,1)),d>100&&(n.fillStyle=ve.textTertiary,n.textAlign="right",n.fillText(String(Oo(ke(a),ke(l))),r+d-8,i+14)),n.restore(),n.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:i,w:d,h:De,mode:"move",avatar:p?{x:r+(d>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(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),o=n[0],a=this.ctx,l=this.dateX(e.start),r=Math.max(92,(Oe(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?ve.accent:"#dee0e3",a.lineWidth=1,ot(a,l,i,r,De,4),a.fill(),a.stroke(),a.fillStyle=o?Dt[o.status]:Dt[e.status],a.beginPath(),a.arc(l+14,i+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":ve.text,a.font="11px "+ze,a.textAlign="left",a.textBaseline="middle";const d=((o==null?void 0:o.name)??e.name)+(n.length>1?` +${n.length-1}`:"");a.fillText(Go(a,d,r-32),l+25,i+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:l,y:i,w:r,h:De,mode:"move"})}drawMilestone(e,t,i){var v;const n=this.ctx,o=this.dayWidth,a=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,l=a?a.start:e.start,r=$o(e),d=Dt[r],c=this.dateX(l)+o/2;n.font="12px "+ze;const p=n.measureText(e.name).width,f=e.owner?24:0,u=19+p+f+14,h=c-u/2;n.fillStyle="#fff",n.strokeStyle=d,n.lineWidth=1.5,ot(n,h,i,u,De,4),n.fill(),n.stroke(),n.fillStyle=d,n.beginPath(),n.arc(h+7+3,i+De/2,3,0,Math.PI*2),n.fill(),n.fillStyle=ve.text,n.textAlign="left",n.textBaseline="middle",n.fillText(e.name,h+14+5,i+De/2+1);let g;if(e.owner){const m=this.options.members.find(C=>C.id===e.owner);m&&(Xt(n,h+u-12,i+De/2,9,Ft(m.id),m.name.slice(0,1)),g={x:h+u-12,y:i+De/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:h,y:i,w:u,h:De,mode:"move",avatar:g})}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 l=this.dateX(a.start),r=this.dateX(a.end)+this.dayWidth;if(r>=t&&l<=t+i)return;const d=r<t?10:i-18,c=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",ot(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+ze,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<t?"‹":"›",d+1,c),this.locateHits.push({id:a.id,x:d+1,y:c}))})}pointAt(e,t){const i=this.eScroll.getBoundingClientRect();return{x:e-i.left+this.eScroll.scrollLeft,y:t-i.top+this.eScroll.scrollTop}}hitAt(e,t){const i=this.pointAt(e,t),n=Math.floor(i.y/this.options.rowHeight),o=this.hitsByRow.get(n)??[];for(const a of o){if(a.avatar){const l=i.x-a.avatar.x,r=i.y-a.avatar.y;if(l*l+r*r<=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 l=a.kind==="task"&&i.x<=a.x+qi,r=a.kind==="task"&&i.x>=a.x+a.w-qi;return{hit:{...a,mode:l?"resize-l":r?"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=At[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 _i){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=At[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=At[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 d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",i.owner===d.id&&c.classList.add("gt-popup-item-active");const p=document.createElement("span");p.className="gt-avatar",p.textContent=d.name.slice(0,1),p.style.backgroundColor=Ft(d.id);const f=document.createElement("span");f.textContent=d.name,c.append(p,f),c.addEventListener("click",u=>{u.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),n.appendChild(c)}if(i.owner){const d=document.createElement("div");d.className="gt-popup-item gt-popup-clear",d.textContent="取消负责人",d.addEventListener("click",c=>{c.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,null)}),n.appendChild(d)}const a=this.eRoot.getBoundingClientRect(),l=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;n.style.left=`${Math.min(a.width-150,Math.max(0,l-40))}px`,n.style.top=`${r+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 ze="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function ot(s,e,t,i,n,o){const a=Math.max(0,i),l=Math.max(0,n);if(a===0||l===0)return;const r=Math.max(0,Math.min(o,a/2,l/2));s.beginPath(),s.moveTo(e+r,t),s.lineTo(e+a-r,t),s.arcTo(e+a,t,e+a,t+r,r),s.lineTo(e+a,t+l-r),s.arcTo(e+a,t+l,e+a-r,t+l,r),s.lineTo(e+r,t+l),s.arcTo(e,t+l,e,t+l-r,r),s.lineTo(e,t+r),s.arcTo(e,t,e+r,t,r),s.closePath()}function Xt(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 ${ze}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function Go(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 ji(s,e,t,i,n,o,a){const r=n>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(i-5,t),s.quadraticCurveTo(i,t,i,t+5*r),s.lineTo(i,n-5*r),s.quadraticCurveTo(i,n,i+5*r,n),s.lineTo(o,a),s.stroke()}function zo(s,e,t){s.fillStyle=ve.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 Ki=["#7e80e7","#47a8f8","#87cf2b","#f3a23a","#e46ba6","#00c2c7","#ff6b6b","#a86dd7"];function Ft(s){let e=0;for(let t=0;t<s.length;t++)e=e*31+s.charCodeAt(t)>>>0;return Ki[e%Ki.length]}const _o={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 Wo(s,e){const t=document.createElement("section");t.className="rowvia-gantt",t.innerHTML=`<div class="gantt-app">
|
|
24
|
+
`,new Blob([d.encode(g)],{type:"application/pdf"})}function lt(s,e){return s.getUint32(e,!0)}function st(s,e){return s.getUint16(e,!0)}async function wo(s){var i;if(typeof DecompressionStream>"u")throw new Error("DecompressionStream is not available in this environment");const t=(i=new Response(s).body)==null?void 0:i.pipeThrough(new DecompressionStream("deflate-raw"));if(!t)throw new Error("Failed to create a decompression stream");const n=await new Response(t).arrayBuffer();return new Uint8Array(n)}function yo(s){const e=new DataView(s),t=new Uint8Array(s);let n=-1;for(let l=t.length-22;l>=0;l--)if(lt(e,l)===101010256){n=l;break}if(n<0)throw new Error("Not a valid XLSX (ZIP) file");const i=st(e,n+10);let o=lt(e,n+16);const a=[];for(let l=0;l<i&<(e,o)===33639248;l++){const r=st(e,o+10),d=lt(e,o+20),c=lt(e,o+24),p=st(e,o+28),h=st(e,o+30),u=st(e,o+32),f=lt(e,o+42),g=new TextDecoder().decode(t.subarray(o+46,o+46+p));a.push({name:g,compressionMethod:r,compressedSize:d,uncompressedSize:c,localHeaderOffset:f}),o+=46+p+h+u}return a}async function en(s,e){const t=new DataView(s),n=new Uint8Array(s),i=st(t,e.localHeaderOffset+26),o=st(t,e.localHeaderOffset+28),a=e.localHeaderOffset+30+i+o,l=n.subarray(a,a+e.compressedSize);return e.compressionMethod===0?l:wo(l)}function tn(s){return new DOMParser().parseFromString(s,"application/xml")}function bo(s){const e=s.replace(/\d+/g,"");let t=0;for(const n of e)t=t*26+(n.charCodeAt(0)-64);return t-1}async function Co(s){const e=yo(s),t=e.find(d=>d.name==="xl/workbook.xml"),n=[];if(t){const c=tn(new TextDecoder().decode(await en(s,t))).getElementsByTagName("sheet");for(let p=0;p<c.length;p++)n.push(c[p].getAttribute("name")||`Sheet${p+1}`),c[p].getAttribute("r:id")||c[p].getAttribute("id")}const i=[],o=e.find(d=>d.name==="xl/sharedStrings.xml");if(o){const c=tn(new TextDecoder().decode(await en(s,o))).getElementsByTagName("si");for(let p=0;p<c.length;p++){const h=c[p].getElementsByTagName("t");let u="";for(let f=0;f<h.length;f++)u+=h[f].textContent||"";i.push(u)}}const l=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<l.length;d++){const p=tn(new TextDecoder().decode(await en(s,l[d]))).getElementsByTagName("row"),h=[];for(let u=0;u<p.length;u++){const f=p[u],g=[],v=f.getElementsByTagName("c");for(let m=0;m<v.length;m++){const y=v[m],k=y.getAttribute("r")||"",C=y.getAttribute("t")||"";let b="";if(C==="s"){const A=y.getElementsByTagName("v")[0],E=Number((A==null?void 0:A.textContent)||"0");b=i[E]??""}else if(C==="inlineStr"){const A=y.getElementsByTagName("t");for(let E=0;E<A.length;E++)b+=A[E].textContent||""}else{const A=y.getElementsByTagName("v")[0];b=(A==null?void 0:A.textContent)??""}const I=k?bo(k):m;g[I]=b}h.push(g.map(m=>m??""))}r.push({name:n[d]||`Sheet${d+1}`,rows:h})}return r}const So=(()=>{const s=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let n=0;n<8;n++)t=t&1?3988292384^t>>>1:t>>>1;s[e]=t>>>0}return s})();function Eo(s){let e=4294967295;for(let t=0;t<s.length;t++)e=So[(e^s[t])&255]^e>>>8;return(e^4294967295)>>>0}function Xn(s){return s.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function xo(s){let e="",t=s+1;for(;t>0;){const n=(t-1)%26;e=String.fromCharCode(65+n)+e,t=Math.floor((t-1)/26)}return e}function ko(s){const e=new TextEncoder,t=[],n=[];let i=0;for(const p of s){const h=e.encode(p.name),u=Eo(p.data),f=new Uint8Array(30+h.length),g=new DataView(f.buffer);g.setUint32(0,67324752,!0),g.setUint16(4,20,!0),g.setUint16(6,2048,!0),g.setUint16(8,0,!0),g.setUint16(10,0,!0),g.setUint16(12,8585,!0),g.setUint32(14,u,!0),g.setUint32(18,p.data.length,!0),g.setUint32(22,p.data.length,!0),g.setUint16(26,h.length,!0),g.setUint16(28,0,!0),f.set(h,30),t.push(f,p.data);const v=new Uint8Array(46+h.length),m=new DataView(v.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,u,!0),m.setUint32(20,p.data.length,!0),m.setUint32(24,p.data.length,!0),m.setUint16(28,h.length,!0),m.setUint32(42,i,!0),v.set(h,46),n.push(v),i+=f.length+p.data.length}const o=n.reduce((p,h)=>p+h.length,0),a=new Uint8Array(22),l=new DataView(a.buffer);l.setUint32(0,101010256,!0),l.setUint16(8,s.length,!0),l.setUint16(10,s.length,!0),l.setUint32(12,o,!0),l.setUint32(16,i,!0);const r=t.reduce((p,h)=>p+h.length,0)+o+a.length,d=new Uint8Array(r);let c=0;for(const p of t)d.set(p,c),c+=p.length;for(const p of n)d.set(p,c),c+=p.length;return d.set(a,c),d}function Mo(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,n)=>{const i=n+1,a=t.some(l=>l.bold)?' s="1" ht="20" customHeight="1"':"";e+=`<row r="${i}"${a}>`,t.forEach((l,r)=>{const d=`${xo(r)}${i}`,c=l.bold?' s="1"':"";if(l.value===null||l.value===void 0||l.value===""){e+=`<c r="${d}"${c}/>`;return}typeof l.value=="number"&&isFinite(l.value)?e+=`<c r="${d}"${c}><v>${l.value}</v></c>`:typeof l.value=="boolean"?e+=`<c r="${d}"${c} t="b"><v>${l.value?1:0}</v></c>`:e+=`<c r="${d}"${c} t="inlineStr"><is><t xml:space="preserve">${Xn(String(l.value))}</t></is></c>`}),e+="</row>"}),e+="</sheetData></worksheet>",e}const Ro='<?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 Lo(s){const e=new TextEncoder,t=(p,h)=>p.replace(/[\\/?*[\]:]/g," ").slice(0,31)||`Sheet${h+1}`;let n="",i="",o="";s.forEach((p,h)=>{const u=t(p.name,h),f=h+1;n+=`<sheet name="${Xn(u)}" sheetId="${f}" r:id="rId${f}"/>`,i+=`<Relationship Id="rId${f}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet${f}.xml"/>`,o+=`<Override PartName="/xl/worksheets/sheet${f}.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>",l='<?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>${n}</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"/>'+i+"</Relationships>",c=[{name:"[Content_Types].xml",data:e.encode(a)},{name:"_rels/.rels",data:e.encode(l)},{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(Ro)}];return s.forEach((p,h)=>{c.push({name:`xl/worksheets/sheet${h+1}.xml`,data:e.encode(Mo(p.rows))})}),new Blob([ko(c)],{type:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"})}class To{constructor(e){w(this,"lastCopied",null);this.grid=e}getExportColumns(e){const t=this.grid.getAllColumns();if(e.columnKeys&&e.columnKeys.length)return e.columnKeys.map(i=>typeof i=="string"?this.grid.getColumn(i):i).filter(i=>!!i);if(e.allColumns)return t.filter(i=>i.field||i.valueGetter);const n=this.grid.getColumns();return[...n.center,...n.left,...n.right]}getExportRows(e){const t=this.grid.getRowModel(),n=[],i=e.onlySelected===!0,o=e.skipGroups!==!1,a=e.skipFooters!==!1;return t.forEachNode(l=>{l.rowPinned==="top"&&e.skipPinnedTop!==!1||l.rowPinned==="bottom"&&e.skipPinnedBottom!==!1||o&&l.group&&!l.footer||a&&l.footer||i&&!l.selected||n.push(l)}),i&&n.length===0?this.getExportRows({...e,onlySelected:!1}):n}getCellValueForExport(e,t,n){let i=Se(e,t,this.grid.getApi()),o=Dt(e,t,this.grid.getApi());if(n.processCellCallback){const l=n.processCellCallback({value:i,formattedValue:o,node:t,column:e,api:this.grid.getApi()});if(l!=null)return String(l)}const a=this.groupValue(e,t);return a!==void 0&&(i=a,o=i===null?"":String(i)),i instanceof Date?i.toISOString().slice(0,10):o??(i==null?"":String(i))}groupValue(e,t){var n;return t.group||t.footer?(n=t.groupData)==null?void 0:n[e.colId]:void 0}getDataAsCsv(e={}){var a;const t=this.getExportColumns(e),n=this.getExportRows(e),i=e.columnSeparator??",",o=[];if(!e.skipHeader){const l=t.map(r=>{const d=r.headerName||r.field||r.colId;return e.processHeaderCallback?e.processHeaderCallback({column:r,api:this.grid.getApi()}):d});this.grid.getOptions().copyGroupHeadersToClipboard&&o.push(this.csvRow(this.grid.getColumnModel().getRowGroupColumns().map(r=>r.headerName),i,e.suppressQuotes)),o.push(this.csvRow(l,i,e.suppressQuotes))}for(const l of n){if((a=e.shouldRowBeSkipped)!=null&&a.call(e,{node:l,api:this.grid.getApi()}))continue;const r=t.map(d=>this.getCellValueForExport(d,l,e));o.push(this.csvRow(r,i,e.suppressQuotes))}return o.join(`\r
|
|
25
|
+
`)}csvRow(e,t,n){return e.map(i=>{const o=i==null?"":String(i);return!n&&(o.includes(t)||o.includes('"')||o.includes(`
|
|
26
|
+
`))?`"${o.replace(/"/g,'""')}"`:o}).join(t)}getDataAsExcel(e={}){const t=this.getExportColumns(e),n=this.getExportRows(e),i=[];e.skipHeader||i.push(t.map(o=>({value:o.headerName||o.field||o.colId,bold:!0})));for(const o of n)i.push(t.map(a=>{let l=Se(a,o,this.grid.getApi());const r=this.groupValue(a,o);return r!==void 0&&(l=r),l instanceof Date&&(l=l.toISOString().slice(0,10)),{value:l}}));return Lo([{name:e.sheetName||"Sheet1",rows:i}])}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 f;const t=this.getExportColumns(e),n=this.getExportRows(e),i=t.map(g=>Math.max(60,Math.min(220,this.grid.getColumnModel().measureTextWidth(g.headerName)+24))),o=[],a=[];e.skipHeader||(o.push(t.map(g=>({text:e.processHeaderCallback?e.processHeaderCallback({column:g,api:this.grid.getApi()}):g.headerName||g.field||g.colId,bold:!0,align:g.type==="numberColumn"||g.cellDataType===!0?"right":"left"}))),a.push([.94,.95,.97]));for(const g of n)(f=e.shouldRowBeSkipped)!=null&&f.call(e,{node:g,api:this.grid.getApi()})||(o.push(t.map(v=>{let m=this.getCellValueForExport(v,g,e);if(e.processCellCallback){const y=e.processCellCallback({value:Se(v,g,this.grid.getApi()),formattedValue:m,node:g,column:v,api:this.grid.getApi()});y!=null&&(m=String(y))}return{text:m,align:v.type==="numberColumn"||v.cellDataType===!0?"right":"left"}})),a.push(void 0));const l=18,r=e.pageSize||"a4-landscape",[d,c]=r.includes("portrait")?[595,842]:[842,595],p=c-64-(e.title?24:0),h=Math.max(5,Math.floor(p/l)),u=[];o.length===0&&u.push({columnWidths:i,rows:[],rowFill:[]});for(let g=0;g<o.length;g+=h)u.push({columnWidths:i,rows:o.slice(g,g+h),rowFill:a.slice(g,g+h)});return vo(u,{pageSize:r,title:e.title})}exportToPdf(e={}){const t=this.getDataAsPdf(e);this.download(t,this.fileName(e,"pdf"))}async importExcel(e,t={}){const n=e instanceof ArrayBuffer?e:await e.arrayBuffer(),o=(await Co(n))[t.sheetIndex??0];if(!o||o.rows.length===0)return[];const a=o.rows[0],l=o.rows.slice(1).map(r=>{const d={};return a.forEach((c,p)=>{const h=c||`col${p+1}`,u=r[p]??"",f=String(u).trim();d[h]=f!==""&&!isNaN(Number(f))&&!/^0\d/.test(f)?Number(f):u}),d});return t.onSuccess?t.onSuccess(l):this.grid.getApi().setRowData(l),this.grid.getEventService().dispatchEvent("excelImportFinished",{rows:l}),l}fileName(e,t){const n=e.fileName||this.grid.getOptions().fileName||"export";return n.endsWith(`.${t}`)?n:`${n}.${t}`}download(e,t){const n=URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.download=t,document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(n),1e3)}copyToClipboard(e={}){const t={onlySelected:!0,skipHeader:!e.includeHeaders,suppressQuotes:!0,columnSeparator:" ",...e},n=this.getDataAsCsv(t);this.lastCopied=n,this.writeToClipboard(n),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(n=>n.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(),n=this.grid.getRangeSelectionService().getRanges();let i,o;if(n.length>0){const p=n[0];i=p.rowStartIndex;const h=this.grid.getColumns().center,u=h.findIndex(f=>f.colId===p.colStartId);o=h[u]??h[0]}else if(t)i=t.rowIndex,o=t.column;else return;const a=e.replace(/\r/g,"").split(`
|
|
27
|
+
`);a.length&&a[a.length-1]===""&&a.pop();const l=[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right],r=l.findIndex(p=>p.colId===o.colId),d=[],c=[];a.forEach((p,h)=>{const u=p.split(" "),f=i+h,g=this.grid.getDisplayedRowAtIndex(f);if(!g){const v={};u.forEach((m,y)=>{const k=l[r+y];k!=null&&k.field&&(v[k.field]=m)}),c.push(v);return}u.forEach((v,m)=>{const y=l[r+m];y&&this.grid.setCellValue(y,g,v,"paste")}),d.push(g)}),c.length&&this.grid.getApi().applyTransaction({add:c}),d.length&&this.grid.refreshCells({rowNodes:d,flash:!0})}writeToClipboard(e){const t=()=>{this.grid.getEventService().dispatchEvent("cutEnd",{})};navigator.clipboard&&navigator.clipboard.writeText?navigator.clipboard.writeText(e).then(t,()=>this.fallbackCopy(e,t)):this.fallbackCopy(e,t)}fallbackCopy(e,t){const n=document.createElement("textarea");n.value=e,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.select();try{document.execCommand("copy")}catch{}document.body.removeChild(n),t()}}const xt=["contains","equals","notEqual","startsWith","endsWith","blank","notBlank"],kt=["equals","notEqual","greaterThan","greaterThanOrEqual","lessThan","lessThanOrEqual","inRange","blank","notBlank"];class No{constructor(e,t){this.grid=e,this.popupService=t}openFilter(e,t){var g,v;if(typeof e.colDef.filterComponent=="function"){this.openCustomFilter(e,t);return}if(e.filter==="multi"){this.openMultiFilter(e,t);return}const n=e.filter===!0?"text":e.filter,i=this.grid.getFilterService().getFilterInstance(e.colId),o=n==="set"?260:240,{ePopup:a}=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);const r=i?{...i}:this.getDefaultModel(n);let d=i?{...i}:null;const c=()=>{d&&this.isMeaningful(d)?this.grid.getFilterService().setColumnFilterModel(e,d):this.grid.getFilterService().setColumnFilterModel(e,null),close()},p=()=>{this.grid.getFilterService().setColumnFilterModel(e,null),close()};if(n==="set")a.appendChild(this.buildSetFilter(e,r,m=>{d=m}));else if(n==="boolean"){const m=this.buildConditionSelect(["true","false"],String(r.filter??""),y=>{d={filterType:"boolean",filter:y==="true"}});a.appendChild(m)}else{const m=n==="number"?kt:xt,y=this.buildConditionSelect(m,r.type||m[0],k=>{r.type=k,d={...r}});if(a.appendChild(y),r.type!=="blank"&&r.type!=="notBlank")if(n==="number"&&r.type==="inRange"){const k=document.createElement("div");k.className="ag-filter-inputs";const C=document.createElement("input");C.type="number",C.className="ag-filter-input",C.value=r.filter??"",C.placeholder=this.grid.t("from"),C.addEventListener("input",()=>{d={...r,filter:C.value,filterTo:b.value}});const b=document.createElement("input");b.type="number",b.className="ag-filter-input",b.value=r.filterTo??"",b.placeholder=this.grid.t("to"),b.addEventListener("input",()=>{d={...r,filter:C.value,filterTo:b.value}}),k.appendChild(C),k.appendChild(b),a.appendChild(k)}else if(n==="date"){const k=document.createElement("div");k.className="ag-filter-inputs";const C=document.createElement("input");C.type="date",C.className="ag-filter-input",C.value=r.dateFrom??"",C.addEventListener("input",()=>{d={...r,dateFrom:C.value,dateTo:b.value}});const b=document.createElement("input");b.type="date",b.className="ag-filter-input",b.value=r.dateTo??"",b.addEventListener("input",()=>{d={...r,dateFrom:C.value,dateTo:b.value}}),k.appendChild(C),k.appendChild(b),a.appendChild(k)}else{const k=document.createElement("input");k.type=n==="number"?"number":"text",k.className="ag-filter-input",k.value=r.filter??"",k.placeholder=this.grid.t("filterOoo"),k.addEventListener("input",()=>{d={...r,filter:k.value}}),k.addEventListener("keydown",C=>{C.key==="Enter"&&c()}),a.appendChild(k),setTimeout(()=>k.focus(),0)}else d={...r}}if(n==="text"||n==="number"){const m=document.createElement("div");m.className="ag-filter-second-condition";const y=document.createElement("select");y.className="ag-filter-condition",y.innerHTML=`<option value="AND">${this.grid.t("and")}</option><option value="OR">${this.grid.t("or")}</option>`,y.value=r.operator||"AND",m.appendChild(y);const k=this.buildConditionSelect(n==="number"?kt:xt,((g=r.condition2)==null?void 0:g.type)||(n==="number"?kt:xt)[0],b=>{d||(d={...r}),d.condition2={...d.condition2,type:b}});m.appendChild(k);const C=document.createElement("input");C.type=n==="number"?"number":"text",C.className="ag-filter-input",C.placeholder=this.grid.t("secondValue"),C.value=((v=r.condition2)==null?void 0:v.filter)??"",C.addEventListener("input",()=>{d||(d={...r}),d.condition2={...d.condition2,filter:C.value}}),m.appendChild(C),a.appendChild(m),y.addEventListener("change",()=>{d||(d={...r}),d.operator=y.value})}const h=document.createElement("div");h.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",c);const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",p),h.appendChild(f),h.appendChild(u),a.appendChild(h),this.popupService.positionAt(a,t),this.grid.getEventService().dispatchEvent("filterOpened",{column:e,api:this.grid.getApi()})}buildSetFilter(e,t,n){const i=document.createElement("div");i.className="ag-set-filter";const o=document.createElement("input");o.type="text",o.className="ag-filter-input",o.placeholder=this.grid.t("search"),i.appendChild(o);const a=new Set;this.grid.getRowModel().forEachNode(g=>{!g.group&&!g.footer&&a.add(Se(e,g,this.grid.getApi()))});const r=[...a].sort((g,v)=>g===v?0:g<v?-1:1),d=document.createElement("div");d.className="ag-set-filter-list";const c=new Set((t.values||[]).map(g=>String(g))),p=()=>{d.innerHTML="";const g=o.value.toLowerCase();let v=0;for(const m of r){const y=m==null?"(Blanks)":String(m);if(g&&!y.toLowerCase().includes(g))continue;v++;const k=document.createElement("label");k.className="ag-set-filter-item";const C=document.createElement("input");C.type="checkbox",C.checked=c.has(String(m)),C.addEventListener("change",()=>{C.checked?c.add(String(m)):c.delete(String(m)),n({filterType:"set",values:[...c]})});const b=document.createElement("span");b.textContent=y,k.appendChild(C),k.appendChild(b),d.appendChild(k)}if(v===0){const m=document.createElement("div");m.className="ag-set-filter-empty",m.textContent=this.grid.t("noMatches"),d.appendChild(m)}};o.addEventListener("input",p),p();const h=document.createElement("div");h.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 g of r)c.add(String(g));p(),n({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(),p(),n({filterType:"set",values:[]})}),h.appendChild(u),h.appendChild(f),i.appendChild(d),i.appendChild(h),n({filterType:"set",values:[...c]}),i}buildConditionSelect(e,t,n){const i=document.createElement("select");i.className="ag-filter-condition";for(const o of e){const a=document.createElement("option");a.value=o;const l=$s[o];a.textContent=l?this.grid.t(l):o,o===t&&(a.selected=!0),i.appendChild(a)}return i.addEventListener("change",()=>n(i.value)),i}openMultiFilter(e,t){var k;const n=this.grid.getFilterService().getFilterInstance(e.colId),i=n&&n.filterType==="multi"?n:null,o=(k=i==null?void 0:i.filterModels)!=null&&k.length?i.filterModels.map(C=>({...C})):[this.getDefaultModel(e.filter===!0?"text":String(e.filter))];let a=(i==null?void 0:i.operator)||"AND";const{ePopup:l,close:r}=this.popupService.createPopup(300,"ag-filter-popup ag-multi-filter-popup");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`Filters for ${e.headerName||e.field||""}`,l.appendChild(d);const c=document.createElement("div");c.className="ag-multi-filter-operator";const p=document.createElement("span");p.textContent=this.grid.t("join");const h=document.createElement("select");h.className="ag-filter-condition",h.innerHTML='<option value="AND">All (AND)</option><option value="OR">Any (OR)</option>',h.value=a,h.addEventListener("change",()=>{a=h.value}),c.appendChild(p),c.appendChild(h),l.appendChild(c);const u=document.createElement("div");u.className="ag-multi-filter-list",l.appendChild(u);const f=()=>{u.innerHTML="",o.forEach((C,b)=>{const I=document.createElement("div");I.className="ag-multi-filter-row";const A=document.createElement("select");A.className="ag-filter-condition";const E=["text","number","date","set","boolean"];for(const N of E){const P=document.createElement("option");P.value=N,P.textContent=N.charAt(0).toUpperCase()+N.slice(1),N===C.filterType&&(P.selected=!0),A.appendChild(P)}A.addEventListener("change",()=>{o[b]={...this.getDefaultModel(A.value)},f()}),I.appendChild(A);const G=C.filterType==="number"?kt:xt,x=this.buildConditionSelect(G,C.type||G[0],N=>{o[b].type=N});if(I.appendChild(x),C.filterType!=="blank"&&C.type!=="blank"&&C.type!=="notBlank"){const N=document.createElement("input");N.type=C.filterType==="number"?"number":"text",N.className="ag-filter-input",N.value=C.filter??"",N.placeholder=this.grid.t("value"),N.addEventListener("input",()=>{o[b].filter=N.value}),I.appendChild(N)}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(b,1),f()}),I.appendChild(M),u.appendChild(I)})};f();const g=document.createElement("button");g.className="ag-button ag-button-small",g.textContent="+ "+this.grid.t("addFilter"),g.addEventListener("click",()=>{o.push(this.getDefaultModel("text")),f()}),l.appendChild(g);const v=document.createElement("div");v.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(b=>b.filter!==void 0&&b.filter!==""||b.type==="blank"||b.type==="notBlank").length?this.grid.getFilterService().setColumnFilterModel(e,{filterType:"multi",operator:a,filterModels:o}):this.grid.getFilterService().setColumnFilterModel(e,null),r()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{this.grid.getFilterService().setColumnFilterModel(e,null),r()}),v.appendChild(y),v.appendChild(m),l.appendChild(v),this.popupService.positionAt(l,t)}openAdvancedFilter(e){var k,C;const t=this.grid.getFilterService(),n=t.getAdvancedFilterModel(),i=(k=n==null?void 0:n.conditions)!=null&&k.length?n.conditions.map(b=>({...b})):[{colId:((C=this.grid.getColumns().center[0])==null?void 0:C.colId)??"",type:"contains",filter:""}];let o=(n==null?void 0:n.operator)||"AND";const{ePopup:a,close:l}=this.popupService.createPopup(420,"ag-filter-popup ag-advanced-filter-popup");a.innerHTML="";const r=document.createElement("div");r.className="ag-popup-title",r.textContent=this.grid.t("advancedFilter"),a.appendChild(r);const d=document.createElement("div");d.className="ag-advanced-filter-list",a.appendChild(d);const c=()=>[...this.grid.getColumns().left,...this.grid.getColumns().center,...this.grid.getColumns().right].filter(b=>b.filter),p=()=>{d.innerHTML="",i.forEach((b,I)=>{const A=document.createElement("div");A.className="ag-advanced-filter-row";const E=document.createElement("select");E.className="ag-filter-condition";for(const L of c()){const H=document.createElement("option");H.value=L.colId,H.textContent=L.headerName||L.field||L.colId,L.colId===b.colId&&(H.selected=!0),E.appendChild(H)}E.addEventListener("change",()=>{i[I].colId=E.value}),A.appendChild(E);const G=this.grid.getColumn(b.colId),x=G&&G.filter!==!1?String(G.filter):"text",M=x==="number"?kt:xt,N=this.buildConditionSelect(M,b.type||"contains",L=>{i[I].type=L});A.appendChild(N);const P=document.createElement("input");P.type=x==="number"?"number":"text",P.className="ag-filter-input",P.value=b.filter??"",P.placeholder=this.grid.t("value"),P.addEventListener("input",()=>{i[I].filter=P.value}),A.appendChild(P);const _=document.createElement("button");_.className="ag-button ag-button-small",_.textContent="×",_.addEventListener("click",()=>{i.splice(I,1),p()}),A.appendChild(_),d.appendChild(A)})};p();const h=document.createElement("button");h.className="ag-button ag-button-small",h.textContent="+ "+this.grid.t("addCondition"),h.addEventListener("click",()=>{var b;i.push({colId:((b=c()[0])==null?void 0:b.colId)??"",type:"contains",filter:""}),p()}),a.appendChild(h);const u=document.createElement("div");u.className="ag-multi-filter-operator";const f=document.createElement("span");f.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}),u.appendChild(f),u.appendChild(g),a.appendChild(u);const v=document.createElement("div");v.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 b=i.filter(I=>I.filter!==void 0&&I.filter!=="");b.length?t.setAdvancedFilterModel({filterType:"advanced",operator:o,conditions:b}):t.setAdvancedFilterModel(null),l()});const y=document.createElement("button");y.className="ag-button",y.textContent=this.grid.t("clear"),y.addEventListener("click",()=>{t.setAdvancedFilterModel(null),l()}),v.appendChild(y),v.appendChild(m),a.appendChild(v),this.popupService.positionAt(a,e)}openCustomFilter(e,t){const n=e.colDef.filterComponent;if(typeof n!="function")return;const i=this.grid.getFilterService(),o=n({column:e,colDef:e.colDef,api:this.grid.getApi(),model:i.getFilterInstance(e.colId)??null,onModelChange:r=>i.setColumnFilterModel(e,r),onGuiAttached:()=>{}}),{ePopup:a}=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}}class Io{constructor(e){w(this,"filterModel",{});w(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 n=this.grid.getRowModel(),i=typeof n.doesNodePassFilterModel=="function"?n.doesNodePassFilterModel.bind(n):null,o=t.conditions.map(a=>{const l=this.grid.getColumn(a.colId);return!l||!i?!0:i(e,l,{...a,filterType:l.filter===!0?"text":l.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 n=typeof e=="string"?e:e.colId;t==null?delete this.filterModel[n]:this.filterModel[n]=t,this.onFilterChanged("api")}isFilterActive(e){const t=this.filterModel[e.colId];return t?t.filterType==="multi"?(t.filterModels||[]).some(i=>this.isModelMeaningful(i)):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 n,i;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("filter");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("filterChanged",{api:t,source:e}),(i=(n=this.grid.getOptions()).onFilterChanged)==null||i.call(n,{api:t,source:e})}}class Ao{constructor(e,t){w(this,"matches",[]);w(this,"activeMatch",0);w(this,"searchText","");w(this,"matchCase",!1);w(this,"ePopup",null);w(this,"eCount",null);w(this,"eInput",null);w(this,"closePopup",null);this.grid=e,this.popupService=t}isOpen(){return this.ePopup!==null}open(){var r,d;if(this.ePopup){(r=this.eInput)==null||r.focus(),(d=this.eInput)==null||d.select();return}const{ePopup:e,close:t}=this.popupService.createPopup(420,"ag-find-bar");this.ePopup=e,this.closePopup=t,e.innerHTML="";const n=document.createElement("input");n.type="text",n.className="ag-find-input",n.placeholder=this.grid.translate("find","Find in grid..."),n.value=this.searchText,this.eInput=n,e.appendChild(n);const i=document.createElement("label");i.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)}),i.appendChild(o),i.appendChild(document.createTextNode(this.grid.translate("matchCase","Match case"))),e.appendChild(i);const a=document.createElement("span");a.className="ag-find-count",this.eCount=a,e.appendChild(a);const l=(c,p,h)=>{const u=document.createElement("button");return u.className="ag-button ag-button-small",u.textContent=c,u.title=p,u.addEventListener("click",h),e.appendChild(u),u};l("‹",this.grid.translate("prevMatch","上一个匹配"),()=>this.findPrevious()),l("›",this.grid.translate("nextMatch","下一个匹配"),()=>this.findNext()),l("×",this.grid.translate("close","关闭"),()=>this.close()),n.addEventListener("input",()=>this.find(n.value)),n.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(()=>n.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((n,i)=>{if(!(n.group||n.footer))for(const o of t){const a=Dt(o,n,this.grid.getApi())??"",l=this.matchCase?a:a.toLowerCase(),r=this.matchCase?e:e.toLowerCase();l.includes(r)&&this.matches.push({rowIndex:i,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 l=t.getPageSize(),r=Math.floor(e.rowIndex/l);r!==t.getCurrentPage()&&t.goToPage(r)}this.grid.getApi().ensureIndexVisible(e.rowIndex,"middle"),this.applyHighlight();const n=this.grid.getDisplayedRowAtIndex(e.rowIndex),i=this.grid.getColumn(e.colId);n&&i&&this.grid.getEditService().setFocusedCell(e.rowIndex,i)}applyHighlight(){const e=this.grid.getRowRenderer().getRowComps();for(const[t,n]of e){let i=-1;this.grid.getRowModel().forEachNode((o,a)=>{o.id===t&&(i=a)});for(const o of n.getCellElements()){const a=o.dataset.colid,l=this.matches.findIndex(r=>r.rowIndex===i&&r.colId===a);o.classList.toggle("ag-find-match",l>=0),o.classList.toggle("ag-find-active-match",l>=0&&l===this.activeMatch)}}}}class $o{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:n,close:i}=this.popupService.createPopup(460,"ag-formula-editor");n.innerHTML="";const o=document.createElement("div");o.className="ag-popup-title",o.textContent=`${this.grid.t("formula")} - ${e.headerName||e.field}`,n.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"),n.appendChild(a);const l=document.createElement("div");l.className="ag-formula-preview";const r=()=>{const g=this.grid.getDisplayedRowAtIndex(0);if(!g){l.textContent="";return}try{const v=St(a.value,{data:g.data});l.textContent=`${this.grid.t("formulaPreview")}: ${v==null?"":String(v)}`,l.classList.remove("ag-formula-error")}catch(v){l.textContent=`${this.grid.t("formulaError")}: ${(v==null?void 0:v.code)||(v==null?void 0:v.message)||this.grid.t("invalidFormula")}`,l.classList.add("ag-formula-error")}};a.addEventListener("input",r),n.appendChild(l);const d=document.createElement("div");d.className="ag-formula-functions";const c=document.createElement("div");c.className="ag-formula-functions-title",c.textContent=this.grid.t("functions"),d.appendChild(c);const p=document.createElement("div");p.className="ag-formula-functions-list";for(const g of Ft){const v=document.createElement("button");v.className="ag-button ag-button-small",v.textContent=g,v.addEventListener("click",()=>{a.value+=`${a.value.endsWith("(")||a.value==="="?"":" "}${g}()`,a.focus(),r()}),p.appendChild(v)}d.appendChild(p),n.appendChild(d);const h=document.createElement("div");h.className="ag-popup-buttons";const u=document.createElement("button");u.className="ag-button ag-button-primary",u.textContent=this.grid.t("apply"),u.addEventListener("click",()=>{const g=a.value.trim(),v=this.grid.getColumnModel(),m=v.getColumn(e.colId);m&&(m.field=g==="="||g===""?e.field:g,m.colDef={...m.colDef,field:m.field},g!=="="&&g!==""&&(m.editable=!1)),v.refreshAll(),this.grid.refreshCells({force:!0}),i()});const f=document.createElement("button");f.className="ag-button",f.textContent=this.grid.t("clear"),f.addEventListener("click",()=>{a.value="=",r()}),h.appendChild(f),h.appendChild(u),n.appendChild(h),this.popupService.positionAt(n,t),r()}}class Fo{constructor(e,t){w(this,"runtimeNotes",new Map);this.grid=e,this.popupService=t}keyOf(e,t){return`${e}::${t}`}getNote(e,t,n,i){const o=this.runtimeNotes.get(this.keyOf(e,t));if(o!==void 0)return o;if(typeof n=="function")return n(i);if(typeof n=="string")return n}setNote(e,t,n){const i=this.keyOf(e,t);n==null||n===""?this.runtimeNotes.delete(i):this.runtimeNotes.set(i,n),this.grid.refreshCells({force:!0})}openNoteEditor(e,t,n){const i=this.grid.getColumn(t),o=this.grid.getRowNode(e),a=this.getNote(e,t,i==null?void 0:i.colDef.note,{data:o==null?void 0:o.data,node:o,column:i,api:this.grid.getApi()})??"",{ePopup:l,close:r}=this.popupService.createPopup(280,"ag-note-editor");l.innerHTML="";const d=document.createElement("div");d.className="ag-popup-title",d.textContent=`${this.grid.t("note")} — ${(i==null?void 0:i.headerName)||t}`,l.appendChild(d);const c=document.createElement("textarea");c.className="ag-formula-input",c.rows=4,c.value=a,c.placeholder=this.grid.t("writeNote"),l.appendChild(c);const p=document.createElement("div");p.className="ag-popup-buttons";const h=document.createElement("button");h.className="ag-button ag-button-primary",h.textContent=this.grid.t("save"),h.addEventListener("click",()=>{this.setNote(e,t,c.value.trim()||void 0),r()});const u=document.createElement("button");u.className="ag-button",u.textContent=this.grid.t("delete"),u.addEventListener("click",()=>{this.setNote(e,t,void 0),r()}),p.appendChild(u),p.appendChild(h),l.appendChild(p),this.popupService.positionAt(l,n),setTimeout(()=>c.focus(),0)}}class Do{constructor(e){w(this,"eOverlayWrapper");w(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 n=document.createElement("div");n.className=`ag-overlay-${e==="loading"?"loading":"no-rows"}-wrapper`;const i=document.createElement("div");if(i.className="ag-overlay-text",i.textContent=t,e==="loading"){const o=document.createElement("div");o.className="ag-overlay-loading-spinner",n.appendChild(o)}n.appendChild(i),this.eOverlayWrapper.appendChild(n),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}e.getRowCount()===0?this.show("noRows",this.grid.translate("noRowsToShow","No Rows To Show")):this.hideOverlay()}getCurrent(){return this.current}}class Zn{constructor(e,t){w(this,"enabled");w(this,"pageSize");w(this,"currentPage",0);w(this,"pageSizeSelector");w(this,"ePanel");w(this,"ePageInfo");w(this,"ePageInput");w(this,"ePageSizeContainer");w(this,"eFromToContainer");this.grid=e,this.eventService=t;const n=e.getOptions();this.enabled=n.pagination===!0,this.pageSize=n.paginationPageSize??100,this.pageSizeSelector=n.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 i=document.createElement("div");i.className="ag-pagination-buttons",this.ePanel.appendChild(i),this.ePageSizeContainer=document.createElement("div"),this.ePageSizeContainer.className="ag-pagination-page-size",i.appendChild(this.ePageSizeContainer),this.eFromToContainer=document.createElement("span"),this.eFromToContainer.className="ag-pagination-from-to",i.appendChild(this.eFromToContainer);const o=document.createElement("span");if(o.className="ag-pagination-page-label",o.textContent=`${this.grid.translate("page","Page")}`,i.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)}),i.appendChild(this.ePageInput),this.ePageInfo=document.createElement("span"),this.ePageInfo.className="ag-pagination-info",i.appendChild(this.ePageInfo),this.pageSizeSelector){const a=this.ePageSizeContainer,l=document.createElement("span");l.textContent=`${this.grid.translate("pageSize","Page Size:")}`,a.appendChild(l);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 p=document.createElement("option");p.value=String(c),p.textContent=String(c),c===this.pageSize&&(p.selected=!0),r.appendChild(p)}r.addEventListener("change",()=>this.setPageSize(parseInt(r.value,10))),a.appendChild(r)}e.getRootElement().appendChild(this.ePanel),this.update()}isEnabled(){return this.enabled}setEnabled(e){this.enabled=e,this.ePanel.style.display=e?"":"none",e||(this.currentPage=0),this.grid.refreshModel("everything"),this.update()}getPageSize(){return this.pageSize}setPageSize(e){const t=this.currentPage*this.pageSize;this.pageSize=Math.max(1,e),this.currentPage=Math.floor(t/this.pageSize),this.grid.refreshModel("everything"),this.update()}getCurrentPage(){return this.currentPage}getTotalPages(){if(!this.enabled)return 1;const e=this.grid.getRowModel(),t=e.getTotalRowCount?e.getTotalRowCount():e.getRowCount();return Math.max(1,Math.ceil(t/this.pageSize))}goToPage(e){const t=this.getTotalPages(),n=Math.max(0,Math.min(t-1,e));if(n===this.currentPage){this.update();return}this.currentPage=n,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 l,r;if(!this.enabled)return;const e=this.getTotalPages();this.currentPage>e-1&&(this.currentPage=e-1,this.grid.refreshModel("everything"));const t=this.grid.getRowModel(),n=t.getTotalRowCount?t.getTotalRowCount():t.getRowCount(),i=n===0?0:this.currentPage*this.pageSize+1,o=Math.min(n,(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=n===0?`0 ${a} 0 ${this.grid.translate("of","/")} 0`:`${i.toLocaleString()} ${a} ${o.toLocaleString()} ${this.grid.translate("of","/")} ${n.toLocaleString()}`,this.eventService.dispatchEvent("paginationChanged",{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize,rowCount:n}),(r=(l=this.grid.getOptions()).onPaginationChanged)==null||r.call(l,{api:this.grid.getApi(),currentPage:this.currentPage,totalPages:e,pageSize:this.pageSize})}getPanel(){return this.ePanel}isLastPageFound(){return!0}}class Po{constructor(e){w(this,"openPopups",new Set);this.grid=e}getParent(){return this.grid.getOptions().popupParent||this.grid.getRootElement()}createPopup(e=220,t=""){const n=document.createElement("div");n.className=`ag-popup ${t}`.trim(),n.style.width=`${e}px`,n.style.display="none";const i={ePopup:n},o=()=>{var d;this.openPopups.has(i)&&(this.openPopups.delete(i),n.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",r,!0),(d=i.onClose)==null||d.call(i))},a=d=>{i.onClose=d},l=d=>{if(!n.contains(d.target)&&!this.grid.getRootElement().contains(d.target)){o();return}n.contains(d.target)||o()},r=d=>{d.key==="Escape"&&(d.stopPropagation(),o())};return this.getParent().appendChild(n),this.openPopups.add(i),document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",r,!0),{ePopup:n,close:o,onClose:a}}positionAt(e,t,n=0){const i=this.grid.getRootElement().getBoundingClientRect(),o=t.getBoundingClientRect(),a=e.offsetWidth||220;let l=o.left-i.left+n;const r=i.width-a-4;l>r&&(l=r),l<4&&(l=4);const d=o.bottom-i.top+2;e.style.left=`${l}px`,e.style.top=`${d}px`,e.style.display="block"}closeAll(){for(const e of[...this.openPopups])e.ePopup.remove(),this.openPopups.delete(e)}}class Ho{constructor(e,t){w(this,"ranges",[]);w(this,"currentRange",null);w(this,"eOverlay");w(this,"eHandle");w(this,"dragState",null);this.grid=e,this.eventService=t;const n=e.getRowRenderer().getContainer();n.style.position="relative",this.eOverlay=document.createElement("div"),this.eOverlay.className="ag-range-overlay",this.eOverlay.style.display="none",n.appendChild(this.eOverlay),this.eHandle=document.createElement("div"),this.eHandle.className="ag-range-handle",this.eHandle.style.display="none",n.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:n,rowIndex:i}=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:i,colEndId:n.colId},this.dragState={startRange:this.currentRange,mode:"create"},this.updateOverlay();return}const o={rowStartIndex:i,rowEndIndex:i,colStartId:n.colId,colEndId:n.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 n=t.closest(".ag-cell");if(!(n!=null&&n.dataset.colid))return;const i=n.closest(".ag-row");if(!(i!=null&&i.dataset.rowid))return;const o=this.grid.getRowModel().getRowNode(i.dataset.rowid);if(!o)return;let a=-1;if(this.grid.getRowModel().forEachNode((r,d)=>{r.id===o.id&&(a=d)}),a<0)return;const l=this.dragState.startRange;this.currentRange={rowStartIndex:Math.min(l.rowStartIndex,a),rowEndIndex:Math.max(l.rowStartIndex,a),colStartId:l.colStartId,colEndId:n.dataset.colid},this.dragState.mode==="handle"&&(this.currentRange.rowEndIndex=Math.max(l.rowStartIndex,a),this.currentRange.colEndId=n.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(),n=t.findIndex(g=>g.colId===e.colStartId),i=t.findIndex(g=>g.colId===e.colEndId);if(n<0||i<0)return null;const o=Math.min(n,i),a=Math.max(n,i);let l=0,r=0;for(let g=0;g<=a;g++)g<o?l+=t[g].width:r+=t[g].width;const c=this.grid.getRowRenderer().getRowOffsets(),p=Math.min(e.rowStartIndex,e.rowEndIndex),h=Math.max(e.rowStartIndex,e.rowEndIndex),u=c[p]??p*(this.grid.getOptions().rowHeight??42);let f=0;for(let g=p;g<=h;g++){const v=this.grid.getDisplayedRowAtIndex(g);f+=v?this.grid.getRowHeight(v):this.grid.getOptions().rowHeight??42}return{top:u,left:l,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 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=n=>this.onHandleMouseDown(n)}applyHighlight(){const e=this.ranges,t=this.grid.getRowRenderer().getRowComps(),n=this.getCenterColumns();for(const[i,o]of t){let a=-1;if(this.grid.getRowModel().forEachNode((l,r)=>{l.id===i&&(a=r)}),!(a<0))for(const l of o.getCellElements()){const r=l.dataset.colid,d=n.findIndex(h=>h.colId===r);let c=!1,p=!1;for(const h of e){const u=n.findIndex(k=>k.colId===h.colStartId),f=n.findIndex(k=>k.colId===h.colEndId),g=Math.min(h.rowStartIndex,h.rowEndIndex),v=Math.max(h.rowStartIndex,h.rowEndIndex),m=Math.min(u,f),y=Math.max(u,f);a>=g&&a<=v&&d>=m&&d<=y&&(c=!0,a===h.rowStartIndex&&d===u&&(p=!0))}l.classList.toggle("ag-cell-range-selected",c),l.classList.toggle("ag-cell-range-anchor",p)}}}getRangeCells(e){const t=this.getCenterColumns(),n=t.findIndex(c=>c.colId===e.colStartId),i=t.findIndex(c=>c.colId===e.colEndId),o=Math.min(e.rowStartIndex,e.rowEndIndex),a=Math.max(e.rowStartIndex,e.rowEndIndex),l=Math.min(n,i),r=Math.max(n,i),d=[];for(let c=o;c<=a;c++){const p=this.grid.getDisplayedRowAtIndex(c);if(p)for(let h=l;h<=r;h++)t[h]&&d.push({node:p,column:t[h]})}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===46||e.keyCode===8)&&this.ranges.length){e.preventDefault();for(const t of this.ranges)for(const n of this.getRangeCells(t))this.grid.setCellValue(n.column,n.node,null,"deleteKey");this.grid.refreshCells({flash:!0})}}}}class Oo{constructor(e,t){w(this,"dragState",null);w(this,"onMouseMoveBind",e=>this.onMouseMove(e));w(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 n=document.createElement("div");n.className="ag-row-drag-ghost",n.textContent=this.rowLabel(e),document.body.appendChild(n);const i=document.createElement("div");i.className="ag-row-drop-indicator",i.style.display="none",this.grid.getRowRenderer().getContainer().appendChild(i),this.dragState={rowNode:e,ghost:n,startY:t.clientY,overIndex:null,indicator:i},document.body.classList.add("ag-row-dragging"),document.addEventListener("mousemove",this.onMouseMoveBind),document.addEventListener("mouseup",this.onMouseUpBind)}rowLabel(e){var i;const t=this.grid.getColumns().center[0]??this.grid.getColumns().left[0],n=t!=null&&t.field?(i=e.data)==null?void 0:i[t.field]:"";return String(n??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 n=document.elementFromPoint(e.clientX,e.clientY),i=n==null?void 0:n.closest(".ag-row");if(!(i!=null&&i.dataset.rowid)){t.overIndex=null,t.indicator.style.display="none";return}let o=-1;if(this.grid.getRowModel().forEachNode((a,l)=>{a.id===i.dataset.rowid&&(o=l)}),t.overIndex=o,o>=0){const a=this.grid.getRowRenderer().getRowOffsets(),l=this.grid.getRowHeight(this.grid.getDisplayedRowAtIndex(o)),r=e.clientY>i.getBoundingClientRect().top+l/2,d=(a[o]??0)+(r?l:0);t.indicator.style.display="block",t.indicator.style.top=`${d-1}px`}else t.indicator.style.display="none"}onMouseUp(e){const t=this.dragState;if(document.removeEventListener("mousemove",this.onMouseMoveBind),document.removeEventListener("mouseup",this.onMouseUpBind),!t)return;this.dragState=null,document.body.classList.remove("ag-row-dragging"),t.ghost.remove(),t.indicator.remove();const n=this.grid.getApi(),i=this.grid.getOptions(),o=t.overIndex,a=this.indexOf(t.rowNode);this.eventService.dispatchEvent("rowDragEnd",{api:n,node:t.rowNode,overIndex:o,overNode:o!==null?this.grid.getDisplayedRowAtIndex(o):void 0,y:e.clientY}),i.rowDragManaged&&a>=0&&o!==null&&o!==a&&this.moveRow(a,o,e.clientY)}indexOf(e){let t=-1;return this.grid.getRowModel().forEachNode((n,i)=>{n.id===e.id&&(t=i)}),t}moveRow(e,t,n){const i=(this.grid.getOptions().rowData||[]).slice();if(e<0||e>=i.length)return;const[o]=i.splice(e,1),a=t>e?t-1:t;this.grid.getDisplayedRowAtIndex(t),i.splice(Math.max(0,Math.min(i.length,a+1)),0,o),this.grid.getApi().setRowData(i),this.eventService.dispatchEvent("rowDragMove",{api:this.grid.getApi(),node:{data:o}})}}class Bo{constructor(e){w(this,"ePanel");w(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 l;o.preventDefault(),this.eChips.classList.remove("ag-drag-over");const a=(l=o.dataTransfer)==null?void 0:l.getData("text/plain");a&&this.grid.getColumnModel().addRowGroupColumn(a)});const n=e.getOptions();(n.rowGroupPanelShow==="always"||n.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 n=document.createElement("div");n.className="ag-row-group-chip",n.draggable=!0,n.addEventListener("dragstart",a=>{var l;(l=a.dataTransfer)==null||l.setData("text/plain",t.colId)});const i=document.createElement("span");i.textContent=t.headerName,n.appendChild(i);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)),n.appendChild(o),this.eChips.appendChild(n)}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 Vo{constructor(e,t,n){w(this,"selectedNodes",new Set);w(this,"lastSelectedNode",null);this.eventService=e,this.getOptions=t,this.isNodeSelectable=n}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 n of e.children)n.footer||n.detailNode||(t?this.isNodeSelectable(n)&&(this.selectedNodes.add(n),n.selected=!0):(this.selectedNodes.delete(n),n.selected=!1),this.selectChildrenRecursively(n,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 n=this.getOptions().rowSelection==="multiple",i=t.ctrlKey||t.metaKey,o=t.shiftKey;return n?o&&this.lastSelectedNode?(this.selectRange(this.lastSelectedNode,e),!0):i?(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 n=this.getOptions().__rowModel;if(!(n!=null&&n.forEachNode))return;let i=-1,o=-1,a=0;if(n.forEachNode(d=>{d===e&&(i=a),d===t&&(o=a),a++}),i<0||o<0)return;const l=Math.min(i,o),r=Math.max(i,o);a=0,n.forEachNode(d=>{a>=l&&a<=r&&this.isNodeSelectable(d)&&!d.footer&&(this.selectedNodes.add(d),d.selected=!0),a++}),this.dispatchChanged()}syncWithModel(){const e=this.getOptions().__rowModel;if(!(e!=null&&e.forEachNode))return;const t=new Set;e.forEachNode(i=>t.add(i));let n=!1;for(const i of this.selectedNodes)t.has(i)?i.selected=!0:n=!0;if(n){for(const i of[...this.selectedNodes])t.has(i)||this.selectedNodes.delete(i);this.dispatchChanged()}}getLastSelectedNode(){return this.lastSelectedNode}setSelectAllCheckboxState(e){e?this.selectAllFiltered():this.deselectAll()}getSelectAllState(){const e=this.getOptions().__rowModel;let t=0,n=0;return e!=null&&e.forEachNode&&e.forEachNode(i=>{i.footer||!this.isNodeSelectable(i)||(t++,i.selected&&n++)}),{checked:t>0&&n===t,indeterminate:n>0&&n<t}}dispatchChanged(){this.eventService.dispatchEvent("selectionChanged",{api:this.getOptions().__api})}}class Go{constructor(e){w(this,"eBar");w(this,"eButtons");w(this,"ePanel");w(this,"panels",[]);w(this,"activePanelId",null);w(this,"visible",!1);w(this,"position");var n,i;this.grid=e;const t=e.getOptions();if(this.position=typeof t.sideBar=="object"&&((n=t.sideBar)!=null&&n.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(r=>typeof r=="string"?{id:r,label:this.defaultLabel(r)}:{id:r.id,label:r.labelDefault}):(this.panels=[{id:"columns",label:this.defaultLabel("columns")},{id:"filters",label:this.defaultLabel("filters")}],t.enableCharts&&this.panels.push({id:"charts",label:this.defaultLabel("charts")}));const a=(o==null?void 0:o.hiddenByDefault)===!0;this.visible=!a,this.eBar.style.display=this.visible?"":"none";const l=(o==null?void 0:o.defaultToolPanel)||((i=this.panels[0])==null?void 0:i.id)||"columns";this.buildButtons(),this.openPanel(l)}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 n=document.createElement("div");n.className="ag-column-panel-columns",e.appendChild(n);const i=()=>{const d=t.value.toLowerCase();n.innerHTML="";const c=this.grid.getColumnModel().getColumns(),p=c.filter(h=>h.pinned!=="left"&&h.pinned!=="right").concat(c.filter(h=>h.pinned==="left"||h.pinned==="right"));for(const h of p)d&&!h.headerName.toLowerCase().includes(d)&&!h.colId.toLowerCase().includes(d)||n.appendChild(this.buildColumnItem(h));if(!n.children.length){const h=document.createElement("div");h.className="ag-side-bar-empty",h.textContent=this.grid.t("noMatchingColumns"),n.appendChild(h)}};t.addEventListener("input",i),i();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 l=document.createElement("div");l.className="ag-column-group-list",o.appendChild(l);const r=()=>{l.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"),l.appendChild(c)}for(const c of d){const p=document.createElement("div");p.className="ag-column-group-item",p.draggable=!0,p.addEventListener("dragstart",f=>{var g;(g=f.dataTransfer)==null||g.setData("text/plain",c.colId)}),p.addEventListener("dragover",f=>f.preventDefault()),p.addEventListener("drop",f=>{var v;f.preventDefault();const g=(v=f.dataTransfer)==null?void 0:v.getData("text/plain");g&&this.grid.getColumnModel().setRowGroupColumns([...d.map(m=>m.colId),g])});const h=document.createElement("span");h.textContent=c.headerName,p.appendChild(h);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)),p.appendChild(u),l.appendChild(p)}};return r(),l.addEventListener("dragover",d=>d.preventDefault()),l.addEventListener("drop",d=>{var p;d.preventDefault();const c=(p=d.dataTransfer)==null?void 0:p.getData("text/plain");c&&this.grid.getColumnModel().addRowGroupColumn(c)}),e.appendChild(o),this.grid.getEventService().addEventListener("columnRowGroupChanged",()=>{this.activePanelId==="columns"&&r()}),this.grid.getEventService().addEventListener("displayedColumnsChanged",()=>{this.activePanelId==="columns"&&i()}),e}buildColumnItem(e){const t=document.createElement("div");t.className="ag-column-select-column",t.draggable=!0,t.dataset.colid=e.colId;const n=document.createElement("input");n.type="checkbox",n.className="ag-column-select-checkbox",n.checked=e.visible,n.addEventListener("change",()=>{this.grid.getColumnApi().setColumnVisible(e,n.checked)}),t.appendChild(n);const i=document.createElement("span");i.className="ag-column-select-label",i.textContent=e.headerName||e.colId,t.appendChild(i);const o=document.createElement("span");if(o.className="ag-column-select-actions",e.enableRowGroup&&e.field){const l=document.createElement("button");l.className="ag-column-select-action",l.title=this.grid.t("groupByThisColumn"),l.textContent="≡",l.addEventListener("click",()=>this.grid.getColumnModel().addRowGroupColumn(e)),o.appendChild(l)}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 l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.textContent=`${a.conditions.length} ${this.grid.t("conditionsUnit")}`,e.appendChild(l)}}const t=document.createElement("input");t.type="text",t.className="ag-column-panel-search",t.placeholder=this.grid.t("searchColumns"),e.appendChild(t);const n=document.createElement("div");n.className="ag-filters-panel-list",e.appendChild(n);const i=()=>{const o=t.value.toLowerCase();n.innerHTML="";const a=this.grid.getColumns().center.filter(l=>l.filter);for(const l of a)o&&!l.headerName.toLowerCase().includes(o)||n.appendChild(this.buildFilterItem(l));if(!n.children.length){const l=document.createElement("div");l.className="ag-side-bar-empty",l.textContent=this.grid.t("noMatchingColumns"),n.appendChild(l)}};return t.addEventListener("input",i),i(),this.grid.getEventService().addEventListener("filterChanged",()=>{this.activePanelId==="filters"&&i()}),e}buildFilterItem(e){const t=this.grid.getFilterService(),n=document.createElement("div");n.className="ag-filters-tool-panel-item";const i=document.createElement("div");i.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,i.appendChild(o);const a=t.isFilterActive(e);if(a){const l=document.createElement("span");l.className="ag-filters-tool-panel-item-badge",l.innerHTML=Un,i.appendChild(l)}if(n.appendChild(i),e.filter==="set"){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=a?"Edit filter":"Add filter",l.addEventListener("click",()=>this.grid.getFilterGui().openFilter(e,l)),n.appendChild(l)}else if(e.filter==="date"){const l=document.createElement("input");l.type="date",l.className="ag-filter-input";const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.dateFrom)??"",l.addEventListener("change",()=>{t.setColumnFilterModel(e,l.value?{filterType:"date",dateFrom:l.value,dateTo:l.value}:null)}),n.appendChild(l)}else{const l=document.createElement("input");l.type=e.filter==="number"?"number":"text",l.className="ag-filter-input",l.placeholder=this.grid.t("filterOoo");const r=t.getFilterInstance(e.colId);l.value=(r==null?void 0:r.filter)??"",l.addEventListener("input",()=>{t.handleFloatingFilterChange(e,l.value)}),n.appendChild(l)}if(a){const l=document.createElement("button");l.className="ag-button ag-button-small",l.textContent=this.grid.t("clear"),l.addEventListener("click",()=>t.setColumnFilterModel(e,null)),n.appendChild(l)}return n}}class qo{constructor(e){this.grid=e}getSortingOrder(){return this.grid.getOptions().sortingOrder??["asc","desc",null]}onSortRequested(e,t,n){const i=this.grid.getOptions().suppressMultiSort,o=n&&!i&&this.grid.getColumns().center.length+this.grid.getColumns().left.length>1,a=this.getSortingOrder(),l=e.sort;let r=a.indexOf(l)+1;r>=a.length&&(r=0);const d=a[r];if(!o)for(const c of this.grid.getAllColumns())c.colId!==e.colId&&(c.sort=null,c.sortIndex=null);e.sort=d,d===null?e.sortIndex=null:this.renumberSortIndices(),this.onSortChanged("uiColumnSorted")}renumberSortIndices(){this.grid.getAllColumns().filter(t=>t.sort).sort((t,n)=>(t.sortIndex??99)-(n.sortIndex??99)).forEach((t,n)=>t.sortIndex=n)}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,n)=>{const i=this.grid.getColumn(t.colId);i&&(i.sort=t.sort,i.sortIndex=n)}),this.onSortChanged("api")}onSortChanged(e){var n,i;this.grid.getHeaderView().updateIndicators(),this.grid.refreshModel("sort");const t=this.grid.getApi();this.grid.getEventService().dispatchEvent("sortChanged",{api:t,source:e}),(i=(n=this.grid.getOptions()).onSortChanged)==null||i.call(n,{api:t,source:e})}}class zo{constructor(e,t){w(this,"eBar");w(this,"panels",[]);this.grid=e,this.eBar=document.createElement("div"),this.eBar.className="ag-status-bar";const i=e.getOptions().statusBar;(!i||!i.statusPanels||i.statusPanels.length===0)&&(this.eBar.style.display="none");const o=((i==null?void 0:i.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 l=document.createElement("div");l.className=`ag-status-panel ag-status-panel-${a.align||"left"}`,this.eBar.appendChild(l);const r={def:a,ePanel:l,render:()=>this.renderPanel(a.key,l)};this.panels.push(r)}}getElement(){return this.eBar}isVisible(){return this.eBar.style.display!=="none"}setVisible(e){this.eBar.style.display=e?"":"none"}update(){for(const e of this.panels)e.render()}renderPanel(e,t){const n=this.grid.getApi(),i=this.grid.getRowModel().getRowCount(),o=this.grid.getRowModel(),a=typeof o.getTotalRowCount=="function"&&o.getType()!=="clientSide"?o.getTotalRowCount():(this.grid.getOptions().rowData||[]).length,l=n.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")} : ${_e(a)}`);break;case"agTotalAndFilteredRowCountComponent":r.push(`${this.grid.translate("rows","Rows")} : ${_e(i)}`);break;case"agFilteredRowCountComponent":r.push(`${this.grid.translate("filtered","Filtered")} : ${_e(i)}`);break;case"agSelectedRowCountComponent":r.push(`${this.grid.translate("selected","Selected")} : ${_e(l)}`);break;case"agAggregationComponent":{if(d.length===0)break;const c=n.getSelectedNodes().filter(h=>!h.group&&!h.footer),p=[];for(const h of d){const f=c.map(y=>Se(h,y,n)).filter(y=>typeof y=="number"&&!isNaN(y)),g=f.reduce((y,k)=>y+k,0),v=y=>y===null?"":_e(y,h.decimals),m=[[this.grid.translate("average","Average"),f.length?g/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?g:null]];for(const[y,k]of m)p.push(`${y}${h.headerName?` (${h.headerName})`:""} : ${v(k)}`)}p.length&&r.push(p.join(" "));break}default:r.push(e);break}t.textContent=r.join(" "),t.style.display=r.length?"":"none"}}class _o{constructor(e,t){w(this,"undoStack",[]);w(this,"redoStack",[]);w(this,"limit",50);w(this,"batchDepth",0);w(this,"batchBuffer",[]);w(this,"batchCounter",0);w(this,"currentBatchId",0);this.grid=e,this.eventService=t;const n=e.getOptions();n.undoRedoCellEditing&&(this.limit=typeof n.undoRedoCellEditing=="number"?n.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 n of e)this.applyValue(n,n.oldValue),this.redoStack.push(n),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 n=this.grid.getRowNode(e.rowNodeId);if(!n)return;const i=this.grid.getColumn(e.colId);i&&(this.grid.setCellValue(i,n,t,"undoRedo"),this.grid.refreshCells({rowNodes:[n],columns:[i],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 n of this.batchBuffer)this.undoStack.push({...n,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 Wo{constructor(e,t){w(this,"ctx");w(this,"eHeader");w(this,"ePinnedLeftHeader");w(this,"ePinnedRightHeader");w(this,"eHeaderViewport");w(this,"eHeaderContainer");w(this,"eHeaderRow");w(this,"eFloatingFiltersRow",null);w(this,"eGroupRows");w(this,"headerCells",new Map);w(this,"customHeaderComponents",new Map);w(this,"resizeState",null);w(this,"dragState",null);w(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:n}=this.ctx.getColumns();this.renderSection(this.ePinnedLeftHeader,e,"left"),this.renderSection(this.eHeaderRow,t,"center"),this.renderSection(this.ePinnedRightHeader,n,"right");const i=[...e,...t,...n].some(o=>o.floatingFilter);i&&!this.eFloatingFiltersRow?(this.eFloatingFiltersRow=document.createElement("div"),this.eFloatingFiltersRow.className="ag-header-row ag-floating-filters",this.eHeaderContainer.appendChild(this.eFloatingFiltersRow)):!i&&this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.remove(),this.eFloatingFiltersRow=null),this.eFloatingFiltersRow&&(this.eFloatingFiltersRow.innerHTML="",this.renderSection(this.eFloatingFiltersRow,t,"center"))}renderGroupRows(){var l;const e=this.ctx.getColumnModel(),t=((l=e==null?void 0:e.getColumnGroups)==null?void 0:l.call(e))||[];this.eGroupRows.innerHTML="";const n=t.reduce((r,d)=>Math.max(r,d.depth),0),i=this.ctx.options.groupHeaderHeight??30;let o=0;for(let r=1;r<=n;r++){const d=document.createElement("div");d.className="ag-header-row ag-group-header-row",d.style.height=`${i}px`;const c=this.ctx.getColumns().center;let p=0,h,u=0,f=0;const g=(m,y)=>{let k=m.groupId;for(;k;){const C=t.find(b=>b.id===k);if(!C)return null;if(C.depth===y)return C.id;k=C.parentId}return null},v=()=>{if(h==null)return;const m=t.find(b=>b.id===h);if(!m)return;const y=document.createElement("div");y.className="ag-header-group-cell",y.style.left=`${u}px`,y.style.width=`${f}px`,y.style.height=`${i}px`;const k=e.isGroupOpen(m.id),C=document.createElement("div");if(C.className="ag-header-group-cell-label",C.textContent=m.headerName,y.appendChild(C),!k){const b=document.createElement("span");b.className="ag-header-group-expand",b.textContent="▸",b.title=this.ctx.t("expandGroup"),y.appendChild(b)}y.addEventListener("click",()=>{e.setGroupOpen(m.id,!k)}),d.appendChild(y)};c.forEach(m=>{const y=g(m,r);y!==h&&(v(),h=y,u=p,f=0),f+=m.width,p+=m.width}),v(),d.style.width=`${p}px`,this.eGroupRows.appendChild(d),o+=i}this.eGroupRows.style.display=n>0?"":"none";const a=this.ctx.headerHeight;this.eHeader.style.height=`${o+a}px`}renderSection(e,t,n){e.innerHTML="";let i=0;for(const o of t){const a=this.createHeaderCell(o);if(a.style.left=`${i}px`,a.style.width=`${o.width}px`,a.style.height=`${this.ctx.headerHeight}px`,i+=o.width,e.appendChild(a),this.headerCells.set(o.colId,a),o.eHeaderCell=a,this.eFloatingFiltersRow&&e===this.eHeaderRow&&o.floatingFilter){const l=this.createFloatingFilter(o);l.style.left=`${i-o.width}px`,l.style.width=`${o.width}px`,this.eFloatingFiltersRow.appendChild(l)}}e===this.eHeaderRow?this.eHeaderContainer.style.width=`${i}px`:(e===this.ePinnedLeftHeader||e===this.ePinnedRightHeader)&&(e.style.width=`${i}px`)}createHeaderCell(e){var a,l;const t=document.createElement("div");if(t.className="ag-header-cell",t.dataset.colid=e.colId,t.setAttribute("role","columnheader"),t.setAttribute("aria-colindex",String(this.headerColumnIndex(e))),e.sort==="asc"?t.setAttribute("aria-sort","ascending"):e.sort==="desc"?t.setAttribute("aria-sort","descending"):t.setAttribute("aria-sort","none"),t.setAttribute("aria-label",e.headerName||e.colId),e.headerClass){const r=Array.isArray(e.headerClass)?e.headerClass.join(" "):e.headerClass;t.classList.add(...String(r).split(" ").filter(Boolean))}const n=e.colDef.headerComponent;if(typeof n=="function"){const r=n({column:e,colDef:e.colDef,api:((l=(a=this.ctx).getApi)==null?void 0:l.call(a))??null,displayName:e.headerName}),d=r&&typeof r.getGui=="function"?r.getGui():r;if(d instanceof HTMLElement)return d.classList.add("ag-header-component"),t.appendChild(d),typeof(r==null?void 0:r.refresh)=="function"&&this.customHeaderComponents.set(e.colId,r),t}const i=document.createElement("div");if(i.className="ag-header-cell-label",e.headerTooltip&&(i.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()),i.appendChild(r)}const o=document.createElement("span");if(o.className="ag-header-cell-text",o.textContent=e.headerName,i.appendChild(o),t.appendChild(i),e.sortable){const r=document.createElement("span");r.className="ag-header-icon ag-sort-indicator",this.updateSortIndicator(r,e.sort,e.sortIndex),t.appendChild(r)}if(e.filter){const r=document.createElement("span");r.className="ag-header-icon ag-filter-icon";const d=this.ctx.isFilterActive(e);r.classList.toggle("ag-filter-active",d),r.innerHTML=ro,r.title=this.ctx.t("openFilterTitle"),r.addEventListener("click",c=>{c.stopPropagation(),this.ctx.onFilterOpened(e,r)}),t.appendChild(r)}if(!this.ctx.isColumnMenuSuppressed(e)&&!e.suppressMenu){const r=document.createElement("span");r.className="ag-header-icon ag-menu-icon",r.innerHTML=ao,r.title=this.ctx.t("openMenuTitle"),r.addEventListener("click",d=>{d.stopPropagation(),this.ctx.onColumnMenuClicked(e,r)}),t.appendChild(r)}if(t.addEventListener("click",r=>{this.ctx.eventService.dispatchEvent("columnHeaderClicked",{column:e,api:null}),e.sortable&&this.ctx.onSortRequested(e,r,r.shiftKey||r.ctrlKey||r.metaKey)}),t.addEventListener("contextmenu",r=>{r.preventDefault(),this.ctx.eventService.dispatchEvent("columnHeaderContextMenu",{column:e,event:r}),this.ctx.onColumnMenuClicked(e,t)}),t.addEventListener("dblclick",r=>{const d=t.getBoundingClientRect();r.clientX>d.right-8&&e.resizable&&this.ctx.eventService.dispatchEvent("columnResized",{column:e,source:"autoSize"})}),e.resizable){const r=document.createElement("div");r.className="ag-header-cell-resize",r.addEventListener("mousedown",d=>{d.stopPropagation(),d.preventDefault(),this.resizeState={column:e,startX:d.clientX,startWidth:e.width};const c=h=>{if(!this.resizeState)return;const u=h.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)},p=()=>{this.resizeState&&this.ctx.onColumnResized(this.resizeState.column,this.resizeState.column.width,!0),this.resizeState=null,document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",p),document.body.classList.remove("ag-resizing")};document.body.classList.add("ag-resizing"),document.addEventListener("mousemove",c),document.addEventListener("mouseup",p)}),t.appendChild(r)}return e.suppressMovable||(t.draggable=!0,t.addEventListener("dragstart",r=>{if(!r.dataTransfer)return;r.dataTransfer.setData("text/plain",e.colId),r.dataTransfer.effectAllowed="move";const d=t.cloneNode(!0);d.classList.add("ag-header-cell-drag-ghost"),d.style.position="absolute",d.style.top="-1000px",d.style.width=`${e.width}px`,d.style.height=`${this.ctx.headerHeight}px`,document.body.appendChild(d),r.dataTransfer.setDragImage(d,20,20),this.dragState={colId:e.colId,ghost:d,startX:r.clientX,startY:r.clientY},setTimeout(()=>d.remove(),0)}),t.addEventListener("dragend",()=>{var r;(r=this.dragState)!=null&&r.ghost.parentNode&&this.dragState.ghost.remove(),this.dragState=null}),t.addEventListener("dragover",r=>{r.preventDefault()}),t.addEventListener("drop",r=>{var c;r.preventDefault();const d=(c=r.dataTransfer)==null?void 0:c.getData("text/plain");d&&d!==e.colId&&this.ctx.onColumnMoved(d,e.colId)})),t}createFloatingFilter(e){const t=document.createElement("div");if(t.className="ag-header-cell ag-floating-filter-cell",t.dataset.colid=e.colId,t.style.position="absolute",t.style.height=`${this.ctx.options.floatingFiltersHeight??24}px`,e.filter==="boolean"){const i=document.createElement("select");return i.className="ag-floating-filter-input",i.innerHTML='<option value="">All</option><option value="true">✓</option><option value="false">✗</option>',i.addEventListener("change",()=>this.ctx.onFloatingFilterChanged(e,i.value)),t.appendChild(i),e.floatingFilterComp=i,t}const n=document.createElement("input");return n.className="ag-floating-filter-input",n.type=e.filter==="number"?"number":e.filter==="date"?"date":"text",n.placeholder=this.ctx.t("filterOoo"),n.value=(this.ctx.getQuickFilterText()&&e.filter==="set",""),n.addEventListener("input",()=>this.ctx.onFloatingFilterChanged(e,n.value)),t.appendChild(n),e.floatingFilterComp=n,t}updateSortIndicator(e,t,n){if(e.innerHTML="",t==="asc"?(e.classList.add("ag-sort-asc"),e.innerHTML=lo):t==="desc"&&(e.classList.add("ag-sort-desc"),e.innerHTML=co),t&&n!==null&&n>0){const i=document.createElement("span");i.className="ag-sort-order",i.textContent=String(n+1),e.appendChild(i)}}updateIndicators(){const{left:e,center:t,right:n}=this.ctx.getColumns();for(const i of[...e,...t,...n]){const o=this.headerCells.get(i.colId);if(!o)continue;const a=o.querySelector(".ag-sort-indicator");a&&this.updateSortIndicator(a,i.sort,i.sortIndex);const l=o.querySelector(".ag-filter-icon");l&&l.classList.toggle("ag-filter-active",this.ctx.isFilterActive(i)),o.style.width=`${i.width}px`,this.lastWidths.get(i.colId)!==i.width&&this.lastWidths.set(i.colId,i.width)}this.layoutPositions()}headerColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(n=>n.colId===e.colId)+1}layoutPositions(){const{left:e,center:t,right:n}=this.ctx.getColumns();let i=0;for(const o of e){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}this.ePinnedLeftHeader.style.width=`${i}px`,i=0;for(const o of t){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}this.eHeaderContainer.style.width=`${i}px`,i=0;for(const o of n){const a=this.headerCells.get(o.colId);a&&(a.style.left=`${i}px`),i+=o.width}if(this.ePinnedRightHeader.style.width=`${i}px`,this.eFloatingFiltersRow){i=0;for(const o of t){const a=this.eFloatingFiltersRow.querySelector(`[data-colid="${o.colId}"]`);a&&(a.style.left=`${i}px`,a.style.width=`${o.width}px`),i+=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 Bt{constructor(e,t,n,i,o,a,l){w(this,"eLeft",null);w(this,"eCenter",null);w(this,"eRight",null);w(this,"cellComps",[]);w(this,"pinned",!1);var r,d,c,p,h,u,f,g,v;if(this.ctx=e,this.node=t,this.rowHeight=a,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}n.length&&(this.eLeft=this.createRowElement(t,n,"left"),this.eLeft.classList.add("ag-row-pinned")),(i.length||t.footer||t.detailNode)&&(this.eCenter=this.createRowElement(t,i,"center")),o.length&&(this.eRight=this.createRowElement(t,o,"right"),this.eRight.classList.add("ag-row-pinned")),t.footer&&((r=this.eCenter)==null||r.classList.add("ag-row-footer"),(d=this.eLeft)==null||d.classList.add("ag-row-footer"),(c=this.eRight)==null||c.classList.add("ag-row-footer")),t.group&&((p=this.eCenter)==null||p.classList.add("ag-row-group"),(h=this.eLeft)==null||h.classList.add("ag-row-group"),(u=this.eRight)==null||u.classList.add("ag-row-group")),(t.rowPinned==="top"||t.rowPinned==="bottom")&&(this.pinned=!0),this.ctx.isNodeSelected(t)&&((f=this.eCenter)==null||f.classList.add("ag-row-selected"),(g=this.eLeft)==null||g.classList.add("ag-row-selected"),(v=this.eRight)==null||v.classList.add("ag-row-selected"))}isPinned(){return this.pinned}setSticky(e){var t,n,i;(t=this.eLeft)==null||t.classList.toggle("ag-row-sticky-group",e),(n=this.eCenter)==null||n.classList.toggle("ag-row-sticky-group",e),(i=this.eRight)==null||i.classList.toggle("ag-row-sticky-group",e)}setHovered(e){var t,n,i;(t=this.eLeft)==null||t.classList.toggle("ag-row-hover",e),(n=this.eCenter)==null||n.classList.toggle("ag-row-hover",e),(i=this.eRight)==null||i.classList.toggle("ag-row-hover",e)}getNode(){return this.node}createRowElement(e,t,n){var r;const i=document.createElement("div");i.className="ag-row",i.dataset.rowid=e.id,i.setAttribute("role","row"),i.setAttribute("aria-rowindex",String((e.__displayIndex??0)+1)),i.setAttribute("aria-selected",String(this.ctx.isNodeSelected(e))),this.ctx.rowDragEnabled()&&i.classList.add("ag-row-draggable"),(e.__displayIndex??0)%2===1&&i.classList.add("ag-row-even"),i.style.height=`${this.rowHeight}px`,i.style.position="absolute",i.style.top="0px";const o=this.ctx.getRowClass(e);o&&i.classList.add(...o.split(" ").filter(Boolean));const a=this.ctx.getRowStyle(e);a&&Object.assign(i.style,a),e.footer&&((r=e.groupData)!=null&&r.__grandTotal)&&(i.classList.add("ag-row-full-width"),i.style.width="100%",i.style.right="0",i.style.left="0");let l=0;for(let d=0;d<t.length;d++){const c=t[d],p=this.createCell(c,e);let h=1;typeof c.colDef.colSpan=="function"&&(h=Math.max(1,Math.round(c.colDef.colSpan({value:Se(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<h&&d+f<t.length;f++)u+=t[d+f].width;p.eCell.style.left=`${l}px`,p.eCell.style.width=`${u}px`,p.eCell.style.position="absolute",p.eCell.style.top="0",p.eCell.style.height=`${this.rowHeight}px`,h>1&&p.eCell.classList.add("ag-cell-col-span"),l+=u,d+=h-1,i.appendChild(p.eCell),this.cellComps.push(p)}return i.style.width=`${l}px`,i}cellColumnIndex(e){return[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].findIndex(n=>n.colId===e.colId)+1}createCell(e,t){var c,p;const n=document.createElement("div");n.className="ag-cell",n.dataset.colid=e.colId;const i=e.colId.replace(/[^a-zA-Z0-9_-]/g,"-");i&&n.classList.add(`ag-col-${i}`);const o={value:Se(e,t,null),data:t.data,node:t,column:e,rowIndex:t.__displayIndex??0,api:null};if(e.cellClass){const h=typeof e.cellClass=="function"?e.cellClass(o):e.cellClass;typeof h=="string"?n.classList.add(...h.split(" ").filter(Boolean)):Array.isArray(h)&&n.classList.add(...h)}if(e.cellClassRules)for(const[h,u]of Object.entries(e.cellClassRules))u(o)&&n.classList.add(h);if(e.cellStyle){const h=typeof e.cellStyle=="function"?e.cellStyle(o):e.cellStyle;Object.assign(n.style,h)}(e.type==="numberColumn"||e.cellDataType===!0)&&n.classList.add("ag-right-aligned-cell"),e.rowDrag&&n.classList.add("ag-cell-row-drag");const a=document.createElement("span");a.className="ag-cell-value",n.appendChild(a),this.ctx.options.enableCellTextSelection&&(n.style.userSelect="text",n.style.cursor="text"),n.setAttribute("role","gridcell"),n.setAttribute("aria-colindex",String(this.cellColumnIndex(e)));const l=(p=(c=this.ctx).getNote)==null?void 0:p.call(c,t.id,e.colId,e.colDef.note,{value:Se(e,t,null),data:t.data,node:t,column:e,api:null});if(l){const h=document.createElement("span");h.className="ag-cell-note-marker",h.title=l,h.addEventListener("click",u=>{var f,g;u.stopPropagation(),(g=(f=this.ctx).onNoteClick)==null||g.call(f,t.id,e.colId,h)}),n.appendChild(h)}if(e.rowDrag){const h=document.createElement("span");h.className="ag-row-drag-handle",h.innerHTML=Wn,h.title=this.ctx.t("dragRow"),h.addEventListener("mousedown",u=>{var f,g;u.button===0&&(u.stopPropagation(),(g=(f=this.ctx).onRowDragStart)==null||g.call(f,t,h,u))}),n.appendChild(h)}const r=e.tooltipField;r&&t.data&&t.data[r]!==void 0?n.title=String(t.data[r]):e.tooltipValueGetter&&(n.title=String(e.tooltipValueGetter({value:Se(e,t,null),valueFormatted:null,data:t.data,node:t,column:e,api:null,colDef:e.colDef})));const d={column:e,eCell:n,eValue:a,lastValue:void 0,lastFormatted:null,rendererKey:"",custom:!1};return this.updateCellContent(d),d}updateCellContent(e){var d;const{column:t,node:n}={column:e.column,node:this.node},i=Se(t,n,null),o=Dt(t,n,null);e.lastValue=i,e.lastFormatted=o;const a=typeof t.cellRenderer=="string"?t.cellRenderer:null,l=typeof t.cellRenderer=="function"?t.cellRenderer:null;if(a||l){e.custom=!0;const c=a||"func";if(e.rendererKey!==c){e.eValue.innerHTML="",e.rendererKey=c;const p={value:i,valueFormatted:o,data:n.data,node:n,column:t,rowIndex:n.__displayIndex??0,api:null,colDef:t.colDef,eGridCell:e.eCell,registerRowDragger:void 0,...t.cellRendererParams||{}};let h=null;if(a&&Ot[a]){const u=Ot[a](p);u instanceof HTMLElement?h=u:(e.rendererInstance=u,h=u.getGui())}else if(l){const u=l(p);u instanceof HTMLElement?h=u:u&&typeof u.getGui=="function"?(e.rendererInstance=u,h=u.getGui()):typeof u=="string"&&(e.eValue.innerHTML=u)}h&&e.eValue.appendChild(h)}return}e.rendererKey="",e.custom=!1,(d=e.rendererInstance)!=null&&d.destroy&&(e.rendererInstance.destroy(),e.rendererInstance=void 0);let r=o??"";if((n.group||n.footer)&&n.groupData){const c=n.groupData[t.colId];r=c==null?"":String(c)}e.eValue.textContent!==r&&(e.eValue.textContent=r)}refreshCells(e,t,n){var a,l,r,d;const i=e&&e.length?new Set(e.map(c=>c.colId)):null;for(const c of this.cellComps){if(i&&!i.has(c.column.colId))continue;const p=Se(c.column,this.node,null),h=t||p!==c.lastValue;if(!h&&!n)continue;const u=c.eValue.textContent;if(c.rendererInstance&&typeof c.rendererInstance.refresh=="function"){c.rendererInstance.refresh({value:p,valueFormatted:Dt(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=p,n&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}if(c.rendererKey){(h||n)&&(c.rendererKey="",this.updateCellContent(c)),c.lastValue=p,n&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.eCell.classList.add("ag-cell-data-change"));continue}this.updateCellContent(c),(n||h&&u!==c.eValue.textContent)&&(c.eCell.classList.remove("ag-cell-data-change"),c.eCell.offsetWidth,c.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),(l=this.eLeft)==null||l.classList.toggle("ag-row-selected",o),(r=this.eRight)==null||r.classList.toggle("ag-row-selected",o),this.node.group&&((d=this.eCenter)==null||d.classList.toggle("ag-row-group-expanded",this.node.expanded))}appendTo(e,t,n){if(this.eLeft&&e.appendChild(this.eLeft),this.eCenter&&t.appendChild(this.eCenter),this.eRight&&n.appendChild(this.eRight),this.node.detailNode&&this.ctx.renderDetailRow){const i=this.ctx.renderDetailRow(this.node,this.eCenter);i&&t.appendChild(i.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,n,i;(e=this.eLeft)!=null&&e.parentNode&&this.eLeft.parentNode.removeChild(this.eLeft),(t=this.eCenter)!=null&&t.parentNode&&this.eCenter.parentNode.removeChild(this.eCenter),(n=this.eRight)!=null&&n.parentNode&&this.eRight.parentNode.removeChild(this.eRight);for(const o of this.cellComps)(i=o.rendererInstance)!=null&&i.destroy&&o.rendererInstance.destroy();this.cellComps=[]}}function Qn(s,e,t){const n=s.length;if(n===0||t<=0)return[];let i=0,o=n-1;for(;i<o;){const c=i+o>>1;s[c]>=t?o=c:i=c+1}const a=s[i]>=t?i:n-1,l=e[a];if(!l||l.level===0)return[];const r=[];let d=l.level;for(let c=a-1;c>=0;c--){const p=e[c];if(!(!p||p.level>=d)&&(d=p.level,p.group&&s[c]<t&&r.push(c),p.level===0))break}return r.reverse()}class Uo{constructor(e,t,n){w(this,"ctx");w(this,"eRoot");w(this,"eHeader");w(this,"eBody");w(this,"ePinnedLeft");w(this,"ePinnedRight");w(this,"ePinnedLeftInner");w(this,"ePinnedRightInner");w(this,"eViewport");w(this,"eContainer");w(this,"eFloatingTop");w(this,"eFloatingBottom");w(this,"eFloatingTopLeft");w(this,"eFloatingTopRight");w(this,"eFloatingBottomLeft");w(this,"eFloatingBottomRight");w(this,"eStickyTop");w(this,"eStickyLeft");w(this,"eStickyCenter");w(this,"eStickyRight");w(this,"rowComps",new Map);w(this,"stickyComps",new Map);w(this,"hoveredRowId",null);w(this,"rowOffsets",[]);w(this,"rowIndices",new Map);w(this,"rowInfos",[]);w(this,"totalHeight",0);w(this,"lastScrollTop",-1);w(this,"lastRange",[-1,-1]);w(this,"heightVersion",0);w(this,"scrollFrame",null);w(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 n=this.eViewport;let i=e.deltaY,o=e.deltaX;e.deltaMode===1?(i*=33,o*=33):e.deltaMode===2&&(i*=n.clientHeight,o*=n.clientWidth),e.shiftKey&&!o&&(o=i,i=0),i&&(n.scrollTop+=i),o&&(n.scrollLeft+=o),this.syncPinnedScroll(),this.scheduleScrollRender(),this.ctx.onViewportScroll&&this.ctx.onViewportScroll(),e.preventDefault()});w(this,"onBodyMouseOver",e=>{var o;const t=e.target,n=(o=t==null?void 0:t.closest)==null?void 0:o.call(t,".ag-row"),i=(n==null?void 0:n.dataset.rowid)??null;if(i===this.hoveredRowId){i&&this.setRowHovered(i,!0);return}this.hoveredRowId&&this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=i,i&&this.setRowHovered(i,!0)});w(this,"onBodyMouseLeave",()=>{this.hoveredRowId&&(this.setRowHovered(this.hoveredRowId,!1),this.hoveredRowId=null)});this.ctx=n,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 i=document.createElement("div");i.className="ag-body-viewport-wrapper",this.eBody.appendChild(i),this.eFloatingTop=document.createElement("div"),this.eFloatingTop.className="ag-floating-top",i.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)),i.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",i.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 n of this.rowComps.values())n.getNode().id===e&&n.setHovered(t);for(const n of this.stickyComps.values())n.getNode().id===e&&n.setHovered(t)}getViewport(){return this.eViewport}getBody(){return this.eBody}getContainer(){return this.eContainer}getRowComps(){return this.rowComps}getHeaderElement(){return this.eHeader}recomputeOffsets(){const e=this.ctx.rowModel.getRowCount();this.rowIndices.clear();const t=new Array(e),n=new Array(e);let i=0;if(this.hasVariableHeights()){for(let a=0;a<e;a++)t[a]=i,n[a]=this.rowInfoAt(a),i+=this.getRowHeightForIndex(a);this.totalHeight=i}else{const a=this.getFixedRowHeight();for(let l=0;l<e;l++)t[l]=l*a,n[l]=this.rowInfoAt(l);this.totalHeight=e*a}this.rowOffsets=t,this.rowInfos=n}rowInfoAt(e){const t=this.ctx.rowModel.getRow(e);return t?(this.rowIndices.set(t.id,e),{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((i,o)=>i+o.width,0),t=this.ctx.getColumns().left.reduce((i,o)=>i+o.width,0),n=this.ctx.getColumns().right.reduce((i,o)=>i+o.width,0);this.eContainer.style.width=`${Math.max(e,1)}px`,this.ePinnedLeft.style.width=`${t}px`,this.ePinnedRight.style.width=`${n}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=`${n}px`,this.eFloatingBottomLeft.style.width=`${t}px`,this.eFloatingBottomRight.style.width=`${n}px`,this.eStickyLeft.style.width=`${t}px`,this.eStickyRight.style.width=`${n}px`,this.eStickyCenter.style.left=`${t}px`,this.eStickyCenter.style.right=`${n}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 n,i;const e=(o,a,l,r,d)=>{o.innerHTML="",a.innerHTML="",l.innerHTML="";const{left:c,center:p,right:h}=this.ctx.getColumns();let u=0;for(let f=0;f<r;f++){const g=d(f);if(!g)continue;const v=this.ctx.getRowHeight(g),m=new Bt(this.ctx,g,c,p,h,v,this.heightVersion);m.appendTo(a,o,l),m.setTop(u),u+=v,this.rowComps.set(`${g.id}|${o===this.eFloatingTop?"top":"bottom"}`,m)}o.style.height=`${u}px`,o.style.display=r>0?"":"none",a.style.height=`${u}px`,l.style.height=`${u}px`},t=this.ctx.rowModel;e(this.eFloatingTop,this.eFloatingTopLeft,this.eFloatingTopRight,((n=t.getPinnedTopRowCount)==null?void 0:n.call(t))??0,o=>{var a;return(a=t.getPinnedTopRow)==null?void 0:a.call(t,o)}),e(this.eFloatingBottom,this.eFloatingBottomLeft,this.eFloatingBottomRight,((i=t.getPinnedBottomRowCount)==null?void 0:i.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 n;e!=null&&e.columns&&(n=e.columns.map(i=>typeof i=="string"?this.ctx.getColumns().left.concat(this.ctx.getColumns().center,this.ctx.getColumns().right).find(o=>o.colId===i):i).filter(Boolean));for(const[i,o]of this.rowComps)t&&!t.includes(o.getNode())||o.refreshCells(n,e==null?void 0:e.force,e==null?void 0:e.flash);for(const i of this.stickyComps.values())t&&!t.includes(i.getNode())||i.refreshCells(n,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 n=t.getNode(),i=this.findRowIndex(n);if(t.destroy(),this.rowComps.delete(this.rowCompKey(n)),i>=0){const{left:o,center:a,right:l}=this.ctx.getColumns(),r=new Bt(this.ctx,n,o,a,l,this.getRowHeightForIndex(i),this.heightVersion);r.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),r.setTop(this.rowOffsets[i]??0),this.rowComps.set(this.rowCompKey(n),r)}}for(const t of this.stickyComps.values())e.rowNodes.includes(t.getNode())&&(t.destroy(),this.stickyComps.delete(t.getNode().id));this.renderVisibleRows(!0)}rowCompKey(e){return e.id}findRowIndex(e){return this.rowIndices.get(e.id)??-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 n=`translateX(${getComputedStyle(this.eStickyTop).direction==="rtl"?this.eViewport.scrollLeft:-this.eViewport.scrollLeft}px)`;for(const i of this.stickyComps.values()){const o=i.getCenterElement();o&&(o.style.transform=n)}}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){var t,n;this.eViewport.scrollLeft=e,this.syncPinnedScroll(),(n=(t=this.ctx).onViewportScroll)==null||n.call(t)}syncStickyGroupRows(){const e=this.ctx.options.suppressGroupRowsSticky?[]:Qn(this.rowOffsets,this.rowInfos,this.eViewport.scrollTop),{left:t,center:n,right:i}=this.ctx.getColumns(),o=parseFloat(this.eFloatingTop.style.height||"0")||0;this.eStickyTop.style.top=`${o}px`;const a=new Set;let l=0;for(const d of e){const c=this.ctx.rowModel.getRow(d);if(!c||!c.group)continue;a.add(c.id);let p=this.stickyComps.get(c.id);if(!p){const h=this.rowComps.get(c.id);h&&(h.destroy(),this.rowComps.delete(c.id)),p=new Bt(this.ctx,c,t,n,i,this.getRowHeightForIndex(d),this.heightVersion),p.appendTo(this.eStickyLeft,this.eStickyCenter,this.eStickyRight),p.setSticky(!0),this.stickyComps.set(c.id,p)}p.setTop(l),l+=this.getRowHeightForIndex(d)}for(const[d,c]of this.stickyComps)a.has(d)||(c.destroy(),this.stickyComps.delete(d));const r=`${l}px`;return this.eStickyTop.style.height=r,this.eStickyLeft.style.height=r,this.eStickyCenter.style.height=r,this.eStickyRight.style.height=r,this.syncStickyHorizontal(),a}renderVisibleRows(e=!1){const t=this.ctx.rowModel.getRowCount(),n=this.eViewport.scrollTop,i=this.eViewport.clientHeight,o=this.ctx.options.rowBuffer??10;let a,l;if(this.hasVariableHeights())a=this.findIndexAtPixel(n)-o,l=this.findIndexAtPixel(n+i)+o;else{const v=this.getFixedRowHeight();a=Math.floor(n/v)-o,l=Math.ceil((n+i)/v)+o}if(a=Math.max(0,a),l=Math.min(t-1,l),!e&&this.lastRange[0]===a&&this.lastRange[1]===l&&this.lastScrollTop===n)return;const r=this.lastRange[0]!==a||this.lastRange[1]!==l;this.lastRange=[a,l],this.lastScrollTop=n;const d=new Set(this.stickyComps.keys()),c=this.syncStickyGroupRows(),p=d.size!==c.size||[...d].some(v=>!c.has(v));if(!e&&!r&&!p)return;const h=new Set(c),{left:u,center:f,right:g}=this.ctx.getColumns();for(let v=a;v<=l;v++){const m=this.ctx.rowModel.getRow(v);if(!m||(h.add(m.id),c.has(m.id)))continue;let y=this.rowComps.get(m.id);y||(y=new Bt(this.ctx,m,u,f,g,this.getRowHeightForIndex(v),this.heightVersion),y.appendTo(this.ePinnedLeftInner,this.eContainer,this.ePinnedRightInner),this.rowComps.set(m.id,y)),y.setTop(this.rowOffsets[v]??v*this.getFixedRowHeight())}for(const[v,m]of this.rowComps)!h.has(v)&&!m.isPinned()&&(m.destroy(),this.rowComps.delete(v))}findIndexAtPixel(e){const t=this.rowOffsets;let n=0,i=t.length-1;for(;n<i;){const o=n+i+1>>1;t[o]<=e?n=o:i=o-1}return n}ensureIndexVisible(e,t="top"){const n=this.rowOffsets[e]??e*this.getFixedRowHeight(),i=this.getRowHeightForIndex(e),o=this.eViewport.clientHeight;let a;t==="top"?a=n:t==="bottom"?a=n+i-o:a=n-(o-i)/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 n=this.eViewport.clientWidth,i=this.eViewport.scrollLeft,o=e.left-this.ctx.getColumns().left.reduce((a,l)=>a+l.width,0);o<i?this.eViewport.scrollLeft=Math.max(0,t==="middle"?o-(n-e.width)/2:o):o+e.width>i+n&&(this.eViewport.scrollLeft=o+e.width-n),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 n=e.target.closest(".ag-cell");if(!n)return null;const i=n.dataset.colid;if(!i)return null;const o=n.closest(".ag-row"),a=o==null?void 0:o.dataset.rowid;if(!a)return null;const l=this.ctx.rowModel.getRowNode(a);if(!l)return null;const d=[...this.ctx.getColumns().left,...this.ctx.getColumns().center,...this.ctx.getColumns().right].find(c=>c.colId===i);return d?{node:l,column:d,eCell:n,rowIndex:this.findRowIndex(l)}:null}onClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellClicked({event:e,node:t.node,column:t.column,value:Se(t.column,t.node,null),rowIndex:this.findRowIndex(t.node),colDef:t.column.colDef});return}const n=e.target.closest(".ag-row");if(n!=null&&n.dataset.rowid){const i=this.ctx.rowModel.getRowNode(n.dataset.rowid);i&&this.ctx.onRowClicked({event:e,node:i,data:i.data,rowIndex:this.findRowIndex(i)})}}onDoubleClick(e){const t=this.findCellFromEvent(e);if(t){this.ctx.onCellDoubleClicked({event:e,node:t.node,column:t.column,value:Se(t.column,t.node,null),rowIndex:this.findRowIndex(t.node),colDef:t.column.colDef});return}const n=e.target.closest(".ag-row");if(n!=null&&n.dataset.rowid){const i=this.ctx.rowModel.getRowNode(n.dataset.rowid);i&&this.ctx.onRowDoubleClicked({event:e,node:i,data:i.data})}}onMouseDown(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellMouseDown({event:e,node:t.node,column:t.column,value:Se(t.column,t.node,null),rowIndex:this.findRowIndex(t.node)})}onContextMenu(e){const t=this.findCellFromEvent(e);t&&this.ctx.onCellContextMenu({event:e,node:t.node,column:t.column,value:Se(t.column,t.node,null),rowIndex:this.findRowIndex(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 je{constructor(){w(this,"cleanups",new Set);w(this,"stopped",!1)}get destroyed(){return this.stopped}add(e){return this.stopped?e():this.cleanups.add(e),()=>{this.cleanups.delete(e)&&e()}}listen(e,t,n,i){return e.addEventListener(t,n,i),this.add(()=>e.removeEventListener(t,n,i))}timeout(e,t){if(this.stopped)return 0;const n=window.setTimeout(()=>{i(),this.stopped||e()},t),i=this.add(()=>window.clearTimeout(n));return n}interval(e,t){if(this.stopped)return 0;const n=window.setInterval(()=>{this.stopped||e()},t);return this.add(()=>window.clearInterval(n)),n}destroy(){if(this.stopped)return;this.stopped=!0;const e=[...this.cleanups].reverse();this.cleanups.clear();let t;for(const n of e)try{n()}catch(i){t??(t=i)}if(t!==void 0)throw t}}function Fe(s,e,t={},n=[]){const i=new je,o=new Set,a=h=>[...o].some(u=>u.contains(h)),l=new Set,r=new WeakMap,d=h=>{const u=h.target;if(!(u!=null&&u.closest))return;const f=u.closest('button,input,select,textarea,a,[data-action],[contenteditable],[role="button"],[role="tab"],[data-node-id],[data-rowid],[data-viewport],canvas');if(!f||!a(f))return;const g={};for(let m=f;m&&a(m);m=m.parentElement)for(const[y,k]of Object.entries(m.dataset))k!==void 0&&!(y in g)&&(g[y]=k);const v=f;r.has(h)||(r.set(h,{component:e,type:h.type,action:g.action??g.control,value:"value"in f?v.value:void 0,checked:v.type==="checkbox"||v.type==="radio"?v.checked:void 0,data:g,originalEvent:h}),queueMicrotask(()=>c(h)))},c=h=>{var g;const u=r.get(h);if(!u||i.destroyed)return;r.delete(h),(g=t.onInteraction)==null||g.call(t,u);for(const v of[...l])v(u);const f=s.ownerDocument.defaultView.CustomEvent;s.dispatchEvent(new f("rowvia:interaction",{detail:u,bubbles:!0}))},p=h=>{if(i.destroyed||o.has(h))return()=>{};o.add(h);const u=[];for(const f of["click","dblclick","contextmenu","input","change","submit","keydown","pointerdown","pointerup","wheel"])u.push(i.listen(h,f,d,{capture:!0,passive:!0}));return()=>{o.delete(h),u.forEach(f=>f())}};for(const h of[s,...n])p(h);return{addRoot:p,onInteraction(h){return i.destroyed?()=>{}:(l.add(h),()=>{l.delete(h)})},destroy(){i.destroy(),l.clear(),o.clear()}}}const jo={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 dt{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eventService",new As);w(this,"columnModel");w(this,"rowModel");w(this,"clientSideRowModel",null);w(this,"serverSideRowModel",null);w(this,"infiniteRowModel",null);w(this,"viewportRowModel",null);w(this,"rowRenderer");w(this,"headerView");w(this,"selectionService");w(this,"editService");w(this,"filterService");w(this,"sortService");w(this,"paginationService",null);w(this,"popupService");w(this,"filterGui");w(this,"contextMenuService");w(this,"columnMenuService");w(this,"statusBarService");w(this,"sideBarService");w(this,"findService");w(this,"rangeSelectionService");w(this,"chartService");w(this,"overlayService");w(this,"exportService");w(this,"rowGroupPanel",null);w(this,"undoRedoService");w(this,"formulaEditorService");w(this,"notesService");w(this,"rowDragService");w(this,"api");w(this,"columnApi");w(this,"localeText");w(this,"rowNodeServices");w(this,"eGridDiv");w(this,"eRoot");w(this,"eMain");w(this,"eHeader");w(this,"quickFilter","");w(this,"resizeObserver",null);w(this,"destroyed",!1);w(this,"gridReadyDispatched",!1);w(this,"context");w(this,"onWindowResize",()=>{this.onGridSizeChanged()});w(this,"onDocumentMouseDown",e=>{var n;const t=e.target;if(t&&this.eRoot.contains(t)){const i=(n=t.closest)==null?void 0:n.call(t,".ag-cell");if(!i){this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell();return}this.editService.isEditing()&&!i.classList.contains("ag-cell-inline-editing")&&this.editService.stopEditing(!1);return}this.editService.isEditing()&&this.editService.stopEditing(!1),this.editService.clearFocusedCell()});var d,c,p,h;this.eGridDiv=e,this.options={...jo,...t},this.quickFilter=this.options.quickFilterText||"",this.context=this.options.context,this.localeText=Ds(this.options.localeText),this.eGridDiv.classList.add("ag-grid-root");const n=this.options.theme||"ag-theme-alpine";this.eGridDiv.classList.add(n),this.eRoot=document.createElement("div"),this.eRoot.className="ag-root",this.eGridDiv.appendChild(this.eRoot),this.interactions=Fe(this.eRoot,"grid",this.options),this.onInteraction=this.interactions.onInteraction,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 Vn(this.options,this.eventService,null),this.columnModel.setGridApi(null),this.selectionService=new Vo(this.eventService,()=>({...this.options,__rowModel:this.rowModel,__api:this.api}),u=>this.isNodeSelectable(u)),this.filterService=new Io(this),this.sortService=new qo(this),this.popupService=new Po(this),this.filterGui=new No(this,this.popupService),this.contextMenuService=new ho(this,this.popupService),this.columnMenuService=new uo(this,this.popupService),this.editService=new po(this,this.eventService),this.undoRedoService=new _o(this,this.eventService),this.formulaEditorService=new $o(this,this.popupService),this.notesService=new Fo(this,this.popupService),this.rowDragService=new Oo(this,this.eventService),this.chartService=new Vs(this,this.popupService),this.findService=new Ao(this,this.popupService),this.exportService=new To(this);const i={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 Hs(i),this.rowModel=this.serverSideRowModel,this.options.serverSideDatasource&&this.serverSideRowModel.setDatasource(this.options.serverSideDatasource)):o==="infinite"?(this.infiniteRowModel=new Os(i),this.rowModel=this.infiniteRowModel,this.options.serverSideDatasource&&this.infiniteRowModel.setDatasource(this.options.serverSideDatasource)):o==="viewport"?(this.viewportRowModel=new Bs(i),this.rowModel=this.viewportRowModel,this.options.serverSideDatasource&&this.viewportRowModel.setViewportDatasource(this.options.serverSideDatasource)):(this.clientSideRowModel=new ks({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 Wo(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,g)=>this.sortService.onSortRequested(u,f,g),onColumnResized:(u,f,g)=>this.onColumnResized(u,f,g),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 Uo(this.eMain,this.eHeader,{options:this.options,eventService:this.eventService,rowModel:this.rowModel,t:u=>this.t(u),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 g,v,m;this.headerView.setScrollLeft(this.rowRenderer.getHorizontalScrollLeft(),this.rowRenderer.getVerticalScrollbarWidth());const u=this.rowRenderer.getFirstVisibleRowIndex(),f=this.rowRenderer.getLastVisibleRowIndex();(g=this.serverSideRowModel)==null||g.onViewportChanged(u,f),(v=this.infiniteRowModel)==null||v.onViewportChanged(u,f),(m=this.viewportRowModel)==null||m.onViewportChanged(u,f)},getCellText:(u,f)=>{const g=Se(u,f,this.api);return g==null?"":String(g)},renderDetailRow:u=>this.renderDetailRow(u),rowDragEnabled:()=>this.rowDragService.isEnabled(),onRowDragStart:(u,f,g)=>this.rowDragService.startDrag(u,g),getNote:(u,f,g,v)=>this.notesService.getNote(u,f,g,v),onNoteClick:(u,f,g)=>this.notesService.openNoteEditor(u,f,g),rowNumberOffset:()=>this.columnModel.getOptions().rowNumbers?1:0}),this.rangeSelectionService=new Ho(this,this.eventService),this.statusBarService=new zo(this,this.eventService),this.eMain.appendChild(this.statusBarService.getElement()),this.overlayService=new Do(this),this.sideBarService=new Go(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 Zn(this,this.eventService)),(this.options.rowGroupPanelShow==="always"||this.options.rowGroupPanelShow==="onlyWhenGrouping")&&(this.rowGroupPanel=new Bo(this));const{api:a,columnApi:l}=xs(this);this.api=a,this.columnApi=l,this.columnModel.setGridApi(this.api),(h=(p=this.rowModel).setGridApi)==null||h.call(p,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=Vn.generateColumnDefs(this.options.rowData)),this.columnModel.setColumnDefs(r),this.setRowData(this.options.rowData||[],!0),typeof ResizeObserver<"u"&&(this.resizeObserver=new ResizeObserver(()=>this.onGridSizeChanged()),this.resizeObserver.observe(this.eGridDiv)),window.addEventListener("resize",this.onWindowResize),document.addEventListener("mousedown",this.onDocumentMouseDown,!0),this.onGridSizeChanged(),this.options.enableRtl&&this.eGridDiv.classList.add("ag-direction-rtl"),this.eRoot.setAttribute("role","grid"),this.eRoot.setAttribute("aria-rowcount",String(this.getDisplayedRowCount())),this.eRoot.setAttribute("aria-colcount",String(this.getColumns().center.length+this.getColumns().left.length+this.getColumns().right.length)),this.eRoot.setAttribute("aria-label",this.translate("dataGrid","数据表格")),this.rowRenderer.getViewport().setAttribute("role","presentation"),this.options.enableCharts&&this.options.chartStorageKey&&this.chartService.loadCharts(),this.dispatchGridReady()}getOptions(){return this.options}t(e){return this.localeText.t(e)}translate(e,t){const n=this.localeText.t(e);return n===e?t:n}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 n,i;const e=new Map,t=this.getAllColumns().filter(o=>o.colDef.showValueAs);if(t.length>0){const o=new Map;(i=(n=this.rowModel).forEachLeafNode)==null||i.call(n,a=>{for(const l of t){const r=Se(l,a,this.api);typeof r=="number"&&!isNaN(r)&&o.set(l.colId,(o.get(l.colId)??0)+r)}});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,n;return!!((e=this.serverSideRowModel)!=null&&e.isLoading()||(t=this.infiniteRowModel)!=null&&t.isLoading()||(n=this.viewportRowModel)!=null&&n.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 n=t({data:e.data,node:e,api:this.api});if(n)return n}return this.options.rowHeight??42}getRowClass(e){const t=[];if(this.options.rowClass&&t.push(this.options.rowClass),typeof this.options.getRowClass=="function"){const n=this.options.getRowClass({data:e.data,node:e,api:this.api});typeof n=="string"?t.push(n):Array.isArray(n)&&t.push(...n)}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 n,i,o;this.options.rowData=e,this.rowModel.updateRowData(e),this.columnModel.isPivotMode()&&this.refreshPivotColumns(),this.selectionService.syncWithModel(),t||(this.overlayService.updateAuto(),this.statusBarService.update(),(n=this.paginationService)==null||n.update(),this.chartService.refreshCharts(),(o=(i=this.options).onRowDataChanged)==null||o.call(i,{api:this.api}))}applyTransaction(e){var n;const t=this.rowModel.applyTransaction(e);return this.selectionService.syncWithModel(),this.overlayService.updateAuto(),this.statusBarService.update(),(n=this.paginationService)==null||n.update(),this.chartService.refreshCharts(),this.eventService.dispatchEvent("rowDataUpdated",{api:this.api}),t}setCellValue(e,t,n,i="api",o){const a=o!==void 0?o:Se(e,t,this.api);if(e.valueSetter){if(e.valueSetter({oldValue:Se(e,t,this.api),newValue:n,data:t.data,node:t,column:e,api:this.api,colDef:e.colDef})===!1)return}else t.setDataValue(e.colId,n);e.rowGroup&&this.rowModel.refreshModel("group"),(i==="edit"||i==="batchEdit")&&this.undoRedoService.pushAction({rowNodeId:t.id,colId:e.colId,oldValue:a,newValue:n,batchId:0}),i!=="edit"&&this.eventService.dispatchEvent("cellValueChanged",{oldValue:null,newValue:n,value:n,data:t.data,node:t,column:e,colDef:e.colDef,api:this.api,source:i})}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,l,r,d;const{node:t,column:n,event:i}=e;if(this.options.enableRangeSelection,n.checkboxSelection){this.selectionService.toggleNode(t),this.rowRenderer.refreshCells({rowNodes:[t]}),(l=(a=this.options).onCellClicked)==null||l.call(a,{...e,api:this.api,colDef:n.colDef,value:Se(n,t,this.api)});return}if(i.target.closest(".ag-group-value-expanded-icon")){this.onRowGroupClicked(t);return}this.selectionService.handleRowClick(t,i),this.editService.onCellClicked(e),(d=(r=this.options).onCellClicked)==null||d.call(r,{...e,api:this.api,colDef:n.colDef,value:Se(n,t,this.api)})}onCellMouseDown(e){this.options.enableRangeSelection&&this.rangeSelectionService.onCellMouseDown(e)}onRowClicked(e){var t,n;this.selectionService.handleRowClick(e.node,e.event),(n=(t=this.options).onRowClicked)==null||n.call(t,{...e,api:this.api})}onRowDoubleClicked(e){var t,n;(n=(t=this.options).onRowDoubleClicked)==null||n.call(t,{...e,api:this.api})}onCellContextMenu(e){var n,i;const t=e.event.target.closest(".ag-cell")||this.eRoot;this.contextMenuService.openContextMenu(t,{column:e.column,node:e.node}),(i=(n=this.options).onCellContextMenu)==null||i.call(n,{...e,api:this.api,colDef:e.column.colDef})}onRowGroupClicked(e){var t,n,i,o,a;if(e.group){const l=(t=this.rowModel.setNodeExpanded)==null?void 0:t.bind(this.rowModel);l&&l(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}),(i=(n=this.options).onRowGroupOpened)==null||i.call(n,{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 n;if(e.headerCheckboxSelectionCurrentPageOnly&&((n=this.paginationService)!=null&&n.isEnabled())){const i=this.rowModel.getRowCount();if(t)for(let o=0;o<i;o++){const a=this.rowModel.getRow(o);a&&this.isNodeSelectable(a)&&this.selectionService.selectNode(a,!1)}else for(let o=0;o<i;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 n=t.querySelector(".ag-header-select-all");if(!n)continue;const i=this.selectionService.getSelectAllState();n.checked=i.checked,n.indeterminate=i.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,n){e.width=t,e.flex=null,this.headerView.updateIndicators(),this.rowRenderer.redrawAllRows(),this.rangeSelectionService.updateOverlay(),n&&this.eventService.dispatchEvent("columnResized",{column:e,source:"uiColumnResized",finished:!0,api:this.api})}onColumnMoved(e,t){const n=this.columnModel.getColumns(),i=n.findIndex(a=>a.colId===e);if(i<0)return;let o=n.length;t&&(o=n.findIndex(a=>a.colId===t)),this.columnModel.moveColumnByIndex(i,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,n,i,o,a,l;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}),(n=(t=this.options).onFirstDataRendered)==null||n.call(t,{api:this.api})),(o=(i=this.options).onModelUpdated)==null||o.call(i,{api:this.api}),(l=(a=this.options).onRowDataChanged)==null||l.call(a,{api:this.api})}setHorizontalScrollLeft(e){this.rowRenderer.setHorizontalScrollLeft(e)}onGridSizeChanged(){var o,a,l;if(this.destroyed)return;const e=this.eGridDiv.clientWidth,t=this.getAllColumns().some(r=>r.flex!==null&&r.flex>0&&r.visible),n=this.sideBarService.isVisible()?this.sideBarService.getElement().offsetWidth:0,i=Math.max(0,e-n);(t||((o=this.options.autoSizeStrategy)==null?void 0:o.type)==="fitGridWidth")&&(this.columnModel.sizeColumnsToFit(i),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}),(l=(a=this.options).onGridSizeChanged)==null||l.call(a,{clientWidth:e,clientHeight:this.eGridDiv.clientHeight,api:this.api})}renderDetailRow(e){var d,c;const t=e.masterNode;if(!t)return null;const n=this.options.detailRowAutoHeight===!0,i=n?this.options.detailRowHeight??200:this.options.detailRowHeight??200,o=document.createElement("div");o.className="ag-row-detail",o.style.height=`${i}px`,o.style.position="absolute",o.style.top="0",o.style.left="0",o.style.right="0";const a=this.options.detailCellRenderer,l=(d=this.options.detailCellRendererParams)==null?void 0:d.detailGridOptions,r=(c=this.options.detailCellRendererParams)==null?void 0:c.getDetailRowData;if(l&&r){const p=r({data:t.data,node:t,api:this.api}),h=document.createElement("div");h.style.height="100%",h.style.padding="8px 16px",o.appendChild(h),setTimeout(()=>{new dt(h,{...l,rowData:p,theme:this.options.theme})},0)}else if(typeof a=="function"){const p=a({data:t.data,node:t,api:this.api,context:this.context});p instanceof HTMLElement?o.appendChild(p):o.textContent=String(p??"")}else typeof a=="string"&&(o.textContent=a);if(n){const p=Math.max(40,o.scrollHeight||i);return e.rowHeight=p,o.style.height=`${p}px`,{eDetail:o,height:p}}return e.rowHeight=i,{eDetail:o,height:i}}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,n=e.rowData!==void 0&&e.rowData!==this.options.rowData,i=e.columnDefs!==void 0||e.defaultColDef!==void 0||e.columnTypes!==void 0;Object.assign(this.options,e),n&&this.setRowData(e.rowData),i&&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 Zn(this,this.eventService):this.paginationService&&this.paginationService.setEnabled(!!e.pagination))}destroy(){var e;this.destroyed||(this.destroyed=!0,this.interactions.destroy(),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 Jn(s,e){const t=new dt(s,e);return{api:t.getApi(),columnApi:t.getColumnApi(),grid:t}}function ei(s,e={}){const t=document.createElement("dialog");t.className="rowvia-detail-dialog";const n=Fe(t,"detail-dialog",e),i=()=>{var d;return(d=e.onClose)==null?void 0:d.call(e)};t.addEventListener("close",i);const o=document.createElement("h2"),a=document.createElement("dl"),l=document.createElement("button");l.type="button",l.textContent="关闭";const r=()=>t.close();return l.addEventListener("click",r),t.append(o,a,l),s.append(t),{onInteraction:n.onInteraction,open(d){var c;o.textContent=d.title,t.setAttribute("aria-label",d.title),a.replaceChildren();for(const p of d.fields){const h=document.createElement("dt"),u=document.createElement("dd");h.textContent=p.label,u.textContent=p.value,a.append(h,u)}t.open||t.showModal(),(c=e.onOpen)==null||c.call(e,d)},close:r,destroy(){t.open&&t.close(),l.removeEventListener("click",r),t.removeEventListener("close",i),n.destroy(),t.remove()}}}const Ko=[{value:"equals",label:"等于"},{value:"notEqual",label:"不等于"},{value:"contains",label:"包含"},{value:"blank",label:"为空"}],Yo=[{value:"equals",label:"等于"},{value:"greaterThan",label:"大于"},{value:"lessThan",label:"小于"},{value:"inRange",label:"介于"}],Xo=[{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 ct(s,e,t){const n=document.createElement("button");return n.type="button",n.className=e,n.textContent=s,n.addEventListener("click",i=>{i.stopPropagation(),t()}),n}class Zo{constructor(e,t,n,i){w(this,"filterFields");w(this,"sortFields");w(this,"filterRows",[]);w(this,"sorts",[]);w(this,"filterPanel",null);w(this,"sortPanel",null);w(this,"filterAnchor",null);w(this,"sortAnchor",null);w(this,"onDocumentMouseDown",e=>{var n,i;const t=e.target;this.filterPanel&&!this.filterPanel.contains(t)&&!((n=this.filterAnchor)!=null&&n.contains(t))&&this.closeFilterPanel(),this.sortPanel&&!this.sortPanel.contains(t)&&!((i=this.sortAnchor)!=null&&i.contains(t))&&this.closeSortPanel()});this.api=e,this.host=t,this.hooks=i,this.filterFields=n.filter,this.sortFields=n.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",d=>d.stopPropagation());const n=Ae("div","gt-panel-title");n.textContent="筛选",t.appendChild(n);const i=Ae("div","gt-filter-rows");t.appendChild(i);const o=()=>{if(i.textContent="",!this.filterRows.length){const d=Ae("div","gt-panel-empty");d.textContent="点击下方字段添加筛选条件",i.appendChild(d)}for(const d of this.filterRows)i.appendChild(this.renderFilterRow(d,o))},a=Ae("div","gt-filter-add");for(const d of this.filterFields)a.appendChild(ct(d.label,"gt-filter-add-btn",()=>{this.filterRows.push({colId:d.colId,kind:d.kind,type:d.kind==="date"?"inRange":"equals",value:"",valueTo:""}),o()}));t.appendChild(a);const l=Ae("div","gt-panel-hint");l.textContent="多个条件同时满足(且)",t.appendChild(l);const r=Ae("div","gt-panel-actions");r.append(ct("清除","gt-panel-btn",()=>{this.filterRows=[],this.applyFilter(),this.closeFilterPanel()}),ct("应用","gt-panel-btn gt-panel-btn-primary",()=>{this.applyFilter(),this.closeFilterPanel()})),t.appendChild(r),this.mount(t,e),this.filterPanel=t,this.filterAnchor=e,o()}renderFilterRow(e,t){const n=Ae("div","gt-filter-row"),i=this.filterFields.find(d=>d.colId===e.colId),o=document.createElement("select");o.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),o.appendChild(c)}o.addEventListener("change",()=>{const d=this.filterFields.find(c=>c.colId===o.value);d&&(e.colId=d.colId,e.kind=d.kind,e.type=d.kind==="date"?"inRange":"equals",e.value="",e.valueTo="",t())}),n.appendChild(o);const a=e.kind==="number"?Yo:e.kind==="date"?Xo:Ko,l=document.createElement("select");l.className="gt-panel-select gt-panel-select-cond";for(const d of a){const c=document.createElement("option");c.value=d.value,c.textContent=d.label,d.value===e.type&&(c.selected=!0),l.appendChild(c)}if(l.addEventListener("change",()=>{e.type=l.value,t()}),n.appendChild(l),e.type!=="blank")if(i!=null&&i.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 p of i.options){const h=document.createElement("option");h.value=p.value,h.textContent=p.label,p.value===e.value&&(h.selected=!0),d.appendChild(h)}d.addEventListener("change",()=>{e.value=d.value}),n.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}),n.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}),n.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}),n.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}),n.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}),n.appendChild(d)}const r=ct("×","gt-filter-remove",()=>{this.filterRows=this.filterRows.filter(d=>d!==e),t()});return r.title="移除条件",n.appendChild(r),n}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 n=(t.type==="after",t.value),i=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:n||void 0,dateTo:i||void 0};continue}if(t.value)if(t.kind==="number"){const n={filterType:"number",type:t.type,filter:Number(t.value)};t.type==="inRange"&&(n.filterTo=Number(t.valueTo||t.value)),e[t.colId]=n}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",l=>l.stopPropagation());const n=Ae("div","gt-panel-title");n.textContent="排序",t.appendChild(n);const i=Ae("div","gt-sort-list");t.appendChild(i);const o=()=>{var l;i.textContent="";for(const r of this.sortFields){const d=this.sorts.findIndex(u=>u.colId===r.colId),c=d>=0,p=Ae("div","gt-sort-item");c&&p.classList.add("gt-sort-item-active");const h=Ae("span","gt-sort-label");if(h.textContent=r.label,p.appendChild(h),c){const u=Ae("span","gt-sort-badge");u.textContent=String(d+1),p.appendChild(u);const f=Ae("span","gt-sort-dir");f.textContent=((l=this.sorts[d])==null?void 0:l.sort)==="asc"?"↑ 升序":"↓ 降序",p.appendChild(f)}p.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"}),o()}),i.appendChild(p)}},a=Ae("div","gt-panel-actions");a.append(ct("清除","gt-panel-btn",()=>{this.sorts=[],this.applySort(),this.closeSortPanel()}),ct("应用","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 n=t.getBoundingClientRect();e.style.top=`${n.bottom+6}px`;const i=window.innerWidth-e.offsetWidth-12;e.style.left=`${Math.max(12,Math.min(n.left,i))}px`,e.style.display="block"}destroy(){this.closeAll(),document.removeEventListener("mousedown",this.onDocumentMouseDown,!0)}closeAll(){this.closeFilterPanel(),this.closeSortPanel()}}const ti=864e5;function et(s){const e=s.getFullYear(),t=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${e}-${t}-${n}`}function Pe(s){return new Date(`${s}T00:00:00`)}function De(s,e){return new Date(s.getTime()+e*ti)}function We(s,e){const t=typeof s=="string"?Pe(s):s,n=typeof e=="string"?Pe(e):e;return Math.round((n.getTime()-t.getTime())/ti)}function Mt(){return et(new Date)}function Qo(s){return s.status!=="done"&&s.end&&s.end<Mt()&&s.progress<100?"delayed":s.status}function nn(s){const e=Pe(s);return`${e.getMonth()+1}月${e.getDate()}日`}const ni=["day","week","biweek","month","bimonth","quarter","halfyear","year"],Vt={day:"天",biweek:"双周",bimonth:"双月",halfyear:"半年",week:"周",month:"月",quarter:"季度",year:"年"},Jo={day:26,week:26,biweek:26,month:26,bimonth:13,quarter:8.7,halfyear:4.3,year:2.2};function sn(s){const e=(s.getDay()+6)%7;return De(s,-e)}function ea(s,e){const t=Math.max(1,We(s,e)+1);let n=0;for(let i=0;i<t;i++){const o=De(s,i).getDay();o!==0&&o!==6&&n++}return Math.max(1,n)}function ta(s,e){return new Date(s.getFullYear(),s.getMonth()+e,1)}function ii(s,e,t){const n=[];if(s==="day"){let r=new Date(e);for(;r<t;){const d=De(r,1);n.push({start:new Date(r),end:d,primary:`${r.getDate()}`,secondary:""}),r=d}return n}if(s==="week"||s==="biweek"){let r=sn(e);for(;r<t;){const d=De(r,s==="biweek"?14:7);n.push({start:new Date(r),end:d,primary:`${r.getMonth()+1}/${r.getDate()}`,secondary:""}),r=d}return n}const i=s==="month"?1:s==="bimonth"?2:s==="quarter"?3:s==="halfyear"?6:12,o=r=>new Date(r.getFullYear(),Math.floor(r.getMonth()/i)*i,1),a=r=>s==="month"||s==="bimonth"?`${r.getMonth()+1}月`:s==="halfyear"?`${r.getMonth()<6?"上":"下"}半年`:s==="quarter"?`Q${Math.floor(r.getMonth()/3)+1}`:`${r.getFullYear()}`;let l=o(e);for(;l<t;){const r=ta(l,i);n.push({start:new Date(l),end:r,primary:a(l),secondary:""}),l=r}return n}const Te={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)"},Gt={"not-started":"#b8bdc4","in-progress":"#3370ff",done:"#2ea121",delayed:"#f54a45"},na=4,si=6,ze=28;class oi{constructor(e,t){w(this,"interactions");w(this,"onInteraction");w(this,"options");w(this,"eRoot");w(this,"eHeader");w(this,"eRuler");w(this,"rulerCtx");w(this,"eRulerTools");w(this,"eStepLabel");w(this,"eZoomValue");w(this,"eStepMenu",null);w(this,"eScroll");w(this,"eSpacer");w(this,"eCanvas");w(this,"ctx");w(this,"eTooltip");w(this,"eTodayBadge");w(this,"ePopup",null);w(this,"tasks",[]);w(this,"tasksById",new Map);w(this,"rows",[]);w(this,"selectedId",null);w(this,"hoverId",null);w(this,"unit","day");w(this,"zoom",1);w(this,"theme","content");w(this,"epochStart",new Date);w(this,"totalDays",1);w(this,"hits",[]);w(this,"hitsByRow",new Map);w(this,"drag",null);w(this,"ghost",null);w(this,"dirty",!0);w(this,"lastLeft",-1);w(this,"lastTop",-1);w(this,"timer");w(this,"observer",null);w(this,"resizeHandler",()=>this.resizeCanvases());w(this,"showChildren",!0);w(this,"milestonesOnly",!1);w(this,"locateHits",[]);w(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)});w(this,"onScroll",()=>{this.tick()});w(this,"todayLabelX",-1);w(this,"onCanvasMouseMove",e=>{if(this.drag){this.updateDrag(e);return}const{hit:t,rowIndex:n,onAvatar:i}=this.hitAt(e.clientX,e.clientY),o=this.rows[n];i?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())});w(this,"onCanvasMouseDown",e=>{const t=this.eCanvas.getBoundingClientRect(),n=this.locateHits.find(d=>Math.abs(d.x-(e.clientX-t.left))<12&&Math.abs(d.y-(e.clientY-t.top))<12);if(n){this.scrollToTask(n.id);return}const{hit:i,rowIndex:o,onAvatar:a}=this.hitAt(e.clientX,e.clientY),l=this.rows[o];if(i){const d=this.tasksById.get(i.id);if(!d)return;if(a){e.stopPropagation(),this.openAssigneePopup(i.id,i);return}if(d.kind!=="task"||d.milestone||!d.start||!d.end){this.options.onSelect(i.id);return}e.preventDefault(),this.drag={id:i.id,mode:i.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(i.id);return}if(!l)return;const r=this.tasksById.get(l.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),p=et(De(this.epochStart,c));this.options.onTaskChange({...r,start:p,end:et(De(Pe(p),4)),progress:0,status:"not-started"}),this.options.onSelect(l.id);return}this.options.onSelect(l.id)}});w(this,"updateDrag",e=>{const t=this.drag;if(!t)return;const n=this.tasksById.get(t.id);if(!n||!t.moved&&Math.abs(e.clientX-t.startX)<na)return;t.moved=!0;const i=this.dayWidth,o=Math.round((e.clientX-t.startX)/i),a=Pe(t.originStart),l=Pe(t.originEnd),r=We(a,l);let d,c;t.mode==="resize-l"?(d=De(a,Math.min(o,r)),c=l):t.mode==="resize-r"?(d=a,c=De(l,Math.max(o,-r))):(d=De(a,o),c=De(l,o)),n.milestone&&(d=c),t.start=et(d),t.end=et(c),this.ghost={id:t.id,start:t.start,end:t.end},this.markDirty(),this.eTooltip.style.display="",this.eTooltip.textContent=n.milestone?nn(t.start):`${nn(t.start)} → ${nn(t.end)}`;const p=this.eRoot.getBoundingClientRect();this.eTooltip.style.left=`${e.clientX-p.left+12}px`,this.eTooltip.style.top=`${e.clientY-p.top+16}px`});w(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})});w(this,"onRootMouseLeave",()=>{this.closeAssigneePopup(),this.closeStepMenu(),this.hoverId&&(this.hoverId=null,this.options.onHover(null),this.markDirty())});w(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.interactions=Fe(this.eRoot,"gantt-chart",t),this.onInteraction=this.interactions.onInteraction,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 n=()=>{this.resizeCanvases(),this.markDirty()};typeof ResizeObserver<"u"&&(this.observer=new ResizeObserver(n),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;this.interactions.destroy(),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.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){e.length===this.rows.length&&e.every((t,n)=>{const i=this.rows[n];return t.id===i.id&&t.group===i.group&&t.expanded===i.expanded})||(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 Jo[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(Mt()),n=Math.max(0,t-this.eScroll.clientWidth*e);this.eScroll.scrollLeft=n}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 n=Mt();(!e||e>n)&&(e=n),(!t||t<n)&&(t=n);const i=sn(De(Pe(e),-7));this.epochStart=i,this.totalDays=Math.max(We(i,Pe(t))+730,1095)}dateX(e){return We(this.epochStart,e)*this.dayWidth}resizeCanvases(){const e=window.devicePixelRatio||1;for(const[t,n]of[[this.eCanvas,this.ctx],[this.eRuler,this.rulerCtx]]){const i=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(i*e)),t.height=Math.max(1,Math.round(o*e)),t.style.width=`${i}px`,t.style.height=`${o}px`,n.setTransform(e,0,0,e,0,0)}this.markDirty()}draw(){const e=this.dayWidth,t=this.options.rowHeight,n=this.totalDays*e,i=Math.max(this.rows.length*t,1);this.eSpacer.style.width=`${n}px`,this.eSpacer.style.height=`${i}px`,this.drawRuler(e,n),this.drawBody(e,n,i,t)}drawRuler(e,t){const n=this.rulerCtx,i=this.eHeader.clientWidth,o=this.eHeader.clientHeight,a=this.eScroll.scrollLeft;n.clearRect(0,0,i,o),n.fillStyle="#fff",n.fillRect(0,0,i,o);const l=De(this.epochStart,this.totalDays),r=(p,h,u,f)=>{for(const g of p){const v=this.dateX(et(g.start))-a,m=We(g.start,g.end)*e;if(v+m<=0||v>=i)continue;const y=Math.max(0,Math.min(v+m,i)-Math.max(0,v));if(this.unit==="day"||this.unit==="week"){const b=g.start.getDay();(b===0||b===6)&&(n.fillStyle=Te.weekend,n.fillRect(Math.max(0,v),h,y,u))}const k=n.measureText(g.primary).width;if(k+8<y){const b=Math.max(0,v)+y/2-k/2,I=h+u/2+5;n.fillStyle=Te.text,n.font="11px "+Ke,n.textAlign="left",n.textBaseline="alphabetic",n.fillText(g.primary,b,I),g.secondary&&(n.fillStyle=Te.textTertiary,n.font="10px "+Ke,n.fillText(g.secondary,b,I+12))}}},d=40,c=De(this.epochStart,Math.floor(a/e));n.fillStyle=Te.text,n.font="14px "+Ke,n.textAlign="left",n.textBaseline="middle",n.fillText(this.unit==="day"||this.unit==="week"||this.unit==="biweek"?`${c.getFullYear()}年${c.getMonth()+1}月`:`${c.getFullYear()} 年`,16,22),r(ii(this.unit,this.epochStart,l),d+1,o-d-1),n.strokeStyle=Te.border,n.beginPath(),n.moveTo(0,o-.5),n.lineTo(i,o-.5),n.stroke()}drawBody(e,t,n,i){const o=this.ctx,a=this.eScroll.clientWidth,l=this.eScroll.clientHeight,r=this.eScroll.scrollLeft,d=this.eScroll.scrollTop;o.clearRect(0,0,a,l),o.fillStyle="#fff",o.fillRect(0,0,a,l),o.save(),o.translate(-r,-d),this.hits=[],this.hitsByRow.clear(),this.drawWeekends(e,t,Math.max(n,d+l)),this.drawGridlines(e,t,Math.max(n,d+l)),this.drawRowBackgrounds(t,i);const c=this.rows.findIndex(h=>h.id===this.hoverId),p=this.hoverId?this.tasksById.get(this.hoverId):null;if(c>=0&&(p==null?void 0:p.kind)==="task"&&!p.start){const h=c*i+6;o.fillStyle="#fff",o.strokeStyle="#dee0e3",o.lineWidth=1,ut(o,r+4,h,Math.max(0,a-8),28,4),o.fill(),o.stroke(),o.fillStyle=Te.textTertiary,o.font="14px "+Ke,o.textAlign="center",o.fillText("新建排期",r+a/2,h+19)}this.drawDependencies(i),this.drawBars(i),this.drawTodayLine(t,Math.max(n,d+l)),o.restore(),this.drawTodayLabel(),this.drawLocateButtons(),this.updateRulerTools()}drawWeekends(e,t,n){if(this.unit!=="day"&&this.unit!=="week")return;const i=this.ctx;i.fillStyle=Te.weekend;let o=sn(this.epochStart);for(;We(this.epochStart,o)<this.totalDays;){const a=this.dateX(et(o))+5*e;a<t&&i.fillRect(Math.max(0,a),0,e*2,n),o=De(o,7)}}drawGridlines(e,t,n){const i=this.ctx,o=De(this.epochStart,this.totalDays);for(const a of ii(this.unit,this.epochStart,o)){const l=Math.round(this.dateX(et(a.start)))+.5;if(l<0||l>t)continue;const r=this.unit==="day"&&a.start.getDate()===1;i.strokeStyle=r?Te.gridlineMonth:Te.gridline,i.beginPath(),i.moveTo(l,0),i.lineTo(l,n),i.stroke()}}drawRowBackgrounds(e,t){const n=this.ctx;n.strokeStyle=Te.rowLine,n.lineWidth=1,n.beginPath();for(let i=1;i<this.rows.length;i++){const o=Math.round(i*t)+.5;n.moveTo(0,o),n.lineTo(e,o)}n.stroke(),this.rows.forEach((i,o)=>{const a=this.selectedId===i.id,l=this.hoverId===i.id;(a||l)&&(n.fillStyle=a?Te.selected:l?Te.hover:Te.groupRow,n.fillRect(0,o*t,e,t))})}drawTodayLine(e,t){const n=this.ctx,i=Math.round(this.dateX(Mt())+this.dayWidth/2)+.5;i<0||i>e||(n.strokeStyle=Te.accent,n.lineWidth=1.5,n.beginPath(),n.moveTo(i,0),n.lineTo(i,t),n.stroke(),this.todayLabelX=i-this.eScroll.scrollLeft)}drawTodayLabel(){this.eTodayBadge.hidden=this.todayLabelX<0||this.todayLabelX>this.eScroll.clientWidth,this.eTodayBadge.textContent=Mt().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((i,o)=>[i.id,o])),n=this.ctx;n.strokeStyle=Te.accent,n.lineWidth=1.2;for(const i of this.rows){const o=this.tasksById.get(i.id);if(!o||o.kind!=="task"||!o.start||!o.end)continue;const a=t.get(i.id);if(a!==void 0)for(const l of o.dependsOn){const r=this.tasksById.get(l),d=t.get(l);if(!(r!=null&&r.start)||!r.end||d===void 0)continue;const c=this.dateX(r.start),p=r.milestone?this.dayWidth:Math.max(We(Pe(r.start),Pe(r.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),h=c+p,u=d*e+e/2,f=this.dateX(o.start),g=Math.max(We(Pe(o.start),Pe(o.end))*this.dayWidth+this.dayWidth,this.dayWidth*.6),v=a*e+e/2,m=h+10;if(f-4>m)ai(n,h,u,m,v,f-5,v);else{const y=f+g+10;ai(n,h,u,m,v,y,v)}sa(n,f-5,v)}}}drawBars(e){this.rows.forEach((t,n)=>{const i=this.tasksById.get(t.id);if(!i||!i.start||i.path.length>1&&(!this.showChildren||this.milestonesOnly&&!i.milestone))return;const o=n*e+(e-ze)/2;if(t.group){this.drawSummaryBar(i,n,o);return}if(i.milestone){this.drawMilestone(i,n,o);return}i.end&&this.drawTaskBar(i,n,o)})}drawTaskBar(e,t,n){var u;const i=this.ctx,o=((u=this.ghost)==null?void 0:u.id)===e.id?this.ghost:null,a=(o==null?void 0:o.start)??e.start,l=(o==null?void 0:o.end)??e.end,r=this.dateX(a),d=Math.max(28,(We(a,l)+1)*this.dayWidth),c=Gt[e.status];i.save(),i.globalAlpha=this.selectedId===e.id||this.hoverId===e.id?1:.55,i.fillStyle=this.theme==="color"?"#eaf2ff":"#fff",i.strokeStyle=this.selectedId===e.id?Te.accent:"#dee0e3",i.lineWidth=1,ut(i,r,n,d,ze,4),i.fill(),i.stroke(),i.save(),ut(i,r,n,d,ze,4),i.clip(),i.beginPath(),i.arc(r+14,n+14,6,0,Math.PI*2),i.fillStyle=c,i.fill(),i.font="12px "+Ke,i.textBaseline="middle",i.textAlign="left",i.fillStyle=Te.text;const p=this.options.members.find(f=>f.id===e.owner),h=i.measureText(e.name).width;d>h+58?(i.fillText(e.name,r+26,n+14),p&&on(i,r+h+42,n+14,7,qt(p.id),p.name.slice(0,1))):p&&d>46&&on(i,r+38,n+14,7,qt(p.id),p.name.slice(0,1)),d>100&&(i.fillStyle=Te.textTertiary,i.textAlign="right",i.fillText(String(ea(Pe(a),Pe(l))),r+d-8,n+14)),i.restore(),i.restore(),this.pushHit({id:e.id,rowIndex:t,kind:"task",x:r,y:n,w:d,h:ze,mode:"move",avatar:p?{x:r+(d>h+58?h+42:38),y:n+14,r:7}:void 0})}drawSummaryBar(e,t,n){if(!e.start||!e.end)return;const i=this.tasks.filter(c=>c.path.length===e.path.length+1&&c.path.slice(0,-1).join("/")===e.path.join("/")&&c.start),o=i[0],a=this.ctx,l=this.dateX(e.start),r=Math.max(92,(We(e.start,e.end)+1)*this.dayWidth);a.fillStyle=this.theme==="color"?"#0565db":"#fff",a.strokeStyle=this.selectedId===e.id?Te.accent:"#dee0e3",a.lineWidth=1,ut(a,l,n,r,ze,4),a.fill(),a.stroke(),a.fillStyle=o?Gt[o.status]:Gt[e.status],a.beginPath(),a.arc(l+14,n+14,5,0,Math.PI*2),a.fill(),a.fillStyle=this.theme==="color"?"#fff":Te.text,a.font="11px "+Ke,a.textAlign="left",a.textBaseline="middle";const d=((o==null?void 0:o.name)??e.name)+(i.length>1?` +${i.length-1}`:"");a.fillText(ia(a,d,r-32),l+25,n+14),this.pushHit({id:e.id,rowIndex:t,kind:"summary",x:l,y:n,w:r,h:ze,mode:"move"})}drawMilestone(e,t,n){var v;const i=this.ctx,o=this.dayWidth,a=((v=this.ghost)==null?void 0:v.id)===e.id?this.ghost:null,l=a?a.start:e.start,r=Qo(e),d=Gt[r],c=this.dateX(l)+o/2;i.font="12px "+Ke;const p=i.measureText(e.name).width,h=e.owner?24:0,u=19+p+h+14,f=c-u/2;i.fillStyle="#fff",i.strokeStyle=d,i.lineWidth=1.5,ut(i,f,n,u,ze,4),i.fill(),i.stroke(),i.fillStyle=d,i.beginPath(),i.arc(f+7+3,n+ze/2,3,0,Math.PI*2),i.fill(),i.fillStyle=Te.text,i.textAlign="left",i.textBaseline="middle",i.fillText(e.name,f+14+5,n+ze/2+1);let g;if(e.owner){const m=this.options.members.find(y=>y.id===e.owner);m&&(on(i,f+u-12,n+ze/2,9,qt(m.id),m.name.slice(0,1)),g={x:f+u-12,y:n+ze/2,r:9})}this.pushHit({id:e.id,rowIndex:t,kind:"milestone",x:f,y:n,w:u,h:ze,mode:"move",avatar:g})}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,n=this.eScroll.clientWidth;this.rows.forEach((i,o)=>{const a=this.tasksById.get(i.id);if(!(a!=null&&a.start)||!a.end||a.path.length>1&&(!this.showChildren||this.milestonesOnly&&!a.milestone))return;const l=this.dateX(a.start),r=this.dateX(a.end)+this.dayWidth;if(r>=t&&l<=t+n)return;const d=r<t?10:n-18,c=o*this.options.rowHeight-this.eScroll.scrollTop+this.options.rowHeight/2;c<0||c>this.eScroll.clientHeight||(e.fillStyle="#8f959e",ut(e,d-5,c-6,13,13,3),e.fill(),e.font="12px "+Ke,e.textAlign="center",e.textBaseline="middle",e.fillStyle="#fff",e.fillText(r<t?"‹":"›",d+1,c),this.locateHits.push({id:a.id,x:d+1,y:c}))})}pointAt(e,t){const n=this.eScroll.getBoundingClientRect();return{x:e-n.left+this.eScroll.scrollLeft,y:t-n.top+this.eScroll.scrollTop}}hitAt(e,t){const n=this.pointAt(e,t),i=Math.floor(n.y/this.options.rowHeight),o=this.hitsByRow.get(i)??[];for(const a of o){if(a.avatar){const l=n.x-a.avatar.x,r=n.y-a.avatar.y;if(l*l+r*r<=a.avatar.r*a.avatar.r)return{hit:a,rowIndex:i,onAvatar:!0}}if(n.x>=a.x&&n.x<=a.x+a.w&&n.y>=a.y&&n.y<=a.y+a.h){const l=a.kind==="task"&&n.x<=a.x+si,r=a.kind==="task"&&n.x>=a.x+a.w-si;return{hit:{...a,mode:l?"resize-l":r?"resize-r":"move"},rowIndex:i,onAvatar:!1}}}return{hit:null,rowIndex:i,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=Vt[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 n=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 i=this.toolButton("+","放大",()=>this.zoomBy(.25));this.eRulerTools.append(n,i),this.eRulerTools.append(this.toolButton("今天","回到今天",()=>this.scrollToToday()),this.toolButton("‹","向左翻页",()=>this.pageBy(-.8)),this.toolButton("›","向右翻页",()=>this.pageBy(.8)))}toolButton(e,t,n){const i=document.createElement("button");return i.type="button",i.className="gt-ruler-btn gt-ruler-icon",e==="今天"&&(i.className="gt-ruler-btn gt-ruler-today"),i.textContent=e,i.title=t,i.addEventListener("click",o=>{o.stopPropagation(),n()}),i}zoomBy(e){this.setZoom(this.zoom+e)}pageBy(e){const t=this.totalDays*this.dayWidth-this.eScroll.clientWidth,n=this.eScroll.scrollLeft+this.eScroll.clientWidth*e;this.eScroll.scrollLeft=Math.max(0,Math.min(t,n))}toggleStepMenu(){if(this.eStepMenu){this.closeStepMenu();return}const e=document.createElement("div");e.className="gt-step-menu";for(const i of ni){const o=document.createElement("div");o.className="gt-step-item",o.setAttribute("role","menuitemradio"),o.setAttribute("aria-checked",String(i===this.unit)),o.tabIndex=0,o.addEventListener("keydown",a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),this.setUnit(i),this.closeStepMenu())}),i===this.unit&&o.classList.add("gt-step-item-active"),o.textContent=Vt[i],o.addEventListener("click",a=>{a.stopPropagation(),this.setUnit(i),this.closeStepMenu()}),e.appendChild(o)}const t=this.eRulerTools.getBoundingClientRect(),n=this.eRoot.getBoundingClientRect();e.style.right=`${Math.max(0,n.right-t.right)}px`,e.style.top=`${t.bottom-n.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=Vt[this.unit],this.eZoomValue.textContent=`${Math.round(this.zoom*100)}%`}openAssigneePopup(e,t){this.closeAssigneePopup();const n=this.tasksById.get(e);if(!n)return;const i=document.createElement("div");i.className="gt-popup";const o=document.createElement("div");o.className="gt-popup-title",o.textContent="更换负责人",i.appendChild(o);for(const d of this.options.members){const c=document.createElement("div");c.className="gt-popup-item",n.owner===d.id&&c.classList.add("gt-popup-item-active");const p=document.createElement("span");p.className="gt-avatar",p.textContent=d.name.slice(0,1),p.style.backgroundColor=qt(d.id);const h=document.createElement("span");h.textContent=d.name,c.append(p,h),c.addEventListener("click",u=>{u.stopPropagation(),this.closeAssigneePopup(),this.options.onAssign(e,d.id)}),i.appendChild(c)}if(n.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)}),i.appendChild(d)}const a=this.eRoot.getBoundingClientRect(),l=t.x+t.w-this.eScroll.scrollLeft,r=t.y-this.eScroll.scrollTop;i.style.left=`${Math.min(a.width-150,Math.max(0,l-40))}px`,i.style.top=`${r+t.h+6}px`,this.eRoot.appendChild(i),this.ePopup=i,document.addEventListener("mousedown",this.onDocumentMouseDown)}closeAssigneePopup(){var e;(e=this.ePopup)==null||e.remove(),this.ePopup=null,document.removeEventListener("mousedown",this.onDocumentMouseDown)}}const Ke="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Roboto, Helvetica, Arial, sans-serif";function ut(s,e,t,n,i,o){const a=Math.max(0,n),l=Math.max(0,i);if(a===0||l===0)return;const r=Math.max(0,Math.min(o,a/2,l/2));s.beginPath(),s.moveTo(e+r,t),s.lineTo(e+a-r,t),s.arcTo(e+a,t,e+a,t+r,r),s.lineTo(e+a,t+l-r),s.arcTo(e+a,t+l,e+a-r,t+l,r),s.lineTo(e+r,t+l),s.arcTo(e,t+l,e,t+l-r,r),s.lineTo(e,t+r),s.arcTo(e,t,e+r,t,r),s.closePath()}function on(s,e,t,n,i,o){s.beginPath(),s.arc(e,t,n,0,Math.PI*2),s.fillStyle=i,s.fill(),s.lineWidth=1.5,s.strokeStyle="#fff",s.stroke(),s.fillStyle="#fff",s.font=`10px ${Ke}`,s.textAlign="center",s.textBaseline="middle",s.fillText(o,e,t+1)}function ia(s,e,t){if(t<=0)return"";if(s.measureText(e).width<=t)return e;let n=e.length;for(;n>1;){n--;const i=`${e.slice(0,n)}…`;if(s.measureText(i).width<=t)return i}return"…"}function ai(s,e,t,n,i,o,a){const r=i>t?1:-1;s.beginPath(),s.moveTo(e,t),s.lineTo(n-5,t),s.quadraticCurveTo(n,t,n,t+5*r),s.lineTo(n,i-5*r),s.quadraticCurveTo(n,i,n+5*r,i),s.lineTo(o,a),s.stroke()}function sa(s,e,t){s.fillStyle=Te.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 ri=["#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 ri[e%ri.length]}const oa={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 aa(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>`,s.append(t);const
|
|
34
|
+
</div>`,s.append(t);const n=Fe(t,"gantt",e),i=e.onTaskOpen?null:ei(t),o=L=>t.querySelector(L);o(".gantt-title-name").textContent=e.title??"甘特图";let a=structuredClone(e.tasks),l=new Map(a.map(L=>[L.id,L])),r=null,d,c=!0,p=!1;const h=o(".gantt-left");h.style.width=`${e.tableWidth??280}px`;const u=new AbortController,f=u.signal,g=o(".gantt-status");function v(){if(!d||p)return;r!==a&&(y.setTasks(a),r=a);const L=Array.from({length:d.getDisplayedRowCount()},(R,$)=>d.getDisplayedRowAtIndex($)).filter(Boolean);y.setRows(L.map(R=>({id:R.id,group:!!R.group,expanded:!!R.expanded})));const H=a.filter(R=>R.path.length===1),T=H.filter(R=>R.status==="done").length;g.textContent=`总工作项数 ${H.length} 完成进度 ${H.length?Math.round(T/H.length*100):0}%`}function m(L){var R;a=a.map($=>$.id===L.id?{...L}:$),l=new Map(a.map($=>[$.id,$]));const H=[L];let T=L.path.slice(0,-1);for(;T.length;){const $=a.find(he=>he.path.join("/")===T.join("/"));if(!$)break;const z=a.filter(he=>he.path.length===T.length+1&&he.path.slice(0,-1).join("/")===T.join("/")),j=z.flatMap(he=>he.start?[he.start]:[]).sort(),te=z.flatMap(he=>he.end?[he.end]:[]).sort();$.start=j[0]??null,$.end=te[te.length-1]??null,H.push($),T=T.slice(0,-1)}d.applyTransaction({update:H}),v(),(R=e.onTaskChange)==null||R.call(e,structuredClone(L))}const y=new oi(o(".gantt-right"),{members:e.members??[],rowHeight:40,onSelect:L=>{var T;y.setSelected(L);const H=L?d==null?void 0:d.getRowNode(L):null;H&&((T=d.selectNode)==null||T.call(d,H,!0))},onHover:L=>{var H;t.querySelectorAll(".ag-row-hover").forEach(T=>T.classList.remove("ag-row-hover")),L&&((H=Array.from(t.querySelectorAll(".ag-row")).find(T=>T.dataset.rowid===L))==null||H.classList.add("ag-row-hover"))},onTaskChange:m,onAssign:(L,H)=>{const T=l.get(L);T&&m({...T,owner:H})}});function k(L){const H=L.data,T=document.createElement("span");if(T.className="gt-task-name",H.path.length>1?T.classList.add("gt-child-name"):L.node.group||T.classList.add("gt-root-leaf"),H.path.length>1){const $=document.createElement("span");$.className=`gt-node-dot gt-node-${H.status}`,T.append($)}const R=document.createElement("button");return R.className="gt-title-link",R.textContent=H.name,R.title=H.name,R.addEventListener("click",()=>{y.scrollToTask(H.id),e.onTaskOpen?e.onTaskOpen(structuredClone(H)):i==null||i.open({title:H.name,fields:[{label:"排期",value:`${H.start??"未设置"} — ${H.end??"未设置"}`}]})}),T.append(R),T}const C=document.createElement("button");C.className="gt-tree-toggle",C.textContent="▾",C.title="收起全部子层级",C.setAttribute("aria-label",C.title);function b(L){c=L,L?d.expandAll():d.collapseAll(),C.textContent=L?"▾":"▸",C.title=L?"收起全部子层级":"展开全部子层级",C.setAttribute("aria-label",C.title),v()}C.addEventListener("click",()=>b(!c));const I=["name","status","start","end","owner","progress"].map(L=>({field:L,hide:!0,filter:!0})),A=new dt(o(".grid"),{columnDefs:I,rowData:a,treeData:!0,getDataPath:L=>L.path,getRowId:L=>L.data.id,groupDefaultExpanded:-1,includeHiddenColumnsInQuickFilter:!0,rowHeight:40,headerHeight:80,rowSelection:"single",localeText:oa,suppressContextMenu:!0,autoGroupColumnDef:{headerName:"标题",width:e.tableWidth??280,minWidth:100,suppressMenu:!0,sortable:!1,resizable:!1,headerComponent:()=>{const L=document.createElement("div");return L.className="gt-title-header",L.append(C,document.createTextNode("标题")),L},cellRenderer:"agGroupCellRenderer",cellRendererParams:{suppressCount:!0,innerRenderer:k}},onGridReady:L=>{d=L.api,v()},onModelUpdated:L=>{d=L.api,v()},onRowGroupOpened:v,onRowClicked:L=>{var H;return y.setSelected(((H=L.node)==null?void 0:H.id)??null)}});d=A.getApi();const E=o(".ag-body-viewport");let G=!1;const x=(L,H)=>{G||(G=!0,H.scrollTop=L.scrollTop,G=!1)};E.addEventListener("scroll",()=>x(E,y.scrollElement),{signal:f}),y.scrollElement.addEventListener("scroll",()=>x(y.scrollElement,E),{signal:f}),E.addEventListener("mousemove",L=>{const H=L.target.closest(".ag-row");y.setHover((H==null?void 0:H.dataset.rowid)??null)},{signal:f}),E.addEventListener("mouseleave",()=>y.setHover(null),{signal:f});const M=new Zo(d,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:L=>o('[data-action="filter"]').classList.toggle("gt-btn-active",L),onSortButton:L=>o('[data-action="sort"]').classList.toggle("gt-btn-active",L)});o('[data-action="filter"]').addEventListener("click",L=>M.openFilterPanel(L.currentTarget),{signal:f}),o('[data-action="sort"]').addEventListener("click",L=>M.openSortPanel(L.currentTarget),{signal:f}),o('[type="search"]').addEventListener("input",L=>d.setQuickFilter(L.target.value),{signal:f});const N=o(".gt-settings"),P=o('[data-action="settings"]');P.addEventListener("click",()=>{N.hidden=!N.hidden,P.setAttribute("aria-expanded",String(!N.hidden))},{signal:f}),document.addEventListener("pointerdown",L=>{!N.contains(L.target)&&!P.contains(L.target)&&(N.hidden=!0,P.setAttribute("aria-expanded","false"))},{signal:f});const _=Math.random().toString(36).slice(2);return N.querySelectorAll('[type="radio"]').forEach(L=>{const H=L.name;L.name=H+_,L.addEventListener("change",()=>{H==="theme"?y.setTheme(L.value):y.setMilestonesOnly(L.value==="milestones")},{signal:f})}),o('[data-setting="children"]').addEventListener("change",L=>y.setShowChildren(L.target.checked),{signal:f}),t.addEventListener("keydown",L=>{L.key==="Escape"&&(N.hidden=!0,M.closeAll())},{signal:f}),v(),e.unit&&y.setUnit(e.unit),y.scrollToToday(.5),{onInteraction:n.onInteraction,grid:d,chart:y,expandAll:()=>b(!0),collapseAll:()=>b(!1),scrollToTask:L=>y.scrollToTask(L),setTasks(L){a=structuredClone(L),l=new Map(a.map(H=>[H.id,H])),d.setRowData(a),v()},destroy(){p||(p=!0,u.abort(),M.destroy(),i==null||i.destroy(),y.destroy(),A.destroy(),n.destroy(),t.remove())}}}const ht={pending:{key:"pending",label:"未开始",className:"pending"},inProgress:{key:"inProgress",label:"进行中",className:"in-progress"},done:{key:"done",label:"已完成",className:"done"},failed:{key:"failed",label:"未通过",className:"failed"}},li={auto:"自动完成",and:"单人确认(并签)",or:"多人确认(会签)"};function an(s){const e=[{id:"owner",label:"已填写节点负责人",met:!!s.owner,fixLabel:"去填写",detail:"对应配置:节点字段必填 › 完成负责人"},{id:"schedule",label:"已填写排期与估分",met:!!(s.schedule&&s.estimate),fixLabel:"去填写",detail:s.milestone?"里程碑节点只需截止时间":"对应配置:节点字段必填 › 完成节点排期与估分"}];for(const t of s.form??[])t.required&&e.push({id:`form:${t.id}`,label:`节点表单「${t.label}」已填写`,met:!!(t.value&&String(t.value).trim()),fixLabel:"去填写",detail:"对应配置:完成表单"});for(const t of s.gates??[])e.push(t);return e}const di=s=>s.every(e=>e.met);function ci(s){const e=s.nodes.length,t=s.nodes.filter(a=>a.status==="done").length,n=s.nodes.filter(a=>a.status==="failed").length,i=s.nodes.filter(a=>a.status==="inProgress").length,o=Math.max(1,s.nodes.findIndex(a=>a.status==="inProgress")+1);return{total:e,done:t,current:i,failed:n,index:o}}function ra(s,e){const t=s.filter(i=>i.groupId===e.id);return{done:t.filter(i=>i.status==="done").length,total:t.length}}function ui(s){var t;const e=new Map;for(const n of s.groups)e.set(n.id,[]);for(const n of s.nodes){const i=n.groupId??((t=s.groups[0])==null?void 0:t.id);e.has(i)||e.set(i,[]),e.get(i).push(n)}return s.groups.map(n=>({group:n,nodes:e.get(n.id)??[]})).filter(n=>n.nodes.length>0)}function rn(s,e){const t=e.trim().toLowerCase();return t?new Set(s.nodes.filter(n=>n.name.toLowerCase().includes(t)).map(n=>n.id)):new Set(s.nodes.map(n=>n.id))}const la=.4,da=1.8,hi=.2;function pi(s,e){const t=document.createElement("div"),n=new je;t.className="rowvia-nf-canvas",t.innerHTML=`
|
|
35
35
|
<div class="rowvia-nf-canvas-toolbar">
|
|
36
36
|
<span class="rowvia-nf-legend" data-legend></span>
|
|
37
37
|
<span class="rowvia-nf-space"></span>
|
|
@@ -44,58 +44,68 @@ ${m}
|
|
|
44
44
|
<div class="rowvia-nf-canvas-sizer" data-sizer>
|
|
45
45
|
<div class="rowvia-nf-canvas-surface" data-surface></div>
|
|
46
46
|
</div>
|
|
47
|
-
</div>`,s.append(t);const
|
|
48
|
-
<span class="rowvia-nf-node-name">${
|
|
49
|
-
<span class="rowvia-nf-node-note">未显示 · ${
|
|
50
|
-
</span>`;const
|
|
47
|
+
</div>`,s.append(t);const i=Fe(t,"flow-canvas",e),o=t.querySelector("[data-viewport]"),a=t.querySelector("[data-sizer]"),l=t.querySelector("[data-surface]"),r=t.querySelector("[data-zoom]"),d=t.querySelector("[data-legend]");let c=e.flow,p=e.selectedNodeId,h=e.query??"",u=1;const f=(x,M,N)=>{if(x.hiddenReason)return`<span class="rowvia-nf-node is-hidden" title="${D(x.hiddenReason)}">
|
|
48
|
+
<span class="rowvia-nf-node-name">${D(x.name)}</span>
|
|
49
|
+
<span class="rowvia-nf-node-note">未显示 · ${D(x.hiddenReason)}</span>
|
|
50
|
+
</span>`;const P=ht[x.status],_=N==="right"&&x.info?`<span class="rowvia-nf-node-info">${D(x.info)}</span>`:"",L=N!=="none"&&(x.progress!==void 0||x.delayed)?[`
|
|
51
51
|
<span class="rowvia-nf-node-sub">
|
|
52
|
-
${
|
|
53
|
-
${
|
|
52
|
+
${x.progress!==void 0?`<span class="rowvia-nf-progress"><i style="width:${x.progress}%"></i></span>${x.progress}%`:""}
|
|
53
|
+
${x.delayed?'<em class="rowvia-nf-delay">延期</em>':""}
|
|
54
54
|
</span>`].join(""):"";return`<button type="button"
|
|
55
|
-
class="rowvia-nf-node status-${
|
|
56
|
-
data-node-id="${
|
|
57
|
-
aria-pressed="${p===
|
|
58
|
-
title="${
|
|
55
|
+
class="rowvia-nf-node status-${P.className} ${p===x.id?"is-selected":""} ${M?"is-dimmed":""} ${x.milestone?"is-milestone":""}"
|
|
56
|
+
data-node-id="${D(x.id)}"
|
|
57
|
+
aria-pressed="${p===x.id}"
|
|
58
|
+
title="${D(x.name)} · ${D(P.label)}${x.milestone?" · 里程碑":""}">
|
|
59
59
|
<span class="rowvia-nf-node-dot" aria-hidden="true"></span>
|
|
60
|
-
<span class="rowvia-nf-node-name">${
|
|
61
|
-
${
|
|
62
|
-
${
|
|
63
|
-
${
|
|
64
|
-
</button>`},g=()=>{var
|
|
60
|
+
<span class="rowvia-nf-node-name">${D(x.name)}</span>
|
|
61
|
+
${x.milestone?'<span class="rowvia-nf-node-flag" title="里程碑:仅可填写截止时间">◆</span>':""}
|
|
62
|
+
${_}
|
|
63
|
+
${L}
|
|
64
|
+
</button>`},g=()=>{var N;const x=rn(c,h),M=((N=c.infoField)==null?void 0:N.position)??"none";d.textContent=c.infoField?`显示:${c.infoField.label} · 位置:${M==="right"?"右侧":M==="below"?"下方":"不显示"}`:"未配置流程图展示信息",l.innerHTML=ui(c).map(({group:P,nodes:_})=>{const L=ra(c.nodes,P),H=P.layout==="parallel",T=_.map((z,j)=>{const te=f(z,!x.has(z.id),M);return H?te:`${j?'<i class="rowvia-nf-edge" aria-hidden="true"></i>':""}${te}`}).join(""),R=c.groups[c.groups.indexOf(P)+1],$=H?`<div class="rowvia-nf-fan"><span>并行 ${_.length} 路</span><span>全部完成 → ${D((R==null?void 0:R.name)??"结束")}</span></div>`:"";return`<section class="rowvia-nf-group" data-group="${D(P.id)}">
|
|
65
65
|
<header class="rowvia-nf-group-head">
|
|
66
|
-
<strong>${
|
|
67
|
-
<em>${
|
|
66
|
+
<strong>${D(P.name)}</strong>
|
|
67
|
+
<em>${L.done}/${L.total}</em>
|
|
68
68
|
</header>
|
|
69
|
-
<div class="rowvia-nf-lane ${
|
|
70
|
-
${
|
|
71
|
-
</section>`}).join(""),v()},v=()=>{l.style.transform=`scale(${u})`,r.textContent=`${Math.round(u*100)}%`,a.style.width=`${l.scrollWidth*u}px`,a.style.height=`${l.scrollHeight*u}px`},m=E=>{var x;u=Math.min(jo,Math.max(Uo,Math.round(E*100)/100)),v(),(x=e.onZoomChange)==null||x.call(e,u)},C=()=>{const E=l.scrollWidth||1,x=o.clientWidth-8;m(x/E),o.scrollTo({left:0,top:0})},S=E=>{var k;const x=E.target.closest("[data-node-id],[data-action]");if(!(!x||!t.contains(x))){if(x.dataset.nodeId){(k=e.onSelectNode)==null||k.call(e,x.dataset.nodeId);return}x.dataset.action==="fit"&&C(),x.dataset.action==="zoom-in"&&m(u+Ji),x.dataset.action==="zoom-out"&&m(u-Ji)}};t.addEventListener("click",S);const b=E=>{!E.ctrlKey&&!E.metaKey||(E.preventDefault(),m(u+(E.deltaY<0?.1:-.1)))};o.addEventListener("wheel",b,{passive:!1});let y=null;const R=E=>{E.target.closest("button")||(y={x:E.clientX,y:E.clientY,left:o.scrollLeft,top:o.scrollTop},o.setPointerCapture(E.pointerId),o.classList.add("is-panning"))},M=E=>{y&&(o.scrollLeft=y.left-(E.clientX-y.x),o.scrollTop=y.top-(E.clientY-y.y))},T=()=>{y=null,o.classList.remove("is-panning")};o.addEventListener("pointerdown",R),o.addEventListener("pointermove",M),o.addEventListener("pointerup",T),o.addEventListener("pointercancel",T);const W=typeof ResizeObserver<"u"?new ResizeObserver(v):null;return W==null||W.observe(o),g(),{onInteraction:n.onInteraction,update(E){const x=E.flow!==void 0||E.hiddenHints!==void 0;if(E.flow&&(c=E.flow),E.selectedNodeId!==void 0&&(p=E.selectedNodeId),E.query!==void 0&&(f=E.query),E.hiddenHints&&(e.hiddenHints=E.hiddenHints),E.onZoomChange!==void 0&&(e.onZoomChange=E.onZoomChange),E.onSelectNode!==void 0&&(e.onSelectNode=E.onSelectNode),x)g();else{const k=Qt(c,f);for(const $ of l.querySelectorAll("[data-node-id]")){const q=$.dataset.nodeId===p;$.classList.toggle("is-selected",q),$.classList.toggle("is-dimmed",!k.has($.dataset.nodeId)),$.setAttribute("aria-pressed",String(q))}}},focusNode(E){const x=Array.from(l.querySelectorAll("[data-node-id]")).find(k=>k.dataset.nodeId===E);x==null||x.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}),x==null||x.classList.add("is-pulsing"),i.timeout(()=>x==null?void 0:x.classList.remove("is-pulsing"),900)},fit:C,getZoom:()=>u,destroy(){W==null||W.disconnect(),t.removeEventListener("click",S),o.removeEventListener("wheel",b),n.destroy(),i.destroy(),t.remove()}}}function Ko(s){const e=[{id:"schedule",label:"总排期",value:s.schedule,source:"系统字段 · 排期",permission:"节点负责人、管理员"},{id:"estimate",label:"估分",value:s.estimate,source:"系统字段 · 估分",permission:"节点负责人、管理员"},{id:"worklog",label:"实际工时",value:s.worklog??"—",source:"系统字段 · 实际工时"}],t=s.progress!==void 0?[{id:"progress",label:"进度",value:s.progress+"%",percent:s.progress,writeMode:s.progressMode,group:"progress",source:"节点进度"}]:[],i=[{id:"conclusion",label:"整体完成结论",value:s.conclusion,source:"节点完成结论与意见",permission:"独立填写或按负责人结论汇总"},{id:"opinion",label:"整体完成意见",value:s.opinion,source:"节点完成结论与意见"}],n=(s.fields??[]).filter(a=>a.group!=="schedule");return[{key:"schedule",title:"排期与工作量",fields:e},{key:"progress",title:"进度",fields:t},{key:"conclusion",title:"结论与意见",fields:i},{key:"custom",title:"自定义字段",fields:n}].filter(a=>a.fields.length>0)}function Yo(s,e,t){var a;const i=!t&&!e.readonly,n=[];e.group==="progress"?(n.push('<span class="rowvia-nf-progress is-large"><i style="width:'+(e.percent??0)+'%"></i></span>',"<b>"+H(e.value)+"</b>"),e.writeMode&&n.push('<em class="rowvia-nf-mode">'+H(e.writeMode)+"</em>")):i&&e.id==="conclusion"&&((a=s.conclusionOptions)!=null&&a.length)?n.push('<select data-field="'+H(e.id)+'" aria-label="'+H(e.label)+'"><option value="">请选择</option>'+s.conclusionOptions.map(l=>"<option"+(l===e.value?" selected":"")+">"+H(l)+"</option>").join("")+"</select>"):i?n.push('<input data-field="'+H(e.id)+'" value="'+H(e.value??"")+'" placeholder="待填" aria-label="'+H(e.label)+'">'):n.push('<span class="rowvia-nf-value'+(e.value?"":" is-empty")+'">'+H(e.value||"待填")+"</span>");const o=[e.source,e.permission?"可编辑:"+e.permission:""].filter(Boolean).join(" · ");return'<div class="rowvia-nf-field"><label>'+H(e.label)+'</label><div class="rowvia-nf-field-control">'+n.join("")+'</div><button type="button" class="rowvia-nf-info" data-info="'+H(o)+'" aria-label="字段来源">ⓘ</button></div>'}function Xo(s){const e=s.filter(i=>i.met).length,t=s.map(i=>{const n=i.met?"":'<button type="button" class="rowvia-nf-fix" data-'+(i.viewLink?'gate-view="'+H(i.id)+'"':'gate-fix="'+H(i.id)+'"')+">"+H(i.fixLabel??"去填写")+"</button>";return'<li class="'+(i.met?"is-met":"is-unmet")+'"><i aria-hidden="true">'+(i.met?"✓":"✕")+"</i><span>"+H(i.label)+(i.detail?"<small>"+H(i.detail)+"</small>":"")+"</span>"+n+"</li>"}).join("");return'<section class="rowvia-nf-gates" data-gates><h4>完成前需满足 <em>'+e+"/"+s.length+"</em></h4><ul>"+t+"</ul></section>"}function Zo(s,e){const t=s.tasks??[],i=e?"":'<button type="button" class="rowvia-nf-link" data-action="add-task">+ 新增任务</button>';if(!t.length)return'<section class="rowvia-nf-tasks is-empty"><h4>全部任务 (0/0)</h4><p>暂无子任务'+(e?"":'<button type="button" data-action="add-task">+ 新增任务</button>')+"</p></section>";const n=t.filter(a=>a.done).length,o=t.map(a=>{const l=a.deliverable?'<span class="rowvia-nf-deliverable">📎 '+H(a.deliverable)+"</span>":'<span class="rowvia-nf-value is-empty">暂无</span>';return'<tr class="'+(a.done?"is-done":"")+'"><td><label class="rowvia-nf-check"><input type="checkbox" data-task="'+H(a.id)+'"'+(a.done?" checked":"")+(e?" disabled":"")+"><span>"+H(a.name)+"</span></label>"+(a.blocking?'<em class="rowvia-nf-blocker" title="未完成前主节点无法流转">阻塞项</em>':"")+"</td><td>"+l+"</td><td>"+H(a.owner||"暂无")+"</td><td>"+H(a.estimate||"暂无")+"</td><td>"+H(a.schedule||"暂无")+"</td></tr>"}).join("");return'<section class="rowvia-nf-tasks"><h4>全部任务 ('+n+"/"+t.length+")"+i+"</h4><table><thead><tr><th>名称</th><th>交付物</th><th>当前负责人</th><th>估分</th><th>排期</th></tr></thead><tbody>"+o+"</tbody></table></section>"}function Qo(s,e){const t=s.form??[];if(!t.length)return"";const i=t.filter(r=>r.required).length,n=t.filter(r=>r.required&&!r.value).length,o=t.map(r=>{var c;let d;return!e&&r.type==="select"&&((c=r.options)!=null&&c.length)?d='<select data-form="'+H(r.id)+'" aria-label="'+H(r.label)+'"><option value="">请选择</option>'+r.options.map(p=>"<option"+(p===r.value?" selected":"")+">"+H(p)+"</option>").join("")+"</select>":!e&&r.type==="date"?d='<input type="date" data-form="'+H(r.id)+'" value="'+H(r.value??"")+'" aria-label="'+H(r.label)+'">':e?d='<span class="rowvia-nf-value'+(r.value?"":" is-empty")+'">'+H(r.value||"待填")+"</span>":d='<input data-form="'+H(r.id)+'" value="'+H(r.value??"")+'" placeholder="'+H(r.placeholder??"待填")+'" aria-label="'+H(r.label)+'">','<div class="rowvia-nf-form-row"><label>'+H(r.label)+(r.required?"<b>*</b>":"")+'</label><div class="rowvia-nf-field-control">'+d+"</div></div>"}).join(""),a=n?'<em class="rowvia-nf-warn">'+n+" 项必填未完成</em>":"",l="节点表单 · "+t.length+" 项"+(i?"("+i+" 必填)":"")+a;return'<section class="rowvia-nf-form'+(n?" has-pending":"")+'"><h4>'+l+"</h4>"+o+"</section>"}function Jo(s){const e=s.events??[];if(!e.length)return"";const t=(o,a)=>a.length?"<span><b>"+o+"</b>"+a.map(l=>H(l.text)).join(";")+"</span>":"",i=e.filter(o=>o.trigger==="arrive"),n=e.filter(o=>o.trigger==="complete");return'<section class="rowvia-nf-events"><details><summary>ℹ 节点事件('+e.length+' 条规则已生效)</summary><div class="rowvia-nf-events-body">'+t("到达本节点时:",i)+t("完成本节点时:",n)+"<p>事件规则由流程模板配置,回滚节点至到达/完成之前的状态可解除限制。</p></div></details></section>"}function tn(s,e){const t=document.createElement("div"),i=new Ge;t.className="rowvia-nf-card",s.append(t);const n=xe(t,"node-card",e);let o=e.node??null,a={...e},l=!1;const r=()=>{var E;if(!o){t.innerHTML='<div class="rowvia-nf-empty">在上方流程画布中选择一个节点,查看它的字段、表单与通行条件。</div>';return}const f=!!a.readonly,u=at[o.status],h=Zt(o),g=o.completionMode?Yi[o.completionMode]:"",v=Ko(o),m=(o.buttons??[]).filter(x=>(x.placement??"inline")==="inline"),C=(o.buttons??[]).filter(x=>x.placement==="more"),S=(x,k,$="")=>'<span class="rowvia-nf-chip '+k+'"'+($?' title="'+H($)+'"':"")+">"+H(x)+"</span>",b=(x,k,$,q="",F=!1)=>'<button type="button" class="rowvia-nf-btn '+$+'" data-action="'+H(x)+'"'+(q?' title="'+H(q)+'"':"")+(F?" disabled":"")+">"+H(k)+"</button>",y=[];if(!f){o.status==="inProgress"&&y.push(b("complete","完成","is-primary")),o.status==="failed"&&y.push(b("resubmit","重新提交","is-primary")),(o.status==="done"||o.status==="failed")&&y.push(b("rollback","回滚","is-ghost","将节点状态回退至进行中")),y.push(b("transfer","转办","is-ghost","将负责人转交他人"));for(const x of m){const k=[x.hint,(E=x.roles)!=null&&E.length?"授权:"+x.roles.join("、"):""].filter(Boolean).join(" · "),$=x.variant==="primary"?"is-primary":x.variant==="warning"?"is-warning":"is-ghost";y.push(b("custom:"+x.id,x.label,$,k))}y.push('<button type="button" class="rowvia-nf-btn is-icon" data-action="more" aria-haspopup="menu" aria-expanded="'+String(l)+'">···</button>')}const R='<span class="rowvia-nf-owner">负责人 '+H(o.owner||"待填")+(o.ownerSource?"<em>"+H(o.ownerSource)+"</em>":"")+"</span>",M='<div class="rowvia-nf-menu" data-menu'+(l?"":" hidden")+' role="menu"><button type="button" role="menuitem" data-action="estimate">填写估分</button><button type="button" role="menuitem" data-action="group-chat">节点建群</button>'+C.map(x=>'<button type="button" role="menuitem" data-action="custom:'+H(x.id)+'">'+H(x.label)+"</button>").join("")+'<button type="button" role="menuitem" class="is-danger" data-action="delete-node"'+(o.deleteRoles?' title="允许删除:'+H(o.deleteRoles.join("、"))+'"':"")+">删除节点</button></div>",T='<header class="rowvia-nf-card-head"><span class="rowvia-nf-dot status-'+u.className+'" aria-hidden="true"></span><h3>'+H(o.name)+"</h3>"+S(u.label,"status-"+u.className)+(g?S(g,"is-mode","对应配置:完成方式"):"")+(o.milestone?S("◆ 里程碑"+(o.deadline?" · "+o.deadline:""),"is-milestone","里程碑:仅可填写截止时间"):"")+R+'<span class="rowvia-nf-space"></span><div class="rowvia-nf-actions">'+y.join("")+"</div>"+M+"</header>",W=v.map(x=>'<div class="rowvia-nf-field-group" data-section="'+x.key+'"><h5>'+H(x.title)+"</h5>"+x.fields.map(k=>Yo(o,k,f)).join("")+"</div>").join("");t.innerHTML=T+Xo(h)+'<details class="rowvia-nf-section" open><summary>节点字段 <em>'+v.length+" 组</em></summary>"+W+"</details>"+Qo(o,f)+Zo(o,f)+Jo(o)},d=f=>{var g,v,m,C,S;const u=f.target.closest("[data-action],[data-gate-fix],[data-gate-view],[data-info]");if(!u||!t.contains(u))return;if(u.dataset.info){i.add(nn(u,u.dataset.info));return}if(u.dataset.gateFix||u.dataset.gateView){p(),(g=a.onAction)==null||g.call(a,u.dataset.gateView?"open-gate-view":"fix-gate",(o==null?void 0:o.id)??"");return}const h=u.dataset.action;if(h){if(h==="more"){const b=t.querySelector("[data-menu]");if(!b)return;l=b.hidden,b.hidden=!l,u.setAttribute("aria-expanded",String(l));return}if(h==="complete"){const b=o?Zt(o):[];if(!Xi(b)){p(),(v=a.onAction)==null||v.call(a,"complete-blocked",(o==null?void 0:o.id)??"");return}if(((m=a.onComplete)==null?void 0:m.call(a,(o==null?void 0:o.id)??"",b))===!1)return;(C=a.onAction)==null||C.call(a,"complete",(o==null?void 0:o.id)??"");return}(S=a.onAction)==null||S.call(a,h,(o==null?void 0:o.id)??"")}},c=f=>{var h,g,v,m,C;const u=f.target;if(u instanceof HTMLInputElement){u.dataset.task?(h=a.onTaskToggle)==null||h.call(a,(o==null?void 0:o.id)??"",u.dataset.task,u.checked):u.dataset.field?(g=a.onFieldChange)==null||g.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((v=a.onFormChange)==null||v.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value));return}u instanceof HTMLSelectElement&&(u.dataset.field?(m=a.onFieldChange)==null||m.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((C=a.onFormChange)==null||C.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value)))};function p(){const f=t.querySelector(".rowvia-nf-gates");f&&(f.classList.add("is-shaking"),i.timeout(()=>f.classList.remove("is-shaking"),700))}return t.addEventListener("click",d),t.addEventListener("change",c),r(),{onInteraction:n.onInteraction,update(f,u){o=f,u&&(a={...a,...u}),r()},destroy(){t.removeEventListener("click",d),t.removeEventListener("change",c),n.destroy(),i.destroy(),t.remove()}}}function nn(s,e){const t=document.createElement("div");t.className="rowvia-nf-tip",t.textContent=e,document.body.append(t);const i=s.getBoundingClientRect();t.style.left=Math.max(8,Math.min(window.innerWidth-260,i.left))+"px",t.style.top=i.bottom+6+"px";const n=window.setTimeout(()=>t.remove(),2600);return()=>{window.clearTimeout(n),t.remove()}}function sn(s,e){const t=document.createElement("div"),i=new Ge;t.className="rowvia-nf-contextbar",s.append(t);const n=xe(t,"flow-context",e);let o=e.flow,a=e.query??"",l=!1;const r=()=>{const c=Zi(o),p=!!(o.templateVersion&&o.latestTemplateVersion&&o.templateVersion!==o.latestTemplateVersion);t.innerHTML=`
|
|
69
|
+
<div class="rowvia-nf-lane ${H?"is-parallel":"is-sequence"}">${T}</div>
|
|
70
|
+
${$}
|
|
71
|
+
</section>`}).join(""),v()},v=()=>{l.style.transform=`scale(${u})`,r.textContent=`${Math.round(u*100)}%`,a.style.width=`${l.scrollWidth*u}px`,a.style.height=`${l.scrollHeight*u}px`},m=x=>{var M;u=Math.min(da,Math.max(la,Math.round(x*100)/100)),v(),(M=e.onZoomChange)==null||M.call(e,u)},y=()=>{const x=l.scrollWidth||1,M=o.clientWidth-8;m(M/x),o.scrollTo({left:0,top:0})},k=x=>{var N;const M=x.target.closest("[data-node-id],[data-action]");if(!(!M||!t.contains(M))){if(M.dataset.nodeId){(N=e.onSelectNode)==null||N.call(e,M.dataset.nodeId);return}M.dataset.action==="fit"&&y(),M.dataset.action==="zoom-in"&&m(u+hi),M.dataset.action==="zoom-out"&&m(u-hi)}};t.addEventListener("click",k);const C=x=>{!x.ctrlKey&&!x.metaKey||(x.preventDefault(),m(u+(x.deltaY<0?.1:-.1)))};o.addEventListener("wheel",C,{passive:!1});let b=null;const I=x=>{x.target.closest("button")||(b={x:x.clientX,y:x.clientY,left:o.scrollLeft,top:o.scrollTop},o.setPointerCapture(x.pointerId),o.classList.add("is-panning"))},A=x=>{b&&(o.scrollLeft=b.left-(x.clientX-b.x),o.scrollTop=b.top-(x.clientY-b.y))},E=()=>{b=null,o.classList.remove("is-panning")};o.addEventListener("pointerdown",I),o.addEventListener("pointermove",A),o.addEventListener("pointerup",E),o.addEventListener("pointercancel",E);const G=typeof ResizeObserver<"u"?new ResizeObserver(v):null;return G==null||G.observe(o),g(),{onInteraction:i.onInteraction,update(x){const M=x.flow!==void 0||x.hiddenHints!==void 0;if(x.flow&&(c=x.flow),x.selectedNodeId!==void 0&&(p=x.selectedNodeId),x.query!==void 0&&(h=x.query),x.hiddenHints&&(e.hiddenHints=x.hiddenHints),x.onZoomChange!==void 0&&(e.onZoomChange=x.onZoomChange),x.onSelectNode!==void 0&&(e.onSelectNode=x.onSelectNode),M)g();else{const N=rn(c,h);for(const P of l.querySelectorAll("[data-node-id]")){const _=P.dataset.nodeId===p;P.classList.toggle("is-selected",_),P.classList.toggle("is-dimmed",!N.has(P.dataset.nodeId)),P.setAttribute("aria-pressed",String(_))}}},focusNode(x){const M=Array.from(l.querySelectorAll("[data-node-id]")).find(N=>N.dataset.nodeId===x);M==null||M.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"}),M==null||M.classList.add("is-pulsing"),n.timeout(()=>M==null?void 0:M.classList.remove("is-pulsing"),900)},fit:y,getZoom:()=>u,destroy(){G==null||G.disconnect(),t.removeEventListener("click",k),o.removeEventListener("wheel",C),i.destroy(),n.destroy(),t.remove()}}}function ca(s){const e=[{id:"schedule",label:"总排期",value:s.schedule,source:"系统字段 · 排期",permission:"节点负责人、管理员"},{id:"estimate",label:"估分",value:s.estimate,source:"系统字段 · 估分",permission:"节点负责人、管理员"},{id:"worklog",label:"实际工时",value:s.worklog??"—",source:"系统字段 · 实际工时"}],t=s.progress!==void 0?[{id:"progress",label:"进度",value:s.progress+"%",percent:s.progress,writeMode:s.progressMode,group:"progress",source:"节点进度"}]:[],n=[{id:"conclusion",label:"整体完成结论",value:s.conclusion,source:"节点完成结论与意见",permission:"独立填写或按负责人结论汇总"},{id:"opinion",label:"整体完成意见",value:s.opinion,source:"节点完成结论与意见"}],i=(s.fields??[]).filter(a=>a.group!=="schedule");return[{key:"schedule",title:"排期与工作量",fields:e},{key:"progress",title:"进度",fields:t},{key:"conclusion",title:"结论与意见",fields:n},{key:"custom",title:"自定义字段",fields:i}].filter(a=>a.fields.length>0)}function ua(s,e,t){var a;const n=!t&&!e.readonly,i=[];e.group==="progress"?(i.push('<span class="rowvia-nf-progress is-large"><i style="width:'+(e.percent??0)+'%"></i></span>',"<b>"+D(e.value)+"</b>"),e.writeMode&&i.push('<em class="rowvia-nf-mode">'+D(e.writeMode)+"</em>")):n&&e.id==="conclusion"&&((a=s.conclusionOptions)!=null&&a.length)?i.push('<select data-field="'+D(e.id)+'" aria-label="'+D(e.label)+'"><option value="">请选择</option>'+s.conclusionOptions.map(l=>"<option"+(l===e.value?" selected":"")+">"+D(l)+"</option>").join("")+"</select>"):n?i.push('<input data-field="'+D(e.id)+'" value="'+D(e.value??"")+'" placeholder="待填" aria-label="'+D(e.label)+'">'):i.push('<span class="rowvia-nf-value'+(e.value?"":" is-empty")+'">'+D(e.value||"待填")+"</span>");const o=[e.source,e.permission?"可编辑:"+e.permission:""].filter(Boolean).join(" · ");return'<div class="rowvia-nf-field"><label>'+D(e.label)+'</label><div class="rowvia-nf-field-control">'+i.join("")+'</div><button type="button" class="rowvia-nf-info" data-info="'+D(o)+'" aria-label="字段来源">ⓘ</button></div>'}function ha(s){const e=s.filter(n=>n.met).length,t=s.map(n=>{const i=n.met?"":'<button type="button" class="rowvia-nf-fix" data-'+(n.viewLink?'gate-view="'+D(n.id)+'"':'gate-fix="'+D(n.id)+'"')+">"+D(n.fixLabel??"去填写")+"</button>";return'<li class="'+(n.met?"is-met":"is-unmet")+'"><i aria-hidden="true">'+(n.met?"✓":"✕")+"</i><span>"+D(n.label)+(n.detail?"<small>"+D(n.detail)+"</small>":"")+"</span>"+i+"</li>"}).join("");return'<section class="rowvia-nf-gates" data-gates><h4>完成前需满足 <em>'+e+"/"+s.length+"</em></h4><ul>"+t+"</ul></section>"}function pa(s,e){const t=s.tasks??[],n=e?"":'<button type="button" class="rowvia-nf-link" data-action="add-task">+ 新增任务</button>';if(!t.length)return'<section class="rowvia-nf-tasks is-empty"><h4>全部任务 (0/0)</h4><p>暂无子任务'+(e?"":'<button type="button" data-action="add-task">+ 新增任务</button>')+"</p></section>";const i=t.filter(a=>a.done).length,o=t.map(a=>{const l=a.deliverable?'<span class="rowvia-nf-deliverable">📎 '+D(a.deliverable)+"</span>":'<span class="rowvia-nf-value is-empty">暂无</span>';return'<tr class="'+(a.done?"is-done":"")+'"><td><label class="rowvia-nf-check"><input type="checkbox" data-task="'+D(a.id)+'"'+(a.done?" checked":"")+(e?" disabled":"")+"><span>"+D(a.name)+"</span></label>"+(a.blocking?'<em class="rowvia-nf-blocker" title="未完成前主节点无法流转">阻塞项</em>':"")+"</td><td>"+l+"</td><td>"+D(a.owner||"暂无")+"</td><td>"+D(a.estimate||"暂无")+"</td><td>"+D(a.schedule||"暂无")+"</td></tr>"}).join("");return'<section class="rowvia-nf-tasks"><h4>全部任务 ('+i+"/"+t.length+")"+n+"</h4><table><thead><tr><th>名称</th><th>交付物</th><th>当前负责人</th><th>估分</th><th>排期</th></tr></thead><tbody>"+o+"</tbody></table></section>"}function fa(s,e){const t=s.form??[];if(!t.length)return"";const n=t.filter(r=>r.required).length,i=t.filter(r=>r.required&&!r.value).length,o=t.map(r=>{var c;let d;return!e&&r.type==="select"&&((c=r.options)!=null&&c.length)?d='<select data-form="'+D(r.id)+'" aria-label="'+D(r.label)+'"><option value="">请选择</option>'+r.options.map(p=>"<option"+(p===r.value?" selected":"")+">"+D(p)+"</option>").join("")+"</select>":!e&&r.type==="date"?d='<input type="date" data-form="'+D(r.id)+'" value="'+D(r.value??"")+'" aria-label="'+D(r.label)+'">':e?d='<span class="rowvia-nf-value'+(r.value?"":" is-empty")+'">'+D(r.value||"待填")+"</span>":d='<input data-form="'+D(r.id)+'" value="'+D(r.value??"")+'" placeholder="'+D(r.placeholder??"待填")+'" aria-label="'+D(r.label)+'">','<div class="rowvia-nf-form-row"><label>'+D(r.label)+(r.required?"<b>*</b>":"")+'</label><div class="rowvia-nf-field-control">'+d+"</div></div>"}).join(""),a=i?'<em class="rowvia-nf-warn">'+i+" 项必填未完成</em>":"",l="节点表单 · "+t.length+" 项"+(n?"("+n+" 必填)":"")+a;return'<section class="rowvia-nf-form'+(i?" has-pending":"")+'"><h4>'+l+"</h4>"+o+"</section>"}function ga(s){const e=s.events??[];if(!e.length)return"";const t=(o,a)=>a.length?"<span><b>"+o+"</b>"+a.map(l=>D(l.text)).join(";")+"</span>":"",n=e.filter(o=>o.trigger==="arrive"),i=e.filter(o=>o.trigger==="complete");return'<section class="rowvia-nf-events"><details><summary>ℹ 节点事件('+e.length+' 条规则已生效)</summary><div class="rowvia-nf-events-body">'+t("到达本节点时:",n)+t("完成本节点时:",i)+"<p>事件规则由流程模板配置,回滚节点至到达/完成之前的状态可解除限制。</p></div></details></section>"}function fi(s,e){const t=document.createElement("div"),n=new je;t.className="rowvia-nf-card",s.append(t);const i=Fe(t,"node-card",e);let o=e.node??null,a={...e},l=!1;const r=()=>{var x;if(!o){t.innerHTML='<div class="rowvia-nf-empty">在上方流程画布中选择一个节点,查看它的字段、表单与通行条件。</div>';return}const h=!!a.readonly,u=ht[o.status],f=an(o),g=o.completionMode?li[o.completionMode]:"",v=ca(o),m=(o.buttons??[]).filter(M=>(M.placement??"inline")==="inline"),y=(o.buttons??[]).filter(M=>M.placement==="more"),k=(M,N,P="")=>'<span class="rowvia-nf-chip '+N+'"'+(P?' title="'+D(P)+'"':"")+">"+D(M)+"</span>",C=(M,N,P,_="",L=!1)=>'<button type="button" class="rowvia-nf-btn '+P+'" data-action="'+D(M)+'"'+(_?' title="'+D(_)+'"':"")+(L?" disabled":"")+">"+D(N)+"</button>",b=[];if(!h){o.status==="inProgress"&&b.push(C("complete","完成","is-primary")),o.status==="failed"&&b.push(C("resubmit","重新提交","is-primary")),(o.status==="done"||o.status==="failed")&&b.push(C("rollback","回滚","is-ghost","将节点状态回退至进行中")),b.push(C("transfer","转办","is-ghost","将负责人转交他人"));for(const M of m){const N=[M.hint,(x=M.roles)!=null&&x.length?"授权:"+M.roles.join("、"):""].filter(Boolean).join(" · "),P=M.variant==="primary"?"is-primary":M.variant==="warning"?"is-warning":"is-ghost";b.push(C("custom:"+M.id,M.label,P,N))}b.push('<button type="button" class="rowvia-nf-btn is-icon" data-action="more" aria-haspopup="menu" aria-expanded="'+String(l)+'">···</button>')}const I='<span class="rowvia-nf-owner">负责人 '+D(o.owner||"待填")+(o.ownerSource?"<em>"+D(o.ownerSource)+"</em>":"")+"</span>",A='<div class="rowvia-nf-menu" data-menu'+(l?"":" hidden")+' role="menu"><button type="button" role="menuitem" data-action="estimate">填写估分</button><button type="button" role="menuitem" data-action="group-chat">节点建群</button>'+y.map(M=>'<button type="button" role="menuitem" data-action="custom:'+D(M.id)+'">'+D(M.label)+"</button>").join("")+'<button type="button" role="menuitem" class="is-danger" data-action="delete-node"'+(o.deleteRoles?' title="允许删除:'+D(o.deleteRoles.join("、"))+'"':"")+">删除节点</button></div>",E='<header class="rowvia-nf-card-head"><span class="rowvia-nf-dot status-'+u.className+'" aria-hidden="true"></span><h3>'+D(o.name)+"</h3>"+k(u.label,"status-"+u.className)+(g?k(g,"is-mode","对应配置:完成方式"):"")+(o.milestone?k("◆ 里程碑"+(o.deadline?" · "+o.deadline:""),"is-milestone","里程碑:仅可填写截止时间"):"")+I+'<span class="rowvia-nf-space"></span><div class="rowvia-nf-actions">'+b.join("")+"</div>"+A+"</header>",G=v.map(M=>'<div class="rowvia-nf-field-group" data-section="'+M.key+'"><h5>'+D(M.title)+"</h5>"+M.fields.map(N=>ua(o,N,h)).join("")+"</div>").join("");t.innerHTML=E+ha(f)+'<details class="rowvia-nf-section" open><summary>节点字段 <em>'+v.length+" 组</em></summary>"+G+"</details>"+fa(o,h)+pa(o,h)+ga(o)},d=h=>{var g,v,m,y,k;const u=h.target.closest("[data-action],[data-gate-fix],[data-gate-view],[data-info]");if(!u||!t.contains(u))return;if(u.dataset.info){n.add(gi(u,u.dataset.info));return}if(u.dataset.gateFix||u.dataset.gateView){p(),(g=a.onAction)==null||g.call(a,u.dataset.gateView?"open-gate-view":"fix-gate",(o==null?void 0:o.id)??"");return}const f=u.dataset.action;if(f){if(f==="more"){const C=t.querySelector("[data-menu]");if(!C)return;l=C.hidden,C.hidden=!l,u.setAttribute("aria-expanded",String(l));return}if(f==="complete"){const C=o?an(o):[];if(!di(C)){p(),(v=a.onAction)==null||v.call(a,"complete-blocked",(o==null?void 0:o.id)??"");return}if(((m=a.onComplete)==null?void 0:m.call(a,(o==null?void 0:o.id)??"",C))===!1)return;(y=a.onAction)==null||y.call(a,"complete",(o==null?void 0:o.id)??"");return}(k=a.onAction)==null||k.call(a,f,(o==null?void 0:o.id)??"")}},c=h=>{var f,g,v,m,y;const u=h.target;if(u instanceof HTMLInputElement){u.dataset.task?(f=a.onTaskToggle)==null||f.call(a,(o==null?void 0:o.id)??"",u.dataset.task,u.checked):u.dataset.field?(g=a.onFieldChange)==null||g.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((v=a.onFormChange)==null||v.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value));return}u instanceof HTMLSelectElement&&(u.dataset.field?(m=a.onFieldChange)==null||m.call(a,(o==null?void 0:o.id)??"",u.dataset.field,u.value):u.dataset.form&&((y=a.onFormChange)==null||y.call(a,(o==null?void 0:o.id)??"",u.dataset.form,u.value)))};function p(){const h=t.querySelector(".rowvia-nf-gates");h&&(h.classList.add("is-shaking"),n.timeout(()=>h.classList.remove("is-shaking"),700))}return t.addEventListener("click",d),t.addEventListener("change",c),r(),{onInteraction:i.onInteraction,update(h,u){o=h,u&&(a={...a,...u}),r()},destroy(){t.removeEventListener("click",d),t.removeEventListener("change",c),i.destroy(),n.destroy(),t.remove()}}}function gi(s,e){const t=document.createElement("div");t.className="rowvia-nf-tip",t.textContent=e,document.body.append(t);const n=s.getBoundingClientRect();t.style.left=Math.max(8,Math.min(window.innerWidth-260,n.left))+"px",t.style.top=n.bottom+6+"px";const i=window.setTimeout(()=>t.remove(),2600);return()=>{window.clearTimeout(i),t.remove()}}function mi(s,e){const t=document.createElement("div"),n=new je;t.className="rowvia-nf-contextbar",s.append(t);const i=Fe(t,"flow-context",e);let o=e.flow,a=e.query??"",l=!1;const r=()=>{const c=ci(o),p=!!(o.templateVersion&&o.latestTemplateVersion&&o.templateVersion!==o.latestTemplateVersion);t.innerHTML=`
|
|
72
72
|
<div class="rowvia-nf-context-main">
|
|
73
73
|
<label class="rowvia-nf-flowtype">
|
|
74
74
|
<span class="rowvia-nf-label">流程类型</span>
|
|
75
|
-
<select data-action="flow-type" aria-label="流程类型"><option>${
|
|
75
|
+
<select data-action="flow-type" aria-label="流程类型"><option>${D(o.name)}</option></select>
|
|
76
76
|
</label>
|
|
77
77
|
<span class="rowvia-nf-divider"></span>
|
|
78
78
|
<span class="rowvia-nf-stats">${c.total} 节点 · 已完成 ${c.done} · 当前第 ${c.index}/${c.total}</span>
|
|
79
79
|
<span class="rowvia-nf-chip ${c.failed?"has-failed":""}">未通过 ${c.failed}</span>
|
|
80
80
|
<span class="rowvia-nf-space"></span>
|
|
81
81
|
<div class="rowvia-nf-search">
|
|
82
|
-
<input data-action="search" placeholder="查找节点" value="${
|
|
82
|
+
<input data-action="search" placeholder="查找节点" value="${D(a)}" aria-label="查找节点">
|
|
83
83
|
<div class="rowvia-nf-suggestions" hidden data-suggestions></div>
|
|
84
84
|
</div>
|
|
85
85
|
<button type="button" class="rowvia-nf-ghost" data-action="rules" title="只读展示该流程的完成方式、节点事件与状态计算规则">⚙ 规则</button>
|
|
86
86
|
</div>
|
|
87
|
-
${p?`<div class="rowvia-nf-banner">当前使用的不是最新流程模板(${H(o.templateVersion)} → ${H(o.latestTemplateVersion)})<button type="button" data-action="diff">查看差异</button></div>`:""}`;const f=t.querySelector('[data-action="search"]'),u=t.querySelector("[data-suggestions]"),h=()=>{if(!u)return;const g=f.value.trim().toLowerCase(),v=g?o.nodes.filter(m=>m.name.toLowerCase().includes(g)).slice(0,8):[];u.hidden=!l||v.length===0,u.innerHTML=v.map(m=>`<button type="button" data-node="${H(m.id)}">${H(m.name)}<em>${H(at[m.status].label)}</em></button>`).join("")};f.addEventListener("focus",()=>{l=!0,h()}),f.addEventListener("blur",()=>{l=!1,i.timeout(h,120)}),f.addEventListener("input",()=>{var g;a=f.value,h(),(g=e.onQuery)==null||g.call(e,a)}),u==null||u.addEventListener("click",g=>{var m;const v=g.target.closest("[data-node]");v&&(l=!1,u.hidden=!0,(m=e.onFocusNode)==null||m.call(e,v.dataset.node))}),a&&h()},d=c=>{var f,u;const p=c.target.closest("[data-action]");!p||!t.contains(p)||(p.dataset.action==="rules"&&((f=e.onOpenRules)==null||f.call(e)),p.dataset.action==="diff"&&((u=e.onOpenDiff)==null||u.call(e)))};return t.addEventListener("click",d),r(),{onInteraction:n.onInteraction,update(c,p){o=c,p!==void 0&&(a=p),r()},getQuery:()=>a,destroy(){t.removeEventListener("click",d),n.destroy(),i.destroy(),t.remove()}}}function on(s,e){const t=document.createElement("div");t.className="rowvia-nf-timeline",s.append(t);const i=xe(t,"node-timeline",e);let n=e.flow,o=e.selectedNodeId,a="timeline",l="all",r=null;const d=[{key:"all",label:"全部状态"},{key:"done",label:"已完成"},{key:"inProgress",label:"进行中"},{key:"pending",label:"未开始"},{key:"failed",label:"未通过"}],c=h=>[h.owner?"负责人 "+h.owner:"负责人待填",h.schedule?"排期 "+h.schedule:"排期待填",h.estimate?"估分 "+h.estimate:"估分待填",h.progress!==void 0?"进度 "+h.progress+"%":"",(h.tasks??[]).length?"任务 "+(h.tasks??[]).filter(v=>v.done).length+"/"+(h.tasks??[]).length:"",(h.form??[]).length?"表单 "+(h.form??[]).filter(v=>v.value).length+"/"+(h.form??[]).length:""].filter(Boolean).join(" · "),p=h=>{const g=at[h.status],v=r===h.id,m=v?'<div class="rowvia-nf-tl-detail"><p>'+H(c(h))+"</p>"+((h.events??[]).length?'<p class="rowvia-nf-tl-events">'+h.events.map(C=>(C.trigger==="arrive"?"到达:":"完成:")+H(C.text)).join(" · ")+"</p>":"")+'<button type="button" class="rowvia-nf-ghost" data-action="edit" data-node="'+H(h.id)+'">回到操作卡编辑</button></div>':"";return'<div class="rowvia-nf-tl-row'+(o===h.id?" is-selected":"")+(h.milestone?" is-milestone":"")+'" data-row="'+H(h.id)+'"><button type="button" class="rowvia-nf-tl-toggle" data-action="toggle" data-node="'+H(h.id)+'" aria-expanded="'+String(v)+'" aria-label="展开">'+(v?"▾":"▸")+'</button><span class="rowvia-nf-dot status-'+g.className+'" aria-hidden="true"></span><button type="button" class="rowvia-nf-tl-name" data-action="edit" data-node="'+H(h.id)+'">'+H(h.name)+(h.milestone?'<em title="里程碑">◆</em>':"")+'</button><span class="rowvia-nf-chip status-'+g.className+'">'+H(g.label)+'</span><span class="rowvia-nf-tl-cell">'+H(h.owner||"待填")+'</span><span class="rowvia-nf-tl-cell">'+H(h.schedule||(h.deadline?"截止 "+h.deadline:"待填"))+'</span><span class="rowvia-nf-tl-cell">'+H(h.estimate||"待填")+'</span><span class="rowvia-nf-tl-cell is-progress">'+(h.progress!==void 0?'<span class="rowvia-nf-progress"><i style="width:'+h.progress+'%"></i></span>'+h.progress+"%":"—")+"</span></div>"+m},f=()=>{const h=n.nodes.filter(v=>l==="all"||v.status===l).map(p).join(""),g="<span>节点</span><span>状态</span><span>负责人</span><span>排期</span><span>估分</span><span>进度</span>";t.innerHTML='<div class="rowvia-nf-tl-toolbar"><div class="rowvia-nf-tl-filters">'+d.map(v=>'<button type="button" class="'+(l===v.key?"is-active":"")+'" data-action="filter" data-filter="'+v.key+'">'+v.label+"</button>").join("")+'</div><span class="rowvia-nf-space"></span><div class="rowvia-nf-seg" role="tablist"><button type="button" role="tab" class="'+(a==="timeline"?"is-active":"")+'" data-action="view" data-view="timeline">节点时间线</button><button type="button" role="tab" class="'+(a==="schedule"?"is-active":"")+'" data-action="view" data-view="schedule">排期信息</button></div></div><div class="rowvia-nf-tl-head">'+g+"</div>"+(h||'<div class="rowvia-nf-empty">没有符合筛选条件的节点</div>')},u=h=>{var m;const g=h.target.closest("[data-action]");if(!g||!t.contains(g))return;const v=g.dataset.action;if(v==="filter")l=g.dataset.filter??"all",f();else if(v==="view")a=g.dataset.view??"timeline",f();else if(v==="toggle"){const C=g.dataset.node;r=r===C?null:C,f()}else if(v==="edit"){const C=g.dataset.node;(m=e.onSelectNode)==null||m.call(e,C)}};return t.addEventListener("click",u),f(),{onInteraction:i.onInteraction,update(h){const g=h.flow!==void 0;if(h.flow&&(n=h.flow),h.selectedNodeId!==void 0&&(o=h.selectedNodeId),h.onSelectNode&&(e.onSelectNode=h.onSelectNode),g)f();else for(const v of t.querySelectorAll("[data-row]"))v.classList.toggle("is-selected",v.dataset.row===o)},destroy(){t.removeEventListener("click",u),i.destroy(),t.remove()}}}const ea=["schedule","estimate","worklog","conclusion","opinion"];function ta(s){const e={};for(const t of s){const i=at[t.status].label;e[i]=(e[i]??0)+1}return Object.entries(e).map(([t,i])=>t+" "+i).join(" · ")}function ia(s,e){let t=e.flow,i=e.selectedNodeId??"",n="",o=!1;const a=E=>{var x,k;return((x=E.nodes.find($=>$.status==="inProgress"))==null?void 0:x.id)??((k=E.nodes[0])==null?void 0:k.id)??""};i||(i=a(t));const l=document.createElement("section");if(l.className="rowvia-nf",e.title){const E=document.createElement("header");E.className="rowvia-nf-title",E.innerHTML="<strong>"+H(e.title)+"</strong>",l.append(E)}const r=document.createElement("div");r.className="rowvia-nf-body",r.innerHTML='<div data-region="context"></div><div data-region="canvas"></div><div data-region="card"></div><div data-region="timeline"></div><aside class="rowvia-nf-rules" data-region="rules" hidden></aside>',l.append(r),s.append(l);const d=xe(l,"node-flow",e),c=E=>r.querySelector('[data-region="'+E+'"]'),p=E=>t.nodes.find(x=>x.id===E)??null,f=sn(c("context"),{flow:t,query:n,onQuery:E=>{n=E,u.update({query:n})},onFocusNode:E=>C(E,!0),onOpenRules:()=>T(),onOpenDiff:()=>{var E;return(E=e.onAction)==null?void 0:E.call(e,"open-template-diff",i)}}),u=en(c("canvas"),{flow:t,selectedNodeId:i,query:n,onSelectNode:E=>C(E)}),h=on(c("timeline"),{flow:t,selectedNodeId:i,onSelectNode:E=>C(E,!0)}),g=c("rules"),v=tn(c("card"),{node:p(i),readonly:e.readonly,onComplete:(E,x)=>{var k;return(k=e.onComplete)==null?void 0:k.call(e,E,x)},onAction:(E,x)=>S(E,x),onFieldChange:(E,x,k)=>y(E,x,k),onFormChange:(E,x,k)=>R(E,x,k),onTaskToggle:(E,x,k)=>M(E,x,k)});function m(){v.update(p(i),{readonly:e.readonly})}function C(E,x=!1){var k;p(E)&&(i=E,u.update({selectedNodeId:E}),h.update({selectedNodeId:E}),m(),x&&u.focusNode(E),(k=e.onSelectNode)==null||k.call(e,E))}function S(E,x){var k;(E==="complete"||E==="rollback"||E==="resubmit")&&b(x,{status:E==="complete"?"done":"inProgress"}),(k=e.onAction)==null||k.call(e,E,x)}function b(E,x){t={...t,nodes:t.nodes.map(k=>k.id===E?{...k,...x}:k)},u.update({flow:t}),h.update({flow:t}),f.update(t,n),m()}function y(E,x,k){var q;const $=p(E);$&&(x==="conclusion"?b(E,{conclusion:k}):x==="opinion"?b(E,{opinion:k}):ea.includes(x)?b(E,{[x]:k}):b(E,{fields:($.fields??[]).map(F=>F.id===x?{...F,value:k}:F)}),(q=e.onFieldChange)==null||q.call(e,E,x,k))}function R(E,x,k){var q;const $=p(E);$&&b(E,{form:($.form??[]).map(F=>F.id===x?{...F,value:k}:F)}),(q=e.onFormChange)==null||q.call(e,E,x,k)}function M(E,x,k){var q;const $=p(E);$&&b(E,{tasks:($.tasks??[]).map(F=>F.id===x?{...F,done:k}:F)}),(q=e.onTaskToggle)==null||q.call(e,E,x,k)}function T(){var k;if(!g.hidden){g.hidden=!0;return}const E=Array.from(new Set(t.nodes.map($=>$.completionMode).filter(Boolean))),x=t.nodes.flatMap($=>$.events??[]);g.innerHTML='<div class="rowvia-nf-rules-head"><strong>流程规则(只读)</strong><button type="button" class="rowvia-nf-ghost" data-action="close-rules">关闭</button></div><dl><dt>流程类型</dt><dd>'+H(t.name)+"</dd><dt>完成方式</dt><dd>"+(E.length?E.map($=>H(String($))).join("、"):"未配置")+"</dd><dt>状态计算规则</dt><dd>"+((k=t.statusRules)!=null&&k.length?t.statusRules.map($=>H($)).join("<br>"):"未命中规则时按节点流转事件配置显示")+"</dd><dt>节点事件</dt><dd>"+(x.length?x.slice(0,6).map($=>($.trigger==="arrive"?"到达:":"完成:")+H($.text)).join("<br>"):"无")+"</dd><dt>节点状态分布</dt><dd>"+H(ta(t.nodes))+"</dd></dl>",g.hidden=!1}const W=E=>{E.target.closest('[data-action="close-rules"]')&&(g.hidden=!0)};return g.addEventListener("click",W),{onInteraction:d.onInteraction,selectNode(E){C(E,!0)},getSelectedNode:()=>p(i),setFlow(E){t=E,p(i)||(i=a(t)),f.update(t,n),u.update({flow:t,selectedNodeId:i,query:n}),h.update({flow:t,selectedNodeId:i}),m(),g.hidden=!0},updateNode(E,x){b(E,x)},focusNode(E){C(E,!0)},destroy(){o||(o=!0,g.removeEventListener("click",W),f.destroy(),u.destroy(),v.destroy(),h.destroy(),d.destroy(),l.remove())}}}const na=(s,e,t={})=>({id:s,name:e,...t});function Te(s){return{groupId:"g1",completionMode:"and",...s}}function sa(){const s=(t,i,n)=>Te({id:t,name:i,status:"pending",groupId:"g4",owner:n,ownerSource:"来源:角色联动",schedule:"09-02 ~ 09-06",estimate:"2d"}),e=[Te({id:"n-start",name:"开始",status:"done",owner:"系统",ownerSource:"来源:自动创建",schedule:"08-11",estimate:"0d",conclusion:"通过",events:[{trigger:"arrive",text:"需求状态 → 选题"}]}),Te({id:"n-meeting",name:"选题会",status:"inProgress",owner:"林小满",ownerSource:"来源:自行添加",schedule:"08-12 ~ 08-14",estimate:"3d",worklog:"1.5d",progress:40,progressMode:"按排期自动计算",conclusionOptions:["通过","不通过","有条件通过"],form:[{id:"f-entry",label:"选题入围",required:!0,placeholder:"请填写选题入围(至少五个主题)"}],tasks:[na("t-1","请填写选题入围",{blocking:!0,deliverable:"选题清单",owner:"林小满",estimate:"1d",schedule:"08-12"})],fields:[{id:"cf-risk",label:"节点风险",value:"中风险",group:"custom",source:"节点字段 · 单选"}],events:[{trigger:"arrive",text:"需求状态 → 选题"},{trigger:"complete",text:"「选题状态」字段 → 已定稿"}],buttons:[{id:"pass",label:"通过评审",variant:"primary",roles:["节点负责人","管理员"],hint:"数据赋值:整体完成结论 → 已通过"},{id:"reject",label:"不通过",variant:"warning",placement:"more"}],actionRoles:["节点负责人","管理员"],deleteRoles:["管理员"]}),Te({id:"n-topic",name:"确定选题",status:"pending",groupId:"g1",owner:"周野",schedule:"08-15 ~ 08-16",estimate:"2d",progress:0,progressMode:"手动填写",predecessors:["选题会"]}),Te({id:"n-ads",name:"广告植入",status:"pending",owner:"商务组",schedule:"08-17",estimate:"1d",predecessors:["确定选题"]}),Te({id:"n-script",name:"脚本制作",status:"pending",groupId:"g2",owner:"周野",schedule:"08-18 ~ 08-20",estimate:"3d"}),Te({id:"n-review",name:"脚本评审",status:"pending",groupId:"g2",completionMode:"or",owner:"内容总监",schedule:"08-21",estimate:"1d",conclusionOptions:["通过","不通过"],events:[{trigger:"complete",text:"「脚本状态」字段 → 已评审"}]}),Te({id:"n-plan",name:"制定计划表",status:"pending",groupId:"g3",owner:"制片人",schedule:"08-22 ~ 08-23",estimate:"2d"}),s("n-shoot","拍摄","导演组"),s("n-edit","剪辑","剪辑师"),s("n-art","美术","美术组"),s("n-audio","收音","录音师"),s("n-dit","DIT","DIT"),s("n-motion","动效","动效师"),s("n-color","调色","调色师"),s("n-mix","混音","混音师"),s("n-cover","封面","设计师"),Te({id:"n-final",name:"成片",status:"pending",groupId:"g5",milestone:!0,deadline:"09-08",owner:"制片人",schedule:"09-08",estimate:"0d",predecessors:["全部并行节点"]}),Te({id:"n-final-review",name:"成片评审会",status:"pending",groupId:"g5",completionMode:"or",owner:"内容总监",schedule:"09-09",estimate:"1d",conclusionOptions:["通过","不通过"],form:[{id:"f-pass",label:"成片评审是否通过",required:!0,type:"select",options:["是","否"]},{id:"f-publish",label:"预计发布时间",required:!0,type:"date"}],gates:[{id:"g-conclusion",label:"自定义条件:整体结论 = 通过",met:!1,fixLabel:"查看规则",detail:"完成流转条件 · 校验当前工作项",viewLink:"gates"},{id:"g-linked",label:"关联缺陷全部关闭",met:!1,fixLabel:"查看 3 条",detail:"完成流转条件 · 校验关联工作项",viewLink:"gates"}],events:[{trigger:"complete",text:"需求状态 → 待发布"}]}),Te({id:"n-publish",name:"发布",status:"pending",groupId:"g5",owner:"运营",schedule:"09-10",estimate:"1d"}),Te({id:"n-monitor",name:"数据监控",status:"pending",groupId:"g6",completionMode:"auto",owner:"数据组",schedule:"09-11 ~ 09-17",estimate:"5d",progress:0,progressMode:"同步自计算字段",delayed:!1}),Te({id:"n-retro",name:"项目复盘",status:"pending",groupId:"g6",owner:"制片人",schedule:"09-18",estimate:"1d",delayed:!0,info:"09-18"}),Te({id:"n-end",name:"结束",status:"pending",groupId:"g6",owner:"系统",estimate:"0d"})];for(const t of e)t.info||(t.info=t.schedule?t.schedule.split(" ~ ")[0]:"");return{id:"video",name:"视频流程",templateVersion:"v3",latestTemplateVersion:"v4",infoField:{label:"排期",position:"right"},statusRules:["整体结论 = 未通过 → 节点状态显示「未通过」","里程碑截止时间早于今天 → 节点状态显示「延期」"],groups:[{id:"g1",name:"前期策划"},{id:"g2",name:"脚本"},{id:"g3",name:"排期"},{id:"g4",name:"制作",layout:"parallel"},{id:"g5",name:"交付"},{id:"g6",name:"复盘"}],nodes:e}}const Me=s=>Date.parse(`${s}T00:00:00Z`)/864e5,Fe=s=>new Date(s*864e5).toISOString().slice(0,10),an=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Me(s))&&Fe(Me(s))===s,Jt=s=>!!s.start&&!!s.end;function ei(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&&(!an(i.start)||!an(i.end)||i.end<i.start))throw new Error("Invalid date range")}}function oa(s,e=!1){const t=[];return s.filter(Jt).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<Me(i.start));return n<0&&(n=t.length),t[n]=Me(i.end),{item:i,lane:n}})}function rn(s){let e=0,t=0;for(const i of s)Jt(i)&&e++,t+=i.estimate;return{scheduled:e,unscheduled:s.length-e,estimate:t}}const ln=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function aa(s,e){const{people:t,items:i,today:n,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:f,children:u,loose:h,colorFirst:g,from:v,days:m,rangeStart:C,rangeEnd:S}=e,b=D=>s.querySelector(D),y=b(".ps-rows"),R=()=>[22,43,64,86,120][p],M=()=>i.filter(D=>(!l||D.name.includes(l))&&(!r||D.status===r)&&(u||!D.parentId)),T=R(),W=m*T;b(".ps-table").style.width=`${W+200}px`;const E=`${C.slice(0,4)}年 第${Number(C.slice(5,7))}-${Number(S.slice(5,7))}月`;b(".ps-date-label").textContent=E,b('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,b(".ps-zoom").value=String(p);const x=b(".ps-weeks");x.replaceChildren();for(let D=0;D<m;D+=7){const z=document.createElement("span");z.style.width=`${Math.min(7,m-D)*T}px`,z.textContent=`${Fe(v+D).slice(5).replace("-","/")}~${Fe(v+D+6).slice(5).replace("-","/")}`,x.append(z)}y.replaceChildren();const k=M(),$=new Map;for(const D of k){const z=$.get(D.personId);z?z.push(D):$.set(D.personId,[D])}const q=new Map(t.map(D=>[D.id,rn($.get(D.id)??[])])),F=t.filter(D=>o.has(D.id)&&(!a||q.get(D.id).scheduled>0));d&&F.sort((D,z)=>{const U=q.get(D.id),K=q.get(z.id);return(d==="estimate"?U.estimate-K.estimate:U.scheduled-K.scheduled)*(c?-1:1)});const G=document.createElement("div");for(let D=0;D<m;D++){const z=new Date((v+D)*864e5).getUTCDay();if(z!==0&&z!==6)continue;const U=document.createElement("i");U.className="ps-weekend",U.style.left=`${D*T}px`,U.style.width=`${T}px`,G.append(U)}for(const D of F){const z=$.get(D.id)??[],U=q.get(D.id),K=oa(z,f),Z=Math.max(0,...K.map(A=>A.lane)),ie=Math.max(h?154:126,60+(Z+1)*(h?48:36)),pe=document.createElement("div");pe.className="ps-person-row",pe.style.height=`${ie}px`,pe.dataset.person=D.id;const J=document.createElement("div");J.className="ps-person",J.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${H(D.name)}</strong></div><div>已排期项 <b>${U.scheduled}</b></div><div>总估分 <b>${U.estimate.toFixed(2)}</b></div><div>未排期·${U.unscheduled}<button data-action="unplanned" data-person="${H(D.id)}">查看</button></div>`;const ce=J.querySelector(".ps-avatar");ce.textContent=D.name.slice(-2),ce.style.background=D.color||ln[t.indexOf(D)%ln.length];const fe=document.createElement("div");fe.className="ps-timeline",fe.style.width=`${W}px`,fe.style.setProperty("--day",`${T}px`);for(const A of G.children)fe.append(A.cloneNode(!0));const ne=Me(n)-v;if(ne>=0&&ne<m){const A=document.createElement("i");A.className="ps-today",A.style.left=`${(ne+.5)*T}px`,fe.append(A)}for(const{item:A,lane:O}of K){const V=Me(A.start),_=Me(A.end);if(_<v||V>=v+m)continue;const X=Math.max(0,V-v)*T,N=Math.min(m,_-v+1)*T,B=document.createElement("button");B.className=`ps-bar ${g?"ps-color":"ps-content"}`,B.dataset.item=A.id,B.setAttribute("aria-label",`${A.name},${A.start} 至 ${A.end}`),B.style.left=`${X}px`,B.style.width=`${N-X}px`,B.style.top=`${52+O*(h?48:36)}px`,B.style.setProperty("--bar-color",A.color||"#8cafeb"),B.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${H(A.name)}</span><span class="ps-status">${H(A.status)}</span><span class="ps-node">● ${H(A.node)}</span><span class="ps-effort">${A.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,fe.append(B)}if(!K.length){const A=document.createElement("span");A.className="ps-no-schedule",A.textContent="暂无排期",fe.append(A)}pe.append(J,fe),y.append(pe)}F.length||(y.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const I=new Set(F.map(D=>D.id)),L=k.filter(D=>I.has(D.personId));b(".ps-total").textContent=`ⓘ 总人数 ${F.length} 总估分 ${rn(L).estimate.toFixed(2)} pd ···`}function ra(s,e){ei(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(A=>A.id)),a=!1,l="",r="",d="",c=!1,p=1,f=!1,u=!1,h=!1,g=!0,v=Me(n)-new Date(`${n}T00:00:00Z`).getUTCDay(),m=90,C=`${n.slice(0,7)}-01`,S=Fe(Date.UTC(Number(n.slice(0,4)),Number(n.slice(5,7))+1,0)/864e5),b=!1,y=!1;const R=document.createElement("section");R.className="personnel-schedule",R.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${H(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
|
|
88
|
-
<div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${
|
|
87
|
+
${p?`<div class="rowvia-nf-banner">当前使用的不是最新流程模板(${D(o.templateVersion)} → ${D(o.latestTemplateVersion)})<button type="button" data-action="diff">查看差异</button></div>`:""}`;const h=t.querySelector('[data-action="search"]'),u=t.querySelector("[data-suggestions]"),f=()=>{if(!u)return;const g=h.value.trim().toLowerCase(),v=g?o.nodes.filter(m=>m.name.toLowerCase().includes(g)).slice(0,8):[];u.hidden=!l||v.length===0,u.innerHTML=v.map(m=>`<button type="button" data-node="${D(m.id)}">${D(m.name)}<em>${D(ht[m.status].label)}</em></button>`).join("")};h.addEventListener("focus",()=>{l=!0,f()}),h.addEventListener("blur",()=>{l=!1,n.timeout(f,120)}),h.addEventListener("input",()=>{var g;a=h.value,f(),(g=e.onQuery)==null||g.call(e,a)}),u==null||u.addEventListener("click",g=>{var m;const v=g.target.closest("[data-node]");v&&(l=!1,u.hidden=!0,(m=e.onFocusNode)==null||m.call(e,v.dataset.node))}),a&&f()},d=c=>{var h,u;const p=c.target.closest("[data-action]");!p||!t.contains(p)||(p.dataset.action==="rules"&&((h=e.onOpenRules)==null||h.call(e)),p.dataset.action==="diff"&&((u=e.onOpenDiff)==null||u.call(e)))};return t.addEventListener("click",d),r(),{onInteraction:i.onInteraction,update(c,p){o=c,p!==void 0&&(a=p),r()},getQuery:()=>a,destroy(){t.removeEventListener("click",d),i.destroy(),n.destroy(),t.remove()}}}function vi(s,e){const t=document.createElement("div");t.className="rowvia-nf-timeline",s.append(t);const n=Fe(t,"node-timeline",e);let i=e.flow,o=e.selectedNodeId,a="timeline",l="all",r=null;const d=[{key:"all",label:"全部状态"},{key:"done",label:"已完成"},{key:"inProgress",label:"进行中"},{key:"pending",label:"未开始"},{key:"failed",label:"未通过"}],c=f=>[f.owner?"负责人 "+f.owner:"负责人待填",f.schedule?"排期 "+f.schedule:"排期待填",f.estimate?"估分 "+f.estimate:"估分待填",f.progress!==void 0?"进度 "+f.progress+"%":"",(f.tasks??[]).length?"任务 "+(f.tasks??[]).filter(v=>v.done).length+"/"+(f.tasks??[]).length:"",(f.form??[]).length?"表单 "+(f.form??[]).filter(v=>v.value).length+"/"+(f.form??[]).length:""].filter(Boolean).join(" · "),p=f=>{const g=ht[f.status],v=r===f.id,m=v?'<div class="rowvia-nf-tl-detail"><p>'+D(c(f))+"</p>"+((f.events??[]).length?'<p class="rowvia-nf-tl-events">'+f.events.map(y=>(y.trigger==="arrive"?"到达:":"完成:")+D(y.text)).join(" · ")+"</p>":"")+'<button type="button" class="rowvia-nf-ghost" data-action="edit" data-node="'+D(f.id)+'">回到操作卡编辑</button></div>':"";return'<div class="rowvia-nf-tl-row'+(o===f.id?" is-selected":"")+(f.milestone?" is-milestone":"")+'" data-row="'+D(f.id)+'"><button type="button" class="rowvia-nf-tl-toggle" data-action="toggle" data-node="'+D(f.id)+'" aria-expanded="'+String(v)+'" aria-label="展开">'+(v?"▾":"▸")+'</button><span class="rowvia-nf-dot status-'+g.className+'" aria-hidden="true"></span><button type="button" class="rowvia-nf-tl-name" data-action="edit" data-node="'+D(f.id)+'">'+D(f.name)+(f.milestone?'<em title="里程碑">◆</em>':"")+'</button><span class="rowvia-nf-chip status-'+g.className+'">'+D(g.label)+'</span><span class="rowvia-nf-tl-cell">'+D(f.owner||"待填")+'</span><span class="rowvia-nf-tl-cell">'+D(f.schedule||(f.deadline?"截止 "+f.deadline:"待填"))+'</span><span class="rowvia-nf-tl-cell">'+D(f.estimate||"待填")+'</span><span class="rowvia-nf-tl-cell is-progress">'+(f.progress!==void 0?'<span class="rowvia-nf-progress"><i style="width:'+f.progress+'%"></i></span>'+f.progress+"%":"—")+"</span></div>"+m},h=()=>{const f=i.nodes.filter(v=>l==="all"||v.status===l).map(p).join(""),g="<span>节点</span><span>状态</span><span>负责人</span><span>排期</span><span>估分</span><span>进度</span>";t.innerHTML='<div class="rowvia-nf-tl-toolbar"><div class="rowvia-nf-tl-filters">'+d.map(v=>'<button type="button" class="'+(l===v.key?"is-active":"")+'" data-action="filter" data-filter="'+v.key+'">'+v.label+"</button>").join("")+'</div><span class="rowvia-nf-space"></span><div class="rowvia-nf-seg" role="tablist"><button type="button" role="tab" class="'+(a==="timeline"?"is-active":"")+'" data-action="view" data-view="timeline">节点时间线</button><button type="button" role="tab" class="'+(a==="schedule"?"is-active":"")+'" data-action="view" data-view="schedule">排期信息</button></div></div><div class="rowvia-nf-tl-head">'+g+"</div>"+(f||'<div class="rowvia-nf-empty">没有符合筛选条件的节点</div>')},u=f=>{var m;const g=f.target.closest("[data-action]");if(!g||!t.contains(g))return;const v=g.dataset.action;if(v==="filter")l=g.dataset.filter??"all",h();else if(v==="view")a=g.dataset.view??"timeline",h();else if(v==="toggle"){const y=g.dataset.node;r=r===y?null:y,h()}else if(v==="edit"){const y=g.dataset.node;(m=e.onSelectNode)==null||m.call(e,y)}};return t.addEventListener("click",u),h(),{onInteraction:n.onInteraction,update(f){const g=f.flow!==void 0;if(f.flow&&(i=f.flow),f.selectedNodeId!==void 0&&(o=f.selectedNodeId),f.onSelectNode&&(e.onSelectNode=f.onSelectNode),g)h();else for(const v of t.querySelectorAll("[data-row]"))v.classList.toggle("is-selected",v.dataset.row===o)},destroy(){t.removeEventListener("click",u),n.destroy(),t.remove()}}}const ma=["schedule","estimate","worklog","conclusion","opinion"];function va(s){const e={};for(const t of s){const n=ht[t.status].label;e[n]=(e[n]??0)+1}return Object.entries(e).map(([t,n])=>t+" "+n).join(" · ")}function wa(s,e){let t=e.flow,n=e.selectedNodeId??"",i="",o=!1;const a=x=>{var M,N;return((M=x.nodes.find(P=>P.status==="inProgress"))==null?void 0:M.id)??((N=x.nodes[0])==null?void 0:N.id)??""};n||(n=a(t));const l=document.createElement("section");if(l.className="rowvia-nf",e.title){const x=document.createElement("header");x.className="rowvia-nf-title",x.innerHTML="<strong>"+D(e.title)+"</strong>",l.append(x)}const r=document.createElement("div");r.className="rowvia-nf-body",r.innerHTML='<div data-region="context"></div><div data-region="canvas"></div><div data-region="card"></div><div data-region="timeline"></div><aside class="rowvia-nf-rules" data-region="rules" hidden></aside>',l.append(r),s.append(l);const d=Fe(l,"node-flow",e),c=x=>r.querySelector('[data-region="'+x+'"]'),p=x=>t.nodes.find(M=>M.id===x)??null,h=mi(c("context"),{flow:t,query:i,onQuery:x=>{i=x,u.update({query:i})},onFocusNode:x=>y(x,!0),onOpenRules:()=>E(),onOpenDiff:()=>{var x;return(x=e.onAction)==null?void 0:x.call(e,"open-template-diff",n)}}),u=pi(c("canvas"),{flow:t,selectedNodeId:n,query:i,onSelectNode:x=>y(x)}),f=vi(c("timeline"),{flow:t,selectedNodeId:n,onSelectNode:x=>y(x,!0)}),g=c("rules"),v=fi(c("card"),{node:p(n),readonly:e.readonly,onComplete:(x,M)=>{var N;return(N=e.onComplete)==null?void 0:N.call(e,x,M)},onAction:(x,M)=>k(x,M),onFieldChange:(x,M,N)=>b(x,M,N),onFormChange:(x,M,N)=>I(x,M,N),onTaskToggle:(x,M,N)=>A(x,M,N)});function m(){v.update(p(n),{readonly:e.readonly})}function y(x,M=!1){var N;p(x)&&(n=x,u.update({selectedNodeId:x}),f.update({selectedNodeId:x}),m(),M&&u.focusNode(x),(N=e.onSelectNode)==null||N.call(e,x))}function k(x,M){var N;(x==="complete"||x==="rollback"||x==="resubmit")&&C(M,{status:x==="complete"?"done":"inProgress"}),(N=e.onAction)==null||N.call(e,x,M)}function C(x,M){t={...t,nodes:t.nodes.map(N=>N.id===x?{...N,...M}:N)},u.update({flow:t}),f.update({flow:t}),h.update(t,i),m()}function b(x,M,N){var _;const P=p(x);P&&(M==="conclusion"?C(x,{conclusion:N}):M==="opinion"?C(x,{opinion:N}):ma.includes(M)?C(x,{[M]:N}):C(x,{fields:(P.fields??[]).map(L=>L.id===M?{...L,value:N}:L)}),(_=e.onFieldChange)==null||_.call(e,x,M,N))}function I(x,M,N){var _;const P=p(x);P&&C(x,{form:(P.form??[]).map(L=>L.id===M?{...L,value:N}:L)}),(_=e.onFormChange)==null||_.call(e,x,M,N)}function A(x,M,N){var _;const P=p(x);P&&C(x,{tasks:(P.tasks??[]).map(L=>L.id===M?{...L,done:N}:L)}),(_=e.onTaskToggle)==null||_.call(e,x,M,N)}function E(){var N;if(!g.hidden){g.hidden=!0;return}const x=Array.from(new Set(t.nodes.map(P=>P.completionMode).filter(Boolean))),M=t.nodes.flatMap(P=>P.events??[]);g.innerHTML='<div class="rowvia-nf-rules-head"><strong>流程规则(只读)</strong><button type="button" class="rowvia-nf-ghost" data-action="close-rules">关闭</button></div><dl><dt>流程类型</dt><dd>'+D(t.name)+"</dd><dt>完成方式</dt><dd>"+(x.length?x.map(P=>D(String(P))).join("、"):"未配置")+"</dd><dt>状态计算规则</dt><dd>"+((N=t.statusRules)!=null&&N.length?t.statusRules.map(P=>D(P)).join("<br>"):"未命中规则时按节点流转事件配置显示")+"</dd><dt>节点事件</dt><dd>"+(M.length?M.slice(0,6).map(P=>(P.trigger==="arrive"?"到达:":"完成:")+D(P.text)).join("<br>"):"无")+"</dd><dt>节点状态分布</dt><dd>"+D(va(t.nodes))+"</dd></dl>",g.hidden=!1}const G=x=>{x.target.closest('[data-action="close-rules"]')&&(g.hidden=!0)};return g.addEventListener("click",G),{onInteraction:d.onInteraction,selectNode(x){y(x,!0)},getSelectedNode:()=>p(n),setFlow(x){t=x,p(n)||(n=a(t)),h.update(t,i),u.update({flow:t,selectedNodeId:n,query:i}),f.update({flow:t,selectedNodeId:n}),m(),g.hidden=!0},updateNode(x,M){C(x,M)},focusNode(x){y(x,!0)},destroy(){o||(o=!0,g.removeEventListener("click",G),h.destroy(),u.destroy(),v.destroy(),f.destroy(),d.destroy(),l.remove())}}}const ya=(s,e,t={})=>({id:s,name:e,...t});function He(s){return{groupId:"g1",completionMode:"and",...s}}function ba(){const s=(t,n,i)=>He({id:t,name:n,status:"pending",groupId:"g4",owner:i,ownerSource:"来源:角色联动",schedule:"09-02 ~ 09-06",estimate:"2d"}),e=[He({id:"n-start",name:"开始",status:"done",owner:"系统",ownerSource:"来源:自动创建",schedule:"08-11",estimate:"0d",conclusion:"通过",events:[{trigger:"arrive",text:"需求状态 → 选题"}]}),He({id:"n-meeting",name:"选题会",status:"inProgress",owner:"林小满",ownerSource:"来源:自行添加",schedule:"08-12 ~ 08-14",estimate:"3d",worklog:"1.5d",progress:40,progressMode:"按排期自动计算",conclusionOptions:["通过","不通过","有条件通过"],form:[{id:"f-entry",label:"选题入围",required:!0,placeholder:"请填写选题入围(至少五个主题)"}],tasks:[ya("t-1","请填写选题入围",{blocking:!0,deliverable:"选题清单",owner:"林小满",estimate:"1d",schedule:"08-12"})],fields:[{id:"cf-risk",label:"节点风险",value:"中风险",group:"custom",source:"节点字段 · 单选"}],events:[{trigger:"arrive",text:"需求状态 → 选题"},{trigger:"complete",text:"「选题状态」字段 → 已定稿"}],buttons:[{id:"pass",label:"通过评审",variant:"primary",roles:["节点负责人","管理员"],hint:"数据赋值:整体完成结论 → 已通过"},{id:"reject",label:"不通过",variant:"warning",placement:"more"}],actionRoles:["节点负责人","管理员"],deleteRoles:["管理员"]}),He({id:"n-topic",name:"确定选题",status:"pending",groupId:"g1",owner:"周野",schedule:"08-15 ~ 08-16",estimate:"2d",progress:0,progressMode:"手动填写",predecessors:["选题会"]}),He({id:"n-ads",name:"广告植入",status:"pending",owner:"商务组",schedule:"08-17",estimate:"1d",predecessors:["确定选题"]}),He({id:"n-script",name:"脚本制作",status:"pending",groupId:"g2",owner:"周野",schedule:"08-18 ~ 08-20",estimate:"3d"}),He({id:"n-review",name:"脚本评审",status:"pending",groupId:"g2",completionMode:"or",owner:"内容总监",schedule:"08-21",estimate:"1d",conclusionOptions:["通过","不通过"],events:[{trigger:"complete",text:"「脚本状态」字段 → 已评审"}]}),He({id:"n-plan",name:"制定计划表",status:"pending",groupId:"g3",owner:"制片人",schedule:"08-22 ~ 08-23",estimate:"2d"}),s("n-shoot","拍摄","导演组"),s("n-edit","剪辑","剪辑师"),s("n-art","美术","美术组"),s("n-audio","收音","录音师"),s("n-dit","DIT","DIT"),s("n-motion","动效","动效师"),s("n-color","调色","调色师"),s("n-mix","混音","混音师"),s("n-cover","封面","设计师"),He({id:"n-final",name:"成片",status:"pending",groupId:"g5",milestone:!0,deadline:"09-08",owner:"制片人",schedule:"09-08",estimate:"0d",predecessors:["全部并行节点"]}),He({id:"n-final-review",name:"成片评审会",status:"pending",groupId:"g5",completionMode:"or",owner:"内容总监",schedule:"09-09",estimate:"1d",conclusionOptions:["通过","不通过"],form:[{id:"f-pass",label:"成片评审是否通过",required:!0,type:"select",options:["是","否"]},{id:"f-publish",label:"预计发布时间",required:!0,type:"date"}],gates:[{id:"g-conclusion",label:"自定义条件:整体结论 = 通过",met:!1,fixLabel:"查看规则",detail:"完成流转条件 · 校验当前工作项",viewLink:"gates"},{id:"g-linked",label:"关联缺陷全部关闭",met:!1,fixLabel:"查看 3 条",detail:"完成流转条件 · 校验关联工作项",viewLink:"gates"}],events:[{trigger:"complete",text:"需求状态 → 待发布"}]}),He({id:"n-publish",name:"发布",status:"pending",groupId:"g5",owner:"运营",schedule:"09-10",estimate:"1d"}),He({id:"n-monitor",name:"数据监控",status:"pending",groupId:"g6",completionMode:"auto",owner:"数据组",schedule:"09-11 ~ 09-17",estimate:"5d",progress:0,progressMode:"同步自计算字段",delayed:!1}),He({id:"n-retro",name:"项目复盘",status:"pending",groupId:"g6",owner:"制片人",schedule:"09-18",estimate:"1d",delayed:!0,info:"09-18"}),He({id:"n-end",name:"结束",status:"pending",groupId:"g6",owner:"系统",estimate:"0d"})];for(const t of e)t.info||(t.info=t.schedule?t.schedule.split(" ~ ")[0]:"");return{id:"video",name:"视频流程",templateVersion:"v3",latestTemplateVersion:"v4",infoField:{label:"排期",position:"right"},statusRules:["整体结论 = 未通过 → 节点状态显示「未通过」","里程碑截止时间早于今天 → 节点状态显示「延期」"],groups:[{id:"g1",name:"前期策划"},{id:"g2",name:"脚本"},{id:"g3",name:"排期"},{id:"g4",name:"制作",layout:"parallel"},{id:"g5",name:"交付"},{id:"g6",name:"复盘"}],nodes:e}}const Ie=s=>Date.parse(`${s}T00:00:00Z`)/864e5,Ge=s=>new Date(s*864e5).toISOString().slice(0,10),wi=s=>/^\d{4}-\d{2}-\d{2}$/.test(s)&&Number.isFinite(Ie(s))&&Ge(Ie(s))===s,ln=s=>!!s.start&&!!s.end;function dn(s,e){const t=new Set(s.map(n=>n.id));if(t.size!==s.length||new Set(e.map(n=>n.id)).size!==e.length)throw new Error("Duplicate schedule ID");for(const n of e){if(!t.has(n.personId))throw new Error(`Unknown person: ${n.personId}`);if(!Number.isFinite(n.estimate)||n.estimate<0)throw new Error("Invalid estimate");if(!!n.start!=!!n.end||n.start&&n.end&&(!wi(n.start)||!wi(n.end)||n.end<n.start))throw new Error("Invalid date range")}}function Ca(s,e=!1){const t=[];return s.filter(ln).slice().sort((n,i)=>n.start.localeCompare(i.start)||n.id.localeCompare(i.id)).map(n=>{let i=e?t.length:t.findIndex(o=>o<Ie(n.start));return i<0&&(i=t.length),t[i]=Ie(n.end),{item:n,lane:i}})}function yi(s){let e=0,t=0;for(const n of s)ln(n)&&e++,t+=n.estimate;return{scheduled:e,unscheduled:s.length-e,estimate:t}}const bi=["#b45ae4","#537bea","#16a999","#ec9952","#df6a9d","#8573dc"];function Sa(s,e){const{people:t,items:n,today:i,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:h,children:u,loose:f,colorFirst:g,from:v,days:m,rangeStart:y,rangeEnd:k}=e,C=$=>s.querySelector($),b=C(".ps-rows"),I=()=>[22,43,64,86,120][p],A=()=>n.filter($=>(!l||$.name.includes(l))&&(!r||$.status===r)&&(u||!$.parentId)),E=I(),G=m*E;C(".ps-table").style.width=`${G+200}px`;const x=`${y.slice(0,4)}年 第${Number(y.slice(5,7))}-${Number(k.slice(5,7))}月`;C(".ps-date-label").textContent=x,C('[data-action="people"]').textContent=`◎ 人员筛选 · ${o.size}人`,C(".ps-zoom").value=String(p);const M=C(".ps-weeks");M.replaceChildren();for(let $=0;$<m;$+=7){const z=document.createElement("span");z.style.width=`${Math.min(7,m-$)*E}px`,z.textContent=`${Ge(v+$).slice(5).replace("-","/")}~${Ge(v+$+6).slice(5).replace("-","/")}`,M.append(z)}b.replaceChildren();const N=A(),P=new Map;for(const $ of N){const z=P.get($.personId);z?z.push($):P.set($.personId,[$])}const _=new Map(t.map($=>[$.id,yi(P.get($.id)??[])])),L=t.filter($=>o.has($.id)&&(!a||_.get($.id).scheduled>0));d&&L.sort(($,z)=>{const j=_.get($.id),te=_.get(z.id);return(d==="estimate"?j.estimate-te.estimate:j.scheduled-te.scheduled)*(c?-1:1)});const H=document.createElement("div");for(let $=0;$<m;$++){const z=new Date((v+$)*864e5).getUTCDay();if(z!==0&&z!==6)continue;const j=document.createElement("i");j.className="ps-weekend",j.style.left=`${$*E}px`,j.style.width=`${E}px`,H.append(j)}for(const $ of L){const z=P.get($.id)??[],j=_.get($.id),te=Ca(z,h),he=Math.max(0,...te.map(U=>U.lane)),ge=Math.max(f?154:126,60+(he+1)*(f?48:36)),be=document.createElement("div");be.className="ps-person-row",be.style.height=`${ge}px`,be.dataset.person=$.id;const fe=document.createElement("div");fe.className="ps-person",fe.innerHTML=`<div class="ps-person-name"><span class="ps-avatar"></span><strong>${D($.name)}</strong></div><div>已排期项 <b>${j.scheduled}</b></div><div>总估分 <b>${j.estimate.toFixed(2)}</b></div><div>未排期·${j.unscheduled}<button data-action="unplanned" data-person="${D($.id)}">查看</button></div>`;const me=fe.querySelector(".ps-avatar");me.textContent=$.name.slice(-2),me.style.background=$.color||bi[t.indexOf($)%bi.length];const Ee=document.createElement("div");Ee.className="ps-timeline",Ee.style.width=`${G}px`,Ee.style.setProperty("--day",`${E}px`);for(const U of H.children)Ee.append(U.cloneNode(!0));const Me=Ie(i)-v;if(Me>=0&&Me<m){const U=document.createElement("i");U.className="ps-today",U.style.left=`${(Me+.5)*E}px`,Ee.append(U)}for(const{item:U,lane:se}of te){const X=Ie(U.start),W=Ie(U.end);if(W<v||X>=v+m)continue;const Z=Math.max(0,X-v)*E,le=Math.min(m,W-v+1)*E,S=document.createElement("button");S.className=`ps-bar ${g?"ps-color":"ps-content"}`,S.dataset.item=U.id,S.setAttribute("aria-label",`${U.name},${U.start} 至 ${U.end}`),S.style.left=`${Z}px`,S.style.width=`${le-Z}px`,S.style.top=`${52+se*(f?48:36)}px`,S.style.setProperty("--bar-color",U.color||"#8cafeb"),S.innerHTML=`<span class="ps-resize" data-edge="start"></span><span class="ps-bar-name">${D(U.name)}</span><span class="ps-status">${D(U.status)}</span><span class="ps-node">● ${D(U.node)}</span><span class="ps-effort">${U.estimate||""}</span><span class="ps-resize" data-edge="end"></span>`,Ee.append(S)}if(!te.length){const U=document.createElement("span");U.className="ps-no-schedule",U.textContent="暂无排期",Ee.append(U)}be.append(fe,Ee),b.append(be)}L.length||(b.innerHTML='<div class="ps-empty">没有符合条件的人员</div>');const T=new Set(L.map($=>$.id)),R=N.filter($=>T.has($.personId));C(".ps-total").textContent=`ⓘ 总人数 ${L.length} 总估分 ${yi(R).estimate.toFixed(2)} pd ···`}function Ea(s,e){dn(e.people,e.items);let t=structuredClone(e.people),n=structuredClone(e.items);const i=e.today??new Date().toISOString().slice(0,10);let o=new Set(t.map(W=>W.id)),a=!1,l="",r="",d="",c=!1,p=1,h=!1,u=!1,f=!1,g=!0,v=Ie(i)-new Date(`${i}T00:00:00Z`).getUTCDay(),m=90,y=`${i.slice(0,7)}-01`,k=Ge(Date.UTC(Number(i.slice(0,4)),Number(i.slice(5,7))+1,0)/864e5),C=!1,b=!1;const I=document.createElement("section");I.className="personnel-schedule",I.innerHTML=`<header class="ps-title"><span class="ps-app-icon">▦</span><strong>${D(e.title??"人员排期")}</strong><nav><button class="active" data-action="schedule">人员排期</button><button data-action="views">视图列表</button></nav></header>
|
|
88
|
+
<div class="ps-toolbar"><button class="ps-tint" data-action="people">◎ 人员筛选</button><button class="ps-tint" data-action="filter">▽ 筛选 · ${D(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>
|
|
89
89
|
<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>
|
|
90
|
-
<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(R);const M=xe(R,"personnel",e),T=A=>R.querySelector(A),W=T(".ps-scroll"),E=T(".ps-rows"),x=T(".ps-popover"),k=T(".ps-detail"),$=new AbortController,q=$.signal;let F;const G=()=>[22,43,64,86,120][p];function I(A){const O=T(".ps-toast");O.textContent=A,O.hidden=!1,clearTimeout(F),F=setTimeout(()=>O.hidden=!0,2200)}function L(){b||aa(R,{people:t,items:i,today:n,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:f,children:u,loose:h,colorFirst:g,from:v,days:m,rangeStart:C,rangeEnd:S})}function D(A,O){if(!x.hidden&&x.dataset.kind===A){x.hidden=!0;return}x.dataset.kind=A,x.hidden=!1;const V=R.getBoundingClientRect(),_=O==null?void 0:O.getBoundingClientRect();if(x.style.left=`${Math.max(12,Math.min(((_==null?void 0:_.left)??V.left)-V.left,R.clientWidth-(A==="unplanned"?760:420)-16))}px`,x.style.top=`${_?_.bottom-V.top+6:96}px`,x.className=`ps-popover ps-panel-${A}`,A==="people")x.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(X=>`<label><input type="checkbox" data-person="${H(X.id)}" ${o.has(X.id)?"checked":""}>${H(X.name)}</label>`).join("")}</div>`;else if(A==="sort")x.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>`,x.querySelector("select").value=d;else if(A==="filter")x.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${H(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${H(l)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(i.map(X=>X.status))].map(X=>`<option>${H(X)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,x.querySelector("select").value=r;else if(A==="settings")x.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${f?"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="${h?"":"selected"}">紧凑</button><button data-action="loose" class="${h?"selected":""}">宽松</button></div><div class="ps-panel-title">甘特条样式 ⓘ</div><div class="ps-style-options"><button data-action="content" class="${g?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${g?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(A==="date")K();else if(A==="save")x.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(A==="views"){const X=fe();x.innerHTML=`<div class="ps-panel-title">视图列表</div>${X.length?X.map((N,B)=>`<button class="ps-view" data-view="${B}">▦ ${H(N.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let z=new Date(`${C}T00:00:00Z`),U=!1;function K(){let A=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${C}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${S}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let O=0;O<2;O++){const V=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+O,1));A+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${V.getUTCFullYear()}年 ${V.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(X=>`<span>${X}</span>`).join("")}`;for(let X=0;X<V.getUTCDay();X++)A+="<span></span>";const _=new Date(Date.UTC(V.getUTCFullYear(),V.getUTCMonth()+1,0)).getUTCDate();for(let X=1;X<=_;X++){const N=Fe(Date.UTC(V.getUTCFullYear(),V.getUTCMonth(),X)/864e5);A+=`<button data-date="${N}" class="${N>=C&&N<=S?"in-range":""} ${N===C||N===S?"selected":""}">${X}</button>`}A+="</div></div>"}x.innerHTML=A+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((O,V)=>`<button data-preset="${V}">${O}</button>`).join("")}</div>`}function Z(){S<C&&([C,S]=[S,C]),v=Me(C),v-=new Date(v*864e5).getUTCDay(),m=Math.max(35,Me(S)-v+8),W.scrollLeft=0,L()}function ie(A,O){var X;if(!i.some(N=>N.id===A))throw new Error(`Unknown schedule item: ${A}`);const V=i.map(N=>N.id===A?{...N,...O}:N);ei(t,V),i=V,L();const _=i.find(N=>N.id===A);_&&((X=e.onItemChange)==null||X.call(e,structuredClone(_)))}function pe(A){var V;const O=i.find(_=>_.id===A);(V=e.onItemOpen)==null||V.call(e,structuredClone(O)),k.hidden=!1,k.dataset.item=A,k.innerHTML=`<header><strong>${H(O.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${H(O.status)}</span><h3>● ${H(O.node)}</h3><form><label>名称<input name="name" required value="${H(O.name)}"></label><label>负责人<select name="personId">${t.map(_=>`<option value="${H(_.id)}" ${_.id===O.personId?"selected":""}>${H(_.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${O.estimate}" required></label><label>开始日期<input type="date" name="start" value="${O.start||""}"></label><label>结束日期<input type="date" name="end" value="${O.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 J(A,O){D("unplanned",O),x.hidden=!1;const V=t.find(_=>_.id===A);x.innerHTML=`<div class="ps-panel-title">未排期工作项 ${H(V.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${i.filter(_=>_.personId===A&&!Jt(_)).map(_=>`<tr><td><button data-open="${H(_.id)}">${H(_.name)}</button></td><td>● ${H(_.node)}</td><td><input type="number" min="0" step="0.1" value="${_.estimate||""}" placeholder="待填" data-estimate="${H(_.id)}" aria-label="${H(_.name)}估分"></td><td><button class="ps-link" data-open="${H(_.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const ce=e.viewStorageKey??"rowvia-personnel-views-v1";function fe(){try{const A=JSON.parse(localStorage.getItem(ce)||"[]");return Array.isArray(A)?A:[]}catch{return[]}}R.addEventListener("click",A=>{const O=A.target,V=O.closest("button");if(!V)return;if(V.dataset.open){x.hidden=!0,pe(V.dataset.open);return}if(V.dataset.item){y||pe(V.dataset.item);return}if(V.dataset.date){U?(S=V.dataset.date,U=!1,Z()):(C=V.dataset.date,S=C,U=!0),K();return}if(V.dataset.preset){const X=Number(V.dataset.preset),N=Me(n),B=new Date(N*864e5);C=Fe(X<2?N-B.getUTCDay():X<4?Date.UTC(B.getUTCFullYear(),B.getUTCMonth(),1)/864e5:N),S=Fe(X===2||X===3?Date.UTC(B.getUTCFullYear(),B.getUTCMonth()+(X===2?1:2),0)/864e5:Me(C)+[6,13,29,60,13,59,364][X]),U=!1,Z(),x.hidden=!0;return}if(V.dataset.view){const X=fe()[Number(V.dataset.view)];X&&(o=new Set(X.selected.filter(N=>t.some(B=>B.id===N))),{query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:C,rangeEnd:S,expanded:f,children:u,loose:h,colorFirst:g,onlyScheduled:a}=X,L(),x.hidden=!0,I(`已打开 ${X.name}`));return}const _=V.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(_||"")){D(_,V);return}if(_==="unplanned"){J(V.dataset.person,V);return}if(_==="close-detail"&&(k.hidden=!0),_==="unschedule"&&(ie(k.dataset.item,{start:null,end:null}),k.hidden=!0),(_==="plus"||_==="minus")&&(p=Math.max(0,Math.min(4,p+(_==="plus"?1:-1))),L()),(_==="prev"||_==="next"||_==="today")&&(v=_==="today"?Me(n)-new Date(`${n}T00:00:00Z`).getUTCDay():v+(_==="prev"?-14:14),C=Fe(v),S=Fe(v+59),W.scrollLeft=0,L()),(_==="asc"||_==="desc"||_==="clear-sort")&&(c=_==="desc",_==="clear-sort"&&(d=""),L(),x.hidden=!0),_==="clear-filter"&&(l="",r="",L(),x.hidden=!0),["compact","loose","content","color"].includes(_||"")&&(_==="compact"||_==="loose"?h=_==="loose":g=_==="color",L(),x.hidden=!0,D("settings",T('[data-action="settings"]'))),(_==="cal-prev"||_==="cal-next")&&(z=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+(_==="cal-prev"?-1:1),1)),K()),_==="save-view"){const X=x.querySelector("[data-view-name]").value.trim();if(!X)return;const N=fe();N.push({name:X,selected:[...o],query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:C,rangeEnd:S,expanded:f,children:u,loose:h,colorFirst:g,onlyScheduled:a});try{localStorage.setItem(ce,JSON.stringify(N)),x.hidden=!0,I("视图已保存")}catch{I("浏览器存储不可用,视图未保存")}}_==="schedule"&&(x.hidden=!0,k.hidden=!0)},{signal:q}),R.addEventListener("input",A=>{const O=A.target;O.classList.contains("ps-zoom")&&(p=Number(O.value),L()),O.classList.contains("ps-person-search")&&x.querySelectorAll(".ps-person-options label").forEach(V=>{var _;return V.hidden=!((_=V.textContent)!=null&&_.includes(O.value))}),O.dataset.control==="query"&&(l=O.value,L())},{signal:q}),R.addEventListener("change",A=>{const O=A.target;if(O.dataset.person&&(O.checked?o.add(O.dataset.person):o.delete(O.dataset.person),L()),O.dataset.estimate){const V=Number(O.value);Number.isFinite(V)&&V>=0&&ie(O.dataset.estimate,{estimate:V});return}switch(O.dataset.control){case"only":a=O.checked;break;case"sort":d=O.value;break;case"status":r=O.value;break;case"expanded":f=O.checked;break;case"children":u=O.checked;break;case"range-start":O.value&&(C=O.value,Z(),K());return;case"range-end":O.value&&(S=O.value,Z(),K());return}L()},{signal:q}),k.addEventListener("submit",A=>{A.preventDefault();const O=new FormData(A.target),V=String(O.get("start")||"")||null,_=String(O.get("end")||"")||null;if(!!V!=!!_||V&&_&&V>_){k.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}ie(k.dataset.item,{name:String(O.get("name")),personId:String(O.get("personId")),estimate:Number(O.get("estimate")),start:V,end:_}),k.hidden=!0,I("排期已更新")},{signal:q}),document.addEventListener("pointerdown",A=>{R.contains(A.target)?!x.contains(A.target)&&!A.target.closest("[data-action]")&&(x.hidden=!0):x.hidden=!0},{signal:q}),R.addEventListener("keydown",A=>{A.key==="Escape"&&(x.hidden=!0,k.hidden=!0)},{signal:q});let ne=null;return E.addEventListener("pointerdown",A=>{const O=A.target,V=O.closest(".ps-bar");if(!V||A.button!==0)return;const _=i.find(X=>X.id===V.dataset.item);y=!1,ne={id:_.id,x:A.clientX,start:Me(_.start),end:Me(_.end),edge:O.dataset.edge||"move",bar:V,left:parseFloat(V.style.left),size:parseFloat(V.style.width),delta:0,scroll:W.scrollLeft}},{signal:q}),document.addEventListener("pointermove",A=>{if(!ne)return;const O=Math.round((A.clientX-ne.x+W.scrollLeft-ne.scroll)/G());ne.delta=ne.edge==="start"?Math.min(O,ne.end-ne.start):ne.edge==="end"?Math.max(O,ne.start-ne.end):O,Math.abs(A.clientX-ne.x)>4&&(y=!0),y&&(ne.bar.style.opacity=".8",ne.edge==="move"?ne.bar.style.transform=`translateX(${ne.delta*G()}px)`:(ne.bar.style.left=`${ne.left+(ne.edge==="start"?ne.delta*G():0)}px`,ne.bar.style.width=`${ne.size+(ne.edge==="start"?-1:1)*ne.delta*G()}px`))},{signal:q}),document.addEventListener("pointerup",()=>{if(!ne)return;const A=ne;ne=null,y&&(ie(A.id,{start:Fe(A.start+(A.edge==="end"?0:A.delta)),end:Fe(A.end+(A.edge==="start"?0:A.delta))}),I("排期已更新"))},{signal:q}),L(),{onInteraction:M.onInteraction,setData(A,O){ei(A,O),t=structuredClone(A),i=structuredClone(O),o=new Set(t.map(V=>V.id)),x.hidden=!0,k.hidden=!0,L()},getItems:()=>structuredClone(i),updateItem:ie,setPeople(A){o=new Set(A.filter(O=>t.some(V=>V.id===O))),L()},destroy(){b=!0,$.abort(),clearTimeout(F),M.destroy(),R.remove()}}}const la=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1});function dn(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)}})}const cn={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"/>',back:'<path d="m15 18-6-6 6-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"/>'},me=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${cn[s]||cn.check}</svg>`,Ce=(s,e,t="",i="")=>`<button type="button" data-action="${s}" class="${i}" aria-label="${H(e)}">${t?me(t):""}${e?`<span>${H(e)}</span>`:""}</button>`,Pt=(s,e,t="")=>`<select ${t}>${s.map(([i,n])=>`<option value="${H(i)}" ${i===e?"selected":""}>${H(n)}</option>`).join("")}</select>`,ti=new WeakMap;function un(s){let e=ti.get(s);e||(e={owners:0,added:!s.classList.contains("rowvia-work-items"),fieldAdded:!s.classList.contains("rowvia-field-scope")},ti.set(s,e),s.classList.add("rowvia-work-items","rowvia-field-scope")),e.owners++;let t=!1;return()=>{t||(t=!0,!--e.owners&&(e.added&&s.classList.remove("rowvia-work-items"),e.fieldAdded&&s.classList.remove("rowvia-field-scope"),ti.delete(s)))}}function ii(s,e,t,i){const n=document.createElement("div");n.className=e,n.innerHTML=t;const o=un(s);s.append(n);const a=new Ge,l=xe(n,e,i);return a.listen(n,"click",r=>{var p;const d=r.target.closest("[data-action]");if(!d||!n.contains(d)||d.matches(":disabled"))return;const c={action:d.dataset.action,anchor:d,originalEvent:r};(p=i.onAction)==null||p.call(i,c),n.dispatchEvent(new CustomEvent("rowvia:action",{detail:c,bubbles:!0}))}),{element:n,lifecycle:a,onInteraction:l.onInteraction,destroy(){a.destroy(),l.destroy(),n.remove(),o()}}}function da(s,e){const t=ii(s,"list-tabs",e.tabs.map(o=>`<button class="list-tab" role="tab" data-tab="${H(o)}">${H(o)}</button>`).join("")+`<div class="create-button">${Ce("create","新建","plus","primary")}${Ce("create-menu","","down","primary")}</div>`,e);t.element.setAttribute("role","tablist");let i=e.value??e.tabs[0]??"";const n=o=>{i=o,t.element.querySelectorAll("[data-tab]").forEach(a=>{const l=a.dataset.tab===i;a.classList.toggle("active",l),a.setAttribute("aria-selected",String(l))})};return t.lifecycle.listen(t.element,"click",o=>{var l;const a=o.target.closest("[data-tab]");!a||a.dataset.tab===i||(n(a.dataset.tab),(l=e.onChange)==null||l.call(e,i),t.element.dispatchEvent(new CustomEvent("rowvia:tab-change",{detail:i,bubbles:!0})))}),t.element.querySelectorAll("[data-action]").forEach(o=>{o.disabled=e.canCreate===!1}),n(i),{element:t.element,onInteraction:t.onInteraction,setValue:n,getValue:()=>i,destroy:t.destroy}}const ni={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};function ca(s,e={}){const t=ii(s,"toolbar",Object.entries(ni).map(([a,l])=>Ce(a,l,a)).join("")+`<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${Ce("previous-match","","up")}${Ce("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${Ce("close-search","","close")}</div>${Ce("search","查找","search")}<div class="right">${Ce("reset","重置","","hidden")}${Ce("saved-views","切换视图","down")}${Ce("save-view","存为视图","save","outline")}</div>`,e),i=t.element.querySelector("#search"),n=t.element.querySelector("#filter-search"),o=()=>{var a;(a=e.onSearch)==null||a.call(e,i.value,n.checked),t.element.dispatchEvent(new CustomEvent("rowvia:search",{detail:{query:i.value,filter:n.checked},bubbles:!0}))};return t.lifecycle.listen(i,"input",o),t.lifecycle.listen(n,"change",o),{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setRuleCounts(a){for(const l of Object.keys(ni)){const r=t.element.querySelector(`[data-action="${l}"]`);r.classList.toggle("is-set",!!a[l]),r.querySelector("span").textContent=ni[l]+(a[l]?` · ${a[l]}`:"")}t.element.querySelector('[data-action="reset"]').classList.toggle("hidden",!Object.values(a).some(Boolean))}}}function ua(s,e={}){const t=ii(s,"selection-bar hidden",`${Ce("deselect","","close")}<span data-selection-count></span>${Ce("batch-status","更新状态")}${Ce("batch-owner","更新负责人")}${Ce("batch-export","导出")}${Ce("batch-archive","终止")}${Ce("deselect","取消选择")}`,e),i=t.element.querySelector("[data-selection-count]");return{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setCount(n){t.element.classList.toggle("hidden",n===0),i.textContent=`已选择 ${n} 项`}}}function ha(s,e){const t=un(s),i=Vi(s,{getRowId:({data:n})=>n.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,localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"},...e});return{...i,onInteraction:i.grid.onInteraction,destroy(){i.grid.destroy(),t()}}}function pa(s){const{config:e,controls:t,fieldConfig:i,options:n,$:o,tag:a,activateCell:l,controlContext:r,openDetail:d,colorRuleMatches:c}=s;function p(u){if(u.node.group)return"";const h=u.data,g=u.colDef.field,v=document.createElement("div");v.className="rendered-cell";const m=i(g);if(m&&(m.control||!["title","status"].includes(m.kind||"text")))v.append(t.resolve(m).render(r(m,h,"cell")));else if((m==null?void 0:m.kind)==="title"){const C=document.createElement("a");C.className="item-name",C.href=`#item/${h.id}`,C.textContent=h[g],C.title=h[g],C.addEventListener("click",b=>{b.preventDefault(),clearTimeout(s.detailClickTimer.get()),b.detail===0?d(h):b.detail===1&&s.detailClickTimer.set(window.setTimeout(()=>d(h),280))}),v.append(C);const S=document.createElement("button");S.className="inline-edit",S.innerHTML=me("pencil"),S.ariaLabel="编辑选题概要",S.onclick=b=>{b.stopPropagation(),l(v,g,h,u.rowIndex)},(m==null?void 0:m.editable)!==!1&&v.append(S)}else(m==null?void 0:m.kind)==="status"?(v.innerHTML=`${a(h.status,g)}<span class="status-days">20 天</span>`,(m==null?void 0:m.editable)!==!1&&(v.onclick=C=>{C.stopPropagation(),l(v,g,h,u.rowIndex)})):n[g]?(v.innerHTML=["creator","owner","space"].includes(g)?H(h[g]):a(h[g],g),(m==null?void 0:m.editable)!==!1&&(v.onclick=C=>{C.stopPropagation(),l(v,g,h,u.rowIndex)})):(v.innerHTML=`<span class="cell-text">${H(h[g]||"暂无")}</span>`,h[g]||v.classList.add("placeholder"));if(m&&m.editable!==!1&&!t.resolve(m).readonly&&m.kind!=="title"){const C=document.createElement("button");C.className="inline-edit field-control",C.ariaLabel=`${m.kind==="status"?"流转":"编辑"}${m.label}`,C.innerHTML=me(m.kind==="status"?"transition":["select","multiSelect","person"].includes(m.kind||"")?"down":"pencil"),C.onclick=S=>{S.stopPropagation(),l(v,g,h,u.rowIndex)},v.append(C)}return v.title=String(h[g]??""),v}function f(){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:u=>{if(u.node.group)return"";const h=document.createElement("div");return h.className="row-controls",h.innerHTML=`<span class="row-number">${u.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${u.rowIndex+1} 行" ${u.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${me("expand")}</button>`,o("input",h).onclick=g=>g.stopPropagation(),o("input",h).onchange=g=>u.node.setSelected(g.target.checked),o("button",h).onclick=g=>{g.stopPropagation(),d(u.data)},h}},...e.fields.map(u=>({field:u.key,headerName:u.label,width:u.width??120,minWidth:u.minWidth??80,pinned:u.pinned,hide:u.hidden,enableRowGroup:!0,editable:!1,valueSetter:h=>u.required&&!String(h.newValue??"").trim()?!1:(h.data[u.key]=h.newValue,!0),comparator:u.options?(h,g)=>u.options.indexOf(h)-u.options.indexOf(g):void 0,sortable:!1,suppressMenu:!0,cellRenderer:p,cellStyle:({data:h})=>{const g=h&&s.view().colors.find(v=>!!v.scope&&v.scope!=="row"&&v.field===u.key&&c(h,v));return g?{backgroundColor:g.color}:{}},tooltipField:u.key,cellClass:u.kind==="title"?"name-cell":void 0,...u.column})),...s.customColumns(),{colId:"_add",hide:e.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}return{cell:p,columnDefs:f}}function fa(s){const{config:e,data:t,fields:i,fieldConfig:n,options:o,controls:a,$:l,showPopup:r,closePopup:d,applyView:c,save:p,resizeGrid:f,decorateHeaders:u}=s;function h(C,S,b={}){e.container.querySelectorAll(".field-picker").forEach(W=>W.remove());const y=document.createElement("div");y.className="field-picker",y.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(W=>`<button data-kind="${W}">${W}</button>`).join("")}</div><div class="field-options"></div>`,e.container.append(y);const R=C.getBoundingClientRect();y.style.left=`${Math.max(12,Math.min(R.left,innerWidth-410))}px`,y.style.top=`${Math.max(12,Math.min(R.bottom+4,innerHeight-340))}px`;let M="推荐";const T=(W="推荐",E="")=>{l(".field-options",y).innerHTML=i.filter(([x,k])=>{var $,q,F,G,I,L;return(!b.available||b.available(x))&&k.includes(E)&&(W==="推荐"||W==="文本"&&["title","text","longText","richText"].includes((($=n(x))==null?void 0:$.kind)||"text")||W==="选择"&&["status","select","multiSelect"].includes(((q=n(x))==null?void 0:q.kind)||"")||W==="人员"&&((F=n(x))==null?void 0:F.kind)==="person"||W==="时间"&&["date","dateTime"].includes(((G=n(x))==null?void 0:G.kind)||"")||W==="关系"&&((I=n(x))==null?void 0:I.kind)==="relation"||W==="其他"&&((L=n(x))==null?void 0:L.kind)==="vote")}).map(([x,k])=>`<button data-field="${H(x)}" ${b.onCreate?`data-insert="${H(x)}"`:""} class="menu-option">${me("table")}${H(k)}</button>`).join(""),b.onCreate&&l(".field-options",y).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${me("add")}添加字段</button>`),y.querySelectorAll("[data-kind]").forEach(x=>{x.classList.toggle("active",x.dataset.kind===W),x.setAttribute("aria-pressed",String(x.dataset.kind===W))})};T(),l("input",y).oninput=W=>T(M,W.target.value),y.onclick=W=>{var x;const E=W.target.closest("button");E&&(W.stopPropagation(),E.dataset.kind&&(M=E.dataset.kind,T(M,l("input",y).value)),E.dataset.field&&(y.remove(),S(E.dataset.field)),E.hasAttribute("data-create-field")&&(y.remove(),(x=b.onCreate)==null||x.call(b)))}}function g(C){const S=s.instance(),b=r(C,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${S.api.getAllColumns().filter(y=>!y.colId.startsWith("_")).map(y=>`<label class="column-option"><input type="checkbox" data-column="${y.colId}" ${y.visible?"checked":""}><span>${H(y.headerName)}</span><button type="button" data-pin="${y.colId}">${y.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);b.onchange=y=>{const R=y.target;R.dataset.column&&S.columnApi.setColumnVisible(R.dataset.column,R.checked)},b.onclick=y=>{const R=y.target.closest("[data-pin]");if(R){y.preventDefault();const M=S.columnApi.getColumn(R.dataset.pin);S.columnApi.setColumnPinned(M,M.pinned?null:"left"),g(C)}},l("input",b).oninput=y=>{const R=y.target.value;b.querySelectorAll(".column-option").forEach(M=>M.hidden=!M.textContent.includes(R))}}function v(C,S,b){const y=s.instance();d();const R=T=>{var x;const E=y.columnApi.getColumnState().findIndex(k=>k.colId===S)+(b?1:0);y.columnApi.setColumnVisible(T,!0),y.columnApi.setColumnPinned(T,S==="_add"?null:((x=y.columnApi.getColumn(S))==null?void 0:x.pinned)??null),y.columnApi.moveColumn(T,Math.max(1,E)),d(),f(),u()};h(C,R,{available:T=>{var W;return!((W=y.columnApi.getColumn(T))!=null&&W.visible)},onCreate:()=>{const T=r(C,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${a.list().map(L=>`<option value="${H(L.id)}">${H(L.label)}</option>`).join("")}</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),W=l('[name="kind"]',T),E=l('[name="options"]',T),x=E.closest("label"),k=document.createElement("div");k.className="fc-field-schema",k.hidden=!0,k.innerHTML='<p class="hint">每组记录包含以下子字段</p><div class="fc-field-schema-rows"></div><button type="button" class="fc-composite-add">+ 添加子字段</button>';const $=a.list().filter(L=>!L.readonly&&!["composite","multiPersonComposite","attitudeVote","singleVote","multiVote","detail"].includes(L.id)),q=()=>{const L=document.createElement("div");L.className="fc-field-schema-row",L.innerHTML='<input class="fc-input" aria-label="子字段名称" placeholder="子字段名称"><select class="fc-input" aria-label="子字段类型">'+$.map(D=>'<option value="'+H(D.id)+'">'+H(D.label)+"</option>").join("")+'</select><button type="button" aria-label="移除子字段">×</button>',L.querySelector("button").onclick=()=>L.remove(),k.querySelector(".fc-field-schema-rows").append(L)};k.querySelector("button").onclick=q,q();const F=document.createElement("p");F.className="fc-service-note";const G=document.createElement("p");G.className="fc-error",G.setAttribute("role","status"),l("form",T).insertBefore(k,l('button[type="submit"]',T)),l("form",T).insertBefore(F,l('button[type="submit"]',T)),l("form",T).insertBefore(G,l('button[type="submit"]',T));const I=()=>{const L=W.value,D=L==="cascadeSingle"||L==="cascadeMulti";x.hidden=!D&&!["select","multiSelect","radio","singleVote","multiVote","person","multiPerson","relation","multiRelation"].includes(L),E.placeholder=D?"每行一条路径,例如:产品 / 设计 / 交互":"每行一个选项",l(".choice-limit",T).classList.toggle("hidden",!["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(L)),k.hidden=!["composite","multiPersonComposite"].includes(L),F.textContent=D?"用 / 分隔层级;同名上级会合并。":L==="attachment"?"上传操作由宿主上传服务提供。":L.endsWith("Vote")?"投票操作由宿主投票服务提供。":"",G.textContent=""};W.onchange=I,I(),l("form",T).onsubmit=L=>{L.preventDefault();const D=new FormData(L.target),z=String(D.get("label")||"").trim();if(!z)return;const U=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,K=String(D.get("kind")),Z={key:U,label:z,kind:K,editable:!a.resolve({key:U,label:z,kind:K}).readonly,width:160};["select","multiSelect","person","multiPerson","radio","singleVote","multiVote","relation","multiRelation"].includes(K)&&(Z.options=[...new Set(String(D.get("options")||"").split(`
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
<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(I);const A=Fe(I,"personnel",e),E=W=>I.querySelector(W),G=E(".ps-scroll"),x=E(".ps-rows"),M=E(".ps-popover"),N=E(".ps-detail"),P=new AbortController,_=P.signal;let L;const H=()=>[22,43,64,86,120][p];function T(W){const Z=E(".ps-toast");Z.textContent=W,Z.hidden=!1,clearTimeout(L),L=setTimeout(()=>Z.hidden=!0,2200)}function R(){C||Sa(I,{people:t,items:n,today:i,selected:o,onlyScheduled:a,query:l,status:r,sort:d,descending:c,zoom:p,expanded:h,children:u,loose:f,colorFirst:g,from:v,days:m,rangeStart:y,rangeEnd:k})}function $(W,Z){if(!M.hidden&&M.dataset.kind===W){M.hidden=!0;return}M.dataset.kind=W,M.hidden=!1;const le=I.getBoundingClientRect(),S=Z==null?void 0:Z.getBoundingClientRect();if(M.style.left=`${Math.max(12,Math.min(((S==null?void 0:S.left)??le.left)-le.left,I.clientWidth-(W==="unplanned"?760:420)-16))}px`,M.style.top=`${S?S.bottom-le.top+6:96}px`,M.className=`ps-popover ps-panel-${W}`,W==="people")M.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(V=>`<label><input type="checkbox" data-person="${D(V.id)}" ${o.has(V.id)?"checked":""}>${D(V.name)}</label>`).join("")}</div>`;else if(W==="sort")M.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>`,M.querySelector("select").value=d;else if(W==="filter")M.innerHTML=`<div class="ps-panel-title">筛选工作项</div><label>工作项类型 <span class="ps-chip">${D(e.workItemLabel??"工作项")}</span></label><label>名称包含 <input data-control="query" value="${D(l)}" placeholder="输入名称"></label><label>状态 <select data-control="status"><option value="">全部状态</option>${[...new Set(n.map(V=>V.status))].map(V=>`<option>${D(V)}</option>`).join("")}</select></label><button data-action="clear-filter" class="ps-link">清空筛选</button>`,M.querySelector("select").value=r;else if(W==="settings")M.innerHTML=`<div class="ps-panel-title">数据显示</div><label><input type="checkbox" data-control="expanded" ${h?"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="${g?"":"selected"}"><i></i>◉ 内容优先</button><button data-action="color" class="${g?"selected":""}"><i></i>◉ 颜色优先</button></div>`;else if(W==="date")te();else if(W==="save")M.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(W==="views"){const V=se();M.innerHTML=`<div class="ps-panel-title">视图列表</div>${V.length?V.map((oe,ce)=>`<button class="ps-view" data-view="${ce}">▦ ${D(oe.name)}</button>`).join(""):"<p>暂无保存的视图</p>"}`}}let z=new Date(`${y}T00:00:00Z`),j=!1;function te(){let W=`<div class="ps-range-inputs"><input type="date" data-control="range-start" value="${y}" aria-label="开始日期">—<input type="date" data-control="range-end" value="${k}" aria-label="结束日期"></div><div class="ps-calendars">`;for(let Z=0;Z<2;Z++){const le=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+Z,1));W+=`<div class="ps-calendar"><div><button data-action="cal-prev">‹</button><strong>${le.getUTCFullYear()}年 ${le.getUTCMonth()+1}月</strong><button data-action="cal-next">›</button></div><div class="ps-calendar-grid">${"日一二三四五六".split("").map(V=>`<span>${V}</span>`).join("")}`;for(let V=0;V<le.getUTCDay();V++)W+="<span></span>";const S=new Date(Date.UTC(le.getUTCFullYear(),le.getUTCMonth()+1,0)).getUTCDate();for(let V=1;V<=S;V++){const oe=Ge(Date.UTC(le.getUTCFullYear(),le.getUTCMonth(),V)/864e5);W+=`<button data-date="${oe}" class="${oe>=y&&oe<=k?"in-range":""} ${oe===y||oe===k?"selected":""}">${V}</button>`}W+="</div></div>"}M.innerHTML=W+`</div><div class="ps-presets">${["本周","本双周","本月","本双月","2周内","2个月内","1年内"].map((Z,le)=>`<button data-preset="${le}">${Z}</button>`).join("")}</div>`}let he=`${y}/${k}`;function ge(){var Z;const W=`${y}/${k}`;W!==he&&(he=W,(Z=e.onRangeChange)==null||Z.call(e,{from:y,to:k}))}function be(W){for(const Z of[W.from,W.to])if(!/^\d{4}-\d{2}-\d{2}$/.test(Z)||!Number.isFinite(Ie(Z))||Ge(Ie(Z))!==Z)throw new Error("Invalid schedule date range");if(W.to<W.from)throw new Error("Invalid schedule date range");y=W.from,k=W.to,z=new Date(`${y}T00:00:00Z`),he=`${y}/${k}`,fe(!1)}function fe(W=!0){k<y&&([y,k]=[k,y]),v=Ie(y),v-=new Date(v*864e5).getUTCDay(),m=Math.max(35,Ie(k)-v+8),G.scrollLeft=0,R(),W&&ge()}function me(W,Z){var V;if(!n.some(oe=>oe.id===W))throw new Error(`Unknown schedule item: ${W}`);const le=n.map(oe=>oe.id===W?{...oe,...Z}:oe);dn(t,le),n=le,R();const S=n.find(oe=>oe.id===W);S&&((V=e.onItemChange)==null||V.call(e,structuredClone(S)))}function Ee(W){var le;const Z=n.find(S=>S.id===W);(le=e.onItemOpen)==null||le.call(e,structuredClone(Z)),N.hidden=!1,N.dataset.item=W,N.innerHTML=`<header><strong>${D(Z.name)}</strong><button data-action="close-detail" aria-label="关闭详情">×</button></header><div class="ps-detail-body"><span class="ps-chip">${D(Z.status)}</span><h3>● ${D(Z.node)}</h3><form><label>名称<input name="name" required value="${D(Z.name)}"></label><label>负责人<select name="personId">${t.map(S=>`<option value="${D(S.id)}" ${S.id===Z.personId?"selected":""}>${D(S.name)}</option>`).join("")}</select></label><label>总估分(pd)<input name="estimate" type="number" min="0" step="0.1" value="${Z.estimate}" required></label><label>开始日期<input type="date" name="start" value="${Z.start||""}"></label><label>结束日期<input type="date" name="end" value="${Z.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 Me(W,Z){$("unplanned",Z),M.hidden=!1;const le=t.find(S=>S.id===W);M.innerHTML=`<div class="ps-panel-title">未排期工作项 ${D(le.name)}</div><table><thead><tr><th>名称</th><th>节点 / 状态</th><th>估分</th><th>排期</th></tr></thead><tbody>${n.filter(S=>S.personId===W&&!ln(S)).map(S=>`<tr><td><button data-open="${D(S.id)}">${D(S.name)}</button></td><td>● ${D(S.node)}</td><td><input type="number" min="0" step="0.1" value="${S.estimate||""}" placeholder="待填" data-estimate="${D(S.id)}" aria-label="${D(S.name)}估分"></td><td><button class="ps-link" data-open="${D(S.id)}">待填</button></td></tr>`).join("")||'<tr><td colspan="4">暂无未排期工作项</td></tr>'}</tbody></table>`}const U=e.viewStorageKey??"rowvia-personnel-views-v1";function se(){try{const W=JSON.parse(localStorage.getItem(U)||"[]");return Array.isArray(W)?W:[]}catch{return[]}}I.addEventListener("click",W=>{const Z=W.target,le=Z.closest("button");if(!le)return;if(le.dataset.open){M.hidden=!0,Ee(le.dataset.open);return}if(le.dataset.item){b||Ee(le.dataset.item);return}if(le.dataset.date){j?(k=le.dataset.date,j=!1,fe()):(y=le.dataset.date,k=y,j=!0),te();return}if(le.dataset.preset){const V=Number(le.dataset.preset),oe=Ie(i),ce=new Date(oe*864e5);y=Ge(V<2?oe-ce.getUTCDay():V<4?Date.UTC(ce.getUTCFullYear(),ce.getUTCMonth(),1)/864e5:oe),k=Ge(V===2||V===3?Date.UTC(ce.getUTCFullYear(),ce.getUTCMonth()+(V===2?1:2),0)/864e5:Ie(y)+[6,13,29,60,13,59,364][V]),j=!1,fe(),M.hidden=!0;return}if(le.dataset.view){const V=se()[Number(le.dataset.view)];V&&(o=new Set(V.selected.filter(oe=>t.some(ce=>ce.id===oe))),{query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:y,rangeEnd:k,expanded:h,children:u,loose:f,colorFirst:g,onlyScheduled:a}=V,R(),ge(),M.hidden=!0,T(`已打开 ${V.name}`));return}const S=le.dataset.action;if(["people","filter","sort","settings","date","save","views"].includes(S||"")){$(S,le);return}if(S==="unplanned"){Me(le.dataset.person,le);return}if(S==="close-detail"&&(N.hidden=!0),S==="unschedule"&&(me(N.dataset.item,{start:null,end:null}),N.hidden=!0),(S==="plus"||S==="minus")&&(p=Math.max(0,Math.min(4,p+(S==="plus"?1:-1))),R()),(S==="prev"||S==="next"||S==="today")&&(v=S==="today"?Ie(i)-new Date(`${i}T00:00:00Z`).getUTCDay():v+(S==="prev"?-14:14),y=Ge(v),k=Ge(v+59),G.scrollLeft=0,R(),ge()),(S==="asc"||S==="desc"||S==="clear-sort")&&(c=S==="desc",S==="clear-sort"&&(d=""),R(),M.hidden=!0),S==="clear-filter"&&(l="",r="",R(),M.hidden=!0),["compact","loose","content","color"].includes(S||"")&&(S==="compact"||S==="loose"?f=S==="loose":g=S==="color",R(),M.hidden=!0,$("settings",E('[data-action="settings"]'))),(S==="cal-prev"||S==="cal-next")&&(z=new Date(Date.UTC(z.getUTCFullYear(),z.getUTCMonth()+(S==="cal-prev"?-1:1),1)),te()),S==="save-view"){const V=M.querySelector("[data-view-name]").value.trim();if(!V)return;const oe=se();oe.push({name:V,selected:[...o],query:l,status:r,sort:d,descending:c,zoom:p,from:v,days:m,rangeStart:y,rangeEnd:k,expanded:h,children:u,loose:f,colorFirst:g,onlyScheduled:a});try{localStorage.setItem(U,JSON.stringify(oe)),M.hidden=!0,T("视图已保存")}catch{T("浏览器存储不可用,视图未保存")}}S==="schedule"&&(M.hidden=!0,N.hidden=!0)},{signal:_}),I.addEventListener("input",W=>{const Z=W.target;Z.classList.contains("ps-zoom")&&(p=Number(Z.value),R()),Z.classList.contains("ps-person-search")&&M.querySelectorAll(".ps-person-options label").forEach(le=>{var S;return le.hidden=!((S=le.textContent)!=null&&S.includes(Z.value))}),Z.dataset.control==="query"&&(l=Z.value,R())},{signal:_}),I.addEventListener("change",W=>{const Z=W.target;if(Z.dataset.person&&(Z.checked?o.add(Z.dataset.person):o.delete(Z.dataset.person),R()),Z.dataset.estimate){const le=Number(Z.value);Number.isFinite(le)&&le>=0&&me(Z.dataset.estimate,{estimate:le});return}switch(Z.dataset.control){case"only":a=Z.checked;break;case"sort":d=Z.value;break;case"status":r=Z.value;break;case"expanded":h=Z.checked;break;case"children":u=Z.checked;break;case"range-start":Z.value&&(y=Z.value,fe(),te());return;case"range-end":Z.value&&(k=Z.value,fe(),te());return}R()},{signal:_}),N.addEventListener("submit",W=>{W.preventDefault();const Z=new FormData(W.target),le=String(Z.get("start")||"")||null,S=String(Z.get("end")||"")||null;if(!!le!=!!S||le&&S&&le>S){N.querySelector(".ps-error").textContent="请填写完整日期,结束日期不能早于开始日期";return}me(N.dataset.item,{name:String(Z.get("name")),personId:String(Z.get("personId")),estimate:Number(Z.get("estimate")),start:le,end:S}),N.hidden=!0,T("排期已更新")},{signal:_}),document.addEventListener("pointerdown",W=>{I.contains(W.target)?!M.contains(W.target)&&!W.target.closest("[data-action]")&&(M.hidden=!0):M.hidden=!0},{signal:_}),I.addEventListener("keydown",W=>{W.key==="Escape"&&(M.hidden=!0,N.hidden=!0)},{signal:_});let X=null;return x.addEventListener("pointerdown",W=>{const Z=W.target,le=Z.closest(".ps-bar");if(!le||W.button!==0)return;const S=n.find(V=>V.id===le.dataset.item);b=!1,X={id:S.id,x:W.clientX,start:Ie(S.start),end:Ie(S.end),edge:Z.dataset.edge||"move",bar:le,left:parseFloat(le.style.left),size:parseFloat(le.style.width),delta:0,scroll:G.scrollLeft}},{signal:_}),document.addEventListener("pointermove",W=>{if(!X)return;const Z=Math.round((W.clientX-X.x+G.scrollLeft-X.scroll)/H());X.delta=X.edge==="start"?Math.min(Z,X.end-X.start):X.edge==="end"?Math.max(Z,X.start-X.end):Z,Math.abs(W.clientX-X.x)>4&&(b=!0),b&&(X.bar.style.opacity=".8",X.edge==="move"?X.bar.style.transform=`translateX(${X.delta*H()}px)`:(X.bar.style.left=`${X.left+(X.edge==="start"?X.delta*H():0)}px`,X.bar.style.width=`${X.size+(X.edge==="start"?-1:1)*X.delta*H()}px`))},{signal:_}),document.addEventListener("pointerup",()=>{if(!X)return;const W=X;X=null,b&&(me(W.id,{start:Ge(W.start+(W.edge==="end"?0:W.delta)),end:Ge(W.end+(W.edge==="start"?0:W.delta))}),T("排期已更新"))},{signal:_}),e.initialRange?be(e.initialRange):R(),{setRange:be,onInteraction:A.onInteraction,setData(W,Z){dn(W,Z),t=structuredClone(W),n=structuredClone(Z),o=new Set(t.map(le=>le.id)),M.hidden=!0,N.hidden=!0,R()},getItems:()=>structuredClone(n),updateItem:me,setPeople(W){o=new Set(W.filter(Z=>t.some(le=>le.id===Z))),R()},destroy(){C=!0,P.abort(),clearTimeout(L),A.destroy(),I.remove()}}}const Ci={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"/>',back:'<path d="m15 18-6-6 6-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">${Ci[s]||Ci.check}</svg>`,Ne=(s,e,t="",n="")=>`<button type="button" data-action="${s}" class="${n}" aria-label="${D(e)}">${t?Re(t):""}${e?`<span>${D(e)}</span>`:""}</button>`,zt=(s,e,t="")=>`<select ${t}>${s.map(([n,i])=>`<option value="${D(n)}" ${n===e?"selected":""}>${D(i)}</option>`).join("")}</select>`;function xa(s){var c,p;const e=s.detail,t=new Set(s.nodes.filter(h=>h.hiddenReason).map(h=>h.id));for(const h of(e==null?void 0:e.tags)??[])h.enabled===!1&&((c=h.nodeIds)==null||c.forEach(u=>t.add(u)));for(const h of(e==null?void 0:e.switches)??[])h.checked||(p=h.nodeIds)==null||p.forEach(u=>t.add(u));const n=s.nodes.filter(h=>!t.has(h.id)),i=new Set(n.map(h=>h.id)),o=(e==null?void 0:e.connections)??ka(s),a=(h,u=new Set)=>u.has(h)?[]:(u.add(h),i.has(h)?[h]:(o[h]??[]).flatMap(f=>a(f,new Set(u)))),l=n.flatMap(h=>[...new Set((o[h.id]??[]).flatMap(u=>a(u)))].map(u=>({from:h.id,to:u}))),r=(h,u,f,g=new Set)=>h===u?!0:g.has(h)?!1:(g.add(h),l.some(v=>v!==f&&v.from===h&&r(v.to,u,f,g))),d=l.filter(h=>!r(h.from,h.to,h));return{controls:{roles:(e==null?void 0:e.tags)??[],switches:(e==null?void 0:e.switches)??[]},graph:{nodes:n,edges:d},nodeList:n,node:h=>{var f,g,v;const u=(f=e==null?void 0:e.nodes)==null?void 0:f[h.id];return{data:h,form:((g=h.form)==null?void 0:g.filter(m=>{var y,k;return!m.visibleWhen||((k=(y=h.form)==null?void 0:y.find(C=>C.id===m.visibleWhen.fieldId))==null?void 0:k.value)===m.visibleWhen.value}))??[],fields:(u==null?void 0:u.fields)??(e==null?void 0:e.fields)??[{key:"owner",label:"负责人"},{key:"schedule",label:"总排期"}],sections:(u==null?void 0:u.sections)??((v=h.form)!=null&&v.length?["form","tasks"]:["tasks"]),completeLabel:(u==null?void 0:u.completeLabel)??"完成",deletable:(u==null?void 0:u.deletable)!==!1}}}}function ka(s){const e=[];for(const t of s.groups){const n=s.nodes.filter(i=>i.groupId===t.id);t.layout==="parallel"?e.push(n):e.push(...n.map(i=>[i]))}return e.push(...s.nodes.filter(t=>!s.groups.some(n=>n.id===t.groupId)).map(t=>[t])),Object.fromEntries(e.flatMap((t,n)=>t.map(i=>{var o;return[i.id,((o=e[n+1])==null?void 0:o.map(a=>a.id))??[]]})))}function Ma(s){const e=new Map(s.nodes.map(l=>[l.id,0]));for(let l=0;l<s.nodes.length;l++){let r=!1;for(const d of s.edges){const c=Math.min(s.nodes.length-1,(e.get(d.from)??0)+1);(e.get(d.to)??0)<c&&(e.set(d.to,c),r=!0)}if(!r)break}const t=[...new Set(e.values())].sort((l,r)=>l-r).map(l=>s.nodes.filter(r=>e.get(r.id)===l));let n=64;const i=t.flatMap(l=>{const r=Math.max(...l.map(c=>Math.max(55,c.name.length*13+27))),d=l.map((c,p)=>({node:c,x:n,y:196+(p-(l.length-1)/2)*40,width:r}));return n+=r+48,d}),o=new Map(i.map(l=>[l.node.id,l])),a=s.edges.flatMap(l=>{const r=o.get(l.from),d=o.get(l.to);if(!r||!d)return[];const c=r.x+r.width,p=r.y+14,h=d.y+14;return[`M ${c} ${p} C ${c+24} ${p} ${d.x-24} ${h} ${d.x} ${h}`]});return{nodes:i,paths:a,width:n+16}}const $e=s=>`<svg class="wf-icon" viewBox="0 0 16 16" aria-hidden="true">${{caret:'<path d="M13.706 6.437 8.503 12.421a.667.667 0 0 1-1.006 0L2.293 6.437a.667.667 0 0 1 .503-1.104h10.407a.667.667 0 0 1 .503 1.104Z" fill="currentColor"/>',chevron:'<path d="m4 6 4 4 4-4" fill="none" stroke="currentColor" stroke-width="1.5"/>',more:'<g fill="currentColor"><circle cx="3" cy="8" r="1.5"/><circle cx="8" cy="8" r="1.5"/><circle cx="13" cy="8" r="1.5"/></g>',expand:'<path d="M6 2H2v4m8-4h4v4M2 10v4h4m8-4v4h-4" fill="none" stroke="currentColor" stroke-width="1.3"/>',filter:'<path d="M2 3h12L9 8v5l-2-1V8Z" fill="none" stroke="currentColor" stroke-width="1.3"/>',list:'<path d="M6 4h8M6 8h8M6 12h8M2 4h1M2 8h1M2 12h1" stroke="currentColor" stroke-width="1.4"/>',detail:'<rect x="2" y="2" width="12" height="12" rx="2" fill="none" stroke="currentColor"/><path d="M5 6h6M5 9h6" stroke="currentColor"/>',plus:'<path d="M8 2v12M2 8h12" stroke="currentColor" stroke-width="1.5"/>'}[s]}</svg>`,_t={pending:"未开始",inProgress:"进行中",done:"已完成",failed:"未通过"},Si={estimate:"填写估分","group-chat":"节点建群","delete-node":"删除节点"};function Ra(s){var ce,xe;let e={...s},t=s.flow,n=t.detail,i=!1,o=!1,a=0;const l=new Map,r=document.createElement("section");r.className="workitem-module-detail-workflow rv-workflow-detail",r.dataset.module="detail:workflow";const d=document.createElement("section");d.className="workflow-node-details rv-workflow-detail",d.dataset.module="detail:tabs:schedule";const c=new AbortController;let p=s.selectedNodeId??((ce=t.nodes.find(F=>F.status==="inProgress"))==null?void 0:ce.id)??((xe=t.nodes[0])==null?void 0:xe.id)??"";const h=new Set([p]);let u="details",f="",g=1;const v=new Set,m=new Set,y=new Set,k=new Map,C=F=>t.nodes.find(O=>O.id===F),b=F=>{var O,q,K;return((K=(q=(O=e.context)==null?void 0:O.people)==null?void 0:q.find(ne=>ne.id===F))==null?void 0:K.name)??F??""},I=F=>`<i class="wf-dot ${F.status}" aria-hidden="true"></i>`,A=F=>`${I(F)}<strong>${D(F.name)}</strong><span class="wf-status ${F.status}">${_t[F.status]}</span>`,E=()=>xa(t);function G(F,O,q){var ne;const K=e.onCommand||(F==="configure"?e.onFlowChange:F==="action"?e.onAction:F==="create-task"?e.onCreateTask||e.onChange:F==="delete"?e.onDelete:F==="complete"&&e.onComplete||e.onChange);return!i&&!o&&!e.readonly&&!!K&&((ne=e.can)==null?void 0:ne.call(e,F,O,q))!==!1}function x(F){var O;if(F.type==="delete-node")return"delete";if(F.type==="update-flow")return"configure";if(F.type==="action")return F.actionId==="__create-task"?"create-task":"action";if(F.patch.status)return"complete";if(F.patch.tasks){const q=C(F.nodeId);return F.patch.tasks.length>(((O=q==null?void 0:q.tasks)==null?void 0:O.length)??0)?"create-task":"toggle-task"}return"edit"}function M(F){var q,K,ne,Q;const O={flow:t,signal:c.signal};return e.onCommand?e.onCommand(F,O):F.type==="delete-node"?(q=e.onDelete)==null?void 0:q.call(e,F.nodeId,O):F.type==="update-flow"?(K=e.onFlowChange)==null?void 0:K.call(e,F.detail,O):F.type==="action"?F.actionId==="__create-task"&&e.onCreateTask?e.onCreateTask(F.nodeId,O):(ne=e.onAction)==null?void 0:ne.call(e,F.nodeId,F.actionId,O):F.patch.status==="done"&&e.onComplete?e.onComplete(F.nodeId,O):(Q=e.onChange)==null?void 0:Q.call(e,F.nodeId,F.patch,F.detail,O)}async function N(F){var J;const O="nodeId"in F?C(F.nodeId):void 0,q=F.type==="action"?F.actionId:F.type==="update-node"?Object.keys(F.patch)[0]:void 0,K=F.type!=="update-node"||Object.keys(F.patch).every(ae=>G(x({...F,patch:{[ae]:F.patch[ae]}}),O,ae)),ne=F.type!=="update-node"||[...(F.patch.form??[]).filter(ae=>{var ie,ue;return ae.value!==((ue=(ie=O==null?void 0:O.form)==null?void 0:ie.find(pe=>pe.id===ae.id))==null?void 0:ue.value)}),...(F.patch.fields??[]).filter(ae=>{var ie,ue;return ae.value!==((ue=(ie=O==null?void 0:O.fields)==null?void 0:ie.find(pe=>pe.id===ae.id))==null?void 0:ue.value)})].every(ae=>{var ie,ue,pe;return((ie=e.can)==null?void 0:ie.call(e,"edit",O,ae.id))!==!1&&!((pe=(ue=O==null?void 0:O.fields)==null?void 0:ue.find(ve=>ve.id===ae.id))!=null&&pe.readonly)});if(!G(x(F),O,q)||!K||!ne||F.type==="delete-node"&&O&&!E().node(O).deletable)return i||Ee(),!1;const Q=a;o=!0,r.querySelectorAll(".wf-error").forEach(ae=>ae.remove()),H(r),H(d);let de,re=!1;try{const ae=M(F),ie=ae instanceof Promise?await ae:ae;return i?!1:(ie&&a===Q&&(t=ie,n=ie.detail,a++),!0)}catch(ae){return de=ae,re=!0,!1}finally{if(o=!1,!i&&(Ee(),re)){const ae=document.createElement("p");ae.className="wf-error",ae.role="alert",ae.textContent=de instanceof Error?de.message:"保存失败,请重试",r.querySelector(".wf-card-area").prepend(ae),(J=e.onError)==null||J.call(e,de,F)}}}function P(F){var O;(O=l.get(F))==null||O.forEach(q=>q()),l.delete(F)}function _(F,O){return{node:F,surface:O===r?"selected":"list",readonly:!G("edit",F),pending:o,signal:c.signal,context:e.context??{currentUser:e.currentUser,workItems:e.workItems},can:(q,K)=>G(q,F,K),commit:(q,K="更新节点字段")=>U(F,q,K),action:q=>N({type:"action",nodeId:F.id,actionId:q})}}function L(F){const O=[];l.set(F,O),F.querySelectorAll("[data-node]").forEach(q=>{var J,ae;const K=C(q.dataset.node);if(!K)return;const ne=_(K,F);e.renderTaskField&&q.querySelectorAll("[data-task-cell]").forEach(ie=>{var ke,we;const ue=(ke=K.tasks)==null?void 0:ke.find(Le=>Le.id===ie.dataset.taskCell),pe=(we=e.taskColumns)==null?void 0:we.call(e,K).find(Le=>Le.key===ie.dataset.taskColumn);if(!ue||!pe)return;const ve=e.renderTaskField(ie,ue,pe,ne);ve&&O.push(ve)}),e.renderTaskActions&&q.querySelectorAll("[data-task-actions]").forEach(ie=>{var ve;const ue=(ve=K.tasks)==null?void 0:ve.find(ke=>ke.id===ie.dataset.taskActions);if(!ue)return;const pe=e.renderTaskActions(ie,ue,ne);pe&&O.push(pe)});const Q=(F===r?"selected:":"list:")+K.id;if(m.has(Q)){const ie=q.querySelector(".wf-card-body"),ue=q.querySelector(".wf-node-schedule");ie&&(ie.hidden=!0),ue&&(ue.hidden=!0),(J=q.querySelector('[data-wf="collapse-card"]'))==null||J.setAttribute("aria-expanded","false")}if(y.has(Q)){const ie=q.querySelector(".wf-task-table");ie&&(ie.hidden=!0),(ae=q.querySelector('[data-wf="toggle-tasks"]'))==null||ae.setAttribute("aria-expanded","false")}const de=q.querySelector("[data-node-fields-slot]");if(de&&e.renderNodeFields){const ie=e.renderNodeFields(K,de,ne);ie&&O.push(ie)}const re=q.querySelector("[data-node-form-slot]");if(re&&e.renderNodeForm){const ie=e.renderNodeForm(K,re,ne);ie&&O.push(ie)}if(e.renderField&&q.querySelectorAll("[data-field-slot]").forEach(ie=>{var ve;const ue=[...E().node(K).form,...K.fields??[]].find(ke=>ke.id===ie.dataset.fieldSlot);if(!ue)return;const pe=e.renderField(ie,ue,{...ne,readonly:ne.readonly||((ve=e.can)==null?void 0:ve.call(e,"edit",K,ue.id))===!1||"readonly"in ue&&!!ue.readonly});pe&&O.push(pe)}),e.renderSystemField&&q.querySelectorAll("[data-system-slot]").forEach(ie=>{var ve;const ue=E().node(K).fields.find(ke=>ke.key===ie.dataset.systemSlot);if(!ue)return;const pe=e.renderSystemField(ie,ue,{...ne,readonly:ne.readonly||((ve=e.can)==null?void 0:ve.call(e,"edit",K,ue.key))===!1});pe&&O.push(pe)}),e.renderActions){const ie=q.querySelector("[data-actions-slot]");if(ie){const ue=e.renderActions(ie,K.buttons??[],ne);ue&&O.push(ue)}}}),H(F)}function H(F){F.setAttribute("aria-busy",String(o)),F.querySelectorAll("input,button,select").forEach(O=>{var de,re,J;const q=C(((de=O.closest("[data-node]"))==null?void 0:de.dataset.node)??""),K=O.dataset.wf;let ne,Q;(O.dataset.field||O.dataset.form||O.dataset.nodeField||K==="edit-reference"||K==="estimate")&&(ne="edit",Q=O.dataset.field??O.dataset.form??O.dataset.nodeField??O.dataset.referenceField??"estimate"),O.dataset.task&&(ne="toggle-task"),K==="add-task"&&(ne="create-task"),K==="complete"&&(ne="complete"),(K==="delete-node"||K==="confirm-delete")&&(ne="delete"),(O.dataset.switch||O.dataset.removeTag)&&(ne="configure"),(O.dataset.action||K==="group-chat")&&(ne="action",Q=O.dataset.action??K),ne&&(O.disabled=!G(ne,q,Q)||ne==="delete"&&!!q&&!E().node(q).deletable||!!O.dataset.nodeField&&!!((J=(re=q==null?void 0:q.fields)==null?void 0:re.find(ae=>ae.id===O.dataset.nodeField))!=null&&J.readonly))})}function T(F){var O;return!((O=F.fields)!=null&&O.length)||e.renderNodeForm?"":'<div class="wf-node-form"><div class="wf-form-fields">'+F.fields.map(q=>e.renderField?'<div data-field-slot="'+D(q.id)+'"></div>':"<label><span>"+D(q.label)+'</span><input data-node-field="'+D(q.id)+'" aria-label="'+D(q.label)+'" value="'+D(q.value??"")+'"></label>').join("")+"</div></div>"}function R(F,O){return e.renderActions?O==="inline"?"<span data-actions-slot></span>":"":(F.buttons??[]).filter(q=>(q.placement??"inline")===O).map(q=>'<button type="button" data-action="'+D(q.id)+'" class="wf-custom-action '+D(q.variant??"normal")+'" title="'+D(q.hint??"")+'">'+D(q.label)+"</button>").join("")}function $(F,O){var It,At;const q=`${O}:${F.id}`,K=F.tasks??[],ne=k.get(q)??0,Q=K.filter(ee=>{var Ce;return ne===2?!ee.done:ne===3?ee.done:ne===1?ee.owner===(((Ce=e.context)==null?void 0:Ce.currentUser)??e.currentUser??"体验官"):!0}),de=((It=e.taskColumns)==null?void 0:It.call(e,F))??[],re=[{key:"name",label:"名称",width:250},{key:"owner",label:"当前负责人",width:150},{key:"deliverable",label:"交付物",expanded:!0},{key:"estimate",label:"估分"},{key:"schedule",label:"排期",width:190}],J=e.taskColumnsMode==="replace"?de:[...re.filter(ee=>!de.some(Ce=>Ce.key===ee.key)),...de],ae=ee=>ee.expanded??!["name","owner","estimate","actual","schedule","dependency"].includes(ee.key),ie=((At=e.taskCanExpand)==null?void 0:At.call(e,F))??(de.some(ae)||K.some(ee=>!!ee.deliverable)),ue=ie&&v.has(q),pe=ue?J.filter(ae):[],ve=ue?J.filter(ee=>!ae(ee)&&!("hideWhenExpanded"in ee&&ee.hideWhenExpanded)):J,ke=' style="grid-template-columns:'+ve.map(ee=>ee.key==="name"?"minmax(250px,1fr)":Math.max(80,ee.width??140)+"px").join(" ")+";min-width:"+ve.reduce((ee,Ce)=>ee+(Ce.width??(Ce.key==="name"?250:140)),0)+'px"',we=(ee,Ce)=>String(ee[Ce]??""),Le=(ee,Ce)=>{if(Ce==="name")return`<label><input type="checkbox" data-task="${D(ee.id)}" aria-label="完成任务:${D(ee.name)}" ${ee.done?"checked":""}><span title="${D(ee.name)}">${D(ee.name)}</span>${ue&&ee.done?'<b class="wf-task-status">已完成</b>':""}${e.renderTaskActions?`<span class="wf-task-actions" data-task-actions="${D(ee.id)}"></span>`:""}</label>`;if(de.some(Kt=>Kt.key===Ce))return`<div class="wf-task-value" data-task-cell="${D(ee.id)}" data-task-column="${D(Ce)}"></div>`;const it=Ce==="owner"?b(we(ee,Ce)):we(ee,Ce);return`<span class="${Ce==="deliverable"?"wf-task-deliverable":""}" title="${D(it||"暂无")}">${D(it||(ue?"待填":"暂无"))}</span>`},wt=Q.map(ee=>`<div class="wf-task-row"${ke}>${ve.map(Ce=>Le(ee,Ce.key)).join("")}</div>${pe.length?`<div class="wf-task-details" data-task-details="${D(ee.id)}">${pe.map(Ce=>`<div class="wf-task-detail"><span class="wf-task-detail-label">${D(Ce.label)}</span>${Le(ee,Ce.key)}</div>`).join("")}</div>`:""}`).join("");return`<section class="wf-tasks" data-module="node:task"><div class="wf-section-head"><div class="wf-task-title"><button type="button" data-wf="toggle-tasks" aria-label="折叠任务" aria-expanded="true"><span class="wf-caret">${$e("caret")}</span></button><button type="button" data-wf="task-filter">${["全部任务","我参与的","未完成","已完成"][ne]} (${K.filter(ee=>ee.done).length}/${K.length}) ${$e("chevron")}</button></div>${ie?`<button type="button" data-wf="expand-tasks">${$e(ue?"list":"expand")} ${ue?"列表模式":"展开模式"}</button>`:""}</div><div class="wf-task-table ${ue?"is-expanded":""}"><div class="wf-task-row wf-task-heading"${ke}>${ve.map(ee=>`<span>${D(ue?ee.expandedLabel??ee.label:ee.label)}</span>`).join("")}</div>${wt}<button type="button" class="wf-add-task" data-wf="add-task">${$e("plus")} 新增任务</button></div></section>`}function z(F){return e.renderNodeFields?'<div class="wf-fields" data-module="node:schedule" data-node-fields-slot></div>':'<div class="wf-fields" data-module="node:schedule">'+E().node(F).fields.map(O=>{var Q;const q=F[O.key]??"",K=(Q=e.context)==null?void 0:Q.people,ne=e.renderSystemField?'<span data-system-slot="'+O.key+'"></span>':O.key==="owner"&&K?'<select data-field="owner" aria-label="'+D(O.label)+'"><option value="">待填</option>'+(q&&!K.some(de=>de.id===q)?'<option selected value="'+D(q)+'">'+D(q)+"</option>":"")+K.map(de=>'<option value="'+D(de.id)+'"'+(de.id===q?" selected":"")+">"+D(de.name)+"</option>").join("")+"</select>":'<input data-field="'+O.key+'" aria-label="'+D(O.label)+'" placeholder="待填" value="'+D(q)+'">';return'<label class="wf-field-'+O.key+'"><span>'+D(O.label)+"</span>"+ne+"</label>"}).join("")+"</div>"}function j(F){if(e.renderNodeForm)return'<details class="wf-node-form" data-module="node:form" open><summary><span class="wf-caret">'+$e("caret")+'</span>节点表单</summary><div class="wf-form-fields" data-node-form-slot></div></details>';const O=E().node(F).form;return O.length?`<details class="wf-node-form" data-module="node:form" open><summary><span class="wf-caret">${$e("caret")}</span>节点表单</summary><div class="wf-form-fields">${O.map(q=>`<div class="wf-form-row"><label><span>${D(q.label)}${q.required?"<b> *</b>":""}</span>${e.renderField?`<span data-field-slot="${D(q.id)}"></span>`:q.control==="workItemSelect"?`<button type="button" class="wf-reference-field ${q.value?"":"is-empty"}" data-wf="edit-reference" data-reference-field="${D(q.id)}" aria-label="${D(q.label)}"><span>${q.value?q.value.split(",").map(K=>{var ne,Q,de;return D(((de=(Q=((ne=e.context)==null?void 0:ne.workItems)??e.workItems)==null?void 0:Q.find(re=>re.id===K))==null?void 0:de.name)??K)}).join("、"):"待填"}</span>${$e("chevron")}</button>`:q.type==="select"?`<select data-form="${D(q.id)}" aria-label="${D(q.label)}"><option value="">待填</option>${(q.options??[]).map(K=>`<option ${K===q.value?"selected":""}>${D(K)}</option>`).join("")}</select>`:`<input data-form="${D(q.id)}" type="${q.type==="date"?"date":q.type==="number"?"number":"text"}" aria-label="${D(q.label)}" placeholder="待填" value="${D(q.value||"")}">`}</label></div>`).join("")}</div></details>`:""}function te(F,O){return O?"":`<div class="wf-card-actions" data-module="node:button-group">${F.status==="inProgress"?`<button type="button" class="wf-complete" data-wf="complete">${D(E().node(F).completeLabel)}</button>`:`<span class="wf-state-hint">${_t[F.status]}</span>`}${R(F,"inline")}<button type="button" data-wf="more" class="wf-more" aria-label="节点更多操作" aria-expanded="false">${$e("more")}</button></div>`}function he(F,O=!1,q="selected"){const ne=E().node(F).sections.map(Q=>Q==="form"?O?"":j(F):$(F,q)).join("");return`<article class="wf-card" data-module="workflow:node" data-surface="${q}" data-node="${D(F.id)}"><div class="wf-node-basic" data-module="node:basic"><header class="wf-card-head"><button type="button" class="wf-card-title" data-wf="collapse-card" aria-expanded="true"><span class="wf-caret">${$e("caret")}</span>${A(F)}</button>${te(F,O)}</header><div class="wf-node-schedule">${z(F)}</div></div><div class="wf-card-body wf-node-sections">${O?"":T(F)}${ne}</div></article>`}function ge(){r.querySelector(".wf-meta").innerHTML=`<div class="wf-roles">${((n==null?void 0:n.tags)??[]).filter(F=>F.enabled!==!1).map(F=>`<span class="wf-role" style="background:${D(F.color||"#eff0f1")}">${D(F.label)}<button type="button" data-remove-tag="${D(F.id)}" aria-label="移除${D(F.label)}">×</button></span>`).join("")}</div>${n!=null&&n.tags.length&&n.switches.length?'<i class="wf-meta-divider"></i>':""}${((n==null?void 0:n.switches)??[]).map(F=>`<label class="wf-switch"><input type="checkbox" data-switch="${D(F.id)}" ${F.checked?"checked":""}>${D(F.label)}</label>`).join("")}`,H(r)}function be(){const F=r.querySelector(".wf-canvas-viewport"),O=F.scrollLeft,{nodes:q,paths:K,width:ne}=Ma(E().graph);F.innerHTML=`<div class="wf-graph-size" style="width:${ne*g}px;height:${420*g}px"><div class="wf-graph" style="width:${ne}px;transform:scale(${g})"><svg width="${ne}" height="420" aria-hidden="true">${K.map(Q=>`<path d="${Q}"/>`).join("")}</svg>${q.map(({node:Q,x:de,y:re,width:J})=>`<button type="button" class="wf-node ${Q.id===p?"is-selected":""}" data-select-node="${D(Q.id)}" aria-pressed="${Q.id===p}" style="left:${de}px;top:${re}px;width:${J}px">${I(Q)}<span>${D(Q.name)}</span></button>`).join("")}</div></div>`,F.scrollLeft=O}function fe(){P(r);const F=C(p);r.querySelector(".wf-card-area").innerHTML=F?he(F):'<p class="wf-empty">暂无节点</p>',L(r)}function me(){P(d),d.innerHTML=`<div class="wf-list-toolbar"><div class="wf-filter-wrap"><button type="button" data-wf="filter" class="wf-filter-button">${$e("filter")} 筛选 ${$e("chevron")}</button><div class="wf-filter-menu" hidden><label>节点状态<select data-status-filter aria-label="筛选节点状态"><option value="">全部状态</option>${Object.entries(_t).map(([F,O])=>`<option value="${F}" ${f===F?"selected":""}>${O}</option>`).join("")}</select></label></div></div><div class="wf-views" role="tablist" aria-label="节点视图"><button type="button" role="tab" data-view="details" aria-selected="${u==="details"}">${$e("detail")} 节点详情</button><button type="button" role="tab" data-view="schedule" aria-selected="${u==="schedule"}">${$e("list")} 排期信息</button></div></div><div class="wf-list-rows">${E().nodeList.filter(F=>!f||F.status===f).map(F=>h.has(F.id)?he(F,u==="schedule","list"):`<div class="wf-list-row" data-node="${D(F.id)}"><button type="button" data-wf="expand-card" class="wf-row-title" aria-expanded="false"><span class="wf-caret is-folded">${$e("caret")}</span>${A(F)}</button><span>${D(b(F.owner)||"待填")}</span><span>${D(F.estimate||"待填")}</span><span>${D(F.schedule||"待填")}</span>${u==="details"?`<span class="wf-state-hint">${_t[F.status]}</span><button type="button" data-wf="more" class="wf-more" aria-label="节点更多操作">${$e("more")}</button>`:""}</div>`).join("")||'<p class="wf-empty">暂无匹配节点</p>'}</div>`,L(d)}function Ee(){var F;E().graph.nodes.some(O=>O.id===p)||(p=((F=E().graph.nodes[0])==null?void 0:F.id)??""),ge(),be(),fe(),me()}function Me(F){var O;i||!E().graph.nodes.some(q=>q.id===F)||(p=F,(O=e.onSelectNode)==null||O.call(e,F),be(),fe())}function U(F,O,q){return N({type:"update-node",nodeId:F.id,patch:O,detail:q})}function se(F,O,q,K){var re;(re=F.querySelector(".wf-inline-editor"))==null||re.remove();const ne=document.createElement("div");ne.className="wf-inline-editor",ne.innerHTML=`<input aria-label="${D(O)}" placeholder="${D(O)}" value="${D(q)}"><button type="button" data-save>保存</button><button type="button" data-cancel>取消</button>`,F.append(ne);const Q=ne.querySelector("input"),de=()=>{Q.value.trim()?K(Q.value.trim()):Q.focus()};ne.querySelector("[data-save]").addEventListener("click",de),ne.querySelector("[data-cancel]").addEventListener("click",()=>ne.remove()),Q.addEventListener("keydown",J=>{J.key==="Enter"&&(J.preventDefault(),de()),J.key==="Escape"&&ne.remove()}),Q.focus()}function X(F,O,q){var ae,ie,ue,pe;const K=(ae=O.form)==null?void 0:ae.find(ve=>ve.id===q);if(!K)return;(ie=F.querySelector(".wf-reference-picker"))==null||ie.remove();const ne=new Set(((ue=K.value)==null?void 0:ue.split(",").filter(Boolean))??[]),Q=document.createElement("div");Q.className="wf-reference-picker",Q.setAttribute("role","dialog"),Q.setAttribute("aria-label",`选择${K.label}`),Q.innerHTML='<input aria-label="查找工作项" placeholder="搜索工作项"><div class="wf-reference-options"></div><footer><button type="button" data-cancel>取消</button><button type="button" data-save>确定</button></footer>',(pe=Array.from(F.querySelectorAll("[data-reference-field]")).find(ve=>ve.dataset.referenceField===q))==null||pe.after(Q);const de=Q.querySelector("input"),re=Q.querySelector(".wf-reference-options"),J=()=>{var ke;const ve=(((ke=e.context)==null?void 0:ke.workItems)??e.workItems??[]).filter(we=>we.name.includes(de.value)).slice(0,50);re.innerHTML=ve.map(we=>`<label><input type="checkbox" value="${D(we.id)}" ${ne.has(we.id)?"checked":""}><span>${D(we.name)}</span></label>`).join("")||"<p>暂无匹配工作项</p>"};re.addEventListener("change",ve=>{const ke=ve.target;ke.checked?ne.add(ke.value):ne.delete(ke.value)}),de.addEventListener("input",J),Q.querySelector("[data-cancel]").addEventListener("click",()=>Q.remove()),Q.querySelector("[data-save]").addEventListener("click",()=>{var ve;return U(O,{form:(ve=O.form)==null?void 0:ve.map(ke=>ke.id===q?{...ke,value:[...ne].join(",")}:ke)},`更新${K.label}`)}),Q.addEventListener("keydown",ve=>{ve.key==="Escape"&&Q.remove()}),J(),de.focus()}function W(F,O){var Q,de,re,J;const q=[...E().node(F).form,...F.fields??[]].find(ae=>{var ie;return ae.required&&!((ie=ae.value)!=null&&ie.trim())}),K=(Q=F.tasks)==null?void 0:Q.find(ae=>ae.blocking&&!ae.done);(de=O.querySelector(".wf-error"))==null||de.remove();const ne=(re=F.gates)==null?void 0:re.find(ae=>!ae.met);if(q||K||ne){const ae=document.createElement("p");ae.className="wf-error",ae.role="alert",ae.textContent=q?`请先填写${q.label}`:K?`请先完成任务:${K.name}`:ne.label,(J=O.querySelector(".wf-card-head"))==null||J.after(ae);return}U(F,{status:"done"},"完成节点")}function Z(F){var ue,pe,ve,ke;const O=F.target;if(O.closest("button:disabled"))return;const q=O.closest("[data-action]");if(q){const we=(ue=q.closest("[data-node]"))==null?void 0:ue.dataset.node;we&&N({type:"action",nodeId:we,actionId:q.dataset.action});return}const K=O.closest("[data-select-node]");if(K){Me(K.dataset.selectNode);return}const ne=O.closest("[data-view]");if(ne){u=ne.dataset.view,me();return}const Q=O.closest("[data-remove-tag]");if(Q&&n){N({type:"update-flow",detail:{...n,tags:n.tags.map(we=>we.id===Q.dataset.removeTag?{...we,enabled:!1}:we)}});return}const de=O.closest("[data-wf]");if(!de)return;const re=de.dataset.wf,J=de.closest("[data-node]"),ae=C((J==null?void 0:J.dataset.node)??p);if(re==="legend"){const we=de.closest(".wf-legend-wrap");we.classList.toggle("is-open"),de.setAttribute("aria-expanded",String(we.classList.contains("is-open")));return}if(re==="filter"){const we=d.querySelector(".wf-filter-menu");we.hidden=!we.hidden;return}if(!ae||!J)return;const ie=`${J.dataset.surface??"list"}:${ae.id}`;if(re==="edit-reference"){X(J,ae,de.dataset.referenceField);return}if(re==="collapse-card")if(m.has(ie)?m.delete(ie):m.add(ie),d.contains(J))h.delete(ae.id),me();else{const we=J.querySelector(".wf-card-body");we.hidden=!we.hidden,J.querySelector(".wf-node-schedule").hidden=we.hidden,de.setAttribute("aria-expanded",String(!we.hidden))}else if(re==="expand-card")m.delete(ie),h.add(ae.id),me();else if(re==="toggle-tasks"){y.has(ie)?y.delete(ie):y.add(ie);const we=J.querySelector(".wf-task-table");we.hidden=!we.hidden,de.setAttribute("aria-expanded",String(!we.hidden))}else if(re==="task-filter"){const we=J.querySelector(".wf-task-filter-menu");if(we){we.remove();return}de.insertAdjacentHTML("afterend",'<div class="wf-task-filter-menu" role="menu">'+["全部任务","我参与的","未完成","已完成"].map((Le,wt)=>`<button type="button" role="menuitem" data-wf="task-filter-option" data-task-filter="${wt}">${Le}</button>`).join("")+"</div>")}else if(re==="task-filter-option")k.set(ie,Number(de.dataset.taskFilter)),fe(),me();else if(re==="expand-tasks")v.has(ie)?v.delete(ie):v.add(ie),fe(),me();else if(re==="add-task"&&e.onCreateTask)N({type:"action",nodeId:ae.id,actionId:"__create-task"});else if(re==="add-task")se(J.querySelector(".wf-task-table"),"任务名称","",we=>U(ae,{tasks:[...ae.tasks??[],{id:crypto.randomUUID(),name:we,done:!1}]},"新增任务"));else if(re==="complete")W(ae,J);else if(re==="more"){const we=J.querySelector(".wf-menu");r.querySelectorAll(".wf-menu").forEach(Le=>Le.remove()),d.querySelectorAll(".wf-menu").forEach(Le=>Le.remove()),we||J.insertAdjacentHTML("beforeend",`<div class="wf-menu" role="menu">${((n==null?void 0:n.menu)??[]).map(Le=>`<button type="button" role="menuitem" data-wf="${Le}" ${Le==="delete-node"&&!E().node(ae).deletable?"disabled":""}>${Le==="delete-node"&&!E().node(ae).deletable?'<span title="流程配置不允许删除该节点">'+Si[Le]+"</span>":Si[Le]}</button>`).join("")}${R(ae,"more")}</div>`),H(J)}else re==="estimate"?((pe=J.querySelector(".wf-menu"))==null||pe.remove(),se(J,"节点估分",ae.estimate??"",we=>U(ae,{estimate:we},"填写估分"))):re==="group-chat"?N({type:"action",nodeId:ae.id,actionId:"group-chat"}):re==="delete-node"?((ve=J.querySelector(".wf-menu"))==null||ve.remove(),J.insertAdjacentHTML("beforeend",'<div class="wf-delete-confirm" role="alertdialog" aria-label="删除节点"><span>删除此节点?</span><button type="button" data-wf="cancel-delete">取消</button><button type="button" data-wf="confirm-delete">删除</button></div>')):re==="cancel-delete"?(ke=J.querySelector(".wf-delete-confirm"))==null||ke.remove():re==="confirm-delete"&&N({type:"delete-node",nodeId:ae.id})}function le(F){var K,ne,Q,de,re,J,ae;const O=F.target;if(!(O instanceof HTMLInputElement||O instanceof HTMLSelectElement)||O.closest("[data-node-fields-slot],[data-node-form-slot],[data-field-slot],[data-system-slot],[data-actions-slot],[data-task-cell]"))return;if(O.dataset.statusFilter!==void 0){f=O.value,me();return}if(O.dataset.switch&&n&&O instanceof HTMLInputElement){const ie=O.checked;N({type:"update-flow",detail:{...n,switches:n.switches.map(ue=>ue.id===O.dataset.switch?{...ue,checked:ie}:ue)}});return}const q=C(((K=O.closest("[data-node]"))==null?void 0:K.dataset.node)??"");if(q){if(O.dataset.nodeField){const ie=(ne=q.fields)==null?void 0:ne.find(ue=>ue.id===O.dataset.nodeField);if(ie!=null&&ie.readonly||((Q=e.can)==null?void 0:Q.call(e,"edit",q,O.dataset.nodeField))===!1){Ee();return}U(q,{fields:(de=q.fields)==null?void 0:de.map(ue=>ue.id===O.dataset.nodeField?{...ue,value:O.value}:ue)},"更新节点字段")}if(O.dataset.form&&((re=e.can)==null?void 0:re.call(e,"edit",q,O.dataset.form))===!1){Ee();return}O.dataset.field&&U(q,{[O.dataset.field]:O.value},`更新${O.ariaLabel}`),O.dataset.form&&U(q,{form:(J=q.form)==null?void 0:J.map(ie=>ie.id===O.dataset.form?{...ie,value:O.value}:ie)},"填写节点表单"),O.dataset.task&&O instanceof HTMLInputElement&&U(q,{tasks:(ae=q.tasks)==null?void 0:ae.map(ie=>ie.id===O.dataset.task?{...ie,done:O.checked}:ie)},"更新节点任务")}}r.innerHTML=`<div class="wf-workflow-graph" data-module="workflow:graph"><div class="wf-meta" data-module="workflow:graph:controls"></div><div class="wf-canvas" data-module="workflow:graph:canvas"><div class="wf-legend-wrap"><button type="button" class="wf-legend-trigger" data-wf="legend" aria-label="节点图例" aria-expanded="false">${$e("list")}</button><div class="wf-legend" role="tooltip"><strong>节点图例</strong><span>○ 节点</span><span>◇ 里程碑</span><span>⊙ 含未完成子任务</span><span><i class="wf-dot pending"></i>未开始</span><span><i class="wf-dot inProgress"></i>进行中</span><span><i class="wf-dot done"></i>已完成</span></div></div><div class="wf-canvas-viewport" aria-label="节点流程图"></div></div></div><div class="wf-card-area" data-module="workflow:selected-node"></div>`;for(const F of[r,d])F.addEventListener("click",Z,{signal:c.signal}),F.addEventListener("change",le,{signal:c.signal});document.addEventListener("pointerdown",F=>{F.target.closest(".wf-task-title")||(r.querySelectorAll(".wf-task-filter-menu").forEach(O=>O.remove()),d.querySelectorAll(".wf-task-filter-menu").forEach(O=>O.remove())),F.target.closest(".wf-menu,.wf-more")||(r.querySelectorAll(".wf-menu").forEach(O=>O.remove()),d.querySelectorAll(".wf-menu").forEach(O=>O.remove()))},{signal:c.signal});const S=r.querySelector(".wf-canvas-viewport");let V=null;S.addEventListener("pointerdown",F=>{F.target.closest("button")||(V={x:F.clientX,y:F.clientY,left:S.scrollLeft,top:S.scrollTop},S.setPointerCapture(F.pointerId))},{signal:c.signal}),S.addEventListener("pointermove",F=>{V&&(S.scrollLeft=V.left+V.x-F.clientX,S.scrollTop=V.top+V.y-F.clientY)},{signal:c.signal});const oe=()=>{V=null};return S.addEventListener("pointerup",oe,{signal:c.signal}),S.addEventListener("pointercancel",oe,{signal:c.signal}),S.addEventListener("wheel",F=>{(F.ctrlKey||F.metaKey)&&(F.preventDefault(),g=Math.max(.5,Math.min(1.5,g+(F.deltaY<0?.1:-.1))),be())},{passive:!1,signal:c.signal}),Ee(),{element:r,nodeListElement:d,renderNodeDetails:()=>d,selectNode:Me,getSelectedNode:()=>C(p),setFlow(F){i||(t=F,n=F.detail,a++,Ee())},update(F){i||(e={...e,...F},F.flow&&(t=F.flow,n=F.flow.detail,a++),F.selectedNodeId!==void 0&&(p=F.selectedNodeId),Ee())},destroy(){i=!0,c.abort(),P(r),P(d),r.remove(),d.remove()}}}function B(s,e="",t){const n=document.createElement(s);return n.className=e,t!==void 0&&(n.textContent=t),n}const pt=new Map;function Ye(s,e){if(!s)return!1;const t=e?[e]:[],n=new Set;for(let i=0;i<Math.max(1,t.length);i++)for(const[o,a]of pt)if(!(n.has(o)||e&&!t[i].contains(a))){if(o.element.contains(s))return!0;n.add(o),t.push(o.element)}return!1}function La(s){for(const[e,t]of[...pt])(!s||s.contains(t))&&e.close()}function Rt(s){const{anchor:e,content:t,width:n="anchor",gap:i=4,onDismiss:o}=s,a=e.ownerDocument,l=a.defaultView||window,r=s.anchorMode==="element"?e:e.closest(".fc-focus-body")||e,d=a.createElement("div");d.className="rowvia-field-scope rowvia-field-popup-layer";const c=a.createElement("div");c.className="rowvia-field-popup",c.append(t),d.append(c),(e.closest("dialog[open]")||a.body||a.documentElement).append(d);let p=!1;const h=()=>{if(p||!d.isConnected)return;const m=r.getBoundingClientRect(),y=a.documentElement.clientWidth||l.innerWidth,k=a.documentElement.clientHeight||l.innerHeight,C=n==="anchor"?m.width+2:n==="auto"?c.getBoundingClientRect().width:n;c.style.width=n==="auto"?"max-content":C+"px";const b=c.getBoundingClientRect().height;let I=m.bottom+i;const A=m.top-i-b;I+b>k-8&&A>=8&&(I=A),I=Math.max(8,Math.min(I,Math.max(8,k-b-8)));const E=Math.max(8,Math.min(s.align==="end"?m.right-C:m.left,Math.max(8,y-C-8)));d.style.top=Math.round(I)+"px",d.style.left=Math.round(E)+"px"},u=()=>{p||(p=!0,La(d),pt.delete(v),a.removeEventListener("pointerdown",f,!0),a.removeEventListener("keydown",g,!0),l.removeEventListener("resize",h),l.removeEventListener("scroll",h,!0),d.remove(),o==null||o())},f=m=>{const y=m.target;y&&(d.contains(y)||r.contains(y)||e.contains(y)||Ye(y,d))||u()},g=m=>{if(m.key!=="Escape"||[...pt.keys()][pt.size-1]!==v)return;if(m.preventDefault(),m.stopPropagation(),u(),s.onEscape){s.onEscape();return}const y=a.defaultView.CustomEvent;e.dispatchEvent(new y("fc-collapse",{bubbles:!0,detail:{reason:"escape"}}))},v={element:d,reposition:h,close:u};return pt.set(v,e),a.addEventListener("pointerdown",f,!0),a.addEventListener("keydown",g,!0),l.addEventListener("resize",h),l.addEventListener("scroll",h,!0),h(),v}const Ue=s=>s.choices??(s.options||[]).map(e=>({id:e,label:e})),Ei=["rgba(61, 188, 47, 0.2)","rgba(0, 184, 159, 0.2)","rgba(244, 118, 189, 0.2)","rgba(149, 155, 238, 0.2)","rgba(184, 143, 255, 0.2)"],cn=(s,e)=>{var t,n;return((t=Ue(s).find(i=>i.id===e))==null?void 0:t.color)||((n=s.colors)==null?void 0:n[e])||Ei[Math.max(0,Ue(s).findIndex(i=>i.id===e))%Ei.length]},xi=s=>(Array.isArray(s)?s:s==null||s===""?[]:[s]).map(String);function Ta(s,e){var t;return((t=Ue(s).find(n=>n.id===e))==null?void 0:t.label)||e}function Na(s,e="choice"){const t=B("div","fc-tags");for(const n of xi(s.value)){const i=Ta(s.field,n),o=B(e==="relation"?"button":"span","fc-tag fc-tag--"+e);e==="choice"&&(o.style.backgroundColor=cn(s.field,n)),e==="person"&&o.append(B("span","fc-avatar",i.slice(0,1))),o.append(B("span","fc-tag-label",i)),o.tagName==="BUTTON"&&(o.type="button",o.onclick=a=>{var l;a.stopPropagation(),(l=s.onAction)==null||l.call(s,{type:"open",value:n})}),t.append(o)}return t.children.length||t.append(B("span","fc-empty","待填")),t}function ki(s,e,t="choice"){var T;const n=B("div","fc-choice fc-choice--"+t);let i=xi(e.value).slice(0,s?void 0:1);const o=new Map(Ue(e.field).map(R=>[R.id,R]));let a=Ue(e.field);const l=s&&(e.field.maxSelections??0)>0?e.field.maxSelections:1/0,r=B("select","fc-select");r.hidden=!0,r.multiple=s,r.disabled=e.readonly,r.required=!!e.field.required,r.ariaLabel=e.field.label;const d=B("div","fc-choice-head"),c=B("div","fc-choice-selection"),p=B("span","fc-empty fc-choice-placeholder","待填"),h=B("input","fc-choice-search");h.placeholder="",h.autocomplete="off",h.ariaLabel="输入以搜索"+e.field.label,h.disabled=e.readonly;const u=()=>{h.size=Math.max(1,[...h.value].length+1)};u();const f=B("div","fc-option-list");f.setAttribute("role",t==="radio"?"radiogroup":"group"),f.ariaLabel=e.field.label;const g=B("div","fc-error fc-choice-feedback");g.setAttribute("role","status");const v=B("div","fc-picker-status");v.setAttribute("role","status");const m=B("button","fc-retry","重试");m.type="button",m.hidden=!0;let y,k=0,C=!1,b=!1;const I=t!=="radio"&&!!((T=e.services)!=null&&T.searchOptions),A=t!=="radio"&&e.layout!=="compact"&&!e.readonly;let E;const G=()=>{const R=E;E=void 0,R==null||R.close()},x=()=>{!A||C||E||e.readonly||(E=Rt({anchor:d,content:f,width:"anchor",onDismiss:()=>{E=void 0}}))},M=()=>{!A||!E||(G(),n.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},N=()=>{var R;(R=e.onSelectedOptions)==null||R.call(e,i.map($=>o.get($)).filter($=>!!$)),n.dispatchEvent(new Event("change",{bubbles:!0}))},P=()=>{var R;if(r.replaceChildren(),!s){const $=B("option");$.value="",r.append($)}for(const $ of new Set([...a.map(z=>z.id),...i])){const z=B("option","",((R=o.get($))==null?void 0:R.label)||$);z.value=$,z.selected=i.includes($),r.append(z)}s||(r.value=i[0]||"")},_=()=>{c.replaceChildren(),f.replaceChildren(),P(),!i.length&&!h.value&&c.append(p);for(const z of i){const j=o.get(z),te=B("span","fc-tag fc-tag--"+t);(t==="choice"||t==="radio")&&(te.style.backgroundColor=cn(e.field,z)),t==="person"&&te.append(B("span","fc-avatar",((j==null?void 0:j.label)||z).slice(0,1))),te.append(B("span","fc-tag-label",((j==null?void 0:j.label)||z)+(j!=null&&j.disabled?"(已停用)":"")));const he=B("span","fc-tag-slot"),ge=B("button","fc-choice-remove","×");ge.type="button",ge.disabled=e.readonly,ge.ariaLabel="移除"+((j==null?void 0:j.label)||z),ge.onclick=be=>{be.stopPropagation(),i=i.filter(fe=>fe!==z),g.textContent="",_(),h.focus(),N()},he.append(ge),te.append(he),c.append(te)}const R=h.value.trim().toLocaleLowerCase(),$=a.filter(z=>!z.disabled&&(I||(z.label+" "+z.id+" "+(z.description||"")).toLocaleLowerCase().includes(R)));for(const z of $){const j=B("button","fc-option");j.type="button",j.dataset.value=z.id,j.disabled=e.readonly||b;const te=i.includes(z.id);j.classList.toggle("selected",te),j.setAttribute(t==="radio"?"aria-checked":"aria-pressed",String(te)),t==="radio"&&j.setAttribute("role","radio");const he=B("span","fc-option-label"+(t==="choice"?" fc-tag":""),z.label);t==="choice"&&(he.style.backgroundColor=cn(e.field,z.id)),t==="person"&&j.append(B("span","fc-avatar",z.label.slice(0,1))),t==="relation"&&j.append(B("span","fc-relation-icon","↗"));const ge=B("span","fc-option-copy");ge.append(he),z.description&&ge.append(B("small","fc-option-description",z.description)),j.append(ge,B("span","fc-option-mark",te?"✓":"")),j.onclick=be=>{if(be.stopPropagation(),!e.readonly){if(!s)i=[z.id];else if(te)i=i.filter(fe=>fe!==z.id);else{const fe=z.exclusive?[]:i.filter(me=>{var Ee;return!((Ee=o.get(me))!=null&&Ee.exclusive)});if(fe.length>=l){g.textContent="最多可选择 "+l+" 项";return}i=[...fe,z.id]}g.textContent="",s||(h.value="",u()),_(),f.querySelectorAll("button").forEach(fe=>{fe.dataset.value===z.id&&fe.focus()}),N(),!s&&A&&M()}},f.append(j)}!$.length&&!b&&f.append(B("p","fc-empty fc-choice-empty","暂无匹配选项"))},L=async()=>{y==null||y.abort();const R=++k;y=new AbortController,b=!0,m.hidden=!0,v.textContent="加载中…",n.setAttribute("aria-busy","true"),_();try{const $=await e.services.searchOptions(e.field,h.value.trim(),y.signal);if(C||R!==k)return;a=$,$.forEach(z=>o.set(z.id,z)),v.textContent=""}catch{if(C||R!==k)return;a=[],v.textContent="加载失败,请重试",m.hidden=!1}finally{!C&&R===k&&(b=!1,n.setAttribute("aria-busy","false"),_())}};h.oninput=()=>{u(),I?L():_()},h.onfocus=()=>x(),d.onclick=R=>{R.target.closest("button")||h.focus()},m.onclick=()=>void L();const H=R=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(R.key))return;const $=[...f.querySelectorAll("button:not(:disabled)")];if(!$.length)return;R.preventDefault();const z=$.indexOf(document.activeElement),j=R.key==="Home"?0:R.key==="End"?$.length-1:(z+(R.key==="ArrowUp"||R.key==="ArrowLeft"?-1:1)+$.length)%$.length;$[j].focus()};if(f.onkeydown=H,h.onkeydown=R=>{R.key==="ArrowDown"&&(x(),H(R))},r.onchange=()=>{i=[...r.selectedOptions].map(R=>R.value).filter(Boolean),_()},d.append(c),t!=="radio"&&d.append(h),A){const R=B("span","fc-field-chevron");R.setAttribute("aria-hidden","true"),d.append(R),n.append(r,d,v,m,g)}else n.append(r,d,v,f,m,g);return _(),I&&!e.readonly&&L(),{element:n,content:A?f:void 0,read:()=>s?[...i]:i[0]||"",validate:()=>e.field.required&&!i.length?"请选择一个选项":i.length>l?"最多可选择 "+l+" 项":void 0,focus:()=>{var R;if(t==="radio"){(R=f.querySelector("button"))==null||R.focus();return}h.focus(),x()},deactivate:()=>{h.value="",u(),G()},destroy:()=>{C=!0,++k,y==null||y.abort(),G()}}}const Ia=new Set("P DIV BR STRONG B EM I U S STRIKE UL OL LI BLOCKQUOTE H1 H2 H3 H4 H5 SPAN FONT A IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),Mi=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function ft(s){const e=document.createElement("template");e.innerHTML=String(s??"");const t=n=>{for(const i of[...n.childNodes]){if(i.nodeType!==1)continue;const o=i;if(["SCRIPT","STYLE","IFRAME","OBJECT","SVG","MATH"].includes(o.tagName)){o.remove();continue}if(t(o),!Ia.has(o.tagName)){o.replaceWith(...o.childNodes);continue}if(o.tagName==="INPUT"&&o.getAttribute("type")!=="checkbox"){o.remove();continue}const a=o.getAttribute("href")||"",l=o.getAttribute("src")||"",r=o.getAttribute("alt")||"",d=o.getAttribute("data-person-id"),c=o.hasAttribute("checked"),p=o.getAttribute("data-task")==="true",h=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(f=>[f,o.style.getPropertyValue(f)]),u=o.tagName==="FONT"?o.getAttribute("color"):null;for(const f of[...o.attributes])o.removeAttribute(f.name);for(const[f,g]of h)(f==="color"||f==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(g):f==="text-align"?/^(left|center|right|justify)$/.test(g):f==="margin-left"?/^\d{1,3}px$/.test(g):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(g))&&o.style.setProperty(f,g);if(u&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(u)&&(o.style.color=u),o.tagName==="A"&&Mi(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="IMG"){if(!/^https?:\/\//i.test(l.trim())){o.remove();continue}o.setAttribute("src",l.trim()),o.setAttribute("alt",r),o.setAttribute("loading","lazy"),o.setAttribute("referrerpolicy","no-referrer")}o.tagName==="SPAN"&&d&&(o.setAttribute("data-person-id",d),o.setAttribute("contenteditable","false")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),c&&o.setAttribute("checked","")),p&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const un={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 Ri(s){const e=B("div",`fc-rich${s.layout==="compact"?" fc-rich-compact":""}`),t=B("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const n=B("div","fc-rich-tools");t.append(n);const i=B("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 o=B("div","fc-rich-menu");o.hidden=!0;let a=null,l=!1,r=[i.innerHTML],d=0,c=!1,p=null,h,u;const f=()=>{const T=window.getSelection();T!=null&&T.rangeCount&&i.contains(T.anchorNode)&&i.contains(T.focusNode)&&(a=T.getRangeAt(0).cloneRange())},g=()=>{i.focus();const T=window.getSelection();if(!T)return;const R=a&&i.contains(a.commonAncestorContainer)?a:document.createRange();R!==a&&(R.selectNodeContents(i),R.collapse(!1)),T.removeAllRanges(),T.addRange(R),a=R},v=()=>{var R;const T=u;u=void 0,T==null||T.close(),(R=h==null?void 0:h.destroy)==null||R.call(h),h=void 0,o.hidden=!0,o.replaceChildren()},m=new Map,y=()=>{var T;m.get("撤销").disabled=s.readonly||d===0,m.get("重做").disabled=s.readonly||d===r.length-1;for(const[R,$]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=m.get(R);if(!z)continue;const j=!!((T=document.queryCommandState)!=null&&T.call(document,$));z.classList.toggle("active",j),z.setAttribute("aria-pressed",String(j))}},k=()=>{c||(i.innerHTML!==r[d]&&(r=r.slice(0,d+1),r.push(i.innerHTML),r.length>100&&r.shift(),d=r.length-1),f(),y())},C=()=>{k(),i.dispatchEvent(new Event("change",{bubbles:!0}))},b=T=>{const R=d+T;R<0||R>=r.length||(d=R,c=!0,i.innerHTML=r[d],a=null,g(),c=!1,y(),i.dispatchEvent(new Event("change",{bubbles:!0})))},I=(T,R)=>{s.readonly||(g(),document.execCommand(T,!1,R),f(),v(),C())},A=T=>{if(s.readonly)return;g();const R=window.getSelection().getRangeAt(0);R.deleteContents(),R.insertNode(T),R.setStartAfter(T),R.collapse(!0),a=R.cloneRange(),v(),C()},E=(T,R,$,z=!0)=>{const j=B("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return j.type="button",j.ariaLabel=T,j.title=T,j.disabled=s.readonly,un[R]?j.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${un[R]}</svg>`:j.textContent=R,j.onmousedown=te=>{te.preventDefault(),f()},j.onclick=te=>{te.stopPropagation(),$()},n.append(j),m.set(T,j),j},G=(T,R)=>{if(!s.readonly){if(f(),!o.hidden&&o.ariaLabel===T){v();return}v(),o.className="fc-rich-menu",o.ariaLabel=T,o.hidden=!1,u=Rt({anchor:m.get(T),anchorMode:"element",content:o,width:"auto",onDismiss:v,onEscape:g}),R(),u==null||u.reposition()}},x=(T,R)=>{const $=B("button","fc-rich-menu-option",T);return $.type="button",$.onmousedown=z=>z.preventDefault(),$.onclick=z=>{z.stopPropagation(),R()},o.append($),$};E("撤销","undo",()=>b(-1),!1),E("重做","redo",()=>b(1),!1),E("格式刷","paint",()=>{f();const T=a==null?void 0:a.startContainer,R=(T==null?void 0:T.nodeType)===1?T:T==null?void 0:T.parentElement;!R||!i.contains(R)||(p={tag:/^(B|STRONG|I|EM|U|S)$/.test(R.tagName)?R.tagName.toLowerCase():"span",css:R.getAttribute("style")||""},m.get("格式刷").classList.add("active"))}),E("正文样式","Aa⌄",()=>G("正文样式",()=>{for(const[T,R]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])x(T,()=>I("formatBlock",R))}));const M=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[T,R,$]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])E(T,R,()=>G(T,()=>{o.classList.add("fc-rich-colors");for(const z of M){const j=x(z,()=>I($,z));j.textContent="",j.style.backgroundColor=z,j.ariaLabel=`${T} ${z}`}x("清除",()=>I($,$==="foreColor"?"#1f2329":"transparent"))}));for(const[T,R,$]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])E(T,R,()=>I($));E("对齐","☰⌄",()=>G("对齐",()=>{for(const[T,R]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])x(T,()=>I(R))})),E("有序列表","1≡",()=>I("insertOrderedList")),E("无序列表","•≡",()=>I("insertUnorderedList")),E("任务列表","task",()=>{g();const T=window.getSelection().getRangeAt(0),R=B("ul"),$=B("li");$.dataset.task="true";const z=B("input");z.type="checkbox",z.contentEditable="false",$.append(z,T.extractContents()),$.textContent||$.append(document.createTextNode("待办事项")),R.append($),A(R)}),E("引用","quote",()=>I("formatBlock","blockquote")),E("缩进","indent",()=>G("缩进",()=>{x("增加缩进",()=>I("indent")),x("减少缩进",()=>I("outdent"))})),E("分隔线","line",()=>A(B("hr"))),E("表格","table",()=>G("表格",()=>{const T=B("p","","选择行列"),R=B("div","fc-rich-table-grid");o.append(T,R);for(let $=1;$<=6;$++)for(let z=1;z<=6;z++){const j=B("button");j.type="button",j.ariaLabel=`${$}行${z}列表格`,j.dataset.row=String($),j.dataset.col=String(z),j.onmousedown=te=>te.preventDefault(),j.onmouseenter=()=>{T.textContent=`${$} × ${z}`,R.querySelectorAll("button").forEach(te=>te.classList.toggle("active",Number(te.dataset.row)<=$&&Number(te.dataset.col)<=z))},j.onclick=()=>{const te=B("table"),he=B("tbody");for(let be=0;be<$;be++){const fe=B("tr");for(let me=0;me<z;me++){const Ee=B("td");Ee.append(B("br")),fe.append(Ee)}he.append(fe)}te.append(he),A(te);const ge=document.createRange();ge.selectNodeContents(te.querySelector("td")),ge.collapse(!0),a=ge,g()},R.append(j)}}));const N=()=>G("链接",()=>{const T=B("input","fc-input");T.ariaLabel="链接文本",T.placeholder="输入文本",T.value=(a==null?void 0:a.toString())||"";const R=B("input","fc-input");R.ariaLabel="链接地址",R.placeholder="粘贴或输入超链接";const $=B("div","fc-error"),z=B("button","primary","确定");z.type="button",z.onclick=()=>{const j=R.value.trim();if(!Mi(j)){$.textContent="请输入 http、https 或 mailto 链接";return}const te=B("a","",T.value||j);te.href=j,te.target="_blank",te.rel="noopener noreferrer",A(te)},o.append(B("span","","文本"),T,B("span","","链接"),R,$,z),T.focus()});E("链接","link",N),E("插入图片","▧",()=>G("插入图片",()=>{const T=B("input","fc-input");T.type="url",T.ariaLabel="图片地址",T.placeholder="https:// 图片地址";const R=B("input","fc-input");R.ariaLabel="图片说明",R.placeholder="图片说明";const $=B("div","fc-error"),z=B("button","primary","插入");z.type="button",z.onclick=()=>{if(!/^https?:\/\//i.test(T.value.trim())||!T.checkValidity()){$.textContent="请输入有效的 http 或 https 图片地址";return}const j=B("img");j.src=T.value.trim(),j.alt=R.value,j.referrerPolicy="no-referrer",A(j)},o.append(T,R,$,z),T.focus()})),E("提及人员","@",()=>G("提及人员",()=>{var R;const T=ki(!1,{...s,value:"",field:{...s.field,label:"人员"}},"person");h=T,o.append(T.element),T.element.addEventListener("change",$=>{var te,he;$.stopPropagation();const z=String(T.read());if(!z)return;const j=B("span","","@"+(((te=Ue(s.field).find(ge=>ge.id===z))==null?void 0:te.label)||((he=T.element.querySelector("option:checked"))==null?void 0:he.textContent)||z));j.dataset.personId=z,j.contentEditable="false",A(j)}),(R=T.focus)==null||R.call(T)})),E("代码块","{ }",()=>I("formatBlock","pre")),E("表情","☺",()=>G("表情",()=>{o.classList.add("fc-rich-emojis");for(const T of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])x(T,()=>A(document.createTextNode(T)))}));const P=E("全屏编辑","expand",()=>{f(),l=!l,e.classList.toggle("is-fullscreen",l),v(),P.ariaLabel=P.title=l?"收起全屏":"全屏编辑",P.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${un[l?"collapse":"expand"]}</svg>`,g()},!1);P.disabled=!1,P.classList.add("fc-rich-expand"),t.append(P);const _=()=>{for(const T of n.children)T.inert=T.offsetTop>=n.clientHeight},L=typeof ResizeObserver>"u"?void 0:new ResizeObserver(_);L==null||L.observe(n);const H=T=>{const R=T.target;i.contains(R)||R.closest("input,textarea,select,[contenteditable=true]")||(T.preventDefault(),!e.contains(document.activeElement)&&!o.contains(document.activeElement)&&g())};return e.addEventListener("mousedown",H),o.addEventListener("mousedown",H),i.addEventListener("input",k),i.addEventListener("mouseup",()=>{if(f(),y(),p&&a&&!a.collapsed){const T=a,R=B(p.tag);R.style.cssText=p.css,R.append(T.extractContents()),T.insertNode(R),p=null,m.get("格式刷").classList.remove("active"),C()}}),i.addEventListener("keyup",()=>{f(),y()}),i.addEventListener("click",T=>{const R=T.target;if(R.tagName==="A"&&T.preventDefault(),R instanceof HTMLInputElement&&R.type==="checkbox"){if(s.readonly){T.preventDefault();return}R.toggleAttribute("checked",R.checked),C()}v()}),i.addEventListener("drop",T=>T.preventDefault()),i.addEventListener("paste",T=>{var $,z;if(s.readonly){T.preventDefault();return}T.preventDefault(),f();const R=($=T.clipboardData)==null?void 0:$.getData("text/html");if(R){const j=document.createElement("template");j.innerHTML=ft(R);const te=j.content,he=document.createTextNode("");te.append(he),g();const ge=window.getSelection().getRangeAt(0);ge.deleteContents(),ge.insertNode(te),ge.setStartAfter(he),ge.collapse(!0),a=ge.cloneRange(),C()}else A(document.createTextNode(((z=T.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",T=>{T.key==="Escape"&&!o.hidden?(T.preventDefault(),T.stopPropagation(),v(),g()):T.key==="Escape"&&l?(T.preventDefault(),T.stopPropagation(),P.click()):!s.readonly&&(T.metaKey||T.ctrlKey)&&T.key.toLowerCase()==="z"?(T.preventDefault(),b(T.shiftKey?1:-1)):(T.metaKey||T.ctrlKey)&&T.key.toLowerCase()==="k"&&(T.preventDefault(),f(),N())}),e.append(t,i),y(),{element:e,content:o,inputRoot:e,read:()=>ft(i.innerHTML),validate:()=>{var T;return s.field.required&&!((T=i.textContent)!=null&&T.trim())&&!i.querySelector("img")?"请填写内容":void 0},focus:()=>i.focus(),deactivate:()=>{v(),l=!1,e.classList.remove("is-fullscreen"),P.ariaLabel=P.title="全屏编辑"},destroy:()=>{L==null||L.disconnect(),v()}}}const Li="请输入评论(Enter 换行,⌘ + Enter 发送)",Aa={reply:'<path d="M4 4h16v13h-5l-3 3-3-3H4zM8 10h8"/>',edit:'<path d="m5 15 10-10 4 4L9 19H5zM13 7l4 4M4 22h17"/>',sort:'<path d="M6 20V4m-3 3 3-3 3 3M13 6h8M13 12h6M13 18h3"/>'},hn=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${Aa[s]}</svg>`,Ti=s=>`<span class="detail-comment-avatar" aria-hidden="true">${D(s.slice(0,1))}</span>`,Ni=s=>s.html===void 0?D(s.content).replace(/\n/g,"<br>"):ft(s.html);function $a(s){let e={...s};const t=typeof e.author=="string"?e.author:e.author.display;let n=e.data||e.comments||[],i,o,a=!1,l=0;const r=new AbortController,d=new Set,c=[],p=()=>{c.splice(0).forEach(L=>L())},h=(L,H)=>{var R;if(A||!(e.onSave||(L==="edit"?e.onEdit:e.onPublish))||L!=="create"&&!H)return!1;const T=(R=e.permissions)==null?void 0:R[L];return typeof T=="function"?!!H&&T(H):T===!0},u=document.createElement("section");u.className="detail-comments rowvia-field-scope rowvia-detail-module",u.dataset.module="detail:tabs:comment",u.ariaLabel="评论/备注";const f=document.createElement("ul");f.className="detail-comment-list",u.append(f);const g=document.createElement("button");g.type="button",g.className="detail-comment-load-more",g.textContent="加载更多";const v=document.createElement("div");v.setAttribute("role","alert"),u.append(g,v);let m=!1;g.onclick=async()=>{if(!(A||m||!e.hasMore||!e.onLoadMore)){m=!0,g.disabled=!0,v.textContent="";try{await e.onLoadMore(r.signal)}catch(L){A||(v.textContent=L instanceof Error?L.message:"加载失败,请重试")}finally{m=!1,A||(g.disabled=!1,g.hidden=!e.hasMore)}}};const y=document.createElement("div");y.className="detail-comment-composer rowvia-field-scope rowvia-detail-module",y.dataset.module="detail:comment:composer",y.innerHTML=`${Ti(t)}<div class="detail-comment-compose-main"></div>`;const k=y.lastElementChild;let C,b,I=!1,A=!1;const E=()=>n.map((L,H)=>typeof L=="string"?{id:`legacy-${H}`,author:t,content:L,createdAt:""}:L);function G(L,H,T,R){var Me;const $=Ri({field:{key:"comment",label:"评论",kind:"richText",required:!0,choices:(Me=e.people)!=null&&Me.length?e.people:[{id:t,label:t}]},value:L,readonly:!1,layout:"form",services:e.services});$.element.classList.add("detail-comment-editor");const z=$.element.querySelector(".fc-rich-tools");for(const U of["插入图片","提及人员"])z.append(z.querySelector(`[aria-label="${U}"]`));const j=$.element.querySelector(".fc-rich-content");j.dataset.placeholder=Li;const te=document.createElement("div");te.className="detail-comment-editor-actions",te.innerHTML='<button type="button" data-cancel-comment>取消</button><button type="button" class="primary" data-publish-comment>发布评论</button>',$.element.append(te);const he=te.querySelector("[data-publish-comment]"),ge=document.createElement("div");ge.className="detail-comment-error",ge.setAttribute("role","alert"),$.element.append(ge);const be=te.querySelector("[data-cancel-comment]"),fe=()=>h(H.action==="edit"?"edit":H.action==="reply"?"reply":"create",E().find(U=>U.id===(H.id||H.replyTo))),me=()=>{var se;const U=!((se=j.textContent)!=null&&se.replace(/[\u200b\u00a0]/g," ").trim())&&!j.querySelector("img,table,hr");j.classList.toggle("is-empty",U),he.disabled=U||a||!fe(),be.disabled=a,$.element.inert=a,j.contentEditable=String(!a&&fe()),$.element.querySelector(".fc-rich-toolbar").inert=a||!fe()},Ee=()=>{if(me(),he.disabled||A)return;const U=String($.read()),se=document.createElement("div");se.innerHTML=U,a=!0,ge.textContent="",$.element.setAttribute("aria-busy","true"),me();const X=l,W=()=>{a=!1,!A&&($.element.setAttribute("aria-busy","false"),me())},Z=S=>{if(!A){if(S!==!0&&!Array.isArray(S)){le(new Error("保存失败,请重试"));return}Array.isArray(S)&&X===l&&(n=S),W(),T()}},le=S=>{A||(W(),ge.textContent=S instanceof Error?S.message:"保存失败,请重试")};try{const S={...H,html:U,content:(se.innerText||se.textContent||"").trim()},V=e.onSave?e.onSave(S,r.signal):H.action==="edit"?e.onEdit(H.id,S,r.signal):e.onPublish(S,r.signal);typeof V=="object"&&V!==null&&"then"in V?Promise.resolve(V).then(Z,le):Z(V)}catch(S){le(S)}};return te.querySelector("[data-cancel-comment]").onclick=()=>{!a&&!A&&R()},he.onclick=Ee,$.element.addEventListener("input",me),$.element.addEventListener("change",me),j.addEventListener("keydown",U=>{U.key==="Enter"&&(U.metaKey||U.ctrlKey)&&!U.isComposing&&(U.preventDefault(),U.stopPropagation(),Ee())}),me(),$}function x(){var L;(L=C==null?void 0:C.destroy)==null||L.call(C),C=void 0,o=void 0,y.classList.remove("is-editing"),y.hidden=!h("create"),k.innerHTML=`<button type="button" class="detail-comment-placeholder">${Li}</button>`,k.querySelector("button").onclick=()=>M()}function M(L){var z,j,te,he,ge,be;if(a||!h(L?"reply":"create",L))return;const H=L==null?void 0:L.author;o=L==null?void 0:L.id;const T=`${(C==null?void 0:C.read())||""}${H?`<span data-person-id="${D(((j=(z=e.people)==null?void 0:z.find(fe=>fe.label===H))==null?void 0:j.id)||H)}">@${D(H)}</span> `:""}`;(te=C==null?void 0:C.destroy)==null||te.call(C),C=G(T,{action:o?"reply":"create",replyTo:o},()=>{x(),N()},x),y.hidden=!1,y.classList.add("is-editing"),k.replaceChildren(C.element),(he=C.focus)==null||he.call(C);const R=C.element.querySelector(".fc-rich-content"),$=document.createRange();$.selectNodeContents(R),$.collapse(!1),(ge=window.getSelection())==null||ge.removeAllRanges(),(be=window.getSelection())==null||be.addRange($)}function N(){if(A)return;p(),g.hidden=!e.hasMore||!e.onLoadMore;const L=E().map((H,T)=>({comment:H,index:T}));I&&L.reverse(),f.innerHTML=L.length?L.map(({comment:H,index:T})=>`
|
|
91
|
+
<li class="detail-comment" data-comment-index="${T}">
|
|
92
|
+
${Ti(H.author)}
|
|
93
|
+
<div class="detail-comment-main">
|
|
94
|
+
<div class="detail-comment-meta"><strong>${D(H.author)}</strong><time>${H.createdAt?`于 ${D(H.createdAt)} 评论`:"历史评论"}</time></div>
|
|
95
|
+
<div class="detail-comment-content-wrapper">
|
|
96
|
+
<div class="detail-comment-bubble"><div class="detail-comment-content fc-value">${Ni(H)}</div></div>
|
|
97
|
+
<div class="detail-comment-actions">${h("reply",H)?`<button type="button" data-comment-action="reply" aria-label="回复评论" title="回复">${hn("reply")}</button>`:""}${h("edit",H)?`<button type="button" data-comment-action="edit" aria-label="编辑评论" title="编辑">${hn("edit")}</button>`:""}</div>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</li>`).join(""):'<li class="detail-empty">暂无评论</li>';for(const H of f.querySelectorAll("[data-comment-index]")){const T=E()[Number(H.dataset.commentIndex)];if(e.renderActions){const R=e.renderActions(H.querySelector(".detail-comment-actions"),T);R&&c.push(R)}if(e.renderAttachments){const R=document.createElement("div");R.className="detail-comment-attachments",H.querySelector(".detail-comment-main").append(R);const $=e.renderAttachments(R,T);$&&c.push($)}}if(b&&i){const H=[...f.querySelectorAll("[data-comment-index]")].find(R=>{var $;return(($=E()[Number(R.dataset.commentIndex)])==null?void 0:$.id)===i}),T=H==null?void 0:H.querySelector(".detail-comment-content-wrapper");T?(T.classList.add("is-editing"),T.replaceChildren(b.element)):P()}f.querySelectorAll(".detail-comment-content input").forEach(H=>{H.disabled=!0})}function P(){var L;(L=b==null?void 0:b.destroy)==null||L.call(b),b=void 0,i=void 0}u.onclick=L=>{var j;if(a||A)return;const H=L.target.closest("[data-comment-action]");if(!H)return;const T=H.closest("[data-comment-index]"),R=Number(T.dataset.commentIndex),$=E()[R];if(H.dataset.commentAction==="reply"){M($);return}if(!h("edit",$))return;P(),N(),i=$.id;const z=f.querySelector(`[data-comment-index="${R}"] .detail-comment-content-wrapper`);b=G(Ni($),{action:"edit",id:$.id},()=>{P(),N()},()=>{P(),N()}),z.classList.add("is-editing"),z.replaceChildren(b.element),(j=b.focus)==null||j.call(b)};function _(L){if(A)return;const H=L.querySelector('[data-detail-tab="评论/备注"]');if(!H||H.querySelector(".detail-comment-sort"))return;const T=document.createElement("span");T.className="detail-comment-sort",T.setAttribute("role","button"),T.tabIndex=0,T.ariaLabel=I?"当前最新在前,切换最早在前":"当前最早在前,切换最新在前",T.title=T.ariaLabel,T.innerHTML=hn("sort"),T.classList.toggle("newest-first",I);const R=$=>{A||a||($.stopPropagation(),I=!I,N(),T.remove(),d.delete(T),_(L))};T.onclick=R,T.onkeydown=$=>{($.key==="Enter"||$.key===" ")&&($.preventDefault(),R($))},H.append(T),d.add(T)}return x(),N(),{element:u,composer:y,decorateTab:_,update:L=>{A||(e={...e,...L},(L.data||L.comments)&&(n=L.data||L.comments,++l),N(),C&&C.element.dispatchEvent(new Event("change")),b&&b.element.dispatchEvent(new Event("change")),C||(y.hidden=!h("create")))},deactivate:()=>{var L,H;(L=C==null?void 0:C.deactivate)==null||L.call(C),(H=b==null?void 0:b.deactivate)==null||H.call(b)},destroy:()=>{var L;A=!0,r.abort(),(L=C==null?void 0:C.destroy)==null||L.call(C),P(),p(),d.forEach(H=>H.remove()),d.clear(),u.onclick=null,g.onclick=null,u.replaceChildren(),y.replaceChildren()}}}const tt=s=>String(s).padStart(2,"0"),pn=s=>`${s.getFullYear()}-${tt(s.getMonth()+1)}-${tt(s.getDate())}`;function Wt(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())&&pn(t)===s}const Ii=s=>{var e,t,n;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,seconds:((n=s.field.dateOptions)==null?void 0:n.showSeconds)??s.field.kind==="datetime"}};function Ai(s){const{time:e,range:t,seconds:n}=Ii(s),o=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(a=>e?String(a).slice(0,n?19:16).replace("T"," "):String(a).slice(0,10)).join(" 至 ");return B("div",`fc-value fc-${s.className||""}${o?"":" fc-empty"}`,o||"待填")}function $i(s){const{time:e,range:t,seconds:n}=Ii(s),i=B("div","fc-calendar"),o=Array.isArray(s.value)?s.value:[s.value],a=[0,1].map(U=>String(o[U]||"").slice(0,10)),l=[0,1].map(U=>(String(o[U]||"").slice(11,16)||"00:00")+(n?":"+(String(o[U]||"").slice(17,19)||"00"):""));let r=0,d=!1,c=Wt(a[0])?new Date(`${a[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const p=B("div","fc-calendar-panel"),h=B("div","fc-calendar-inputs"),u=[],f=()=>i.dispatchEvent(new Event("change",{bubbles:!0})),g=B("div","fc-error");g.setAttribute("role","status");const v=()=>{if(a.some(U=>U&&!Wt(U)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!a[0])return"请选择日期";if(t&&!!a[0]!=!!a[1])return"请选择完整的日期范围";if(e&&l.slice(0,t?2:1).some(U=>!(n?/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/:/^([01]\d|2[0-3]):[0-5]\d$/).test(U)))return"请输入有效时间";if(t&&a[0]&&`${a[0]}T${e?l[0]:""}`>`${a[1]}T${e?l[1]:""}`)return"结束日期时间不能早于开始日期时间"},m=()=>{g.textContent=v()||"",g.textContent||f()};for(let U=0;U<(t?2:1);U++){const se=B("input","fc-input fc-calendar-date");se.type="text",se.value=a[U],se.placeholder=t?U?"结束日期":"开始日期":"YYYY-MM-DD",se.ariaLabel=t?se.placeholder:s.field.label,se.disabled=s.readonly,se.onfocus=()=>{if(r=U,d=U===1,Wt(a[U])){const X=new Date(`${a[U]}T12:00:00`);c=new Date(X.getFullYear(),X.getMonth(),1)}$()},se.addEventListener("change",X=>{if(X.stopPropagation(),a[U]=se.value.trim(),Wt(a[U])){const W=new Date(`${a[U]}T12:00:00`);c=new Date(W.getFullYear(),W.getMonth(),1)}$(),m()}),h.append(se),u.push(se)}const y=B("div","fc-calendar-header"),k=B("button","fc-calendar-month");k.type="button",k.ariaLabel="选择年份和月份",k.setAttribute("aria-expanded","false"),k.setAttribute("aria-live","polite");const C=(U,se,X)=>{const W=B("button","fc-calendar-nav");return W.type="button",W.ariaLabel=U,W.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${X?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,se>0&&W.classList.add("next"),W.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+se,1),$()},W};y.append(C("上一年",-12,!0),C("上个月",-1,!1),k,C("下个月",1,!1),C("下一年",12,!0));const b=B("div","fc-calendar-weekdays");for(const U of["日","一","二","三","四","五","六"])b.append(B("span","",U));const I=B("div","fc-calendar-days");I.setAttribute("role","group"),I.ariaLabel="选择日期";const A=B("div","fc-calendar-period");A.hidden=!0;const E=B("button","fc-calendar-back","‹ 返回选择日期");E.type="button";const G=B("div","fc-calendar-period-columns"),x=B("div","fc-calendar-period-list");x.setAttribute("role","group"),x.ariaLabel="年份";const M=B("div","fc-calendar-period-list");M.setAttribute("role","group"),M.ariaLabel="月份";const N=B("div","fc-calendar-period-list");N.ariaLabel="秒",N.hidden=!0,G.append(x,M,N),A.append(E,G);let P="period",_=0;const L=[],H=(U=!1)=>{const se=l[_].split(":").map(Number),X=P==="period"?[[x,c.getFullYear(),"年"],[M,c.getMonth()+1,"月"]]:[[x,se[0],"时"],[M,se[1],"分"],[N,se[2],"秒"]];for(const[W,Z,le]of X)for(const S of W.querySelectorAll("button")){const V=Number(S.dataset.value)===Z;S.classList.toggle("selected",V),S.setAttribute("aria-pressed",String(V)),S.textContent=`${P==="time"?tt(Number(S.dataset.value)):S.dataset.value}${V?le:""}`,V&&U&&(W.scrollTop=Math.max(0,S.offsetTop-108))}},T=(U,se)=>{const X=B("button","fc-calendar-period-option",String(U));return X.type="button",X.dataset.value=String(U),X.ariaLabel=`${P==="time"?tt(U):U}${P==="time"?se?"时":"分":se?"年":"月"}`,X.disabled=P==="time"&&s.readonly,X.onclick=()=>{if(P==="time"){const W=l[_].split(":");W[se?0:1]=tt(U),l[_]=W.join(":"),L[_].textContent=l[_],H(),m();return}c.setFullYear(se?U:c.getFullYear(),se?c.getMonth():U-1,1),H(),$()},X},R=(U,se=0)=>{if(P=U,_=se,x.replaceChildren(),M.replaceChildren(),N.replaceChildren(),N.hidden=U!=="time"||!n,x.ariaLabel=U==="period"?"年份":"小时",M.ariaLabel=U==="period"?"月份":"分钟",U==="period"){for(let X=Math.max(1,c.getFullYear()-100);X<=Math.min(9999,c.getFullYear()+100);X++)x.append(T(X,!0));for(let X=1;X<=12;X++)M.append(T(X,!1))}else{for(let X=0;X<24;X++)x.append(T(X,!0));for(let X=0;X<60;X++)M.append(T(X,!1));if(n)for(let X=0;X<60;X++){const W=B("button","fc-calendar-period-option",tt(X));W.type="button",W.dataset.value=String(X),W.ariaLabel=tt(X)+"秒",W.disabled=s.readonly,W.onclick=()=>{const Z=l[_].split(":");Z[2]=tt(X),l[_]=Z.join(":"),L[_].textContent=l[_],H(),m()},N.append(W)}}i.classList.add("choosing-period"),A.hidden=!1,(U==="period"?k:L[se]).setAttribute("aria-expanded","true"),H(!0),E.focus()};k.onclick=()=>R("period"),E.onclick=()=>{i.classList.remove("choosing-period"),A.hidden=!0;const U=P==="period"?k:L[_];U.setAttribute("aria-expanded","false"),$(),U.focus()},A.addEventListener("keydown",U=>{if(U.key==="Escape"&&(U.preventDefault(),U.stopPropagation(),E.click()),!["ArrowUp","ArrowDown","Home","End"].includes(U.key))return;const se=U.target,X=se.closest(".fc-calendar-period-list");if(!X)return;const W=[...X.querySelectorAll("button")],Z=W.indexOf(se),le=U.key==="Home"?0:U.key==="End"?W.length-1:Math.max(0,Math.min(W.length-1,Z+(U.key==="ArrowDown"?1:-1)));U.preventDefault(),W[le].focus()});function $(){k.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((se,X)=>se.classList.toggle("active",X===r)),I.replaceChildren();for(let se=0;se<c.getDay();se++)I.append(B("span","fc-calendar-blank"));const U=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let se=1;se<=U;se++){const X=pn(new Date(c.getFullYear(),c.getMonth(),se)),W=B("button","fc-calendar-day",String(se));W.type="button",W.ariaLabel=X,W.disabled=s.readonly;const Z=a[0]===X||t&&a[1]===X;W.classList.toggle("selected",Z),W.setAttribute("aria-pressed",String(Z)),W.classList.toggle("in-range",t&&!!a[0]&&!!a[1]&&X>a[0]&&X<a[1]),X===pn(new Date)&&(W.classList.add("today"),W.setAttribute("aria-current","date")),W.onclick=()=>{var le;t?d?(a[1]=X,a[0]&&a[1]<a[0]&&([a[0],a[1]]=[a[1],a[0]]),r=0,d=!1):(a[0]=X,a[1]="",r=1,d=!0):a[0]=X,u.forEach((S,V)=>S.value=a[V]),$(),!t||a[1]?m():g.textContent="",(le=I.querySelector(`[aria-label="${X}"]`))==null||le.focus(),(!t||a[1])&&i.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))},I.append(W)}}p.append(y,b,I,A);const z=B("div","fc-calendar-time");if(e){for(let U=0;U<(t?2:1);U++){const se=B("div","fc-calendar-time-field"),X=t?U?"结束时间":"开始时间":"时间",W=B("button","fc-input fc-calendar-time-trigger",l[U]);W.type="button",W.disabled=s.readonly,W.ariaLabel=X,W.setAttribute("aria-expanded","false"),W.onclick=()=>R("time",U),L.push(W),se.append(B("span","",X),W),z.append(se)}p.append(z)}const j=B("button","fc-calendar-clear","清空");j.type="button",j.disabled=s.readonly,j.onclick=()=>{a.fill(""),u.forEach(U=>U.value=""),r=0,d=!1,$(),m()},i.append(h,p,j,g);const te=()=>{const U=a.slice(0,t?2:1).map((se,X)=>se?se+(e?`T${l[X]}`:""):"");return t?U.some(Boolean)?U:[]:U[0]};if(s.layout==="compact"||s.readonly)return $(),{element:i,read:te,validate:v,focus:()=>{u[0].focus()},deactivate:()=>{i.classList.remove("choosing-period"),A.hidden=!0}};const he=B("div","fc-date-mirror"),ge=()=>he.replaceChildren(Ai({...s,value:te()})),be=B("span","fc-field-chevron");be.setAttribute("aria-hidden","true");const fe=B("div","fc-date-trigger");fe.tabIndex=0,fe.setAttribute("role","button"),fe.ariaLabel=`编辑${s.field.label}`,fe.append(he,be);let me;const Ee=()=>{const U=me;me=void 0;const se=!!U&&U.element.contains(document.activeElement);U==null||U.close(),be.classList.remove("is-open"),se&&queueMicrotask(()=>{me||!fe.isConnected||fe.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))})},Me=()=>{me||s.readonly||(ge(),me=Rt({anchor:fe,content:i,width:320,gap:4,onDismiss:()=>{me=void 0,be.classList.remove("is-open")}}),be.classList.add("is-open"))};return fe.onclick=()=>Me(),fe.onkeydown=U=>{(U.key==="Enter"||U.key===" ")&&(U.preventDefault(),Me())},i.addEventListener("focusout",U=>{const se=U.relatedTarget;if(se&&(i.contains(se)||fe.contains(se)||Ye(se)))return;const X=new Event("focusout",{bubbles:!0});se&&Object.defineProperty(X,"relatedTarget",{value:se}),fe.dispatchEvent(X)}),i.addEventListener("change",()=>fe.dispatchEvent(new Event("change",{bubbles:!0}))),$(),ge(),{element:fe,content:i,inputRoot:fe,read:te,validate:v,focus:()=>{Me(),u[0].focus()},deactivate:Ee,destroy:Ee}}const fn=[{key:"wit_node",label:"节点"},{key:"wit_subtask",label:"任务"},{key:"wit_field",label:"字段"},{key:"wit_role_and_user",label:"角色与人员"},{key:"wit_schedule",label:"计划表"},{key:"ai_run",label:"AI 操作"},{key:"wit",label:"工作项"}];function Fi(s,e){return s.history.map((t,n)=>{var o;const i=typeof t=="string"?{actor:e,module:t.startsWith("关联素材")?"素材管理":"工作项",detail:t,createdAt:""}:t;return{...i,id:i.id||`legacy-${n}`,actorId:i.actorId||i.actor,actorKind:i.actorKind||"user",moduleKey:i.moduleKey||(i.module==="节点流程"?"wit_node":"")||((o=fn.find(a=>a.label===i.module))==null?void 0:o.key)||i.module}}).sort((t,n)=>n.createdAt.localeCompare(t.createdAt))}function Fa(s){return s.map(e=>{var t,n;return{id:e.id,actorId:(t=e.operator)==null?void 0:t.user_key,actor:((n=e.operator)==null?void 0:n.name)||"系统",actorKind:e.operator_type===0?"user":"system",moduleKey:e.op_record_type_key,module:e.op_record_type_name,detail:e.content,createdAt:new Date(e.created_at).toLocaleString("sv-SE")}})}function Di(s,e){const t=e.keyword.trim().toLocaleLowerCase(),n=s.filter(d=>e.operatorKinds.has(d.actorKind||"user")&&(!e.operators.size||d.actorKind!=="user"||e.operators.has(d.actorId||d.actor))&&(!e.modules.size||e.modules.has(d.moduleKey||d.module))&&(!e.start||d.createdAt>=e.start.replace("T"," "))&&(!e.end||!!d.createdAt&&d.createdAt<=e.end.replace("T"," "))),i=d=>[d.actor,d.module,d.detail,d.createdAt].some(c=>c.toLocaleLowerCase().includes(t)),o=t?n.filter(i):n,a=t&&e.keywordFilter?o:n,l=Math.max(1,Math.ceil(a.length/20)),r=Math.max(1,Math.min(e.page,l));return{rows:a.slice((r-1)*20,r*20),total:n.length,matching:o.length,filteredTotal:a.length,page:r,pageCount:l}}const gn=s=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${s}</svg>`,mn=gn('<path d="M3 4h18l-7 8v7l-4 2v-9z"/>'),Da=gn('<circle cx="10" cy="10" r="6"/><path d="m15 15 6 6"/>'),Pa=gn('<path d="m6 6 12 12M6 18 18 6"/>'),Ha=[["user","用户"],["computed","计算字段"],["automation","自动化规则"],["system","其它系统操作"]];function Oa(s){let e={...s},t=e.page||{rows:e.rows||(e.records||[]).filter(E=>typeof E!="string"),nextCursor:e.nextCursor,previousCursor:e.previousCursor},n=!1,i=!1,o=0,a;const l=[],r=()=>{l.splice(0).forEach(E=>E())},d=()=>Fi({history:e.rows||e.records||[]},e.actor||""),c=()=>e.mode==="local",p=document.createElement("section");p.className="detail-history rowvia-detail-module",p.dataset.module="detail:tabs:log";const h={keyword:"",keywordFilter:!1,operatorKinds:new Set(["user","automation","system"]),operators:new Set,modules:new Set,start:"",end:"",page:1,...e.query},u=()=>({...h,operatorKinds:new Set(h.operatorKinds),operators:new Set(h.operators),modules:new Set(h.modules)});Object.assign(h,u());let f;p.innerHTML=`<div class="detail-history-search"><span>${Da}</span><input type="search" placeholder="搜索" aria-label="搜索操作记录"><div class="detail-history-search-actions" hidden><span data-match-count aria-live="polite"></span><label><input type="checkbox" data-keyword-filter>过滤</label><button type="button" data-clear-search aria-label="清空搜索">${Pa}</button></div></div><div class="detail-history-table-wrap"><table class="detail-history-table" aria-label="操作记录"><colgroup><col style="width:172px"><col style="width:140px"><col><col style="width:252px"></colgroup><thead><tr><th scope="col"><span>操作人</span><button type="button" data-history-filter="actor" aria-label="筛选操作人" aria-haspopup="dialog" aria-expanded="false">${mn}</button></th><th scope="col"><span>操作模块</span><button type="button" data-history-filter="module" aria-label="筛选操作模块" aria-haspopup="dialog" aria-expanded="false">${mn}</button></th><th scope="col">操作详情</th><th scope="col"><span>操作时间</span><button type="button" data-history-filter="time" aria-label="筛选操作时间" aria-haspopup="dialog" aria-expanded="false">${mn}</button></th></tr></thead><tbody></tbody></table></div><div class="detail-history-pagination"></div>`;const g=document.createElement("div");g.className="detail-history-status",g.setAttribute("role","status"),p.append(g);const v=p.querySelector("input[type=search]"),m=p.querySelector("tbody"),y=E=>{const G=h.keyword.trim();if(!G)return D(E);let x=0,M="";for(let N=E.toLocaleLowerCase().indexOf(G.toLocaleLowerCase());N>=0;N=E.toLocaleLowerCase().indexOf(G.toLocaleLowerCase(),x))M+=D(E.slice(x,N))+`<mark>${D(E.slice(N,N+G.length))}</mark>`,x=N+G.length;return M+D(E.slice(x))};function k(){if(n)return;r();const E=c()?Di(d(),h):{rows:t.rows,total:t.total,matching:t.matching,filteredTotal:t.total,page:h.page,pageCount:1};c()&&(h.page=E.page),v.value=h.keyword,p.querySelector("[data-keyword-filter]").checked=h.keywordFilter,p.setAttribute("aria-busy",String(i)),p.querySelector(".detail-history-search-actions").hidden=!h.keyword.trim(),p.querySelector("[data-match-count]").textContent=`${E.matching??"—"} / ${E.total??"—"}`,m.innerHTML=E.rows.length?E.rows.map(x=>`<tr><td><span class="detail-history-actor" title="${D(x.actor)}"><span class="detail-history-avatar" aria-hidden="true">${D(x.actor.slice(0,1))}</span><span>${y(x.actor)}</span></span></td><td title="${D(x.module)}">${y(x.module)}</td><td class="detail-history-description"><span>${y(x.detail)}</span></td><td><time>${y(x.createdAt||"历史记录")}</time></td></tr>`).join(""):'<tr><td colspan="4" class="detail-history-empty">暂无数据</td></tr>',e.renderDetail&&m.querySelectorAll(".detail-history-description > span").forEach((x,M)=>{const N=e.renderDetail(x,E.rows[M]);N&&l.push(N)}),p.querySelector("[data-history-filter=actor]").classList.toggle("active",h.operatorKinds.size!==4||!!h.operators.size),p.querySelector("[data-history-filter=module]").classList.toggle("active",!!h.modules.size);const G=p.querySelector("[data-history-filter=time]");G.classList.toggle("active",!!h.start||!!h.end),G.title=h.start?`${h.start} 至 ${h.end}`:"筛选操作时间",p.querySelector(".detail-history-pagination").innerHTML=c()?E.pageCount>1?`<span>共 ${E.filteredTotal} 条</span><button type="button" data-page="-1" ${E.page===1?"disabled":""} aria-label="上一页">‹</button><span>${E.page} / ${E.pageCount}</span><button type="button" data-page="1" ${E.page===E.pageCount?"disabled":""} aria-label="下一页">›</button>`:"":`<span>${t.total===void 0?"":`共 ${t.total} 条`}</span><button type="button" data-page="-1" ${i||!e.onQuery||t.previousCursor==null?"disabled":""} aria-label="上一页">‹</button><button type="button" data-page="1" ${i||!(e.onQuery||e.onLoadMore)||t.nextCursor==null?"disabled":""} aria-label="下一页">›</button>`}function C(E=!1){if(n)return;if(c()){k();return}if(!(E?e.onLoadMore:e.onQuery)){k();return}a==null||a.abort(),a=new AbortController;const G=++o;i=!0,g.textContent="加载中…",k();const x=u(),M=P=>{n||G!==o||(P&&(t=P,e.records=P.rows,e.rows=P.rows),i=!1,g.textContent="",k())},N=P=>{if(n||G!==o)return;i=!1,g.textContent=P instanceof Error?P.message:"加载失败,请重试";const _=document.createElement("button");_.type="button",_.textContent="重试",_.onclick=()=>C(E),g.append(_),k()};try{const P=E?e.onLoadMore(h.cursor,x,a.signal):e.onQuery(x,a.signal);P instanceof Promise||P&&"then"in P?Promise.resolve(P).then(M,N):M(P)}catch(P){N(P)}}const b=()=>{h.page=1,h.cursor=void 0,C()},I=()=>{const E=f;f=void 0,E==null||E.close()};function A(E){if(E.getAttribute("aria-expanded")==="true"){I();return}I();const G=document.createElement("div");G.className="detail-history-filter-panel",G.setAttribute("role","dialog"),G.ariaLabel=E.ariaLabel;const x=E.dataset.historyFilter,M=[],N=(P,_,L)=>{const H=document.createElement("label");return H.className="detail-history-filter-option",H.innerHTML=`<input type="checkbox" value="${D(_)}" ${L.has(_)?"checked":""}><span>${D(P)}</span>`,H.querySelector("input").onchange=T=>{T.target.checked?L.add(_):L.delete(_),b()},H};if(x==="module"){const P=d(),_=e.modules?[...e.modules]:fn.filter(L=>e.nodeFlow||!["wit_node","wit_subtask"].includes(L.key));for(const L of P)_.some(H=>H.key===L.moduleKey)||_.push({key:L.moduleKey,label:L.module});_.forEach(L=>G.append(N(L.label,L.key,h.modules)))}else if(x==="actor"){for(const[P,_]of Ha)if(G.append(N(_,P,h.operatorKinds)),P==="user"){const L=document.createElement("details");L.className="detail-history-users",L.innerHTML='<summary>请选择用户</summary><input type="search" aria-label="搜索用户" placeholder="搜索用户"><div></div>';const H=e.operators?e.operators.map($=>[$.id,$.label]):[...new Map(d().filter($=>$.actorKind==="user").map($=>[$.actorId,$.actor])).entries()],T=L.querySelector("input"),R=()=>L.querySelector("div").replaceChildren(...H.filter(([,$])=>$.includes(T.value)).map(([$,z])=>N(z,$,h.operators)));T.oninput=R,R(),G.append(L)}}else{G.classList.add("detail-history-date-panel");const P=document.createElement("div");P.className="detail-history-date-range",G.append(P);const _=["开始","结束"].map((R,$)=>$i({field:{key:`log-date-${$}`,label:`${R}日期`,kind:"dateTime",dateOptions:{showTime:!0,showSeconds:!0}},readonly:!1,layout:"compact",value:$?h.end:h.start})),L=document.createElement("div");L.className="detail-history-filter-error",L.setAttribute("role","status");const H=()=>{const[R,$]=_.map(z=>String(z.read()));L.textContent=_.map(z=>{var j;return(j=z.validate)==null?void 0:j.call(z)}).find(Boolean)||(R&&$&&R>$?"结束日期时间不能早于开始日期时间":""),!L.textContent&&(!R&&!$?(h.start="",h.end="",b()):R&&$&&(h.start=R,h.end=$,b()))};_.forEach((R,$)=>{var he,ge;const z=document.createElement("div");z.className="detail-history-date-column",z.setAttribute("aria-label",$?"结束日期时间":"开始日期时间");const j=R.element.querySelector(".fc-calendar-date");j.placeholder="yyyy-MM-dd";const te=R.element.querySelector(".fc-calendar-time-trigger");R.element.querySelector(".fc-calendar-inputs").append(te),(he=R.element.querySelector(".fc-calendar-time"))==null||he.remove(),(ge=R.element.querySelector(".fc-calendar-clear"))==null||ge.remove(),z.append(R.element),P.append(z),R.element.addEventListener("change",H),M.push(()=>{var be;return(be=R.destroy)==null?void 0:be.call(R)})}),h.end||_[1].element.querySelector('[aria-label="下个月"]').click();const T=document.createElement("button");T.type="button",T.className="detail-history-clear-dates",T.textContent="清空",T.onclick=()=>{h.start="",h.end="",b(),I()},G.append(L,T)}E.setAttribute("aria-expanded","true"),f=Rt({anchor:E,anchorMode:"element",content:G,align:x==="time"?"end":"start",width:x==="time"?570:x==="actor"?240:190,onDismiss:()=>{f=void 0,E.setAttribute("aria-expanded","false"),M.forEach(P=>P())},onEscape:()=>E.focus()})}return v.oninput=()=>{h.keyword=v.value,b()},p.querySelector("[data-keyword-filter]").onchange=E=>{h.keywordFilter=E.target.checked,b()},p.onclick=E=>{if(n)return;const G=E.target.closest("button");G&&(G.dataset.historyFilter?A(G):G.hasAttribute("data-clear-search")?(v.value="",h.keyword="",b(),v.focus()):G.dataset.page&&!G.disabled&&(c()?h.page+=Number(G.dataset.page):h.cursor=(G.dataset.page==="1"?t.nextCursor:t.previousCursor)??void 0,C(!c()&&G.dataset.page==="1"&&!!e.onLoadMore)))},k(),{element:p,refresh:C,deactivate:I,update:E=>{n||(++o,a==null||a.abort(),i=!1,g.textContent="",e={...e,...E},E.query&&(Object.assign(h,E.query),Object.assign(h,u())),E.page?(t=E.page,e.records=E.page.rows,e.rows=E.page.rows):(E.rows||E.records)&&(t={...t,rows:E.rows||E.records.filter(G=>typeof G!="string")},e.rows=t.rows),"nextCursor"in E&&(t.nextCursor=E.nextCursor),"previousCursor"in E&&(t.previousCursor=E.previousCursor),I(),k())},destroy:()=>{n||(n=!0,++o,a==null||a.abort(),I(),r(),v.oninput=null,p.querySelector("[data-keyword-filter]").onchange=null,p.onclick=null,p.replaceChildren())}}}const Ba=()=>({filters:[],sorts:[],groups:[],colors:[],showTerminated:!1});function Pi(s,e){return e.every(t=>{const n=String(s[t.field]??"").toLocaleLowerCase(),i=t.value.toLocaleLowerCase();switch(t.operator){case"equals":return n===i;case"notEqual":return n!==i;case"blank":return!n;case"notBlank":return!!n;default:return n.includes(i)}})}const vn=new WeakMap;function Hi(s){let e=vn.get(s);e||(e={owners:0,added:!s.classList.contains("rowvia-work-items"),fieldAdded:!s.classList.contains("rowvia-field-scope")},vn.set(s,e),s.classList.add("rowvia-work-items","rowvia-field-scope")),e.owners++;let t=!1;return()=>{t||(t=!0,!--e.owners&&(e.added&&s.classList.remove("rowvia-work-items"),e.fieldAdded&&s.classList.remove("rowvia-field-scope"),vn.delete(s)))}}function wn(s,e,t,n){const i=document.createElement("div");i.className=e,i.innerHTML=t;const o=Hi(s);s.append(i);const a=new je,l=Fe(i,e,n);return a.listen(i,"click",r=>{var p;const d=r.target.closest("[data-action]");if(!d||!i.contains(d)||d.matches(":disabled"))return;const c={action:d.dataset.action,anchor:d,originalEvent:r};(p=n.onAction)==null||p.call(n,c),i.dispatchEvent(new CustomEvent("rowvia:action",{detail:c,bubbles:!0}))}),{element:i,lifecycle:a,onInteraction:l.onInteraction,destroy(){a.destroy(),l.destroy(),i.remove(),o()}}}function Va(s,e){const t=wn(s,"list-tabs",e.tabs.map(o=>`<button class="list-tab" role="tab" data-tab="${D(o)}">${D(o)}</button>`).join("")+`<div class="create-button">${Ne("create","新建","plus","primary")}${Ne("create-menu","","down","primary")}</div>`,e);t.element.setAttribute("role","tablist");let n=e.value??e.tabs[0]??"";const i=o=>{n=o,t.element.querySelectorAll("[data-tab]").forEach(a=>{const l=a.dataset.tab===n;a.classList.toggle("active",l),a.setAttribute("aria-selected",String(l))})};return t.lifecycle.listen(t.element,"click",o=>{var l;const a=o.target.closest("[data-tab]");!a||a.dataset.tab===n||(i(a.dataset.tab),(l=e.onChange)==null||l.call(e,n),t.element.dispatchEvent(new CustomEvent("rowvia:tab-change",{detail:n,bubbles:!0})))}),t.element.querySelectorAll("[data-action]").forEach(o=>{o.disabled=e.canCreate===!1}),i(n),{element:t.element,onInteraction:t.onInteraction,setValue:i,getValue:()=>n,destroy:t.destroy}}const yn={filter:"筛选",sort:"排序",group:"分组",color:"设置颜色"};function Ga(s,e={}){const t=wn(s,"toolbar",Object.entries(yn).map(([a,l])=>Ne(a,l,a)).join("")+`<div class="search-wrap hidden"><input id="search" aria-label="按标题查找" placeholder="按标题查找"><span id="matches"></span>${Ne("previous-match","","up")}${Ne("next-match","","down")}<label><input id="filter-search" type="checkbox">过滤</label>${Ne("close-search","","close")}</div>${Ne("search","查找","search")}<div class="right">${Ne("reset","重置","","hidden")}${Ne("saved-views","切换视图","down")}${Ne("save-view","存为视图","save","outline")}</div>`,e),n=t.element.querySelector("#search"),i=t.element.querySelector("#filter-search"),o=()=>{var a;(a=e.onSearch)==null||a.call(e,n.value,i.checked),t.element.dispatchEvent(new CustomEvent("rowvia:search",{detail:{query:n.value,filter:i.checked},bubbles:!0}))};return t.lifecycle.listen(n,"input",o),t.lifecycle.listen(i,"change",o),{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setRuleCounts(a){for(const l of Object.keys(yn)){const r=t.element.querySelector(`[data-action="${l}"]`);r.classList.toggle("is-set",!!a[l]),r.querySelector("span").textContent=yn[l]+(a[l]?` · ${a[l]}`:"")}t.element.querySelector('[data-action="reset"]').classList.toggle("hidden",!Object.values(a).some(Boolean))}}}function qa(s,e={}){const t=wn(s,"selection-bar hidden",`${Ne("deselect","","close")}<span data-selection-count></span>${Ne("batch-status","更新状态")}${Ne("batch-owner","更新负责人")}${Ne("batch-export","导出")}${Ne("batch-archive","终止")}${Ne("deselect","取消选择")}`,e),n=t.element.querySelector("[data-selection-count]");return{element:t.element,onInteraction:t.onInteraction,destroy:t.destroy,setCount(i){t.element.classList.toggle("hidden",i===0),n.textContent=`已选择 ${i} 项`}}}function za(s,e){const t=Hi(s),n=Jn(s,{getRowId:({data:i})=>i.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,localeText:{noRowsToShow:"暂无数据",loadingOoo:"加载中…",blank:"暂无",selectAll:"全选",filterOoo:"筛选…",searchOoo:"搜索…"},...e});return{...n,onInteraction:n.grid.onInteraction,destroy(){n.grid.destroy(),t()}}}function _a(s){const{config:e,controls:t,fieldConfig:n,options:i,$:o,tag:a,activateCell:l,controlContext:r,openDetail:d,colorRuleMatches:c}=s;function p(u){if(u.node.group)return"";const f=u.data,g=u.colDef.field,v=document.createElement("div");v.className="rendered-cell";const m=n(g);if(m&&(m.control||!["title","status"].includes(m.kind||"text")))v.append(t.resolve(m).render(r(m,f,"cell")));else if((m==null?void 0:m.kind)==="title"){const y=document.createElement("a");y.className="item-name",y.href=`#item/${f.id}`,y.textContent=f[g],y.title=f[g],y.addEventListener("click",C=>{C.preventDefault(),clearTimeout(s.detailClickTimer.get()),C.detail===0?d(f):C.detail===1&&s.detailClickTimer.set(window.setTimeout(()=>d(f),280))}),v.append(y);const k=document.createElement("button");k.className="inline-edit",k.innerHTML=Re("pencil"),k.ariaLabel="编辑选题概要",k.onclick=C=>{C.stopPropagation(),l(v,g,f,u.rowIndex)},(m==null?void 0:m.editable)!==!1&&v.append(k)}else(m==null?void 0:m.kind)==="status"?(v.innerHTML=`${a(f.status,g)}<span class="status-days">20 天</span>`,(m==null?void 0:m.editable)!==!1&&(v.onclick=y=>{y.stopPropagation(),l(v,g,f,u.rowIndex)})):i[g]?(v.innerHTML=["creator","owner","space"].includes(g)?D(f[g]):a(f[g],g),(m==null?void 0:m.editable)!==!1&&(v.onclick=y=>{y.stopPropagation(),l(v,g,f,u.rowIndex)})):(v.innerHTML=`<span class="cell-text">${D(f[g]||"暂无")}</span>`,f[g]||v.classList.add("placeholder"));if(m&&m.editable!==!1&&!t.resolve(m).readonly&&m.kind!=="title"){const y=document.createElement("button");y.className="inline-edit field-control",y.ariaLabel=`${m.kind==="status"?"流转":"编辑"}${m.label}`,y.innerHTML=Re(m.kind==="status"?"transition":["select","multiSelect","person"].includes(m.kind||"")?"down":"pencil"),y.onclick=k=>{k.stopPropagation(),l(v,g,f,u.rowIndex)},v.append(y)}return v.title=String(f[g]??""),v}function h(){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:u=>{if(u.node.group)return"";const f=document.createElement("div");return f.className="row-controls",f.innerHTML=`<span class="row-number">${u.rowIndex+1}</span><input class="row-checkbox" type="checkbox" aria-label="选择第 ${u.rowIndex+1} 行" ${u.node.isSelected()?"checked":""}><button class="row-open" aria-label="展开详情">${Re("expand")}</button>`,o("input",f).onclick=g=>g.stopPropagation(),o("input",f).onchange=g=>u.node.setSelected(g.target.checked),o("button",f).onclick=g=>{g.stopPropagation(),d(u.data)},f}},...e.fields.map(u=>({field:u.key,headerName:u.label,width:u.width??120,minWidth:u.minWidth??80,pinned:u.pinned,hide:u.hidden,enableRowGroup:!0,editable:!1,valueSetter:f=>u.required&&!String(f.newValue??"").trim()?!1:(f.data[u.key]=f.newValue,!0),comparator:u.options?(f,g)=>u.options.indexOf(f)-u.options.indexOf(g):void 0,sortable:!1,suppressMenu:!0,cellRenderer:p,cellStyle:({data:f})=>{const g=f&&s.view().colors.find(v=>!!v.scope&&v.scope!=="row"&&v.field===u.key&&c(f,v));return g?{backgroundColor:g.color}:{}},tooltipField:u.key,cellClass:u.kind==="title"?"name-cell":void 0,...u.column})),...s.customColumns(),{colId:"_add",hide:e.allowCustomFields===!1,suppressMovable:!0,headerName:"新增字段",width:40,minWidth:40,maxWidth:40,sortable:!1,resizable:!1,suppressMenu:!0,cellRenderer:()=>""}]}return{cell:p,columnDefs:h}}function Wa(s){const{config:e,data:t,fields:n,fieldConfig:i,options:o,controls:a,$:l,showPopup:r,closePopup:d,applyView:c,save:p,resizeGrid:h,decorateHeaders:u}=s;function f(y,k,C={}){e.container.querySelectorAll(".field-picker").forEach(G=>G.remove());const b=document.createElement("div");b.className="field-picker",b.innerHTML=`<input placeholder="搜索字段" aria-label="搜索字段"><div class="picker-tabs">${["推荐","文本","选择","人员","时间","关系","其他"].map(G=>`<button data-kind="${G}">${G}</button>`).join("")}</div><div class="field-options"></div>`,e.container.append(b);const I=y.getBoundingClientRect();b.style.left=`${Math.max(12,Math.min(I.left,innerWidth-410))}px`,b.style.top=`${Math.max(12,Math.min(I.bottom+4,innerHeight-340))}px`;let A="推荐";const E=(G="推荐",x="")=>{l(".field-options",b).innerHTML=n.filter(([M,N])=>{var P,_,L,H,T,R;return(!C.available||C.available(M))&&N.includes(x)&&(G==="推荐"||G==="文本"&&["title","text","longText","richText"].includes(((P=i(M))==null?void 0:P.kind)||"text")||G==="选择"&&["status","select","multiSelect"].includes(((_=i(M))==null?void 0:_.kind)||"")||G==="人员"&&((L=i(M))==null?void 0:L.kind)==="person"||G==="时间"&&["date","dateTime"].includes(((H=i(M))==null?void 0:H.kind)||"")||G==="关系"&&((T=i(M))==null?void 0:T.kind)==="relation"||G==="其他"&&((R=i(M))==null?void 0:R.kind)==="vote")}).map(([M,N])=>`<button data-field="${D(M)}" ${C.onCreate?`data-insert="${D(M)}"`:""} class="menu-option">${Re("table")}${D(N)}</button>`).join(""),C.onCreate&&l(".field-options",b).insertAdjacentHTML("beforeend",`<button class="menu-option new-field" data-create-field>${Re("add")}添加字段</button>`),b.querySelectorAll("[data-kind]").forEach(M=>{M.classList.toggle("active",M.dataset.kind===G),M.setAttribute("aria-pressed",String(M.dataset.kind===G))})};E(),l("input",b).oninput=G=>E(A,G.target.value),b.onclick=G=>{var M;const x=G.target.closest("button");x&&(G.stopPropagation(),x.dataset.kind&&(A=x.dataset.kind,E(A,l("input",b).value)),x.dataset.field&&(b.remove(),k(x.dataset.field)),x.hasAttribute("data-create-field")&&(b.remove(),(M=C.onCreate)==null||M.call(C)))}}function g(y){const k=s.instance(),C=r(y,"表格显示设置",`<input class="column-search" placeholder="搜索字段" aria-label="搜索字段"><div class="column-options">${k.api.getAllColumns().filter(b=>!b.colId.startsWith("_")).map(b=>`<label class="column-option"><input type="checkbox" data-column="${b.colId}" ${b.visible?"checked":""}><span>${D(b.headerName)}</span><button type="button" data-pin="${b.colId}">${b.pinned?"取消冻结":"冻结"}</button></label>`).join("")}</div>`,320);C.onchange=b=>{const I=b.target;I.dataset.column&&k.columnApi.setColumnVisible(I.dataset.column,I.checked)},C.onclick=b=>{const I=b.target.closest("[data-pin]");if(I){b.preventDefault();const A=k.columnApi.getColumn(I.dataset.pin);k.columnApi.setColumnPinned(A,A.pinned?null:"left"),g(y)}},l("input",C).oninput=b=>{const I=b.target.value;C.querySelectorAll(".column-option").forEach(A=>A.hidden=!A.textContent.includes(I))}}function v(y,k,C){const b=s.instance();d();const I=E=>{var M;const x=b.columnApi.getColumnState().findIndex(N=>N.colId===k)+(C?1:0);b.columnApi.setColumnVisible(E,!0),b.columnApi.setColumnPinned(E,k==="_add"?null:((M=b.columnApi.getColumn(k))==null?void 0:M.pinned)??null),b.columnApi.moveColumn(E,Math.max(1,x)),d(),h(),u()};f(y,I,{available:E=>{var G;return!((G=b.columnApi.getColumn(E))!=null&&G.visible)},onCreate:()=>{const E=r(y,"新建字段",`<form class="new-field-form"><label>字段名称<input name="label" aria-label="字段名称" required maxlength="80"></label><label>字段类型<select name="kind" aria-label="字段类型">${a.list().map(R=>`<option value="${D(R.id)}">${D(R.label)}</option>`).join("")}</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),G=l('[name="kind"]',E),x=l('[name="options"]',E),M=x.closest("label"),N=document.createElement("div");N.className="fc-field-schema",N.hidden=!0,N.innerHTML='<p class="hint">每组记录包含以下子字段</p><div class="fc-field-schema-rows"></div><button type="button" class="fc-composite-add">+ 添加子字段</button>';const P=a.list().filter(R=>!R.readonly&&!["composite","multiPersonComposite","attitudeVote","singleVote","multiVote","detail"].includes(R.id)),_=()=>{const R=document.createElement("div");R.className="fc-field-schema-row",R.innerHTML='<input class="fc-input" aria-label="子字段名称" placeholder="子字段名称"><select class="fc-input" aria-label="子字段类型">'+P.map($=>'<option value="'+D($.id)+'">'+D($.label)+"</option>").join("")+'</select><button type="button" aria-label="移除子字段">×</button>',R.querySelector("button").onclick=()=>R.remove(),N.querySelector(".fc-field-schema-rows").append(R)};N.querySelector("button").onclick=_,_();const L=document.createElement("p");L.className="fc-service-note";const H=document.createElement("p");H.className="fc-error",H.setAttribute("role","status"),l("form",E).insertBefore(N,l('button[type="submit"]',E)),l("form",E).insertBefore(L,l('button[type="submit"]',E)),l("form",E).insertBefore(H,l('button[type="submit"]',E));const T=()=>{const R=G.value,$=R==="cascadeSingle"||R==="cascadeMulti";M.hidden=!$&&!["select","multiSelect","radio","singleVote","multiVote","person","multiPerson","relation","multiRelation"].includes(R),x.placeholder=$?"每行一条路径,例如:产品 / 设计 / 交互":"每行一个选项",l(".choice-limit",E).classList.toggle("hidden",!["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(R)),N.hidden=!["composite","multiPersonComposite"].includes(R),L.textContent=$?"用 / 分隔层级;同名上级会合并。":R==="attachment"?"上传操作由宿主上传服务提供。":R.endsWith("Vote")?"投票操作由宿主投票服务提供。":"",H.textContent=""};G.onchange=T,T(),l("form",E).onsubmit=R=>{R.preventDefault();const $=new FormData(R.target),z=String($.get("label")||"").trim();if(!z)return;const j=`field_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,te=String($.get("kind")),he={key:j,label:z,kind:te,editable:!a.resolve({key:j,label:z,kind:te}).readonly,width:160};["select","multiSelect","person","multiPerson","radio","singleVote","multiVote","relation","multiRelation"].includes(te)&&(he.options=[...new Set(String($.get("options")||"").split(`
|
|
101
|
+
`).map(fe=>fe.trim()).filter(Boolean))]);const ge=Number($.get("maxSelections"));if(["multiSelect","multiPerson","multiRelation","cascadeMulti"].includes(te)&&Number.isInteger(ge)&&ge>0&&(he.maxSelections=ge),te==="dateTime"&&(he.dateOptions={showTime:!0,showSeconds:!0}),te==="cascadeSingle"||te==="cascadeMulti"){he.choices=[];for(const fe of x.value.split(`
|
|
102
|
+
`).filter(me=>me.trim())){let me=he.choices;const Ee=fe.split("/").map(Me=>Me.trim()).filter(Boolean);Ee.forEach((Me,U)=>{let se=me.find(X=>X.id===Me);se||(se={id:Me,label:Me},me.push(se)),U<Ee.length-1&&(se.children??(se.children=[]),me=se.children)})}if(!he.choices.length){H.textContent="请至少填写一条分类路径";return}}if(te==="composite"||te==="multiPersonComposite"){const fe=[...N.querySelectorAll(".fc-field-schema-row")];if(!fe.length||fe.some(me=>!me.querySelector("input").value.trim())){H.textContent="请填写子字段名称";return}he.compositeFields=fe.map((me,Ee)=>({key:"sub_"+Ee,label:me.querySelector("input").value.trim(),kind:me.querySelector("select").value})),te==="multiPersonComposite"&&he.compositeFields.unshift({key:"owner",label:"填写人",kind:"person",required:!0})}e.fields.push(he),n.push([j,z]),he.options&&(o[j]=he.options),t.customFields.push(he);const be=b.columnApi.getColumnState();b.api.setColumnDefs(s.columnDefs()),b.columnApi.applyColumnState(be,!0),I(j),p(),c()}}})}function m(y,k){const C=s.instance(),b=s.view(),I=C.columnApi.getColumn(k);if(!I||k==="_select")return;if(k==="_add"){v(y,k,!1);return}const A=["向左插入列","向右插入列",o[k]?"以 首项 → 末项 排序":"以 A → Z 排序",o[k]?"以 末项 → 首项 排序":"以 Z → A 排序","以此筛选",I.pinned?"取消冻结":"冻结列","编辑列","删除列","以此分组"],E=r(y,"",[[0,1],[2,3],[4,8],[5,6,7]].map(G=>G.map(x=>`<button class="menu-option${x===7?" destructive":""}" data-col-menu="${x}" ${x===7&&k==="name"?"disabled":""}>${A[x]}</button>`).join("")).join('<div class="column-menu-separator" role="separator"></div>'),240,"column-menu");E.dataset.headerMenu="true",E.onclick=G=>{const x=G.target.closest("[data-col-menu]");if(!x)return;const M=+x.dataset.colMenu;d(),(M===0||M===1)&&v(y,k,M===1),(M===2||M===3)&&(b.sorts=[{colId:k,sort:M===2?"asc":"desc"}],c()),M===4&&(b.filters.push({field:k,operator:"contains",value:""}),s.rulePanel("filter",l('[data-action="filter"]'))),M===5&&C.columnApi.setColumnPinned(k,I.pinned?null:"left"),M===6&&s.textDialog("编辑列",I.headerName,N=>{const P=i(k);P&&(P.label=N);const _=C.api.getColumnDefs(),L=_.find(T=>T.field===k);L&&(L.headerName=N);const H=C.columnApi.getColumnState();C.api.setColumnDefs(_),C.columnApi.applyColumnState(H,!0),u()}),M===7&&C.columnApi.setColumnVisible(k,!1),M===8&&(b.groups.includes(k)||b.groups.push(k),c())}}return{fieldPicker:f,showColumns:g,showInsertField:v,showColumnMenu:m}}function Ua(s){const{root:e,view:t,fieldConfig:n,showInsertField:i,showColumnMenu:o,applyView:a}=s,l=r=>e.querySelector(r);return function(){l("#grid").querySelectorAll(".ag-header-cell").forEach(d=>{var f,g;const c=d.dataset.colid;if(c==="_add"){if(!d.querySelector(".work-add-column")){const v=d.querySelector(".ag-header-cell-label"),m=document.createElement("button");m.type="button",m.className="work-add-column",m.ariaLabel="新增字段",m.title="新增字段",m.innerHTML=Re("add"),m.onmousedown=y=>y.stopPropagation(),m.onclick=y=>{y.stopPropagation(),i(m,"_add",!1)},v.replaceChildren(m)}return}if(!n(c))return;if(!d.querySelector(".work-header-sort")){const v=document.createElement("span");v.className="work-header-sort",(f=d.querySelector(".ag-header-cell-label"))==null||f.append(v);const m=document.createElement("button");m.className="work-header-menu",m.ariaLabel=`${n(c).label}操作`,m.innerHTML=Re("more"),m.onclick=k=>{k.stopPropagation(),o(m,c)},m.onmousedown=k=>k.stopPropagation(),d.append(m);for(const k of["right","left"]){const C=document.createElement("button");C.className="work-header-add",C.dataset.insertSide=k,C.ariaLabel=`在${n(c).label}${k==="right"?"右":"左"}侧插入列`,C.title="插入列",C.innerHTML=Re("add"),C.onclick=b=>{b.stopPropagation(),i(C,c,k==="right")},C.onmousedown=b=>b.stopPropagation(),d.append(C)}const y=()=>{const k=d.getBoundingClientRect(),C=l(".grid-wrap").getBoundingClientRect(),I=d.closest(".ag-header-viewport,.ag-pinned-left-header,.ag-pinned-right-header").getBoundingClientRect();d.querySelectorAll(".work-header-add").forEach(A=>{const E=A.dataset.insertSide==="left"?k.left:k.right;A.style.left=`${E-12}px`,A.style.top=`${k.top-20}px`,A.style.setProperty("--insert-line-height",`${Math.max(0,C.bottom-k.top+8)}px`),A.style.display=E<Math.max(C.left,I.left)-1||E>Math.min(C.right,I.right)+1?"none":""}),d.classList.add("insert-points-ready")};d.addEventListener("mouseenter",y),d.addEventListener("focusin",y),d.addEventListener("click",k=>{var b;if(k.target.closest("button,.ag-header-cell-resize"))return;k.stopImmediatePropagation();const C=(b=t().sorts.find(I=>I.colId===c))==null?void 0:b.sort;t().sorts=C==="desc"?[]:[{colId:c,sort:C==="asc"?"desc":"asc"}],a()},{capture:!0})}const p=(g=t().sorts.find(v=>v.colId===c))==null?void 0:g.sort,h=d.querySelector(".work-header-sort"),u=p==="asc"?"↑":p==="desc"?"↓":"↕";h.textContent!==u&&(h.textContent=u),h.classList.toggle("sorted",!!p),d.setAttribute("aria-sort",p==="asc"?"ascending":p==="desc"?"descending":"none")})}}function ja(s){const{fields:e,fieldConfig:t,options:n,controls:i,newItem:o,fieldPicker:a,showPopup:l,applyView:r}=s;function d(h,u){return!!u.field&&(!!u.value||["blank","notBlank"].includes(u.operator))&&Pi(h,[u])}function c(h){const u=s.view(),f=u.colors.map((I,A)=>{var N;const E=(N=t(I.field))==null?void 0:N.label,G=I.field?[["contains",n[I.field]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]]:[["","运算符"]],x=!I.field||["blank","notBlank"].includes(I.operator),M=n[I.field]?zt([["","请选择目标值"],...n[I.field].map(P=>[P,P])],I.value,`data-rule-value="${A}" aria-label="目标值" ${x?"disabled":""}`):`<input data-rule-value="${A}" aria-label="目标值" placeholder="请选择目标值" value="${D(I.value)}" ${x?"disabled":""}>`;return`<div class="color-condition" data-color-row="${A}">
|
|
93
103
|
<button class="color-drag" draggable="true" title="拖动调整条件优先级" aria-label="拖动条件">⠿</button>
|
|
94
|
-
<button type="button" class="color-swatch" data-color="${
|
|
95
|
-
<button type="button" class="field-select" data-color-scope="${
|
|
96
|
-
<button class="field-select ${
|
|
97
|
-
${
|
|
98
|
-
${
|
|
99
|
-
<button class="color-remove" data-remove="${
|
|
100
|
-
<div class="color-more-wrap"><button class="color-more" data-color-more="${
|
|
101
|
-
</div>`}).join(""),g=l(f,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${h}</div><div class="color-panel-footer"><button class="add-condition">${me("plus")}添加着色条件</button><button class="clear-rules" ${u.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");g.ariaLabel="设置颜色条件",s.setActiveRulePanel("color");const v=()=>c(f),m=()=>{r(),v()},C=["#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"],S=()=>{var R;(R=g.querySelector(".color-palette"))==null||R.remove(),g.querySelectorAll("[data-color]").forEach(M=>M.setAttribute("aria-expanded","false"))},b=()=>{var R,M,T;(R=g.querySelector(".color-scope-picker"))==null||R.remove(),(T=(M=s.getPopupEditor())==null?void 0:M.destroy)==null||T.call(M),s.setPopupEditor(null),g.querySelectorAll("[data-color-scope]").forEach(W=>W.setAttribute("aria-expanded","false"))};let y=-1;g.querySelectorAll(".color-condition").forEach((R,M)=>{R.ondragstart=T=>{var W;y=M,(W=T.dataTransfer)==null||W.setData("text/plain",String(M))},R.ondragover=T=>T.preventDefault(),R.ondrop=T=>{if(T.preventDefault(),y<0||y===M)return;const[W]=u.colors.splice(y,1);u.colors.splice(M,0,W),m()}}),g.onclick=R=>{var W,E,x;R.stopPropagation();const M=R.target.closest("button");if(R.target.closest(".color-scope-picker"))return;const T=(M==null?void 0:M.getAttribute("aria-expanded"))==="true";if(b(),!M||M.disabled){S();return}if(M.dataset.colorScope!==void 0){if(S(),T)return;const k=Number(M.dataset.colorScope),$=u.colors[k],q={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},F=n.resolve(q).createEditor({field:q,value:!$.scope||$.scope==="row"?"整行":"单元格",item:o(),surface:"cell",readonly:!1,openDetail:()=>{}});s.setPopupEditor(F);const G=document.createElement("div");G.className="popup fc-popup fc-choice-popup color-scope-picker",G.style.width="272px",G.append(F.element),g.append(G);const I=M.getBoundingClientRect();G.style.left=`${Math.max(8,Math.min(I.left,innerWidth-280))}px`,G.style.top=`${Math.max(8,Math.min(I.bottom+6,innerHeight-G.offsetHeight-8))}px`,M.setAttribute("aria-expanded","true"),F.element.addEventListener("change",L=>{var D,z,U;L.stopPropagation(),!((D=F.validate)!=null&&D.call(F))&&($.scope=F.read()==="整行"?"row":"cell",m(),(U=(z=s.popup())==null?void 0:z.querySelector(`[data-color-scope="${k}"]`))==null||U.focus())}),G.onkeydown=L=>{L.key==="Escape"&&(L.stopPropagation(),b(),M.focus())},(W=F.focus)==null||W.call(F);return}if(M.dataset.paletteColor!==void 0){const k=Number(M.closest(".color-palette").dataset.ruleIndex);u.colors[k].color=M.dataset.paletteColor,m(),(x=(E=s.popup())==null?void 0:E.querySelector(`[data-color="${k}"]`))==null||x.focus();return}if(M.dataset.color!==void 0){const k=M.getAttribute("aria-expanded")==="true";if(S(),k)return;const $=Number(M.dataset.color),q=document.createElement("div");q.className="color-palette",q.dataset.ruleIndex=String($),q.setAttribute("role","group"),q.ariaLabel="选择着色颜色",q.innerHTML=C.map(G=>`<button type="button" class="color-palette-option" data-palette-color="${G}" style="background-color:${G}" aria-label="颜色 ${G}" aria-pressed="${G===u.colors[$].color.toLowerCase()}"></button>`).join(""),g.append(q);const F=M.getBoundingClientRect();q.style.left=`${Math.max(8,Math.min(F.left,innerWidth-q.offsetWidth-8))}px`,q.style.top=`${Math.max(8,Math.min(F.bottom+6,innerHeight-q.offsetHeight-8))}px`,M.setAttribute("aria-expanded","true"),q.onkeydown=G=>{G.key==="Escape"&&(G.stopPropagation(),S(),M.focus())};return}if(S(),M.classList.contains("add-condition"))u.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),m();else if(M.dataset.pick!==void 0){const k=+M.dataset.pick;a(M,$=>{u.colors[k].field=$,u.colors[k].value="",u.colors[k].operator="contains",m()})}else if(M.dataset.remove!==void 0)u.colors.splice(+M.dataset.remove,1),m();else if(M.classList.contains("clear-rules"))u.colors=[],m();else if(M.dataset.colorMore!==void 0){const k=M.nextElementSibling,$=k.classList.contains("hidden");g.querySelectorAll(".color-rule-menu").forEach(q=>q.classList.add("hidden")),g.querySelectorAll("[data-color-more]").forEach(q=>q.setAttribute("aria-expanded","false")),k.classList.toggle("hidden",!$),M.setAttribute("aria-expanded",String($))}else if(M.dataset.colorCopy!==void 0){const k=+M.dataset.colorCopy;u.colors.splice(k+1,0,structuredClone(u.colors[k])),m()}else if(M.dataset.colorUp!==void 0||M.dataset.colorDown!==void 0){const k=Number(M.dataset.colorUp??M.dataset.colorDown),[$]=u.colors.splice(k,1);u.colors.splice(k+(M.dataset.colorUp!==void 0?-1:1),0,$),m()}},g.onchange=R=>{const M=R.target;if(M.dataset.operator!==void 0){u.colors[+M.dataset.operator].operator=M.value,m();return}M.dataset.ruleValue!==void 0&&(u.colors[+M.dataset.ruleValue].value=M.value),r()},g.oninput=R=>{const M=R.target;if(M.dataset.ruleValue!==void 0)u.colors[+M.dataset.ruleValue].value=M.value;else return;r()}}function p(f,u){if(f==="color"){c(u);return}const h=s.view(),g={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[f],v=f==="filter"?h.filters:f==="sort"?h.sorts:f==="group"?h.groups:h.colors,m=v.map((y,R)=>{var k;const M=f==="sort"?y.colId:f==="group"?y:y.field,T=((k=e.find(([$])=>$===M))==null?void 0:k[1])||M,W=`<button class="field-select" data-pick="${R}">${H(T)}${me("down")}</button>`;if(f==="sort")return`<div class="condition">${W}<button class="sort-direction ${y.sort==="asc"?"selected":""}" data-dir="asc" data-index="${R}">首项 → 末项</button><button class="sort-direction ${y.sort==="desc"?"selected":""}" data-dir="desc" data-index="${R}">末项 → 首项</button><button data-remove="${R}" aria-label="删除条件">${me("close")}</button></div>`;if(f==="group")return`<div class="condition">${W}<span class="spacer"></span><button data-remove="${R}" aria-label="删除条件">${me("close")}</button></div>`;const E=Pt([["contains",i[M]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],y.operator,`data-operator="${R}" aria-label="运算符"`),x=["blank","notBlank"].includes(y.operator)?"":i[M]?Pt([["","请选择目标值"],...i[M].map($=>[$,$])],y.value,`data-rule-value="${R}" aria-label="目标值"`):`<input data-rule-value="${R}" aria-label="目标值" value="${H(y.value)}" placeholder="请选择目标值">`;return`<div class="condition">${W}${E}${x}${f==="color"?`<input type="color" data-color="${R}" value="${y.color}" aria-label="行颜色">`:""}<button data-remove="${R}" aria-label="删除条件">${me("close")}</button></div>`}).join(""),C=l(u,`设置${g}条件`,`${f==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${h.showTerminated?"checked":""}>显示已终止数据</label>`:""}${m}<button class="add-condition">${me("plus")}添加${f==="color"?"着色":g}条件</button>${v.length?'<button class="clear-rules">清空全部条件</button>':""}`,f==="color"?650:560);s.setActiveRulePanel(f);const S=()=>p(f,u);let b=-1;C.querySelectorAll(".condition").forEach((y,R)=>{y.draggable=!0,y.ondragstart=M=>{var T;b=R,(T=M.dataTransfer)==null||T.setData("text/plain",String(R))},y.ondragover=M=>M.preventDefault(),y.ondrop=M=>{if(M.preventDefault(),b<0||b===R)return;const[T]=v.splice(b,1);v.splice(R,0,T),r(),S()}}),C.onclick=y=>{const R=y.target.closest("button");R&&(R.classList.contains("add-condition")&&a(R,M=>{f==="filter"&&h.filters.push({field:M,operator:"contains",value:""}),f==="sort"&&h.sorts.push({colId:M,sort:"asc"}),f==="group"&&!h.groups.includes(M)&&h.groups.push(M),f==="color"&&h.colors.push({field:M,operator:"contains",value:"",color:"#e9f2ff"}),r(),S()}),R.dataset.pick!==void 0&&a(R,M=>{const T=+R.dataset.pick;f==="sort"?h.sorts[T].colId=M:f==="group"?h.groups[T]=M:(v[T].field=M,v[T].value=""),r(),S()}),R.dataset.remove!==void 0&&(v.splice(+R.dataset.remove,1),r(),S()),R.classList.contains("clear-rules")&&(v.splice(0),r(),S()),R.dataset.dir&&(h.sorts[+R.dataset.index].sort=R.dataset.dir,r(),S()))},C.onchange=y=>{const R=y.target;R.id==="terminated"&&(h.showTerminated=R.checked),R.dataset.operator!==void 0&&(v[+R.dataset.operator].operator=R.value,S()),R.dataset.ruleValue!==void 0&&(v[+R.dataset.ruleValue].value=R.value),R.dataset.color!==void 0&&(h.colors[+R.dataset.color].color=R.value),r()},C.oninput=y=>{const R=y.target;R.tagName==="INPUT"&&R.dataset.ruleValue!==void 0&&(v[+R.dataset.ruleValue].value=R.value,r())}}return{colorRuleMatches:d,colorPanel:c,rulePanel:p}}function va(s={}){var d;const e=document.createElement("section");e.className="rowvia-work-items detail-header-surface";const t=document.createElement("div");t.className="detail-meta-row";const i=s.tags??[];t.innerHTML=`${i.map(c=>`<span class="detail-meta-tag">${H(c)}</span>`).join("")}<button type="button" class="detail-meta-add" data-detail-action="add-tag" aria-label="添加标签">${me("add")}</button><span class="detail-meta-divider"></span>${(s.signals||[]).map(c=>`<button type="button" class="detail-signal${c.checked?" checked":""}" data-detail-action="toggle-signal"><span class="detail-signal-dot">${c.checked?"✓":""}</span>${H(c.label)}</button>`).join("")}`,e.append(t);const n=s.stages??[],o=s.activeStage||((d=n.find(c=>c.state==="active"))==null?void 0:d.id),a=document.createElement("div");a.className="detail-process-strip",a.setAttribute("aria-label","工作项流程"),a.innerHTML=n.map((c,p)=>`<div class="detail-stage-wrap"><button type="button" class="detail-stage ${c.id===o?"active":""} ${c.state||""}" data-detail-action="stage" data-stage="${H(c.id)}"><span class="detail-stage-dot"></span>${H(c.label)}</button>${p<n.length-1?'<span class="detail-stage-line"></span>':""}</div>`).join(""),e.append(a);const l=document.createElement("div");l.className="detail-stage-card";const r=n.find(c=>c.id===o)||n[0];return r&&(l.innerHTML=`<div class="detail-stage-card-head"><div><span class="detail-stage-chevron">⌄</span><span class="detail-stage-card-dot ${r.state||""}"></span><strong>${H(r.label)}</strong><span class="detail-stage-status">进行中</span></div><div class="detail-stage-card-actions"><button type="button" class="primary" data-detail-action="complete-stage">完成</button><button type="button" class="icon-button" data-detail-action="stage-more" aria-label="节点更多">${me("more")}</button></div></div><div class="detail-stage-card-body"><span>负责人</span><strong>${H(s.owner||"待填")}</strong></div><div class="detail-dependency"><span>⌄</span> 依赖项</div>`),r&&e.append(l),e.onclick=c=>{var u;const p=c.target.closest("[data-detail-action]");if(!p)return;const f=p.dataset.detailAction||"";(u=s.onAction)==null||u.call(s,f),e.dispatchEvent(new CustomEvent("rowvia:detail-action",{detail:{action:f,stage:p.dataset.stage},bubbles:!0}))},e}function wa(s={}){const e=va(s),t=xe(e,"work-item-detail-header",s);return{element:e,onInteraction:t.onInteraction,destroy(){t.destroy(),e.onclick=null,e.remove()}}}function Ca(s,e={}){const t=document.createElement("div");t.className="rowvia-work-items rowvia-field-scope",t.style.display="contents",s.append(t);const i=new Ge,n=xe(t,"work-item-layers",e);let o=null,a=null,l=null,r,d=null;const c=(u,h,g)=>{var v,m;u==="open"?(v=e.onOpen)==null||v.call(e,h,g):(m=e.onClose)==null||m.call(e,h),t.dispatchEvent(new CustomEvent(`rowvia:layer-${u}`,{detail:{kind:h,element:g},bubbles:!0}))};function p(){o&&(o.remove(),o=null,c("close","popup"))}function f(){a&&(a.remove(),a=null,l==null||l.focus(),l=null,c("close","overlay"))}return i.listen(t,"click",u=>{var m;const h=u.target,g=(m=h.closest("[data-action]"))==null?void 0:m.dataset.action,v=g==="close-popup"?"popup":g==="close-overlay"||h===a?"overlay":void 0;v&&(u.stopPropagation(),e.onCloseRequest?e.onCloseRequest(v):v==="popup"?p():f())}),{element:t,onInteraction:n.onInteraction,closePopup:p,closeOverlay:f,showPopup(u,h,g,v=460,m=""){if(i.destroyed)throw new Error("Cannot open a destroyed layer host");p(),o=document.createElement("section"),o.className=`popup ${m}`,o.setAttribute("role","dialog"),o.ariaLabel=h||"列操作",o.style.width=`${v}px`,o.innerHTML=`${h?`<div class="popup-head"><span>${H(h)}</span>${Ce("close-popup","","close")}</div>`:""}${g}`,t.append(o);const C=u.getBoundingClientRect();return o.style.left=`${Math.max(12,Math.min(C.left,innerWidth-v-16))}px`,o.style.top=`${Math.min(C.bottom+8,Math.max(12,innerHeight-o.offsetHeight-16))}px`,c("open","popup",o),o},showOverlay(u,h="dialog-overlay"){if(i.destroyed)throw new Error("Cannot open a destroyed layer host");return a?(a.remove(),c("close","overlay")):l=document.activeElement,a=document.createElement("div"),a.className=`overlay ${h}`,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),typeof u=="string"?a.innerHTML=u:a.append(u),t.append(a),c("open","overlay",a),a},toast(u){if(i.destroyed)return;r==null||r(),d==null||d.remove();const h=document.createElement("div");h.className="toast",h.setAttribute("role","status"),h.innerHTML=me("check")+H(u),t.append(h),d=h;const g=window.setTimeout(()=>{h.remove(),r==null||r()},2500);r=i.add(()=>window.clearTimeout(g))},destroy(){i.destroyed||(i.destroy(),n.destroy(),p(),f(),t.remove())}}}const rt=new Map;function Ke(s,e){if(!s)return!1;const t=e?[e]:[],i=new Set;for(let n=0;n<Math.max(1,t.length);n++)for(const[o,a]of rt)if(!(i.has(o)||e&&!t[n].contains(a))){if(o.element.contains(s))return!0;i.add(o),t.push(o.element)}return!1}function ya(s){for(const[e,t]of[...rt])(!s||s.contains(t))&&e.close()}function $t(s){const{anchor:e,content:t,width:i="anchor",gap:n=4,onDismiss:o}=s,a=e.ownerDocument,l=a.defaultView||window,r=s.anchorMode==="element"?e:e.closest(".fc-focus-body")||e,d=a.createElement("div");d.className="rowvia-field-scope rowvia-field-popup-layer";const c=a.createElement("div");c.className="rowvia-field-popup",c.append(t),d.append(c),(a.body||a.documentElement).append(d);let p=!1;const f=()=>{if(p||!d.isConnected)return;const m=r.getBoundingClientRect(),C=a.documentElement.clientWidth||l.innerWidth,S=a.documentElement.clientHeight||l.innerHeight,b=i==="anchor"?m.width+2:i==="auto"?c.getBoundingClientRect().width:i;c.style.width=i==="auto"?"max-content":b+"px";const y=c.getBoundingClientRect().height;let R=m.bottom+n;const M=m.top-n-y;R+y>S-8&&M>=8&&(R=M),R=Math.max(8,Math.min(R,Math.max(8,S-y-8)));const T=Math.max(8,Math.min(s.align==="end"?m.right-b:m.left,Math.max(8,C-b-8)));d.style.top=Math.round(R)+"px",d.style.left=Math.round(T)+"px"},u=()=>{p||(p=!0,ya(d),rt.delete(v),a.removeEventListener("pointerdown",h,!0),a.removeEventListener("keydown",g,!0),l.removeEventListener("resize",f),l.removeEventListener("scroll",f,!0),d.remove(),o==null||o())},h=m=>{const C=m.target;C&&(d.contains(C)||r.contains(C)||e.contains(C)||Ke(C,d))||u()},g=m=>{if(m.key!=="Escape"||[...rt.keys()][rt.size-1]!==v)return;if(m.preventDefault(),m.stopPropagation(),u(),s.onEscape){s.onEscape();return}const C=a.defaultView.CustomEvent;e.dispatchEvent(new C("fc-collapse",{bubbles:!0,detail:{reason:"escape"}}))},v={element:d,reposition:f,close:u};return rt.set(v,e),a.addEventListener("pointerdown",h,!0),a.addEventListener("keydown",g,!0),l.addEventListener("resize",f),l.addEventListener("scroll",f,!0),f(),v}const si=new WeakMap;function hn(s,e){let t=si.get(s);if(!t){const n=new Set,o=a=>{for(const l of[...n])n.has(l)&&!l.contains(a.target,a)&&l.leave(a)};s.addEventListener("pointerdown",o,!0),s.addEventListener("focusin",o,!0),t={boundaries:n,stop:()=>{s.removeEventListener("pointerdown",o,!0),s.removeEventListener("focusin",o,!0)}},si.set(s,t)}t.boundaries.add(e);const i=t;return()=>{!i.boundaries.delete(e)||i.boundaries.size||(i.stop(),si.delete(s))}}class Le{constructor(e){w(this,"root");w(this,"destroying",!1);w(this,"feedback");w(this,"options");w(this,"value");w(this,"committedValue");w(this,"state");w(this,"view");w(this,"viewLife",new Ge);w(this,"life",new Ge);w(this,"listeners",new Set);w(this,"interactions");w(this,"interactionListeners",new Set);w(this,"mounted",!1);w(this,"handled",new WeakSet);this.options={...e},this.value=e.value,this.committedValue=e.value,this.state=e.readonly||e.canEdit===!1?"display":e.state??"display"}get element(){if(this.root)return this.root;const e=document.createElement("div");return e.className="rowvia-field",e.tabIndex=0,e.setAttribute("aria-label",this.options.field.label),this.root=e,e}bindRoot(){this.life.listen(this.element,"pointerenter",()=>{this.state==="display"&&this.setState("hover","user")}),this.life.listen(this.element,"pointerleave",()=>{this.state==="hover"&&this.setState("display","user")}),this.life.listen(this.element,"click",e=>{e.target.closest("button,a,input,textarea,select,[contenteditable]")||this.edit("user")}),this.life.listen(this.element,"keydown",e=>{const t=e.key;t==="Escape"&&this.state==="editing"?(e.preventDefault(),this.cancel("user")):(t==="Enter"||t===" ")&&this.state!=="editing"&&e.target===this.element&&(e.preventDefault(),this.edit("user"))}),this.life.listen(this.element,"fc-collapse",e=>{var t;((t=e.detail)==null?void 0:t.reason)==="escape"?this.cancel("user"):this.commit("user")}),this.life.listen(this.element,"focusout",()=>{queueMicrotask(()=>{var t,i;if(this.life.destroyed||!this.element.isConnected||this.state!=="editing")return;const e=this.element.ownerDocument.activeElement;this.element.contains(e)||(i=(t=this.view)==null?void 0:t.content)!=null&&i.contains(e)||Ke(e,this.element)||this.commit("user")})})}renderHover(e){return this.renderDisplay(e)}beforeInput(e){return e}beforeCommit(e){return!0}beforeCancel(e){return!0}beforeStateChange(e){return!0}validateValue(e){}isReadonly(){return!!this.options.readonly||this.options.canEdit===!1||this.options.field.editable===!1}onOutput(e){}get snapshot(){return{key:this.options.field.key,value:this.read(),committedValue:this.committedValue,state:this.state,readonly:this.isReadonly()}}mount(e){if(this.life.destroyed)throw new Error("Cannot mount a destroyed field");return this.mounted||(this.mounted=!0,this.bindRoot(),this.draw()),e==null||e.append(this.element),this}read(){var e;return this.state==="editing"&&((e=this.view)!=null&&e.read)?this.view.read():this.value}on(e){return this.life.destroyed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)})}onInteraction(e){return this.life.destroyed?()=>{}:(this.interactionListeners.add(e),()=>{this.interactionListeners.delete(e)})}input(e,t="api",i){var l;if(this.life.destroyed||this.snapshot.readonly)return;const n=this.value,o=this.snapshot,a=this.beforeInput(e);this.value=(l=this.options.hooks)!=null&&l.beforeInput?this.options.hooks.beforeInput(a,o):a,(t==="api"||!Object.is(e,this.value))&&this.draw(),this.emit("input",t,{previousValue:n,originalEvent:i})}setValue(e){if(this.life.destroyed)return;const t=this.read();this.value=e,this.committedValue=e,this.draw(),this.emit("change","api",{previousValue:t})}update(e){this.life.destroyed||(this.value=this.read(),this.options={...this.options,...e},"value"in e&&(this.value=this.committedValue=e.value),e.state&&(this.state=e.state),this.isReadonly()&&(this.state="display"),this.draw())}validate(){var i,n,o,a;const e=this.read(),t=e==null||e===""||Array.isArray(e)&&e.length===0;return(this.options.field.required&&t?"此项必填":void 0)||this.validateValue(e)||((n=(i=this.view)==null?void 0:i.validate)==null?void 0:n.call(i))||((a=(o=this.options.hooks)==null?void 0:o.validate)==null?void 0:a.call(o,e))}commit(e="api"){var n,o;if(this.life.destroyed||this.snapshot.readonly)return!1;const t=this.validate();if(this.showValidation(t),t)return this.emit("invalid",e,{message:t}),!1;const i=this.event("commit",e,{previousValue:this.committedValue});return!this.beforeCommit(i)||((o=(n=this.options.hooks)==null?void 0:n.beforeCommit)==null?void 0:o.call(n,i))===!1?!1:(this.value=this.read(),this.committedValue=this.value,this.element.removeAttribute("aria-invalid"),this.emit("commit",e,{previousValue:i.previousValue}),this.setState("display",e),!0)}cancel(e="api"){var n,o,a,l;if(this.life.destroyed)return;const t=this.event("cancel",e);if(!this.beforeCancel(t)||((o=(n=this.options.hooks)==null?void 0:n.beforeCancel)==null?void 0:o.call(n,t))===!1)return;const i=this.event("state",e,{previousState:this.state,state:"display",value:this.committedValue});this.state!=="display"&&(!this.beforeStateChange(i)||((l=(a=this.options.hooks)==null?void 0:a.beforeStateChange)==null?void 0:l.call(a,i))===!1)||(this.value=this.committedValue,this.disposeView(),this.state="display",this.draw(),this.emit("cancel",e),i.previousState!=="display"&&this.publish(i))}edit(e="api"){var t,i;this.life.destroyed||(this.setState("editing",e),this.state==="editing"&&((i=(t=this.view)==null?void 0:t.focus)==null||i.call(t)))}setState(e,t="api"){var o,a,l,r;if(this.life.destroyed||e===this.state||e==="editing"&&this.snapshot.readonly)return;const i=this.event("state",t,{previousState:this.state});if(i.state=e,!this.beforeStateChange(i)||((a=(o=this.options.hooks)==null?void 0:o.beforeStateChange)==null?void 0:a.call(o,i))===!1)return;const n=this.state!=="editing"&&e!=="editing"&&!((l=this.options.renderers)!=null&&l.display)&&!((r=this.options.renderers)!=null&&r.hover)&&this.renderHover===Le.prototype.renderHover;this.value=this.read(),this.state=e,n&&this.view?this.element.dataset.state=e:this.draw(),this.publish(i)}action(e,t){var n,o;if(this.life.destroyed)return;const i={type:e,value:t};(o=(n=this.options).onAction)==null||o.call(n,i),this.emit("action","api",{action:i})}destroy(){var e,t;if(!(this.life.destroyed||this.destroying)){this.destroying=!0,this.value=this.read();try{this.emit("destroy","api")}finally{try{this.disposeView()}finally{(e=this.interactions)==null||e.destroy(),this.life.destroy(),this.listeners.clear(),this.interactionListeners.clear(),(t=this.root)==null||t.remove()}}}}createEditor(){if(this.life.destroyed)throw new Error("Cannot edit a destroyed field");this.disposeView(),this.state="editing";const e=this.renderEditing(this.context());return this.view=e,this.watch(e),{...e,read:()=>this.read(),validate:()=>this.validate(),onInteraction:t=>this.onInteraction(t),destroy:()=>this.destroy()}}render(){if(this.life.destroyed)throw new Error("Cannot render a destroyed field");return this.disposeView(),this.view=this.renderDisplay(this.context()),{...this.view,destroy:()=>this.destroy()}}context(){return{...this.options,readonly:this.isReadonly(),value:this.value,onAction:e=>this.action(e.type,e.value)}}showValidation(e){var t;if(this.mounted){if(!e){this.element.removeAttribute("aria-invalid"),(t=this.feedback)==null||t.remove();return}this.feedback??(this.feedback=this.element.ownerDocument.createElement("div")),this.feedback.className="fc-error",this.feedback.setAttribute("role","status"),this.feedback.textContent=e,this.element.setAttribute("aria-invalid","true"),this.element.append(this.feedback)}}draw(){var c,p,f,u,h,g,v;if(!this.mounted||this.life.destroyed)return;const e=this.element.ownerDocument.activeElement,t=this.state==="editing"&&!!e&&(!!((c=this.view)!=null&&c.element.contains(e))||!!((f=(p=this.view)==null?void 0:p.content)!=null&&f.contains(e))),i=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:void 0;this.disposeView(),this.isReadonly()&&(this.state="display");const n=this.snapshot,o=this.options.content,a=typeof o=="function"?o(n):o??{kind:"text",text:this.value==null?"":String(this.value)},l=this.context(),r=()=>this.state==="editing"?this.renderEditing(l):o?oi(a):this.state==="hover"?this.renderHover(l):this.renderDisplay(l),d={...n,element:this.element,field:this.options.field,content:a,renderDefault:r,input:m=>this.input(m),commit:()=>this.commit(),cancel:()=>this.cancel(),edit:()=>this.edit(),action:(m,C)=>this.action(m,C)};if(this.view=((h=(u=this.options.renderers)==null?void 0:u[this.state])==null?void 0:h.call(u,d))??r(),this.element.setAttribute("aria-label",this.options.field.label),this.element.dataset.state=this.state,this.element.dataset.readonly=String(n.readonly),this.element.replaceChildren(this.view.element),this.element.removeAttribute("aria-invalid"),this.watch(this.view),t){(v=(g=this.view).focus)==null||v.call(g);const m=this.element.ownerDocument.activeElement;if((i==null?void 0:i.start)!=null&&i.end!=null&&(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement))try{m.setSelectionRange(i.start,i.end)}catch{}}}watch(e){if(this.mounted&&this.state==="editing"){const i=()=>[this.element,e.content,this.options.focusBoundary].filter(n=>!!n);this.viewLife.add(hn(this.element.ownerDocument,{contains:(n,o)=>i().some(a=>o.composedPath().includes(a)||!!n&&a.contains(n)||Ke(n,a)),leave:()=>{this.element.isConnected&&this.commit("user")}}))}this.interactions??(this.interactions=xe(this.mounted?this.element:e.element,`field:${this.options.field.key}`,{onInteraction:i=>{var n,o;(o=(n=this.options).onInteraction)==null||o.call(n,i);for(const a of this.interactionListeners)a(i)}}));const t=[...new Set([e.element,e.content].filter(i=>!!i))];for(const i of t)this.viewLife.add(this.interactions.addRoot(i));for(const i of e.inputRoot?[e.inputRoot]:t)for(const n of["input","change"])this.viewLife.listen(i,n,o=>{var a;this.handled.has(o)||(this.handled.add(o),this.input(((a=e.read)==null?void 0:a.call(e))??this.value,"user",o),n==="change"&&this.emit("change","user",{originalEvent:o}))})}disposeView(){var t;this.viewLife.destroy(),this.viewLife=new Ge;const e=this.view;this.view=void 0,(t=e==null?void 0:e.destroy)==null||t.call(e)}event(e,t,i={}){return{...this.snapshot,type:e,source:t,...i}}emit(e,t,i={}){this.publish(this.event(e,t,i))}publish(e){var n,o,a;this.onOutput(e),(o=(n=this.options).onEvent)==null||o.call(n,e);for(const l of[...this.listeners])l(e);const t=this.mounted?this.element:(a=this.view)==null?void 0:a.element;if(!t)return;const i=t.ownerDocument.defaultView.CustomEvent;t.dispatchEvent(new i(`field:${e.type}`,{detail:e,bubbles:!0}))}}function oi(s){if(s.kind==="node")return{element:s.node,destroy:s.destroy};const e=document.createElement("div");if(e.className=s.className??"",s.kind==="text")return e.textContent=s.text,{element:e};const t=s.children.map(oi);return e.append(...t.map(i=>i.element)),{element:e,destroy:()=>t.forEach(i=>{var n;return(n=i.destroy)==null?void 0:n.call(i)})}}function P(s,e="",t){const i=document.createElement(s);return i.className=e,t!==void 0&&(i.textContent=t),i}function pn(s,e=312){s.rows=1,s.style.resize="none";const t=()=>{s.style.height="auto";const i=s.scrollHeight;i>0&&(s.style.height=Math.min(i,e)+"px"),s.style.overflowY=i>e?"auto":"hidden"};return s.addEventListener("input",t),s.addEventListener("focus",t),queueMicrotask(t),t}const Be=s=>s.choices??(s.options||[]).map(e=>({id:e,label:e})),fn=["rgba(61, 188, 47, 0.2)","rgba(0, 184, 159, 0.2)","rgba(244, 118, 189, 0.2)","rgba(149, 155, 238, 0.2)","rgba(184, 143, 255, 0.2)"],ai=(s,e)=>{var t,i;return((t=Be(s).find(n=>n.id===e))==null?void 0:t.color)||((i=s.colors)==null?void 0:i[e])||fn[Math.max(0,Be(s).findIndex(n=>n.id===e))%fn.length]},gn=s=>(Array.isArray(s)?s:s==null||s===""?[]:[s]).map(String);function ba(s,e){var t;return((t=Be(s).find(i=>i.id===e))==null?void 0:t.label)||e}function Sa(s,e="choice"){const t=P("div","fc-tags");for(const i of gn(s.value)){const n=ba(s.field,i),o=P(e==="relation"?"button":"span","fc-tag fc-tag--"+e);e==="choice"&&(o.style.backgroundColor=ai(s.field,i)),e==="person"&&o.append(P("span","fc-avatar",n.slice(0,1))),o.append(P("span","fc-tag-label",n)),o.tagName==="BUTTON"&&(o.type="button",o.onclick=a=>{var l;a.stopPropagation(),(l=s.onAction)==null||l.call(s,{type:"open",value:i})}),t.append(o)}return t.children.length||t.append(P("span","fc-empty","待填")),t}function mn(s,e,t="choice"){var I;const i=P("div","fc-choice fc-choice--"+t);let n=gn(e.value).slice(0,s?void 0:1);const o=new Map(Be(e.field).map(L=>[L.id,L]));let a=Be(e.field);const l=s&&(e.field.maxSelections??0)>0?e.field.maxSelections:1/0,r=P("select","fc-select");r.hidden=!0,r.multiple=s,r.disabled=e.readonly,r.required=!!e.field.required,r.ariaLabel=e.field.label;const d=P("div","fc-choice-head"),c=P("div","fc-choice-selection"),p=P("span","fc-empty fc-choice-placeholder","待填"),f=P("input","fc-choice-search");f.placeholder="",f.autocomplete="off",f.ariaLabel="输入以搜索"+e.field.label,f.disabled=e.readonly;const u=()=>{f.size=Math.max(1,[...f.value].length+1)};u();const h=P("div","fc-option-list");h.setAttribute("role",t==="radio"?"radiogroup":"group"),h.ariaLabel=e.field.label;const g=P("div","fc-error fc-choice-feedback");g.setAttribute("role","status");const v=P("div","fc-picker-status");v.setAttribute("role","status");const m=P("button","fc-retry","重试");m.type="button",m.hidden=!0;let C,S=0,b=!1,y=!1;const R=t!=="radio"&&!!((I=e.services)!=null&&I.searchOptions),M=t!=="radio"&&e.layout!=="compact"&&!e.readonly;let T;const W=()=>{const L=T;T=void 0,L==null||L.close()},E=()=>{!M||b||T||e.readonly||(T=$t({anchor:d,content:h,width:"anchor",onDismiss:()=>{T=void 0}}))},x=()=>{!M||!T||(W(),i.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},k=()=>{var L;(L=e.onSelectedOptions)==null||L.call(e,n.map(D=>o.get(D)).filter(D=>!!D)),i.dispatchEvent(new Event("change",{bubbles:!0}))},$=()=>{var L;if(r.replaceChildren(),!s){const D=P("option");D.value="",r.append(D)}for(const D of new Set([...a.map(z=>z.id),...n])){const z=P("option","",((L=o.get(D))==null?void 0:L.label)||D);z.value=D,z.selected=n.includes(D),r.append(z)}s||(r.value=n[0]||"")},q=()=>{c.replaceChildren(),h.replaceChildren(),$(),!n.length&&!f.value&&c.append(p);for(const z of n){const U=o.get(z),K=P("span","fc-tag fc-tag--"+t);(t==="choice"||t==="radio")&&(K.style.backgroundColor=ai(e.field,z)),t==="person"&&K.append(P("span","fc-avatar",((U==null?void 0:U.label)||z).slice(0,1))),K.append(P("span","fc-tag-label",((U==null?void 0:U.label)||z)+(U!=null&&U.disabled?"(已停用)":"")));const Z=P("span","fc-tag-slot"),ie=P("button","fc-choice-remove","×");ie.type="button",ie.disabled=e.readonly,ie.ariaLabel="移除"+((U==null?void 0:U.label)||z),ie.onclick=pe=>{pe.stopPropagation(),n=n.filter(J=>J!==z),g.textContent="",q(),f.focus(),k()},Z.append(ie),K.append(Z),c.append(K)}const L=f.value.trim().toLocaleLowerCase(),D=a.filter(z=>!z.disabled&&(R||(z.label+" "+z.id+" "+(z.description||"")).toLocaleLowerCase().includes(L)));for(const z of D){const U=P("button","fc-option");U.type="button",U.dataset.value=z.id,U.disabled=e.readonly||y;const K=n.includes(z.id);U.classList.toggle("selected",K),U.setAttribute(t==="radio"?"aria-checked":"aria-pressed",String(K)),t==="radio"&&U.setAttribute("role","radio");const Z=P("span","fc-option-label"+(t==="choice"?" fc-tag":""),z.label);t==="choice"&&(Z.style.backgroundColor=ai(e.field,z.id)),t==="person"&&U.append(P("span","fc-avatar",z.label.slice(0,1))),t==="relation"&&U.append(P("span","fc-relation-icon","↗"));const ie=P("span","fc-option-copy");ie.append(Z),z.description&&ie.append(P("small","fc-option-description",z.description)),U.append(ie,P("span","fc-option-mark",K?"✓":"")),U.onclick=pe=>{if(pe.stopPropagation(),!e.readonly){if(!s)n=[z.id];else if(K)n=n.filter(J=>J!==z.id);else{const J=z.exclusive?[]:n.filter(ce=>{var fe;return!((fe=o.get(ce))!=null&&fe.exclusive)});if(J.length>=l){g.textContent="最多可选择 "+l+" 项";return}n=[...J,z.id]}g.textContent="",s||(f.value="",u()),q(),h.querySelectorAll("button").forEach(J=>{J.dataset.value===z.id&&J.focus()}),k(),!s&&M&&x()}},h.append(U)}!D.length&&!y&&h.append(P("p","fc-empty fc-choice-empty","暂无匹配选项"))},F=async()=>{C==null||C.abort();const L=++S;C=new AbortController,y=!0,m.hidden=!0,v.textContent="加载中…",i.setAttribute("aria-busy","true"),q();try{const D=await e.services.searchOptions(e.field,f.value.trim(),C.signal);if(b||L!==S)return;a=D,D.forEach(z=>o.set(z.id,z)),v.textContent=""}catch{if(b||L!==S)return;a=[],v.textContent="加载失败,请重试",m.hidden=!1}finally{!b&&L===S&&(y=!1,i.setAttribute("aria-busy","false"),q())}};f.oninput=()=>{u(),R?F():q()},f.onfocus=()=>E(),d.onclick=L=>{L.target.closest("button")||f.focus()},m.onclick=()=>void F();const G=L=>{if(!["ArrowDown","ArrowUp","ArrowLeft","ArrowRight","Home","End"].includes(L.key))return;const D=[...h.querySelectorAll("button:not(:disabled)")];if(!D.length)return;L.preventDefault();const z=D.indexOf(document.activeElement),U=L.key==="Home"?0:L.key==="End"?D.length-1:(z+(L.key==="ArrowUp"||L.key==="ArrowLeft"?-1:1)+D.length)%D.length;D[U].focus()};if(h.onkeydown=G,f.onkeydown=L=>{L.key==="ArrowDown"&&(E(),G(L))},r.onchange=()=>{n=[...r.selectedOptions].map(L=>L.value).filter(Boolean),q()},d.append(c),t!=="radio"&&d.append(f),M){const L=P("span","fc-field-chevron");L.setAttribute("aria-hidden","true"),d.append(L),i.append(r,d,v,m,g)}else i.append(r,d,v,h,m,g);return q(),R&&!e.readonly&&F(),{element:i,content:M?h:void 0,read:()=>s?[...n]:n[0]||"",validate:()=>e.field.required&&!n.length?"请选择一个选项":n.length>l?"最多可选择 "+l+" 项":void 0,focus:()=>{var L;if(t==="radio"){(L=h.querySelector("button"))==null||L.focus();return}f.focus(),E()},deactivate:()=>{f.value="",u(),W()},destroy:()=>{b=!0,++S,C==null||C.abort(),W()}}}const 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 IMG PRE CODE HR TABLE THEAD TBODY TR TH TD INPUT".split(" ")),vn=s=>/^(https?:\/\/|mailto:)/i.test(s.trim());function yt(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")||"",l=o.getAttribute("src")||"",r=o.getAttribute("alt")||"",d=o.getAttribute("data-person-id"),c=o.hasAttribute("checked"),p=o.getAttribute("data-task")==="true",f=["color","background-color","text-align","margin-left","font-weight","font-style","text-decoration-line"].map(h=>[h,o.style.getPropertyValue(h)]),u=o.tagName==="FONT"?o.getAttribute("color"):null;for(const h of[...o.attributes])o.removeAttribute(h.name);for(const[h,g]of f)(h==="color"||h==="background-color"?/^(#[a-f\d]{3,8}|rgba?\([\d.,%\s]+\)|[a-z]+)$/i.test(g):h==="text-align"?/^(left|center|right|justify)$/.test(g):h==="margin-left"?/^\d{1,3}px$/.test(g):/^(bold|normal|italic|underline|line-through|[1-9]00)$/.test(g))&&o.style.setProperty(h,g);if(u&&/^(#[a-f\d]{3,8}|[a-z]+)$/i.test(u)&&(o.style.color=u),o.tagName==="A"&&vn(a)&&(o.setAttribute("href",a.trim()),o.setAttribute("target","_blank"),o.setAttribute("rel","noopener noreferrer")),o.tagName==="IMG"){if(!/^https?:\/\//i.test(l.trim())){o.remove();continue}o.setAttribute("src",l.trim()),o.setAttribute("alt",r),o.setAttribute("loading","lazy"),o.setAttribute("referrerpolicy","no-referrer")}o.tagName==="SPAN"&&d&&(o.setAttribute("data-person-id",d),o.setAttribute("contenteditable","false")),o.tagName==="INPUT"&&(o.setAttribute("type","checkbox"),o.setAttribute("contenteditable","false"),c&&o.setAttribute("checked","")),p&&o.tagName==="LI"&&o.setAttribute("data-task","true")}};return t(e.content),e.innerHTML}const ri={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 xa(s){const e=P("div",`fc-rich${s.layout==="compact"?" fc-rich-compact":""}`),t=P("div","fc-rich-toolbar");t.setAttribute("role","toolbar"),t.ariaLabel="文本格式";const i=P("div","fc-rich-tools");t.append(i);const n=P("div","fc-rich-content");n.contentEditable=String(!s.readonly),n.setAttribute("role","textbox"),n.setAttribute("aria-multiline","true"),n.ariaLabel=s.field.label,n.tabIndex=s.readonly?-1:0,n.innerHTML=yt(s.value);const o=P("div","fc-rich-menu");o.hidden=!0;let a=null,l=!1,r=[n.innerHTML],d=0,c=!1,p=null,f,u;const h=()=>{const I=window.getSelection();I!=null&&I.rangeCount&&n.contains(I.anchorNode)&&n.contains(I.focusNode)&&(a=I.getRangeAt(0).cloneRange())},g=()=>{n.focus();const I=window.getSelection();if(!I)return;const L=a&&n.contains(a.commonAncestorContainer)?a:document.createRange();L!==a&&(L.selectNodeContents(n),L.collapse(!1)),I.removeAllRanges(),I.addRange(L),a=L},v=()=>{var L;const I=u;u=void 0,I==null||I.close(),(L=f==null?void 0:f.destroy)==null||L.call(f),f=void 0,o.hidden=!0,o.replaceChildren()},m=new Map,C=()=>{var I;m.get("撤销").disabled=s.readonly||d===0,m.get("重做").disabled=s.readonly||d===r.length-1;for(const[L,D]of[["加粗","bold"],["斜体","italic"],["下划线","underline"],["删除线","strikeThrough"],["有序列表","insertOrderedList"],["无序列表","insertUnorderedList"]]){const z=m.get(L);if(!z)continue;const U=!!((I=document.queryCommandState)!=null&&I.call(document,D));z.classList.toggle("active",U),z.setAttribute("aria-pressed",String(U))}},S=()=>{c||(n.innerHTML!==r[d]&&(r=r.slice(0,d+1),r.push(n.innerHTML),r.length>100&&r.shift(),d=r.length-1),h(),C())},b=()=>{S(),n.dispatchEvent(new Event("change",{bubbles:!0}))},y=I=>{const L=d+I;L<0||L>=r.length||(d=L,c=!0,n.innerHTML=r[d],a=null,g(),c=!1,C(),n.dispatchEvent(new Event("change",{bubbles:!0})))},R=(I,L)=>{s.readonly||(g(),document.execCommand(I,!1,L),h(),v(),b())},M=I=>{if(s.readonly)return;g();const L=window.getSelection().getRangeAt(0);L.deleteContents(),L.insertNode(I),L.setStartAfter(I),L.collapse(!0),a=L.cloneRange(),v(),b()},T=(I,L,D,z=!0)=>{const U=P("button",z?"fc-rich-tool fc-rich-advanced":"fc-rich-tool");return U.type="button",U.ariaLabel=I,U.title=I,U.disabled=s.readonly,ri[L]?U.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${ri[L]}</svg>`:U.textContent=L,U.onmousedown=K=>{K.preventDefault(),h()},U.onclick=K=>{K.stopPropagation(),D()},i.append(U),m.set(I,U),U},W=(I,L)=>{if(!s.readonly){if(h(),!o.hidden&&o.ariaLabel===I){v();return}v(),o.className="fc-rich-menu",o.ariaLabel=I,o.hidden=!1,u=$t({anchor:m.get(I),anchorMode:"element",content:o,width:"auto",onDismiss:v,onEscape:g}),L(),u==null||u.reposition()}},E=(I,L)=>{const D=P("button","fc-rich-menu-option",I);return D.type="button",D.onmousedown=z=>z.preventDefault(),D.onclick=z=>{z.stopPropagation(),L()},o.append(D),D};T("撤销","undo",()=>y(-1),!1),T("重做","redo",()=>y(1),!1),T("格式刷","paint",()=>{h();const I=a==null?void 0:a.startContainer,L=(I==null?void 0:I.nodeType)===1?I:I==null?void 0:I.parentElement;!L||!n.contains(L)||(p={tag:/^(B|STRONG|I|EM|U|S)$/.test(L.tagName)?L.tagName.toLowerCase():"span",css:L.getAttribute("style")||""},m.get("格式刷").classList.add("active"))}),T("正文样式","Aa⌄",()=>W("正文样式",()=>{for(const[I,L]of[["正文","p"],["标题 1","h1"],["标题 2","h2"],["标题 3","h3"],["标题 4","h4"],["标题 5","h5"]])E(I,()=>R("formatBlock",L))}));const x=["#1f2329","#8f959e","#ffffff","#f54a45","#ff8800","#ffc60a","#34c724","#14b8a6","#3370ff","#7f3bf5","#f7cdd9","#fce2cf","#fff3b8","#d9f5d6","#d6e8ff","#e9ddfa"];for(const[I,L,D]of[["文字颜色","A⌄","foreColor"],["背景高亮","▰⌄","hiliteColor"]])T(I,L,()=>W(I,()=>{o.classList.add("fc-rich-colors");for(const z of x){const U=E(z,()=>R(D,z));U.textContent="",U.style.backgroundColor=z,U.ariaLabel=`${I} ${z}`}E("清除",()=>R(D,D==="foreColor"?"#1f2329":"transparent"))}));for(const[I,L,D]of[["加粗","B","bold"],["斜体","I","italic"],["下划线","U","underline"],["删除线","S","strikeThrough"]])T(I,L,()=>R(D));T("对齐","☰⌄",()=>W("对齐",()=>{for(const[I,L]of[["左对齐","justifyLeft"],["居中对齐","justifyCenter"],["右对齐","justifyRight"],["两端对齐","justifyFull"]])E(I,()=>R(L))})),T("有序列表","1≡",()=>R("insertOrderedList")),T("无序列表","•≡",()=>R("insertUnorderedList")),T("任务列表","task",()=>{g();const I=window.getSelection().getRangeAt(0),L=P("ul"),D=P("li");D.dataset.task="true";const z=P("input");z.type="checkbox",z.contentEditable="false",D.append(z,I.extractContents()),D.textContent||D.append(document.createTextNode("待办事项")),L.append(D),M(L)}),T("引用","quote",()=>R("formatBlock","blockquote")),T("缩进","indent",()=>W("缩进",()=>{E("增加缩进",()=>R("indent")),E("减少缩进",()=>R("outdent"))})),T("分隔线","line",()=>M(P("hr"))),T("表格","table",()=>W("表格",()=>{const I=P("p","","选择行列"),L=P("div","fc-rich-table-grid");o.append(I,L);for(let D=1;D<=6;D++)for(let z=1;z<=6;z++){const U=P("button");U.type="button",U.ariaLabel=`${D}行${z}列表格`,U.dataset.row=String(D),U.dataset.col=String(z),U.onmousedown=K=>K.preventDefault(),U.onmouseenter=()=>{I.textContent=`${D} × ${z}`,L.querySelectorAll("button").forEach(K=>K.classList.toggle("active",Number(K.dataset.row)<=D&&Number(K.dataset.col)<=z))},U.onclick=()=>{const K=P("table"),Z=P("tbody");for(let pe=0;pe<D;pe++){const J=P("tr");for(let ce=0;ce<z;ce++){const fe=P("td");fe.append(P("br")),J.append(fe)}Z.append(J)}K.append(Z),M(K);const ie=document.createRange();ie.selectNodeContents(K.querySelector("td")),ie.collapse(!0),a=ie,g()},L.append(U)}}));const k=()=>W("链接",()=>{const I=P("input","fc-input");I.ariaLabel="链接文本",I.placeholder="输入文本",I.value=(a==null?void 0:a.toString())||"";const L=P("input","fc-input");L.ariaLabel="链接地址",L.placeholder="粘贴或输入超链接";const D=P("div","fc-error"),z=P("button","primary","确定");z.type="button",z.onclick=()=>{const U=L.value.trim();if(!vn(U)){D.textContent="请输入 http、https 或 mailto 链接";return}const K=P("a","",I.value||U);K.href=U,K.target="_blank",K.rel="noopener noreferrer",M(K)},o.append(P("span","","文本"),I,P("span","","链接"),L,D,z),I.focus()});T("链接","link",k),T("插入图片","▧",()=>W("插入图片",()=>{const I=P("input","fc-input");I.type="url",I.ariaLabel="图片地址",I.placeholder="https:// 图片地址";const L=P("input","fc-input");L.ariaLabel="图片说明",L.placeholder="图片说明";const D=P("div","fc-error"),z=P("button","primary","插入");z.type="button",z.onclick=()=>{if(!/^https?:\/\//i.test(I.value.trim())||!I.checkValidity()){D.textContent="请输入有效的 http 或 https 图片地址";return}const U=P("img");U.src=I.value.trim(),U.alt=L.value,U.referrerPolicy="no-referrer",M(U)},o.append(I,L,D,z),I.focus()})),T("提及人员","@",()=>W("提及人员",()=>{var L;const I=mn(!1,{...s,value:"",field:{...s.field,label:"人员"}},"person");f=I,o.append(I.element),I.element.addEventListener("change",D=>{var K,Z;D.stopPropagation();const z=String(I.read());if(!z)return;const U=P("span","","@"+(((K=Be(s.field).find(ie=>ie.id===z))==null?void 0:K.label)||((Z=I.element.querySelector("option:checked"))==null?void 0:Z.textContent)||z));U.dataset.personId=z,U.contentEditable="false",M(U)}),(L=I.focus)==null||L.call(I)})),T("代码块","{ }",()=>R("formatBlock","pre")),T("表情","☺",()=>W("表情",()=>{o.classList.add("fc-rich-emojis");for(const I of["😀","😊","😂","👍","👏","🎉","❤️","🔥","✅","💡","🚀","👀","🤔","🙏","💪","⭐"])E(I,()=>M(document.createTextNode(I)))}));const $=T("全屏编辑","expand",()=>{h(),l=!l,e.classList.toggle("is-fullscreen",l),v(),$.ariaLabel=$.title=l?"收起全屏":"全屏编辑",$.innerHTML=`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7">${ri[l?"collapse":"expand"]}</svg>`,g()},!1);$.disabled=!1,$.classList.add("fc-rich-expand"),t.append($);const q=()=>{for(const I of i.children)I.inert=I.offsetTop>=i.clientHeight},F=typeof ResizeObserver>"u"?void 0:new ResizeObserver(q);F==null||F.observe(i);const G=I=>{const L=I.target;n.contains(L)||L.closest("input,textarea,select,[contenteditable=true]")||(I.preventDefault(),!e.contains(document.activeElement)&&!o.contains(document.activeElement)&&g())};return e.addEventListener("mousedown",G),o.addEventListener("mousedown",G),n.addEventListener("input",S),n.addEventListener("mouseup",()=>{if(h(),C(),p&&a&&!a.collapsed){const I=a,L=P(p.tag);L.style.cssText=p.css,L.append(I.extractContents()),I.insertNode(L),p=null,m.get("格式刷").classList.remove("active"),b()}}),n.addEventListener("keyup",()=>{h(),C()}),n.addEventListener("click",I=>{const L=I.target;if(L.tagName==="A"&&I.preventDefault(),L instanceof HTMLInputElement&&L.type==="checkbox"){if(s.readonly){I.preventDefault();return}L.toggleAttribute("checked",L.checked),b()}v()}),n.addEventListener("drop",I=>I.preventDefault()),n.addEventListener("paste",I=>{var D,z;if(s.readonly){I.preventDefault();return}I.preventDefault(),h();const L=(D=I.clipboardData)==null?void 0:D.getData("text/html");if(L){const U=document.createElement("template");U.innerHTML=yt(L);const K=U.content,Z=document.createTextNode("");K.append(Z),g();const ie=window.getSelection().getRangeAt(0);ie.deleteContents(),ie.insertNode(K),ie.setStartAfter(Z),ie.collapse(!0),a=ie.cloneRange(),b()}else M(document.createTextNode(((z=I.clipboardData)==null?void 0:z.getData("text/plain"))||""))}),e.addEventListener("keydown",I=>{I.key==="Escape"&&!o.hidden?(I.preventDefault(),I.stopPropagation(),v(),g()):I.key==="Escape"&&l?(I.preventDefault(),I.stopPropagation(),$.click()):!s.readonly&&(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="z"?(I.preventDefault(),y(I.shiftKey?1:-1)):(I.metaKey||I.ctrlKey)&&I.key.toLowerCase()==="k"&&(I.preventDefault(),h(),k())}),e.append(t,n),C(),{element:e,content:o,inputRoot:e,read:()=>yt(n.innerHTML),validate:()=>{var I;return s.field.required&&!((I=n.textContent)!=null&&I.trim())&&!n.querySelector("img")?"请填写内容":void 0},focus:()=>n.focus(),deactivate:()=>{v(),l=!1,e.classList.remove("is-fullscreen"),$.ariaLabel=$.title="全屏编辑"},destroy:()=>{F==null||F.disconnect(),v()}}}const wn=s=>s==null?"":String(s);function Ra(s){var t;const e=P("div",`fc-value fc-${s.className||""}`);if(s.field.kind==="richText"||s.field.kind==="richtext"||s.field.kind==="longText"||s.field.control==="richText")e.innerHTML=yt(s.value);else if(s.field.kind==="number"&&typeof s.value=="number"){const i=s.field.numberOptions;e.textContent=s.value.toLocaleString("zh-CN",{useGrouping:(i==null?void 0:i.thousandsSeparator)??!1,maximumFractionDigits:(i==null?void 0:i.decimals)??10})+((i==null?void 0:i.suffix)||""),e.classList.add("fc-plain")}else e.textContent=wn(s.value),e.classList.add("fc-plain");return(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function Cn(s,e){const i=s==="text"&&e.layout!=="compact"?P("textarea","fc-input fc-textarea"):P("input","fc-input");if(i instanceof HTMLInputElement&&(i.type=s),i.value=wn(e.value),i.disabled=e.readonly,i.required=!!e.field.required,i.ariaLabel=e.field.label,i.placeholder=e.field.placeholder||(e.layout!=="compact"?"待填":`请输入${e.field.label}`),e.field.maxLength!==void 0&&(i.maxLength=e.field.maxLength),s==="number"&&i instanceof HTMLInputElement){const n=e.field.numberOptions;i.step=String((n==null?void 0:n.step)??"any"),(n==null?void 0:n.min)!==void 0&&(i.min=String(n.min)),(n==null?void 0:n.max)!==void 0&&(i.max=String(n.max))}return i instanceof HTMLTextAreaElement&&pn(i),s==="text"&&e.layout!=="compact"&&i.addEventListener("keydown",n=>{n.key==="Enter"&&(n.preventDefault(),i.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))}),{element:i,read:()=>s==="number"?i.value===""?null:Number(i.value):i.value,validate:()=>e.field.required&&!i.value.trim()?"此项必填":i.checkValidity()?void 0:i.validationMessage||"请填写有效值",focus:()=>i.focus()}}const yn=s=>!Array.isArray(s)||!s.length?[]:Array.isArray(s[0])?s.map(e=>e.map(String)):[s.map(String)];function bt(s,e){const t=[];for(const i of e){const n=s.find(o=>o.id===i);t.push((n==null?void 0:n.label)||i),s=(n==null?void 0:n.children)||[]}return t.join(" / ")}function Ma(s){const e=P("div","fc-tags");for(const t of yn(s.value)){const i=P("span","fc-tag");i.append(P("span","fc-tag-label",bt(Be(s.field),t))),e.append(i)}return e.children.length||e.append(P("span","fc-empty","待填")),e}function ka(s,e){const t=P("div","fc-cascade"),i=P("div","fc-choice-selection"),n=P("input","fc-choice-search");n.placeholder="",n.autocomplete="off",n.ariaLabel="输入以搜索"+e.field.label,n.disabled=e.readonly;const o=()=>{n.size=Math.max(1,[...n.value].length+1)};o();const a=P("div","fc-cascade-columns"),l=P("div","fc-error");l.setAttribute("role","status");const r=Be(e.field);let d=yn(e.value),c=[];const p=[],f=(y,R,M=!1)=>y.forEach(T=>{var W;(W=T.children)!=null&&W.length?f(T.children,[...R,T.id],M||!!T.disabled):p.push({path:[...R,T.id],disabled:M||!!T.disabled})});f(r,[]);const u=(y,R)=>JSON.stringify(y)===JSON.stringify(R),h=e.layout!=="compact"&&!e.readonly;let g;const v=()=>{const y=g;g=void 0,y==null||y.close()},m=()=>{!h||g||e.readonly||(g=$t({anchor:n.parentElement||t,content:a,width:"anchor",gap:4,onDismiss:()=>{g=void 0}}))},C=()=>{!h||!g||(v(),t.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},S=y=>{if(e.readonly)return;const R=d.findIndex(M=>u(M,y));if(s&&R>=0)d.splice(R,1);else{if(s&&e.field.maxSelections&&d.length>=e.field.maxSelections){l.textContent="最多可选择 "+e.field.maxSelections+" 项";return}d=s?[...d,y]:[y]}l.textContent="",b(),t.dispatchEvent(new Event("change",{bubbles:!0})),s||C()},b=()=>{var T,W;if(i.replaceChildren(),a.replaceChildren(),d.forEach(E=>{const x=P("span","fc-tag");x.append(P("span","fc-tag-label",bt(r,E)));const k=P("span","fc-tag-slot"),$=P("button","fc-choice-remove","×");$.type="button",$.disabled=e.readonly,$.ariaLabel="移除"+bt(r,E),$.onclick=()=>{d=d.filter(q=>!u(E,q)),b(),t.dispatchEvent(new Event("change",{bubbles:!0}))},k.append($),x.append(k),i.append(x)}),n.value.trim()){const E=p.filter(x=>!x.disabled&&bt(r,x.path).toLocaleLowerCase().includes(n.value.trim().toLocaleLowerCase()));for(const{path:x}of E){const k=P("button","fc-option",bt(r,x));k.type="button",k.disabled=e.readonly,k.setAttribute("aria-pressed",String(d.some($=>u($,x)))),k.onclick=()=>S(x),a.append(k)}a.classList.add("is-search"),E.length||a.append(P("p","fc-empty","暂无匹配路径"));return}a.classList.remove("is-search");let y=r,R=[],M=0;for(;y.length;){const E=P("div","fc-cascade-column");E.setAttribute("role","group"),E.ariaLabel="第"+(M+1)+"级";for(const k of y.filter($=>!$.disabled)){const $=[...R,k.id],q=!!((T=k.children)!=null&&T.length),F=P("button","fc-option",k.label+(q?" ›":""));F.type="button",F.disabled=e.readonly,F.classList.toggle("selected",q?c[M]===k.id:d.some(G=>u(G,$))),F.setAttribute(q?"aria-expanded":"aria-pressed",String(q?c[M]===k.id:d.some(G=>u(G,$)))),F.onclick=()=>{var G,I;q?(c=$,b(),(I=(G=a.lastElementChild)==null?void 0:G.querySelector("button"))==null||I.focus()):S($)},E.append(F)}a.append(E);const x=y.find(k=>k.id===c[M]&&!k.disabled);if(!((W=x==null?void 0:x.children)!=null&&W.length))break;R=[...R,x.id],y=x.children,M++}r.length||a.append(P("p","fc-empty","暂无可选分类"))};if(n.oninput=()=>{o(),b()},n.onfocus=m,a.onkeydown=y=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(y.key))return;const R=y.target,T=[...(R.closest(".fc-cascade-column")||a).querySelectorAll("button:not(:disabled)")];if(!T.length)return;y.preventDefault();const W=T.indexOf(R);T[y.key==="Home"?0:y.key==="End"?T.length-1:(W+(y.key==="ArrowDown"?1:-1)+T.length)%T.length].focus()},t.append(i,n,l),h){const y=P("span","fc-field-chevron");y.setAttribute("aria-hidden","true"),t.append(y),t.addEventListener("click",()=>m())}else t.append(a);return b(),{element:t,content:h?a:void 0,read:()=>s?d.map(y=>[...y]):[...d[0]||[]],focus:()=>{n.focus(),m()},deactivate:()=>{n.value="",o(),v()},destroy:()=>v(),validate:()=>e.field.required&&!d.length?"请选择分类":void 0}}const Ye=s=>String(s).padStart(2,"0"),li=s=>`${s.getFullYear()}-${Ye(s.getMonth()+1)}-${Ye(s.getDate())}`;function Ht(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())&&li(t)===s}const bn=s=>{var e,t,i;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,seconds:((i=s.field.dateOptions)==null?void 0:i.showSeconds)??s.field.kind==="datetime"}};function Sn(s){const{time:e,range:t,seconds:i}=bn(s),o=(Array.isArray(s.value)?s.value:[s.value]).slice(0,t?2:1).filter(Boolean).map(a=>e?String(a).slice(0,i?19:16).replace("T"," "):String(a).slice(0,10)).join(" 至 ");return P("div",`fc-value fc-${s.className||""}${o?"":" fc-empty"}`,o||"待填")}function Ta(s){const{time:e,range:t,seconds:i}=bn(s),n=P("div","fc-calendar"),o=Array.isArray(s.value)?s.value:[s.value],a=[0,1].map(A=>String(o[A]||"").slice(0,10)),l=[0,1].map(A=>(String(o[A]||"").slice(11,16)||"00:00")+(i?":"+(String(o[A]||"").slice(17,19)||"00"):""));let r=0,d=!1,c=Ht(a[0])?new Date(`${a[0]}T12:00:00`):new Date;c=new Date(c.getFullYear(),c.getMonth(),1);const p=P("div","fc-calendar-panel"),f=P("div","fc-calendar-inputs"),u=[],h=()=>n.dispatchEvent(new Event("change",{bubbles:!0})),g=P("div","fc-error");g.setAttribute("role","status");const v=()=>{if(a.some(A=>A&&!Ht(A)))return"请输入有效日期,格式为 YYYY-MM-DD";if(s.field.required&&!a[0])return"请选择日期";if(t&&!!a[0]!=!!a[1])return"请选择完整的日期范围";if(e&&l.slice(0,t?2:1).some(A=>!(i?/^([01]\d|2[0-3]):[0-5]\d:[0-5]\d$/:/^([01]\d|2[0-3]):[0-5]\d$/).test(A)))return"请输入有效时间";if(t&&a[0]&&`${a[0]}T${e?l[0]:""}`>`${a[1]}T${e?l[1]:""}`)return"结束日期时间不能早于开始日期时间"},m=()=>{g.textContent=v()||"",g.textContent||h()};for(let A=0;A<(t?2:1);A++){const O=P("input","fc-input fc-calendar-date");O.type="text",O.value=a[A],O.placeholder=t?A?"结束日期":"开始日期":"YYYY-MM-DD",O.ariaLabel=t?O.placeholder:s.field.label,O.disabled=s.readonly,O.onfocus=()=>{if(r=A,d=A===1,Ht(a[A])){const V=new Date(`${a[A]}T12:00:00`);c=new Date(V.getFullYear(),V.getMonth(),1)}D()},O.addEventListener("change",V=>{if(V.stopPropagation(),a[A]=O.value.trim(),Ht(a[A])){const _=new Date(`${a[A]}T12:00:00`);c=new Date(_.getFullYear(),_.getMonth(),1)}D(),m()}),f.append(O),u.push(O)}const C=P("div","fc-calendar-header"),S=P("button","fc-calendar-month");S.type="button",S.ariaLabel="选择年份和月份",S.setAttribute("aria-expanded","false"),S.setAttribute("aria-live","polite");const b=(A,O,V)=>{const _=P("button","fc-calendar-nav");return _.type="button",_.ariaLabel=A,_.innerHTML=`<svg viewBox="0 0 24 24" aria-hidden="true"><path d="${V?"M10 6l-6 6 6 6M19 6l-6 6 6 6":"M15 6l-6 6 6 6"}"/></svg>`,O>0&&_.classList.add("next"),_.onclick=()=>{c=new Date(c.getFullYear(),c.getMonth()+O,1),D()},_};C.append(b("上一年",-12,!0),b("上个月",-1,!1),S,b("下个月",1,!1),b("下一年",12,!0));const y=P("div","fc-calendar-weekdays");for(const A of["日","一","二","三","四","五","六"])y.append(P("span","",A));const R=P("div","fc-calendar-days");R.setAttribute("role","group"),R.ariaLabel="选择日期";const M=P("div","fc-calendar-period");M.hidden=!0;const T=P("button","fc-calendar-back","‹ 返回选择日期");T.type="button";const W=P("div","fc-calendar-period-columns"),E=P("div","fc-calendar-period-list");E.setAttribute("role","group"),E.ariaLabel="年份";const x=P("div","fc-calendar-period-list");x.setAttribute("role","group"),x.ariaLabel="月份";const k=P("div","fc-calendar-period-list");k.ariaLabel="秒",k.hidden=!0,W.append(E,x,k),M.append(T,W);let $="period",q=0;const F=[],G=(A=!1)=>{const O=l[q].split(":").map(Number),V=$==="period"?[[E,c.getFullYear(),"年"],[x,c.getMonth()+1,"月"]]:[[E,O[0],"时"],[x,O[1],"分"],[k,O[2],"秒"]];for(const[_,X,N]of V)for(const B of _.querySelectorAll("button")){const Y=Number(B.dataset.value)===X;B.classList.toggle("selected",Y),B.setAttribute("aria-pressed",String(Y)),B.textContent=`${$==="time"?Ye(Number(B.dataset.value)):B.dataset.value}${Y?N:""}`,Y&&A&&(_.scrollTop=Math.max(0,B.offsetTop-108))}},I=(A,O)=>{const V=P("button","fc-calendar-period-option",String(A));return V.type="button",V.dataset.value=String(A),V.ariaLabel=`${$==="time"?Ye(A):A}${$==="time"?O?"时":"分":O?"年":"月"}`,V.disabled=$==="time"&&s.readonly,V.onclick=()=>{if($==="time"){const _=l[q].split(":");_[O?0:1]=Ye(A),l[q]=_.join(":"),F[q].textContent=l[q],G(),m();return}c.setFullYear(O?A:c.getFullYear(),O?c.getMonth():A-1,1),G(),D()},V},L=(A,O=0)=>{if($=A,q=O,E.replaceChildren(),x.replaceChildren(),k.replaceChildren(),k.hidden=A!=="time"||!i,E.ariaLabel=A==="period"?"年份":"小时",x.ariaLabel=A==="period"?"月份":"分钟",A==="period"){for(let V=Math.max(1,c.getFullYear()-100);V<=Math.min(9999,c.getFullYear()+100);V++)E.append(I(V,!0));for(let V=1;V<=12;V++)x.append(I(V,!1))}else{for(let V=0;V<24;V++)E.append(I(V,!0));for(let V=0;V<60;V++)x.append(I(V,!1));if(i)for(let V=0;V<60;V++){const _=P("button","fc-calendar-period-option",Ye(V));_.type="button",_.dataset.value=String(V),_.ariaLabel=Ye(V)+"秒",_.disabled=s.readonly,_.onclick=()=>{const X=l[q].split(":");X[2]=Ye(V),l[q]=X.join(":"),F[q].textContent=l[q],G(),m()},k.append(_)}}n.classList.add("choosing-period"),M.hidden=!1,(A==="period"?S:F[O]).setAttribute("aria-expanded","true"),G(!0),T.focus()};S.onclick=()=>L("period"),T.onclick=()=>{n.classList.remove("choosing-period"),M.hidden=!0;const A=$==="period"?S:F[q];A.setAttribute("aria-expanded","false"),D(),A.focus()},M.addEventListener("keydown",A=>{if(A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),T.click()),!["ArrowUp","ArrowDown","Home","End"].includes(A.key))return;const O=A.target,V=O.closest(".fc-calendar-period-list");if(!V)return;const _=[...V.querySelectorAll("button")],X=_.indexOf(O),N=A.key==="Home"?0:A.key==="End"?_.length-1:Math.max(0,Math.min(_.length-1,X+(A.key==="ArrowDown"?1:-1)));A.preventDefault(),_[N].focus()});function D(){S.textContent=`${c.getFullYear()}年 ${c.getMonth()+1}月`,u.forEach((O,V)=>O.classList.toggle("active",V===r)),R.replaceChildren();for(let O=0;O<c.getDay();O++)R.append(P("span","fc-calendar-blank"));const A=new Date(c.getFullYear(),c.getMonth()+1,0).getDate();for(let O=1;O<=A;O++){const V=li(new Date(c.getFullYear(),c.getMonth(),O)),_=P("button","fc-calendar-day",String(O));_.type="button",_.ariaLabel=V,_.disabled=s.readonly;const X=a[0]===V||t&&a[1]===V;_.classList.toggle("selected",X),_.setAttribute("aria-pressed",String(X)),_.classList.toggle("in-range",t&&!!a[0]&&!!a[1]&&V>a[0]&&V<a[1]),V===li(new Date)&&(_.classList.add("today"),_.setAttribute("aria-current","date")),_.onclick=()=>{var N;t?d?(a[1]=V,a[0]&&a[1]<a[0]&&([a[0],a[1]]=[a[1],a[0]]),r=0,d=!1):(a[0]=V,a[1]="",r=1,d=!0):a[0]=V,u.forEach((B,Y)=>B.value=a[Y]),D(),!t||a[1]?m():g.textContent="",(N=R.querySelector(`[aria-label="${V}"]`))==null||N.focus(),(!t||a[1])&&n.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))},R.append(_)}}p.append(C,y,R,M);const z=P("div","fc-calendar-time");if(e){for(let A=0;A<(t?2:1);A++){const O=P("div","fc-calendar-time-field"),V=t?A?"结束时间":"开始时间":"时间",_=P("button","fc-input fc-calendar-time-trigger",l[A]);_.type="button",_.disabled=s.readonly,_.ariaLabel=V,_.setAttribute("aria-expanded","false"),_.onclick=()=>L("time",A),F.push(_),O.append(P("span","",V),_),z.append(O)}p.append(z)}const U=P("button","fc-calendar-clear","清空");U.type="button",U.disabled=s.readonly,U.onclick=()=>{a.fill(""),u.forEach(A=>A.value=""),r=0,d=!1,D(),m()},n.append(f,p,U,g);const K=()=>{const A=a.slice(0,t?2:1).map((O,V)=>O?O+(e?`T${l[V]}`:""):"");return t?A.some(Boolean)?A:[]:A[0]};if(s.layout==="compact"||s.readonly)return D(),{element:n,read:K,validate:v,focus:()=>{u[0].focus()},deactivate:()=>{n.classList.remove("choosing-period"),M.hidden=!0}};const Z=P("div","fc-date-mirror"),ie=()=>Z.replaceChildren(Sn({...s,value:K()})),pe=P("span","fc-field-chevron");pe.setAttribute("aria-hidden","true");const J=P("div","fc-date-trigger");J.tabIndex=0,J.setAttribute("role","button"),J.ariaLabel=`编辑${s.field.label}`,J.append(Z,pe);let ce;const fe=()=>{const A=ce;ce=void 0;const O=!!A&&A.element.contains(document.activeElement);A==null||A.close(),pe.classList.remove("is-open"),O&&queueMicrotask(()=>{ce||!J.isConnected||J.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))})},ne=()=>{ce||s.readonly||(ie(),ce=$t({anchor:J,content:n,width:320,gap:4,onDismiss:()=>{ce=void 0,pe.classList.remove("is-open")}}),pe.classList.add("is-open"))};return J.onclick=()=>ne(),J.onkeydown=A=>{(A.key==="Enter"||A.key===" ")&&(A.preventDefault(),ne())},n.addEventListener("focusout",A=>{const O=A.relatedTarget;if(O&&(n.contains(O)||J.contains(O)||Ke(O)))return;const V=new Event("focusout",{bubbles:!0});O&&Object.defineProperty(V,"relatedTarget",{value:O}),J.dispatchEvent(V)}),n.addEventListener("change",()=>J.dispatchEvent(new Event("change",{bubbles:!0}))),D(),ie(),{element:J,content:n,inputRoot:J,read:K,validate:v,focus:()=>{ne(),u[0].focus()},deactivate:fe,destroy:fe}}const Je=s=>s==null?"":String(s),lt=s=>s.dispatchEvent(new Event("change",{bubbles:!0}));function di(s){try{const e=new URL(Je(s));return["http:","https:"].includes(e.protocol)?e.href:void 0}catch{return}}function St(s){return P("div","fc-value fc-plain fc-"+(s.className||"")+(s.value==null||s.value===""?" fc-empty":""),Je(s.value)||"待填")}function Ot(s,e){const t=e==="textarea"?P("textarea","fc-input fc-textarea"):P("input","fc-input");return t instanceof HTMLInputElement&&(t.type=e),t instanceof HTMLTextAreaElement&&pn(t),t.value=Je(s.value),t.disabled=s.readonly,t.required=!!s.field.required,t.ariaLabel=s.field.label,t.placeholder=s.field.placeholder||"请输入"+s.field.label,s.field.maxLength!==void 0&&(t.maxLength=s.field.maxLength),{element:t,read:()=>t.value,focus:()=>t.focus(),validate:()=>e==="url"&&t.value&&!di(t.value)?"请输入 http 或 https 链接":t.checkValidity()?void 0:"请填写有效的"+s.field.label}}function La(s){const e=P("div","fc-link-value"),t=di(s.value);if(!t)return St(s);const i=P("a","fc-link",Je(s.value));return i.href=t,i.target="_blank",i.rel="noopener noreferrer",i.onclick=n=>n.stopPropagation(),e.append(P("span","fc-link-icon","↗"),i),e}function En(s){let e=s.value===!0;const t=P("div","fc-switch-field"),i=P("button","fc-switch");i.type="button",i.setAttribute("role","switch"),i.ariaLabel=s.field.label,i.disabled=s.readonly;const n=P("span"),o=()=>{i.setAttribute("aria-checked",String(e)),n.textContent=e?"是":"否"};return i.onclick=()=>{s.readonly||(e=!e,o(),lt(t))},t.append(i,n),o(),{element:t,read:()=>e,focus:()=>i.focus()}}function Na(s){return En({...s,readonly:!0}).element}function Ia(s){const e=P("div","fc-signals"),t=Array.isArray(s.value)?s.value:[s.value];for(const i of t.filter(n=>n!=null&&n!=="")){const n=typeof i=="object"?i:{status:i},o=n.status??n.value,a=o===!0||o==="passed"||o==="success",l=P("span","fc-signal "+(a?"is-success":"is-pending"),(a?"● ":"○ ")+Je(n.label||n.name||(a?"已满足":o===!1?"未满足":o||"等待信号")));e.append(l)}return e.children.length||e.append(P("span","fc-empty","等待外部信号")),e}function Aa(s){const e=s.value&&typeof s.value=="object"?s.value.display??s.value.value:s.value;return St({...s,value:e!=null&&typeof e!="object"?e:""})}function Da(s,e){const t=P("div","fc-readonly");return t.append(e(s),P("small","fc-service-note","由系统更新 · 只读")),{element:t,read:()=>s.value}}function xn(s){var h,g,v;let e=Array.isArray(s.value)?structuredClone(s.value):[];const t=P("div","fc-attachments"),i=P("div","fc-file-list"),n=P("label","fc-upload-zone","+ 上传附件"),o=P("input");o.type="file",o.multiple=!0,o.ariaLabel="上传"+s.field.label,o.accept=((h=s.field.attachmentOptions)==null?void 0:h.accept)||"",o.disabled=s.readonly||!((g=s.services)!=null&&g.upload);const a=P("p","fc-error");a.setAttribute("role","status");const l=P("button","fc-retry","重试上传");l.type="button",l.hidden=!0;let r=[],d=!1,c=!1,p;const f=()=>{i.replaceChildren(),e.forEach((m,C)=>{const S=P("div","fc-file-row"),b=di(m.url),y=b?P("a","fc-link",m.name):P("span","",m.name);if(y.tagName==="A"){const R=y;R.href=b,R.target="_blank",R.rel="noopener noreferrer"}if(S.append(P("span","fc-file-icon","▤"),y),m.size!=null&&S.append(P("small","fc-file-size",Math.ceil(m.size/1024)+" KB")),!s.readonly){const R=P("button","fc-file-remove","×");R.type="button",R.disabled=d,R.ariaLabel="移除"+m.name,R.onclick=()=>{e.splice(C,1),f(),lt(t)},S.append(R)}i.append(S)}),e.length||i.append(P("span","fc-empty","暂无附件"))},u=async()=>{var S;if(!((S=s.services)!=null&&S.upload)||s.readonly||d||!r.length)return;const m=s.field.attachmentOptions;if(m!=null&&m.maxFiles&&e.length+r.length>m.maxFiles){a.textContent="最多上传 "+m.maxFiles+" 个文件";return}if(m!=null&&m.maxBytes&&r.some(b=>b.size>m.maxBytes)){a.textContent="文件大小超过限制";return}const C=((m==null?void 0:m.accept)||"").split(",").map(b=>b.trim().toLowerCase()).filter(Boolean);if(C.length&&r.some(b=>!C.some(y=>y.startsWith(".")?b.name.toLowerCase().endsWith(y):y.endsWith("/*")?b.type.toLowerCase().startsWith(y.slice(0,-1)):b.type.toLowerCase()===y))){a.textContent="文件类型不符合要求";return}p=new AbortController,d=!0,o.disabled=!0,l.hidden=!0,a.textContent="上传中…",t.setAttribute("aria-busy","true"),f();try{const b=await s.services.upload(s.field,r,p.signal);if(c)return;if(b.length!==r.length||b.some(y=>!y.id||!y.name))throw new Error("Invalid file references");e=[...e,...b],r=[],a.textContent="",o.value=""}catch{c||(a.textContent="上传失败,已保留原有附件",l.hidden=!1)}finally{c||(d=!1,o.disabled=!1,t.setAttribute("aria-busy","false"),f(),r.length||lt(t))}};return o.onchange=m=>{m.stopPropagation(),r=Array.from(o.files||[]),u()},l.onclick=()=>void u(),n.append(o),t.append(i),s.readonly||(t.append(n),(v=s.services)!=null&&v.upload||t.append(P("p","fc-service-note","上传服务未接入"))),t.append(a,l),f(),{element:t,read:()=>structuredClone(e),focus:()=>o.focus(),validate:()=>d?"请等待上传完成":r.length?"请完成或重新选择上传文件":s.field.required&&!e.length?"请上传附件":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function Rn(s){if(s&&typeof s=="object"&&!Array.isArray(s)){const e=s;return{selected:Array.isArray(e.selected)?[...e.selected]:[],counts:{...e.counts},total:e.total}}return{selected:[],counts:{}}}function Mn(s,e){var u;let t=Rn(s.value),i=[...t.selected];const n=e==="attitude"?[{id:"like",label:"赞同"}]:Be(s.field),o=P("div","fc-vote"),a=P("div","fc-vote-list"),l=P("p","fc-error");l.setAttribute("role","status");const r=P("button","fc-vote-submit","提交投票");r.type="button";let d=!1,c=!1,p;const f=()=>{var g,v;a.replaceChildren();const h=Math.max(1,...Object.values(t.counts));for(const m of n){const C=P("button","fc-vote-option");C.type="button",C.disabled=s.readonly||d||!((g=s.services)!=null&&g.vote)||!!m.disabled,C.classList.toggle("selected",i.includes(m.id)),C.setAttribute("aria-pressed",String(i.includes(m.id)));const S=P("span","fc-vote-bar");S.style.width=(t.counts[m.id]||0)/h*100+"%",C.append(S,P("span","",(e==="attitude"?"♡ ":"")+m.label),P("strong","",String(t.counts[m.id]||0))),C.onclick=()=>{i=i.includes(m.id)?i.filter(b=>b!==m.id):e==="multi"?[...i,m.id]:[m.id],f()},a.append(C)}n.length||a.append(P("p","fc-empty","暂无投票选项")),r.disabled=d||!((v=s.services)!=null&&v.vote)||!n.length,r.textContent=d?"提交中…":"提交投票"};return r.onclick=async()=>{var h;if(!(d||s.readonly||!((h=s.services)!=null&&h.vote))){d=!0,l.textContent="",p=new AbortController,o.setAttribute("aria-busy","true"),f();try{const g=await s.services.vote(s.field,i,p.signal);if(c)return;t=Rn(g),i=[...t.selected]}catch{c||(l.textContent="投票失败,请重试")}finally{c||(d=!1,o.setAttribute("aria-busy","false"),f(),l.textContent||lt(o))}}},o.append(a),s.readonly||(o.append(r),(u=s.services)!=null&&u.vote||o.append(P("p","fc-service-note","投票服务未接入"))),o.append(l),f(),{element:o,read:()=>structuredClone(t),validate:()=>d?"请等待投票完成":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function Fa(s){const e=s.value&&typeof s.value=="object"?s.value:{},t=P("div","fc-location"),n=[["address","地址","text"],["longitude","经度","number"],["latitude","纬度","number"]].map(([a,l,r])=>{const d=P("label","fc-location-part",l),c=P("input","fc-input");return c.type=r,c.value=Je(e[a]),c.disabled=s.readonly,c.ariaLabel=l,c.placeholder=l,r==="number"&&(c.step="any",c.min=a==="longitude"?"-180":"-90",c.max=a==="longitude"?"180":"90"),d.append(c),t.append(d),c}),o=()=>n.every(a=>!a.value)?null:{address:n[0].value,longitude:n[1].value?Number(n[1].value):null,latitude:n[2].value?Number(n[2].value):null};return{element:t,read:o,focus:()=>n[0].focus(),validate:()=>{if(!o())return s.field.required?"请填写位置":void 0;if(n.slice(1).some(a=>a.value===""||!a.checkValidity()))return"请填写有效的经纬度"}}}function Pa(s){const e=s.value;return St({...s,value:e&&typeof e=="object"?Je(e.address)||[e.longitude,e.latitude].filter(t=>t!=null).join(", "):""})}function $a(s,e){const t=P("div","fc-composite"),i=P("div","fc-composite-rows"),n=P("button","fc-composite-add","+ 添加一组");n.type="button";const o=s.field.compositeFields||[],a=[];let l=!1;const r=u=>({...u.value,...Object.fromEntries(u.editors.map(({field:h,editor:g})=>[h.key,g.read()]))}),d=u=>{u.editors.forEach(({editor:h})=>{var g;return(g=h.destroy)==null?void 0:g.call(h)}),u.remove&&(u.remove.onclick=null),u.element.remove()},c=P("p","fc-empty","暂无记录"),p=()=>{a.forEach((u,h)=>{u.legend.textContent="第 "+(h+1)+" 组"}),n.disabled=s.readonly||!o.length||a.length>=(s.field.maxRows||100),a.length?c.remove():i.append(c)},f=u=>{const h=P("fieldset","fc-composite-row"),g=P("legend");h.append(g);const v=o.map(C=>{const S=e(C),b=S.createEditor({...s,field:C,value:u[C.key],readonly:s.readonly||C.editable===!1||!!S.readonly,focusBoundary:void 0,onSelectedOptions:R=>{var M;(M=s.services)!=null&&M.searchOptions&&(C.choices=[...new Map([...Be(C),...R].map(T=>[T.id,T])).values()])}}),y=P("div","fc-composite-field");return y.append(P("label","",C.label+(C.required?" *":"")),b.element),h.append(y),{field:C,editor:b}}),m={value:u,element:h,legend:g,editors:v};if(!s.readonly){const C=P("button","fc-composite-remove","删除此组");C.type="button",C.onclick=()=>{if(l)return;const S=a.indexOf(m);S<0||(d(m),a.splice(S,1),p(),lt(t))},m.remove=C,h.append(C)}a.push(m),i.append(h),p()};for(const u of Array.isArray(s.value)?s.value:[])f(structuredClone(u));return n.onclick=()=>{l||n.disabled||(f({}),lt(t))},t.append(i),s.readonly||t.append(n),o.length||t.append(P("p","fc-service-note","请配置复合子字段")),p(),{element:t,read:()=>a.map(r),validate:()=>{var u;if(s.field.required&&!a.length)return"请至少添加一组";for(const[h,g]of a.entries())for(const{field:v,editor:m}of g.editors){const C=(u=m.validate)==null?void 0:u.call(m);if(C)return"第 "+(h+1)+" 组 · "+v.label+":"+C}},destroy:()=>{l||(l=!0,n.onclick=null,a.forEach(d))}}}class _e extends Le{renderDisplay(e){return{element:Ra(e)}}renderEditing(e){return Cn("text",e)}}class kn extends _e{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,kind:"number"}})}renderEditing(e){return Cn("number",e)}}class Tn extends _e{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,control:"richText"}})}renderEditing(e){return xa(e)}}class Ln extends _e{renderDisplay(e){return{element:St(e)}}renderEditing(e){return Ot(e,"textarea")}}class ci extends _e{renderDisplay(e){return{element:La(e)}}renderEditing(e){return Ot(e,"url")}}class Nn extends _e{renderEditing(e){return Ot(e,"email")}}class In extends _e{renderEditing(e){return Ot(e,"tel")}}class dt extends Le{constructor(){super(...arguments);w(this,"multiple",!1);w(this,"variant","choice")}renderDisplay(t){return{element:Sa(t,this.variant==="radio"?"choice":this.variant)}}renderEditing(t){return mn(this.multiple,t,this.variant)}}class An extends dt{constructor(){super(...arguments);w(this,"multiple",!0)}}class Dn extends dt{constructor(){super(...arguments);w(this,"variant","radio")}}class ui extends dt{constructor(){super(...arguments);w(this,"variant","person")}}class Fn extends ui{constructor(){super(...arguments);w(this,"multiple",!0)}}class hi extends dt{constructor(){super(...arguments);w(this,"variant","relation")}}class Pn extends hi{constructor(){super(...arguments);w(this,"multiple",!0)}}class pi extends Le{constructor(){super(...arguments);w(this,"multiple",!1)}renderDisplay(t){return{element:Ma(t)}}renderEditing(t){return ka(this.multiple,t)}}class $n extends pi{constructor(){super(...arguments);w(this,"multiple",!0)}}class fi extends Le{normalize(e){return e}renderDisplay(e){return{element:Sn(this.normalize(e))}}renderEditing(e){return Ta(this.normalize(e))}}class gi extends fi{constructor(){super(...arguments);w(this,"range",!1)}normalize(t){return{...t,field:{...t.field,dateOptions:{showTime:!1,showRange:this.range,...t.field.dateOptions}}}}}class Hn extends gi{constructor(){super(...arguments);w(this,"range",!0)}}class On extends Le{renderDisplay(e){return{element:Na(e)}}renderEditing(e){return En(e)}}class Bn extends Le{renderDisplay(e){return xn({...e,readonly:!0})}renderEditing(e){return xn(e)}}class Vn extends Le{renderDisplay(e){return{element:Pa(e)}}renderEditing(e){return Fa(e)}}class Bt extends Le{constructor(){super(...arguments);w(this,"mode","attitude")}renderDisplay(t){return Mn({...t,readonly:!0},this.mode)}renderEditing(t){return Mn(t,this.mode)}}class Gn extends Bt{constructor(){super(...arguments);w(this,"mode","single")}}class zn extends Bt{constructor(){super(...arguments);w(this,"mode","multi")}}class ct extends Le{isReadonly(){return!0}constructor(e){super({...e,readonly:!0})}renderDisplay(e){return{element:Aa(e)}}renderEditing(e){return Da(e,t=>this.renderDisplay(t).element)}}class mi extends ct{renderDisplay(e){return{element:Ia(e)}}}class _n extends _e{renderDisplay(e){const t=document.createElement("button");return t.type="button",t.className="fc-detail-link",t.textContent=e.field.label,t.onclick=i=>{var n;i.stopPropagation(),(n=e.onAction)==null||n.call(e,{type:"open",value:e.value})},{element:t,destroy:()=>{t.onclick=null}}}}class Wn extends Le{constructor(e,t){super(e),this.resolve=t}renderDisplay(e){var n;if(e.layout==="compact")return{element:St({...e,value:Array.isArray(e.value)&&e.value.length?e.value.length+" 组记录":""})};const t=document.createElement("div");t.className="fc-composite";const i=[];for(const o of Array.isArray(e.value)?e.value:[]){const a=document.createElement("fieldset");a.className="fc-composite-row";for(const l of e.field.compositeFields??[]){const r=document.createElement("label");r.textContent=l.label;const d={...e,field:l,value:o[l.key],readonly:!0},c=this.resolve(l),p=((n=c.renderView)==null?void 0:n.call(c,d))??{element:c.render(d)};i.push(p),a.append(r,p.element)}t.append(a)}return{element:t,destroy:()=>i.forEach(o=>{var a;return(a=o.destroy)==null?void 0:a.call(o)})}}renderEditing(e){return $a(e,this.resolve)}}const Ha={textarea:"保留换行的纯文本,支持长度限制",radio:"平铺选项,一次选择一项",cascadeSingle:"逐级浏览分类,选择完整路径",cascadeMulti:"逐级浏览并选择多条路径",person:"按姓名搜索,以稳定人员 ID 保存",multiPerson:"按姓名搜索,以稳定人员 ID 保存",date:"日历选择和直接输入,支持清空",dateRange:"连续选择起止日期,校验完整范围",url:"填写网址并在新窗口安全打开",cloudDocument:"添加云文档链接,点击打开原文档",email:"邮箱输入与格式校验",phone:"支持国家区号的电话输入",switch:"以是或否记录布尔状态",attachment:"文件列表、上传与删除,支持上传失败重试",location:"填写地址和经纬度,校验坐标边界",relation:"按名称或编号搜索工作项,点击名称打开详情",multiRelation:"按名称或编号搜索工作项,点击名称打开详情",attitudeVote:"选择并提交投票,结果以宿主服务回读为准",singleVote:"选择并提交投票,结果以宿主服务回读为准",multiVote:"选择并提交投票,结果以宿主服务回读为准",externalSignal:"由外部系统更新,系统内只读",externalMultiSignal:"由外部系统更新,系统内只读",formula:"展示服务端计算结果,不可手工覆盖",aggregate:"展示服务端计算结果,不可手工覆盖",ai:"展示服务端计算结果,不可手工覆盖",system:"展示服务端计算结果,不可手工覆盖",composite:"可重复字段组,复用已注册子控件并逐组校验",multiPersonComposite:"可重复字段组,复用已注册子控件并逐组校验",text:"单行输入,支持清空和必填校验",richText:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",select:"从字段配置中选择一个选项",multiSelect:"点击标签选择多项,保存为数组",number:"支持小数和负数,空值与零分别保存",dateTime:"日历、时间与日期范围",detail:"由调用方处理关联内容导航"},Oa={title:"text",longText:"richText",status:"select",richtext:"richText",single_select:"select",multi_select:"multiSelect",user:"person",multi_user:"multiPerson",multi_person:"multiPerson",cascade_select:"cascadeSingle",cascade_single:"cascadeSingle",cascade_multi:"cascadeMulti",daterange:"dateRange",date_range:"dateRange",datetime:"dateTime",multi_relation:"multiRelation",attitude_vote:"attitudeVote",single_vote:"singleVote",multi_vote:"multiVote",vote:"attitudeVote",external_signal:"externalSignal",external_multi_signal:"externalMultiSignal",multi_person_composite:"multiPersonComposite",cloud_document:"cloudDocument"},Ba=[["text","单行文本",_e,"文本","T"],["richText","富文本",Tn,"文本","¶"],["select","单选",dt,"选择","◉"],["multiSelect","多选",An,"选择","☑"],["number","数字",kn,"其他","#"],["dateTime","日期时间",fi,"日期","◷"],["detail","详情页查看",_n,"关联工作项","↗"],["textarea","多行文本",Ln,"文本","≡"],["radio","单选按钮",Dn,"选择","◉"],["cascadeSingle","级联单选",pi,"选择","⑂"],["cascadeMulti","级联多选",$n,"选择","⑂"],["person","单选人员",ui,"人员","♙"],["multiPerson","多选人员",Fn,"人员","♙"],["date","日期",gi,"日期","▦"],["dateRange","日期区间",Hn,"日期","▦"],["url","URL 链接",ci,"其他","↗"],["cloudDocument","关联云文档",ci,"其他","▤"],["email","邮箱",Nn,"其他","@"],["phone","电话",In,"其他","☎"],["switch","开关",On,"其他","◐"],["attachment","附件",Bn,"其他","⌑"],["location","地理位置",Vn,"其他","⌖"],["relation","单选关联工作项",hi,"关联工作项","↗"],["multiRelation","多选关联工作项",Pn,"关联工作项","↗"],["attitudeVote","表态投票",Bt,"投票","♡"],["singleVote","单选投票",Gn,"投票","♡"],["multiVote","多选投票",zn,"投票","♡"],["externalSignal","系统外信号",mi,"系统","◌",!0],["externalMultiSignal","多值系统外信号",mi,"系统","◌",!0],["formula","公式计算",ct,"系统","ƒ",!0],["aggregate","聚合计算",ct,"系统","ƒ",!0],["ai","AI 字段",ct,"系统","ƒ",!0],["system","系统字段",ct,"系统","ƒ",!0]];function qn(s=[]){const e=new Map,t=a=>{if(!/^[A-Za-z][\w-]*$/.test(a.id))throw new Error("Invalid control id");if(e.has(a.id))throw new Error(`Control already registered: ${a.id}`);e.set(a.id,a)},i=a=>{const l=a.control||Oa[a.kind||"text"]||a.kind||"text",r=e.get(l);if(!r)throw new Error(`Unknown control: ${l}`);return r},n=a=>i(a.field).create(a),o=a=>{const l=i(a);return{...l,render:r=>l.create(r).render().element,renderView:r=>l.create(r).render(),createEditor:r=>l.create(r).createEditor()}};for(const[a,l,r,d,c,p]of Ba)t({id:a,label:l,description:Ha[a]||l,glyph:c,group:d,readonly:p,action:a==="detail"?"view":a==="select"||a==="multiSelect"?"select":void 0,create:f=>new r({...f,readonly:p||f.readonly})});for(const[a,l]of[["composite","复合字段"],["multiPersonComposite","多人复合字段"]])t({id:a,label:l,description:"组合多个已注册字段",glyph:"▦",group:"其他",create:r=>new Wn(r,o)});return s.forEach(t),{register:t,resolve:i,create:n,list:()=>[...e.values()]}}class vi extends Le{constructor(e,t){super(e),this.control=t}renderDisplay(e){return{element:this.control.render(e)}}renderEditing(e){return this.control.createEditor(e)}}const Xe={page(s){return s.page||(s.surface==="cell"?"table":"basic")},render(s,e){const t=P("div","fc-base-control"),i=Xe.page(s);return t.dataset.page=i,t.dataset.mode=s.mode||"default",t.dataset.editable=String(s.canEdit??!s.readonly),t.dataset.readonly=String(s.readonly),t.setAttribute("data-field-control",s.field.control||s.field.kind||"text"),t.append(e),t}},Va=new Set(["select","multiSelect","person","multiPerson","relation","multiRelation","cascadeSingle","cascadeMulti","date","dateRange","dateTime","detail","composite","multiPersonComposite"]);function Et(s){return s.id==="richText"?"rich":Va.has(s.id)?"select":"text"}function Un(s,e,t){if(Xe.page(e)==="table"||e.readonly||s.readonly||e.canEdit===!1)return t;const i=document.createElement("div");i.className="fc-base-control fc-focus-editor",i.dataset.expanded="true",i.tabIndex=-1;const n=Xe.page(e);i.dataset.page=n,i.dataset.mode=n==="table"?"editing":"expanded",i.dataset.controlKey=s.id,i.dataset.box=Et(s);const o=document.createElement("div");o.className="fc-focus-body",o.dataset.box=Et(s),o.append(t.element);const a=document.createElement("div");a.className="fc-focus-trigger",a.tabIndex=0,a.setAttribute("role","button"),a.ariaLabel="编辑"+e.field.label,a.setAttribute("aria-expanded","true"),a.hidden=!0;const l=document.createElement("span");l.className="fc-error fc-focus-error",l.setAttribute("role","status"),i.append(o,a,l);const r=i.ownerDocument,d=e.focusBoundary||i,c=m=>!!m&&(d.contains(m)||Ke(m,i));let p=!1;const f=()=>{p||(o.hidden=!1,a.hidden=!0,i.dataset.expanded="true",i.dataset.mode="editing",a.setAttribute("aria-expanded","true"),l.textContent="",t.focus&&t.focus(),!o.contains(r.activeElement)&&!Ke(r.activeElement,i)&&(Array.from(o.querySelectorAll('input:not([type=hidden]):not(:disabled),textarea:not(:disabled),[contenteditable=true],button:not(:disabled),[tabindex="0"]')).find(C=>!C.closest("[hidden]"))||i).focus())},u=()=>{var b,y,R;if(p||!i.isConnected||i.dataset.expanded==="false")return;const m=(b=t.validate)==null?void 0:b.call(t),C={...e,readonly:!0,canEdit:!1,mode:"default",value:m?e.value:t.read()},S=Xe.render(C,s.render(C));S.inert=!0,a.replaceChildren(S),l.textContent=m?"尚未保存:"+m:"",(y=t.deactivate)==null||y.call(t),i.dataset.expanded="false",i.dataset.mode="default",o.hidden=!0,a.hidden=!1,a.setAttribute("aria-expanded","false"),(R=e.onDeactivate)==null||R.call(e)},h=m=>{if(m.relatedTarget instanceof Node&&c(m.relatedTarget))return;const C=m.target;queueMicrotask(()=>{p||!i.isConnected||c(r.activeElement)||(C&&!C.isConnected&&r.activeElement===r.body?i.focus():u())})},g=()=>{queueMicrotask(()=>{!p&&i.isConnected&&i.dataset.expanded==="true"&&(!r.activeElement||r.activeElement===r.body)&&i.focus()})};a.onclick=m=>{m.stopPropagation(),f()},a.onkeydown=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),f())},d.addEventListener("focusout",h),i.addEventListener("click",g,!0),i.addEventListener("fc-collapse",u);const v=hn(r,{contains:(m,C)=>C.composedPath().includes(d)||c(m),leave:u});return{...t,element:i,focus:f,destroy:()=>{var m;p||(p=!0,v(),d.removeEventListener("focusout",h),i.removeEventListener("click",g,!0),i.removeEventListener("fc-collapse",u),(m=t.destroy)==null||m.call(t))}}}function wi(s){return{...s,context:s,layout:Xe.page(s)==="table"?"compact":"form",className:s.surface,services:s.services?{searchOptions:s.services.searchOptions,upload:s.services.upload,vote:s.services.vote?(e,t,i)=>s.services.vote(e,s.item,t,i):void 0}:void 0,onAction:e=>{e.type==="open"&&s.openDetail(String(e.value||s.item.id))}}}function jn(s=[]){const e=qn(),t=new Map;for(const n of e.list()){const o={...n,render(a){const l=e.create(wi(a));return Xe.render(a,l.render().element)},createEditor(a){const l=e.create(wi(a));return Un(o,a,l.createEditor())}};t.set(n.id,o)}const i=n=>{e.register({...n,create:a=>new vi(a,{render:l=>n.render({...l.context,field:l.field,value:l.value,readonly:l.readonly}),createEditor:l=>n.createEditor({...l.context,field:l.field,value:l.value,readonly:l.readonly})})});const o={...n,render:a=>Xe.render(a,n.render(a)),createEditor(a){const l=new vi(wi(a),{render:r=>n.render({...a,value:r.value}),createEditor:r=>n.createEditor({...a,value:r.value})});return Un(n,a,l.createEditor())}};t.set(n.id,o)};return s.forEach(i),{register:i,list:()=>[...t.values()],resolve:n=>t.get(e.resolve(n).id)}}function Ga(s,e){const t=e[s.field],i=s.value,n=Array.isArray(t)?t.map(String):t==null||t===""?[]:[String(t)];switch(s.op){case"equals":return Array.isArray(t)?n.includes(String(i)):String(t??"")===String(i??"");case"notEqual":return Array.isArray(t)?!n.includes(String(i)):String(t??"")!==String(i??"");case"contains":return n.some(o=>o.includes(String(i??"")));case"notContains":return!n.some(o=>o.includes(String(i??"")));case"in":return(Array.isArray(i)?i.map(String):[String(i??"")]).some(o=>n.includes(o));case"notIn":return!(Array.isArray(i)?i.map(String):[String(i??"")]).some(o=>n.includes(o));case"blank":return n.length===0;case"notBlank":return n.length>0;default:return!0}}function Ne(s,e,t={}){return s?"all"in s?s.all.every(i=>Ne(i,e,t)):"any"in s?s.any.some(i=>Ne(i,e,t)):"not"in s?!Ne(s.not,e,t):Ga(s,e):!0}function et(s,e={}){var t,i,n,o,a,l;return!s||s.all||(t=s.members)!=null&&t.length&&s.members.includes(e.currentUser||"")||(i=s.teams)!=null&&i.length&&(e.teams||[]).some(r=>s.teams.includes(r))||(n=s.roles)!=null&&n.length&&(e.roles||[]).some(r=>s.roles.includes(r))?!0:!((o=s.members)!=null&&o.length||(a=s.teams)!=null&&a.length||(l=s.roles)!=null&&l.length)}const za={empty:"待填",required:"此项必填",simpleMode:"简洁模式",continuous:"连续创建",cancel:"取消",draft:"存草稿",submit:"确认创建",addRole:"添加角色",addMeeting:"添加一组进入选题会"};function _a(s){return s.items!==void 0}function Wa(s,e={}){var X;const t=s.variant,i=s.presentation||(t==="create"?"modal":"drawer"),n={...za,...s.labels},o=e.controls||jn(),a=s.events||{},l={...s.data||{}};let r={...s.context||{}},d=s.fields.map(N=>({...N})),c=(s.tabs||[]).map(N=>({...N})),p=s.items?[...s.items]:d.map(N=>({field:N.key})),f=s.blocks?[...s.blocks]:[],u=s.actions?[...s.actions]:b();const h=t==="create"?"new":"detail";let g=s.fieldState||"display",v=s.simpleMode??!1;const m=s.simpleKeep&&s.simpleKeep.length?new Set(s.simpleKeep):new Set(d.slice(0,1).map(N=>N.key));let C=s.open??!0,S=!1;function b(){return t==="create"?[{id:"continuous",kind:"checkbox",label:n.continuous},{id:"close-overlay",label:n.cancel,variant:"outline"},{id:"save-draft",label:n.draft,variant:"outline"},{id:"submit",kind:"submit",label:n.submit,variant:"primary"}]:[]}const y=N=>d.find(B=>B.key===N);function R(N,B,Y){var we,ge,ae;const Q=Ne(N.visibleWhen,l,r)&&et((we=N.permission)==null?void 0:we.view,r)&&(!B||Ne(B.visibleWhen,l,r))&&(!Y||Ne(Y.visibleWhen,l,r)&&et(Y.visibleScope,r))&&(t!=="create"||N.createVisible!==!1),ue=!!N.required||(N.requiredWhen?Ne(N.requiredWhen,l,r):!1)||(B!=null&&B.requiredWhen?Ne(B.requiredWhen,l,r):!1)||((ge=N.permission)!=null&&ge.required?et(N.permission.required,r):!1),he=N.editable!==!1&&et((ae=N.permission)==null?void 0:ae.edit,r);return{visible:Q,required:!!ue,editable:he}}function M(N){if(l[N.key]===void 0&&(N.defaultMode==="always"&&N.defaultValue!==void 0&&(l[N.key]=N.defaultValue),N.defaultMode==="conditional")){for(const B of N.defaultWhen||[])if(Ne(B.when,l,r)){l[N.key]=B.value;return}}}const T=document.createElement(t==="create"?"form":"article"),W=xe(T,"form-surface",s);T.className=t==="create"?"rowvia-work-items rowvia-field-scope create-dialog form-surface":`rowvia-work-items rowvia-field-scope drawer form-surface${i==="fullscreen"?" is-fullscreen":""}`,T.dataset.variant=t,T.dataset.presentation=i,T.dataset.fieldState=g;let E=[];function x(){var ue,he,we,ge,ae,Se;for(const re of E)re.destroy();E=[],T.innerHTML="";const N=document.createElement("div");if(N.className="drawer-header",(ue=s.slots)!=null&&ue.leading){const re=document.createElement("div");re.className="drawer-leading",k(re,s.slots.leading),N.append(re)}if(N.insertAdjacentHTML("beforeend",`<span class="page-logo">${me("check")}</span><strong>${H(s.title||"")}</strong>`),(he=s.slots)!=null&&he.header&&k(N,s.slots.header),T.append(N),(we=s.slots)!=null&&we.subHeader){const re=document.createElement("div");re.className="detail-sub-header",k(re,s.slots.subHeader),T.append(re)}if((ge=s.slots)!=null&&ge.navigation){const re=document.createElement("div");re.className="detail-navigation",k(re,s.slots.navigation),T.append(re)}const B=F();if(t==="detail"&&B.length){const re=document.createElement("div");re.className="detail-tabs",re.setAttribute("role","tablist");for(const le of B){const se=document.createElement("button");se.type="button",se.className=`detail-tab${le.id===G?" active":""}`,se.dataset.tabId=le.id,se.dataset.detailTab=le.label,se.setAttribute("role","tab"),se.setAttribute("aria-selected",String(le.id===G)),se.textContent=le.label,se.onclick=()=>A(le.id),re.append(se)}const ye=document.createElement("div");ye.className="spacer",re.append(ye),(ae=s.slots)!=null&&ae.tabSuffix&&k(re,s.slots.tabSuffix),T.append(re)}const Y=document.createElement("div");Y.className=t==="create"?"create-body":"drawer-body",t==="create"&&s.simpleMode!==void 0&&Y.append($());const Q=B.find(re=>re.id===G);if(Y.append(I(Q)),T.append(Y),(Se=s.slots)!=null&&Se.footer){const re=document.createElement("div");re.className="form-surface-slot-footer",k(re,s.slots.footer),T.append(re)}u.length&&T.append(q()),t==="create"&&(T.onsubmit=re=>{var le,se;re.preventDefault();const ye=ce();if(ye){(le=a.onInvalid)==null||le.call(a,ye);return}(se=a.onSubmit)==null||se.call(a,J())})}function k(N,B){typeof B=="string"?N.insertAdjacentHTML("beforeend",B):N.append(B)}function $(){const N=document.createElement("div");return N.className="simple-mode",N.innerHTML=`<label><input type="checkbox" id="simple-mode"${v?" checked":""}>${H(n.simpleMode)}</label>`,N.querySelector("input").onchange=B=>O(B.target.checked),N}function q(){const N=document.createElement("div");N.className=t==="create"?"drawer-footer":"drawer-footer form-surface-actions";for(const B of u)if(Ne(B.visibleWhen,l,r)){if(B.kind==="checkbox"){const Y=document.createElement("label");Y.className="continuous",Y.innerHTML=`<input id="${H(B.id)}" type="checkbox"${B.checked?" checked":""}>${H(B.label||"")}`,N.append(Y);continue}if(B.kind==="submit"){const Y=document.createElement("button");Y.type="submit",Y.className=B.variant||"primary",Y.dataset.action=B.id,Y.textContent=B.label||n.submit,N.append(Y);continue}N.insertAdjacentHTML("beforeend",Ce(B.id,B.label||"",B.glyph||"",B.variant||""))}return N}function F(){return c.filter(B=>Ne(B.visibleWhen,l,r)&&et(B.visibleScope,r)).map((B,Y)=>({...B,order:B.order??Y})).sort((B,Y)=>B.order-Y.order)}let G=s.defaultTab||((X=c[0])==null?void 0:X.id);function I(N){var he;const B={data:l,context:r,variant:t,tab:N},Y=document.createElement("div");if(Y.className=t==="create"?"form-surface-body":"detail-fields form-surface-body",!N||N.kind==="form"){const we=(N==null?void 0:N.items)??p;for(const ae of we)if(_a(ae)){const Se=L(ae);Se&&Y.append(Se)}else{const Se=D(ae);Se&&Y.append(Se)}const ge=(N==null?void 0:N.blocks)??f;for(const ae of ge){const Se=z(ae,B);Se&&Y.append(Se)}return Y}const Q=N.kind==="custom"?N.render:((he=e.renderers)==null?void 0:he[N.kind])||N.render,ue=Q?Q(B):"";return typeof ue=="string"?Y.innerHTML=ue:ue&&Y.append(ue),Y}function L(N){const B=Ne(N.visibleWhen,l,r),Y=[];for(const ue of N.items){const he=D(ue);he&&Y.push(he)}if(!B||!Y.length)return null;const Q=document.createElement("section");return Q.className="form-group",Q.dataset.group=N.id,Q.innerHTML=`<p class="form-group-title">${H(N.label)}</p>`,Q.append(...Y),Q}function D(N){var ae;const B=y(N.field);if(!B)return null;const Y=R(B,N,K());if(!Y.visible||v&&!m.has(B.key))return null;M(B);const Q=document.createElement("div");Q.className=t==="create"?"create-field":"detail-row",Q.dataset.field=B.key,N.span===2&&Q.classList.add("span-2"),(N.labelPosition||((ae=s.layout)==null?void 0:ae.labelPosition)||"side")==="top"&&Q.classList.add("label-top");const he=Y.required,we=t==="create"?"<em>*</em>":" *";Q.innerHTML=`<label for="${h}-${H(B.key)}">${H(B.label)}${he?we:""}</label><div class="field-value"><div class="fc-host" data-control-field="${H(B.key)}" data-control-mode="${t}"></div>`+(B.description?`<small class="field-description">${H(B.description)}</small>`:"")+"</div>";const ge=Q.querySelector(".fc-host");return ie(ge,{...B,required:he},he),Q}function z(N,B){var ue;if(!Ne(N.visibleWhen,l,r)||v&&!m.has(N.id))return null;const Y=(ue=e.renderers)!=null&&ue.block?e.renderers.block({...B,block:N}):N.render?N.render(B):U(N,B),Q=document.createElement("div");return Q.className=`form-surface-block block-${N.kind}`,Q.dataset.block=N.id,typeof Y=="string"?Q.innerHTML=Y:Y&&Q.append(Y),Q}function U(N,B){var Y,Q;if(N.kind==="roles"){const ue=document.createElement("div");ue.className=t==="create"?"create-field":"detail-row",ue.innerHTML=`<label>${H(N.label||"角色与人员")}${(Y=N.requiredRoles)!=null&&Y.length?"<em>*</em>":""}</label><div class="role-body"><div class="role-rows"></div><div class="role-actions">${Ce("add-role",n.addRole,"","outline")}</div></div>`;const he=ue.querySelector(".role-rows"),we=(Q=N.roleOptions)!=null&&Q.length?N.roleOptions:["提报人"],ge=N.people??[],ae=()=>{const ye=Array.isArray(l.roles)?l.roles:[];return ye.length||ye.push({name:we[0],person:String(l.owner??B.context.currentUser??"")}),l.roles=ye,ye};let Se=[];const re=()=>{for(const le of Se)le.destroy(),E=E.filter(se=>se!==le);Se=[],he.replaceChildren();const ye=ae();ye.forEach((le,se)=>{const Pe=document.createElement("div");Pe.className="role-line";const Ze=document.createElement("div");Ze.className="fc-host role-select";const $e=document.createElement("div");if($e.className="fc-host role-person",Pe.append(Ze,$e),ye.length>1){const de=document.createElement("button");de.type="button",de.className="role-remove",de.dataset.roleRemove=String(se),de.setAttribute("aria-label","移除角色"),de.textContent="×",Pe.append(de)}he.append(Pe),Se.push(ie(Ze,{key:`role-${se}`,label:"角色",kind:"select",options:we,editable:!0},!1,{get:()=>le.name,set:de=>{le.name=String(de??"")},notify:()=>{var de;return(de=a.onCommit)==null?void 0:de.call(a,"roles",ae(),l)}}),ie($e,{key:`role-person-${se}`,label:"人员",kind:"person",options:ge.map(de=>de.id),choices:ge,editable:!0},()=>{var de;return!!((de=N.requiredRoles)!=null&&de.includes(le.name))},{get:()=>le.person,set:de=>{le.person=String(de??"")},notify:()=>{var de,Ve;se===0&&(l.owner=le.person,(de=a.onCommit)==null||de.call(a,"owner",le.person,l)),(Ve=a.onCommit)==null||Ve.call(a,"roles",ae(),l)}}))})};return re(),ue.addEventListener("click",ye=>{var Pe,Ze,$e;const le=ye.target,se=le.closest("[data-role-remove]");if(se){const de=ae();de.splice(Number(se.dataset.roleRemove),1),de.length||de.push({name:we[0],person:""}),l.owner=((Pe=de[0])==null?void 0:Pe.person)??"",re(),(Ze=a.onChange)==null||Ze.call(a,"roles",de,l);return}if(le.closest('[data-action="add-role"]')){const de=ae();de.push({name:we.find(Ve=>!de.some(ut=>ut.name===Ve))??we[0],person:""}),re(),($e=a.onChange)==null||$e.call(a,"roles",de,l)}}),ue}if(N.kind==="meetings"){const ue=document.createElement("section");return ue.className="detail-section",ue.innerHTML=`<p>${H(N.label||"进入选题会")}</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${Ce("add-meeting",n.addMeeting,"add")}</div>`,ue}return""}function K(){return F().find(N=>N.id===G)}function Z(N,B,Y){return{field:N,value:Y?Y.get():l[N.key]??N.defaultValue??"",item:l,surface:t==="create"?"create":"detail",page:"basic",mode:"default",canEdit:B,readonly:!B,services:e.services,onSelectedOptions:ue=>{(we=>{we.choices=[...new Map([...we.choices||(we.options||[]).map(ge=>({id:ge,label:ge})),...ue].map(ge=>[ge.id,ge])).values()]})(N)},openDetail:ue=>{var he;return(he=a.onOpenDetail)==null?void 0:he.call(a,ue)}}}function ie(N,B,Y,Q){var Zn;const ue=()=>typeof Y=="function"?Y():Y,he=B.editable!==!1&&et((Zn=B.permission)==null?void 0:Zn.edit,r),we=Z(B,he,Q),ge=o.resolve(B),ae=ge.createEditor(we),Se="input,select,textarea,[role=textbox]",re=[ae.content,ae.element].filter(ee=>!!ee).map(ee=>ee.matches(Se)?ee:ee.querySelector(Se)).find(Boolean);re&&(re.id=`${h}-${B.key}`);const ye=document.createElement("div");ye.className="fc-error",ye.setAttribute("role","status");const le=document.createElement("div");le.className="fc-detail-editor",le.dataset.mode="editing",le.dataset.box=Et(ge),le.append(ae.element),N.classList.add("fc-detail-host"),N.dataset.page="basic",N.dataset.mode="default",N.dataset.surface=t==="create"?"create":"detail",N.append(le,ye);const se=document.createElement("div");se.className="fc-detail-preview",se.dataset.box=Et(ge),se.dataset.editable=String(he),se.dataset.surface=t==="create"?"create":"detail",N.prepend(se);const Pe=()=>{if(!N.classList.contains("editing")){N.style.minHeight="";return}N.style.minHeight=`${le.offsetHeight}px`},Ze=ee=>{le.style.minHeight=`${ee}px`,le.style.maxHeight=`${ee}px`},$e=()=>{le.style.maxHeight="",Pe()},de=Et(ge)==="rich",Ve=()=>{var be,xt;if(!he||N.classList.contains("editing"))return;const ee=se.offsetHeight;N.classList.add("editing"),N.dataset.mode="editing",de||Ze(ee),Pe(),(be=ae.focus)==null||be.call(ae),(xt=a.onFieldStateChange)==null||xt.call(a,B.key,"edit")},ut=()=>{if(se.replaceChildren(ge.render({...Z(B,he,Q),readonly:!0,canEdit:!1,mode:"default",value:Q?Q.get():l[B.key]??""})),se.dataset.box==="select"){const ee=document.createElement("span");ee.className="fc-field-chevron",ee.setAttribute("aria-hidden","true"),se.append(ee)}if(he){se.tabIndex=0,se.setAttribute("role","button"),se.setAttribute("aria-label",`编辑${B.label}`),se.onclick=be=>{be.target.closest("a,button,input,textarea,select")||Ve()},se.onkeydown=be=>{(be.key==="Enter"||be.key===" ")&&(be.preventDefault(),Ve())};const ee=document.createElement("button");ee.type="button",ee.className="fc-detail-edit",ee.tabIndex=-1,ee.textContent="编辑",ee.ariaLabel=`编辑${B.label}`,ee.onclick=be=>{be.stopPropagation(),Ve()},se.append(ee)}else se.removeAttribute("role"),se.removeAttribute("tabindex"),se.onclick=null,se.onkeydown=null};ut();const Kn=()=>{var be;const ee=ue()&&!pe(ae.read())?n.required:(be=ae.validate)==null?void 0:be.call(ae);return ye.textContent=ee||"",N.classList.toggle("is-error",!!ee),ee},Vt=()=>{var be,xt,Qn;if(!he)return!0;const ee=Kn();if(ee&&$e(),!ee){const ht=ae.read(),Ya=Q?Q.get():l[B.key];JSON.stringify(Ya)!==JSON.stringify(ht)&&(Q?(Q.set(ht),(be=Q.notify)==null||be.call(Q,ht)):(l[B.key]=ht,(xt=a.onCommit)==null||xt.call(a,B.key,ht,l))),(Qn=a.onChange)==null||Qn.call(a,B.key,ht,l),ut()}return!ee},Yn=()=>{var ee;N.classList.remove("editing"),N.dataset.mode="default",N.style.minHeight="",le.style.minHeight="",le.style.maxHeight="",(ee=a.onFieldStateChange)==null||ee.call(a,B.key,"display")};N.addEventListener("input",()=>{var ee;$e(),(ee=a.onChange)==null||ee.call(a,B.key,ae.read(),l)}),N.addEventListener("pointerdown",()=>{N.classList.contains("editing")&&$e()},!0),N.addEventListener("mousedown",ee=>{var be;ge.id!=="richText"||!N.classList.contains("editing")||ee.target.closest("button,a,input,textarea,select,[contenteditable=true]")||(ee.preventDefault(),!N.contains(document.activeElement)&&!Ke(document.activeElement,N)&&((be=ae.focus)==null||be.call(ae)))}),N.addEventListener("change",()=>{$e(),Vt()}),N.addEventListener("fc-collapse",()=>{Vt(),Yn(),ut()}),N.addEventListener("focusout",()=>{queueMicrotask(()=>{if(!(S||!N.isConnected)){if(N.contains(document.activeElement)||Ke(document.activeElement,N)){Pe();return}Vt(),Yn(),ut()}})}),(B.defaultState||g)==="edit"&&he&&queueMicrotask(()=>{S||Ve()});const Xn={key:B.key,host:N,editor:ae,editable:he,check:Kn,commit:Vt,beginEdit:Ve,write:ee=>{Q?Q.set(ee):l[B.key]=ee},destroy:()=>{var ee;return(ee=ae.destroy)==null?void 0:ee.call(ae)}};return E.push(Xn),Xn}const pe=N=>Array.isArray(N)?N.length>0:N!=null&&String(N).trim()!=="";function J(){for(const N of E)N.editable&&N.write(N.editor.read());return{...l}}function ce(){let N;for(const B of E){if(!B.editable)continue;const Y=B.check();Y&&N===void 0&&(N=Y,B.beginEdit())}return N}function fe(N){C=N,T.hidden=!N,T.dataset.open=String(N)}function ne(N){g=N,T.dataset.fieldState=N;for(const B of E)N==="edit"?B.beginEdit():B.host.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))}function A(N){var Y;if(N===G||!F().some(Q=>Q.id===N))return;G=N;const B=K();x(),B&&((Y=a.onTabChange)==null||Y.call(a,N,B))}function O(N){v=N,x()}function V(N){N.data&&Object.assign(l,N.data),N.fields&&(d=N.fields.map(B=>({...B}))),N.tabs&&(c=N.tabs.map(B=>({...B}))),N.items&&(p=[...N.items]),N.blocks&&(f=[...N.blocks]),N.actions&&(u=[...N.actions]),N.context&&(r={...N.context}),x()}function _(){var N;if(!S){S=!0,(N=a.onDestroy)==null||N.call(a),W.destroy();for(const B of E)B.destroy();E=[],T.remove()}}return x(),fe(C),{element:T,onInteraction:W.onInteraction,read:J,validate:ce,setOpen:fe,setFieldState:ne,setTab:A,setSimpleMode:O,activeTab:()=>G,update:V,destroy:_}}function qa(s){const e=P("div",s.className??"tag");return s.marker?e.append(s.marker):s.markerClassName&&e.append(P("span",s.markerClassName)),e.append(P("span","",s.label)),e}function Ua(s){const e=P("div",s.className);if(s.leading)e.append(s.leading);else if(s.image){const i=P("img");i.src=s.image.src,i.alt=s.image.alt,e.append(i)}const t=s.inline?e:P("div",s.contentClassName);return t.append(P(s.titleTag??"span",s.titleClassName,s.title)),s.description!==void 0&&t.append(P(s.descriptionTag??"span",s.descriptionClassName,s.description)),s.inline||e.append(t),e}function ja(s,e){Nt[s]=e}function Ka(s,e){Ue[s]=e}j.ActionField=_n,j.AttachmentField=Bn,j.BaseField=Le,j.BaseFieldControl=Xe,j.CELL_EDITORS=Ue,j.CELL_RENDERERS=Nt,j.COMPLETION_LABEL=Yi,j.CascadeField=pi,j.ChoiceField=dt,j.CompositeField=Wn,j.ComputedField=ct,j.CustomField=vi,j.DEFAULT_LOCALE_TEXT=Li,j.DateField=gi,j.DateRangeField=Hn,j.DateTimeField=fi,j.EmailField=Nn,j.FORMULA_FUNCTIONS=Mt,j.GANTT_UNITS=_i,j.GanttChart=Ui,j.Grid=nt,j.LinkField=ci,j.LocationField=Vn,j.MultiCascadeField=$n,j.MultiChoiceField=An,j.MultiPersonField=Fn,j.MultiRelationField=Pn,j.MultiVoteField=zn,j.NumberField=kn,j.PersonField=ui,j.PhoneField=In,j.RadioField=Dn,j.RelationField=hi,j.RichTextField=Tn,j.STATUS_META=at,j.SignalField=mi,j.SingleVoteField=Gn,j.SwitchField=On,j.TextField=_e,j.TextareaField=Ln,j.UNIT_LABEL=At,j.VoteField=Bt,j.allGatesMet=Xi,j.computeStickyGroupRows=Bi,j.createControlRegistry=jn,j.createDetailDialog=Gi,j.createFieldRegistry=qn,j.createFlowCanvas=en,j.createFlowContextBar=sn,j.createGantt=Wo,j.createGrid=Vi,j.createMediaCell=Ua,j.createNodeCard=tn,j.createNodeFlow=ia,j.createNodeTimeline=on,j.createPersonnelSchedule=ra,j.createSparklineSvg=qt,j.createTagCell=qa,j.createWorkItemColumnPanels=fa,j.createWorkItemColumns=pa,j.createWorkItemDetailHeader=wa,j.createWorkItemFormSurface=Wa,j.createWorkItemHeaderDecorator=ga,j.createWorkItemLayers=Ca,j.createWorkItemRulePanels=ma,j.createWorkItemSelectionBar=ua,j.createWorkItemTable=ha,j.createWorkItemTabs=da,j.createWorkItemToolbar=ca,j.default=nt,j.emptyView=la,j.escapeHtml=H,j.evalFormCondition=Ne,j.evalFormScope=et,j.evaluateFormula=gt,j.evaluateGates=Zt,j.formatNumberCommas=He,j.groupNodes=Qi,j.isFormula=_t,j.matchNodes=Qt,j.matches=dn,j.parse=bi,j.registerEditor=Ka,j.registerFormulaFunction=ns,j.registerRenderer=ja,j.renderContent=oi,j.sanitizeRichText=yt,j.showTip=nn,j.summarize=Zi,j.tokenize=Ci,j.videoFlow=sa,Object.defineProperties(j,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
104
|
+
<button type="button" class="color-swatch" data-color="${A}" style="background-color:${D(I.color)}" aria-label="着色颜色" title="设置颜色" aria-expanded="false"></button>
|
|
105
|
+
<button type="button" class="field-select" data-color-scope="${A}" aria-label="着色范围" aria-expanded="false">${!I.scope||I.scope==="row"?"整行":"单元格"}${Re("down")}</button>
|
|
106
|
+
<button class="field-select ${E?"":"empty"}" data-pick="${A}">${D(E||"请选择筛选项")}${Re("down")}</button>
|
|
107
|
+
${zt(G,I.field?I.operator:"",`data-operator="${A}" aria-label="运算符" ${I.field?"":"disabled"}`)}
|
|
108
|
+
${M}
|
|
109
|
+
<button class="color-remove" data-remove="${A}" aria-label="删除条件" title="删除条件">${Re("close")}</button>
|
|
110
|
+
<div class="color-more-wrap"><button class="color-more" data-color-more="${A}" aria-label="更多条件操作" aria-expanded="false">${Re("more")}</button><div class="color-rule-menu hidden"><button data-color-copy="${A}">复制条件</button><button data-color-up="${A}" ${A===0?"disabled":""}>上移</button><button data-color-down="${A}" ${A===u.colors.length-1?"disabled":""}>下移</button></div></div>
|
|
111
|
+
</div>`}).join(""),g=l(h,"",`<div class="color-panel-title">设置颜色条件<span class="color-help" tabindex="0" title="按条件优先级着色;同一范围满足多个条件时,使用最上方条件的颜色。" aria-label="颜色条件说明">i</span></div><div class="color-conditions">${f}</div><div class="color-panel-footer"><button class="add-condition">${Re("plus")}添加着色条件</button><button class="clear-rules" ${u.colors.length?"":"disabled"}>清空全部条件</button></div>`,Math.min(944,innerWidth-24),"color-panel");g.ariaLabel="设置颜色条件",s.setActiveRulePanel("color");const v=()=>c(h),m=()=>{r(),v()},y=["#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"],k=()=>{var I;(I=g.querySelector(".color-palette"))==null||I.remove(),g.querySelectorAll("[data-color]").forEach(A=>A.setAttribute("aria-expanded","false"))},C=()=>{var I,A,E;(I=g.querySelector(".color-scope-picker"))==null||I.remove(),(E=(A=s.getPopupEditor())==null?void 0:A.destroy)==null||E.call(A),s.setPopupEditor(null),g.querySelectorAll("[data-color-scope]").forEach(G=>G.setAttribute("aria-expanded","false"))};let b=-1;g.querySelectorAll(".color-condition").forEach((I,A)=>{I.ondragstart=E=>{var G;b=A,(G=E.dataTransfer)==null||G.setData("text/plain",String(A))},I.ondragover=E=>E.preventDefault(),I.ondrop=E=>{if(E.preventDefault(),b<0||b===A)return;const[G]=u.colors.splice(b,1);u.colors.splice(A,0,G),m()}}),g.onclick=I=>{var G,x,M;I.stopPropagation();const A=I.target.closest("button");if(I.target.closest(".color-scope-picker"))return;const E=(A==null?void 0:A.getAttribute("aria-expanded"))==="true";if(C(),!A||A.disabled){k();return}if(A.dataset.colorScope!==void 0){if(k(),E)return;const N=Number(A.dataset.colorScope),P=u.colors[N],_={key:"colorScope",label:"着色范围",kind:"select",options:["整行","单元格"],required:!0},L=i.resolve(_).createEditor({field:_,value:!P.scope||P.scope==="row"?"整行":"单元格",item:o(),surface:"cell",readonly:!1,openDetail:()=>{}});s.setPopupEditor(L);const H=document.createElement("div");H.className="popup fc-popup fc-choice-popup color-scope-picker",H.style.width="272px",H.append(L.element),g.append(H);const T=A.getBoundingClientRect();H.style.left=`${Math.max(8,Math.min(T.left,innerWidth-280))}px`,H.style.top=`${Math.max(8,Math.min(T.bottom+6,innerHeight-H.offsetHeight-8))}px`,A.setAttribute("aria-expanded","true"),L.element.addEventListener("change",R=>{var $,z,j;R.stopPropagation(),!(($=L.validate)!=null&&$.call(L))&&(P.scope=L.read()==="整行"?"row":"cell",m(),(j=(z=s.popup())==null?void 0:z.querySelector(`[data-color-scope="${N}"]`))==null||j.focus())}),H.onkeydown=R=>{R.key==="Escape"&&(R.stopPropagation(),C(),A.focus())},(G=L.focus)==null||G.call(L);return}if(A.dataset.paletteColor!==void 0){const N=Number(A.closest(".color-palette").dataset.ruleIndex);u.colors[N].color=A.dataset.paletteColor,m(),(M=(x=s.popup())==null?void 0:x.querySelector(`[data-color="${N}"]`))==null||M.focus();return}if(A.dataset.color!==void 0){const N=A.getAttribute("aria-expanded")==="true";if(k(),N)return;const P=Number(A.dataset.color),_=document.createElement("div");_.className="color-palette",_.dataset.ruleIndex=String(P),_.setAttribute("role","group"),_.ariaLabel="选择着色颜色",_.innerHTML=y.map(H=>`<button type="button" class="color-palette-option" data-palette-color="${H}" style="background-color:${H}" aria-label="颜色 ${H}" aria-pressed="${H===u.colors[P].color.toLowerCase()}"></button>`).join(""),g.append(_);const L=A.getBoundingClientRect();_.style.left=`${Math.max(8,Math.min(L.left,innerWidth-_.offsetWidth-8))}px`,_.style.top=`${Math.max(8,Math.min(L.bottom+6,innerHeight-_.offsetHeight-8))}px`,A.setAttribute("aria-expanded","true"),_.onkeydown=H=>{H.key==="Escape"&&(H.stopPropagation(),k(),A.focus())};return}if(k(),A.classList.contains("add-condition"))u.colors.push({field:"",operator:"contains",value:"",color:"#fff5d6",scope:"row"}),m();else if(A.dataset.pick!==void 0){const N=+A.dataset.pick;a(A,P=>{u.colors[N].field=P,u.colors[N].value="",u.colors[N].operator="contains",m()})}else if(A.dataset.remove!==void 0)u.colors.splice(+A.dataset.remove,1),m();else if(A.classList.contains("clear-rules"))u.colors=[],m();else if(A.dataset.colorMore!==void 0){const N=A.nextElementSibling,P=N.classList.contains("hidden");g.querySelectorAll(".color-rule-menu").forEach(_=>_.classList.add("hidden")),g.querySelectorAll("[data-color-more]").forEach(_=>_.setAttribute("aria-expanded","false")),N.classList.toggle("hidden",!P),A.setAttribute("aria-expanded",String(P))}else if(A.dataset.colorCopy!==void 0){const N=+A.dataset.colorCopy;u.colors.splice(N+1,0,structuredClone(u.colors[N])),m()}else if(A.dataset.colorUp!==void 0||A.dataset.colorDown!==void 0){const N=Number(A.dataset.colorUp??A.dataset.colorDown),[P]=u.colors.splice(N,1);u.colors.splice(N+(A.dataset.colorUp!==void 0?-1:1),0,P),m()}},g.onchange=I=>{const A=I.target;if(A.dataset.operator!==void 0){u.colors[+A.dataset.operator].operator=A.value,m();return}A.dataset.ruleValue!==void 0&&(u.colors[+A.dataset.ruleValue].value=A.value),r()},g.oninput=I=>{const A=I.target;if(A.dataset.ruleValue!==void 0)u.colors[+A.dataset.ruleValue].value=A.value;else return;r()}}function p(h,u){if(h==="color"){c(u);return}const f=s.view(),g={filter:"筛选",sort:"排序",group:"分组",color:"颜色"}[h],v=h==="filter"?f.filters:h==="sort"?f.sorts:h==="group"?f.groups:f.colors,m=v.map((b,I)=>{var N;const A=h==="sort"?b.colId:h==="group"?b:b.field,E=((N=e.find(([P])=>P===A))==null?void 0:N[1])||A,G=`<button class="field-select" data-pick="${I}">${D(E)}${Re("down")}</button>`;if(h==="sort")return`<div class="condition">${G}<button class="sort-direction ${b.sort==="asc"?"selected":""}" data-dir="asc" data-index="${I}">首项 → 末项</button><button class="sort-direction ${b.sort==="desc"?"selected":""}" data-dir="desc" data-index="${I}">末项 → 首项</button><button data-remove="${I}" aria-label="删除条件">${Re("close")}</button></div>`;if(h==="group")return`<div class="condition">${G}<span class="spacer"></span><button data-remove="${I}" aria-label="删除条件">${Re("close")}</button></div>`;const x=zt([["contains",n[A]?"存在选项属于":"包含"],["equals","等于"],["notEqual","不等于"],["blank","为空"],["notBlank","不为空"]],b.operator,`data-operator="${I}" aria-label="运算符"`),M=["blank","notBlank"].includes(b.operator)?"":n[A]?zt([["","请选择目标值"],...n[A].map(P=>[P,P])],b.value,`data-rule-value="${I}" aria-label="目标值"`):`<input data-rule-value="${I}" aria-label="目标值" value="${D(b.value)}" placeholder="请选择目标值">`;return`<div class="condition">${G}${x}${M}${h==="color"?`<input type="color" data-color="${I}" value="${b.color}" aria-label="行颜色">`:""}<button data-remove="${I}" aria-label="删除条件">${Re("close")}</button></div>`}).join(""),y=l(u,`设置${g}条件`,`${h==="filter"?`<label class="terminated"><input type="checkbox" id="terminated" ${f.showTerminated?"checked":""}>显示已终止数据</label>`:""}${m}<button class="add-condition">${Re("plus")}添加${h==="color"?"着色":g}条件</button>${v.length?'<button class="clear-rules">清空全部条件</button>':""}`,h==="color"?650:560);s.setActiveRulePanel(h);const k=()=>p(h,u);let C=-1;y.querySelectorAll(".condition").forEach((b,I)=>{b.draggable=!0,b.ondragstart=A=>{var E;C=I,(E=A.dataTransfer)==null||E.setData("text/plain",String(I))},b.ondragover=A=>A.preventDefault(),b.ondrop=A=>{if(A.preventDefault(),C<0||C===I)return;const[E]=v.splice(C,1);v.splice(I,0,E),r(),k()}}),y.onclick=b=>{const I=b.target.closest("button");I&&(I.classList.contains("add-condition")&&a(I,A=>{h==="filter"&&f.filters.push({field:A,operator:"contains",value:""}),h==="sort"&&f.sorts.push({colId:A,sort:"asc"}),h==="group"&&!f.groups.includes(A)&&f.groups.push(A),h==="color"&&f.colors.push({field:A,operator:"contains",value:"",color:"#e9f2ff"}),r(),k()}),I.dataset.pick!==void 0&&a(I,A=>{const E=+I.dataset.pick;h==="sort"?f.sorts[E].colId=A:h==="group"?f.groups[E]=A:(v[E].field=A,v[E].value=""),r(),k()}),I.dataset.remove!==void 0&&(v.splice(+I.dataset.remove,1),r(),k()),I.classList.contains("clear-rules")&&(v.splice(0),r(),k()),I.dataset.dir&&(f.sorts[+I.dataset.index].sort=I.dataset.dir,r(),k()))},y.onchange=b=>{const I=b.target;I.id==="terminated"&&(f.showTerminated=I.checked),I.dataset.operator!==void 0&&(v[+I.dataset.operator].operator=I.value,k()),I.dataset.ruleValue!==void 0&&(v[+I.dataset.ruleValue].value=I.value),I.dataset.color!==void 0&&(f.colors[+I.dataset.color].color=I.value),r()},y.oninput=b=>{const I=b.target;I.tagName==="INPUT"&&I.dataset.ruleValue!==void 0&&(v[+I.dataset.ruleValue].value=I.value,r())}}return{colorRuleMatches:d,colorPanel:c,rulePanel:p}}function Ka(s={}){var d;const e=document.createElement("section");e.className="rowvia-work-items detail-header-surface";const t=document.createElement("div");t.className="detail-meta-row";const n=s.tags??[];t.innerHTML=`${n.map(c=>`<span class="detail-meta-tag">${D(c)}</span>`).join("")}<button type="button" class="detail-meta-add" data-detail-action="add-tag" aria-label="添加标签">${Re("add")}</button><span class="detail-meta-divider"></span>${(s.signals||[]).map(c=>`<button type="button" class="detail-signal${c.checked?" checked":""}" data-detail-action="toggle-signal"><span class="detail-signal-dot">${c.checked?"✓":""}</span>${D(c.label)}</button>`).join("")}`,e.append(t);const i=s.stages??[],o=s.activeStage||((d=i.find(c=>c.state==="active"))==null?void 0:d.id),a=document.createElement("div");a.className="detail-process-strip",a.setAttribute("aria-label","工作项流程"),a.innerHTML=i.map((c,p)=>`<div class="detail-stage-wrap"><button type="button" class="detail-stage ${c.id===o?"active":""} ${c.state||""}" data-detail-action="stage" data-stage="${D(c.id)}"><span class="detail-stage-dot"></span>${D(c.label)}</button>${p<i.length-1?'<span class="detail-stage-line"></span>':""}</div>`).join(""),e.append(a);const l=document.createElement("div");l.className="detail-stage-card";const r=i.find(c=>c.id===o)||i[0];return r&&(l.innerHTML=`<div class="detail-stage-card-head"><div><span class="detail-stage-chevron">⌄</span><span class="detail-stage-card-dot ${r.state||""}"></span><strong>${D(r.label)}</strong><span class="detail-stage-status">进行中</span></div><div class="detail-stage-card-actions"><button type="button" class="primary" data-detail-action="complete-stage">完成</button><button type="button" class="icon-button" data-detail-action="stage-more" aria-label="节点更多">${Re("more")}</button></div></div><div class="detail-stage-card-body"><span>负责人</span><strong>${D(s.owner||"待填")}</strong></div><div class="detail-dependency"><span>⌄</span> 依赖项</div>`),r&&e.append(l),e.onclick=c=>{var u;const p=c.target.closest("[data-detail-action]");if(!p)return;const h=p.dataset.detailAction||"";(u=s.onAction)==null||u.call(s,h),e.dispatchEvent(new CustomEvent("rowvia:detail-action",{detail:{action:h,stage:p.dataset.stage},bubbles:!0}))},e}function Ya(s={}){const e=Ka(s),t=Fe(e,"work-item-detail-header",s);return{element:e,onInteraction:t.onInteraction,destroy(){t.destroy(),e.onclick=null,e.remove()}}}function Xa(s,e={}){const t=document.createElement("div");t.className="rowvia-work-items rowvia-field-scope",t.style.display="contents",s.append(t);const n=new je,i=Fe(t,"work-item-layers",e);let o=null,a=null,l=null,r,d=null;const c=(u,f,g)=>{var v,m;u==="open"?(v=e.onOpen)==null||v.call(e,f,g):(m=e.onClose)==null||m.call(e,f),t.dispatchEvent(new CustomEvent(`rowvia:layer-${u}`,{detail:{kind:f,element:g},bubbles:!0}))};function p(){o&&(o.remove(),o=null,c("close","popup"))}function h(){a&&(a.remove(),a=null,l==null||l.focus(),l=null,c("close","overlay"))}return n.listen(t,"click",u=>{var m;const f=u.target,g=(m=f.closest("[data-action]"))==null?void 0:m.dataset.action,v=g==="close-popup"?"popup":g==="close-overlay"||f===a?"overlay":void 0;v&&(u.stopPropagation(),e.onCloseRequest?e.onCloseRequest(v):v==="popup"?p():h())}),{element:t,onInteraction:i.onInteraction,closePopup:p,closeOverlay:h,showPopup(u,f,g,v=460,m=""){if(n.destroyed)throw new Error("Cannot open a destroyed layer host");p(),o=document.createElement("section"),o.className=`popup ${m}`,o.setAttribute("role","dialog"),o.ariaLabel=f||"列操作",o.style.width=`${v}px`,o.innerHTML=`${f?`<div class="popup-head"><span>${D(f)}</span>${Ne("close-popup","","close")}</div>`:""}${g}`,t.append(o);const y=u.getBoundingClientRect();return o.style.left=`${Math.max(12,Math.min(y.left,innerWidth-v-16))}px`,o.style.top=`${Math.min(y.bottom+8,Math.max(12,innerHeight-o.offsetHeight-16))}px`,c("open","popup",o),o},showOverlay(u,f="dialog-overlay"){if(n.destroyed)throw new Error("Cannot open a destroyed layer host");return a?(a.remove(),c("close","overlay")):l=document.activeElement,a=document.createElement("div"),a.className=`overlay ${f}`,a.setAttribute("role","dialog"),a.setAttribute("aria-modal","true"),typeof u=="string"?a.innerHTML=u:a.append(u),t.append(a),c("open","overlay",a),a},toast(u){if(n.destroyed)return;r==null||r(),d==null||d.remove();const f=document.createElement("div");f.className="toast",f.setAttribute("role","status"),f.innerHTML=Re("check")+D(u),t.append(f),d=f;const g=window.setTimeout(()=>{f.remove(),r==null||r()},2500);r=n.add(()=>window.clearTimeout(g))},destroy(){n.destroyed||(n.destroy(),i.destroy(),p(),h(),t.remove())}}}const bn=new WeakMap;function Oi(s,e){let t=bn.get(s);if(!t){const i=new Set,o=a=>{for(const l of[...i])i.has(l)&&!l.contains(a.target,a)&&l.leave(a)};s.addEventListener("pointerdown",o,!0),s.addEventListener("focusin",o,!0),t={boundaries:i,stop:()=>{s.removeEventListener("pointerdown",o,!0),s.removeEventListener("focusin",o,!0)}},bn.set(s,t)}t.boundaries.add(e);const n=t;return()=>{!n.boundaries.delete(e)||n.boundaries.size||(n.stop(),bn.delete(s))}}class Oe{constructor(e){w(this,"root");w(this,"destroying",!1);w(this,"feedback");w(this,"options");w(this,"value");w(this,"committedValue");w(this,"state");w(this,"view");w(this,"viewLife",new je);w(this,"life",new je);w(this,"listeners",new Set);w(this,"interactions");w(this,"interactionListeners",new Set);w(this,"mounted",!1);w(this,"handled",new WeakSet);this.options={...e},this.value=e.value,this.committedValue=e.value,this.state=e.readonly||e.canEdit===!1?"display":e.state??"display"}get element(){if(this.root)return this.root;const e=document.createElement("div");return e.className="rowvia-field",e.tabIndex=0,e.setAttribute("aria-label",this.options.field.label),this.root=e,e}bindRoot(){this.life.listen(this.element,"pointerenter",()=>{this.state==="display"&&this.setState("hover","user")}),this.life.listen(this.element,"pointerleave",()=>{this.state==="hover"&&this.setState("display","user")}),this.life.listen(this.element,"click",e=>{e.target.closest("button,a,input,textarea,select,[contenteditable]")||this.edit("user")}),this.life.listen(this.element,"keydown",e=>{const t=e.key;t==="Escape"&&this.state==="editing"?(e.preventDefault(),this.cancel("user")):(t==="Enter"||t===" ")&&this.state!=="editing"&&e.target===this.element&&(e.preventDefault(),this.edit("user"))}),this.life.listen(this.element,"fc-collapse",e=>{var t;((t=e.detail)==null?void 0:t.reason)==="escape"?this.cancel("user"):this.commit("user")}),this.life.listen(this.element,"focusout",()=>{queueMicrotask(()=>{var t,n;if(this.life.destroyed||!this.element.isConnected||this.state!=="editing")return;const e=this.element.ownerDocument.activeElement;this.element.contains(e)||(n=(t=this.view)==null?void 0:t.content)!=null&&n.contains(e)||Ye(e,this.element)||this.commit("user")})})}renderHover(e){return this.renderDisplay(e)}beforeInput(e){return e}beforeCommit(e){return!0}beforeCancel(e){return!0}beforeStateChange(e){return!0}validateValue(e){}isReadonly(){return!!this.options.readonly||this.options.canEdit===!1||this.options.field.editable===!1}onOutput(e){}get snapshot(){return{key:this.options.field.key,value:this.read(),committedValue:this.committedValue,state:this.state,readonly:this.isReadonly()}}mount(e){if(this.life.destroyed)throw new Error("Cannot mount a destroyed field");return this.mounted||(this.mounted=!0,this.bindRoot(),this.draw()),e==null||e.append(this.element),this}read(){var e;return this.state==="editing"&&((e=this.view)!=null&&e.read)?this.view.read():this.value}on(e){return this.life.destroyed?()=>{}:(this.listeners.add(e),()=>{this.listeners.delete(e)})}onInteraction(e){return this.life.destroyed?()=>{}:(this.interactionListeners.add(e),()=>{this.interactionListeners.delete(e)})}input(e,t="api",n){var l;if(this.life.destroyed||this.snapshot.readonly)return;const i=this.value,o=this.snapshot,a=this.beforeInput(e);this.value=(l=this.options.hooks)!=null&&l.beforeInput?this.options.hooks.beforeInput(a,o):a,(t==="api"||!Object.is(e,this.value))&&this.draw(),this.emit("input",t,{previousValue:i,originalEvent:n})}setValue(e){if(this.life.destroyed)return;const t=this.read();this.value=e,this.committedValue=e,this.draw(),this.emit("change","api",{previousValue:t})}update(e){this.life.destroyed||(this.value=this.read(),this.options={...this.options,...e},"value"in e&&(this.value=this.committedValue=e.value),e.state&&(this.state=e.state),this.isReadonly()&&(this.state="display"),this.draw())}validate(){var n,i,o,a;const e=this.read(),t=e==null||e===""||Array.isArray(e)&&e.length===0;return(this.options.field.required&&t?"此项必填":void 0)||this.validateValue(e)||((i=(n=this.view)==null?void 0:n.validate)==null?void 0:i.call(n))||((a=(o=this.options.hooks)==null?void 0:o.validate)==null?void 0:a.call(o,e))}commit(e="api"){var i,o;if(this.life.destroyed||this.snapshot.readonly)return!1;const t=this.validate();if(this.showValidation(t),t)return this.emit("invalid",e,{message:t}),!1;const n=this.event("commit",e,{previousValue:this.committedValue});return!this.beforeCommit(n)||((o=(i=this.options.hooks)==null?void 0:i.beforeCommit)==null?void 0:o.call(i,n))===!1?!1:(this.value=this.read(),this.committedValue=this.value,this.element.removeAttribute("aria-invalid"),this.emit("commit",e,{previousValue:n.previousValue}),this.setState("display",e),!0)}cancel(e="api"){var i,o,a,l;if(this.life.destroyed)return;const t=this.event("cancel",e);if(!this.beforeCancel(t)||((o=(i=this.options.hooks)==null?void 0:i.beforeCancel)==null?void 0:o.call(i,t))===!1)return;const n=this.event("state",e,{previousState:this.state,state:"display",value:this.committedValue});this.state!=="display"&&(!this.beforeStateChange(n)||((l=(a=this.options.hooks)==null?void 0:a.beforeStateChange)==null?void 0:l.call(a,n))===!1)||(this.value=this.committedValue,this.disposeView(),this.state="display",this.draw(),this.emit("cancel",e),n.previousState!=="display"&&this.publish(n))}edit(e="api"){var t,n;this.life.destroyed||(this.setState("editing",e),this.state==="editing"&&((n=(t=this.view)==null?void 0:t.focus)==null||n.call(t)))}setState(e,t="api"){var o,a,l,r;if(this.life.destroyed||e===this.state||e==="editing"&&this.snapshot.readonly)return;const n=this.event("state",t,{previousState:this.state});if(n.state=e,!this.beforeStateChange(n)||((a=(o=this.options.hooks)==null?void 0:o.beforeStateChange)==null?void 0:a.call(o,n))===!1)return;const i=this.state!=="editing"&&e!=="editing"&&!((l=this.options.renderers)!=null&&l.display)&&!((r=this.options.renderers)!=null&&r.hover)&&this.renderHover===Oe.prototype.renderHover;this.value=this.read(),this.state=e,i&&this.view?this.element.dataset.state=e:this.draw(),this.publish(n)}action(e,t){var i,o;if(this.life.destroyed)return;const n={type:e,value:t};(o=(i=this.options).onAction)==null||o.call(i,n),this.emit("action","api",{action:n})}destroy(){var e,t;if(!(this.life.destroyed||this.destroying)){this.destroying=!0,this.value=this.read();try{this.emit("destroy","api")}finally{try{this.disposeView()}finally{(e=this.interactions)==null||e.destroy(),this.life.destroy(),this.listeners.clear(),this.interactionListeners.clear(),(t=this.root)==null||t.remove()}}}}createEditor(){if(this.life.destroyed)throw new Error("Cannot edit a destroyed field");this.disposeView(),this.state="editing";const e=this.renderEditing(this.context());return this.view=e,this.watch(e),{...e,read:()=>this.read(),validate:()=>this.validate(),onInteraction:t=>this.onInteraction(t),destroy:()=>this.destroy()}}render(){if(this.life.destroyed)throw new Error("Cannot render a destroyed field");return this.disposeView(),this.view=this.renderDisplay(this.context()),{...this.view,destroy:()=>this.destroy()}}context(){return{...this.options,readonly:this.isReadonly(),value:this.value,onAction:e=>this.action(e.type,e.value)}}showValidation(e){var t;if(this.mounted){if(!e){this.element.removeAttribute("aria-invalid"),(t=this.feedback)==null||t.remove();return}this.feedback??(this.feedback=this.element.ownerDocument.createElement("div")),this.feedback.className="fc-error",this.feedback.setAttribute("role","status"),this.feedback.textContent=e,this.element.setAttribute("aria-invalid","true"),this.element.append(this.feedback)}}draw(){var c,p,h,u,f,g,v;if(!this.mounted||this.life.destroyed)return;const e=this.element.ownerDocument.activeElement,t=this.state==="editing"&&!!e&&(!!((c=this.view)!=null&&c.element.contains(e))||!!((h=(p=this.view)==null?void 0:p.content)!=null&&h.contains(e))),n=e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?{start:e.selectionStart,end:e.selectionEnd}:void 0;this.disposeView(),this.isReadonly()&&(this.state="display");const i=this.snapshot,o=this.options.content,a=typeof o=="function"?o(i):o??{kind:"text",text:this.value==null?"":String(this.value)},l=this.context(),r=()=>this.state==="editing"?this.renderEditing(l):o?Cn(a):this.state==="hover"?this.renderHover(l):this.renderDisplay(l),d={...i,element:this.element,field:this.options.field,content:a,renderDefault:r,input:m=>this.input(m),commit:()=>this.commit(),cancel:()=>this.cancel(),edit:()=>this.edit(),action:(m,y)=>this.action(m,y)};if(this.view=((f=(u=this.options.renderers)==null?void 0:u[this.state])==null?void 0:f.call(u,d))??r(),this.element.setAttribute("aria-label",this.options.field.label),this.element.dataset.state=this.state,this.element.dataset.readonly=String(i.readonly),this.element.replaceChildren(this.view.element),this.element.removeAttribute("aria-invalid"),this.watch(this.view),t){(v=(g=this.view).focus)==null||v.call(g);const m=this.element.ownerDocument.activeElement;if((n==null?void 0:n.start)!=null&&n.end!=null&&(m instanceof HTMLInputElement||m instanceof HTMLTextAreaElement))try{m.setSelectionRange(n.start,n.end)}catch{}}}watch(e){if(this.mounted&&this.state==="editing"){const n=()=>[this.element,e.content,this.options.focusBoundary].filter(i=>!!i);this.viewLife.add(Oi(this.element.ownerDocument,{contains:(i,o)=>n().some(a=>o.composedPath().includes(a)||!!i&&a.contains(i)||Ye(i,a)),leave:()=>{this.element.isConnected&&this.commit("user")}}))}this.interactions??(this.interactions=Fe(this.mounted?this.element:e.element,`field:${this.options.field.key}`,{onInteraction:n=>{var i,o;(o=(i=this.options).onInteraction)==null||o.call(i,n);for(const a of this.interactionListeners)a(n)}}));const t=[...new Set([e.element,e.content].filter(n=>!!n))];for(const n of t)this.viewLife.add(this.interactions.addRoot(n));for(const n of e.inputRoot?[e.inputRoot]:t)for(const i of["input","change"])this.viewLife.listen(n,i,o=>{var a;this.handled.has(o)||(this.handled.add(o),this.input(((a=e.read)==null?void 0:a.call(e))??this.value,"user",o),i==="change"&&this.emit("change","user",{originalEvent:o}))})}disposeView(){var t;this.viewLife.destroy(),this.viewLife=new je;const e=this.view;this.view=void 0,(t=e==null?void 0:e.destroy)==null||t.call(e)}event(e,t,n={}){return{...this.snapshot,type:e,source:t,...n}}emit(e,t,n={}){this.publish(this.event(e,t,n))}publish(e){var i,o,a;this.onOutput(e),(o=(i=this.options).onEvent)==null||o.call(i,e);for(const l of[...this.listeners])l(e);const t=this.mounted?this.element:(a=this.view)==null?void 0:a.element;if(!t)return;const n=t.ownerDocument.defaultView.CustomEvent;t.dispatchEvent(new n(`field:${e.type}`,{detail:e,bubbles:!0}))}}function Cn(s){if(s.kind==="node")return{element:s.node,destroy:s.destroy};const e=document.createElement("div");if(e.className=s.className??"",s.kind==="text")return e.textContent=s.text,{element:e};const t=s.children.map(Cn);return e.append(...t.map(n=>n.element)),{element:e,destroy:()=>t.forEach(n=>{var i;return(i=n.destroy)==null?void 0:i.call(n)})}}function Bi(s,e=312){s.rows=1,s.style.resize="none";const t=()=>{s.style.height="auto";const n=s.scrollHeight;n>0&&(s.style.height=Math.min(n,e)+"px"),s.style.overflowY=n>e?"auto":"hidden"};return s.addEventListener("input",t),s.addEventListener("focus",t),queueMicrotask(t),t}const Vi=s=>s==null?"":String(s);function Za(s){var t;const e=B("div",`fc-value fc-${s.className||""}`);if(s.field.kind==="richText"||s.field.kind==="richtext"||s.field.kind==="longText"||s.field.control==="richText")e.innerHTML=ft(s.value);else if(s.field.kind==="number"&&typeof s.value=="number"){const n=s.field.numberOptions;e.textContent=s.value.toLocaleString("zh-CN",{useGrouping:(n==null?void 0:n.thousandsSeparator)??!1,maximumFractionDigits:(n==null?void 0:n.decimals)??10})+((n==null?void 0:n.suffix)||""),e.classList.add("fc-plain")}else e.textContent=Vi(s.value),e.classList.add("fc-plain");return(t=e.textContent)!=null&&t.trim()||(e.textContent="待填",e.classList.add("fc-empty")),e}function Gi(s,e){const n=s==="text"&&e.layout!=="compact"?B("textarea","fc-input fc-textarea"):B("input","fc-input");if(n instanceof HTMLInputElement&&(n.type=s),n.value=Vi(e.value),n.disabled=e.readonly,n.required=!!e.field.required,n.ariaLabel=e.field.label,n.placeholder=e.field.placeholder||(e.layout!=="compact"?"待填":`请输入${e.field.label}`),e.field.maxLength!==void 0&&(n.maxLength=e.field.maxLength),s==="number"&&n instanceof HTMLInputElement){const i=e.field.numberOptions;n.step=String((i==null?void 0:i.step)??"any"),(i==null?void 0:i.min)!==void 0&&(n.min=String(i.min)),(i==null?void 0:i.max)!==void 0&&(n.max=String(i.max))}return n instanceof HTMLTextAreaElement&&Bi(n),s==="text"&&e.layout!=="compact"&&n.addEventListener("keydown",i=>{i.key==="Enter"&&(i.preventDefault(),n.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))}),{element:n,read:()=>s==="number"?n.value===""?null:Number(n.value):n.value,validate:()=>e.field.required&&!n.value.trim()?"此项必填":n.checkValidity()?void 0:n.validationMessage||"请填写有效值",focus:()=>n.focus()}}const qi=s=>!Array.isArray(s)||!s.length?[]:Array.isArray(s[0])?s.map(e=>e.map(String)):[s.map(String)];function Lt(s,e){const t=[];for(const n of e){const i=s.find(o=>o.id===n);t.push((i==null?void 0:i.label)||n),s=(i==null?void 0:i.children)||[]}return t.join(" / ")}function Qa(s){const e=B("div","fc-tags");for(const t of qi(s.value)){const n=B("span","fc-tag");n.append(B("span","fc-tag-label",Lt(Ue(s.field),t))),e.append(n)}return e.children.length||e.append(B("span","fc-empty","待填")),e}function Ja(s,e){const t=B("div","fc-cascade"),n=B("div","fc-choice-selection"),i=B("input","fc-choice-search");i.placeholder="",i.autocomplete="off",i.ariaLabel="输入以搜索"+e.field.label,i.disabled=e.readonly;const o=()=>{i.size=Math.max(1,[...i.value].length+1)};o();const a=B("div","fc-cascade-columns"),l=B("div","fc-error");l.setAttribute("role","status");const r=Ue(e.field);let d=qi(e.value),c=[];const p=[],h=(b,I,A=!1)=>b.forEach(E=>{var G;(G=E.children)!=null&&G.length?h(E.children,[...I,E.id],A||!!E.disabled):p.push({path:[...I,E.id],disabled:A||!!E.disabled})});h(r,[]);const u=(b,I)=>JSON.stringify(b)===JSON.stringify(I),f=e.layout!=="compact"&&!e.readonly;let g;const v=()=>{const b=g;g=void 0,b==null||b.close()},m=()=>{!f||g||e.readonly||(g=Rt({anchor:i.parentElement||t,content:a,width:"anchor",gap:4,onDismiss:()=>{g=void 0}}))},y=()=>{!f||!g||(v(),t.dispatchEvent(new Event("fc-collapse",{bubbles:!0})))},k=b=>{if(e.readonly)return;const I=d.findIndex(A=>u(A,b));if(s&&I>=0)d.splice(I,1);else{if(s&&e.field.maxSelections&&d.length>=e.field.maxSelections){l.textContent="最多可选择 "+e.field.maxSelections+" 项";return}d=s?[...d,b]:[b]}l.textContent="",C(),t.dispatchEvent(new Event("change",{bubbles:!0})),s||y()},C=()=>{var E,G;if(n.replaceChildren(),a.replaceChildren(),d.forEach(x=>{const M=B("span","fc-tag");M.append(B("span","fc-tag-label",Lt(r,x)));const N=B("span","fc-tag-slot"),P=B("button","fc-choice-remove","×");P.type="button",P.disabled=e.readonly,P.ariaLabel="移除"+Lt(r,x),P.onclick=()=>{d=d.filter(_=>!u(x,_)),C(),t.dispatchEvent(new Event("change",{bubbles:!0}))},N.append(P),M.append(N),n.append(M)}),i.value.trim()){const x=p.filter(M=>!M.disabled&&Lt(r,M.path).toLocaleLowerCase().includes(i.value.trim().toLocaleLowerCase()));for(const{path:M}of x){const N=B("button","fc-option",Lt(r,M));N.type="button",N.disabled=e.readonly,N.setAttribute("aria-pressed",String(d.some(P=>u(P,M)))),N.onclick=()=>k(M),a.append(N)}a.classList.add("is-search"),x.length||a.append(B("p","fc-empty","暂无匹配路径"));return}a.classList.remove("is-search");let b=r,I=[],A=0;for(;b.length;){const x=B("div","fc-cascade-column");x.setAttribute("role","group"),x.ariaLabel="第"+(A+1)+"级";for(const N of b.filter(P=>!P.disabled)){const P=[...I,N.id],_=!!((E=N.children)!=null&&E.length),L=B("button","fc-option",N.label+(_?" ›":""));L.type="button",L.disabled=e.readonly,L.classList.toggle("selected",_?c[A]===N.id:d.some(H=>u(H,P))),L.setAttribute(_?"aria-expanded":"aria-pressed",String(_?c[A]===N.id:d.some(H=>u(H,P)))),L.onclick=()=>{var H,T;_?(c=P,C(),(T=(H=a.lastElementChild)==null?void 0:H.querySelector("button"))==null||T.focus()):k(P)},x.append(L)}a.append(x);const M=b.find(N=>N.id===c[A]&&!N.disabled);if(!((G=M==null?void 0:M.children)!=null&&G.length))break;I=[...I,M.id],b=M.children,A++}r.length||a.append(B("p","fc-empty","暂无可选分类"))};if(i.oninput=()=>{o(),C()},i.onfocus=m,a.onkeydown=b=>{if(!["ArrowDown","ArrowUp","Home","End"].includes(b.key))return;const I=b.target,E=[...(I.closest(".fc-cascade-column")||a).querySelectorAll("button:not(:disabled)")];if(!E.length)return;b.preventDefault();const G=E.indexOf(I);E[b.key==="Home"?0:b.key==="End"?E.length-1:(G+(b.key==="ArrowDown"?1:-1)+E.length)%E.length].focus()},t.append(n,i,l),f){const b=B("span","fc-field-chevron");b.setAttribute("aria-hidden","true"),t.append(b),t.addEventListener("click",()=>m())}else t.append(a);return C(),{element:t,content:f?a:void 0,read:()=>s?d.map(b=>[...b]):[...d[0]||[]],focus:()=>{i.focus(),m()},deactivate:()=>{i.value="",o(),v()},destroy:()=>v(),validate:()=>e.field.required&&!d.length?"请选择分类":void 0}}const ot=s=>s==null?"":String(s),gt=s=>s.dispatchEvent(new Event("change",{bubbles:!0}));function Sn(s){try{const e=new URL(ot(s));return["http:","https:"].includes(e.protocol)?e.href:void 0}catch{return}}function Tt(s){return B("div","fc-value fc-plain fc-"+(s.className||"")+(s.value==null||s.value===""?" fc-empty":""),ot(s.value)||"待填")}function Ut(s,e){const t=e==="textarea"?B("textarea","fc-input fc-textarea"):B("input","fc-input");return t instanceof HTMLInputElement&&(t.type=e),t instanceof HTMLTextAreaElement&&Bi(t),t.value=ot(s.value),t.disabled=s.readonly,t.required=!!s.field.required,t.ariaLabel=s.field.label,t.placeholder=s.field.placeholder||"请输入"+s.field.label,s.field.maxLength!==void 0&&(t.maxLength=s.field.maxLength),{element:t,read:()=>t.value,focus:()=>t.focus(),validate:()=>e==="url"&&t.value&&!Sn(t.value)?"请输入 http 或 https 链接":t.checkValidity()?void 0:"请填写有效的"+s.field.label}}function er(s){const e=B("div","fc-link-value"),t=Sn(s.value);if(!t)return Tt(s);const n=B("a","fc-link",ot(s.value));return n.href=t,n.target="_blank",n.rel="noopener noreferrer",n.onclick=i=>i.stopPropagation(),e.append(B("span","fc-link-icon","↗"),n),e}function zi(s){let e=s.value===!0;const t=B("div","fc-switch-field"),n=B("button","fc-switch");n.type="button",n.setAttribute("role","switch"),n.ariaLabel=s.field.label,n.disabled=s.readonly;const i=B("span"),o=()=>{n.setAttribute("aria-checked",String(e)),i.textContent=e?"是":"否"};return n.onclick=()=>{s.readonly||(e=!e,o(),gt(t))},t.append(n,i),o(),{element:t,read:()=>e,focus:()=>n.focus()}}function tr(s){return zi({...s,readonly:!0}).element}function nr(s){const e=B("div","fc-signals"),t=Array.isArray(s.value)?s.value:[s.value];for(const n of t.filter(i=>i!=null&&i!=="")){const i=typeof n=="object"?n:{status:n},o=i.status??i.value,a=o===!0||o==="passed"||o==="success",l=B("span","fc-signal "+(a?"is-success":"is-pending"),(a?"● ":"○ ")+ot(i.label||i.name||(a?"已满足":o===!1?"未满足":o||"等待信号")));e.append(l)}return e.children.length||e.append(B("span","fc-empty","等待外部信号")),e}function ir(s){const e=s.value&&typeof s.value=="object"?s.value.display??s.value.value:s.value;return Tt({...s,value:e!=null&&typeof e!="object"?e:""})}function sr(s,e){const t=B("div","fc-readonly");return t.append(e(s),B("small","fc-service-note","由系统更新 · 只读")),{element:t,read:()=>s.value}}function _i(s){var f,g,v;let e=Array.isArray(s.value)?structuredClone(s.value):[];const t=B("div","fc-attachments"),n=B("div","fc-file-list"),i=B("label","fc-upload-zone","+ 上传附件"),o=B("input");o.type="file",o.multiple=!0,o.ariaLabel="上传"+s.field.label,o.accept=((f=s.field.attachmentOptions)==null?void 0:f.accept)||"",o.disabled=s.readonly||!((g=s.services)!=null&&g.upload);const a=B("p","fc-error");a.setAttribute("role","status");const l=B("button","fc-retry","重试上传");l.type="button",l.hidden=!0;let r=[],d=!1,c=!1,p;const h=()=>{n.replaceChildren(),e.forEach((m,y)=>{const k=B("div","fc-file-row"),C=Sn(m.url),b=C?B("a","fc-link",m.name):B("span","",m.name);if(b.tagName==="A"){const I=b;I.href=C,I.target="_blank",I.rel="noopener noreferrer"}if(k.append(B("span","fc-file-icon","▤"),b),m.size!=null&&k.append(B("small","fc-file-size",Math.ceil(m.size/1024)+" KB")),!s.readonly){const I=B("button","fc-file-remove","×");I.type="button",I.disabled=d,I.ariaLabel="移除"+m.name,I.onclick=()=>{e.splice(y,1),h(),gt(t)},k.append(I)}n.append(k)}),e.length||n.append(B("span","fc-empty","暂无附件"))},u=async()=>{var k;if(!((k=s.services)!=null&&k.upload)||s.readonly||d||!r.length)return;const m=s.field.attachmentOptions;if(m!=null&&m.maxFiles&&e.length+r.length>m.maxFiles){a.textContent="最多上传 "+m.maxFiles+" 个文件";return}if(m!=null&&m.maxBytes&&r.some(C=>C.size>m.maxBytes)){a.textContent="文件大小超过限制";return}const y=((m==null?void 0:m.accept)||"").split(",").map(C=>C.trim().toLowerCase()).filter(Boolean);if(y.length&&r.some(C=>!y.some(b=>b.startsWith(".")?C.name.toLowerCase().endsWith(b):b.endsWith("/*")?C.type.toLowerCase().startsWith(b.slice(0,-1)):C.type.toLowerCase()===b))){a.textContent="文件类型不符合要求";return}p=new AbortController,d=!0,o.disabled=!0,l.hidden=!0,a.textContent="上传中…",t.setAttribute("aria-busy","true"),h();try{const C=await s.services.upload(s.field,r,p.signal);if(c)return;if(C.length!==r.length||C.some(b=>!b.id||!b.name))throw new Error("Invalid file references");e=[...e,...C],r=[],a.textContent="",o.value=""}catch{c||(a.textContent="上传失败,已保留原有附件",l.hidden=!1)}finally{c||(d=!1,o.disabled=!1,t.setAttribute("aria-busy","false"),h(),r.length||gt(t))}};return o.onchange=m=>{m.stopPropagation(),r=Array.from(o.files||[]),u()},l.onclick=()=>void u(),i.append(o),t.append(n),s.readonly||(t.append(i),(v=s.services)!=null&&v.upload||t.append(B("p","fc-service-note","上传服务未接入"))),t.append(a,l),h(),{element:t,read:()=>structuredClone(e),focus:()=>o.focus(),validate:()=>d?"请等待上传完成":r.length?"请完成或重新选择上传文件":s.field.required&&!e.length?"请上传附件":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function Wi(s){if(s&&typeof s=="object"&&!Array.isArray(s)){const e=s;return{selected:Array.isArray(e.selected)?[...e.selected]:[],counts:{...e.counts},total:e.total}}return{selected:[],counts:{}}}function Ui(s,e){var u;let t=Wi(s.value),n=[...t.selected];const i=e==="attitude"?[{id:"like",label:"赞同"}]:Ue(s.field),o=B("div","fc-vote"),a=B("div","fc-vote-list"),l=B("p","fc-error");l.setAttribute("role","status");const r=B("button","fc-vote-submit","提交投票");r.type="button";let d=!1,c=!1,p;const h=()=>{var g,v;a.replaceChildren();const f=Math.max(1,...Object.values(t.counts));for(const m of i){const y=B("button","fc-vote-option");y.type="button",y.disabled=s.readonly||d||!((g=s.services)!=null&&g.vote)||!!m.disabled,y.classList.toggle("selected",n.includes(m.id)),y.setAttribute("aria-pressed",String(n.includes(m.id)));const k=B("span","fc-vote-bar");k.style.width=(t.counts[m.id]||0)/f*100+"%",y.append(k,B("span","",(e==="attitude"?"♡ ":"")+m.label),B("strong","",String(t.counts[m.id]||0))),y.onclick=()=>{n=n.includes(m.id)?n.filter(C=>C!==m.id):e==="multi"?[...n,m.id]:[m.id],h()},a.append(y)}i.length||a.append(B("p","fc-empty","暂无投票选项")),r.disabled=d||!((v=s.services)!=null&&v.vote)||!i.length,r.textContent=d?"提交中…":"提交投票"};return r.onclick=async()=>{var f;if(!(d||s.readonly||!((f=s.services)!=null&&f.vote))){d=!0,l.textContent="",p=new AbortController,o.setAttribute("aria-busy","true"),h();try{const g=await s.services.vote(s.field,n,p.signal);if(c)return;t=Wi(g),n=[...t.selected]}catch{c||(l.textContent="投票失败,请重试")}finally{c||(d=!1,o.setAttribute("aria-busy","false"),h(),l.textContent||gt(o))}}},o.append(a),s.readonly||(o.append(r),(u=s.services)!=null&&u.vote||o.append(B("p","fc-service-note","投票服务未接入"))),o.append(l),h(),{element:o,read:()=>structuredClone(t),validate:()=>d?"请等待投票完成":void 0,destroy:()=>{c=!0,p==null||p.abort()}}}function or(s){const e=s.value&&typeof s.value=="object"?s.value:{},t=B("div","fc-location"),i=[["address","地址","text"],["longitude","经度","number"],["latitude","纬度","number"]].map(([a,l,r])=>{const d=B("label","fc-location-part",l),c=B("input","fc-input");return c.type=r,c.value=ot(e[a]),c.disabled=s.readonly,c.ariaLabel=l,c.placeholder=l,r==="number"&&(c.step="any",c.min=a==="longitude"?"-180":"-90",c.max=a==="longitude"?"180":"90"),d.append(c),t.append(d),c}),o=()=>i.every(a=>!a.value)?null:{address:i[0].value,longitude:i[1].value?Number(i[1].value):null,latitude:i[2].value?Number(i[2].value):null};return{element:t,read:o,focus:()=>i[0].focus(),validate:()=>{if(!o())return s.field.required?"请填写位置":void 0;if(i.slice(1).some(a=>a.value===""||!a.checkValidity()))return"请填写有效的经纬度"}}}function ar(s){const e=s.value;return Tt({...s,value:e&&typeof e=="object"?ot(e.address)||[e.longitude,e.latitude].filter(t=>t!=null).join(", "):""})}function rr(s,e){const t=B("div","fc-composite"),n=B("div","fc-composite-rows"),i=B("button","fc-composite-add","+ 添加一组");i.type="button";const o=s.field.compositeFields||[],a=[];let l=!1;const r=u=>({...u.value,...Object.fromEntries(u.editors.map(({field:f,editor:g})=>[f.key,g.read()]))}),d=u=>{u.editors.forEach(({editor:f})=>{var g;return(g=f.destroy)==null?void 0:g.call(f)}),u.remove&&(u.remove.onclick=null),u.element.remove()},c=B("p","fc-empty","暂无记录"),p=()=>{a.forEach((u,f)=>{u.legend.textContent="第 "+(f+1)+" 组"}),i.disabled=s.readonly||!o.length||a.length>=(s.field.maxRows||100),a.length?c.remove():n.append(c)},h=u=>{const f=B("fieldset","fc-composite-row"),g=B("legend");f.append(g);const v=o.map(y=>{const k=e(y),C=k.createEditor({...s,field:y,value:u[y.key],readonly:s.readonly||y.editable===!1||!!k.readonly,focusBoundary:void 0,onSelectedOptions:I=>{var A;(A=s.services)!=null&&A.searchOptions&&(y.choices=[...new Map([...Ue(y),...I].map(E=>[E.id,E])).values()])}}),b=B("div","fc-composite-field");return b.append(B("label","",y.label+(y.required?" *":"")),C.element),f.append(b),{field:y,editor:C}}),m={value:u,element:f,legend:g,editors:v};if(!s.readonly){const y=B("button","fc-composite-remove","删除此组");y.type="button",y.onclick=()=>{if(l)return;const k=a.indexOf(m);k<0||(d(m),a.splice(k,1),p(),gt(t))},m.remove=y,f.append(y)}a.push(m),n.append(f),p()};for(const u of Array.isArray(s.value)?s.value:[])h(structuredClone(u));return i.onclick=()=>{l||i.disabled||(h({}),gt(t))},t.append(n),s.readonly||t.append(i),o.length||t.append(B("p","fc-service-note","请配置复合子字段")),p(),{element:t,read:()=>a.map(r),validate:()=>{var u;if(s.field.required&&!a.length)return"请至少添加一组";for(const[f,g]of a.entries())for(const{field:v,editor:m}of g.editors){const y=(u=m.validate)==null?void 0:u.call(m);if(y)return"第 "+(f+1)+" 组 · "+v.label+":"+y}},destroy:()=>{l||(l=!0,i.onclick=null,a.forEach(d))}}}class Xe extends Oe{renderDisplay(e){return{element:Za(e)}}renderEditing(e){return Gi("text",e)}}class ji extends Xe{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,kind:"number"}})}renderEditing(e){return Gi("number",e)}}class Ki extends Xe{renderDisplay(e){return super.renderDisplay({...e,field:{...e.field,control:"richText"}})}renderEditing(e){return Ri(e)}}class Yi extends Xe{renderDisplay(e){return{element:Tt(e)}}renderEditing(e){return Ut(e,"textarea")}}class En extends Xe{renderDisplay(e){return{element:er(e)}}renderEditing(e){return Ut(e,"url")}}class Xi extends Xe{renderEditing(e){return Ut(e,"email")}}class Zi extends Xe{renderEditing(e){return Ut(e,"tel")}}class mt extends Oe{constructor(){super(...arguments);w(this,"multiple",!1);w(this,"variant","choice")}renderDisplay(t){return{element:Na(t,this.variant==="radio"?"choice":this.variant)}}renderEditing(t){return ki(this.multiple,t,this.variant)}}class Qi extends mt{constructor(){super(...arguments);w(this,"multiple",!0)}}class Ji extends mt{constructor(){super(...arguments);w(this,"variant","radio")}}class xn extends mt{constructor(){super(...arguments);w(this,"variant","person")}}class es extends xn{constructor(){super(...arguments);w(this,"multiple",!0)}}class kn extends mt{constructor(){super(...arguments);w(this,"variant","relation")}}class ts extends kn{constructor(){super(...arguments);w(this,"multiple",!0)}}class Mn extends Oe{constructor(){super(...arguments);w(this,"multiple",!1)}renderDisplay(t){return{element:Qa(t)}}renderEditing(t){return Ja(this.multiple,t)}}class ns extends Mn{constructor(){super(...arguments);w(this,"multiple",!0)}}class Rn extends Oe{normalize(e){return e}renderDisplay(e){return{element:Ai(this.normalize(e))}}renderEditing(e){return $i(this.normalize(e))}}class Ln extends Rn{constructor(){super(...arguments);w(this,"range",!1)}normalize(t){return{...t,field:{...t.field,dateOptions:{showTime:!1,showRange:this.range,...t.field.dateOptions}}}}}class is extends Ln{constructor(){super(...arguments);w(this,"range",!0)}}class ss extends Oe{renderDisplay(e){return{element:tr(e)}}renderEditing(e){return zi(e)}}class os extends Oe{renderDisplay(e){return _i({...e,readonly:!0})}renderEditing(e){return _i(e)}}class as extends Oe{renderDisplay(e){return{element:ar(e)}}renderEditing(e){return or(e)}}class jt extends Oe{constructor(){super(...arguments);w(this,"mode","attitude")}renderDisplay(t){return Ui({...t,readonly:!0},this.mode)}renderEditing(t){return Ui(t,this.mode)}}class rs extends jt{constructor(){super(...arguments);w(this,"mode","single")}}class ls extends jt{constructor(){super(...arguments);w(this,"mode","multi")}}class vt extends Oe{isReadonly(){return!0}constructor(e){super({...e,readonly:!0})}renderDisplay(e){return{element:ir(e)}}renderEditing(e){return sr(e,t=>this.renderDisplay(t).element)}}class Tn extends vt{renderDisplay(e){return{element:nr(e)}}}class ds extends Xe{renderDisplay(e){const t=document.createElement("button");return t.type="button",t.className="fc-detail-link",t.textContent=e.field.label,t.onclick=n=>{var i;n.stopPropagation(),(i=e.onAction)==null||i.call(e,{type:"open",value:e.value})},{element:t,destroy:()=>{t.onclick=null}}}}class cs extends Oe{constructor(e,t){super(e),this.resolve=t}renderDisplay(e){var i;if(e.layout==="compact")return{element:Tt({...e,value:Array.isArray(e.value)&&e.value.length?e.value.length+" 组记录":""})};const t=document.createElement("div");t.className="fc-composite";const n=[];for(const o of Array.isArray(e.value)?e.value:[]){const a=document.createElement("fieldset");a.className="fc-composite-row";for(const l of e.field.compositeFields??[]){const r=document.createElement("label");r.textContent=l.label;const d={...e,field:l,value:o[l.key],readonly:!0},c=this.resolve(l),p=((i=c.renderView)==null?void 0:i.call(c,d))??{element:c.render(d)};n.push(p),a.append(r,p.element)}t.append(a)}return{element:t,destroy:()=>n.forEach(o=>{var a;return(a=o.destroy)==null?void 0:a.call(o)})}}renderEditing(e){return rr(e,this.resolve)}}const lr={textarea:"保留换行的纯文本,支持长度限制",radio:"平铺选项,一次选择一项",cascadeSingle:"逐级浏览分类,选择完整路径",cascadeMulti:"逐级浏览并选择多条路径",person:"按姓名搜索,以稳定人员 ID 保存",multiPerson:"按姓名搜索,以稳定人员 ID 保存",date:"日历选择和直接输入,支持清空",dateRange:"连续选择起止日期,校验完整范围",url:"填写网址并在新窗口安全打开",cloudDocument:"添加云文档链接,点击打开原文档",email:"邮箱输入与格式校验",phone:"支持国家区号的电话输入",switch:"以是或否记录布尔状态",attachment:"文件列表、上传与删除,支持上传失败重试",location:"填写地址和经纬度,校验坐标边界",relation:"按名称或编号搜索工作项,点击名称打开详情",multiRelation:"按名称或编号搜索工作项,点击名称打开详情",attitudeVote:"选择并提交投票,结果以宿主服务回读为准",singleVote:"选择并提交投票,结果以宿主服务回读为准",multiVote:"选择并提交投票,结果以宿主服务回读为准",externalSignal:"由外部系统更新,系统内只读",externalMultiSignal:"由外部系统更新,系统内只读",formula:"展示服务端计算结果,不可手工覆盖",aggregate:"展示服务端计算结果,不可手工覆盖",ai:"展示服务端计算结果,不可手工覆盖",system:"展示服务端计算结果,不可手工覆盖",composite:"可重复字段组,复用已注册子控件并逐组校验",multiPersonComposite:"可重复字段组,复用已注册子控件并逐组校验",text:"单行输入,支持清空和必填校验",richText:"紧凑编辑与全屏排版,支持标题、颜色、列表、表格和链接",select:"从字段配置中选择一个选项",multiSelect:"点击标签选择多项,保存为数组",number:"支持小数和负数,空值与零分别保存",dateTime:"日历、时间与日期范围",detail:"由调用方处理关联内容导航"},dr={title:"text",longText:"richText",status:"select",richtext:"richText",single_select:"select",multi_select:"multiSelect",user:"person",multi_user:"multiPerson",multi_person:"multiPerson",cascade_select:"cascadeSingle",cascade_single:"cascadeSingle",cascade_multi:"cascadeMulti",daterange:"dateRange",date_range:"dateRange",datetime:"dateTime",multi_relation:"multiRelation",attitude_vote:"attitudeVote",single_vote:"singleVote",multi_vote:"multiVote",vote:"attitudeVote",external_signal:"externalSignal",external_multi_signal:"externalMultiSignal",multi_person_composite:"multiPersonComposite",cloud_document:"cloudDocument"},cr=[["text","单行文本",Xe,"文本","T"],["richText","富文本",Ki,"文本","¶"],["select","单选",mt,"选择","◉"],["multiSelect","多选",Qi,"选择","☑"],["number","数字",ji,"其他","#"],["dateTime","日期时间",Rn,"日期","◷"],["detail","详情页查看",ds,"关联工作项","↗"],["textarea","多行文本",Yi,"文本","≡"],["radio","单选按钮",Ji,"选择","◉"],["cascadeSingle","级联单选",Mn,"选择","⑂"],["cascadeMulti","级联多选",ns,"选择","⑂"],["person","单选人员",xn,"人员","♙"],["multiPerson","多选人员",es,"人员","♙"],["date","日期",Ln,"日期","▦"],["dateRange","日期区间",is,"日期","▦"],["url","URL 链接",En,"其他","↗"],["cloudDocument","关联云文档",En,"其他","▤"],["email","邮箱",Xi,"其他","@"],["phone","电话",Zi,"其他","☎"],["switch","开关",ss,"其他","◐"],["attachment","附件",os,"其他","⌑"],["location","地理位置",as,"其他","⌖"],["relation","单选关联工作项",kn,"关联工作项","↗"],["multiRelation","多选关联工作项",ts,"关联工作项","↗"],["attitudeVote","表态投票",jt,"投票","♡"],["singleVote","单选投票",rs,"投票","♡"],["multiVote","多选投票",ls,"投票","♡"],["externalSignal","系统外信号",Tn,"系统","◌",!0],["externalMultiSignal","多值系统外信号",Tn,"系统","◌",!0],["formula","公式计算",vt,"系统","ƒ",!0],["aggregate","聚合计算",vt,"系统","ƒ",!0],["ai","AI 字段",vt,"系统","ƒ",!0],["system","系统字段",vt,"系统","ƒ",!0]];function us(s=[]){const e=new Map,t=a=>{if(!/^[A-Za-z][\w-]*$/.test(a.id))throw new Error("Invalid control id");if(e.has(a.id))throw new Error(`Control already registered: ${a.id}`);e.set(a.id,a)},n=a=>{const l=a.control||dr[a.kind||"text"]||a.kind||"text",r=e.get(l);if(!r)throw new Error(`Unknown control: ${l}`);return r},i=a=>n(a.field).create(a),o=a=>{const l=n(a);return{...l,render:r=>l.create(r).render().element,renderView:r=>l.create(r).render(),createEditor:r=>l.create(r).createEditor()}};for(const[a,l,r,d,c,p]of cr)t({id:a,label:l,description:lr[a]||l,glyph:c,group:d,readonly:p,action:a==="detail"?"view":a==="select"||a==="multiSelect"?"select":void 0,create:h=>new r({...h,readonly:p||h.readonly})});for(const[a,l]of[["composite","复合字段"],["multiPersonComposite","多人复合字段"]])t({id:a,label:l,description:"组合多个已注册字段",glyph:"▦",group:"其他",create:r=>new cs(r,o)});return s.forEach(t),{register:t,resolve:n,create:i,list:()=>[...e.values()]}}class Nn extends Oe{constructor(e,t){super(e),this.control=t}renderDisplay(e){return{element:this.control.render(e)}}renderEditing(e){return this.control.createEditor(e)}}const nt={page(s){return s.page||(s.surface==="cell"?"table":"basic")},render(s,e){const t=B("div","fc-base-control"),n=nt.page(s);return t.dataset.page=n,t.dataset.mode=s.mode||"default",t.dataset.editable=String(s.canEdit??!s.readonly),t.dataset.readonly=String(s.readonly),t.setAttribute("data-field-control",s.field.control||s.field.kind||"text"),t.append(e),t}},ur=new Set(["select","multiSelect","person","multiPerson","relation","multiRelation","cascadeSingle","cascadeMulti","date","dateRange","dateTime","detail","composite","multiPersonComposite"]);function Nt(s){return s.id==="richText"?"rich":ur.has(s.id)?"select":"text"}function hs(s,e,t){if(nt.page(e)==="table"||e.readonly||s.readonly||e.canEdit===!1)return t;const n=document.createElement("div");n.className="fc-base-control fc-focus-editor",n.dataset.expanded="true",n.tabIndex=-1;const i=nt.page(e);n.dataset.page=i,n.dataset.mode=i==="table"?"editing":"expanded",n.dataset.controlKey=s.id,n.dataset.box=Nt(s);const o=document.createElement("div");o.className="fc-focus-body",o.dataset.box=Nt(s),o.append(t.element);const a=document.createElement("div");a.className="fc-focus-trigger",a.tabIndex=0,a.setAttribute("role","button"),a.ariaLabel="编辑"+e.field.label,a.setAttribute("aria-expanded","true"),a.hidden=!0;const l=document.createElement("span");l.className="fc-error fc-focus-error",l.setAttribute("role","status"),n.append(o,a,l);const r=n.ownerDocument,d=e.focusBoundary||n,c=m=>!!m&&(d.contains(m)||Ye(m,n));let p=!1;const h=()=>{p||(o.hidden=!1,a.hidden=!0,n.dataset.expanded="true",n.dataset.mode="editing",a.setAttribute("aria-expanded","true"),l.textContent="",t.focus&&t.focus(),!o.contains(r.activeElement)&&!Ye(r.activeElement,n)&&(Array.from(o.querySelectorAll('input:not([type=hidden]):not(:disabled),textarea:not(:disabled),[contenteditable=true],button:not(:disabled),[tabindex="0"]')).find(y=>!y.closest("[hidden]"))||n).focus())},u=()=>{var C,b,I;if(p||!n.isConnected||n.dataset.expanded==="false")return;const m=(C=t.validate)==null?void 0:C.call(t),y={...e,readonly:!0,canEdit:!1,mode:"default",value:m?e.value:t.read()},k=nt.render(y,s.render(y));k.inert=!0,a.replaceChildren(k),l.textContent=m?"尚未保存:"+m:"",(b=t.deactivate)==null||b.call(t),n.dataset.expanded="false",n.dataset.mode="default",o.hidden=!0,a.hidden=!1,a.setAttribute("aria-expanded","false"),(I=e.onDeactivate)==null||I.call(e)},f=m=>{if(m.relatedTarget instanceof Node&&c(m.relatedTarget))return;const y=m.target;queueMicrotask(()=>{p||!n.isConnected||c(r.activeElement)||(y&&!y.isConnected&&r.activeElement===r.body?n.focus():u())})},g=()=>{queueMicrotask(()=>{!p&&n.isConnected&&n.dataset.expanded==="true"&&(!r.activeElement||r.activeElement===r.body)&&n.focus()})};a.onclick=m=>{m.stopPropagation(),h()},a.onkeydown=m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),m.stopPropagation(),h())},d.addEventListener("focusout",f),n.addEventListener("click",g,!0),n.addEventListener("fc-collapse",u);const v=Oi(r,{contains:(m,y)=>y.composedPath().includes(d)||c(m),leave:u});return{...t,element:n,focus:h,destroy:()=>{var m;p||(p=!0,v(),d.removeEventListener("focusout",f),n.removeEventListener("click",g,!0),n.removeEventListener("fc-collapse",u),(m=t.destroy)==null||m.call(t))}}}function In(s){return{...s,context:s,layout:nt.page(s)==="table"?"compact":"form",className:s.surface,services:s.services?{searchOptions:s.services.searchOptions,upload:s.services.upload,vote:s.services.vote?(e,t,n)=>s.services.vote(e,s.item,t,n):void 0}:void 0,onAction:e=>{e.type==="open"&&s.openDetail(String(e.value||s.item.id))}}}function ps(s=[]){const e=us(),t=new Map;for(const i of e.list()){const o={...i,render(a){const l=e.create(In(a));return nt.render(a,l.render().element)},createEditor(a){const l=e.create(In(a));return hs(o,a,l.createEditor())}};t.set(i.id,o)}const n=i=>{e.register({...i,create:a=>new Nn(a,{render:l=>i.render({...l.context,field:l.field,value:l.value,readonly:l.readonly}),createEditor:l=>i.createEditor({...l.context,field:l.field,value:l.value,readonly:l.readonly})})});const o={...i,render:a=>nt.render(a,i.render(a)),createEditor(a){const l=new Nn(In(a),{render:r=>i.render({...a,value:r.value}),createEditor:r=>i.createEditor({...a,value:r.value})});return hs(i,a,l.createEditor())}};t.set(i.id,o)};return s.forEach(n),{register:n,list:()=>[...t.values()],resolve:i=>t.get(e.resolve(i).id)}}function hr(s,e){const t=e[s.field],n=s.value,i=Array.isArray(t)?t.map(String):t==null||t===""?[]:[String(t)];switch(s.op){case"equals":return Array.isArray(t)?i.includes(String(n)):String(t??"")===String(n??"");case"notEqual":return Array.isArray(t)?!i.includes(String(n)):String(t??"")!==String(n??"");case"contains":return i.some(o=>o.includes(String(n??"")));case"notContains":return!i.some(o=>o.includes(String(n??"")));case"in":return(Array.isArray(n)?n.map(String):[String(n??"")]).some(o=>i.includes(o));case"notIn":return!(Array.isArray(n)?n.map(String):[String(n??"")]).some(o=>i.includes(o));case"blank":return i.length===0;case"notBlank":return i.length>0;default:return!0}}function Be(s,e,t={}){return s?"all"in s?s.all.every(n=>Be(n,e,t)):"any"in s?s.any.some(n=>Be(n,e,t)):"not"in s?!Be(s.not,e,t):hr(s,e):!0}function at(s,e={}){var t,n,i,o,a,l;return!s||s.all||(t=s.members)!=null&&t.length&&s.members.includes(e.currentUser||"")||(n=s.teams)!=null&&n.length&&(e.teams||[]).some(r=>s.teams.includes(r))||(i=s.roles)!=null&&i.length&&(e.roles||[]).some(r=>s.roles.includes(r))?!0:!((o=s.members)!=null&&o.length||(a=s.teams)!=null&&a.length||(l=s.roles)!=null&&l.length)}const pr={empty:"待填",required:"此项必填",simpleMode:"简洁模式",continuous:"连续创建",cancel:"取消",draft:"存草稿",submit:"确认创建",addRole:"添加角色",addMeeting:"添加一组进入选题会"};function fs(s){return s.items!==void 0}function fr(s,e={}){var le;const t=s.variant,n=s.presentation||(t==="create"?"modal":"drawer"),i={...pr,...s.labels},o=e.controls||ps(),a=s.events||{},l={...s.data||{}};let r={...s.context||{}},d=s.fields.map(S=>({...S})),c=(s.tabs||[]).map(S=>({...S})),p=s.items?[...s.items]:d.map(S=>({field:S.key})),h=s.blocks?[...s.blocks]:[],u=s.actions?[...s.actions]:C();const f=t==="create"?"new":"detail";let g=s.fieldState||"display",v=s.simpleMode??!1;const m=s.simpleKeep&&s.simpleKeep.length?new Set(s.simpleKeep):new Set(d.slice(0,1).map(S=>S.key));let y=s.open??!0,k=!1;function C(){return t==="create"?[{id:"continuous",kind:"checkbox",label:i.continuous},{id:"close-overlay",label:i.cancel,variant:"outline"},{id:"save-draft",label:i.draft,variant:"outline"},{id:"submit",kind:"submit",label:i.submit,variant:"primary"}]:[]}const b=S=>d.find(V=>V.key===S);function I(S,V,oe){var O,q,K;const ce=Be(S.visibleWhen,l,r)&&at((O=S.permission)==null?void 0:O.view,r)&&(!V||Be(V.visibleWhen,l,r))&&(!oe||Be(oe.visibleWhen,l,r)&&at(oe.visibleScope,r))&&(t!=="create"||S.createVisible!==!1),xe=!!S.required||(S.requiredWhen?Be(S.requiredWhen,l,r):!1)||(V!=null&&V.requiredWhen?Be(V.requiredWhen,l,r):!1)||((q=S.permission)!=null&&q.required?at(S.permission.required,r):!1),F=S.editable!==!1&&at((K=S.permission)==null?void 0:K.edit,r);return{visible:ce,required:!!xe,editable:F}}function A(S){if(l[S.key]===void 0&&(S.defaultMode==="always"&&S.defaultValue!==void 0&&(l[S.key]=S.defaultValue),S.defaultMode==="conditional")){for(const V of S.defaultWhen||[])if(Be(V.when,l,r)){l[S.key]=V.value;return}}}const E=document.createElement(t==="create"?"form":"article");t==="create"&&(E.noValidate=!0);const G=Fe(E,"form-surface",s);E.className=t==="create"?"rowvia-work-items rowvia-field-scope create-dialog form-surface":`rowvia-work-items rowvia-field-scope drawer form-surface${n==="fullscreen"?" is-fullscreen":""}`,E.dataset.variant=t,E.dataset.presentation=n,E.dataset.fieldState=g;let x=[];function M(){var xe,F,O,q,K,ne;for(const Q of x)Q.destroy();x=[],E.innerHTML="";const S=document.createElement("div");if(S.className="drawer-header",(xe=s.slots)!=null&&xe.leading){const Q=document.createElement("div");Q.className="drawer-leading",N(Q,s.slots.leading),S.append(Q)}if(S.insertAdjacentHTML("beforeend",`<span class="page-logo">${Re("check")}</span><strong>${D(s.title||"")}</strong>`),(F=s.slots)!=null&&F.header&&N(S,s.slots.header),E.append(S),(O=s.slots)!=null&&O.subHeader){const Q=document.createElement("div");Q.className="detail-sub-header",N(Q,s.slots.subHeader),E.append(Q)}if((q=s.slots)!=null&&q.navigation){const Q=document.createElement("div");Q.className="detail-navigation",N(Q,s.slots.navigation),E.append(Q)}const V=L();if(t==="detail"&&V.length){const Q=document.createElement("div");Q.className="detail-tabs",Q.setAttribute("role","tablist");for(const re of V){const J=document.createElement("button");J.type="button",J.className=`detail-tab${re.id===H?" active":""}`,J.dataset.tabId=re.id,J.dataset.detailTab=re.label,J.setAttribute("role","tab"),J.setAttribute("aria-selected",String(re.id===H)),J.textContent=re.label,J.onclick=()=>se(re.id),Q.append(J)}const de=document.createElement("div");de.className="spacer",Q.append(de),(K=s.slots)!=null&&K.tabSuffix&&N(Q,s.slots.tabSuffix),E.append(Q)}const oe=document.createElement("div");oe.className=t==="create"?"create-body":"drawer-body",t==="create"&&s.simpleMode!==void 0&&oe.append(P());const ce=V.find(Q=>Q.id===H);if(oe.append(T(ce)),E.append(oe),(ne=s.slots)!=null&&ne.footer){const Q=document.createElement("div");Q.className="form-surface-slot-footer",N(Q,s.slots.footer),E.append(Q)}u.length&&E.append(_()),t==="create"&&(E.onsubmit=Q=>{var re,J;if(Q.preventDefault(),k)return;const de=Ee();if(de){(re=a.onInvalid)==null||re.call(a,de);return}(J=a.onSubmit)==null||J.call(a,me())})}function N(S,V){typeof V=="string"?S.insertAdjacentHTML("beforeend",V):S.append(V)}function P(){const S=document.createElement("div");return S.className="simple-mode",S.innerHTML=`<label><input type="checkbox" id="simple-mode"${v?" checked":""}>${D(i.simpleMode)}</label>`,S.querySelector("input").onchange=V=>X(V.target.checked),S}function _(){const S=document.createElement("div");S.className=t==="create"?"drawer-footer":"drawer-footer form-surface-actions";for(const V of u){if(!Be(V.visibleWhen,l,r))continue;if(V.kind==="checkbox"){const ce=document.createElement("label");ce.className="continuous",ce.innerHTML=`<input id="${D(V.id)}" type="checkbox"${V.checked?" checked":""}>${D(V.label||"")}`,S.append(ce);continue}if(V.kind==="submit"){const ce=document.createElement("button");ce.type="submit",ce.className=V.variant||"primary",ce.dataset.action=V.id,ce.textContent=V.label||i.submit,S.append(ce);continue}S.insertAdjacentHTML("beforeend",Ne(V.id,V.label||"",V.glyph||"",V.variant||""));const oe=S.lastElementChild;oe.onclick=()=>{var ce;k||S.parentElement!==E||oe.disabled||((V.id==="close-overlay"||V.id==="cancel")&&a.onCancel?a.onCancel():V.id==="save-draft"&&a.onSaveDraft?a.onSaveDraft(me()):(ce=a.onAction)==null||ce.call(a,V.id,me()))}}return S}function L(){return c.filter(V=>Be(V.visibleWhen,l,r)&&at(V.visibleScope,r)).map((V,oe)=>({...V,order:V.order??oe})).sort((V,oe)=>V.order-oe.order)}let H=s.defaultTab||((le=c[0])==null?void 0:le.id);function T(S){var F;const V={data:l,context:r,variant:t,tab:S},oe=document.createElement("div");if(oe.className=t==="create"?"form-surface-body":"detail-fields form-surface-body",!S||S.kind==="form"){const O=(S==null?void 0:S.items)??p;for(const K of O){const ne=R(K,V);ne&&oe.append(ne)}const q=(S==null?void 0:S.blocks)??h;for(const K of q){const ne=j(K,V);ne&&oe.append(ne)}return oe}const ce=S.kind==="custom"?S.render:((F=e.renderers)==null?void 0:F[S.kind])||S.render,xe=ce?ce(V):"";return typeof xe=="string"?oe.innerHTML=xe:xe&&oe.append(xe),oe}function R(S,V){if("field"in S)return z(S);const oe=fs(S)?$(S,V):j(S,V);return oe&&S.span!==1&&!(fs(S)&&S.layoutRole==="column")&&(oe.style.gridColumn="1 / -1"),oe}function $(S,V){var O;const oe=Be(S.visibleWhen,l,r),ce=S.layoutRole==="column";if(!oe&&!ce)return null;const xe=[];for(const q of oe?S.items:[]){const K=R(q,V);K&&xe.push(K)}if(!ce&&!xe.some(q=>q.dataset.layoutRole!=="column"||q.childElementCount>0))return null;const F=document.createElement("section");if(F.className="form-group",F.dataset.group=S.id,ce)return F.className="form-layout-column",F.dataset.layoutRole="column",F.append(...xe),F;if(S.columns===2&&!v){F.classList.add("form-group--columns");const q=((O=S.columnRatio)==null?void 0:O.length)===2&&S.columnRatio.every(K=>Number.isFinite(K)&&K>0)?S.columnRatio:[1,1];F.style.display="grid",F.style.gridTemplateColumns=q.map(K=>`minmax(0, ${K}fr)`).join(" "),F.style.columnGap="24px"}return F.innerHTML=`<p class="form-group-title">${D(S.label)}</p>`,F.firstElementChild.style.gridColumn="1 / -1",F.append(...xe),F}function z(S){var K;const V=b(S.field);if(!V)return null;const oe=I(V,S,he());if(!oe.visible||v&&!m.has(V.key))return null;A(V);const ce=document.createElement("div");ce.className=t==="create"?"create-field":"detail-row",ce.dataset.field=V.key,S.span===2&&(ce.classList.add("span-2"),ce.style.gridColumn="1 / -1"),(S.labelPosition||((K=s.layout)==null?void 0:K.labelPosition)||"side")==="top"&&ce.classList.add("label-top");const F=oe.required,O=t==="create"?"<em>*</em>":" *";ce.innerHTML=`<label for="${f}-${D(V.key)}">${D(V.label)}${F?O:""}</label><div class="field-value"><div class="fc-host" data-control-field="${D(V.key)}" data-control-mode="${t}"></div>`+(V.description?`<small class="field-description">${D(V.description)}</small>`:"")+"</div>";const q=ce.querySelector(".fc-host");return be(q,{...V,required:F},F),ce}function j(S,V){var xe;if(!Be(S.visibleWhen,l,r)||v&&!m.has(S.id))return null;const oe=(xe=e.renderers)!=null&&xe.block?e.renderers.block({...V,block:S}):S.render?S.render(V):te(S,V),ce=document.createElement("div");return ce.className=`form-surface-block block-${S.kind}`,ce.dataset.block=S.id,typeof oe=="string"?ce.innerHTML=oe:oe&&ce.append(oe),ce}function te(S,V){var oe,ce;if(S.kind==="roles"){const xe=document.createElement("div");xe.className=t==="create"?"create-field":"detail-row",xe.innerHTML=`<label>${D(S.label||"角色与人员")}${(oe=S.requiredRoles)!=null&&oe.length?"<em>*</em>":""}</label><div class="role-body"><div class="role-rows"></div><div class="role-actions">${Ne("add-role",i.addRole,"","outline")}</div></div>`;const F=xe.querySelector(".role-rows"),O=(ce=S.roleOptions)!=null&&ce.length?S.roleOptions:["提报人"],q=S.people??[],K=()=>{const de=Array.isArray(l.roles)?l.roles:[];return de.length||de.push({name:O[0],person:String(l.owner??V.context.currentUser??"")}),l.roles=de,de};let ne=[];const Q=()=>{for(const re of ne)re.destroy(),x=x.filter(J=>J!==re);ne=[],F.replaceChildren();const de=K();de.forEach((re,J)=>{const ae=document.createElement("div");ae.className="role-line";const ie=document.createElement("div");ie.className="fc-host role-select";const ue=document.createElement("div");if(ue.className="fc-host role-person",ae.append(ie,ue),de.length>1){const pe=document.createElement("button");pe.type="button",pe.className="role-remove",pe.dataset.roleRemove=String(J),pe.setAttribute("aria-label","移除角色"),pe.textContent="×",ae.append(pe)}F.append(ae),ne.push(be(ie,{key:`role-${J}`,label:"角色",kind:"select",options:O,editable:!0},!1,{get:()=>re.name,set:pe=>{re.name=String(pe??"")},notify:()=>{var pe;return(pe=a.onCommit)==null?void 0:pe.call(a,"roles",K(),l)}}),be(ue,{key:`role-person-${J}`,label:"人员",kind:"person",options:q.map(pe=>pe.id),choices:q,editable:!0},()=>{var pe;return!!((pe=S.requiredRoles)!=null&&pe.includes(re.name))},{get:()=>re.person,set:pe=>{re.person=String(pe??"")},notify:()=>{var pe,ve;J===0&&(l.owner=re.person,(pe=a.onCommit)==null||pe.call(a,"owner",re.person,l)),(ve=a.onCommit)==null||ve.call(a,"roles",K(),l)}}))})};return Q(),xe.addEventListener("click",de=>{var ae,ie,ue;const re=de.target,J=re.closest("[data-role-remove]");if(J){const pe=K();pe.splice(Number(J.dataset.roleRemove),1),pe.length||pe.push({name:O[0],person:""}),l.owner=((ae=pe[0])==null?void 0:ae.person)??"",Q(),(ie=a.onChange)==null||ie.call(a,"roles",pe,l);return}if(re.closest('[data-action="add-role"]')){const pe=K();pe.push({name:O.find(ve=>!pe.some(ke=>ke.name===ve))??O[0],person:""}),Q(),(ue=a.onChange)==null||ue.call(a,"roles",pe,l)}}),xe}if(S.kind==="meetings"){const xe=document.createElement("section");return xe.className="detail-section",xe.innerHTML=`<p>${D(S.label||"进入选题会")}</p><div class="meeting-table"><div>选题会<span>提报人</span><span>操作</span></div><div class="meeting-rows"></div>${Ne("add-meeting",i.addMeeting,"add")}</div>`,xe}return""}function he(){return L().find(S=>S.id===H)}function ge(S,V,oe){return{field:S,value:oe?oe.get():l[S.key]??S.defaultValue??"",item:l,surface:t==="create"?"create":"detail",page:"basic",mode:"default",canEdit:V,readonly:!V,services:e.services,onSelectedOptions:xe=>{(O=>{O.choices=[...new Map([...O.choices||(O.options||[]).map(q=>({id:q,label:q})),...xe].map(q=>[q.id,q])).values()]})(S)},openDetail:xe=>{var F;return(F=a.onOpenDetail)==null?void 0:F.call(a,xe)}}}function be(S,V,oe,ce){var At;const xe=()=>typeof oe=="function"?oe():oe,F=V.editable!==!1&&at((At=V.permission)==null?void 0:At.edit,r),O=ge(V,F,ce),q=o.resolve(V),K=q.createEditor(O),ne="input,select,textarea,[role=textbox]",Q=[K.content,K.element].filter(ee=>!!ee).map(ee=>ee.matches(ne)?ee:ee.querySelector(ne)).find(Boolean);Q&&(Q.id=`${f}-${V.key}`);const de=document.createElement("div");de.className="fc-error",de.setAttribute("role","status");const re=document.createElement("div");re.className="fc-detail-editor",re.dataset.mode="editing",re.dataset.box=Nt(q),re.append(K.element),S.classList.add("fc-detail-host"),S.dataset.page="basic",S.dataset.mode="default",S.dataset.surface=t==="create"?"create":"detail",S.append(re,de);const J=document.createElement("div");J.className="fc-detail-preview",J.dataset.box=Nt(q),J.dataset.editable=String(F),J.dataset.surface=t==="create"?"create":"detail",S.prepend(J);const ae=()=>{if(!S.classList.contains("editing")){S.style.minHeight="";return}S.style.minHeight=`${re.offsetHeight}px`},ie=ee=>{re.style.minHeight=`${ee}px`,re.style.maxHeight=`${ee}px`},ue=()=>{re.style.maxHeight="",ae()},pe=Nt(q)==="rich",ve=()=>{var Ce,it;if(!F||S.classList.contains("editing"))return;const ee=J.offsetHeight;S.classList.add("editing"),S.dataset.mode="editing",pe||ie(ee),ae(),(Ce=K.focus)==null||Ce.call(K),(it=a.onFieldStateChange)==null||it.call(a,V.key,"edit")},ke=()=>{if(J.replaceChildren(q.render({...ge(V,F,ce),readonly:!0,canEdit:!1,mode:"default",value:ce?ce.get():l[V.key]??""})),J.dataset.box==="select"){const ee=document.createElement("span");ee.className="fc-field-chevron",ee.setAttribute("aria-hidden","true"),J.append(ee)}if(F){J.tabIndex=0,J.setAttribute("role","button"),J.setAttribute("aria-label",`编辑${V.label}`),J.onclick=Ce=>{Ce.target.closest("a,button,input,textarea,select")||ve()},J.onkeydown=Ce=>{(Ce.key==="Enter"||Ce.key===" ")&&(Ce.preventDefault(),ve())};const ee=document.createElement("button");ee.type="button",ee.className="fc-detail-edit",ee.tabIndex=-1,ee.textContent="编辑",ee.ariaLabel=`编辑${V.label}`,ee.onclick=Ce=>{Ce.stopPropagation(),ve()},J.append(ee)}else J.removeAttribute("role"),J.removeAttribute("tabindex"),J.onclick=null,J.onkeydown=null};ke();const we=()=>{var Ce;const ee=xe()&&!fe(K.read())?i.required:(Ce=K.validate)==null?void 0:Ce.call(K);return de.textContent=ee||"",S.classList.toggle("is-error",!!ee),ee},Le=()=>{var Ce,it,Kt;if(!F)return!0;const ee=we();if(ee&&ue(),!ee){const yt=K.read(),yr=ce?ce.get():l[V.key];JSON.stringify(yr)!==JSON.stringify(yt)&&(ce?(ce.set(yt),(Ce=ce.notify)==null||Ce.call(ce,yt)):(l[V.key]=yt,(it=a.onCommit)==null||it.call(a,V.key,yt,l))),(Kt=a.onChange)==null||Kt.call(a,V.key,yt,l),ke()}return!ee},wt=()=>{var ee;S.classList.remove("editing"),S.dataset.mode="default",S.style.minHeight="",re.style.minHeight="",re.style.maxHeight="",(ee=a.onFieldStateChange)==null||ee.call(a,V.key,"display")};S.addEventListener("input",()=>{var ee;ue(),(ee=a.onChange)==null||ee.call(a,V.key,K.read(),l)}),S.addEventListener("pointerdown",()=>{S.classList.contains("editing")&&ue()},!0),S.addEventListener("mousedown",ee=>{var Ce;q.id!=="richText"||!S.classList.contains("editing")||ee.target.closest("button,a,input,textarea,select,[contenteditable=true]")||(ee.preventDefault(),!S.contains(document.activeElement)&&!Ye(document.activeElement,S)&&((Ce=K.focus)==null||Ce.call(K)))}),S.addEventListener("change",()=>{ue(),Le()}),S.addEventListener("fc-collapse",()=>{Le(),wt(),ke()}),S.addEventListener("focusout",ee=>{ee.relatedTarget instanceof Node&&(S.contains(ee.relatedTarget)||Ye(ee.relatedTarget,S))||queueMicrotask(()=>{if(!(k||!S.isConnected)){if(S.contains(document.activeElement)||Ye(document.activeElement,S)){ae();return}Le(),wt(),ke()}})}),(V.defaultState||g)==="edit"&&F&&queueMicrotask(()=>{k||ve()});const It={key:V.key,host:S,editor:K,editable:F,check:we,commit:Le,beginEdit:ve,write:ee=>{ce?ce.set(ee):l[V.key]=ee},destroy:()=>{var ee;return(ee=K.destroy)==null?void 0:ee.call(K)}};return x.push(It),It}const fe=S=>Array.isArray(S)?S.length>0:S!=null&&String(S).trim()!=="";function me(){for(const S of x)S.editable&&S.write(S.editor.read());return{...l}}function Ee(){let S;for(const V of x){if(!V.editable)continue;const oe=V.check();oe&&S===void 0&&(S=oe,V.beginEdit())}return S}function Me(S){y=S,E.hidden=!S,E.dataset.open=String(S)}function U(S){g=S,E.dataset.fieldState=S;for(const V of x)S==="edit"?V.beginEdit():V.host.dispatchEvent(new Event("fc-collapse",{bubbles:!0}))}function se(S){var oe;if(S===H||!L().some(ce=>ce.id===S))return;H=S;const V=he();M(),V&&((oe=a.onTabChange)==null||oe.call(a,S,V))}function X(S){me(),v=S,M()}function W(S){S.data&&Object.assign(l,S.data),S.fields&&(d=S.fields.map(V=>({...V}))),S.tabs&&(c=S.tabs.map(V=>({...V}))),S.items&&(p=[...S.items]),S.blocks&&(h=[...S.blocks]),S.actions&&(u=[...S.actions]),S.context&&(r={...S.context}),M()}function Z(){var S;if(!k){k=!0,(S=a.onDestroy)==null||S.call(a),G.destroy(),E.onsubmit=null;for(const V of x)V.destroy();x=[],E.remove()}}return M(),Me(y),{element:E,onInteraction:G.onInteraction,read:me,validate:Ee,setOpen:Me,setFieldState:U,setTab:se,setSimpleMode:X,activeTab:()=>H,update:W,destroy:Z}}function gr(s){const e=B("div",s.className??"tag");return s.marker?e.append(s.marker):s.markerClassName&&e.append(B("span",s.markerClassName)),e.append(B("span","",s.label)),e}function mr(s){const e=B("div",s.className);if(s.leading)e.append(s.leading);else if(s.image){const n=B("img");n.src=s.image.src,n.alt=s.image.alt,e.append(n)}const t=s.inline?e:B("div",s.contentClassName);return t.append(B(s.titleTag??"span",s.titleClassName,s.title)),s.description!==void 0&&t.append(B(s.descriptionTag??"span",s.descriptionClassName,s.description)),s.inline||e.append(t),e}function vr(s,e){Ot[s]=e}function wr(s,e){Je[s]=e}Y.ActionField=ds,Y.AttachmentField=os,Y.BaseField=Oe,Y.BaseFieldControl=nt,Y.CELL_EDITORS=Je,Y.CELL_RENDERERS=Ot,Y.COMPLETION_LABEL=li,Y.CascadeField=Mn,Y.ChoiceField=mt,Y.CompositeField=cs,Y.ComputedField=vt,Y.CustomField=Nn,Y.DEFAULT_LOCALE_TEXT=qn,Y.DateField=Ln,Y.DateRangeField=is,Y.DateTimeField=Rn,Y.EmailField=Xi,Y.FORMULA_FUNCTIONS=Ft,Y.GANTT_UNITS=ni,Y.GanttChart=oi,Y.Grid=dt,Y.LinkField=En,Y.LocationField=as,Y.MultiCascadeField=ns,Y.MultiChoiceField=Qi,Y.MultiPersonField=es,Y.MultiRelationField=ts,Y.MultiVoteField=ls,Y.NumberField=ji,Y.PersonField=xn,Y.PhoneField=Zi,Y.RadioField=Ji,Y.RelationField=kn,Y.RichTextField=Ki,Y.STATUS_META=ht,Y.SignalField=Tn,Y.SingleVoteField=rs,Y.SwitchField=ss,Y.TextField=Xe,Y.TextareaField=Yi,Y.UNIT_LABEL=Vt,Y.VoteField=jt,Y.adaptOperationRecords=Fa,Y.allGatesMet=di,Y.computeStickyGroupRows=Qn,Y.createControlRegistry=ps,Y.createDetailComments=$a,Y.createDetailDialog=ei,Y.createDetailHistory=Oa,Y.createFieldRegistry=us,Y.createFlowCanvas=pi,Y.createFlowContextBar=mi,Y.createGantt=aa,Y.createGrid=Jn,Y.createMediaCell=mr,Y.createNodeCard=fi,Y.createNodeFlow=wa,Y.createNodeTimeline=vi,Y.createPersonnelSchedule=Ea,Y.createSparklineSvg=Jt,Y.createTagCell=gr,Y.createWorkItemColumnPanels=Wa,Y.createWorkItemColumns=_a,Y.createWorkItemDetailHeader=Ya,Y.createWorkItemFormSurface=fr,Y.createWorkItemHeaderDecorator=Ua,Y.createWorkItemLayers=Xa,Y.createWorkItemRulePanels=ja,Y.createWorkItemSelectionBar=qa,Y.createWorkItemTable=za,Y.createWorkItemTabs=Va,Y.createWorkItemToolbar=Ga,Y.createWorkflowDetail=Ra,Y.default=dt,Y.emptyView=Ba,Y.escapeHtml=D,Y.evalFormCondition=Be,Y.evalFormScope=at,Y.evaluateFormula=St,Y.evaluateGates=an,Y.formatNumberCommas=_e,Y.groupNodes=ui,Y.historyModules=fn,Y.isFormula=Zt,Y.matchNodes=rn,Y.matches=Pi,Y.normalizeHistory=Fi,Y.parse=Fn,Y.queryHistory=Di,Y.registerEditor=wr,Y.registerFormulaFunction=ys,Y.registerRenderer=vr,Y.renderContent=Cn,Y.sanitizeRichText=ft,Y.showTip=gi,Y.summarize=ci,Y.tokenize=An,Y.videoFlow=ba,Object.defineProperties(Y,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|