@univerjs/sheets-filter-ui 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -1,75 +1,7 @@
1
- import{BooleanNumber as e,ColorKit as t,CommandType as n,DependentOn as r,Disposable as i,ICommandService as a,IConfigService as o,IContextService as s,ILogService as c,IUniverInstanceService as l,Inject as u,Injector as d,InterceptorEffectEnum as f,LocaleService as p,Optional as m,Plugin as h,Quantity as g,RxDisposable as _,ThemeService as v,Tools as y,UniverInstanceType as b,VerticalAlign as x,createIdentifier as S,extractPureTextFromCell as ee,fromCallback as C,merge as w,numfmt as te,registerDependencies as ne,touchDependencies as re}from"@univerjs/core";import{ClearSheetsFilterCriteriaCommand as ie,CustomFilterOperator as T,FILTER_MUTATIONS as ae,FilterBy as E,ReCalcSheetsFilterCommand as oe,ReCalcSheetsFilterMutation as se,RemoveSheetFilterCommand as ce,RemoveSheetsFilterMutation as le,SetSheetFilterRangeCommand as ue,SetSheetsFilterCriteriaCommand as D,SetSheetsFilterCriteriaMutation as de,SetSheetsFilterRangeMutation as fe,SheetsFilterService as O,SheetsFilterSyncController as pe,SmartToggleSheetsFilterCommand as me,UniverSheetsFilterPlugin as he}from"@univerjs/sheets-filter";import{IEditorBridgeService as ge,ISheetSelectionRenderService as _e,SelectionControl as ve,SetCellEditVisibleOperation as ye,SheetCanvasPopManagerService as be,SheetSkeletonManagerService as xe,SheetsRenderService as Se,SheetsUIPart as Ce,attachSelectionWithCoord as we,getCoordByCell as Te,getCurrentRangeDisable$ as Ee,getObservableWithExclusiveRange$ as De,whenSheetEditorFocused as Oe}from"@univerjs/sheets-ui";import{ComponentContainer as ke,ComponentManager as Ae,ILayoutService as je,IMenuManagerService as Me,IMessageService as Ne,IShortcutService as Pe,KeyCode as Fe,MenuItemType as Ie,MetaKeys as Le,RibbonDataGroup as Re,getMenuHiddenObservable as ze,useComponentsOfPart as Be,useDependency as k,useObservable as A}from"@univerjs/ui";import{COLOR_BLACK_RGB as Ve,IRenderManagerService as He,Rect as Ue,Shape as We}from"@univerjs/engine-render";import{INTERCEPTOR_POINT as Ge,RangeProtectionPermissionViewPoint as j,RefRangeService as Ke,SetRangeValuesMutation as qe,SheetInterceptorService as Je,SheetPermissionCheckController as Ye,SheetsSelectionsService as Xe,WorksheetFilterPermission as M,WorksheetViewPermission as N,expandToContinuousRange as Ze,getSheetCommandTarget as Qe}from"@univerjs/sheets";import{BehaviorSubject as P,ReplaySubject as $e,Subject as et,combineLatest as tt,distinctUntilChanged as nt,filter as rt,map as F,merge as it,of as I,shareReplay as at,startWith as ot,switchMap as st,takeUntil as ct,throttleTime as lt}from"rxjs";import{IRPCChannelService as ut,fromModule as dt,toModule as ft}from"@univerjs/rpc";import{Button as pt,Checkbox as mt,Input as ht,MessageType as gt,Radio as _t,RadioGroup as vt,Segmented as yt,Select as bt,Switch as xt,Tooltip as St,Tree as Ct,borderClassName as wt,clsx as Tt}from"@univerjs/design";import{AIcon as Et,BanIcon as Dt,FilterIcon as Ot,InfoIcon as kt,SuccessIcon as At}from"@univerjs/icons";import{useCallback as L,useMemo as jt}from"react";import{Fragment as Mt,jsx as R,jsxs as z}from"react/jsx-runtime";let B=function(e){return e[e.FIRST=0]=`FIRST`,e[e.SECOND=1]=`SECOND`,e}({}),V=function(e){return 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}({}),H;(function(t){let n=t.NONE={label:`sheets-filter.conditions.none`,operator:V.NONE,order:B.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw Error(`[FilterConditionItems.NONE]: should not have initial form params!`)},testMappingParams:e=>e.operator1===V.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:e=>!e.customFilters&&!e.filters?{}:!1},r=t.ALL_CONDITIONS=[n,t.EMPTY={label:`sheets-filter.conditions.empty`,operator:V.EMPTY,order:B.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw Error(`[FilterConditionItems.EMPTY]: should not have initial form params!`)},testMappingParams:({operator1:e})=>e===V.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:``}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.val===``&&n.operator===void 0?{operator1:V.EMPTY}:!1}},t.NOT_EMPTY={label:`sheets-filter.conditions.not-empty`,operator:V.NOT_EMPTY,order:B.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw Error(`[FilterConditionItems.NOT_EMPTY]: should not have initial form params!`)},testMappingParams:({operator1:e})=>e===V.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:``,operator:T.NOT_EQUALS}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.val===` `&&n.operator===T.NOT_EQUALS?{operator1:V.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:`sheets-filter.conditions.text-contains`,operator:V.CONTAINS,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.CONTAINS,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===V.CONTAINS},mapToFilterColumn:e=>{let{val1:t}=e;return t===``?null:{customFilters:{customFilters:[{val:`*${t}*`}]}}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return!n.operator&&r.startsWith(`*`)&&r.endsWith(`*`)?{operator1:V.CONTAINS,val1:r.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:`sheets-filter.conditions.does-not-contain`,operator:V.DOES_NOT_CONTAIN,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.DOES_NOT_CONTAIN,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:`*${e.val1}*`,operator:T.NOT_EQUALS}]}}),testMappingParams:e=>{let[t]=U(e);return t===V.DOES_NOT_CONTAIN},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return n.operator===T.NOT_EQUALS&&r.startsWith(`*`)&&r.endsWith(`*`)?{operator1:V.DOES_NOT_CONTAIN,val1:r.slice(1,-1)}:!1}},t.STARTS_WITH={label:`sheets-filter.conditions.starts-with`,operator:V.STARTS_WITH,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.STARTS_WITH,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:`${e.val1}*`}]}}),testMappingParams:e=>{let[t]=U(e);return t===V.STARTS_WITH},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return!n.operator&&r.endsWith(`*`)&&!r.startsWith(`*`)?{operator1:V.STARTS_WITH,val1:r.slice(0,-1)}:!1}},t.ENDS_WITH={label:`sheets-filter.conditions.ends-with`,operator:V.ENDS_WITH,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.ENDS_WITH,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:`*${e.val1}`}]}}),testMappingParams:e=>{let[t]=U(e);return t===V.ENDS_WITH},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return!n.operator&&r.startsWith(`*`)&&!r.endsWith(`*`)?{operator1:V.ENDS_WITH,val1:r.slice(1)}:!1}},t.EQUALS={label:`sheets-filter.conditions.equals`,operator:V.EQUALS,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.EQUALS,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===V.EQUALS},mapToFilterColumn:e=>{let{val1:t}=e;return t===``?null:{customFilters:{customFilters:[{val:t}]}}},testMappingFilterColumn:e=>{var t,n;return((t=e.filters)==null||(t=t.filters)==null?void 0:t.length)===1?{operator1:V.EQUALS,val1:``}:((n=e.customFilters)==null?void 0:n.customFilters.length)===1&&!e.customFilters.customFilters[0].operator?{operator1:V.EQUALS,val1:e.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:`sheets-filter.conditions.greater-than`,operator:T.GREATER_THAN,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.GREATER_THAN,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.GREATER_THAN}]}}),testMappingParams:e=>{let[t]=U(e);return t===T.GREATER_THAN},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.GREATER_THAN?{operator1:T.GREATER_THAN,val1:n.val.toString()}:!1}},t.GREATER_THAN_OR_EQUAL={label:`sheets-filter.conditions.greater-than-or-equal`,operator:T.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.GREATER_THAN_OR_EQUAL,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.GREATER_THAN_OR_EQUAL},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.GREATER_THAN_OR_EQUAL?{operator1:T.GREATER_THAN_OR_EQUAL,val1:n.val.toString()}:!1}},t.LESS_THAN={label:`sheets-filter.conditions.less-than`,operator:T.LESS_THAN,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.LESS_THAN,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.LESS_THAN},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.LESS_THAN}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.LESS_THAN?{operator1:T.LESS_THAN,val1:n.val.toString()}:!1}},t.LESS_THAN_OR_EQUAL={label:`sheets-filter.conditions.less-than-or-equal`,operator:T.LESS_THAN_OR_EQUAL,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.LESS_THAN_OR_EQUAL,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.LESS_THAN_OR_EQUAL},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.LESS_THAN_OR_EQUAL?{operator1:T.LESS_THAN_OR_EQUAL,val1:n.val.toString()}:!1}},t.EQUAL={label:`sheets-filter.conditions.equal`,operator:T.EQUAL,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.EQUAL,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.EQUAL},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.EQUAL}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.EQUAL?{operator1:T.EQUAL,val1:n.val.toString()}:!1}},t.NOT_EQUAL={label:`sheets-filter.conditions.not-equal`,operator:T.NOT_EQUALS,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.NOT_EQUALS,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.NOT_EQUALS},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.NOT_EQUALS}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.NOT_EQUALS?{operator1:T.NOT_EQUALS,val1:n.val.toString()}:!1}},t.BETWEEN={label:`sheets-filter.conditions.between`,operator:V.BETWEEN,order:B.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:T.GREATER_THAN_OR_EQUAL,val1:``,operator2:T.LESS_THAN_OR_EQUAL,val2:``}),testMappingParams:e=>{let{and:t,operator1:n,operator2:r}=e;if(!t)return!1;let i=[n,r];return i.includes(T.GREATER_THAN_OR_EQUAL)&&i.includes(T.LESS_THAN_OR_EQUAL)},mapToFilterColumn:t=>{let{val1:n,val2:r,operator1:i}=t,a=i===T.GREATER_THAN_OR_EQUAL;return{customFilters:{and:e.TRUE,customFilters:[{val:a?n:r,operator:T.GREATER_THAN_OR_EQUAL},{val:a?r:n,operator:T.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==2)return!1;let[n,r]=e.customFilters.customFilters;return n.operator===T.GREATER_THAN_OR_EQUAL&&r.operator===T.LESS_THAN_OR_EQUAL&&e.customFilters.and?{and:!0,operator1:T.GREATER_THAN_OR_EQUAL,val1:n.val.toString(),operator2:T.LESS_THAN_OR_EQUAL,val2:r.val.toString()}:r.operator===T.GREATER_THAN_OR_EQUAL&&n.operator===T.LESS_THAN_OR_EQUAL&&e.customFilters.and?{and:!0,operator1:T.GREATER_THAN_OR_EQUAL,val1:r.val.toString(),operator2:T.LESS_THAN_OR_EQUAL,val2:n.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:`sheets-filter.conditions.not-between`,operator:V.NOT_BETWEEN,order:B.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:T.LESS_THAN,val1:``,operator2:T.GREATER_THAN,val2:``}),testMappingParams:e=>{let{and:t,operator1:n,operator2:r}=e;if(t)return!1;let i=[n,r];return i.includes(T.GREATER_THAN)&&i.includes(T.LESS_THAN)},mapToFilterColumn:e=>{let{val1:t,val2:n,operator1:r}=e,i=r===T.GREATER_THAN;return{customFilters:{customFilters:[{val:i?t:n,operator:T.GREATER_THAN},{val:i?n:t,operator:T.LESS_THAN}]}}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==2)return!1;let[n,r]=e.customFilters.customFilters;return n.operator===T.LESS_THAN&&r.operator===T.GREATER_THAN&&!e.customFilters.and?{operator1:T.LESS_THAN,val1:n.val.toString(),operator2:T.GREATER_THAN,val2:r.val.toString()}:r.operator===T.LESS_THAN&&n.operator===T.GREATER_THAN&&!e.customFilters.and?{operator1:T.GREATER_THAN,val1:r.val.toString(),operator2:T.LESS_THAN,val2:n.val.toLocaleString()}:!1}},t.CUSTOM={label:`sheets-filter.conditions.custom`,operator:V.CUSTOM,order:B.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:V.NONE,val1:``,operator2:V.NONE,val2:``}),testMappingParams:()=>!0,mapToFilterColumn:t=>{let{and:i,val1:a,val2:o,operator1:s,operator2:c}=t;function l(e,t){for(let n of r)if(n.operator===e)return n.mapToFilterColumn({val1:t,operator1:e})}let u=!s||s===H.NONE.operator,d=!c||c===H.NONE.operator;if(u&&d)return n.mapToFilterColumn({});if(u)return l(c,o);if(d)return l(s,a);let f=l(s,a),p=l(c,o),m={customFilters:[f.customFilters.customFilters[0],p.customFilters.customFilters[0]]};return i&&(m.and=e.TRUE),{customFilters:m}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==2)return!1;let n=e.customFilters.customFilters.map(e=>c({customFilters:{customFilters:[e]}})),r={operator1:n[0][0].operator,val1:n[0][1].val1,operator2:n[1][0].operator,val2:n[1][1].val1};return e.customFilters.and&&(r.and=!0),r}}];function i(e){let t=r.find(t=>t.operator===e);if(!t)throw Error(`[SheetsFilter]: no condition item found for operator: ${e}`);return t}t.getItemByOperator=i;function a(e,t){for(let n of r.filter(e=>e.numOfParameters===t))if(n.numOfParameters!==0&&n.testMappingParams(e))return n;for(let t of r)if(t.testMappingParams(e))return t;throw Error(`[SheetsFilter]: no condition item can be mapped from the filter map params!`)}t.testMappingParams=a;function o(e){let t=r.find(t=>t.operator===e);return(t==null?void 0:t.numOfParameters)===0?{operator1:t.operator}:t.getDefaultFormParams()}t.getInitialFormParams=o;function s(e,t){return e.mapToFilterColumn(t)}t.mapToFilterColumn=s;function c(e){if(!e)return[n,{}];for(let t of r){let n=t.testMappingFilterColumn(e);if(n)return[t,n]}return[n,{}]}t.testMappingFilterColumn=c})(H||(H={}));function U(e){let{operator1:t,operator2:n,val1:r,val2:i}=e;if(t&&n)throw Error(`Both operator1 and operator2 are set!`);if(!t&&!n)throw Error(`Neither operator1 and operator2 and both not set!`);return t?[t,r]:[n,i]}function Nt(e){let t=[],n=[],r=0,i=0;function a(e){e.leaf&&(e.checked?(t.push(e),r+=e.count):(n.push(e),i+=e.count)),e.children&&e.children.forEach(a)}return e.forEach(a),{checkedItems:t,uncheckedItems:n,checked:r,unchecked:i}}function W(e,t){return function(n,r){t(n,r,e)}}function G(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const Pt=`sheets-filter.generate-filter-values.service`,Ft=S(Pt);let It=class extends i{constructor(e,t,n){super(),this._localeService=e,this._univerInstanceService=t,this._logService=n}async getFilterValues(e){var t;let{unitId:n,subUnitId:r,filteredOutRowsByOtherColumns:i,filterColumn:a,filters:o,blankChecked:s,iterateRange:c,alreadyChecked:l}=e,u=this._univerInstanceService.getUnit(n),d=(t=this._univerInstanceService.getUnit(n))==null?void 0:t.getSheetBySheetId(r);return!u||!d?[]:(this._logService.debug(`[SheetsGenerateFilterValuesService]`,`getFilterValues for`,{unitId:n,subUnitId:r}),Lt(o,this._localeService,c,d,new Set(i),a,new Set(l.map(String)),s,u.getStyles()))}};It=G([W(0,u(p)),W(1,l),W(2,c)],It);function Lt(e,t,n,r,i,a,o,s,c){var l;let u=new Map,d=new Map,f=`empty`,p=!e&&((a==null?void 0:a.filterBy)===E.COLORS||(a==null?void 0:a.filterBy)===E.CONDITIONS)&&((l=a.filteredOutRows)==null?void 0:l.size),m=0;for(let e of r.iterateByColumn(n,!1,!1)){let{row:n,rowSpan:a=1}=e,l=0;for(;l<a;){var h,g,_;let f=n+l;if(i.has(f)){l++;continue}let C=e!=null&&e.value?ee(e.value):``;if(!C){m+=1,l+=a;continue}let w=(h=e.value)!=null&&h.v&&!e.value.p?(g=c.get((_=e.value)==null?void 0:_.s))==null||(g=g.n)==null?void 0:g.pattern:``,ne=w&&te.getFormatInfo(w).isDate,re=!1;if(ne){let{year:e,month:t,day:n}=te.getFormatDateInfo(w);re=e||t||n}if(w&&ne&&re){var v,y,b;let n=(v=r.getCellRaw(e.row,e.col))==null?void 0:v.v;if(!n){l++;continue}let[i,a,c]=te.format(`yyyy-mm-dd`,Number(n)).split(`-`).map(Number),f=u.get(`${i}`);f||(f={title:`${i}`,key:`${i}`,children:[],count:0,leaf:!1,checked:!1},u.set(`${i}`,f),d.set(`${i}`,[`${i}`]));let m=(y=f.children)==null?void 0:y.find(e=>e.key===`${i}-${a}`);if(!m){var x;m={title:t.t(`sheets-filter.date.${a}`),key:`${i}-${a}`,children:[],count:0,leaf:!1,checked:!1},(x=f.children)==null||x.push(m),d.set(`${i}-${a}`,[`${i}`,`${i}-${a}`])}let h=m==null||(b=m.children)==null?void 0:b.find(e=>e.key===`${i}-${a}-${c}`);if(h)h.originValues.add(C),h.count++,m.count++,f.count++;else{var S;(S=m.children)==null||S.push({title:`${c}`,key:`${i}-${a}-${c}`,count:1,originValues:new Set([C]),leaf:!0,checked:p?!1:o.size?o.has(C):!s}),m.count++,f.count++,d.set(`${i}-${a}-${c}`,[`${i}`,`${i}-${a}`,`${i}-${a}-${c}`])}}else{let e=C,t=u.get(e);t?t.count++:(t={title:C,leaf:!0,checked:p?!1:o.size?o.has(C):!s,key:e,count:1},u.set(e,t),d.set(e,[e]))}l++}}let C=p?!1:e?s:!0;if(m>0){let e={title:t.t(`sheets-filter.panel.empty`),count:m,leaf:!0,checked:C,key:f};u.set(`empty`,e),d.set(`empty`,[f])}return{filterTreeItems:Rt(Array.from(u.values())),filterTreeMapCache:d}}function Rt(e){return Array.from(e).sort((e,t)=>e.children&&!t.children?-1:!e.children&&t.children?1:Bt(e.title,t.title)).map(e=>(e.children&&e.children.sort((e,t)=>Number.parseInt(e.key.split(`-`)[1],10)-Number.parseInt(t.key.split(`-`)[1],10)).forEach(e=>{e.children&&e.children.sort((e,t)=>Number.parseInt(e.key.split(`-`)[2],10)-Number.parseInt(t.key.split(`-`)[2],10))}),e))}const zt=e=>!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e));function Bt(e,t){let n=zt(e),r=zt(t);return n&&r?Number.parseFloat(e)-Number.parseFloat(t):n&&!r?-1:!n&&r?1:e.localeCompare(t)}function Vt(e,t){for(let n of e){if(n.key===t)return n;if(n.children){let e=Vt(n.children,t);if(e)return e}}return null}function Ht(e){return e.leaf?e.checked:e.children?e.children.every(e=>Ht(e)):!0}function K(e,t){e.leaf&&(t===void 0?e.checked=!e.checked:e.checked=t),e.children&&e.children.forEach(e=>K(e,t))}function Ut(e,t){let n=[];return e.forEach(e=>{let r=e.originValues?t.some(t=>Array.from(e.originValues).some(e=>e.toLowerCase().includes(t.toLowerCase()))):!1,i=!r&&t.some(t=>e.title.toLowerCase().includes(t.toLowerCase()));if(r||i)n.push({...e});else if(e.children){let r=Ut(e.children,t);if(r.length>0){let t=r.reduce((e,t)=>e+t.count,0);n.push({...e,count:t,children:r})}}}),n}function Wt(e){"@babel/helpers - typeof";return Wt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Wt(e)}function Gt(e,t){if(Wt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Wt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Kt(e){var t=Gt(e,`string`);return Wt(t)==`symbol`?t:t+``}function q(e,t,n){return(t=Kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qt,Jt,Yt;S(`sheets-filter-ui.sheets-filter-panel.service`);let J=class extends i{get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}constructor(e,t){super(),this._injector=e,this._refRangeService=t,q(this,`_filterBy$`,new P(E.VALUES)),q(this,`filterBy$`,this._filterBy$.asObservable()),q(this,`_filterByModel$`,new $e(1)),q(this,`filterByModel$`,this._filterByModel$.asObservable()),q(this,`_filterByModel`,null),q(this,`_hasCriteria$`,new P(!1)),q(this,`hasCriteria$`,this._hasCriteria$.asObservable()),q(this,`_filterModel`,null),q(this,`_col$`,new P(-1)),q(this,`col$`,this._col$.asObservable()),q(this,`_filterHeaderListener`,null)}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,t){this.terminate(),this._filterModel=e,this._col$.next(t);let n=e.getFilterColumn(t);if(n){let r=n.getColumnData();if(r.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,t);return}if(r.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,t);return}if(r.filters){this._hasCriteria$.next(!0),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t)}changeFilterBy(e){if(!this._filterModel||this.col===-1)return!1;switch(e){case E.VALUES:this._setupByValues(this._filterModel,this.col);break;case E.COLORS:this._setupByColors(this._filterModel,this.col);break;case E.CONDITIONS:this._setupByConditions(this._filterModel,this.col);break}return!0}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,t){this._disposeFilterHeaderChangeListener();let n=e.unitId,r=e.subUnitId,i=e.getRange(),a={startColumn:t,startRow:i.startRow,endRow:i.startRow,endColumn:t};this._filterHeaderListener=this._refRangeService.watchRange(n,r,a,(e,t)=>{if(!t)this.terminate();else{let n=t.startColumn-e.startColumn;n!==0&&this._filterByModel.deltaCol(n)}})}async _setupByValues(e,t){this._disposePreviousModel();let n=e.getRange();return n.startRow===n.endRow?!1:(this.filterByModel=await Zt.fromFilterColumn(this._injector,e,t),this._filterBy$.next(E.VALUES),this._listenToFilterHeaderChange(e,t),!0)}async _setupByColors(e,t){this._disposePreviousModel();let n=e.getRange();return n.startRow===n.endRow?!1:(this.filterByModel=await Qt.fromFilterColumn(this._injector,e,t),this._filterBy$.next(E.COLORS),this._listenToFilterHeaderChange(e,t),!0)}_setupByConditions(e,t){this._disposePreviousModel();let n=e.getRange();return n.startRow===n.endRow?!1:(this.filterByModel=Xt.fromFilterColumn(this._injector,e,t,e.getFilterColumn(t)),this._filterBy$.next(E.CONDITIONS),this._listenToFilterHeaderChange(e,t),!0)}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};J=G([W(0,u(d)),W(1,u(Ke))],J);let Xt=qt=class extends i{static fromFilterColumn(e,t,n,r){let[i,a]=H.testMappingFilterColumn(r==null?void 0:r.getColumnData());return e.createInstance(qt,t,n,i,a)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}constructor(e,t,n,r,i){super(),this._filterModel=e,this.col=t,this._commandService=i,q(this,`canApply$`,I(!0)),q(this,`_conditionItem$`,void 0),q(this,`conditionItem$`,void 0),q(this,`_filterConditionFormParams$`,void 0),q(this,`filterConditionFormParams$`,void 0),this._conditionItem$=new P(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new P(r),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;let e=H.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){let t=H.ALL_CONDITIONS.find(t=>t.operator===e);if(!t)throw Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(t),this._filterConditionFormParams$.next(H.getInitialFormParams(e))}onConditionFormChange(e){let t={...this.filterConditionFormParams,...e};if(t.and!==!0&&delete t.and,e.and!==void 0||e.operator1!==void 0||e.operator2!==void 0){let e=H.testMappingParams(t,this.conditionItem.numOfParameters);this._conditionItem$.next(e)}this._filterConditionFormParams$.next(t)}};Xt=qt=G([W(4,a)],Xt);let Zt=Jt=class extends i{static async fromFilterColumn(e,t,n){let r=e.get(l),i=e.get(p),a=e.get(Ft,g.OPTIONAL),{unitId:o,subUnitId:s}=t,c=r.getUniverSheetInstance(o);if(!c)throw Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);let u=c==null?void 0:c.getSheetBySheetId(s);if(!u)throw Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${s}!`);let d=t.getRange(),f=n,m=t.getFilterColumn(n),h=m==null?void 0:m.getColumnData().filters,_=new Set(h==null?void 0:h.filters),v=!!(h&&h.blank),y=t.getFilteredOutRowsExceptCol(n),b={...d,startRow:d.startRow+1,startColumn:f,endColumn:f},x,S;if(a){let e=await a.getFilterValues({unitId:o,subUnitId:s,filteredOutRowsByOtherColumns:Array.from(y),filterColumn:m,filters:!!h,blankChecked:v,iterateRange:b,alreadyChecked:Array.from(_)});x=e.filterTreeItems,S=e.filterTreeMapCache}else{let e=Lt(!!h,i,b,u,y,m,_,v,c.getStyles());x=e.filterTreeItems,S=e.filterTreeMapCache}return e.createInstance(Jt,t,n,x,S)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}constructor(e,t,n,r,i){super(),this._filterModel=e,this.col=t,this._commandService=i,q(this,`_rawFilterItems$`,void 0),q(this,`rawFilterItems$`,void 0),q(this,`filterItems$`,void 0),q(this,`_filterItems`,[]),q(this,`_treeMapCache`,void 0),q(this,`canApply$`,void 0),q(this,`_manuallyUpdateFilterItems$`,void 0),q(this,`_searchString$`,void 0),q(this,`searchString$`,void 0),this._treeMapCache=r,this._searchString$=new P(``),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new P(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new et,this.filterItems$=it(tt([this._searchString$.pipe(lt(500,void 0,{leading:!0,trailing:!0}),ot(void 0)),this._rawFilterItems$]).pipe(F(([e,t])=>e?Ut(t,e.toLowerCase().split(/\s+/).filter(e=>!!e)):t)),this._manuallyUpdateFilterItems$).pipe(at(1)),this.canApply$=this.filterItems$.pipe(F(e=>Nt(e).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(e=>this._filterItems=e))}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){let t=y.deepClone(this._filterItems);t.forEach(t=>K(t,e)),this._manuallyUpdateFilterItems(t)}onFilterCheckToggled(e){let t=y.deepClone(this._filterItems),n=Vt(t,e.key);n&&(K(n,!Ht(n)),this._manuallyUpdateFilterItems(t))}onFilterOnly(e){let t=y.deepClone(this._filterItems);t.forEach(e=>K(e,!1)),e.forEach(e=>{let n=Vt(t,e);n&&K(n,!0)}),this._manuallyUpdateFilterItems(t)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;let e=Nt(this._filterItems),{checked:t,checkedItems:n}=e,r=this.rawFilterItems,i=0;for(let e of r)i+=e.count;let a=t===0,o=e.checked===i,s={colId:this.col};if(a)throw Error(`[ByValuesModel]: no checked items!`);if(o)return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{s.filters={};let e=n.filter(e=>e.key!==`empty`);e.length>0&&(s.filters={filters:e.flatMap(e=>e.originValues?Array.from(e.originValues):[e.title])}),e.length!==n.length&&(s.filters.blank=!0)}return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:s})}};Zt=Jt=G([W(4,a)],Zt);let Qt=Yt=class extends i{static async fromFilterColumn(e,n,r){var i,a,o;let s=e.get(l),{unitId:c,subUnitId:u}=n,d=s.getUniverSheetInstance(c);if(!d)throw Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${c}!`);let f=d==null?void 0:d.getSheetBySheetId(u);if(!f)throw Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${c} and subUnitId: ${u}!`);let p=n.getRange(),m=r,h=(i=n.getFilterColumn(r))==null?void 0:i.getColumnData().colorFilters,g=n.getFilteredOutRowsExceptCol(r),_={...p,startRow:p.startRow+1,startColumn:m,endColumn:m},v=new Map,y=new Set((a=h==null?void 0:h.cellFillColors)==null?[]:a),b=new Map,x=new Set((o=h==null?void 0:h.cellTextColors)==null?[]:o);for(let e of f.iterateByColumn(_,!1,!0)){let{row:n,col:r,value:i}=e;if(g.has(n))continue;let a=f.getComposedCellStyleByCellData(n,r,i);if(a.bg&&a.bg.rgb){let e=new t(a.bg.rgb).toRgbString();v.has(e)||v.set(e,{color:e,checked:y.has(e)})}else v.set(`default-fill-color`,{color:null,checked:y.has(null)});if(a.cl&&a.cl.rgb){let e=new t(a.cl.rgb).toRgbString();b.has(e)||b.set(e,{color:e,checked:x.has(e)})}else b.set(`default-font-color`,{color:Ve,checked:x.has(Ve)})}return e.createInstance(Yt,n,r,v,b)}get cellFillColors(){return this._cellFillColors$.getValue()}get cellTextColors(){return this._cellTextColors$.getValue()}constructor(e,t,n,r,i){super(),this._filterModel=e,this.col=t,this._commandService=i,q(this,`canApply$`,I(!0)),q(this,`_cellFillColors$`,void 0),q(this,`cellFillColors$`,void 0),q(this,`_cellTextColors$`,void 0),q(this,`cellTextColors$`,void 0),this._cellFillColors$=new P(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new P(Array.from(r.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}dispose(){super.dispose(),this._cellFillColors$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}onFilterCheckToggled(e,t=!0){let n=t?this.cellFillColors:this.cellTextColors,r=[],i=!1;for(let t=0;t<n.length;t++){let a=n[t];if(a.color===e.color){i=!0,r.push({color:a.color,checked:!a.checked});continue}r.push({color:a.color,checked:a.checked})}i&&(this._resetColorsCheckedStatus(!t),t?this._cellFillColors$.next([...r]):this._cellTextColors$.next([...r]))}_resetColorsCheckedStatus(e=!0){let t=e?this.cellFillColors:this.cellTextColors,n=[];for(let e=0;e<t.length;e++)n.push({color:t[e].color,checked:!1});e?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n])}async apply(){if(this._disposed)return!1;let e=this.cellFillColors.filter(e=>e.checked).map(e=>e.color),t=this.cellTextColors.filter(e=>e.checked).map(e=>e.color);if(e.length===0&&t.length===0)return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});let n={colId:this.col};return e.length>0?n.colorFilters={cellFillColors:e}:t.length>0&&(n.colorFilters={cellTextColors:t}),this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Qt=Yt=G([W(4,a)],Qt);const $t=`FILTER_PANEL_OPENED`,en={id:`sheet.operation.open-filter-panel`,type:n.OPERATION,handler:(e,t)=>{let n=e.get(s),r=e.get(O),i=e.get(J),o=e.get(a),c=e.has(ge)?e.get(ge):null;c!=null&&c.isVisible().visible&&o.syncExecuteCommand(ye.id,{visible:!1});let{unitId:l,subUnitId:u,col:d}=t,f=r.getFilterModel(l,u);return f?(i.setupCol(f,d),n.getContextValue(`FILTER_PANEL_OPENED`)||n.setContextValue($t,!0),!0):!1}},Y={id:`sheet.operation.close-filter-panel`,type:n.OPERATION,handler:e=>{let t=e.get(s),n=e.get(J),r=e.get(je,g.OPTIONAL);return t.getContextValue(`FILTER_PANEL_OPENED`)?(t.setContextValue($t,!1),r==null||r.focus(),n.terminate()):!1}},tn={id:`sheet.operation.apply-filter`,type:n.OPERATION,handler:(e,t)=>{let{filterBy:n}=t;return e.get(J).changeFilterBy(n)}};var nn=`@univerjs/sheets-filter-ui`,rn=`0.18.0`;const an=`sheets-filter-ui.config`;Symbol(an);const on={};let X=class extends i{constructor(e,t,n,r,i,a){super(),this._sheetsFilterService=e,this._localeService=t,this._commandService=n,this._sheetPermissionCheckPermission=r,this._injector=i,this._sheetsSelectionService=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===me.id){var t;let e=Qe(this._injector.get(l));if(!e)return;let{unitId:r,subUnitId:i,worksheet:a}=e,o=(t=this._sheetsFilterService.getFilterModel(r,i))==null?void 0:t.getRange(),s;if(o)s=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[j],worksheetTypes:[M,N]},[o],r,i);else{var n;let e=(n=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:n.range;if(e){let t={...e};t=e.startColumn===e.endColumn&&e.startRow===e.endRow?Ze(t,{left:!0,right:!0,up:!0,down:!0},a):t,s=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[j],worksheetTypes:[N,M]},[t],r,i)}else s=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[j],worksheetTypes:[N,M]})}s||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.filterErr`))}if(e.id===en.id){var r;let t=e.params,{unitId:n,subUnitId:i}=t,a=(r=this._sheetsFilterService.getFilterModel(n,i))==null?void 0:r.getRange(),o=y.deepClone(a);o&&(o.startColumn=t.col,o.endColumn=t.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[j],worksheetTypes:[M,N]},[o],n,i)||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.filterErr`)))}}))}};X=G([W(0,u(O)),W(1,u(p)),W(2,a),W(3,u(Ye)),W(4,u(d)),W(5,u(Xe))],X);const sn=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`);var cn=class{static drawNoCriteria(e,t,n,r){e.save(),Ue.drawWith(e,{radius:2,width:16,height:16,fill:r}),e.lineCap=`square`,e.strokeStyle=n,e.scale(t/16,t/16),e.beginPath(),e.lineWidth=1,e.lineCap=`round`,e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,t,n,r){e.save(),Ue.drawWith(e,{radius:2,width:16,height:16,fill:r}),e.scale(t/16,t/16),e.fillStyle=n,e.fill(sn),e.restore()}};let ln=class extends We{constructor(e,t,n,r,i){super(e,t),this._contextService=n,this._commandService=r,this._themeService=i,q(this,`_cellWidth`,0),q(this,`_cellHeight`,0),q(this,`_filterParams`,void 0),q(this,`_hovered`,!1),this.setShapeProps(t),this.onPointerDown$.subscribeEvent(e=>this.onPointerDown(e)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){e.cellHeight!==void 0&&(this._cellHeight=e.cellHeight),e.cellWidth!==void 0&&(this._cellWidth=e.cellWidth),e.filterParams!==void 0&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){let t=this._cellHeight,n=this._cellWidth,r=16-n,i=16-t;e.save();let a=new Path2D;a.rect(r,i,n,t),e.clip(a);let{hasCriteria:o}=this._filterParams,s=this._themeService.getColorFromTheme(`primary.600`),c=this._hovered?this._themeService.getColorFromTheme(`gray.50`):`rgba(255, 255, 255, 1.0)`;o?cn.drawHasCriteria(e,16,s,c):cn.drawNoCriteria(e,16,s,c),e.restore()}onPointerDown(e){if(e.button===2)return;let{col:t,unitId:n,subUnitId:r}=this._filterParams;this._contextService.getContextValue(`FILTER_PANEL_OPENED`)||!this._commandService.hasCommand(en.id)||setTimeout(()=>{this._commandService.executeCommand(en.id,{unitId:n,subUnitId:r,col:t})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ln=G([W(2,s),W(3,a),W(4,u(v))],ln);function un(e,t,n,r){switch(r){case x.TOP:return e+1;case x.MIDDLE:return e+Math.max(0,(n-16)/2);case x.BOTTOM:default:return t-16-1}}let dn=class extends _{constructor(e,t,n,r,i,a,o,s){super(),this._context=e,this._injector=t,this._sheetSkeletonManagerService=n,this._sheetsFilterService=r,this._themeService=i,this._sheetInterceptorService=a,this._commandService=o,this._selectionRenderService=s,q(this,`_filterRangeShape`,null),q(this,`_buttonRenderDisposable`,null),q(this,`_filterButtonShapes`,[]),this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(st(e=>{var t,r;if(!e)return I(null);let{unit:i,unitId:a}=this._context,o=((t=i.getActiveSheet())==null?void 0:t.getSheetId())||``,s=(r=this._sheetsFilterService.getFilterModel(a,o))==null?void 0:r,c=()=>({unitId:a,worksheetId:o,filterModel:s,range:s==null?void 0:s.getRange(),skeleton:e.skeleton});return C(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(rt(([e])=>{var t;return e.type===n.MUTATION&&((t=e.params)==null?void 0:t.unitId)===i.getUnitId()&&(ae.has(e.id)||e.id===qe.id)}),lt(20,void 0,{leading:!1,trailing:!0}),F(c),ot(c()))}),ct(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,t){let{scene:n}=this._context,{rowHeaderWidth:r,columnHeaderHeight:i}=t,a=this._filterRangeShape=new ve(n,1e3,this._themeService,{rowHeaderWidth:r,columnHeaderHeight:i,enableAutoFill:!1,highlightHeader:!1}),o=we({range:e,primary:null,style:{fill:`rgba(0, 0, 0, 0.0)`}},t);a.updateRangeBySelectionWithCoord(o),a.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){let{range:t,filterModel:n,unitId:r,skeleton:i,worksheetId:a}=e,{unit:o,scene:s}=this._context,c=o.getSheetBySheetId(a);if(!c)return;this._interceptCellContent(r,a,e.range);let{startColumn:l,endColumn:u,startRow:d}=t;for(let e=l;e<=u;e++){let t=`sheets-filter-button-${e}`,o=Te(d,e,s,i),l=c.getComposedCellStyle(d,e),u=(l==null?void 0:l.vt)||x.BOTTOM,{startX:f,startY:p,endX:m,endY:h}=o,g=m-f,_=h-p;if(_<=1||g<=1)continue;let v=!!n.getFilterColumn(e),y={left:m-16-1,top:un(p,h,_,u),height:16,width:16,zIndex:5e3,cellHeight:_,cellWidth:g,filterParams:{unitId:r,subUnitId:a,col:e,hasCriteria:v}},b=this._injector.createInstance(ln,t,y);this._filterButtonShapes.push(b)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,t,n){let{startRow:r,startColumn:i,endColumn:a}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(Ge.CELL_CONTENT,{effect:f.Style,handler:(n,o,s)=>{let{row:c,col:l,unitId:u,subUnitId:d}=o;return u!==e||d!==t||c!==r||l<i||l>a?s(n):((!n||n===o.rawData)&&(n={...o.rawData}),n.fontRenderExtension={...n==null?void 0:n.fontRenderExtension,rightOffset:16},s(n))},priority:10})}_disposeRendering(){var e,t;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(e=>e.dispose()),(t=this._buttonRenderDisposable)==null||t.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};dn=G([W(1,u(d)),W(2,u(xe)),W(3,u(O)),W(4,u(v)),W(5,u(Je)),W(6,a),W(7,_e)],dn);let fn=class extends _{constructor(e,t){super(),this._renderManagerService=e,this._sheetsRenderService=t,[fe,de,le,se].forEach(e=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(e.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(b.UNIVER_SHEET,[dn]))}};fn=G([W(0,He),W(1,u(Se))],fn);let Z=class extends h{constructor(e=on,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=w({},on,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(an,i)}onStarting(){[[X],[fn]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(X)}onRendered(){this._injector.get(fn)}};q(Z,`type`,b.UNIVER_SHEET),q(Z,`pluginName`,`SHEET_FILTER_UI_PLUGIN`),q(Z,`packageName`,nn),q(Z,`version`,rn),Z=G([r(he),W(1,u(d)),W(2,o)],Z);function pn(e){let t=e.get(O);return{id:me.id,type:Ie.BUTTON_SELECTOR,icon:`FilterIcon`,tooltip:`sheets-filter.toolbar.smart-toggle-filter-tooltip`,hidden$:ze(e,b.UNIVER_SHEET),activated$:t.activeFilterModel$.pipe(F(e=>!!e)),disabled$:De(e,Ee(e,{worksheetTypes:[M,N],rangeTypes:[j]}))}}function mn(e){let t=e.get(O);return{id:ie.id,type:Ie.BUTTON,title:`sheets-filter.toolbar.clear-filter-criteria`,hidden$:ze(e,b.UNIVER_SHEET),disabled$:t.activeFilterModel$.pipe(st(e=>{var t;return(t=e==null?void 0:e.hasCriteria$.pipe(F(e=>!e)))==null?I(!0):t}))}}function hn(e){let t=e.get(O);return{id:oe.id,type:Ie.BUTTON,title:`sheets-filter.toolbar.re-calc-filter-conditions`,hidden$:ze(e,b.UNIVER_SHEET),disabled$:t.activeFilterModel$.pipe(st(e=>{var t;return(t=e==null?void 0:e.hasCriteria$.pipe(F(e=>!e)))==null?I(!0):t}))}}const gn={[Re.ORGANIZATION]:{[me.id]:{order:2,menuItemFactory:pn,[ie.id]:{order:0,menuItemFactory:mn},[oe.id]:{order:1,menuItemFactory:hn}}}};function _n(e){let{model:t}=e,n=k(p),r=A(t.cellFillColors$,[],!0),i=A(t.cellTextColors$,[],!0),a=L(e=>{t.onFilterCheckToggled(e)},[t]),o=L(e=>{t.onFilterCheckToggled(e,!1)},[t]);return R(`div`,{"data-u-comp":`sheets-filter-panel-colors-container`,className:`univer-flex univer-h-full univer-min-h-[300px] univer-flex-col`,children:z(`div`,{"data-u-comp":`sheets-filter-panel`,className:Tt(`
2
- univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col
3
- univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5
4
- `,wt),children:[r.length>1&&z(`div`,{children:[R(`div`,{className:`
5
- univer-mb-2 univer-text-sm univer-text-gray-900
6
- dark:!univer-text-white
7
- `,children:n.t(`sheets-filter.panel.filter-by-cell-fill-color`)}),R(`div`,{className:`
8
- univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2
9
- `,children:r.map((e,t)=>z(`div`,{className:`univer-relative univer-size-6`,onClick:()=>a(e),children:[e.color?R(`button`,{type:`button`,className:Tt(`
10
- univer-box-border univer-size-6 univer-cursor-pointer
11
- univer-rounded-full univer-border univer-border-solid
12
- univer-border-transparent univer-bg-gray-300 univer-transition-shadow
13
- hover:univer-ring-2 hover:univer-ring-offset-2
14
- hover:univer-ring-offset-white
15
- `),style:{backgroundColor:e.color}}):R(Dt,{className:`
16
- univer-size-6 univer-cursor-pointer univer-rounded-full
17
- hover:univer-ring-2 hover:univer-ring-offset-2
18
- hover:univer-ring-offset-white
19
- `}),e.checked&&R(vn,{})]},`sheets-filter-cell-fill-color-${t}`))})]}),i.length>1&&z(`div`,{children:[R(`div`,{className:`
20
- univer-mb-2 univer-text-sm univer-text-gray-900
21
- dark:!univer-text-white
22
- `,children:n.t(`sheets-filter.panel.filter-by-cell-text-color`)}),R(`div`,{className:`
23
- univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2
24
- `,children:i.map((e,t)=>z(`div`,{className:`univer-relative univer-size-6`,onClick:()=>o(e),children:[R(`div`,{className:`
25
- univer-box-border univer-flex univer-size-full univer-cursor-pointer
26
- univer-items-center univer-justify-center univer-rounded-full univer-border
27
- univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5
28
- hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white
29
- dark:!univer-border-[rgba(255,255,255,0.06)]
30
- `,children:R(Et,{style:{color:e.color}})}),e.checked&&R(vn,{})]},`sheets-filter-cell-text-color-${t}`))})]}),r.length<=1&&i.length<=1&&R(`div`,{className:`
31
- univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm
32
- univer-text-gray-900
33
- dark:!univer-text-gray-200
34
- `,children:n.t(`sheets-filter.panel.filter-by-color-none`)})]})})}function vn(){return R(`div`,{className:`
35
- univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer
36
- univer-items-center univer-justify-center univer-rounded-full univer-bg-white
37
- `,children:R(At,{className:`univer-size-full univer-font-bold univer-text-[#418F1F]`})})}function yn(e){var t,n;let{model:r}=e,i=k(p),a=A(r.conditionItem$,void 0),o=A(r.filterConditionFormParams$,void 0),s=o!=null&&o.and?`AND`:`OR`,c=L(e=>{r.onConditionFormChange({and:e===`AND`})},[r]),l=bn(i),u=L(e=>{r.onPrimaryConditionChange(e)},[r]),d=xn(i),f=L(e=>{r.onConditionFormChange(e)},[r]),m=i.t(`sheets-filter.panel.input-values-placeholder`);function h(e,t,n){let r=H.getItemByOperator(e).numOfParameters===1;return z(Mt,{children:[n===`operator2`&&z(vt,{value:s,onChange:c,children:[R(_t,{value:`AND`,children:i.t(`sheets-filter.panel.and`)}),R(_t,{value:`OR`,children:i.t(`sheets-filter.panel.or`)})]}),R(bt,{value:e,options:d,onChange:e=>f({[n]:e})}),r&&R(`div`,{children:R(ht,{className:`univer-mt-2`,value:t,placeholder:m,onChange:e=>f({[n===`operator1`?`val1`:`val2`]:e})})})]})}return R(`div`,{"data-u-comp":`sheets-filter-panel-conditions-container`,className:`univer-flex univer-h-full univer-min-h-[300px] univer-flex-col`,children:a&&o&&z(Mt,{children:[R(bt,{value:a.operator,options:l,onChange:u}),H.getItemByOperator(a.operator).numOfParameters===0?null:z(`div`,{"data-u-comp":`sheets-filter-panel-conditions-container-inner`,className:Tt(`
38
- univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2
39
- `,wt),children:[a.numOfParameters>=1&&h(o.operator1,(t=o.val1)==null?``:t,`operator1`),a.numOfParameters>=2&&h(o.operator2,(n=o.val2)==null?``:n,`operator2`),z(`div`,{"data-u-comp":`sheets-filter-panel-conditions-desc`,className:`univer-mt-2 univer-text-xs univer-text-gray-500`,children:[i.t(`sheets-filter.panel.?`),R(`br`,{}),i.t(`sheets-filter.panel.*`)]})]})]})})}function bn(e){return jt(()=>[{options:[{label:e.t(H.NONE.label),value:H.NONE.operator}]},{options:[{label:e.t(H.EMPTY.label),value:H.EMPTY.operator},{label:e.t(H.NOT_EMPTY.label),value:H.NOT_EMPTY.operator}]},{options:[{label:e.t(H.TEXT_CONTAINS.label),value:H.TEXT_CONTAINS.operator},{label:e.t(H.DOES_NOT_CONTAIN.label),value:H.DOES_NOT_CONTAIN.operator},{label:e.t(H.STARTS_WITH.label),value:H.STARTS_WITH.operator},{label:e.t(H.ENDS_WITH.label),value:H.ENDS_WITH.operator},{label:e.t(H.EQUALS.label),value:H.EQUALS.operator}]},{options:[{label:e.t(H.GREATER_THAN.label),value:H.GREATER_THAN.operator},{label:e.t(H.GREATER_THAN_OR_EQUAL.label),value:H.GREATER_THAN_OR_EQUAL.operator},{label:e.t(H.LESS_THAN.label),value:H.LESS_THAN.operator},{label:e.t(H.LESS_THAN_OR_EQUAL.label),value:H.LESS_THAN_OR_EQUAL.operator},{label:e.t(H.EQUAL.label),value:H.EQUAL.operator},{label:e.t(H.NOT_EQUAL.label),value:H.NOT_EQUAL.operator},{label:e.t(H.BETWEEN.label),value:H.BETWEEN.operator},{label:e.t(H.NOT_BETWEEN.label),value:H.NOT_BETWEEN.operator}]},{options:[{label:e.t(H.CUSTOM.label),value:H.CUSTOM.operator}]}],[e.getCurrentLocale(),e])}function xn(e){return jt(()=>H.ALL_CONDITIONS.filter(e=>e.numOfParameters!==2).map(t=>({label:e.t(t.label),value:t.operator})),[e.getCurrentLocale(),e])}function Sn(e){let{model:t}=e,n=k(p),r=A(t.searchString$,``,!0),i=A(t.filterItems$,void 0,!0),a=n.t(`sheets-filter.panel.filter-only`),o=Nt(i),s=o.checked>0&&o.unchecked===0,c=o.checked>0&&o.unchecked>0,l=t.treeMapCache,u=L(()=>{t.onCheckAllToggled(!s)},[t,s]),d=L(e=>{t.setSearchString(e)},[t]);function f(e){let t=[];return e.forEach(e=>{e.checked&&t.push(e.key),e.children&&(t=t.concat(f(e.children)))}),t}return z(`div`,{"data-u-comp":`sheets-filter-panel-values-container`,className:`univer-flex univer-h-full univer-min-h-[300px] univer-flex-col`,children:[R(ht,{autoFocus:!0,value:r,placeholder:n.t(`sheets-filter.panel.search-placeholder`),onChange:d}),z(`div`,{"data-u-comp":`sheets-filter-panel`,className:Tt(`
40
- univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden
41
- univer-rounded-md univer-px-2 univer-py-2.5
42
- `,wt),children:[R(`div`,{"data-u-comp":`sheets-filter-panel-values-item`,className:`univer-box-border univer-h-8 univer-w-full univer-py-0.5`,children:z(`div`,{"data-u-comp":`sheets-filter-panel-values-item-inner`,className:`
43
- univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-py-0
44
- univer-pl-5 univer-pr-0.5 univer-text-sm
45
- `,children:[R(mt,{indeterminate:c,disabled:i.length===0,checked:s,onChange:u}),R(`span`,{"data-u-comp":`sheets-filter-panel-values-item-text`,className:`
46
- univer-mx-1 univer-inline-block univer-flex-shrink univer-truncate univer-text-gray-900
47
- dark:!univer-text-white
48
- `,children:`${n.t(`sheets-filter.panel.select-all`)}`}),R(`span`,{"data-u-comp":`sheets-filter-panel-values-item-count`,className:`
49
- univer-text-gray-400
50
- dark:!univer-text-gray-500
51
- `,children:`(${o.checked}/${o.checked+o.unchecked})`})]})}),R(`div`,{"data-u-comp":`sheets-filter-panel-values-virtual`,className:`univer-flex-grow`,children:R(Ct,{data:i,defaultExpandAll:!1,valueGroup:f(i),onChange:e=>{t.onFilterCheckToggled(e)},defaultCache:l,itemHeight:28,treeNodeClassName:`
1
+ import{BooleanNumber as e,ColorKit as t,CommandType as n,DependentOn as r,Disposable as i,ICommandService as a,IConfigService as o,IContextService as s,ILogService as c,IUniverInstanceService as l,Inject as u,Injector as d,InterceptorEffectEnum as f,LocaleService as p,Optional as m,Plugin as h,Quantity as g,RxDisposable as _,ThemeService as v,Tools as y,UniverInstanceType as b,VerticalAlign as x,createIdentifier as S,extractPureTextFromCell as ee,fromCallback as C,merge as w,numfmt as te,registerDependencies as ne,touchDependencies as re}from"@univerjs/core";import{ClearSheetsFilterCriteriaCommand as ie,CustomFilterOperator as T,FILTER_MUTATIONS as ae,FilterBy as E,ReCalcSheetsFilterCommand as oe,ReCalcSheetsFilterMutation as se,RemoveSheetFilterCommand as ce,RemoveSheetsFilterMutation as le,SetSheetFilterRangeCommand as ue,SetSheetsFilterCriteriaCommand as D,SetSheetsFilterCriteriaMutation as de,SetSheetsFilterRangeMutation as fe,SheetsFilterService as O,SheetsFilterSyncController as pe,SmartToggleSheetsFilterCommand as me,UniverSheetsFilterPlugin as he}from"@univerjs/sheets-filter";import{IEditorBridgeService as ge,ISheetSelectionRenderService as _e,SelectionControl as ve,SetCellEditVisibleOperation as ye,SheetCanvasPopManagerService as be,SheetSkeletonManagerService as xe,SheetsRenderService as Se,SheetsUIPart as Ce,attachSelectionWithCoord as we,getCoordByCell as Te,getCurrentRangeDisable$ as Ee,getObservableWithExclusiveRange$ as De,whenSheetEditorFocused as Oe}from"@univerjs/sheets-ui";import{ComponentContainer as ke,ComponentManager as Ae,ILayoutService as je,IMenuManagerService as Me,IMessageService as Ne,IShortcutService as Pe,KeyCode as Fe,MenuItemType as Ie,MetaKeys as Le,RibbonDataGroup as Re,getMenuHiddenObservable as ze,useComponentsOfPart as Be,useDependency as k,useObservable as A}from"@univerjs/ui";import{COLOR_BLACK_RGB as Ve,IRenderManagerService as He,Rect as Ue,Shape as We}from"@univerjs/engine-render";import{INTERCEPTOR_POINT as Ge,RangeProtectionPermissionViewPoint as j,RefRangeService as Ke,SetRangeValuesMutation as qe,SheetInterceptorService as Je,SheetPermissionCheckController as Ye,SheetsSelectionsService as Xe,WorksheetFilterPermission as M,WorksheetViewPermission as N,expandToContinuousRange as Ze,getSheetCommandTarget as Qe}from"@univerjs/sheets";import{BehaviorSubject as P,ReplaySubject as $e,Subject as et,combineLatest as tt,distinctUntilChanged as nt,filter as rt,map as F,merge as it,of as I,shareReplay as at,startWith as ot,switchMap as st,takeUntil as ct,throttleTime as lt}from"rxjs";import{IRPCChannelService as ut,fromModule as dt,toModule as ft}from"@univerjs/rpc";import{Button as pt,Checkbox as mt,Input as ht,MessageType as gt,Radio as _t,RadioGroup as vt,Segmented as yt,Select as bt,Switch as xt,Tooltip as St,Tree as Ct,borderClassName as wt,clsx as Tt}from"@univerjs/design";import{AIcon as Et,BanIcon as Dt,FilterIcon as Ot,InfoIcon as kt,SuccessIcon as At}from"@univerjs/icons";import{useCallback as L,useMemo as jt}from"react";import{Fragment as Mt,jsx as R,jsxs as z}from"react/jsx-runtime";let B=function(e){return e[e.FIRST=0]=`FIRST`,e[e.SECOND=1]=`SECOND`,e}({}),V=function(e){return 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}({}),H;(function(t){let n=t.NONE={label:`sheets-filter.conditions.none`,operator:V.NONE,order:B.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw Error(`[FilterConditionItems.NONE]: should not have initial form params!`)},testMappingParams:e=>e.operator1===V.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:e=>!e.customFilters&&!e.filters?{}:!1},r=t.ALL_CONDITIONS=[n,t.EMPTY={label:`sheets-filter.conditions.empty`,operator:V.EMPTY,order:B.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw Error(`[FilterConditionItems.EMPTY]: should not have initial form params!`)},testMappingParams:({operator1:e})=>e===V.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:``}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.val===``&&n.operator===void 0?{operator1:V.EMPTY}:!1}},t.NOT_EMPTY={label:`sheets-filter.conditions.not-empty`,operator:V.NOT_EMPTY,order:B.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw Error(`[FilterConditionItems.NOT_EMPTY]: should not have initial form params!`)},testMappingParams:({operator1:e})=>e===V.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:``,operator:T.NOT_EQUALS}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.val===` `&&n.operator===T.NOT_EQUALS?{operator1:V.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:`sheets-filter.conditions.text-contains`,operator:V.CONTAINS,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.CONTAINS,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===V.CONTAINS},mapToFilterColumn:e=>{let{val1:t}=e;return t===``?null:{customFilters:{customFilters:[{val:`*${t}*`}]}}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return!n.operator&&r.startsWith(`*`)&&r.endsWith(`*`)?{operator1:V.CONTAINS,val1:r.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:`sheets-filter.conditions.does-not-contain`,operator:V.DOES_NOT_CONTAIN,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.DOES_NOT_CONTAIN,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:`*${e.val1}*`,operator:T.NOT_EQUALS}]}}),testMappingParams:e=>{let[t]=U(e);return t===V.DOES_NOT_CONTAIN},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return n.operator===T.NOT_EQUALS&&r.startsWith(`*`)&&r.endsWith(`*`)?{operator1:V.DOES_NOT_CONTAIN,val1:r.slice(1,-1)}:!1}},t.STARTS_WITH={label:`sheets-filter.conditions.starts-with`,operator:V.STARTS_WITH,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.STARTS_WITH,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:`${e.val1}*`}]}}),testMappingParams:e=>{let[t]=U(e);return t===V.STARTS_WITH},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return!n.operator&&r.endsWith(`*`)&&!r.startsWith(`*`)?{operator1:V.STARTS_WITH,val1:r.slice(0,-1)}:!1}},t.ENDS_WITH={label:`sheets-filter.conditions.ends-with`,operator:V.ENDS_WITH,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.ENDS_WITH,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:`*${e.val1}`}]}}),testMappingParams:e=>{let[t]=U(e);return t===V.ENDS_WITH},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0],r=n.val.toString();return!n.operator&&r.startsWith(`*`)&&!r.endsWith(`*`)?{operator1:V.ENDS_WITH,val1:r.slice(1)}:!1}},t.EQUALS={label:`sheets-filter.conditions.equals`,operator:V.EQUALS,order:B.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:V.EQUALS,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===V.EQUALS},mapToFilterColumn:e=>{let{val1:t}=e;return t===``?null:{customFilters:{customFilters:[{val:t}]}}},testMappingFilterColumn:e=>{var t,n;return((t=e.filters)==null||(t=t.filters)==null?void 0:t.length)===1?{operator1:V.EQUALS,val1:``}:((n=e.customFilters)==null?void 0:n.customFilters.length)===1&&!e.customFilters.customFilters[0].operator?{operator1:V.EQUALS,val1:e.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:`sheets-filter.conditions.greater-than`,operator:T.GREATER_THAN,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.GREATER_THAN,val1:``}),mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.GREATER_THAN}]}}),testMappingParams:e=>{let[t]=U(e);return t===T.GREATER_THAN},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.GREATER_THAN?{operator1:T.GREATER_THAN,val1:n.val.toString()}:!1}},t.GREATER_THAN_OR_EQUAL={label:`sheets-filter.conditions.greater-than-or-equal`,operator:T.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.GREATER_THAN_OR_EQUAL,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.GREATER_THAN_OR_EQUAL},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.GREATER_THAN_OR_EQUAL?{operator1:T.GREATER_THAN_OR_EQUAL,val1:n.val.toString()}:!1}},t.LESS_THAN={label:`sheets-filter.conditions.less-than`,operator:T.LESS_THAN,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.LESS_THAN,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.LESS_THAN},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.LESS_THAN}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.LESS_THAN?{operator1:T.LESS_THAN,val1:n.val.toString()}:!1}},t.LESS_THAN_OR_EQUAL={label:`sheets-filter.conditions.less-than-or-equal`,operator:T.LESS_THAN_OR_EQUAL,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.LESS_THAN_OR_EQUAL,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.LESS_THAN_OR_EQUAL},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.LESS_THAN_OR_EQUAL?{operator1:T.LESS_THAN_OR_EQUAL,val1:n.val.toString()}:!1}},t.EQUAL={label:`sheets-filter.conditions.equal`,operator:T.EQUAL,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.EQUAL,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.EQUAL},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.EQUAL}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.EQUAL?{operator1:T.EQUAL,val1:n.val.toString()}:!1}},t.NOT_EQUAL={label:`sheets-filter.conditions.not-equal`,operator:T.NOT_EQUALS,numOfParameters:1,order:B.FIRST,getDefaultFormParams:()=>({operator1:T.NOT_EQUALS,val1:``}),testMappingParams:e=>{let[t]=U(e);return t===T.NOT_EQUALS},mapToFilterColumn:e=>({customFilters:{customFilters:[{val:e.val1,operator:T.NOT_EQUALS}]}}),testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==1)return!1;let n=e.customFilters.customFilters[0];return n.operator===T.NOT_EQUALS?{operator1:T.NOT_EQUALS,val1:n.val.toString()}:!1}},t.BETWEEN={label:`sheets-filter.conditions.between`,operator:V.BETWEEN,order:B.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:T.GREATER_THAN_OR_EQUAL,val1:``,operator2:T.LESS_THAN_OR_EQUAL,val2:``}),testMappingParams:e=>{let{and:t,operator1:n,operator2:r}=e;if(!t)return!1;let i=[n,r];return i.includes(T.GREATER_THAN_OR_EQUAL)&&i.includes(T.LESS_THAN_OR_EQUAL)},mapToFilterColumn:t=>{let{val1:n,val2:r,operator1:i}=t,a=i===T.GREATER_THAN_OR_EQUAL;return{customFilters:{and:e.TRUE,customFilters:[{val:a?n:r,operator:T.GREATER_THAN_OR_EQUAL},{val:a?r:n,operator:T.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==2)return!1;let[n,r]=e.customFilters.customFilters;return n.operator===T.GREATER_THAN_OR_EQUAL&&r.operator===T.LESS_THAN_OR_EQUAL&&e.customFilters.and?{and:!0,operator1:T.GREATER_THAN_OR_EQUAL,val1:n.val.toString(),operator2:T.LESS_THAN_OR_EQUAL,val2:r.val.toString()}:r.operator===T.GREATER_THAN_OR_EQUAL&&n.operator===T.LESS_THAN_OR_EQUAL&&e.customFilters.and?{and:!0,operator1:T.GREATER_THAN_OR_EQUAL,val1:r.val.toString(),operator2:T.LESS_THAN_OR_EQUAL,val2:n.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:`sheets-filter.conditions.not-between`,operator:V.NOT_BETWEEN,order:B.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:T.LESS_THAN,val1:``,operator2:T.GREATER_THAN,val2:``}),testMappingParams:e=>{let{and:t,operator1:n,operator2:r}=e;if(t)return!1;let i=[n,r];return i.includes(T.GREATER_THAN)&&i.includes(T.LESS_THAN)},mapToFilterColumn:e=>{let{val1:t,val2:n,operator1:r}=e,i=r===T.GREATER_THAN;return{customFilters:{customFilters:[{val:i?t:n,operator:T.GREATER_THAN},{val:i?n:t,operator:T.LESS_THAN}]}}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==2)return!1;let[n,r]=e.customFilters.customFilters;return n.operator===T.LESS_THAN&&r.operator===T.GREATER_THAN&&!e.customFilters.and?{operator1:T.LESS_THAN,val1:n.val.toString(),operator2:T.GREATER_THAN,val2:r.val.toString()}:r.operator===T.LESS_THAN&&n.operator===T.GREATER_THAN&&!e.customFilters.and?{operator1:T.GREATER_THAN,val1:r.val.toString(),operator2:T.LESS_THAN,val2:n.val.toLocaleString()}:!1}},t.CUSTOM={label:`sheets-filter.conditions.custom`,operator:V.CUSTOM,order:B.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:V.NONE,val1:``,operator2:V.NONE,val2:``}),testMappingParams:()=>!0,mapToFilterColumn:t=>{let{and:i,val1:a,val2:o,operator1:s,operator2:c}=t;function l(e,t){for(let n of r)if(n.operator===e)return n.mapToFilterColumn({val1:t,operator1:e})}let u=!s||s===H.NONE.operator,d=!c||c===H.NONE.operator;if(u&&d)return n.mapToFilterColumn({});if(u)return l(c,o);if(d)return l(s,a);let f=l(s,a),p=l(c,o),m={customFilters:[f.customFilters.customFilters[0],p.customFilters.customFilters[0]]};return i&&(m.and=e.TRUE),{customFilters:m}},testMappingFilterColumn:e=>{var t;if(((t=e.customFilters)==null?void 0:t.customFilters.length)!==2)return!1;let n=e.customFilters.customFilters.map(e=>c({customFilters:{customFilters:[e]}})),r={operator1:n[0][0].operator,val1:n[0][1].val1,operator2:n[1][0].operator,val2:n[1][1].val1};return e.customFilters.and&&(r.and=!0),r}}];function i(e){let t=r.find(t=>t.operator===e);if(!t)throw Error(`[SheetsFilter]: no condition item found for operator: ${e}`);return t}t.getItemByOperator=i;function a(e,t){for(let n of r.filter(e=>e.numOfParameters===t))if(n.numOfParameters!==0&&n.testMappingParams(e))return n;for(let t of r)if(t.testMappingParams(e))return t;throw Error(`[SheetsFilter]: no condition item can be mapped from the filter map params!`)}t.testMappingParams=a;function o(e){let t=r.find(t=>t.operator===e);return(t==null?void 0:t.numOfParameters)===0?{operator1:t.operator}:t.getDefaultFormParams()}t.getInitialFormParams=o;function s(e,t){return e.mapToFilterColumn(t)}t.mapToFilterColumn=s;function c(e){if(!e)return[n,{}];for(let t of r){let n=t.testMappingFilterColumn(e);if(n)return[t,n]}return[n,{}]}t.testMappingFilterColumn=c})(H||(H={}));function U(e){let{operator1:t,operator2:n,val1:r,val2:i}=e;if(t&&n)throw Error(`Both operator1 and operator2 are set!`);if(!t&&!n)throw Error(`Neither operator1 and operator2 and both not set!`);return t?[t,r]:[n,i]}function Nt(e){let t=[],n=[],r=0,i=0;function a(e){e.leaf&&(e.checked?(t.push(e),r+=e.count):(n.push(e),i+=e.count)),e.children&&e.children.forEach(a)}return e.forEach(a),{checkedItems:t,uncheckedItems:n,checked:r,unchecked:i}}function W(e,t){return function(n,r){t(n,r,e)}}function G(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}const Pt=`sheets-filter.generate-filter-values.service`,Ft=S(Pt);let It=class extends i{constructor(e,t,n){super(),this._localeService=e,this._univerInstanceService=t,this._logService=n}async getFilterValues(e){var t;let{unitId:n,subUnitId:r,filteredOutRowsByOtherColumns:i,filterColumn:a,filters:o,blankChecked:s,iterateRange:c,alreadyChecked:l}=e,u=this._univerInstanceService.getUnit(n),d=(t=this._univerInstanceService.getUnit(n))==null?void 0:t.getSheetBySheetId(r);return!u||!d?[]:(this._logService.debug(`[SheetsGenerateFilterValuesService]`,`getFilterValues for`,{unitId:n,subUnitId:r}),Lt(o,this._localeService,c,d,new Set(i),a,new Set(l.map(String)),s,u.getStyles()))}};It=G([W(0,u(p)),W(1,l),W(2,c)],It);function Lt(e,t,n,r,i,a,o,s,c){var l;let u=new Map,d=new Map,f=`empty`,p=!e&&((a==null?void 0:a.filterBy)===E.COLORS||(a==null?void 0:a.filterBy)===E.CONDITIONS)&&((l=a.filteredOutRows)==null?void 0:l.size),m=0;for(let e of r.iterateByColumn(n,!1,!1)){let{row:n,rowSpan:a=1}=e,l=0;for(;l<a;){var h,g,_;let f=n+l;if(i.has(f)){l++;continue}let C=e!=null&&e.value?ee(e.value):``;if(!C){m+=1,l+=a;continue}let w=(h=e.value)!=null&&h.v&&!e.value.p?(g=c.get((_=e.value)==null?void 0:_.s))==null||(g=g.n)==null?void 0:g.pattern:``,ne=w&&te.getFormatInfo(w).isDate,re=!1;if(ne){let{year:e,month:t,day:n}=te.getFormatDateInfo(w);re=e||t||n}if(w&&ne&&re){var v,y,b;let n=(v=r.getCellRaw(e.row,e.col))==null?void 0:v.v;if(!n){l++;continue}let[i,a,c]=te.format(`yyyy-mm-dd`,Number(n)).split(`-`).map(Number),f=u.get(`${i}`);f||(f={title:`${i}`,key:`${i}`,children:[],count:0,leaf:!1,checked:!1},u.set(`${i}`,f),d.set(`${i}`,[`${i}`]));let m=(y=f.children)==null?void 0:y.find(e=>e.key===`${i}-${a}`);if(!m){var x;m={title:t.t(`sheets-filter.date.${a}`),key:`${i}-${a}`,children:[],count:0,leaf:!1,checked:!1},(x=f.children)==null||x.push(m),d.set(`${i}-${a}`,[`${i}`,`${i}-${a}`])}let h=m==null||(b=m.children)==null?void 0:b.find(e=>e.key===`${i}-${a}-${c}`);if(h)h.originValues.add(C),h.count++,m.count++,f.count++;else{var S;(S=m.children)==null||S.push({title:`${c}`,key:`${i}-${a}-${c}`,count:1,originValues:new Set([C]),leaf:!0,checked:p?!1:o.size?o.has(C):!s}),m.count++,f.count++,d.set(`${i}-${a}-${c}`,[`${i}`,`${i}-${a}`,`${i}-${a}-${c}`])}}else{let e=C,t=u.get(e);t?t.count++:(t={title:C,leaf:!0,checked:p?!1:o.size?o.has(C):!s,key:e,count:1},u.set(e,t),d.set(e,[e]))}l++}}let C=p?!1:e?s:!0;if(m>0){let e={title:t.t(`sheets-filter.panel.empty`),count:m,leaf:!0,checked:C,key:f};u.set(`empty`,e),d.set(`empty`,[f])}return{filterTreeItems:Rt(Array.from(u.values())),filterTreeMapCache:d}}function Rt(e){return Array.from(e).sort((e,t)=>e.children&&!t.children?-1:!e.children&&t.children?1:Bt(e.title,t.title)).map(e=>(e.children&&e.children.sort((e,t)=>Number.parseInt(e.key.split(`-`)[1],10)-Number.parseInt(t.key.split(`-`)[1],10)).forEach(e=>{e.children&&e.children.sort((e,t)=>Number.parseInt(e.key.split(`-`)[2],10)-Number.parseInt(t.key.split(`-`)[2],10))}),e))}const zt=e=>!Number.isNaN(Number(e))&&!Number.isNaN(Number.parseFloat(e));function Bt(e,t){let n=zt(e),r=zt(t);return n&&r?Number.parseFloat(e)-Number.parseFloat(t):n&&!r?-1:!n&&r?1:e.localeCompare(t)}function Vt(e,t){for(let n of e){if(n.key===t)return n;if(n.children){let e=Vt(n.children,t);if(e)return e}}return null}function Ht(e){return e.leaf?e.checked:e.children?e.children.every(e=>Ht(e)):!0}function K(e,t){e.leaf&&(t===void 0?e.checked=!e.checked:e.checked=t),e.children&&e.children.forEach(e=>K(e,t))}function Ut(e,t){let n=[];return e.forEach(e=>{let r=e.originValues?t.some(t=>Array.from(e.originValues).some(e=>e.toLowerCase().includes(t.toLowerCase()))):!1,i=!r&&t.some(t=>e.title.toLowerCase().includes(t.toLowerCase()));if(r||i)n.push({...e});else if(e.children){let r=Ut(e.children,t);if(r.length>0){let t=r.reduce((e,t)=>e+t.count,0);n.push({...e,count:t,children:r})}}}),n}function Wt(e){"@babel/helpers - typeof";return Wt=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},Wt(e)}function Gt(e,t){if(Wt(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(Wt(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Kt(e){var t=Gt(e,`string`);return Wt(t)==`symbol`?t:t+``}function q(e,t,n){return(t=Kt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var qt,Jt,Yt;S(`sheets-filter-ui.sheets-filter-panel.service`);let J=class extends i{get filterBy(){return this._filterBy$.getValue()}get filterByModel(){return this._filterByModel}set filterByModel(e){this._filterByModel=e,this._filterByModel$.next(e)}get filterModel(){return this._filterModel}get col(){return this._col$.getValue()}constructor(e,t){super(),this._injector=e,this._refRangeService=t,q(this,`_filterBy$`,new P(E.VALUES)),q(this,`filterBy$`,this._filterBy$.asObservable()),q(this,`_filterByModel$`,new $e(1)),q(this,`filterByModel$`,this._filterByModel$.asObservable()),q(this,`_filterByModel`,null),q(this,`_hasCriteria$`,new P(!1)),q(this,`hasCriteria$`,this._hasCriteria$.asObservable()),q(this,`_filterModel`,null),q(this,`_col$`,new P(-1)),q(this,`col$`,this._col$.asObservable()),q(this,`_filterHeaderListener`,null)}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,t){this.terminate(),this._filterModel=e,this._col$.next(t);let n=e.getFilterColumn(t);if(n){let r=n.getColumnData();if(r.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,t);return}if(r.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,t);return}if(r.filters){this._hasCriteria$.next(!0),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t);return}this._hasCriteria$.next(!1),this._setupByValues(e,t)}changeFilterBy(e){if(!this._filterModel||this.col===-1)return!1;switch(e){case E.VALUES:this._setupByValues(this._filterModel,this.col);break;case E.COLORS:this._setupByColors(this._filterModel,this.col);break;case E.CONDITIONS:this._setupByConditions(this._filterModel,this.col);break}return!0}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,t){this._disposeFilterHeaderChangeListener();let n=e.unitId,r=e.subUnitId,i=e.getRange(),a={startColumn:t,startRow:i.startRow,endRow:i.startRow,endColumn:t};this._filterHeaderListener=this._refRangeService.watchRange(n,r,a,(e,t)=>{if(!t)this.terminate();else{let n=t.startColumn-e.startColumn;n!==0&&this._filterByModel.deltaCol(n)}})}async _setupByValues(e,t){this._disposePreviousModel();let n=e.getRange();return n.startRow===n.endRow?!1:(this.filterByModel=await Zt.fromFilterColumn(this._injector,e,t),this._filterBy$.next(E.VALUES),this._listenToFilterHeaderChange(e,t),!0)}async _setupByColors(e,t){this._disposePreviousModel();let n=e.getRange();return n.startRow===n.endRow?!1:(this.filterByModel=await Qt.fromFilterColumn(this._injector,e,t),this._filterBy$.next(E.COLORS),this._listenToFilterHeaderChange(e,t),!0)}_setupByConditions(e,t){this._disposePreviousModel();let n=e.getRange();return n.startRow===n.endRow?!1:(this.filterByModel=Xt.fromFilterColumn(this._injector,e,t,e.getFilterColumn(t)),this._filterBy$.next(E.CONDITIONS),this._listenToFilterHeaderChange(e,t),!0)}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};J=G([W(0,u(d)),W(1,u(Ke))],J);let Xt=qt=class extends i{static fromFilterColumn(e,t,n,r){let[i,a]=H.testMappingFilterColumn(r==null?void 0:r.getColumnData());return e.createInstance(qt,t,n,i,a)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}constructor(e,t,n,r,i){super(),this._filterModel=e,this.col=t,this._commandService=i,q(this,`canApply$`,I(!0)),q(this,`_conditionItem$`,void 0),q(this,`conditionItem$`,void 0),q(this,`_filterConditionFormParams$`,void 0),q(this,`filterConditionFormParams$`,void 0),this._conditionItem$=new P(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new P(r),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;let e=H.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){let t=H.ALL_CONDITIONS.find(t=>t.operator===e);if(!t)throw Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(t),this._filterConditionFormParams$.next(H.getInitialFormParams(e))}onConditionFormChange(e){let t={...this.filterConditionFormParams,...e};if(t.and!==!0&&delete t.and,e.and!==void 0||e.operator1!==void 0||e.operator2!==void 0){let e=H.testMappingParams(t,this.conditionItem.numOfParameters);this._conditionItem$.next(e)}this._filterConditionFormParams$.next(t)}};Xt=qt=G([W(4,a)],Xt);let Zt=Jt=class extends i{static async fromFilterColumn(e,t,n){let r=e.get(l),i=e.get(p),a=e.get(Ft,g.OPTIONAL),{unitId:o,subUnitId:s}=t,c=r.getUniverSheetInstance(o);if(!c)throw Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);let u=c==null?void 0:c.getSheetBySheetId(s);if(!u)throw Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${s}!`);let d=t.getRange(),f=n,m=t.getFilterColumn(n),h=m==null?void 0:m.getColumnData().filters,_=new Set(h==null?void 0:h.filters),v=!!(h&&h.blank),y=t.getFilteredOutRowsExceptCol(n),b={...d,startRow:d.startRow+1,startColumn:f,endColumn:f},x,S;if(a){let e=await a.getFilterValues({unitId:o,subUnitId:s,filteredOutRowsByOtherColumns:Array.from(y),filterColumn:m,filters:!!h,blankChecked:v,iterateRange:b,alreadyChecked:Array.from(_)});x=e.filterTreeItems,S=e.filterTreeMapCache}else{let e=Lt(!!h,i,b,u,y,m,_,v,c.getStyles());x=e.filterTreeItems,S=e.filterTreeMapCache}return e.createInstance(Jt,t,n,x,S)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}constructor(e,t,n,r,i){super(),this._filterModel=e,this.col=t,this._commandService=i,q(this,`_rawFilterItems$`,void 0),q(this,`rawFilterItems$`,void 0),q(this,`filterItems$`,void 0),q(this,`_filterItems`,[]),q(this,`_treeMapCache`,void 0),q(this,`canApply$`,void 0),q(this,`_manuallyUpdateFilterItems$`,void 0),q(this,`_searchString$`,void 0),q(this,`searchString$`,void 0),this._treeMapCache=r,this._searchString$=new P(``),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new P(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new et,this.filterItems$=it(tt([this._searchString$.pipe(lt(500,void 0,{leading:!0,trailing:!0}),ot(void 0)),this._rawFilterItems$]).pipe(F(([e,t])=>e?Ut(t,e.toLowerCase().split(/\s+/).filter(e=>!!e)):t)),this._manuallyUpdateFilterItems$).pipe(at(1)),this.canApply$=this.filterItems$.pipe(F(e=>Nt(e).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(e=>this._filterItems=e))}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){let t=y.deepClone(this._filterItems);t.forEach(t=>K(t,e)),this._manuallyUpdateFilterItems(t)}onFilterCheckToggled(e){let t=y.deepClone(this._filterItems),n=Vt(t,e.key);n&&(K(n,!Ht(n)),this._manuallyUpdateFilterItems(t))}onFilterOnly(e){let t=y.deepClone(this._filterItems);t.forEach(e=>K(e,!1)),e.forEach(e=>{let n=Vt(t,e);n&&K(n,!0)}),this._manuallyUpdateFilterItems(t)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;let e=Nt(this._filterItems),{checked:t,checkedItems:n}=e,r=this.rawFilterItems,i=0;for(let e of r)i+=e.count;let a=t===0,o=e.checked===i,s={colId:this.col};if(a)throw Error(`[ByValuesModel]: no checked items!`);if(o)return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{s.filters={};let e=n.filter(e=>e.key!==`empty`);e.length>0&&(s.filters={filters:e.flatMap(e=>e.originValues?Array.from(e.originValues):[e.title])}),e.length!==n.length&&(s.filters.blank=!0)}return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:s})}};Zt=Jt=G([W(4,a)],Zt);let Qt=Yt=class extends i{static async fromFilterColumn(e,n,r){var i,a,o;let s=e.get(l),{unitId:c,subUnitId:u}=n,d=s.getUniverSheetInstance(c);if(!d)throw Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${c}!`);let f=d==null?void 0:d.getSheetBySheetId(u);if(!f)throw Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${c} and subUnitId: ${u}!`);let p=n.getRange(),m=r,h=(i=n.getFilterColumn(r))==null?void 0:i.getColumnData().colorFilters,g=n.getFilteredOutRowsExceptCol(r),_={...p,startRow:p.startRow+1,startColumn:m,endColumn:m},v=new Map,y=new Set((a=h==null?void 0:h.cellFillColors)==null?[]:a),b=new Map,x=new Set((o=h==null?void 0:h.cellTextColors)==null?[]:o);for(let e of f.iterateByColumn(_,!1,!0)){let{row:n,col:r,value:i}=e;if(g.has(n))continue;let a=f.getComposedCellStyleByCellData(n,r,i);if(a.bg&&a.bg.rgb){let e=new t(a.bg.rgb).toRgbString();v.has(e)||v.set(e,{color:e,checked:y.has(e)})}else v.set(`default-fill-color`,{color:null,checked:y.has(null)});if(a.cl&&a.cl.rgb){let e=new t(a.cl.rgb).toRgbString();b.has(e)||b.set(e,{color:e,checked:x.has(e)})}else b.set(`default-font-color`,{color:Ve,checked:x.has(Ve)})}return e.createInstance(Yt,n,r,v,b)}get cellFillColors(){return this._cellFillColors$.getValue()}get cellTextColors(){return this._cellTextColors$.getValue()}constructor(e,t,n,r,i){super(),this._filterModel=e,this.col=t,this._commandService=i,q(this,`canApply$`,I(!0)),q(this,`_cellFillColors$`,void 0),q(this,`cellFillColors$`,void 0),q(this,`_cellTextColors$`,void 0),q(this,`cellTextColors$`,void 0),this._cellFillColors$=new P(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new P(Array.from(r.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}dispose(){super.dispose(),this._cellFillColors$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}onFilterCheckToggled(e,t=!0){let n=t?this.cellFillColors:this.cellTextColors,r=[],i=!1;for(let t=0;t<n.length;t++){let a=n[t];if(a.color===e.color){i=!0,r.push({color:a.color,checked:!a.checked});continue}r.push({color:a.color,checked:a.checked})}i&&(this._resetColorsCheckedStatus(!t),t?this._cellFillColors$.next([...r]):this._cellTextColors$.next([...r]))}_resetColorsCheckedStatus(e=!0){let t=e?this.cellFillColors:this.cellTextColors,n=[];for(let e=0;e<t.length;e++)n.push({color:t[e].color,checked:!1});e?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n])}async apply(){if(this._disposed)return!1;let e=this.cellFillColors.filter(e=>e.checked).map(e=>e.color),t=this.cellTextColors.filter(e=>e.checked).map(e=>e.color);if(e.length===0&&t.length===0)return this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});let n={colId:this.col};return e.length>0?n.colorFilters={cellFillColors:e}:t.length>0&&(n.colorFilters={cellTextColors:t}),this._commandService.executeCommand(D.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Qt=Yt=G([W(4,a)],Qt);const $t=`FILTER_PANEL_OPENED`,en={id:`sheet.operation.open-filter-panel`,type:n.OPERATION,handler:(e,t)=>{let n=e.get(s),r=e.get(O),i=e.get(J),o=e.get(a),c=e.has(ge)?e.get(ge):null;c!=null&&c.isVisible().visible&&o.syncExecuteCommand(ye.id,{visible:!1});let{unitId:l,subUnitId:u,col:d}=t,f=r.getFilterModel(l,u);return f?(i.setupCol(f,d),n.getContextValue(`FILTER_PANEL_OPENED`)||n.setContextValue($t,!0),!0):!1}},Y={id:`sheet.operation.close-filter-panel`,type:n.OPERATION,handler:e=>{let t=e.get(s),n=e.get(J),r=e.get(je,g.OPTIONAL);return t.getContextValue(`FILTER_PANEL_OPENED`)?(t.setContextValue($t,!1),r==null||r.focus(),n.terminate()):!1}},tn={id:`sheet.operation.apply-filter`,type:n.OPERATION,handler:(e,t)=>{let{filterBy:n}=t;return e.get(J).changeFilterBy(n)}};var nn=`@univerjs/sheets-filter-ui`,rn=`0.19.0`;const an=`sheets-filter-ui.config`;Symbol(an);const on={};let X=class extends i{constructor(e,t,n,r,i,a){super(),this._sheetsFilterService=e,this._localeService=t,this._commandService=n,this._sheetPermissionCheckPermission=r,this._injector=i,this._sheetsSelectionService=a,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===me.id){var t;let e=Qe(this._injector.get(l));if(!e)return;let{unitId:r,subUnitId:i,worksheet:a}=e,o=(t=this._sheetsFilterService.getFilterModel(r,i))==null?void 0:t.getRange(),s;if(o)s=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[j],worksheetTypes:[M,N]},[o],r,i);else{var n;let e=(n=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:n.range;if(e){let t={...e};t=e.startColumn===e.endColumn&&e.startRow===e.endRow?Ze(t,{left:!0,right:!0,up:!0,down:!0},a):t,s=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[j],worksheetTypes:[N,M]},[t],r,i)}else s=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[j],worksheetTypes:[N,M]})}s||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.filterErr`))}if(e.id===en.id){var r;let t=e.params,{unitId:n,subUnitId:i}=t,a=(r=this._sheetsFilterService.getFilterModel(n,i))==null?void 0:r.getRange(),o=y.deepClone(a);o&&(o.startColumn=t.col,o.endColumn=t.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[j],worksheetTypes:[M,N]},[o],n,i)||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.filterErr`)))}}))}};X=G([W(0,u(O)),W(1,u(p)),W(2,a),W(3,u(Ye)),W(4,u(d)),W(5,u(Xe))],X);const sn=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`);var cn=class{static drawNoCriteria(e,t,n,r){e.save(),Ue.drawWith(e,{radius:2,width:16,height:16,fill:r}),e.lineCap=`square`,e.strokeStyle=n,e.scale(t/16,t/16),e.beginPath(),e.lineWidth=1,e.lineCap=`round`,e.moveTo(3,4),e.lineTo(13,4),e.moveTo(4.5,8),e.lineTo(11.5,8),e.moveTo(6,12),e.lineTo(10,12),e.stroke(),e.restore()}static drawHasCriteria(e,t,n,r){e.save(),Ue.drawWith(e,{radius:2,width:16,height:16,fill:r}),e.scale(t/16,t/16),e.fillStyle=n,e.fill(sn),e.restore()}};let ln=class extends We{constructor(e,t,n,r,i){super(e,t),this._contextService=n,this._commandService=r,this._themeService=i,q(this,`_cellWidth`,0),q(this,`_cellHeight`,0),q(this,`_filterParams`,void 0),q(this,`_hovered`,!1),this.setShapeProps(t),this.onPointerDown$.subscribeEvent(e=>this.onPointerDown(e)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){e.cellHeight!==void 0&&(this._cellHeight=e.cellHeight),e.cellWidth!==void 0&&(this._cellWidth=e.cellWidth),e.filterParams!==void 0&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){let t=this._cellHeight,n=this._cellWidth,r=16-n,i=16-t;e.save();let a=new Path2D;a.rect(r,i,n,t),e.clip(a);let{hasCriteria:o}=this._filterParams,s=this._themeService.getColorFromTheme(`primary.600`),c=this._hovered?this._themeService.getColorFromTheme(`gray.50`):`rgba(255, 255, 255, 1.0)`;o?cn.drawHasCriteria(e,16,s,c):cn.drawNoCriteria(e,16,s,c),e.restore()}onPointerDown(e){if(e.button===2)return;let{col:t,unitId:n,subUnitId:r}=this._filterParams;this._contextService.getContextValue(`FILTER_PANEL_OPENED`)||!this._commandService.hasCommand(en.id)||setTimeout(()=>{this._commandService.executeCommand(en.id,{unitId:n,subUnitId:r,col:t})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ln=G([W(2,s),W(3,a),W(4,u(v))],ln);function un(e,t,n,r){switch(r){case x.TOP:return e+1;case x.MIDDLE:return e+Math.max(0,(n-16)/2);case x.BOTTOM:default:return t-16-1}}let dn=class extends _{constructor(e,t,n,r,i,a,o,s){super(),this._context=e,this._injector=t,this._sheetSkeletonManagerService=n,this._sheetsFilterService=r,this._themeService=i,this._sheetInterceptorService=a,this._commandService=o,this._selectionRenderService=s,q(this,`_currentRenderParams`,null),q(this,`_filterRangeShape`,null),q(this,`_buttonRenderDisposable`,null),q(this,`_filterButtonShapes`,[]),this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this.disposeWithMe(this._themeService.currentTheme$.subscribe(()=>{this._refreshRendering(this._currentRenderParams)})),this._sheetSkeletonManagerService.currentSkeleton$.pipe(st(e=>{var t,r;if(!e)return I(null);let{unit:i,unitId:a}=this._context,o=((t=i.getActiveSheet())==null?void 0:t.getSheetId())||``,s=(r=this._sheetsFilterService.getFilterModel(a,o))==null?void 0:r,c=()=>({unitId:a,worksheetId:o,filterModel:s,range:s==null?void 0:s.getRange(),skeleton:e.skeleton});return C(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(rt(([e])=>{var t;return e.type===n.MUTATION&&((t=e.params)==null?void 0:t.unitId)===i.getUnitId()&&(ae.has(e.id)||e.id===qe.id)}),lt(20,void 0,{leading:!1,trailing:!0}),F(c),ot(c()))}),ct(this.dispose$)).subscribe(e=>{this._currentRenderParams=e,this._refreshRendering(e)})}_refreshRendering(e){this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))}_renderRange(e,t){let{scene:n}=this._context,{rowHeaderWidth:r,columnHeaderHeight:i}=t,a=this._filterRangeShape=new ve(n,1e3,this._themeService,{rowHeaderWidth:r,columnHeaderHeight:i,enableAutoFill:!1,highlightHeader:!1}),o=we({range:e,primary:null,style:{fill:`rgba(0, 0, 0, 0.0)`}},t);a.updateRangeBySelectionWithCoord(o),a.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){let{range:t,filterModel:n,unitId:r,skeleton:i,worksheetId:a}=e,{unit:o,scene:s}=this._context,c=o.getSheetBySheetId(a);if(!c)return;this._interceptCellContent(r,a,e.range);let{startColumn:l,endColumn:u,startRow:d}=t;for(let e=l;e<=u;e++){let t=`sheets-filter-button-${e}`,o=Te(d,e,s,i),l=c.getComposedCellStyle(d,e),u=(l==null?void 0:l.vt)||x.BOTTOM,{startX:f,startY:p,endX:m,endY:h}=o,g=m-f,_=h-p;if(_<=1||g<=1)continue;let v=!!n.getFilterColumn(e),y={left:m-16-1,top:un(p,h,_,u),height:16,width:16,zIndex:5e3,cellHeight:_,cellWidth:g,filterParams:{unitId:r,subUnitId:a,col:e,hasCriteria:v}},b=this._injector.createInstance(ln,t,y);this._filterButtonShapes.push(b)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,t,n){let{startRow:r,startColumn:i,endColumn:a}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(Ge.CELL_CONTENT,{effect:f.Style,handler:(n,o,s)=>{let{row:c,col:l,unitId:u,subUnitId:d}=o;return u!==e||d!==t||c!==r||l<i||l>a?s(n):((!n||n===o.rawData)&&(n={...o.rawData}),n.fontRenderExtension={...n==null?void 0:n.fontRenderExtension,rightOffset:16},s(n))},priority:10})}_disposeRendering(){var e,t;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(e=>e.dispose()),(t=this._buttonRenderDisposable)==null||t.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};dn=G([W(1,u(d)),W(2,u(xe)),W(3,u(O)),W(4,u(v)),W(5,u(Je)),W(6,a),W(7,_e)],dn);let fn=class extends _{constructor(e,t){super(),this._renderManagerService=e,this._sheetsRenderService=t,[fe,de,le,se].forEach(e=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(e.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(b.UNIVER_SHEET,[dn]))}};fn=G([W(0,He),W(1,u(Se))],fn);let Z=class extends h{constructor(e=on,t,n){super(),this._config=e,this._injector=t,this._configService=n;let{menu:r,...i}=w({},on,this._config);r&&this._configService.setConfig(`menu`,r,{merge:!0}),this._configService.setConfig(an,i)}onStarting(){[[X],[fn]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(X)}onRendered(){this._injector.get(fn)}};q(Z,`type`,b.UNIVER_SHEET),q(Z,`pluginName`,`SHEET_FILTER_UI_PLUGIN`),q(Z,`packageName`,nn),q(Z,`version`,rn),Z=G([r(he),W(1,u(d)),W(2,o)],Z);function pn(e){let t=e.get(O);return{id:me.id,type:Ie.BUTTON_SELECTOR,icon:`FilterIcon`,tooltip:`sheets-filter.toolbar.smart-toggle-filter-tooltip`,hidden$:ze(e,b.UNIVER_SHEET),activated$:t.activeFilterModel$.pipe(F(e=>!!e)),disabled$:De(e,Ee(e,{worksheetTypes:[M,N],rangeTypes:[j]}))}}function mn(e){let t=e.get(O);return{id:ie.id,type:Ie.BUTTON,title:`sheets-filter.toolbar.clear-filter-criteria`,hidden$:ze(e,b.UNIVER_SHEET),disabled$:t.activeFilterModel$.pipe(st(e=>{var t;return(t=e==null?void 0:e.hasCriteria$.pipe(F(e=>!e)))==null?I(!0):t}))}}function hn(e){let t=e.get(O);return{id:oe.id,type:Ie.BUTTON,title:`sheets-filter.toolbar.re-calc-filter-conditions`,hidden$:ze(e,b.UNIVER_SHEET),disabled$:t.activeFilterModel$.pipe(st(e=>{var t;return(t=e==null?void 0:e.hasCriteria$.pipe(F(e=>!e)))==null?I(!0):t}))}}const gn={[Re.ORGANIZATION]:{[me.id]:{order:2,menuItemFactory:pn,[ie.id]:{order:0,menuItemFactory:mn},[oe.id]:{order:1,menuItemFactory:hn}}}};function _n(e){let{model:t}=e,n=k(p),r=A(t.cellFillColors$,[],!0),i=A(t.cellTextColors$,[],!0),a=L(e=>{t.onFilterCheckToggled(e)},[t]),o=L(e=>{t.onFilterCheckToggled(e,!1)},[t]);return R(`div`,{"data-u-comp":`sheets-filter-panel-colors-container`,className:`univer-flex univer-h-full univer-min-h-[300px] univer-flex-col`,children:z(`div`,{"data-u-comp":`sheets-filter-panel`,className:Tt(`univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5`,wt),children:[r.length>1&&z(`div`,{children:[R(`div`,{className:`univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:n.t(`sheets-filter.panel.filter-by-cell-fill-color`)}),R(`div`,{className:`univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2`,children:r.map((e,t)=>z(`div`,{className:`univer-relative univer-size-6`,onClick:()=>a(e),children:[e.color?R(`button`,{type:`button`,className:Tt(`univer-box-border univer-size-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white`),style:{backgroundColor:e.color}}):R(Dt,{className:`univer-size-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white`}),e.checked&&R(vn,{})]},`sheets-filter-cell-fill-color-${t}`))})]}),i.length>1&&z(`div`,{children:[R(`div`,{className:`univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:n.t(`sheets-filter.panel.filter-by-cell-text-color`)}),R(`div`,{className:`univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2`,children:i.map((e,t)=>z(`div`,{className:`univer-relative univer-size-6`,onClick:()=>o(e),children:[R(`div`,{className:`univer-box-border univer-flex univer-size-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]`,children:R(Et,{style:{color:e.color}})}),e.checked&&R(vn,{})]},`sheets-filter-cell-text-color-${t}`))})]}),r.length<=1&&i.length<=1&&R(`div`,{className:`univer-flex univer-size-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200`,children:n.t(`sheets-filter.panel.filter-by-color-none`)})]})})}function vn(){return R(`div`,{className:`univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-size-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white`,children:R(At,{className:`univer-size-full univer-font-bold univer-text-[#418F1F]`})})}function yn(e){var t,n;let{model:r}=e,i=k(p),a=A(r.conditionItem$,void 0),o=A(r.filterConditionFormParams$,void 0),s=o!=null&&o.and?`AND`:`OR`,c=L(e=>{r.onConditionFormChange({and:e===`AND`})},[r]),l=bn(i),u=L(e=>{r.onPrimaryConditionChange(e)},[r]),d=xn(i),f=L(e=>{r.onConditionFormChange(e)},[r]),m=i.t(`sheets-filter.panel.input-values-placeholder`);function h(e,t,n){let r=H.getItemByOperator(e).numOfParameters===1;return z(Mt,{children:[n===`operator2`&&z(vt,{value:s,onChange:c,children:[R(_t,{value:`AND`,children:i.t(`sheets-filter.panel.and`)}),R(_t,{value:`OR`,children:i.t(`sheets-filter.panel.or`)})]}),R(bt,{value:e,options:d,onChange:e=>f({[n]:e})}),r&&R(`div`,{children:R(ht,{className:`univer-mt-2`,value:t,placeholder:m,onChange:e=>f({[n===`operator1`?`val1`:`val2`]:e})})})]})}return R(`div`,{"data-u-comp":`sheets-filter-panel-conditions-container`,className:`univer-flex univer-h-full univer-min-h-[300px] univer-flex-col`,children:a&&o&&z(Mt,{children:[R(bt,{value:a.operator,options:l,onChange:u}),H.getItemByOperator(a.operator).numOfParameters===0?null:z(`div`,{"data-u-comp":`sheets-filter-panel-conditions-container-inner`,className:Tt(`univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2`,wt),children:[a.numOfParameters>=1&&h(o.operator1,(t=o.val1)==null?``:t,`operator1`),a.numOfParameters>=2&&h(o.operator2,(n=o.val2)==null?``:n,`operator2`),z(`div`,{"data-u-comp":`sheets-filter-panel-conditions-desc`,className:`univer-mt-2 univer-text-xs univer-text-gray-500`,children:[i.t(`sheets-filter.panel.?`),R(`br`,{}),i.t(`sheets-filter.panel.*`)]})]})]})})}function bn(e){return jt(()=>[{options:[{label:e.t(H.NONE.label),value:H.NONE.operator}]},{options:[{label:e.t(H.EMPTY.label),value:H.EMPTY.operator},{label:e.t(H.NOT_EMPTY.label),value:H.NOT_EMPTY.operator}]},{options:[{label:e.t(H.TEXT_CONTAINS.label),value:H.TEXT_CONTAINS.operator},{label:e.t(H.DOES_NOT_CONTAIN.label),value:H.DOES_NOT_CONTAIN.operator},{label:e.t(H.STARTS_WITH.label),value:H.STARTS_WITH.operator},{label:e.t(H.ENDS_WITH.label),value:H.ENDS_WITH.operator},{label:e.t(H.EQUALS.label),value:H.EQUALS.operator}]},{options:[{label:e.t(H.GREATER_THAN.label),value:H.GREATER_THAN.operator},{label:e.t(H.GREATER_THAN_OR_EQUAL.label),value:H.GREATER_THAN_OR_EQUAL.operator},{label:e.t(H.LESS_THAN.label),value:H.LESS_THAN.operator},{label:e.t(H.LESS_THAN_OR_EQUAL.label),value:H.LESS_THAN_OR_EQUAL.operator},{label:e.t(H.EQUAL.label),value:H.EQUAL.operator},{label:e.t(H.NOT_EQUAL.label),value:H.NOT_EQUAL.operator},{label:e.t(H.BETWEEN.label),value:H.BETWEEN.operator},{label:e.t(H.NOT_BETWEEN.label),value:H.NOT_BETWEEN.operator}]},{options:[{label:e.t(H.CUSTOM.label),value:H.CUSTOM.operator}]}],[e.getCurrentLocale(),e])}function xn(e){return jt(()=>H.ALL_CONDITIONS.filter(e=>e.numOfParameters!==2).map(t=>({label:e.t(t.label),value:t.operator})),[e.getCurrentLocale(),e])}function Sn(e){let{model:t}=e,n=k(p),r=A(t.searchString$,``,!0),i=A(t.filterItems$,void 0,!0),a=n.t(`sheets-filter.panel.filter-only`),o=Nt(i),s=o.checked>0&&o.unchecked===0,c=o.checked>0&&o.unchecked>0,l=t.treeMapCache,u=L(()=>{t.onCheckAllToggled(!s)},[t,s]),d=L(e=>{t.setSearchString(e)},[t]);function f(e){let t=[];return e.forEach(e=>{e.checked&&t.push(e.key),e.children&&(t=t.concat(f(e.children)))}),t}return z(`div`,{"data-u-comp":`sheets-filter-panel-values-container`,className:`univer-flex univer-h-full univer-min-h-[300px] univer-flex-col`,children:[R(ht,{autoFocus:!0,value:r,placeholder:n.t(`sheets-filter.panel.search-placeholder`),onChange:d}),z(`div`,{"data-u-comp":`sheets-filter-panel`,className:Tt(`univer-mt-2 univer-box-border univer-flex univer-flex-grow univer-flex-col univer-overflow-hidden univer-rounded-md univer-px-2 univer-py-2.5`,wt),children:[R(`div`,{"data-u-comp":`sheets-filter-panel-values-item`,className:`univer-box-border univer-h-8 univer-w-full univer-py-0.5`,children:z(`div`,{"data-u-comp":`sheets-filter-panel-values-item-inner`,className:`univer-box-border univer-flex univer-h-7 univer-items-center univer-rounded-md univer-py-0 univer-pl-5 univer-pr-0.5 univer-text-sm`,children:[R(mt,{indeterminate:c,disabled:i.length===0,checked:s,onChange:u}),R(`span`,{"data-u-comp":`sheets-filter-panel-values-item-text`,className:`univer-mx-1 univer-inline-block univer-flex-shrink univer-truncate univer-text-gray-900 dark:!univer-text-white`,children:`${n.t(`sheets-filter.panel.select-all`)}`}),R(`span`,{"data-u-comp":`sheets-filter-panel-values-item-count`,className:`univer-text-gray-400 dark:!univer-text-gray-500`,children:`(${o.checked}/${o.checked+o.unchecked})`})]})}),R(`div`,{"data-u-comp":`sheets-filter-panel-values-virtual`,className:`univer-flex-grow`,children:R(Ct,{data:i,defaultExpandAll:!1,valueGroup:f(i),onChange:e=>{t.onFilterCheckToggled(e)},defaultCache:l,itemHeight:28,treeNodeClassName:`
52
2
  univer-pr-2 univer-border-box univer-rounded-md
53
3
  [&:hover_a]:univer-inline-block
54
4
  hover:univer-bg-gray-50 univer-h-full
55
5
  univer-text-gray-900 dark:hover:!univer-bg-gray-900
56
6
  dark:!univer-text-white
57
- `,attachRender:e=>z(`div`,{className:`
58
- univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer
59
- univer-items-center univer-justify-between univer-text-sm univer-text-primary-500
60
- `,children:[R(`span`,{"data-u-comp":`sheets-filter-panel-values-item-count`,className:`
61
- univer-text-gray-400
62
- dark:!univer-text-gray-500
63
- `,children:`(${e.count})`}),R(`a`,{className:`
64
- univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5
65
- `,onClick:()=>{let n=[];e.children?e.children.forEach(e=>{e.children?e.children.forEach(e=>{n.push(e.key)}):n.push(e.key)}):n.push(e.key),t.onFilterOnly(n)},children:a})]})})})]})]})}function Cn(){let e=k(pe);if(!A(e.visible$,void 0,!0))return null;let t=k(p),n=k(Ne),r=A(e.enabled$,void 0,!0);return z(`div`,{className:`
66
- univer-mt-2 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-900
67
- dark:!univer-text-gray-200
68
- `,children:[z(`div`,{className:`univer-flex univer-items-center univer-gap-1`,children:[R(`span`,{children:t.t(`sheets-filter.sync.title`)}),R(St,{title:r?t.t(`sheets-filter.sync.statusTips.off`):t.t(`sheets-filter.sync.statusTips.on`),asChild:!0,children:R(kt,{className:`univer-block`})})]}),R(xt,{defaultChecked:r,onChange:r=>{let i=r?t.t(`sheets-filter.sync.switchTips.on`):t.t(`sheets-filter.sync.switchTips.off`);e.setEnabled(r),n.show({content:i,type:gt.Success,duration:2e3})}})]})}function wn(){var e;let t=k(J),n=k(p),r=k(a),i=A(t.filterBy$,void 0,!0),o=A(t.filterByModel$,void 0,!1),s=A(()=>(o==null?void 0:o.canApply$)||I(!1),void 0,!1,[o]),c=Tn(n),l=!A(t.hasCriteria$),u=L(e=>{r.executeCommand(tn.id,{filterBy:e})},[r]),d=L(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(Y.id)},[o,r]),f=L(()=>{r.executeCommand(Y.id)},[r]),m=L(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(Y.id)},[o,r]),h=(e=k(O).activeFilterModel)==null?void 0:e.getRange(),g=t.col,_=Be(Ce.FILTER_PANEL_EMBED_POINT);return z(`div`,{"data-u-comp":`sheets-filter-panel`,className:`
69
- univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg
70
- univer-bg-white univer-p-4 univer-shadow-lg
71
- dark:!univer-border-gray-600 dark:!univer-bg-gray-700
72
- `,children:[R(ke,{components:_,sharedProps:{range:h,colIndex:g,onClose:f}}),R(`div`,{className:`univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0`,children:R(yt,{value:i,items:c,onChange:e=>u(e)})}),o?R(`div`,{"data-u-comp":`sheets-filter-panel-content`,className:`univer-flex-shrink univer-flex-grow univer-pt-2`,children:i===E.VALUES?R(Sn,{model:o}):i===E.COLORS?R(_n,{model:o}):R(yn,{model:o})}):R(`div`,{className:`univer-flex-1`}),R(Cn,{}),z(`div`,{"data-u-comp":`sheets-filter-panel-footer`,className:`
73
- univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap
74
- univer-justify-between univer-overflow-hidden
75
- `,children:[R(pt,{variant:`link`,onClick:d,disabled:l,children:n.t(`sheets-filter.panel.clear-filter`)}),z(`span`,{className:`univer-flex univer-gap-2`,children:[R(pt,{variant:`default`,onClick:f,children:n.t(`sheets-filter.panel.cancel`)}),R(pt,{disabled:!s,variant:`primary`,onClick:m,children:n.t(`sheets-filter.panel.confirm`)})]})]})]})}function Tn(e){return jt(()=>[{label:e.t(`sheets-filter.panel.by-values`),value:E.VALUES},{label:e.t(`sheets-filter.panel.by-colors`),value:E.COLORS},{label:e.t(`sheets-filter.panel.by-conditions`),value:E.CONDITIONS}],[e.getCurrentLocale(),e])}const En={id:me.id,binding:Fe.L|Le.CTRL_COMMAND|Le.SHIFT,description:`sheets-filter.shortcut.smart-toggle-filter`,preconditions:Oe,group:`4_sheet-edit`},Dn=`FILTER_PANEL_POPUP`;let On=class extends fn{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){super(f,d),this._injector=e,this._componentManager=t,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=r,this._sheetsFilterService=i,this._localeService=a,this._shortcutService=o,this._commandService=s,this._menuManagerService=c,this._contextService=l,this._messageService=u,q(this,`_popupDisposable`,void 0),this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[En].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[me,ce,ue,D,ie,oe,tn,en,Y].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(gn)}_initUI(){[[Dn,wn],[`FilterIcon`,Ot]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))}),this.disposeWithMe(this._contextService.subscribeContextValue$($t).pipe(nt()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:gt.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){let e=this._sheetsFilterPanelService.filterModel;if(!e)throw Error(`[SheetsFilterUIController]: no filter model when opening filter popup!`);let t=e.getRange(),n=this._sheetsFilterPanelService.col,{startRow:r}=t;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(r,n,{componentKey:Dn,direction:`horizontal`,onClickOutside:()=>this._commandService.syncExecuteCommand(Y.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};On=G([W(0,u(d)),W(1,u(Ae)),W(2,u(J)),W(3,u(be)),W(4,u(O)),W(5,u(p)),W(6,Pe),W(7,a),W(8,Me),W(9,s),W(10,Ne),W(11,u(Se)),W(12,He)],On);let Q=class extends h{constructor(e=on,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._rpcChannelService=r;let{menu:i,...a}=w({},on,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(an,a)}onStarting(){ne(this._injector,[[J],[X],[On]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([Ft,{useFactory:()=>ft(this._rpcChannelService.requestChannel(Pt))}])}onReady(){re(this._injector,[[X]])}onRendered(){re(this._injector,[[On]])}};q(Q,`type`,b.UNIVER_SHEET),q(Q,`pluginName`,`SHEET_FILTER_UI_PLUGIN`),q(Q,`packageName`,nn),q(Q,`version`,rn),Q=G([r(he),W(1,u(d)),W(2,o),W(3,m(ut))],Q);let $=class extends h{constructor(e,t,n){super(),this._config=e,this._injector=t,this._rpcChannelService=n}onStarting(){[[Ft,{useClass:It}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Pt,dt(this._injector.get(Ft)))}};q($,`type`,b.UNIVER_SHEET),q($,`pluginName`,`SHEET_FILTER_UI_WORKER_PLUGIN`),q($,`packageName`,nn),q($,`version`,rn),$=G([W(1,u(d)),W(2,ut)],$);export{tn as ChangeFilterByOperation,Y as CloseFilterPanelOperation,en as OpenFilterPanelOperation,Z as UniverSheetsFilterMobileUIPlugin,Q as UniverSheetsFilterUIPlugin,$ as UniverSheetsFilterUIWorkerPlugin};
7
+ `,attachRender:e=>z(`div`,{className:`univer-ml-1 univer-flex univer-h-5 univer-flex-1 univer-cursor-pointer univer-items-center univer-justify-between univer-text-sm univer-text-primary-500`,children:[R(`span`,{"data-u-comp":`sheets-filter-panel-values-item-count`,className:`univer-text-gray-400 dark:!univer-text-gray-500`,children:`(${e.count})`}),R(`a`,{className:`univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5`,onClick:()=>{let n=[];e.children?e.children.forEach(e=>{e.children?e.children.forEach(e=>{n.push(e.key)}):n.push(e.key)}):n.push(e.key),t.onFilterOnly(n)},children:a})]})})})]})]})}function Cn(){let e=k(pe);if(!A(e.visible$,void 0,!0))return null;let t=k(p),n=k(Ne),r=A(e.enabled$,void 0,!0);return z(`div`,{className:`univer-mt-2 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200`,children:[z(`div`,{className:`univer-flex univer-items-center univer-gap-1`,children:[R(`span`,{children:t.t(`sheets-filter.sync.title`)}),R(St,{title:r?t.t(`sheets-filter.sync.statusTips.off`):t.t(`sheets-filter.sync.statusTips.on`),asChild:!0,children:R(kt,{className:`univer-block`})})]}),R(xt,{defaultChecked:r,onChange:r=>{let i=r?t.t(`sheets-filter.sync.switchTips.on`):t.t(`sheets-filter.sync.switchTips.off`);e.setEnabled(r),n.show({content:i,type:gt.Success,duration:2e3})}})]})}function wn(){var e;let t=k(J),n=k(p),r=k(a),i=A(t.filterBy$,void 0,!0),o=A(t.filterByModel$,void 0,!1),s=A(()=>(o==null?void 0:o.canApply$)||I(!1),void 0,!1,[o]),c=Tn(n),l=!A(t.hasCriteria$),u=L(e=>{r.executeCommand(tn.id,{filterBy:e})},[r]),d=L(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(Y.id)},[o,r]),f=L(()=>{r.executeCommand(Y.id)},[r]),m=L(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(Y.id)},[o,r]),h=(e=k(O).activeFilterModel)==null?void 0:e.getRange(),g=t.col,_=Be(Ce.FILTER_PANEL_EMBED_POINT);return z(`div`,{"data-u-comp":`sheets-filter-panel`,className:`univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700`,children:[R(ke,{components:_,sharedProps:{range:h,colIndex:g,onClose:f}}),R(`div`,{className:`univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0`,children:R(yt,{value:i,items:c,onChange:e=>u(e)})}),o?R(`div`,{"data-u-comp":`sheets-filter-panel-content`,className:`univer-flex-shrink univer-flex-grow univer-pt-2`,children:i===E.VALUES?R(Sn,{model:o}):i===E.COLORS?R(_n,{model:o}):R(yn,{model:o})}):R(`div`,{className:`univer-flex-1`}),R(Cn,{}),z(`div`,{"data-u-comp":`sheets-filter-panel-footer`,className:`univer-mt-4 univer-inline-flex univer-flex-shrink-0 univer-flex-grow-0 univer-flex-nowrap univer-justify-between univer-overflow-hidden`,children:[R(pt,{variant:`link`,onClick:d,disabled:l,children:n.t(`sheets-filter.panel.clear-filter`)}),z(`span`,{className:`univer-flex univer-gap-2`,children:[R(pt,{variant:`default`,onClick:f,children:n.t(`sheets-filter.panel.cancel`)}),R(pt,{disabled:!s,variant:`primary`,onClick:m,children:n.t(`sheets-filter.panel.confirm`)})]})]})]})}function Tn(e){return jt(()=>[{label:e.t(`sheets-filter.panel.by-values`),value:E.VALUES},{label:e.t(`sheets-filter.panel.by-colors`),value:E.COLORS},{label:e.t(`sheets-filter.panel.by-conditions`),value:E.CONDITIONS}],[e.getCurrentLocale(),e])}const En={id:me.id,binding:Fe.L|Le.CTRL_COMMAND|Le.SHIFT,description:`sheets-filter.shortcut.smart-toggle-filter`,preconditions:Oe,group:`4_sheet-edit`},Dn=`FILTER_PANEL_POPUP`;let On=class extends fn{constructor(e,t,n,r,i,a,o,s,c,l,u,d,f){super(f,d),this._injector=e,this._componentManager=t,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=r,this._sheetsFilterService=i,this._localeService=a,this._shortcutService=o,this._commandService=s,this._menuManagerService=c,this._contextService=l,this._messageService=u,q(this,`_popupDisposable`,void 0),this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[En].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[me,ce,ue,D,ie,oe,tn,en,Y].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(gn)}_initUI(){[[Dn,wn],[`FilterIcon`,Ot]].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))}),this.disposeWithMe(this._contextService.subscribeContextValue$($t).pipe(nt()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:gt.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){let e=this._sheetsFilterPanelService.filterModel;if(!e)throw Error(`[SheetsFilterUIController]: no filter model when opening filter popup!`);let t=e.getRange(),n=this._sheetsFilterPanelService.col,{startRow:r}=t;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(r,n,{componentKey:Dn,direction:`horizontal`,onClickOutside:()=>this._commandService.syncExecuteCommand(Y.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};On=G([W(0,u(d)),W(1,u(Ae)),W(2,u(J)),W(3,u(be)),W(4,u(O)),W(5,u(p)),W(6,Pe),W(7,a),W(8,Me),W(9,s),W(10,Ne),W(11,u(Se)),W(12,He)],On);let Q=class extends h{constructor(e=on,t,n,r){super(),this._config=e,this._injector=t,this._configService=n,this._rpcChannelService=r;let{menu:i,...a}=w({},on,this._config);i&&this._configService.setConfig(`menu`,i,{merge:!0}),this._configService.setConfig(an,a)}onStarting(){ne(this._injector,[[J],[X],[On]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([Ft,{useFactory:()=>ft(this._rpcChannelService.requestChannel(Pt))}])}onReady(){re(this._injector,[[X]])}onRendered(){re(this._injector,[[On]])}};q(Q,`type`,b.UNIVER_SHEET),q(Q,`pluginName`,`SHEET_FILTER_UI_PLUGIN`),q(Q,`packageName`,nn),q(Q,`version`,rn),Q=G([r(he),W(1,u(d)),W(2,o),W(3,m(ut))],Q);let $=class extends h{constructor(e,t,n){super(),this._config=e,this._injector=t,this._rpcChannelService=n}onStarting(){[[Ft,{useClass:It}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Pt,dt(this._injector.get(Ft)))}};q($,`type`,b.UNIVER_SHEET),q($,`pluginName`,`SHEET_FILTER_UI_WORKER_PLUGIN`),q($,`packageName`,nn),q($,`version`,rn),$=G([W(1,u(d)),W(2,ut)],$);export{tn as ChangeFilterByOperation,Y as CloseFilterPanelOperation,en as OpenFilterPanelOperation,Z as UniverSheetsFilterMobileUIPlugin,Q as UniverSheetsFilterUIPlugin,$ as UniverSheetsFilterUIWorkerPlugin};
@@ -31,12 +31,14 @@ export declare class SheetsFilterRenderController extends RxDisposable implement
31
31
  private readonly _sheetInterceptorService;
32
32
  private readonly _commandService;
33
33
  private readonly _selectionRenderService;
34
+ private _currentRenderParams;
34
35
  private _filterRangeShape;
35
36
  private _buttonRenderDisposable;
36
37
  private _filterButtonShapes;
37
38
  constructor(_context: IRenderContext<Workbook>, _injector: Injector, _sheetSkeletonManagerService: SheetSkeletonManagerService, _sheetsFilterService: SheetsFilterService, _themeService: ThemeService, _sheetInterceptorService: SheetInterceptorService, _commandService: ICommandService, _selectionRenderService: ISheetSelectionRenderService);
38
39
  dispose(): void;
39
40
  private _initRenderer;
41
+ private _refreshRendering;
40
42
  private _renderRange;
41
43
  private _renderButtons;
42
44
  private _interceptCellContent;