@univerjs/sheets-filter-ui 0.10.0 → 0.10.1-nightly.202508020912

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,5 +1,5 @@
1
1
  "use strict";var st=Object.defineProperty;var nt=(t,e,r)=>e in t?st(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var v=(t,e,r)=>nt(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),c=require("@univerjs/sheets-filter"),M=require("@univerjs/sheets-ui"),F=require("@univerjs/ui"),z=require("@univerjs/engine-render"),I=require("@univerjs/sheets"),S=require("rxjs"),Te=require("@univerjs/rpc"),b=require("@univerjs/design"),m=require("react/jsx-runtime"),O=require("react");var P=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(P||{}),C=(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))(C||{}),f;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:C.NONE,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===C.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:C.EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===C.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:C.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:C.NOT_EMPTY,order:P.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===C.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:C.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:C.CONTAINS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:C.CONTAINS,val1:""}),testMappingParams:i=>{const[o]=B(i);return o===C.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],l=o.val.toString();return!o.operator&&l.startsWith("*")&&l.endsWith("*")?{operator1:C.CONTAINS,val1:l.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:C.DOES_NOT_CONTAIN,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:C.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[o]=B(i);return o===C.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],l=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&l.startsWith("*")&&l.endsWith("*")?{operator1:C.DOES_NOT_CONTAIN,val1:l.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:C.STARTS_WITH,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:C.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[o]=B(i);return o===C.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],l=o.val.toString();return!o.operator&&l.endsWith("*")&&!l.startsWith("*")?{operator1:C.STARTS_WITH,val1:l.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:C.ENDS_WITH,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:C.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[o]=B(i);return o===C.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],l=o.val.toString();return!o.operator&&l.startsWith("*")&&!l.endsWith("*")?{operator1:C.ENDS_WITH,val1:l.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:C.EQUALS,order:P.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:C.EQUALS,val1:""}),testMappingParams:i=>{const[o]=B(i);return o===C.EQUALS},mapToFilterColumn:i=>{const{val1:o}=i;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:i=>{var o,l,h;return((l=(o=i.filters)==null?void 0:o.filters)==null?void 0:l.length)===1?{operator1:C.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:C.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:P.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[o]=B(i);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.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:P.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=B(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 l;if(((l=i.customFilters)==null?void 0:l.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:P.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[o]=B(i);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const 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:P.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[o]=B(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 l;if(((l=i.customFilters)==null?void 0:l.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:P.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[o]=B(i);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const 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:P.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[o]=B(i);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:i=>{var l;if(((l=i.customFilters)==null?void 0:l.customFilters.length)!==1)return!1;const 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:C.BETWEEN,order:P.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:l,operator2:h}=i;if(!o)return!1;const d=[l,h];return d.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&d.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:i=>{const{val1:o,val2:l,operator1:h}=i,d=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:d?o:l,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:d?l: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,l]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&l.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&i.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:l.val.toString()}:l.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:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:C.NOT_BETWEEN,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:o,operator1:l,operator2:h}=i;if(o)return!1;const d=[l,h];return d.includes(c.CustomFilterOperator.GREATER_THAN)&&d.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:o,val2:l,operator1:h}=i,d=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:d?o:l,operator:c.CustomFilterOperator.GREATER_THAN},{val:d?l: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,l]=i.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&l.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:l.val.toString()}:l.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:l.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:C.CUSTOM,order:P.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:C.NONE,val1:"",operator2:C.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:o,val1:l,val2:h,operator1:d,operator2:p}=i;function E(w,R){for(const x of t.ALL_CONDITIONS)if(x.operator===w)return x.mapToFilterColumn({val1:R,operator1:w})}const _=!d||d===t.NONE.operator,g=!p||p===t.NONE.operator;if(_&&g)return t.NONE.mapToFilterColumn({});if(_)return E(p,h);if(g)return E(d,l);const T=E(d,l),N=E(p,h),y={customFilters:[T.customFilters.customFilters[0],N.customFilters.customFilters[0]]};return o&&(y.and=u.BooleanNumber.TRUE),{customFilters:y}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=i.customFilters.customFilters.map(d=>a({customFilters:{customFilters:[d]}})),l={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return i.customFilters.and&&(l.and=!0),l}},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(l=>l.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 l of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(l.numOfParameters!==0&&l.testMappingParams(i))return l;for(const l of t.ALL_CONDITIONS)if(l.testMappingParams(i))return l;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(l=>l.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 a(i){if(!i)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const l=o.testMappingFilterColumn(i);if(l)return[o,l]}return[t.NONE,{}]}t.testMappingFilterColumn=a})(f||(f={}));function B(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 Re(t){const e=[],r=[];let s=0,n=0;function a(i){i.leaf&&(i.checked?(e.push(i),s+=i.count):(r.push(i),n+=i.count)),i.children&&i.children.forEach(a)}return t.forEach(a),{checkedItems:e,uncheckedItems:r,checked:s,unchecked:n}}var ot=Object.getOwnPropertyDescriptor,lt=(t,e,r,s)=>{for(var n=s>1?void 0:s?ot(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},ye=(t,e)=>(r,s)=>e(r,s,t);const Le="sheets-filter.generate-filter-values.service",ve=u.createIdentifier(Le),at=["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 Pe=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var p;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:s,filterColumn:n,filters:a,blankChecked:i,iterateRange:o,alreadyChecked:l}=t,h=this._univerInstanceService.getUnit(e),d=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(r);return!h||!d?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),Ve(a,this._localeService,o,d,new Set(s),n,new Set(l.map(String)),i,h.getStyles()))}};Pe=lt([ye(0,u.Inject(u.LocaleService)),ye(1,u.IUniverInstanceService),ye(2,u.ILogService)],Pe);function Ve(t,e,r,s,n,a,i,o,l){var y,w,R,x,$,q,J,ee,H,U;const h=new Map,d=new Map,p="yyyy-mm-dd",E=new Set(at),_="empty",g=!t&&((a==null?void 0:a.filterBy)===c.FilterBy.COLORS||(a==null?void 0:a.filterBy)===c.FilterBy.CONDITIONS)&&((y=a.filteredOutRows)==null?void 0:y.size);let T=0;for(const k of s.iterateByColumn(r,!1,!1)){const{row:tt,rowSpan:$e=1}=k;let te=0;for(;te<$e;){const rt=tt+te;if(n.has(rt)){te++;continue}const K=k!=null&&k.value?u.extractPureTextFromCell(k.value):"";if(!K){T+=1,te+=$e;continue}const me=(w=k.value)!=null&&w.v&&!k.value.p?($=(x=l.get((R=k.value)==null?void 0:R.s))==null?void 0:x.n)==null?void 0:$.pattern:"",it=me&&u.numfmt.getFormatInfo(me).isDate;if(me&&it&&E.has(me)){const Q=(q=s.getCellRaw(k.row,k.col))==null?void 0:q.v;if(!Q){te++;continue}const re=u.numfmt.format(p,Q),[A,D,le]=re.split("-").map(Number);let Z=h.get(`${A}`);Z||(Z={title:`${A}`,key:`${A}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${A}`,Z),d.set(`${A}`,[`${A}`]));let W=(J=Z.children)==null?void 0:J.find(Ie=>Ie.key===`${A}-${D}`);W||(W={title:e.t(`sheets-filter.date.${D}`),key:`${A}-${D}`,children:[],count:0,leaf:!1,checked:!1},(ee=Z.children)==null||ee.push(W),d.set(`${A}-${D}`,[`${A}`,`${A}-${D}`]));const Oe=(H=W==null?void 0:W.children)==null?void 0:H.find(Ie=>Ie.key===`${A}-${D}-${le}`);Oe?(Oe.originValues.add(K),Oe.count++,W.count++,Z.count++):((U=W.children)==null||U.push({title:`${le}`,key:`${A}-${D}-${le}`,count:1,originValues:new Set([K]),leaf:!0,checked:g?!1:i.size?i.has(K):!o}),W.count++,Z.count++,d.set(`${A}-${D}-${le}`,[`${A}`,`${A}-${D}`,`${A}-${D}-${le}`]))}else{const Q=K;let re=h.get(Q);re?re.count++:(re={title:K,leaf:!0,checked:g?!1:i.size?i.has(K):!o,key:Q,count:1},h.set(Q,re),d.set(Q,[Q]))}te++}}const N=g?!1:t?o:!0;if(T>0){const k={title:e.t("sheets-filter.panel.empty"),count:T,leaf:!0,checked:N,key:_};h.set("empty",k),d.set("empty",[_])}return{filterTreeItems:ct(Array.from(h.values())),filterTreeMapCache:d}}function ct(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:ut(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,s)=>{const n=Number.parseInt(r.key.split("-")[1],10),a=Number.parseInt(s.key.split("-")[1],10);return n-a}).forEach(r=>{r.children&&r.children.sort((s,n)=>{const a=Number.parseInt(s.key.split("-")[2],10),i=Number.parseInt(n.key.split("-")[2],10);return a-i})}),e))}const Ue=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function ut(t,e){const r=Ue(t),s=Ue(e);return r&&s?Number.parseFloat(t)-Number.parseFloat(e):r&&!s?-1:!r&&s?1:t.localeCompare(e)}function Ae(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const s=Ae(r.children,e);if(s)return s}}return null}function Qe(t){return t.leaf?t.checked:t.children?t.children.every(e=>Qe(e)):!0}function ae(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>ae(r,e))}function Ge(t,e){const r=[];return t.forEach(s=>{const n=s.originValues?e.some(o=>Array.from(s.originValues).some(l=>l.toLowerCase().includes(o.toLowerCase()))):!1,a=!n&&e.some(o=>s.title.toLowerCase().includes(o.toLowerCase()));if(n||a)r.push({...s});else if(s.children){const o=Ge(s.children,e);if(o.length>0){const l=o.reduce((h,d)=>h+d.count,0);r.push({...s,count:l,children:o})}}}),r}var ht=Object.getOwnPropertyDescriptor,Ee=(t,e,r,s)=>{for(var n=s>1?void 0:s?ht(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},ce=(t,e)=>(r,s)=>e(r,s,t);u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let Y=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new S.BehaviorSubject(c.FilterBy.VALUES));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.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(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){if(!this._filterModel||this.col===-1)return!1;switch(e){case c.FilterBy.VALUES:this._setupByValues(this._filterModel,this.col);break;case c.FilterBy.COLORS:this._setupByColors(this._filterModel,this.col);break;case c.FilterBy.CONDITIONS:this._setupByConditions(this._filterModel,this.col);break}return!0}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const s=e.unitId,n=e.subUnitId,a=e.getRange(),i={startColumn:r,startRow:a.startRow,endRow:a.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(s,n,i,(o,l)=>{if(!l)this.terminate();else{const h=l.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 ge.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(c.FilterBy.VALUES),this._listenToFilterHeaderChange(e,r),!0}async _setupByColors(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(c.FilterBy.COLORS),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const s=e.getRange();if(s.startRow===s.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(c.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};Y=Ee([ce(0,u.Inject(u.Injector)),ce(1,u.Inject(I.RefRangeService))],Y);let _e=class extends u.Disposable{constructor(e,r,s,n,a){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=a,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[a,i]=f.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,r,s,a,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=f.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=f.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(f.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=f.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(s)}this._filterConditionFormParams$.next(r)}};_e=Ee([ce(4,u.ICommandService)],_e);let ge=class extends u.Disposable{constructor(e,r,s,n,a){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=a,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(d=>!!d);return Ge(o,h)})),this._manuallyUpdateFilterItems$).pipe(S.shareReplay(1)),this.canApply$=this.filterItems$.pipe(S.map(i=>Re(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,s){const n=e.get(u.IUniverInstanceService),a=e.get(u.LocaleService),i=e.get(ve,u.Quantity.OPTIONAL),{unitId:o,subUnitId:l}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const d=h==null?void 0:h.getSheetBySheetId(l);if(!d)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${l}!`);const p=r.getRange(),E=s,_=r.getFilterColumn(s),g=_==null?void 0:_.getColumnData().filters,T=new Set(g==null?void 0:g.filters),N=!!(g&&g.blank),y=r.getFilteredOutRowsExceptCol(s),w={...p,startRow:p.startRow+1,startColumn:E,endColumn:E};let R,x;if(i){const $=await i.getFilterValues({unitId:o,subUnitId:l,filteredOutRowsByOtherColumns:Array.from(y),filterColumn:_,filters:!!g,blankChecked:N,iterateRange:w,alreadyChecked:Array.from(T)});R=$.filterTreeItems,x=$.filterTreeMapCache}else{const $=Ve(!!g,a,w,d,y,_,T,N,h.getStyles());R=$.filterTreeItems,x=$.filterTreeMapCache}return e.createInstance(ge,r,s,R,x)}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=>ae(s,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),s=Ae(r,e.key);if(!s)return;const n=Qe(s);ae(s,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(s=>ae(s,!1)),e.forEach(s=>{const n=Ae(r,s);n&&ae(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=Re(this._filterItems),{checked:r,checkedItems:s}=e,n=this.rawFilterItems;let a=0;for(const h of n)a+=h.count;const i=r===0,o=e.checked===a,l={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});{l.filters={};const h=s.filter(p=>p.key!=="empty");h.length>0&&(l.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==s.length&&(l.filters.blank=!0)}return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:l})}};ge=Ee([ce(4,u.ICommandService)],ge);let Se=class extends u.Disposable{constructor(e,r,s,n,a){super();v(this,"canApply$",S.of(!0));v(this,"_cellFillColors$");v(this,"cellFillColors$");v(this,"_cellTextColors$");v(this,"cellTextColors$");this._filterModel=e,this.col=r,this._commandService=a,this._cellFillColors$=new S.BehaviorSubject(Array.from(s.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new S.BehaviorSubject(Array.from(n.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,r,s){var w,R,x;const n=e.get(u.IUniverInstanceService),{unitId:a,subUnitId:i}=r,o=n.getUniverSheetInstance(a);if(!o)throw new Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${a}!`);const l=o==null?void 0:o.getSheetBySheetId(i);if(!l)throw new Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${a} and subUnitId: ${i}!`);const h=r.getRange(),d=s,p=(w=r.getFilterColumn(s))==null?void 0:w.getColumnData().colorFilters,E=r.getFilteredOutRowsExceptCol(s),_={...h,startRow:h.startRow+1,startColumn:d,endColumn:d},g=new Map,T=new Set((R=p==null?void 0:p.cellFillColors)!=null?R:[]),N=new Map,y=new Set((x=p==null?void 0:p.cellTextColors)!=null?x:[]);for(const $ of l.iterateByColumn(_,!1,!0)){const{row:q,col:J,value:ee}=$;if(E.has(q))continue;const H=l.getComposedCellStyleByCellData(q,J,ee);if(H.bg&&H.bg.rgb){const U=new u.ColorKit(H.bg.rgb).toRgbString();g.has(U)||g.set(U,{color:U,checked:T.has(U)})}else g.set("default-fill-color",{color:null,checked:T.has(null)});if(H.cl&&H.cl.rgb){const U=new u.ColorKit(H.cl.rgb).toRgbString();N.has(U)||N.set(U,{color:U,checked:y.has(U)})}else N.set("default-font-color",{color:z.COLOR_BLACK_RGB,checked:y.has(z.COLOR_BLACK_RGB)})}return e.createInstance(Se,r,s,g,N)}get cellFillColors(){return this._cellFillColors$.getValue()}get cellTextColors(){return this._cellTextColors$.getValue()}dispose(){super.dispose(),this._cellFillColors$.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})}onFilterCheckToggled(e,r=!0){const s=r?this.cellFillColors:this.cellTextColors,n=[];let a=!1;for(let i=0;i<s.length;i++){const o=s[i];if(o.color===e.color){a=!0,n.push({color:o.color,checked:!o.checked});continue}n.push({color:o.color,checked:o.checked})}a&&(this._resetColorsCheckedStatus(!r),r?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n]))}_resetColorsCheckedStatus(e=!0){const r=e?this.cellFillColors:this.cellTextColors,s=[];for(let n=0;n<r.length;n++)s.push({color:r[n].color,checked:!1});e?this._cellFillColors$.next([...s]):this._cellTextColors$.next([...s])}async apply(){if(this._disposed)return!1;const e=this.cellFillColors.filter(n=>n.checked).map(n=>n.color),r=this.cellTextColors.filter(n=>n.checked).map(n=>n.color);if(e.length===0&&r.length===0)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});const s={colId:this.col};return e.length>0?s.colorFilters={cellFillColors:e}:r.length>0&&(s.colorFilters={cellTextColors:r}),this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:s})}};Se=Ee([ce(4,u.ICommandService)],Se);const ne="FILTER_PANEL_OPENED",ue={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(Y);t.get(u.ICommandService).syncExecuteCommand(M.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:o,col:l}=e,h=s.getFilterModel(i,o);return h?(n.setupCol(h,l),r.getContextValue(ne)||r.setContextValue(ne,!0),!0):!1}},se={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(Y),s=t.get(F.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(ne)?(e.setContextValue(ne,!1),s==null||s.focus(),r.terminate()):!1}},Me={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(Y).changeFilterBy(r)}},Ye="sheets-filter-ui.config",Ce={};var dt=Object.getOwnPropertyDescriptor,mt=(t,e,r,s)=>{for(var n=s>1?void 0:s?dt(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},ie=(t,e)=>(r,s)=>e(r,s,t);let oe=class extends u.Disposable{constructor(t,e,r,s,n,a){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=s,this._injector=n,this._sheetsSelectionService=a,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),a=I.getSheetCommandTarget(n);if(!a)return;const{unitId:i,subUnitId:o,worksheet:l}=a,h=(e=this._sheetsFilterService.getFilterModel(i,o))==null?void 0:e.getRange();let d;if(h)d=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let E={...p};E=p.startColumn===p.endColumn&&p.startRow===p.endRow?I.expandToContinuousRange(E,{left:!0,right:!0,up:!0,down:!0},l):E,d=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetViewPermission,I.WorksheetFilterPermission]},[E],i,o)}else d=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetViewPermission,I.WorksheetFilterPermission]})}d||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ue.id){const n=t.params,{unitId:a,subUnitId:i}=n,o=(s=this._sheetsFilterService.getFilterModel(a,i))==null?void 0:s.getRange(),l=u.Tools.deepClone(o);l&&(l.startColumn=n.col,l.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[I.RangeProtectionPermissionViewPoint],worksheetTypes:[I.WorksheetFilterPermission,I.WorksheetViewPermission]},[l])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};oe=mt([ie(0,u.Inject(c.SheetsFilterService)),ie(1,u.Inject(u.LocaleService)),ie(2,u.ICommandService),ie(3,u.Inject(I.SheetPermissionCheckController)),ie(4,u.Inject(u.Injector)),ie(5,u.Inject(I.SheetsSelectionsService))],oe);const G=16,pt=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 ke{static drawNoCriteria(e,r,s,n){e.save(),z.Rect.drawWith(e,{radius:2,width:G,height:G,fill:n}),e.lineCap="square",e.strokeStyle=s,e.scale(r/G,r/G),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(),z.Rect.drawWith(e,{radius:2,width:G,height:G,fill:n}),e.scale(r/G,r/G),e.fillStyle=s,e.fill(pt),e.restore()}}var ft=Object.getOwnPropertyDescriptor,vt=(t,e,r,s)=>{for(var n=s>1?void 0:s?ft(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},Ne=(t,e)=>(r,s)=>e(r,s,t);const V=16,pe=1;let we=class extends z.Shape{constructor(e,r,s,n,a){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=a,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=V-s,a=V-r;e.save();const i=new Path2D;i.rect(n,a,s,r),e.clip(i);const{hasCriteria:o}=this._filterParams,l=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";o?ke.drawHasCriteria(e,V,l,h):ke.drawNoCriteria(e,V,l,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:s,subUnitId:n}=this._filterParams;this._contextService.getContextValue(ne)||!this._commandService.hasCommand(ue.id)||setTimeout(()=>{this._commandService.executeCommand(ue.id,{unitId:s,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};we=vt([Ne(2,u.IContextService),Ne(3,u.ICommandService),Ne(4,u.Inject(u.ThemeService))],we);var _t=Object.getOwnPropertyDescriptor,gt=(t,e,r,s)=>{for(var n=s>1?void 0:s?_t(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},X=(t,e)=>(r,s)=>e(r,s,t);const St=1e3,Ct=5e3;let xe=class extends u.RxDisposable{constructor(e,r,s,n,a,i,o,l){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=a,this._sheetInterceptorService=i,this._commandService=o,this._selectionRenderService=l,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(S.switchMap(e=>{var o,l;if(!e)return S.of(null);const{unit:r,unitId:s}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",a=(l=this._sheetsFilterService.getFilterModel(s,n))!=null?l:void 0,i=()=>({unitId:s,worksheetId:n,filterModel:a,range:a==null?void 0:a.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(S.filter(([h])=>{var d;return h.type===u.CommandType.MUTATION&&((d=h.params)==null?void 0:d.unitId)===r.getUnitId()&&(c.FILTER_MUTATIONS.has(h.id)||h.id===I.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:a}=r,i=this._filterRangeShape=new M.SelectionControl(s,St,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:a,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},l=M.attachSelectionWithCoord(o,r);i.updateRangeBySelectionWithCoord(l),i.setEvent(!1),s.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:s,unitId:n,skeleton:a,worksheetId:i}=e,{scene:o}=this._context;this._interceptCellContent(n,i,e.range);const{startColumn:l,endColumn:h,startRow:d}=r;for(let p=l;p<=h;p++){const E=`sheets-filter-button-${p}`,_=M.getCoordByCell(d,p,o,a),{startX:g,startY:T,endX:N,endY:y}=_,w=N-g,R=y-T;if(R<=pe||w<=pe)continue;const x=!!s.getFilterColumn(p),$=N-V-pe,q=y-V-pe,J={left:$,top:q,height:V,width:V,zIndex:Ct,cellHeight:R,cellWidth:w,filterParams:{unitId:n,subUnitId:i,col:p,hasCriteria:x}},ee=this._injector.createInstance(we,E,J);this._filterButtonShapes.push(ee)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,s){const{startRow:n,startColumn:a,endColumn:i}=s;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(I.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,l,h)=>{const{row:d,col:p,unitId:E,subUnitId:_}=l;return E!==e||_!==r||d!==n||p<a||p>i||((!o||o===l.rawData)&&(o={...l.rawData}),o.fontRenderExtension={...o==null?void 0:o.fontRenderExtension,rightOffset:V}),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=[]}};xe=gt([X(1,u.Inject(u.Injector)),X(2,u.Inject(M.SheetSkeletonManagerService)),X(3,u.Inject(c.SheetsFilterService)),X(4,u.Inject(u.ThemeService)),X(5,u.Inject(I.SheetInterceptorService)),X(6,u.ICommandService),X(7,M.ISheetSelectionRenderService)],xe);var Ft=Object.getOwnPropertyDescriptor,Tt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ft(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},je=(t,e)=>(r,s)=>e(r,s,t);let he=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,[xe]))}};he=Tt([je(0,z.IRenderManagerService),je(1,u.Inject(M.SheetsRenderService))],he);var Et=Object.defineProperty,Ot=Object.getOwnPropertyDescriptor,It=(t,e,r)=>e in t?Et(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,yt=(t,e,r,s)=>{for(var n=s>1?void 0:s?Ot(e,r):e,a=t.length-1,i;a>=0;a--)(i=t[a])&&(n=i(n)||n);return n},Be=(t,e)=>(r,s)=>e(r,s,t),qe=(t,e,r)=>It(t,typeof e!="symbol"?e+"":e,r);const Nt="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=Ce,r,s){super(),this._config=e,this._injector=r,this._configService=s;const{menu:n,...a}=u.merge({},Ce,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(Ye,a)}onStarting(){[[oe],[he]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(oe)}onRendered(){this._injector.get(he)}};qe(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);qe(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Nt);exports.UniverSheetsFilterMobileUIPlugin=yt([u.DependentOn(c.UniverSheetsFilterPlugin),Be(1,u.Inject(u.Injector)),Be(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var j=function(){return j=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},j.apply(this,arguments)},bt=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},de=O.forwardRef(function(t,e){var r=t.icon,s=t.id,n=t.className,a=t.extend,i=bt(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(s," ").concat(n||"").trim(),l=O.useRef("_".concat(At()));return Ke(r,"".concat(s),{defIds:r.defIds,idSuffix:l.current},j({ref:e,className:o},i),a)});function Ke(t,e,r,s,n){return O.createElement(t.tag,j(j({key:e},Rt(t,r,n)),s),(Pt(t,r).children||[]).map(function(a,i){return Ke(a,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,n)}))}function Rt(t,e,r){var s=j({},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(a){var i=a[0],o=a[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(a){var i=a[0],o=a[1];typeof o=="string"&&(s[i]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),s}function Pt(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)?j(j({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&s&&s.includes(n.attrs.id)?j(j({},n),{attrs:j(j({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function At(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M10 1.05957C10.356 1.05957 10.6816 1.26162 10.8408 1.58008L18.8408 17.5801L18.8799 17.668C19.0486 18.1134 18.8551 18.6232 18.4199 18.8408C17.9557 19.0727 17.3913 18.8841 17.1592 18.4199L10 4.10156L2.84082 18.4199C2.60871 18.8841 2.04434 19.0727 1.58008 18.8408C1.11587 18.6087 0.92731 18.0443 1.15918 17.5801L9.15918 1.58008C9.31841 1.26162 9.64395 1.05957 10 1.05957Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M15.3337 11.7261L15.4294 11.731C15.9035 11.779 16.2732 12.1798 16.2732 12.6665C16.2732 13.1532 15.9035 13.554 15.4294 13.602L15.3337 13.6069H4.66675C4.1476 13.6069 3.72632 13.1856 3.72632 12.6665C3.72632 12.1474 4.1476 11.7261 4.66675 11.7261H15.3337Z"}}]},Ze=O.forwardRef(function(t,e){return O.createElement(de,Object.assign({},t,{id:"a-icon",ref:e,icon:wt}))});Ze.displayName="AIcon";var xt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M17.0596 10C17.0596 6.10087 13.8992 2.94043 10 2.94043C6.10087 2.94043 2.94043 6.10087 2.94043 10C2.94043 13.8992 6.10087 17.0596 10 17.0596C13.8992 17.0596 17.0596 13.8992 17.0596 10ZM18.9404 10C18.9404 14.9374 14.9374 18.9404 10 18.9404C5.06257 18.9404 1.05957 14.9374 1.05957 10C1.05957 5.06257 5.06257 1.05957 10 1.05957C14.9374 1.05957 18.9404 5.06257 18.9404 10Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.29492 4.13476C4.63911 3.79057 5.1845 3.76906 5.55371 4.07031L5.625 4.13476L16.0244 14.5352L16.0889 14.6064C16.3902 14.9757 16.3686 15.52 16.0244 15.8643C15.6573 16.2313 15.0624 16.2313 14.6953 15.8643L4.29492 5.46484L4.23047 5.39355C3.92922 5.02434 3.95073 4.47895 4.29492 4.13476Z"}}]},Xe=O.forwardRef(function(t,e){return O.createElement(de,Object.assign({},t,{id:"ban-icon",ref:e,icon:xt}))});Xe.displayName="BanIcon";var Lt={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"}}]},ze=O.forwardRef(function(t,e){return O.createElement(de,Object.assign({},t,{id:"filter-icon",ref:e,icon:Lt}))});ze.displayName="FilterIcon";var Mt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Je=O.forwardRef(function(t,e){return O.createElement(de,Object.assign({},t,{id:"success-icon",ref:e,icon:Mt}))});Je.displayName="SuccessIcon";function $t(t){const{model:e}=t,r=F.useDependency(u.LocaleService),s=F.useObservable(e.cellFillColors$,[],!0),n=F.useObservable(e.cellTextColors$,[],!0),a=O.useCallback(o=>{e.onFilterCheckToggled(o)},[e]),i=O.useCallback(o=>{e.onFilterCheckToggled(o,!1)},[e]);return m.jsx("div",{"data-u-comp":"sheets-filter-panel-colors-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:m.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.clsx("univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5",b.borderClassName),children:[s.length>1&&m.jsxs("div",{children:[m.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-fill-color")}),m.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:s.map((o,l)=>m.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>a(o),children:[o.color?m.jsx("button",{type:"button",className:b.clsx("univer-box-border univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"),style:{backgroundColor:o.color}}):m.jsx(Xe,{className:"univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"}),o.checked&&m.jsx(De,{})]},`sheets-filter-cell-fill-color-${l}`))})]}),n.length>1&&m.jsxs("div",{children:[m.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-text-color")}),m.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:n.map((o,l)=>m.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>i(o),children:[m.jsx("div",{className:"univer-box-border univer-flex univer-h-full univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]",children:m.jsx(Ze,{style:{color:o.color}})}),o.checked&&m.jsx(De,{})]},`sheets-filter-cell-text-color-${l}`))})]}),s.length<=1&&n.length<=1&&m.jsx("div",{className:"univer-flex univer-h-full univer-w-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:r.t("sheets-filter.panel.filter-by-color-none")})]})})}function De(){return m.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-h-3 univer-w-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:m.jsx(Je,{className:"univer-h-full univer-w-full univer-font-bold univer-text-[#418F1F]"})})}function Ut(t){var _,g;const{model:e}=t,r=F.useDependency(u.LocaleService),s=F.useObservable(e.conditionItem$,void 0),n=F.useObservable(e.filterConditionFormParams$,void 0),a=n!=null&&n.and?"AND":"OR",i=O.useCallback(T=>{e.onConditionFormChange({and:T==="AND"})},[e]),o=kt(r),l=O.useCallback(T=>{e.onPrimaryConditionChange(T)},[e]),h=jt(r),d=O.useCallback(T=>{e.onConditionFormChange(T)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function E(T,N,y){const w=f.getItemByOperator(T).numOfParameters===1;return m.jsxs(m.Fragment,{children:[y==="operator2"&&m.jsxs(b.RadioGroup,{value:a,onChange:i,children:[m.jsx(b.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),m.jsx(b.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),m.jsx(b.Select,{value:T,options:h,onChange:R=>d({[y]:R})}),w&&m.jsx("div",{children:m.jsx(b.Input,{className:"univer-mt-2",value:N,placeholder:p,onChange:R=>d({[y==="operator1"?"val1":"val2"]:R})})})]})}return m.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:s&&n&&m.jsxs(m.Fragment,{children:[m.jsx(b.Select,{value:s.operator,options:o,onChange:l}),f.getItemByOperator(s.operator).numOfParameters!==0?m.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:b.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",b.borderClassName),children:[s.numOfParameters>=1&&E(n.operator1,(_=n.val1)!=null?_:"","operator1"),s.numOfParameters>=2&&E(n.operator2,(g=n.val2)!=null?g:"","operator2"),m.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.?"),m.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function kt(t){const e=t.getCurrentLocale();return O.useMemo(()=>[{options:[{label:t.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:t.t(f.EMPTY.label),value:f.EMPTY.operator},{label:t.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:t.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:t.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:t.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:t.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:t.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:t.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:t.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:t.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:t.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:t.t(f.EQUAL.label),value:f.EQUAL.operator},{label:t.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:t.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:t.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:t.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,t])}function jt(t){const e=t.getCurrentLocale();return O.useMemo(()=>f.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Bt(t){const{model:e}=t,r=F.useDependency(u.LocaleService),s=F.useObservable(e.searchString$,"",!0),n=F.useObservable(e.filterItems$,void 0,!0),a=r.t("sheets-filter.panel.filter-only"),i=Re(n),o=i.checked>0&&i.unchecked===0,l=i.checked>0&&i.unchecked>0,h=e.treeMapCache,d=O.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),p=O.useCallback(_=>{e.setSearchString(_)},[e]);function E(_){let g=[];return _.forEach(T=>{T.checked&&g.push(T.key),T.children&&(g=g.concat(E(T.children)))}),g}return m.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[m.jsx(b.Input,{autoFocus:!0,value:s,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),m.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.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",b.borderClassName),children:[m.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:m.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:[m.jsx(b.Checkbox,{indeterminate:l,disabled:n.length===0,checked:o,onChange:d}),m.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")}`}),m.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})`})]})}),m.jsx("div",{"data-u-comp":"sheets-filter-panel-values-virtual",className:"univer-flex-grow",children:m.jsx(b.Tree,{data:n,defaultExpandAll:!1,valueGroup:E(n),onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
- univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
2
+ univer-pr-2 univer-border-box 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
package/lib/es/index.js CHANGED
@@ -1920,7 +1920,7 @@ function Vi(t) {
1920
1920
  defaultCache: c,
1921
1921
  itemHeight: 28,
1922
1922
  treeNodeClassName: `
1923
- univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
1923
+ univer-pr-2 univer-border-box univer-rounded-md
1924
1924
  [&:hover_a]:univer-inline-block
1925
1925
  hover:univer-bg-gray-50 univer-h-full
1926
1926
  univer-text-gray-900 dark:hover:!univer-bg-gray-900
package/lib/index.css CHANGED
@@ -1 +1 @@
1
- .univer-absolute{position:absolute}.univer-relative{position:relative}.-univer-bottom-0\.5{bottom:-.125rem}.-univer-right-0\.5{right:-.125rem}.univer-mx-1{margin-left:.25rem;margin-right:.25rem}.univer-mb-1{margin-bottom:.25rem}.univer-mb-2{margin-bottom:.5rem}.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-mt-4{margin-top:1rem}.univer-box-border{box-sizing:border-box}.univer-inline-block{display:inline-block}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-grid{display:grid}.univer-hidden{display:none}.univer-h-3{height:.75rem}.univer-h-4{height:1rem}.univer-h-5{height:1.25rem}.univer-h-6{height:1.5rem}.univer-h-7{height:1.75rem}.univer-h-8{height:2rem}.univer-h-\[300px\]{height:300px}.univer-h-full{height:100%}.univer-max-h-\[500px\]{max-height:500px}.univer-min-h-\[300px\]{min-height:300px}.univer-w-3{width:.75rem}.univer-w-6{width:1.5rem}.univer-w-\[400px\]{width:400px}.univer-w-full{width:100%}.univer-max-w-\[245px\]{max-width:245px}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow{flex-grow:1}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.univer-flex-col{flex-direction:column}.univer-flex-nowrap{flex-wrap:nowrap}.univer-items-center{align-items:center}.univer-justify-start{justify-content:flex-start}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:.5rem}.univer-gap-4{gap:1rem}.univer-overflow-auto{overflow:auto}.univer-overflow-hidden{overflow:hidden}.univer-text-ellipsis{text-overflow:ellipsis}.univer-whitespace-nowrap{white-space:nowrap}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-\[rgba\(13\,13\,13\,0\.06\)\]{border-color:#0d0d0d0f}.univer-border-transparent{border-color:transparent}.univer-bg-gray-300{background-color:var(--univer-gray-300)}.univer-bg-white{background-color:var(--univer-white)}.univer-p-0\.5{padding:.125rem}.univer-p-2{padding:.5rem}.univer-p-4{padding:1rem}.univer-px-1\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.univer-py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pb-0{padding-bottom:0}.univer-pl-5{padding-left:1.25rem}.univer-pr-0\.5{padding-right:.125rem}.univer-pr-2{padding-right:.5rem}.univer-pt-0{padding-top:0}.univer-pt-2{padding-top:.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-font-bold{font-weight:700}.univer-text-\[\#418F1F\]{--univer-tw-text-opacity: 1;color:#418f1f;color:rgba(65,143,31,var(--univer-tw-text-opacity, 1))}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-shadow-lg{--univer-tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--univer-tw-shadow-colored: 0px 4px 6px 0px var(--univer-tw-shadow-color), 0px 10px 15px -3px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-shadow)}.univer-transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.hover\:univer-ring-2:hover{--univer-tw-ring-offset-shadow: var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow: var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow, 0 0 rgba(0,0,0,0))}.hover\:univer-ring-offset-2:hover{--univer-tw-ring-offset-width: 2px }.hover\:univer-ring-offset-white:hover{--univer-tw-ring-offset-color: var(--univer-white) }.dark\:\!univer-border-\[rgba\(255\,255\,255\,0\.06\)\]:where(.univer-dark,.univer-dark *){border-color:#ffffff0f!important}.dark\:\!univer-border-gray-600:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\:\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-gray-500:where(.univer-dark,.univer-dark *){color:var(--univer-gray-500)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-900:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.\[\&\:hover_a\]\:univer-inline-block:hover a{display:inline-block}
1
+ .univer-absolute{position:absolute}.univer-relative{position:relative}.-univer-bottom-0\.5{bottom:-.125rem}.-univer-right-0\.5{right:-.125rem}.univer-mx-1{margin-left:.25rem;margin-right:.25rem}.univer-mb-1{margin-bottom:.25rem}.univer-mb-2{margin-bottom:.5rem}.univer-ml-1{margin-left:.25rem}.univer-mt-2{margin-top:.5rem}.univer-mt-4{margin-top:1rem}.univer-box-border{box-sizing:border-box}.univer-inline-block{display:inline-block}.univer-flex{display:flex}.univer-inline-flex{display:inline-flex}.univer-grid{display:grid}.univer-hidden{display:none}.univer-h-3{height:.75rem}.univer-h-4{height:1rem}.univer-h-5{height:1.25rem}.univer-h-6{height:1.5rem}.univer-h-7{height:1.75rem}.univer-h-8{height:2rem}.univer-h-\[300px\]{height:300px}.univer-h-full{height:100%}.univer-max-h-\[500px\]{max-height:500px}.univer-min-h-\[300px\]{min-height:300px}.univer-w-3{width:.75rem}.univer-w-6{width:1.5rem}.univer-w-\[400px\]{width:400px}.univer-w-full{width:100%}.univer-flex-1{flex:1 1 0%}.univer-flex-shrink{flex-shrink:1}.univer-flex-shrink-0{flex-shrink:0}.univer-flex-grow{flex-grow:1}.univer-flex-grow-0{flex-grow:0}.univer-cursor-pointer{cursor:pointer}.univer-grid-cols-8{grid-template-columns:repeat(8,minmax(0,1fr))}.univer-flex-col{flex-direction:column}.univer-flex-nowrap{flex-wrap:nowrap}.univer-items-center{align-items:center}.univer-justify-start{justify-content:flex-start}.univer-justify-center{justify-content:center}.univer-justify-between{justify-content:space-between}.univer-gap-2{gap:.5rem}.univer-gap-4{gap:1rem}.univer-overflow-auto{overflow:auto}.univer-overflow-hidden{overflow:hidden}.univer-text-ellipsis{text-overflow:ellipsis}.univer-whitespace-nowrap{white-space:nowrap}.univer-rounded-full{border-radius:9999px}.univer-rounded-lg{border-radius:.5rem}.univer-rounded-md{border-radius:.375rem}.univer-border{border-width:1px}.univer-border-solid{border-style:solid}.univer-border-\[rgba\(13\,13\,13\,0\.06\)\]{border-color:#0d0d0d0f}.univer-border-transparent{border-color:transparent}.univer-bg-gray-300{background-color:var(--univer-gray-300)}.univer-bg-white{background-color:var(--univer-white)}.univer-p-0\.5{padding:.125rem}.univer-p-2{padding:.5rem}.univer-p-4{padding:1rem}.univer-px-1\.5{padding-left:.375rem;padding-right:.375rem}.univer-px-2{padding-left:.5rem;padding-right:.5rem}.univer-py-0\.5{padding-top:.125rem;padding-bottom:.125rem}.univer-py-2\.5{padding-top:.625rem;padding-bottom:.625rem}.univer-pb-0{padding-bottom:0}.univer-pl-5{padding-left:1.25rem}.univer-pr-0\.5{padding-right:.125rem}.univer-pr-2{padding-right:.5rem}.univer-pt-0{padding-top:0}.univer-pt-2{padding-top:.5rem}.univer-text-sm{font-size:.875rem;line-height:1.25rem}.univer-text-xs{font-size:.75rem;line-height:1rem}.univer-font-bold{font-weight:700}.univer-text-\[\#418F1F\]{--univer-tw-text-opacity: 1;color:#418f1f;color:rgba(65,143,31,var(--univer-tw-text-opacity, 1))}.univer-text-gray-400{color:var(--univer-gray-400)}.univer-text-gray-500{color:var(--univer-gray-500)}.univer-text-gray-900{color:var(--univer-gray-900)}.univer-text-primary-500{color:var(--univer-primary-500)}.univer-shadow-lg{--univer-tw-shadow: 0px 4px 6px 0px rgba(30, 40, 77, .05), 0px 10px 15px -3px rgba(30, 40, 77, .1);--univer-tw-shadow-colored: 0px 4px 6px 0px var(--univer-tw-shadow-color), 0px 10px 15px -3px var(--univer-tw-shadow-color);box-shadow:0 0 #0000,0 0 #0000,0 4px 6px #1e284d0d,0 10px 15px -3px #1e284d1a;box-shadow:var(--univer-tw-ring-offset-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-ring-shadow, 0 0 rgba(0,0,0,0)),var(--univer-tw-shadow)}.univer-transition-shadow{transition-property:box-shadow;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.hover\:univer-bg-gray-50:hover{background-color:var(--univer-gray-50)}.hover\:univer-ring-2:hover{--univer-tw-ring-offset-shadow: var(--univer-tw-ring-inset) 0 0 0 var(--univer-tw-ring-offset-width) var(--univer-tw-ring-offset-color);--univer-tw-ring-shadow: var(--univer-tw-ring-inset) 0 0 0 calc(2px + var(--univer-tw-ring-offset-width)) var(--univer-tw-ring-color);box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),0 0 #0000;box-shadow:var(--univer-tw-ring-offset-shadow),var(--univer-tw-ring-shadow),var(--univer-tw-shadow, 0 0 rgba(0,0,0,0))}.hover\:univer-ring-offset-2:hover{--univer-tw-ring-offset-width: 2px }.hover\:univer-ring-offset-white:hover{--univer-tw-ring-offset-color: var(--univer-white) }.dark\:\!univer-border-\[rgba\(255\,255\,255\,0\.06\)\]:where(.univer-dark,.univer-dark *){border-color:#ffffff0f!important}.dark\:\!univer-border-gray-600:where(.univer-dark,.univer-dark *){border-color:var(--univer-gray-600)!important}.dark\:\!univer-bg-gray-700:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-700)!important}.dark\:\!univer-text-gray-200:where(.univer-dark,.univer-dark *){color:var(--univer-gray-200)!important}.dark\:\!univer-text-gray-500:where(.univer-dark,.univer-dark *){color:var(--univer-gray-500)!important}.dark\:\!univer-text-white:where(.univer-dark,.univer-dark *){color:var(--univer-white)!important}.dark\:hover\:\!univer-bg-gray-900:hover:where(.univer-dark,.univer-dark *){background-color:var(--univer-gray-900)!important}.\[\&\:hover_a\]\:univer-inline-block:hover a{display:inline-block}
package/lib/index.js CHANGED
@@ -1920,7 +1920,7 @@ function Vi(t) {
1920
1920
  defaultCache: c,
1921
1921
  itemHeight: 28,
1922
1922
  treeNodeClassName: `
1923
- univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
1923
+ univer-pr-2 univer-border-box univer-rounded-md
1924
1924
  [&:hover_a]:univer-inline-block
1925
1925
  hover:univer-bg-gray-50 univer-h-full
1926
1926
  univer-text-gray-900 dark:hover:!univer-bg-gray-900
package/lib/umd/index.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(_,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/rpc"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-render","@univerjs/sheets","rxjs","@univerjs/rpc","@univerjs/design","react/jsx-runtime","react"],u):(_=typeof globalThis<"u"?globalThis:_||self,u(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverSheetsFilter,_.UniverSheetsUi,_.UniverUi,_.UniverEngineRender,_.UniverSheets,_.rxjs,_.UniverRpc,_.UniverDesign,_.React,_.React))})(this,function(_,u,c,$,E,K,F,g,pe,b,d,I){"use strict";var rr=Object.defineProperty;var ir=(_,u,c)=>u in _?rr(_,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):_[u]=c;var v=(_,u,c)=>ir(_,typeof u!="symbol"?u+"":u,c);var Oe;var A=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(A||{}),T=(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))(T||{}),f;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:T.NONE,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===T.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:T.EMPTY,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===T.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===""&&s.operator===void 0?{operator1:T.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:T.NOT_EMPTY,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===T.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 s=i.customFilters.customFilters[0];return s.val===" "&&s.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:T.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:T.CONTAINS,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===T.CONTAINS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:`*${s}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:T.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:T.DOES_NOT_CONTAIN,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=H(i);return s===T.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return s.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:T.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:T.STARTS_WITH,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=H(i);return s===T.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:T.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:T.ENDS_WITH,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=H(i);return s===T.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:T.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:T.EQUALS,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.EQUALS,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===T.EQUALS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:s}]}}},testMappingFilterColumn:i=>{var s,a,h;return((a=(s=i.filters)==null?void 0:s.filters)==null?void 0:a.length)===1?{operator1:T.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:T.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=H(i);return s===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:s.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:s.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:s.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:s.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=H(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:s.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:T.BETWEEN,order:A.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:s,operator1:a,operator2:h}=i;if(!s)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:s,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?s:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:s,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[s,a]=i.customFilters.customFilters;return s.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:s.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&s.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:s.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:T.NOT_BETWEEN,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:h}=i;if(s)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?s:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:s,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:s.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&s.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:s.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:T.CUSTOM,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:T.NONE,val1:"",operator2:T.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:h,operator1:m,operator2:p}=i;function y(L,w){for(const M of t.ALL_CONDITIONS)if(M.operator===L)return M.mapToFilterColumn({val1:w,operator1:L})}const S=!m||m===t.NONE.operator,C=!p||p===t.NONE.operator;if(S&&C)return t.NONE.mapToFilterColumn({});if(S)return y(p,h);if(C)return y(m,a);const O=y(m,a),P=y(p,h),N={customFilters:[O.customFilters.customFilters[0],P.customFilters.customFilters[0]]};return s&&(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 s=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:s[0][0].operator,val1:s[0][1].val1,operator2:s[1][0].operator,val2:s[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 s=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}t.getItemByOperator=e;function r(i,s){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===s))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 n(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}t.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}t.mapToFilterColumn=o;function l(i){if(!i)return[t.NONE,{}];for(const s of t.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(f||(f={}));function H(t){const{operator1:e,operator2:r,val1:n,val2:o}=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,n]:[r,o]}function Ie(t){const e=[],r=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(r.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:n,unchecked:o}}var rt=Object.getOwnPropertyDescriptor,it=(t,e,r,n)=>{for(var o=n>1?void 0:n?rt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Fe=(t,e)=>(r,n)=>e(r,n,t);const Ne="sheets-filter.generate-filter-values.service",fe=u.createIdentifier(Ne),nt=["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 be=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var p;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:n,filterColumn:o,filters:l,blankChecked:i,iterateRange:s,alreadyChecked:a}=t,h=this._univerInstanceService.getUnit(e),m=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(r);return!h||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),ke(l,this._localeService,s,m,new Set(n),o,new Set(a.map(String)),i,h.getStyles()))}};be=it([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],be);function ke(t,e,r,n,o,l,i,s,a){var N,L,w,M,B,X,ne,oe,V,D;const h=new Map,m=new Map,p="yyyy-mm-dd",y=new Set(nt),S="empty",C=!t&&((l==null?void 0:l.filterBy)===c.FilterBy.COLORS||(l==null?void 0:l.filterBy)===c.FilterBy.CONDITIONS)&&((N=l.filteredOutRows)==null?void 0:N.size);let O=0;for(const x of n.iterateByColumn(r,!1,!1)){const{row:Jt,rowSpan:tt=1}=x;let se=0;for(;se<tt;){const er=Jt+se;if(o.has(er)){se++;continue}const z=x!=null&&x.value?u.extractPureTextFromCell(x.value):"";if(!z){O+=1,se+=tt;continue}const ye=(L=x.value)!=null&&L.v&&!x.value.p?(B=(M=a.get((w=x.value)==null?void 0:w.s))==null?void 0:M.n)==null?void 0:B.pattern:"",tr=ye&&u.numfmt.getFormatInfo(ye).isDate;if(ye&&tr&&y.has(ye)){const q=(X=n.getCellRaw(x.row,x.col))==null?void 0:X.v;if(!q){se++;continue}const ae=u.numfmt.format(p,q),[R,W,me]=ae.split("-").map(Number);let J=h.get(`${R}`);J||(J={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${R}`,J),m.set(`${R}`,[`${R}`]));let Q=(ne=J.children)==null?void 0:ne.find(Ue=>Ue.key===`${R}-${W}`);Q||(Q={title:e.t(`sheets-filter.date.${W}`),key:`${R}-${W}`,children:[],count:0,leaf:!1,checked:!1},(oe=J.children)==null||oe.push(Q),m.set(`${R}-${W}`,[`${R}`,`${R}-${W}`]));const $e=(V=Q==null?void 0:Q.children)==null?void 0:V.find(Ue=>Ue.key===`${R}-${W}-${me}`);$e?($e.originValues.add(z),$e.count++,Q.count++,J.count++):((D=Q.children)==null||D.push({title:`${me}`,key:`${R}-${W}-${me}`,count:1,originValues:new Set([z]),leaf:!0,checked:C?!1:i.size?i.has(z):!s}),Q.count++,J.count++,m.set(`${R}-${W}-${me}`,[`${R}`,`${R}-${W}`,`${R}-${W}-${me}`]))}else{const q=z;let ae=h.get(q);ae?ae.count++:(ae={title:z,leaf:!0,checked:C?!1:i.size?i.has(z):!s,key:q,count:1},h.set(q,ae),m.set(q,[q]))}se++}}const P=C?!1:t?s:!0;if(O>0){const x={title:e.t("sheets-filter.panel.empty"),count:O,leaf:!0,checked:P,key:S};h.set("empty",x),m.set("empty",[S])}return{filterTreeItems:ot(Array.from(h.values())),filterTreeMapCache:m}}function ot(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:st(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,n)=>{const o=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(r=>{r.children&&r.children.sort((n,o)=>{const l=Number.parseInt(n.key.split("-")[2],10),i=Number.parseInt(o.key.split("-")[2],10);return l-i})}),e))}const Be=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function st(t,e){const r=Be(t),n=Be(e);return r&&n?Number.parseFloat(t)-Number.parseFloat(e):r&&!n?-1:!r&&n?1:t.localeCompare(e)}function Pe(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const n=Pe(r.children,e);if(n)return n}}return null}function De(t){return t.leaf?t.checked:t.children?t.children.every(e=>De(e)):!0}function le(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>le(r,e))}function xe(t,e){const r=[];return t.forEach(n=>{const o=n.originValues?e.some(s=>Array.from(n.originValues).some(a=>a.toLowerCase().includes(s.toLowerCase()))):!1,l=!o&&e.some(s=>n.title.toLowerCase().includes(s.toLowerCase()));if(o||l)r.push({...n});else if(n.children){const s=xe(n.children,e);if(s.length>0){const a=s.reduce((h,m)=>h+m.count,0);r.push({...n,count:a,children:s})}}}),r}var at=Object.getOwnPropertyDescriptor,ve=(t,e,r,n)=>{for(var o=n>1?void 0:n?at(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ce=(t,e)=>(r,n)=>e(r,n,t);u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new g.BehaviorSubject(c.FilterBy.VALUES));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new g.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new g.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new g.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 n=e.getFilterColumn(r);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(o.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,r);return}if(o.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){if(!this._filterModel||this.col===-1)return!1;switch(e){case c.FilterBy.VALUES:this._setupByValues(this._filterModel,this.col);break;case c.FilterBy.COLORS:this._setupByColors(this._filterModel,this.col);break;case c.FilterBy.CONDITIONS:this._setupByConditions(this._filterModel,this.col);break}return!0}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(s,a)=>{if(!a)this.terminate();else{const h=a.startColumn-s.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await ge.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(c.FilterBy.VALUES),this._listenToFilterHeaderChange(e,r),!0}async _setupByColors(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(c.FilterBy.COLORS),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(c.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=ve([ce(0,u.Inject(u.Injector)),ce(1,u.Inject(F.RefRangeService))],G);let _e=class extends u.Disposable{constructor(e,r,n,o,l){super();v(this,"canApply$",g.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 g.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,n,o){const[l,i]=f.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(_e,r,n,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=f.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=f.ALL_CONDITIONS.find(n=>n.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(f.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 n=f.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};_e=ve([ce(4,u.ICommandService)],_e);let ge=class extends u.Disposable{constructor(e,r,n,o,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=o,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new g.Subject,this.filterItems$=g.merge(g.combineLatest([this._searchString$.pipe(g.throttleTime(500,void 0,{leading:!0,trailing:!0}),g.startWith(void 0)),this._rawFilterItems$]).pipe(g.map(([i,s])=>{if(!i)return s;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return xe(s,h)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(i=>Ie(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,n){const o=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(fe,u.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=r,h=o.getUniverSheetInstance(s);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${s}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${s} and subUnitId: ${a}!`);const p=r.getRange(),y=n,S=r.getFilterColumn(n),C=S==null?void 0:S.getColumnData().filters,O=new Set(C==null?void 0:C.filters),P=!!(C&&C.blank),N=r.getFilteredOutRowsExceptCol(n),L={...p,startRow:p.startRow+1,startColumn:y,endColumn:y};let w,M;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(N),filterColumn:S,filters:!!C,blankChecked:P,iterateRange:L,alreadyChecked:Array.from(O)});w=B.filterTreeItems,M=B.filterTreeMapCache}else{const B=ke(!!C,l,L,m,N,S,O,P,h.getStyles());w=B.filterTreeItems,M=B.filterTreeMapCache}return e.createInstance(ge,r,n,w,M)}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(n=>le(n,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),n=Pe(r,e.key);if(!n)return;const o=De(n);le(n,!o),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(n=>le(n,!1)),e.forEach(n=>{const o=Pe(r,n);o&&le(o,!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=Ie(this._filterItems),{checked:r,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const h of o)l+=h.count;const i=r===0,s=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(s)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=n.filter(p=>p.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==n.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})}};ge=ve([ce(4,u.ICommandService)],ge);let Se=class extends u.Disposable{constructor(e,r,n,o,l){super();v(this,"canApply$",g.of(!0));v(this,"_cellFillColors$");v(this,"cellFillColors$");v(this,"_cellTextColors$");v(this,"cellTextColors$");this._filterModel=e,this.col=r,this._commandService=l,this._cellFillColors$=new g.BehaviorSubject(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new g.BehaviorSubject(Array.from(o.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,r,n){var L,w,M;const o=e.get(u.IUniverInstanceService),{unitId:l,subUnitId:i}=r,s=o.getUniverSheetInstance(l);if(!s)throw new Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${l}!`);const a=s==null?void 0:s.getSheetBySheetId(i);if(!a)throw new Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${l} and subUnitId: ${i}!`);const h=r.getRange(),m=n,p=(L=r.getFilterColumn(n))==null?void 0:L.getColumnData().colorFilters,y=r.getFilteredOutRowsExceptCol(n),S={...h,startRow:h.startRow+1,startColumn:m,endColumn:m},C=new Map,O=new Set((w=p==null?void 0:p.cellFillColors)!=null?w:[]),P=new Map,N=new Set((M=p==null?void 0:p.cellTextColors)!=null?M:[]);for(const B of a.iterateByColumn(S,!1,!0)){const{row:X,col:ne,value:oe}=B;if(y.has(X))continue;const V=a.getComposedCellStyleByCellData(X,ne,oe);if(V.bg&&V.bg.rgb){const D=new u.ColorKit(V.bg.rgb).toRgbString();C.has(D)||C.set(D,{color:D,checked:O.has(D)})}else C.set("default-fill-color",{color:null,checked:O.has(null)});if(V.cl&&V.cl.rgb){const D=new u.ColorKit(V.cl.rgb).toRgbString();P.has(D)||P.set(D,{color:D,checked:N.has(D)})}else P.set("default-font-color",{color:K.COLOR_BLACK_RGB,checked:N.has(K.COLOR_BLACK_RGB)})}return e.createInstance(Se,r,n,C,P)}get cellFillColors(){return this._cellFillColors$.getValue()}get cellTextColors(){return this._cellTextColors$.getValue()}dispose(){super.dispose(),this._cellFillColors$.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})}onFilterCheckToggled(e,r=!0){const n=r?this.cellFillColors:this.cellTextColors,o=[];let l=!1;for(let i=0;i<n.length;i++){const s=n[i];if(s.color===e.color){l=!0,o.push({color:s.color,checked:!s.checked});continue}o.push({color:s.color,checked:s.checked})}l&&(this._resetColorsCheckedStatus(!r),r?this._cellFillColors$.next([...o]):this._cellTextColors$.next([...o]))}_resetColorsCheckedStatus(e=!0){const r=e?this.cellFillColors:this.cellTextColors,n=[];for(let o=0;o<r.length;o++)n.push({color:r[o].color,checked:!1});e?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n])}async apply(){if(this._disposed)return!1;const e=this.cellFillColors.filter(o=>o.checked).map(o=>o.color),r=this.cellTextColors.filter(o=>o.checked).map(o=>o.color);if(e.length===0&&r.length===0)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});const n={colId:this.col};return e.length>0?n.colorFilters={cellFillColors:e}:r.length>0&&(n.colorFilters={cellTextColors:r}),this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Se=ve([ce(4,u.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",ue={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),n=t.get(c.SheetsFilterService),o=t.get(G);t.get(u.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:s,col:a}=e,h=n.getFilterModel(i,s);return h?(o.setupCol(h,a),r.getContextValue(ee)||r.setContextValue(ee,!0),!0):!1}},te={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(G),n=t.get(E.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),n==null||n.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}},He="sheets-filter-ui.config",Ce={};var lt=Object.getOwnPropertyDescriptor,ct=(t,e,r,n)=>{for(var o=n>1?void 0:n?lt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},re=(t,e)=>(r,n)=>e(r,n,t);let ie=class extends u.Disposable{constructor(t,e,r,n,o,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,n;if(t.id===c.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(u.IUniverInstanceService),l=F.getSheetCommandTarget(o);if(!l)return;const{unitId:i,subUnitId:s,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,s))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let y={...p};y=p.startColumn===p.endColumn&&p.startRow===p.endRow?F.expandToContinuousRange(y,{left:!0,right:!0,up:!0,down:!0},a):y,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetViewPermission,F.WorksheetFilterPermission]},[y],i,s)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetViewPermission,F.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ue.id){const o=t.params,{unitId:l,subUnitId:i}=o,s=(n=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:n.getRange(),a=u.Tools.deepClone(s);a&&(a.startColumn=o.col,a.endColumn=o.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ie=ct([re(0,u.Inject(c.SheetsFilterService)),re(1,u.Inject(u.LocaleService)),re(2,u.ICommandService),re(3,u.Inject(F.SheetPermissionCheckController)),re(4,u.Inject(u.Injector)),re(5,u.Inject(F.SheetsSelectionsService))],ie);const Y=16,ut=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,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(r/Y,r/Y),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,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:o}),e.scale(r/Y,r/Y),e.fillStyle=n,e.fill(ut),e.restore()}}var ht=Object.getOwnPropertyDescriptor,dt=(t,e,r,n)=>{for(var o=n>1?void 0:n?ht(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},we=(t,e)=>(r,n)=>e(r,n,t);const j=16,Te=1;let Re=class extends K.Shape{constructor(e,r,n,o,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=n,this._commandService=o,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,n=this._cellWidth,o=j-n,l=j-r;e.save();const i=new Path2D;i.rect(o,l,n,r),e.clip(i);const{hasCriteria:s}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";s?We.drawHasCriteria(e,j,a,h):We.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(ue.id)||setTimeout(()=>{this._commandService.executeCommand(ue.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Re=dt([we(2,u.IContextService),we(3,u.ICommandService),we(4,u.Inject(u.ThemeService))],Re);var mt=Object.getOwnPropertyDescriptor,pt=(t,e,r,n)=>{for(var o=n>1?void 0:n?mt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Z=(t,e)=>(r,n)=>e(r,n,t);const ft=1e3,vt=5e3;let Le=class extends u.RxDisposable{constructor(e,r,n,o,l,i,s,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=n,this._sheetsFilterService=o,this._themeService=l,this._sheetInterceptorService=i,this._commandService=s,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var s,a;if(!e)return g.of(null);const{unit:r,unitId:n}=this._context,o=((s=r.getActiveSheet())==null?void 0:s.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(n,o))!=null?a:void 0,i=()=>({unitId:n,worksheetId:o,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(g.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===F.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(i),g.startWith(i()))}),g.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=r,i=this._filterRangeShape=new $.SelectionControl(n,ft,this._themeService,{rowHeaderWidth:o,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),s={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(s,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{scene:s}=this._context;this._interceptCellContent(o,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let p=a;p<=h;p++){const y=`sheets-filter-button-${p}`,S=$.getCoordByCell(m,p,s,l),{startX:C,startY:O,endX:P,endY:N}=S,L=P-C,w=N-O;if(w<=Te||L<=Te)continue;const M=!!n.getFilterColumn(p),B=P-j-Te,X=N-j-Te,ne={left:B,top:X,height:j,width:j,zIndex:vt,cellHeight:w,cellWidth:L,filterParams:{unitId:o,subUnitId:i,col:p,hasCriteria:M}},oe=this._injector.createInstance(Re,y,ne);this._filterButtonShapes.push(oe)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,r,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(F.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(s,a,h)=>{const{row:m,col:p,unitId:y,subUnitId:S}=a;return y!==e||S!==r||m!==o||p<l||p>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:j}),h(s)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Le=pt([Z(1,u.Inject(u.Injector)),Z(2,u.Inject($.SheetSkeletonManagerService)),Z(3,u.Inject(c.SheetsFilterService)),Z(4,u.Inject(u.ThemeService)),Z(5,u.Inject(F.SheetInterceptorService)),Z(6,u.ICommandService),Z(7,$.ISheetSelectionRenderService)],Le);var _t=Object.getOwnPropertyDescriptor,gt=(t,e,r,n)=>{for(var o=n>1?void 0:n?_t(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},je=(t,e)=>(r,n)=>e(r,n,t);let he=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,[Le]))}};he=gt([je(0,K.IRenderManagerService),je(1,u.Inject($.SheetsRenderService))],he);var St=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r)=>e in t?St(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Et=(t,e,r,n)=>{for(var o=n>1?void 0:n?Ct(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ve=(t,e)=>(r,n)=>e(r,n,t),Qe=(t,e,r)=>Tt(t,typeof e!="symbol"?e+"":e,r);const Ot="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=Ce,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{menu:o,...l}=u.merge({},Ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(He,l)}onStarting(){[[ie],[he]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ie)}onRendered(){this._injector.get(he)}},Qe(_.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Qe(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Ot),_.UniverSheetsFilterMobileUIPlugin=Et([u.DependentOn(c.UniverSheetsFilterPlugin),Ve(1,u.Inject(u.Injector)),Ve(2,u.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var k=function(){return k=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},k.apply(this,arguments)},yt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},de=I.forwardRef(function(t,e){var r=t.icon,n=t.id,o=t.className,l=t.extend,i=yt(t,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),a=I.useRef("_".concat(Nt()));return Ge(r,"".concat(n),{defIds:r.defIds,idSuffix:a.current},k({ref:e,className:s},i),l)});function Ge(t,e,r,n,o){return I.createElement(t.tag,k(k({key:e},It(t,r,o)),n),(Ft(t,r).children||[]).map(function(l,i){return Ge(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,o)}))}function It(t,e,r){var n=k({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];i==="mask"&&typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Ft(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?k(k({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?k(k({},o),{attrs:k(k({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function Nt(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M10 1.05957C10.356 1.05957 10.6816 1.26162 10.8408 1.58008L18.8408 17.5801L18.8799 17.668C19.0486 18.1134 18.8551 18.6232 18.4199 18.8408C17.9557 19.0727 17.3913 18.8841 17.1592 18.4199L10 4.10156L2.84082 18.4199C2.60871 18.8841 2.04434 19.0727 1.58008 18.8408C1.11587 18.6087 0.92731 18.0443 1.15918 17.5801L9.15918 1.58008C9.31841 1.26162 9.64395 1.05957 10 1.05957Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M15.3337 11.7261L15.4294 11.731C15.9035 11.779 16.2732 12.1798 16.2732 12.6665C16.2732 13.1532 15.9035 13.554 15.4294 13.602L15.3337 13.6069H4.66675C4.1476 13.6069 3.72632 13.1856 3.72632 12.6665C3.72632 12.1474 4.1476 11.7261 4.66675 11.7261H15.3337Z"}}]},Ye=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"a-icon",ref:e,icon:bt}))});Ye.displayName="AIcon";var Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M17.0596 10C17.0596 6.10087 13.8992 2.94043 10 2.94043C6.10087 2.94043 2.94043 6.10087 2.94043 10C2.94043 13.8992 6.10087 17.0596 10 17.0596C13.8992 17.0596 17.0596 13.8992 17.0596 10ZM18.9404 10C18.9404 14.9374 14.9374 18.9404 10 18.9404C5.06257 18.9404 1.05957 14.9374 1.05957 10C1.05957 5.06257 5.06257 1.05957 10 1.05957C14.9374 1.05957 18.9404 5.06257 18.9404 10Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.29492 4.13476C4.63911 3.79057 5.1845 3.76906 5.55371 4.07031L5.625 4.13476L16.0244 14.5352L16.0889 14.6064C16.3902 14.9757 16.3686 15.52 16.0244 15.8643C15.6573 16.2313 15.0624 16.2313 14.6953 15.8643L4.29492 5.46484L4.23047 5.39355C3.92922 5.02434 3.95073 4.47895 4.29492 4.13476Z"}}]},qe=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"ban-icon",ref:e,icon:Pt}))});qe.displayName="BanIcon";var At={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"}}]},Ke=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"filter-icon",ref:e,icon:At}))});Ke.displayName="FilterIcon";var wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ze=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"success-icon",ref:e,icon:wt}))});Ze.displayName="SuccessIcon";function Rt(t){const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.cellFillColors$,[],!0),o=E.useObservable(e.cellTextColors$,[],!0),l=I.useCallback(s=>{e.onFilterCheckToggled(s)},[e]),i=I.useCallback(s=>{e.onFilterCheckToggled(s,!1)},[e]);return d.jsx("div",{"data-u-comp":"sheets-filter-panel-colors-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.clsx("univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5",b.borderClassName),children:[n.length>1&&d.jsxs("div",{children:[d.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-fill-color")}),d.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:n.map((s,a)=>d.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>l(s),children:[s.color?d.jsx("button",{type:"button",className:b.clsx("univer-box-border univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"),style:{backgroundColor:s.color}}):d.jsx(qe,{className:"univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"}),s.checked&&d.jsx(Xe,{})]},`sheets-filter-cell-fill-color-${a}`))})]}),o.length>1&&d.jsxs("div",{children:[d.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-text-color")}),d.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:o.map((s,a)=>d.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>i(s),children:[d.jsx("div",{className:"univer-box-border univer-flex univer-h-full univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]",children:d.jsx(Ye,{style:{color:s.color}})}),s.checked&&d.jsx(Xe,{})]},`sheets-filter-cell-text-color-${a}`))})]}),n.length<=1&&o.length<=1&&d.jsx("div",{className:"univer-flex univer-h-full univer-w-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:r.t("sheets-filter.panel.filter-by-color-none")})]})})}function Xe(){return d.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-h-3 univer-w-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:d.jsx(Ze,{className:"univer-h-full univer-w-full univer-font-bold univer-text-[#418F1F]"})})}function Lt(t){var S,C;const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.conditionItem$,void 0),o=E.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=I.useCallback(O=>{e.onConditionFormChange({and:O==="AND"})},[e]),s=Mt(r),a=I.useCallback(O=>{e.onPrimaryConditionChange(O)},[e]),h=$t(r),m=I.useCallback(O=>{e.onConditionFormChange(O)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function y(O,P,N){const L=f.getItemByOperator(O).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(b.RadioGroup,{value:l,onChange:i,children:[d.jsx(b.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(b.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(b.Select,{value:O,options:h,onChange:w=>m({[N]:w})}),L&&d.jsx("div",{children:d.jsx(b.Input,{className:"univer-mt-2",value:P,placeholder:p,onChange:w=>m({[N==="operator1"?"val1":"val2"]:w})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:n&&o&&d.jsxs(d.Fragment,{children:[d.jsx(b.Select,{value:n.operator,options:s,onChange:a}),f.getItemByOperator(n.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:b.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",b.borderClassName),children:[n.numOfParameters>=1&&y(o.operator1,(S=o.val1)!=null?S:"","operator1"),n.numOfParameters>=2&&y(o.operator2,(C=o.val2)!=null?C:"","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 Mt(t){const e=t.getCurrentLocale();return I.useMemo(()=>[{options:[{label:t.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:t.t(f.EMPTY.label),value:f.EMPTY.operator},{label:t.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:t.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:t.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:t.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:t.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:t.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:t.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:t.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:t.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:t.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:t.t(f.EQUAL.label),value:f.EQUAL.operator},{label:t.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:t.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:t.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:t.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,t])}function $t(t){const e=t.getCurrentLocale();return I.useMemo(()=>f.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Ut(t){const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.searchString$,"",!0),o=E.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Ie(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=I.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),p=I.useCallback(S=>{e.setSearchString(S)},[e]);function y(S){let C=[];return S.forEach(O=>{O.checked&&C.push(O.key),O.children&&(C=C.concat(y(O.children)))}),C}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[d.jsx(b.Input,{autoFocus:!0,value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.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",b.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(b.Checkbox,{indeterminate:a,disabled:o.length===0,checked:s,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(b.Tree,{data:o,defaultExpandAll:!1,valueGroup:y(o),onChange:S=>{e.onFilterCheckToggled(S)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
- univer-pr-2 univer-border-box univer-max-w-[245px] univer-rounded-md
1
+ (function(_,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("@univerjs/core"),require("@univerjs/sheets-filter"),require("@univerjs/sheets-ui"),require("@univerjs/ui"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("rxjs"),require("@univerjs/rpc"),require("@univerjs/design"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets-filter","@univerjs/sheets-ui","@univerjs/ui","@univerjs/engine-render","@univerjs/sheets","rxjs","@univerjs/rpc","@univerjs/design","react/jsx-runtime","react"],u):(_=typeof globalThis<"u"?globalThis:_||self,u(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverSheetsFilter,_.UniverSheetsUi,_.UniverUi,_.UniverEngineRender,_.UniverSheets,_.rxjs,_.UniverRpc,_.UniverDesign,_.React,_.React))})(this,function(_,u,c,$,E,K,F,g,pe,b,d,I){"use strict";var rr=Object.defineProperty;var ir=(_,u,c)=>u in _?rr(_,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):_[u]=c;var v=(_,u,c)=>ir(_,typeof u!="symbol"?u+"":u,c);var Oe;var A=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(A||{}),T=(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))(T||{}),f;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:T.NONE,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:i=>i.operator1===T.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:i=>!i.customFilters&&!i.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:T.EMPTY,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===T.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.val===""&&s.operator===void 0?{operator1:T.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:T.NOT_EMPTY,order:A.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:i})=>i===T.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 s=i.customFilters.customFilters[0];return s.val===" "&&s.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:T.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:T.CONTAINS,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.CONTAINS,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===T.CONTAINS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:`*${s}*`}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:T.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:T.DOES_NOT_CONTAIN,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:i=>{const[s]=x(i);return s===T.DOES_NOT_CONTAIN},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return s.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:T.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:T.STARTS_WITH,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.STARTS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`${i.val1}*`}]}}),testMappingParams:i=>{const[s]=x(i);return s===T.STARTS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:T.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:T.ENDS_WITH,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.ENDS_WITH,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:`*${i.val1}`}]}}),testMappingParams:i=>{const[s]=x(i);return s===T.ENDS_WITH},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0],a=s.val.toString();return!s.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:T.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:T.EQUALS,order:A.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:T.EQUALS,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===T.EQUALS},mapToFilterColumn:i=>{const{val1:s}=i;return s===""?null:{customFilters:{customFilters:[{val:s}]}}},testMappingFilterColumn:i=>{var s,a,h;return((a=(s=i.filters)==null?void 0:s.filters)==null?void 0:a.length)===1?{operator1:T.EQUALS,val1:""}:((h=i.customFilters)==null?void 0:h.customFilters.length)===1&&!i.customFilters.customFilters[0].operator?{operator1:T.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:i=>({customFilters:{customFilters:[{val:i.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:i=>{const[s]=x(i);return s===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:i=>{var a;if(((a=i.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.GREATER_THAN?!1:{operator1:c.CustomFilterOperator.GREATER_THAN,val1:s.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:s.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:c.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.LESS_THAN?!1:{operator1:c.CustomFilterOperator.LESS_THAN,val1:s.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:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:s.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:c.CustomFilterOperator.EQUAL,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.EQUAL?!1:{operator1:c.CustomFilterOperator.EQUAL,val1:s.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:c.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:A.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:i=>{const[s]=x(i);return s===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 s=i.customFilters.customFilters[0];return s.operator!==c.CustomFilterOperator.NOT_EQUALS?!1:{operator1:c.CustomFilterOperator.NOT_EQUALS,val1:s.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:T.BETWEEN,order:A.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:s,operator1:a,operator2:h}=i;if(!s)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:s,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?s:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:s,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[s,a]=i.customFilters.customFilters;return s.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:s.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&s.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:s.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:T.NOT_BETWEEN,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:i=>{const{and:s,operator1:a,operator2:h}=i;if(s)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:i=>{const{val1:s,val2:a,operator1:h}=i,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?s:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:s,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:i=>{var h;if(((h=i.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[s,a]=i.customFilters.customFilters;return s.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:s.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&s.operator===c.CustomFilterOperator.GREATER_THAN&&!i.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:s.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:T.CUSTOM,order:A.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:T.NONE,val1:"",operator2:T.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:i=>{const{and:s,val1:a,val2:h,operator1:m,operator2:p}=i;function y(L,w){for(const M of t.ALL_CONDITIONS)if(M.operator===L)return M.mapToFilterColumn({val1:w,operator1:L})}const S=!m||m===t.NONE.operator,C=!p||p===t.NONE.operator;if(S&&C)return t.NONE.mapToFilterColumn({});if(S)return y(p,h);if(C)return y(m,a);const O=y(m,a),P=y(p,h),N={customFilters:[O.customFilters.customFilters[0],P.customFilters.customFilters[0]]};return s&&(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 s=i.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:s[0][0].operator,val1:s[0][1].val1,operator2:s[1][0].operator,val2:s[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 s=t.ALL_CONDITIONS.find(a=>a.operator===i);if(!s)throw new Error(`[SheetsFilter]: no condition item found for operator: ${i}`);return s}t.getItemByOperator=e;function r(i,s){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===s))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 n(i){const s=t.ALL_CONDITIONS.find(a=>a.operator===i);return(s==null?void 0:s.numOfParameters)===0?{operator1:s.operator}:s.getDefaultFormParams()}t.getInitialFormParams=n;function o(i,s){return i.mapToFilterColumn(s)}t.mapToFilterColumn=o;function l(i){if(!i)return[t.NONE,{}];for(const s of t.ALL_CONDITIONS){const a=s.testMappingFilterColumn(i);if(a)return[s,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(f||(f={}));function x(t){const{operator1:e,operator2:r,val1:n,val2:o}=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,n]:[r,o]}function Ie(t){const e=[],r=[];let n=0,o=0;function l(i){i.leaf&&(i.checked?(e.push(i),n+=i.count):(r.push(i),o+=i.count)),i.children&&i.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:n,unchecked:o}}var rt=Object.getOwnPropertyDescriptor,it=(t,e,r,n)=>{for(var o=n>1?void 0:n?rt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Fe=(t,e)=>(r,n)=>e(r,n,t);const Ne="sheets-filter.generate-filter-values.service",fe=u.createIdentifier(Ne),nt=["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 be=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var p;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:n,filterColumn:o,filters:l,blankChecked:i,iterateRange:s,alreadyChecked:a}=t,h=this._univerInstanceService.getUnit(e),m=(p=this._univerInstanceService.getUnit(e))==null?void 0:p.getSheetBySheetId(r);return!h||!m?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),ke(l,this._localeService,s,m,new Set(n),o,new Set(a.map(String)),i,h.getStyles()))}};be=it([Fe(0,u.Inject(u.LocaleService)),Fe(1,u.IUniverInstanceService),Fe(2,u.ILogService)],be);function ke(t,e,r,n,o,l,i,s,a){var N,L,w,M,B,X,ne,oe,V,D;const h=new Map,m=new Map,p="yyyy-mm-dd",y=new Set(nt),S="empty",C=!t&&((l==null?void 0:l.filterBy)===c.FilterBy.COLORS||(l==null?void 0:l.filterBy)===c.FilterBy.CONDITIONS)&&((N=l.filteredOutRows)==null?void 0:N.size);let O=0;for(const H of n.iterateByColumn(r,!1,!1)){const{row:Jt,rowSpan:tt=1}=H;let se=0;for(;se<tt;){const er=Jt+se;if(o.has(er)){se++;continue}const z=H!=null&&H.value?u.extractPureTextFromCell(H.value):"";if(!z){O+=1,se+=tt;continue}const ye=(L=H.value)!=null&&L.v&&!H.value.p?(B=(M=a.get((w=H.value)==null?void 0:w.s))==null?void 0:M.n)==null?void 0:B.pattern:"",tr=ye&&u.numfmt.getFormatInfo(ye).isDate;if(ye&&tr&&y.has(ye)){const q=(X=n.getCellRaw(H.row,H.col))==null?void 0:X.v;if(!q){se++;continue}const ae=u.numfmt.format(p,q),[R,W,me]=ae.split("-").map(Number);let J=h.get(`${R}`);J||(J={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},h.set(`${R}`,J),m.set(`${R}`,[`${R}`]));let Q=(ne=J.children)==null?void 0:ne.find(Ue=>Ue.key===`${R}-${W}`);Q||(Q={title:e.t(`sheets-filter.date.${W}`),key:`${R}-${W}`,children:[],count:0,leaf:!1,checked:!1},(oe=J.children)==null||oe.push(Q),m.set(`${R}-${W}`,[`${R}`,`${R}-${W}`]));const $e=(V=Q==null?void 0:Q.children)==null?void 0:V.find(Ue=>Ue.key===`${R}-${W}-${me}`);$e?($e.originValues.add(z),$e.count++,Q.count++,J.count++):((D=Q.children)==null||D.push({title:`${me}`,key:`${R}-${W}-${me}`,count:1,originValues:new Set([z]),leaf:!0,checked:C?!1:i.size?i.has(z):!s}),Q.count++,J.count++,m.set(`${R}-${W}-${me}`,[`${R}`,`${R}-${W}`,`${R}-${W}-${me}`]))}else{const q=z;let ae=h.get(q);ae?ae.count++:(ae={title:z,leaf:!0,checked:C?!1:i.size?i.has(z):!s,key:q,count:1},h.set(q,ae),m.set(q,[q]))}se++}}const P=C?!1:t?s:!0;if(O>0){const H={title:e.t("sheets-filter.panel.empty"),count:O,leaf:!0,checked:P,key:S};h.set("empty",H),m.set("empty",[S])}return{filterTreeItems:ot(Array.from(h.values())),filterTreeMapCache:m}}function ot(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:st(e.title,r.title)).map(e=>(e.children&&e.children.sort((r,n)=>{const o=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(n.key.split("-")[1],10);return o-l}).forEach(r=>{r.children&&r.children.sort((n,o)=>{const l=Number.parseInt(n.key.split("-")[2],10),i=Number.parseInt(o.key.split("-")[2],10);return l-i})}),e))}const Be=t=>!Number.isNaN(Number(t))&&!Number.isNaN(Number.parseFloat(t));function st(t,e){const r=Be(t),n=Be(e);return r&&n?Number.parseFloat(t)-Number.parseFloat(e):r&&!n?-1:!r&&n?1:t.localeCompare(e)}function Pe(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const n=Pe(r.children,e);if(n)return n}}return null}function De(t){return t.leaf?t.checked:t.children?t.children.every(e=>De(e)):!0}function le(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>le(r,e))}function He(t,e){const r=[];return t.forEach(n=>{const o=n.originValues?e.some(s=>Array.from(n.originValues).some(a=>a.toLowerCase().includes(s.toLowerCase()))):!1,l=!o&&e.some(s=>n.title.toLowerCase().includes(s.toLowerCase()));if(o||l)r.push({...n});else if(n.children){const s=He(n.children,e);if(s.length>0){const a=s.reduce((h,m)=>h+m.count,0);r.push({...n,count:a,children:s})}}}),r}var at=Object.getOwnPropertyDescriptor,ve=(t,e,r,n)=>{for(var o=n>1?void 0:n?at(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},ce=(t,e)=>(r,n)=>e(r,n,t);u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends u.Disposable{constructor(e,r){super();v(this,"_filterBy$",new g.BehaviorSubject(c.FilterBy.VALUES));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new g.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new g.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new g.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 n=e.getFilterColumn(r);if(n){const o=n.getColumnData();if(o.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(o.colorFilters){this._hasCriteria$.next(!0),this._setupByColors(e,r);return}if(o.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){if(!this._filterModel||this.col===-1)return!1;switch(e){case c.FilterBy.VALUES:this._setupByValues(this._filterModel,this.col);break;case c.FilterBy.COLORS:this._setupByColors(this._filterModel,this.col);break;case c.FilterBy.CONDITIONS:this._setupByConditions(this._filterModel,this.col);break}return!0}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const n=e.unitId,o=e.subUnitId,l=e.getRange(),i={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(n,o,i,(s,a)=>{if(!a)this.terminate();else{const h=a.startColumn-s.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await ge.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(c.FilterBy.VALUES),this._listenToFilterHeaderChange(e,r),!0}async _setupByColors(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=o,this._filterBy$.next(c.FilterBy.COLORS),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const n=e.getRange();if(n.startRow===n.endRow)return!1;const o=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=o,this._filterBy$.next(c.FilterBy.CONDITIONS),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=ve([ce(0,u.Inject(u.Injector)),ce(1,u.Inject(F.RefRangeService))],G);let _e=class extends u.Disposable{constructor(e,r,n,o,l){super();v(this,"canApply$",g.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 g.BehaviorSubject(n),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(o),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,n,o){const[l,i]=f.testMappingFilterColumn(o==null?void 0:o.getColumnData());return e.createInstance(_e,r,n,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=f.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=f.ALL_CONDITIONS.find(n=>n.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(f.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 n=f.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(n)}this._filterConditionFormParams$.next(r)}};_e=ve([ce(4,u.ICommandService)],_e);let ge=class extends u.Disposable{constructor(e,r,n,o,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=o,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(n),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new g.Subject,this.filterItems$=g.merge(g.combineLatest([this._searchString$.pipe(g.throttleTime(500,void 0,{leading:!0,trailing:!0}),g.startWith(void 0)),this._rawFilterItems$]).pipe(g.map(([i,s])=>{if(!i)return s;const h=i.toLowerCase().split(/\s+/).filter(m=>!!m);return He(s,h)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(i=>Ie(i).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(i=>this._filterItems=i))}static async fromFilterColumn(e,r,n){const o=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),i=e.get(fe,u.Quantity.OPTIONAL),{unitId:s,subUnitId:a}=r,h=o.getUniverSheetInstance(s);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${s}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${s} and subUnitId: ${a}!`);const p=r.getRange(),y=n,S=r.getFilterColumn(n),C=S==null?void 0:S.getColumnData().filters,O=new Set(C==null?void 0:C.filters),P=!!(C&&C.blank),N=r.getFilteredOutRowsExceptCol(n),L={...p,startRow:p.startRow+1,startColumn:y,endColumn:y};let w,M;if(i){const B=await i.getFilterValues({unitId:s,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(N),filterColumn:S,filters:!!C,blankChecked:P,iterateRange:L,alreadyChecked:Array.from(O)});w=B.filterTreeItems,M=B.filterTreeMapCache}else{const B=ke(!!C,l,L,m,N,S,O,P,h.getStyles());w=B.filterTreeItems,M=B.filterTreeMapCache}return e.createInstance(ge,r,n,w,M)}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(n=>le(n,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),n=Pe(r,e.key);if(!n)return;const o=De(n);le(n,!o),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(n=>le(n,!1)),e.forEach(n=>{const o=Pe(r,n);o&&le(o,!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=Ie(this._filterItems),{checked:r,checkedItems:n}=e,o=this.rawFilterItems;let l=0;for(const h of o)l+=h.count;const i=r===0,s=e.checked===l,a={colId:this.col};if(i)throw new Error("[ByValuesModel]: no checked items!");if(s)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=n.filter(p=>p.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(p=>p.originValues?Array.from(p.originValues):[p.title])}),h.length!==n.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})}};ge=ve([ce(4,u.ICommandService)],ge);let Se=class extends u.Disposable{constructor(e,r,n,o,l){super();v(this,"canApply$",g.of(!0));v(this,"_cellFillColors$");v(this,"cellFillColors$");v(this,"_cellTextColors$");v(this,"cellTextColors$");this._filterModel=e,this.col=r,this._commandService=l,this._cellFillColors$=new g.BehaviorSubject(Array.from(n.values())),this.cellFillColors$=this._cellFillColors$.asObservable(),this._cellTextColors$=new g.BehaviorSubject(Array.from(o.values())),this.cellTextColors$=this._cellTextColors$.asObservable()}static async fromFilterColumn(e,r,n){var L,w,M;const o=e.get(u.IUniverInstanceService),{unitId:l,subUnitId:i}=r,s=o.getUniverSheetInstance(l);if(!s)throw new Error(`[ByColorsModel]: Workbook not found for filter model with unitId: ${l}!`);const a=s==null?void 0:s.getSheetBySheetId(i);if(!a)throw new Error(`[ByColorsModel]: Worksheet not found for filter model with unitId: ${l} and subUnitId: ${i}!`);const h=r.getRange(),m=n,p=(L=r.getFilterColumn(n))==null?void 0:L.getColumnData().colorFilters,y=r.getFilteredOutRowsExceptCol(n),S={...h,startRow:h.startRow+1,startColumn:m,endColumn:m},C=new Map,O=new Set((w=p==null?void 0:p.cellFillColors)!=null?w:[]),P=new Map,N=new Set((M=p==null?void 0:p.cellTextColors)!=null?M:[]);for(const B of a.iterateByColumn(S,!1,!0)){const{row:X,col:ne,value:oe}=B;if(y.has(X))continue;const V=a.getComposedCellStyleByCellData(X,ne,oe);if(V.bg&&V.bg.rgb){const D=new u.ColorKit(V.bg.rgb).toRgbString();C.has(D)||C.set(D,{color:D,checked:O.has(D)})}else C.set("default-fill-color",{color:null,checked:O.has(null)});if(V.cl&&V.cl.rgb){const D=new u.ColorKit(V.cl.rgb).toRgbString();P.has(D)||P.set(D,{color:D,checked:N.has(D)})}else P.set("default-font-color",{color:K.COLOR_BLACK_RGB,checked:N.has(K.COLOR_BLACK_RGB)})}return e.createInstance(Se,r,n,C,P)}get cellFillColors(){return this._cellFillColors$.getValue()}get cellTextColors(){return this._cellTextColors$.getValue()}dispose(){super.dispose(),this._cellFillColors$.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})}onFilterCheckToggled(e,r=!0){const n=r?this.cellFillColors:this.cellTextColors,o=[];let l=!1;for(let i=0;i<n.length;i++){const s=n[i];if(s.color===e.color){l=!0,o.push({color:s.color,checked:!s.checked});continue}o.push({color:s.color,checked:s.checked})}l&&(this._resetColorsCheckedStatus(!r),r?this._cellFillColors$.next([...o]):this._cellTextColors$.next([...o]))}_resetColorsCheckedStatus(e=!0){const r=e?this.cellFillColors:this.cellTextColors,n=[];for(let o=0;o<r.length;o++)n.push({color:r[o].color,checked:!1});e?this._cellFillColors$.next([...n]):this._cellTextColors$.next([...n])}async apply(){if(this._disposed)return!1;const e=this.cellFillColors.filter(o=>o.checked).map(o=>o.color),r=this.cellTextColors.filter(o=>o.checked).map(o=>o.color);if(e.length===0&&r.length===0)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});const n={colId:this.col};return e.length>0?n.colorFilters={cellFillColors:e}:r.length>0&&(n.colorFilters={cellTextColors:r}),this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:n})}};Se=ve([ce(4,u.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",ue={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),n=t.get(c.SheetsFilterService),o=t.get(G);t.get(u.ICommandService).syncExecuteCommand($.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:i,subUnitId:s,col:a}=e,h=n.getFilterModel(i,s);return h?(o.setupCol(h,a),r.getContextValue(ee)||r.setContextValue(ee,!0),!0):!1}},te={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(G),n=t.get(E.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),n==null||n.focus(),r.terminate()):!1}},Ae={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}},xe="sheets-filter-ui.config",Ce={};var lt=Object.getOwnPropertyDescriptor,ct=(t,e,r,n)=>{for(var o=n>1?void 0:n?lt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},re=(t,e)=>(r,n)=>e(r,n,t);let ie=class extends u.Disposable{constructor(t,e,r,n,o,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=n,this._injector=o,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,n;if(t.id===c.SmartToggleSheetsFilterCommand.id){const o=this._injector.get(u.IUniverInstanceService),l=F.getSheetCommandTarget(o);if(!l)return;const{unitId:i,subUnitId:s,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(i,s))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission]},[h]);else{const p=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(p){let y={...p};y=p.startColumn===p.endColumn&&p.startRow===p.endRow?F.expandToContinuousRange(y,{left:!0,right:!0,up:!0,down:!0},a):y,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetViewPermission,F.WorksheetFilterPermission]},[y],i,s)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetViewPermission,F.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ue.id){const o=t.params,{unitId:l,subUnitId:i}=o,s=(n=this._sheetsFilterService.getFilterModel(l,i))==null?void 0:n.getRange(),a=u.Tools.deepClone(s);a&&(a.startColumn=o.col,a.endColumn=o.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[F.RangeProtectionPermissionViewPoint],worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};ie=ct([re(0,u.Inject(c.SheetsFilterService)),re(1,u.Inject(u.LocaleService)),re(2,u.ICommandService),re(3,u.Inject(F.SheetPermissionCheckController)),re(4,u.Inject(u.Injector)),re(5,u.Inject(F.SheetsSelectionsService))],ie);const Y=16,ut=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,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:o}),e.lineCap="square",e.strokeStyle=n,e.scale(r/Y,r/Y),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,n,o){e.save(),K.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:o}),e.scale(r/Y,r/Y),e.fillStyle=n,e.fill(ut),e.restore()}}var ht=Object.getOwnPropertyDescriptor,dt=(t,e,r,n)=>{for(var o=n>1?void 0:n?ht(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},we=(t,e)=>(r,n)=>e(r,n,t);const j=16,Te=1;let Re=class extends K.Shape{constructor(e,r,n,o,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=n,this._commandService=o,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,n=this._cellWidth,o=j-n,l=j-r;e.save();const i=new Path2D;i.rect(o,l,n,r),e.clip(i);const{hasCriteria:s}=this._filterParams,a=this._themeService.getColorFromTheme("primary.600"),h=this._hovered?this._themeService.getColorFromTheme("gray.50"):"rgba(255, 255, 255, 1.0)";s?We.drawHasCriteria(e,j,a,h):We.drawNoCriteria(e,j,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:n,subUnitId:o}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(ue.id)||setTimeout(()=>{this._commandService.executeCommand(ue.id,{unitId:n,subUnitId:o,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Re=dt([we(2,u.IContextService),we(3,u.ICommandService),we(4,u.Inject(u.ThemeService))],Re);var mt=Object.getOwnPropertyDescriptor,pt=(t,e,r,n)=>{for(var o=n>1?void 0:n?mt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Z=(t,e)=>(r,n)=>e(r,n,t);const ft=1e3,vt=5e3;let Le=class extends u.RxDisposable{constructor(e,r,n,o,l,i,s,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=n,this._sheetsFilterService=o,this._themeService=l,this._sheetInterceptorService=i,this._commandService=s,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var s,a;if(!e)return g.of(null);const{unit:r,unitId:n}=this._context,o=((s=r.getActiveSheet())==null?void 0:s.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(n,o))!=null?a:void 0,i=()=>({unitId:n,worksheetId:o,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return u.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(g.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===F.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(i),g.startWith(i()))}),g.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:n}=this._context,{rowHeaderWidth:o,columnHeaderHeight:l}=r,i=this._filterRangeShape=new $.SelectionControl(n,ft,this._themeService,{rowHeaderWidth:o,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),s={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=$.attachSelectionWithCoord(s,r);i.updateRangeBySelectionWithCoord(a),i.setEvent(!1),n.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:n,unitId:o,skeleton:l,worksheetId:i}=e,{scene:s}=this._context;this._interceptCellContent(o,i,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let p=a;p<=h;p++){const y=`sheets-filter-button-${p}`,S=$.getCoordByCell(m,p,s,l),{startX:C,startY:O,endX:P,endY:N}=S,L=P-C,w=N-O;if(w<=Te||L<=Te)continue;const M=!!n.getFilterColumn(p),B=P-j-Te,X=N-j-Te,ne={left:B,top:X,height:j,width:j,zIndex:vt,cellHeight:w,cellWidth:L,filterParams:{unitId:o,subUnitId:i,col:p,hasCriteria:M}},oe=this._injector.createInstance(Re,y,ne);this._filterButtonShapes.push(oe)}s.addObjects(this._filterButtonShapes),s.makeDirty()}_interceptCellContent(e,r,n){const{startRow:o,startColumn:l,endColumn:i}=n;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(F.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(s,a,h)=>{const{row:m,col:p,unitId:y,subUnitId:S}=a;return y!==e||S!==r||m!==o||p<l||p>i||((!s||s===a.rawData)&&(s={...a.rawData}),s.fontRenderExtension={...s==null?void 0:s.fontRenderExtension,rightOffset:j}),h(s)},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(n=>n.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Le=pt([Z(1,u.Inject(u.Injector)),Z(2,u.Inject($.SheetSkeletonManagerService)),Z(3,u.Inject(c.SheetsFilterService)),Z(4,u.Inject(u.ThemeService)),Z(5,u.Inject(F.SheetInterceptorService)),Z(6,u.ICommandService),Z(7,$.ISheetSelectionRenderService)],Le);var _t=Object.getOwnPropertyDescriptor,gt=(t,e,r,n)=>{for(var o=n>1?void 0:n?_t(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},je=(t,e)=>(r,n)=>e(r,n,t);let he=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,[Le]))}};he=gt([je(0,K.IRenderManagerService),je(1,u.Inject($.SheetsRenderService))],he);var St=Object.defineProperty,Ct=Object.getOwnPropertyDescriptor,Tt=(t,e,r)=>e in t?St(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Et=(t,e,r,n)=>{for(var o=n>1?void 0:n?Ct(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Ve=(t,e)=>(r,n)=>e(r,n,t),Qe=(t,e,r)=>Tt(t,typeof e!="symbol"?e+"":e,r);const Ot="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=Ce,r,n){super(),this._config=e,this._injector=r,this._configService=n;const{menu:o,...l}=u.merge({},Ce,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(xe,l)}onStarting(){[[ie],[he]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(ie)}onRendered(){this._injector.get(he)}},Qe(_.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Qe(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Ot),_.UniverSheetsFilterMobileUIPlugin=Et([u.DependentOn(c.UniverSheetsFilterPlugin),Ve(1,u.Inject(u.Injector)),Ve(2,u.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var k=function(){return k=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++){e=arguments[r];for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])}return t},k.apply(this,arguments)},yt=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var o=0,n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]]);return r},de=I.forwardRef(function(t,e){var r=t.icon,n=t.id,o=t.className,l=t.extend,i=yt(t,["icon","id","className","extend"]),s="univerjs-icon univerjs-icon-".concat(n," ").concat(o||"").trim(),a=I.useRef("_".concat(Nt()));return Ge(r,"".concat(n),{defIds:r.defIds,idSuffix:a.current},k({ref:e,className:s},i),l)});function Ge(t,e,r,n,o){return I.createElement(t.tag,k(k({key:e},It(t,r,o)),n),(Ft(t,r).children||[]).map(function(l,i){return Ge(l,"".concat(e,"-").concat(t.tag,"-").concat(i),r,void 0,o)}))}function It(t,e,r){var n=k({},t.attrs);r!=null&&r.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=r.colorChannel1),t.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];i==="mask"&&typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var o=e.defIds;return!o||o.length===0||(t.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(function(l){var i=l[0],s=l[1];typeof s=="string"&&(n[i]=s.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),n}function Ft(t,e){var r,n=e.defIds;return!n||n.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?k(k({},t),{children:t.children.map(function(o){return typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?k(k({},o),{attrs:k(k({},o.attrs),{id:o.attrs.id+e.idSuffix})}):o})}):t}function Nt(){return Math.random().toString(36).substring(2,8)}de.displayName="UniverIcon";var bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M10 1.05957C10.356 1.05957 10.6816 1.26162 10.8408 1.58008L18.8408 17.5801L18.8799 17.668C19.0486 18.1134 18.8551 18.6232 18.4199 18.8408C17.9557 19.0727 17.3913 18.8841 17.1592 18.4199L10 4.10156L2.84082 18.4199C2.60871 18.8841 2.04434 19.0727 1.58008 18.8408C1.11587 18.6087 0.92731 18.0443 1.15918 17.5801L9.15918 1.58008C9.31841 1.26162 9.64395 1.05957 10 1.05957Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M15.3337 11.7261L15.4294 11.731C15.9035 11.779 16.2732 12.1798 16.2732 12.6665C16.2732 13.1532 15.9035 13.554 15.4294 13.602L15.3337 13.6069H4.66675C4.1476 13.6069 3.72632 13.1856 3.72632 12.6665C3.72632 12.1474 4.1476 11.7261 4.66675 11.7261H15.3337Z"}}]},Ye=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"a-icon",ref:e,icon:bt}))});Ye.displayName="AIcon";var Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 20 20",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M17.0596 10C17.0596 6.10087 13.8992 2.94043 10 2.94043C6.10087 2.94043 2.94043 6.10087 2.94043 10C2.94043 13.8992 6.10087 17.0596 10 17.0596C13.8992 17.0596 17.0596 13.8992 17.0596 10ZM18.9404 10C18.9404 14.9374 14.9374 18.9404 10 18.9404C5.06257 18.9404 1.05957 14.9374 1.05957 10C1.05957 5.06257 5.06257 1.05957 10 1.05957C14.9374 1.05957 18.9404 5.06257 18.9404 10Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.29492 4.13476C4.63911 3.79057 5.1845 3.76906 5.55371 4.07031L5.625 4.13476L16.0244 14.5352L16.0889 14.6064C16.3902 14.9757 16.3686 15.52 16.0244 15.8643C15.6573 16.2313 15.0624 16.2313 14.6953 15.8643L4.29492 5.46484L4.23047 5.39355C3.92922 5.02434 3.95073 4.47895 4.29492 4.13476Z"}}]},qe=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"ban-icon",ref:e,icon:Pt}))});qe.displayName="BanIcon";var At={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"}}]},Ke=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"filter-icon",ref:e,icon:At}))});Ke.displayName="FilterIcon";var wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8 15C11.866 15 15 11.866 15 8C15 4.13401 11.866 1 8 1C4.13401 1 1 4.13401 1 8C1 11.866 4.13401 15 8 15ZM11.7245 6.42417C11.9588 6.18985 11.9588 5.80995 11.7245 5.57564C11.4901 5.34132 11.1102 5.34132 10.8759 5.57564L7.3002 9.15137L5.72446 7.57564C5.49014 7.34132 5.11025 7.34132 4.87593 7.57564C4.64162 7.80995 4.64162 8.18985 4.87593 8.42417L6.87593 10.4242C7.11025 10.6585 7.49014 10.6585 7.72446 10.4242L11.7245 6.42417Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ze=I.forwardRef(function(t,e){return I.createElement(de,Object.assign({},t,{id:"success-icon",ref:e,icon:wt}))});Ze.displayName="SuccessIcon";function Rt(t){const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.cellFillColors$,[],!0),o=E.useObservable(e.cellTextColors$,[],!0),l=I.useCallback(s=>{e.onFilterCheckToggled(s)},[e]),i=I.useCallback(s=>{e.onFilterCheckToggled(s,!1)},[e]);return d.jsx("div",{"data-u-comp":"sheets-filter-panel-colors-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.clsx("univer-mt-2 univer-box-border univer-flex univer-h-[300px] univer-flex-grow univer-flex-col univer-gap-4 univer-overflow-auto univer-rounded-md univer-px-2 univer-py-2.5",b.borderClassName),children:[n.length>1&&d.jsxs("div",{children:[d.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-fill-color")}),d.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:n.map((s,a)=>d.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>l(s),children:[s.color?d.jsx("button",{type:"button",className:b.clsx("univer-box-border univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full univer-border univer-border-solid univer-border-transparent univer-bg-gray-300 univer-transition-shadow hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"),style:{backgroundColor:s.color}}):d.jsx(qe,{className:"univer-h-6 univer-w-6 univer-cursor-pointer univer-rounded-full hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white"}),s.checked&&d.jsx(Xe,{})]},`sheets-filter-cell-fill-color-${a}`))})]}),o.length>1&&d.jsxs("div",{children:[d.jsx("div",{className:"univer-mb-2 univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:r.t("sheets-filter.panel.filter-by-cell-text-color")}),d.jsx("div",{className:"univer-grid univer-grid-cols-8 univer-items-center univer-justify-start univer-gap-2",children:o.map((s,a)=>d.jsxs("div",{className:"univer-relative univer-h-6 univer-w-6",onClick:()=>i(s),children:[d.jsx("div",{className:"univer-box-border univer-flex univer-h-full univer-w-full univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-border univer-border-solid univer-border-[rgba(13,13,13,0.06)] univer-p-0.5 hover:univer-ring-2 hover:univer-ring-offset-2 hover:univer-ring-offset-white dark:!univer-border-[rgba(255,255,255,0.06)]",children:d.jsx(Ye,{style:{color:s.color}})}),s.checked&&d.jsx(Xe,{})]},`sheets-filter-cell-text-color-${a}`))})]}),n.length<=1&&o.length<=1&&d.jsx("div",{className:"univer-flex univer-h-full univer-w-full univer-items-center univer-justify-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-200",children:r.t("sheets-filter.panel.filter-by-color-none")})]})})}function Xe(){return d.jsx("div",{className:"univer-absolute -univer-bottom-0.5 -univer-right-0.5 univer-flex univer-h-3 univer-w-3 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded-full univer-bg-white",children:d.jsx(Ze,{className:"univer-h-full univer-w-full univer-font-bold univer-text-[#418F1F]"})})}function Lt(t){var S,C;const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.conditionItem$,void 0),o=E.useObservable(e.filterConditionFormParams$,void 0),l=o!=null&&o.and?"AND":"OR",i=I.useCallback(O=>{e.onConditionFormChange({and:O==="AND"})},[e]),s=Mt(r),a=I.useCallback(O=>{e.onPrimaryConditionChange(O)},[e]),h=$t(r),m=I.useCallback(O=>{e.onConditionFormChange(O)},[e]),p=r.t("sheets-filter.panel.input-values-placeholder");function y(O,P,N){const L=f.getItemByOperator(O).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(b.RadioGroup,{value:l,onChange:i,children:[d.jsx(b.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(b.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(b.Select,{value:O,options:h,onChange:w=>m({[N]:w})}),L&&d.jsx("div",{children:d.jsx(b.Input,{className:"univer-mt-2",value:P,placeholder:p,onChange:w=>m({[N==="operator1"?"val1":"val2"]:w})})})]})}return d.jsx("div",{"data-u-comp":"sheets-filter-panel-conditions-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:n&&o&&d.jsxs(d.Fragment,{children:[d.jsx(b.Select,{value:n.operator,options:s,onChange:a}),f.getItemByOperator(n.operator).numOfParameters!==0?d.jsxs("div",{"data-u-comp":"sheets-filter-panel-conditions-container-inner",className:b.clsx("univer-mt-2 univer-flex-grow univer-overflow-hidden univer-rounded-md univer-p-2",b.borderClassName),children:[n.numOfParameters>=1&&y(o.operator1,(S=o.val1)!=null?S:"","operator1"),n.numOfParameters>=2&&y(o.operator2,(C=o.val2)!=null?C:"","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 Mt(t){const e=t.getCurrentLocale();return I.useMemo(()=>[{options:[{label:t.t(f.NONE.label),value:f.NONE.operator}]},{options:[{label:t.t(f.EMPTY.label),value:f.EMPTY.operator},{label:t.t(f.NOT_EMPTY.label),value:f.NOT_EMPTY.operator}]},{options:[{label:t.t(f.TEXT_CONTAINS.label),value:f.TEXT_CONTAINS.operator},{label:t.t(f.DOES_NOT_CONTAIN.label),value:f.DOES_NOT_CONTAIN.operator},{label:t.t(f.STARTS_WITH.label),value:f.STARTS_WITH.operator},{label:t.t(f.ENDS_WITH.label),value:f.ENDS_WITH.operator},{label:t.t(f.EQUALS.label),value:f.EQUALS.operator}]},{options:[{label:t.t(f.GREATER_THAN.label),value:f.GREATER_THAN.operator},{label:t.t(f.GREATER_THAN_OR_EQUAL.label),value:f.GREATER_THAN_OR_EQUAL.operator},{label:t.t(f.LESS_THAN.label),value:f.LESS_THAN.operator},{label:t.t(f.LESS_THAN_OR_EQUAL.label),value:f.LESS_THAN_OR_EQUAL.operator},{label:t.t(f.EQUAL.label),value:f.EQUAL.operator},{label:t.t(f.NOT_EQUAL.label),value:f.NOT_EQUAL.operator},{label:t.t(f.BETWEEN.label),value:f.BETWEEN.operator},{label:t.t(f.NOT_BETWEEN.label),value:f.NOT_BETWEEN.operator}]},{options:[{label:t.t(f.CUSTOM.label),value:f.CUSTOM.operator}]}],[e,t])}function $t(t){const e=t.getCurrentLocale();return I.useMemo(()=>f.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function Ut(t){const{model:e}=t,r=E.useDependency(u.LocaleService),n=E.useObservable(e.searchString$,"",!0),o=E.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),i=Ie(o),s=i.checked>0&&i.unchecked===0,a=i.checked>0&&i.unchecked>0,h=e.treeMapCache,m=I.useCallback(()=>{e.onCheckAllToggled(!s)},[e,s]),p=I.useCallback(S=>{e.setSearchString(S)},[e]);function y(S){let C=[];return S.forEach(O=>{O.checked&&C.push(O.key),O.children&&(C=C.concat(y(O.children)))}),C}return d.jsxs("div",{"data-u-comp":"sheets-filter-panel-values-container",className:"univer-flex univer-h-full univer-min-h-[300px] univer-flex-col",children:[d.jsx(b.Input,{autoFocus:!0,value:n,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:p}),d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:b.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",b.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(b.Checkbox,{indeterminate:a,disabled:o.length===0,checked:s,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(b.Tree,{data:o,defaultExpandAll:!1,valueGroup:y(o),onChange:S=>{e.onFilterCheckToggled(S)},defaultCache:h,itemHeight:28,treeNodeClassName:`
2
+ univer-pr-2 univer-border-box 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:S=>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:`(${S.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const C=[];S.children?S.children.forEach(O=>{O.children?O.children.forEach(P=>{C.push(P.key)}):C.push(O.key)}):C.push(S.key),e.onFilterOnly(C)},children:l})]})})})]})]})}function kt(){var P;const t=E.useDependency(G),e=E.useDependency(u.LocaleService),r=E.useDependency(u.ICommandService),n=E.useObservable(t.filterBy$,void 0,!0),o=E.useObservable(t.filterByModel$,void 0,!1),l=E.useObservable(()=>(o==null?void 0:o.canApply$)||g.of(!1),void 0,!1,[o]),i=Bt(e),s=!E.useObservable(t.hasCriteria$),a=I.useCallback(N=>{r.executeCommand(Ae.id,{filterBy:N})},[r]),h=I.useCallback(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(te.id)},[o,r]),m=I.useCallback(()=>{r.executeCommand(te.id)},[r]),p=I.useCallback(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(te.id)},[o,r]),S=(P=E.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:P.getRange(),C=t.col,O=E.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",children:[d.jsx(E.ComponentContainer,{components:O,sharedProps:{range:S,colIndex:C,onClose:m}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(b.Segmented,{value:n,items:i,onChange:N=>a(N)})}),o?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:n===c.FilterBy.VALUES?d.jsx(Ut,{model:o}):n===c.FilterBy.COLORS?d.jsx(Rt,{model:o}):d.jsx(Lt,{model:o})}):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(b.Button,{variant:"link",onClick:h,disabled:s,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(b.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(b.Button,{disabled:!l,variant:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Bt(t){const e=t.getCurrentLocale();return I.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:c.FilterBy.VALUES},{label:t.t("sheets-filter.panel.by-colors"),value:c.FilterBy.COLORS},{label:t.t("sheets-filter.panel.by-conditions"),value:c.FilterBy.CONDITIONS}],[e,t])}function Dt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:E.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission],rangeTypes:[F.RangeProtectionPermissionViewPoint]}))}}function xt(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(g.map(o=>!o)))!=null?n:g.of(!0)}))}}function Ht(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(g.map(o=>!o)))!=null?n:g.of(!0)}))}}const Wt={[E.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:Dt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:xt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ht}}}},jt={id:c.SmartToggleSheetsFilterCommand.id,binding:E.KeyCode.L|E.MetaKeys.CTRL_COMMAND|E.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var Vt=Object.getOwnPropertyDescriptor,Qt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},U=(t,e)=>(r,n)=>e(r,n,t);const ze="FILTER_PANEL_POPUP";let Ee=class extends he{constructor(e,r,n,o,l,i,s,a,h,m,p,y,S){super(S,y);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=o,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=s,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=p,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[jt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Ae,ue,te].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Wt)}_initUI(){[[ze,kt],["FilterIcon",Ke]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(ee).pipe(g.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:b.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(),n=this._sheetsFilterPanelService.col,{startRow:o}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(o,n,{componentKey:ze,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(te.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};Ee=Qt([U(0,u.Inject(u.Injector)),U(1,u.Inject(E.ComponentManager)),U(2,u.Inject(G)),U(3,u.Inject($.SheetCanvasPopManagerService)),U(4,u.Inject(c.SheetsFilterService)),U(5,u.Inject(u.LocaleService)),U(6,E.IShortcutService),U(7,u.ICommandService),U(8,E.IMenuManagerService),U(9,u.IContextService),U(10,E.IMessageService),U(11,u.Inject($.SheetsRenderService)),U(12,K.IRenderManagerService)],Ee);var Gt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,qt=(t,e,r)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Yt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Me=(t,e)=>(r,n)=>e(r,n,t),Je=(t,e,r)=>qt(t,typeof e!="symbol"?e+"":e,r);const Zt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=Ce,r,n,o){super(),this._config=e,this._injector=r,this._configService=n,this._rpcChannelService=o;const{menu:l,...i}=u.merge({},Ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(He,i)}onStarting(){u.registerDependencies(this._injector,[[G],[ie],[Ee]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([fe,{useFactory:()=>pe.toModule(this._rpcChannelService.requestChannel(Ne))}])}onReady(){u.touchDependencies(this._injector,[[ie]])}onRendered(){u.touchDependencies(this._injector,[[Ee]])}},Je(_.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Je(_.UniverSheetsFilterUIPlugin,"pluginName",Zt),_.UniverSheetsFilterUIPlugin=Kt([u.DependentOn(c.UniverSheetsFilterPlugin),Me(1,u.Inject(u.Injector)),Me(2,u.IConfigService),Me(3,u.Optional(pe.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var Xt=Object.getOwnPropertyDescriptor,zt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Xt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},et=(t,e)=>(r,n)=>e(r,n,t);_.UniverSheetsFilterUIWorkerPlugin=(Oe=class extends u.Plugin{constructor(e,r,n){super(),this._config=e,this._injector=r,this._rpcChannelService=n}onStarting(){[[fe,{useClass:be}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ne,pe.fromModule(this._injector.get(fe)))}},v(Oe,"type",u.UniverInstanceType.UNIVER_SHEET),v(Oe,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),Oe),_.UniverSheetsFilterUIWorkerPlugin=zt([et(1,u.Inject(u.Injector)),et(2,pe.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ae,_.CloseFilterPanelOperation=te,_.OpenFilterPanelOperation=ue,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
7
+ `,attachRender:S=>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:`(${S.count})`}),d.jsx("a",{className:"univer-box-border univer-hidden univer-h-4 univer-whitespace-nowrap univer-px-1.5",onClick:()=>{const C=[];S.children?S.children.forEach(O=>{O.children?O.children.forEach(P=>{C.push(P.key)}):C.push(O.key)}):C.push(S.key),e.onFilterOnly(C)},children:l})]})})})]})]})}function kt(){var P;const t=E.useDependency(G),e=E.useDependency(u.LocaleService),r=E.useDependency(u.ICommandService),n=E.useObservable(t.filterBy$,void 0,!0),o=E.useObservable(t.filterByModel$,void 0,!1),l=E.useObservable(()=>(o==null?void 0:o.canApply$)||g.of(!1),void 0,!1,[o]),i=Bt(e),s=!E.useObservable(t.hasCriteria$),a=I.useCallback(N=>{r.executeCommand(Ae.id,{filterBy:N})},[r]),h=I.useCallback(async()=>{await(o==null?void 0:o.clear()),r.executeCommand(te.id)},[o,r]),m=I.useCallback(()=>{r.executeCommand(te.id)},[r]),p=I.useCallback(async()=>{await(o==null?void 0:o.apply()),r.executeCommand(te.id)},[o,r]),S=(P=E.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:P.getRange(),C=t.col,O=E.useComponentsOfPart($.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{"data-u-comp":"sheets-filter-panel",className:"univer-box-border univer-flex univer-max-h-[500px] univer-w-[400px] univer-flex-col univer-rounded-lg univer-bg-white univer-p-4 univer-shadow-lg dark:!univer-border-gray-600 dark:!univer-bg-gray-700",children:[d.jsx(E.ComponentContainer,{components:O,sharedProps:{range:S,colIndex:C,onClose:m}}),d.jsx("div",{className:"univer-mb-1 univer-flex-shrink-0 univer-flex-grow-0",children:d.jsx(b.Segmented,{value:n,items:i,onChange:N=>a(N)})}),o?d.jsx("div",{"data-u-comp":"sheets-filter-panel-content",className:"univer-flex-shrink univer-flex-grow univer-pt-2",children:n===c.FilterBy.VALUES?d.jsx(Ut,{model:o}):n===c.FilterBy.COLORS?d.jsx(Rt,{model:o}):d.jsx(Lt,{model:o})}):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(b.Button,{variant:"link",onClick:h,disabled:s,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:"univer-flex univer-gap-2",children:[d.jsx(b.Button,{variant:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(b.Button,{disabled:!l,variant:"primary",onClick:p,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Bt(t){const e=t.getCurrentLocale();return I.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:c.FilterBy.VALUES},{label:t.t("sheets-filter.panel.by-colors"),value:c.FilterBy.COLORS},{label:t.t("sheets-filter.panel.by-conditions"),value:c.FilterBy.CONDITIONS}],[e,t])}function Dt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:E.MenuItemType.BUTTON_SELECTOR,icon:"FilterIcon",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:$.getObservableWithExclusiveRange$(t,$.getCurrentRangeDisable$(t,{worksheetTypes:[F.WorksheetFilterPermission,F.WorksheetViewPermission],rangeTypes:[F.RangeProtectionPermissionViewPoint]}))}}function Ht(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(g.map(o=>!o)))!=null?n:g.of(!0)}))}}function xt(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:E.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var n;return(n=r==null?void 0:r.hasCriteria$.pipe(g.map(o=>!o)))!=null?n:g.of(!0)}))}}const Wt={[E.RibbonDataGroup.ORGANIZATION]:{[c.SmartToggleSheetsFilterCommand.id]:{order:2,menuItemFactory:Dt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:Ht},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:xt}}}},jt={id:c.SmartToggleSheetsFilterCommand.id,binding:E.KeyCode.L|E.MetaKeys.CTRL_COMMAND|E.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:$.whenSheetEditorFocused,group:"4_sheet-edit"};var Vt=Object.getOwnPropertyDescriptor,Qt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Vt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},U=(t,e)=>(r,n)=>e(r,n,t);const ze="FILTER_PANEL_POPUP";let Ee=class extends he{constructor(e,r,n,o,l,i,s,a,h,m,p,y,S){super(S,y);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=n,this._sheetCanvasPopupService=o,this._sheetsFilterService=l,this._localeService=i,this._shortcutService=s,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=p,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[jt].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Ae,ue,te].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Wt)}_initUI(){[[ze,kt],["FilterIcon",Ke]].forEach(([e,r])=>{this.disposeWithMe(this._componentManager.register(e,r))}),this.disposeWithMe(this._contextService.subscribeContextValue$(ee).pipe(g.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:b.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(),n=this._sheetsFilterPanelService.col,{startRow:o}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(o,n,{componentKey:ze,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(te.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};Ee=Qt([U(0,u.Inject(u.Injector)),U(1,u.Inject(E.ComponentManager)),U(2,u.Inject(G)),U(3,u.Inject($.SheetCanvasPopManagerService)),U(4,u.Inject(c.SheetsFilterService)),U(5,u.Inject(u.LocaleService)),U(6,E.IShortcutService),U(7,u.ICommandService),U(8,E.IMenuManagerService),U(9,u.IContextService),U(10,E.IMessageService),U(11,u.Inject($.SheetsRenderService)),U(12,K.IRenderManagerService)],Ee);var Gt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,qt=(t,e,r)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Yt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},Me=(t,e)=>(r,n)=>e(r,n,t),Je=(t,e,r)=>qt(t,typeof e!="symbol"?e+"":e,r);const Zt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=Ce,r,n,o){super(),this._config=e,this._injector=r,this._configService=n,this._rpcChannelService=o;const{menu:l,...i}=u.merge({},Ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(xe,i)}onStarting(){u.registerDependencies(this._injector,[[G],[ie],[Ee]]),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([fe,{useFactory:()=>pe.toModule(this._rpcChannelService.requestChannel(Ne))}])}onReady(){u.touchDependencies(this._injector,[[ie]])}onRendered(){u.touchDependencies(this._injector,[[Ee]])}},Je(_.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET),Je(_.UniverSheetsFilterUIPlugin,"pluginName",Zt),_.UniverSheetsFilterUIPlugin=Kt([u.DependentOn(c.UniverSheetsFilterPlugin),Me(1,u.Inject(u.Injector)),Me(2,u.IConfigService),Me(3,u.Optional(pe.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var Xt=Object.getOwnPropertyDescriptor,zt=(t,e,r,n)=>{for(var o=n>1?void 0:n?Xt(e,r):e,l=t.length-1,i;l>=0;l--)(i=t[l])&&(o=i(o)||o);return o},et=(t,e)=>(r,n)=>e(r,n,t);_.UniverSheetsFilterUIWorkerPlugin=(Oe=class extends u.Plugin{constructor(e,r,n){super(),this._config=e,this._injector=r,this._rpcChannelService=n}onStarting(){[[fe,{useClass:be}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ne,pe.fromModule(this._injector.get(fe)))}},v(Oe,"type",u.UniverInstanceType.UNIVER_SHEET),v(Oe,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),Oe),_.UniverSheetsFilterUIWorkerPlugin=zt([et(1,u.Inject(u.Injector)),et(2,pe.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ae,_.CloseFilterPanelOperation=te,_.OpenFilterPanelOperation=ue,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-filter-ui",
3
- "version": "0.10.0",
3
+ "version": "0.10.1-nightly.202508020912",
4
4
  "private": false,
5
5
  "description": "Univer Sheets Filter UI",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -53,14 +53,14 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@univerjs/icons": "^0.4.6",
56
- "@univerjs/design": "0.10.0",
57
- "@univerjs/core": "0.10.0",
58
- "@univerjs/rpc": "0.10.0",
59
- "@univerjs/sheets": "0.10.0",
60
- "@univerjs/sheets-ui": "0.10.0",
61
- "@univerjs/sheets-filter": "0.10.0",
62
- "@univerjs/engine-render": "0.10.0",
63
- "@univerjs/ui": "0.10.0"
56
+ "@univerjs/core": "0.10.1-nightly.202508020912",
57
+ "@univerjs/design": "0.10.1-nightly.202508020912",
58
+ "@univerjs/engine-render": "0.10.1-nightly.202508020912",
59
+ "@univerjs/sheets": "0.10.1-nightly.202508020912",
60
+ "@univerjs/rpc": "0.10.1-nightly.202508020912",
61
+ "@univerjs/sheets-filter": "0.10.1-nightly.202508020912",
62
+ "@univerjs/ui": "0.10.1-nightly.202508020912",
63
+ "@univerjs/sheets-ui": "0.10.1-nightly.202508020912"
64
64
  },
65
65
  "devDependencies": {
66
66
  "postcss": "^8.5.6",
@@ -70,14 +70,14 @@
70
70
  "typescript": "^5.8.3",
71
71
  "vite": "^7.0.6",
72
72
  "vitest": "^3.2.4",
73
- "@univerjs-infra/shared": "0.10.0",
74
- "@univerjs/engine-formula": "0.10.0"
73
+ "@univerjs/engine-formula": "0.10.1-nightly.202508020912",
74
+ "@univerjs-infra/shared": "0.10.1"
75
75
  },
76
76
  "scripts": {
77
77
  "test": "vitest run",
78
78
  "test:watch": "vitest",
79
79
  "coverage": "vitest run --coverage",
80
- "lint:types": "tsc --noEmit",
80
+ "typecheck": "tsc --noEmit",
81
81
  "build": "univer-cli build"
82
82
  },
83
83
  "module": "./lib/es/index.js"
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS