@univerjs/sheets-conditional-formatting-ui 0.12.4 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Nt=Object.defineProperty;var Et=(r,e,n)=>e in r?Nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var Q=(r,e,n)=>Et(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),U=require("@univerjs/sheets"),t=require("@univerjs/sheets-conditional-formatting"),D=require("@univerjs/ui"),u=require("react/jsx-runtime"),C=require("react"),M=require("@univerjs/design"),We=require("@univerjs/engine-formula"),Se=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),vt=require("@univerjs/engine-render"),pe=require("rxjs/operators"),qe={type:a.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s}=e,l=r.get(t.ConditionalFormattingRuleModel),v=r.get(a.ICommandService),c=r.get(a.IUniverInstanceService),h=U.getSheetCommandTarget(c);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=l.createCfId(d,m),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:s,style:i}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:b})}},Ge={type:a.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,config:i,stopIfTrue:o}=e,s=r.get(t.ConditionalFormattingRuleModel),l=r.get(a.ICommandService),v=r.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=s.createCfId(h,d),g={ranges:n,cfId:m,stopIfTrue:!!o,rule:{type:t.CFRuleType.colorScale,config:i}};return l.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}},Ze={type:a.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,min:i,max:o,nativeColor:s,positiveColor:l,isGradient:v,stopIfTrue:c,isShowValue:h}=e,d=r.get(t.ConditionalFormattingRuleModel),m=r.get(a.IUniverInstanceService),g=U.getSheetCommandTarget(m);if(!g)return!1;const{unitId:b,subUnitId:S}=g,y=r.get(a.ICommandService),_=d.createCfId(b,S),T={ranges:n,cfId:_,stopIfTrue:!!c,rule:{type:t.CFRuleType.dataBar,isShowValue:h,config:{min:i,max:o,nativeColor:s,positiveColor:l,isGradient:v}}};return y.executeCommand(t.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:T})}},ze={type:a.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o}=e,s=r.get(t.ConditionalFormattingRuleModel),l=r.get(a.ICommandService),v=r.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=s.createCfId(h,d),g={ranges:n,cfId:m,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:i}};return l.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}},Ye={type:a.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s,value:l}=e,v=r.get(t.ConditionalFormattingRuleModel),c=r.get(a.ICommandService),h=r.get(a.IUniverInstanceService),d=U.getSheetCommandTarget(h);if(!d)return!1;const{unitId:m,subUnitId:g}=d,b=v.createCfId(m,g);let S;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(s)){const y=l;if(y.length!==2||!Array.isArray(y))return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:i,value:y}}}else{const y=l;if(typeof y!="number")return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:i,value:y}}}return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:g,rule:S})}},Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,isPercent:s,isBottom:l,value:v}=e,c=r.get(t.ConditionalFormattingRuleModel),h=r.get(a.IUniverInstanceService),d=r.get(a.ICommandService),m=U.getSheetCommandTarget(h);if(!m)return!1;const{unitId:g,subUnitId:b}=m,S=c.createCfId(g,b),y={ranges:n,cfId:S,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:s,isBottom:l,style:i,value:v}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:y})}},Xe={type:a.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s,value:l}=e,v=r.get(t.ConditionalFormattingRuleModel),c=r.get(a.IUniverInstanceService),h=U.getSheetCommandTarget(c);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=r.get(a.ICommandService),b=v.createCfId(d,m),S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:s,style:i,value:l}};return g.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:S})}},Je={type:a.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s}=e,l=r.get(t.ConditionalFormattingRuleModel),v=r.get(a.IUniverInstanceService),c=r.get(a.ICommandService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=l.createCfId(d,m),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:s,style:i}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:b})}},Qe={type:a.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o}=e,s=r.get(t.ConditionalFormattingRuleModel),l=r.get(a.IUniverInstanceService),v=r.get(a.ICommandService),c=U.getSheetCommandTarget(l);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=s.createCfId(h,d),g={ranges:n,cfId:m,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:i}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}};function Y({ref:r,...e}){const{icon:n,id:i,className:o,extend:s,...l}=e,v=`univerjs-icon univerjs-icon-${i} ${o||""}`.trim(),c=C.useRef(`_${Vt()}`);return ht(n,`${i}`,{defIds:n.defIds,idSuffix:c.current},{ref:r,className:v,...l},s)}function ht(r,e,n,i,o){return C.createElement(r.tag,{key:e,...jt(r,n,o),...i},(Mt(r,n).children||[]).map((s,l)=>ht(s,`${e}-${r.tag}-${l}`,n,void 0,o)))}function jt(r,e,n){const i={...r.attrs};n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(([s,l])=>{s==="mask"&&typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(([s,l])=>{typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),i}function Mt(r,e){var i;const{defIds:n}=e;return!n||n.length===0?r:r.tag==="defs"&&((i=r.children)!=null&&i.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function Vt(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const Ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"bold-icon",ref:n,icon:Ot}))});gt.displayName="BoldIcon";const Ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Me=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"delete-icon",ref:n,icon:Ut}))});Me.displayName="DeleteIcon";const kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},pt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"increase-icon",ref:n,icon:kt}))});pt.displayName="IncreaseIcon";const Dt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},ft=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"italic-icon",ref:n,icon:Dt}))});ft.displayName="ItalicIcon";const Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"more-down-icon",ref:n,icon:Pt}))});et.displayName="MoreDownIcon";const Lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Ct=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"sequence-icon",ref:n,icon:Lt}))});Ct.displayName="SequenceIcon";const At={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},yt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"strikethrough-icon",ref:n,icon:At}))});yt.displayName="StrikethroughIcon";const $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},bt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"underline-icon",ref:n,icon:$t}))});bt.displayName="UnderlineIcon";const Bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},It=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"font-color-double-icon",ref:n,icon:Bt}))});It.displayName="FontColorDoubleIcon";const Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},St=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"paint-bucket-double-icon",ref:n,icon:Ht}))});St.displayName="PaintBucketDoubleIcon";const Wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xe=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"slash-double-icon",ref:n,icon:Wt}))});xe.displayName="SlashDoubleIcon";const re=r=>{const{color:e,onChange:n,disable:i=!1,Icon:o=St,className:s}=r,l=C.useMemo(()=>new a.ColorKit(e),[e]),v=()=>{const c={className:M.clsx("univer-fill-primary-600",i&&s),extend:{colorChannel1:l.isValid?e:""}};return u.jsx(o,{...c})};return i?v():u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(M.ColorPicker,{value:e,onChange:n})}),children:u.jsx("span",{className:M.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",s),children:v()})})},ce=r=>{var s,l,v,c,h;const e=r.rule;if(!e)return null;const n=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const d=e.config.map((b,S)=>({color:new a.ColorKit(b.color),value:S})),m=d.length-1;return new Array(5).fill("").map((b,S,y)=>S*m/(y.length-1)).map(b=>t.getColorScaleFromValue(d,b))}return null},[e]),i=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(d=>{const m=t.iconMap[d.iconType];return m&&m[Number(d.iconId)]})},[e]),o="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:d}=e.config,m=d?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=d?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return u.jsxs("div",{className:o,children:[u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(s=e.config.nativeColor)!=null?s:t.defaultDataBarNativeColor}}),u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:m,borderColor:(l=e.config.positiveColor)!=null?l:t.defaultDataBarPositiveColor}})]})}case t.CFRuleType.colorScale:return n&&u.jsx("div",{className:o,children:n.map((d,m)=>u.jsx("div",{className:"univer-h-full",style:{width:`${100/n.length}%`,background:d}},m))});case t.CFRuleType.iconSet:return i&&u.jsx("div",{className:o,children:i.map((d,m)=>d?u.jsx("img",{className:"univer-h-full",src:d,draggable:!1},m):u.jsx(xe,{},m))});case t.CFRuleType.highlightCell:{const{ul:d,st:m,it:g,bl:b,bg:S,cl:y}=e.style,_=(d==null?void 0:d.s)===a.BooleanNumber.TRUE,T=(m==null?void 0:m.s)===a.BooleanNumber.TRUE,w=g===a.BooleanNumber.TRUE,E=b===a.BooleanNumber.TRUE,N=(v=S==null?void 0:S.rgb)!=null?v:t.DEFAULT_BG_COLOR,p=(c=y==null?void 0:y.rgb)!=null?c:t.DEFAULT_FONT_COLOR,x={textDecoration:(h=`${_?"underline":""} ${T?"line-through":""}`.replace(/^ /,""))!=null?h:void 0,backgroundColor:N,color:p};return u.jsx("div",{className:M.clsx(o,{"univer-font-bold":E,"univer-italic":w}),style:x,children:"123"})}}},Te=M.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",M.borderClassName),ne=(r,e)=>({label:e.t(`sheet.cf.valueType.${r}`),value:r}),Le=r=>{var S;const{type:e,className:n,onChange:i,id:o,value:s}=r,l=D.useDependency(a.IUniverInstanceService),v=l.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(S=l.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),h=C.useMemo(()=>String(s).startsWith("=")?String(s):"=",[s]),d=C.useMemo(()=>[t.CFValueType.max,t.CFValueType.min,"none"].includes(e)?{disabled:!0}:[t.CFValueType.percent,t.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),m=C.useRef(null),[g,b]=C.useState(!1);return D.useSidebarClick(y=>{var T;((T=m.current)==null?void 0:T.isClickOutSide(y))&&b(!1)}),e===t.CFValueType.formula?u.jsx("div",{className:"univer-ml-1 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:m,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:h,unitId:v,subUnitId:c,isFocus:g,onChange:(y="")=>{i(y||"")},onFocus:()=>b(!0)})}):u.jsx(M.InputNumber,{className:n,value:Number(r.value)||0,onChange:y=>r.onChange(y||0),...d})},qt=r=>{var k;const{interceptorManager:e}=r,n=D.useDependency(a.LocaleService),i=((k=r.rule)==null?void 0:k.type)===t.CFRuleType.colorScale?r.rule:void 0,o=[ne(t.CFValueType.num,n),ne(t.CFValueType.percent,n),ne(t.CFValueType.percentile,n),ne(t.CFValueType.formula,n)],s=[ne(t.CFValueType.min,n),...o],l=[ne("none",n),...o],v=[ne(t.CFValueType.max,n),...o],[c,h]=C.useState(()=>{var F;const f=t.CFValueType.min;return i&&((F=i.config[0])==null?void 0:F.value.type)||f}),[d,m]=C.useState(()=>{var F;const f="none";return!i||i.config.length!==3?f:((F=i.config[1])==null?void 0:F.value.type)||f}),[g,b]=C.useState(()=>{var F;const f=t.CFValueType.max;return i&&((F=i.config[i.config.length-1])==null?void 0:F.value.type)||f}),[S,y]=C.useState(()=>{if(!i)return 10;const F=i.config[0];return(F==null?void 0:F.value.value)===void 0?10:F==null?void 0:F.value.value}),[_,T]=C.useState(()=>{var L;if(!i||i.config.length!==3)return 50;const F=(L=i.config[1])==null?void 0:L.value.value;return F===void 0?50:F}),[w,E]=C.useState(()=>{var L;if(!i)return 90;const F=(L=i.config[i.config.length-1])==null?void 0:L.value.value;return F===void 0?90:F}),[N,p]=C.useState(()=>{var F;const f="#d0d9fb";return i&&((F=i.config[0])==null?void 0:F.color)||f}),[x,R]=C.useState(()=>{var F;const f="#7790f3";return!i||i.config.length!==3?f:((F=i.config[1])==null?void 0:F.color)||f}),[I,V]=C.useState(()=>{var F;const f="#2e55ef";return i&&((F=i.config[i.config.length-1])==null?void 0:F.color)||f}),j=C.useMemo(()=>f=>{const{minType:F,medianType:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:oe,medianColor:P,maxColor:A}=f,B=[];return B.push({color:oe,value:{type:F,value:X}}),L!=="none"&&B.push({color:P,value:{type:L,value:J}}),B.push({color:A,value:{type:q,value:ie}}),{config:B.map((G,Z)=>({...G,index:Z})),type:t.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return j({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),[j,c,d,g,S,_,w,N,x,I,e]);const O=f=>{r.onChange(j(f))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:j({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})})}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:s,value:c,onChange:f=>{h(f);const F=t.createDefaultValueByValueType(f,10);y(F),O({minType:f,medianType:d,maxType:g,minValue:F,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(Le,{id:"min",className:"univer-ml-1",value:S,type:c,onChange:f=>{y(f),O({minType:c,medianType:d,maxType:g,minValue:f,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:N,onChange:f=>{p(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:f,medianColor:x,maxColor:I})}})]}),u.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:n.t("sheet.cf.panel.medianValue")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:l,value:d,onChange:f=>{m(f);const F=t.createDefaultValueByValueType(f,50);T(F),O({minType:c,medianType:f,maxType:g,minValue:S,medianValue:F,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(Le,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{T(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:f,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),d!=="none"&&u.jsx(re,{className:"univer-ml-1",color:x,onChange:f=>{R(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:f,maxColor:I})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:v,value:g,onChange:f=>{b(f);const F=t.createDefaultValueByValueType(f,90);E(F),O({minType:c,medianType:d,maxType:f,minValue:S,medianValue:_,maxValue:F,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(Le,{id:"max",className:"univer-ml-1",value:w,type:g,onChange:f=>{E(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:f,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:f})}})]})]})},se=(r,e)=>({label:e.t(`sheet.cf.valueType.${r}`),value:r}),nt=r=>{var y;const{onChange:e,className:n,value:i,type:o,id:s,disabled:l=!1}=r,v=D.useDependency(a.IUniverInstanceService),c=v.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(y=v.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId(),d=C.useRef(null),[m,g]=C.useState(!1);D.useSidebarClick(_=>{var w;((w=d.current)==null?void 0:w.isClickOutSide(_))&&g(!1)});const b=C.useRef(i),S=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(o)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[o]);if(o===t.CFValueType.formula){const _=String(b.current).startsWith("=")?String(b.current)||"":"=";return u.jsx("div",{className:"univer-ml-3 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:d,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:_,unitId:c,subUnitId:h,isFocus:m,onChange:(T="")=>{e(T||"")},onFocus:()=>g(!0)})})}return u.jsx(M.InputNumber,{className:n,value:Number(i)||0,disabled:l,onChange:_=>{e(_||0)},...S})},Gt=r=>{var k;const{interceptorManager:e}=r,n=D.useDependency(a.LocaleService),i=((k=r.rule)==null?void 0:k.type)===t.CFRuleType.dataBar?r.rule:void 0,[o,s]=C.useState(()=>{var F;return i&&(F=i.config)!=null&&F.isGradient?"1":"0"}),[l,v]=C.useState(()=>{var f;return i&&((f=i.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[c,h]=C.useState(()=>{var f;return i&&((f=i.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),d=[se(t.CFValueType.num,n),se(t.CFValueType.percent,n),se(t.CFValueType.percentile,n),se(t.CFValueType.formula,n)],m=[se(t.CFValueType.min,n),...d],g=[se(t.CFValueType.max,n),...d],[b,S]=C.useState(()=>{var F;const f=m[0].value;return i&&((F=i.config)==null?void 0:F.min.type)||f}),[y,_]=C.useState(()=>{var F;const f=g[0].value;return i&&((F=i.config)==null?void 0:F.max.type)||f}),[T,w]=C.useState(()=>{var L;if(!i)return 0;const F=((L=i.config)==null?void 0:L.min)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value||0}),[E,N]=C.useState(()=>{var L;if(!i)return 100;const F=((L=i.config)==null?void 0:L.max)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value===void 0?100:F.value}),[p,x]=C.useState(()=>i?i.isShowValue===void 0?!0:!!i.isShowValue:!0),R=f=>({config:{min:{type:f.minValueType,value:f.minValue},max:{type:f.maxValueType,value:f.maxValue},isGradient:f.isGradient==="1",positiveColor:f.positiveColor||t.defaultDataBarPositiveColor,nativeColor:f.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:f.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return R({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}}),[o,T,b,E,y,l,c,e,p]);const I=f=>{r.onChange(R(f))},V=f=>{v(f),I({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:f,nativeColor:c,isShowValue:p})},j=f=>{h(f),I({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:f,isShowValue:p})},O=f=>d.map(F=>F.value).includes(f);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:R({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})})}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.fillType")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs(M.RadioGroup,{value:o,onChange:f=>{s(f),I({isGradient:f,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})},children:[u.jsx(M.Radio,{value:"0",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.pureColor")})}),u.jsx(M.Radio,{value:"1",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.gradient")})})]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!p,onChange:f=>{x(!f),I({isGradient:f,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:!f})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.colorSet")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs("div",{className:"univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.native")}),u.jsx(re,{color:c,onChange:j})]}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.positive")}),u.jsx(re,{color:l,onChange:V})]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:m,value:b,onChange:f=>{S(f);const F=t.createDefaultValueByValueType(f,10);w(F),I({isGradient:o,minValue:F,minValueType:f,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}}),u.jsx(nt,{id:"min",className:"univer-ml-3",disabled:!O(b),type:b,value:T,onChange:f=>{w(f||0),I({isGradient:o,minValue:f||0,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:y,onChange:f=>{_(f);const F=t.createDefaultValueByValueType(f,90);N(F),I({isGradient:o,minValue:T,minValueType:b,maxValue:F,maxValueType:f,positiveColor:l,nativeColor:c,isShowValue:p})}}),u.jsx(nt,{className:"univer-ml-3",disabled:!O(y),id:"max",type:y,value:E,onChange:f=>{N(f||0),I({isGradient:o,minValue:T,minValueType:b,maxValue:f||0,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}})]})]})]})},_e=r=>[a.BooleanNumber.FALSE,void 0].includes(r)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,we=r=>r!==a.BooleanNumber.FALSE,tt=r=>{const{style:e,onChange:n,className:i}=r,[o,s]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[l,v]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[c,h]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[d,m]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[g,b]=C.useState(()=>{var w;const T="#2f56ef";return(w=e==null?void 0:e.cl)!=null&&w.rgb?e.cl.rgb:T}),[S,y]=C.useState(()=>{var w;const T="#e8ecfc";return(w=e==null?void 0:e.bg)!=null&&w.rgb?e.bg.rgb:T});C.useEffect(()=>{const T={bl:o,it:l};g!==void 0&&(T.cl={rgb:g}),S!==void 0&&(T.bg={rgb:S}),d!==void 0&&(T.st={s:d}),c!==void 0&&(T.ul={s:c}),n(t.removeUndefinedAttr(T))},[o,l,c,d,g,S]);const _="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return u.jsxs("div",{className:M.clsx("univer-my-2.5 univer-flex univer-justify-between",i),children:[u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(o||a.BooleanNumber.FALSE)}),onClick:()=>s(_e(o)),children:u.jsx(gt,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(l||a.BooleanNumber.FALSE)}),onClick:()=>v(_e(l)),children:u.jsx(ft,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(c||a.BooleanNumber.FALSE)}),onClick:()=>h(_e(c)),children:u.jsx(bt,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(d||a.BooleanNumber.FALSE)}),onClick:()=>m(_e(d)),children:u.jsx(yt,{})}),u.jsx(re,{color:g,onChange:b,Icon:It}),u.jsx(re,{color:S,onChange:y})]})},Zt=r=>{var N;const{onChange:e,interceptorManager:n}=r,i=D.useDependency(a.LocaleService),s=D.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),v=((N=r.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?r.rule:void 0,c=C.useRef(null),[h,d]=C.useState(!1),m=C.useRef(null),[g,b]=C.useState({}),[S,y]=C.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,T]=C.useState(void 0),w=p=>({style:p.style,value:S,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return w({style:g})}}),[g,S,n]),C.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(x,R,I)=>_||S.length===1||!S.startsWith("=")?(T(i.t("sheet.cf.errorMessage.formulaError")),!1):I(x)}),[_,S]);const E=p=>{e(w(p))};return D.useSidebarClick(p=>{var R;((R=m.current)==null?void 0:R.isClickOutSide(p))&&d(!1)}),u.jsxs("div",{ref:c,children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(Se.FormulaEditor,{ref:m,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),errorText:_,isFocus:h,initValue:S,unitId:s.getUnitId(),subUnitId:l==null?void 0:l.getSheetId(),onFocus:()=>{d(!0)},onChange:p=>{y(p),E({style:g})},onVerify:(p,x)=>{!p||x.length===1?T(i.t("sheet.cf.errorMessage.formulaError")):T(void 0)}})}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:w({style:g})})}),u.jsx(tt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:p=>{b(p),E({style:p})}})]})},Ne=r=>u.jsxs("div",{className:"univer-relative",children:[u.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:r.errorText}),r.children]}),$=(r,e)=>({label:e.t(`sheet.cf.operator.${r}`),value:r}),zt=r=>{const{type:e,operator:n,onChange:i,value:o,interceptorManager:s}=r,l=D.useDependency(a.LocaleService),[v,c]=C.useState(()=>typeof o=="number"?o:0),[h,d]=C.useState(""),[m,g]=C.useState(()=>typeof o=="string"?o:""),[b,S]=C.useState(""),[y,_]=C.useState(()=>Array.isArray(o)?o[0]===void 0?0:o[0]:0),[T,w]=C.useState(""),[E,N]=C.useState(()=>Array.isArray(o)?o[1]===void 0?100:o[1]:100),[p,x]=C.useState("");switch(C.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)&&i(m);break}case t.CFSubRuleType.number:{[t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)&&i(v),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)&&i([y,E]);break}}},[e]),C.useEffect(()=>{const R=s.intercept(s.getInterceptPoints().beforeSubmit,{handler:(I,V,j)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(n))return m?j(I):(S(l.t("sheet.cf.errorMessage.notBlank")),!1)}return j(I)}});return()=>{R()}},[e,v,m,n]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)){const R=I=>{g(I),i(I)};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:b,children:u.jsx(M.Input,{value:m,onChange:I=>{S(""),R(I)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)){const R=I=>{c(I||0),i(I||0),d("")};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:h,children:u.jsx(M.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:R})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)){const R=V=>{_(V||0),i([V||0,E]),w("")},I=V=>{N(V||0),i([y,V||0]),x("")};return u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(Ne,{errorText:T,children:u.jsx(M.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:y,onChange:R})}),u.jsx(Ne,{errorText:p,children:u.jsx(M.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},rt=(r,e)=>{switch(r){case t.CFSubRuleType.text:return[$(t.CFTextOperator.containsText,e),$(t.CFTextOperator.notContainsText,e),$(t.CFTextOperator.beginsWith,e),$(t.CFTextOperator.endsWith,e),$(t.CFTextOperator.equal,e),$(t.CFTextOperator.notEqual,e),$(t.CFTextOperator.containsBlanks,e),$(t.CFTextOperator.notContainsBlanks,e),$(t.CFTextOperator.containsErrors,e),$(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[$(t.CFNumberOperator.between,e),$(t.CFNumberOperator.notBetween,e),$(t.CFNumberOperator.equal,e),$(t.CFNumberOperator.notEqual,e),$(t.CFNumberOperator.greaterThan,e),$(t.CFNumberOperator.greaterThanOrEqual,e),$(t.CFNumberOperator.lessThan,e),$(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[$(t.CFTimePeriodOperator.yesterday,e),$(t.CFTimePeriodOperator.today,e),$(t.CFTimePeriodOperator.tomorrow,e),$(t.CFTimePeriodOperator.last7Days,e),$(t.CFTimePeriodOperator.lastWeek,e),$(t.CFTimePeriodOperator.thisWeek,e),$(t.CFTimePeriodOperator.nextWeek,e),$(t.CFTimePeriodOperator.lastMonth,e),$(t.CFTimePeriodOperator.thisMonth,e),$(t.CFTimePeriodOperator.nextMonth,e)]}},it=r=>{var N;const{interceptorManager:e,onChange:n}=r,i=D.useDependency(a.LocaleService),o=((N=r.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?r.rule:void 0,[s,l]=C.useState(()=>{const p=t.CFSubRuleType.text;return o&&o.subType||p}),v=[{value:t.CFSubRuleType.text,label:i.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:i.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:i.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:i.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:i.t("sheet.cf.subRuleType.uniqueValues")}],c=C.useMemo(()=>rt(s,i),[s]),[h,d]=C.useState(()=>{const p=c?c[0].value:void 0;return o&&o.operator||p}),[m,g]=C.useState(()=>{var R;return o?(R=o.value)!=null?R:t.createDefaultValue(o.subType,o.operator):""}),[b,S]=C.useState({}),y=C.useMemo(()=>p=>{var x,R,I,V,j,O,k,f,F,L,q,X,J,ie,oe;switch(p.subType||s){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(h))return{type:t.CFRuleType.highlightCell,subType:(x=p.subType)!=null?x:s,operator:(R=p.operator)!=null?R:h,style:(I=p.style)!=null?I:b,value:(V=p.value)!=null?V:m};break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(h))return{type:t.CFRuleType.highlightCell,subType:(j=p.subType)!=null?j:s,operator:(O=p.operator)!=null?O:h,style:(k=p.style)!=null?k:b,value:(f=p.value)!=null?f:m};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(h))return{type:t.CFRuleType.highlightCell,subType:(F=p.subType)!=null?F:s,operator:(L=p.operator)!=null?L:h,style:(q=p.style)!=null?q:b,value:(X=p.value)!=null?X:m};break}}return{type:t.CFRuleType.highlightCell,subType:(J=p.subType)!=null?J:s,operator:(ie=p.operator)!=null?ie:h,style:(oe=p.style)!=null?oe:b}},[s,h,m,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return y({})}}),[y,e]),C.useEffect(()=>{v.some(p=>p.value===s)||l(v[0].value)},[v]);const _=p=>{const x=p,R=rt(x,i),I=R&&R[0].value;l(x),d(I),I&&g(t.createDefaultValue(x,I)),n(y({subType:x,operator:I}))},T=p=>{const x=p;d(x),n(y({operator:x}))},w=p=>{g(p),n(y({value:p}))},E=C.useMemo(()=>`${s}_${h}_${Math.random()}`,[s,h]);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),u.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:s,options:v}),(c==null?void 0:c.length)&&u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:T,value:h||"",options:c})]}),u.jsx(zt,{value:m,interceptorManager:e,type:s,operator:h,rule:o,onChange:w},E),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:y({})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-ml-1",onChange:p=>{S(p),n(y({style:p}))}})]})},xt=(r,e)=>(t.iconMap[r]||[])[Number(e)]||"",Yt=r=>{var d;const{error:e,type:n,onChange:i}=r,o=D.useDependency(a.IUniverInstanceService),s=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=(d=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),v=C.useRef(null),[c,h]=C.useState(!1);return D.useSidebarClick(m=>{var b;((b=v.current)==null?void 0:b.isClickOutSide(m))&&h(!1)}),u.jsx("div",{className:"univer-relative",children:n!==t.CFValueType.formula?u.jsxs(u.Fragment,{children:[u.jsx(M.InputNumber,{className:M.clsx({"univer-border-red-500":e}),value:Number(r.value)||0,onChange:m=>i(m!=null?m:0)}),e&&u.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):u.jsx("div",{className:"univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:v,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:String(r.value),unitId:s,subUnitId:l,isFocus:c,onChange:(m="")=>{i(m||"")},onFocus:()=>h(!0)})})})},ot=(r,e,n)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(n.length-1-e)*10},iconType:r,iconId:String(e)}),Kt=C.forwardRef((r,e)=>{const{onClick:n}=r,i=D.useDependency(a.LocaleService),o=s=>{n(s)};return u.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((s,l)=>u.jsxs("div",{className:"univer-mb-3",children:[u.jsx("div",{className:"univer-mb-1 univer-text-sm",children:i.t(s.title)}),u.jsx("div",{className:"univer-flex univer-flex-wrap",children:s.group.map(v=>u.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{o(v.name)},children:u.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:v.list.map((c,h)=>u.jsx("img",{className:"univer-size-5",src:c,draggable:!1},h))})},v.name))})]},l))})}),Xt=r=>{const{onClick:e}=r,n=C.useMemo(()=>{const o=[];for(const s in t.iconMap){const l=t.iconMap[s],v=s;l.forEach((c,h)=>{o.push({iconType:v,base64:c,iconId:String(h)})})}return o},[]),i=o=>{e(o.iconType,o.iconId)};return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>i({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[u.jsx(xe,{className:"univer-size-5"}),u.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),u.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:n.map(o=>u.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:u.jsx("img",{className:"univer-size-5",src:o.base64,draggable:!1,onClick:()=>i(o)})},`${o.iconType}_${o.iconId}`))})]})},Jt=r=>{const{onChange:e,configList:n,errorMap:i={}}=r,o=D.useDependency(a.LocaleService),s=[{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],l=[{label:o.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:o.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],v=(m,g)=>{e([String(g),"value","value"],m)},c=(m,g)=>{e([String(g),"operator"],m);const b=t.createDefaultValue(t.CFSubRuleType.number,m);v(b,g)},h=(m,g)=>{e([String(g),"value","type"],m);const b=n[g],S=t.createDefaultValue(t.CFSubRuleType.number,b.operator);v(S,g)};return C.useMemo(()=>n.map((m,g)=>{const b=i[g],S=xt(m.iconType,m.iconId),y=g===n.length-1,_=g===0,T=n[g-1],w=(T==null?void 0:T.value.type)===t.CFValueType.formula?o.t("sheet.cf.valueType.formula"):T==null?void 0:T.value.value,E=(N,p)=>{const x={...m,iconId:p,iconType:N};e([String(g)],x)};return u.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsxs("div",{className:"univer-w-[45%]",children:[o.t("sheet.cf.iconSet.icon"),g+1]}),u.jsx("div",{className:"univer-w-[45%]",children:u.jsxs(u.Fragment,{children:[!_&&!y&&o.t("sheet.cf.iconSet.rule"),!_&&!y&&u.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(T.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]})})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx("div",{className:"univer-flex univer-items-center",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Xt,{onClick:E,iconId:m.iconId,iconType:m.iconType})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",M.borderClassName),children:[S?u.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):u.jsx(xe,{className:"univer-size-4"}),u.jsx(et,{})]})})}),y?u.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.rule"),u.jsxs("span",{className:"univer-font-medium",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(T.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]}):u.jsx(M.Select,{options:s,value:m.operator,onChange:N=>{c(N,g)}})]}),y?u.jsx("div",{}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsx("div",{children:o.t("sheet.cf.iconSet.type")}),u.jsx("div",{children:o.t("sheet.cf.iconSet.value")})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx(M.Select,{options:l,value:m.value.type,onChange:N=>{h(N,g)}}),u.jsx(Yt,{id:g,type:m.value.type,error:b,value:m.value.value||"",onChange:N=>{v(N,g)}})]})]})]},g)}),[n,i])},Qt=r=>{var N;const{interceptorManager:e}=r,n=((N=r.rule)==null?void 0:N.type)===t.CFRuleType.iconSet?r.rule:void 0,i=D.useDependency(a.LocaleService),[o,s]=C.useState({}),[l,v]=C.useState(()=>{const p=Object.keys(t.iconMap)[0];if(n&&n.config.length){const x=n.config[0].iconType;if(!n.config.some(I=>I.iconType!==x))return x}return p}),[c,h]=C.useState(()=>{if(n&&n.config.length)return a.Tools.deepClone(n==null?void 0:n.config);const p=t.iconMap[l]||[];return new Array(p.length).fill("").map((x,R,I)=>R===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:l,iconId:String(R)}:ot(l,R,I))}),[d,m]=C.useState(()=>n?!!n.isShowValue:!0),g=C.useMemo(()=>{const p=c.map(x=>xt(x.iconType,x.iconId));return u.jsx("div",{className:"univer-flex univer-items-center",children:p.map((x,R)=>x?u.jsx("img",{className:"univer-size-5",src:x},R):u.jsx(xe,{className:"univer-size-5"},R))})},[c]),b=p=>{if(p.reduce((R,I,V)=>R.preType&&!R.result||p.length-1===V?R:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:R.preType?{result:R.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(p[0].value.type)){const R={};return p.forEach((I,V,j)=>{if(V-1<0||V===j.length-1)return;const k=p[V-1],f=t.getOppositeOperator(k.operator);t.compareWithNumber({operator:f,value:k.value.value},I.value.value)||(R[V]=`${i.t(`sheet.cf.form.${f}`,String(k.value.value))} `)}),R}return{}},S=(p,x)=>{a.get(c,p)!==x&&(a.set(c,p,x),h([...c]),s(b(c)))},y=p=>{v(p);const x=t.iconMap[p]||[],R=new Array(x.length).fill("").map((I,V,j)=>ot(p,V,j));h(R),s(b(R))};C.useEffect(()=>{const p=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:d,config:c}}});return()=>{p()}},[d,c,e]),C.useEffect(()=>{const p=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(o).length===0}});return()=>{p()}},[d,c,e,o]);const _=()=>{const p=c.map(x=>({...x}));c.forEach((x,R)=>{const I=c.length-1-R,V=p[I];x.iconId=V.iconId,x.iconType=V.iconType}),h([...c])},T=D.useDependency(D.ILayoutService),[w,E]=C.useState();return D.useScrollYOverContainer(w,T.rootContainerElement),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Kt,{ref:p=>{!w&&p&&E(p)},iconType:l,onClick:y})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",M.borderClassName),children:[g,u.jsx(et,{})]})})}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{onChange:_}),i.t("sheet.cf.iconSet.reverseIconOrder")]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!d,onChange:p=>{m(!p)}}),i.t("sheet.cf.iconSet.onlyShowIcon")]})]}),u.jsx(Jt,{errorMap:o,onChange:S,configList:c})]})},en=r=>{var _;const{onChange:e,interceptorManager:n}=r,i=D.useDependency(a.LocaleService),o=((_=r.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?r.rule:void 0,s=[{label:i.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:i.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:i.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:i.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[l,v]=C.useState(()=>{const T=s[0].value,w=o==null?void 0:o.type;if(!o)return T;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(o.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(o.operator)?"lessThanAverage":T;case t.CFSubRuleType.rank:return o.isBottom?"isBottom":"isNotBottom"}}return T}),[c,h]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return 10;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.rank:return o.value||10}}return 10}),[d,m]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return!1;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.rank:return o.isPercent||!1}}return!1}),[g,b]=C.useState({}),S=T=>{const{type:w,isPercent:E,value:N,style:p}=T;if(w==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:N,style:p};if(w==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:N,style:p};if(w==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:p};if(w==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:p}};C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return S({type:l,isPercent:d,value:c,style:g})}}),[l,d,c,g,n]);const y=T=>{e(S(T))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",value:l,options:s,onChange:T=>{v(T),y({type:T,isPercent:d,value:c,style:g})}}),["isNotBottom","isBottom"].includes(l)&&u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.InputNumber,{min:1,max:1e3,value:c,onChange:T=>{const w=T||0;h(w),y({type:l,isPercent:d,value:w,style:g})}}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:d,onChange:T=>{m(!!T),y({type:l,isPercent:!!T,value:c,style:g})}}),i.t("sheet.cf.valueType.percent")]})]}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:S({type:l,isPercent:d,value:c,style:g})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-mt-3",onChange:T=>{b(T),y({type:l,isPercent:d,value:c,style:T})}})]})},tn=a.createInterceptorKey("beforeSubmit"),nn=a.createInterceptorKey("submit"),st=r=>r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),at=r=>{var e;return(e=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},rn=r=>{var R,I,V;const e=D.useDependency(a.LocaleService),n=D.useDependency(a.ICommandService),i=D.useDependency(a.IUniverInstanceService),o=D.useDependency(t.ConditionalFormattingRuleModel),s=D.useDependency(U.SheetsSelectionsService),l=st(i),v=at(i),[c,h]=C.useState(void 0),d=C.useRef((I=(R=r.rule)==null?void 0:R.ranges)!=null?I:[]),m=C.useMemo(()=>{var O,k,f;let j=(O=r.rule)==null?void 0:O.ranges;return j!=null&&j.length||(j=(f=(k=s.getCurrentSelections())==null?void 0:k.map(F=>F.range))!=null?f:[]),d.current=j,j!=null&&j.length?j.map(F=>{const L=We.serializeRange(F);return L==="NaN"?"":L}).filter(F=>!!F).join(","):""},[r.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var k,f;const j=(k=r.rule)==null?void 0:k.rule.type,O=g[0].value;if(!j)return O;switch(j){case t.CFRuleType.highlightCell:{switch((f=r.rule)==null?void 0:f.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return O}),y=C.useRef(void 0),_=C.useMemo(()=>new a.InterceptorManager({beforeSubmit:tn,submit:nn}),[]),T=C.useMemo(()=>{switch(b){case"1":return it;case"2":return en;case"3":return Gt;case"4":return qt;case"5":return Zt;case"6":return Qt;default:return it}},[b]);C.useEffect(()=>{const j=n.onCommandExecuted(O=>{if(O.id===U.RemoveSheetMutation.id){const k=O.params;k.subUnitId===v&&k.unitId===l&&r.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&r.onCancel()});return()=>j.dispose()},[]);const w=j=>{y.current=j},E=j=>{const O=j.split(",").filter(k=>!!k).map(We.deserializeRangeWithSheet).map(k=>k.range);d.current=O},N=()=>{if(c)return;const O=(()=>{const f=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return d.current.map(q=>U.setEndForRange(q,f.getRowCount(),f.getColumnCount())).filter(q=>!(Number.isNaN(q.startRow)||Number.isNaN(q.startColumn)))})();if(_.fetchThroughInterceptors(_.getInterceptPoints().beforeSubmit)(!0,null)){const f=_.fetchThroughInterceptors(_.getInterceptPoints().submit)(null,null);if(f){const F=st(i),L=at(i);if(!F||!L)throw new Error("No active sheet found");let q={};r.rule&&r.rule.cfId?(q={...r.rule,ranges:O,rule:f},n.executeCommand(t.SetCfCommand.id,{unitId:F,subUnitId:L,rule:q}),r.onCancel()):(q={cfId:o.createCfId(F,L),ranges:O,rule:f,stopIfTrue:!1},n.executeCommand(t.AddCfCommand.id,{unitId:F,subUnitId:L,rule:q}),r.onCancel())}}},p=()=>{r.onCancel()},x=(j,O)=>{j?O.length<1?h(e.t("sheet.cf.errorMessage.rangeError")):h(void 0):h(e.t("sheet.cf.errorMessage.rangeError"))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),u.jsxs("div",{className:"univer-mt-4",children:[u.jsx(Se.RangeSelector,{unitId:l,subUnitId:v,initialValue:m,onChange:(j,O)=>E(O),onVerify:x}),c&&u.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:c})]}),u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),u.jsx(M.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:j=>S(j)}),u.jsx(T,{interceptorManager:_,rule:(V=r.rule)==null?void 0:V.rule,onChange:w}),u.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[u.jsx(M.Button,{onClick:p,children:e.t("sheet.cf.panel.cancel")}),u.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:N,children:e.t("sheet.cf.panel.submit")})]})]})};var on=Object.getOwnPropertyDescriptor,sn=(r,e,n,i)=>{for(var o=i>1?void 0:i?on(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},an=(r,e)=>(n,i)=>e(n,i,r);let ue=class extends a.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const n=/\{([^}]+)?\}/g,i=[];let o=n.exec(e);for(;o;)i.push({startIndex:o.index,key:Number(o[1]),endIndex:o.index+o[0].length-1}),o=n.exec(e);return i});this._localeService=e,this._initLocal()}tWithReactNode(e,...n){const i=this._localeService.getLocales(),o=e.split("."),s=i&&this._localeService.resolveKeyPath(i,o);if(typeof s=="string"){const l=[];return this._findReplaceIndex(s).forEach((v,c,h)=>{const d=h[c-1]||{endIndex:-1};if(d.endIndex+1<v.startIndex){const m=s.slice(d.endIndex+1,v.startIndex);m&&l.push(m)}if(n[v.key]&&l.push(n[v.key]),c===h.length-1){const m=s.slice(v.endIndex+1);m&&l.push(m)}}),l}return[]}};ue=sn([an(0,a.Inject(a.LocaleService))],ue);const ln=(r,e)=>{const n=r.rule;switch(n.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(n.subType){case t.CFSubRuleType.average:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`,e.t("sheet.cf.subRuleType.average"))}case t.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case t.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case t.CFSubRuleType.number:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`,...Array.isArray(n.value)?n.value.map(o=>String(o)):[String(n.value||"")])}case t.CFSubRuleType.text:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`,n.value||"")}case t.CFSubRuleType.timePeriod:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`)}case t.CFSubRuleType.rank:return n.isPercent?n.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(n.value)):e.t("sheet.cf.preview.describe.topNPercent",String(n.value)):n.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(n.value)):e.t("sheet.cf.preview.describe.topN",String(n.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let lt=0;const un=r=>{const{onClick:e}=r,n=D.useDependency(t.ConditionalFormattingRuleModel),i=D.useDependency(a.IUniverInstanceService),o=D.useDependency(U.SheetsSelectionsService),s=D.useDependency(a.ICommandService),l=D.useDependency(a.LocaleService),v=D.useDependency(a.Injector),c=D.useDependency(D.ISidebarService),h=D.useDependency(ue),d=D.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),m=d.getUnitId(),g=d.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[S,y]=C.useState([]),[_,T]=C.useState("2"),[w,E]=C.useState(0),[N,p]=C.useState(-1),[x,R]=C.useState(lt),I=C.useRef(null),V=[{label:l.t("sheet.cf.panel.workSheet"),value:"2"},{label:l.t("sheet.cf.panel.selectedRange"),value:"1"}],j=()=>{const P=n.getSubunitRules(m,b);if(!P||!P.length)return[];if(_==="1"){const A=o.getCurrentLastSelection();if(!A)return[];const B=A.range;return P.filter(G=>G.ranges.some(Z=>a.Rectangle.intersects(Z,B)))}else if(_==="2")return[...P];return[]},[O,k]=C.useState(j);H.useHighlightRange(S),C.useEffect(()=>{const P=s.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>P.dispose()}),C.useEffect(()=>{k(j)},[_,w,m,b]),C.useEffect(()=>{if(_==="2")return;const P=new K.Observable(A=>{const B=[U.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],W=s.onCommandExecuted(G=>{const{id:Z,params:ee}=G,te=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(Z)&&ee.unitId===te&&A.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{k(j)});return()=>{P.unsubscribe()}},[i,_,m,b]),C.useEffect(()=>{const P=n.$ruleChange.subscribe(()=>{E(Math.random())});return()=>P.unsubscribe()},[n]),C.useEffect(()=>{const P=()=>{var G,Z;const W=Math.max(0,((Z=(G=I.current)==null?void 0:G.getBoundingClientRect().width)!=null?Z:0)-8);return lt=W,W},B=new K.Observable(W=>{const G=c.getContainer();if(G){let Z=setTimeout(()=>{W.next(void 0)},150);const ee=()=>{Z&&clearTimeout(Z),Z=null},te=Fe=>{Fe.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{R(P())});return()=>{B.unsubscribe()}},[]);const f=P=>{var W;const A=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");s.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:P.cfId})},F=(P,A)=>{p(A.y)},L=(P,A,B)=>{var Fe;p(-1);const W=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(Fe=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Fe.getSheetId();if(!W||!G)throw new Error("No active sheet found");const Z=_t=>{const wt=O.length;return Math.min(wt-1,Math.max(0,_t))},ee=O[Z(A.y)].cfId,te=O[Z(B.y)].cfId;ee!==te&&s.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>A.y?"after":"before"}})},q=()=>{r.onCreate()},X=()=>{_==="2"?s.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:m,subUnitId:b,cfId:A.cfId})).forEach(A=>{s.executeCommand(t.DeleteCfCommand.id,A)})},J=C.useMemo(()=>{const P=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=P.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,P.getUnitId(),A.getSheetId(),W)})},[O]),ie=J.map((P,A)=>({i:P.cfId,x:0,w:12,y:A,h:1,isResizable:!1})),oe=C.useMemo(()=>{const P=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=P.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,P.getUnitId(),A.getSheetId(),W)})},[O]);return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[u.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:h.tWithReactNode("sheet.cf.panel.managerRuleSelect",u.jsx(M.Select,{className:"univer-w-36",options:V,value:_,onChange:P=>{T(P)}})).map((P,A)=>u.jsx("span",{children:P},A))}),u.jsxs("div",{className:"univer-flex univer-justify-end",children:[u.jsx(M.Tooltip,{title:l.t("sheet.cf.panel.createRule"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:u.jsx(pt,{})})}),O.length&&oe?u.jsx(M.Tooltip,{title:l.t("sheet.cf.panel.clear"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:u.jsx(Me,{className:"univer-text-red-500"})})}):u.jsx("div",{children:u.jsx(Me,{className:"univer-text-gray-300"})})]})]}),u.jsx("div",{ref:I,children:x>0&&u.jsx(M.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:x,margin:[0,10],onDragStop:L,onDragStart:F,children:J==null?void 0:J.map((P,A)=>u.jsx("div",{children:u.jsxs("div",{className:M.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":N===A}),onMouseMove:()=>{P.ranges!==S&&y(P.ranges)},onMouseLeave:()=>y([]),onClick:()=>{e(P)},children:[u.jsx("div",{className:M.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:B=>B.stopPropagation(),children:u.jsx(Ct,{})}),u.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[u.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:ln(P,l)}),u.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:P.ranges.map(B=>We.serializeRange(B)).join(",")})]}),u.jsx("div",{children:u.jsx(ce,{rule:P.rule})}),u.jsx("div",{className:M.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":N===A}),onClick:B=>{B.stopPropagation(),f(P),y([])},children:u.jsx(Me,{})})]})},`${P.cfId}`))})})]})},cn=r=>{const[e,n]=C.useState(r.rule),[i,o]=C.useState(!!r.rule),s=()=>{o(!0)},l=()=>{o(!1),n(void 0)},v=c=>{n(c),o(!0)};return u.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:i?u.jsx(rn,{onCancel:l,rule:e}):u.jsx(un,{onClick:v,onCreate:s})})};var dn=Object.getOwnPropertyDescriptor,mn=(r,e,n,i)=>{for(var o=i>1?void 0:i?dn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},de=(r,e)=>(n,i)=>e(n,i,r);const Ee="sheet.conditional.formatting.panel";let fe=class extends a.Disposable{constructor(e,n,i,o,s){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=i,this._sidebarService=o,this._localeService=s,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(l=>{var v;l||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(l=>{l.id===Ee&&(l.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Ee,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ee,rule:e,key:a.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ee,cn))}};fe=mn([de(0,a.IUniverInstanceService),de(1,a.Inject(a.Injector)),de(2,a.Inject(D.ComponentManager)),de(3,a.Inject(D.ISidebarService)),de(4,a.Inject(a.LocaleService))],fe);var z=(r=>(r[r.createRule=1]="createRule",r[r.viewRule=2]="viewRule",r[r.highlightCell=3]="highlightCell",r[r.rank=4]="rank",r[r.formula=5]="formula",r[r.colorScale=6]="colorScale",r[r.dataBar=7]="dataBar",r[r.icon=8]="icon",r[r.clearRangeRules=9]="clearRangeRules",r[r.clearWorkSheetRules=10]="clearWorkSheetRules",r))(z||{});const Re={id:"sheet.operation.open.conditional.formatting.panel",type:a.CommandType.OPERATION,handler:(r,e)=>{var v;const n=r.get(fe),i=r.get(U.SheetsSelectionsService),o=r.get(a.ICommandService),s=((v=i.getCurrentSelections())==null?void 0:v.map(c=>c.range))||[];switch(e.value){case 3:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 4:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};n.openPanel(c);break}case 5:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};n.openPanel(c);break}case 6:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.colorScale,config:[]}};n.openPanel(c);break}case 7:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(c);break}case 8:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(c);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 9:{o.executeCommand(t.ClearRangeCfCommand.id,{ranges:s});break}case 10:{o.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var vn=Object.getOwnPropertyDescriptor,hn=(r,e,n,i)=>{for(var o=i>1?void 0:i?vn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},me=(r,e)=>(n,i)=>e(n,i,r);exports.ConditionalFormattingClearController=class extends a.Disposable{constructor(e,n,i,o,s){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=i,this._selectionManagerService=o,this._conditionalFormattingRuleModel=s,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var s;const n=[],i=[],o={redos:n,undos:i};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const l=(s=this._selectionManagerService.getCurrentSelections())==null?void 0:s.map(S=>S.range);if(!l)return o;const v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!c)return o;const h=v.getUnitId(),d=c.getSheetId(),m=this._conditionalFormattingRuleModel.getSubunitRules(h,d);if(!m||!m.length)return o;const{redos:g,undos:b}=ut(this._injector,m,l,h,d);n.push(...g),i.push(...b)}return o}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:i})=>{const o=[],s=[],l={redos:o,undos:s};if(!i||!i.length)return l;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!v||!v.length)return l;const{redos:c,undos:h}=ut(this._injector,v,i,e,n);return o.push(...c),s.push(...h),l}}))}};exports.ConditionalFormattingClearController=hn([me(0,a.Inject(a.Injector)),me(1,a.Inject(a.IUniverInstanceService)),me(2,a.Inject(U.SheetInterceptorService)),me(3,a.Inject(U.SheetsSelectionsService)),me(4,a.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ut(r,e,n,i,o){const s=[],l=[];return e.filter(v=>n.some(c=>v.ranges.some(h=>a.Rectangle.getIntersects(h,c)))).forEach(v=>{const h=new U.RangeMergeUtil().add(...v.ranges).subtract(...n).merge();if(h.length){const d={id:t.SetConditionalRuleMutation.id,params:{unitId:i,subUnitId:o,rule:{...v,ranges:h}}},m=t.setConditionalRuleMutationUndoFactory(r,d.params);s.push(d),l.push(...m)}else{const d={id:t.DeleteConditionalRuleMutation.id,params:{unitId:i,subUnitId:o,cfId:v.cfId}},m=t.DeleteConditionalRuleMutationUndoFactory(r,d.params);s.push(d),l.push(...m)}}),{redos:s,undos:l}}var gn=Object.getOwnPropertyDescriptor,pn=(r,e,n,i)=>{for(var o=i>1?void 0:i?gn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},ve=(r,e)=>(n,i)=>e(n,i,r);let Ce=class extends a.Disposable{constructor(e,n,i,o,s){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=i,this._conditionalFormattingViewModel=o,this._univerInstanceService=s,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,i)=>this._collectConditionalRule(e,n,i),onPasteCells:(e,n,i,o)=>{const{copyType:s=H.COPY_TYPE.COPY,pasteType:l}=o,{range:v}=e||{},{range:c}=n;return this._generateConditionalFormattingMutations(c,{copyType:s,pasteType:l,copyRange:v})}}))}_collectConditionalRule(e,n,i){const o=new a.ObjectMatrix,s={};this._copyInfo={matrix:o,info:{unitId:e,subUnitId:n,cfMap:s}};const l=this._injector.invoke(d=>U.rangeToDiscreteRange(i,d,e,n));if(!l)return;const{rows:v,cols:c}=l,h=new Set;v.forEach((d,m)=>{c.forEach((g,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,d,g);S&&(S.forEach(y=>h.add(y.cfId)),o.setValue(m,b,S.map(y=>y.cfId)))})}),h.forEach(d=>{const m=this._conditionalFormattingRuleModel.getRule(e,n,d);m&&(s[d]=m.rule)})}_generateConditionalFormattingMutations(e,n){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=i.getActiveSheet(),s=i.getUnitId();if(!o)return{redos:[],undos:[]};const l=o.getSheetId();if(n.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,H.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[c,h],mapFunc:d}=H.virtualizeDiscreteRanges([n.copyRange,e]),m=H.getRepeatRange(c,h,!0),g={};a.Range.foreach(h,(p,x)=>{const{row:R,col:I}=d(p,x),V=this._conditionalFormattingViewModel.getCellCfs(s,l,R,I);V&&V.forEach(j=>{if(!g[j.cfId]){const O=new a.ObjectMatrix;g[j.cfId]=O;const k=this._conditionalFormattingRuleModel.getRule(s,l,j.cfId);k==null||k.ranges.forEach(f=>{a.Range.foreach(f,(F,L)=>{O.setValue(F,L,1)})})}g[j.cfId].realDeleteValue(R,I)})});const{matrix:b,info:S}=this._copyInfo,y=[];let _=this._conditionalFormattingRuleModel.createCfId(s,l);const T={},w=p=>{if(T[p])return T[p];const x=S==null?void 0:S.cfMap[p],R=[...this._conditionalFormattingRuleModel.getSubunitRules(s,l)||[],...y].find(I=>a.Tools.diffValue(I.rule,x));if(R)return T[p]=R,R;{const I={rule:x,cfId:_,ranges:[],stopIfTrue:!1};return T[p]=I,y.push(I),_=`${Number(_)+1}`,I}};m.forEach(p=>{b&&b.forValue((x,R,I)=>{const V=a.Rectangle.getPositionRange({startRow:x,endRow:x,startColumn:R,endColumn:R},p.startRange),{row:j,col:O}=d(V.startRow,V.startColumn);I.forEach(k=>{if(!g[k]){const f=w(k),F=new a.ObjectMatrix;g[k]=F,f.ranges.forEach(L=>{a.Range.foreach(L,(q,X)=>{F.setValue(q,X,1)})})}g[k].setValue(j,O,1)})})});const E=[],N=[];for(const p in g){const x=g[p],R=U.findAllRectangle(U.createTopMatrixFromMatrix(x));if(!R.length){const I={unitId:s,subUnitId:l,cfId:p};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),N.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(y.some(I=>I.cfId===p)){const I=w(p),V={unitId:s,subUnitId:l,rule:{...I,ranges:R}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),N.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(s,l,p);if(!I)continue;const V={unitId:s,subUnitId:l,rule:{...I,ranges:R}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),N.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:N}}};Ce=pn([ve(0,a.Inject(H.ISheetClipboardService)),ve(1,a.Inject(t.ConditionalFormattingRuleModel)),ve(2,a.Inject(a.Injector)),ve(3,a.Inject(t.ConditionalFormattingViewModel)),ve(4,a.Inject(a.IUniverInstanceService))],Ce);var fn=Object.getOwnPropertyDescriptor,Cn=(r,e,n,i)=>{for(var o=i>1?void 0:i?fn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},Ae=(r,e)=>(n,i)=>e(n,i,r);let ye=class extends a.Disposable{constructor(r,e,n){super(),this._localeService=r,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{if(r.id===t.AddCfCommand.id){const{unitId:e,subUnitId:n,rule:{ranges:i}}=r.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},i,e,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};ye=Cn([Ae(0,a.Inject(a.LocaleService)),Ae(1,a.ICommandService),Ae(2,a.Inject(U.SheetPermissionCheckController))],ye);var yn=Object.getOwnPropertyDescriptor,bn=(r,e,n,i)=>{for(var o=i>1?void 0:i?yn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},je=(r,e)=>(n,i)=>e(n,i,r);let be=class extends a.Disposable{constructor(r,e,n,i){super(),this._conditionalFormattingRuleModel=r,this._univerInstanceService=e,this._injector=n,this._refRangeService=i,this._initRefRange()}_initRefRange(){const r=new Map,e=(i,o,s)=>`${i}_${o}_${s}`,n=(i,o,s)=>{const l=c=>{const h=[...s.ranges],d=h.map(g=>U.handleDefaultRangeChangeWithEffectRefCommands(g,c)).filter(g=>!!g);if(t.isRangesEqual(d,h))return{redos:[],undos:[]};if(d.length){const g={unitId:i,subUnitId:o,rule:{...s,ranges:d}},b=[{id:t.SetConditionalRuleMutation.id,params:g}],S=t.setConditionalRuleMutationUndoFactory(this._injector,g);return{redos:b,undos:S}}else{const g={unitId:i,subUnitId:o,cfId:s.cfId},b=[{id:t.DeleteConditionalRuleMutation.id,params:g}],S=t.DeleteConditionalRuleMutationUndoFactory(this._injector,g);return{redos:b,undos:S}}},v=[];s.ranges.forEach(c=>{const h=this._refRangeService.registerRefRange(c,l);v.push(()=>h.dispose())}),r.set(e(i,o,s.cfId),()=>v.forEach(c=>c()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(i=>{const{unitId:o,subUnitId:s,rule:l}=i,v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!(i.unitId!==v.getUnitId()||i.subUnitId!==(c==null?void 0:c.getSheetId())))switch(i.type){case"add":{n(i.unitId,i.subUnitId,i.rule);break}case"delete":{const h=r.get(e(o,s,l.cfId));h&&h();break}case"set":{const h=r.get(e(o,s,l.cfId));h&&h(),n(i.unitId,i.subUnitId,i.rule)}}})),this.disposeWithMe(a.toDisposable(()=>{r.forEach(i=>{i()}),r.clear()}))}};be=bn([je(0,a.Inject(t.ConditionalFormattingRuleModel)),je(1,a.Inject(a.IUniverInstanceService)),je(2,a.Inject(a.Injector)),je(3,a.Inject(U.RefRangeService))],be);var In=Object.getOwnPropertyDescriptor,Sn=(r,e,n,i)=>{for(var o=i>1?void 0:i?In(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},ae=(r,e)=>(n,i)=>e(n,i,r);let Ie=class extends a.Disposable{constructor(e,n,i,o,s,l){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=i,this._renderManagerService=o,this._conditionalFormattingViewModel=s,this._conditionalFormattingRuleModel=l,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,i,o;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(H.SheetSkeletonManagerService).reCalculate(),(o=(i=this._renderManagerService.getRenderById(e))==null?void 0:i.mainComponent)==null||o.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(pe.bufferTime(16),pe.filter(e=>!!e.length),pe.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const i=n.getActiveSheet();return i?e.filter(o=>o.unitId===n.getUnitId()&&o.subUnitId===i.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,n,i)=>{const o=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!o)return i(e);const s=n.workbook.getStyles(),l=(typeof(e==null?void 0:e.s)=="string"?s.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},v=e===n.rawData?{...n.rawData}:e;if(o.style){const c={...l,...o.style};Object.assign(v,{s:c})}return v.fontRenderExtension||(v.fontRenderExtension={},o.isShowValue!==void 0&&(v.fontRenderExtension.isSkip=!o.isShowValue)),o.dataBar&&(v.dataBar=o.dataBar),o.iconSet&&(v.iconSet=o.iconSet,v.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),i(v)},priority:10}))}};Ie=Sn([ae(0,a.Inject(U.SheetInterceptorService)),ae(1,a.Inject(t.ConditionalFormattingService)),ae(2,a.Inject(a.IUniverInstanceService)),ae(3,a.Inject(vt.IRenderManagerService)),ae(4,a.Inject(t.ConditionalFormattingViewModel)),ae(5,a.Inject(t.ConditionalFormattingRuleModel))],Ie);const Tt="sheets-conditional-formatting-ui.config",Ve={};var xn=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Rn=(r,e,n)=>e in r?xn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Fn=(r,e,n,i)=>{for(var o=i>1?void 0:i?Tn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},$e=(r,e)=>(n,i)=>e(n,i,r),Rt=(r,e,n)=>Rn(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends a.Plugin{constructor(e=Ve,n,i,o){super(),this._config=e,this._injector=n,this._commandService=i,this._configService=o;const{menu:s,...l}=a.merge({},Ve,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Tt,l),this._initCommand(),this._injector.add([Ie]),this._injector.add([be]),this._injector.add([Ce]),this._injector.add([ye]),this._injector.add([ue])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};Rt(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);Rt(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=Fn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),$e(1,a.Inject(a.Injector)),$e(2,a.Inject(a.ICommandService)),$e(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var _n=Object.getOwnPropertyDescriptor,wn=(r,e,n,i)=>{for(var o=i>1?void 0:i?_n(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},he=(r,e)=>(n,i)=>e(n,i,r);let Oe=class extends a.Disposable{constructor(r,e,n,i,o){super(),this._injector=r,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=o,this._initAutoFill()}_initAutoFill(){const r=()=>({redos:[],undos:[]}),e=(o,s,l,v,c)=>{var b;const h=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(b=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!h||!d)return;const m={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},g={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};a.Range.foreach(l,(S,y)=>{const _=a.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},m),T=a.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},g),{row:w,col:E}=c(_.startRow,_.startColumn),N=this._conditionalFormattingViewModel.getCellCfs(h,d,w,E),{row:p,col:x}=c(T.startRow,T.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(h,d,p,x);R&&R.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(h,d,I.cfId);if(!j)return;V=new a.ObjectMatrix,j.ranges.forEach(O=>{a.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),v.set(I.cfId,V)}V.realDeleteValue(p,x)}),N&&N.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(h,d,I.cfId);if(!j)return;V=new a.ObjectMatrix,j.ranges.forEach(O=>{a.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),v.set(I.cfId,V)}V.setValue(p,x,1)})})},n=(o,s)=>{var T,w,E;const l=(T=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:T.getUnitId(),v=(E=(w=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getActiveSheet())==null?void 0:E.getSheetId(),c=new Map,h=[],d=[];if(!l||!v)return r();const m=H.virtualizeDiscreteRanges([o,s]),[g,b]=m.ranges,{mapFunc:S}=m,y={row:g.startRow,col:g.startColumn};return H.getAutoFillRepeatRange(g,b).forEach(N=>{e(y,N.repeatStartCell,N.relativeRange,c,S)}),c.forEach((N,p)=>{const x=this._conditionalFormattingRuleModel.getRule(l,v,p);if(!x)return;const R=U.findAllRectangle(U.createTopMatrixFromMatrix(N));if(R.length){const I={unitId:l,subUnitId:v,rule:{...x,ranges:R}};h.push({id:t.SetConditionalRuleMutation.id,params:I}),d.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:l,subUnitId:v,cfId:x.cfId};h.push({id:t.DeleteConditionalRuleMutation.id,params:I}),d.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:h}},i={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(o,s,l)=>{if(l===H.APPLY_TYPE.COPY||l===H.APPLY_TYPE.ONLY_FORMAT||l===H.APPLY_TYPE.SERIES){const{source:v,target:c}=o;return n(v,c)}return r()}};this.disposeWithMe(this._autoFillService.addHook(i))}};Oe=wn([he(0,a.Inject(a.Injector)),he(1,a.Inject(a.IUniverInstanceService)),he(2,a.Inject(H.IAutoFillService)),he(3,a.Inject(t.ConditionalFormattingRuleModel)),he(4,a.Inject(t.ConditionalFormattingViewModel))],Oe);var Nn=Object.getOwnPropertyDescriptor,En=(r,e,n,i)=>{for(var o=i>1?void 0:i?Nn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},ct=(r,e)=>(n,i)=>e(n,i,r);let Ue=class extends a.Disposable{constructor(r,e){super(),this._sheetInterceptorService=r,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(r,e,n)=>{var l,v,c;r||n(r);const i=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),o=(l=i==null?void 0:i.style)!=null?l:{},s=Object.keys(o);if(r!=null&&r.p)return(c=(v=r.p.body)==null?void 0:v.textRuns)==null||c.forEach(h=>{h.ts&&s.forEach(d=>{var m;(m=h.ts)==null||delete m[d]})}),n(r);{const h={...(typeof(r==null?void 0:r.s)=="string"?e.workbook.getStyles().get(r.s):r==null?void 0:r.s)||{}};s.forEach(m=>{delete h[m]});const d={...r,s:{...h}};return n(d)}}})))}};Ue=En([ct(0,a.Inject(U.SheetInterceptorService)),ct(1,a.Inject(t.ConditionalFormattingService))],Ue);const dt=[U.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],ge=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:z.clearWorkSheetRules}],jn=r=>{const e=r.get(U.SheetsSelectionsService),n=r.get(a.ICommandService),i=r.get(a.IUniverInstanceService),o=r.get(t.ConditionalFormattingRuleModel),s=new K.Observable(c=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(h=>{const d=n.onCommandExecuted(m=>{var y;const{id:g,params:b}=m,S=(y=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&h.next(null)});return()=>d.dispose()})).pipe(pe.debounceTime(16)).subscribe(()=>{var y;const h=((y=e.getCurrentSelections())==null?void 0:y.map(_=>_.range))||[],d=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d)return;const m=d.getActiveSheet();if(!m)return;const S=(o.getSubunitRules(d.getUnitId(),m.getSheetId())||[]).filter(_=>_.ranges.some(T=>h.some(w=>a.Rectangle.intersects(w,T)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(r,d.getUnitId(),m.getSheetId(),_));c.next(S)})),l=new K.Observable(c=>new K.Observable(h=>{const d=n.onCommandExecuted(m=>{var y;const{id:g,params:b}=m,S=(y=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&h.next(null)});return()=>d.dispose()}).pipe(pe.debounceTime(16)).subscribe(()=>{const h=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!h)return;const d=h.getActiveSheet();if(!d)return;const m=o.getSubunitRules(h.getUnitId(),d.getSheetId())||[];if(!m.length)return c.next(!1),!1;const g=m.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(r,h.getUnitId(),d.getSheetId(),b));c.next(g)})),v=new K.Observable(c=>{s.subscribe(h=>{const d=ge.find(m=>m.value===z.clearRangeRules);d&&(d.disabled=!h,c.next(ge))}),l.subscribe(h=>{const d=ge.find(m=>m.value===z.clearWorkSheetRules);d&&(d.disabled=!h,c.next(ge))}),c.next(ge)});return{id:Re.id,type:D.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:v,hidden$:D.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(r,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Mn={[D.RibbonDataGroup.RULES]:{[Re.id]:{order:1,menuItemFactory:jn}}};var Vn=Object.getOwnPropertyDescriptor,On=(r,e,n,i)=>{for(var o=i>1?void 0:i?Vn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},mt=(r,e)=>(n,i)=>e(n,i,r);let ke=class extends a.Disposable{constructor(e,n){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(Mn)}};ke=On([mt(0,a.Inject(a.Injector)),mt(1,D.IMenuManagerService)],ke);var Un=Object.getOwnPropertyDescriptor,kn=(r,e,n,i)=>{for(var o=i>1?void 0:i?Un(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},le=(r,e)=>(n,i)=>e(n,i,r);const Dn=(r,e)=>{const n=d=>d.endRow-d.startRow+1,i=d=>d.endColumn-d.startColumn+1,o=n(e)%n(r),s=i(e)%i(r),l=Math.floor(n(e)/n(r)),v=Math.floor(i(e)/i(r)),c=[],h={startRow:0,endRow:n(r)-1,startColumn:0,endColumn:i(r)-1};if(n(e)===1&&i(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return c.push({repeatRelativeRange:h,startRange:d}),c}for(let d=0;d<l+(o?.1:0);d++)for(let m=0;m<v+(s?.1:0);m++){const g=n(r)*d,b=i(r)*m,S={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let y=h;d===l&&o&&(y={...y},y.endRow=y.endRow-(n(r)-o)),m===v&&s&&(y={...y},y.endColumn=y.endColumn-(i(r)-s)),c.push({repeatRelativeRange:y,startRange:S})}return c};let De=class extends a.Disposable{constructor(e,n,i,o,s,l){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=i,this._sheetsSelectionsService=o,this._conditionalFormattingRuleModel=s,this._conditionalFormattingViewModel=l,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(s,l,v,c,h)=>{const{unitId:d,subUnitId:m}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=h,S={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},y={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row};a.Range.foreach(v,(_,T)=>{const w=a.Rectangle.getPositionRange({startRow:_,startColumn:T,endColumn:T,endRow:_},S),E=a.Rectangle.getPositionRange({startRow:_,startColumn:T,endColumn:T,endRow:_},y),N=this._conditionalFormattingViewModel.getCellCfs(d,m,w.startRow,w.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(g,b,E.startRow,E.startColumn);p&&p.forEach(x=>{let R=c.get(x.cfId);if(!c.get(x.cfId)){const I=this._conditionalFormattingRuleModel.getRule(g,b,x.cfId);if(!I)return;R=new a.ObjectMatrix,I.ranges.forEach(V=>{a.Range.foreach(V,(j,O)=>{R.setValue(j,O,1)})}),c.set(x.cfId,R)}R.realDeleteValue(E.startRow,E.startColumn)}),N&&N.forEach(x=>{const R=c.get(x.cfId);R&&R.setValue(E.startRow,E.startColumn,1)})})},i=(s,l,v)=>{var w;const{range:c,unitId:h,subUnitId:d}=this._painterConfig,m=s!==h||d!==l,g=new Map,b=[],S=[];if(!s||!l||!h||!d)return e();const y=(w=this._conditionalFormattingRuleModel.getSubunitRules(h,d))!=null?w:[];y==null||y.forEach(E=>{const{ranges:N,cfId:p}=E;if(N.some(x=>a.Rectangle.intersects(c,x))){const x=new a.ObjectMatrix;m||N.forEach(R=>{a.Range.foreach(R,(I,V)=>{x.setValue(I,V,1)})}),g.set(p,x)}});const _={row:c.startRow,col:c.startColumn};return Dn(c,v).forEach(E=>{n(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,g,{targetUnitId:s,targetSubUnitId:l})}),g.forEach((E,N)=>{if(m){const p=this._conditionalFormattingRuleModel.getRule(s,l,N),x=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(p)if(x.length){const R={unitId:s,subUnitId:l,rule:{...p,ranges:x}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:s,subUnitId:l,cfId:p.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}else if(x.length){const R=this._conditionalFormattingRuleModel.getRule(h,d,N);if(R){const I={unitId:s,subUnitId:l,rule:{...a.Tools.deepClone(R),cfId:this._conditionalFormattingRuleModel.createCfId(s,l),ranges:x}};b.push({id:t.AddConditionalRuleMutation.id,params:I}),S.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const p=this._conditionalFormattingRuleModel.getRule(h,d,N);if(!p)return;const x=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(x.length){const R={unitId:h,subUnitId:d,rule:{...p,ranges:x}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:h,subUnitId:d,cfId:p.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}}}),{undos:S,redos:b}},o={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:s=>{var l,v,c;switch(s){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const h=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getUnitId(),d=(c=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:c.getSheetId(),m=this._sheetsSelectionsService.getCurrentLastSelection(),g=m==null?void 0:m.range;h&&d&&g&&(this._painterConfig={unitId:h,subUnitId:d,range:g});break}case H.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(s,l,v)=>this._painterConfig?i(s,l,v):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};De=kn([le(0,a.Inject(a.Injector)),le(1,a.Inject(a.IUniverInstanceService)),le(2,a.Inject(H.IFormatPainterService)),le(3,a.Inject(U.SheetsSelectionsService)),le(4,a.Inject(t.ConditionalFormattingRuleModel)),le(5,a.Inject(t.ConditionalFormattingViewModel))],De);var Pn=Object.getOwnPropertyDescriptor,Ln=(r,e,n,i)=>{for(var o=i>1?void 0:i?Pn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},Be=(r,e)=>(n,i)=>e(n,i,r);let Pe=class extends a.Disposable{constructor(r,e,n){super(),this._conditionalFormattingViewModel=r,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),e=n=>{const i=n.getUnitId(),o=this._renderManagerService.getRenderById(i);if(!o)return;const s=o.with(H.SheetSkeletonManagerService);this.disposeWithMe(s.currentSkeleton$.subscribe(l=>{if(l){const v=l.skeleton.rowColumnSegment,c=v.endColumn-v.startColumn+1,d=(v.endRow-v.startRow+1)*c*9,m=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(m)}}))};r&&e(r),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Pe=Ln([Be(0,a.Inject(t.ConditionalFormattingViewModel)),Be(1,a.IUniverInstanceService),Be(2,vt.IRenderManagerService)],Pe);var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Bn=(r,e,n)=>e in r?An(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Hn=(r,e,n,i)=>{for(var o=i>1?void 0:i?$n(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},He=(r,e)=>(n,i)=>e(n,i,r),Ft=(r,e,n)=>Bn(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends a.Plugin{constructor(e=Ve,n,i,o){super(),this._config=e,this._injector=n,this._commandService=i,this._configService=o;const{menu:s,...l}=a.merge({},Ve,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Tt,l),this._initCommand()}onStarting(){a.registerDependencies(this._injector,[[Ie],[be],[Ce],[Oe],[ye],[fe],[ke],[ue],[Ue],[exports.ConditionalFormattingClearController],[De],[Pe]]),a.touchDependencies(this._injector,[[Ie]])}onReady(){a.touchDependencies(this._injector,[[ke],[fe]])}onRendered(){a.touchDependencies(this._injector,[[Oe],[exports.ConditionalFormattingClearController],[Ce],[Ue],[ue],[De],[ye],[be],[Pe]])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};Ft(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);Ft(exports.UniverSheetsConditionalFormattingUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Hn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),He(1,a.Inject(a.Injector)),He(2,a.Inject(a.ICommandService)),He(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=qe;exports.AddColorScaleConditionalRuleCommand=Ge;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=ze;exports.AddNumberCfCommand=Ye;exports.AddRankCfCommand=Ke;exports.AddTextCfCommand=Xe;exports.AddTimePeriodCfCommand=Je;exports.AddUniqueValuesCfCommand=Qe;exports.OpenConditionalFormattingOperator=Re;
1
+ "use strict";var Nt=Object.defineProperty;var Et=(r,e,n)=>e in r?Nt(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n;var Q=(r,e,n)=>Et(r,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),U=require("@univerjs/sheets"),t=require("@univerjs/sheets-conditional-formatting"),P=require("@univerjs/ui"),u=require("react/jsx-runtime"),C=require("react"),M=require("@univerjs/design"),We=require("@univerjs/engine-formula"),Se=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),vt=require("@univerjs/engine-render"),pe=require("rxjs/operators"),qe={type:a.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s}=e,l=r.get(t.ConditionalFormattingRuleModel),v=r.get(a.ICommandService),c=r.get(a.IUniverInstanceService),h=U.getSheetCommandTarget(c);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=l.createCfId(d,m),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:s,style:i}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:b})}},Ge={type:a.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,config:i,stopIfTrue:o}=e,s=r.get(t.ConditionalFormattingRuleModel),l=r.get(a.ICommandService),v=r.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=s.createCfId(h,d),g={ranges:n,cfId:m,stopIfTrue:!!o,rule:{type:t.CFRuleType.colorScale,config:i}};return l.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}},Ze={type:a.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,min:i,max:o,nativeColor:s,positiveColor:l,isGradient:v,stopIfTrue:c,isShowValue:h}=e,d=r.get(t.ConditionalFormattingRuleModel),m=r.get(a.IUniverInstanceService),g=U.getSheetCommandTarget(m);if(!g)return!1;const{unitId:b,subUnitId:S}=g,y=r.get(a.ICommandService),_=d.createCfId(b,S),T={ranges:n,cfId:_,stopIfTrue:!!c,rule:{type:t.CFRuleType.dataBar,isShowValue:h,config:{min:i,max:o,nativeColor:s,positiveColor:l,isGradient:v}}};return y.executeCommand(t.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:T})}},ze={type:a.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o}=e,s=r.get(t.ConditionalFormattingRuleModel),l=r.get(a.ICommandService),v=r.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=s.createCfId(h,d),g={ranges:n,cfId:m,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:i}};return l.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}},Ye={type:a.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s,value:l}=e,v=r.get(t.ConditionalFormattingRuleModel),c=r.get(a.ICommandService),h=r.get(a.IUniverInstanceService),d=U.getSheetCommandTarget(h);if(!d)return!1;const{unitId:m,subUnitId:g}=d,b=v.createCfId(m,g);let S;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(s)){const y=l;if(y.length!==2||!Array.isArray(y))return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:i,value:y}}}else{const y=l;if(typeof y!="number")return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:i,value:y}}}return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:g,rule:S})}},Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,isPercent:s,isBottom:l,value:v}=e,c=r.get(t.ConditionalFormattingRuleModel),h=r.get(a.IUniverInstanceService),d=r.get(a.ICommandService),m=U.getSheetCommandTarget(h);if(!m)return!1;const{unitId:g,subUnitId:b}=m,S=c.createCfId(g,b),y={ranges:n,cfId:S,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:s,isBottom:l,style:i,value:v}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:y})}},Xe={type:a.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s,value:l}=e,v=r.get(t.ConditionalFormattingRuleModel),c=r.get(a.IUniverInstanceService),h=U.getSheetCommandTarget(c);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=r.get(a.ICommandService),b=v.createCfId(d,m),S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:s,style:i,value:l}};return g.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:S})}},Je={type:a.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o,operator:s}=e,l=r.get(t.ConditionalFormattingRuleModel),v=r.get(a.IUniverInstanceService),c=r.get(a.ICommandService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=l.createCfId(d,m),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:s,style:i}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:b})}},Qe={type:a.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(r,e){if(!e)return!1;const{ranges:n,style:i,stopIfTrue:o}=e,s=r.get(t.ConditionalFormattingRuleModel),l=r.get(a.IUniverInstanceService),v=r.get(a.ICommandService),c=U.getSheetCommandTarget(l);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=s.createCfId(h,d),g={ranges:n,cfId:m,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:i}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}};function Y({ref:r,...e}){const{icon:n,id:i,className:o,extend:s,...l}=e,v=`univerjs-icon univerjs-icon-${i} ${o||""}`.trim(),c=C.useRef(`_${Vt()}`);return ht(n,`${i}`,{defIds:n.defIds,idSuffix:c.current},{ref:r,className:v,...l},s)}function ht(r,e,n,i,o){return C.createElement(r.tag,{key:e,...jt(r,n,o),...i},(Mt(r,n).children||[]).map((s,l)=>ht(s,`${e}-${r.tag}-${l}`,n,void 0,o)))}function jt(r,e,n){const i={...r.attrs};n!=null&&n.colorChannel1&&i.fill==="colorChannel1"&&(i.fill=n.colorChannel1),r.tag==="mask"&&i.id&&(i.id=i.id+e.idSuffix),Object.entries(i).forEach(([s,l])=>{s==="mask"&&typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(r.tag==="use"&&i["xlink:href"]&&(i["xlink:href"]=i["xlink:href"]+e.idSuffix),Object.entries(i).forEach(([s,l])=>{typeof l=="string"&&(i[s]=l.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),i}function Mt(r,e){var i;const{defIds:n}=e;return!n||n.length===0?r:r.tag==="defs"&&((i=r.children)!=null&&i.length)?{...r,children:r.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:r}function Vt(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const Ot={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"bold-icon",ref:n,icon:Ot}))});gt.displayName="BoldIcon";const Ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Me=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"delete-icon",ref:n,icon:Ut}))});Me.displayName="DeleteIcon";const kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},pt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"increase-icon",ref:n,icon:kt}))});pt.displayName="IncreaseIcon";const Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},ft=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"italic-icon",ref:n,icon:Pt}))});ft.displayName="ItalicIcon";const Dt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"more-down-icon",ref:n,icon:Dt}))});et.displayName="MoreDownIcon";const Lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Ct=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"sequence-icon",ref:n,icon:Lt}))});Ct.displayName="SequenceIcon";const At={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},yt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"strikethrough-icon",ref:n,icon:At}))});yt.displayName="StrikethroughIcon";const $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},bt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"underline-icon",ref:n,icon:$t}))});bt.displayName="UnderlineIcon";const Bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},It=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"font-color-double-icon",ref:n,icon:Bt}))});It.displayName="FontColorDoubleIcon";const Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},St=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"paint-bucket-double-icon",ref:n,icon:Ht}))});St.displayName="PaintBucketDoubleIcon";const Wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},xe=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"slash-double-icon",ref:n,icon:Wt}))});xe.displayName="SlashDoubleIcon";const re=r=>{const{color:e,onChange:n,disable:i=!1,Icon:o=St,className:s}=r,l=C.useMemo(()=>new a.ColorKit(e),[e]),v=()=>{const c={className:M.clsx("univer-fill-primary-600",i&&s),extend:{colorChannel1:l.isValid?e:""}};return u.jsx(o,{...c})};return i?v():u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(M.ColorPicker,{value:e,onChange:n})}),children:u.jsx("span",{className:M.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",s),children:v()})})},ce=r=>{var s,l,v,c,h;const e=r.rule;if(!e)return null;const n=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const d=e.config.map((b,S)=>({color:new a.ColorKit(b.color),value:S})),m=d.length-1;return new Array(5).fill("").map((b,S,y)=>S*m/(y.length-1)).map(b=>t.getColorScaleFromValue(d,b))}return null},[e]),i=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(d=>{const m=t.iconMap[d.iconType];return m&&m[Number(d.iconId)]})},[e]),o="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:d}=e.config,m=d?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=d?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return u.jsxs("div",{className:o,children:[u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(s=e.config.nativeColor)!=null?s:t.defaultDataBarNativeColor}}),u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:m,borderColor:(l=e.config.positiveColor)!=null?l:t.defaultDataBarPositiveColor}})]})}case t.CFRuleType.colorScale:return n&&u.jsx("div",{className:o,children:n.map((d,m)=>u.jsx("div",{className:"univer-h-full",style:{width:`${100/n.length}%`,background:d}},m))});case t.CFRuleType.iconSet:return i&&u.jsx("div",{className:o,children:i.map((d,m)=>d?u.jsx("img",{className:"univer-h-full",src:d,draggable:!1},m):u.jsx(xe,{},m))});case t.CFRuleType.highlightCell:{const{ul:d,st:m,it:g,bl:b,bg:S,cl:y}=e.style,_=(d==null?void 0:d.s)===a.BooleanNumber.TRUE,T=(m==null?void 0:m.s)===a.BooleanNumber.TRUE,w=g===a.BooleanNumber.TRUE,E=b===a.BooleanNumber.TRUE,N=(v=S==null?void 0:S.rgb)!=null?v:t.DEFAULT_BG_COLOR,p=(c=y==null?void 0:y.rgb)!=null?c:t.DEFAULT_FONT_COLOR,x={textDecoration:(h=`${_?"underline":""} ${T?"line-through":""}`.replace(/^ /,""))!=null?h:void 0,backgroundColor:N,color:p};return u.jsx("div",{className:M.clsx(o,{"univer-font-bold":E,"univer-italic":w}),style:x,children:"123"})}}},Te=M.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",M.borderClassName),ne=(r,e)=>({label:e.t(`sheet.cf.valueType.${r}`),value:r}),Le=r=>{var S;const{type:e,className:n,onChange:i,id:o,value:s}=r,l=P.useDependency(a.IUniverInstanceService),v=l.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(S=l.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),h=C.useMemo(()=>String(s).startsWith("=")?String(s):"=",[s]),d=C.useMemo(()=>[t.CFValueType.max,t.CFValueType.min,"none"].includes(e)?{disabled:!0}:[t.CFValueType.percent,t.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),m=C.useRef(null),[g,b]=C.useState(!1);return P.useSidebarClick(y=>{var T;((T=m.current)==null?void 0:T.isClickOutSide(y))&&b(!1)}),e===t.CFValueType.formula?u.jsx("div",{className:"univer-ml-1 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:m,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:h,unitId:v,subUnitId:c,isFocus:g,onChange:(y="")=>{i(y||"")},onFocus:()=>b(!0)})}):u.jsx(M.InputNumber,{className:n,value:Number(r.value)||0,onChange:y=>r.onChange(y||0),...d})},qt=r=>{var k;const{interceptorManager:e}=r,n=P.useDependency(a.LocaleService),i=((k=r.rule)==null?void 0:k.type)===t.CFRuleType.colorScale?r.rule:void 0,o=[ne(t.CFValueType.num,n),ne(t.CFValueType.percent,n),ne(t.CFValueType.percentile,n),ne(t.CFValueType.formula,n)],s=[ne(t.CFValueType.min,n),...o],l=[ne("none",n),...o],v=[ne(t.CFValueType.max,n),...o],[c,h]=C.useState(()=>{var F;const f=t.CFValueType.min;return i&&((F=i.config[0])==null?void 0:F.value.type)||f}),[d,m]=C.useState(()=>{var F;const f="none";return!i||i.config.length!==3?f:((F=i.config[1])==null?void 0:F.value.type)||f}),[g,b]=C.useState(()=>{var F;const f=t.CFValueType.max;return i&&((F=i.config[i.config.length-1])==null?void 0:F.value.type)||f}),[S,y]=C.useState(()=>{if(!i)return 10;const F=i.config[0];return(F==null?void 0:F.value.value)===void 0?10:F==null?void 0:F.value.value}),[_,T]=C.useState(()=>{var L;if(!i||i.config.length!==3)return 50;const F=(L=i.config[1])==null?void 0:L.value.value;return F===void 0?50:F}),[w,E]=C.useState(()=>{var L;if(!i)return 90;const F=(L=i.config[i.config.length-1])==null?void 0:L.value.value;return F===void 0?90:F}),[N,p]=C.useState(()=>{var F;const f="#d0d9fb";return i&&((F=i.config[0])==null?void 0:F.color)||f}),[x,R]=C.useState(()=>{var F;const f="#7790f3";return!i||i.config.length!==3?f:((F=i.config[1])==null?void 0:F.color)||f}),[I,V]=C.useState(()=>{var F;const f="#2e55ef";return i&&((F=i.config[i.config.length-1])==null?void 0:F.color)||f}),j=C.useMemo(()=>f=>{const{minType:F,medianType:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:oe,medianColor:D,maxColor:A}=f,B=[];return B.push({color:oe,value:{type:F,value:X}}),L!=="none"&&B.push({color:D,value:{type:L,value:J}}),B.push({color:A,value:{type:q,value:ie}}),{config:B.map((G,Z)=>({...G,index:Z})),type:t.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return j({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),[j,c,d,g,S,_,w,N,x,I,e]);const O=f=>{r.onChange(j(f))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:j({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})})}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:s,value:c,onChange:f=>{h(f);const F=t.createDefaultValueByValueType(f,10);y(F),O({minType:f,medianType:d,maxType:g,minValue:F,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(Le,{id:"min",className:"univer-ml-1",value:S,type:c,onChange:f=>{y(f),O({minType:c,medianType:d,maxType:g,minValue:f,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:N,onChange:f=>{p(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:f,medianColor:x,maxColor:I})}})]}),u.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:n.t("sheet.cf.panel.medianValue")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:l,value:d,onChange:f=>{m(f);const F=t.createDefaultValueByValueType(f,50);T(F),O({minType:c,medianType:f,maxType:g,minValue:S,medianValue:F,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(Le,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{T(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:f,maxValue:w,minColor:N,medianColor:x,maxColor:I})}}),d!=="none"&&u.jsx(re,{className:"univer-ml-1",color:x,onChange:f=>{R(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:f,maxColor:I})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:v,value:g,onChange:f=>{b(f);const F=t.createDefaultValueByValueType(f,90);E(F),O({minType:c,medianType:d,maxType:f,minValue:S,medianValue:_,maxValue:F,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(Le,{id:"max",className:"univer-ml-1",value:w,type:g,onChange:f=>{E(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:f,minColor:N,medianColor:x,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:c,medianType:d,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:x,maxColor:f})}})]})]})},se=(r,e)=>({label:e.t(`sheet.cf.valueType.${r}`),value:r}),nt=r=>{var y;const{onChange:e,className:n,value:i,type:o,id:s,disabled:l=!1}=r,v=P.useDependency(a.IUniverInstanceService),c=v.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(y=v.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId(),d=C.useRef(null),[m,g]=C.useState(!1);P.useSidebarClick(_=>{var w;((w=d.current)==null?void 0:w.isClickOutSide(_))&&g(!1)});const b=C.useRef(i),S=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(o)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[o]);if(o===t.CFValueType.formula){const _=String(b.current).startsWith("=")?String(b.current)||"":"=";return u.jsx("div",{className:"univer-ml-3 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:d,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:_,unitId:c,subUnitId:h,isFocus:m,onChange:(T="")=>{e(T||"")},onFocus:()=>g(!0)})})}return u.jsx(M.InputNumber,{className:n,value:Number(i)||0,disabled:l,onChange:_=>{e(_||0)},...S})},Gt=r=>{var k;const{interceptorManager:e}=r,n=P.useDependency(a.LocaleService),i=((k=r.rule)==null?void 0:k.type)===t.CFRuleType.dataBar?r.rule:void 0,[o,s]=C.useState(()=>{var F;return i&&(F=i.config)!=null&&F.isGradient?"1":"0"}),[l,v]=C.useState(()=>{var f;return i&&((f=i.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[c,h]=C.useState(()=>{var f;return i&&((f=i.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),d=[se(t.CFValueType.num,n),se(t.CFValueType.percent,n),se(t.CFValueType.percentile,n),se(t.CFValueType.formula,n)],m=[se(t.CFValueType.min,n),...d],g=[se(t.CFValueType.max,n),...d],[b,S]=C.useState(()=>{var F;const f=m[0].value;return i&&((F=i.config)==null?void 0:F.min.type)||f}),[y,_]=C.useState(()=>{var F;const f=g[0].value;return i&&((F=i.config)==null?void 0:F.max.type)||f}),[T,w]=C.useState(()=>{var L;if(!i)return 0;const F=((L=i.config)==null?void 0:L.min)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value||0}),[E,N]=C.useState(()=>{var L;if(!i)return 100;const F=((L=i.config)==null?void 0:L.max)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value===void 0?100:F.value}),[p,x]=C.useState(()=>i?i.isShowValue===void 0?!0:!!i.isShowValue:!0),R=f=>({config:{min:{type:f.minValueType,value:f.minValue},max:{type:f.maxValueType,value:f.maxValue},isGradient:f.isGradient==="1",positiveColor:f.positiveColor||t.defaultDataBarPositiveColor,nativeColor:f.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:f.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return R({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}}),[o,T,b,E,y,l,c,e,p]);const I=f=>{r.onChange(R(f))},V=f=>{v(f),I({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:f,nativeColor:c,isShowValue:p})},j=f=>{h(f),I({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:f,isShowValue:p})},O=f=>d.map(F=>F.value).includes(f);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:R({isGradient:o,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})})}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.fillType")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs(M.RadioGroup,{value:o,onChange:f=>{s(f),I({isGradient:f,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})},children:[u.jsx(M.Radio,{value:"0",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.pureColor")})}),u.jsx(M.Radio,{value:"1",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.gradient")})})]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!p,onChange:f=>{x(!f),I({isGradient:f,minValue:T,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:!f})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.colorSet")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs("div",{className:"univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.native")}),u.jsx(re,{color:c,onChange:j})]}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.positive")}),u.jsx(re,{color:l,onChange:V})]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:m,value:b,onChange:f=>{S(f);const F=t.createDefaultValueByValueType(f,10);w(F),I({isGradient:o,minValue:F,minValueType:f,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}}),u.jsx(nt,{id:"min",className:"univer-ml-3",disabled:!O(b),type:b,value:T,onChange:f=>{w(f||0),I({isGradient:o,minValue:f||0,minValueType:b,maxValue:E,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:y,onChange:f=>{_(f);const F=t.createDefaultValueByValueType(f,90);N(F),I({isGradient:o,minValue:T,minValueType:b,maxValue:F,maxValueType:f,positiveColor:l,nativeColor:c,isShowValue:p})}}),u.jsx(nt,{className:"univer-ml-3",disabled:!O(y),id:"max",type:y,value:E,onChange:f=>{N(f||0),I({isGradient:o,minValue:T,minValueType:b,maxValue:f||0,maxValueType:y,positiveColor:l,nativeColor:c,isShowValue:p})}})]})]})]})},_e=r=>[a.BooleanNumber.FALSE,void 0].includes(r)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,we=r=>r!==a.BooleanNumber.FALSE,tt=r=>{const{style:e,onChange:n,className:i}=r,[o,s]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[l,v]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[c,h]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[d,m]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[g,b]=C.useState(()=>{var w;const T="#2f56ef";return(w=e==null?void 0:e.cl)!=null&&w.rgb?e.cl.rgb:T}),[S,y]=C.useState(()=>{var w;const T="#e8ecfc";return(w=e==null?void 0:e.bg)!=null&&w.rgb?e.bg.rgb:T});C.useEffect(()=>{const T={bl:o,it:l};g!==void 0&&(T.cl={rgb:g}),S!==void 0&&(T.bg={rgb:S}),d!==void 0&&(T.st={s:d}),c!==void 0&&(T.ul={s:c}),n(t.removeUndefinedAttr(T))},[o,l,c,d,g,S]);const _="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return u.jsxs("div",{className:M.clsx("univer-my-2.5 univer-flex univer-justify-between",i),children:[u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(o||a.BooleanNumber.FALSE)}),onClick:()=>s(_e(o)),children:u.jsx(gt,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(l||a.BooleanNumber.FALSE)}),onClick:()=>v(_e(l)),children:u.jsx(ft,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(c||a.BooleanNumber.FALSE)}),onClick:()=>h(_e(c)),children:u.jsx(bt,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(d||a.BooleanNumber.FALSE)}),onClick:()=>m(_e(d)),children:u.jsx(yt,{})}),u.jsx(re,{color:g,onChange:b,Icon:It}),u.jsx(re,{color:S,onChange:y})]})},Zt=r=>{var N;const{onChange:e,interceptorManager:n}=r,i=P.useDependency(a.LocaleService),s=P.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),l=s.getActiveSheet(),v=((N=r.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?r.rule:void 0,c=C.useRef(null),[h,d]=C.useState(!1),m=C.useRef(null),[g,b]=C.useState({}),[S,y]=C.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,T]=C.useState(void 0),w=p=>({style:p.style,value:S,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return w({style:g})}}),[g,S,n]),C.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(x,R,I)=>_||S.length===1||!S.startsWith("=")?(T(i.t("sheet.cf.errorMessage.formulaError")),!1):I(x)}),[_,S]);const E=p=>{e(w(p))};return P.useSidebarClick(p=>{var R;((R=m.current)==null?void 0:R.isClickOutSide(p))&&d(!1)}),u.jsxs("div",{ref:c,children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(Se.FormulaEditor,{ref:m,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),errorText:_,isFocus:h,initValue:S,unitId:s.getUnitId(),subUnitId:l==null?void 0:l.getSheetId(),onFocus:()=>{d(!0)},onChange:p=>{y(p),E({style:g})},onVerify:(p,x)=>{!p||x.length===1?T(i.t("sheet.cf.errorMessage.formulaError")):T(void 0)}})}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:w({style:g})})}),u.jsx(tt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:p=>{b(p),E({style:p})}})]})},Ne=r=>u.jsxs("div",{className:"univer-relative",children:[u.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:r.errorText}),r.children]}),$=(r,e)=>({label:e.t(`sheet.cf.operator.${r}`),value:r}),zt=r=>{const{type:e,operator:n,onChange:i,value:o,interceptorManager:s}=r,l=P.useDependency(a.LocaleService),[v,c]=C.useState(()=>typeof o=="number"?o:0),[h,d]=C.useState(""),[m,g]=C.useState(()=>typeof o=="string"?o:""),[b,S]=C.useState(""),[y,_]=C.useState(()=>Array.isArray(o)?o[0]===void 0?0:o[0]:0),[T,w]=C.useState(""),[E,N]=C.useState(()=>Array.isArray(o)?o[1]===void 0?100:o[1]:100),[p,x]=C.useState("");switch(C.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)&&i(m);break}case t.CFSubRuleType.number:{[t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)&&i(v),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)&&i([y,E]);break}}},[e]),C.useEffect(()=>{const R=s.intercept(s.getInterceptPoints().beforeSubmit,{handler:(I,V,j)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(n))return m?j(I):(S(l.t("sheet.cf.errorMessage.notBlank")),!1)}return j(I)}});return()=>{R()}},[e,v,m,n]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)){const R=I=>{g(I),i(I)};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:b,children:u.jsx(M.Input,{value:m,onChange:I=>{S(""),R(I)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)){const R=I=>{c(I||0),i(I||0),d("")};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:h,children:u.jsx(M.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:R})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)){const R=V=>{_(V||0),i([V||0,E]),w("")},I=V=>{N(V||0),i([y,V||0]),x("")};return u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(Ne,{errorText:T,children:u.jsx(M.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:y,onChange:R})}),u.jsx(Ne,{errorText:p,children:u.jsx(M.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},rt=(r,e)=>{switch(r){case t.CFSubRuleType.text:return[$(t.CFTextOperator.containsText,e),$(t.CFTextOperator.notContainsText,e),$(t.CFTextOperator.beginsWith,e),$(t.CFTextOperator.endsWith,e),$(t.CFTextOperator.equal,e),$(t.CFTextOperator.notEqual,e),$(t.CFTextOperator.containsBlanks,e),$(t.CFTextOperator.notContainsBlanks,e),$(t.CFTextOperator.containsErrors,e),$(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[$(t.CFNumberOperator.between,e),$(t.CFNumberOperator.notBetween,e),$(t.CFNumberOperator.equal,e),$(t.CFNumberOperator.notEqual,e),$(t.CFNumberOperator.greaterThan,e),$(t.CFNumberOperator.greaterThanOrEqual,e),$(t.CFNumberOperator.lessThan,e),$(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[$(t.CFTimePeriodOperator.yesterday,e),$(t.CFTimePeriodOperator.today,e),$(t.CFTimePeriodOperator.tomorrow,e),$(t.CFTimePeriodOperator.last7Days,e),$(t.CFTimePeriodOperator.lastWeek,e),$(t.CFTimePeriodOperator.thisWeek,e),$(t.CFTimePeriodOperator.nextWeek,e),$(t.CFTimePeriodOperator.lastMonth,e),$(t.CFTimePeriodOperator.thisMonth,e),$(t.CFTimePeriodOperator.nextMonth,e)]}},it=r=>{var N;const{interceptorManager:e,onChange:n}=r,i=P.useDependency(a.LocaleService),o=((N=r.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?r.rule:void 0,[s,l]=C.useState(()=>{const p=t.CFSubRuleType.text;return o&&o.subType||p}),v=[{value:t.CFSubRuleType.text,label:i.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:i.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:i.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:i.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:i.t("sheet.cf.subRuleType.uniqueValues")}],c=C.useMemo(()=>rt(s,i),[s]),[h,d]=C.useState(()=>{const p=c?c[0].value:void 0;return o&&o.operator||p}),[m,g]=C.useState(()=>{var R;return o?(R=o.value)!=null?R:t.createDefaultValue(o.subType,o.operator):""}),[b,S]=C.useState({}),y=C.useMemo(()=>p=>{var x,R,I,V,j,O,k,f,F,L,q,X,J,ie,oe;switch(p.subType||s){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(h))return{type:t.CFRuleType.highlightCell,subType:(x=p.subType)!=null?x:s,operator:(R=p.operator)!=null?R:h,style:(I=p.style)!=null?I:b,value:(V=p.value)!=null?V:m};break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(h))return{type:t.CFRuleType.highlightCell,subType:(j=p.subType)!=null?j:s,operator:(O=p.operator)!=null?O:h,style:(k=p.style)!=null?k:b,value:(f=p.value)!=null?f:m};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(h))return{type:t.CFRuleType.highlightCell,subType:(F=p.subType)!=null?F:s,operator:(L=p.operator)!=null?L:h,style:(q=p.style)!=null?q:b,value:(X=p.value)!=null?X:m};break}}return{type:t.CFRuleType.highlightCell,subType:(J=p.subType)!=null?J:s,operator:(ie=p.operator)!=null?ie:h,style:(oe=p.style)!=null?oe:b}},[s,h,m,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return y({})}}),[y,e]),C.useEffect(()=>{v.some(p=>p.value===s)||l(v[0].value)},[v]);const _=p=>{const x=p,R=rt(x,i),I=R&&R[0].value;l(x),d(I),I&&g(t.createDefaultValue(x,I)),n(y({subType:x,operator:I}))},T=p=>{const x=p;d(x),n(y({operator:x}))},w=p=>{g(p),n(y({value:p}))},E=C.useMemo(()=>`${s}_${h}_${Math.random()}`,[s,h]);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),u.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:s,options:v}),(c==null?void 0:c.length)&&u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:T,value:h||"",options:c})]}),u.jsx(zt,{value:m,interceptorManager:e,type:s,operator:h,rule:o,onChange:w},E),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:y({})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-ml-1",onChange:p=>{S(p),n(y({style:p}))}})]})},xt=(r,e)=>(t.iconMap[r]||[])[Number(e)]||"",Yt=r=>{var d;const{error:e,type:n,onChange:i}=r,o=P.useDependency(a.IUniverInstanceService),s=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=(d=o.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),v=C.useRef(null),[c,h]=C.useState(!1);return P.useSidebarClick(m=>{var b;((b=v.current)==null?void 0:b.isClickOutSide(m))&&h(!1)}),u.jsx("div",{className:"univer-relative",children:n!==t.CFValueType.formula?u.jsxs(u.Fragment,{children:[u.jsx(M.InputNumber,{className:M.clsx({"univer-border-red-500":e}),value:Number(r.value)||0,onChange:m=>i(m!=null?m:0)}),e&&u.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):u.jsx("div",{className:"univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:v,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:String(r.value),unitId:s,subUnitId:l,isFocus:c,onChange:(m="")=>{i(m||"")},onFocus:()=>h(!0)})})})},ot=(r,e,n)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(n.length-1-e)*10},iconType:r,iconId:String(e)}),Kt=C.forwardRef((r,e)=>{const{onClick:n}=r,i=P.useDependency(a.LocaleService),o=s=>{n(s)};return u.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((s,l)=>u.jsxs("div",{className:"univer-mb-3",children:[u.jsx("div",{className:"univer-mb-1 univer-text-sm",children:i.t(s.title)}),u.jsx("div",{className:"univer-flex univer-flex-wrap",children:s.group.map(v=>u.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{o(v.name)},children:u.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:v.list.map((c,h)=>u.jsx("img",{className:"univer-size-5",src:c,draggable:!1},h))})},v.name))})]},l))})}),Xt=r=>{const{onClick:e}=r,n=C.useMemo(()=>{const o=[];for(const s in t.iconMap){const l=t.iconMap[s],v=s;l.forEach((c,h)=>{o.push({iconType:v,base64:c,iconId:String(h)})})}return o},[]),i=o=>{e(o.iconType,o.iconId)};return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>i({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[u.jsx(xe,{className:"univer-size-5"}),u.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),u.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:n.map(o=>u.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:u.jsx("img",{className:"univer-size-5",src:o.base64,draggable:!1,onClick:()=>i(o)})},`${o.iconType}_${o.iconId}`))})]})},Jt=r=>{const{onChange:e,configList:n,errorMap:i={}}=r,o=P.useDependency(a.LocaleService),s=[{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],l=[{label:o.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:o.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],v=(m,g)=>{e([String(g),"value","value"],m)},c=(m,g)=>{e([String(g),"operator"],m);const b=t.createDefaultValue(t.CFSubRuleType.number,m);v(b,g)},h=(m,g)=>{e([String(g),"value","type"],m);const b=n[g],S=t.createDefaultValue(t.CFSubRuleType.number,b.operator);v(S,g)};return C.useMemo(()=>n.map((m,g)=>{const b=i[g],S=xt(m.iconType,m.iconId),y=g===n.length-1,_=g===0,T=n[g-1],w=(T==null?void 0:T.value.type)===t.CFValueType.formula?o.t("sheet.cf.valueType.formula"):T==null?void 0:T.value.value,E=(N,p)=>{const x={...m,iconId:p,iconType:N};e([String(g)],x)};return u.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsxs("div",{className:"univer-w-[45%]",children:[o.t("sheet.cf.iconSet.icon"),g+1]}),u.jsx("div",{className:"univer-w-[45%]",children:u.jsxs(u.Fragment,{children:[!_&&!y&&o.t("sheet.cf.iconSet.rule"),!_&&!y&&u.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(T.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]})})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx("div",{className:"univer-flex univer-items-center",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Xt,{onClick:E,iconId:m.iconId,iconType:m.iconType})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",M.borderClassName),children:[S?u.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):u.jsx(xe,{className:"univer-size-4"}),u.jsx(et,{})]})})}),y?u.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.rule"),u.jsxs("span",{className:"univer-font-medium",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(T.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]}):u.jsx(M.Select,{options:s,value:m.operator,onChange:N=>{c(N,g)}})]}),y?u.jsx("div",{}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsx("div",{children:o.t("sheet.cf.iconSet.type")}),u.jsx("div",{children:o.t("sheet.cf.iconSet.value")})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx(M.Select,{options:l,value:m.value.type,onChange:N=>{h(N,g)}}),u.jsx(Yt,{id:g,type:m.value.type,error:b,value:m.value.value||"",onChange:N=>{v(N,g)}})]})]})]},g)}),[n,i])},Qt=r=>{var N;const{interceptorManager:e}=r,n=((N=r.rule)==null?void 0:N.type)===t.CFRuleType.iconSet?r.rule:void 0,i=P.useDependency(a.LocaleService),[o,s]=C.useState({}),[l,v]=C.useState(()=>{const p=Object.keys(t.iconMap)[0];if(n&&n.config.length){const x=n.config[0].iconType;if(!n.config.some(I=>I.iconType!==x))return x}return p}),[c,h]=C.useState(()=>{if(n&&n.config.length)return a.Tools.deepClone(n==null?void 0:n.config);const p=t.iconMap[l]||[];return new Array(p.length).fill("").map((x,R,I)=>R===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:l,iconId:String(R)}:ot(l,R,I))}),[d,m]=C.useState(()=>n?!!n.isShowValue:!0),g=C.useMemo(()=>{const p=c.map(x=>xt(x.iconType,x.iconId));return u.jsx("div",{className:"univer-flex univer-items-center",children:p.map((x,R)=>x?u.jsx("img",{className:"univer-size-5",src:x},R):u.jsx(xe,{className:"univer-size-5"},R))})},[c]),b=p=>{if(p.reduce((R,I,V)=>R.preType&&!R.result||p.length-1===V?R:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:R.preType?{result:R.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(p[0].value.type)){const R={};return p.forEach((I,V,j)=>{if(V-1<0||V===j.length-1)return;const k=p[V-1],f=t.getOppositeOperator(k.operator);t.compareWithNumber({operator:f,value:k.value.value},I.value.value)||(R[V]=`${i.t(`sheet.cf.form.${f}`,String(k.value.value))} `)}),R}return{}},S=(p,x)=>{a.get(c,p)!==x&&(a.set(c,p,x),h([...c]),s(b(c)))},y=p=>{v(p);const x=t.iconMap[p]||[],R=new Array(x.length).fill("").map((I,V,j)=>ot(p,V,j));h(R),s(b(R))};C.useEffect(()=>{const p=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:d,config:c}}});return()=>{p()}},[d,c,e]),C.useEffect(()=>{const p=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(o).length===0}});return()=>{p()}},[d,c,e,o]);const _=()=>{const p=c.map(x=>({...x}));c.forEach((x,R)=>{const I=c.length-1-R,V=p[I];x.iconId=V.iconId,x.iconType=V.iconType}),h([...c])},T=P.useDependency(P.ILayoutService),[w,E]=C.useState();return P.useScrollYOverContainer(w,T.rootContainerElement),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:i.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Kt,{ref:p=>{!w&&p&&E(p)},iconType:l,onClick:y})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",M.borderClassName),children:[g,u.jsx(et,{})]})})}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{onChange:_}),i.t("sheet.cf.iconSet.reverseIconOrder")]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!d,onChange:p=>{m(!p)}}),i.t("sheet.cf.iconSet.onlyShowIcon")]})]}),u.jsx(Jt,{errorMap:o,onChange:S,configList:c})]})},en=r=>{var _;const{onChange:e,interceptorManager:n}=r,i=P.useDependency(a.LocaleService),o=((_=r.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?r.rule:void 0,s=[{label:i.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:i.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:i.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:i.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[l,v]=C.useState(()=>{const T=s[0].value,w=o==null?void 0:o.type;if(!o)return T;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(o.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(o.operator)?"lessThanAverage":T;case t.CFSubRuleType.rank:return o.isBottom?"isBottom":"isNotBottom"}}return T}),[c,h]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return 10;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.rank:return o.value||10}}return 10}),[d,m]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return!1;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.rank:return o.isPercent||!1}}return!1}),[g,b]=C.useState({}),S=T=>{const{type:w,isPercent:E,value:N,style:p}=T;if(w==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:N,style:p};if(w==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:N,style:p};if(w==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:p};if(w==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:p}};C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return S({type:l,isPercent:d,value:c,style:g})}}),[l,d,c,g,n]);const y=T=>{e(S(T))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.styleRule")}),u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",value:l,options:s,onChange:T=>{v(T),y({type:T,isPercent:d,value:c,style:g})}}),["isNotBottom","isBottom"].includes(l)&&u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.InputNumber,{min:1,max:1e3,value:c,onChange:T=>{const w=T||0;h(w),y({type:l,isPercent:d,value:w,style:g})}}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:d,onChange:T=>{m(!!T),y({type:l,isPercent:!!T,value:c,style:g})}}),i.t("sheet.cf.valueType.percent")]})]}),u.jsx("div",{className:Te,children:u.jsx(ce,{rule:S({type:l,isPercent:d,value:c,style:g})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-mt-3",onChange:T=>{b(T),y({type:l,isPercent:d,value:c,style:T})}})]})},tn=a.createInterceptorKey("beforeSubmit"),nn=a.createInterceptorKey("submit"),st=r=>r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),at=r=>{var e;return(e=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},rn=r=>{var R,I,V;const e=P.useDependency(a.LocaleService),n=P.useDependency(a.ICommandService),i=P.useDependency(a.IUniverInstanceService),o=P.useDependency(t.ConditionalFormattingRuleModel),s=P.useDependency(U.SheetsSelectionsService),l=st(i),v=at(i),[c,h]=C.useState(void 0),d=C.useRef((I=(R=r.rule)==null?void 0:R.ranges)!=null?I:[]),m=C.useMemo(()=>{var O,k,f;let j=(O=r.rule)==null?void 0:O.ranges;return j!=null&&j.length||(j=(f=(k=s.getCurrentSelections())==null?void 0:k.map(F=>F.range))!=null?f:[]),d.current=j,j!=null&&j.length?j.map(F=>{const L=We.serializeRange(F);return L==="NaN"?"":L}).filter(F=>!!F).join(","):""},[r.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var k,f;const j=(k=r.rule)==null?void 0:k.rule.type,O=g[0].value;if(!j)return O;switch(j){case t.CFRuleType.highlightCell:{switch((f=r.rule)==null?void 0:f.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return O}),y=C.useRef(void 0),_=C.useMemo(()=>new a.InterceptorManager({beforeSubmit:tn,submit:nn}),[]),T=C.useMemo(()=>{switch(b){case"1":return it;case"2":return en;case"3":return Gt;case"4":return qt;case"5":return Zt;case"6":return Qt;default:return it}},[b]);C.useEffect(()=>{const j=n.onCommandExecuted(O=>{if(O.id===U.RemoveSheetMutation.id){const k=O.params;k.subUnitId===v&&k.unitId===l&&r.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&r.onCancel()});return()=>j.dispose()},[]);const w=j=>{y.current=j},E=j=>{const O=j.split(",").filter(k=>!!k).map(We.deserializeRangeWithSheet).map(k=>k.range);d.current=O},N=()=>{if(c)return;const O=(()=>{const f=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return d.current.map(q=>U.setEndForRange(q,f.getRowCount(),f.getColumnCount())).filter(q=>!(Number.isNaN(q.startRow)||Number.isNaN(q.startColumn)))})();if(_.fetchThroughInterceptors(_.getInterceptPoints().beforeSubmit)(!0,null)){const f=_.fetchThroughInterceptors(_.getInterceptPoints().submit)(null,null);if(f){const F=st(i),L=at(i);if(!F||!L)throw new Error("No active sheet found");let q={};r.rule&&r.rule.cfId?(q={...r.rule,ranges:O,rule:f},n.executeCommand(t.SetCfCommand.id,{unitId:F,subUnitId:L,rule:q}),r.onCancel()):(q={cfId:o.createCfId(F,L),ranges:O,rule:f,stopIfTrue:!1},n.executeCommand(t.AddCfCommand.id,{unitId:F,subUnitId:L,rule:q}),r.onCancel())}}},p=()=>{r.onCancel()},x=(j,O)=>{j?O.length<1?h(e.t("sheet.cf.errorMessage.rangeError")):h(void 0):h(e.t("sheet.cf.errorMessage.rangeError"))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),u.jsxs("div",{className:"univer-mt-4",children:[u.jsx(Se.RangeSelector,{unitId:l,subUnitId:v,initialValue:m,onChange:(j,O)=>E(O),onVerify:x}),c&&u.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:c})]}),u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),u.jsx(M.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:j=>S(j)}),u.jsx(T,{interceptorManager:_,rule:(V=r.rule)==null?void 0:V.rule,onChange:w}),u.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[u.jsx(M.Button,{onClick:p,children:e.t("sheet.cf.panel.cancel")}),u.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:N,children:e.t("sheet.cf.panel.submit")})]})]})};var on=Object.getOwnPropertyDescriptor,sn=(r,e,n,i)=>{for(var o=i>1?void 0:i?on(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},an=(r,e)=>(n,i)=>e(n,i,r);let ue=class extends a.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const n=/\{([^}]+)?\}/g,i=[];let o=n.exec(e);for(;o;)i.push({startIndex:o.index,key:Number(o[1]),endIndex:o.index+o[0].length-1}),o=n.exec(e);return i});this._localeService=e,this._initLocal()}tWithReactNode(e,...n){const i=this._localeService.getLocales(),o=e.split("."),s=i&&this._localeService.resolveKeyPath(i,o);if(typeof s=="string"){const l=[];return this._findReplaceIndex(s).forEach((v,c,h)=>{const d=h[c-1]||{endIndex:-1};if(d.endIndex+1<v.startIndex){const m=s.slice(d.endIndex+1,v.startIndex);m&&l.push(m)}if(n[v.key]&&l.push(n[v.key]),c===h.length-1){const m=s.slice(v.endIndex+1);m&&l.push(m)}}),l}return[]}};ue=sn([an(0,a.Inject(a.LocaleService))],ue);const ln=(r,e)=>{const n=r.rule;switch(n.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(n.subType){case t.CFSubRuleType.average:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`,e.t("sheet.cf.subRuleType.average"))}case t.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case t.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case t.CFSubRuleType.number:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`,...Array.isArray(n.value)?n.value.map(o=>String(o)):[String(n.value||"")])}case t.CFSubRuleType.text:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`,n.value||"")}case t.CFSubRuleType.timePeriod:{const i=n.operator;return e.t(`sheet.cf.preview.describe.${i}`)}case t.CFSubRuleType.rank:return n.isPercent?n.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(n.value)):e.t("sheet.cf.preview.describe.topNPercent",String(n.value)):n.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(n.value)):e.t("sheet.cf.preview.describe.topN",String(n.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let lt=0;const un=r=>{const{onClick:e}=r,n=P.useDependency(t.ConditionalFormattingRuleModel),i=P.useDependency(a.IUniverInstanceService),o=P.useDependency(U.SheetsSelectionsService),s=P.useDependency(a.ICommandService),l=P.useDependency(a.LocaleService),v=P.useDependency(a.Injector),c=P.useDependency(P.ISidebarService),h=P.useDependency(ue),d=P.useObservable(()=>i.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),m=d.getUnitId(),g=d.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[S,y]=C.useState([]),[_,T]=C.useState("2"),[w,E]=C.useState(0),[N,p]=C.useState(-1),[x,R]=C.useState(lt),I=C.useRef(null),V=[{label:l.t("sheet.cf.panel.workSheet"),value:"2"},{label:l.t("sheet.cf.panel.selectedRange"),value:"1"}],j=()=>{const D=n.getSubunitRules(m,b);if(!D||!D.length)return[];if(_==="1"){const A=o.getCurrentLastSelection();if(!A)return[];const B=A.range;return D.filter(G=>G.ranges.some(Z=>a.Rectangle.intersects(Z,B)))}else if(_==="2")return[...D];return[]},[O,k]=C.useState(j);H.useHighlightRange(S),C.useEffect(()=>{const D=s.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{k(j)},[_,w,m,b]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(A=>{const B=[U.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],W=s.onCommandExecuted(G=>{const{id:Z,params:ee}=G,te=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(Z)&&ee.unitId===te&&A.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{k(j)});return()=>{D.unsubscribe()}},[i,_,m,b]),C.useEffect(()=>{const D=n.$ruleChange.subscribe(()=>{E(Math.random())});return()=>D.unsubscribe()},[n]),C.useEffect(()=>{const D=()=>{var G,Z;const W=Math.max(0,((Z=(G=I.current)==null?void 0:G.getBoundingClientRect().width)!=null?Z:0)-8);return lt=W,W},B=new K.Observable(W=>{const G=c.getContainer();if(G){let Z=setTimeout(()=>{W.next(void 0)},150);const ee=()=>{Z&&clearTimeout(Z),Z=null},te=Fe=>{Fe.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{R(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const A=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");s.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:D.cfId})},F=(D,A)=>{p(A.y)},L=(D,A,B)=>{var Fe;p(-1);const W=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(Fe=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Fe.getSheetId();if(!W||!G)throw new Error("No active sheet found");const Z=_t=>{const wt=O.length;return Math.min(wt-1,Math.max(0,_t))},ee=O[Z(A.y)].cfId,te=O[Z(B.y)].cfId;ee!==te&&s.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>A.y?"after":"before"}})},q=()=>{r.onCreate()},X=()=>{_==="2"?s.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:m,subUnitId:b,cfId:A.cfId})).forEach(A=>{s.executeCommand(t.DeleteCfCommand.id,A)})},J=C.useMemo(()=>{const D=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),A.getSheetId(),W)})},[O]),ie=J.map((D,A)=>({i:D.cfId,x:0,w:12,y:A,h:1,isResizable:!1})),oe=C.useMemo(()=>{const D=i.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),A.getSheetId(),W)})},[O]);return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[u.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:h.tWithReactNode("sheet.cf.panel.managerRuleSelect",u.jsx(M.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{T(D)}})).map((D,A)=>u.jsx("span",{children:D},A))}),u.jsxs("div",{className:"univer-flex univer-justify-end",children:[u.jsx(M.Tooltip,{title:l.t("sheet.cf.panel.createRule"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:u.jsx(pt,{})})}),O.length&&oe?u.jsx(M.Tooltip,{title:l.t("sheet.cf.panel.clear"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:u.jsx(Me,{className:"univer-text-red-500"})})}):u.jsx("div",{children:u.jsx(Me,{className:"univer-text-gray-300"})})]})]}),u.jsx("div",{ref:I,children:x>0&&u.jsx(M.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:x,margin:[0,10],onDragStop:L,onDragStart:F,children:J==null?void 0:J.map((D,A)=>u.jsx("div",{children:u.jsxs("div",{className:M.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":N===A}),onMouseMove:()=>{D.ranges!==S&&y(D.ranges)},onMouseLeave:()=>y([]),onClick:()=>{e(D)},children:[u.jsx("div",{className:M.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:B=>B.stopPropagation(),children:u.jsx(Ct,{})}),u.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[u.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:ln(D,l)}),u.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(B=>We.serializeRange(B)).join(",")})]}),u.jsx("div",{children:u.jsx(ce,{rule:D.rule})}),u.jsx("div",{className:M.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":N===A}),onClick:B=>{B.stopPropagation(),f(D),y([])},children:u.jsx(Me,{})})]})},`${D.cfId}`))})})]})},cn=r=>{const[e,n]=C.useState(r.rule),[i,o]=C.useState(!!r.rule),s=()=>{o(!0)},l=()=>{o(!1),n(void 0)},v=c=>{n(c),o(!0)};return u.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:i?u.jsx(rn,{onCancel:l,rule:e}):u.jsx(un,{onClick:v,onCreate:s})})};var dn=Object.getOwnPropertyDescriptor,mn=(r,e,n,i)=>{for(var o=i>1?void 0:i?dn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},de=(r,e)=>(n,i)=>e(n,i,r);const Ee="sheet.conditional.formatting.panel";let fe=class extends a.Disposable{constructor(e,n,i,o,s){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=i,this._sidebarService=o,this._localeService=s,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(l=>{var v;l||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(l=>{l.id===Ee&&(l.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Ee,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ee,rule:e,key:a.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ee,cn))}};fe=mn([de(0,a.IUniverInstanceService),de(1,a.Inject(a.Injector)),de(2,a.Inject(P.ComponentManager)),de(3,a.Inject(P.ISidebarService)),de(4,a.Inject(a.LocaleService))],fe);var z=(r=>(r[r.createRule=1]="createRule",r[r.viewRule=2]="viewRule",r[r.highlightCell=3]="highlightCell",r[r.rank=4]="rank",r[r.formula=5]="formula",r[r.colorScale=6]="colorScale",r[r.dataBar=7]="dataBar",r[r.icon=8]="icon",r[r.clearRangeRules=9]="clearRangeRules",r[r.clearWorkSheetRules=10]="clearWorkSheetRules",r))(z||{});const Re={id:"sheet.operation.open.conditional.formatting.panel",type:a.CommandType.OPERATION,handler:(r,e)=>{var v;const n=r.get(fe),i=r.get(U.SheetsSelectionsService),o=r.get(a.ICommandService),s=((v=i.getCurrentSelections())==null?void 0:v.map(c=>c.range))||[];switch(e.value){case 3:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 4:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};n.openPanel(c);break}case 5:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};n.openPanel(c);break}case 6:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.colorScale,config:[]}};n.openPanel(c);break}case 7:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(c);break}case 8:{const c={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(c);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 9:{o.executeCommand(t.ClearRangeCfCommand.id,{ranges:s});break}case 10:{o.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var vn=Object.getOwnPropertyDescriptor,hn=(r,e,n,i)=>{for(var o=i>1?void 0:i?vn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},me=(r,e)=>(n,i)=>e(n,i,r);exports.ConditionalFormattingClearController=class extends a.Disposable{constructor(e,n,i,o,s){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=i,this._selectionManagerService=o,this._conditionalFormattingRuleModel=s,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var s;const n=[],i=[],o={redos:n,undos:i};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const l=(s=this._selectionManagerService.getCurrentSelections())==null?void 0:s.map(S=>S.range);if(!l)return o;const v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!c)return o;const h=v.getUnitId(),d=c.getSheetId(),m=this._conditionalFormattingRuleModel.getSubunitRules(h,d);if(!m||!m.length)return o;const{redos:g,undos:b}=ut(this._injector,m,l,h,d);n.push(...g),i.push(...b)}return o}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:i})=>{const o=[],s=[],l={redos:o,undos:s};if(!i||!i.length)return l;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!v||!v.length)return l;const{redos:c,undos:h}=ut(this._injector,v,i,e,n);return o.push(...c),s.push(...h),l}}))}};exports.ConditionalFormattingClearController=hn([me(0,a.Inject(a.Injector)),me(1,a.Inject(a.IUniverInstanceService)),me(2,a.Inject(U.SheetInterceptorService)),me(3,a.Inject(U.SheetsSelectionsService)),me(4,a.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ut(r,e,n,i,o){const s=[],l=[];return e.filter(v=>n.some(c=>v.ranges.some(h=>a.Rectangle.getIntersects(h,c)))).forEach(v=>{const h=new U.RangeMergeUtil().add(...v.ranges).subtract(...n).merge();if(h.length){const d={id:t.SetConditionalRuleMutation.id,params:{unitId:i,subUnitId:o,rule:{...v,ranges:h}}},m=t.setConditionalRuleMutationUndoFactory(r,d.params);s.push(d),l.push(...m)}else{const d={id:t.DeleteConditionalRuleMutation.id,params:{unitId:i,subUnitId:o,cfId:v.cfId}},m=t.DeleteConditionalRuleMutationUndoFactory(r,d.params);s.push(d),l.push(...m)}}),{redos:s,undos:l}}var gn=Object.getOwnPropertyDescriptor,pn=(r,e,n,i)=>{for(var o=i>1?void 0:i?gn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},ve=(r,e)=>(n,i)=>e(n,i,r);let Ce=class extends a.Disposable{constructor(e,n,i,o,s){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=i,this._conditionalFormattingViewModel=o,this._univerInstanceService=s,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,i)=>this._collectConditionalRule(e,n,i),onPasteCells:(e,n,i,o)=>{const{copyType:s=H.COPY_TYPE.COPY,pasteType:l}=o,{range:v}=e||{},{range:c}=n;return this._generateConditionalFormattingMutations(c,{copyType:s,pasteType:l,copyRange:v})}}))}_collectConditionalRule(e,n,i){const o=new a.ObjectMatrix,s={};this._copyInfo={matrix:o,info:{unitId:e,subUnitId:n,cfMap:s}};const l=this._injector.invoke(d=>U.rangeToDiscreteRange(i,d,e,n));if(!l)return;const{rows:v,cols:c}=l,h=new Set;v.forEach((d,m)=>{c.forEach((g,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,d,g);S&&(S.forEach(y=>h.add(y.cfId)),o.setValue(m,b,S.map(y=>y.cfId)))})}),h.forEach(d=>{const m=this._conditionalFormattingRuleModel.getRule(e,n,d);m&&(s[d]=m.rule)})}_generateConditionalFormattingMutations(e,n){const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),o=i.getActiveSheet(),s=i.getUnitId();if(!o)return{redos:[],undos:[]};const l=o.getSheetId();if(n.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[c,h],mapFunc:d}=H.virtualizeDiscreteRanges([n.copyRange,e]),m=H.getRepeatRange(c,h,!0),g={};a.Range.foreach(h,(p,x)=>{const{row:R,col:I}=d(p,x),V=this._conditionalFormattingViewModel.getCellCfs(s,l,R,I);V&&V.forEach(j=>{if(!g[j.cfId]){const O=new a.ObjectMatrix;g[j.cfId]=O;const k=this._conditionalFormattingRuleModel.getRule(s,l,j.cfId);k==null||k.ranges.forEach(f=>{a.Range.foreach(f,(F,L)=>{O.setValue(F,L,1)})})}g[j.cfId].realDeleteValue(R,I)})});const{matrix:b,info:S}=this._copyInfo,y=[];let _=this._conditionalFormattingRuleModel.createCfId(s,l);const T={},w=p=>{if(T[p])return T[p];const x=S==null?void 0:S.cfMap[p],R=[...this._conditionalFormattingRuleModel.getSubunitRules(s,l)||[],...y].find(I=>a.Tools.diffValue(I.rule,x));if(R)return T[p]=R,R;{const I={rule:x,cfId:_,ranges:[],stopIfTrue:!1};return T[p]=I,y.push(I),_=`${Number(_)+1}`,I}};m.forEach(p=>{b&&b.forValue((x,R,I)=>{const V=a.Rectangle.getPositionRange({startRow:x,endRow:x,startColumn:R,endColumn:R},p.startRange),{row:j,col:O}=d(V.startRow,V.startColumn);I.forEach(k=>{if(!g[k]){const f=w(k),F=new a.ObjectMatrix;g[k]=F,f.ranges.forEach(L=>{a.Range.foreach(L,(q,X)=>{F.setValue(q,X,1)})})}g[k].setValue(j,O,1)})})});const E=[],N=[];for(const p in g){const x=g[p],R=U.findAllRectangle(U.createTopMatrixFromMatrix(x));if(!R.length){const I={unitId:s,subUnitId:l,cfId:p};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),N.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(y.some(I=>I.cfId===p)){const I=w(p),V={unitId:s,subUnitId:l,rule:{...I,ranges:R}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),N.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(s,l,p);if(!I)continue;const V={unitId:s,subUnitId:l,rule:{...I,ranges:R}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),N.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:N}}};Ce=pn([ve(0,a.Inject(H.ISheetClipboardService)),ve(1,a.Inject(t.ConditionalFormattingRuleModel)),ve(2,a.Inject(a.Injector)),ve(3,a.Inject(t.ConditionalFormattingViewModel)),ve(4,a.Inject(a.IUniverInstanceService))],Ce);var fn=Object.getOwnPropertyDescriptor,Cn=(r,e,n,i)=>{for(var o=i>1?void 0:i?fn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},Ae=(r,e)=>(n,i)=>e(n,i,r);let ye=class extends a.Disposable{constructor(r,e,n){super(),this._localeService=r,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(r=>{if(r.id===t.AddCfCommand.id){const{unitId:e,subUnitId:n,rule:{ranges:i}}=r.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},i,e,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};ye=Cn([Ae(0,a.Inject(a.LocaleService)),Ae(1,a.ICommandService),Ae(2,a.Inject(U.SheetPermissionCheckController))],ye);var yn=Object.getOwnPropertyDescriptor,bn=(r,e,n,i)=>{for(var o=i>1?void 0:i?yn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},je=(r,e)=>(n,i)=>e(n,i,r);let be=class extends a.Disposable{constructor(r,e,n,i){super(),this._conditionalFormattingRuleModel=r,this._univerInstanceService=e,this._injector=n,this._refRangeService=i,this._initRefRange()}_initRefRange(){const r=new Map,e=(i,o,s)=>`${i}_${o}_${s}`,n=(i,o,s)=>{const l=c=>{const h=[...s.ranges],d=h.map(g=>U.handleDefaultRangeChangeWithEffectRefCommands(g,c)).filter(g=>!!g);if(t.isRangesEqual(d,h))return{redos:[],undos:[]};if(d.length){const g={unitId:i,subUnitId:o,rule:{...s,ranges:d}},b=[{id:t.SetConditionalRuleMutation.id,params:g}],S=t.setConditionalRuleMutationUndoFactory(this._injector,g);return{redos:b,undos:S}}else{const g={unitId:i,subUnitId:o,cfId:s.cfId},b=[{id:t.DeleteConditionalRuleMutation.id,params:g}],S=t.DeleteConditionalRuleMutationUndoFactory(this._injector,g);return{redos:b,undos:S}}},v=[];s.ranges.forEach(c=>{const h=this._refRangeService.registerRefRange(c,l);v.push(()=>h.dispose())}),r.set(e(i,o,s.cfId),()=>v.forEach(c=>c()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(i=>{const{unitId:o,subUnitId:s,rule:l}=i,v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!(i.unitId!==v.getUnitId()||i.subUnitId!==(c==null?void 0:c.getSheetId())))switch(i.type){case"add":{n(i.unitId,i.subUnitId,i.rule);break}case"delete":{const h=r.get(e(o,s,l.cfId));h&&h();break}case"set":{const h=r.get(e(o,s,l.cfId));h&&h(),n(i.unitId,i.subUnitId,i.rule)}}})),this.disposeWithMe(a.toDisposable(()=>{r.forEach(i=>{i()}),r.clear()}))}};be=bn([je(0,a.Inject(t.ConditionalFormattingRuleModel)),je(1,a.Inject(a.IUniverInstanceService)),je(2,a.Inject(a.Injector)),je(3,a.Inject(U.RefRangeService))],be);var In=Object.getOwnPropertyDescriptor,Sn=(r,e,n,i)=>{for(var o=i>1?void 0:i?In(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},ae=(r,e)=>(n,i)=>e(n,i,r);let Ie=class extends a.Disposable{constructor(e,n,i,o,s,l){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=i,this._renderManagerService=o,this._conditionalFormattingViewModel=s,this._conditionalFormattingRuleModel=l,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,i,o;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(H.SheetSkeletonManagerService).reCalculate(),(o=(i=this._renderManagerService.getRenderById(e))==null?void 0:i.mainComponent)==null||o.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(pe.bufferTime(16),pe.filter(e=>!!e.length),pe.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const i=n.getActiveSheet();return i?e.filter(o=>o.unitId===n.getUnitId()&&o.subUnitId===i.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,n,i)=>{const o=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!o)return i(e);const s=n.workbook.getStyles(),l=(typeof(e==null?void 0:e.s)=="string"?s.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},v=e===n.rawData?{...n.rawData}:e;if(o.style){const c={...l,...o.style};Object.assign(v,{s:c})}return v.fontRenderExtension||(v.fontRenderExtension={},o.isShowValue!==void 0&&(v.fontRenderExtension.isSkip=!o.isShowValue)),o.dataBar&&(v.dataBar=o.dataBar),o.iconSet&&(v.iconSet=o.iconSet,v.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),i(v)},priority:10}))}};Ie=Sn([ae(0,a.Inject(U.SheetInterceptorService)),ae(1,a.Inject(t.ConditionalFormattingService)),ae(2,a.Inject(a.IUniverInstanceService)),ae(3,a.Inject(vt.IRenderManagerService)),ae(4,a.Inject(t.ConditionalFormattingViewModel)),ae(5,a.Inject(t.ConditionalFormattingRuleModel))],Ie);const Tt="sheets-conditional-formatting-ui.config",Ve={};var xn=Object.defineProperty,Tn=Object.getOwnPropertyDescriptor,Rn=(r,e,n)=>e in r?xn(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Fn=(r,e,n,i)=>{for(var o=i>1?void 0:i?Tn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},$e=(r,e)=>(n,i)=>e(n,i,r),Rt=(r,e,n)=>Rn(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends a.Plugin{constructor(e=Ve,n,i,o){super(),this._config=e,this._injector=n,this._commandService=i,this._configService=o;const{menu:s,...l}=a.merge({},Ve,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Tt,l),this._initCommand(),this._injector.add([Ie]),this._injector.add([be]),this._injector.add([Ce]),this._injector.add([ye]),this._injector.add([ue])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};Rt(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);Rt(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=Fn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),$e(1,a.Inject(a.Injector)),$e(2,a.Inject(a.ICommandService)),$e(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var _n=Object.getOwnPropertyDescriptor,wn=(r,e,n,i)=>{for(var o=i>1?void 0:i?_n(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},he=(r,e)=>(n,i)=>e(n,i,r);let Oe=class extends a.Disposable{constructor(r,e,n,i,o){super(),this._injector=r,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=o,this._initAutoFill()}_initAutoFill(){const r=()=>({redos:[],undos:[]}),e=(o,s,l,v,c)=>{var b;const h=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(b=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!h||!d)return;const m={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},g={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};a.Range.foreach(l,(S,y)=>{const _=a.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},m),T=a.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},g),{row:w,col:E}=c(_.startRow,_.startColumn),N=this._conditionalFormattingViewModel.getCellCfs(h,d,w,E),{row:p,col:x}=c(T.startRow,T.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(h,d,p,x);R&&R.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(h,d,I.cfId);if(!j)return;V=new a.ObjectMatrix,j.ranges.forEach(O=>{a.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),v.set(I.cfId,V)}V.realDeleteValue(p,x)}),N&&N.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(h,d,I.cfId);if(!j)return;V=new a.ObjectMatrix,j.ranges.forEach(O=>{a.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),v.set(I.cfId,V)}V.setValue(p,x,1)})})},n=(o,s)=>{var T,w,E;const l=(T=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:T.getUnitId(),v=(E=(w=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getActiveSheet())==null?void 0:E.getSheetId(),c=new Map,h=[],d=[];if(!l||!v)return r();const m=H.virtualizeDiscreteRanges([o,s]),[g,b]=m.ranges,{mapFunc:S}=m,y={row:g.startRow,col:g.startColumn};return H.getAutoFillRepeatRange(g,b).forEach(N=>{e(y,N.repeatStartCell,N.relativeRange,c,S)}),c.forEach((N,p)=>{const x=this._conditionalFormattingRuleModel.getRule(l,v,p);if(!x)return;const R=U.findAllRectangle(U.createTopMatrixFromMatrix(N));if(R.length){const I={unitId:l,subUnitId:v,rule:{...x,ranges:R}};h.push({id:t.SetConditionalRuleMutation.id,params:I}),d.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:l,subUnitId:v,cfId:x.cfId};h.push({id:t.DeleteConditionalRuleMutation.id,params:I}),d.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:h}},i={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(o,s,l)=>{if(l===H.APPLY_TYPE.COPY||l===H.APPLY_TYPE.ONLY_FORMAT||l===H.APPLY_TYPE.SERIES){const{source:v,target:c}=o;return n(v,c)}return r()}};this.disposeWithMe(this._autoFillService.addHook(i))}};Oe=wn([he(0,a.Inject(a.Injector)),he(1,a.Inject(a.IUniverInstanceService)),he(2,a.Inject(H.IAutoFillService)),he(3,a.Inject(t.ConditionalFormattingRuleModel)),he(4,a.Inject(t.ConditionalFormattingViewModel))],Oe);var Nn=Object.getOwnPropertyDescriptor,En=(r,e,n,i)=>{for(var o=i>1?void 0:i?Nn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},ct=(r,e)=>(n,i)=>e(n,i,r);let Ue=class extends a.Disposable{constructor(r,e){super(),this._sheetInterceptorService=r,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(r,e,n)=>{var l,v,c;r||n(r);const i=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),o=(l=i==null?void 0:i.style)!=null?l:{},s=Object.keys(o);if(r!=null&&r.p)return(c=(v=r.p.body)==null?void 0:v.textRuns)==null||c.forEach(h=>{h.ts&&s.forEach(d=>{var m;(m=h.ts)==null||delete m[d]})}),n(r);{const h={...(typeof(r==null?void 0:r.s)=="string"?e.workbook.getStyles().get(r.s):r==null?void 0:r.s)||{}};s.forEach(m=>{delete h[m]});const d={...r,s:{...h}};return n(d)}}})))}};Ue=En([ct(0,a.Inject(U.SheetInterceptorService)),ct(1,a.Inject(t.ConditionalFormattingService))],Ue);const dt=[U.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],ge=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:z.clearWorkSheetRules}],jn=r=>{const e=r.get(U.SheetsSelectionsService),n=r.get(a.ICommandService),i=r.get(a.IUniverInstanceService),o=r.get(t.ConditionalFormattingRuleModel),s=new K.Observable(c=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(h=>{const d=n.onCommandExecuted(m=>{var y;const{id:g,params:b}=m,S=(y=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&h.next(null)});return()=>d.dispose()})).pipe(pe.debounceTime(16)).subscribe(()=>{var y;const h=((y=e.getCurrentSelections())==null?void 0:y.map(_=>_.range))||[],d=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d)return;const m=d.getActiveSheet();if(!m)return;const S=(o.getSubunitRules(d.getUnitId(),m.getSheetId())||[]).filter(_=>_.ranges.some(T=>h.some(w=>a.Rectangle.intersects(w,T)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(r,d.getUnitId(),m.getSheetId(),_));c.next(S)})),l=new K.Observable(c=>new K.Observable(h=>{const d=n.onCommandExecuted(m=>{var y;const{id:g,params:b}=m,S=(y=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&h.next(null)});return()=>d.dispose()}).pipe(pe.debounceTime(16)).subscribe(()=>{const h=i.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!h)return;const d=h.getActiveSheet();if(!d)return;const m=o.getSubunitRules(h.getUnitId(),d.getSheetId())||[];if(!m.length)return c.next(!1),!1;const g=m.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(r,h.getUnitId(),d.getSheetId(),b));c.next(g)})),v=new K.Observable(c=>{s.subscribe(h=>{const d=ge.find(m=>m.value===z.clearRangeRules);d&&(d.disabled=!h,c.next(ge))}),l.subscribe(h=>{const d=ge.find(m=>m.value===z.clearWorkSheetRules);d&&(d.disabled=!h,c.next(ge))}),c.next(ge)});return{id:Re.id,type:P.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:v,hidden$:P.getMenuHiddenObservable(r,a.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(r,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Mn={[P.RibbonDataGroup.RULES]:{[Re.id]:{order:1,menuItemFactory:jn}}};var Vn=Object.getOwnPropertyDescriptor,On=(r,e,n,i)=>{for(var o=i>1?void 0:i?Vn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},mt=(r,e)=>(n,i)=>e(n,i,r);let ke=class extends a.Disposable{constructor(e,n){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(Mn)}};ke=On([mt(0,a.Inject(a.Injector)),mt(1,P.IMenuManagerService)],ke);var Un=Object.getOwnPropertyDescriptor,kn=(r,e,n,i)=>{for(var o=i>1?void 0:i?Un(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},le=(r,e)=>(n,i)=>e(n,i,r);const Pn=(r,e)=>{const n=d=>d.endRow-d.startRow+1,i=d=>d.endColumn-d.startColumn+1,o=n(e)%n(r),s=i(e)%i(r),l=Math.floor(n(e)/n(r)),v=Math.floor(i(e)/i(r)),c=[],h={startRow:0,endRow:n(r)-1,startColumn:0,endColumn:i(r)-1};if(n(e)===1&&i(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return c.push({repeatRelativeRange:h,startRange:d}),c}for(let d=0;d<l+(o?.1:0);d++)for(let m=0;m<v+(s?.1:0);m++){const g=n(r)*d,b=i(r)*m,S={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let y=h;d===l&&o&&(y={...y},y.endRow=y.endRow-(n(r)-o)),m===v&&s&&(y={...y},y.endColumn=y.endColumn-(i(r)-s)),c.push({repeatRelativeRange:y,startRange:S})}return c};let Pe=class extends a.Disposable{constructor(e,n,i,o,s,l){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=i,this._sheetsSelectionsService=o,this._conditionalFormattingRuleModel=s,this._conditionalFormattingViewModel=l,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(s,l,v,c,h)=>{const{unitId:d,subUnitId:m}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=h,S={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},y={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row};a.Range.foreach(v,(_,T)=>{const w=a.Rectangle.getPositionRange({startRow:_,startColumn:T,endColumn:T,endRow:_},S),E=a.Rectangle.getPositionRange({startRow:_,startColumn:T,endColumn:T,endRow:_},y),N=this._conditionalFormattingViewModel.getCellCfs(d,m,w.startRow,w.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(g,b,E.startRow,E.startColumn);p&&p.forEach(x=>{let R=c.get(x.cfId);if(!c.get(x.cfId)){const I=this._conditionalFormattingRuleModel.getRule(g,b,x.cfId);if(!I)return;R=new a.ObjectMatrix,I.ranges.forEach(V=>{a.Range.foreach(V,(j,O)=>{R.setValue(j,O,1)})}),c.set(x.cfId,R)}R.realDeleteValue(E.startRow,E.startColumn)}),N&&N.forEach(x=>{const R=c.get(x.cfId);R&&R.setValue(E.startRow,E.startColumn,1)})})},i=(s,l,v)=>{var w;const{range:c,unitId:h,subUnitId:d}=this._painterConfig,m=s!==h||d!==l,g=new Map,b=[],S=[];if(!s||!l||!h||!d)return e();const y=(w=this._conditionalFormattingRuleModel.getSubunitRules(h,d))!=null?w:[];y==null||y.forEach(E=>{const{ranges:N,cfId:p}=E;if(N.some(x=>a.Rectangle.intersects(c,x))){const x=new a.ObjectMatrix;m||N.forEach(R=>{a.Range.foreach(R,(I,V)=>{x.setValue(I,V,1)})}),g.set(p,x)}});const _={row:c.startRow,col:c.startColumn};return Pn(c,v).forEach(E=>{n(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,g,{targetUnitId:s,targetSubUnitId:l})}),g.forEach((E,N)=>{if(m){const p=this._conditionalFormattingRuleModel.getRule(s,l,N),x=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(p)if(x.length){const R={unitId:s,subUnitId:l,rule:{...p,ranges:x}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:s,subUnitId:l,cfId:p.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}else if(x.length){const R=this._conditionalFormattingRuleModel.getRule(h,d,N);if(R){const I={unitId:s,subUnitId:l,rule:{...a.Tools.deepClone(R),cfId:this._conditionalFormattingRuleModel.createCfId(s,l),ranges:x}};b.push({id:t.AddConditionalRuleMutation.id,params:I}),S.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const p=this._conditionalFormattingRuleModel.getRule(h,d,N);if(!p)return;const x=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(x.length){const R={unitId:h,subUnitId:d,rule:{...p,ranges:x}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:h,subUnitId:d,cfId:p.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}}}),{undos:S,redos:b}},o={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:s=>{var l,v,c;switch(s){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const h=(l=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:l.getUnitId(),d=(c=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:c.getSheetId(),m=this._sheetsSelectionsService.getCurrentLastSelection(),g=m==null?void 0:m.range;h&&d&&g&&(this._painterConfig={unitId:h,subUnitId:d,range:g});break}case H.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(s,l,v)=>this._painterConfig?i(s,l,v):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};Pe=kn([le(0,a.Inject(a.Injector)),le(1,a.Inject(a.IUniverInstanceService)),le(2,a.Inject(H.IFormatPainterService)),le(3,a.Inject(U.SheetsSelectionsService)),le(4,a.Inject(t.ConditionalFormattingRuleModel)),le(5,a.Inject(t.ConditionalFormattingViewModel))],Pe);var Dn=Object.getOwnPropertyDescriptor,Ln=(r,e,n,i)=>{for(var o=i>1?void 0:i?Dn(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},Be=(r,e)=>(n,i)=>e(n,i,r);let De=class extends a.Disposable{constructor(r,e,n){super(),this._conditionalFormattingViewModel=r,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),e=n=>{const i=n.getUnitId(),o=this._renderManagerService.getRenderById(i);if(!o)return;const s=o.with(H.SheetSkeletonManagerService);this.disposeWithMe(s.currentSkeleton$.subscribe(l=>{if(l){const v=l.skeleton.rowColumnSegment,c=v.endColumn-v.startColumn+1,d=(v.endRow-v.startRow+1)*c*9,m=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(m)}}))};r&&e(r),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};De=Ln([Be(0,a.Inject(t.ConditionalFormattingViewModel)),Be(1,a.IUniverInstanceService),Be(2,vt.IRenderManagerService)],De);var An=Object.defineProperty,$n=Object.getOwnPropertyDescriptor,Bn=(r,e,n)=>e in r?An(r,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):r[e]=n,Hn=(r,e,n,i)=>{for(var o=i>1?void 0:i?$n(e,n):e,s=r.length-1,l;s>=0;s--)(l=r[s])&&(o=l(o)||o);return o},He=(r,e)=>(n,i)=>e(n,i,r),Ft=(r,e,n)=>Bn(r,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends a.Plugin{constructor(e=Ve,n,i,o){super(),this._config=e,this._injector=n,this._commandService=i,this._configService=o;const{menu:s,...l}=a.merge({},Ve,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Tt,l),this._initCommand()}onStarting(){a.registerDependencies(this._injector,[[Ie],[be],[Ce],[Oe],[ye],[fe],[ke],[ue],[Ue],[exports.ConditionalFormattingClearController],[Pe],[De]]),a.touchDependencies(this._injector,[[Ie]])}onReady(){a.touchDependencies(this._injector,[[ke],[fe]])}onRendered(){a.touchDependencies(this._injector,[[Oe],[exports.ConditionalFormattingClearController],[Ce],[Ue],[ue],[Pe],[ye],[be],[De]])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};Ft(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);Ft(exports.UniverSheetsConditionalFormattingUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Hn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),He(1,a.Inject(a.Injector)),He(2,a.Inject(a.ICommandService)),He(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=qe;exports.AddColorScaleConditionalRuleCommand=Ge;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=ze;exports.AddNumberCfCommand=Ye;exports.AddRankCfCommand=Ke;exports.AddTextCfCommand=Xe;exports.AddTimePeriodCfCommand=Je;exports.AddUniqueValuesCfCommand=Qe;exports.OpenConditionalFormattingOperator=Re;
package/lib/es/index.js CHANGED
@@ -10,7 +10,7 @@ import { useRef as ve, createElement as ce, forwardRef as ue, useMemo as J, useS
10
10
  import { Dropdown as qt, clsx as Y, ColorPicker as Yr, borderClassName as Fe, Select as ae, InputNumber as Ve, RadioGroup as Kr, Radio as Yt, Checkbox as Ct, Input as Xr, Button as Kt, Tooltip as Xt, ReactGridLayout as Jr } from "@univerjs/design";
11
11
  import { serializeRange as kn, deserializeRangeWithSheet as Qr } from "@univerjs/engine-formula";
12
12
  import { FormulaEditor as Nt, RangeSelector as ei } from "@univerjs/sheets-formula-ui";
13
- import { useHighlightRange as ti, ISheetClipboardService as ni, COPY_TYPE as Jt, PREDEFINED_HOOK_NAME as kt, virtualizeDiscreteRanges as Fn, getRepeatRange as ri, SheetSkeletonManagerService as Ln, IAutoFillService as ii, APPLY_TYPE as Ft, getAutoFillRepeatRange as oi, getCurrentRangeDisable$ as si, IFormatPainterService as ai, FormatPainterStatus as Lt } from "@univerjs/sheets-ui";
13
+ import { useHighlightRange as ti, ISheetClipboardService as ni, COPY_TYPE as Jt, PREDEFINED_HOOK_NAME_PASTE as kt, virtualizeDiscreteRanges as Fn, getRepeatRange as ri, SheetSkeletonManagerService as Ln, IAutoFillService as ii, APPLY_TYPE as Ft, getAutoFillRepeatRange as oi, getCurrentRangeDisable$ as si, IFormatPainterService as ai, FormatPainterStatus as Lt } from "@univerjs/sheets-ui";
14
14
  import { Observable as Ee, debounceTime as Qt, merge as Un } from "rxjs";
15
15
  import { IRenderManagerService as Pn } from "@univerjs/engine-render";
16
16
  import { bufferTime as li, filter as en, debounceTime as tn } from "rxjs/operators";
package/lib/index.js CHANGED
@@ -10,7 +10,7 @@ import { useRef as ve, createElement as ce, forwardRef as ue, useMemo as J, useS
10
10
  import { Dropdown as qt, clsx as Y, ColorPicker as Yr, borderClassName as Fe, Select as ae, InputNumber as Ve, RadioGroup as Kr, Radio as Yt, Checkbox as Ct, Input as Xr, Button as Kt, Tooltip as Xt, ReactGridLayout as Jr } from "@univerjs/design";
11
11
  import { serializeRange as kn, deserializeRangeWithSheet as Qr } from "@univerjs/engine-formula";
12
12
  import { FormulaEditor as Nt, RangeSelector as ei } from "@univerjs/sheets-formula-ui";
13
- import { useHighlightRange as ti, ISheetClipboardService as ni, COPY_TYPE as Jt, PREDEFINED_HOOK_NAME as kt, virtualizeDiscreteRanges as Fn, getRepeatRange as ri, SheetSkeletonManagerService as Ln, IAutoFillService as ii, APPLY_TYPE as Ft, getAutoFillRepeatRange as oi, getCurrentRangeDisable$ as si, IFormatPainterService as ai, FormatPainterStatus as Lt } from "@univerjs/sheets-ui";
13
+ import { useHighlightRange as ti, ISheetClipboardService as ni, COPY_TYPE as Jt, PREDEFINED_HOOK_NAME_PASTE as kt, virtualizeDiscreteRanges as Fn, getRepeatRange as ri, SheetSkeletonManagerService as Ln, IAutoFillService as ii, APPLY_TYPE as Ft, getAutoFillRepeatRange as oi, getCurrentRangeDisable$ as si, IFormatPainterService as ai, FormatPainterStatus as Lt } from "@univerjs/sheets-ui";
14
14
  import { Observable as Ee, debounceTime as Qt, merge as Un } from "rxjs";
15
15
  import { IRenderManagerService as Pn } from "@univerjs/engine-render";
16
16
  import { bufferTime as li, filter as en, debounceTime as tn } from "rxjs/operators";
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(P,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-conditional-formatting","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],s):(P=typeof globalThis<"u"?globalThis:P||self,s(P.UniverSheetsConditionalFormattingUi={},P.UniverCore,P.UniverSheets,P.UniverSheetsConditionalFormatting,P.UniverUi,P.React,P.React,P.UniverDesign,P.UniverEngineFormula,P.UniverSheetsFormulaUi,P.UniverSheetsUi,P.rxjs,P.UniverEngineRender,P.rxjs.operators))})(this,(function(P,s,U,r,j,c,C,O,$e,ve,W,X,nr,pe){"use strict";var Bt=Object.defineProperty;var Ht=(P,s,U)=>s in P?Bt(P,s,{enumerable:!0,configurable:!0,writable:!0,value:U}):P[s]=U;var ee=(P,s,U)=>Ht(P,typeof s!="symbol"?s+"":s,U);const Fe={type:s.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u}=e,i=n.get(r.ConditionalFormattingRuleModel),p=n.get(s.ICommandService),o=n.get(s.IUniverInstanceService),f=U.getSheetCommandTarget(o);if(!f)return!1;const{unitId:d,subUnitId:v}=f,h=i.createCfId(d,v),b={ranges:t,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:l}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:b})}},Be={type:s.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,config:l,stopIfTrue:a}=e,u=n.get(r.ConditionalFormattingRuleModel),i=n.get(s.ICommandService),p=n.get(s.IUniverInstanceService),o=U.getSheetCommandTarget(p);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=u.createCfId(f,d),h={ranges:t,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.colorScale,config:l}};return i.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:h})}},He={type:s.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,min:l,max:a,nativeColor:u,positiveColor:i,isGradient:p,stopIfTrue:o,isShowValue:f}=e,d=n.get(r.ConditionalFormattingRuleModel),v=n.get(s.IUniverInstanceService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:b,subUnitId:S}=h,m=n.get(s.ICommandService),N=d.createCfId(b,S),_={ranges:t,cfId:N,stopIfTrue:!!o,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:l,max:a,nativeColor:u,positiveColor:i,isGradient:p}}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:_})}},We={type:s.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a}=e,u=n.get(r.ConditionalFormattingRuleModel),i=n.get(s.ICommandService),p=n.get(s.IUniverInstanceService),o=U.getSheetCommandTarget(p);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=u.createCfId(f,d),h={ranges:t,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:l}};return i.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:h})}},qe={type:s.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u,value:i}=e,p=n.get(r.ConditionalFormattingRuleModel),o=n.get(s.ICommandService),f=n.get(s.IUniverInstanceService),d=U.getSheetCommandTarget(f);if(!d)return!1;const{unitId:v,subUnitId:h}=d,b=p.createCfId(v,h);let S;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const m=i;if(m.length!==2||!Array.isArray(m))return!1;S={ranges:t,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:l,value:m}}}else{const m=i;if(typeof m!="number")return!1;S={ranges:t,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:l,value:m}}}return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:h,rule:S})}},Ge={type:s.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,isPercent:u,isBottom:i,value:p}=e,o=n.get(r.ConditionalFormattingRuleModel),f=n.get(s.IUniverInstanceService),d=n.get(s.ICommandService),v=U.getSheetCommandTarget(f);if(!v)return!1;const{unitId:h,subUnitId:b}=v,S=o.createCfId(h,b),m={ranges:t,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:i,style:l,value:p}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:b,rule:m})}},Ze={type:s.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u,value:i}=e,p=n.get(r.ConditionalFormattingRuleModel),o=n.get(s.IUniverInstanceService),f=U.getSheetCommandTarget(o);if(!f)return!1;const{unitId:d,subUnitId:v}=f,h=n.get(s.ICommandService),b=p.createCfId(d,v),S={ranges:t,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:l,value:i}};return h.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:S})}},ze={type:s.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u}=e,i=n.get(r.ConditionalFormattingRuleModel),p=n.get(s.IUniverInstanceService),o=n.get(s.ICommandService),f=U.getSheetCommandTarget(p);if(!f)return!1;const{unitId:d,subUnitId:v}=f,h=i.createCfId(d,v),b={ranges:t,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:l}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:b})}},Ye={type:s.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a}=e,u=n.get(r.ConditionalFormattingRuleModel),i=n.get(s.IUniverInstanceService),p=n.get(s.ICommandService),o=U.getSheetCommandTarget(i);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=u.createCfId(f,d),h={ranges:t,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:l}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:h})}};function K({ref:n,...e}){const{icon:t,id:l,className:a,extend:u,...i}=e,p=`univerjs-icon univerjs-icon-${l} ${a||""}`.trim(),o=C.useRef(`_${Mr()}`);return lr(t,`${l}`,{defIds:t.defIds,idSuffix:o.current},{ref:n,className:p,...i},u)}function lr(n,e,t,l,a){return C.createElement(n.tag,{key:e,...Er(n,t,a),...l},(Rr(n,t).children||[]).map((u,i)=>lr(u,`${e}-${n.tag}-${i}`,t,void 0,a)))}function Er(n,e,t){const l={...n.attrs};t!=null&&t.colorChannel1&&l.fill==="colorChannel1"&&(l.fill=t.colorChannel1),n.tag==="mask"&&l.id&&(l.id=l.id+e.idSuffix),Object.entries(l).forEach(([u,i])=>{u==="mask"&&typeof i=="string"&&(l[u]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:a}=e;return!a||a.length===0||(n.tag==="use"&&l["xlink:href"]&&(l["xlink:href"]=l["xlink:href"]+e.idSuffix),Object.entries(l).forEach(([u,i])=>{typeof i=="string"&&(l[u]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),l}function Rr(n,e){var l;const{defIds:t}=e;return!t||t.length===0?n:n.tag==="defs"&&((l=n.children)!=null&&l.length)?{...n,children:n.children.map(a=>typeof a.attrs.id=="string"&&t&&t.includes(a.attrs.id)?{...a,attrs:{...a.attrs,id:a.attrs.id+e.idSuffix}}:a)}:n}function Mr(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";const Vr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ar=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"bold-icon",ref:t,icon:Vr}))});ar.displayName="BoldIcon";const Or={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ne=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"delete-icon",ref:t,icon:Or}))});Ne.displayName="DeleteIcon";const Ur={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},ur=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"increase-icon",ref:t,icon:Ur}))});ur.displayName="IncreaseIcon";const kr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},sr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"italic-icon",ref:t,icon:kr}))});sr.displayName="ItalicIcon";const Dr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ke=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Dr}))});Ke.displayName="MoreDownIcon";const Pr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},ir=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Pr}))});ir.displayName="SequenceIcon";const Lr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},cr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"strikethrough-icon",ref:t,icon:Lr}))});cr.displayName="StrikethroughIcon";const jr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},or=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"underline-icon",ref:t,icon:jr}))});or.displayName="UnderlineIcon";const Ar={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"font-color-double-icon",ref:t,icon:Ar}))});dr.displayName="FontColorDoubleIcon";const $r={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},vr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"paint-bucket-double-icon",ref:t,icon:$r}))});vr.displayName="PaintBucketDoubleIcon";const Fr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fe=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"slash-double-icon",ref:t,icon:Fr}))});fe.displayName="SlashDoubleIcon";const re=n=>{const{color:e,onChange:t,disable:l=!1,Icon:a=vr,className:u}=n,i=C.useMemo(()=>new s.ColorKit(e),[e]),p=()=>{const o={className:O.clsx("univer-fill-primary-600",l&&u),extend:{colorChannel1:i.isValid?e:""}};return c.jsx(a,{...o})};return l?p():c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(O.ColorPicker,{value:e,onChange:t})}),children:c.jsx("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",u),children:p()})})},ae=n=>{var u,i,p,o,f;const e=n.rule;if(!e)return null;const t=C.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const d=e.config.map((b,S)=>({color:new s.ColorKit(b.color),value:S})),v=d.length-1;return new Array(5).fill("").map((b,S,m)=>S*v/(m.length-1)).map(b=>r.getColorScaleFromValue(d,b))}return null},[e]),l=C.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(d=>{const v=r.iconMap[d.iconType];return v&&v[Number(d.iconId)]})},[e]),a="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:d}=e.config,v=d?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,h=d?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return c.jsxs("div",{className:a,children:[c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:h,borderColor:(u=e.config.nativeColor)!=null?u:r.defaultDataBarNativeColor}}),c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:v,borderColor:(i=e.config.positiveColor)!=null?i:r.defaultDataBarPositiveColor}})]})}case r.CFRuleType.colorScale:return t&&c.jsx("div",{className:a,children:t.map((d,v)=>c.jsx("div",{className:"univer-h-full",style:{width:`${100/t.length}%`,background:d}},v))});case r.CFRuleType.iconSet:return l&&c.jsx("div",{className:a,children:l.map((d,v)=>d?c.jsx("img",{className:"univer-h-full",src:d,draggable:!1},v):c.jsx(fe,{},v))});case r.CFRuleType.highlightCell:{const{ul:d,st:v,it:h,bl:b,bg:S,cl:m}=e.style,N=(d==null?void 0:d.s)===s.BooleanNumber.TRUE,_=(v==null?void 0:v.s)===s.BooleanNumber.TRUE,E=h===s.BooleanNumber.TRUE,M=b===s.BooleanNumber.TRUE,R=(p=S==null?void 0:S.rgb)!=null?p:r.DEFAULT_BG_COLOR,g=(o=m==null?void 0:m.rgb)!=null?o:r.DEFAULT_FONT_COLOR,T={textDecoration:(f=`${N?"underline":""} ${_?"line-through":""}`.replace(/^ /,""))!=null?f:void 0,backgroundColor:R,color:g};return c.jsx("div",{className:O.clsx(a,{"univer-font-bold":M,"univer-italic":E}),style:T,children:"123"})}}},he=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),Xe=n=>{var S;const{type:e,className:t,onChange:l,id:a,value:u}=n,i=j.useDependency(s.IUniverInstanceService),p=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(S=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),f=C.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),d=C.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),v=C.useRef(null),[h,b]=C.useState(!1);return j.useSidebarClick(m=>{var _;((_=v.current)==null?void 0:_.isClickOutSide(m))&&b(!1)}),e===r.CFValueType.formula?c.jsx("div",{className:"univer-ml-1 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:f,unitId:p,subUnitId:o,isFocus:h,onChange:(m="")=>{l(m||"")},onFocus:()=>b(!0)})}):c.jsx(O.InputNumber,{className:t,value:Number(n.value)||0,onChange:m=>n.onChange(m||0),...d})},Br=n=>{var L;const{interceptorManager:e}=n,t=j.useDependency(s.LocaleService),l=((L=n.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?n.rule:void 0,a=[te(r.CFValueType.num,t),te(r.CFValueType.percent,t),te(r.CFValueType.percentile,t),te(r.CFValueType.formula,t)],u=[te(r.CFValueType.min,t),...a],i=[te("none",t),...a],p=[te(r.CFValueType.max,t),...a],[o,f]=C.useState(()=>{var x;const y=r.CFValueType.min;return l&&((x=l.config[0])==null?void 0:x.value.type)||y}),[d,v]=C.useState(()=>{var x;const y="none";return!l||l.config.length!==3?y:((x=l.config[1])==null?void 0:x.value.type)||y}),[h,b]=C.useState(()=>{var x;const y=r.CFValueType.max;return l&&((x=l.config[l.config.length-1])==null?void 0:x.value.type)||y}),[S,m]=C.useState(()=>{if(!l)return 10;const x=l.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[N,_]=C.useState(()=>{var $;if(!l||l.config.length!==3)return 50;const x=($=l.config[1])==null?void 0:$.value.value;return x===void 0?50:x}),[E,M]=C.useState(()=>{var $;if(!l)return 90;const x=($=l.config[l.config.length-1])==null?void 0:$.value.value;return x===void 0?90:x}),[R,g]=C.useState(()=>{var x;const y="#d0d9fb";return l&&((x=l.config[0])==null?void 0:x.color)||y}),[T,w]=C.useState(()=>{var x;const y="#7790f3";return!l||l.config.length!==3?y:((x=l.config[1])==null?void 0:x.color)||y}),[I,k]=C.useState(()=>{var x;const y="#2e55ef";return l&&((x=l.config[l.config.length-1])==null?void 0:x.color)||y}),V=C.useMemo(()=>y=>{const{minType:x,medianType:$,maxType:G,minValue:J,medianValue:Q,maxValue:oe,minColor:de,medianColor:A,maxColor:F}=y,H=[];return H.push({color:de,value:{type:x,value:J}}),$!=="none"&&H.push({color:A,value:{type:$,value:Q}}),H.push({color:F,value:{type:G,value:oe}}),{config:H.map((Z,z)=>({...Z,index:z})),type:r.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),[V,o,d,h,S,N,E,R,T,I,e]);const D=y=>{n.onChange(V(y))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:V({minType:o,medianType:d,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})})}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:o,onChange:y=>{f(y);const x=r.createDefaultValueByValueType(y,10);m(x),D({minType:y,medianType:d,maxType:h,minValue:x,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Xe,{id:"min",className:"univer-ml-1",value:S,type:o,onChange:y=>{m(y),D({minType:o,medianType:d,maxType:h,minValue:y,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(re,{className:"univer-ml-1",color:R,onChange:y=>{g(y),D({minType:o,medianType:d,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:y,medianColor:T,maxColor:I})}})]}),c.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:t.t("sheet.cf.panel.medianValue")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:i,value:d,onChange:y=>{v(y);const x=r.createDefaultValueByValueType(y,50);_(x),D({minType:o,medianType:y,maxType:h,minValue:S,medianValue:x,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Xe,{id:"median",className:"univer-ml-1",value:N,type:d,onChange:y=>{_(y),D({minType:o,medianType:d,maxType:h,minValue:S,medianValue:y,maxValue:E,minColor:R,medianColor:T,maxColor:I})}}),d!=="none"&&c.jsx(re,{className:"univer-ml-1",color:T,onChange:y=>{w(y),D({minType:o,medianType:d,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:y,maxColor:I})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:p,value:h,onChange:y=>{b(y);const x=r.createDefaultValueByValueType(y,90);M(x),D({minType:o,medianType:d,maxType:y,minValue:S,medianValue:N,maxValue:x,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Xe,{id:"max",className:"univer-ml-1",value:E,type:h,onChange:y=>{M(y),D({minType:o,medianType:d,maxType:h,minValue:S,medianValue:N,maxValue:y,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(re,{className:"univer-ml-1",color:I,onChange:y=>{k(y),D({minType:o,medianType:d,maxType:h,minValue:S,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:y})}})]})]})},ue=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),pr=n=>{var m;const{onChange:e,className:t,value:l,type:a,id:u,disabled:i=!1}=n,p=j.useDependency(s.IUniverInstanceService),o=p.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),f=(m=p.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),d=C.useRef(null),[v,h]=C.useState(!1);j.useSidebarClick(N=>{var E;((E=d.current)==null?void 0:E.isClickOutSide(N))&&h(!1)});const b=C.useRef(l),S=C.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===r.CFValueType.formula){const N=String(b.current).startsWith("=")?String(b.current)||"":"=";return c.jsx("div",{className:"univer-ml-3 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:d,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:N,unitId:o,subUnitId:f,isFocus:v,onChange:(_="")=>{e(_||"")},onFocus:()=>h(!0)})})}return c.jsx(O.InputNumber,{className:t,value:Number(l)||0,disabled:i,onChange:N=>{e(N||0)},...S})},Hr=n=>{var L;const{interceptorManager:e}=n,t=j.useDependency(s.LocaleService),l=((L=n.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?n.rule:void 0,[a,u]=C.useState(()=>{var x;return l&&(x=l.config)!=null&&x.isGradient?"1":"0"}),[i,p]=C.useState(()=>{var y;return l&&((y=l.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[o,f]=C.useState(()=>{var y;return l&&((y=l.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),d=[ue(r.CFValueType.num,t),ue(r.CFValueType.percent,t),ue(r.CFValueType.percentile,t),ue(r.CFValueType.formula,t)],v=[ue(r.CFValueType.min,t),...d],h=[ue(r.CFValueType.max,t),...d],[b,S]=C.useState(()=>{var x;const y=v[0].value;return l&&((x=l.config)==null?void 0:x.min.type)||y}),[m,N]=C.useState(()=>{var x;const y=h[0].value;return l&&((x=l.config)==null?void 0:x.max.type)||y}),[_,E]=C.useState(()=>{var $;if(!l)return 0;const x=(($=l.config)==null?void 0:$.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[M,R]=C.useState(()=>{var $;if(!l)return 100;const x=(($=l.config)==null?void 0:$.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[g,T]=C.useState(()=>l?l.isShowValue===void 0?!0:!!l.isShowValue:!0),w=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return w({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}}),[a,_,b,M,m,i,o,e,g]);const I=y=>{n.onChange(w(y))},k=y=>{p(y),I({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:y,nativeColor:o,isShowValue:g})},V=y=>{f(y),I({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:y,isShowValue:g})},D=y=>d.map(x=>x.value).includes(y);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:w({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})})}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.fillType")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs(O.RadioGroup,{value:a,onChange:y=>{u(y),I({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})},children:[c.jsx(O.Radio,{value:"0",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.pureColor")})}),c.jsx(O.Radio,{value:"1",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.gradient")})})]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!g,onChange:y=>{T(!y),I({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:!y})}}),t.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.colorSet")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.native")}),c.jsx(re,{color:o,onChange:V})]}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.positive")}),c.jsx(re,{color:i,onChange:k})]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:v,value:b,onChange:y=>{S(y);const x=r.createDefaultValueByValueType(y,10);E(x),I({isGradient:a,minValue:x,minValueType:y,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}}),c.jsx(pr,{id:"min",className:"univer-ml-3",disabled:!D(b),type:b,value:_,onChange:y=>{E(y||0),I({isGradient:a,minValue:y||0,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:m,onChange:y=>{N(y);const x=r.createDefaultValueByValueType(y,90);R(x),I({isGradient:a,minValue:_,minValueType:b,maxValue:x,maxValueType:y,positiveColor:i,nativeColor:o,isShowValue:g})}}),c.jsx(pr,{className:"univer-ml-3",disabled:!D(m),id:"max",type:m,value:M,onChange:y=>{R(y||0),I({isGradient:a,minValue:_,minValueType:b,maxValue:y||0,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}})]})]})]})},Ee=n=>[s.BooleanNumber.FALSE,void 0].includes(n)?s.BooleanNumber.TRUE:s.BooleanNumber.FALSE,Re=n=>n!==s.BooleanNumber.FALSE,Je=n=>{const{style:e,onChange:t,className:l}=n,[a,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[i,p]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[o,f]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[d,v]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[h,b]=C.useState(()=>{var E;const _="#2f56ef";return(E=e==null?void 0:e.cl)!=null&&E.rgb?e.cl.rgb:_}),[S,m]=C.useState(()=>{var E;const _="#e8ecfc";return(E=e==null?void 0:e.bg)!=null&&E.rgb?e.bg.rgb:_});C.useEffect(()=>{const _={bl:a,it:i};h!==void 0&&(_.cl={rgb:h}),S!==void 0&&(_.bg={rgb:S}),d!==void 0&&(_.st={s:d}),o!==void 0&&(_.ul={s:o}),t(r.removeUndefinedAttr(_))},[a,i,o,d,h,S]);const N="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return c.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",l),children:[c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(a||s.BooleanNumber.FALSE)}),onClick:()=>u(Ee(a)),children:c.jsx(ar,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(i||s.BooleanNumber.FALSE)}),onClick:()=>p(Ee(i)),children:c.jsx(sr,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(o||s.BooleanNumber.FALSE)}),onClick:()=>f(Ee(o)),children:c.jsx(or,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(d||s.BooleanNumber.FALSE)}),onClick:()=>v(Ee(d)),children:c.jsx(cr,{})}),c.jsx(re,{color:h,onChange:b,Icon:dr}),c.jsx(re,{color:S,onChange:m})]})},Wr=n=>{var R;const{onChange:e,interceptorManager:t}=n,l=j.useDependency(s.LocaleService),u=j.useDependency(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=u.getActiveSheet(),p=((R=n.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?n.rule:void 0,o=C.useRef(null),[f,d]=C.useState(!1),v=C.useRef(null),[h,b]=C.useState({}),[S,m]=C.useState(()=>(p==null?void 0:p.subType)===r.CFSubRuleType.formula?p.value:"="),[N,_]=C.useState(void 0),E=g=>({style:g.style,value:S,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return E({style:h})}}),[h,S,t]),C.useEffect(()=>t.intercept(t.getInterceptPoints().beforeSubmit,{handler:(T,w,I)=>N||S.length===1||!S.startsWith("=")?(_(l.t("sheet.cf.errorMessage.formulaError")),!1):I(T)}),[N,S]);const M=g=>{e(E(g))};return j.useSidebarClick(g=>{var w;((w=v.current)==null?void 0:w.isClickOutSide(g))&&d(!1)}),c.jsxs("div",{ref:o,children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(ve.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),errorText:N,isFocus:f,initValue:S,unitId:u.getUnitId(),subUnitId:i==null?void 0:i.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{m(g),M({style:h})},onVerify:(g,T)=>{!g||T.length===1?_(l.t("sheet.cf.errorMessage.formulaError")):_(void 0)}})}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:E({style:h})})}),c.jsx(Je,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:g=>{b(g),M({style:g})}})]})},Me=n=>c.jsxs("div",{className:"univer-relative",children:[c.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:n.errorText}),n.children]}),B=(n,e)=>({label:e.t(`sheet.cf.operator.${n}`),value:n}),qr=n=>{const{type:e,operator:t,onChange:l,value:a,interceptorManager:u}=n,i=j.useDependency(s.LocaleService),[p,o]=C.useState(()=>typeof a=="number"?a:0),[f,d]=C.useState(""),[v,h]=C.useState(()=>typeof a=="string"?a:""),[b,S]=C.useState(""),[m,N]=C.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[_,E]=C.useState(""),[M,R]=C.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[g,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)&&l(v);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)&&l(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)&&l([m,M]);break}}},[e]),C.useEffect(()=>{const w=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(I,k,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(t))return v?V(I):(S(i.t("sheet.cf.errorMessage.notBlank")),!1)}return V(I)}});return()=>{w()}},[e,p,v,t]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)){const w=I=>{h(I),l(I)};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:b,children:c.jsx(O.Input,{value:v,onChange:I=>{S(""),w(I)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)){const w=I=>{o(I||0),l(I||0),d("")};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:f,children:c.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:w})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)){const w=k=>{N(k||0),l([k||0,M]),E("")},I=k=>{R(k||0),l([m,k||0]),T("")};return c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(Me,{errorText:_,children:c.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:w})}),c.jsx(Me,{errorText:g,children:c.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:M,onChange:I})})]})}}}return null},fr=(n,e)=>{switch(n){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},hr=n=>{var R;const{interceptorManager:e,onChange:t}=n,l=j.useDependency(s.LocaleService),a=((R=n.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?n.rule:void 0,[u,i]=C.useState(()=>{const g=r.CFSubRuleType.text;return a&&a.subType||g}),p=[{value:r.CFSubRuleType.text,label:l.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:l.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:l.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:l.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:l.t("sheet.cf.subRuleType.uniqueValues")}],o=C.useMemo(()=>fr(u,l),[u]),[f,d]=C.useState(()=>{const g=o?o[0].value:void 0;return a&&a.operator||g}),[v,h]=C.useState(()=>{var w;return a?(w=a.value)!=null?w:r.createDefaultValue(a.subType,a.operator):""}),[b,S]=C.useState({}),m=C.useMemo(()=>g=>{var T,w,I,k,V,D,L,y,x,$,G,J,Q,oe,de;switch(g.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(T=g.subType)!=null?T:u,operator:(w=g.operator)!=null?w:f,style:(I=g.style)!=null?I:b,value:(k=g.value)!=null?k:v};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(V=g.subType)!=null?V:u,operator:(D=g.operator)!=null?D:f,style:(L=g.style)!=null?L:b,value:(y=g.value)!=null?y:v};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(f))return{type:r.CFRuleType.highlightCell,subType:(x=g.subType)!=null?x:u,operator:($=g.operator)!=null?$:f,style:(G=g.style)!=null?G:b,value:(J=g.value)!=null?J:v};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=g.subType)!=null?Q:u,operator:(oe=g.operator)!=null?oe:f,style:(de=g.style)!=null?de:b}},[u,f,v,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return m({})}}),[m,e]),C.useEffect(()=>{p.some(g=>g.value===u)||i(p[0].value)},[p]);const N=g=>{const T=g,w=fr(T,l),I=w&&w[0].value;i(T),d(I),I&&h(r.createDefaultValue(T,I)),t(m({subType:T,operator:I}))},_=g=>{const T=g;d(T),t(m({operator:T}))},E=g=>{h(g),t(m({value:g}))},M=C.useMemo(()=>`${u}_${f}_${Math.random()}`,[u,f]);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),c.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:u,options:p}),(o==null?void 0:o.length)&&c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:f||"",options:o})]}),c.jsx(qr,{value:v,interceptorManager:e,type:u,operator:f,rule:a,onChange:E},M),c.jsx("div",{className:he,children:c.jsx(ae,{rule:m({})})}),c.jsx(Je,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:g=>{S(g),t(m({style:g}))}})]})},gr=(n,e)=>(r.iconMap[n]||[])[Number(e)]||"",Gr=n=>{var d;const{error:e,type:t,onChange:l}=n,a=j.useDependency(s.IUniverInstanceService),u=a.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),i=(d=a.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=C.useRef(null),[o,f]=C.useState(!1);return j.useSidebarClick(v=>{var b;((b=p.current)==null?void 0:b.isClickOutSide(v))&&f(!1)}),c.jsx("div",{className:"univer-relative",children:t!==r.CFValueType.formula?c.jsxs(c.Fragment,{children:[c.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(n.value)||0,onChange:v=>l(v!=null?v:0)}),e&&c.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):c.jsx("div",{className:"univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:p,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:String(n.value),unitId:u,subUnitId:i,isFocus:o,onChange:(v="")=>{l(v||"")},onFocus:()=>f(!0)})})})},yr=(n,e,t)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(t.length-1-e)*10},iconType:n,iconId:String(e)}),Zr=C.forwardRef((n,e)=>{const{onClick:t}=n,l=j.useDependency(s.LocaleService),a=u=>{t(u)};return c.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,i)=>c.jsxs("div",{className:"univer-mb-3",children:[c.jsx("div",{className:"univer-mb-1 univer-text-sm",children:l.t(u.title)}),c.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(p=>c.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(p.name)},children:c.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:p.list.map((o,f)=>c.jsx("img",{className:"univer-size-5",src:o,draggable:!1},f))})},p.name))})]},i))})}),zr=n=>{const{onClick:e}=n,t=C.useMemo(()=>{const a=[];for(const u in r.iconMap){const i=r.iconMap[u],p=u;i.forEach((o,f)=>{a.push({iconType:p,base64:o,iconId:String(f)})})}return a},[]),l=a=>{e(a.iconType,a.iconId)};return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>l({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[c.jsx(fe,{className:"univer-size-5"}),c.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),c.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:t.map(a=>c.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:c.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>l(a)})},`${a.iconType}_${a.iconId}`))})]})},Yr=n=>{const{onChange:e,configList:t,errorMap:l={}}=n,a=j.useDependency(s.LocaleService),u=[{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],i=[{label:a.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(v,h)=>{e([String(h),"value","value"],v)},o=(v,h)=>{e([String(h),"operator"],v);const b=r.createDefaultValue(r.CFSubRuleType.number,v);p(b,h)},f=(v,h)=>{e([String(h),"value","type"],v);const b=t[h],S=r.createDefaultValue(r.CFSubRuleType.number,b.operator);p(S,h)};return C.useMemo(()=>t.map((v,h)=>{const b=l[h],S=gr(v.iconType,v.iconId),m=h===t.length-1,N=h===0,_=t[h-1],E=(_==null?void 0:_.value.type)===r.CFValueType.formula?a.t("sheet.cf.valueType.formula"):_==null?void 0:_.value.value,M=(R,g)=>{const T={...v,iconId:g,iconType:R};e([String(h)],T)};return c.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),h+1]}),c.jsx("div",{className:"univer-w-[45%]",children:c.jsxs(c.Fragment,{children:[!N&&!m&&a.t("sheet.cf.iconSet.rule"),!N&&!m&&c.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),E,m?"":` ${a.t("sheet.cf.iconSet.and")} `]})]})})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx("div",{className:"univer-flex univer-items-center",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(zr,{onClick:M,iconId:v.iconId,iconType:v.iconType})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",O.borderClassName),children:[S?c.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):c.jsx(fe,{className:"univer-size-4"}),c.jsx(Ke,{})]})})}),m?c.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.rule"),c.jsxs("span",{className:"univer-font-medium",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),E,m?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):c.jsx(O.Select,{options:u,value:v.operator,onChange:R=>{o(R,h)}})]}),m?c.jsx("div",{}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),c.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx(O.Select,{options:i,value:v.value.type,onChange:R=>{f(R,h)}}),c.jsx(Gr,{id:h,type:v.value.type,error:b,value:v.value.value||"",onChange:R=>{p(R,h)}})]})]})]},h)}),[t,l])},Kr=n=>{var R;const{interceptorManager:e}=n,t=((R=n.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?n.rule:void 0,l=j.useDependency(s.LocaleService),[a,u]=C.useState({}),[i,p]=C.useState(()=>{const g=Object.keys(r.iconMap)[0];if(t&&t.config.length){const T=t.config[0].iconType;if(!t.config.some(I=>I.iconType!==T))return T}return g}),[o,f]=C.useState(()=>{if(t&&t.config.length)return s.Tools.deepClone(t==null?void 0:t.config);const g=r.iconMap[i]||[];return new Array(g.length).fill("").map((T,w,I)=>w===I.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:i,iconId:String(w)}:yr(i,w,I))}),[d,v]=C.useState(()=>t?!!t.isShowValue:!0),h=C.useMemo(()=>{const g=o.map(T=>gr(T.iconType,T.iconId));return c.jsx("div",{className:"univer-flex univer-items-center",children:g.map((T,w)=>T?c.jsx("img",{className:"univer-size-5",src:T},w):c.jsx(fe,{className:"univer-size-5"},w))})},[o]),b=g=>{if(g.reduce((w,I,k)=>w.preType&&!w.result||g.length-1===k?w:I.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:w.preType?{result:w.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(g[0].value.type)){const w={};return g.forEach((I,k,V)=>{if(k-1<0||k===V.length-1)return;const L=g[k-1],y=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:y,value:L.value.value},I.value.value)||(w[k]=`${l.t(`sheet.cf.form.${y}`,String(L.value.value))} `)}),w}return{}},S=(g,T)=>{s.get(o,g)!==T&&(s.set(o,g,T),f([...o]),u(b(o)))},m=g=>{p(g);const T=r.iconMap[g]||[],w=new Array(T.length).fill("").map((I,k,V)=>yr(g,k,V));f(w),u(b(w))};C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{g()}},[d,o,e]),C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{g()}},[d,o,e,a]);const N=()=>{const g=o.map(T=>({...T}));o.forEach((T,w)=>{const I=o.length-1-w,k=g[I];T.iconId=k.iconId,T.iconType=k.iconType}),f([...o])},_=j.useDependency(j.ILayoutService),[E,M]=C.useState();return j.useScrollYOverContainer(E,_.rootContainerElement),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:l.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(Zr,{ref:g=>{!E&&g&&M(g)},iconType:i,onClick:m})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[h,c.jsx(Ke,{})]})})}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{onChange:N}),l.t("sheet.cf.iconSet.reverseIconOrder")]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!d,onChange:g=>{v(!g)}}),l.t("sheet.cf.iconSet.onlyShowIcon")]})]}),c.jsx(Yr,{errorMap:a,onChange:S,configList:o})]})},Xr=n=>{var N;const{onChange:e,interceptorManager:t}=n,l=j.useDependency(s.LocaleService),a=((N=n.rule)==null?void 0:N.type)===r.CFRuleType.highlightCell?n.rule:void 0,u=[{label:l.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:l.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:l.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:l.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[i,p]=C.useState(()=>{const _=u[0].value,E=a==null?void 0:a.type;if(!a)return _;switch(E){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":_;case r.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return _}),[o,f]=C.useState(()=>{const E=a==null?void 0:a.type;if(!a)return 10;switch(E){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.value||10}}return 10}),[d,v]=C.useState(()=>{const E=a==null?void 0:a.type;if(!a)return!1;switch(E){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[h,b]=C.useState({}),S=_=>{const{type:E,isPercent:M,value:R,style:g}=_;if(E==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!1,value:R,style:g};if(E==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!0,value:R,style:g};if(E==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:g};if(E==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:g}};C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return S({type:i,isPercent:d,value:o,style:h})}}),[i,d,o,h,t]);const m=_=>{e(S(_))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:i,options:u,onChange:_=>{p(_),m({type:_,isPercent:d,value:o,style:h})}}),["isNotBottom","isBottom"].includes(i)&&c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.InputNumber,{min:1,max:1e3,value:o,onChange:_=>{const E=_||0;f(E),m({type:i,isPercent:d,value:E,style:h})}}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:d,onChange:_=>{v(!!_),m({type:i,isPercent:!!_,value:o,style:h})}}),l.t("sheet.cf.valueType.percent")]})]}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:S({type:i,isPercent:d,value:o,style:h})})}),c.jsx(Je,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:_=>{b(_),m({type:i,isPercent:d,value:o,style:_})}})]})},Jr=s.createInterceptorKey("beforeSubmit"),Qr=s.createInterceptorKey("submit"),Cr=n=>n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),mr=n=>{var e;return(e=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},et=n=>{var w,I,k;const e=j.useDependency(s.LocaleService),t=j.useDependency(s.ICommandService),l=j.useDependency(s.IUniverInstanceService),a=j.useDependency(r.ConditionalFormattingRuleModel),u=j.useDependency(U.SheetsSelectionsService),i=Cr(l),p=mr(l),[o,f]=C.useState(void 0),d=C.useRef((I=(w=n.rule)==null?void 0:w.ranges)!=null?I:[]),v=C.useMemo(()=>{var D,L,y;let V=(D=n.rule)==null?void 0:D.ranges;return V!=null&&V.length||(V=(y=(L=u.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?y:[]),d.current=V,V!=null&&V.length?V.map(x=>{const $=$e.serializeRange(x);return $==="NaN"?"":$}).filter(x=>!!x).join(","):""},[n.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var L,y;const V=(L=n.rule)==null?void 0:L.rule.type,D=h[0].value;if(!V)return D;switch(V){case r.CFRuleType.highlightCell:{switch((y=n.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return D}),m=C.useRef(void 0),N=C.useMemo(()=>new s.InterceptorManager({beforeSubmit:Jr,submit:Qr}),[]),_=C.useMemo(()=>{switch(b){case"1":return hr;case"2":return Xr;case"3":return Hr;case"4":return Br;case"5":return Wr;case"6":return Kr;default:return hr}},[b]);C.useEffect(()=>{const V=t.onCommandExecuted(D=>{if(D.id===U.RemoveSheetMutation.id){const L=D.params;L.subUnitId===p&&L.unitId===i&&n.onCancel()}D.id===U.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>V.dispose()},[]);const E=V=>{m.current=V},M=V=>{const D=V.split(",").filter(L=>!!L).map($e.deserializeRangeWithSheet).map(L=>L.range);d.current=D},R=()=>{if(o)return;const D=(()=>{const y=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return d.current.map(G=>U.setEndForRange(G,y.getRowCount(),y.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(N.fetchThroughInterceptors(N.getInterceptPoints().beforeSubmit)(!0,null)){const y=N.fetchThroughInterceptors(N.getInterceptPoints().submit)(null,null);if(y){const x=Cr(l),$=mr(l);if(!x||!$)throw new Error("No active sheet found");let G={};n.rule&&n.rule.cfId?(G={...n.rule,ranges:D,rule:y},t.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:$,rule:G}),n.onCancel()):(G={cfId:a.createCfId(x,$),ranges:D,rule:y,stopIfTrue:!1},t.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:$,rule:G}),n.onCancel())}}},g=()=>{n.onCancel()},T=(V,D)=>{V?D.length<1?f(e.t("sheet.cf.errorMessage.rangeError")):f(void 0):f(e.t("sheet.cf.errorMessage.rangeError"))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),c.jsxs("div",{className:"univer-mt-4",children:[c.jsx(ve.RangeSelector,{unitId:i,subUnitId:p,initialValue:v,onChange:(V,D)=>M(D),onVerify:T}),o&&c.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),c.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:b,options:h,onChange:V=>S(V)}),c.jsx(_,{interceptorManager:N,rule:(k=n.rule)==null?void 0:k.rule,onChange:E}),c.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[c.jsx(O.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),c.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var rt=Object.getOwnPropertyDescriptor,tt=(n,e,t,l)=>{for(var a=l>1?void 0:l?rt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},nt=(n,e)=>(t,l)=>e(t,l,n);let se=class extends s.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const t=/\{([^}]+)?\}/g,l=[];let a=t.exec(e);for(;a;)l.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=t.exec(e);return l});this._localeService=e,this._initLocal()}tWithReactNode(e,...t){const l=this._localeService.getLocales(),a=e.split("."),u=l&&this._localeService.resolveKeyPath(l,a);if(typeof u=="string"){const i=[];return this._findReplaceIndex(u).forEach((p,o,f)=>{const d=f[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const v=u.slice(d.endIndex+1,p.startIndex);v&&i.push(v)}if(t[p.key]&&i.push(t[p.key]),o===f.length-1){const v=u.slice(p.endIndex+1);v&&i.push(v)}}),i}return[]}};se=tt([nt(0,s.Inject(s.LocaleService))],se);const lt=(n,e)=>{const t=n.rule;switch(t.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(t.subType){case r.CFSubRuleType.average:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`,...Array.isArray(t.value)?t.value.map(a=>String(a)):[String(t.value||"")])}case r.CFSubRuleType.text:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`,t.value||"")}case r.CFSubRuleType.timePeriod:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`)}case r.CFSubRuleType.rank:return t.isPercent?t.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(t.value)):e.t("sheet.cf.preview.describe.topNPercent",String(t.value)):t.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(t.value)):e.t("sheet.cf.preview.describe.topN",String(t.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let br=0;const at=n=>{const{onClick:e}=n,t=j.useDependency(r.ConditionalFormattingRuleModel),l=j.useDependency(s.IUniverInstanceService),a=j.useDependency(U.SheetsSelectionsService),u=j.useDependency(s.ICommandService),i=j.useDependency(s.LocaleService),p=j.useDependency(s.Injector),o=j.useDependency(j.ISidebarService),f=j.useDependency(se),d=j.useObservable(()=>l.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),v=d.getUnitId(),h=d.getActiveSheet();if(!h)throw new Error("No active sheet found");const b=h.getSheetId(),[S,m]=C.useState([]),[N,_]=C.useState("2"),[E,M]=C.useState(0),[R,g]=C.useState(-1),[T,w]=C.useState(br),I=C.useRef(null),k=[{label:i.t("sheet.cf.panel.workSheet"),value:"2"},{label:i.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=t.getSubunitRules(v,b);if(!A||!A.length)return[];if(N==="1"){const F=a.getCurrentLastSelection();if(!F)return[];const H=F.range;return A.filter(Z=>Z.ranges.some(z=>s.Rectangle.intersects(z,H)))}else if(N==="2")return[...A];return[]},[D,L]=C.useState(V);W.useHighlightRange(S),C.useEffect(()=>{const A=u.onCommandExecuted(F=>{F.id===U.SetWorksheetActiveOperation.id&&M(Math.random())});return()=>A.dispose()}),C.useEffect(()=>{L(V)},[N,E,v,b]),C.useEffect(()=>{if(N==="2")return;const A=new X.Observable(F=>{const H=[U.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(Z=>{const{id:z,params:ne}=Z,le=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(z)&&ne.unitId===le&&F.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[l,N,v,b]),C.useEffect(()=>{const A=t.$ruleChange.subscribe(()=>{M(Math.random())});return()=>A.unsubscribe()},[t]),C.useEffect(()=>{const A=()=>{var Z,z;const q=Math.max(0,((z=(Z=I.current)==null?void 0:Z.getBoundingClientRect().width)!=null?z:0)-8);return br=q,q},H=new X.Observable(q=>{const Z=o.getContainer();if(Z){let z=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{z&&clearTimeout(z),z=null},le=Ae=>{Ae.propertyName==="width"&&(ne(),q.next(void 0))};return Z.addEventListener("transitionend",le),()=>{ne(),Z.removeEventListener("transitionend",le)}}}).pipe(X.debounceTime(16)).subscribe(()=>{w(A())});return()=>{H.unsubscribe()}},[]);const y=A=>{var q;const F=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!F||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:F,subUnitId:H,cfId:A.cfId})},x=(A,F)=>{g(F.y)},$=(A,F,H)=>{var Ae;g(-1);const q=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),Z=(Ae=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Ae.getSheetId();if(!q||!Z)throw new Error("No active sheet found");const z=$t=>{const Ft=D.length;return Math.min(Ft-1,Math.max(0,$t))},ne=D[z(F.y)].cfId,le=D[z(H.y)].cfId;ne!==le&&u.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:Z,start:{id:ne,type:"self"},end:{id:le,type:H.y>F.y?"after":"before"}})},G=()=>{n.onCreate()},J=()=>{N==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):N==="1"&&D.map(F=>({unitId:v,subUnitId:b,cfId:F.cfId})).forEach(F=>{u.executeCommand(r.DeleteCfCommand.id,F)})},Q=C.useMemo(()=>{const A=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return D.filter(H=>{const q=H.ranges;return U.checkRangesEditablePermission(p,A.getUnitId(),F.getSheetId(),q)})},[D]),oe=Q.map((A,F)=>({i:A.cfId,x:0,w:12,y:F,h:1,isResizable:!1})),de=C.useMemo(()=>{const A=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return D.every(H=>{const q=H.ranges;return U.checkRangesEditablePermission(p,A.getUnitId(),F.getSheetId(),q)})},[D]);return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[c.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:f.tWithReactNode("sheet.cf.panel.managerRuleSelect",c.jsx(O.Select,{className:"univer-w-36",options:k,value:N,onChange:A=>{_(A)}})).map((A,F)=>c.jsx("span",{children:A},F))}),c.jsxs("div",{className:"univer-flex univer-justify-end",children:[c.jsx(O.Tooltip,{title:i.t("sheet.cf.panel.createRule"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:c.jsx(ur,{})})}),D.length&&de?c.jsx(O.Tooltip,{title:i.t("sheet.cf.panel.clear"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:c.jsx(Ne,{className:"univer-text-red-500"})})}):c.jsx("div",{children:c.jsx(Ne,{className:"univer-text-gray-300"})})]})]}),c.jsx("div",{ref:I,children:T>0&&c.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:oe,cols:12,rowHeight:60,width:T,margin:[0,10],onDragStop:$,onDragStart:x,children:Q==null?void 0:Q.map((A,F)=>c.jsx("div",{children:c.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":R===F}),onMouseMove:()=>{A.ranges!==S&&m(A.ranges)},onMouseLeave:()=>m([]),onClick:()=>{e(A)},children:[c.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:c.jsx(ir,{})}),c.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[c.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:lt(A,i)}),c.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>$e.serializeRange(H)).join(",")})]}),c.jsx("div",{children:c.jsx(ae,{rule:A.rule})}),c.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":R===F}),onClick:H=>{H.stopPropagation(),y(A),m([])},children:c.jsx(Ne,{})})]})},`${A.cfId}`))})})]})},ut=n=>{const[e,t]=C.useState(n.rule),[l,a]=C.useState(!!n.rule),u=()=>{a(!0)},i=()=>{a(!1),t(void 0)},p=o=>{t(o),a(!0)};return c.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:l?c.jsx(et,{onCancel:i,rule:e}):c.jsx(at,{onClick:p,onCreate:u})})};var st=Object.getOwnPropertyDescriptor,it=(n,e,t,l)=>{for(var a=l>1?void 0:l?st(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},ge=(n,e)=>(t,l)=>e(t,l,n);const Ve="sheet.conditional.formatting.panel";let ye=class extends s.Disposable{constructor(e,t,l,a,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=t,this._componentManager=l,this._sidebarService=a,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{var p;i||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(i=>{i.id===Ve&&(i.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const t={id:Ve,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ve,rule:e,key:s.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(t)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ve,ut))}};ye=it([ge(0,s.IUniverInstanceService),ge(1,s.Inject(s.Injector)),ge(2,s.Inject(j.ComponentManager)),ge(3,s.Inject(j.ISidebarService)),ge(4,s.Inject(s.LocaleService))],ye);var Y=(n=>(n[n.createRule=1]="createRule",n[n.viewRule=2]="viewRule",n[n.highlightCell=3]="highlightCell",n[n.rank=4]="rank",n[n.formula=5]="formula",n[n.colorScale=6]="colorScale",n[n.dataBar=7]="dataBar",n[n.icon=8]="icon",n[n.clearRangeRules=9]="clearRangeRules",n[n.clearWorkSheetRules=10]="clearWorkSheetRules",n))(Y||{});const Ce={id:"sheet.operation.open.conditional.formatting.panel",type:s.CommandType.OPERATION,handler:(n,e)=>{var p;const t=n.get(ye),l=n.get(U.SheetsSelectionsService),a=n.get(s.ICommandService),u=((p=l.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};t.openPanel(o);break}case 5:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};t.openPanel(o);break}case 6:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};t.openPanel(o);break}case 7:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};t.openPanel(o);break}case 8:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};t.openPanel(o);break}case 2:{t.openPanel();break}case 1:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{a.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{a.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var ct=Object.getOwnPropertyDescriptor,ot=(n,e,t,l)=>{for(var a=l>1?void 0:l?ct(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},me=(n,e)=>(t,l)=>e(t,l,n);P.ConditionalFormattingClearController=class extends s.Disposable{constructor(e,t,l,a,u){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=l,this._selectionManagerService=a,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const t=[],l=[],a={redos:t,undos:l};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const i=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(S=>S.range);if(!i)return a;const p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return a;const f=p.getUnitId(),d=o.getSheetId(),v=this._conditionalFormattingRuleModel.getSubunitRules(f,d);if(!v||!v.length)return a;const{redos:h,undos:b}=Ir(this._injector,v,i,f,d);t.push(...h),l.push(...b)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:l})=>{const a=[],u=[],i={redos:a,undos:u};if(!l||!l.length)return i;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!p||!p.length)return i;const{redos:o,undos:f}=Ir(this._injector,p,l,e,t);return a.push(...o),u.push(...f),i}}))}},P.ConditionalFormattingClearController=ot([me(0,s.Inject(s.Injector)),me(1,s.Inject(s.IUniverInstanceService)),me(2,s.Inject(U.SheetInterceptorService)),me(3,s.Inject(U.SheetsSelectionsService)),me(4,s.Inject(r.ConditionalFormattingRuleModel))],P.ConditionalFormattingClearController);function Ir(n,e,t,l,a){const u=[],i=[];return e.filter(p=>t.some(o=>p.ranges.some(f=>s.Rectangle.getIntersects(f,o)))).forEach(p=>{const f=new U.RangeMergeUtil().add(...p.ranges).subtract(...t).merge();if(f.length){const d={id:r.SetConditionalRuleMutation.id,params:{unitId:l,subUnitId:a,rule:{...p,ranges:f}}},v=r.setConditionalRuleMutationUndoFactory(n,d.params);u.push(d),i.push(...v)}else{const d={id:r.DeleteConditionalRuleMutation.id,params:{unitId:l,subUnitId:a,cfId:p.cfId}},v=r.DeleteConditionalRuleMutationUndoFactory(n,d.params);u.push(d),i.push(...v)}}),{redos:u,undos:i}}var dt=Object.getOwnPropertyDescriptor,vt=(n,e,t,l)=>{for(var a=l>1?void 0:l?dt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},be=(n,e)=>(t,l)=>e(t,l,n);let Ie=class extends s.Disposable{constructor(e,t,l,a,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=l,this._conditionalFormattingViewModel=a,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,l)=>this._collectConditionalRule(e,t,l),onPasteCells:(e,t,l,a)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:i}=a,{range:p}=e||{},{range:o}=t;return this._generateConditionalFormattingMutations(o,{copyType:u,pasteType:i,copyRange:p})}}))}_collectConditionalRule(e,t,l){const a=new s.ObjectMatrix,u={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:t,cfMap:u}};const i=this._injector.invoke(d=>U.rangeToDiscreteRange(l,d,e,t));if(!i)return;const{rows:p,cols:o}=i,f=new Set;p.forEach((d,v)=>{o.forEach((h,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,t,d,h);S&&(S.forEach(m=>f.add(m.cfId)),a.setValue(v,b,S.map(m=>m.cfId)))})}),f.forEach(d=>{const v=this._conditionalFormattingRuleModel.getRule(e,t,d);v&&(u[d]=v.rule)})}_generateConditionalFormattingMutations(e,t){const l=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),a=l.getActiveSheet(),u=l.getUnitId();if(!a)return{redos:[],undos:[]};const i=a.getSheetId();if(t.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!t.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_BESIDES_BORDER].includes(t.pasteType))return{redos:[],undos:[]};const{ranges:[o,f],mapFunc:d}=W.virtualizeDiscreteRanges([t.copyRange,e]),v=W.getRepeatRange(o,f,!0),h={};s.Range.foreach(f,(g,T)=>{const{row:w,col:I}=d(g,T),k=this._conditionalFormattingViewModel.getCellCfs(u,i,w,I);k&&k.forEach(V=>{if(!h[V.cfId]){const D=new s.ObjectMatrix;h[V.cfId]=D;const L=this._conditionalFormattingRuleModel.getRule(u,i,V.cfId);L==null||L.ranges.forEach(y=>{s.Range.foreach(y,(x,$)=>{D.setValue(x,$,1)})})}h[V.cfId].realDeleteValue(w,I)})});const{matrix:b,info:S}=this._copyInfo,m=[];let N=this._conditionalFormattingRuleModel.createCfId(u,i);const _={},E=g=>{if(_[g])return _[g];const T=S==null?void 0:S.cfMap[g],w=[...this._conditionalFormattingRuleModel.getSubunitRules(u,i)||[],...m].find(I=>s.Tools.diffValue(I.rule,T));if(w)return _[g]=w,w;{const I={rule:T,cfId:N,ranges:[],stopIfTrue:!1};return _[g]=I,m.push(I),N=`${Number(N)+1}`,I}};v.forEach(g=>{b&&b.forValue((T,w,I)=>{const k=s.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:w,endColumn:w},g.startRange),{row:V,col:D}=d(k.startRow,k.startColumn);I.forEach(L=>{if(!h[L]){const y=E(L),x=new s.ObjectMatrix;h[L]=x,y.ranges.forEach($=>{s.Range.foreach($,(G,J)=>{x.setValue(G,J,1)})})}h[L].setValue(V,D,1)})})});const M=[],R=[];for(const g in h){const T=h[g],w=U.findAllRectangle(U.createTopMatrixFromMatrix(T));if(!w.length){const I={unitId:u,subUnitId:i,cfId:g};M.push({id:r.DeleteConditionalRuleMutation.id,params:I}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(m.some(I=>I.cfId===g)){const I=E(g),k={unitId:u,subUnitId:i,rule:{...I,ranges:w}};M.push({id:r.AddConditionalRuleMutation.id,params:k}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,k))}else{const I=this._conditionalFormattingRuleModel.getRule(u,i,g);if(!I)continue;const k={unitId:u,subUnitId:i,rule:{...I,ranges:w}};M.push({id:r.SetConditionalRuleMutation.id,params:k}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,k))}}return{redos:M,undos:R}}};Ie=vt([be(0,s.Inject(W.ISheetClipboardService)),be(1,s.Inject(r.ConditionalFormattingRuleModel)),be(2,s.Inject(s.Injector)),be(3,s.Inject(r.ConditionalFormattingViewModel)),be(4,s.Inject(s.IUniverInstanceService))],Ie);var pt=Object.getOwnPropertyDescriptor,ft=(n,e,t,l)=>{for(var a=l>1?void 0:l?pt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},Qe=(n,e)=>(t,l)=>e(t,l,n);let Se=class extends s.Disposable{constructor(n,e,t){super(),this._localeService=n,this._commandService=e,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===r.AddCfCommand.id){const{unitId:e,subUnitId:t,rule:{ranges:l}}=n.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},l,e,t)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Se=ft([Qe(0,s.Inject(s.LocaleService)),Qe(1,s.ICommandService),Qe(2,s.Inject(U.SheetPermissionCheckController))],Se);var ht=Object.getOwnPropertyDescriptor,gt=(n,e,t,l)=>{for(var a=l>1?void 0:l?ht(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},Oe=(n,e)=>(t,l)=>e(t,l,n);let Te=class extends s.Disposable{constructor(n,e,t,l){super(),this._conditionalFormattingRuleModel=n,this._univerInstanceService=e,this._injector=t,this._refRangeService=l,this._initRefRange()}_initRefRange(){const n=new Map,e=(l,a,u)=>`${l}_${a}_${u}`,t=(l,a,u)=>{const i=o=>{const f=[...u.ranges],d=f.map(h=>U.handleDefaultRangeChangeWithEffectRefCommands(h,o)).filter(h=>!!h);if(r.isRangesEqual(d,f))return{redos:[],undos:[]};if(d.length){const h={unitId:l,subUnitId:a,rule:{...u,ranges:d}},b=[{id:r.SetConditionalRuleMutation.id,params:h}],S=r.setConditionalRuleMutationUndoFactory(this._injector,h);return{redos:b,undos:S}}else{const h={unitId:l,subUnitId:a,cfId:u.cfId},b=[{id:r.DeleteConditionalRuleMutation.id,params:h}],S=r.DeleteConditionalRuleMutationUndoFactory(this._injector,h);return{redos:b,undos:S}}},p=[];u.ranges.forEach(o=>{const f=this._refRangeService.registerRefRange(o,i);p.push(()=>f.dispose())}),n.set(e(l,a,u.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(l=>{const{unitId:a,subUnitId:u,rule:i}=l,p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(l.unitId!==p.getUnitId()||l.subUnitId!==(o==null?void 0:o.getSheetId())))switch(l.type){case"add":{t(l.unitId,l.subUnitId,l.rule);break}case"delete":{const f=n.get(e(a,u,i.cfId));f&&f();break}case"set":{const f=n.get(e(a,u,i.cfId));f&&f(),t(l.unitId,l.subUnitId,l.rule)}}})),this.disposeWithMe(s.toDisposable(()=>{n.forEach(l=>{l()}),n.clear()}))}};Te=gt([Oe(0,s.Inject(r.ConditionalFormattingRuleModel)),Oe(1,s.Inject(s.IUniverInstanceService)),Oe(2,s.Inject(s.Injector)),Oe(3,s.Inject(U.RefRangeService))],Te);var yt=Object.getOwnPropertyDescriptor,Ct=(n,e,t,l)=>{for(var a=l>1?void 0:l?yt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},ie=(n,e)=>(t,l)=>e(t,l,n);let _e=class extends s.Disposable{constructor(e,t,l,a,u,i){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=l,this._renderManagerService=a,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=i,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var t,l,a;const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();(t=this._renderManagerService.getRenderById(e))==null||t.with(W.SheetSkeletonManagerService).reCalculate(),(a=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(pe.bufferTime(16),pe.filter(e=>!!e.length),pe.filter(e=>{const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const l=t.getActiveSheet();return l?e.filter(a=>a.unitId===t.getUnitId()&&a.subUnitId===l.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(e,t,l)=>{const a=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!a)return l(e);const u=t.workbook.getStyles(),i=(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},p=e===t.rawData?{...t.rawData}:e;if(a.style){const o={...i,...a.style};Object.assign(p,{s:o})}return p.fontRenderExtension||(p.fontRenderExtension={},a.isShowValue!==void 0&&(p.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(p.dataBar=a.dataBar),a.iconSet&&(p.iconSet=a.iconSet,p.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),l(p)},priority:10}))}};_e=Ct([ie(0,s.Inject(U.SheetInterceptorService)),ie(1,s.Inject(r.ConditionalFormattingService)),ie(2,s.Inject(s.IUniverInstanceService)),ie(3,s.Inject(nr.IRenderManagerService)),ie(4,s.Inject(r.ConditionalFormattingViewModel)),ie(5,s.Inject(r.ConditionalFormattingRuleModel))],_e);const Sr="sheets-conditional-formatting-ui.config",Ue={};var mt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,It=(n,e,t)=>e in n?mt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,St=(n,e,t,l)=>{for(var a=l>1?void 0:l?bt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},er=(n,e)=>(t,l)=>e(t,l,n),Tr=(n,e,t)=>It(n,typeof e!="symbol"?e+"":e,t);P.UniverSheetsConditionalFormattingMobileUIPlugin=class extends s.Plugin{constructor(e=Ue,t,l,a){super(),this._config=e,this._injector=t,this._commandService=l,this._configService=a;const{menu:u,...i}=s.merge({},Ue,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Se]),this._injector.add([se])}_initCommand(){[Fe,Be,He,We,qe,Ge,Ze,ze,Ye,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},Tr(P.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),Tr(P.UniverSheetsConditionalFormattingMobileUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingMobileUIPlugin=St([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin),er(1,s.Inject(s.Injector)),er(2,s.Inject(s.ICommandService)),er(3,s.IConfigService)],P.UniverSheetsConditionalFormattingMobileUIPlugin);var Tt=Object.getOwnPropertyDescriptor,_t=(n,e,t,l)=>{for(var a=l>1?void 0:l?Tt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},we=(n,e)=>(t,l)=>e(t,l,n);let ke=class extends s.Disposable{constructor(n,e,t,l,a){super(),this._injector=n,this._univerInstanceService=e,this._autoFillService=t,this._conditionalFormattingRuleModel=l,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),e=(a,u,i,p,o)=>{var b;const f=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(b=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!f||!d)return;const v={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};s.Range.foreach(i,(S,m)=>{const N=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},v),_=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},h),{row:E,col:M}=o(N.startRow,N.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(f,d,E,M),{row:g,col:T}=o(_.startRow,_.startColumn),w=this._conditionalFormattingViewModel.getCellCfs(f,d,g,T);w&&w.forEach(I=>{let k=p.get(I.cfId);if(!p.get(I.cfId)){const V=this._conditionalFormattingRuleModel.getRule(f,d,I.cfId);if(!V)return;k=new s.ObjectMatrix,V.ranges.forEach(D=>{s.Range.foreach(D,(L,y)=>{k.setValue(L,y,1)})}),p.set(I.cfId,k)}k.realDeleteValue(g,T)}),R&&R.forEach(I=>{let k=p.get(I.cfId);if(!p.get(I.cfId)){const V=this._conditionalFormattingRuleModel.getRule(f,d,I.cfId);if(!V)return;k=new s.ObjectMatrix,V.ranges.forEach(D=>{s.Range.foreach(D,(L,y)=>{k.setValue(L,y,1)})}),p.set(I.cfId,k)}k.setValue(g,T,1)})})},t=(a,u)=>{var _,E,M;const i=(_=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getUnitId(),p=(M=(E=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:E.getActiveSheet())==null?void 0:M.getSheetId(),o=new Map,f=[],d=[];if(!i||!p)return n();const v=W.virtualizeDiscreteRanges([a,u]),[h,b]=v.ranges,{mapFunc:S}=v,m={row:h.startRow,col:h.startColumn};return W.getAutoFillRepeatRange(h,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,o,S)}),o.forEach((R,g)=>{const T=this._conditionalFormattingRuleModel.getRule(i,p,g);if(!T)return;const w=U.findAllRectangle(U.createTopMatrixFromMatrix(R));if(w.length){const I={unitId:i,subUnitId:p,rule:{...T,ranges:w}};f.push({id:r.SetConditionalRuleMutation.id,params:I}),d.push(...r.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:i,subUnitId:p,cfId:T.cfId};f.push({id:r.DeleteConditionalRuleMutation.id,params:I}),d.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:f}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,u,i)=>{if(i===W.APPLY_TYPE.COPY||i===W.APPLY_TYPE.ONLY_FORMAT||i===W.APPLY_TYPE.SERIES){const{source:p,target:o}=a;return t(p,o)}return n()}};this.disposeWithMe(this._autoFillService.addHook(l))}};ke=_t([we(0,s.Inject(s.Injector)),we(1,s.Inject(s.IUniverInstanceService)),we(2,s.Inject(W.IAutoFillService)),we(3,s.Inject(r.ConditionalFormattingRuleModel)),we(4,s.Inject(r.ConditionalFormattingViewModel))],ke);var wt=Object.getOwnPropertyDescriptor,xt=(n,e,t,l)=>{for(var a=l>1?void 0:l?wt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},_r=(n,e)=>(t,l)=>e(t,l,n);let De=class extends s.Disposable{constructor(n,e){super(),this._sheetInterceptorService=n,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(n,e,t)=>{var i,p,o;n||t(n);const l=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(i=l==null?void 0:l.style)!=null?i:{},u=Object.keys(a);if(n!=null&&n.p)return(o=(p=n.p.body)==null?void 0:p.textRuns)==null||o.forEach(f=>{f.ts&&u.forEach(d=>{var v;(v=f.ts)==null||delete v[d]})}),t(n);{const f={...(typeof(n==null?void 0:n.s)=="string"?e.workbook.getStyles().get(n.s):n==null?void 0:n.s)||{}};u.forEach(v=>{delete f[v]});const d={...n,s:{...f}};return t(d)}}})))}};De=xt([_r(0,s.Inject(U.SheetInterceptorService)),_r(1,s.Inject(r.ConditionalFormattingService))],De);const wr=[U.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],xe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Y.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Y.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Y.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Y.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Y.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Y.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Y.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Y.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Y.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Y.clearWorkSheetRules}],Nt=n=>{const e=n.get(U.SheetsSelectionsService),t=n.get(s.ICommandService),l=n.get(s.IUniverInstanceService),a=n.get(r.ConditionalFormattingRuleModel),u=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(f=>{const d=t.onCommandExecuted(v=>{var m;const{id:h,params:b}=v,S=(m=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();wr.includes(h)&&b.unitId===S&&f.next(null)});return()=>d.dispose()})).pipe(pe.debounceTime(16)).subscribe(()=>{var m;const f=((m=e.getCurrentSelections())==null?void 0:m.map(N=>N.range))||[],d=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!d)return;const v=d.getActiveSheet();if(!v)return;const S=(a.getSubunitRules(d.getUnitId(),v.getSheetId())||[]).filter(N=>N.ranges.some(_=>f.some(E=>s.Rectangle.intersects(E,_)))).map(N=>N.ranges).every(N=>U.checkRangesEditablePermission(n,d.getUnitId(),v.getSheetId(),N));o.next(S)})),i=new X.Observable(o=>new X.Observable(f=>{const d=t.onCommandExecuted(v=>{var m;const{id:h,params:b}=v,S=(m=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();wr.includes(h)&&b.unitId===S&&f.next(null)});return()=>d.dispose()}).pipe(pe.debounceTime(16)).subscribe(()=>{const f=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!f)return;const d=f.getActiveSheet();if(!d)return;const v=a.getSubunitRules(f.getUnitId(),d.getSheetId())||[];if(!v.length)return o.next(!1),!1;const h=v.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(n,f.getUnitId(),d.getSheetId(),b));o.next(h)})),p=new X.Observable(o=>{u.subscribe(f=>{const d=xe.find(v=>v.value===Y.clearRangeRules);d&&(d.disabled=!f,o.next(xe))}),i.subscribe(f=>{const d=xe.find(v=>v.value===Y.clearWorkSheetRules);d&&(d.disabled=!f,o.next(xe))}),o.next(xe)});return{id:Ce.id,type:j.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(n,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Et={[j.RibbonDataGroup.RULES]:{[Ce.id]:{order:1,menuItemFactory:Nt}}};var Rt=Object.getOwnPropertyDescriptor,Mt=(n,e,t,l)=>{for(var a=l>1?void 0:l?Rt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},xr=(n,e)=>(t,l)=>e(t,l,n);let Pe=class extends s.Disposable{constructor(e,t){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=t,this._menuManagerService.mergeMenu(Et)}};Pe=Mt([xr(0,s.Inject(s.Injector)),xr(1,j.IMenuManagerService)],Pe);var Vt=Object.getOwnPropertyDescriptor,Ot=(n,e,t,l)=>{for(var a=l>1?void 0:l?Vt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},ce=(n,e)=>(t,l)=>e(t,l,n);const Ut=(n,e)=>{const t=d=>d.endRow-d.startRow+1,l=d=>d.endColumn-d.startColumn+1,a=t(e)%t(n),u=l(e)%l(n),i=Math.floor(t(e)/t(n)),p=Math.floor(l(e)/l(n)),o=[],f={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:l(n)-1};if(t(e)===1&&l(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:f,startRange:d}),o}for(let d=0;d<i+(a?.1:0);d++)for(let v=0;v<p+(u?.1:0);v++){const h=t(n)*d,b=l(n)*v,S={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=f;d===i&&a&&(m={...m},m.endRow=m.endRow-(t(n)-a)),v===p&&u&&(m={...m},m.endColumn=m.endColumn-(l(n)-u)),o.push({repeatRelativeRange:m,startRange:S})}return o};let Le=class extends s.Disposable{constructor(e,t,l,a,u,i){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=t,this._formatPainterService=l,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=i,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),t=(u,i,p,o,f)=>{const{unitId:d,subUnitId:v}=this._painterConfig,{targetUnitId:h,targetSubUnitId:b}=f,S={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},m={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row};s.Range.foreach(p,(N,_)=>{const E=s.Rectangle.getPositionRange({startRow:N,startColumn:_,endColumn:_,endRow:N},S),M=s.Rectangle.getPositionRange({startRow:N,startColumn:_,endColumn:_,endRow:N},m),R=this._conditionalFormattingViewModel.getCellCfs(d,v,E.startRow,E.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(h,b,M.startRow,M.startColumn);g&&g.forEach(T=>{let w=o.get(T.cfId);if(!o.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(h,b,T.cfId);if(!I)return;w=new s.ObjectMatrix,I.ranges.forEach(k=>{s.Range.foreach(k,(V,D)=>{w.setValue(V,D,1)})}),o.set(T.cfId,w)}w.realDeleteValue(M.startRow,M.startColumn)}),R&&R.forEach(T=>{const w=o.get(T.cfId);w&&w.setValue(M.startRow,M.startColumn,1)})})},l=(u,i,p)=>{var E;const{range:o,unitId:f,subUnitId:d}=this._painterConfig,v=u!==f||d!==i,h=new Map,b=[],S=[];if(!u||!i||!f||!d)return e();const m=(E=this._conditionalFormattingRuleModel.getSubunitRules(f,d))!=null?E:[];m==null||m.forEach(M=>{const{ranges:R,cfId:g}=M;if(R.some(T=>s.Rectangle.intersects(o,T))){const T=new s.ObjectMatrix;v||R.forEach(w=>{s.Range.foreach(w,(I,k)=>{T.setValue(I,k,1)})}),h.set(g,T)}});const N={row:o.startRow,col:o.startColumn};return Ut(o,p).forEach(M=>{t(N,{row:M.startRange.startRow,col:M.startRange.startColumn},M.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:i})}),h.forEach((M,R)=>{if(v){const g=this._conditionalFormattingRuleModel.getRule(u,i,R),T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(g)if(T.length){const w={unitId:u,subUnitId:i,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:u,subUnitId:i,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}else if(T.length){const w=this._conditionalFormattingRuleModel.getRule(f,d,R);if(w){const I={unitId:u,subUnitId:i,rule:{...s.Tools.deepClone(w),cfId:this._conditionalFormattingRuleModel.createCfId(u,i),ranges:T}};b.push({id:r.AddConditionalRuleMutation.id,params:I}),S.push(r.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(f,d,R);if(!g)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(T.length){const w={unitId:f,subUnitId:d,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:f,subUnitId:d,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}}}),{undos:S,redos:b}},a={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var i,p,o;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const f=(i=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),v=this._sheetsSelectionsService.getCurrentLastSelection(),h=v==null?void 0:v.range;f&&d&&h&&(this._painterConfig={unitId:f,subUnitId:d,range:h});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,i,p)=>this._painterConfig?l(u,i,p):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Le=Ot([ce(0,s.Inject(s.Injector)),ce(1,s.Inject(s.IUniverInstanceService)),ce(2,s.Inject(W.IFormatPainterService)),ce(3,s.Inject(U.SheetsSelectionsService)),ce(4,s.Inject(r.ConditionalFormattingRuleModel)),ce(5,s.Inject(r.ConditionalFormattingViewModel))],Le);var kt=Object.getOwnPropertyDescriptor,Dt=(n,e,t,l)=>{for(var a=l>1?void 0:l?kt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},rr=(n,e)=>(t,l)=>e(t,l,n);let je=class extends s.Disposable{constructor(n,e,t){super(),this._conditionalFormattingViewModel=n,this._univerInstanceService=e,this._renderManagerService=t,this._init()}_init(){const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),e=t=>{const l=t.getUnitId(),a=this._renderManagerService.getRenderById(l);if(!a)return;const u=a.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(i=>{if(i){const p=i.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,v=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(v)}}))};n&&e(n),this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{t&&e(t)})}};je=Dt([rr(0,s.Inject(r.ConditionalFormattingViewModel)),rr(1,s.IUniverInstanceService),rr(2,nr.IRenderManagerService)],je);var Pt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,jt=(n,e,t)=>e in n?Pt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,At=(n,e,t,l)=>{for(var a=l>1?void 0:l?Lt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},tr=(n,e)=>(t,l)=>e(t,l,n),Nr=(n,e,t)=>jt(n,typeof e!="symbol"?e+"":e,t);P.UniverSheetsConditionalFormattingUIPlugin=class extends s.Plugin{constructor(e=Ue,t,l,a){super(),this._config=e,this._injector=t,this._commandService=l,this._configService=a;const{menu:u,...i}=s.merge({},Ue,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand()}onStarting(){s.registerDependencies(this._injector,[[_e],[Te],[Ie],[ke],[Se],[ye],[Pe],[se],[De],[P.ConditionalFormattingClearController],[Le],[je]]),s.touchDependencies(this._injector,[[_e]])}onReady(){s.touchDependencies(this._injector,[[Pe],[ye]])}onRendered(){s.touchDependencies(this._injector,[[ke],[P.ConditionalFormattingClearController],[Ie],[De],[se],[Le],[Se],[Te],[je]])}_initCommand(){[Fe,Be,He,We,qe,Ge,Ze,ze,Ye,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},Nr(P.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Nr(P.UniverSheetsConditionalFormattingUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),P.UniverSheetsConditionalFormattingUIPlugin=At([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin),tr(1,s.Inject(s.Injector)),tr(2,s.Inject(s.ICommandService)),tr(3,s.IConfigService)],P.UniverSheetsConditionalFormattingUIPlugin),P.AddAverageCfCommand=Fe,P.AddColorScaleConditionalRuleCommand=Be,P.AddDataBarConditionalRuleCommand=He,P.AddDuplicateValuesCfCommand=We,P.AddNumberCfCommand=qe,P.AddRankCfCommand=Ge,P.AddTextCfCommand=Ze,P.AddTimePeriodCfCommand=ze,P.AddUniqueValuesCfCommand=Ye,P.OpenConditionalFormattingOperator=Ce,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(D,s){typeof exports=="object"&&typeof module<"u"?s(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-conditional-formatting","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/engine-render","rxjs/operators"],s):(D=typeof globalThis<"u"?globalThis:D||self,s(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheets,D.UniverSheetsConditionalFormatting,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverEngineRender,D.rxjs.operators))})(this,(function(D,s,U,r,j,c,C,O,$e,ve,W,X,nr,pe){"use strict";var Bt=Object.defineProperty;var Ht=(D,s,U)=>s in D?Bt(D,s,{enumerable:!0,configurable:!0,writable:!0,value:U}):D[s]=U;var ee=(D,s,U)=>Ht(D,typeof s!="symbol"?s+"":s,U);const Fe={type:s.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u}=e,i=n.get(r.ConditionalFormattingRuleModel),p=n.get(s.ICommandService),o=n.get(s.IUniverInstanceService),f=U.getSheetCommandTarget(o);if(!f)return!1;const{unitId:d,subUnitId:v}=f,h=i.createCfId(d,v),b={ranges:t,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:l}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:b})}},Be={type:s.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,config:l,stopIfTrue:a}=e,u=n.get(r.ConditionalFormattingRuleModel),i=n.get(s.ICommandService),p=n.get(s.IUniverInstanceService),o=U.getSheetCommandTarget(p);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=u.createCfId(f,d),h={ranges:t,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.colorScale,config:l}};return i.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:h})}},He={type:s.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,min:l,max:a,nativeColor:u,positiveColor:i,isGradient:p,stopIfTrue:o,isShowValue:f}=e,d=n.get(r.ConditionalFormattingRuleModel),v=n.get(s.IUniverInstanceService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:b,subUnitId:S}=h,m=n.get(s.ICommandService),E=d.createCfId(b,S),_={ranges:t,cfId:E,stopIfTrue:!!o,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:l,max:a,nativeColor:u,positiveColor:i,isGradient:p}}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:_})}},We={type:s.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a}=e,u=n.get(r.ConditionalFormattingRuleModel),i=n.get(s.ICommandService),p=n.get(s.IUniverInstanceService),o=U.getSheetCommandTarget(p);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=u.createCfId(f,d),h={ranges:t,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:l}};return i.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:h})}},qe={type:s.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u,value:i}=e,p=n.get(r.ConditionalFormattingRuleModel),o=n.get(s.ICommandService),f=n.get(s.IUniverInstanceService),d=U.getSheetCommandTarget(f);if(!d)return!1;const{unitId:v,subUnitId:h}=d,b=p.createCfId(v,h);let S;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const m=i;if(m.length!==2||!Array.isArray(m))return!1;S={ranges:t,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:l,value:m}}}else{const m=i;if(typeof m!="number")return!1;S={ranges:t,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:l,value:m}}}return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:v,subUnitId:h,rule:S})}},Ge={type:s.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,isPercent:u,isBottom:i,value:p}=e,o=n.get(r.ConditionalFormattingRuleModel),f=n.get(s.IUniverInstanceService),d=n.get(s.ICommandService),v=U.getSheetCommandTarget(f);if(!v)return!1;const{unitId:h,subUnitId:b}=v,S=o.createCfId(h,b),m={ranges:t,cfId:S,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:i,style:l,value:p}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:b,rule:m})}},Ze={type:s.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u,value:i}=e,p=n.get(r.ConditionalFormattingRuleModel),o=n.get(s.IUniverInstanceService),f=U.getSheetCommandTarget(o);if(!f)return!1;const{unitId:d,subUnitId:v}=f,h=n.get(s.ICommandService),b=p.createCfId(d,v),S={ranges:t,cfId:b,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:l,value:i}};return h.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:S})}},ze={type:s.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a,operator:u}=e,i=n.get(r.ConditionalFormattingRuleModel),p=n.get(s.IUniverInstanceService),o=n.get(s.ICommandService),f=U.getSheetCommandTarget(p);if(!f)return!1;const{unitId:d,subUnitId:v}=f,h=i.createCfId(d,v),b={ranges:t,cfId:h,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:l}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:v,rule:b})}},Ye={type:s.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:t,style:l,stopIfTrue:a}=e,u=n.get(r.ConditionalFormattingRuleModel),i=n.get(s.IUniverInstanceService),p=n.get(s.ICommandService),o=U.getSheetCommandTarget(i);if(!o)return!1;const{unitId:f,subUnitId:d}=o,v=u.createCfId(f,d),h={ranges:t,cfId:v,stopIfTrue:!!a,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:l}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:d,rule:h})}};function K({ref:n,...e}){const{icon:t,id:l,className:a,extend:u,...i}=e,p=`univerjs-icon univerjs-icon-${l} ${a||""}`.trim(),o=C.useRef(`_${Mr()}`);return lr(t,`${l}`,{defIds:t.defIds,idSuffix:o.current},{ref:n,className:p,...i},u)}function lr(n,e,t,l,a){return C.createElement(n.tag,{key:e,...Nr(n,t,a),...l},(Rr(n,t).children||[]).map((u,i)=>lr(u,`${e}-${n.tag}-${i}`,t,void 0,a)))}function Nr(n,e,t){const l={...n.attrs};t!=null&&t.colorChannel1&&l.fill==="colorChannel1"&&(l.fill=t.colorChannel1),n.tag==="mask"&&l.id&&(l.id=l.id+e.idSuffix),Object.entries(l).forEach(([u,i])=>{u==="mask"&&typeof i=="string"&&(l[u]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:a}=e;return!a||a.length===0||(n.tag==="use"&&l["xlink:href"]&&(l["xlink:href"]=l["xlink:href"]+e.idSuffix),Object.entries(l).forEach(([u,i])=>{typeof i=="string"&&(l[u]=i.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),l}function Rr(n,e){var l;const{defIds:t}=e;return!t||t.length===0?n:n.tag==="defs"&&((l=n.children)!=null&&l.length)?{...n,children:n.children.map(a=>typeof a.attrs.id=="string"&&t&&t.includes(a.attrs.id)?{...a,attrs:{...a.attrs,id:a.attrs.id+e.idSuffix}}:a)}:n}function Mr(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";const Vr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ar=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"bold-icon",ref:t,icon:Vr}))});ar.displayName="BoldIcon";const Or={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ee=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"delete-icon",ref:t,icon:Or}))});Ee.displayName="DeleteIcon";const Ur={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z"}}]},ur=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"increase-icon",ref:t,icon:Ur}))});ur.displayName="IncreaseIcon";const kr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},sr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"italic-icon",ref:t,icon:kr}))});sr.displayName="ItalicIcon";const Pr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ke=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Pr}))});Ke.displayName="MoreDownIcon";const Dr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},ir=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Dr}))});ir.displayName="SequenceIcon";const Lr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},cr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"strikethrough-icon",ref:t,icon:Lr}))});cr.displayName="StrikethroughIcon";const jr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},or=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"underline-icon",ref:t,icon:jr}))});or.displayName="UnderlineIcon";const Ar={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},dr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"font-color-double-icon",ref:t,icon:Ar}))});dr.displayName="FontColorDoubleIcon";const $r={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},vr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"paint-bucket-double-icon",ref:t,icon:$r}))});vr.displayName="PaintBucketDoubleIcon";const Fr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fe=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"slash-double-icon",ref:t,icon:Fr}))});fe.displayName="SlashDoubleIcon";const re=n=>{const{color:e,onChange:t,disable:l=!1,Icon:a=vr,className:u}=n,i=C.useMemo(()=>new s.ColorKit(e),[e]),p=()=>{const o={className:O.clsx("univer-fill-primary-600",l&&u),extend:{colorChannel1:i.isValid?e:""}};return c.jsx(a,{...o})};return l?p():c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(O.ColorPicker,{value:e,onChange:t})}),children:c.jsx("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",u),children:p()})})},ae=n=>{var u,i,p,o,f;const e=n.rule;if(!e)return null;const t=C.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const d=e.config.map((b,S)=>({color:new s.ColorKit(b.color),value:S})),v=d.length-1;return new Array(5).fill("").map((b,S,m)=>S*v/(m.length-1)).map(b=>r.getColorScaleFromValue(d,b))}return null},[e]),l=C.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(d=>{const v=r.iconMap[d.iconType];return v&&v[Number(d.iconId)]})},[e]),a="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:d}=e.config,v=d?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,h=d?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return c.jsxs("div",{className:a,children:[c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:h,borderColor:(u=e.config.nativeColor)!=null?u:r.defaultDataBarNativeColor}}),c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:v,borderColor:(i=e.config.positiveColor)!=null?i:r.defaultDataBarPositiveColor}})]})}case r.CFRuleType.colorScale:return t&&c.jsx("div",{className:a,children:t.map((d,v)=>c.jsx("div",{className:"univer-h-full",style:{width:`${100/t.length}%`,background:d}},v))});case r.CFRuleType.iconSet:return l&&c.jsx("div",{className:a,children:l.map((d,v)=>d?c.jsx("img",{className:"univer-h-full",src:d,draggable:!1},v):c.jsx(fe,{},v))});case r.CFRuleType.highlightCell:{const{ul:d,st:v,it:h,bl:b,bg:S,cl:m}=e.style,E=(d==null?void 0:d.s)===s.BooleanNumber.TRUE,_=(v==null?void 0:v.s)===s.BooleanNumber.TRUE,N=h===s.BooleanNumber.TRUE,M=b===s.BooleanNumber.TRUE,R=(p=S==null?void 0:S.rgb)!=null?p:r.DEFAULT_BG_COLOR,g=(o=m==null?void 0:m.rgb)!=null?o:r.DEFAULT_FONT_COLOR,T={textDecoration:(f=`${E?"underline":""} ${_?"line-through":""}`.replace(/^ /,""))!=null?f:void 0,backgroundColor:R,color:g};return c.jsx("div",{className:O.clsx(a,{"univer-font-bold":M,"univer-italic":N}),style:T,children:"123"})}}},he=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),Xe=n=>{var S;const{type:e,className:t,onChange:l,id:a,value:u}=n,i=j.useDependency(s.IUniverInstanceService),p=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(S=i.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),f=C.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),d=C.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),v=C.useRef(null),[h,b]=C.useState(!1);return j.useSidebarClick(m=>{var _;((_=v.current)==null?void 0:_.isClickOutSide(m))&&b(!1)}),e===r.CFValueType.formula?c.jsx("div",{className:"univer-ml-1 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:f,unitId:p,subUnitId:o,isFocus:h,onChange:(m="")=>{l(m||"")},onFocus:()=>b(!0)})}):c.jsx(O.InputNumber,{className:t,value:Number(n.value)||0,onChange:m=>n.onChange(m||0),...d})},Br=n=>{var L;const{interceptorManager:e}=n,t=j.useDependency(s.LocaleService),l=((L=n.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?n.rule:void 0,a=[te(r.CFValueType.num,t),te(r.CFValueType.percent,t),te(r.CFValueType.percentile,t),te(r.CFValueType.formula,t)],u=[te(r.CFValueType.min,t),...a],i=[te("none",t),...a],p=[te(r.CFValueType.max,t),...a],[o,f]=C.useState(()=>{var x;const y=r.CFValueType.min;return l&&((x=l.config[0])==null?void 0:x.value.type)||y}),[d,v]=C.useState(()=>{var x;const y="none";return!l||l.config.length!==3?y:((x=l.config[1])==null?void 0:x.value.type)||y}),[h,b]=C.useState(()=>{var x;const y=r.CFValueType.max;return l&&((x=l.config[l.config.length-1])==null?void 0:x.value.type)||y}),[S,m]=C.useState(()=>{if(!l)return 10;const x=l.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[E,_]=C.useState(()=>{var $;if(!l||l.config.length!==3)return 50;const x=($=l.config[1])==null?void 0:$.value.value;return x===void 0?50:x}),[N,M]=C.useState(()=>{var $;if(!l)return 90;const x=($=l.config[l.config.length-1])==null?void 0:$.value.value;return x===void 0?90:x}),[R,g]=C.useState(()=>{var x;const y="#d0d9fb";return l&&((x=l.config[0])==null?void 0:x.color)||y}),[T,w]=C.useState(()=>{var x;const y="#7790f3";return!l||l.config.length!==3?y:((x=l.config[1])==null?void 0:x.color)||y}),[I,k]=C.useState(()=>{var x;const y="#2e55ef";return l&&((x=l.config[l.config.length-1])==null?void 0:x.color)||y}),V=C.useMemo(()=>y=>{const{minType:x,medianType:$,maxType:G,minValue:J,medianValue:Q,maxValue:oe,minColor:de,medianColor:A,maxColor:F}=y,H=[];return H.push({color:de,value:{type:x,value:J}}),$!=="none"&&H.push({color:A,value:{type:$,value:Q}}),H.push({color:F,value:{type:G,value:oe}}),{config:H.map((Z,z)=>({...Z,index:z})),type:r.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:o,medianType:d,maxType:h,minValue:S,medianValue:E,maxValue:N,minColor:R,medianColor:T,maxColor:I})}}),[V,o,d,h,S,E,N,R,T,I,e]);const P=y=>{n.onChange(V(y))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:V({minType:o,medianType:d,maxType:h,minValue:S,medianValue:E,maxValue:N,minColor:R,medianColor:T,maxColor:I})})}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:o,onChange:y=>{f(y);const x=r.createDefaultValueByValueType(y,10);m(x),P({minType:y,medianType:d,maxType:h,minValue:x,medianValue:E,maxValue:N,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Xe,{id:"min",className:"univer-ml-1",value:S,type:o,onChange:y=>{m(y),P({minType:o,medianType:d,maxType:h,minValue:y,medianValue:E,maxValue:N,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(re,{className:"univer-ml-1",color:R,onChange:y=>{g(y),P({minType:o,medianType:d,maxType:h,minValue:S,medianValue:E,maxValue:N,minColor:y,medianColor:T,maxColor:I})}})]}),c.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:t.t("sheet.cf.panel.medianValue")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:i,value:d,onChange:y=>{v(y);const x=r.createDefaultValueByValueType(y,50);_(x),P({minType:o,medianType:y,maxType:h,minValue:S,medianValue:x,maxValue:N,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Xe,{id:"median",className:"univer-ml-1",value:E,type:d,onChange:y=>{_(y),P({minType:o,medianType:d,maxType:h,minValue:S,medianValue:y,maxValue:N,minColor:R,medianColor:T,maxColor:I})}}),d!=="none"&&c.jsx(re,{className:"univer-ml-1",color:T,onChange:y=>{w(y),P({minType:o,medianType:d,maxType:h,minValue:S,medianValue:E,maxValue:N,minColor:R,medianColor:y,maxColor:I})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:p,value:h,onChange:y=>{b(y);const x=r.createDefaultValueByValueType(y,90);M(x),P({minType:o,medianType:d,maxType:y,minValue:S,medianValue:E,maxValue:x,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(Xe,{id:"max",className:"univer-ml-1",value:N,type:h,onChange:y=>{M(y),P({minType:o,medianType:d,maxType:h,minValue:S,medianValue:E,maxValue:y,minColor:R,medianColor:T,maxColor:I})}}),c.jsx(re,{className:"univer-ml-1",color:I,onChange:y=>{k(y),P({minType:o,medianType:d,maxType:h,minValue:S,medianValue:E,maxValue:N,minColor:R,medianColor:T,maxColor:y})}})]})]})},ue=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),pr=n=>{var m;const{onChange:e,className:t,value:l,type:a,id:u,disabled:i=!1}=n,p=j.useDependency(s.IUniverInstanceService),o=p.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),f=(m=p.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),d=C.useRef(null),[v,h]=C.useState(!1);j.useSidebarClick(E=>{var N;((N=d.current)==null?void 0:N.isClickOutSide(E))&&h(!1)});const b=C.useRef(l),S=C.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(a)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[a]);if(a===r.CFValueType.formula){const E=String(b.current).startsWith("=")?String(b.current)||"":"=";return c.jsx("div",{className:"univer-ml-3 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:d,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:E,unitId:o,subUnitId:f,isFocus:v,onChange:(_="")=>{e(_||"")},onFocus:()=>h(!0)})})}return c.jsx(O.InputNumber,{className:t,value:Number(l)||0,disabled:i,onChange:E=>{e(E||0)},...S})},Hr=n=>{var L;const{interceptorManager:e}=n,t=j.useDependency(s.LocaleService),l=((L=n.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?n.rule:void 0,[a,u]=C.useState(()=>{var x;return l&&(x=l.config)!=null&&x.isGradient?"1":"0"}),[i,p]=C.useState(()=>{var y;return l&&((y=l.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[o,f]=C.useState(()=>{var y;return l&&((y=l.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),d=[ue(r.CFValueType.num,t),ue(r.CFValueType.percent,t),ue(r.CFValueType.percentile,t),ue(r.CFValueType.formula,t)],v=[ue(r.CFValueType.min,t),...d],h=[ue(r.CFValueType.max,t),...d],[b,S]=C.useState(()=>{var x;const y=v[0].value;return l&&((x=l.config)==null?void 0:x.min.type)||y}),[m,E]=C.useState(()=>{var x;const y=h[0].value;return l&&((x=l.config)==null?void 0:x.max.type)||y}),[_,N]=C.useState(()=>{var $;if(!l)return 0;const x=(($=l.config)==null?void 0:$.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[M,R]=C.useState(()=>{var $;if(!l)return 100;const x=(($=l.config)==null?void 0:$.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[g,T]=C.useState(()=>l?l.isShowValue===void 0?!0:!!l.isShowValue:!0),w=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return w({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}}),[a,_,b,M,m,i,o,e,g]);const I=y=>{n.onChange(w(y))},k=y=>{p(y),I({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:y,nativeColor:o,isShowValue:g})},V=y=>{f(y),I({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:y,isShowValue:g})},P=y=>d.map(x=>x.value).includes(y);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:w({isGradient:a,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})})}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.fillType")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs(O.RadioGroup,{value:a,onChange:y=>{u(y),I({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})},children:[c.jsx(O.Radio,{value:"0",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.pureColor")})}),c.jsx(O.Radio,{value:"1",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.gradient")})})]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!g,onChange:y=>{T(!y),I({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:!y})}}),t.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.colorSet")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.native")}),c.jsx(re,{color:o,onChange:V})]}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.positive")}),c.jsx(re,{color:i,onChange:k})]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:v,value:b,onChange:y=>{S(y);const x=r.createDefaultValueByValueType(y,10);N(x),I({isGradient:a,minValue:x,minValueType:y,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}}),c.jsx(pr,{id:"min",className:"univer-ml-3",disabled:!P(b),type:b,value:_,onChange:y=>{N(y||0),I({isGradient:a,minValue:y||0,minValueType:b,maxValue:M,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:m,onChange:y=>{E(y);const x=r.createDefaultValueByValueType(y,90);R(x),I({isGradient:a,minValue:_,minValueType:b,maxValue:x,maxValueType:y,positiveColor:i,nativeColor:o,isShowValue:g})}}),c.jsx(pr,{className:"univer-ml-3",disabled:!P(m),id:"max",type:m,value:M,onChange:y=>{R(y||0),I({isGradient:a,minValue:_,minValueType:b,maxValue:y||0,maxValueType:m,positiveColor:i,nativeColor:o,isShowValue:g})}})]})]})]})},Ne=n=>[s.BooleanNumber.FALSE,void 0].includes(n)?s.BooleanNumber.TRUE:s.BooleanNumber.FALSE,Re=n=>n!==s.BooleanNumber.FALSE,Je=n=>{const{style:e,onChange:t,className:l}=n,[a,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[i,p]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[o,f]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[d,v]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[h,b]=C.useState(()=>{var N;const _="#2f56ef";return(N=e==null?void 0:e.cl)!=null&&N.rgb?e.cl.rgb:_}),[S,m]=C.useState(()=>{var N;const _="#e8ecfc";return(N=e==null?void 0:e.bg)!=null&&N.rgb?e.bg.rgb:_});C.useEffect(()=>{const _={bl:a,it:i};h!==void 0&&(_.cl={rgb:h}),S!==void 0&&(_.bg={rgb:S}),d!==void 0&&(_.st={s:d}),o!==void 0&&(_.ul={s:o}),t(r.removeUndefinedAttr(_))},[a,i,o,d,h,S]);const E="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return c.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",l),children:[c.jsx("div",{className:O.clsx(E,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(a||s.BooleanNumber.FALSE)}),onClick:()=>u(Ne(a)),children:c.jsx(ar,{})}),c.jsx("div",{className:O.clsx(E,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(i||s.BooleanNumber.FALSE)}),onClick:()=>p(Ne(i)),children:c.jsx(sr,{})}),c.jsx("div",{className:O.clsx(E,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(o||s.BooleanNumber.FALSE)}),onClick:()=>f(Ne(o)),children:c.jsx(or,{})}),c.jsx("div",{className:O.clsx(E,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(d||s.BooleanNumber.FALSE)}),onClick:()=>v(Ne(d)),children:c.jsx(cr,{})}),c.jsx(re,{color:h,onChange:b,Icon:dr}),c.jsx(re,{color:S,onChange:m})]})},Wr=n=>{var R;const{onChange:e,interceptorManager:t}=n,l=j.useDependency(s.LocaleService),u=j.useDependency(s.IUniverInstanceService).getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),i=u.getActiveSheet(),p=((R=n.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?n.rule:void 0,o=C.useRef(null),[f,d]=C.useState(!1),v=C.useRef(null),[h,b]=C.useState({}),[S,m]=C.useState(()=>(p==null?void 0:p.subType)===r.CFSubRuleType.formula?p.value:"="),[E,_]=C.useState(void 0),N=g=>({style:g.style,value:S,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return N({style:h})}}),[h,S,t]),C.useEffect(()=>t.intercept(t.getInterceptPoints().beforeSubmit,{handler:(T,w,I)=>E||S.length===1||!S.startsWith("=")?(_(l.t("sheet.cf.errorMessage.formulaError")),!1):I(T)}),[E,S]);const M=g=>{e(N(g))};return j.useSidebarClick(g=>{var w;((w=v.current)==null?void 0:w.isClickOutSide(g))&&d(!1)}),c.jsxs("div",{ref:o,children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(ve.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),errorText:E,isFocus:f,initValue:S,unitId:u.getUnitId(),subUnitId:i==null?void 0:i.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{m(g),M({style:h})},onVerify:(g,T)=>{!g||T.length===1?_(l.t("sheet.cf.errorMessage.formulaError")):_(void 0)}})}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:N({style:h})})}),c.jsx(Je,{style:p==null?void 0:p.style,className:"univer-mt-3",onChange:g=>{b(g),M({style:g})}})]})},Me=n=>c.jsxs("div",{className:"univer-relative",children:[c.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:n.errorText}),n.children]}),B=(n,e)=>({label:e.t(`sheet.cf.operator.${n}`),value:n}),qr=n=>{const{type:e,operator:t,onChange:l,value:a,interceptorManager:u}=n,i=j.useDependency(s.LocaleService),[p,o]=C.useState(()=>typeof a=="number"?a:0),[f,d]=C.useState(""),[v,h]=C.useState(()=>typeof a=="string"?a:""),[b,S]=C.useState(""),[m,E]=C.useState(()=>Array.isArray(a)?a[0]===void 0?0:a[0]:0),[_,N]=C.useState(""),[M,R]=C.useState(()=>Array.isArray(a)?a[1]===void 0?100:a[1]:100),[g,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)&&l(v);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)&&l(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)&&l([m,M]);break}}},[e]),C.useEffect(()=>{const w=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(I,k,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(t))return v?V(I):(S(i.t("sheet.cf.errorMessage.notBlank")),!1)}return V(I)}});return()=>{w()}},[e,p,v,t]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)){const w=I=>{h(I),l(I)};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:b,children:c.jsx(O.Input,{value:v,onChange:I=>{S(""),w(I)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)){const w=I=>{o(I||0),l(I||0),d("")};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:f,children:c.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:p,onChange:w})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)){const w=k=>{E(k||0),l([k||0,M]),N("")},I=k=>{R(k||0),l([m,k||0]),T("")};return c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(Me,{errorText:_,children:c.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:w})}),c.jsx(Me,{errorText:g,children:c.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:M,onChange:I})})]})}}}return null},fr=(n,e)=>{switch(n){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},hr=n=>{var R;const{interceptorManager:e,onChange:t}=n,l=j.useDependency(s.LocaleService),a=((R=n.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?n.rule:void 0,[u,i]=C.useState(()=>{const g=r.CFSubRuleType.text;return a&&a.subType||g}),p=[{value:r.CFSubRuleType.text,label:l.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:l.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:l.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:l.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:l.t("sheet.cf.subRuleType.uniqueValues")}],o=C.useMemo(()=>fr(u,l),[u]),[f,d]=C.useState(()=>{const g=o?o[0].value:void 0;return a&&a.operator||g}),[v,h]=C.useState(()=>{var w;return a?(w=a.value)!=null?w:r.createDefaultValue(a.subType,a.operator):""}),[b,S]=C.useState({}),m=C.useMemo(()=>g=>{var T,w,I,k,V,P,L,y,x,$,G,J,Q,oe,de;switch(g.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(T=g.subType)!=null?T:u,operator:(w=g.operator)!=null?w:f,style:(I=g.style)!=null?I:b,value:(k=g.value)!=null?k:v};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(f))return{type:r.CFRuleType.highlightCell,subType:(V=g.subType)!=null?V:u,operator:(P=g.operator)!=null?P:f,style:(L=g.style)!=null?L:b,value:(y=g.value)!=null?y:v};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(f))return{type:r.CFRuleType.highlightCell,subType:(x=g.subType)!=null?x:u,operator:($=g.operator)!=null?$:f,style:(G=g.style)!=null?G:b,value:(J=g.value)!=null?J:v};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=g.subType)!=null?Q:u,operator:(oe=g.operator)!=null?oe:f,style:(de=g.style)!=null?de:b}},[u,f,v,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return m({})}}),[m,e]),C.useEffect(()=>{p.some(g=>g.value===u)||i(p[0].value)},[p]);const E=g=>{const T=g,w=fr(T,l),I=w&&w[0].value;i(T),d(I),I&&h(r.createDefaultValue(T,I)),t(m({subType:T,operator:I}))},_=g=>{const T=g;d(T),t(m({operator:T}))},N=g=>{h(g),t(m({value:g}))},M=C.useMemo(()=>`${u}_${f}_${Math.random()}`,[u,f]);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),c.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:E,value:u,options:p}),(o==null?void 0:o.length)&&c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:f||"",options:o})]}),c.jsx(qr,{value:v,interceptorManager:e,type:u,operator:f,rule:a,onChange:N},M),c.jsx("div",{className:he,children:c.jsx(ae,{rule:m({})})}),c.jsx(Je,{style:a==null?void 0:a.style,className:"univer-ml-1",onChange:g=>{S(g),t(m({style:g}))}})]})},gr=(n,e)=>(r.iconMap[n]||[])[Number(e)]||"",Gr=n=>{var d;const{error:e,type:t,onChange:l}=n,a=j.useDependency(s.IUniverInstanceService),u=a.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),i=(d=a.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),p=C.useRef(null),[o,f]=C.useState(!1);return j.useSidebarClick(v=>{var b;((b=p.current)==null?void 0:b.isClickOutSide(v))&&f(!1)}),c.jsx("div",{className:"univer-relative",children:t!==r.CFValueType.formula?c.jsxs(c.Fragment,{children:[c.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(n.value)||0,onChange:v=>l(v!=null?v:0)}),e&&c.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):c.jsx("div",{className:"univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:p,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:String(n.value),unitId:u,subUnitId:i,isFocus:o,onChange:(v="")=>{l(v||"")},onFocus:()=>f(!0)})})})},yr=(n,e,t)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(t.length-1-e)*10},iconType:n,iconId:String(e)}),Zr=C.forwardRef((n,e)=>{const{onClick:t}=n,l=j.useDependency(s.LocaleService),a=u=>{t(u)};return c.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,i)=>c.jsxs("div",{className:"univer-mb-3",children:[c.jsx("div",{className:"univer-mb-1 univer-text-sm",children:l.t(u.title)}),c.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(p=>c.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{a(p.name)},children:c.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:p.list.map((o,f)=>c.jsx("img",{className:"univer-size-5",src:o,draggable:!1},f))})},p.name))})]},i))})}),zr=n=>{const{onClick:e}=n,t=C.useMemo(()=>{const a=[];for(const u in r.iconMap){const i=r.iconMap[u],p=u;i.forEach((o,f)=>{a.push({iconType:p,base64:o,iconId:String(f)})})}return a},[]),l=a=>{e(a.iconType,a.iconId)};return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>l({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[c.jsx(fe,{className:"univer-size-5"}),c.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),c.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:t.map(a=>c.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:c.jsx("img",{className:"univer-size-5",src:a.base64,draggable:!1,onClick:()=>l(a)})},`${a.iconType}_${a.iconId}`))})]})},Yr=n=>{const{onChange:e,configList:t,errorMap:l={}}=n,a=j.useDependency(s.LocaleService),u=[{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:a.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],i=[{label:a.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:a.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:a.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(v,h)=>{e([String(h),"value","value"],v)},o=(v,h)=>{e([String(h),"operator"],v);const b=r.createDefaultValue(r.CFSubRuleType.number,v);p(b,h)},f=(v,h)=>{e([String(h),"value","type"],v);const b=t[h],S=r.createDefaultValue(r.CFSubRuleType.number,b.operator);p(S,h)};return C.useMemo(()=>t.map((v,h)=>{const b=l[h],S=gr(v.iconType,v.iconId),m=h===t.length-1,E=h===0,_=t[h-1],N=(_==null?void 0:_.value.type)===r.CFValueType.formula?a.t("sheet.cf.valueType.formula"):_==null?void 0:_.value.value,M=(R,g)=>{const T={...v,iconId:g,iconType:R};e([String(h)],T)};return c.jsxs("div",{className:h?"univer-mt-6":"univer-mt-3",children:[c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsxs("div",{className:"univer-w-[45%]",children:[a.t("sheet.cf.iconSet.icon"),h+1]}),c.jsx("div",{className:"univer-w-[45%]",children:c.jsxs(c.Fragment,{children:[!E&&!m&&a.t("sheet.cf.iconSet.rule"),!E&&!m&&c.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),N,m?"":` ${a.t("sheet.cf.iconSet.and")} `]})]})})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx("div",{className:"univer-flex univer-items-center",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(zr,{onClick:M,iconId:v.iconId,iconType:v.iconType})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",O.borderClassName),children:[S?c.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):c.jsx(fe,{className:"univer-size-4"}),c.jsx(Ke,{})]})})}),m?c.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[a.t("sheet.cf.iconSet.rule"),c.jsxs("span",{className:"univer-font-medium",children:[a.t("sheet.cf.iconSet.when"),a.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),N,m?"":` ${a.t("sheet.cf.iconSet.and")} `]})]}):c.jsx(O.Select,{options:u,value:v.operator,onChange:R=>{o(R,h)}})]}),m?c.jsx("div",{}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsx("div",{children:a.t("sheet.cf.iconSet.type")}),c.jsx("div",{children:a.t("sheet.cf.iconSet.value")})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx(O.Select,{options:i,value:v.value.type,onChange:R=>{f(R,h)}}),c.jsx(Gr,{id:h,type:v.value.type,error:b,value:v.value.value||"",onChange:R=>{p(R,h)}})]})]})]},h)}),[t,l])},Kr=n=>{var R;const{interceptorManager:e}=n,t=((R=n.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?n.rule:void 0,l=j.useDependency(s.LocaleService),[a,u]=C.useState({}),[i,p]=C.useState(()=>{const g=Object.keys(r.iconMap)[0];if(t&&t.config.length){const T=t.config[0].iconType;if(!t.config.some(I=>I.iconType!==T))return T}return g}),[o,f]=C.useState(()=>{if(t&&t.config.length)return s.Tools.deepClone(t==null?void 0:t.config);const g=r.iconMap[i]||[];return new Array(g.length).fill("").map((T,w,I)=>w===I.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:i,iconId:String(w)}:yr(i,w,I))}),[d,v]=C.useState(()=>t?!!t.isShowValue:!0),h=C.useMemo(()=>{const g=o.map(T=>gr(T.iconType,T.iconId));return c.jsx("div",{className:"univer-flex univer-items-center",children:g.map((T,w)=>T?c.jsx("img",{className:"univer-size-5",src:T},w):c.jsx(fe,{className:"univer-size-5"},w))})},[o]),b=g=>{if(g.reduce((w,I,k)=>w.preType&&!w.result||g.length-1===k?w:I.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:w.preType?{result:w.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(g[0].value.type)){const w={};return g.forEach((I,k,V)=>{if(k-1<0||k===V.length-1)return;const L=g[k-1],y=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:y,value:L.value.value},I.value.value)||(w[k]=`${l.t(`sheet.cf.form.${y}`,String(L.value.value))} `)}),w}return{}},S=(g,T)=>{s.get(o,g)!==T&&(s.set(o,g,T),f([...o]),u(b(o)))},m=g=>{p(g);const T=r.iconMap[g]||[],w=new Array(T.length).fill("").map((I,k,V)=>yr(g,k,V));f(w),u(b(w))};C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:d,config:o}}});return()=>{g()}},[d,o,e]),C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(a).length===0}});return()=>{g()}},[d,o,e,a]);const E=()=>{const g=o.map(T=>({...T}));o.forEach((T,w)=>{const I=o.length-1-w,k=g[I];T.iconId=k.iconId,T.iconType=k.iconType}),f([...o])},_=j.useDependency(j.ILayoutService),[N,M]=C.useState();return j.useScrollYOverContainer(N,_.rootContainerElement),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:l.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(Zr,{ref:g=>{!N&&g&&M(g)},iconType:i,onClick:m})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[h,c.jsx(Ke,{})]})})}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{onChange:E}),l.t("sheet.cf.iconSet.reverseIconOrder")]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!d,onChange:g=>{v(!g)}}),l.t("sheet.cf.iconSet.onlyShowIcon")]})]}),c.jsx(Yr,{errorMap:a,onChange:S,configList:o})]})},Xr=n=>{var E;const{onChange:e,interceptorManager:t}=n,l=j.useDependency(s.LocaleService),a=((E=n.rule)==null?void 0:E.type)===r.CFRuleType.highlightCell?n.rule:void 0,u=[{label:l.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:l.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:l.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:l.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[i,p]=C.useState(()=>{const _=u[0].value,N=a==null?void 0:a.type;if(!a)return _;switch(N){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(a.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(a.operator)?"lessThanAverage":_;case r.CFSubRuleType.rank:return a.isBottom?"isBottom":"isNotBottom"}}return _}),[o,f]=C.useState(()=>{const N=a==null?void 0:a.type;if(!a)return 10;switch(N){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.value||10}}return 10}),[d,v]=C.useState(()=>{const N=a==null?void 0:a.type;if(!a)return!1;switch(N){case r.CFRuleType.highlightCell:switch(a.subType){case r.CFSubRuleType.rank:return a.isPercent||!1}}return!1}),[h,b]=C.useState({}),S=_=>{const{type:N,isPercent:M,value:R,style:g}=_;if(N==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!1,value:R,style:g};if(N==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!0,value:R,style:g};if(N==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:g};if(N==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:g}};C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return S({type:i,isPercent:d,value:o,style:h})}}),[i,d,o,h,t]);const m=_=>{e(S(_))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:l.t("sheet.cf.panel.styleRule")}),c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:i,options:u,onChange:_=>{p(_),m({type:_,isPercent:d,value:o,style:h})}}),["isNotBottom","isBottom"].includes(i)&&c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.InputNumber,{min:1,max:1e3,value:o,onChange:_=>{const N=_||0;f(N),m({type:i,isPercent:d,value:N,style:h})}}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:d,onChange:_=>{v(!!_),m({type:i,isPercent:!!_,value:o,style:h})}}),l.t("sheet.cf.valueType.percent")]})]}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:S({type:i,isPercent:d,value:o,style:h})})}),c.jsx(Je,{style:a==null?void 0:a.style,className:"univer-mt-3",onChange:_=>{b(_),m({type:i,isPercent:d,value:o,style:_})}})]})},Jr=s.createInterceptorKey("beforeSubmit"),Qr=s.createInterceptorKey("submit"),Cr=n=>n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),mr=n=>{var e;return(e=n.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},et=n=>{var w,I,k;const e=j.useDependency(s.LocaleService),t=j.useDependency(s.ICommandService),l=j.useDependency(s.IUniverInstanceService),a=j.useDependency(r.ConditionalFormattingRuleModel),u=j.useDependency(U.SheetsSelectionsService),i=Cr(l),p=mr(l),[o,f]=C.useState(void 0),d=C.useRef((I=(w=n.rule)==null?void 0:w.ranges)!=null?I:[]),v=C.useMemo(()=>{var P,L,y;let V=(P=n.rule)==null?void 0:P.ranges;return V!=null&&V.length||(V=(y=(L=u.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?y:[]),d.current=V,V!=null&&V.length?V.map(x=>{const $=$e.serializeRange(x);return $==="NaN"?"":$}).filter(x=>!!x).join(","):""},[n.rule]),h=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var L,y;const V=(L=n.rule)==null?void 0:L.rule.type,P=h[0].value;if(!V)return P;switch(V){case r.CFRuleType.highlightCell:{switch((y=n.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return P}),m=C.useRef(void 0),E=C.useMemo(()=>new s.InterceptorManager({beforeSubmit:Jr,submit:Qr}),[]),_=C.useMemo(()=>{switch(b){case"1":return hr;case"2":return Xr;case"3":return Hr;case"4":return Br;case"5":return Wr;case"6":return Kr;default:return hr}},[b]);C.useEffect(()=>{const V=t.onCommandExecuted(P=>{if(P.id===U.RemoveSheetMutation.id){const L=P.params;L.subUnitId===p&&L.unitId===i&&n.onCancel()}P.id===U.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>V.dispose()},[]);const N=V=>{m.current=V},M=V=>{const P=V.split(",").filter(L=>!!L).map($e.deserializeRangeWithSheet).map(L=>L.range);d.current=P},R=()=>{if(o)return;const P=(()=>{const y=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return d.current.map(G=>U.setEndForRange(G,y.getRowCount(),y.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(E.fetchThroughInterceptors(E.getInterceptPoints().beforeSubmit)(!0,null)){const y=E.fetchThroughInterceptors(E.getInterceptPoints().submit)(null,null);if(y){const x=Cr(l),$=mr(l);if(!x||!$)throw new Error("No active sheet found");let G={};n.rule&&n.rule.cfId?(G={...n.rule,ranges:P,rule:y},t.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:$,rule:G}),n.onCancel()):(G={cfId:a.createCfId(x,$),ranges:P,rule:y,stopIfTrue:!1},t.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:$,rule:G}),n.onCancel())}}},g=()=>{n.onCancel()},T=(V,P)=>{V?P.length<1?f(e.t("sheet.cf.errorMessage.rangeError")):f(void 0):f(e.t("sheet.cf.errorMessage.rangeError"))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),c.jsxs("div",{className:"univer-mt-4",children:[c.jsx(ve.RangeSelector,{unitId:i,subUnitId:p,initialValue:v,onChange:(V,P)=>M(P),onVerify:T}),o&&c.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:o})]}),c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),c.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:b,options:h,onChange:V=>S(V)}),c.jsx(_,{interceptorManager:E,rule:(k=n.rule)==null?void 0:k.rule,onChange:N}),c.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[c.jsx(O.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),c.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var rt=Object.getOwnPropertyDescriptor,tt=(n,e,t,l)=>{for(var a=l>1?void 0:l?rt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},nt=(n,e)=>(t,l)=>e(t,l,n);let se=class extends s.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const t=/\{([^}]+)?\}/g,l=[];let a=t.exec(e);for(;a;)l.push({startIndex:a.index,key:Number(a[1]),endIndex:a.index+a[0].length-1}),a=t.exec(e);return l});this._localeService=e,this._initLocal()}tWithReactNode(e,...t){const l=this._localeService.getLocales(),a=e.split("."),u=l&&this._localeService.resolveKeyPath(l,a);if(typeof u=="string"){const i=[];return this._findReplaceIndex(u).forEach((p,o,f)=>{const d=f[o-1]||{endIndex:-1};if(d.endIndex+1<p.startIndex){const v=u.slice(d.endIndex+1,p.startIndex);v&&i.push(v)}if(t[p.key]&&i.push(t[p.key]),o===f.length-1){const v=u.slice(p.endIndex+1);v&&i.push(v)}}),i}return[]}};se=tt([nt(0,s.Inject(s.LocaleService))],se);const lt=(n,e)=>{const t=n.rule;switch(t.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(t.subType){case r.CFSubRuleType.average:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`,...Array.isArray(t.value)?t.value.map(a=>String(a)):[String(t.value||"")])}case r.CFSubRuleType.text:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`,t.value||"")}case r.CFSubRuleType.timePeriod:{const l=t.operator;return e.t(`sheet.cf.preview.describe.${l}`)}case r.CFSubRuleType.rank:return t.isPercent?t.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(t.value)):e.t("sheet.cf.preview.describe.topNPercent",String(t.value)):t.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(t.value)):e.t("sheet.cf.preview.describe.topN",String(t.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let br=0;const at=n=>{const{onClick:e}=n,t=j.useDependency(r.ConditionalFormattingRuleModel),l=j.useDependency(s.IUniverInstanceService),a=j.useDependency(U.SheetsSelectionsService),u=j.useDependency(s.ICommandService),i=j.useDependency(s.LocaleService),p=j.useDependency(s.Injector),o=j.useDependency(j.ISidebarService),f=j.useDependency(se),d=j.useObservable(()=>l.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),v=d.getUnitId(),h=d.getActiveSheet();if(!h)throw new Error("No active sheet found");const b=h.getSheetId(),[S,m]=C.useState([]),[E,_]=C.useState("2"),[N,M]=C.useState(0),[R,g]=C.useState(-1),[T,w]=C.useState(br),I=C.useRef(null),k=[{label:i.t("sheet.cf.panel.workSheet"),value:"2"},{label:i.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=t.getSubunitRules(v,b);if(!A||!A.length)return[];if(E==="1"){const F=a.getCurrentLastSelection();if(!F)return[];const H=F.range;return A.filter(Z=>Z.ranges.some(z=>s.Rectangle.intersects(z,H)))}else if(E==="2")return[...A];return[]},[P,L]=C.useState(V);W.useHighlightRange(S),C.useEffect(()=>{const A=u.onCommandExecuted(F=>{F.id===U.SetWorksheetActiveOperation.id&&M(Math.random())});return()=>A.dispose()}),C.useEffect(()=>{L(V)},[E,N,v,b]),C.useEffect(()=>{if(E==="2")return;const A=new X.Observable(F=>{const H=[U.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(Z=>{const{id:z,params:ne}=Z,le=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(z)&&ne.unitId===le&&F.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[l,E,v,b]),C.useEffect(()=>{const A=t.$ruleChange.subscribe(()=>{M(Math.random())});return()=>A.unsubscribe()},[t]),C.useEffect(()=>{const A=()=>{var Z,z;const q=Math.max(0,((z=(Z=I.current)==null?void 0:Z.getBoundingClientRect().width)!=null?z:0)-8);return br=q,q},H=new X.Observable(q=>{const Z=o.getContainer();if(Z){let z=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{z&&clearTimeout(z),z=null},le=Ae=>{Ae.propertyName==="width"&&(ne(),q.next(void 0))};return Z.addEventListener("transitionend",le),()=>{ne(),Z.removeEventListener("transitionend",le)}}}).pipe(X.debounceTime(16)).subscribe(()=>{w(A())});return()=>{H.unsubscribe()}},[]);const y=A=>{var q;const F=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!F||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:F,subUnitId:H,cfId:A.cfId})},x=(A,F)=>{g(F.y)},$=(A,F,H)=>{var Ae;g(-1);const q=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),Z=(Ae=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Ae.getSheetId();if(!q||!Z)throw new Error("No active sheet found");const z=$t=>{const Ft=P.length;return Math.min(Ft-1,Math.max(0,$t))},ne=P[z(F.y)].cfId,le=P[z(H.y)].cfId;ne!==le&&u.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:Z,start:{id:ne,type:"self"},end:{id:le,type:H.y>F.y?"after":"before"}})},G=()=>{n.onCreate()},J=()=>{E==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):E==="1"&&P.map(F=>({unitId:v,subUnitId:b,cfId:F.cfId})).forEach(F=>{u.executeCommand(r.DeleteCfCommand.id,F)})},Q=C.useMemo(()=>{const A=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return P.filter(H=>{const q=H.ranges;return U.checkRangesEditablePermission(p,A.getUnitId(),F.getSheetId(),q)})},[P]),oe=Q.map((A,F)=>({i:A.cfId,x:0,w:12,y:F,h:1,isResizable:!1})),de=C.useMemo(()=>{const A=l.getCurrentUnitOfType(s.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return P.every(H=>{const q=H.ranges;return U.checkRangesEditablePermission(p,A.getUnitId(),F.getSheetId(),q)})},[P]);return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[c.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:f.tWithReactNode("sheet.cf.panel.managerRuleSelect",c.jsx(O.Select,{className:"univer-w-36",options:k,value:E,onChange:A=>{_(A)}})).map((A,F)=>c.jsx("span",{children:A},F))}),c.jsxs("div",{className:"univer-flex univer-justify-end",children:[c.jsx(O.Tooltip,{title:i.t("sheet.cf.panel.createRule"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:c.jsx(ur,{})})}),P.length&&de?c.jsx(O.Tooltip,{title:i.t("sheet.cf.panel.clear"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:c.jsx(Ee,{className:"univer-text-red-500"})})}):c.jsx("div",{children:c.jsx(Ee,{className:"univer-text-gray-300"})})]})]}),c.jsx("div",{ref:I,children:T>0&&c.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:oe,cols:12,rowHeight:60,width:T,margin:[0,10],onDragStop:$,onDragStart:x,children:Q==null?void 0:Q.map((A,F)=>c.jsx("div",{children:c.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":R===F}),onMouseMove:()=>{A.ranges!==S&&m(A.ranges)},onMouseLeave:()=>m([]),onClick:()=>{e(A)},children:[c.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:c.jsx(ir,{})}),c.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[c.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:lt(A,i)}),c.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>$e.serializeRange(H)).join(",")})]}),c.jsx("div",{children:c.jsx(ae,{rule:A.rule})}),c.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":R===F}),onClick:H=>{H.stopPropagation(),y(A),m([])},children:c.jsx(Ee,{})})]})},`${A.cfId}`))})})]})},ut=n=>{const[e,t]=C.useState(n.rule),[l,a]=C.useState(!!n.rule),u=()=>{a(!0)},i=()=>{a(!1),t(void 0)},p=o=>{t(o),a(!0)};return c.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:l?c.jsx(et,{onCancel:i,rule:e}):c.jsx(at,{onClick:p,onCreate:u})})};var st=Object.getOwnPropertyDescriptor,it=(n,e,t,l)=>{for(var a=l>1?void 0:l?st(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},ge=(n,e)=>(t,l)=>e(t,l,n);const Ve="sheet.conditional.formatting.panel";let ye=class extends s.Disposable{constructor(e,t,l,a,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=t,this._componentManager=l,this._sidebarService=a,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{var p;i||(p=this._sidebarDisposable)==null||p.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(i=>{i.id===Ve&&(i.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const t={id:Ve,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ve,rule:e,key:s.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(t)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ve,ut))}};ye=it([ge(0,s.IUniverInstanceService),ge(1,s.Inject(s.Injector)),ge(2,s.Inject(j.ComponentManager)),ge(3,s.Inject(j.ISidebarService)),ge(4,s.Inject(s.LocaleService))],ye);var Y=(n=>(n[n.createRule=1]="createRule",n[n.viewRule=2]="viewRule",n[n.highlightCell=3]="highlightCell",n[n.rank=4]="rank",n[n.formula=5]="formula",n[n.colorScale=6]="colorScale",n[n.dataBar=7]="dataBar",n[n.icon=8]="icon",n[n.clearRangeRules=9]="clearRangeRules",n[n.clearWorkSheetRules=10]="clearWorkSheetRules",n))(Y||{});const Ce={id:"sheet.operation.open.conditional.formatting.panel",type:s.CommandType.OPERATION,handler:(n,e)=>{var p;const t=n.get(ye),l=n.get(U.SheetsSelectionsService),a=n.get(s.ICommandService),u=((p=l.getCurrentSelections())==null?void 0:p.map(o=>o.range))||[];switch(e.value){case 3:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};t.openPanel(o);break}case 5:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};t.openPanel(o);break}case 6:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};t.openPanel(o);break}case 7:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};t.openPanel(o);break}case 8:{const o={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};t.openPanel(o);break}case 2:{t.openPanel();break}case 1:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{a.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{a.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var ct=Object.getOwnPropertyDescriptor,ot=(n,e,t,l)=>{for(var a=l>1?void 0:l?ct(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},me=(n,e)=>(t,l)=>e(t,l,n);D.ConditionalFormattingClearController=class extends s.Disposable{constructor(e,t,l,a,u){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=l,this._selectionManagerService=a,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const t=[],l=[],a={redos:t,undos:l};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const i=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(S=>S.range);if(!i)return a;const p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!o)return a;const f=p.getUnitId(),d=o.getSheetId(),v=this._conditionalFormattingRuleModel.getSubunitRules(f,d);if(!v||!v.length)return a;const{redos:h,undos:b}=Ir(this._injector,v,i,f,d);t.push(...h),l.push(...b)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:l})=>{const a=[],u=[],i={redos:a,undos:u};if(!l||!l.length)return i;const p=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!p||!p.length)return i;const{redos:o,undos:f}=Ir(this._injector,p,l,e,t);return a.push(...o),u.push(...f),i}}))}},D.ConditionalFormattingClearController=ot([me(0,s.Inject(s.Injector)),me(1,s.Inject(s.IUniverInstanceService)),me(2,s.Inject(U.SheetInterceptorService)),me(3,s.Inject(U.SheetsSelectionsService)),me(4,s.Inject(r.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function Ir(n,e,t,l,a){const u=[],i=[];return e.filter(p=>t.some(o=>p.ranges.some(f=>s.Rectangle.getIntersects(f,o)))).forEach(p=>{const f=new U.RangeMergeUtil().add(...p.ranges).subtract(...t).merge();if(f.length){const d={id:r.SetConditionalRuleMutation.id,params:{unitId:l,subUnitId:a,rule:{...p,ranges:f}}},v=r.setConditionalRuleMutationUndoFactory(n,d.params);u.push(d),i.push(...v)}else{const d={id:r.DeleteConditionalRuleMutation.id,params:{unitId:l,subUnitId:a,cfId:p.cfId}},v=r.DeleteConditionalRuleMutationUndoFactory(n,d.params);u.push(d),i.push(...v)}}),{redos:u,undos:i}}var dt=Object.getOwnPropertyDescriptor,vt=(n,e,t,l)=>{for(var a=l>1?void 0:l?dt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},be=(n,e)=>(t,l)=>e(t,l,n);let Ie=class extends s.Disposable{constructor(e,t,l,a,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=l,this._conditionalFormattingViewModel=a,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,l)=>this._collectConditionalRule(e,t,l),onPasteCells:(e,t,l,a)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:i}=a,{range:p}=e||{},{range:o}=t;return this._generateConditionalFormattingMutations(o,{copyType:u,pasteType:i,copyRange:p})}}))}_collectConditionalRule(e,t,l){const a=new s.ObjectMatrix,u={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:t,cfMap:u}};const i=this._injector.invoke(d=>U.rangeToDiscreteRange(l,d,e,t));if(!i)return;const{rows:p,cols:o}=i,f=new Set;p.forEach((d,v)=>{o.forEach((h,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,t,d,h);S&&(S.forEach(m=>f.add(m.cfId)),a.setValue(v,b,S.map(m=>m.cfId)))})}),f.forEach(d=>{const v=this._conditionalFormattingRuleModel.getRule(e,t,d);v&&(u[d]=v.rule)})}_generateConditionalFormattingMutations(e,t){const l=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),a=l.getActiveSheet(),u=l.getUnitId();if(!a)return{redos:[],undos:[]};const i=a.getSheetId();if(t.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!t.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(t.pasteType))return{redos:[],undos:[]};const{ranges:[o,f],mapFunc:d}=W.virtualizeDiscreteRanges([t.copyRange,e]),v=W.getRepeatRange(o,f,!0),h={};s.Range.foreach(f,(g,T)=>{const{row:w,col:I}=d(g,T),k=this._conditionalFormattingViewModel.getCellCfs(u,i,w,I);k&&k.forEach(V=>{if(!h[V.cfId]){const P=new s.ObjectMatrix;h[V.cfId]=P;const L=this._conditionalFormattingRuleModel.getRule(u,i,V.cfId);L==null||L.ranges.forEach(y=>{s.Range.foreach(y,(x,$)=>{P.setValue(x,$,1)})})}h[V.cfId].realDeleteValue(w,I)})});const{matrix:b,info:S}=this._copyInfo,m=[];let E=this._conditionalFormattingRuleModel.createCfId(u,i);const _={},N=g=>{if(_[g])return _[g];const T=S==null?void 0:S.cfMap[g],w=[...this._conditionalFormattingRuleModel.getSubunitRules(u,i)||[],...m].find(I=>s.Tools.diffValue(I.rule,T));if(w)return _[g]=w,w;{const I={rule:T,cfId:E,ranges:[],stopIfTrue:!1};return _[g]=I,m.push(I),E=`${Number(E)+1}`,I}};v.forEach(g=>{b&&b.forValue((T,w,I)=>{const k=s.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:w,endColumn:w},g.startRange),{row:V,col:P}=d(k.startRow,k.startColumn);I.forEach(L=>{if(!h[L]){const y=N(L),x=new s.ObjectMatrix;h[L]=x,y.ranges.forEach($=>{s.Range.foreach($,(G,J)=>{x.setValue(G,J,1)})})}h[L].setValue(V,P,1)})})});const M=[],R=[];for(const g in h){const T=h[g],w=U.findAllRectangle(U.createTopMatrixFromMatrix(T));if(!w.length){const I={unitId:u,subUnitId:i,cfId:g};M.push({id:r.DeleteConditionalRuleMutation.id,params:I}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(m.some(I=>I.cfId===g)){const I=N(g),k={unitId:u,subUnitId:i,rule:{...I,ranges:w}};M.push({id:r.AddConditionalRuleMutation.id,params:k}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,k))}else{const I=this._conditionalFormattingRuleModel.getRule(u,i,g);if(!I)continue;const k={unitId:u,subUnitId:i,rule:{...I,ranges:w}};M.push({id:r.SetConditionalRuleMutation.id,params:k}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,k))}}return{redos:M,undos:R}}};Ie=vt([be(0,s.Inject(W.ISheetClipboardService)),be(1,s.Inject(r.ConditionalFormattingRuleModel)),be(2,s.Inject(s.Injector)),be(3,s.Inject(r.ConditionalFormattingViewModel)),be(4,s.Inject(s.IUniverInstanceService))],Ie);var pt=Object.getOwnPropertyDescriptor,ft=(n,e,t,l)=>{for(var a=l>1?void 0:l?pt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},Qe=(n,e)=>(t,l)=>e(t,l,n);let Se=class extends s.Disposable{constructor(n,e,t){super(),this._localeService=n,this._commandService=e,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{if(n.id===r.AddCfCommand.id){const{unitId:e,subUnitId:t,rule:{ranges:l}}=n.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},l,e,t)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Se=ft([Qe(0,s.Inject(s.LocaleService)),Qe(1,s.ICommandService),Qe(2,s.Inject(U.SheetPermissionCheckController))],Se);var ht=Object.getOwnPropertyDescriptor,gt=(n,e,t,l)=>{for(var a=l>1?void 0:l?ht(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},Oe=(n,e)=>(t,l)=>e(t,l,n);let Te=class extends s.Disposable{constructor(n,e,t,l){super(),this._conditionalFormattingRuleModel=n,this._univerInstanceService=e,this._injector=t,this._refRangeService=l,this._initRefRange()}_initRefRange(){const n=new Map,e=(l,a,u)=>`${l}_${a}_${u}`,t=(l,a,u)=>{const i=o=>{const f=[...u.ranges],d=f.map(h=>U.handleDefaultRangeChangeWithEffectRefCommands(h,o)).filter(h=>!!h);if(r.isRangesEqual(d,f))return{redos:[],undos:[]};if(d.length){const h={unitId:l,subUnitId:a,rule:{...u,ranges:d}},b=[{id:r.SetConditionalRuleMutation.id,params:h}],S=r.setConditionalRuleMutationUndoFactory(this._injector,h);return{redos:b,undos:S}}else{const h={unitId:l,subUnitId:a,cfId:u.cfId},b=[{id:r.DeleteConditionalRuleMutation.id,params:h}],S=r.DeleteConditionalRuleMutationUndoFactory(this._injector,h);return{redos:b,undos:S}}},p=[];u.ranges.forEach(o=>{const f=this._refRangeService.registerRefRange(o,i);p.push(()=>f.dispose())}),n.set(e(l,a,u.cfId),()=>p.forEach(o=>o()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(l=>{const{unitId:a,subUnitId:u,rule:i}=l,p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),o=p.getActiveSheet();if(!(l.unitId!==p.getUnitId()||l.subUnitId!==(o==null?void 0:o.getSheetId())))switch(l.type){case"add":{t(l.unitId,l.subUnitId,l.rule);break}case"delete":{const f=n.get(e(a,u,i.cfId));f&&f();break}case"set":{const f=n.get(e(a,u,i.cfId));f&&f(),t(l.unitId,l.subUnitId,l.rule)}}})),this.disposeWithMe(s.toDisposable(()=>{n.forEach(l=>{l()}),n.clear()}))}};Te=gt([Oe(0,s.Inject(r.ConditionalFormattingRuleModel)),Oe(1,s.Inject(s.IUniverInstanceService)),Oe(2,s.Inject(s.Injector)),Oe(3,s.Inject(U.RefRangeService))],Te);var yt=Object.getOwnPropertyDescriptor,Ct=(n,e,t,l)=>{for(var a=l>1?void 0:l?yt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},ie=(n,e)=>(t,l)=>e(t,l,n);let _e=class extends s.Disposable{constructor(e,t,l,a,u,i){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=l,this._renderManagerService=a,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=i,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var t,l,a;const e=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId();(t=this._renderManagerService.getRenderById(e))==null||t.with(W.SheetSkeletonManagerService).reCalculate(),(a=(l=this._renderManagerService.getRenderById(e))==null?void 0:l.mainComponent)==null||a.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(pe.bufferTime(16),pe.filter(e=>!!e.length),pe.filter(e=>{const t=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const l=t.getActiveSheet();return l?e.filter(a=>a.unitId===t.getUnitId()&&a.subUnitId===l.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:s.InterceptorEffectEnum.Style,handler:(e,t,l)=>{const a=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!a)return l(e);const u=t.workbook.getStyles(),i=(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},p=e===t.rawData?{...t.rawData}:e;if(a.style){const o={...i,...a.style};Object.assign(p,{s:o})}return p.fontRenderExtension||(p.fontRenderExtension={},a.isShowValue!==void 0&&(p.fontRenderExtension.isSkip=!a.isShowValue)),a.dataBar&&(p.dataBar=a.dataBar),a.iconSet&&(p.iconSet=a.iconSet,p.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),l(p)},priority:10}))}};_e=Ct([ie(0,s.Inject(U.SheetInterceptorService)),ie(1,s.Inject(r.ConditionalFormattingService)),ie(2,s.Inject(s.IUniverInstanceService)),ie(3,s.Inject(nr.IRenderManagerService)),ie(4,s.Inject(r.ConditionalFormattingViewModel)),ie(5,s.Inject(r.ConditionalFormattingRuleModel))],_e);const Sr="sheets-conditional-formatting-ui.config",Ue={};var mt=Object.defineProperty,bt=Object.getOwnPropertyDescriptor,It=(n,e,t)=>e in n?mt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,St=(n,e,t,l)=>{for(var a=l>1?void 0:l?bt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},er=(n,e)=>(t,l)=>e(t,l,n),Tr=(n,e,t)=>It(n,typeof e!="symbol"?e+"":e,t);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends s.Plugin{constructor(e=Ue,t,l,a){super(),this._config=e,this._injector=t,this._commandService=l,this._configService=a;const{menu:u,...i}=s.merge({},Ue,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand(),this._injector.add([_e]),this._injector.add([Te]),this._injector.add([Ie]),this._injector.add([Se]),this._injector.add([se])}_initCommand(){[Fe,Be,He,We,qe,Ge,Ze,ze,Ye,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},Tr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),Tr(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=St([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin),er(1,s.Inject(s.Injector)),er(2,s.Inject(s.ICommandService)),er(3,s.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var Tt=Object.getOwnPropertyDescriptor,_t=(n,e,t,l)=>{for(var a=l>1?void 0:l?Tt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},we=(n,e)=>(t,l)=>e(t,l,n);let ke=class extends s.Disposable{constructor(n,e,t,l,a){super(),this._injector=n,this._univerInstanceService=e,this._autoFillService=t,this._conditionalFormattingRuleModel=l,this._conditionalFormattingViewModel=a,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),e=(a,u,i,p,o)=>{var b;const f=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(b=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!f||!d)return;const v={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row},h={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};s.Range.foreach(i,(S,m)=>{const E=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},v),_=s.Rectangle.getPositionRange({startRow:S,startColumn:m,endColumn:m,endRow:S},h),{row:N,col:M}=o(E.startRow,E.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(f,d,N,M),{row:g,col:T}=o(_.startRow,_.startColumn),w=this._conditionalFormattingViewModel.getCellCfs(f,d,g,T);w&&w.forEach(I=>{let k=p.get(I.cfId);if(!p.get(I.cfId)){const V=this._conditionalFormattingRuleModel.getRule(f,d,I.cfId);if(!V)return;k=new s.ObjectMatrix,V.ranges.forEach(P=>{s.Range.foreach(P,(L,y)=>{k.setValue(L,y,1)})}),p.set(I.cfId,k)}k.realDeleteValue(g,T)}),R&&R.forEach(I=>{let k=p.get(I.cfId);if(!p.get(I.cfId)){const V=this._conditionalFormattingRuleModel.getRule(f,d,I.cfId);if(!V)return;k=new s.ObjectMatrix,V.ranges.forEach(P=>{s.Range.foreach(P,(L,y)=>{k.setValue(L,y,1)})}),p.set(I.cfId,k)}k.setValue(g,T,1)})})},t=(a,u)=>{var _,N,M;const i=(_=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getUnitId(),p=(M=(N=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getActiveSheet())==null?void 0:M.getSheetId(),o=new Map,f=[],d=[];if(!i||!p)return n();const v=W.virtualizeDiscreteRanges([a,u]),[h,b]=v.ranges,{mapFunc:S}=v,m={row:h.startRow,col:h.startColumn};return W.getAutoFillRepeatRange(h,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,o,S)}),o.forEach((R,g)=>{const T=this._conditionalFormattingRuleModel.getRule(i,p,g);if(!T)return;const w=U.findAllRectangle(U.createTopMatrixFromMatrix(R));if(w.length){const I={unitId:i,subUnitId:p,rule:{...T,ranges:w}};f.push({id:r.SetConditionalRuleMutation.id,params:I}),d.push(...r.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:i,subUnitId:p,cfId:T.cfId};f.push({id:r.DeleteConditionalRuleMutation.id,params:I}),d.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:f}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(a,u,i)=>{if(i===W.APPLY_TYPE.COPY||i===W.APPLY_TYPE.ONLY_FORMAT||i===W.APPLY_TYPE.SERIES){const{source:p,target:o}=a;return t(p,o)}return n()}};this.disposeWithMe(this._autoFillService.addHook(l))}};ke=_t([we(0,s.Inject(s.Injector)),we(1,s.Inject(s.IUniverInstanceService)),we(2,s.Inject(W.IAutoFillService)),we(3,s.Inject(r.ConditionalFormattingRuleModel)),we(4,s.Inject(r.ConditionalFormattingViewModel))],ke);var wt=Object.getOwnPropertyDescriptor,xt=(n,e,t,l)=>{for(var a=l>1?void 0:l?wt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},_r=(n,e)=>(t,l)=>e(t,l,n);let Pe=class extends s.Disposable{constructor(n,e){super(),this._sheetInterceptorService=n,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(s.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(n,e,t)=>{var i,p,o;n||t(n);const l=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),a=(i=l==null?void 0:l.style)!=null?i:{},u=Object.keys(a);if(n!=null&&n.p)return(o=(p=n.p.body)==null?void 0:p.textRuns)==null||o.forEach(f=>{f.ts&&u.forEach(d=>{var v;(v=f.ts)==null||delete v[d]})}),t(n);{const f={...(typeof(n==null?void 0:n.s)=="string"?e.workbook.getStyles().get(n.s):n==null?void 0:n.s)||{}};u.forEach(v=>{delete f[v]});const d={...n,s:{...f}};return t(d)}}})))}};Pe=xt([_r(0,s.Inject(U.SheetInterceptorService)),_r(1,s.Inject(r.ConditionalFormattingService))],Pe);const wr=[U.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],xe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Y.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Y.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Y.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Y.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Y.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Y.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Y.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Y.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Y.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Y.clearWorkSheetRules}],Et=n=>{const e=n.get(U.SheetsSelectionsService),t=n.get(s.ICommandService),l=n.get(s.IUniverInstanceService),a=n.get(r.ConditionalFormattingRuleModel),u=new X.Observable(o=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(f=>{const d=t.onCommandExecuted(v=>{var m;const{id:h,params:b}=v,S=(m=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();wr.includes(h)&&b.unitId===S&&f.next(null)});return()=>d.dispose()})).pipe(pe.debounceTime(16)).subscribe(()=>{var m;const f=((m=e.getCurrentSelections())==null?void 0:m.map(E=>E.range))||[],d=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!d)return;const v=d.getActiveSheet();if(!v)return;const S=(a.getSubunitRules(d.getUnitId(),v.getSheetId())||[]).filter(E=>E.ranges.some(_=>f.some(N=>s.Rectangle.intersects(N,_)))).map(E=>E.ranges).every(E=>U.checkRangesEditablePermission(n,d.getUnitId(),v.getSheetId(),E));o.next(S)})),i=new X.Observable(o=>new X.Observable(f=>{const d=t.onCommandExecuted(v=>{var m;const{id:h,params:b}=v,S=(m=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();wr.includes(h)&&b.unitId===S&&f.next(null)});return()=>d.dispose()}).pipe(pe.debounceTime(16)).subscribe(()=>{const f=l.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET);if(!f)return;const d=f.getActiveSheet();if(!d)return;const v=a.getSubunitRules(f.getUnitId(),d.getSheetId())||[];if(!v.length)return o.next(!1),!1;const h=v.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(n,f.getUnitId(),d.getSheetId(),b));o.next(h)})),p=new X.Observable(o=>{u.subscribe(f=>{const d=xe.find(v=>v.value===Y.clearRangeRules);d&&(d.disabled=!f,o.next(xe))}),i.subscribe(f=>{const d=xe.find(v=>v.value===Y.clearWorkSheetRules);d&&(d.disabled=!f,o.next(xe))}),o.next(xe)});return{id:Ce.id,type:j.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:p,hidden$:j.getMenuHiddenObservable(n,s.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(n,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Nt={[j.RibbonDataGroup.RULES]:{[Ce.id]:{order:1,menuItemFactory:Et}}};var Rt=Object.getOwnPropertyDescriptor,Mt=(n,e,t,l)=>{for(var a=l>1?void 0:l?Rt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},xr=(n,e)=>(t,l)=>e(t,l,n);let De=class extends s.Disposable{constructor(e,t){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=t,this._menuManagerService.mergeMenu(Nt)}};De=Mt([xr(0,s.Inject(s.Injector)),xr(1,j.IMenuManagerService)],De);var Vt=Object.getOwnPropertyDescriptor,Ot=(n,e,t,l)=>{for(var a=l>1?void 0:l?Vt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},ce=(n,e)=>(t,l)=>e(t,l,n);const Ut=(n,e)=>{const t=d=>d.endRow-d.startRow+1,l=d=>d.endColumn-d.startColumn+1,a=t(e)%t(n),u=l(e)%l(n),i=Math.floor(t(e)/t(n)),p=Math.floor(l(e)/l(n)),o=[],f={startRow:0,endRow:t(n)-1,startColumn:0,endColumn:l(n)-1};if(t(e)===1&&l(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return o.push({repeatRelativeRange:f,startRange:d}),o}for(let d=0;d<i+(a?.1:0);d++)for(let v=0;v<p+(u?.1:0);v++){const h=t(n)*d,b=l(n)*v,S={startRow:h+e.startRow,endRow:h+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=f;d===i&&a&&(m={...m},m.endRow=m.endRow-(t(n)-a)),v===p&&u&&(m={...m},m.endColumn=m.endColumn-(l(n)-u)),o.push({repeatRelativeRange:m,startRange:S})}return o};let Le=class extends s.Disposable{constructor(e,t,l,a,u,i){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=t,this._formatPainterService=l,this._sheetsSelectionsService=a,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=i,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),t=(u,i,p,o,f)=>{const{unitId:d,subUnitId:v}=this._painterConfig,{targetUnitId:h,targetSubUnitId:b}=f,S={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},m={startRow:i.row,startColumn:i.col,endColumn:i.col,endRow:i.row};s.Range.foreach(p,(E,_)=>{const N=s.Rectangle.getPositionRange({startRow:E,startColumn:_,endColumn:_,endRow:E},S),M=s.Rectangle.getPositionRange({startRow:E,startColumn:_,endColumn:_,endRow:E},m),R=this._conditionalFormattingViewModel.getCellCfs(d,v,N.startRow,N.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(h,b,M.startRow,M.startColumn);g&&g.forEach(T=>{let w=o.get(T.cfId);if(!o.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(h,b,T.cfId);if(!I)return;w=new s.ObjectMatrix,I.ranges.forEach(k=>{s.Range.foreach(k,(V,P)=>{w.setValue(V,P,1)})}),o.set(T.cfId,w)}w.realDeleteValue(M.startRow,M.startColumn)}),R&&R.forEach(T=>{const w=o.get(T.cfId);w&&w.setValue(M.startRow,M.startColumn,1)})})},l=(u,i,p)=>{var N;const{range:o,unitId:f,subUnitId:d}=this._painterConfig,v=u!==f||d!==i,h=new Map,b=[],S=[];if(!u||!i||!f||!d)return e();const m=(N=this._conditionalFormattingRuleModel.getSubunitRules(f,d))!=null?N:[];m==null||m.forEach(M=>{const{ranges:R,cfId:g}=M;if(R.some(T=>s.Rectangle.intersects(o,T))){const T=new s.ObjectMatrix;v||R.forEach(w=>{s.Range.foreach(w,(I,k)=>{T.setValue(I,k,1)})}),h.set(g,T)}});const E={row:o.startRow,col:o.startColumn};return Ut(o,p).forEach(M=>{t(E,{row:M.startRange.startRow,col:M.startRange.startColumn},M.repeatRelativeRange,h,{targetUnitId:u,targetSubUnitId:i})}),h.forEach((M,R)=>{if(v){const g=this._conditionalFormattingRuleModel.getRule(u,i,R),T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(g)if(T.length){const w={unitId:u,subUnitId:i,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:u,subUnitId:i,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}else if(T.length){const w=this._conditionalFormattingRuleModel.getRule(f,d,R);if(w){const I={unitId:u,subUnitId:i,rule:{...s.Tools.deepClone(w),cfId:this._conditionalFormattingRuleModel.createCfId(u,i),ranges:T}};b.push({id:r.AddConditionalRuleMutation.id,params:I}),S.push(r.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(f,d,R);if(!g)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(T.length){const w={unitId:f,subUnitId:d,rule:{...g,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),S.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:f,subUnitId:d,cfId:g.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),S.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}}}),{undos:S,redos:b}},a={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var i,p,o;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const f=(i=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getUnitId(),d=(o=(p=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET))==null?void 0:p.getActiveSheet())==null?void 0:o.getSheetId(),v=this._sheetsSelectionsService.getCurrentLastSelection(),h=v==null?void 0:v.range;f&&d&&h&&(this._painterConfig={unitId:f,subUnitId:d,range:h});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,i,p)=>this._painterConfig?l(u,i,p):{redos:[],undos:[]}};this._formatPainterService.addHook(a)}};Le=Ot([ce(0,s.Inject(s.Injector)),ce(1,s.Inject(s.IUniverInstanceService)),ce(2,s.Inject(W.IFormatPainterService)),ce(3,s.Inject(U.SheetsSelectionsService)),ce(4,s.Inject(r.ConditionalFormattingRuleModel)),ce(5,s.Inject(r.ConditionalFormattingViewModel))],Le);var kt=Object.getOwnPropertyDescriptor,Pt=(n,e,t,l)=>{for(var a=l>1?void 0:l?kt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},rr=(n,e)=>(t,l)=>e(t,l,n);let je=class extends s.Disposable{constructor(n,e,t){super(),this._conditionalFormattingViewModel=n,this._univerInstanceService=e,this._renderManagerService=t,this._init()}_init(){const n=this._univerInstanceService.getCurrentUnitForType(s.UniverInstanceType.UNIVER_SHEET),e=t=>{const l=t.getUnitId(),a=this._renderManagerService.getRenderById(l);if(!a)return;const u=a.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(i=>{if(i){const p=i.skeleton.rowColumnSegment,o=p.endColumn-p.startColumn+1,d=(p.endRow-p.startRow+1)*o*9,v=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(v)}}))};n&&e(n),this._univerInstanceService.getCurrentTypeOfUnit$(s.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{t&&e(t)})}};je=Pt([rr(0,s.Inject(r.ConditionalFormattingViewModel)),rr(1,s.IUniverInstanceService),rr(2,nr.IRenderManagerService)],je);var Dt=Object.defineProperty,Lt=Object.getOwnPropertyDescriptor,jt=(n,e,t)=>e in n?Dt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,At=(n,e,t,l)=>{for(var a=l>1?void 0:l?Lt(e,t):e,u=n.length-1,i;u>=0;u--)(i=n[u])&&(a=i(a)||a);return a},tr=(n,e)=>(t,l)=>e(t,l,n),Er=(n,e,t)=>jt(n,typeof e!="symbol"?e+"":e,t);D.UniverSheetsConditionalFormattingUIPlugin=class extends s.Plugin{constructor(e=Ue,t,l,a){super(),this._config=e,this._injector=t,this._commandService=l,this._configService=a;const{menu:u,...i}=s.merge({},Ue,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Sr,i),this._initCommand()}onStarting(){s.registerDependencies(this._injector,[[_e],[Te],[Ie],[ke],[Se],[ye],[De],[se],[Pe],[D.ConditionalFormattingClearController],[Le],[je]]),s.touchDependencies(this._injector,[[_e]])}onReady(){s.touchDependencies(this._injector,[[De],[ye]])}onRendered(){s.touchDependencies(this._injector,[[ke],[D.ConditionalFormattingClearController],[Ie],[Pe],[se],[Le],[Se],[Te],[je]])}_initCommand(){[Fe,Be,He,We,qe,Ge,Ze,ze,Ye,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},Er(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Er(D.UniverSheetsConditionalFormattingUIPlugin,"type",s.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=At([s.DependentOn(r.UniverSheetsConditionalFormattingPlugin),tr(1,s.Inject(s.Injector)),tr(2,s.Inject(s.ICommandService)),tr(3,s.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=Fe,D.AddColorScaleConditionalRuleCommand=Be,D.AddDataBarConditionalRuleCommand=He,D.AddDuplicateValuesCfCommand=We,D.AddNumberCfCommand=qe,D.AddRankCfCommand=Ge,D.AddTextCfCommand=Ze,D.AddTimePeriodCfCommand=ze,D.AddUniqueValuesCfCommand=Ye,D.OpenConditionalFormattingOperator=Ce,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting-ui",
3
- "version": "0.12.4",
3
+ "version": "0.13.0",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,15 +55,15 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^1.0.2",
58
- "@univerjs/core": "0.12.4",
59
- "@univerjs/design": "0.12.4",
60
- "@univerjs/engine-render": "0.12.4",
61
- "@univerjs/sheets-conditional-formatting": "0.12.4",
62
- "@univerjs/sheets": "0.12.4",
63
- "@univerjs/sheets-formula-ui": "0.12.4",
64
- "@univerjs/engine-formula": "0.12.4",
65
- "@univerjs/sheets-ui": "0.12.4",
66
- "@univerjs/ui": "0.12.4"
58
+ "@univerjs/core": "0.13.0",
59
+ "@univerjs/design": "0.13.0",
60
+ "@univerjs/engine-formula": "0.13.0",
61
+ "@univerjs/sheets": "0.13.0",
62
+ "@univerjs/sheets-conditional-formatting": "0.13.0",
63
+ "@univerjs/sheets-formula-ui": "0.13.0",
64
+ "@univerjs/engine-render": "0.13.0",
65
+ "@univerjs/sheets-ui": "0.13.0",
66
+ "@univerjs/ui": "0.13.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "postcss": "^8.5.6",
@@ -71,9 +71,9 @@
71
71
  "rxjs": "^7.8.2",
72
72
  "tailwindcss": "3.4.18",
73
73
  "typescript": "^5.9.3",
74
- "vite": "^7.2.6",
74
+ "vite": "^7.2.7",
75
75
  "vitest": "^4.0.15",
76
- "@univerjs-infra/shared": "0.12.4"
76
+ "@univerjs-infra/shared": "0.13.0"
77
77
  },
78
78
  "scripts": {
79
79
  "test": "vitest run",