@univerjs/sheets-filter-ui 0.1.8

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.
Files changed (34) hide show
  1. package/LICENSE +176 -0
  2. package/README.md +34 -0
  3. package/lib/cjs/index.js +14 -0
  4. package/lib/es/index.js +3158 -0
  5. package/lib/index.css +1 -0
  6. package/lib/types/__testing__/data.d.ts +22 -0
  7. package/lib/types/commands/__tests__/sheets-filter.command.spec.d.ts +16 -0
  8. package/lib/types/commands/__tests__/sheets-filter.operation.spec.d.ts +16 -0
  9. package/lib/types/commands/sheets-filter.command.d.ts +25 -0
  10. package/lib/types/commands/sheets-filter.operation.d.ts +18 -0
  11. package/lib/types/controllers/__tests__/sheets-filter.menu.spec.d.ts +16 -0
  12. package/lib/types/controllers/sheets-filter-render.controller.d.ts +28 -0
  13. package/lib/types/controllers/sheets-filter-ui.controller.d.ts +29 -0
  14. package/lib/types/controllers/sheets-filter.menu.d.ts +6 -0
  15. package/lib/types/controllers/sheets-filter.shortcut.d.ts +3 -0
  16. package/lib/types/index.d.ts +18 -0
  17. package/lib/types/locale/en-US.d.ts +66 -0
  18. package/lib/types/locale/index.d.ts +17 -0
  19. package/lib/types/locale/zh-CN.d.ts +4 -0
  20. package/lib/types/models/__tests__/conditions.spec.d.ts +16 -0
  21. package/lib/types/models/conditions.d.ts +75 -0
  22. package/lib/types/models/extended-operators.d.ts +89 -0
  23. package/lib/types/models/utils.d.ts +8 -0
  24. package/lib/types/plugin.d.ts +11 -0
  25. package/lib/types/services/__tests__/sheets-filter-panel.service.spec.d.ts +16 -0
  26. package/lib/types/services/sheets-filter-panel.service.d.ts +186 -0
  27. package/lib/types/views/components/SheetsFilterByConditionsPanel.d.ts +9 -0
  28. package/lib/types/views/components/SheetsFilterByValuesPanel.d.ts +9 -0
  29. package/lib/types/views/components/SheetsFilterPanel.d.ts +8 -0
  30. package/lib/types/views/components/SheetsFilterPanel.stories.d.ts +15 -0
  31. package/lib/types/views/widgets/drawings.d.ts +7 -0
  32. package/lib/types/views/widgets/filter-button.shape.d.ts +33 -0
  33. package/lib/umd/index.js +14 -0
  34. package/package.json +91 -0
@@ -0,0 +1,186 @@
1
+ import { FilterOperator, IFilterConditionFormParams, IFilterConditionItem } from '../models/conditions';
2
+ import { RefRangeService } from '@univerjs/sheets';
3
+ import { Observable } from 'rxjs';
4
+ import { IDisposable, Injector } from '@wendellhu/redi';
5
+ import { SheetsFilterService, FilterColumn, FilterModel } from '@univerjs/sheets-filter';
6
+ import { Nullable, Disposable, ICommandService, IUniverInstanceService } from '@univerjs/core';
7
+
8
+ export declare enum FilterBy {
9
+ VALUES = 0,
10
+ CONDITIONS = 1
11
+ }
12
+ export interface IFilterByValueItem {
13
+ value: string;
14
+ checked: boolean;
15
+ count: number;
16
+ index: number;
17
+ /**
18
+ * This property indicates that this is a special item which maps to empty strings or empty cells.
19
+ */
20
+ isEmpty: boolean;
21
+ }
22
+ export interface ISheetsFilterPanelService {
23
+ /**
24
+ * Set up the panel to change the filter condition on a specific column.
25
+ * @param filterModel the filter model we will be working on
26
+ * @param col
27
+ * @returns if the filter condition is set up successfully
28
+ */
29
+ setUpFilterConditionOfCol(filterModel: FilterModel, col: number): boolean;
30
+ /**
31
+ * Terminate the filter panel without applying changes.
32
+ */
33
+ terminate(): boolean;
34
+ }
35
+ export declare const ISheetsFilterPanelService: import('@wendellhu/redi').IdentifierDecorator<ISheetsFilterPanelService>;
36
+ export interface IFilterByModel extends IDisposable {
37
+ canApply$: Observable<boolean>;
38
+ deltaCol(offset: number): void;
39
+ clear(): Promise<boolean>;
40
+ apply(): Promise<boolean>;
41
+ }
42
+ /**
43
+ * This service controls the state of the filter panel. There should be only one instance of the filter panel
44
+ * at one time.
45
+ */
46
+ export declare class SheetsFilterPanelService extends Disposable {
47
+ private readonly _injector;
48
+ private _sheetsFilterService;
49
+ private readonly _univerInstanceService;
50
+ private readonly _refRangeService;
51
+ private readonly _filterBy$;
52
+ readonly filterBy$: Observable<FilterBy>;
53
+ get filterBy(): FilterBy;
54
+ private readonly _filterByModel$;
55
+ readonly filterByModel$: Observable<Nullable<IFilterByModel>>;
56
+ private _filterByModel;
57
+ get filterByModel(): Nullable<IFilterByModel>;
58
+ private set filterByModel(value);
59
+ private readonly _hasCriteria$;
60
+ readonly hasCriteria$: Observable<boolean>;
61
+ private _filterModel;
62
+ get filterModel(): Nullable<FilterModel>;
63
+ private readonly _col$;
64
+ readonly col$: Observable<number>;
65
+ get col(): number;
66
+ constructor(_injector: Injector, _sheetsFilterService: SheetsFilterService, _univerInstanceService: IUniverInstanceService, _refRangeService: RefRangeService);
67
+ dispose(): void;
68
+ setupCol(filterModel: FilterModel, col: number): boolean;
69
+ changeFilterBy(filterBy: FilterBy): boolean;
70
+ terminate(): boolean;
71
+ private _filterHeaderListener;
72
+ private _disposeFilterHeaderChangeListener;
73
+ private _listenToFilterHeaderChange;
74
+ private _setupByValues;
75
+ private _setupByConditions;
76
+ private _disposePreviousModel;
77
+ }
78
+ /**
79
+ * This model would be used to control the "Filter By Conditions" panel. It should be reconstructed in the following
80
+ * situations:
81
+ *
82
+ * 1. The target `FilterColumn` object is changed
83
+ * 2. User toggles "Filter By"
84
+ */
85
+ export declare class ByConditionsModel extends Disposable implements IFilterByModel {
86
+ private readonly _filterModel;
87
+ col: number;
88
+ private readonly _commandService;
89
+ /**
90
+ * Create a model with targeting filter column. If there is not a filter column, the model would be created with
91
+ * default values.
92
+ *
93
+ * @param injector
94
+ * @param filterModel
95
+ * @param col
96
+ * @param filterColumn
97
+ *
98
+ * @returns the model to control the panel's state
99
+ */
100
+ static fromFilterColumn(injector: Injector, filterModel: FilterModel, col: number, filterColumn?: Nullable<FilterColumn>): ByConditionsModel;
101
+ canApply$: Observable<boolean>;
102
+ private readonly _conditionItem$;
103
+ readonly conditionItem$: Observable<IFilterConditionItem>;
104
+ get conditionItem(): IFilterConditionItem;
105
+ private readonly _filterConditionFormParams$;
106
+ readonly filterConditionFormParams$: Observable<IFilterConditionFormParams>;
107
+ get filterConditionFormParams(): IFilterConditionFormParams;
108
+ constructor(_filterModel: FilterModel, col: number, conditionItem: IFilterConditionItem, conditionParams: IFilterConditionFormParams, _commandService: ICommandService);
109
+ dispose(): void;
110
+ deltaCol(offset: number): void;
111
+ clear(): Promise<boolean>;
112
+ /**
113
+ * Apply the filter condition to the target filter column.
114
+ */
115
+ apply(): Promise<boolean>;
116
+ /**
117
+ * This method would be called when user changes the primary condition. The model would load the corresponding
118
+ * `IFilterConditionFormParams` and load default condition form params.
119
+ */
120
+ onPrimaryConditionChange(operator: FilterOperator): void;
121
+ /**
122
+ * This method would be called when user changes the primary conditions, the input values or "AND" "OR" ratio.
123
+ * If the primary conditions or the ratio is changed, the method would load the corresponding `IFilterCondition`.
124
+ *
125
+ * When the panel call this method, it only has to pass the changed keys.
126
+ *
127
+ * @param params
128
+ */
129
+ onConditionFormChange(params: Partial<Omit<IFilterConditionFormParams, 'and'> & {
130
+ and: boolean;
131
+ }>): void;
132
+ }
133
+ /**
134
+ * This model would be used to control the "Filter By Values" panel. It should be reconstructed in the following
135
+ * situations:
136
+ *
137
+ * 1. The target `FilterColumn` object is changed
138
+ * 2. User toggles "Filter By"
139
+ */
140
+ export declare class ByValuesModel extends Disposable implements IFilterByModel {
141
+ private readonly _filterModel;
142
+ col: number;
143
+ private readonly _commandService;
144
+ /**
145
+ * Create a model with targeting filter column. If there is not a filter column, the model would be created with
146
+ * default values.
147
+ *
148
+ * @param injector
149
+ * @param filterModel
150
+ * @param col
151
+ *
152
+ * @returns the model to control the panel's state
153
+ */
154
+ static fromFilterColumn(injector: Injector, filterModel: FilterModel, col: number): ByValuesModel;
155
+ private readonly _rawFilterItems$;
156
+ readonly rawFilterItems$: Observable<IFilterByValueItem[]>;
157
+ get rawFilterItems(): IFilterByValueItem[];
158
+ readonly filterItems$: Observable<IFilterByValueItem[]>;
159
+ private _filterItems;
160
+ get filterItems(): IFilterByValueItem[];
161
+ readonly canApply$: Observable<boolean>;
162
+ private readonly _manuallyUpdateFilterItems$;
163
+ private readonly _searchString$;
164
+ readonly searchString$: Observable<string>;
165
+ constructor(_filterModel: FilterModel, col: number,
166
+ /**
167
+ * Filter items would remain unchanged after we create them,
168
+ * though data may change after.
169
+ */
170
+ items: IFilterByValueItem[], _commandService: ICommandService);
171
+ dispose(): void;
172
+ deltaCol(offset: number): void;
173
+ setSearchString(str: string): void;
174
+ /**
175
+ * Toggle a filter item.
176
+ */
177
+ onFilterCheckToggled(item: IFilterByValueItem, checked: boolean): void;
178
+ onFilterOnly(item: IFilterByValueItem): void;
179
+ onCheckAllToggled(checked: boolean): void;
180
+ private _manuallyUpdateFilterItems;
181
+ clear(): Promise<boolean>;
182
+ /**
183
+ * Apply the filter condition to the target filter column.
184
+ */
185
+ apply(): Promise<boolean>;
186
+ }
@@ -0,0 +1,9 @@
1
+ import { ByConditionsModel } from '../../services/sheets-filter-panel.service';
2
+ import { default as React } from 'react';
3
+
4
+ /**
5
+ * Filter by conditions.
6
+ */
7
+ export declare function FilterByCondition(props: {
8
+ model: ByConditionsModel;
9
+ }): React.JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { ByValuesModel } from '../../services/sheets-filter-panel.service';
2
+ import { default as React } from 'react';
3
+
4
+ /**
5
+ * Filter by values.
6
+ */
7
+ export declare function FilterByValue(props: {
8
+ model: ByValuesModel;
9
+ }): React.JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+
3
+ /**
4
+ * This Filter Panel component is used to filter the data in the sheet.
5
+ *
6
+ * @returns React element
7
+ */
8
+ export declare function FilterPanel(): React.JSX.Element;
@@ -0,0 +1,15 @@
1
+ import { FilterPanel } from './SheetsFilterPanel';
2
+ import { Meta } from '@storybook/react';
3
+ import { default as React } from 'react';
4
+
5
+ declare const meta: Meta<typeof FilterPanel>;
6
+ export default meta;
7
+ export declare const FilterWithConditions: {
8
+ render(): React.JSX.Element;
9
+ };
10
+ export declare const FilterWithValues: {
11
+ render(): React.JSX.Element;
12
+ };
13
+ export declare const FilterWithChinese: {
14
+ render(): React.JSX.Element;
15
+ };
@@ -0,0 +1,7 @@
1
+ import { UniverRenderingContext2D } from '@univerjs/engine-render';
2
+
3
+ export declare const FILTER_BUTTON_EMPTY: Path2D;
4
+ export declare class FilterButton {
5
+ static drawNoCriteria(ctx: UniverRenderingContext2D, size: number, fgColor: string, bgColor: string): void;
6
+ static drawHasCriteria(ctx: UniverRenderingContext2D, size: number, fgColor: string, bgColor: string): void;
7
+ }
@@ -0,0 +1,33 @@
1
+ import { IMouseEvent, IPointerEvent, IShapeProps, Shape, UniverRenderingContext2D } from '@univerjs/engine-render';
2
+ import { ICommandService, IContextService, ThemeService } from '@univerjs/core';
3
+
4
+ export declare const FILTER_ICON_SIZE = 16;
5
+ export declare const FILTER_ICON_PADDING = 1;
6
+ export interface ISheetsFilterButtonShapeProps extends IShapeProps {
7
+ cellWidth: number;
8
+ cellHeight: number;
9
+ filterParams: {
10
+ col: number;
11
+ unitId: string;
12
+ subUnitId: string;
13
+ hasCriteria: boolean;
14
+ };
15
+ }
16
+ /**
17
+ * The widget to render a filter button on canvas.
18
+ */
19
+ export declare class SheetsFilterButtonShape extends Shape<ISheetsFilterButtonShapeProps> {
20
+ private readonly _contextService;
21
+ private readonly _commandService;
22
+ private readonly _themeService;
23
+ private _cellWidth;
24
+ private _cellHeight;
25
+ private _filterParams?;
26
+ private _hovered;
27
+ constructor(key: string, props: ISheetsFilterButtonShapeProps, _contextService: IContextService, _commandService: ICommandService, _themeService: ThemeService);
28
+ setShapeProps(props: Partial<ISheetsFilterButtonShapeProps>): void;
29
+ protected _draw(ctx: UniverRenderingContext2D): void;
30
+ onPointerDown(evt: IPointerEvent | IMouseEvent): void;
31
+ onPointerEnter(): void;
32
+ onPointerLeave(): void;
33
+ }
@@ -0,0 +1,14 @@
1
+ (function(D,S){typeof exports=="object"&&typeof module<"u"?S(exports,require("@univerjs/core"),require("@wendellhu/redi"),require("@univerjs/ui"),require("rxjs"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("@univerjs/sheets"),require("@univerjs/sheets-filter"),require("react"),require("@wendellhu/redi/react-bindings"),require("react-dom"),require("@univerjs/engine-render")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@wendellhu/redi","@univerjs/ui","rxjs","@univerjs/sheets-ui","@univerjs/design","@univerjs/sheets","@univerjs/sheets-filter","react","@wendellhu/redi/react-bindings","react-dom","@univerjs/engine-render"],S):(D=typeof globalThis<"u"?globalThis:D||self,S(D.UniverSheetsFilterUi={},D.UniverCore,D["@wendellhu/redi"],D.UniverUi,D.rxjs,D.UniverSheetsUi,D.UniverDesign,D.UniverSheets,D.UniverSheetsFilter,D.React,D["@wendellhu/redi/react-bindings"],D.ReactDOM,D.UniverEngineRender))})(this,function(D,S,w,H,N,me,K,Ue,c,h,$e,It,Ze){"use strict";var fo=Object.defineProperty;var ho=(D,S,w)=>S in D?fo(D,S,{enumerable:!0,configurable:!0,writable:!0,value:w}):D[S]=w;var P=(D,S,w)=>(ho(D,typeof S!="symbol"?S+"":S,w),w);var bt;function Zr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const p=Zr(h),Jr={"sheets-filter":{toolbar:{"smart-toggle-filter-tooltip":"Toggle Filter","clear-filter-criteria":"Clear Filter Conditions","re-calc-filter-conditions":"Re-calc Filter Conditions"},command:{"not-valid-filter-range":"The selected range only has one row and not valid for filter."},shortcut:{"smart-toggle-filter":"Toggle Filter"},panel:{"clear-filter":"Clear Filter",cancel:"Cancel",confirm:"Confirm","by-values":"By Values","by-conditions":"By Conditions","filter-only":"Filter Only","search-placeholder":"Use space to separate keywords","select-all":"Select All","input-values-placeholder":"Input Values",and:"AND",or:"OR",empty:"(empty)","?":"Use “?” to represent a single character.","*":"Use “*” to represent multiple characters."},conditions:{none:"None",empty:"Is Empty","not-empty":"Is Not Empty","text-contains":"Text Contains","does-not-contain":"Text Does Not Contain","starts-with":"Text Starts With","ends-with":"Text Ends With",equals:"Text Equals","greater-than":"Greater Than","greater-than-or-equal":"Greater Than Or Equal To","less-than":"Less Than","less-than-or-equal":"Less Than Or Equal To",equal:"Equal","not-equal":"Not Equal",between:"Between","not-between":"Not Between",custom:"Custom"}}},Kt={"sheets-filter":{toolbar:{"smart-toggle-filter-tooltip":"筛选","clear-filter-criteria":"清除筛选条件","re-calc-filter-conditions":"重新计算"},command:{"not-valid-filter-range":"选中的区域只有一行,无法进行筛选"},shortcut:{"smart-toggle-filter":"切换筛选"},panel:{"clear-filter":"清除筛选",cancel:"取消",confirm:"确认","by-values":"按值","by-conditions":"按条件","filter-only":"仅筛选","search-placeholder":"使用空格分隔关键字","select-all":"全选","input-values-placeholder":"请输入",or:"或",and:"和",empty:"(空白)","?":"可用 ? 代表单个字符","*":"可用 * 代表任意多个字符"},conditions:{none:"无",empty:"为空","not-empty":"不为空","text-contains":"文本包含","does-not-contain":"文本不包含","starts-with":"文本开头","ends-with":"文本结尾",equals:"文本相符","greater-than":"大于","greater-than-or-equal":"大于等于","less-than":"小于","less-than-or-equal":"小于等于",equal:"等于","not-equal":"不等于",between:"介于","not-between":"不介于",custom:"自定义"}}};var ne=function(){return ne=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++){t=arguments[r];for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o])}return e},ne.apply(this,arguments)},en=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]]);return r},Zt=h.forwardRef(function(e,t){var r=e.icon,n=e.id,o=e.className,s=e.extend,i=en(e,["icon","id","className","extend"]),a="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),l=h.useRef("_".concat(nn()));return Jt(r,"".concat(n),{defIds:r.defIds,idSuffix:l.current},ne({ref:t,className:a},i),s)});function Jt(e,t,r,n,o){return h.createElement(e.tag,ne(ne({key:t},tn(e,r,o)),n),(rn(e,r).children||[]).map(function(s,i){return Jt(s,"".concat(t,"-").concat(e.tag,"-").concat(i),r,void 0,o)}))}function tn(e,t,r){var n=ne({},e.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1);var o=t.defIds;return!o||o.length===0||(e.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+t.idSuffix),Object.entries(n).forEach(function(s){var i=s[0],a=s[1];typeof a=="string"&&(n[i]=a.replace(/url\(#(.*)\)/,"url(#$1".concat(t.idSuffix,")")))})),n}function rn(e,t){var r,n=t.defIds;return!n||n.length===0?e:e.tag==="defs"&&(!((r=e.children)===null||r===void 0)&&r.length)?ne(ne({},e),{children:e.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.indexOf(o.attrs.id)>-1?ne(ne({},o),{attrs:ne(ne({},o.attrs),{id:o.attrs.id+t.idSuffix})}):o})}):e}function nn(){return Math.random().toString(36).substring(2,8)}Zt.displayName="UniverIcon";var on={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{stroke:"currentColor",d:"M2 3L6.8 8.60593V12.8148L9.2 14V8.60593L14 3H2Z",strokeLinejoin:"round",strokeWidth:1.33}}]},er=h.forwardRef(function(e,t){return h.createElement(Zt,Object.assign({},e,{id:"filter-single",ref:t,icon:on}))});er.displayName="FilterSingle";const xe={id:"sheet.command.smart-toggle-filter",type:S.CommandType.COMMAND,handler:async e=>{const t=e.get(S.IUniverInstanceService),r=e.get(c.SheetsFilterService),n=e.get(S.ICommandService),o=e.get(S.IUndoRedoService),s=t.getCurrentUnitForType(S.UniverInstanceType.UNIVER_SHEET),i=s==null?void 0:s.getActiveSheet();if(!i||!s)return!1;const a=s.getUnitId(),l=i.getSheetId(),u=r.getFilterModel(a,l);if(u){const g=u==null?void 0:u.serialize(),y=an(a,l,g),C=n.syncExecuteCommand(c.RemoveSheetsFilterMutation.id,{unitId:a,subUnitId:l});return C&&o.pushUndoRedo({unitID:a,undoMutations:y,redoMutations:[{id:c.RemoveSheetsFilterMutation.id,params:{unitId:a,subUnitId:l}}]}),C}const d=e.get(Ue.SelectionManagerService).getLast();if(!d)return!1;const v=d.range,m=Ue.isSingleCellSelection(d)?me.expandToContinuousRange(v,{left:!0,right:!0,up:!0,down:!0},i):v;if(m.endRow===m.startRow){const g=e.get(H.IMessageService,w.Quantity.OPTIONAL),y=e.get(S.LocaleService);return g==null||g.show({type:K.MessageType.Warning,content:y.t("sheets-filter.command.not-valid-filter-range")}),!1}const _={id:c.SetSheetsFilterRangeMutation.id,params:{unitId:a,subUnitId:l,range:m}},E=n.syncExecuteCommand(_.id,_.params);return E&&o.pushUndoRedo({unitID:a,undoMutations:[{id:c.RemoveSheetsFilterMutation.id,params:{unitId:a,subUnitId:l}}],redoMutations:[_]}),E}},Ie={id:"sheet.command.set-filter-criteria",type:S.CommandType.COMMAND,handler:async(e,t)=>{const r=e.get(c.SheetsFilterService),n=e.get(S.ICommandService),o=e.get(S.IUndoRedoService),{unitId:s,subUnitId:i,col:a,criteria:l}=t,u=r.getFilterModel(s,i);if(!u)return!1;const f=u.getRange();if(!f||a<f.startColumn||a>f.endColumn)return!1;const d=u.getFilterColumn(a),v=ln(s,i,a,d),m={id:c.SetSheetsFilterCriteriaMutation.id,params:{unitId:s,subUnitId:i,col:a,criteria:l}},_=n.syncExecuteCommand(m.id,m.params);return _&&o.pushUndoRedo({unitID:s,undoMutations:[v],redoMutations:[m]}),_}},tr={id:"sheet.command.clear-filter-criteria",type:S.CommandType.COMMAND,handler:e=>{const t=e.get(c.SheetsFilterService),r=e.get(S.IUndoRedoService),n=e.get(S.ICommandService),o=t.activeFilterModel;if(!o)return!1;const{unitId:s,subUnitId:i}=o,a=o.serialize(),l=nr(s,i,a),u=sn(s,i,a);return S.sequenceExecute(u,n)&&r.pushUndoRedo({unitID:s,undoMutations:l,redoMutations:u}),!0}},rr={id:"sheet.command.re-calc-filter",type:S.CommandType.COMMAND,handler:e=>{const t=e.get(c.SheetsFilterService),r=e.get(S.ICommandService),n=t.activeFilterModel;if(!n)return!1;const{unitId:o,subUnitId:s}=n;return r.executeCommand(c.ReCalcSheetsFilterMutation.id,{unitId:o,subUnitId:s})}};function an(e,t,r){const n=[],o={id:c.SetSheetsFilterRangeMutation.id,params:{unitId:e,subUnitId:t,range:r.ref}};return n.push(o),nr(e,t,r).forEach(i=>n.push(i)),n}function nr(e,t,r){var o;const n=[];return(o=r.filterColumns)==null||o.forEach(s=>{const i={id:c.SetSheetsFilterCriteriaMutation.id,params:{unitId:e,subUnitId:t,col:s.colId,criteria:s}};n.push(i)}),n}function sn(e,t,r){var o;const n=[];return(o=r.filterColumns)==null||o.forEach(s=>{const i={id:c.SetSheetsFilterCriteriaMutation.id,params:{unitId:e,subUnitId:t,col:s.colId,criteria:null}};n.push(i)}),n}function ln(e,t,r,n){if(!n)return{id:c.SetSheetsFilterCriteriaMutation.id,params:{unitId:e,subUnitId:t,col:r,criteria:null}};const o=n.serialize();return{id:c.SetSheetsFilterCriteriaMutation.id,params:{unitId:e,subUnitId:t,col:r,criteria:o}}}var k=(e=>(e[e.FIRST=0]="FIRST",e[e.SECOND=1]="SECOND",e))(k||{}),I=(e=>(e.NONE="none",e.STARTS_WITH="startsWith",e.DOES_NOT_START_WITH="doesNotStartWith",e.ENDS_WITH="endsWith",e.DOES_NOT_END_WITH="doesNotEndWith",e.CONTAINS="contains",e.DOES_NOT_CONTAIN="doesNotContain",e.EQUALS="equals",e.NOT_EQUALS="notEquals",e.EMPTY="empty",e.NOT_EMPTY="notEmpty",e.BETWEEN="between",e.NOT_BETWEEN="notBetween",e.CUSTOM="custom",e))(I||{}),T;(e=>{e.NONE={label:"sheets-filter.conditions.none",operator:I.NONE,order:k.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===I.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},e.EMPTY={label:"sheets-filter.conditions.empty",operator:I.EMPTY,order:k.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===I.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.val===""&&a.operator===void 0?{operator1:I.EMPTY}:!1}},e.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:I.NOT_EMPTY,order:k.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===I.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:" ",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.val===" "&&a.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:I.NOT_EMPTY}:!1}},e.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:I.CONTAINS,order:k.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:I.CONTAINS,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===I.CONTAINS},mapToFilterColumn:i=>{const{val1:a}=i;return a===""?null:{customFilters:{customFilters:[{val:`*${a}*`}]}}},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0],l=a.val.toString();return!a.operator&&l.startsWith("*")&&l.endsWith("*")?{operator1:I.CONTAINS,val1:l.slice(1,-1)}:!1}},e.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:I.DOES_NOT_CONTAIN,order:k.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:I.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[a]=se(i);return a===I.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0],l=a.val.toString();return a.operator===c.CustomFilterOperator.NOT_EQUALS&&l.startsWith("*")&&l.endsWith("*")?{operator1:I.DOES_NOT_CONTAIN,val1:l.slice(1,-1)}:!1}},e.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:I.STARTS_WITH,order:k.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:I.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[a]=se(i);return a===I.STARTS_WITH},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0],l=a.val.toString();return!a.operator&&l.endsWith("*")&&!l.startsWith("*")?{operator1:I.STARTS_WITH,val1:l.slice(0,-1)}:!1}},e.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:I.ENDS_WITH,order:k.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:I.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[a]=se(i);return a===I.ENDS_WITH},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0],l=a.val.toString();return!a.operator&&l.startsWith("*")&&!l.endsWith("*")?{operator1:I.ENDS_WITH,val1:l.slice(1)}:!1}},e.EQUALS={label:"sheets-filter.conditions.equals",operator:I.EQUALS,order:k.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:I.EQUALS,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===I.EQUALS},mapToFilterColumn:i=>{const{val1:a}=i;return a===""?null:{customFilters:{customFilters:[{val:a}]}}},testMappingFilterColumn:i=>{var a,l,u;return((l=(a=i.filters)==null?void 0:a.filters)==null?void 0:l.length)===1?{operator1:I.EQUALS,val1:""}:((u=i.customFilters)==null?void 0:u.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:I.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},e.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:k.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[a]=se(i);return a===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString()}}},e.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:k.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString()}}},e.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:k.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:a.val.toString()}}},e.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:k.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:a.val.toString()}}},e.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:k.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:a.val.toString()}}},e.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:k.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[a]=se(i);return a===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const a=i.customFilters.customFilters[0];return a.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:a.val.toString()}}},e.BETWEEN={label:"sheets-filter.conditions.between",operator:I.BETWEEN,order:k.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:a,operator1:l,operator2:u}=i;if(!a)return!1;const f=[l,u];return f.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&f.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:a,val2:l,operator1:u}=i,f=u===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:S.BooleanNumber.TRUE,customFilters:[{val:f?a:l,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:f?l:a,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==2)return!1;const[a,l]=i.customFilters.customFilters;return a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&l.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toLocaleString()}:!1}},e.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:I.NOT_BETWEEN,order:k.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:a,operator1:l,operator2:u}=i;if(a)return!1;const f=[l,u];return f.includes(c.CustomFilterOperator.GREATER_THAN)&&f.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:a,val2:l,operator1:u}=i,f=u===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:f?a:l,operator:c.CustomFilterOperator.GREATER_THAN},{val:f?l:a,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==2)return!1;const[a,l]=i.customFilters.customFilters;return a.operator===c.CustomFilterOperator.LESS_THAN&&l.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:a.val.toLocaleString()}:!1}},e.CUSTOM={label:"sheets-filter.conditions.custom",operator:I.CUSTOM,order:k.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:I.NONE,val1:"",operator2:I.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:a,val1:l,val2:u,operator1:f,operator2:d}=i;function v(C,L){for(const R of e.ALL_CONDITIONS)if(R.operator===C)return R.mapToFilterColumn({val1:L,operator1:C})}const m=!f||f===e.NONE.operator,_=!d||d===e.NONE.operator;if(m&&_)return e.NONE.mapToFilterColumn({});if(m)return v(d,u);if(_)return v(f,l);const E=v(f,l),g=v(d,u),y={customFilters:[E.customFilters.customFilters[0],g.customFilters.customFilters[0]]};return a&&(y.and=S.BooleanNumber.TRUE),{customFilters:y}},testMappingFilterColumn:i=>{var u;if(((u=i.customFilters)==null?void 0:u.customFilters.length)!==2)return!1;const a=i.customFilters.customFilters.map(f=>s({customFilters:{customFilters:[f]}})),l={operator1:a[0][0].operator,val1:a[0][1].val1,operator2:a[1][0].operator,val2:a[1][1].val1};return i.customFilters.and&&(l.and=!0),l}},e.ALL_CONDITIONS=[e.NONE,e.EMPTY,e.NOT_EMPTY,e.TEXT_CONTAINS,e.DOES_NOT_CONTAIN,e.STARTS_WITH,e.ENDS_WITH,e.EQUALS,e.GREATER_THAN,e.GREATER_THAN_OR_EQUAL,e.LESS_THAN,e.LESS_THAN_OR_EQUAL,e.EQUAL,e.NOT_EQUAL,e.BETWEEN,e.NOT_BETWEEN,e.CUSTOM];function t(i){const a=e.ALL_CONDITIONS.find(l=>l.operator===i);if(!a)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return a}e.getItemByOperator=t;function r(i,a){for(const l of e.ALL_CONDITIONS.filter(u=>u.numOfParameters===a))if(l.numOfParameters!==0&&l.testMappingParams(i))return l;for(const l of e.ALL_CONDITIONS)if(l.testMappingParams(i))return l;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}e.testMappingParams=r;function n(i){const a=e.ALL_CONDITIONS.find(l=>l.operator===i);return(a==null?void 0:a.numOfParameters)===0?{operator1:a.operator}:a.getDefaultFormParams()}e.getInitialFormParams=n;function o(i,a){return i.mapToFilterColumn(a)}e.mapToFilterColumn=o;function s(i){if(!i)return[e.NONE,{}];for(const a of e.ALL_CONDITIONS){const l=a.testMappingFilterColumn(i);if(l)return[a,l]}return[e.NONE,{}]}e.testMappingFilterColumn=s})(T||(T={}));function se(e){const{operator1:t,operator2:r,val1:n,val2:o}=e;if(t&&r)throw new Error("Both operator1 and operator2 are set!");if(!t&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return t?[t,n]:[r,o]}function Pt(e){const t=[],r=[];for(const n of e)n.checked?t.push(n):r.push(n);return{checkedItems:t,uncheckedItems:r,checked:t.length,unchecked:r.length}}var un=Object.defineProperty,cn=Object.getOwnPropertyDescriptor,Nt=(e,t,r,n)=>{for(var o=n>1?void 0:n?cn(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&un(t,r,o),o},Pe=(e,t)=>(r,n)=>t(r,n,e),Je=(e=>(e[e.VALUES=0]="VALUES",e[e.CONDITIONS=1]="CONDITIONS",e))(Je||{});w.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let ge=class extends S.Disposable{constructor(t,r,n,o){super();P(this,"_filterBy$",new N.BehaviorSubject(0));P(this,"filterBy$",this._filterBy$.asObservable());P(this,"_filterByModel$",new N.ReplaySubject(1));P(this,"filterByModel$",this._filterByModel$.asObservable());P(this,"_filterByModel",null);P(this,"_hasCriteria$",new N.BehaviorSubject(!1));P(this,"hasCriteria$",this._hasCriteria$.asObservable());P(this,"_filterModel",null);P(this,"_col$",new N.BehaviorSubject(-1));P(this,"col$",this._col$.asObservable());P(this,"_filterHeaderListener",null);this._injector=t,this._sheetsFilterService=r,this._univerInstanceService=n,this._refRangeService=o}get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(t){this._filterByModel=t,this._filterByModel$.next(t)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(t,r){this.terminate(),this._filterModel=t,this._col$.next(r);const n=t.getFilterColumn(r);if(n){const o=n.getColumnData();return o.customFilters?(this._hasCriteria$.next(!0),this._setupByConditions(t,r)):o.filters?(this._hasCriteria$.next(!0),this._setupByValues(t,r)):(this._hasCriteria$.next(!1),this._setupByValues(t,r))}return this._hasCriteria$.next(!1),this._setupByValues(t,r)}changeFilterBy(t){return!this._filterModel||this.col===-1?!1:(t===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var t;(t=this._filterHeaderListener)==null||t.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(t,r){this._disposeFilterHeaderChangeListener();const n=t.unitId,o=t.subUnitId,s=t.getRange(),i={startColumn:r,startRow:s.startRow,endRow:s.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(a,l)=>{if(!l)this.terminate();else{const u=l.startColumn-a.startColumn;u!==0&&this._filterByModel.deltaCol(u)}})}_setupByValues(t,r){this._disposePreviousModel();const n=t.getRange();if(n.startRow===n.endRow)return!1;const o=tt.fromFilterColumn(this._injector,t,r);return this.filterByModel=o,this._filterBy$.next(0),this._listenToFilterHeaderChange(t,r),!0}_setupByConditions(t,r){this._disposePreviousModel();const n=t.getRange();if(n.startRow===n.endRow)return!1;const o=et.fromFilterColumn(this._injector,t,r,t.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(1),this._listenToFilterHeaderChange(t,r),!0}_disposePreviousModel(){var t;(t=this._filterByModel)==null||t.dispose(),this.filterByModel=null}};ge=Nt([Pe(0,w.Inject(w.Injector)),Pe(1,w.Inject(c.SheetsFilterService)),Pe(2,S.IUniverInstanceService),Pe(3,w.Inject(Ue.RefRangeService))],ge);let et=class extends S.Disposable{constructor(t,r,n,o,s){super();P(this,"canApply$",N.of(!0));P(this,"_conditionItem$");P(this,"conditionItem$");P(this,"_filterConditionFormParams$");P(this,"filterConditionFormParams$");this._filterModel=t,this.col=r,this._commandService=s,this._conditionItem$=new N.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new N.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(t,r,n,o){const[s,i]=T.testMappingFilterColumn(o==null?void 0:o.getColumnData());return t.createInstance(et,r,n,s,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(t){this.col+=t}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(Ie.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const t=T.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(Ie.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:t})}onPrimaryConditionChange(t){const r=T.ALL_CONDITIONS.find(n=>n.operator===t);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${t}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(T.getInitialFormParams(t))}onConditionFormChange(t){const r={...this.filterConditionFormParams,...t};if(r.and!==!0&&delete r.and,typeof t.and<"u"||typeof t.operator1<"u"||typeof t.operator2<"u"){const n=T.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};et=Nt([Pe(4,S.ICommandService)],et);let tt=class extends S.Disposable{constructor(t,r,n,o){super();P(this,"_rawFilterItems$");P(this,"rawFilterItems$");P(this,"filterItems$");P(this,"_filterItems",[]);P(this,"canApply$");P(this,"_manuallyUpdateFilterItems$");P(this,"_searchString$");P(this,"searchString$");this._filterModel=t,this.col=r,this._commandService=o,this._searchString$=new N.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new N.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new N.Subject,this.filterItems$=N.merge(N.combineLatest([this._searchString$.pipe(N.throttleTime(500,void 0,{leading:!0,trailing:!0}),N.startWith(void 0)),this._rawFilterItems$]).pipe(N.map(([s,i])=>{if(!s)return i;const l=s.toLowerCase().split(/\s+/).filter(u=>!!u);return i.filter(u=>{const f=u.value.toLowerCase();return l.some(d=>f.includes(d))})})),this._manuallyUpdateFilterItems$).pipe(N.shareReplay(1)),this.canApply$=this.filterItems$.pipe(N.map(s=>Pt(s).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(s=>this._filterItems=s))}static fromFilterColumn(t,r,n){var U;const o=t.get(S.IUniverInstanceService),s=t.get(S.LocaleService),{unitId:i,subUnitId:a}=r,l=o.getUniverSheetInstance(i);if(!l)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${i}!`);const u=l==null?void 0:l.getSheetBySheetId(a);if(!u)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${i} and subUnitId: ${a}!`);const f=r.getRange(),d=n,v=(U=r.getFilterColumn(n))==null?void 0:U.getColumnData().filters,m=!!(v&&v.blank),_={...f,startRow:f.startRow+1,startColumn:d,endColumn:d},E=[],g={},y=new Set(v==null?void 0:v.filters),C=r.getFilteredOutRowsExceptCol(n);let L=0,R=0;for(const F of u.iterateByColumn(_,!1,!1)){const{row:$,rowSpan:W=1}=F;let z=0;for(;z<W;){const te=$+z;if(C.has(te)){z++;continue}const Y=F!=null&&F.value?S.extractPureTextFromCell(F.value):"";if(!Y){R+=1,z+=W;continue}if(g[Y])g[Y].count++;else{const oe={value:Y,checked:y.size?y.has(Y):!m,count:1,index:L,isEmpty:!1};g[Y]=oe,E.push(oe)}z++}L++}const V=v?m:!0;if(R>0){const F={value:s.t("sheets-filter.panel.empty"),checked:V,count:R,index:L,isEmpty:!0};E.push(F)}return t.createInstance(tt,r,n,E)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(t){this.col+=t}setSearchString(t){this._searchString$.next(t)}onFilterCheckToggled(t,r){const n=this._filterItems.slice(),o=n.find(s=>s.index===t.index);o.checked=r,this._manuallyUpdateFilterItems(n)}onFilterOnly(t){const r=this._filterItems.slice();r.forEach(n=>n.checked=n.index===t.index),this._manuallyUpdateFilterItems(r)}onCheckAllToggled(t){const r=this._filterItems.slice();r.forEach(n=>n.checked=t),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(t){this._manuallyUpdateFilterItems$.next(t)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(Ie.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const t=Pt(this._filterItems),{checked:r,checkedItems:n}=t,o=this.rawFilterItems,s=r===0,i=t.checked===o.length,a={colId:this.col};if(s)throw new Error("[ByValuesModel]: no checked items!");if(i)return this._commandService.executeCommand(Ie.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const l=n.filter(f=>!f.isEmpty);l.length>0&&(a.filters={filters:l.map(f=>f.value)}),l.length!==n.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(Ie.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};tt=Nt([Pe(3,S.ICommandService)],tt);const Ne="FILTER_PANEL_OPENED",ir={id:"sheet.operation.open-filter-panel",type:S.CommandType.OPERATION,handler:(e,t)=>{const r=e.get(S.IContextService),n=e.get(c.SheetsFilterService),o=e.get(ge);e.get(S.ICommandService).syncExecuteCommand(me.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:a,col:l}=t,u=n.getFilterModel(i,a);return!u||!o.setupCol(u,l)?!1:(r.getContextValue(Ne)||r.setContextValue(Ne,!0),!0)}},Be={id:"sheet.operation.close-filter-panel",type:S.CommandType.OPERATION,handler:e=>{const t=e.get(S.IContextService),r=e.get(ge),n=e.get(H.ILayoutService,w.Quantity.OPTIONAL);return t.getContextValue(Ne)?(t.setContextValue(Ne,!1),n==null||n.focus(),r.terminate()):!1}},or={id:"sheet.operation.apply-filter",type:S.CommandType.OPERATION,handler:(e,t)=>{const{filterBy:r}=t;return e.get(ge).changeFilterBy(r)}},B={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelSelectAll:"univer-sheets-filter-panel-select-all",sheetsFilterPanelSelectAllCount:"univer-sheets-filter-panel-select-all-count",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",inputAffixWrapper:"univer-input-affix-wrapper",select:"univer-select",radioGroup:"univer-radio-group",sheetsFilterPanelValuesFind:"univer-sheets-filter-panel-values-find",sheetsFilterPanelValuesList:"univer-sheets-filter-panel-values-list",sheetsFilterPanelValuesListInnerContainer:"univer-sheets-filter-panel-values-list-inner-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemExcludeButton:"univer-sheets-filter-panel-values-item-exclude-button",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons",button:"univer-button",input:"univer-input",formDualColumnLayout:"univer-form-dual-column-layout"};function fn(e){const{model:t}=e,r=$e.useDependency(S.LocaleService),n=H.useObservable(t.conditionItem$,void 0,!0),o=H.useObservable(t.filterConditionFormParams$,void 0,!0),{operator:s,numOfParameters:i}=n,{operator1:a,operator2:l,val1:u,val2:f,and:d}=o,v=d?"AND":"OR",m=h.useCallback(R=>{t.onConditionFormChange({and:R==="AND"})},[t]),_=hn(r),E=h.useCallback(R=>{t.onPrimaryConditionChange(R)},[t]),g=dn(r),y=h.useCallback(R=>{t.onConditionFormChange(R)},[t]),C=r.t("sheets-filter.panel.input-values-placeholder");function L(R,V,U){const F=T.getItemByOperator(R).numOfParameters===1;return h.createElement(h.Fragment,null,U==="operator2"&&h.createElement(K.RadioGroup,{value:v,onChange:m},h.createElement(K.Radio,{value:"AND"},r.t("sheets-filter.panel.and")),h.createElement(K.Radio,{value:"OR"},r.t("sheets-filter.panel.or"))),h.createElement(K.Select,{value:R,options:g,onChange:$=>y({[U]:$})}),F&&h.createElement(K.Input,{value:V,placeholder:C,onChange:$=>y({[U==="operator1"?"val1":"val2"]:$})}))}return h.createElement("div",{className:B.sheetsFilterPanelConditionsContainer},h.createElement(K.Select,{value:s,options:_,onChange:E}),T.getItemByOperator(s).numOfParameters!==0?h.createElement("div",{className:B.sheetsFilterPanelConditionsContainerInner},i>=1&&L(a,u!=null?u:"","operator1"),i>=2&&L(l,f!=null?f:"","operator2"),h.createElement("div",{className:B.sheetsFilterPanelConditionsDesc},r.t("sheets-filter.panel.?"),h.createElement("br",null),r.t("sheets-filter.panel.*"))):null)}function hn(e){const t=e.getCurrentLocale();return h.useMemo(()=>[{options:[{label:e.t(T.NONE.label),value:T.NONE.operator}]},{options:[{label:e.t(T.EMPTY.label),value:T.EMPTY.operator},{label:e.t(T.NOT_EMPTY.label),value:T.NOT_EMPTY.operator}]},{options:[{label:e.t(T.TEXT_CONTAINS.label),value:T.TEXT_CONTAINS.operator},{label:e.t(T.DOES_NOT_CONTAIN.label),value:T.DOES_NOT_CONTAIN.operator},{label:e.t(T.STARTS_WITH.label),value:T.STARTS_WITH.operator},{label:e.t(T.ENDS_WITH.label),value:T.ENDS_WITH.operator},{label:e.t(T.EQUALS.label),value:T.EQUALS.operator}]},{options:[{label:e.t(T.GREATER_THAN.label),value:T.GREATER_THAN.operator},{label:e.t(T.GREATER_THAN_OR_EQUAL.label),value:T.GREATER_THAN_OR_EQUAL.operator},{label:e.t(T.LESS_THAN.label),value:T.LESS_THAN.operator},{label:e.t(T.LESS_THAN_OR_EQUAL.label),value:T.LESS_THAN_OR_EQUAL.operator},{label:e.t(T.EQUAL.label),value:T.EQUAL.operator},{label:e.t(T.NOT_EQUAL.label),value:T.NOT_EQUAL.operator},{label:e.t(T.BETWEEN.label),value:T.BETWEEN.operator},{label:e.t(T.NOT_BETWEEN.label),value:T.NOT_BETWEEN.operator}]},{options:[{label:e.t(T.CUSTOM.label),value:T.CUSTOM.operator}]}],[t,e])}function dn(e){const t=e.getCurrentLocale();return h.useMemo(()=>T.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:e.t(r.label),value:r.operator})),[t,e])}function Ve(){return Ve=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Ve.apply(this,arguments)}function le(e){"@babel/helpers - typeof";return le=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},le(e)}function mn(e,t){if(le(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t||"default");if(le(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ar(e){var t=mn(e,"string");return le(t)=="symbol"?t:t+""}function Z(e,t,r){return t=ar(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function sr(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),r.push.apply(r,n)}return r}function ee(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sr(Object(r),!0).forEach(function(n){Z(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sr(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function vn(e){if(Array.isArray(e))return e}function pn(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n,o,s,i,a=[],l=!0,u=!1;try{if(s=(r=r.call(e)).next,t===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=s.call(r)).done)&&(a.push(n.value),a.length!==t);l=!0);}catch(f){u=!0,o=f}finally{try{if(!l&&r.return!=null&&(i=r.return(),Object(i)!==i))return}finally{if(u)throw o}}return a}}function lr(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Sn(e,t){if(e){if(typeof e=="string")return lr(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return lr(e,t)}}function gn(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function q(e,t){return vn(e)||pn(e,t)||Sn(e,t)||gn()}function _n(e,t){if(e==null)return{};var r={},n=Object.keys(e),o,s;for(s=0;s<n.length;s++)o=n[s],!(t.indexOf(o)>=0)&&(r[o]=e[o]);return r}function En(e,t){if(e==null)return{};var r=_n(e,t),n,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)n=s[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function yn(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ur={exports:{}};/*!
3
+ Copyright (c) 2018 Jed Watson.
4
+ Licensed under the MIT License (MIT), see
5
+ http://jedwatson.github.io/classnames
6
+ */(function(e){(function(){var t={}.hasOwnProperty;function r(){for(var s="",i=0;i<arguments.length;i++){var a=arguments[i];a&&(s=o(s,n(a)))}return s}function n(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return r.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var a in s)t.call(s,a)&&s[a]&&(i=o(i,a));return i}function o(s,i){return i?s?s+" "+i:s+i:s}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(ur);var bn=ur.exports;const rt=yn(bn);var cr={exports:{}},A={};/**
7
+ * @license React
8
+ * react-is.production.min.js
9
+ *
10
+ * Copyright (c) Facebook, Inc. and its affiliates.
11
+ *
12
+ * This source code is licensed under the MIT license found in the
13
+ * LICENSE file in the root directory of this source tree.
14
+ */var Mt=Symbol.for("react.element"),wt=Symbol.for("react.portal"),nt=Symbol.for("react.fragment"),it=Symbol.for("react.strict_mode"),ot=Symbol.for("react.profiler"),at=Symbol.for("react.provider"),st=Symbol.for("react.context"),On=Symbol.for("react.server_context"),lt=Symbol.for("react.forward_ref"),ut=Symbol.for("react.suspense"),ct=Symbol.for("react.suspense_list"),ft=Symbol.for("react.memo"),ht=Symbol.for("react.lazy"),Tn=Symbol.for("react.offscreen"),fr;fr=Symbol.for("react.module.reference");function ie(e){if(typeof e=="object"&&e!==null){var t=e.$$typeof;switch(t){case Mt:switch(e=e.type,e){case nt:case ot:case it:case ut:case ct:return e;default:switch(e=e&&e.$$typeof,e){case On:case st:case lt:case ht:case ft:case at:return e;default:return t}}case wt:return t}}}A.ContextConsumer=st,A.ContextProvider=at,A.Element=Mt,A.ForwardRef=lt,A.Fragment=nt,A.Lazy=ht,A.Memo=ft,A.Portal=wt,A.Profiler=ot,A.StrictMode=it,A.Suspense=ut,A.SuspenseList=ct,A.isAsyncMode=function(){return!1},A.isConcurrentMode=function(){return!1},A.isContextConsumer=function(e){return ie(e)===st},A.isContextProvider=function(e){return ie(e)===at},A.isElement=function(e){return typeof e=="object"&&e!==null&&e.$$typeof===Mt},A.isForwardRef=function(e){return ie(e)===lt},A.isFragment=function(e){return ie(e)===nt},A.isLazy=function(e){return ie(e)===ht},A.isMemo=function(e){return ie(e)===ft},A.isPortal=function(e){return ie(e)===wt},A.isProfiler=function(e){return ie(e)===ot},A.isStrictMode=function(e){return ie(e)===it},A.isSuspense=function(e){return ie(e)===ut},A.isSuspenseList=function(e){return ie(e)===ct},A.isValidElementType=function(e){return typeof e=="string"||typeof e=="function"||e===nt||e===ot||e===it||e===ut||e===ct||e===Tn||typeof e=="object"&&e!==null&&(e.$$typeof===ht||e.$$typeof===ft||e.$$typeof===at||e.$$typeof===st||e.$$typeof===lt||e.$$typeof===fr||e.getModuleId!==void 0)},A.typeOf=ie,cr.exports=A;var dt=cr.exports;function At(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=[];return h.Children.forEach(e,function(n){n==null&&!t.keepEmpty||(Array.isArray(n)?r=r.concat(At(n)):dt.isFragment(n)&&n.props?r=r.concat(At(n.props.children,t)):r.push(n))}),r}function Cn(e){return e instanceof HTMLElement||e instanceof SVGElement}function mt(e){return Cn(e)?e:e instanceof h.Component?It.findDOMNode(e):null}function Fn(e,t,r){var n=p.useRef({});return(!("value"in n.current)||r(n.current.condition,t))&&(n.current.value=e(),n.current.condition=t),n.current.value}function Rn(e,t){typeof e=="function"?e(t):le(e)==="object"&&e&&"current"in e&&(e.current=t)}function In(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=t.filter(function(o){return o});return n.length<=1?n[0]:function(o){t.forEach(function(s){Rn(s,o)})}}function Pn(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Fn(function(){return In.apply(void 0,t)},t,function(n,o){return n.length!==o.length||n.every(function(s,i){return s!==o[i]})})}function Nn(e){var t,r,n=dt.isMemo(e)?e.type.type:e.type;return!(typeof n=="function"&&!((t=n.prototype)!==null&&t!==void 0&&t.render)&&n.$$typeof!==dt.ForwardRef||typeof e=="function"&&!((r=e.prototype)!==null&&r!==void 0&&r.render)&&e.$$typeof!==dt.ForwardRef)}var Lt=p.createContext(null);function Mn(e){var t=e.children,r=e.onBatchResize,n=p.useRef(0),o=p.useRef([]),s=p.useContext(Lt),i=p.useCallback(function(a,l,u){n.current+=1;var f=n.current;o.current.push({size:a,element:l,data:u}),Promise.resolve().then(function(){f===n.current&&(r==null||r(o.current),o.current=[])}),s==null||s(a,l,u)},[r,s]);return p.createElement(Lt.Provider,{value:i},t)}var hr=function(){if(typeof Map<"u")return Map;function e(t,r){var n=-1;return t.some(function(o,s){return o[0]===r?(n=s,!0):!1}),n}return function(){function t(){this.__entries__=[]}return Object.defineProperty(t.prototype,"size",{get:function(){return this.__entries__.length},enumerable:!0,configurable:!0}),t.prototype.get=function(r){var n=e(this.__entries__,r),o=this.__entries__[n];return o&&o[1]},t.prototype.set=function(r,n){var o=e(this.__entries__,r);~o?this.__entries__[o][1]=n:this.__entries__.push([r,n])},t.prototype.delete=function(r){var n=this.__entries__,o=e(n,r);~o&&n.splice(o,1)},t.prototype.has=function(r){return!!~e(this.__entries__,r)},t.prototype.clear=function(){this.__entries__.splice(0)},t.prototype.forEach=function(r,n){n===void 0&&(n=null);for(var o=0,s=this.__entries__;o<s.length;o++){var i=s[o];r.call(n,i[1],i[0])}},t}()}(),Dt=typeof window<"u"&&typeof document<"u"&&window.document===document,vt=function(){return typeof global<"u"&&global.Math===Math?global:typeof self<"u"&&self.Math===Math?self:typeof window<"u"&&window.Math===Math?window:Function("return this")()}(),wn=function(){return typeof requestAnimationFrame=="function"?requestAnimationFrame.bind(vt):function(e){return setTimeout(function(){return e(Date.now())},1e3/60)}}(),An=2;function Ln(e,t){var r=!1,n=!1,o=0;function s(){r&&(r=!1,e()),n&&a()}function i(){wn(s)}function a(){var l=Date.now();if(r){if(l-o<An)return;n=!0}else r=!0,n=!1,setTimeout(i,t);o=l}return a}var Dn=20,Hn=["top","right","bottom","left","width","height","size","weight"],Un=typeof MutationObserver<"u",$n=function(){function e(){this.connected_=!1,this.mutationEventsAdded_=!1,this.mutationsObserver_=null,this.observers_=[],this.onTransitionEnd_=this.onTransitionEnd_.bind(this),this.refresh=Ln(this.refresh.bind(this),Dn)}return e.prototype.addObserver=function(t){~this.observers_.indexOf(t)||this.observers_.push(t),this.connected_||this.connect_()},e.prototype.removeObserver=function(t){var r=this.observers_,n=r.indexOf(t);~n&&r.splice(n,1),!r.length&&this.connected_&&this.disconnect_()},e.prototype.refresh=function(){var t=this.updateObservers_();t&&this.refresh()},e.prototype.updateObservers_=function(){var t=this.observers_.filter(function(r){return r.gatherActive(),r.hasActive()});return t.forEach(function(r){return r.broadcastActive()}),t.length>0},e.prototype.connect_=function(){!Dt||this.connected_||(document.addEventListener("transitionend",this.onTransitionEnd_),window.addEventListener("resize",this.refresh),Un?(this.mutationsObserver_=new MutationObserver(this.refresh),this.mutationsObserver_.observe(document,{attributes:!0,childList:!0,characterData:!0,subtree:!0})):(document.addEventListener("DOMSubtreeModified",this.refresh),this.mutationEventsAdded_=!0),this.connected_=!0)},e.prototype.disconnect_=function(){!Dt||!this.connected_||(document.removeEventListener("transitionend",this.onTransitionEnd_),window.removeEventListener("resize",this.refresh),this.mutationsObserver_&&this.mutationsObserver_.disconnect(),this.mutationEventsAdded_&&document.removeEventListener("DOMSubtreeModified",this.refresh),this.mutationsObserver_=null,this.mutationEventsAdded_=!1,this.connected_=!1)},e.prototype.onTransitionEnd_=function(t){var r=t.propertyName,n=r===void 0?"":r,o=Hn.some(function(s){return!!~n.indexOf(s)});o&&this.refresh()},e.getInstance=function(){return this.instance_||(this.instance_=new e),this.instance_},e.instance_=null,e}(),dr=function(e,t){for(var r=0,n=Object.keys(t);r<n.length;r++){var o=n[r];Object.defineProperty(e,o,{value:t[o],enumerable:!1,writable:!1,configurable:!0})}return e},Me=function(e){var t=e&&e.ownerDocument&&e.ownerDocument.defaultView;return t||vt},mr=St(0,0,0,0);function pt(e){return parseFloat(e)||0}function vr(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];return t.reduce(function(n,o){var s=e["border-"+o+"-width"];return n+pt(s)},0)}function xn(e){for(var t=["top","right","bottom","left"],r={},n=0,o=t;n<o.length;n++){var s=o[n],i=e["padding-"+s];r[s]=pt(i)}return r}function Bn(e){var t=e.getBBox();return St(0,0,t.width,t.height)}function Vn(e){var t=e.clientWidth,r=e.clientHeight;if(!t&&!r)return mr;var n=Me(e).getComputedStyle(e),o=xn(n),s=o.left+o.right,i=o.top+o.bottom,a=pt(n.width),l=pt(n.height);if(n.boxSizing==="border-box"&&(Math.round(a+s)!==t&&(a-=vr(n,"left","right")+s),Math.round(l+i)!==r&&(l-=vr(n,"top","bottom")+i)),!jn(e)){var u=Math.round(a+s)-t,f=Math.round(l+i)-r;Math.abs(u)!==1&&(a-=u),Math.abs(f)!==1&&(l-=f)}return St(o.left,o.top,a,l)}var Wn=function(){return typeof SVGGraphicsElement<"u"?function(e){return e instanceof Me(e).SVGGraphicsElement}:function(e){return e instanceof Me(e).SVGElement&&typeof e.getBBox=="function"}}();function jn(e){return e===Me(e).document.documentElement}function kn(e){return Dt?Wn(e)?Bn(e):Vn(e):mr}function zn(e){var t=e.x,r=e.y,n=e.width,o=e.height,s=typeof DOMRectReadOnly<"u"?DOMRectReadOnly:Object,i=Object.create(s.prototype);return dr(i,{x:t,y:r,width:n,height:o,top:r,right:t+n,bottom:o+r,left:t}),i}function St(e,t,r,n){return{x:e,y:t,width:r,height:n}}var Qn=function(){function e(t){this.broadcastWidth=0,this.broadcastHeight=0,this.contentRect_=St(0,0,0,0),this.target=t}return e.prototype.isActive=function(){var t=kn(this.target);return this.contentRect_=t,t.width!==this.broadcastWidth||t.height!==this.broadcastHeight},e.prototype.broadcastRect=function(){var t=this.contentRect_;return this.broadcastWidth=t.width,this.broadcastHeight=t.height,t},e}(),Gn=function(){function e(t,r){var n=zn(r);dr(this,{target:t,contentRect:n})}return e}(),qn=function(){function e(t,r,n){if(this.activeObservations_=[],this.observations_=new hr,typeof t!="function")throw new TypeError("The callback provided as parameter 1 is not a function.");this.callback_=t,this.controller_=r,this.callbackCtx_=n}return e.prototype.observe=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof Me(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(t)||(r.set(t,new Qn(t)),this.controller_.addObserver(this),this.controller_.refresh())}},e.prototype.unobserve=function(t){if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");if(!(typeof Element>"u"||!(Element instanceof Object))){if(!(t instanceof Me(t).Element))throw new TypeError('parameter 1 is not of type "Element".');var r=this.observations_;r.has(t)&&(r.delete(t),r.size||this.controller_.removeObserver(this))}},e.prototype.disconnect=function(){this.clearActive(),this.observations_.clear(),this.controller_.removeObserver(this)},e.prototype.gatherActive=function(){var t=this;this.clearActive(),this.observations_.forEach(function(r){r.isActive()&&t.activeObservations_.push(r)})},e.prototype.broadcastActive=function(){if(this.hasActive()){var t=this.callbackCtx_,r=this.activeObservations_.map(function(n){return new Gn(n.target,n.broadcastRect())});this.callback_.call(t,r,t),this.clearActive()}},e.prototype.clearActive=function(){this.activeObservations_.splice(0)},e.prototype.hasActive=function(){return this.activeObservations_.length>0},e}(),pr=typeof WeakMap<"u"?new WeakMap:new hr,Sr=function(){function e(t){if(!(this instanceof e))throw new TypeError("Cannot call a class as a function.");if(!arguments.length)throw new TypeError("1 argument required, but only 0 present.");var r=$n.getInstance(),n=new qn(t,r,this);pr.set(this,n)}return e}();["observe","unobserve","disconnect"].forEach(function(e){Sr.prototype[e]=function(){var t;return(t=pr.get(this))[e].apply(t,arguments)}});var Yn=function(){return typeof vt.ResizeObserver<"u"?vt.ResizeObserver:Sr}(),_e=new Map;function Xn(e){e.forEach(function(t){var r,n=t.target;(r=_e.get(n))===null||r===void 0||r.forEach(function(o){return o(n)})})}var gr=new Yn(Xn);function Kn(e,t){_e.has(e)||(_e.set(e,new Set),gr.observe(e)),_e.get(e).add(t)}function Zn(e,t){_e.has(e)&&(_e.get(e).delete(t),_e.get(e).size||(gr.unobserve(e),_e.delete(e)))}function _r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Er(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,ar(n.key),n)}}function yr(e,t,r){return t&&Er(e.prototype,t),r&&Er(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Ht(e,t){return Ht=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,o){return n.__proto__=o,n},Ht(e,t)}function Jn(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ht(e,t)}function gt(e){return gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},gt(e)}function br(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(br=function(){return!!e})()}function ei(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function ti(e,t){if(t&&(le(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return ei(e)}function ri(e){var t=br();return function(){var n=gt(e),o;if(t){var s=gt(this).constructor;o=Reflect.construct(n,arguments,s)}else o=n.apply(this,arguments);return ti(this,o)}}var ni=function(e){Jn(r,e);var t=ri(r);function r(){return _r(this,r),t.apply(this,arguments)}return yr(r,[{key:"render",value:function(){return this.props.children}}]),r}(p.Component);function ii(e,t){var r=e.children,n=e.disabled,o=p.useRef(null),s=p.useRef(null),i=p.useContext(Lt),a=typeof r=="function",l=a?r(o):r,u=p.useRef({width:-1,height:-1,offsetWidth:-1,offsetHeight:-1}),f=!a&&p.isValidElement(l)&&Nn(l),d=f?l.ref:null,v=Pn(d,o),m=function(){var y;return mt(o.current)||(o.current&&le(o.current)==="object"?mt((y=o.current)===null||y===void 0?void 0:y.nativeElement):null)||mt(s.current)};p.useImperativeHandle(t,function(){return m()});var _=p.useRef(e);_.current=e;var E=p.useCallback(function(g){var y=_.current,C=y.onResize,L=y.data,R=g.getBoundingClientRect(),V=R.width,U=R.height,F=g.offsetWidth,$=g.offsetHeight,W=Math.floor(V),z=Math.floor(U);if(u.current.width!==W||u.current.height!==z||u.current.offsetWidth!==F||u.current.offsetHeight!==$){var te={width:W,height:z,offsetWidth:F,offsetHeight:$};u.current=te;var Y=F===Math.round(V)?V:F,oe=$===Math.round(U)?U:$,X=ee(ee({},te),{},{offsetWidth:Y,offsetHeight:oe});i==null||i(X,g,L),C&&Promise.resolve().then(function(){C(X,g)})}},[]);return p.useEffect(function(){var g=m();return g&&!n&&Kn(g,E),function(){return Zn(g,E)}},[o.current,n]),p.createElement(ni,{ref:s},f?p.cloneElement(l,{ref:v}):l)}var oi=p.forwardRef(ii),ai="rc-observer-key";function si(e,t){var r=e.children,n=typeof r=="function"?[r]:At(r);return n.map(function(o,s){var i=(o==null?void 0:o.key)||"".concat(ai,"-").concat(s);return p.createElement(oi,Ve({},e,{key:i,ref:s===0?t:void 0}),o)})}var Ut=p.forwardRef(si);Ut.Collection=Mn;var Or=p.forwardRef(function(e,t){var r=e.height,n=e.offsetY,o=e.offsetX,s=e.children,i=e.prefixCls,a=e.onInnerResize,l=e.innerProps,u=e.rtl,f=e.extra,d={},v={display:"flex",flexDirection:"column"};return n!==void 0&&(d={height:r,position:"relative",overflow:"hidden"},v=ee(ee({},v),{},Z(Z(Z(Z(Z({transform:"translateY(".concat(n,"px)")},u?"marginRight":"marginLeft",-o),"position","absolute"),"left",0),"right",0),"top",0))),p.createElement("div",{style:d},p.createElement(Ut,{onResize:function(_){var E=_.offsetHeight;E&&a&&a()}},p.createElement("div",Ve({style:v,className:rt(Z({},"".concat(i,"-holder-inner"),i)),ref:t},l),s,f)))});Or.displayName="Filler";var Tr=function(t){return+setTimeout(t,16)},Cr=function(t){return clearTimeout(t)};typeof window<"u"&&"requestAnimationFrame"in window&&(Tr=function(t){return window.requestAnimationFrame(t)},Cr=function(t){return window.cancelAnimationFrame(t)});var Fr=0,$t=new Map;function Rr(e){$t.delete(e)}var ue=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1;Fr+=1;var n=Fr;function o(s){if(s===0)Rr(n),t();else{var i=Tr(function(){o(s-1)});$t.set(n,i)}}return o(r),n};ue.cancel=function(e){var t=$t.get(e);return Rr(e),Cr(t)};function Ir(e,t){var r="touches"in e?e.touches[0]:e;return r[t?"pageX":"pageY"]}var Pr=p.forwardRef(function(e,t){var r=e.prefixCls,n=e.rtl,o=e.scrollOffset,s=e.scrollRange,i=e.onStartMove,a=e.onStopMove,l=e.onScroll,u=e.horizontal,f=e.spinSize,d=e.containerSize,v=e.style,m=e.thumbStyle,_=p.useState(!1),E=q(_,2),g=E[0],y=E[1],C=p.useState(null),L=q(C,2),R=L[0],V=L[1],U=p.useState(null),F=q(U,2),$=F[0],W=F[1],z=!n,te=p.useRef(),Y=p.useRef(),oe=p.useState(!1),X=q(oe,2),we=X[0],re=X[1],Te=p.useRef(),ce=function(){clearTimeout(Te.current),re(!0),Te.current=setTimeout(function(){re(!1)},3e3)},J=s-d||0,je=d-f||0,x=p.useMemo(function(){if(o===0||J===0)return 0;var Q=o/J;return Q*je},[o,J,je]),Ce=function(j){j.stopPropagation(),j.preventDefault()},Ae=p.useRef({top:x,dragging:g,pageY:R,startTop:$});Ae.current={top:x,dragging:g,pageY:R,startTop:$};var ke=function(j){y(!0),V(Ir(j,u)),W(Ae.current.top),i(),j.stopPropagation(),j.preventDefault()};p.useEffect(function(){var Q=function(Ge){Ge.preventDefault()},j=te.current,pe=Y.current;return j.addEventListener("touchstart",Q),pe.addEventListener("touchstart",ke),function(){j.removeEventListener("touchstart",Q),pe.removeEventListener("touchstart",ke)}},[]);var ze=p.useRef();ze.current=J;var fe=p.useRef();fe.current=je,p.useEffect(function(){if(g){var Q,j=function(Ge){var Le=Ae.current,Ot=Le.dragging,Tt=Le.pageY,Vt=Le.startTop;if(ue.cancel(Q),Ot){var Fe=Ir(Ge,u)-Tt,De=Vt;!z&&u?De-=Fe:De+=Fe;var Ct=ze.current,Ft=fe.current,Wt=Ft?De/Ft:0,Re=Math.ceil(Wt*Ct);Re=Math.max(Re,0),Re=Math.min(Re,Ct),Q=ue(function(){l(Re,u)})}},pe=function(){y(!1),a()};return window.addEventListener("mousemove",j),window.addEventListener("touchmove",j),window.addEventListener("mouseup",pe),window.addEventListener("touchend",pe),function(){window.removeEventListener("mousemove",j),window.removeEventListener("touchmove",j),window.removeEventListener("mouseup",pe),window.removeEventListener("touchend",pe),ue.cancel(Q)}}},[g]),p.useEffect(function(){ce()},[o]),p.useImperativeHandle(t,function(){return{delayHidden:ce}});var be="".concat(r,"-scrollbar"),ae={position:"absolute",visibility:we?null:"hidden"},he={position:"absolute",background:"rgba(0, 0, 0, 0.5)",borderRadius:99,cursor:"pointer",userSelect:"none"};return u?(ae.height=8,ae.left=0,ae.right=0,ae.bottom=0,he.height="100%",he.width=f,z?he.left=x:he.right=x):(ae.width=8,ae.top=0,ae.bottom=0,z?ae.right=0:ae.left=0,he.width="100%",he.height=f,he.top=x),p.createElement("div",{ref:te,className:rt(be,Z(Z(Z({},"".concat(be,"-horizontal"),u),"".concat(be,"-vertical"),!u),"".concat(be,"-visible"),we)),style:ee(ee({},ae),v),onMouseDown:Ce,onMouseMove:ce},p.createElement("div",{ref:Y,className:rt("".concat(be,"-thumb"),Z({},"".concat(be,"-thumb-moving"),g)),style:ee(ee({},he),m),onMouseDown:ke}))});function li(e){var t=e.children,r=e.setRef,n=p.useCallback(function(o){r(o)},[]);return p.cloneElement(t,{ref:n})}function ui(e,t,r,n,o,s,i){var a=i.getKey;return e.slice(t,r+1).map(function(l,u){var f=t+u,d=s(l,f,{style:{width:n}}),v=a(l);return p.createElement(li,{key:v,setRef:function(_){return o(l,_)}},d)})}var ci=function(){function e(){_r(this,e),Z(this,"maps",void 0),Z(this,"id",0),this.maps=Object.create(null)}return yr(e,[{key:"set",value:function(r,n){this.maps[r]=n,this.id+=1}},{key:"get",value:function(r){return this.maps[r]}}]),e}();function fi(e,t,r){var n=p.useState(0),o=q(n,2),s=o[0],i=o[1],a=h.useRef(new Map),l=h.useRef(new ci),u=h.useRef();function f(){ue.cancel(u.current)}function d(){var m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;f();var _=function(){a.current.forEach(function(g,y){if(g&&g.offsetParent){var C=mt(g),L=C.offsetHeight;l.current.get(y)!==L&&l.current.set(y,C.offsetHeight)}}),i(function(g){return g+1})};m?_():u.current=ue(_)}function v(m,_){var E=e(m),g=a.current.get(E);_?(a.current.set(E,_),d()):a.current.delete(E),!g!=!_&&(_?t==null||t(m):r==null||r(m))}return h.useEffect(function(){return f},[]),[v,d,l.current,s]}function hi(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}var Nr=hi()?p.useLayoutEffect:p.useEffect,We=function(t,r){var n=p.useRef(!0);Nr(function(){return t(n.current)},r),Nr(function(){return n.current=!1,function(){n.current=!0}},[])};function Mr(e){var t=p.useRef();t.current=e;var r=p.useCallback(function(){for(var n,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];return(n=t.current)===null||n===void 0?void 0:n.call.apply(n,[t].concat(s))},[]);return r}var di=10;function mi(e,t,r,n,o,s,i,a){var l=p.useRef(),u=p.useState(null),f=q(u,2),d=f[0],v=f[1];return We(function(){if(d&&d.times<di){if(!e.current){v(function(J){return ee({},J)});return}s();var m=d.targetAlign,_=d.originAlign,E=d.index,g=d.offset,y=e.current.clientHeight,C=!1,L=m,R=null;if(y){for(var V=m||_,U=0,F=0,$=0,W=Math.min(t.length-1,E),z=0;z<=W;z+=1){var te=o(t[z]);F=U;var Y=r.get(te);$=F+(Y===void 0?n:Y),U=$}for(var oe=V==="top"?g:y-g,X=W;X>=0;X-=1){var we=o(t[X]),re=r.get(we);if(re===void 0){C=!0;break}if(oe-=re,oe<=0)break}switch(V){case"top":R=F-g;break;case"bottom":R=$-y+g;break;default:{var Te=e.current.scrollTop,ce=Te+y;F<Te?L="top":$>ce&&(L="bottom")}}R!==null&&i(R),R!==d.lastTop&&(C=!0)}C&&v(ee(ee({},d),{},{times:d.times+1,targetAlign:L,lastTop:R}))}},[d,e.current]),function(m){if(m==null){a();return}if(ue.cancel(l.current),typeof m=="number")i(m);else if(m&&le(m)==="object"){var _,E=m.align;"index"in m?_=m.index:_=t.findIndex(function(C){return o(C)===m.key});var g=m.offset,y=g===void 0?0:g;v({times:0,index:_,offset:y,originAlign:E})}}}function vi(e,t,r){var n=e.length,o=t.length,s,i;if(n===0&&o===0)return null;n<o?(s=e,i=t):(s=t,i=e);var a={__EMPTY_ITEM__:!0};function l(_){return _!==void 0?r(_):a}for(var u=null,f=Math.abs(n-o)!==1,d=0;d<i.length;d+=1){var v=l(s[d]),m=l(i[d]);if(v!==m){u=d,f=f||v!==l(i[d+1]);break}}return u===null?null:{index:u,multiple:f}}function pi(e,t,r){var n=p.useState(e),o=q(n,2),s=o[0],i=o[1],a=p.useState(null),l=q(a,2),u=l[0],f=l[1];return p.useEffect(function(){var d=vi(s||[],e||[],t);(d==null?void 0:d.index)!==void 0&&(r==null||r(d.index),f(e[d.index])),i(e)},[e]),[u]}var wr=(typeof navigator>"u"?"undefined":le(navigator))==="object"&&/Firefox/i.test(navigator.userAgent);const Ar=function(e,t){var r=h.useRef(!1),n=h.useRef(null);function o(){clearTimeout(n.current),r.current=!0,n.current=setTimeout(function(){r.current=!1},50)}var s=h.useRef({top:e,bottom:t});return s.current.top=e,s.current.bottom=t,function(i){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,l=i<0&&s.current.top||i>0&&s.current.bottom;return a&&l?(clearTimeout(n.current),r.current=!1):(!l||r.current)&&o(),!r.current&&l}};function Si(e,t,r,n,o){var s=h.useRef(0),i=h.useRef(null),a=h.useRef(null),l=h.useRef(!1),u=Ar(t,r);function f(g,y){ue.cancel(i.current),s.current+=y,a.current=y,!u(y)&&(wr||g.preventDefault(),i.current=ue(function(){var C=l.current?10:1;o(s.current*C),s.current=0}))}function d(g,y){o(y,!0),wr||g.preventDefault()}var v=h.useRef(null),m=h.useRef(null);function _(g){if(e){ue.cancel(m.current),m.current=ue(function(){v.current=null},2);var y=g.deltaX,C=g.deltaY,L=g.shiftKey,R=y,V=C;(v.current==="sx"||!v.current&&L&&C&&!y)&&(R=C,V=0,v.current="sx");var U=Math.abs(R),F=Math.abs(V);v.current===null&&(v.current=n&&U>F?"x":"y"),v.current==="y"?f(g,V):d(g,R)}}function E(g){e&&(l.current=g.detail===a.current)}return[_,E]}var gi=14/15;function _i(e,t,r){var n=h.useRef(!1),o=h.useRef(0),s=h.useRef(null),i=h.useRef(null),a,l=function(v){if(n.current){var m=Math.ceil(v.touches[0].pageY),_=o.current-m;o.current=m,r(_)&&v.preventDefault(),clearInterval(i.current),i.current=setInterval(function(){_*=gi,(!r(_,!0)||Math.abs(_)<=.1)&&clearInterval(i.current)},16)}},u=function(){n.current=!1,a()},f=function(v){a(),v.touches.length===1&&!n.current&&(n.current=!0,o.current=Math.ceil(v.touches[0].pageY),s.current=v.target,s.current.addEventListener("touchmove",l),s.current.addEventListener("touchend",u))};a=function(){s.current&&(s.current.removeEventListener("touchmove",l),s.current.removeEventListener("touchend",u))},We(function(){return e&&t.current.addEventListener("touchstart",f),function(){var d;(d=t.current)===null||d===void 0||d.removeEventListener("touchstart",f),a(),clearInterval(i.current)}},[e])}var Ei=20;function Lr(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,r=e/t*e;return isNaN(r)&&(r=0),r=Math.max(r,Ei),Math.floor(r)}function yi(e,t,r,n){var o=p.useMemo(function(){return[new Map,[]]},[e,r.id,n]),s=q(o,2),i=s[0],a=s[1],l=function(f){var d=arguments.length>1&&arguments[1]!==void 0?arguments[1]:f,v=i.get(f),m=i.get(d);if(v===void 0||m===void 0)for(var _=e.length,E=a.length;E<_;E+=1){var g,y=e[E],C=t(y);i.set(C,E);var L=(g=r.get(C))!==null&&g!==void 0?g:n;if(a[E]=(a[E-1]||0)+L,C===f&&(v=E),C===d&&(m=E),v!==void 0&&m!==void 0)break}return{top:a[v-1]||0,bottom:a[m]}};return l}var bi=["prefixCls","className","height","itemHeight","fullHeight","style","data","children","itemKey","virtual","direction","scrollWidth","component","onScroll","onVirtualScroll","onVisibleChange","innerProps","extraRender","styles"],Oi=[],Ti={overflowY:"auto",overflowAnchor:"none"};function Ci(e,t){var r=e.prefixCls,n=r===void 0?"rc-virtual-list":r,o=e.className,s=e.height,i=e.itemHeight,a=e.fullHeight,l=a===void 0?!0:a,u=e.style,f=e.data,d=e.children,v=e.itemKey,m=e.virtual,_=e.direction,E=e.scrollWidth,g=e.component,y=g===void 0?"div":g,C=e.onScroll,L=e.onVirtualScroll,R=e.onVisibleChange,V=e.innerProps,U=e.extraRender,F=e.styles,$=En(e,bi),W=p.useCallback(function(b){return typeof v=="function"?v(b):b==null?void 0:b[v]},[v]),z=fi(W,null,null),te=q(z,4),Y=te[0],oe=te[1],X=te[2],we=te[3],re=!!(m!==!1&&s&&i),Te=p.useMemo(function(){return Object.values(X.maps).reduce(function(b,O){return b+O},0)},[X.id,X.maps]),ce=re&&f&&(Math.max(i*f.length,Te)>s||!!E),J=_==="rtl",je=rt(n,Z({},"".concat(n,"-rtl"),J),o),x=f||Oi,Ce=h.useRef(),Ae=h.useRef(),ke=h.useState(0),ze=q(ke,2),fe=ze[0],be=ze[1],ae=h.useState(0),he=q(ae,2),Q=he[0],j=he[1],pe=h.useState(!1),Qe=q(pe,2),Ge=Qe[0],Le=Qe[1],Ot=function(){Le(!0)},Tt=function(){Le(!1)},Vt={getKey:W};function Fe(b){be(function(O){var M;typeof b=="function"?M=b(O):M=b;var G=eo(M);return Ce.current.scrollTop=G,G})}var De=h.useRef({start:0,end:x.length}),Ct=h.useRef(),Ft=pi(x,W),Wt=q(Ft,1),Re=Wt[0];Ct.current=Re;var Rt=p.useMemo(function(){if(!re)return{scrollHeight:void 0,start:0,end:x.length-1,offset:void 0};if(!ce){var b;return{scrollHeight:((b=Ae.current)===null||b===void 0?void 0:b.offsetHeight)||0,start:0,end:x.length-1,offset:void 0}}for(var O=0,M,G,Oe,lo=x.length,Ke=0;Ke<lo;Ke+=1){var uo=x[Ke],co=W(uo),Kr=X.get(co),Xt=O+(Kr===void 0?i:Kr);Xt>=fe&&M===void 0&&(M=Ke,G=O),Xt>fe+s&&Oe===void 0&&(Oe=Ke),O=Xt}return M===void 0&&(M=0,G=0,Oe=Math.ceil(s/i)),Oe===void 0&&(Oe=x.length-1),Oe=Math.min(Oe+1,x.length-1),{scrollHeight:O,start:M,end:Oe,offset:G}},[ce,re,fe,x,we,s]),He=Rt.scrollHeight,qe=Rt.start,Ye=Rt.end,xr=Rt.offset;De.current.start=qe,De.current.end=Ye;var Yi=p.useState({width:0,height:s}),Br=q(Yi,2),Se=Br[0],Xi=Br[1],Ki=function(O){Xi({width:O.width||O.offsetWidth,height:O.height||O.offsetHeight})},Vr=h.useRef(),Wr=h.useRef(),Zi=p.useMemo(function(){return Lr(Se.width,E)},[Se.width,E]),Ji=p.useMemo(function(){return Lr(Se.height,He)},[Se.height,He]),jt=He-s,kt=h.useRef(jt);kt.current=jt;function eo(b){var O=b;return Number.isNaN(kt.current)||(O=Math.min(O,kt.current)),O=Math.max(O,0),O}var jr=fe<=0,kr=fe>=jt,to=Ar(jr,kr),zt=function(){return{x:J?-Q:Q,y:fe}},Qt=h.useRef(zt()),Gt=Mr(function(){if(L){var b=zt();(Qt.current.x!==b.x||Qt.current.y!==b.y)&&(L(b),Qt.current=b)}});function zr(b,O){var M=b;O?(It.flushSync(function(){j(M)}),Gt()):Fe(M)}function ro(b){var O=b.currentTarget.scrollTop;O!==fe&&Fe(O),C==null||C(b),Gt()}var qt=function(O){var M=O,G=E?E-Se.width:0;return M=Math.max(M,0),M=Math.min(M,G),M},no=Mr(function(b,O){O?(It.flushSync(function(){j(function(M){var G=M+(J?-b:b);return qt(G)})}),Gt()):Fe(function(M){var G=M+b;return G})}),io=Si(re,jr,kr,!!E,no),Qr=q(io,2),Yt=Qr[0],Gr=Qr[1];_i(re,Ce,function(b,O){return to(b,O)?!1:(Yt({preventDefault:function(){},deltaY:b}),!0)}),We(function(){function b(M){re&&M.preventDefault()}var O=Ce.current;return O.addEventListener("wheel",Yt),O.addEventListener("DOMMouseScroll",Gr),O.addEventListener("MozMousePixelScroll",b),function(){O.removeEventListener("wheel",Yt),O.removeEventListener("DOMMouseScroll",Gr),O.removeEventListener("MozMousePixelScroll",b)}},[re]),We(function(){E&&j(function(b){return qt(b)})},[Se.width,E]);var qr=function(){var O,M;(O=Vr.current)===null||O===void 0||O.delayHidden(),(M=Wr.current)===null||M===void 0||M.delayHidden()},Yr=mi(Ce,x,X,i,W,function(){return oe(!0)},Fe,qr);p.useImperativeHandle(t,function(){return{getScrollInfo:zt,scrollTo:function(O){function M(G){return G&&le(G)==="object"&&("left"in G||"top"in G)}M(O)?(O.left!==void 0&&j(qt(O.left)),Yr(O.top)):Yr(O)}}}),We(function(){if(R){var b=x.slice(qe,Ye+1);R(b,x)}},[qe,Ye,x]);var oo=yi(x,W,X,i),ao=U==null?void 0:U({start:qe,end:Ye,virtual:ce,offsetX:Q,offsetY:xr,rtl:J,getSize:oo}),so=ui(x,qe,Ye,E,Y,d,Vt),Xe=null;s&&(Xe=ee(Z({},l?"height":"maxHeight",s),Ti),re&&(Xe.overflowY="hidden",E&&(Xe.overflowX="hidden"),Ge&&(Xe.pointerEvents="none")));var Xr={};return J&&(Xr.dir="rtl"),p.createElement("div",Ve({style:ee(ee({},u),{},{position:"relative"}),className:je},Xr,$),p.createElement(Ut,{onResize:Ki},p.createElement(y,{className:"".concat(n,"-holder"),style:Xe,ref:Ce,onScroll:ro,onMouseEnter:qr},p.createElement(Or,{prefixCls:n,height:He,offsetX:Q,offsetY:xr,scrollWidth:E,onInnerResize:oe,ref:Ae,innerProps:V,rtl:J,extra:ao},so))),ce&&He>s&&p.createElement(Pr,{ref:Vr,prefixCls:n,scrollOffset:fe,scrollRange:He,rtl:J,onScroll:zr,onStartMove:Ot,onStopMove:Tt,spinSize:Ji,containerSize:Se.height,style:F==null?void 0:F.verticalScrollBar,thumbStyle:F==null?void 0:F.verticalScrollBarThumb}),ce&&E>Se.width&&p.createElement(Pr,{ref:Wr,prefixCls:n,scrollOffset:Q,scrollRange:E,rtl:J,onScroll:zr,onStartMove:Ot,onStopMove:Tt,spinSize:Zi,containerSize:Se.width,horizontal:!0,style:F==null?void 0:F.horizontalScrollBar,thumbStyle:F==null?void 0:F.horizontalScrollBarThumb}))}var Dr=p.forwardRef(Ci);Dr.displayName="List";function Fi(e){const{model:t}=e,r=$e.useDependency(S.LocaleService),n=H.useObservable(t.searchString$,"",!0),o=H.useObservable(t.filterItems$,void 0,!0),s=r.t("sheets-filter.panel.filter-only"),i=Pt(o),a=i.checked>0&&i.unchecked===0,l=i.checked>0&&i.unchecked>0,u=h.useCallback((m,_)=>{t.onFilterCheckToggled(m,_)},[t]),f=h.useCallback(m=>{t.onFilterOnly(m)},[t]),d=h.useCallback(()=>{t.onCheckAllToggled(!a)},[t,a]),v=h.useCallback(m=>{t.setSearchString(m)},[t]);return h.createElement("div",{className:B.sheetsFilterPanelValuesContainer},h.createElement(K.Input,{value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:v}),h.createElement("div",{className:B.sheetsFilterPanelValuesList},h.createElement("div",{className:B.sheetsFilterPanelValuesItem},h.createElement("div",{className:B.sheetsFilterPanelValuesItemInner},h.createElement(K.Checkbox,{indeterminate:l,disabled:o.length===0,checked:a,onChange:d}),h.createElement("span",{className:B.sheetsFilterPanelValuesItemText},`${r.t("sheets-filter.panel.select-all")}`),h.createElement("span",{className:B.sheetsFilterPanelValuesItemCount},`(${i.checked}/${i.checked+i.unchecked})`))),h.createElement("div",{className:B.sheetsFilterPanelValuesVirtual},h.createElement(Dr,{style:{paddingRight:8},data:o,height:190,itemHeight:32,itemKey:m=>`${m.value}----${m.checked}`},m=>h.createElement("div",{className:B.sheetsFilterPanelValuesItem},h.createElement("div",{className:B.sheetsFilterPanelValuesItemInner},h.createElement(K.Checkbox,{checked:m.checked,onChange:()=>u(m,!m.checked)}),h.createElement("span",{className:B.sheetsFilterPanelValuesItemText},m.value),h.createElement("span",{className:B.sheetsFilterPanelValuesItemCount},`(${m.count})`),h.createElement(K.Button,{className:B.sheetsFilterPanelValuesItemExcludeButton,size:"small",type:"link",onClick:()=>f(m)},s)))))))}function Ri(){const e=$e.useDependency(ge),t=$e.useDependency(S.LocaleService),r=$e.useDependency(S.ICommandService),n=H.useObservable(e.filterBy$,void 0,!0),o=H.useObservable(e.filterByModel$,void 0,!1),s=H.useObservable(()=>(o==null?void 0:o.canApply$)||N.of(!1),void 0,!1,[o]),i=Ii(t),a=!H.useObservable(e.hasCriteria$),l=h.useCallback(v=>{r.executeCommand(or.id,{filterBy:v})},[r]),u=h.useCallback(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(Be.id)},[o,r]),f=h.useCallback(()=>{r.executeCommand(Be.id)},[r]),d=h.useCallback(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(Be.id)},[o,r]);return h.createElement("div",{className:B.sheetsFilterPanel},h.createElement("div",{className:B.sheetsFilterPanelHeader},h.createElement(K.Segmented,{value:n,options:i,onChange:v=>l(v)})),o?h.createElement("div",{className:B.sheetsFilterPanelContent},n===Je.VALUES?h.createElement(Fi,{model:o}):h.createElement(fn,{model:o})):null,h.createElement("div",{className:B.sheetsFilterPanelFooter},h.createElement(K.Button,{type:"link",onClick:u,disabled:a},t.t("sheets-filter.panel.clear-filter")),h.createElement("span",{className:B.sheetsFilterPanelFooterPrimaryButtons},h.createElement(K.Button,{type:"default",onClick:f},t.t("sheets-filter.panel.cancel")),h.createElement(K.Button,{disabled:!s,type:"primary",onClick:d},t.t("sheets-filter.panel.confirm")))))}function Ii(e){const t=e.getCurrentLocale();return h.useMemo(()=>[{label:e.t("sheets-filter.panel.by-values"),value:Je.VALUES},{label:e.t("sheets-filter.panel.by-conditions"),value:Je.CONDITIONS}],[t,e])}const Pi={id:xe.id,binding:H.KeyCode.L|H.MetaKeys.CTRL_COMMAND|H.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:me.whenSheetEditorFocused,group:"4_sheet-edit"};function Ni(e){const t=e.get(c.SheetsFilterService);return{id:xe.id,group:H.MenuGroup.TOOLBAR_FORMULAS_INSERT,type:H.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",positions:[H.MenuPosition.TOOLBAR_START],hidden$:H.getMenuHiddenObservable(e,S.UniverInstanceType.UNIVER_SHEET),activated$:t.activeFilterModel$.pipe(N.map(r=>!!r))}}function Mi(e){const t=e.get(c.SheetsFilterService);return{id:tr.id,group:H.MenuGroup.TOOLBAR_OTHERS,type:H.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",positions:[xe.id],hidden$:H.getMenuHiddenObservable(e,S.UniverInstanceType.UNIVER_SHEET),disabled$:t.activeFilterModel$.pipe(N.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(N.map(o=>!o)))!=null?n:N.of(!0)}))}}function wi(e){const t=e.get(c.SheetsFilterService);return{id:rr.id,group:H.MenuGroup.TOOLBAR_OTHERS,type:H.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",positions:[xe.id],hidden$:H.getMenuHiddenObservable(e,S.UniverInstanceType.UNIVER_SHEET),disabled$:t.activeFilterModel$.pipe(N.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(N.map(o=>!o)))!=null?n:N.of(!0)}))}}var Ai=Object.defineProperty,Li=Object.getOwnPropertyDescriptor,Di=(e,t,r,n)=>{for(var o=n>1?void 0:n?Li(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Ai(t,r,o),o},Ee=(e,t)=>(r,n)=>t(r,n,e);const Hr="FILTER_PANEL_POPUP";let _t=class extends S.RxDisposable{constructor(t,r,n,o,s,i,a,l){super();P(this,"_popupDisposable");this._injector=t,this._componentManager=r,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=o,this._shortcutService=s,this._commandService=i,this._menuService=a,this._contextService=l,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[Pi].forEach(t=>{this.disposeWithMe(this._shortcutService.registerShortcut(t))})}_initCommands(){[xe,Ie,tr,rr,or,ir,Be].forEach(t=>{this.disposeWithMe(this._commandService.registerCommand(t))})}_initMenuItems(){[Ni,Mi,wi].forEach(t=>{this.disposeWithMe(this._menuService.addMenuItem(this._injector.invoke(t)))})}_initUI(){this.disposeWithMe(this._componentManager.register(Hr,Ri)),this.disposeWithMe(this._componentManager.register("FilterSingle",er)),this.disposeWithMe(this._contextService.subscribeContextValue$(Ne).pipe(N.distinctUntilChanged()).subscribe(t=>{t?this._openFilterPopup():this._closeFilterPopup()}))}_openFilterPopup(){const t=this._sheetsFilterPanelService.filterModel;if(!t)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=t.getRange(),n=this._sheetsFilterPanelService.col,{startRow:o}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(o,n,{componentKey:Hr,direction:"horizontal",closeOnSelfTarget:!0,onClickOutside:()=>this._commandService.syncExecuteCommand(Be.id)})}_closeFilterPopup(){var t;(t=this._popupDisposable)==null||t.dispose(),this._popupDisposable=null}};_t=Di([S.OnLifecycle(S.LifecycleStages.Ready,_t),Ee(0,w.Inject(w.Injector)),Ee(1,w.Inject(H.ComponentManager)),Ee(2,w.Inject(ge)),Ee(3,w.Inject(me.SheetCanvasPopManagerService)),Ee(4,H.IShortcutService),Ee(5,S.ICommandService),Ee(6,H.IMenuService),Ee(7,S.IContextService)],_t);const ye=16,Hi=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Ur{static drawNoCriteria(t,r,n,o){t.save(),Ze.Rect.drawWith(t,{radius:2,width:ye,height:ye,fill:o}),t.lineCap="square",t.strokeStyle=n,t.scale(r/ye,r/ye),t.beginPath(),t.lineWidth=1,t.lineCap="round",t.moveTo(3,4),t.lineTo(13,4),t.moveTo(4.5,8),t.lineTo(11.5,8),t.moveTo(6,12),t.lineTo(10,12),t.stroke(),t.restore()}static drawHasCriteria(t,r,n,o){t.save(),Ze.Rect.drawWith(t,{radius:2,width:ye,height:ye,fill:o}),t.scale(r/ye,r/ye),t.fillStyle=n,t.fill(Hi),t.restore()}}var Ui=Object.defineProperty,$i=Object.getOwnPropertyDescriptor,xi=(e,t,r,n)=>{for(var o=n>1?void 0:n?$i(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Ui(t,r,o),o},xt=(e,t)=>(r,n)=>t(r,n,e);const ve=16,Et=1;let Bt=class extends Ze.Shape{constructor(t,r,n,o,s){super(t,r);P(this,"_cellWidth",0);P(this,"_cellHeight",0);P(this,"_filterParams");P(this,"_hovered",!1);this._contextService=n,this._commandService=o,this._themeService=s,this.setShapeProps(r),this.onPointerDownObserver.add(i=>this.onPointerDown(i)),this.onPointerEnterObserver.add(()=>this.onPointerEnter()),this.onPointerLeaveObserver.add(()=>this.onPointerLeave())}setShapeProps(t){typeof t.cellHeight<"u"&&(this._cellHeight=t.cellHeight),typeof t.cellWidth<"u"&&(this._cellWidth=t.cellWidth),typeof t.filterParams<"u"&&(this._filterParams=t.filterParams),this.transformByState({width:t.width,height:t.height})}_draw(t){const r=this._cellHeight,n=this._cellWidth,o=ve-n,s=ve-r;t.save();const i=new Path2D;i.rect(o,s,n,r),t.clip(i);const{hasCriteria:a}=this._filterParams,l=this._themeService.getCurrentTheme().primaryColor,u=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";a?Ur.drawHasCriteria(t,ve,l,u):Ur.drawNoCriteria(t,ve,l,u),t.restore()}onPointerDown(t){if(t.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(Ne)||setTimeout(()=>{this._commandService.executeCommand(ir.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Bt=xi([xt(2,S.IContextService),xt(3,S.ICommandService),xt(4,w.Inject(S.ThemeService))],Bt);var Bi=Object.defineProperty,Vi=Object.getOwnPropertyDescriptor,Wi=(e,t,r,n)=>{for(var o=n>1?void 0:n?Vi(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&Bi(t,r,o),o},de=(e,t)=>(r,n)=>t(r,n,e);const ji=1e3,ki=5e3;let yt=class extends S.RxDisposable{constructor(t,r,n,o,s,i,a,l,u,f){super();P(this,"_filterRangeShape",null);P(this,"_buttonRenderDisposable",null);P(this,"_filterButtonShapes",[]);this._injector=t,this._sheetSkeletonManagerService=r,this._sheetsFilterService=n,this._themeService=o,this._sheetInterceptorService=s,this._sheetRenderController=i,this._commandService=a,this._univerInstanceService=l,this._renderManagerService=u,this._selectionRenderService=f,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(d=>this.disposeWithMe(this._sheetRenderController.registerSkeletonChangingMutations(d.id))),this._initRenderer()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(N.switchMap(t=>{var a;if(!t)return N.of(null);const{unitId:r}=t,n=this._univerInstanceService.getUniverSheetInstance(r);if(!n)return N.of(null);const o=n.getActiveSheet().getSheetId(),s=(a=this._sheetsFilterService.getFilterModel(r,o))!=null?a:void 0,i=()=>({unitId:r,worksheetId:o,filterModel:s,range:s==null?void 0:s.getRange(),skeleton:t.skeleton});return S.fromCallback(this._commandService.onCommandExecuted).pipe(N.filter(([l])=>l.type===S.CommandType.MUTATION&&l.params.unitId===n.getUnitId()&&c.FILTER_MUTATIONS.has(l.id)),N.throttleTime(20,void 0,{leading:!1,trailing:!0}),N.map(i),N.startWith(i()))}),N.takeUntil(this.dispose$)).subscribe(t=>{this._disposeRendering(),!(!t||!t.range)&&(this._renderRange(t.unitId,t.range,t.skeleton),this._renderButtons(t))})}_renderRange(t,r,n){const o=this._renderManagerService.getRenderById(t);if(!o)return;const{scene:s}=o,{rangeWithCoord:i,style:a}=this._selectionRenderService.convertSelectionRangeToData({range:r,primary:null,style:null}),{rowHeaderWidth:l,columnHeaderHeight:u}=n,f=this._filterRangeShape=new me.SelectionShape(s,ji,!0,this._themeService);f.update(i,l,u,{hasAutoFill:!1,fill:"rgba(0, 0, 0, 0.0)",...a}),f.setEvent(!1),s.makeDirty(!0)}_renderButtons(t){const{range:r,filterModel:n,unitId:o,skeleton:s,worksheetId:i}=t,a=this._renderManagerService.getRenderById(o);if(!a)return;const{scene:l}=a;this._interceptCellContent(t.range);const{startColumn:u,endColumn:f,startRow:d}=r;for(let v=u;v<=f;v++){const m=`sheets-filter-button-${v}`,_=me.getCoordByCell(d,v,l,s),{startX:E,startY:g,endX:y,endY:C}=_,L=y-E,R=C-g;if(R<=Et||L<=Et)continue;const V=!!n.getFilterColumn(v),U=y-ve-Et,F=C-ve-Et,$={left:U,top:F,height:ve,width:ve,cellHeight:R,cellWidth:L,filterParams:{unitId:o,subUnitId:i,col:v,hasCriteria:V}},W=this._injector.createInstance(Bt,m,$);this._filterButtonShapes.push(W)}l.addObjects(this._filterButtonShapes,ki),l.makeDirty()}_interceptCellContent(t){const{startRow:r,startColumn:n,endColumn:o}=t;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(Ue.INTERCEPTOR_POINT.CELL_CONTENT,{handler:(s,i,a)=>{const{row:l,col:u}=i;return l!==r||u<n||u>o?a(s):a({...s,fontRenderExtension:{...s==null?void 0:s.fontRenderExtension,rightOffset:ve}})}})}_disposeRendering(){var t,r;(t=this._filterRangeShape)==null||t.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};yt=Wi([S.OnLifecycle(S.LifecycleStages.Ready,yt),de(0,w.Inject(w.Injector)),de(1,w.Inject(me.SheetSkeletonManagerService)),de(2,w.Inject(c.SheetsFilterService)),de(3,w.Inject(S.ThemeService)),de(4,w.Inject(Ue.SheetInterceptorService)),de(5,w.Inject(me.SheetRenderController)),de(6,S.ICommandService),de(7,S.IUniverInstanceService),de(8,Ze.IRenderManagerService),de(9,me.ISelectionRenderService)],yt);var zi=Object.defineProperty,Qi=Object.getOwnPropertyDescriptor,Gi=(e,t,r,n)=>{for(var o=n>1?void 0:n?Qi(t,r):t,s=e.length-1,i;s>=0;s--)(i=e[s])&&(o=(n?i(t,r,o):i(o))||o);return n&&o&&zi(t,r,o),o},$r=(e,t)=>(r,n)=>t(r,n,e);const qi="UNIVER_SHEETS_FILTER_UI_PLUGIN";D.UniverSheetsFilterUIPlugin=(bt=class extends S.Plugin{constructor(t,r,n){super(),this._injector=r,this._localeService=n,this._localeService.load({zhCN:Kt})}onStarting(t){[[ge],[_t],[yt]].forEach(r=>t.add(r))}},P(bt,"type",S.UniverInstanceType.UNIVER_SHEET),P(bt,"pluginName",qi),bt),D.UniverSheetsFilterUIPlugin=Gi([$r(1,w.Inject(w.Injector)),$r(2,w.Inject(S.LocaleService))],D.UniverSheetsFilterUIPlugin),D.enUS=Jr,D.zhCN=Kt,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})});
package/package.json ADDED
@@ -0,0 +1,91 @@
1
+ {
2
+ "name": "@univerjs/sheets-filter-ui",
3
+ "version": "0.1.8",
4
+ "private": false,
5
+ "description": "Univer Sheets Filter UI",
6
+ "author": "DreamNum <developer@univer.ai>",
7
+ "license": "Apache-2.0",
8
+ "funding": {
9
+ "type": "opencollective",
10
+ "url": "https://opencollective.com/univer"
11
+ },
12
+ "homepage": "https://univer.ai",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/dream-num/univer"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/dream-num/univer/issues"
19
+ },
20
+ "keywords": [],
21
+ "sideEffects": [
22
+ "**/*.css"
23
+ ],
24
+ "exports": {
25
+ ".": {
26
+ "import": "./lib/es/index.js",
27
+ "require": "./lib/cjs/index.js",
28
+ "types": "./lib/types/index.d.ts"
29
+ },
30
+ "./*": {
31
+ "import": "./lib/es/*",
32
+ "require": "./lib/cjs/*",
33
+ "types": "./lib/types/index.d.ts"
34
+ },
35
+ "./lib/*": "./lib/*"
36
+ },
37
+ "main": "./lib/cjs/index.js",
38
+ "module": "./lib/es/index.js",
39
+ "types": "./lib/types/index.d.ts",
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "directories": {
44
+ "lib": "lib"
45
+ },
46
+ "files": [
47
+ "lib"
48
+ ],
49
+ "peerDependencies": {
50
+ "@wendellhu/redi": "^0.13.3",
51
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
52
+ "react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0",
53
+ "rxjs": ">=7.0.0",
54
+ "@univerjs/core": "0.1.8",
55
+ "@univerjs/design": "0.1.8",
56
+ "@univerjs/engine-render": "0.1.8",
57
+ "@univerjs/sheets": "0.1.8",
58
+ "@univerjs/sheets-ui": "0.1.8",
59
+ "@univerjs/sheets-filter": "0.1.8",
60
+ "@univerjs/ui": "0.1.8"
61
+ },
62
+ "dependencies": {
63
+ "@univerjs/icons": "^0.1.44",
64
+ "rc-virtual-list": "^3.11.5"
65
+ },
66
+ "devDependencies": {
67
+ "@wendellhu/redi": "^0.13.3",
68
+ "clsx": "^2.1.1",
69
+ "less": "^4.2.0",
70
+ "react": "^18.2.0",
71
+ "rxjs": "^7.8.1",
72
+ "typescript": "^5.4.5",
73
+ "vite": "^5.2.10",
74
+ "vitest": "^1.5.2",
75
+ "@univerjs/core": "0.1.8",
76
+ "@univerjs/design": "0.1.8",
77
+ "@univerjs/engine-render": "0.1.8",
78
+ "@univerjs/sheets": "0.1.8",
79
+ "@univerjs/shared": "0.1.8",
80
+ "@univerjs/sheets-filter": "0.1.8",
81
+ "@univerjs/sheets-ui": "0.1.8",
82
+ "@univerjs/ui": "0.1.8"
83
+ },
84
+ "scripts": {
85
+ "test": "vitest run",
86
+ "test:watch": "vitest",
87
+ "coverage": "vitest run --coverage",
88
+ "lint:types": "tsc --noEmit",
89
+ "build": "tsc && vite build"
90
+ }
91
+ }