@univerjs/sheets-filter-ui 0.8.0-beta.0 → 0.8.0-nightly.202505271607

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/cjs/index.js CHANGED
@@ -1,7 +1,7 @@
1
- "use strict";var Ze=Object.defineProperty;var ze=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var v=(t,e,r)=>ze(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),ge=require("@univerjs/rpc"),c=require("@univerjs/sheets-filter"),O=require("@univerjs/sheets"),C=require("@univerjs/ui"),U=require("@univerjs/sheets-ui"),S=require("rxjs"),y=require("@univerjs/design"),ie=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),b=require("react"),De="sheets-filter-ui.config",he={};var I=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(I||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:I.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:I.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:I.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.CONTAINS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,a,h;return((a=(o=i.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:I.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:o,operator1:a,operator2:h}=i;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:I.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:a,operator2:h}=i;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:I.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=i;function T(M,A){for(const k of t.ALL_CONDITIONS)if(k.operator===M)return k.mapToFilterColumn({val1:A,operator1:M})}const _=!m||m===t.NONE.operator,E=!f||f===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return T(f,h);if(E)return T(m,a);const F=T(m,a),R=T(f,h),N={customFilters:[F.customFilters.customFilters[0],R.customFilters.customFilters[0]]};return o&&(N.and=u.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return o}t.getItemByOperator=e;function r(i,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function s(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=s;function n(i,o){return i.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(i){if(!i)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(i);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function x(t){const{operator1:e,operator2:r,val1:s,val2:n}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,s]:[r,n]}function Oe(t){const e=[],r=[];let s=0,n=0;function l(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(r.push(i),n+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:s,unchecked:n}}var Je=Object.getOwnPropertyDescriptor,et=(t,e,r,s)=>{for(var n=s>1?void 0:s?Je(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Fe=(t,e)=>(r,s)=>e(r,s,t);const Pe="sheets-filter.generate-filter-values.service",me=u.createIdentifier(Pe),tt=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Ne=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:s,filters:n,blankChecked:l,iterateRange:i,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),He(n,this._localeService,i,h,new Set(s),new Set(o.map(String)),l,a.getStyles()))}};Ne=et([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],Ne);function He(t,e,r,s,n,l,i,o){var F,R,N,M,A,k,D,oe,ae;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(tt),T="empty";let _=0;for(const L of s.iterateByColumn(r,!1,!1)){const{row:qe,rowSpan:Me=1}=L;let K=0;for(;K<Me;){const Ke=qe+K;if(n.has(Ke)){K++;continue}const G=L!=null&&L.value?u.extractPureTextFromCell(L.value):"";if(!G){_+=1,K+=Me;continue}const le=(F=L.value)!=null&&F.v&&!L.value.p?(M=(N=o.get((R=L.value)==null?void 0:R.s))==null?void 0:N.n)==null?void 0:M.pattern:"",Xe=le&&u.numfmt.isDate(le);if(le&&Xe&&f.has(le)){const W=(A=s.getCellRaw(L.row,L.col))==null?void 0:A.v;if(!W){K++;continue}const X=u.numfmt.format(m,W),[P,H,te]=X.split("-").map(Number);let Y=a.get(`${P}`);Y||(Y={title:`${P}`,key:`${P}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${P}`,Y),h.set(`${P}`,[`${P}`]));let j=(k=Y.children)==null?void 0:k.find(Ce=>Ce.key===`${P}-${H}`);j||(j={title:e.t(`sheets-filter.date.${H}`),key:`${P}-${H}`,children:[],count:0,leaf:!1,checked:!1},(D=Y.children)==null||D.push(j),h.set(`${P}-${H}`,[`${P}`,`${P}-${H}`]));const Se=(oe=j==null?void 0:j.children)==null?void 0:oe.find(Ce=>Ce.key===`${P}-${H}-${te}`);Se?(Se.originValues.add(G),Se.count++,j.count++,Y.count++):((ae=j.children)==null||ae.push({title:`${te}`,key:`${P}-${H}-${te}`,count:1,originValues:new Set([G]),leaf:!0,checked:l.size?l.has(G):!i}),j.count++,Y.count++,h.set(`${P}-${H}-${te}`,[`${P}`,`${P}-${H}`,`${P}-${H}-${te}`]))}else{const W=G;let X=a.get(W);X?X.count++:(X={title:G,leaf:!0,checked:l.size?l.has(G):!i,key:W,count:1},a.set(W,X),h.set(W,[W]))}K++}}const E=t?i:!0;if(_>0){const L={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:T};a.set("empty",L),h.set("empty",[T])}return{filterTreeItems:rt(Array.from(a.values())),filterTreeMapCache:h}}function rt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:it(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,s)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(s.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((s,n)=>{const l=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return l-i})}),e))}const Le=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function it(t,e){const r=Le(t),s=Le(e);return r&&s?Number.parseFloat(t)-Number.parseFloat(e):r&&!s?-1:!r&&s?1:t.localeCompare(e)}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const s=Ie(r.children,e);if(s)return s}}return null}function je(t){return t.leaf?t.checked:t.children?t.children.every(e=>je(e)):!0}function re(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>re(r,e))}function Be(t,e){const r=[];return t.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...s});else if(s.children){const o=Be(s.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...s,count:a,children:o})}}}),r}var st=Object.getOwnPropertyDescriptor,be=(t,e,r,s)=>{for(var n=s>1?void 0:s?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},pe=(t,e)=>(r,s)=>e(r,s,t),de=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(de||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new S.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new S.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new S.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new S.BehaviorSubject(-1));v(this,"col$",this._col$.asObservable());v(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}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()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const s=e.getFilterColumn(r);if(s){const n=s.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await _e.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=fe.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=be([pe(0,u.Inject(u.Injector)),pe(1,u.Inject(O.RefRangeService))],Q);let fe=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"canApply$",S.of(!0));v(this,"_conditionItem$");v(this,"conditionItem$");v(this,"_filterConditionFormParams$");v(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new S.BehaviorSubject(s),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,s,n){const[l,i]=p.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(fe,r,s,l,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(s=>s.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const s=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(r)}};fe=be([pe(4,u.ICommandService)],fe);let _e=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"_rawFilterItems$");v(this,"rawFilterItems$");v(this,"filterItems$");v(this,"_filterItems",[]);v(this,"_treeMapCache");v(this,"canApply$");v(this,"_manuallyUpdateFilterItems$");v(this,"_searchString$");v(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=n,this._searchString$=new S.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new S.BehaviorSubject(s),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new S.Subject,this.filterItems$=S.merge(S.combineLatest([this._searchString$.pipe(S.throttleTime(500,void 0,{leading:!0,trailing:!0}),S.startWith(void 0)),this._rawFilterItems$]).pipe(S.map(([i,o])=>{if(!i)return o;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return Be(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>Oe(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,s){var k;const n=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(me,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),T=s,_=(k=r.getFilterColumn(s))==null?void 0:k.getColumnData().filters,E=new Set(_==null?void 0:_.filters),F=!!(_&&_.blank),R=r.getFilteredOutRowsExceptCol(s),N={...f,startRow:f.startRow+1,startColumn:T,endColumn:T};let M,A;if(i){const D=await i.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(R),filters:!!_,blankChecked:F,iterateRange:N,alreadyChecked:Array.from(E)});M=D.filterTreeItems,A=D.filterTreeMapCache}else{const D=He(!!_,l,N,m,R,E,F,h.getStyles());M=D.filterTreeItems,A=D.filterTreeMapCache}return e.createInstance(_e,r,s,M,A)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),s=Ie(r,e.key);if(!s)return;const n=je(s);re(s,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,!1)),e.forEach(s=>{const n=Ie(r,s);n&&re(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Oe(this._filterItems),{checked:r,checkedItems:s}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const i=r===0,o=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=s.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==s.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};_e=be([pe(4,u.ICommandService)],_e);const J="FILTER_PANEL_OPENED",se={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),s=t.get(c.SheetsFilterService),n=t.get(Q);t.get(u.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:o,col:a}=e,h=s.getFilterModel(i,o);return h?(n.setupCol(h,a),r.getContextValue(J)||r.setContextValue(J,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(Q),s=t.get(C.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(J)?(e.setContextValue(J,!1),s==null||s.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}};var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,s)=>{for(var n=s>1?void 0:s?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Z=(t,e)=>(r,s)=>e(r,s,t);let ee=class extends u.Disposable{constructor(t,e,r,s,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,s;if(t.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:i,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let T={...f};T=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[T],i,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===se.id){const n=t.params,{unitId:l,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:s.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ee=ot([Z(0,u.Inject(c.SheetsFilterService)),Z(1,u.Inject(u.LocaleService)),Z(2,u.ICommandService),Z(3,u.Inject(O.SheetPermissionCheckController)),Z(4,u.Inject(u.Injector)),Z(5,u.Inject(O.SheetsSelectionsService))],ee);var $=function(){return $=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},$.apply(this,arguments)},at=function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r},We=b.forwardRef(function(t,e){var r=t.icon,s=t.id,n=t.className,l=t.extend,i=at(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(s," ").concat(n||"").trim(),a=b.useRef("_".concat(ut()));return Ve(r,"".concat(s),{defIds:r.defIds,idSuffix:a.current},$({ref:e,className:o},i),l)});function Ve(t,e,r,s,n){return b.createElement(t.tag,$($({key:e},lt(t,r,n)),s),(ct(t,r).children||[]).map(function(l,i){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,n)}))}function lt(t,e,r){var s=$({},t.attrs);r!=null&&r.colorChannel1&&s.fill==="colorChannel1"&&(s.fill=r.colorChannel1),t.tag==="mask"&&s.id&&(s.id=s.id+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];i==="mask"&&typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&s["xlink:href"]&&(s["xlink:href"]=s["xlink:href"]+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),s}function ct(t,e){var r,s=e.defIds;return!s||s.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?$($({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&s&&s.indexOf(n.attrs.id)>-1?$($({},n),{attrs:$($({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function ut(){return Math.random().toString(36).substring(2,8)}We.displayName="UniverIcon";var ht={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=b.forwardRef(function(t,e){return b.createElement(We,Object.assign({},t,{id:"filter-single",ref:e,icon:ht}))});Qe.displayName="FilterSingle";function mt(t){var _,E;const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.conditionItem$,void 0),n=C.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",i=b.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=pt(r),a=b.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=dt(r),m=b.useCallback(F=>{e.onConditionFormChange(F)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function T(F,R,N){const M=p.getItemByOperator(F).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:F,options:h,onChange:A=>m({[N]:A})}),M&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:R,placeholder:f,onChange:A=>m({[N==="operator1"?"val1":"val2"]:A})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-flex-col",children:s&&n&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:s.operator,options:o,onChange:a}),p.getItemByOperator(s.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[s.numOfParameters>=1&&T(n.operator1,(_=n.val1)!=null?_:"","operator1"),s.numOfParameters>=2&&T(n.operator2,(E=n.val2)!=null?E:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function pt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function dt(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function ft(t){const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.searchString$,"",!0),n=C.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Oe(n),o=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=b.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=b.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let E=[];return _.forEach(F=>{F.checked&&E.push(F.key),F.children&&(E=E.concat(T(F.children)))}),E}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:s,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("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",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("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-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:`
1
+ "use strict";var Ze=Object.defineProperty;var ze=(t,e,r)=>e in t?Ze(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var v=(t,e,r)=>ze(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),ge=require("@univerjs/rpc"),c=require("@univerjs/sheets-filter"),O=require("@univerjs/sheets"),C=require("@univerjs/ui"),U=require("@univerjs/sheets-ui"),S=require("rxjs"),y=require("@univerjs/design"),ie=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),b=require("react"),De="sheets-filter-ui.config",he={};var I=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(I||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:I.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:I.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:I.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.CONTAINS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=x(i);return o===g.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:I.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===g.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,a,h;return((a=(o=i.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:i.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:I.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=x(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=i.customFilters.customFilters[0];return o.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:I.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:i=>{const{and:o,operator1:a,operator2:h}=i;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:I.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:a,operator2:h}=i;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:I.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=i;function T(M,A){for(const k of t.ALL_CONDITIONS)if(k.operator===M)return k.mapToFilterColumn({val1:A,operator1:M})}const _=!m||m===t.NONE.operator,E=!f||f===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return T(f,h);if(E)return T(m,a);const F=T(m,a),R=T(f,h),N={customFilters:[F.customFilters.customFilters[0],R.customFilters.customFilters[0]]};return o&&(N.and=u.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(a.and=!0),a}},t.ALL_CONDITIONS=[t.NONE,t.EMPTY,t.NOT_EMPTY,t.TEXT_CONTAINS,t.DOES_NOT_CONTAIN,t.STARTS_WITH,t.ENDS_WITH,t.EQUALS,t.GREATER_THAN,t.GREATER_THAN_OR_EQUAL,t.LESS_THAN,t.LESS_THAN_OR_EQUAL,t.EQUAL,t.NOT_EQUAL,t.BETWEEN,t.NOT_BETWEEN,t.CUSTOM];function e(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return o}t.getItemByOperator=e;function r(i,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(i))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(i))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function s(i){const o=t.ALL_CONDITIONS.find(a=>a.operator===i);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=s;function n(i,o){return i.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(i){if(!i)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(i);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function x(t){const{operator1:e,operator2:r,val1:s,val2:n}=t;if(e&&r)throw new Error("Both operator1 and operator2 are set!");if(!e&&!r)throw new Error("Neither operator1 and operator2 and both not set!");return e?[e,s]:[r,n]}function Oe(t){const e=[],r=[];let s=0,n=0;function l(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(r.push(i),n+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:s,unchecked:n}}var Je=Object.getOwnPropertyDescriptor,et=(t,e,r,s)=>{for(var n=s>1?void 0:s?Je(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Fe=(t,e)=>(r,s)=>e(r,s,t);const Pe="sheets-filter.generate-filter-values.service",me=u.createIdentifier(Pe),tt=["yyyy-mm-dd","yyyy-mm-dd;@","yyyy/mm/dd;@","yyyy/mm/dd hh:mm","yyyy-m-d am/pm h:mm","yyyy-MM-dd","yyyy/MM/dd","yyyy/mm/dd",'yyyy"年"MM"月"dd"日"',"MM-dd",'M"月"d"日"',"MM-dd A/P hh:mm"];let Ne=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:s,filters:n,blankChecked:l,iterateRange:i,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),He(n,this._localeService,i,h,new Set(s),new Set(o.map(String)),l,a.getStyles()))}};Ne=et([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],Ne);function He(t,e,r,s,n,l,i,o){var F,R,N,M,A,k,D,oe,ae;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(tt),T="empty";let _=0;for(const w of s.iterateByColumn(r,!1,!1)){const{row:qe,rowSpan:Me=1}=w;let K=0;for(;K<Me;){const Ke=qe+K;if(n.has(Ke)){K++;continue}const G=w!=null&&w.value?u.extractPureTextFromCell(w.value):"";if(!G){_+=1,K+=Me;continue}const le=(F=w.value)!=null&&F.v&&!w.value.p?(M=(N=o.get((R=w.value)==null?void 0:R.s))==null?void 0:N.n)==null?void 0:M.pattern:"",Xe=le&&u.numfmt.isDate(le);if(le&&Xe&&f.has(le)){const W=(A=s.getCellRaw(w.row,w.col))==null?void 0:A.v;if(!W){K++;continue}const X=u.numfmt.format(m,W),[P,H,te]=X.split("-").map(Number);let Y=a.get(`${P}`);Y||(Y={title:`${P}`,key:`${P}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${P}`,Y),h.set(`${P}`,[`${P}`]));let j=(k=Y.children)==null?void 0:k.find(Ce=>Ce.key===`${P}-${H}`);j||(j={title:e.t(`sheets-filter.date.${H}`),key:`${P}-${H}`,children:[],count:0,leaf:!1,checked:!1},(D=Y.children)==null||D.push(j),h.set(`${P}-${H}`,[`${P}`,`${P}-${H}`]));const Se=(oe=j==null?void 0:j.children)==null?void 0:oe.find(Ce=>Ce.key===`${P}-${H}-${te}`);Se?(Se.originValues.add(G),Se.count++,j.count++,Y.count++):((ae=j.children)==null||ae.push({title:`${te}`,key:`${P}-${H}-${te}`,count:1,originValues:new Set([G]),leaf:!0,checked:l.size?l.has(G):!i}),j.count++,Y.count++,h.set(`${P}-${H}-${te}`,[`${P}`,`${P}-${H}`,`${P}-${H}-${te}`]))}else{const W=G;let X=a.get(W);X?X.count++:(X={title:G,leaf:!0,checked:l.size?l.has(G):!i,key:W,count:1},a.set(W,X),h.set(W,[W]))}K++}}const E=t?i:!0;if(_>0){const w={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:T};a.set("empty",w),h.set("empty",[T])}return{filterTreeItems:rt(Array.from(a.values())),filterTreeMapCache:h}}function rt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:it(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,s)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(s.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((s,n)=>{const l=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return l-i})}),e))}const we=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function it(t,e){const r=we(t),s=we(e);return r&&s?Number.parseFloat(t)-Number.parseFloat(e):r&&!s?-1:!r&&s?1:t.localeCompare(e)}function Ie(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const s=Ie(r.children,e);if(s)return s}}return null}function je(t){return t.leaf?t.checked:t.children?t.children.every(e=>je(e)):!0}function re(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>re(r,e))}function Be(t,e){const r=[];return t.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...s});else if(s.children){const o=Be(s.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...s,count:a,children:o})}}}),r}var st=Object.getOwnPropertyDescriptor,be=(t,e,r,s)=>{for(var n=s>1?void 0:s?st(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},pe=(t,e)=>(r,s)=>e(r,s,t),de=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(de||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Q=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new S.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new S.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new S.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new S.BehaviorSubject(-1));v(this,"col$",this._col$.asObservable());v(this,"_filterHeaderListener",null);this._injector=e,this._refRangeService=r}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()}dispose(){this._filterBy$.complete(),this._filterByModel$.complete(),this._hasCriteria$.complete()}setupCol(e,r){this.terminate(),this._filterModel=e,this._col$.next(r);const s=e.getFilterColumn(r);if(s){const n=s.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await _e.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=fe.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Q=be([pe(0,u.Inject(u.Injector)),pe(1,u.Inject(O.RefRangeService))],Q);let fe=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"canApply$",S.of(!0));v(this,"_conditionItem$");v(this,"conditionItem$");v(this,"_filterConditionFormParams$");v(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new S.BehaviorSubject(s),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new S.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,s,n){const[l,i]=p.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(fe,r,s,l,i)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(s=>s.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const s=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(r)}};fe=be([pe(4,u.ICommandService)],fe);let _e=class extends u.Disposable{constructor(e,r,s,n,l){super();v(this,"_rawFilterItems$");v(this,"rawFilterItems$");v(this,"filterItems$");v(this,"_filterItems",[]);v(this,"_treeMapCache");v(this,"canApply$");v(this,"_manuallyUpdateFilterItems$");v(this,"_searchString$");v(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=n,this._searchString$=new S.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new S.BehaviorSubject(s),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new S.Subject,this.filterItems$=S.merge(S.combineLatest([this._searchString$.pipe(S.throttleTime(500,void 0,{leading:!0,trailing:!0}),S.startWith(void 0)),this._rawFilterItems$]).pipe(S.map(([i,o])=>{if(!i)return o;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return Be(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>Oe(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,s){var k;const n=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(me,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),T=s,_=(k=r.getFilterColumn(s))==null?void 0:k.getColumnData().filters,E=new Set(_==null?void 0:_.filters),F=!!(_&&_.blank),R=r.getFilteredOutRowsExceptCol(s),N={...f,startRow:f.startRow+1,startColumn:T,endColumn:T};let M,A;if(i){const D=await i.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(R),filters:!!_,blankChecked:F,iterateRange:N,alreadyChecked:Array.from(E)});M=D.filterTreeItems,A=D.filterTreeMapCache}else{const D=He(!!_,l,N,m,R,E,F,h.getStyles());M=D.filterTreeItems,A=D.filterTreeMapCache}return e.createInstance(_e,r,s,M,A)}get rawFilterItems(){return this._rawFilterItems$.getValue()}get filterItems(){return this._filterItems}get treeMapCache(){return this._treeMapCache}dispose(){this._rawFilterItems$.complete(),this._searchString$.complete()}deltaCol(e){this.col+=e}setSearchString(e){this._searchString$.next(e)}onCheckAllToggled(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),s=Ie(r,e.key);if(!s)return;const n=je(s);re(s,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>re(s,!1)),e.forEach(s=>{const n=Ie(r,s);n&&re(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Oe(this._filterItems),{checked:r,checkedItems:s}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const i=r===0,o=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=s.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==s.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};_e=be([pe(4,u.ICommandService)],_e);const J="FILTER_PANEL_OPENED",se={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),s=t.get(c.SheetsFilterService),n=t.get(Q);t.get(u.ICommandService).syncExecuteCommand(U.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:o,col:a}=e,h=s.getFilterModel(i,o);return h?(n.setupCol(h,a),r.getContextValue(J)||r.setContextValue(J,!0),!0):!1}},z={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(Q),s=t.get(C.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(J)?(e.setContextValue(J,!1),s==null||s.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Q).changeFilterBy(r)}};var nt=Object.getOwnPropertyDescriptor,ot=(t,e,r,s)=>{for(var n=s>1?void 0:s?nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Z=(t,e)=>(r,s)=>e(r,s,t);let ee=class extends u.Disposable{constructor(t,e,r,s,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,s;if(t.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:i,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let T={...f};T=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[T],i,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===se.id){const n=t.params,{unitId:l,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:s.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ee=ot([Z(0,u.Inject(c.SheetsFilterService)),Z(1,u.Inject(u.LocaleService)),Z(2,u.ICommandService),Z(3,u.Inject(O.SheetPermissionCheckController)),Z(4,u.Inject(u.Injector)),Z(5,u.Inject(O.SheetsSelectionsService))],ee);var $=function(){return $=Object.assign||function(t){for(var e,r=1,s=arguments.length;r<s;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},$.apply(this,arguments)},at=function(t,e){var r={};for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.indexOf(s)<0&&(r[s]=t[s]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,s=Object.getOwnPropertySymbols(t);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(t,s[n])&&(r[s[n]]=t[s[n]]);return r},We=b.forwardRef(function(t,e){var r=t.icon,s=t.id,n=t.className,l=t.extend,i=at(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(s," ").concat(n||"").trim(),a=b.useRef("_".concat(ut()));return Ve(r,"".concat(s),{defIds:r.defIds,idSuffix:a.current},$({ref:e,className:o},i),l)});function Ve(t,e,r,s,n){return b.createElement(t.tag,$($({key:e},lt(t,r,n)),s),(ct(t,r).children||[]).map(function(l,i){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,n)}))}function lt(t,e,r){var s=$({},t.attrs);r!=null&&r.colorChannel1&&s.fill==="colorChannel1"&&(s.fill=r.colorChannel1),t.tag==="mask"&&s.id&&(s.id=s.id+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];i==="mask"&&typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&s["xlink:href"]&&(s["xlink:href"]=s["xlink:href"]+e.idSuffix),Object.entries(s).forEach(function(l){var i=l[0],o=l[1];typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),s}function ct(t,e){var r,s=e.defIds;return!s||s.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?$($({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&s&&s.indexOf(n.attrs.id)>-1?$($({},n),{attrs:$($({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function ut(){return Math.random().toString(36).substring(2,8)}We.displayName="UniverIcon";var ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=b.forwardRef(function(t,e){return b.createElement(We,Object.assign({},t,{id:"filter-icon",ref:e,icon:ht}))});Qe.displayName="FilterIcon";function mt(t){var _,E;const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.conditionItem$,void 0),n=C.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",i=b.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=pt(r),a=b.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=dt(r),m=b.useCallback(F=>{e.onConditionFormChange(F)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function T(F,R,N){const M=p.getItemByOperator(F).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(y.RadioGroup,{value:l,onChange:i,children:[d.jsx(y.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(y.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(y.Select,{value:F,options:h,onChange:A=>m({[N]:A})}),M&&d.jsx("div",{children:d.jsx(y.Input,{className:"univer-mt-2",value:R,placeholder:f,onChange:A=>m({[N==="operator1"?"val1":"val2"]:A})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-flex-col",children:s&&n&&d.jsxs(d.Fragment,{children:[d.jsx(y.Select,{value:s.operator,options:o,onChange:a}),p.getItemByOperator(s.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:y.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",y.borderClassName),children:[s.numOfParameters>=1&&T(n.operator1,(_=n.val1)!=null?_:"","operator1"),s.numOfParameters>=2&&T(n.operator2,(E=n.val2)!=null?E:"","operator2"),d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-desc",className:"univer-mt-2 univer-text-xs univer-text-gray-500",children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function pt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function dt(t){const e=t.getCurrentLocale();return b.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function ft(t){const{model:e}=t,r=C.useDependency(u.LocaleService),s=C.useObservable(e.searchString$,"",!0),n=C.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Oe(n),o=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=b.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=b.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let E=[];return _.forEach(F=>{F.checked&&E.push(F.key),F.children&&(E=E.concat(T(F.children)))}),E}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-flex-col",children:[d.jsx(y.Input,{autoFocus:!0,value:s,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:y.clsx("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",y.borderClassName),children:[d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-item",className:"univer-box-border univer-h-8 univer-w-full univer-py-0.5",children:d.jsxs("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-pb-0 univer-pl-5 univer-pr-0.5 univer-pt-0 univer-text-sm",children:[d.jsx(y.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-text",className:"univer-mx-1 univer-inline-block univer-flex-shrink univer-overflow-hidden univer-text-ellipsis univer-whitespace-nowrap univer-text-gray-900 dark:!univer-text-white",children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${i.checked}/${i.checked+i.unchecked})`})]})}),d.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:d.jsx(y.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
2
  univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
3
3
  [&:hover_a]:univer-inline-block
4
4
  hover:univer-bg-gray-50 univer-h-full
5
5
  univer-text-gray-900 dark:hover:!univer-bg-gray-900
6
6
  dark:!univer-text-white
7
- `,attachRender:_=>d.jsxs("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:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${_.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const E=[];_.children?_.children.forEach(F=>{F.children?F.children.forEach(R=>{E.push(R.key)}):E.push(F.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function _t(){var R;const t=C.useDependency(Q),e=C.useDependency(u.LocaleService),r=C.useDependency(u.ICommandService),s=C.useObservable(t.filterBy$,void 0,!0),n=C.useObservable(t.filterByModel$,void 0,!1),l=C.useObservable(()=>(n==null?void 0:n.canApply$)||S.of(!1),void 0,!1,[n]),i=vt(e),o=!C.useObservable(t.hasCriteria$),a=b.useCallback(N=>{r.executeCommand(Ae.id,{filterBy:N})},[r]),h=b.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(z.id)},[n,r]),m=b.useCallback(()=>{r.executeCommand(z.id)},[r]),f=b.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(z.id)},[n,r]),_=(R=C.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:R.getRange(),E=t.col,F=C.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-h-[442px] univer-w-[312px] 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:[d.jsx(C.ComponentContainer,{components:F,sharedProps:{range:_,colIndex:E,onClose:m}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(y.Segmented,{value:s,items:i,onChange:N=>a(N)})}),n?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:s===de.VALUES?d.jsx(ft,{model:n}):d.jsx(mt,{model:n})}):d.jsx("div",{className:"univer-flex-1"}),d.jsxs("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:[d.jsx(y.Button,{variant:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(y.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(y.Button,{disabled:!l,variant:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function vt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:de.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:de.CONDITIONS}],[e,t])}function gt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:C.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(r=>!!r)),disabled$:U.getObservableWithExclusiveRange$(t,U.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function St(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(r=>{var s;return(s=r==null?void 0:r.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}function Ct(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(r=>{var s;return(s=r==null?void 0:r.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}const Ft={[C.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:gt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:St},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ct}}}},V=16,Tt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class we{static drawNoCriteria(e,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(r/V,r/V),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,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.scale(r/V,r/V),e.fillStyle=s,e.fill(Tt),e.restore()}}var Et=Object.getOwnPropertyDescriptor,Ot=(t,e,r,s)=>{for(var n=s>1?void 0:s?Et(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Te=(t,e)=>(r,s)=>e(r,s,t);const B=16,ce=1;let ye=class extends ie.Shape{constructor(e,r,s,n,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=s,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,s=this._cellWidth,n=B-s,l=B-r;e.save();const i=new Path2D;i.rect(n,l,s,r),e.clip(i);const{hasCriteria:o}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?we.drawHasCriteria(e,B,a,h):we.drawNoCriteria(e,B,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(J)||!this._commandService.hasCommand(se.id)||setTimeout(()=>{this._commandService.executeCommand(se.id,{unitId:s,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ye=Ot([Te(2,u.IContextService),Te(3,u.ICommandService),Te(4,u.Inject(u.ThemeService))],ye);var Nt=Object.getOwnPropertyDescriptor,It=(t,e,r,s)=>{for(var n=s>1?void 0:s?Nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},q=(t,e)=>(r,s)=>e(r,s,t);const yt=1e3,Rt=5e3;let Re=class extends u.RxDisposable{constructor(e,r,s,n,l,i,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=s,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,a;if(!e)return S.of(null);const{unit:r,unitId:s}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(s,n))!=null?a:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var m;return h.type===u.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===O.SetRangeValuesMutation.id)}),S.throttleTime(20,void 0,{leading:!1,trailing:!0}),S.map(i),S.startWith(i()))}),S.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:s}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(s,yt,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(o,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:s,unitId:n,skeleton:l,worksheetId:i}=e,{scene:o}=this._context;this._interceptCellContent(n,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const T=`sheets-filter-button-${f}`,_=U.getCoordByCell(m,f,o,l),{startX:E,startY:F,endX:R,endY:N}=_,M=R-E,A=N-F;if(A<=ce||M<=ce)continue;const k=!!s.getFilterColumn(f),D=R-B-ce,oe=N-B-ce,ae={left:D,top:oe,height:B,width:B,zIndex:Rt,cellHeight:A,cellWidth:M,filterParams:{unitId:n,subUnitId:i,col:f,hasCriteria:k}},L=this._injector.createInstance(ye,T,ae);this._filterButtonShapes.push(L)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,s){const{startRow:n,startColumn:l,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==n||f<l||f>i?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:B}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(s=>s.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Re=It([q(1,u.Inject(u.Injector)),q(2,u.Inject(U.SheetSkeletonManagerService)),q(3,u.Inject(c.SheetsFilterService)),q(4,u.Inject(u.ThemeService)),q(5,u.Inject(O.SheetInterceptorService)),q(6,u.ICommandService),q(7,U.ISheetSelectionRenderService)],Re);var Pt=Object.getOwnPropertyDescriptor,bt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Pt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ue=(t,e)=>(r,s)=>e(r,s,t);let ne=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Re]))}};ne=bt([Ue(0,ie.IRenderManagerService),Ue(1,u.Inject(U.SheetsRenderService))],ne);const At={id:c.SmartToggleSheetsFilterCommand.id,binding:C.KeyCode.L|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:U.whenSheetEditorFocused,group:"4_sheet-edit"};var Mt=Object.getOwnPropertyDescriptor,Lt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Mt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},w=(t,e)=>(r,s)=>e(r,s,t);const $e="FILTER_PANEL_POPUP";let ve=class extends ne{constructor(e,r,s,n,l,i,o,a,h,m,f,T,_){super(_,T);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=s,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[At].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Ae,se,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Ft)}_initUI(){[[$e,_t],["FilterSingle",Qe]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(J).pipe(S.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:y.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),s=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,s,{componentKey:$e,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=Lt([w(0,u.Inject(u.Injector)),w(1,u.Inject(C.ComponentManager)),w(2,u.Inject(Q)),w(3,u.Inject(U.SheetCanvasPopManagerService)),w(4,u.Inject(c.SheetsFilterService)),w(5,u.Inject(u.LocaleService)),w(6,C.IShortcutService),w(7,u.ICommandService),w(8,C.IMenuManagerService),w(9,u.IContextService),w(10,C.IMessageService),w(11,u.Inject(U.SheetsRenderService)),w(12,ie.IRenderManagerService)],ve);var wt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,$t=(t,e,r)=>e in t?wt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ee=(t,e)=>(r,s)=>e(r,s,t),Ge=(t,e,r)=>$t(t,typeof e!="symbol"?e+"":e,r);const kt="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=he,r,s,n){super(),this._config=e,this._injector=r,this._configService=s,this._rpcChannelService=n;const{menu:l,...i}=u.merge({},he,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(De,i)}onStarting(){[[Q],[ee],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([me,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(Pe))}])}onReady(){this._injector.get(ee)}onRendered(){this._injector.get(ve)}};Ge(exports.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ge(exports.UniverSheetsFilterUIPlugin,"pluginName",kt);exports.UniverSheetsFilterUIPlugin=xt([u.DependentOn(c.UniverSheetsFilterPlugin),Ee(1,u.Inject(u.Injector)),Ee(2,u.IConfigService),Ee(3,u.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var Dt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,jt=(t,e,r)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ht(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},xe=(t,e)=>(r,s)=>e(r,s,t),Ye=(t,e,r)=>jt(t,typeof e!="symbol"?e+"":e,r);const Wt="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=he,r,s){super(),this._config=e,this._injector=r,this._configService=s;const{menu:n,...l}=u.merge({},he,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(De,l)}onStarting(){[[ee],[ne]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ee)}onRendered(){this._injector.get(ne)}};Ye(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ye(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Wt);exports.UniverSheetsFilterMobileUIPlugin=Bt([u.DependentOn(c.UniverSheetsFilterPlugin),xe(1,u.Inject(u.Injector)),xe(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var Vt=Object.getOwnPropertyDescriptor,Qt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},ke=(t,e)=>(r,s)=>e(r,s,t),ue;exports.UniverSheetsFilterUIWorkerPlugin=(ue=class extends u.Plugin{constructor(e,r,s){super(),this._config=e,this._injector=r,this._rpcChannelService=s}onStarting(){[[me,{useClass:Ne}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Pe,ge.fromModule(this._injector.get(me)))}},v(ue,"type",u.UniverInstanceType.UNIVER_SHEET),v(ue,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ue);exports.UniverSheetsFilterUIWorkerPlugin=Qt([ke(1,u.Inject(u.Injector)),ke(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Ae;exports.CloseFilterPanelOperation=z;exports.OpenFilterPanelOperation=se;
7
+ `,attachRender:_=>d.jsxs("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:[d.jsx("span",{"data-u-comp":"sheets-filter-panel-values-item-count",className:"univer-text-gray-400 dark:!univer-text-gray-500",children:`(${_.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const E=[];_.children?_.children.forEach(F=>{F.children?F.children.forEach(R=>{E.push(R.key)}):E.push(F.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function _t(){var R;const t=C.useDependency(Q),e=C.useDependency(u.LocaleService),r=C.useDependency(u.ICommandService),s=C.useObservable(t.filterBy$,void 0,!0),n=C.useObservable(t.filterByModel$,void 0,!1),l=C.useObservable(()=>(n==null?void 0:n.canApply$)||S.of(!1),void 0,!1,[n]),i=vt(e),o=!C.useObservable(t.hasCriteria$),a=b.useCallback(N=>{r.executeCommand(Ae.id,{filterBy:N})},[r]),h=b.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(z.id)},[n,r]),m=b.useCallback(()=>{r.executeCommand(z.id)},[r]),f=b.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(z.id)},[n,r]),_=(R=C.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:R.getRange(),E=t.col,F=C.useComponentsOfPart(U.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-h-[442px] univer-w-[312px] 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:[d.jsx(C.ComponentContainer,{components:F,sharedProps:{range:_,colIndex:E,onClose:m}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(y.Segmented,{value:s,items:i,onChange:N=>a(N)})}),n?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:s===de.VALUES?d.jsx(ft,{model:n}):d.jsx(mt,{model:n})}):d.jsx("div",{className:"univer-flex-1"}),d.jsxs("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:[d.jsx(y.Button,{variant:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(y.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(y.Button,{disabled:!l,variant:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function vt(t){const e=t.getCurrentLocale();return b.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:de.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:de.CONDITIONS}],[e,t])}function gt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:C.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(S.map(r=>!!r)),disabled$:U.getObservableWithExclusiveRange$(t,U.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function St(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(r=>{var s;return(s=r==null?void 0:r.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}function Ct(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:C.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:C.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(S.switchMap(r=>{var s;return(s=r==null?void 0:r.hasCriteria$.pipe(S.map(n=>!n)))!=null?s:S.of(!0)}))}}const Ft={[C.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:gt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:St},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ct}}}},V=16,Tt=new Path2D("M3.30363 3C2.79117 3 2.51457 3.60097 2.84788 3.99024L6.8 8.60593V12.5662C6.8 12.7184 6.8864 12.8575 7.02289 12.9249L8.76717 13.7863C8.96655 13.8847 9.2 13.7396 9.2 13.5173V8.60593L13.1521 3.99024C13.4854 3.60097 13.2088 3 12.6964 3H3.30363Z");class Le{static drawNoCriteria(e,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(r/V,r/V),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,r,s,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:V,height:V,fill:n}),e.scale(r/V,r/V),e.fillStyle=s,e.fill(Tt),e.restore()}}var Et=Object.getOwnPropertyDescriptor,Ot=(t,e,r,s)=>{for(var n=s>1?void 0:s?Et(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Te=(t,e)=>(r,s)=>e(r,s,t);const B=16,ce=1;let ye=class extends ie.Shape{constructor(e,r,s,n,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=s,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(i=>this.onPointerDown(i)),this.onPointerEnter$.subscribeEvent(()=>this.onPointerEnter()),this.onPointerLeave$.subscribeEvent(()=>this.onPointerLeave())}setShapeProps(e){typeof e.cellHeight<"u"&&(this._cellHeight=e.cellHeight),typeof e.cellWidth<"u"&&(this._cellWidth=e.cellWidth),typeof e.filterParams<"u"&&(this._filterParams=e.filterParams),this.transformByState({width:e.width,height:e.height})}_draw(e){const r=this._cellHeight,s=this._cellWidth,n=B-s,l=B-r;e.save();const i=new Path2D;i.rect(n,l,s,r),e.clip(i);const{hasCriteria:o}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?Le.drawHasCriteria(e,B,a,h):Le.drawNoCriteria(e,B,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(J)||!this._commandService.hasCommand(se.id)||setTimeout(()=>{this._commandService.executeCommand(se.id,{unitId:s,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ye=Ot([Te(2,u.IContextService),Te(3,u.ICommandService),Te(4,u.Inject(u.ThemeService))],ye);var Nt=Object.getOwnPropertyDescriptor,It=(t,e,r,s)=>{for(var n=s>1?void 0:s?Nt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},q=(t,e)=>(r,s)=>e(r,s,t);const yt=1e3,Rt=5e3;let Re=class extends u.RxDisposable{constructor(e,r,s,n,l,i,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=s,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,a;if(!e)return S.of(null);const{unit:r,unitId:s}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(s,n))!=null?a:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var m;return h.type===u.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===O.SetRangeValuesMutation.id)}),S.throttleTime(20,void 0,{leading:!1,trailing:!0}),S.map(i),S.startWith(i()))}),S.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:s}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,i=this._filterRangeShape=new U.SelectionControl(s,yt,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=U.attachSelectionWithCoord(o,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:s,unitId:n,skeleton:l,worksheetId:i}=e,{scene:o}=this._context;this._interceptCellContent(n,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const T=`sheets-filter-button-${f}`,_=U.getCoordByCell(m,f,o,l),{startX:E,startY:F,endX:R,endY:N}=_,M=R-E,A=N-F;if(A<=ce||M<=ce)continue;const k=!!s.getFilterColumn(f),D=R-B-ce,oe=N-B-ce,ae={left:D,top:oe,height:B,width:B,zIndex:Rt,cellHeight:A,cellWidth:M,filterParams:{unitId:n,subUnitId:i,col:f,hasCriteria:k}},w=this._injector.createInstance(ye,T,ae);this._filterButtonShapes.push(w)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,s){const{startRow:n,startColumn:l,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==n||f<l||f>i||((!o||o===a.rawData)&&(o={...a.rawData}),o.fontRenderExtension={...o==null?void 0:o.fontRenderExtension,rightOffset:B}),h(o)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(s=>s.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Re=It([q(1,u.Inject(u.Injector)),q(2,u.Inject(U.SheetSkeletonManagerService)),q(3,u.Inject(c.SheetsFilterService)),q(4,u.Inject(u.ThemeService)),q(5,u.Inject(O.SheetInterceptorService)),q(6,u.ICommandService),q(7,U.ISheetSelectionRenderService)],Re);var Pt=Object.getOwnPropertyDescriptor,bt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Pt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ue=(t,e)=>(r,s)=>e(r,s,t);let ne=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Re]))}};ne=bt([Ue(0,ie.IRenderManagerService),Ue(1,u.Inject(U.SheetsRenderService))],ne);const At={id:c.SmartToggleSheetsFilterCommand.id,binding:C.KeyCode.L|C.MetaKeys.CTRL_COMMAND|C.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:U.whenSheetEditorFocused,group:"4_sheet-edit"};var Mt=Object.getOwnPropertyDescriptor,wt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Mt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},L=(t,e)=>(r,s)=>e(r,s,t);const $e="FILTER_PANEL_POPUP";let ve=class extends ne{constructor(e,r,s,n,l,i,o,a,h,m,f,T,_){super(_,T);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=s,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[At].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Ae,se,z].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Ft)}_initUI(){[[$e,_t],["FilterIcon",Qe]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(J).pipe(S.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:y.MessageType.Error,content:this._localeService.t(e)})}))}_openFilterPopup(){const e=this._sheetsFilterPanelService.filterModel;if(!e)throw new Error("[SheetsFilterUIController]: no filter model when opening filter popup!");const r=e.getRange(),s=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,s,{componentKey:$e,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(z.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=wt([L(0,u.Inject(u.Injector)),L(1,u.Inject(C.ComponentManager)),L(2,u.Inject(Q)),L(3,u.Inject(U.SheetCanvasPopManagerService)),L(4,u.Inject(c.SheetsFilterService)),L(5,u.Inject(u.LocaleService)),L(6,C.IShortcutService),L(7,u.ICommandService),L(8,C.IMenuManagerService),L(9,u.IContextService),L(10,C.IMessageService),L(11,u.Inject(U.SheetsRenderService)),L(12,ie.IRenderManagerService)],ve);var Lt=Object.defineProperty,Ut=Object.getOwnPropertyDescriptor,$t=(t,e,r)=>e in t?Lt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,xt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ut(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},Ee=(t,e)=>(r,s)=>e(r,s,t),Ge=(t,e,r)=>$t(t,typeof e!="symbol"?e+"":e,r);const kt="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=he,r,s,n){super(),this._config=e,this._injector=r,this._configService=s,this._rpcChannelService=n;const{menu:l,...i}=u.merge({},he,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(De,i)}onStarting(){[[Q],[ee],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([me,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(Pe))}])}onReady(){this._injector.get(ee)}onRendered(){this._injector.get(ve)}};Ge(exports.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ge(exports.UniverSheetsFilterUIPlugin,"pluginName",kt);exports.UniverSheetsFilterUIPlugin=xt([u.DependentOn(c.UniverSheetsFilterPlugin),Ee(1,u.Inject(u.Injector)),Ee(2,u.IConfigService),Ee(3,u.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var Dt=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,jt=(t,e,r)=>e in t?Dt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ht(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},xe=(t,e)=>(r,s)=>e(r,s,t),Ye=(t,e,r)=>jt(t,typeof e!="symbol"?e+"":e,r);const Wt="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=he,r,s){super(),this._config=e,this._injector=r,this._configService=s;const{menu:n,...l}=u.merge({},he,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(De,l)}onStarting(){[[ee],[ne]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ee)}onRendered(){this._injector.get(ne)}};Ye(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ye(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Wt);exports.UniverSheetsFilterMobileUIPlugin=Bt([u.DependentOn(c.UniverSheetsFilterPlugin),xe(1,u.Inject(u.Injector)),xe(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var Vt=Object.getOwnPropertyDescriptor,Qt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(n=i(n)||n);return n},ke=(t,e)=>(r,s)=>e(r,s,t),ue;exports.UniverSheetsFilterUIWorkerPlugin=(ue=class extends u.Plugin{constructor(e,r,s){super(),this._config=e,this._injector=r,this._rpcChannelService=s}onStarting(){[[me,{useClass:Ne}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Pe,ge.fromModule(this._injector.get(me)))}},v(ue,"type",u.UniverInstanceType.UNIVER_SHEET),v(ue,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),ue);exports.UniverSheetsFilterUIWorkerPlugin=Qt([ke(1,u.Inject(u.Injector)),ke(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Ae;exports.CloseFilterPanelOperation=z;exports.OpenFilterPanelOperation=se;
package/lib/es/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  var Yt = Object.defineProperty;
2
2
  var qt = (t, e, r) => e in t ? Yt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var f = (t, e, r) => qt(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { BooleanNumber as rt, createIdentifier as _t, Inject as E, LocaleService as K, IUniverInstanceService as Ge, ILogService as Kt, extractPureTextFromCell as Xt, numfmt as it, Disposable as me, Injector as X, Quantity as vt, Tools as Te, ICommandService as Q, CommandType as Le, IContextService as Me, UniverInstanceType as Z, ThemeService as gt, RxDisposable as St, fromCallback as Zt, InterceptorEffectEnum as zt, DependentOn as Et, IConfigService as Tt, Optional as Jt, Plugin as je, merge as Nt } from "@univerjs/core";
4
+ import { BooleanNumber as rt, createIdentifier as _t, Inject as E, LocaleService as K, IUniverInstanceService as Ge, ILogService as Kt, extractPureTextFromCell as Xt, numfmt as it, Disposable as me, Injector as X, Quantity as vt, Tools as Te, ICommandService as Q, CommandType as Le, IContextService as we, UniverInstanceType as Z, ThemeService as gt, RxDisposable as St, fromCallback as Zt, InterceptorEffectEnum as zt, DependentOn as Et, IConfigService as Tt, Optional as Jt, Plugin as je, merge as Nt } from "@univerjs/core";
5
5
  import { IRPCChannelService as Ct, toModule as er, fromModule as tr } from "@univerjs/rpc";
6
6
  import { CustomFilterOperator as u, SetSheetsFilterCriteriaCommand as re, SheetsFilterService as V, SmartToggleSheetsFilterCommand as pe, ReCalcSheetsFilterCommand as Ye, ClearSheetsFilterCriteriaCommand as qe, FILTER_MUTATIONS as rr, SetSheetsFilterRangeMutation as ir, SetSheetsFilterCriteriaMutation as sr, RemoveSheetsFilterMutation as nr, ReCalcSheetsFilterMutation as or, RemoveSheetFilterCommand as ar, SetSheetFilterRangeCommand as lr, UniverSheetsFilterPlugin as Ft } from "@univerjs/sheets-filter";
7
7
  import { RefRangeService as cr, SheetPermissionCheckController as ur, SheetsSelectionsService as hr, getSheetCommandTarget as dr, WorksheetFilterPermission as ae, WorksheetViewPermission as le, RangeProtectionPermissionViewPoint as ce, expandToContinuousRange as mr, SheetInterceptorService as pr, SetRangeValuesMutation as fr, INTERCEPTOR_POINT as _r } from "@univerjs/sheets";
8
8
  import { ILayoutService as vr, useDependency as te, useObservable as B, useComponentsOfPart as gr, ComponentContainer as Sr, getMenuHiddenObservable as Ke, MenuItemType as Xe, RibbonDataGroup as Er, KeyCode as Tr, MetaKeys as st, ComponentManager as Nr, IShortcutService as Cr, IMenuManagerService as Fr, IMessageService as yr } from "@univerjs/ui";
9
- import { SetCellEditVisibleOperation as Or, SheetsUIPart as Rr, getObservableWithExclusiveRange$ as Ir, getCurrentRangeDisable$ as Ar, SheetSkeletonManagerService as Pr, ISheetSelectionRenderService as br, SelectionControl as Lr, attachSelectionWithCoord as Mr, getCoordByCell as wr, SheetsRenderService as yt, whenSheetEditorFocused as $r, SheetCanvasPopManagerService as Ur } from "@univerjs/sheets-ui";
9
+ import { SetCellEditVisibleOperation as Or, SheetsUIPart as Rr, getObservableWithExclusiveRange$ as Ir, getCurrentRangeDisable$ as Ar, SheetSkeletonManagerService as Pr, ISheetSelectionRenderService as br, SelectionControl as Lr, attachSelectionWithCoord as wr, getCoordByCell as Mr, SheetsRenderService as yt, whenSheetEditorFocused as $r, SheetCanvasPopManagerService as Ur } from "@univerjs/sheets-ui";
10
10
  import { BehaviorSubject as q, ReplaySubject as Hr, Subject as Dr, merge as kr, combineLatest as xr, throttleTime as Ot, startWith as Rt, map as ie, shareReplay as Br, of as fe, switchMap as Ze, filter as Wr, takeUntil as Qr, distinctUntilChanged as Vr } from "rxjs";
11
11
  import { Select as nt, clsx as It, borderClassName as At, RadioGroup as Gr, Radio as ot, Input as Pt, Checkbox as jr, Tree as Yr, Segmented as qr, Button as Ue, MessageType as Kr } from "@univerjs/design";
12
12
  import { Rect as at, Shape as Xr, IRenderManagerService as bt } from "@univerjs/engine-render";
13
13
  import { jsx as S, jsxs as b, Fragment as lt } from "react/jsx-runtime";
14
- import { forwardRef as Lt, useRef as Zr, createElement as Mt, useCallback as D, useMemo as ze } from "react";
15
- const wt = "sheets-filter-ui.config", Ne = {};
14
+ import { forwardRef as Lt, useRef as Zr, createElement as wt, useCallback as D, useMemo as ze } from "react";
15
+ const Mt = "sheets-filter-ui.config", Ne = {};
16
16
  var C = /* @__PURE__ */ ((t) => (t[t.FIRST = 0] = "FIRST", t[t.SECOND = 1] = "SECOND", t))(C || {}), _ = /* @__PURE__ */ ((t) => (t.NONE = "none", t.STARTS_WITH = "startsWith", t.DOES_NOT_START_WITH = "doesNotStartWith", t.ENDS_WITH = "endsWith", t.DOES_NOT_END_WITH = "doesNotEndWith", t.CONTAINS = "contains", t.DOES_NOT_CONTAIN = "doesNotContain", t.EQUALS = "equals", t.NOT_EQUALS = "notEquals", t.EMPTY = "empty", t.NOT_EMPTY = "notEmpty", t.BETWEEN = "between", t.NOT_BETWEEN = "notBetween", t.CUSTOM = "custom", t))(_ || {}), d;
17
17
  ((t) => {
18
18
  t.NONE = {
@@ -392,9 +392,9 @@ var C = /* @__PURE__ */ ((t) => (t[t.FIRST = 0] = "FIRST", t[t.SECOND = 1] = "SE
392
392
  mapToFilterColumn: (i) => {
393
393
  const { and: o, val1: a, val2: c, operator1: h, operator2: m } = i;
394
394
  function g(R, O) {
395
- for (const M of t.ALL_CONDITIONS)
396
- if (M.operator === R)
397
- return M.mapToFilterColumn({ val1: O, operator1: R });
395
+ for (const w of t.ALL_CONDITIONS)
396
+ if (w.operator === R)
397
+ return w.mapToFilterColumn({ val1: O, operator1: R });
398
398
  }
399
399
  const p = !h || h === t.NONE.operator, T = !m || m === t.NONE.operator;
400
400
  if (p && T)
@@ -528,7 +528,7 @@ Be = Jr([
528
528
  He(2, Kt)
529
529
  ], Be);
530
530
  function $t(t, e, r, s, n, l, i, o) {
531
- var v, F, N, R, O, M, w, _e, ve;
531
+ var v, F, N, R, O, w, M, _e, ve;
532
532
  const a = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), h = "yyyy-mm-dd", m = new Set(ei), g = "empty";
533
533
  let p = 0;
534
534
  for (const I of s.iterateByColumn(r, !1, !1)) {
@@ -562,7 +562,7 @@ function $t(t, e, r, s, n, l, i, o) {
562
562
  leaf: !1,
563
563
  checked: !1
564
564
  }, a.set(`${y}`, j), c.set(`${y}`, [`${y}`]));
565
- let U = (M = j.children) == null ? void 0 : M.find(($e) => $e.key === `${y}-${$}`);
565
+ let U = (w = j.children) == null ? void 0 : w.find(($e) => $e.key === `${y}-${$}`);
566
566
  U || (U = {
567
567
  title: e.t(`sheets-filter.date.${$}`),
568
568
  key: `${y}-${$}`,
@@ -570,9 +570,9 @@ function $t(t, e, r, s, n, l, i, o) {
570
570
  count: 0,
571
571
  leaf: !1,
572
572
  checked: !1
573
- }, (w = j.children) == null || w.push(U), c.set(`${y}-${$}`, [`${y}`, `${y}-${$}`]));
574
- const we = (_e = U == null ? void 0 : U.children) == null ? void 0 : _e.find(($e) => $e.key === `${y}-${$}-${oe}`);
575
- we ? (we.originValues.add(G), we.count++, U.count++, j.count++) : ((ve = U.children) == null || ve.push({
573
+ }, (M = j.children) == null || M.push(U), c.set(`${y}-${$}`, [`${y}`, `${y}-${$}`]));
574
+ const Me = (_e = U == null ? void 0 : U.children) == null ? void 0 : _e.find(($e) => $e.key === `${y}-${$}-${oe}`);
575
+ Me ? (Me.originValues.add(G), Me.count++, U.count++, j.count++) : ((ve = U.children) == null || ve.push({
576
576
  title: `${oe}`,
577
577
  key: `${y}-${$}-${oe}`,
578
578
  count: 1,
@@ -919,15 +919,15 @@ let Re = class extends me {
919
919
  * @returns the model to control the panel's state
920
920
  */
921
921
  static async fromFilterColumn(e, r, s) {
922
- var M;
922
+ var w;
923
923
  const n = e.get(Ge), l = e.get(K), i = e.get(Ce, vt.OPTIONAL), { unitId: o, subUnitId: a } = r, c = n.getUniverSheetInstance(o);
924
924
  if (!c) throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);
925
925
  const h = c == null ? void 0 : c.getSheetBySheetId(a);
926
926
  if (!h) throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);
927
- const m = r.getRange(), g = s, p = (M = r.getFilterColumn(s)) == null ? void 0 : M.getColumnData().filters, T = new Set(p == null ? void 0 : p.filters), v = !!(p && p.blank), F = r.getFilteredOutRowsExceptCol(s), N = { ...m, startRow: m.startRow + 1, startColumn: g, endColumn: g };
927
+ const m = r.getRange(), g = s, p = (w = r.getFilterColumn(s)) == null ? void 0 : w.getColumnData().filters, T = new Set(p == null ? void 0 : p.filters), v = !!(p && p.blank), F = r.getFilteredOutRowsExceptCol(s), N = { ...m, startRow: m.startRow + 1, startColumn: g, endColumn: g };
928
928
  let R, O;
929
929
  if (i) {
930
- const w = await i.getFilterValues({
930
+ const M = await i.getFilterValues({
931
931
  unitId: o,
932
932
  subUnitId: a,
933
933
  filteredOutRowsByOtherColumns: Array.from(F),
@@ -936,10 +936,10 @@ let Re = class extends me {
936
936
  iterateRange: N,
937
937
  alreadyChecked: Array.from(T)
938
938
  });
939
- R = w.filterTreeItems, O = w.filterTreeMapCache;
939
+ R = M.filterTreeItems, O = M.filterTreeMapCache;
940
940
  } else {
941
- const w = $t(!!p, l, N, h, F, T, v, c.getStyles());
942
- R = w.filterTreeItems, O = w.filterTreeMapCache;
941
+ const M = $t(!!p, l, N, h, F, T, v, c.getStyles());
942
+ R = M.filterTreeItems, O = M.filterTreeMapCache;
943
943
  }
944
944
  return e.createInstance(Re, r, s, R, O);
945
945
  }
@@ -1038,7 +1038,7 @@ const se = "FILTER_PANEL_OPENED", Ie = {
1038
1038
  id: "sheet.operation.open-filter-panel",
1039
1039
  type: Le.OPERATION,
1040
1040
  handler: (t, e) => {
1041
- const r = t.get(Me), s = t.get(V), n = t.get(W);
1041
+ const r = t.get(we), s = t.get(V), n = t.get(W);
1042
1042
  t.get(Q).syncExecuteCommand(Or.id, { visible: !1 });
1043
1043
  const { unitId: i, subUnitId: o, col: a } = e, c = s.getFilterModel(i, o);
1044
1044
  return c ? (n.setupCol(c, a), r.getContextValue(se) || r.setContextValue(se, !0), !0) : !1;
@@ -1047,7 +1047,7 @@ const se = "FILTER_PANEL_OPENED", Ie = {
1047
1047
  id: "sheet.operation.close-filter-panel",
1048
1048
  type: Le.OPERATION,
1049
1049
  handler: (t) => {
1050
- const e = t.get(Me), r = t.get(W), s = t.get(vr, vt.OPTIONAL);
1050
+ const e = t.get(we), r = t.get(W), s = t.get(vr, vt.OPTIONAL);
1051
1051
  return e.getContextValue(se) ? (e.setContextValue(se, !1), s == null || s.focus(), r.terminate()) : !1;
1052
1052
  }
1053
1053
  }, Dt = {
@@ -1136,7 +1136,7 @@ var P = function() {
1136
1136
  return xt(r, "".concat(s), { defIds: r.defIds, idSuffix: a.current }, P({ ref: e, className: o }, i), l);
1137
1137
  });
1138
1138
  function xt(t, e, r, s, n) {
1139
- return Mt(t.tag, P(P({ key: e }, ai(t, r, n)), s), (li(t, r).children || []).map(function(l, i) {
1139
+ return wt(t.tag, P(P({ key: e }, ai(t, r, n)), s), (li(t, r).children || []).map(function(l, i) {
1140
1140
  return xt(l, "".concat(e, "-").concat(t.tag, "-").concat(i), r, void 0, n);
1141
1141
  }));
1142
1142
  }
@@ -1162,14 +1162,14 @@ function ci() {
1162
1162
  return Math.random().toString(36).substring(2, 8);
1163
1163
  }
1164
1164
  kt.displayName = "UniverIcon";
1165
- var ui = { tag: "svg", attrs: { fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Bt = Lt(function(t, e) {
1166
- return Mt(kt, Object.assign({}, t, {
1167
- id: "filter-single",
1165
+ var ui = { tag: "svg", attrs: { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 17 16", width: "1em", height: "1em" }, children: [{ tag: "path", attrs: { fill: "currentColor", d: "M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z", fillRule: "evenodd", clipRule: "evenodd" } }] }, Bt = Lt(function(t, e) {
1166
+ return wt(kt, Object.assign({}, t, {
1167
+ id: "filter-icon",
1168
1168
  ref: e,
1169
1169
  icon: ui
1170
1170
  }));
1171
1171
  });
1172
- Bt.displayName = "FilterSingle";
1172
+ Bt.displayName = "FilterIcon";
1173
1173
  function hi(t) {
1174
1174
  var p, T;
1175
1175
  const { model: e } = t, r = te(K), s = B(e.conditionItem$, void 0), n = B(e.filterConditionFormParams$, void 0), l = n != null && n.and ? "AND" : "OR", i = D((v) => {
@@ -1488,7 +1488,7 @@ function vi(t) {
1488
1488
  return {
1489
1489
  id: pe.id,
1490
1490
  type: Xe.BUTTON_SELECTOR,
1491
- icon: "FilterSingle",
1491
+ icon: "FilterIcon",
1492
1492
  tooltip: "sheets-filter.toolbar.smart-toggle-filter-tooltip",
1493
1493
  hidden$: Ke(t, Z.UNIVER_SHEET),
1494
1494
  activated$: e.activeFilterModel$.pipe(ie((r) => !!r)),
@@ -1604,7 +1604,7 @@ let Qe = class extends Xr {
1604
1604
  }
1605
1605
  };
1606
1606
  Qe = Ci([
1607
- De(2, Me),
1607
+ De(2, we),
1608
1608
  De(3, Q),
1609
1609
  De(4, E(gt))
1610
1610
  ], Qe);
@@ -1666,7 +1666,7 @@ let Ve = class extends St {
1666
1666
  enableAutoFill: !1,
1667
1667
  highlightHeader: !1
1668
1668
  }
1669
- ), a = Mr({
1669
+ ), a = wr({
1670
1670
  range: e,
1671
1671
  primary: null,
1672
1672
  style: { fill: "rgba(0, 0, 0, 0.0)" }
@@ -1678,18 +1678,18 @@ let Ve = class extends St {
1678
1678
  this._interceptCellContent(n, i, e.range);
1679
1679
  const { startColumn: a, endColumn: c, startRow: h } = r;
1680
1680
  for (let m = a; m <= c; m++) {
1681
- const g = `sheets-filter-button-${m}`, p = wr(h, m, o, l), { startX: T, startY: v, endX: F, endY: N } = p, R = F - T, O = N - v;
1681
+ const g = `sheets-filter-button-${m}`, p = Mr(h, m, o, l), { startX: T, startY: v, endX: F, endY: N } = p, R = F - T, O = N - v;
1682
1682
  if (O <= Se || R <= Se)
1683
1683
  continue;
1684
- const M = !!s.getFilterColumn(m), w = F - H - Se, _e = N - H - Se, ve = {
1685
- left: w,
1684
+ const w = !!s.getFilterColumn(m), M = F - H - Se, _e = N - H - Se, ve = {
1685
+ left: M,
1686
1686
  top: _e,
1687
1687
  height: H,
1688
1688
  width: H,
1689
1689
  zIndex: Ri,
1690
1690
  cellHeight: O,
1691
1691
  cellWidth: R,
1692
- filterParams: { unitId: n, subUnitId: i, col: m, hasCriteria: M }
1692
+ filterParams: { unitId: n, subUnitId: i, col: m, hasCriteria: w }
1693
1693
  }, I = this._injector.createInstance(Qe, g, ve);
1694
1694
  this._filterButtonShapes.push(I);
1695
1695
  }
@@ -1701,13 +1701,10 @@ let Ve = class extends St {
1701
1701
  effect: zt.Style,
1702
1702
  handler: (o, a, c) => {
1703
1703
  const { row: h, col: m, unitId: g, subUnitId: p } = a;
1704
- return g !== e || p !== r || h !== n || m < l || m > i ? c(o) : c({
1705
- ...o,
1706
- fontRenderExtension: {
1707
- ...o == null ? void 0 : o.fontRenderExtension,
1708
- rightOffset: H
1709
- }
1710
- });
1704
+ return g !== e || p !== r || h !== n || m < l || m > i || ((!o || o === a.rawData) && (o = { ...a.rawData }), o.fontRenderExtension = {
1705
+ ...o == null ? void 0 : o.fontRenderExtension,
1706
+ rightOffset: H
1707
+ }), c(o);
1711
1708
  },
1712
1709
  priority: 10
1713
1710
  });
@@ -1798,7 +1795,7 @@ let Ae = class extends de {
1798
1795
  _initUI() {
1799
1796
  [
1800
1797
  [dt, fi],
1801
- ["FilterSingle", Bt]
1798
+ ["FilterIcon", Bt]
1802
1799
  ].forEach(([e, r]) => {
1803
1800
  this.disposeWithMe(
1804
1801
  this._componentManager.register(e, r)
@@ -1839,13 +1836,13 @@ Ae = Li([
1839
1836
  A(6, Cr),
1840
1837
  A(7, Q),
1841
1838
  A(8, Fr),
1842
- A(9, Me),
1839
+ A(9, we),
1843
1840
  A(10, yr),
1844
1841
  A(11, E(yt)),
1845
1842
  A(12, bt)
1846
1843
  ], Ae);
1847
- var Mi = Object.defineProperty, wi = Object.getOwnPropertyDescriptor, $i = (t, e, r) => e in t ? Mi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Ui = (t, e, r, s) => {
1848
- for (var n = s > 1 ? void 0 : s ? wi(e, r) : e, l = t.length - 1, i; l >= 0; l--)
1844
+ var wi = Object.defineProperty, Mi = Object.getOwnPropertyDescriptor, $i = (t, e, r) => e in t ? wi(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r, Ui = (t, e, r, s) => {
1845
+ for (var n = s > 1 ? void 0 : s ? Mi(e, r) : e, l = t.length - 1, i; l >= 0; l--)
1849
1846
  (i = t[l]) && (n = i(n) || n);
1850
1847
  return n;
1851
1848
  }, ke = (t, e) => (r, s) => e(r, s, t), Wt = (t, e, r) => $i(t, typeof e != "symbol" ? e + "" : e, r);
@@ -1858,7 +1855,7 @@ let Pe = class extends je {
1858
1855
  Ne,
1859
1856
  this._config
1860
1857
  );
1861
- n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(wt, l);
1858
+ n && this._configService.setConfig("menu", n, { merge: !0 }), this._configService.setConfig(Mt, l);
1862
1859
  }
1863
1860
  onStarting() {
1864
1861
  [
@@ -1900,7 +1897,7 @@ let be = class extends je {
1900
1897
  Ne,
1901
1898
  this._config
1902
1899
  );
1903
- s && this._configService.setConfig("menu", s, { merge: !0 }), this._configService.setConfig(wt, n);
1900
+ s && this._configService.setConfig("menu", s, { merge: !0 }), this._configService.setConfig(Mt, n);
1904
1901
  }
1905
1902
  onStarting() {
1906
1903
  [