@univerjs/sheets-filter-ui 0.6.0-alpha.0 → 0.6.0-experimental.20250212-dbe9830
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 +1 -1
- package/lib/es/index.js +3 -2
- package/lib/types/index.d.ts +1 -1
- package/lib/types/locale/zh-CN.d.ts +1 -1
- package/lib/types/models/extended-operators.d.ts +1 -1
- package/lib/types/views/components/SheetsFilterPanel.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +13 -13
- package/LICENSE +0 -176
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Je=Object.defineProperty;var et=(t,e,r)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>et(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@univerjs/core"),ge=require("@univerjs/rpc"),u=require("@univerjs/sheets-filter"),O=require("@univerjs/sheets"),T=require("@univerjs/ui"),w=require("@univerjs/sheets-ui"),g=require("rxjs"),L=require("@univerjs/design"),ie=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),A=require("react"),je="sheets-filter-ui.config",me={};var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),v=(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))(v||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:v.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:s=>s.operator1===v.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:s=>!s.customFilters&&!s.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:v.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:v.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:v.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:v.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:v.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.CONTAINS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===v.CONTAINS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:v.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.DOES_NOT_CONTAIN},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:v.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.STARTS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`${s.val1}*`}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.STARTS_WITH},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:v.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:v.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.ENDS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}`}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.ENDS_WITH},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:v.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:v.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.EQUALS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===v.EQUALS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:s=>{var o,a,h;return((a=(o=s.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:v.EQUALS,val1:""}:((h=s.customFilters)==null?void 0:h.customFilters.length)===1&&!s.customFilters.customFilters[0].operator?{operator1:v.EQUALS,val1:s.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:s=>{const[o]=H(s);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:v.BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:h}=s;if(!o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:h}=s,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:v.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:h}=s;if(o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:h}=s,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:v.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:v.NONE,val1:"",operator2:v.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:s=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=s;function C(M,b){for(const j of t.ALL_CONDITIONS)if(j.operator===M)return j.mapToFilterColumn({val1:b,operator1:M})}const _=!m||m===t.NONE.operator,E=!f||f===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return C(f,h);if(E)return C(m,a);const F=C(m,a),y=C(f,h),P={customFilters:[F.customFilters.customFilters[0],y.customFilters.customFilters[0]]};return o&&(P.and=c.BooleanNumber.TRUE),{customFilters:P}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=s.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return s.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(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${s}`);return o}t.getItemByOperator=e;function r(s,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(s))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(s))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function n(s,o){return s.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(s){if(!s)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(s);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function H(t){const{operator1:e,operator2:r,val1:i,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,i]:[r,n]}function Pe(t){const e=[],r=[];let i=0,n=0;function l(s){s.leaf&&(s.checked?(e.push(s),i+=s.count):(r.push(s),n+=s.count)),s.children&&s.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:n}}var tt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,st=(t,e,r,i)=>{for(var n=i>1?void 0:i?rt(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&tt(e,r,n),n},Te=(t,e)=>(r,i)=>e(r,i,t);const Ae="sheets-filter.generate-filter-values.service",pe=c.createIdentifier(Ae),it=["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 Ie=class extends c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:n,blankChecked:l,iterateRange:s,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),Be(n,this._localeService,s,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Ie=st([Te(0,c.Inject(c.LocaleService)),Te(1,c.IUniverInstanceService),Te(2,c.ILogService)],Ie);function Be(t,e,r,i,n,l,s,o){var F,y,P,M,b,j,B,ae,le;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(it),C="empty";let _=0;for(const U of i.iterateByColumn(r,!1,!1)){const{row:Xe,rowSpan:Me=1}=U;let X=0;for(;X<Me;){const Ze=Xe+X;if(n.has(Ze)){X++;continue}const Y=U!=null&&U.value?c.extractPureTextFromCell(U.value):"";if(!Y){_+=1,X+=Me;continue}const ce=(F=U.value)!=null&&F.v&&!U.value.p?(M=(P=o.get((y=U.value)==null?void 0:y.s))==null?void 0:P.n)==null?void 0:M.pattern:"",ze=ce&&c.numfmt.isDate(ce);if(ce&&ze&&f.has(ce)){const k=(b=i.getCellRaw(U.row,U.col))==null?void 0:b.v;if(!k){X++;continue}const Z=c.numfmt.format(m,k),[R,x,re]=Z.split("-").map(Number);let q=a.get(`${R}`);q||(q={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,q),h.set(`${R}`,[`${R}`]));let V=(j=q.children)==null?void 0:j.find(Ce=>Ce.key===`${R}-${x}`);V||(V={title:e.t(`sheets-filter.date.${x}`),key:`${R}-${x}`,children:[],count:0,leaf:!1,checked:!1},(B=q.children)==null||B.push(V),h.set(`${R}-${x}`,[`${R}`,`${R}-${x}`]));const Fe=(ae=V==null?void 0:V.children)==null?void 0:ae.find(Ce=>Ce.key===`${R}-${x}-${re}`);Fe?(Fe.originValues.add(Y),Fe.count++,V.count++,q.count++):((le=V.children)==null||le.push({title:`${re}`,key:`${R}-${x}-${re}`,count:1,originValues:new Set([Y]),leaf:!0,checked:l.size?l.has(Y):!s}),V.count++,q.count++,h.set(`${R}-${x}-${re}`,[`${R}`,`${R}-${x}`,`${R}-${x}-${re}`]))}else{const k=Y;let Z=a.get(k);Z?Z.count++:(Z={title:Y,leaf:!0,checked:l.size?l.has(Y):!s,key:k,count:1},a.set(k,Z),h.set(k,[k]))}X++}}const E=t?s:!0;if(_>0){const U={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:C};a.set("empty",U),h.set("empty",[C])}return{filterTreeItems:nt(Array.from(a.values())),filterTreeMapCache:h}}function nt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((i,n)=>{const l=Number.parseInt(i.key.split("-")[2],10),s=Number.parseInt(n.key.split("-")[2],10);return l-s})}),e))}function Ne(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Ne(r.children,e);if(i)return i}}return null}function xe(t){return t.leaf?t.checked:t.children?t.children.every(e=>xe(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function Ve(t,e){const r=[];return t.forEach(i=>{const n=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...i});else if(i.children){const o=Ve(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,be=(t,e,r,i)=>{for(var n=i>1?void 0:i?at(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ot(e,r,n),n},de=(t,e)=>(r,i)=>e(r,i,t),fe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(fe||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends c.Disposable{constructor(e,r){super();S(this,"_filterBy$",new g.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new g.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new g.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new g.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(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 i=e.getFilterColumn(r);if(i){const n=i.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,n=e.subUnitId,l=e.getRange(),s={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,n,s,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=be([de(0,c.Inject(c.Injector)),de(1,c.Inject(O.RefRangeService))],G);let _e=class extends c.Disposable{constructor(e,r,i,n,l){super();S(this,"canApply$",g.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new g.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,n){const[l,s]=p.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,r,i,l,s)}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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};_e=be([de(4,c.ICommandService)],_e);let Se=class extends c.Disposable{constructor(e,r,i,n,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=n,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(i),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(([s,o])=>{if(!s)return o;const h=s.toLowerCase().split(/\s+/).filter(m=>!!m);return Ve(o,h)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(s=>Pe(s).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(s=>this._filterItems=s))}static async fromFilterColumn(e,r,i){var j;const n=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),s=e.get(pe,c.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),C=i,_=(j=r.getFilterColumn(i))==null?void 0:j.getColumnData().filters,E=new Set(_==null?void 0:_.filters),F=!!(_&&_.blank),y=r.getFilteredOutRowsExceptCol(i),P={...f,startRow:f.startRow+1,startColumn:C,endColumn:C};let M,b;if(s){const B=await s.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(y),filters:!!_,blankChecked:F,iterateRange:P,alreadyChecked:Array.from(E)});M=B.filterTreeItems,b=B.filterTreeMapCache}else{const B=Be(!!_,l,P,m,y,E,F,h.getStyles());M=B.filterTreeItems,b=B.filterTreeMapCache}return e.createInstance(Se,r,i,M,b)}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=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),i=Ne(r,e.key);if(!i)return;const n=xe(i);se(i,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const n=Ne(r,i);n&&se(n,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Pe(this._filterItems),{checked:r,checkedItems:i}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const s=r===0,o=e.checked===l,a={colId:this.col};if(s)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};Se=be([de(4,c.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",ne={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),i=t.get(u.SheetsFilterService),n=t.get(G);t.get(c.ICommandService).syncExecuteCommand(w.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:s,subUnitId:o,col:a}=e,h=i.getFilterModel(s,o);return h?(n.setupCol(h,a),r.getContextValue(ee)||r.setContextValue(ee,!0),!0):!1}},J={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(G),i=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),i==null||i.focus(),r.terminate()):!1}},Le={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ut=(t,e,r,i)=>{for(var n=i>1?void 0:i?ct(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&<(e,r,n),n},z=(t,e)=>(r,i)=>e(r,i,t);let te=class extends c.Disposable{constructor(t,e,r,i,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(c.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:s,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(s,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let C={...f};C=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(C,{left:!0,right:!0,up:!0,down:!0},a):C,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[C],s,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ne.id){const n=t.params,{unitId:l,subUnitId:s}=n,o=(i=this._sheetsFilterService.getFilterModel(l,s))==null?void 0:i.getRange(),a=c.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=ut([z(0,c.Inject(u.SheetsFilterService)),z(1,c.Inject(c.LocaleService)),z(2,c.ICommandService),z(3,c.Inject(O.SheetPermissionCheckController)),z(4,c.Inject(c.Injector)),z(5,c.Inject(O.SheetsSelectionsService))],te);var D=function(){return D=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},D.apply(this,arguments)},ht=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},We=A.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,l=t.extend,s=ht(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),a=A.useRef("_".concat(dt()));return ke(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},D({ref:e,className:o},s),l)});function ke(t,e,r,i,n){return A.createElement(t.tag,D(D({key:e},mt(t,r,n)),i),(pt(t,r).children||[]).map(function(l,s){return ke(l,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function mt(t,e,r){var i=D({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var s=l[0],o=l[1];typeof o=="string"&&(i[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function pt(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?D(D({},n),{attrs:D(D({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function dt(){return Math.random().toString(36).substring(2,8)}We.displayName="UniverIcon";var ft={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=A.forwardRef(function(t,e){return A.createElement(We,Object.assign({},t,{id:"filter-single",ref:e,icon:ft}))});Qe.displayName="FilterSingle";const _t="univer-sheets-filter-panel",St="univer-sheets-filter-panel-header",vt="univer-sheets-filter-panel-content",gt="univer-sheets-filter-panel-select-all",Ft="univer-sheets-filter-panel-select-all-count",Ct="univer-sheets-filter-panel-values-container",Tt="univer-input-affix-wrapper",Et="univer-select",Ot="univer-radio-group",Pt="univer-sheets-filter-panel-values-find",It="univer-sheets-filter-panel-values-list",Nt="univer-sheets-filter-panel-values-list-inner-container",yt="univer-sheets-filter-panel-values-virtual",Rt="univer-sheets-filter-panel-values-item",At="univer-sheets-filter-panel-values-item-inner",bt="univer-sheets-filter-panel-values-item-count",Lt="univer-sheets-filter-panel-values-item-exclude-button",Mt="univer-sheets-filter-panel-values-item-text",Ut="univer-sheets-filter-panel-conditions-container",$t="univer-sheets-filter-panel-conditions-container-inner",wt="univer-sheets-filter-panel-conditions-desc",Dt="univer-sheets-filter-panel-footer",Ht="univer-sheets-filter-panel-footer-primary-buttons",jt="univer-button",Bt="univer-input",xt="univer-form-dual-column-layout",Vt="univer-sheets-filter-tree-node",Wt="univer-sheets-filter-tree-node-filter-only",kt="univer-sheets-filter-tree-node-attach",I={sheetsFilterPanel:_t,sheetsFilterPanelHeader:St,sheetsFilterPanelContent:vt,sheetsFilterPanelSelectAll:gt,sheetsFilterPanelSelectAllCount:Ft,sheetsFilterPanelValuesContainer:Ct,inputAffixWrapper:Tt,select:Et,radioGroup:Ot,sheetsFilterPanelValuesFind:Pt,sheetsFilterPanelValuesList:It,sheetsFilterPanelValuesListInnerContainer:Nt,sheetsFilterPanelValuesVirtual:yt,sheetsFilterPanelValuesItem:Rt,sheetsFilterPanelValuesItemInner:At,sheetsFilterPanelValuesItemCount:bt,sheetsFilterPanelValuesItemExcludeButton:Lt,sheetsFilterPanelValuesItemText:Mt,sheetsFilterPanelConditionsContainer:Ut,sheetsFilterPanelConditionsContainerInner:$t,sheetsFilterPanelConditionsDesc:wt,sheetsFilterPanelFooter:Dt,sheetsFilterPanelFooterPrimaryButtons:Ht,button:jt,input:Bt,formDualColumnLayout:xt,sheetsFilterTreeNode:Vt,sheetsFilterTreeNodeFilterOnly:Wt,sheetsFilterTreeNodeAttach:kt};function Qt(t){var _,E;const{model:e}=t,r=c.useDependency(c.LocaleService),i=T.useObservable(e.conditionItem$,void 0),n=T.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",s=A.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=Gt(r),a=A.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=Yt(r),m=A.useCallback(F=>{e.onConditionFormChange(F)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function C(F,y,P){const M=p.getItemByOperator(F).numOfParameters===1;return d.jsxs(d.Fragment,{children:[P==="operator2"&&d.jsxs(L.RadioGroup,{value:l,onChange:s,children:[d.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(L.Select,{value:F,options:h,onChange:b=>m({[P]:b})}),M&&d.jsx("div",{children:d.jsx(L.Input,{value:y,placeholder:f,onChange:b=>m({[P==="operator1"?"val1":"val2"]:b})})})]})}return d.jsx("div",{className:I.sheetsFilterPanelConditionsContainer,children:i&&n&&d.jsxs(d.Fragment,{children:[d.jsx(L.Select,{value:i.operator,options:o,onChange:a}),p.getItemByOperator(i.operator).numOfParameters!==0?d.jsxs("div",{className:I.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&C(n.operator1,(_=n.val1)!=null?_:"","operator1"),i.numOfParameters>=2&&C(n.operator2,(E=n.val2)!=null?E:"","operator2"),d.jsxs("div",{className:I.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Gt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function Yt(t){const e=t.getCurrentLocale();return A.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function qt(t){const{model:e}=t,r=c.useDependency(c.LocaleService),i=T.useObservable(e.searchString$,"",!0),n=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),s=Pe(n),o=s.checked>0&&s.unchecked===0,a=s.checked>0&&s.unchecked>0,h=e.treeMapCache,m=A.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=A.useCallback(_=>{e.setSearchString(_)},[e]);function C(_){let E=[];return _.forEach(F=>{F.checked&&E.push(F.key),F.children&&(E=E.concat(C(F.children)))}),E}return d.jsxs("div",{className:I.sheetsFilterPanelValuesContainer,children:[d.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{className:I.sheetsFilterPanelValuesList,children:[d.jsx("div",{className:I.sheetsFilterPanelValuesItem,children:d.jsxs("div",{className:I.sheetsFilterPanelValuesItemInner,children:[d.jsx(L.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${s.checked}/${s.checked+s.unchecked})`})]})}),d.jsx("div",{className:I.sheetsFilterPanelValuesVirtual,children:d.jsx(L.Tree,{data:n,defaultExpandAll:!1,valueGroup:C(n),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:I.sheetsFilterTreeNode,attachRender:_=>d.jsxs("div",{className:I.sheetsFilterTreeNodeAttach,children:[d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${_.count})`}),d.jsx(L.Button,{className:I.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const E=[];_.children?_.children.forEach(F=>{F.children?F.children.forEach(y=>{E.push(y.key)}):E.push(F.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function Kt(){var y;const t=c.useDependency(G),e=c.useDependency(c.LocaleService),r=c.useDependency(c.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),n=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(n==null?void 0:n.canApply$)||g.of(!1),void 0,!1,[n]),s=Xt(e),o=!T.useObservable(t.hasCriteria$),a=A.useCallback(P=>{r.executeCommand(Le.id,{filterBy:P})},[r]),h=A.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(J.id)},[n,r]),m=A.useCallback(()=>{r.executeCommand(J.id)},[r]),f=A.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(J.id)},[n,r]),_=(y=c.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:y.getRange(),E=t.col,F=T.useComponentsOfPart(w.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:I.sheetsFilterPanel,children:[d.jsx(T.ComponentContainer,{components:F,sharedProps:{range:_,colIndex:E,onClose:m}}),d.jsx("div",{className:I.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,options:s,onChange:P=>a(P)})}),n?d.jsx("div",{className:I.sheetsFilterPanelContent,children:i===fe.VALUES?d.jsx(qt,{model:n}):d.jsx(Qt,{model:n})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:I.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:I.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Xt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:fe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:fe.CONDITIONS}],[e,t])}function Zt(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:w.getObservableWithExclusiveRange$(t,w.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function zt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}function Jt(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}const er={[T.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:Zt,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:zt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Jt}}}},Q=16,tr=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 Ue{static drawNoCriteria(e,r,i,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:Q,height:Q,fill:n}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Q,r/Q),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,i,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:Q,height:Q,fill:n}),e.scale(r/Q,r/Q),e.fillStyle=i,e.fill(tr),e.restore()}}var rr=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,ir=(t,e,r,i)=>{for(var n=i>1?void 0:i?sr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&rr(e,r,n),n},Ee=(t,e)=>(r,i)=>e(r,i,t);const W=16,ue=1;let ye=class extends ie.Shape{constructor(e,r,i,n,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(s=>this.onPointerDown(s)),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,i=this._cellWidth,n=W-i,l=W-r;e.save();const s=new Path2D;s.rect(n,l,i,r),e.clip(s);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?Ue.drawHasCriteria(e,W,a,h):Ue.drawNoCriteria(e,W,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:n}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(ne.id)||setTimeout(()=>{this._commandService.executeCommand(ne.id,{unitId:i,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ye=ir([Ee(2,c.IContextService),Ee(3,c.ICommandService),Ee(4,c.Inject(c.ThemeService))],ye);var nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor,ar=(t,e,r,i)=>{for(var n=i>1?void 0:i?or(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&nr(e,r,n),n},K=(t,e)=>(r,i)=>e(r,i,t);const lr=1e3,cr=5e3;let Re=class extends c.RxDisposable{constructor(e,r,i,n,l,s,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=s,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var o,a;if(!e)return g.of(null);const{unit:r,unitId:i}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,n))!=null?a:void 0,s=()=>({unitId:i,worksheetId:n,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(g.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===O.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(s),g.startWith(s()))}),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:i}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,s=this._filterRangeShape=new w.SelectionControl(i,lr,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=w.attachSelectionWithCoord(o,r);s.updateRangeBySelectionWithCoord(a),s.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:n,skeleton:l,worksheetId:s}=e,{scene:o}=this._context;this._interceptCellContent(n,s,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const C=`sheets-filter-button-${f}`,_=w.getCoordByCell(m,f,o,l),{startX:E,startY:F,endX:y,endY:P}=_,M=y-E,b=P-F;if(b<=ue||M<=ue)continue;const j=!!i.getFilterColumn(f),B=y-W-ue,ae=P-W-ue,le={left:B,top:ae,height:W,width:W,zIndex:cr,cellHeight:b,cellWidth:M,filterParams:{unitId:n,subUnitId:s,col:f,hasCriteria:j}},U=this._injector.createInstance(ye,C,le);this._filterButtonShapes.push(U)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:n,startColumn:l,endColumn:s}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:C,subUnitId:_}=a;return C!==e||_!==r||m!==n||f<l||f>s?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:W}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Re=ar([K(1,c.Inject(c.Injector)),K(2,c.Inject(w.SheetSkeletonManagerService)),K(3,c.Inject(u.SheetsFilterService)),K(4,c.Inject(c.ThemeService)),K(5,c.Inject(O.SheetInterceptorService)),K(6,c.ICommandService),K(7,w.ISheetSelectionRenderService)],Re);var ur=Object.defineProperty,hr=Object.getOwnPropertyDescriptor,mr=(t,e,r,i)=>{for(var n=i>1?void 0:i?hr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ur(e,r,n),n},$e=(t,e)=>(r,i)=>e(r,i,t);let oe=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[Re]))}};oe=mr([$e(0,ie.IRenderManagerService),$e(1,c.Inject(w.SheetsRenderService))],oe);const pr={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:w.whenSheetEditorFocused,group:"4_sheet-edit"};var dr=Object.defineProperty,fr=Object.getOwnPropertyDescriptor,_r=(t,e,r,i)=>{for(var n=i>1?void 0:i?fr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&dr(e,r,n),n},$=(t,e)=>(r,i)=>e(r,i,t);const we="FILTER_PANEL_POPUP";let ve=class extends oe{constructor(e,r,i,n,l,s,o,a,h,m,f,C,_){super(_,C);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=s,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[pr].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Le,ne,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(er)}_initUI(){this.disposeWithMe(this._componentManager.register(we,Kt)),this.disposeWithMe(this._componentManager.register("FilterSingle",Qe)),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:L.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(),i=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,i,{componentKey:we,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=_r([$(0,c.Inject(c.Injector)),$(1,c.Inject(T.ComponentManager)),$(2,c.Inject(G)),$(3,c.Inject(w.SheetCanvasPopManagerService)),$(4,c.Inject(u.SheetsFilterService)),$(5,c.Inject(c.LocaleService)),$(6,T.IShortcutService),$(7,c.ICommandService),$(8,T.IMenuManagerService),$(9,c.IContextService),$(10,T.IMessageService),$(11,c.Inject(w.SheetsRenderService)),$(12,ie.IRenderManagerService)],ve);var Ge=Object.defineProperty,Sr=Object.getOwnPropertyDescriptor,vr=(t,e,r)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Sr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Ge(e,r,n),n},Oe=(t,e)=>(r,i)=>e(r,i,t),Ye=(t,e,r)=>vr(t,typeof e!="symbol"?e+"":e,r);const Fr="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=me,r,i,n){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=n;const{menu:l,...s}=c.merge({},me,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(je,s)}onStarting(){[[G],[te],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([pe,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(Ae))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ve)}};Ye(exports.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);Ye(exports.UniverSheetsFilterUIPlugin,"pluginName",Fr);exports.UniverSheetsFilterUIPlugin=gr([c.DependentOn(u.UniverSheetsFilterPlugin),Oe(1,c.Inject(c.Injector)),Oe(2,c.IConfigService),Oe(3,c.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var qe=Object.defineProperty,Cr=Object.getOwnPropertyDescriptor,Tr=(t,e,r)=>e in t?qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Er=(t,e,r,i)=>{for(var n=i>1?void 0:i?Cr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&qe(e,r,n),n},De=(t,e)=>(r,i)=>e(r,i,t),Ke=(t,e,r)=>Tr(t,typeof e!="symbol"?e+"":e,r);const Or="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=me,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:n,...l}=c.merge({},me,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(je,l)}onStarting(){[[te],[oe]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(oe)}};Ke(exports.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET);Ke(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Or);exports.UniverSheetsFilterMobileUIPlugin=Er([c.DependentOn(u.UniverSheetsFilterPlugin),De(1,c.Inject(c.Injector)),De(2,c.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var Pr=Object.defineProperty,Ir=Object.getOwnPropertyDescriptor,Nr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Ir(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Pr(e,r,n),n},He=(t,e)=>(r,i)=>e(r,i,t),he;exports.UniverSheetsFilterUIWorkerPlugin=(he=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[pe,{useClass:Ie}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ae,ge.fromModule(this._injector.get(pe)))}},S(he,"type",c.UniverInstanceType.UNIVER_SHEET),S(he,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),he);exports.UniverSheetsFilterUIWorkerPlugin=Nr([He(1,c.Inject(c.Injector)),He(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Le;exports.CloseFilterPanelOperation=J;exports.OpenFilterPanelOperation=ne;
|
|
1
|
+
"use strict";var Je=Object.defineProperty;var et=(t,e,r)=>e in t?Je(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var S=(t,e,r)=>et(t,typeof e!="symbol"?e+"":e,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("@univerjs/core"),ge=require("@univerjs/rpc"),c=require("@univerjs/sheets-filter"),O=require("@univerjs/sheets"),F=require("@univerjs/ui"),w=require("@univerjs/sheets-ui"),g=require("rxjs"),L=require("@univerjs/design"),ie=require("@univerjs/engine-render"),d=require("react/jsx-runtime"),A=require("react"),je="sheets-filter-ui.config",me={};var N=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(N||{}),v=(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))(v||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:v.NONE,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:s=>s.operator1===v.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:s=>!s.customFilters&&!s.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:v.EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:v.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:v.NOT_EMPTY,order:N.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:s})=>s===v.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0];return o.val===" "&&o.operator===c.CustomFilterOperator.NOT_EQUALS?{operator1:v.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:v.CONTAINS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.CONTAINS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===v.CONTAINS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:v.DOES_NOT_CONTAIN,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}*`,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.DOES_NOT_CONTAIN},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return o.operator===c.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:v.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:v.STARTS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.STARTS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`${s.val1}*`}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.STARTS_WITH},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:v.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:v.ENDS_WITH,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.ENDS_WITH,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:`*${s.val1}`}]}}),testMappingParams:s=>{const[o]=H(s);return o===v.ENDS_WITH},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=s.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:v.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:v.EQUALS,order:N.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:v.EQUALS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===v.EQUALS},mapToFilterColumn:s=>{const{val1:o}=s;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:s=>{var o,a,h;return((a=(o=s.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:v.EQUALS,val1:""}:((h=s.customFilters)==null?void 0:h.customFilters.length)===1&&!s.customFilters.customFilters[0].operator?{operator1:v.EQUALS,val1:s.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:c.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.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:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.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:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.LESS_THAN},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.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:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.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:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.EQUAL},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.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:N.FIRST,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:s=>{const[o]=H(s);return o===c.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:s=>({customFilters:{customFilters:[{val:s.val1,operator:c.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:s=>{var a;if(((a=s.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=s.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:v.BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:h}=s;if(!o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(c.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:h}=s,m=h===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:u.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===c.CustomFilterOperator.LESS_THAN_OR_EQUAL&&s.customFilters.and?{and:!0,operator1:c.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:v.NOT_BETWEEN,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:c.CustomFilterOperator.LESS_THAN,val1:"",operator2:c.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:s=>{const{and:o,operator1:a,operator2:h}=s;if(o)return!1;const m=[a,h];return m.includes(c.CustomFilterOperator.GREATER_THAN)&&m.includes(c.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:s=>{const{val1:o,val2:a,operator1:h}=s,m=h===c.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:c.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:c.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=s.customFilters.customFilters;return o.operator===c.CustomFilterOperator.LESS_THAN&&a.operator===c.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:c.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:c.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===c.CustomFilterOperator.LESS_THAN&&o.operator===c.CustomFilterOperator.GREATER_THAN&&!s.customFilters.and?{operator1:c.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:c.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:v.CUSTOM,order:N.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:v.NONE,val1:"",operator2:v.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:s=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=s;function T(M,b){for(const j of t.ALL_CONDITIONS)if(j.operator===M)return j.mapToFilterColumn({val1:b,operator1:M})}const _=!m||m===t.NONE.operator,E=!f||f===t.NONE.operator;if(_&&E)return t.NONE.mapToFilterColumn({});if(_)return T(f,h);if(E)return T(m,a);const C=T(m,a),y=T(f,h),P={customFilters:[C.customFilters.customFilters[0],y.customFilters.customFilters[0]]};return o&&(P.and=u.BooleanNumber.TRUE),{customFilters:P}},testMappingFilterColumn:s=>{var h;if(((h=s.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=s.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return s.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(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${s}`);return o}t.getItemByOperator=e;function r(s,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(s))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(s))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(s){const o=t.ALL_CONDITIONS.find(a=>a.operator===s);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function n(s,o){return s.mapToFilterColumn(o)}t.mapToFilterColumn=n;function l(s){if(!s)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(s);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function H(t){const{operator1:e,operator2:r,val1:i,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,i]:[r,n]}function Pe(t){const e=[],r=[];let i=0,n=0;function l(s){s.leaf&&(s.checked?(e.push(s),i+=s.count):(r.push(s),n+=s.count)),s.children&&s.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:n}}var tt=Object.defineProperty,rt=Object.getOwnPropertyDescriptor,st=(t,e,r,i)=>{for(var n=i>1?void 0:i?rt(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&tt(e,r,n),n},Te=(t,e)=>(r,i)=>e(r,i,t);const Ae="sheets-filter.generate-filter-values.service",pe=u.createIdentifier(Ae),it=["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 Ie=class extends u.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:n,blankChecked:l,iterateRange:s,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),Be(n,this._localeService,s,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Ie=st([Te(0,u.Inject(u.LocaleService)),Te(1,u.IUniverInstanceService),Te(2,u.ILogService)],Ie);function Be(t,e,r,i,n,l,s,o){var C,y,P,M,b,j,B,ae,le;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(it),T="empty";let _=0;for(const U of i.iterateByColumn(r,!1,!1)){const{row:Xe,rowSpan:Me=1}=U;let X=0;for(;X<Me;){const Ze=Xe+X;if(n.has(Ze)){X++;continue}const Y=U!=null&&U.value?u.extractPureTextFromCell(U.value):"";if(!Y){_+=1,X+=Me;continue}const ce=(C=U.value)!=null&&C.v&&!U.value.p?(M=(P=o.get((y=U.value)==null?void 0:y.s))==null?void 0:P.n)==null?void 0:M.pattern:"",ze=ce&&u.numfmt.isDate(ce);if(ce&&ze&&f.has(ce)){const k=(b=i.getCellRaw(U.row,U.col))==null?void 0:b.v;if(!k){X++;continue}const Z=u.numfmt.format(m,k),[R,x,re]=Z.split("-").map(Number);let q=a.get(`${R}`);q||(q={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,q),h.set(`${R}`,[`${R}`]));let V=(j=q.children)==null?void 0:j.find(Ce=>Ce.key===`${R}-${x}`);V||(V={title:e.t(`sheets-filter.date.${x}`),key:`${R}-${x}`,children:[],count:0,leaf:!1,checked:!1},(B=q.children)==null||B.push(V),h.set(`${R}-${x}`,[`${R}`,`${R}-${x}`]));const Fe=(ae=V==null?void 0:V.children)==null?void 0:ae.find(Ce=>Ce.key===`${R}-${x}-${re}`);Fe?(Fe.originValues.add(Y),Fe.count++,V.count++,q.count++):((le=V.children)==null||le.push({title:`${re}`,key:`${R}-${x}-${re}`,count:1,originValues:new Set([Y]),leaf:!0,checked:l.size?l.has(Y):!s}),V.count++,q.count++,h.set(`${R}-${x}-${re}`,[`${R}`,`${R}-${x}`,`${R}-${x}-${re}`]))}else{const k=Y;let Z=a.get(k);Z?Z.count++:(Z={title:Y,leaf:!0,checked:l.size?l.has(Y):!s,key:k,count:1},a.set(k,Z),h.set(k,[k]))}X++}}const E=t?s:!0;if(_>0){const U={title:e.t("sheets-filter.panel.empty"),count:_,leaf:!0,checked:E,key:T};a.set("empty",U),h.set("empty",[T])}return{filterTreeItems:nt(Array.from(a.values())),filterTreeMapCache:h}}function nt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const n=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return n-l}).forEach(r=>{r.children&&r.children.sort((i,n)=>{const l=Number.parseInt(i.key.split("-")[2],10),s=Number.parseInt(n.key.split("-")[2],10);return l-s})}),e))}function Ne(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Ne(r.children,e);if(i)return i}}return null}function xe(t){return t.leaf?t.checked:t.children?t.children.every(e=>xe(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function Ve(t,e){const r=[];return t.forEach(i=>{const n=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!n&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(n||l)r.push({...i});else if(i.children){const o=Ve(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var ot=Object.defineProperty,at=Object.getOwnPropertyDescriptor,be=(t,e,r,i)=>{for(var n=i>1?void 0:i?at(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ot(e,r,n),n},de=(t,e)=>(r,i)=>e(r,i,t),fe=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(fe||{});u.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let G=class extends u.Disposable{constructor(e,r){super();S(this,"_filterBy$",new g.BehaviorSubject(0));S(this,"filterBy$",this._filterBy$.asObservable());S(this,"_filterByModel$",new g.ReplaySubject(1));S(this,"filterByModel$",this._filterByModel$.asObservable());S(this,"_filterByModel",null);S(this,"_hasCriteria$",new g.BehaviorSubject(!1));S(this,"hasCriteria$",this._hasCriteria$.asObservable());S(this,"_filterModel",null);S(this,"_col$",new g.BehaviorSubject(-1));S(this,"col$",this._col$.asObservable());S(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 i=e.getFilterColumn(r);if(i){const n=i.getColumnData();if(n.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(n.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,n=e.subUnitId,l=e.getRange(),s={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,n,s,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=await Se.fromFilterColumn(this._injector,e,r);return this.filterByModel=n,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const n=_e.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=n,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};G=be([de(0,u.Inject(u.Injector)),de(1,u.Inject(O.RefRangeService))],G);let _e=class extends u.Disposable{constructor(e,r,i,n,l){super();S(this,"canApply$",g.of(!0));S(this,"_conditionItem$");S(this,"conditionItem$");S(this,"_filterConditionFormParams$");S(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=l,this._conditionItem$=new g.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new g.BehaviorSubject(n),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,n){const[l,s]=p.testMappingFilterColumn(n==null?void 0:n.getColumnData());return e.createInstance(_e,r,i,l,s)}get conditionItem(){return this._conditionItem$.getValue()}get filterConditionFormParams(){return this._filterConditionFormParams$.getValue()}dispose(){super.dispose(),this._conditionItem$.complete(),this._filterConditionFormParams$.complete()}deltaCol(e){this.col+=e}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};_e=be([de(4,u.ICommandService)],_e);let Se=class extends u.Disposable{constructor(e,r,i,n,l){super();S(this,"_rawFilterItems$");S(this,"rawFilterItems$");S(this,"filterItems$");S(this,"_filterItems",[]);S(this,"_treeMapCache");S(this,"canApply$");S(this,"_manuallyUpdateFilterItems$");S(this,"_searchString$");S(this,"searchString$");this._filterModel=e,this.col=r,this._commandService=l,this._treeMapCache=n,this._searchString$=new g.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new g.BehaviorSubject(i),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(([s,o])=>{if(!s)return o;const h=s.toLowerCase().split(/\s+/).filter(m=>!!m);return Ve(o,h)})),this._manuallyUpdateFilterItems$).pipe(g.shareReplay(1)),this.canApply$=this.filterItems$.pipe(g.map(s=>Pe(s).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(s=>this._filterItems=s))}static async fromFilterColumn(e,r,i){var j;const n=e.get(u.IUniverInstanceService),l=e.get(u.LocaleService),s=e.get(pe,u.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=n.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),T=i,_=(j=r.getFilterColumn(i))==null?void 0:j.getColumnData().filters,E=new Set(_==null?void 0:_.filters),C=!!(_&&_.blank),y=r.getFilteredOutRowsExceptCol(i),P={...f,startRow:f.startRow+1,startColumn:T,endColumn:T};let M,b;if(s){const B=await s.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(y),filters:!!_,blankChecked:C,iterateRange:P,alreadyChecked:Array.from(E)});M=B.filterTreeItems,b=B.filterTreeMapCache}else{const B=Be(!!_,l,P,m,y,E,C,h.getStyles());M=B.filterTreeItems,b=B.filterTreeMapCache}return e.createInstance(Se,r,i,M,b)}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(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=u.Tools.deepClone(this._filterItems),i=Ne(r,e.key);if(!i)return;const n=xe(i);se(i,!n),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=u.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const n=Ne(r,i);n&&se(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=Pe(this._filterItems),{checked:r,checkedItems:i}=e,n=this.rawFilterItems;let l=0;for(const h of n)l+=h.count;const s=r===0,o=e.checked===l,a={colId:this.col};if(s)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(c.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==i.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})}};Se=be([de(4,u.ICommandService)],Se);const ee="FILTER_PANEL_OPENED",ne={id:"sheet.operation.open-filter-panel",type:u.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(u.IContextService),i=t.get(c.SheetsFilterService),n=t.get(G);t.get(u.ICommandService).syncExecuteCommand(w.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:s,subUnitId:o,col:a}=e,h=i.getFilterModel(s,o);return h?(n.setupCol(h,a),r.getContextValue(ee)||r.setContextValue(ee,!0),!0):!1}},J={id:"sheet.operation.close-filter-panel",type:u.CommandType.OPERATION,handler:t=>{const e=t.get(u.IContextService),r=t.get(G),i=t.get(F.ILayoutService,u.Quantity.OPTIONAL);return e.getContextValue(ee)?(e.setContextValue(ee,!1),i==null||i.focus(),r.terminate()):!1}},Le={id:"sheet.operation.apply-filter",type:u.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(G).changeFilterBy(r)}};var lt=Object.defineProperty,ct=Object.getOwnPropertyDescriptor,ut=(t,e,r,i)=>{for(var n=i>1?void 0:i?ct(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&<(e,r,n),n},z=(t,e)=>(r,i)=>e(r,i,t);let te=class extends u.Disposable{constructor(t,e,r,i,n,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=n,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===c.SmartToggleSheetsFilterCommand.id){const n=this._injector.get(u.IUniverInstanceService),l=O.getSheetCommandTarget(n);if(!l)return;const{unitId:s,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(s,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let T={...f};T=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(T,{left:!0,right:!0,up:!0,down:!0},a):T,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[T],s,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===ne.id){const n=t.params,{unitId:l,subUnitId:s}=n,o=(i=this._sheetsFilterService.getFilterModel(l,s))==null?void 0:i.getRange(),a=u.Tools.deepClone(o);a&&(a.startColumn=n.col,a.endColumn=n.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=ut([z(0,u.Inject(c.SheetsFilterService)),z(1,u.Inject(u.LocaleService)),z(2,u.ICommandService),z(3,u.Inject(O.SheetPermissionCheckController)),z(4,u.Inject(u.Injector)),z(5,u.Inject(O.SheetsSelectionsService))],te);var D=function(){return D=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t},D.apply(this,arguments)},ht=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n<i.length;n++)e.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(t,i[n])&&(r[i[n]]=t[i[n]]);return r},We=A.forwardRef(function(t,e){var r=t.icon,i=t.id,n=t.className,l=t.extend,s=ht(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(n||"").trim(),a=A.useRef("_".concat(dt()));return ke(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},D({ref:e,className:o},s),l)});function ke(t,e,r,i,n){return A.createElement(t.tag,D(D({key:e},mt(t,r,n)),i),(pt(t,r).children||[]).map(function(l,s){return ke(l,"".concat(e,"-").concat(t.tag,"-").concat(s),r,void 0,n)}))}function mt(t,e,r){var i=D({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var n=e.defIds;return!n||n.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var s=l[0],o=l[1];typeof o=="string"&&(i[s]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function pt(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?D(D({},t),{children:t.children.map(function(n){return typeof n.attrs.id=="string"&&i&&i.indexOf(n.attrs.id)>-1?D(D({},n),{attrs:D(D({},n.attrs),{id:n.attrs.id+e.idSuffix})}):n})}):t}function dt(){return Math.random().toString(36).substring(2,8)}We.displayName="UniverIcon";var ft={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Qe=A.forwardRef(function(t,e){return A.createElement(We,Object.assign({},t,{id:"filter-single",ref:e,icon:ft}))});Qe.displayName="FilterSingle";const _t="univer-sheets-filter-panel",St="univer-sheets-filter-panel-header",vt="univer-sheets-filter-panel-content",gt="univer-sheets-filter-panel-select-all",Ft="univer-sheets-filter-panel-select-all-count",Ct="univer-sheets-filter-panel-values-container",Tt="univer-input-affix-wrapper",Et="univer-select",Ot="univer-radio-group",Pt="univer-sheets-filter-panel-values-find",It="univer-sheets-filter-panel-values-list",Nt="univer-sheets-filter-panel-values-list-inner-container",yt="univer-sheets-filter-panel-values-virtual",Rt="univer-sheets-filter-panel-values-item",At="univer-sheets-filter-panel-values-item-inner",bt="univer-sheets-filter-panel-values-item-count",Lt="univer-sheets-filter-panel-values-item-exclude-button",Mt="univer-sheets-filter-panel-values-item-text",Ut="univer-sheets-filter-panel-conditions-container",$t="univer-sheets-filter-panel-conditions-container-inner",wt="univer-sheets-filter-panel-conditions-desc",Dt="univer-sheets-filter-panel-footer",Ht="univer-sheets-filter-panel-footer-primary-buttons",jt="univer-button",Bt="univer-input",xt="univer-form-dual-column-layout",Vt="univer-sheets-filter-tree-node",Wt="univer-sheets-filter-tree-node-filter-only",kt="univer-sheets-filter-tree-node-attach",I={sheetsFilterPanel:_t,sheetsFilterPanelHeader:St,sheetsFilterPanelContent:vt,sheetsFilterPanelSelectAll:gt,sheetsFilterPanelSelectAllCount:Ft,sheetsFilterPanelValuesContainer:Ct,inputAffixWrapper:Tt,select:Et,radioGroup:Ot,sheetsFilterPanelValuesFind:Pt,sheetsFilterPanelValuesList:It,sheetsFilterPanelValuesListInnerContainer:Nt,sheetsFilterPanelValuesVirtual:yt,sheetsFilterPanelValuesItem:Rt,sheetsFilterPanelValuesItemInner:At,sheetsFilterPanelValuesItemCount:bt,sheetsFilterPanelValuesItemExcludeButton:Lt,sheetsFilterPanelValuesItemText:Mt,sheetsFilterPanelConditionsContainer:Ut,sheetsFilterPanelConditionsContainerInner:$t,sheetsFilterPanelConditionsDesc:wt,sheetsFilterPanelFooter:Dt,sheetsFilterPanelFooterPrimaryButtons:Ht,button:jt,input:Bt,formDualColumnLayout:xt,sheetsFilterTreeNode:Vt,sheetsFilterTreeNodeFilterOnly:Wt,sheetsFilterTreeNodeAttach:kt};function Qt(t){var _,E;const{model:e}=t,r=F.useDependency(u.LocaleService),i=F.useObservable(e.conditionItem$,void 0),n=F.useObservable(e.filterConditionFormParams$,void 0),l=n!=null&&n.and?"AND":"OR",s=A.useCallback(C=>{e.onConditionFormChange({and:C==="AND"})},[e]),o=Gt(r),a=A.useCallback(C=>{e.onPrimaryConditionChange(C)},[e]),h=Yt(r),m=A.useCallback(C=>{e.onConditionFormChange(C)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function T(C,y,P){const M=p.getItemByOperator(C).numOfParameters===1;return d.jsxs(d.Fragment,{children:[P==="operator2"&&d.jsxs(L.RadioGroup,{value:l,onChange:s,children:[d.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(L.Select,{value:C,options:h,onChange:b=>m({[P]:b})}),M&&d.jsx("div",{children:d.jsx(L.Input,{value:y,placeholder:f,onChange:b=>m({[P==="operator1"?"val1":"val2"]:b})})})]})}return d.jsx("div",{className:I.sheetsFilterPanelConditionsContainer,children:i&&n&&d.jsxs(d.Fragment,{children:[d.jsx(L.Select,{value:i.operator,options:o,onChange:a}),p.getItemByOperator(i.operator).numOfParameters!==0?d.jsxs("div",{className:I.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&T(n.operator1,(_=n.val1)!=null?_:"","operator1"),i.numOfParameters>=2&&T(n.operator2,(E=n.val2)!=null?E:"","operator2"),d.jsxs("div",{className:I.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function Gt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function Yt(t){const e=t.getCurrentLocale();return A.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function qt(t){const{model:e}=t,r=F.useDependency(u.LocaleService),i=F.useObservable(e.searchString$,"",!0),n=F.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),s=Pe(n),o=s.checked>0&&s.unchecked===0,a=s.checked>0&&s.unchecked>0,h=e.treeMapCache,m=A.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=A.useCallback(_=>{e.setSearchString(_)},[e]);function T(_){let E=[];return _.forEach(C=>{C.checked&&E.push(C.key),C.children&&(E=E.concat(T(C.children)))}),E}return d.jsxs("div",{className:I.sheetsFilterPanelValuesContainer,children:[d.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{className:I.sheetsFilterPanelValuesList,children:[d.jsx("div",{className:I.sheetsFilterPanelValuesItem,children:d.jsxs("div",{className:I.sheetsFilterPanelValuesItemInner,children:[d.jsx(L.Checkbox,{indeterminate:a,disabled:n.length===0,checked:o,onChange:m}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${s.checked}/${s.checked+s.unchecked})`})]})}),d.jsx("div",{className:I.sheetsFilterPanelValuesVirtual,children:d.jsx(L.Tree,{data:n,defaultExpandAll:!1,valueGroup:T(n),height:180,onChange:_=>{e.onFilterCheckToggled(_)},defaultCache:h,itemHeight:28,treeNodeClassName:I.sheetsFilterTreeNode,attachRender:_=>d.jsxs("div",{className:I.sheetsFilterTreeNodeAttach,children:[d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${_.count})`}),d.jsx(L.Button,{className:I.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const E=[];_.children?_.children.forEach(C=>{C.children?C.children.forEach(y=>{E.push(y.key)}):E.push(C.key)}):E.push(_.key),e.onFilterOnly(E)},children:l})]})})})]})]})}function Kt(){var y;const t=F.useDependency(G),e=F.useDependency(u.LocaleService),r=F.useDependency(u.ICommandService),i=F.useObservable(t.filterBy$,void 0,!0),n=F.useObservable(t.filterByModel$,void 0,!1),l=F.useObservable(()=>(n==null?void 0:n.canApply$)||g.of(!1),void 0,!1,[n]),s=Xt(e),o=!F.useObservable(t.hasCriteria$),a=A.useCallback(P=>{r.executeCommand(Le.id,{filterBy:P})},[r]),h=A.useCallback(async()=>{await(n==null?void 0:n.clear()),r.executeCommand(J.id)},[n,r]),m=A.useCallback(()=>{r.executeCommand(J.id)},[r]),f=A.useCallback(async()=>{await(n==null?void 0:n.apply()),r.executeCommand(J.id)},[n,r]),_=(y=F.useDependency(c.SheetsFilterService).activeFilterModel)==null?void 0:y.getRange(),E=t.col,C=F.useComponentsOfPart(w.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:I.sheetsFilterPanel,children:[d.jsx(F.ComponentContainer,{components:C,sharedProps:{range:_,colIndex:E,onClose:m}}),d.jsx("div",{className:I.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,options:s,onChange:P=>a(P)})}),n?d.jsx("div",{className:I.sheetsFilterPanelContent,children:i===fe.VALUES?d.jsx(qt,{model:n}):d.jsx(Qt,{model:n})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:I.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:I.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function Xt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:fe.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:fe.CONDITIONS}],[e,t])}function Zt(t){const e=t.get(c.SheetsFilterService);return{id:c.SmartToggleSheetsFilterCommand.id,type:F.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:F.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(g.map(r=>!!r)),disabled$:w.getObservableWithExclusiveRange$(t,w.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function zt(t){const e=t.get(c.SheetsFilterService);return{id:c.ClearSheetsFilterCriteriaCommand.id,type:F.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:F.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}function Jt(t){const e=t.get(c.SheetsFilterService);return{id:c.ReCalcSheetsFilterCommand.id,type:F.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:F.getMenuHiddenObservable(t,u.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(g.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(g.map(n=>!n)))!=null?i:g.of(!0)}))}}const er={[F.RibbonStartGroup.FORMULAS_INSERT]:{[c.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:Zt,[c.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:zt},[c.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Jt}}}},Q=16,tr=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 Ue{static drawNoCriteria(e,r,i,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:Q,height:Q,fill:n}),e.lineCap="square",e.strokeStyle=i,e.scale(r/Q,r/Q),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,i,n){e.save(),ie.Rect.drawWith(e,{radius:2,width:Q,height:Q,fill:n}),e.scale(r/Q,r/Q),e.fillStyle=i,e.fill(tr),e.restore()}}var rr=Object.defineProperty,sr=Object.getOwnPropertyDescriptor,ir=(t,e,r,i)=>{for(var n=i>1?void 0:i?sr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&rr(e,r,n),n},Ee=(t,e)=>(r,i)=>e(r,i,t);const W=16,ue=1;let ye=class extends ie.Shape{constructor(e,r,i,n,l){super(e,r);S(this,"_cellWidth",0);S(this,"_cellHeight",0);S(this,"_filterParams");S(this,"_hovered",!1);this._contextService=i,this._commandService=n,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(s=>this.onPointerDown(s)),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,i=this._cellWidth,n=W-i,l=W-r;e.save();const s=new Path2D;s.rect(n,l,i,r),e.clip(s);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?Ue.drawHasCriteria(e,W,a,h):Ue.drawNoCriteria(e,W,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:n}=this._filterParams;this._contextService.getContextValue(ee)||!this._commandService.hasCommand(ne.id)||setTimeout(()=>{this._commandService.executeCommand(ne.id,{unitId:i,subUnitId:n,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};ye=ir([Ee(2,u.IContextService),Ee(3,u.ICommandService),Ee(4,u.Inject(u.ThemeService))],ye);var nr=Object.defineProperty,or=Object.getOwnPropertyDescriptor,ar=(t,e,r,i)=>{for(var n=i>1?void 0:i?or(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&nr(e,r,n),n},K=(t,e)=>(r,i)=>e(r,i,t);const lr=1e3,cr=5e3;let Re=class extends u.RxDisposable{constructor(e,r,i,n,l,s,o,a){super();S(this,"_filterRangeShape",null);S(this,"_buttonRenderDisposable",null);S(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=n,this._themeService=l,this._sheetInterceptorService=s,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(g.switchMap(e=>{var o,a;if(!e)return g.of(null);const{unit:r,unitId:i}=this._context,n=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,n))!=null?a:void 0,s=()=>({unitId:i,worksheetId:n,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===O.SetRangeValuesMutation.id)}),g.throttleTime(20,void 0,{leading:!1,trailing:!0}),g.map(s),g.startWith(s()))}),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:i}=this._context,{rowHeaderWidth:n,columnHeaderHeight:l}=r,s=this._filterRangeShape=new w.SelectionControl(i,lr,this._themeService,{rowHeaderWidth:n,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=w.attachSelectionWithCoord(o,r);s.updateRangeBySelectionWithCoord(a),s.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:n,skeleton:l,worksheetId:s}=e,{scene:o}=this._context;this._interceptCellContent(n,s,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const T=`sheets-filter-button-${f}`,_=w.getCoordByCell(m,f,o,l),{startX:E,startY:C,endX:y,endY:P}=_,M=y-E,b=P-C;if(b<=ue||M<=ue)continue;const j=!!i.getFilterColumn(f),B=y-W-ue,ae=P-W-ue,le={left:B,top:ae,height:W,width:W,zIndex:cr,cellHeight:b,cellWidth:M,filterParams:{unitId:n,subUnitId:s,col:f,hasCriteria:j}},U=this._injector.createInstance(ye,T,le);this._filterButtonShapes.push(U)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:n,startColumn:l,endColumn:s}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:u.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:T,subUnitId:_}=a;return T!==e||_!==r||m!==n||f<l||f>s?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:W}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};Re=ar([K(1,u.Inject(u.Injector)),K(2,u.Inject(w.SheetSkeletonManagerService)),K(3,u.Inject(c.SheetsFilterService)),K(4,u.Inject(u.ThemeService)),K(5,u.Inject(O.SheetInterceptorService)),K(6,u.ICommandService),K(7,w.ISheetSelectionRenderService)],Re);var ur=Object.defineProperty,hr=Object.getOwnPropertyDescriptor,mr=(t,e,r,i)=>{for(var n=i>1?void 0:i?hr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&ur(e,r,n),n},$e=(t,e)=>(r,i)=>e(r,i,t);let oe=class extends u.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[c.SetSheetsFilterRangeMutation,c.SetSheetsFilterCriteriaMutation,c.RemoveSheetsFilterMutation,c.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(u.UniverInstanceType.UNIVER_SHEET,[Re]))}};oe=mr([$e(0,ie.IRenderManagerService),$e(1,u.Inject(w.SheetsRenderService))],oe);const pr={id:c.SmartToggleSheetsFilterCommand.id,binding:F.KeyCode.L|F.MetaKeys.CTRL_COMMAND|F.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:w.whenSheetEditorFocused,group:"4_sheet-edit"};var dr=Object.defineProperty,fr=Object.getOwnPropertyDescriptor,_r=(t,e,r,i)=>{for(var n=i>1?void 0:i?fr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&dr(e,r,n),n},$=(t,e)=>(r,i)=>e(r,i,t);const we="FILTER_PANEL_POPUP";let ve=class extends oe{constructor(e,r,i,n,l,s,o,a,h,m,f,T,_){super(_,T);S(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=n,this._sheetsFilterService=l,this._localeService=s,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[pr].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[c.SmartToggleSheetsFilterCommand,c.RemoveSheetFilterCommand,c.SetSheetFilterRangeCommand,c.SetSheetsFilterCriteriaCommand,c.ClearSheetsFilterCriteriaCommand,c.ReCalcSheetsFilterCommand,Le,ne,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(er)}_initUI(){this.disposeWithMe(this._componentManager.register(we,Kt)),this.disposeWithMe(this._componentManager.register("FilterSingle",Qe)),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:L.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(),i=this._sheetsFilterPanelService.col,{startRow:n}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(n,i,{componentKey:we,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};ve=_r([$(0,u.Inject(u.Injector)),$(1,u.Inject(F.ComponentManager)),$(2,u.Inject(G)),$(3,u.Inject(w.SheetCanvasPopManagerService)),$(4,u.Inject(c.SheetsFilterService)),$(5,u.Inject(u.LocaleService)),$(6,F.IShortcutService),$(7,u.ICommandService),$(8,F.IMenuManagerService),$(9,u.IContextService),$(10,F.IMessageService),$(11,u.Inject(w.SheetsRenderService)),$(12,ie.IRenderManagerService)],ve);var Ge=Object.defineProperty,Sr=Object.getOwnPropertyDescriptor,vr=(t,e,r)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,gr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Sr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Ge(e,r,n),n},Oe=(t,e)=>(r,i)=>e(r,i,t),Ye=(t,e,r)=>vr(t,typeof e!="symbol"?e+"":e,r);const Fr="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterUIPlugin=class extends u.Plugin{constructor(e=me,r,i,n){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=n;const{menu:l,...s}=u.merge({},me,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(je,s)}onStarting(){[[G],[te],[ve]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([pe,{useFactory:()=>ge.toModule(this._rpcChannelService.requestChannel(Ae))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ve)}};Ye(exports.UniverSheetsFilterUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ye(exports.UniverSheetsFilterUIPlugin,"pluginName",Fr);exports.UniverSheetsFilterUIPlugin=gr([u.DependentOn(c.UniverSheetsFilterPlugin),Oe(1,u.Inject(u.Injector)),Oe(2,u.IConfigService),Oe(3,u.Optional(ge.IRPCChannelService))],exports.UniverSheetsFilterUIPlugin);var qe=Object.defineProperty,Cr=Object.getOwnPropertyDescriptor,Tr=(t,e,r)=>e in t?qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Er=(t,e,r,i)=>{for(var n=i>1?void 0:i?Cr(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&qe(e,r,n),n},De=(t,e)=>(r,i)=>e(r,i,t),Ke=(t,e,r)=>Tr(t,typeof e!="symbol"?e+"":e,r);const Or="SHEET_FILTER_UI_PLUGIN";exports.UniverSheetsFilterMobileUIPlugin=class extends u.Plugin{constructor(e=me,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:n,...l}=u.merge({},me,this._config);n&&this._configService.setConfig("menu",n,{merge:!0}),this._configService.setConfig(je,l)}onStarting(){[[te],[oe]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(oe)}};Ke(exports.UniverSheetsFilterMobileUIPlugin,"type",u.UniverInstanceType.UNIVER_SHEET);Ke(exports.UniverSheetsFilterMobileUIPlugin,"pluginName",Or);exports.UniverSheetsFilterMobileUIPlugin=Er([u.DependentOn(c.UniverSheetsFilterPlugin),De(1,u.Inject(u.Injector)),De(2,u.IConfigService)],exports.UniverSheetsFilterMobileUIPlugin);var Pr=Object.defineProperty,Ir=Object.getOwnPropertyDescriptor,Nr=(t,e,r,i)=>{for(var n=i>1?void 0:i?Ir(e,r):e,l=t.length-1,s;l>=0;l--)(s=t[l])&&(n=(i?s(e,r,n):s(n))||n);return i&&n&&Pr(e,r,n),n},He=(t,e)=>(r,i)=>e(r,i,t),he;exports.UniverSheetsFilterUIWorkerPlugin=(he=class extends u.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[pe,{useClass:Ie}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ae,ge.fromModule(this._injector.get(pe)))}},S(he,"type",u.UniverInstanceType.UNIVER_SHEET),S(he,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),he);exports.UniverSheetsFilterUIWorkerPlugin=Nr([He(1,u.Inject(u.Injector)),He(2,ge.IRPCChannelService)],exports.UniverSheetsFilterUIWorkerPlugin);exports.ChangeFilterByOperation=Le;exports.CloseFilterPanelOperation=J;exports.OpenFilterPanelOperation=ne;
|
package/lib/es/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
var Yt = Object.defineProperty;
|
|
2
2
|
var qt = (t, e, r) => e in t ? Yt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
|
|
3
3
|
var m = (t, e, r) => qt(t, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
-
import { BooleanNumber as st, createIdentifier as _t, Inject as E, LocaleService as X, Disposable as fe, IUniverInstanceService as je, ILogService as Kt, extractPureTextFromCell as Xt, numfmt as nt, Injector as Z, ICommandService as x, Quantity as St, Tools as Fe, CommandType as $e, IContextService as we,
|
|
4
|
+
import { BooleanNumber as st, createIdentifier as _t, Inject as E, LocaleService as X, Disposable as fe, IUniverInstanceService as je, ILogService as Kt, extractPureTextFromCell as Xt, numfmt as nt, Injector as Z, ICommandService as x, Quantity as St, Tools as Fe, CommandType as $e, IContextService as we, UniverInstanceType as z, ThemeService as gt, RxDisposable as vt, fromCallback as Zt, InterceptorEffectEnum as zt, DependentOn as Et, Optional as Jt, Plugin as Ye, merge as Tt, IConfigService as Ft } from "@univerjs/core";
|
|
5
5
|
import { IRPCChannelService as Ct, toModule as er, fromModule as tr } from "@univerjs/rpc";
|
|
6
6
|
import { CustomFilterOperator as u, SetSheetsFilterCriteriaCommand as se, SheetsFilterService as G, SmartToggleSheetsFilterCommand as me, ClearSheetsFilterCriteriaCommand as qe, ReCalcSheetsFilterCommand as Ke, FILTER_MUTATIONS as rr, SetSheetsFilterRangeMutation as sr, SetSheetsFilterCriteriaMutation as nr, RemoveSheetsFilterMutation as ir, ReCalcSheetsFilterMutation as or, RemoveSheetFilterCommand as ar, SetSheetFilterRangeCommand as lr, UniverSheetsFilterPlugin as Nt } from "@univerjs/sheets-filter";
|
|
7
7
|
import { RefRangeService as cr, SheetPermissionCheckController as ur, SheetsSelectionsService as hr, getSheetCommandTarget as dr, RangeProtectionPermissionViewPoint as le, WorksheetFilterPermission as ce, WorksheetViewPermission as ue, expandToContinuousRange as pr, SheetInterceptorService as fr, SetRangeValuesMutation as mr, INTERCEPTOR_POINT as _r } from "@univerjs/sheets";
|
|
8
|
-
import { ILayoutService as Sr, useObservable as Q, useComponentsOfPart as gr, ComponentContainer as vr, MenuItemType as Xe, getMenuHiddenObservable as Ze, RibbonStartGroup as Er, KeyCode as Tr, MetaKeys as it, ComponentManager as Fr, IShortcutService as Cr, IMenuManagerService as Nr, IMessageService as Pr } from "@univerjs/ui";
|
|
8
|
+
import { ILayoutService as Sr, useDependency as re, useObservable as Q, useComponentsOfPart as gr, ComponentContainer as vr, MenuItemType as Xe, getMenuHiddenObservable as Ze, RibbonStartGroup as Er, KeyCode as Tr, MetaKeys as it, ComponentManager as Fr, IShortcutService as Cr, IMenuManagerService as Nr, IMessageService as Pr } from "@univerjs/ui";
|
|
9
9
|
import { SetCellEditVisibleOperation as Or, SheetsUIPart as Ir, getObservableWithExclusiveRange$ as yr, getCurrentRangeDisable$ as Rr, SheetSkeletonManagerService as Ar, ISheetSelectionRenderService as br, SelectionControl as Lr, attachSelectionWithCoord as Mr, getCoordByCell as $r, SheetsRenderService as Pt, whenSheetEditorFocused as wr, SheetCanvasPopManagerService as Ur } from "@univerjs/sheets-ui";
|
|
10
10
|
import { BehaviorSubject as K, ReplaySubject as Hr, of as _e, Subject as Dr, merge as Br, combineLatest as Vr, throttleTime as Ot, startWith as It, map as ne, shareReplay as Wr, switchMap as ze, filter as Qr, takeUntil as kr, distinctUntilChanged as xr } from "rxjs";
|
|
11
11
|
import { Select as ot, RadioGroup as Gr, Radio as at, Input as yt, Checkbox as jr, Tree as Yr, Button as Ce, Segmented as qr, MessageType as Kr } from "@univerjs/design";
|
|
@@ -1383,6 +1383,7 @@ function Ys(t) {
|
|
|
1383
1383
|
{ label: t.t("sheets-filter.panel.by-values"), value: Ie.VALUES },
|
|
1384
1384
|
{ label: t.t("sheets-filter.panel.by-conditions"), value: Ie.CONDITIONS }
|
|
1385
1385
|
],
|
|
1386
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1386
1387
|
[e, t]
|
|
1387
1388
|
);
|
|
1388
1389
|
}
|
package/lib/types/index.d.ts
CHANGED
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(_,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("@univerjs/sheets-filter"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/rpc","@univerjs/sheets-filter","@univerjs/sheets","@univerjs/ui","@univerjs/sheets-ui","rxjs","@univerjs/design","@univerjs/engine-render","react/jsx-runtime","react"],l):(_=typeof globalThis<"u"?globalThis:_||self,l(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverRpc,_.UniverSheetsFilter,_.UniverSheets,_.UniverUi,_.UniverSheetsUi,_.rxjs,_.UniverDesign,_.UniverEngineRender,_.React,_.React))})(this,function(_,l,j,u,O,E,w,C,L,ie,d,A){"use strict";var zt=Object.defineProperty;var Jt=(_,l,j)=>l in _?zt(_,l,{enumerable:!0,configurable:!0,writable:!0,value:j}):_[l]=j;var v=(_,l,j)=>Jt(_,typeof l!="symbol"?l+"":l,j);var Se;const Ue="sheets-filter-ui.config",ce={};var y=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(y||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:y.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:n=>n.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:n=>!n.customFilters&&!n.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:y.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:y.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===g.CONTAINS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:n=>{const[o]=V(n);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`${n.val1}*`}]}}),testMappingParams:n=>{const[o]=V(n);return o===g.STARTS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}`}]}}),testMappingParams:n=>{const[o]=V(n);return o===g.ENDS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===g.EQUALS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:n=>{var o,a,h;return((a=(o=n.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=n.customFilters)==null?void 0:h.customFilters.length)===1&&!n.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:n.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:y.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(!o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:l.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:y.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:y.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:n=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=n;function F(U,M){for(const B of t.ALL_CONDITIONS)if(B.operator===U)return B.mapToFilterColumn({val1:M,operator1:U})}const S=!m||m===t.NONE.operator,P=!f||f===t.NONE.operator;if(S&&P)return t.NONE.mapToFilterColumn({});if(S)return F(f,h);if(P)return F(m,a);const T=F(m,a),b=F(f,h),N={customFilters:[T.customFilters.customFilters[0],b.customFilters.customFilters[0]]};return o&&(N.and=l.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=n.customFilters.customFilters.map(m=>c({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return n.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(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${n}`);return o}t.getItemByOperator=e;function r(n,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(n))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(n))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function s(n,o){return n.mapToFilterColumn(o)}t.mapToFilterColumn=s;function c(n){if(!n)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(n);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=c})(p||(p={}));function V(t){const{operator1:e,operator2:r,val1:i,val2:s}=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,i]:[r,s]}function Te(t){const e=[],r=[];let i=0,s=0;function c(n){n.leaf&&(n.checked?(e.push(n),i+=n.count):(r.push(n),s+=n.count)),n.children&&n.children.forEach(c)}return t.forEach(c),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:s}}var Ze=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Je=(t,e,r,i)=>{for(var s=i>1?void 0:i?ze(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Ze(e,r,s),s},Fe=(t,e)=>(r,i)=>e(r,i,t);const Ee="sheets-filter.generate-filter-values.service",ue=l.createIdentifier(Ee),et=["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 l.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:s,blankChecked:c,iterateRange:n,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),$e(s,this._localeService,n,h,new Set(i),new Set(o.map(String)),c,a.getStyles()))}};Pe=Je([Fe(0,l.Inject(l.LocaleService)),Fe(1,l.IUniverInstanceService),Fe(2,l.ILogService)],Pe);function $e(t,e,r,i,s,c,n,o){var T,b,N,U,M,B,W,ve,ge;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(et),F="empty";let S=0;for(const $ of i.iterateByColumn(r,!1,!1)){const{row:Kt,rowSpan:Xe=1}=$;let re=0;for(;re<Xe;){const Xt=Kt+re;if(s.has(Xt)){re++;continue}const X=$!=null&&$.value?l.extractPureTextFromCell($.value):"";if(!X){S+=1,re+=Xe;continue}const Ce=(T=$.value)!=null&&T.v&&!$.value.p?(U=(N=o.get((b=$.value)==null?void 0:b.s))==null?void 0:N.n)==null?void 0:U.pattern:"",Zt=Ce&&l.numfmt.isDate(Ce);if(Ce&&Zt&&f.has(Ce)){const q=(M=i.getCellRaw($.row,$.col))==null?void 0:M.v;if(!q){re++;continue}const ne=l.numfmt.format(m,q),[R,k,le]=ne.split("-").map(Number);let Z=a.get(`${R}`);Z||(Z={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,Z),h.set(`${R}`,[`${R}`]));let G=(B=Z.children)==null?void 0:B.find(Me=>Me.key===`${R}-${k}`);G||(G={title:e.t(`sheets-filter.date.${k}`),key:`${R}-${k}`,children:[],count:0,leaf:!1,checked:!1},(W=Z.children)==null||W.push(G),h.set(`${R}-${k}`,[`${R}`,`${R}-${k}`]));const Le=(ve=G==null?void 0:G.children)==null?void 0:ve.find(Me=>Me.key===`${R}-${k}-${le}`);Le?(Le.originValues.add(X),Le.count++,G.count++,Z.count++):((ge=G.children)==null||ge.push({title:`${le}`,key:`${R}-${k}-${le}`,count:1,originValues:new Set([X]),leaf:!0,checked:c.size?c.has(X):!n}),G.count++,Z.count++,h.set(`${R}-${k}-${le}`,[`${R}`,`${R}-${k}`,`${R}-${k}-${le}`]))}else{const q=X;let ne=a.get(q);ne?ne.count++:(ne={title:X,leaf:!0,checked:c.size?c.has(X):!n,key:q,count:1},a.set(q,ne),h.set(q,[q]))}re++}}const P=t?n:!0;if(S>0){const $={title:e.t("sheets-filter.panel.empty"),count:S,leaf:!0,checked:P,key:F};a.set("empty",$),h.set("empty",[F])}return{filterTreeItems:tt(Array.from(a.values())),filterTreeMapCache:h}}function tt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const s=Number.parseInt(r.key.split("-")[1],10),c=Number.parseInt(i.key.split("-")[1],10);return s-c}).forEach(r=>{r.children&&r.children.sort((i,s)=>{const c=Number.parseInt(i.key.split("-")[2],10),n=Number.parseInt(s.key.split("-")[2],10);return c-n})}),e))}function Oe(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Oe(r.children,e);if(i)return i}}return null}function we(t){return t.leaf?t.checked:t.children?t.children.every(e=>we(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function De(t,e){const r=[];return t.forEach(i=>{const s=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,c=!s&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(s||c)r.push({...i});else if(i.children){const o=De(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var rt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,Ie=(t,e,r,i)=>{for(var s=i>1?void 0:i?nt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&rt(e,r,s),s},he=(t,e)=>(r,i)=>e(r,i,t),me=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(me||{});l.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let x=class extends l.Disposable{constructor(e,r){super();v(this,"_filterBy$",new C.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new C.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new C.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new C.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 i=e.getFilterColumn(r);if(i){const s=i.getColumnData();if(s.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(s.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,s=e.subUnitId,c=e.getRange(),n={startColumn:r,startRow:c.startRow,endRow:c.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,s,n,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=await de.fromFilterColumn(this._injector,e,r);return this.filterByModel=s,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=pe.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=s,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};x=Ie([he(0,l.Inject(l.Injector)),he(1,l.Inject(O.RefRangeService))],x);let pe=class extends l.Disposable{constructor(e,r,i,s,c){super();v(this,"canApply$",C.of(!0));v(this,"_conditionItem$");v(this,"conditionItem$");v(this,"_filterConditionFormParams$");v(this,"filterConditionFormParams$");this._filterModel=e,this.col=r,this._commandService=c,this._conditionItem$=new C.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(s),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,s){const[c,n]=p.testMappingFilterColumn(s==null?void 0:s.getColumnData());return e.createInstance(pe,r,i,c,n)}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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};pe=Ie([he(4,l.ICommandService)],pe);let de=class extends l.Disposable{constructor(e,r,i,s,c){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=c,this._treeMapCache=s,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([n,o])=>{if(!n)return o;const h=n.toLowerCase().split(/\s+/).filter(m=>!!m);return De(o,h)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(n=>Te(n).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(n=>this._filterItems=n))}static async fromFilterColumn(e,r,i){var B;const s=e.get(l.IUniverInstanceService),c=e.get(l.LocaleService),n=e.get(ue,l.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=s.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),F=i,S=(B=r.getFilterColumn(i))==null?void 0:B.getColumnData().filters,P=new Set(S==null?void 0:S.filters),T=!!(S&&S.blank),b=r.getFilteredOutRowsExceptCol(i),N={...f,startRow:f.startRow+1,startColumn:F,endColumn:F};let U,M;if(n){const W=await n.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(b),filters:!!S,blankChecked:T,iterateRange:N,alreadyChecked:Array.from(P)});U=W.filterTreeItems,M=W.filterTreeMapCache}else{const W=$e(!!S,c,N,m,b,P,T,h.getStyles());U=W.filterTreeItems,M=W.filterTreeMapCache}return e.createInstance(de,r,i,U,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=l.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=l.Tools.deepClone(this._filterItems),i=Oe(r,e.key);if(!i)return;const s=we(i);se(i,!s),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=l.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const s=Oe(r,i);s&&se(s,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Te(this._filterItems),{checked:r,checkedItems:i}=e,s=this.rawFilterItems;let c=0;for(const h of s)c+=h.count;const n=r===0,o=e.checked===c,a={colId:this.col};if(n)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};de=Ie([he(4,l.ICommandService)],de);const z="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:l.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(l.IContextService),i=t.get(u.SheetsFilterService),s=t.get(x);t.get(l.ICommandService).syncExecuteCommand(w.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:n,subUnitId:o,col:a}=e,h=i.getFilterModel(n,o);return h?(s.setupCol(h,a),r.getContextValue(z)||r.setContextValue(z,!0),!0):!1}},J={id:"sheet.operation.close-filter-panel",type:l.CommandType.OPERATION,handler:t=>{const e=t.get(l.IContextService),r=t.get(x),i=t.get(E.ILayoutService,l.Quantity.OPTIONAL);return e.getContextValue(z)?(e.setContextValue(z,!1),i==null||i.focus(),r.terminate()):!1}},Ne={id:"sheet.operation.apply-filter",type:l.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(x).changeFilterBy(r)}};var it=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ot=(t,e,r,i)=>{for(var s=i>1?void 0:i?st(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&it(e,r,s),s},ee=(t,e)=>(r,i)=>e(r,i,t);let te=class extends l.Disposable{constructor(t,e,r,i,s,c){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=s,this._sheetsSelectionService=c,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const s=this._injector.get(l.IUniverInstanceService),c=O.getSheetCommandTarget(s);if(!c)return;const{unitId:n,subUnitId:o,worksheet:a}=c,h=(e=this._sheetsFilterService.getFilterModel(n,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let F={...f};F=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(F,{left:!0,right:!0,up:!0,down:!0},a):F,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[F],n,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const s=t.params,{unitId:c,subUnitId:n}=s,o=(i=this._sheetsFilterService.getFilterModel(c,n))==null?void 0:i.getRange(),a=l.Tools.deepClone(o);a&&(a.startColumn=s.col,a.endColumn=s.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=ot([ee(0,l.Inject(u.SheetsFilterService)),ee(1,l.Inject(l.LocaleService)),ee(2,l.ICommandService),ee(3,l.Inject(O.SheetPermissionCheckController)),ee(4,l.Inject(l.Injector)),ee(5,l.Inject(O.SheetsSelectionsService))],te);var H=function(){return H=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},H.apply(this,arguments)},at=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},He=A.forwardRef(function(t,e){var r=t.icon,i=t.id,s=t.className,c=t.extend,n=at(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),a=A.useRef("_".concat(ut()));return Ve(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},H({ref:e,className:o},n),c)});function Ve(t,e,r,i,s){return A.createElement(t.tag,H(H({key:e},lt(t,r,s)),i),(ct(t,r).children||[]).map(function(c,n){return Ve(c,"".concat(e,"-").concat(t.tag,"-").concat(n),r,void 0,s)}))}function lt(t,e,r){var i=H({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(c){var n=c[0],o=c[1];typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function ct(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?H(H({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?H(H({},s),{attrs:H(H({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function ut(){return Math.random().toString(36).substring(2,8)}He.displayName="UniverIcon";var ht={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Be=A.forwardRef(function(t,e){return A.createElement(He,Object.assign({},t,{id:"filter-single",ref:e,icon:ht}))});Be.displayName="FilterSingle";const I={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelSelectAll:"univer-sheets-filter-panel-select-all",sheetsFilterPanelSelectAllCount:"univer-sheets-filter-panel-select-all-count",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",inputAffixWrapper:"univer-input-affix-wrapper",select:"univer-select",radioGroup:"univer-radio-group",sheetsFilterPanelValuesFind:"univer-sheets-filter-panel-values-find",sheetsFilterPanelValuesList:"univer-sheets-filter-panel-values-list",sheetsFilterPanelValuesListInnerContainer:"univer-sheets-filter-panel-values-list-inner-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemExcludeButton:"univer-sheets-filter-panel-values-item-exclude-button",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons",button:"univer-button",input:"univer-input",formDualColumnLayout:"univer-form-dual-column-layout",sheetsFilterTreeNode:"univer-sheets-filter-tree-node",sheetsFilterTreeNodeFilterOnly:"univer-sheets-filter-tree-node-filter-only",sheetsFilterTreeNodeAttach:"univer-sheets-filter-tree-node-attach"};function mt(t){var S,P;const{model:e}=t,r=l.useDependency(l.LocaleService),i=E.useObservable(e.conditionItem$,void 0),s=E.useObservable(e.filterConditionFormParams$,void 0),c=s!=null&&s.and?"AND":"OR",n=A.useCallback(T=>{e.onConditionFormChange({and:T==="AND"})},[e]),o=pt(r),a=A.useCallback(T=>{e.onPrimaryConditionChange(T)},[e]),h=dt(r),m=A.useCallback(T=>{e.onConditionFormChange(T)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function F(T,b,N){const U=p.getItemByOperator(T).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(L.RadioGroup,{value:c,onChange:n,children:[d.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(L.Select,{value:T,options:h,onChange:M=>m({[N]:M})}),U&&d.jsx("div",{children:d.jsx(L.Input,{value:b,placeholder:f,onChange:M=>m({[N==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{className:I.sheetsFilterPanelConditionsContainer,children:i&&s&&d.jsxs(d.Fragment,{children:[d.jsx(L.Select,{value:i.operator,options:o,onChange:a}),p.getItemByOperator(i.operator).numOfParameters!==0?d.jsxs("div",{className:I.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&F(s.operator1,(S=s.val1)!=null?S:"","operator1"),i.numOfParameters>=2&&F(s.operator2,(P=s.val2)!=null?P:"","operator2"),d.jsxs("div",{className:I.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function pt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function dt(t){const e=t.getCurrentLocale();return A.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function ft(t){const{model:e}=t,r=l.useDependency(l.LocaleService),i=E.useObservable(e.searchString$,"",!0),s=E.useObservable(e.filterItems$,void 0,!0),c=r.t("sheets-filter.panel.filter-only"),n=Te(s),o=n.checked>0&&n.unchecked===0,a=n.checked>0&&n.unchecked>0,h=e.treeMapCache,m=A.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=A.useCallback(S=>{e.setSearchString(S)},[e]);function F(S){let P=[];return S.forEach(T=>{T.checked&&P.push(T.key),T.children&&(P=P.concat(F(T.children)))}),P}return d.jsxs("div",{className:I.sheetsFilterPanelValuesContainer,children:[d.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{className:I.sheetsFilterPanelValuesList,children:[d.jsx("div",{className:I.sheetsFilterPanelValuesItem,children:d.jsxs("div",{className:I.sheetsFilterPanelValuesItemInner,children:[d.jsx(L.Checkbox,{indeterminate:a,disabled:s.length===0,checked:o,onChange:m}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${n.checked}/${n.checked+n.unchecked})`})]})}),d.jsx("div",{className:I.sheetsFilterPanelValuesVirtual,children:d.jsx(L.Tree,{data:s,defaultExpandAll:!1,valueGroup:F(s),height:180,onChange:S=>{e.onFilterCheckToggled(S)},defaultCache:h,itemHeight:28,treeNodeClassName:I.sheetsFilterTreeNode,attachRender:S=>d.jsxs("div",{className:I.sheetsFilterTreeNodeAttach,children:[d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${S.count})`}),d.jsx(L.Button,{className:I.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const P=[];S.children?S.children.forEach(T=>{T.children?T.children.forEach(b=>{P.push(b.key)}):P.push(T.key)}):P.push(S.key),e.onFilterOnly(P)},children:c})]})})})]})]})}function _t(){var b;const t=l.useDependency(x),e=l.useDependency(l.LocaleService),r=l.useDependency(l.ICommandService),i=E.useObservable(t.filterBy$,void 0,!0),s=E.useObservable(t.filterByModel$,void 0,!1),c=E.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=St(e),o=!E.useObservable(t.hasCriteria$),a=A.useCallback(N=>{r.executeCommand(Ne.id,{filterBy:N})},[r]),h=A.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(J.id)},[s,r]),m=A.useCallback(()=>{r.executeCommand(J.id)},[r]),f=A.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(J.id)},[s,r]),S=(b=l.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:b.getRange(),P=t.col,T=E.useComponentsOfPart(w.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:I.sheetsFilterPanel,children:[d.jsx(E.ComponentContainer,{components:T,sharedProps:{range:S,colIndex:P,onClose:m}}),d.jsx("div",{className:I.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,options:n,onChange:N=>a(N)})}),s?d.jsx("div",{className:I.sheetsFilterPanelContent,children:i===me.VALUES?d.jsx(ft,{model:s}):d.jsx(mt,{model:s})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:I.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:I.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!c,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function St(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:me.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:me.CONDITIONS}],[e,t])}function vt(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:E.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:E.getMenuHiddenObservable(t,l.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:w.getObservableWithExclusiveRange$(t,w.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function gt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:E.getMenuHiddenObservable(t,l.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function Ct(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:E.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:E.getMenuHiddenObservable(t,l.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const Tt={[E.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:vt,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:gt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ct}}}},Y=16,Ft=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,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,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,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(Ft),e.restore()}}var Et=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ot=(t,e,r,i)=>{for(var s=i>1?void 0:i?Pt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Et(e,r,s),s},ye=(t,e)=>(r,i)=>e(r,i,t);const Q=16,fe=1;let Ae=class extends ie.Shape{constructor(e,r,i,s,c){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=c,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),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,i=this._cellWidth,s=Q-i,c=Q-r;e.save();const n=new Path2D;n.rect(s,c,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?We.drawHasCriteria(e,Q,a,h):We.drawNoCriteria(e,Q,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(z)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Ae=Ot([ye(2,l.IContextService),ye(3,l.ICommandService),ye(4,l.Inject(l.ThemeService))],Ae);var It=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,yt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Nt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&It(e,r,s),s},K=(t,e)=>(r,i)=>e(r,i,t);const At=1e3,bt=5e3;let be=class extends l.RxDisposable{constructor(e,r,i,s,c,n,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=c,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",c=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:c,range:c==null?void 0:c.getRange(),skeleton:e.skeleton});return l.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===l.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===O.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:c}=r,n=this._filterRangeShape=new w.SelectionControl(i,At,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:c,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=w.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:c,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const F=`sheets-filter-button-${f}`,S=w.getCoordByCell(m,f,o,c),{startX:P,startY:T,endX:b,endY:N}=S,U=b-P,M=N-T;if(M<=fe||U<=fe)continue;const B=!!i.getFilterColumn(f),W=b-Q-fe,ve=N-Q-fe,ge={left:W,top:ve,height:Q,width:Q,zIndex:bt,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:f,hasCriteria:B}},$=this._injector.createInstance(Ae,F,ge);this._filterButtonShapes.push($)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:c,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:F,subUnitId:S}=a;return F!==e||S!==r||m!==s||f<c||f>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:Q}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=yt([K(1,l.Inject(l.Injector)),K(2,l.Inject(w.SheetSkeletonManagerService)),K(3,l.Inject(u.SheetsFilterService)),K(4,l.Inject(l.ThemeService)),K(5,l.Inject(O.SheetInterceptorService)),K(6,l.ICommandService),K(7,w.ISheetSelectionRenderService)],be);var Rt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,Mt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Lt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Rt(e,r,s),s},ke=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends l.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(l.UniverInstanceType.UNIVER_SHEET,[be]))}};ae=Mt([ke(0,ie.IRenderManagerService),ke(1,l.Inject(w.SheetsRenderService))],ae);const Ut={id:u.SmartToggleSheetsFilterCommand.id,binding:E.KeyCode.L|E.MetaKeys.CTRL_COMMAND|E.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:w.whenSheetEditorFocused,group:"4_sheet-edit"};var $t=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,Dt=(t,e,r,i)=>{for(var s=i>1?void 0:i?wt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&$t(e,r,s),s},D=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let _e=class extends ae{constructor(e,r,i,s,c,n,o,a,h,m,f,F,S){super(S,F);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=c,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[Ut].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Ne,oe,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Tt)}_initUI(){this.disposeWithMe(this._componentManager.register(je,_t)),this.disposeWithMe(this._componentManager.register("FilterSingle",Be)),this.disposeWithMe(this._contextService.subscribeContextValue$(z).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.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(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};_e=Dt([D(0,l.Inject(l.Injector)),D(1,l.Inject(E.ComponentManager)),D(2,l.Inject(x)),D(3,l.Inject(w.SheetCanvasPopManagerService)),D(4,l.Inject(u.SheetsFilterService)),D(5,l.Inject(l.LocaleService)),D(6,E.IShortcutService),D(7,l.ICommandService),D(8,E.IMenuManagerService),D(9,l.IContextService),D(10,E.IMessageService),D(11,l.Inject(w.SheetsRenderService)),D(12,ie.IRenderManagerService)],_e);var Qe=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Vt=(t,e,r)=>e in t?Qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ht(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Qe(e,r,s),s},Re=(t,e)=>(r,i)=>e(r,i,t),Ge=(t,e,r)=>Vt(t,typeof e!="symbol"?e+"":e,r);const Wt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends l.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:c,...n}=l.merge({},ce,this._config);c&&this._configService.setConfig("menu",c,{merge:!0}),this._configService.setConfig(Ue,n)}onStarting(){[[x],[te],[_e]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([ue,{useFactory:()=>j.toModule(this._rpcChannelService.requestChannel(Ee))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(_e)}},Ge(_.UniverSheetsFilterUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),Ge(_.UniverSheetsFilterUIPlugin,"pluginName",Wt),_.UniverSheetsFilterUIPlugin=Bt([l.DependentOn(u.UniverSheetsFilterPlugin),Re(1,l.Inject(l.Injector)),Re(2,l.IConfigService),Re(3,l.Optional(j.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var xe=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,jt=(t,e,r)=>e in t?xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qt=(t,e,r,i)=>{for(var s=i>1?void 0:i?kt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&xe(e,r,s),s},Ye=(t,e)=>(r,i)=>e(r,i,t),qe=(t,e,r)=>jt(t,typeof e!="symbol"?e+"":e,r);const Gt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends l.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...c}=l.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ue,c)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}},qe(_.UniverSheetsFilterMobileUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET),qe(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Gt),_.UniverSheetsFilterMobileUIPlugin=Qt([l.DependentOn(u.UniverSheetsFilterPlugin),Ye(1,l.Inject(l.Injector)),Ye(2,l.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var xt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,qt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Yt(e,r):e,c=t.length-1,n;c>=0;c--)(n=t[c])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&xt(e,r,s),s},Ke=(t,e)=>(r,i)=>e(r,i,t);_.UniverSheetsFilterUIWorkerPlugin=(Se=class extends l.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[ue,{useClass:Pe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ee,j.fromModule(this._injector.get(ue)))}},v(Se,"type",l.UniverInstanceType.UNIVER_SHEET),v(Se,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),Se),_.UniverSheetsFilterUIWorkerPlugin=qt([Ke(1,l.Inject(l.Injector)),Ke(2,j.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ne,_.CloseFilterPanelOperation=J,_.OpenFilterPanelOperation=oe,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(_,c){typeof exports=="object"&&typeof module<"u"?c(exports,require("@univerjs/core"),require("@univerjs/rpc"),require("@univerjs/sheets-filter"),require("@univerjs/sheets"),require("@univerjs/ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/design"),require("@univerjs/engine-render"),require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/rpc","@univerjs/sheets-filter","@univerjs/sheets","@univerjs/ui","@univerjs/sheets-ui","rxjs","@univerjs/design","@univerjs/engine-render","react/jsx-runtime","react"],c):(_=typeof globalThis<"u"?globalThis:_||self,c(_.UniverSheetsFilterUi={},_.UniverCore,_.UniverRpc,_.UniverSheetsFilter,_.UniverSheets,_.UniverUi,_.UniverSheetsUi,_.rxjs,_.UniverDesign,_.UniverEngineRender,_.React,_.React))})(this,function(_,c,j,u,O,T,w,C,L,ie,d,A){"use strict";var zt=Object.defineProperty;var Jt=(_,c,j)=>c in _?zt(_,c,{enumerable:!0,configurable:!0,writable:!0,value:j}):_[c]=j;var v=(_,c,j)=>Jt(_,typeof c!="symbol"?c+"":c,j);var Se;const Ue="sheets-filter-ui.config",ce={};var y=(t=>(t[t.FIRST=0]="FIRST",t[t.SECOND=1]="SECOND",t))(y||{}),g=(t=>(t.NONE="none",t.STARTS_WITH="startsWith",t.DOES_NOT_START_WITH="doesNotStartWith",t.ENDS_WITH="endsWith",t.DOES_NOT_END_WITH="doesNotEndWith",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="doesNotContain",t.EQUALS="equals",t.NOT_EQUALS="notEquals",t.EMPTY="empty",t.NOT_EMPTY="notEmpty",t.BETWEEN="between",t.NOT_BETWEEN="notBetween",t.CUSTOM="custom",t))(g||{}),p;(t=>{t.NONE={label:"sheets-filter.conditions.none",operator:g.NONE,order:y.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NONE]: should not have initial form params!")},testMappingParams:n=>n.operator1===g.NONE,mapToFilterColumn:()=>null,testMappingFilterColumn:n=>!n.customFilters&&!n.filters?{}:!1},t.EMPTY={label:"sheets-filter.conditions.empty",operator:g.EMPTY,order:y.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:""}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===""&&o.operator===void 0?{operator1:g.EMPTY}:!1}},t.NOT_EMPTY={label:"sheets-filter.conditions.not-empty",operator:g.NOT_EMPTY,order:y.SECOND,numOfParameters:0,getDefaultFormParams:()=>{throw new Error("[FilterConditionItems.NOT_EMPTY]: should not have initial form params!")},testMappingParams:({operator1:n})=>n===g.NOT_EMPTY,mapToFilterColumn:()=>({customFilters:{customFilters:[{val:"",operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.val===" "&&o.operator===u.CustomFilterOperator.NOT_EQUALS?{operator1:g.NOT_EMPTY}:!1}},t.TEXT_CONTAINS={label:"sheets-filter.conditions.text-contains",operator:g.CONTAINS,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.CONTAINS,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===g.CONTAINS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:`*${o}*`}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.CONTAINS,val1:a.slice(1,-1)}:!1}},t.DOES_NOT_CONTAIN={label:"sheets-filter.conditions.does-not-contain",operator:g.DOES_NOT_CONTAIN,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.DOES_NOT_CONTAIN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}*`,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingParams:n=>{const[o]=V(n);return o===g.DOES_NOT_CONTAIN},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return o.operator===u.CustomFilterOperator.NOT_EQUALS&&a.startsWith("*")&&a.endsWith("*")?{operator1:g.DOES_NOT_CONTAIN,val1:a.slice(1,-1)}:!1}},t.STARTS_WITH={label:"sheets-filter.conditions.starts-with",operator:g.STARTS_WITH,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.STARTS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`${n.val1}*`}]}}),testMappingParams:n=>{const[o]=V(n);return o===g.STARTS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.endsWith("*")&&!a.startsWith("*")?{operator1:g.STARTS_WITH,val1:a.slice(0,-1)}:!1}},t.ENDS_WITH={label:"sheets-filter.conditions.ends-with",operator:g.ENDS_WITH,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.ENDS_WITH,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:`*${n.val1}`}]}}),testMappingParams:n=>{const[o]=V(n);return o===g.ENDS_WITH},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0],a=o.val.toString();return!o.operator&&a.startsWith("*")&&!a.endsWith("*")?{operator1:g.ENDS_WITH,val1:a.slice(1)}:!1}},t.EQUALS={label:"sheets-filter.conditions.equals",operator:g.EQUALS,order:y.FIRST,numOfParameters:1,getDefaultFormParams:()=>({operator1:g.EQUALS,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===g.EQUALS},mapToFilterColumn:n=>{const{val1:o}=n;return o===""?null:{customFilters:{customFilters:[{val:o}]}}},testMappingFilterColumn:n=>{var o,a,h;return((a=(o=n.filters)==null?void 0:o.filters)==null?void 0:a.length)===1?{operator1:g.EQUALS,val1:""}:((h=n.customFilters)==null?void 0:h.customFilters.length)===1&&!n.customFilters.customFilters[0].operator?{operator1:g.EQUALS,val1:n.customFilters.customFilters[0].val.toString()}:!1}},t.GREATER_THAN={label:"sheets-filter.conditions.greater-than",operator:u.CustomFilterOperator.GREATER_THAN,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN,val1:""}),mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN}]}}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.GREATER_THAN},testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN?!1:{operator1:u.CustomFilterOperator.GREATER_THAN,val1:o.val.toString()}}},t.GREATER_THAN_OR_EQUAL={label:"sheets-filter.conditions.greater-than-or-equal",operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.GREATER_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString()}}},t.LESS_THAN={label:"sheets-filter.conditions.less-than",operator:u.CustomFilterOperator.LESS_THAN,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.LESS_THAN},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN?!1:{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString()}}},t.LESS_THAN_OR_EQUAL={label:"sheets-filter.conditions.less-than-or-equal",operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.LESS_THAN_OR_EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.LESS_THAN_OR_EQUAL?!1:{operator1:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val1:o.val.toString()}}},t.EQUAL={label:"sheets-filter.conditions.equal",operator:u.CustomFilterOperator.EQUAL,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.EQUAL,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.EQUAL},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.EQUAL}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.EQUAL?!1:{operator1:u.CustomFilterOperator.EQUAL,val1:o.val.toString()}}},t.NOT_EQUAL={label:"sheets-filter.conditions.not-equal",operator:u.CustomFilterOperator.NOT_EQUALS,numOfParameters:1,order:y.FIRST,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.NOT_EQUALS,val1:""}),testMappingParams:n=>{const[o]=V(n);return o===u.CustomFilterOperator.NOT_EQUALS},mapToFilterColumn:n=>({customFilters:{customFilters:[{val:n.val1,operator:u.CustomFilterOperator.NOT_EQUALS}]}}),testMappingFilterColumn:n=>{var a;if(((a=n.customFilters)==null?void 0:a.customFilters.length)!==1)return!1;const o=n.customFilters.customFilters[0];return o.operator!==u.CustomFilterOperator.NOT_EQUALS?!1:{operator1:u.CustomFilterOperator.NOT_EQUALS,val1:o.val.toString()}}},t.BETWEEN={label:"sheets-filter.conditions.between",operator:g.BETWEEN,order:y.SECOND,numOfParameters:2,getDefaultFormParams:()=>({and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:"",operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(!o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN_OR_EQUAL)&&m.includes(u.CustomFilterOperator.LESS_THAN_OR_EQUAL)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL;return{customFilters:{and:c.BooleanNumber.TRUE,customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN_OR_EQUAL}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&a.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:o.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.GREATER_THAN_OR_EQUAL&&o.operator===u.CustomFilterOperator.LESS_THAN_OR_EQUAL&&n.customFilters.and?{and:!0,operator1:u.CustomFilterOperator.GREATER_THAN_OR_EQUAL,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN_OR_EQUAL,val2:o.val.toLocaleString()}:!1}},t.NOT_BETWEEN={label:"sheets-filter.conditions.not-between",operator:g.NOT_BETWEEN,order:y.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:u.CustomFilterOperator.LESS_THAN,val1:"",operator2:u.CustomFilterOperator.GREATER_THAN,val2:""}),testMappingParams:n=>{const{and:o,operator1:a,operator2:h}=n;if(o)return!1;const m=[a,h];return m.includes(u.CustomFilterOperator.GREATER_THAN)&&m.includes(u.CustomFilterOperator.LESS_THAN)},mapToFilterColumn:n=>{const{val1:o,val2:a,operator1:h}=n,m=h===u.CustomFilterOperator.GREATER_THAN;return{customFilters:{customFilters:[{val:m?o:a,operator:u.CustomFilterOperator.GREATER_THAN},{val:m?a:o,operator:u.CustomFilterOperator.LESS_THAN}]}}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const[o,a]=n.customFilters.customFilters;return o.operator===u.CustomFilterOperator.LESS_THAN&&a.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.LESS_THAN,val1:o.val.toString(),operator2:u.CustomFilterOperator.GREATER_THAN,val2:a.val.toString()}:a.operator===u.CustomFilterOperator.LESS_THAN&&o.operator===u.CustomFilterOperator.GREATER_THAN&&!n.customFilters.and?{operator1:u.CustomFilterOperator.GREATER_THAN,val1:a.val.toString(),operator2:u.CustomFilterOperator.LESS_THAN,val2:o.val.toLocaleString()}:!1}},t.CUSTOM={label:"sheets-filter.conditions.custom",operator:g.CUSTOM,order:y.SECOND,numOfParameters:2,getDefaultFormParams:()=>({operator1:g.NONE,val1:"",operator2:g.NONE,val2:""}),testMappingParams:()=>!0,mapToFilterColumn:n=>{const{and:o,val1:a,val2:h,operator1:m,operator2:f}=n;function E(U,M){for(const B of t.ALL_CONDITIONS)if(B.operator===U)return B.mapToFilterColumn({val1:M,operator1:U})}const S=!m||m===t.NONE.operator,P=!f||f===t.NONE.operator;if(S&&P)return t.NONE.mapToFilterColumn({});if(S)return E(f,h);if(P)return E(m,a);const F=E(m,a),b=E(f,h),N={customFilters:[F.customFilters.customFilters[0],b.customFilters.customFilters[0]]};return o&&(N.and=c.BooleanNumber.TRUE),{customFilters:N}},testMappingFilterColumn:n=>{var h;if(((h=n.customFilters)==null?void 0:h.customFilters.length)!==2)return!1;const o=n.customFilters.customFilters.map(m=>l({customFilters:{customFilters:[m]}})),a={operator1:o[0][0].operator,val1:o[0][1].val1,operator2:o[1][0].operator,val2:o[1][1].val1};return n.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(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);if(!o)throw new Error(`[SheetsFilter]: no condition item found for operator: ${n}`);return o}t.getItemByOperator=e;function r(n,o){for(const a of t.ALL_CONDITIONS.filter(h=>h.numOfParameters===o))if(a.numOfParameters!==0&&a.testMappingParams(n))return a;for(const a of t.ALL_CONDITIONS)if(a.testMappingParams(n))return a;throw new Error("[SheetsFilter]: no condition item can be mapped from the filter map params!")}t.testMappingParams=r;function i(n){const o=t.ALL_CONDITIONS.find(a=>a.operator===n);return(o==null?void 0:o.numOfParameters)===0?{operator1:o.operator}:o.getDefaultFormParams()}t.getInitialFormParams=i;function s(n,o){return n.mapToFilterColumn(o)}t.mapToFilterColumn=s;function l(n){if(!n)return[t.NONE,{}];for(const o of t.ALL_CONDITIONS){const a=o.testMappingFilterColumn(n);if(a)return[o,a]}return[t.NONE,{}]}t.testMappingFilterColumn=l})(p||(p={}));function V(t){const{operator1:e,operator2:r,val1:i,val2:s}=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,i]:[r,s]}function Te(t){const e=[],r=[];let i=0,s=0;function l(n){n.leaf&&(n.checked?(e.push(n),i+=n.count):(r.push(n),s+=n.count)),n.children&&n.children.forEach(l)}return t.forEach(l),{checkedItems:e,uncheckedItems:r,checked:i,unchecked:s}}var Ze=Object.defineProperty,ze=Object.getOwnPropertyDescriptor,Je=(t,e,r,i)=>{for(var s=i>1?void 0:i?ze(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Ze(e,r,s),s},Fe=(t,e)=>(r,i)=>e(r,i,t);const Ee="sheets-filter.generate-filter-values.service",ue=c.createIdentifier(Ee),et=["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 c.Disposable{constructor(t,e,r){super(),this._localeService=t,this._univerInstanceService=e,this._logService=r}async getFilterValues(t){var m;const{unitId:e,subUnitId:r,filteredOutRowsByOtherColumns:i,filters:s,blankChecked:l,iterateRange:n,alreadyChecked:o}=t,a=this._univerInstanceService.getUnit(e),h=(m=this._univerInstanceService.getUnit(e))==null?void 0:m.getSheetBySheetId(r);return!a||!h?[]:(this._logService.debug("[SheetsGenerateFilterValuesService]","getFilterValues for",{unitId:e,subUnitId:r}),$e(s,this._localeService,n,h,new Set(i),new Set(o.map(String)),l,a.getStyles()))}};Pe=Je([Fe(0,c.Inject(c.LocaleService)),Fe(1,c.IUniverInstanceService),Fe(2,c.ILogService)],Pe);function $e(t,e,r,i,s,l,n,o){var F,b,N,U,M,B,W,ve,ge;const a=new Map,h=new Map,m="yyyy-mm-dd",f=new Set(et),E="empty";let S=0;for(const $ of i.iterateByColumn(r,!1,!1)){const{row:Kt,rowSpan:Xe=1}=$;let re=0;for(;re<Xe;){const Xt=Kt+re;if(s.has(Xt)){re++;continue}const X=$!=null&&$.value?c.extractPureTextFromCell($.value):"";if(!X){S+=1,re+=Xe;continue}const Ce=(F=$.value)!=null&&F.v&&!$.value.p?(U=(N=o.get((b=$.value)==null?void 0:b.s))==null?void 0:N.n)==null?void 0:U.pattern:"",Zt=Ce&&c.numfmt.isDate(Ce);if(Ce&&Zt&&f.has(Ce)){const q=(M=i.getCellRaw($.row,$.col))==null?void 0:M.v;if(!q){re++;continue}const ne=c.numfmt.format(m,q),[R,k,le]=ne.split("-").map(Number);let Z=a.get(`${R}`);Z||(Z={title:`${R}`,key:`${R}`,children:[],count:0,leaf:!1,checked:!1},a.set(`${R}`,Z),h.set(`${R}`,[`${R}`]));let G=(B=Z.children)==null?void 0:B.find(Me=>Me.key===`${R}-${k}`);G||(G={title:e.t(`sheets-filter.date.${k}`),key:`${R}-${k}`,children:[],count:0,leaf:!1,checked:!1},(W=Z.children)==null||W.push(G),h.set(`${R}-${k}`,[`${R}`,`${R}-${k}`]));const Le=(ve=G==null?void 0:G.children)==null?void 0:ve.find(Me=>Me.key===`${R}-${k}-${le}`);Le?(Le.originValues.add(X),Le.count++,G.count++,Z.count++):((ge=G.children)==null||ge.push({title:`${le}`,key:`${R}-${k}-${le}`,count:1,originValues:new Set([X]),leaf:!0,checked:l.size?l.has(X):!n}),G.count++,Z.count++,h.set(`${R}-${k}-${le}`,[`${R}`,`${R}-${k}`,`${R}-${k}-${le}`]))}else{const q=X;let ne=a.get(q);ne?ne.count++:(ne={title:X,leaf:!0,checked:l.size?l.has(X):!n,key:q,count:1},a.set(q,ne),h.set(q,[q]))}re++}}const P=t?n:!0;if(S>0){const $={title:e.t("sheets-filter.panel.empty"),count:S,leaf:!0,checked:P,key:E};a.set("empty",$),h.set("empty",[E])}return{filterTreeItems:tt(Array.from(a.values())),filterTreeMapCache:h}}function tt(t){return Array.from(t).sort((e,r)=>e.children&&!r.children?-1:!e.children&&r.children?1:r.title.localeCompare(e.title)).map(e=>(e.children&&e.children.sort((r,i)=>{const s=Number.parseInt(r.key.split("-")[1],10),l=Number.parseInt(i.key.split("-")[1],10);return s-l}).forEach(r=>{r.children&&r.children.sort((i,s)=>{const l=Number.parseInt(i.key.split("-")[2],10),n=Number.parseInt(s.key.split("-")[2],10);return l-n})}),e))}function Oe(t,e){for(const r of t){if(r.key===e)return r;if(r.children){const i=Oe(r.children,e);if(i)return i}}return null}function we(t){return t.leaf?t.checked:t.children?t.children.every(e=>we(e)):!0}function se(t,e){t.leaf&&(e!==void 0?t.checked=e:t.checked=!t.checked),t.children&&t.children.forEach(r=>se(r,e))}function De(t,e){const r=[];return t.forEach(i=>{const s=i.originValues?e.some(o=>Array.from(i.originValues).some(a=>a.toLowerCase().includes(o.toLowerCase()))):!1,l=!s&&e.some(o=>i.title.toLowerCase().includes(o.toLowerCase()));if(s||l)r.push({...i});else if(i.children){const o=De(i.children,e);if(o.length>0){const a=o.reduce((h,m)=>h+m.count,0);r.push({...i,count:a,children:o})}}}),r}var rt=Object.defineProperty,nt=Object.getOwnPropertyDescriptor,Ie=(t,e,r,i)=>{for(var s=i>1?void 0:i?nt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&rt(e,r,s),s},he=(t,e)=>(r,i)=>e(r,i,t),me=(t=>(t[t.VALUES=0]="VALUES",t[t.CONDITIONS=1]="CONDITIONS",t))(me||{});c.createIdentifier("sheets-filter-ui.sheets-filter-panel.service");let x=class extends c.Disposable{constructor(e,r){super();v(this,"_filterBy$",new C.BehaviorSubject(0));v(this,"filterBy$",this._filterBy$.asObservable());v(this,"_filterByModel$",new C.ReplaySubject(1));v(this,"filterByModel$",this._filterByModel$.asObservable());v(this,"_filterByModel",null);v(this,"_hasCriteria$",new C.BehaviorSubject(!1));v(this,"hasCriteria$",this._hasCriteria$.asObservable());v(this,"_filterModel",null);v(this,"_col$",new C.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 i=e.getFilterColumn(r);if(i){const s=i.getColumnData();if(s.customFilters){this._hasCriteria$.next(!0),this._setupByConditions(e,r);return}if(s.filters){this._hasCriteria$.next(!0),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r);return}this._hasCriteria$.next(!1),this._setupByValues(e,r)}changeFilterBy(e){return!this._filterModel||this.col===-1?!1:(e===0?this._setupByValues(this._filterModel,this.col):this._setupByConditions(this._filterModel,this.col),!0)}terminate(){return this._filterModel=null,this._col$.next(-1),this._disposeFilterHeaderChangeListener(),!0}_disposeFilterHeaderChangeListener(){var e;(e=this._filterHeaderListener)==null||e.dispose(),this._filterHeaderListener=null}_listenToFilterHeaderChange(e,r){this._disposeFilterHeaderChangeListener();const i=e.unitId,s=e.subUnitId,l=e.getRange(),n={startColumn:r,startRow:l.startRow,endRow:l.startRow,endColumn:r};this._filterHeaderListener=this._refRangeService.watchRange(i,s,n,(o,a)=>{if(!a)this.terminate();else{const h=a.startColumn-o.startColumn;h!==0&&this._filterByModel.deltaCol(h)}})}async _setupByValues(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=await de.fromFilterColumn(this._injector,e,r);return this.filterByModel=s,this._filterBy$.next(0),this._listenToFilterHeaderChange(e,r),!0}_setupByConditions(e,r){this._disposePreviousModel();const i=e.getRange();if(i.startRow===i.endRow)return!1;const s=pe.fromFilterColumn(this._injector,e,r,e.getFilterColumn(r));return this.filterByModel=s,this._filterBy$.next(1),this._listenToFilterHeaderChange(e,r),!0}_disposePreviousModel(){var e;(e=this._filterByModel)==null||e.dispose(),this.filterByModel=null}};x=Ie([he(0,c.Inject(c.Injector)),he(1,c.Inject(O.RefRangeService))],x);let pe=class extends c.Disposable{constructor(e,r,i,s,l){super();v(this,"canApply$",C.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 C.BehaviorSubject(i),this.conditionItem$=this._conditionItem$.asObservable(),this._filterConditionFormParams$=new C.BehaviorSubject(s),this.filterConditionFormParams$=this._filterConditionFormParams$.asObservable()}static fromFilterColumn(e,r,i,s){const[l,n]=p.testMappingFilterColumn(s==null?void 0:s.getColumnData());return e.createInstance(pe,r,i,l,n)}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(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=p.mapToFilterColumn(this.conditionItem,this.filterConditionFormParams);return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:e})}onPrimaryConditionChange(e){const r=p.ALL_CONDITIONS.find(i=>i.operator===e);if(!r)throw new Error(`[ByConditionsModel]: condition item not found for operator: ${e}!`);this._conditionItem$.next(r),this._filterConditionFormParams$.next(p.getInitialFormParams(e))}onConditionFormChange(e){const r={...this.filterConditionFormParams,...e};if(r.and!==!0&&delete r.and,typeof e.and<"u"||typeof e.operator1<"u"||typeof e.operator2<"u"){const i=p.testMappingParams(r,this.conditionItem.numOfParameters);this._conditionItem$.next(i)}this._filterConditionFormParams$.next(r)}};pe=Ie([he(4,c.ICommandService)],pe);let de=class extends c.Disposable{constructor(e,r,i,s,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=s,this._searchString$=new C.BehaviorSubject(""),this.searchString$=this._searchString$.asObservable(),this._rawFilterItems$=new C.BehaviorSubject(i),this.rawFilterItems$=this._rawFilterItems$.asObservable(),this._manuallyUpdateFilterItems$=new C.Subject,this.filterItems$=C.merge(C.combineLatest([this._searchString$.pipe(C.throttleTime(500,void 0,{leading:!0,trailing:!0}),C.startWith(void 0)),this._rawFilterItems$]).pipe(C.map(([n,o])=>{if(!n)return o;const h=n.toLowerCase().split(/\s+/).filter(m=>!!m);return De(o,h)})),this._manuallyUpdateFilterItems$).pipe(C.shareReplay(1)),this.canApply$=this.filterItems$.pipe(C.map(n=>Te(n).checked>0)),this.disposeWithMe(this.filterItems$.subscribe(n=>this._filterItems=n))}static async fromFilterColumn(e,r,i){var B;const s=e.get(c.IUniverInstanceService),l=e.get(c.LocaleService),n=e.get(ue,c.Quantity.OPTIONAL),{unitId:o,subUnitId:a}=r,h=s.getUniverSheetInstance(o);if(!h)throw new Error(`[ByValuesModel]: Workbook not found for filter model with unitId: ${o}!`);const m=h==null?void 0:h.getSheetBySheetId(a);if(!m)throw new Error(`[ByValuesModel]: Worksheet not found for filter model with unitId: ${o} and subUnitId: ${a}!`);const f=r.getRange(),E=i,S=(B=r.getFilterColumn(i))==null?void 0:B.getColumnData().filters,P=new Set(S==null?void 0:S.filters),F=!!(S&&S.blank),b=r.getFilteredOutRowsExceptCol(i),N={...f,startRow:f.startRow+1,startColumn:E,endColumn:E};let U,M;if(n){const W=await n.getFilterValues({unitId:o,subUnitId:a,filteredOutRowsByOtherColumns:Array.from(b),filters:!!S,blankChecked:F,iterateRange:N,alreadyChecked:Array.from(P)});U=W.filterTreeItems,M=W.filterTreeMapCache}else{const W=$e(!!S,l,N,m,b,P,F,h.getStyles());U=W.filterTreeItems,M=W.filterTreeMapCache}return e.createInstance(de,r,i,U,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=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,e)),this._manuallyUpdateFilterItems(r)}onFilterCheckToggled(e){const r=c.Tools.deepClone(this._filterItems),i=Oe(r,e.key);if(!i)return;const s=we(i);se(i,!s),this._manuallyUpdateFilterItems(r)}onFilterOnly(e){const r=c.Tools.deepClone(this._filterItems);r.forEach(i=>se(i,!1)),e.forEach(i=>{const s=Oe(r,i);s&&se(s,!0)}),this._manuallyUpdateFilterItems(r)}_manuallyUpdateFilterItems(e){this._manuallyUpdateFilterItems$.next(e)}clear(){return this._disposed?Promise.resolve(!1):this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null})}async apply(){if(this._disposed)return!1;const e=Te(this._filterItems),{checked:r,checkedItems:i}=e,s=this.rawFilterItems;let l=0;for(const h of s)l+=h.count;const n=r===0,o=e.checked===l,a={colId:this.col};if(n)throw new Error("[ByValuesModel]: no checked items!");if(o)return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:null});{a.filters={};const h=i.filter(f=>f.key!=="empty");h.length>0&&(a.filters={filters:h.flatMap(f=>f.originValues?Array.from(f.originValues):[f.title])}),h.length!==i.length&&(a.filters.blank=!0)}return this._commandService.executeCommand(u.SetSheetsFilterCriteriaCommand.id,{unitId:this._filterModel.unitId,subUnitId:this._filterModel.subUnitId,col:this.col,criteria:a})}};de=Ie([he(4,c.ICommandService)],de);const z="FILTER_PANEL_OPENED",oe={id:"sheet.operation.open-filter-panel",type:c.CommandType.OPERATION,handler:(t,e)=>{const r=t.get(c.IContextService),i=t.get(u.SheetsFilterService),s=t.get(x);t.get(c.ICommandService).syncExecuteCommand(w.SetCellEditVisibleOperation.id,{visible:!1});const{unitId:n,subUnitId:o,col:a}=e,h=i.getFilterModel(n,o);return h?(s.setupCol(h,a),r.getContextValue(z)||r.setContextValue(z,!0),!0):!1}},J={id:"sheet.operation.close-filter-panel",type:c.CommandType.OPERATION,handler:t=>{const e=t.get(c.IContextService),r=t.get(x),i=t.get(T.ILayoutService,c.Quantity.OPTIONAL);return e.getContextValue(z)?(e.setContextValue(z,!1),i==null||i.focus(),r.terminate()):!1}},Ne={id:"sheet.operation.apply-filter",type:c.CommandType.OPERATION,handler:(t,e)=>{const{filterBy:r}=e;return t.get(x).changeFilterBy(r)}};var it=Object.defineProperty,st=Object.getOwnPropertyDescriptor,ot=(t,e,r,i)=>{for(var s=i>1?void 0:i?st(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&it(e,r,s),s},ee=(t,e)=>(r,i)=>e(r,i,t);let te=class extends c.Disposable{constructor(t,e,r,i,s,l){super(),this._sheetsFilterService=t,this._localeService=e,this._commandService=r,this._sheetPermissionCheckPermission=i,this._injector=s,this._sheetsSelectionService=l,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(t=>{var e,r,i;if(t.id===u.SmartToggleSheetsFilterCommand.id){const s=this._injector.get(c.IUniverInstanceService),l=O.getSheetCommandTarget(s);if(!l)return;const{unitId:n,subUnitId:o,worksheet:a}=l,h=(e=this._sheetsFilterService.getFilterModel(n,o))==null?void 0:e.getRange();let m;if(h)m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[h]);else{const f=(r=this._sheetsSelectionService.getCurrentLastSelection())==null?void 0:r.range;if(f){let E={...f};E=f.startColumn===f.endColumn&&f.startRow===f.endRow?O.expandToContinuousRange(E,{left:!0,right:!0,up:!0,down:!0},a):E,m=this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]},[E],n,o)}else m=this._sheetPermissionCheckPermission.permissionCheckWithoutRange({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetViewPermission,O.WorksheetFilterPermission]})}m||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr"))}if(t.id===oe.id){const s=t.params,{unitId:l,subUnitId:n}=s,o=(i=this._sheetsFilterService.getFilterModel(l,n))==null?void 0:i.getRange(),a=c.Tools.deepClone(o);a&&(a.startColumn=s.col,a.endColumn=s.col,this._sheetPermissionCheckPermission.permissionCheckWithRanges({rangeTypes:[O.RangeProtectionPermissionViewPoint],worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission]},[a])||this._sheetPermissionCheckPermission.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.filterErr")))}}))}};te=ot([ee(0,c.Inject(u.SheetsFilterService)),ee(1,c.Inject(c.LocaleService)),ee(2,c.ICommandService),ee(3,c.Inject(O.SheetPermissionCheckController)),ee(4,c.Inject(c.Injector)),ee(5,c.Inject(O.SheetsSelectionsService))],te);var H=function(){return H=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++){e=arguments[r];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s])}return t},H.apply(this,arguments)},at=function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,i=Object.getOwnPropertySymbols(t);s<i.length;s++)e.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(t,i[s])&&(r[i[s]]=t[i[s]]);return r},He=A.forwardRef(function(t,e){var r=t.icon,i=t.id,s=t.className,l=t.extend,n=at(t,["icon","id","className","extend"]),o="univerjs-icon univerjs-icon-".concat(i," ").concat(s||"").trim(),a=A.useRef("_".concat(ut()));return Ve(r,"".concat(i),{defIds:r.defIds,idSuffix:a.current},H({ref:e,className:o},n),l)});function Ve(t,e,r,i,s){return A.createElement(t.tag,H(H({key:e},lt(t,r,s)),i),(ct(t,r).children||[]).map(function(l,n){return Ve(l,"".concat(e,"-").concat(t.tag,"-").concat(n),r,void 0,s)}))}function lt(t,e,r){var i=H({},t.attrs);r!=null&&r.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=r.colorChannel1);var s=e.defIds;return!s||s.length===0||(t.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(function(l){var n=l[0],o=l[1];typeof o=="string"&&(i[n]=o.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),i}function ct(t,e){var r,i=e.defIds;return!i||i.length===0?t:t.tag==="defs"&&(!((r=t.children)===null||r===void 0)&&r.length)?H(H({},t),{children:t.children.map(function(s){return typeof s.attrs.id=="string"&&i&&i.indexOf(s.attrs.id)>-1?H(H({},s),{attrs:H(H({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):t}function ut(){return Math.random().toString(36).substring(2,8)}He.displayName="UniverIcon";var ht={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M3.32182 2.60967C2.98161 2.60967 2.79671 3.0074 3.01601 3.2675L6.85819 7.8246C6.94943 7.93282 6.99947 8.06981 6.99947 8.21136V12.7338C6.99947 12.898 7.0998 13.0455 7.2525 13.1058L8.73833 13.6928C9.00085 13.7965 9.28531 13.6031 9.28531 13.3208V8.21136C9.28531 8.06981 9.33535 7.93282 9.42659 7.8246L13.2688 3.2675C13.4881 3.0074 13.3032 2.60967 12.963 2.60967H3.32182ZM2.09858 4.04101C1.22139 3.0006 1.96097 1.40967 3.32182 1.40967H12.963C14.3238 1.40967 15.0634 3.0006 14.1862 4.04101L10.4853 8.43054V13.3208C10.4853 14.4498 9.34747 15.2237 8.29742 14.8089L6.81158 14.2219C6.20078 13.9806 5.79947 13.3905 5.79947 12.7338V8.43054L2.09858 4.04101Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Be=A.forwardRef(function(t,e){return A.createElement(He,Object.assign({},t,{id:"filter-single",ref:e,icon:ht}))});Be.displayName="FilterSingle";const I={sheetsFilterPanel:"univer-sheets-filter-panel",sheetsFilterPanelHeader:"univer-sheets-filter-panel-header",sheetsFilterPanelContent:"univer-sheets-filter-panel-content",sheetsFilterPanelSelectAll:"univer-sheets-filter-panel-select-all",sheetsFilterPanelSelectAllCount:"univer-sheets-filter-panel-select-all-count",sheetsFilterPanelValuesContainer:"univer-sheets-filter-panel-values-container",inputAffixWrapper:"univer-input-affix-wrapper",select:"univer-select",radioGroup:"univer-radio-group",sheetsFilterPanelValuesFind:"univer-sheets-filter-panel-values-find",sheetsFilterPanelValuesList:"univer-sheets-filter-panel-values-list",sheetsFilterPanelValuesListInnerContainer:"univer-sheets-filter-panel-values-list-inner-container",sheetsFilterPanelValuesVirtual:"univer-sheets-filter-panel-values-virtual",sheetsFilterPanelValuesItem:"univer-sheets-filter-panel-values-item",sheetsFilterPanelValuesItemInner:"univer-sheets-filter-panel-values-item-inner",sheetsFilterPanelValuesItemCount:"univer-sheets-filter-panel-values-item-count",sheetsFilterPanelValuesItemExcludeButton:"univer-sheets-filter-panel-values-item-exclude-button",sheetsFilterPanelValuesItemText:"univer-sheets-filter-panel-values-item-text",sheetsFilterPanelConditionsContainer:"univer-sheets-filter-panel-conditions-container",sheetsFilterPanelConditionsContainerInner:"univer-sheets-filter-panel-conditions-container-inner",sheetsFilterPanelConditionsDesc:"univer-sheets-filter-panel-conditions-desc",sheetsFilterPanelFooter:"univer-sheets-filter-panel-footer",sheetsFilterPanelFooterPrimaryButtons:"univer-sheets-filter-panel-footer-primary-buttons",button:"univer-button",input:"univer-input",formDualColumnLayout:"univer-form-dual-column-layout",sheetsFilterTreeNode:"univer-sheets-filter-tree-node",sheetsFilterTreeNodeFilterOnly:"univer-sheets-filter-tree-node-filter-only",sheetsFilterTreeNodeAttach:"univer-sheets-filter-tree-node-attach"};function mt(t){var S,P;const{model:e}=t,r=T.useDependency(c.LocaleService),i=T.useObservable(e.conditionItem$,void 0),s=T.useObservable(e.filterConditionFormParams$,void 0),l=s!=null&&s.and?"AND":"OR",n=A.useCallback(F=>{e.onConditionFormChange({and:F==="AND"})},[e]),o=pt(r),a=A.useCallback(F=>{e.onPrimaryConditionChange(F)},[e]),h=dt(r),m=A.useCallback(F=>{e.onConditionFormChange(F)},[e]),f=r.t("sheets-filter.panel.input-values-placeholder");function E(F,b,N){const U=p.getItemByOperator(F).numOfParameters===1;return d.jsxs(d.Fragment,{children:[N==="operator2"&&d.jsxs(L.RadioGroup,{value:l,onChange:n,children:[d.jsx(L.Radio,{value:"AND",children:r.t("sheets-filter.panel.and")}),d.jsx(L.Radio,{value:"OR",children:r.t("sheets-filter.panel.or")})]}),d.jsx(L.Select,{value:F,options:h,onChange:M=>m({[N]:M})}),U&&d.jsx("div",{children:d.jsx(L.Input,{value:b,placeholder:f,onChange:M=>m({[N==="operator1"?"val1":"val2"]:M})})})]})}return d.jsx("div",{className:I.sheetsFilterPanelConditionsContainer,children:i&&s&&d.jsxs(d.Fragment,{children:[d.jsx(L.Select,{value:i.operator,options:o,onChange:a}),p.getItemByOperator(i.operator).numOfParameters!==0?d.jsxs("div",{className:I.sheetsFilterPanelConditionsContainerInner,children:[i.numOfParameters>=1&&E(s.operator1,(S=s.val1)!=null?S:"","operator1"),i.numOfParameters>=2&&E(s.operator2,(P=s.val2)!=null?P:"","operator2"),d.jsxs("div",{className:I.sheetsFilterPanelConditionsDesc,children:[r.t("sheets-filter.panel.?"),d.jsx("br",{}),r.t("sheets-filter.panel.*")]})]}):null]})})}function pt(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{options:[{label:t.t(p.NONE.label),value:p.NONE.operator}]},{options:[{label:t.t(p.EMPTY.label),value:p.EMPTY.operator},{label:t.t(p.NOT_EMPTY.label),value:p.NOT_EMPTY.operator}]},{options:[{label:t.t(p.TEXT_CONTAINS.label),value:p.TEXT_CONTAINS.operator},{label:t.t(p.DOES_NOT_CONTAIN.label),value:p.DOES_NOT_CONTAIN.operator},{label:t.t(p.STARTS_WITH.label),value:p.STARTS_WITH.operator},{label:t.t(p.ENDS_WITH.label),value:p.ENDS_WITH.operator},{label:t.t(p.EQUALS.label),value:p.EQUALS.operator}]},{options:[{label:t.t(p.GREATER_THAN.label),value:p.GREATER_THAN.operator},{label:t.t(p.GREATER_THAN_OR_EQUAL.label),value:p.GREATER_THAN_OR_EQUAL.operator},{label:t.t(p.LESS_THAN.label),value:p.LESS_THAN.operator},{label:t.t(p.LESS_THAN_OR_EQUAL.label),value:p.LESS_THAN_OR_EQUAL.operator},{label:t.t(p.EQUAL.label),value:p.EQUAL.operator},{label:t.t(p.NOT_EQUAL.label),value:p.NOT_EQUAL.operator},{label:t.t(p.BETWEEN.label),value:p.BETWEEN.operator},{label:t.t(p.NOT_BETWEEN.label),value:p.NOT_BETWEEN.operator}]},{options:[{label:t.t(p.CUSTOM.label),value:p.CUSTOM.operator}]}],[e,t])}function dt(t){const e=t.getCurrentLocale();return A.useMemo(()=>p.ALL_CONDITIONS.filter(r=>r.numOfParameters!==2).map(r=>({label:t.t(r.label),value:r.operator})),[e,t])}function ft(t){const{model:e}=t,r=T.useDependency(c.LocaleService),i=T.useObservable(e.searchString$,"",!0),s=T.useObservable(e.filterItems$,void 0,!0),l=r.t("sheets-filter.panel.filter-only"),n=Te(s),o=n.checked>0&&n.unchecked===0,a=n.checked>0&&n.unchecked>0,h=e.treeMapCache,m=A.useCallback(()=>{e.onCheckAllToggled(!o)},[e,o]),f=A.useCallback(S=>{e.setSearchString(S)},[e]);function E(S){let P=[];return S.forEach(F=>{F.checked&&P.push(F.key),F.children&&(P=P.concat(E(F.children)))}),P}return d.jsxs("div",{className:I.sheetsFilterPanelValuesContainer,children:[d.jsx(L.Input,{autoFocus:!0,value:i,placeholder:r.t("sheets-filter.panel.search-placeholder"),onChange:f}),d.jsxs("div",{className:I.sheetsFilterPanelValuesList,children:[d.jsx("div",{className:I.sheetsFilterPanelValuesItem,children:d.jsxs("div",{className:I.sheetsFilterPanelValuesItemInner,children:[d.jsx(L.Checkbox,{indeterminate:a,disabled:s.length===0,checked:o,onChange:m}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemText,children:`${r.t("sheets-filter.panel.select-all")}`}),d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${n.checked}/${n.checked+n.unchecked})`})]})}),d.jsx("div",{className:I.sheetsFilterPanelValuesVirtual,children:d.jsx(L.Tree,{data:s,defaultExpandAll:!1,valueGroup:E(s),height:180,onChange:S=>{e.onFilterCheckToggled(S)},defaultCache:h,itemHeight:28,treeNodeClassName:I.sheetsFilterTreeNode,attachRender:S=>d.jsxs("div",{className:I.sheetsFilterTreeNodeAttach,children:[d.jsx("span",{className:I.sheetsFilterPanelValuesItemCount,children:`(${S.count})`}),d.jsx(L.Button,{className:I.sheetsFilterTreeNodeFilterOnly,size:"small",type:"link",onClick:()=>{const P=[];S.children?S.children.forEach(F=>{F.children?F.children.forEach(b=>{P.push(b.key)}):P.push(F.key)}):P.push(S.key),e.onFilterOnly(P)},children:l})]})})})]})]})}function _t(){var b;const t=T.useDependency(x),e=T.useDependency(c.LocaleService),r=T.useDependency(c.ICommandService),i=T.useObservable(t.filterBy$,void 0,!0),s=T.useObservable(t.filterByModel$,void 0,!1),l=T.useObservable(()=>(s==null?void 0:s.canApply$)||C.of(!1),void 0,!1,[s]),n=St(e),o=!T.useObservable(t.hasCriteria$),a=A.useCallback(N=>{r.executeCommand(Ne.id,{filterBy:N})},[r]),h=A.useCallback(async()=>{await(s==null?void 0:s.clear()),r.executeCommand(J.id)},[s,r]),m=A.useCallback(()=>{r.executeCommand(J.id)},[r]),f=A.useCallback(async()=>{await(s==null?void 0:s.apply()),r.executeCommand(J.id)},[s,r]),S=(b=T.useDependency(u.SheetsFilterService).activeFilterModel)==null?void 0:b.getRange(),P=t.col,F=T.useComponentsOfPart(w.SheetsUIPart.FILTER_PANEL_EMBED_POINT);return d.jsxs("div",{className:I.sheetsFilterPanel,children:[d.jsx(T.ComponentContainer,{components:F,sharedProps:{range:S,colIndex:P,onClose:m}}),d.jsx("div",{className:I.sheetsFilterPanelHeader,children:d.jsx(L.Segmented,{value:i,options:n,onChange:N=>a(N)})}),s?d.jsx("div",{className:I.sheetsFilterPanelContent,children:i===me.VALUES?d.jsx(ft,{model:s}):d.jsx(mt,{model:s})}):d.jsx("div",{style:{flex:1}}),d.jsxs("div",{className:I.sheetsFilterPanelFooter,children:[d.jsx(L.Button,{type:"link",onClick:h,disabled:o,children:e.t("sheets-filter.panel.clear-filter")}),d.jsxs("span",{className:I.sheetsFilterPanelFooterPrimaryButtons,children:[d.jsx(L.Button,{type:"default",onClick:m,children:e.t("sheets-filter.panel.cancel")}),d.jsx(L.Button,{disabled:!l,type:"primary",onClick:f,children:e.t("sheets-filter.panel.confirm")})]})]})]})}function St(t){const e=t.getCurrentLocale();return A.useMemo(()=>[{label:t.t("sheets-filter.panel.by-values"),value:me.VALUES},{label:t.t("sheets-filter.panel.by-conditions"),value:me.CONDITIONS}],[e,t])}function vt(t){const e=t.get(u.SheetsFilterService);return{id:u.SmartToggleSheetsFilterCommand.id,type:T.MenuItemType.BUTTON_SELECTOR,icon:"FilterSingle",tooltip:"sheets-filter.toolbar.smart-toggle-filter-tooltip",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),activated$:e.activeFilterModel$.pipe(C.map(r=>!!r)),disabled$:w.getObservableWithExclusiveRange$(t,w.getCurrentRangeDisable$(t,{worksheetTypes:[O.WorksheetFilterPermission,O.WorksheetViewPermission],rangeTypes:[O.RangeProtectionPermissionViewPoint]}))}}function gt(t){const e=t.get(u.SheetsFilterService);return{id:u.ClearSheetsFilterCriteriaCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.clear-filter-criteria",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}function Ct(t){const e=t.get(u.SheetsFilterService);return{id:u.ReCalcSheetsFilterCommand.id,type:T.MenuItemType.BUTTON,title:"sheets-filter.toolbar.re-calc-filter-conditions",hidden$:T.getMenuHiddenObservable(t,c.UniverInstanceType.UNIVER_SHEET),disabled$:e.activeFilterModel$.pipe(C.switchMap(r=>{var i;return(i=r==null?void 0:r.hasCriteria$.pipe(C.map(s=>!s)))!=null?i:C.of(!0)}))}}const Tt={[T.RibbonStartGroup.FORMULAS_INSERT]:{[u.SmartToggleSheetsFilterCommand.id]:{order:10,menuItemFactory:vt,[u.ClearSheetsFilterCriteriaCommand.id]:{order:0,menuItemFactory:gt},[u.ReCalcSheetsFilterCommand.id]:{order:1,menuItemFactory:Ct}}}},Y=16,Ft=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,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.lineCap="square",e.strokeStyle=i,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,i,s){e.save(),ie.Rect.drawWith(e,{radius:2,width:Y,height:Y,fill:s}),e.scale(r/Y,r/Y),e.fillStyle=i,e.fill(Ft),e.restore()}}var Et=Object.defineProperty,Pt=Object.getOwnPropertyDescriptor,Ot=(t,e,r,i)=>{for(var s=i>1?void 0:i?Pt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Et(e,r,s),s},ye=(t,e)=>(r,i)=>e(r,i,t);const Q=16,fe=1;let Ae=class extends ie.Shape{constructor(e,r,i,s,l){super(e,r);v(this,"_cellWidth",0);v(this,"_cellHeight",0);v(this,"_filterParams");v(this,"_hovered",!1);this._contextService=i,this._commandService=s,this._themeService=l,this.setShapeProps(r),this.onPointerDown$.subscribeEvent(n=>this.onPointerDown(n)),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,i=this._cellWidth,s=Q-i,l=Q-r;e.save();const n=new Path2D;n.rect(s,l,i,r),e.clip(n);const{hasCriteria:o}=this._filterParams,a=this._themeService.getCurrentTheme().primaryColor,h=this._hovered?this._themeService.getCurrentTheme().grey50:"rgba(255, 255, 255, 1.0)";o?We.drawHasCriteria(e,Q,a,h):We.drawNoCriteria(e,Q,a,h),e.restore()}onPointerDown(e){if(e.button===2)return;const{col:r,unitId:i,subUnitId:s}=this._filterParams;this._contextService.getContextValue(z)||!this._commandService.hasCommand(oe.id)||setTimeout(()=>{this._commandService.executeCommand(oe.id,{unitId:i,subUnitId:s,col:r})},200)}onPointerEnter(){this._hovered=!0,this.makeDirty(!0)}onPointerLeave(){this._hovered=!1,this.makeDirty(!0)}};Ae=Ot([ye(2,c.IContextService),ye(3,c.ICommandService),ye(4,c.Inject(c.ThemeService))],Ae);var It=Object.defineProperty,Nt=Object.getOwnPropertyDescriptor,yt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Nt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&It(e,r,s),s},K=(t,e)=>(r,i)=>e(r,i,t);const At=1e3,bt=5e3;let be=class extends c.RxDisposable{constructor(e,r,i,s,l,n,o,a){super();v(this,"_filterRangeShape",null);v(this,"_buttonRenderDisposable",null);v(this,"_filterButtonShapes",[]);this._context=e,this._injector=r,this._sheetSkeletonManagerService=i,this._sheetsFilterService=s,this._themeService=l,this._sheetInterceptorService=n,this._commandService=o,this._selectionRenderService=a,this._initRenderer()}dispose(){super.dispose(),this._disposeRendering()}_initRenderer(){this._sheetSkeletonManagerService.currentSkeleton$.pipe(C.switchMap(e=>{var o,a;if(!e)return C.of(null);const{unit:r,unitId:i}=this._context,s=((o=r.getActiveSheet())==null?void 0:o.getSheetId())||"",l=(a=this._sheetsFilterService.getFilterModel(i,s))!=null?a:void 0,n=()=>({unitId:i,worksheetId:s,filterModel:l,range:l==null?void 0:l.getRange(),skeleton:e.skeleton});return c.fromCallback(this._commandService.onCommandExecuted.bind(this._commandService)).pipe(C.filter(([h])=>{var m;return h.type===c.CommandType.MUTATION&&((m=h.params)==null?void 0:m.unitId)===r.getUnitId()&&(u.FILTER_MUTATIONS.has(h.id)||h.id===O.SetRangeValuesMutation.id)}),C.throttleTime(20,void 0,{leading:!1,trailing:!0}),C.map(n),C.startWith(n()))}),C.takeUntil(this.dispose$)).subscribe(e=>{this._disposeRendering(),!(!e||!e.range)&&(this._renderRange(e.range,e.skeleton),this._renderButtons(e))})}_renderRange(e,r){const{scene:i}=this._context,{rowHeaderWidth:s,columnHeaderHeight:l}=r,n=this._filterRangeShape=new w.SelectionControl(i,At,this._themeService,{rowHeaderWidth:s,columnHeaderHeight:l,enableAutoFill:!1,highlightHeader:!1}),o={range:e,primary:null,style:{fill:"rgba(0, 0, 0, 0.0)"}},a=w.attachSelectionWithCoord(o,r);n.updateRangeBySelectionWithCoord(a),n.setEvent(!1),i.makeDirty(!0)}_renderButtons(e){const{range:r,filterModel:i,unitId:s,skeleton:l,worksheetId:n}=e,{scene:o}=this._context;this._interceptCellContent(s,n,e.range);const{startColumn:a,endColumn:h,startRow:m}=r;for(let f=a;f<=h;f++){const E=`sheets-filter-button-${f}`,S=w.getCoordByCell(m,f,o,l),{startX:P,startY:F,endX:b,endY:N}=S,U=b-P,M=N-F;if(M<=fe||U<=fe)continue;const B=!!i.getFilterColumn(f),W=b-Q-fe,ve=N-Q-fe,ge={left:W,top:ve,height:Q,width:Q,zIndex:bt,cellHeight:M,cellWidth:U,filterParams:{unitId:s,subUnitId:n,col:f,hasCriteria:B}},$=this._injector.createInstance(Ae,E,ge);this._filterButtonShapes.push($)}o.addObjects(this._filterButtonShapes),o.makeDirty()}_interceptCellContent(e,r,i){const{startRow:s,startColumn:l,endColumn:n}=i;this._buttonRenderDisposable=this._sheetInterceptorService.intercept(O.INTERCEPTOR_POINT.CELL_CONTENT,{effect:c.InterceptorEffectEnum.Style,handler:(o,a,h)=>{const{row:m,col:f,unitId:E,subUnitId:S}=a;return E!==e||S!==r||m!==s||f<l||f>n?h(o):h({...o,fontRenderExtension:{...o==null?void 0:o.fontRenderExtension,rightOffset:Q}})},priority:10})}_disposeRendering(){var e,r;(e=this._filterRangeShape)==null||e.dispose(),this._filterButtonShapes.forEach(i=>i.dispose()),(r=this._buttonRenderDisposable)==null||r.dispose(),this._filterRangeShape=null,this._buttonRenderDisposable=null,this._filterButtonShapes=[]}};be=yt([K(1,c.Inject(c.Injector)),K(2,c.Inject(w.SheetSkeletonManagerService)),K(3,c.Inject(u.SheetsFilterService)),K(4,c.Inject(c.ThemeService)),K(5,c.Inject(O.SheetInterceptorService)),K(6,c.ICommandService),K(7,w.ISheetSelectionRenderService)],be);var Rt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,Mt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Lt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Rt(e,r,s),s},ke=(t,e)=>(r,i)=>e(r,i,t);let ae=class extends c.RxDisposable{constructor(t,e){super(),this._renderManagerService=t,this._sheetsRenderService=e,[u.SetSheetsFilterRangeMutation,u.SetSheetsFilterCriteriaMutation,u.RemoveSheetsFilterMutation,u.ReCalcSheetsFilterMutation].forEach(r=>this.disposeWithMe(this._sheetsRenderService.registerSkeletonChangingMutations(r.id))),this.disposeWithMe(this._renderManagerService.registerRenderModule(c.UniverInstanceType.UNIVER_SHEET,[be]))}};ae=Mt([ke(0,ie.IRenderManagerService),ke(1,c.Inject(w.SheetsRenderService))],ae);const Ut={id:u.SmartToggleSheetsFilterCommand.id,binding:T.KeyCode.L|T.MetaKeys.CTRL_COMMAND|T.MetaKeys.SHIFT,description:"sheets-filter.shortcut.smart-toggle-filter",preconditions:w.whenSheetEditorFocused,group:"4_sheet-edit"};var $t=Object.defineProperty,wt=Object.getOwnPropertyDescriptor,Dt=(t,e,r,i)=>{for(var s=i>1?void 0:i?wt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&$t(e,r,s),s},D=(t,e)=>(r,i)=>e(r,i,t);const je="FILTER_PANEL_POPUP";let _e=class extends ae{constructor(e,r,i,s,l,n,o,a,h,m,f,E,S){super(S,E);v(this,"_popupDisposable");this._injector=e,this._componentManager=r,this._sheetsFilterPanelService=i,this._sheetCanvasPopupService=s,this._sheetsFilterService=l,this._localeService=n,this._shortcutService=o,this._commandService=a,this._menuManagerService=h,this._contextService=m,this._messageService=f,this._initCommands(),this._initShortcuts(),this._initMenuItems(),this._initUI()}dispose(){super.dispose(),this._closeFilterPopup()}_initShortcuts(){[Ut].forEach(e=>{this.disposeWithMe(this._shortcutService.registerShortcut(e))})}_initCommands(){[u.SmartToggleSheetsFilterCommand,u.RemoveSheetFilterCommand,u.SetSheetFilterRangeCommand,u.SetSheetsFilterCriteriaCommand,u.ClearSheetsFilterCriteriaCommand,u.ReCalcSheetsFilterCommand,Ne,oe,J].forEach(e=>{this.disposeWithMe(this._commandService.registerCommand(e))})}_initMenuItems(){this._menuManagerService.mergeMenu(Tt)}_initUI(){this.disposeWithMe(this._componentManager.register(je,_t)),this.disposeWithMe(this._componentManager.register("FilterSingle",Be)),this.disposeWithMe(this._contextService.subscribeContextValue$(z).pipe(C.distinctUntilChanged()).subscribe(e=>{e?this._openFilterPopup():this._closeFilterPopup()})),this.disposeWithMe(this._sheetsFilterService.errorMsg$.subscribe(e=>{e&&this._messageService.show({type:L.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(),i=this._sheetsFilterPanelService.col,{startRow:s}=r;this._popupDisposable=this._sheetCanvasPopupService.attachPopupToCell(s,i,{componentKey:je,direction:"horizontal",onClickOutside:()=>this._commandService.syncExecuteCommand(J.id),offset:[5,0]})}_closeFilterPopup(){var e;(e=this._popupDisposable)==null||e.dispose(),this._popupDisposable=null}};_e=Dt([D(0,c.Inject(c.Injector)),D(1,c.Inject(T.ComponentManager)),D(2,c.Inject(x)),D(3,c.Inject(w.SheetCanvasPopManagerService)),D(4,c.Inject(u.SheetsFilterService)),D(5,c.Inject(c.LocaleService)),D(6,T.IShortcutService),D(7,c.ICommandService),D(8,T.IMenuManagerService),D(9,c.IContextService),D(10,T.IMessageService),D(11,c.Inject(w.SheetsRenderService)),D(12,ie.IRenderManagerService)],_e);var Qe=Object.defineProperty,Ht=Object.getOwnPropertyDescriptor,Vt=(t,e,r)=>e in t?Qe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Bt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Ht(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&Qe(e,r,s),s},Re=(t,e)=>(r,i)=>e(r,i,t),Ge=(t,e,r)=>Vt(t,typeof e!="symbol"?e+"":e,r);const Wt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterUIPlugin=class extends c.Plugin{constructor(e=ce,r,i,s){super(),this._config=e,this._injector=r,this._configService=i,this._rpcChannelService=s;const{menu:l,...n}=c.merge({},ce,this._config);l&&this._configService.setConfig("menu",l,{merge:!0}),this._configService.setConfig(Ue,n)}onStarting(){[[x],[te],[_e]].forEach(e=>this._injector.add(e)),this._config.useRemoteFilterValuesGenerator&&this._rpcChannelService&&this._injector.add([ue,{useFactory:()=>j.toModule(this._rpcChannelService.requestChannel(Ee))}])}onReady(){this._injector.get(te)}onRendered(){this._injector.get(_e)}},Ge(_.UniverSheetsFilterUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),Ge(_.UniverSheetsFilterUIPlugin,"pluginName",Wt),_.UniverSheetsFilterUIPlugin=Bt([c.DependentOn(u.UniverSheetsFilterPlugin),Re(1,c.Inject(c.Injector)),Re(2,c.IConfigService),Re(3,c.Optional(j.IRPCChannelService))],_.UniverSheetsFilterUIPlugin);var xe=Object.defineProperty,kt=Object.getOwnPropertyDescriptor,jt=(t,e,r)=>e in t?xe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Qt=(t,e,r,i)=>{for(var s=i>1?void 0:i?kt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&xe(e,r,s),s},Ye=(t,e)=>(r,i)=>e(r,i,t),qe=(t,e,r)=>jt(t,typeof e!="symbol"?e+"":e,r);const Gt="SHEET_FILTER_UI_PLUGIN";_.UniverSheetsFilterMobileUIPlugin=class extends c.Plugin{constructor(e=ce,r,i){super(),this._config=e,this._injector=r,this._configService=i;const{menu:s,...l}=c.merge({},ce,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Ue,l)}onStarting(){[[te],[ae]].forEach(e=>this._injector.add(e))}onReady(){this._injector.get(te)}onRendered(){this._injector.get(ae)}},qe(_.UniverSheetsFilterMobileUIPlugin,"type",c.UniverInstanceType.UNIVER_SHEET),qe(_.UniverSheetsFilterMobileUIPlugin,"pluginName",Gt),_.UniverSheetsFilterMobileUIPlugin=Qt([c.DependentOn(u.UniverSheetsFilterPlugin),Ye(1,c.Inject(c.Injector)),Ye(2,c.IConfigService)],_.UniverSheetsFilterMobileUIPlugin);var xt=Object.defineProperty,Yt=Object.getOwnPropertyDescriptor,qt=(t,e,r,i)=>{for(var s=i>1?void 0:i?Yt(e,r):e,l=t.length-1,n;l>=0;l--)(n=t[l])&&(s=(i?n(e,r,s):n(s))||s);return i&&s&&xt(e,r,s),s},Ke=(t,e)=>(r,i)=>e(r,i,t);_.UniverSheetsFilterUIWorkerPlugin=(Se=class extends c.Plugin{constructor(e,r,i){super(),this._config=e,this._injector=r,this._rpcChannelService=i}onStarting(){[[ue,{useClass:Pe}]].forEach(e=>this._injector.add(e))}onReady(){this._rpcChannelService.registerChannel(Ee,j.fromModule(this._injector.get(ue)))}},v(Se,"type",c.UniverInstanceType.UNIVER_SHEET),v(Se,"pluginName","SHEET_FILTER_UI_WORKER_PLUGIN"),Se),_.UniverSheetsFilterUIWorkerPlugin=qt([Ke(1,c.Inject(c.Injector)),Ke(2,j.IRPCChannelService)],_.UniverSheetsFilterUIWorkerPlugin),_.ChangeFilterByOperation=Ne,_.CloseFilterPanelOperation=J,_.OpenFilterPanelOperation=oe,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.6.0-
|
|
3
|
+
"version": "0.6.0-experimental.20250212-dbe9830",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Univer Sheets Filter UI",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -55,24 +55,24 @@
|
|
|
55
55
|
"@univerjs/icons": "^0.2.14",
|
|
56
56
|
"clsx": "^2.1.1",
|
|
57
57
|
"rc-virtual-list": "^3.15.0",
|
|
58
|
-
"@univerjs/core": "0.6.0-
|
|
59
|
-
"@univerjs/design": "0.6.0-
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/sheets": "0.6.0-
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/sheets-
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/
|
|
58
|
+
"@univerjs/core": "0.6.0-experimental.20250212-dbe9830",
|
|
59
|
+
"@univerjs/design": "0.6.0-experimental.20250212-dbe9830",
|
|
60
|
+
"@univerjs/rpc": "0.6.0-experimental.20250212-dbe9830",
|
|
61
|
+
"@univerjs/sheets-filter": "0.6.0-experimental.20250212-dbe9830",
|
|
62
|
+
"@univerjs/sheets": "0.6.0-experimental.20250212-dbe9830",
|
|
63
|
+
"@univerjs/sheets-ui": "0.6.0-experimental.20250212-dbe9830",
|
|
64
|
+
"@univerjs/ui": "0.6.0-experimental.20250212-dbe9830",
|
|
65
|
+
"@univerjs/engine-render": "0.6.0-experimental.20250212-dbe9830"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"less": "^4.2.
|
|
69
|
-
"postcss": "^8.
|
|
68
|
+
"less": "^4.2.2",
|
|
69
|
+
"postcss": "^8.5.1",
|
|
70
70
|
"react": "18.3.1",
|
|
71
71
|
"rxjs": "^7.8.1",
|
|
72
72
|
"tailwindcss": "^3.4.17",
|
|
73
73
|
"typescript": "^5.7.3",
|
|
74
|
-
"vite": "^6.0.
|
|
75
|
-
"vitest": "^
|
|
74
|
+
"vite": "^6.0.11",
|
|
75
|
+
"vitest": "^3.0.4",
|
|
76
76
|
"@univerjs-infra/shared": "0.6.0-alpha.0"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
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
|