@univerjs/sheets-conditional-formatting-ui 0.7.0 → 0.8.0-beta.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 +1 -2
- package/lib/es/index.js +592 -590
- package/lib/index.css +1 -1
- package/lib/index.js +592 -590
- package/lib/types/components/wrapper-error/WrapperError.d.ts +2 -2
- package/lib/types/locale/en-US.d.ts +174 -2
- package/lib/types/locale/fa-IR.d.ts +2 -2
- package/lib/types/locale/ru-RU.d.ts +2 -2
- package/lib/types/locale/vi-VN.d.ts +2 -2
- package/lib/types/locale/zh-CN.d.ts +2 -174
- package/lib/types/locale/zh-TW.d.ts +2 -2
- package/lib/umd/index.js +1 -2
- package/package.json +12 -12
package/lib/cjs/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
"use strict";var Tt=Object.defineProperty;var Rt=(n,e,i)=>e in n?Tt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var Q=(n,e,i)=>Rt(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),t=require("@univerjs/sheets-conditional-formatting"),U=require("@univerjs/sheets"),k=require("@univerjs/ui"),l=require("react/jsx-runtime"),C=require("react"),w=require("@univerjs/design"),Ge=require("@univerjs/engine-formula"),xe=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),ht=require("@univerjs/engine-render"),fe=require("rxjs/operators"),ze={type:a.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o}=e,u=n.get(t.ConditionalFormattingRuleModel),v=n.get(a.ICommandService),c=n.get(a.IUniverInstanceService),m=U.getSheetCommandTarget(c);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=u.createCfId(d,h),y={ranges:i,cfId:p,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:o,style:r}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:h,rule:y})}},Ye={type:a.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,config:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.ICommandService),v=n.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:m,subUnitId:d}=c,h=o.createCfId(m,d),p={ranges:i,cfId:h,stopIfTrue:!!s,rule:{type:t.CFRuleType.colorScale,config:r}};return u.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:d,rule:p})}},Ze={type:a.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,min:r,max:s,nativeColor:o,positiveColor:u,isGradient:v,stopIfTrue:c,isShowValue:m}=e,d=n.get(t.ConditionalFormattingRuleModel),h=n.get(a.IUniverInstanceService),p=U.getSheetCommandTarget(h);if(!p)return!1;const{unitId:y,subUnitId:T}=p,S=n.get(a.ICommandService),_=d.createCfId(y,T),F={ranges:i,cfId:_,stopIfTrue:!!c,rule:{type:t.CFRuleType.dataBar,isShowValue:m,config:{min:r,max:s,nativeColor:o,positiveColor:u,isGradient:v}}};return S.executeCommand(t.AddConditionalRuleMutation.id,{unitId:y,subUnitId:T,rule:F})}},Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.ICommandService),v=n.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:m,subUnitId:d}=c,h=o.createCfId(m,d),p={ranges:i,cfId:h,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:r}};return u.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:d,rule:p})}},Xe={type:a.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o,value:u}=e,v=n.get(t.ConditionalFormattingRuleModel),c=n.get(a.ICommandService),m=n.get(a.IUniverInstanceService),d=U.getSheetCommandTarget(m);if(!d)return!1;const{unitId:h,subUnitId:p}=d,y=v.createCfId(h,p);let T;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(o)){const S=u;if(S.length!==2||!Array.isArray(S))return!1;T={ranges:i,cfId:y,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:o,style:r,value:S}}}else{const S=u;if(typeof S!="number")return!1;T={ranges:i,cfId:y,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:o,style:r,value:S}}}return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:p,rule:T})}},Je={type:a.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,isPercent:o,isBottom:u,value:v}=e,c=n.get(t.ConditionalFormattingRuleModel),m=n.get(a.IUniverInstanceService),d=n.get(a.ICommandService),h=U.getSheetCommandTarget(m);if(!h)return!1;const{unitId:p,subUnitId:y}=h,T=c.createCfId(p,y),S={ranges:i,cfId:T,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:o,isBottom:u,style:r,value:v}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:y,rule:S})}},Qe={type:a.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o,value:u}=e,v=n.get(t.ConditionalFormattingRuleModel),c=n.get(a.IUniverInstanceService),m=U.getSheetCommandTarget(c);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=n.get(a.ICommandService),y=v.createCfId(d,h),T={ranges:i,cfId:y,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:o,style:r,value:u}};return p.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:h,rule:T})}},et={type:a.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o}=e,u=n.get(t.ConditionalFormattingRuleModel),v=n.get(a.IUniverInstanceService),c=n.get(a.ICommandService),m=U.getSheetCommandTarget(v);if(!m)return!1;const{unitId:d,subUnitId:h}=m,p=u.createCfId(d,h),y={ranges:i,cfId:p,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:o,style:r}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:h,rule:y})}},tt={type:a.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.IUniverInstanceService),v=n.get(a.ICommandService),c=U.getSheetCommandTarget(u);if(!c)return!1;const{unitId:m,subUnitId:d}=c,h=o.createCfId(m,d),p={ranges:i,cfId:h,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:r}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:d,rule:p})}};var Z=function(){return Z=Object.assign||function(n){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},Z.apply(this,arguments)},Ft=function(n,e){var i={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(i[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(i[r[s]]=n[r[s]]);return i},ce=C.forwardRef(function(n,e){var i=n.icon,r=n.id,s=n.className,o=n.extend,u=Ft(n,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),c=C.useRef("_".concat(jt()));return pt(i,"".concat(r),{defIds:i.defIds,idSuffix:c.current},Z({ref:e,className:v},u),o)});function pt(n,e,i,r,s){return C.createElement(n.tag,Z(Z({key:e},_t(n,i,s)),r),(Nt(n,i).children||[]).map(function(o,u){return pt(o,"".concat(e,"-").concat(n.tag,"-").concat(u),i,void 0,s)}))}function _t(n,e,i){var r=Z({},n.attrs);i!=null&&i.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=i.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var u=o[0],v=o[1];u==="mask"&&typeof v=="string"&&(r[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var u=o[0],v=o[1];typeof v=="string"&&(r[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Nt(n,e){var i,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?Z(Z({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?Z(Z({},s),{attrs:Z(Z({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function jt(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Et={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},Ve=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"delete-single",ref:e,icon:Et}))});Ve.displayName="DeleteSingle";var Mt={tag:"svg",attrs:{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"}}]},gt=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"increase-single",ref:e,icon:Mt}))});gt.displayName="IncreaseSingle";var wt={tag:"svg",attrs:{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"}}]},Le=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"more-down-single",ref:e,icon:wt}))});Le.displayName="MoreDownSingle";var Vt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},ft=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"sequence-single",ref:e,icon:Vt}))});ft.displayName="SequenceSingle";var Ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",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"}}]}]},Te=C.forwardRef(function(n,e){return C.createElement(ce,Object.assign({},n,{id:"slash-single",ref:e,icon:Ot}))});Te.displayName="SlashSingle";const re=n=>{const{color:e,onChange:i,disable:r=!1,iconId:s="PaintBucket",className:o,isNeedDropdownIcon:u=!0}=n,v=k.useDependency(k.ComponentManager),c=C.useMemo(()=>new a.ColorKit(e),[e]),m=v.get(s);return m?r?l.jsx(m,{className:w.clsx("univer-fill-primary-600",o),extend:{colorChannel1:c.isValid?e:""}}):l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(w.ColorPicker,{value:e,onChange:i})}),children:l.jsxs("span",{className:w.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100",o),children:[l.jsx(m,{className:"univer-fill-primary-600",extend:{colorChannel1:c.isValid?e:""}}),u&&l.jsx(Le,{className:"univer-ml-1.5 univer-text-gray-400"})]})}):null},de=n=>{var o,u,v;const e=n.rule;if(!e)return null;const i=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const c=e.config.map((h,p)=>({color:new a.ColorKit(h.color),value:p})),m=c.length-1;return new Array(5).fill("").map((h,p,y)=>p*m/(y.length-1)).map(h=>t.getColorScaleFromValue(c,h))}return null},[e]),r=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(c=>{const m=t.iconMap[c.iconType];return m&&m[Number(c.iconId)]})},[e]),s=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center
|
|
2
|
-
univer-justify-center univer-text-xs`;switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:c}=e.config,m=c?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,d=c?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return l.jsxs("div",{className:s,children:[l.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:d,border:`1px solid ${e.config.nativeColor||t.defaultDataBarNativeColor}`}}),l.jsx("div",{className:"univer-h-full univer-w-1/2",style:{background:m,border:`1px solid ${e.config.positiveColor||t.defaultDataBarPositiveColor}`}})]})}case t.CFRuleType.colorScale:return i&&l.jsx("div",{className:s,children:i.map((c,m)=>l.jsx("div",{className:"univer-h-full",style:{width:`${100/i.length}%`,background:c}},m))});case t.CFRuleType.iconSet:return r&&l.jsx("div",{className:s,children:r.map((c,m)=>c?l.jsx("img",{className:"univer-h-full",src:c,draggable:!1},m):l.jsx(Te,{},m))});case t.CFRuleType.highlightCell:{const{ul:c,st:m,it:d,bl:h,bg:p,cl:y}=e.style,T=(c==null?void 0:c.s)===a.BooleanNumber.TRUE,S=(m==null?void 0:m.s)===a.BooleanNumber.TRUE,_=d===a.BooleanNumber.TRUE,F=h===a.BooleanNumber.TRUE,N=(o=p==null?void 0:p.rgb)!=null?o:t.DEFAULT_BG_COLOR,E=(u=y==null?void 0:y.rgb)!=null?u:t.DEFAULT_FONT_COLOR,j={textDecoration:(v=`${T?"underline":""} ${S?"line-through":""}`.replace(/^ /,""))!=null?v:void 0,backgroundColor:N,color:E};return l.jsx("div",{className:w.clsx(s,{"univer-font-bold":F,"univer-italic":_}),style:j,children:"123"})}}},Re=w.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",w.borderClassName),ne=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),$e=n=>{var T;const{type:e,className:i,onChange:r,id:s,value:o}=n,u=k.useDependency(a.IUniverInstanceService),v=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(T=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:T.getSheetId(),m=C.useMemo(()=>String(o).startsWith("=")?String(o):"=",[o]),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]),h=C.useRef(null),[p,y]=C.useState(!1);return k.useSidebarClick(S=>{var F;((F=h.current)==null?void 0:F.isClickOutSide(S))&&y(!1)}),e===t.CFValueType.formula?l.jsx("div",{className:"univer-ml-1 univer-w-full",children:l.jsx(xe.FormulaEditor,{ref:h,className:w.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 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:univer-bg-gray-700 dark:univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:m,unitId:v,subUnitId:c,isFocus:p,onChange:(S="")=>{r(S||"")},onFocus:()=>y(!0)})}):l.jsx(w.InputNumber,{className:i,value:Number(n.value)||0,onChange:S=>n.onChange(S||0),...d})},Ut=n=>{var P;const{interceptorManager:e}=n,i=k.useDependency(a.LocaleService),r=((P=n.rule)==null?void 0:P.type)===t.CFRuleType.colorScale?n.rule:void 0,s=[ne(t.CFValueType.num,i),ne(t.CFValueType.percent,i),ne(t.CFValueType.percentile,i),ne(t.CFValueType.formula,i)],o=[ne(t.CFValueType.min,i),...s],u=[ne("none",i),...s],v=[ne(t.CFValueType.max,i),...s],[c,m]=C.useState(()=>{var R;const f=t.CFValueType.min;return r&&((R=r.config[0])==null?void 0:R.value.type)||f}),[d,h]=C.useState(()=>{var R;const f="none";return!r||r.config.length!==3?f:((R=r.config[1])==null?void 0:R.value.type)||f}),[p,y]=C.useState(()=>{var R;const f=t.CFValueType.max;return r&&((R=r.config[r.config.length-1])==null?void 0:R.value.type)||f}),[T,S]=C.useState(()=>{if(!r)return 10;const R=r.config[0];return(R==null?void 0:R.value.value)===void 0?10:R==null?void 0:R.value.value}),[_,F]=C.useState(()=>{var A;if(!r||r.config.length!==3)return 50;const R=(A=r.config[1])==null?void 0:A.value.value;return R===void 0?50:R}),[N,E]=C.useState(()=>{var A;if(!r)return 90;const R=(A=r.config[r.config.length-1])==null?void 0:A.value.value;return R===void 0?90:R}),[j,g]=C.useState(()=>{var R;const f="#d0d9fb";return r&&((R=r.config[0])==null?void 0:R.color)||f}),[b,x]=C.useState(()=>{var R;const f="#7790f3";return!r||r.config.length!==3?f:((R=r.config[1])==null?void 0:R.color)||f}),[I,V]=C.useState(()=>{var R;const f="#2e55ef";return r&&((R=r.config[r.config.length-1])==null?void 0:R.color)||f}),M=C.useMemo(()=>f=>{const{minType:R,medianType:A,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:se,medianColor:D,maxColor:L}=f,B=[];return B.push({color:se,value:{type:R,value:X}}),A!=="none"&&B.push({color:D,value:{type:A,value:J}}),B.push({color:L,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 M({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),[M,c,d,p,T,_,N,j,b,I,e]);const O=f=>{n.onChange(M(f))};return l.jsxs("div",{children:[l.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")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:M({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})})}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:univer-text-gray-200",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:o,value:c,onChange:f=>{m(f);const R=t.createDefaultValueByValueType(f,10);S(R),O({minType:f,medianType:d,maxType:p,minValue:R,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"min",className:"univer-ml-1",value:T,type:c,onChange:f=>{S(f),O({minType:c,medianType:d,maxType:p,minValue:f,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:j,onChange:f=>{g(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:f,medianColor:b,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:univer-text-gray-200",children:i.t("sheet.cf.panel.medianValue")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:f=>{h(f);const R=t.createDefaultValueByValueType(f,50);F(R),O({minType:c,medianType:f,maxType:p,minValue:T,medianValue:R,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{F(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:f,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),d!=="none"&&l.jsx(re,{className:"univer-ml-1",color:b,onChange:f=>{x(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,medianColor:f,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:univer-text-gray-200",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:v,value:p,onChange:f=>{y(f);const R=t.createDefaultValueByValueType(f,90);E(R),O({minType:c,medianType:d,maxType:f,minValue:T,medianValue:_,maxValue:R,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"max",className:"univer-ml-1",value:N,type:p,onChange:f=>{E(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:f,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:c,medianType:d,maxType:p,minValue:T,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:f})}})]})]})},oe=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),rt=n=>{var S;const{onChange:e,className:i,value:r,type:s,id:o,disabled:u=!1}=n,v=k.useDependency(a.IUniverInstanceService),c=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(S=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),d=C.useRef(null),[h,p]=C.useState(!1);k.useSidebarClick(_=>{var N;((N=d.current)==null?void 0:N.isClickOutSide(_))&&p(!1)});const y=C.useRef(r),T=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(s)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[s]);if(s===t.CFValueType.formula){const _=String(y.current).startsWith("=")?String(y.current)||"":"=";return l.jsx("div",{className:"univer-ml-3 univer-w-full",children:l.jsx(xe.FormulaEditor,{ref:d,className:w.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 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:univer-bg-gray-700 dark:univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:_,unitId:c,subUnitId:m,isFocus:h,onChange:(F="")=>{e(F||"")},onFocus:()=>p(!0)})})}return l.jsx(w.InputNumber,{className:i,value:Number(r)||0,disabled:u,onChange:_=>{e(_||0)},...T})},kt=n=>{var P;const{interceptorManager:e}=n,i=k.useDependency(a.LocaleService),r=((P=n.rule)==null?void 0:P.type)===t.CFRuleType.dataBar?n.rule:void 0,[s,o]=C.useState(()=>{var R;const f="0";return r?(R=r.config)!=null&&R.isGradient?"1":"0":f}),[u,v]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[c,m]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),d=[oe(t.CFValueType.num,i),oe(t.CFValueType.percent,i),oe(t.CFValueType.percentile,i),oe(t.CFValueType.formula,i)],h=[oe(t.CFValueType.min,i),...d],p=[oe(t.CFValueType.max,i),...d],[y,T]=C.useState(()=>{var R;const f=h[0].value;return r&&((R=r.config)==null?void 0:R.min.type)||f}),[S,_]=C.useState(()=>{var R;const f=p[0].value;return r&&((R=r.config)==null?void 0:R.max.type)||f}),[F,N]=C.useState(()=>{var A;if(!r)return 0;const R=((A=r.config)==null?void 0:A.min)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value||0}),[E,j]=C.useState(()=>{var A;if(!r)return 100;const R=((A=r.config)==null?void 0:A.max)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value===void 0?100:R.value}),[g,b]=C.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),x=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 x({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),[s,F,y,E,S,u,c,e,g]);const I=f=>{n.onChange(x(f))},V=f=>{v(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:f,nativeColor:c,isShowValue:g})},M=f=>{m(f),I({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:f,isShowValue:g})},O=f=>d.map(R=>R.value).includes(f);return l.jsxs("div",{children:[l.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")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:x({isGradient:s,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})})}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:i.t("sheet.cf.panel.fillType")}),l.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[l.jsxs(w.RadioGroup,{value:s,onChange:f=>{o(f),I({isGradient:f,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})},children:[l.jsx(w.Radio,{value:"0",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.pureColor")})}),l.jsx(w.Radio,{value:"1",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.gradient")})})]}),l.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{checked:!g,onChange:f=>{b(!f),I({isGradient:f,minValue:F,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:!f})}}),i.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:i.t("sheet.cf.panel.colorSet")}),l.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[l.jsxs("div",{className:"univer-flex univer-items-center",children:[l.jsx("div",{className:"univer-text-xs",children:i.t("sheet.cf.panel.native")}),l.jsx(re,{color:c,onChange:M})]}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[l.jsx("div",{className:"univer-text-xs",children:i.t("sheet.cf.panel.positive")}),l.jsx(re,{color:u,onChange:V})]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:y,onChange:f=>{T(f);const R=t.createDefaultValueByValueType(f,10);N(R),I({isGradient:s,minValue:R,minValueType:f,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}}),l.jsx(rt,{id:"min",className:"univer-ml-3",disabled:!O(y),type:y,value:F,onChange:f=>{N(f||0),I({isGradient:s,minValue:f||0,minValueType:y,maxValue:E,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:S,onChange:f=>{_(f);const R=t.createDefaultValueByValueType(f,90);j(R),I({isGradient:s,minValue:F,minValueType:y,maxValue:R,maxValueType:f,positiveColor:u,nativeColor:c,isShowValue:g})}}),l.jsx(rt,{className:"univer-ml-3",disabled:!O(S),id:"max",type:S,value:E,onChange:f=>{j(f||0),I({isGradient:s,minValue:F,minValueType:y,maxValue:f||0,maxValueType:S,positiveColor:u,nativeColor:c,isShowValue:g})}})]})]})]})},Ne=n=>[a.BooleanNumber.FALSE,void 0].includes(n)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,je=n=>n!==a.BooleanNumber.FALSE,nt=n=>{const{style:e,onChange:i,className:r}=n,s=k.useDependency(k.ComponentManager),[o,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[v,c]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[m,d]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[h,p]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[y,T]=C.useState(()=>{var x;const b="#2f56ef";return(x=e==null?void 0:e.cl)!=null&&x.rgb?e.cl.rgb:b}),[S,_]=C.useState(()=>{var x;const b="#e8ecfc";return(x=e==null?void 0:e.bg)!=null&&x.rgb?e.bg.rgb:b}),F=s.get("BoldSingle"),N=s.get("ItalicSingle"),E=s.get("UnderlineSingle"),j=s.get("StrikethroughSingle");C.useEffect(()=>{const b={bl:o,it:v};y!==void 0&&(b.cl={rgb:y}),S!==void 0&&(b.bg={rgb:S}),h!==void 0&&(b.st={s:h}),m!==void 0&&(b.ul={s:m}),i(t.removeUndefinedAttr(b))},[o,v,m,h,y,S]);const g="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return l.jsxs("div",{className:w.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[F&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(o||a.BooleanNumber.FALSE)}),onClick:()=>u(Ne(o)),children:l.jsx(F,{})}),N&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(v||a.BooleanNumber.FALSE)}),onClick:()=>c(Ne(v)),children:l.jsx(N,{})}),E&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(m||a.BooleanNumber.FALSE)}),onClick:()=>d(Ne(m)),children:l.jsx(E,{})}),j&&l.jsx("div",{className:w.clsx(g,{"univer-bg-gray-100":je(h||a.BooleanNumber.FALSE)}),onClick:()=>p(Ne(h)),children:l.jsx(j,{})}),l.jsx(re,{color:y,onChange:T,iconId:"FontColor"}),l.jsx(re,{color:S,onChange:_,iconId:"PaintBucket"})]})},Pt=n=>{var j;const{onChange:e,interceptorManager:i}=n,r=k.useDependency(a.LocaleService),o=k.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=o.getActiveSheet(),v=((j=n.rule)==null?void 0:j.type)===t.CFRuleType.highlightCell?n.rule:void 0,c=C.useRef(null),[m,d]=C.useState(!1),h=C.useRef(null),[p,y]=C.useState({}),[T,S]=C.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,F]=C.useState(void 0),N=g=>({style:g.style,value:T,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return N({style:p})}}),[p,T,i]),C.useEffect(()=>i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(b,x,I)=>_||T.length===1||!T.startsWith("=")?(F(r.t("sheet.cf.errorMessage.formulaError")),!1):I(b)}),[_,T]);const E=g=>{e(N(g))};return k.useSidebarClick(g=>{var x;((x=h.current)==null?void 0:x.isClickOutSide(g))&&d(!1)}),l.jsxs("div",{ref:c,children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(xe.FormulaEditor,{ref:h,className:w.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 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:univer-bg-gray-700 dark:univer-text-white hover:univer-border-primary-600",w.borderClassName),errorText:_,isFocus:m,initValue:T,unitId:o.getUnitId(),subUnitId:u==null?void 0:u.getSheetId(),onFocus:()=>{d(!0)},onChange:g=>{S(g),E({style:p})},onVerify:(g,b)=>{!g||b.length===1?F(r.t("sheet.cf.errorMessage.formulaError")):F(void 0)}})}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:N({style:p})})}),l.jsx(nt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:g=>{y(g),E({style:g})}})]})},Ee=n=>l.jsxs("div",{style:{position:"relative"},children:[l.jsx("div",{style:{position:"absolute",zIndex:999,bottom:"-13px",fontSize:"10px",color:"red"},children:n.errorText}),n.children]}),$=(n,e)=>({label:e.t(`sheet.cf.operator.${n}`),value:n}),Dt=n=>{const{type:e,operator:i,onChange:r,value:s,interceptorManager:o}=n,u=k.useDependency(a.LocaleService),[v,c]=C.useState(()=>typeof s=="number"?s:0),[m,d]=C.useState(""),[h,p]=C.useState(()=>typeof s=="string"?s:""),[y,T]=C.useState(""),[S,_]=C.useState(()=>Array.isArray(s)?s[0]===void 0?0:s[0]:0),[F,N]=C.useState(""),[E,j]=C.useState(()=>Array.isArray(s)?s[1]===void 0?100:s[1]:100),[g,b]=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(i)&&r(h);break}case t.CFSubRuleType.number:{[t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(i)&&r(v),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)&&r([S,E]);break}}},[e]),C.useEffect(()=>{const x=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(I,V,M)=>{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(i))return h?M(I):(T(u.t("sheet.cf.errorMessage.notBlank")),!1)}return M(I)}});return()=>{x()}},[e,v,h,i]),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(i)){const x=I=>{p(I),r(I)};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:y,children:l.jsx(w.Input,{value:h,onChange:I=>{T(""),x(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(i)){const x=I=>{c(I||0),r(I||0),d("")};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:m,children:l.jsx(w.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:x})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)){const x=V=>{_(V||0),r([V||0,E]),N("")},I=V=>{j(V||0),r([S,V||0]),b("")};return l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(Ee,{errorText:F,children:l.jsx(w.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:S,onChange:x})}),l.jsx(Ee,{errorText:g,children:l.jsx(w.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},it=(n,e)=>{switch(n){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)]}},st=n=>{var j;const{interceptorManager:e,onChange:i}=n,r=k.useDependency(a.LocaleService),s=((j=n.rule)==null?void 0:j.type)===t.CFRuleType.highlightCell?n.rule:void 0,[o,u]=C.useState(()=>{const g=t.CFSubRuleType.text;return s&&s.subType||g}),v=[{value:t.CFSubRuleType.text,label:r.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:r.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:r.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:r.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:r.t("sheet.cf.subRuleType.uniqueValues")}],c=C.useMemo(()=>it(o,r),[o]),[m,d]=C.useState(()=>{const g=c?c[0].value:void 0;return s&&s.operator||g}),[h,p]=C.useState(()=>{var x;const g="";return s?(x=s.value)!=null?x:t.createDefaultValue(s.subType,s.operator):g}),[y,T]=C.useState({}),S=C.useMemo(()=>g=>{var b,x,I,V,M,O,P,f,R,A,q,X,J,ie,se;switch(g.subType||o){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(m))return{type:t.CFRuleType.highlightCell,subType:(b=g.subType)!=null?b:o,operator:(x=g.operator)!=null?x:m,style:(I=g.style)!=null?I:y,value:(V=g.value)!=null?V:h};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(m))return{type:t.CFRuleType.highlightCell,subType:(M=g.subType)!=null?M:o,operator:(O=g.operator)!=null?O:m,style:(P=g.style)!=null?P:y,value:(f=g.value)!=null?f:h};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(m))return{type:t.CFRuleType.highlightCell,subType:(R=g.subType)!=null?R:o,operator:(A=g.operator)!=null?A:m,style:(q=g.style)!=null?q:y,value:(X=g.value)!=null?X:h};break}}return{type:t.CFRuleType.highlightCell,subType:(J=g.subType)!=null?J:o,operator:(ie=g.operator)!=null?ie:m,style:(se=g.style)!=null?se:y}},[o,m,h,y]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return S({})}}),[S,e]),C.useEffect(()=>{v.some(g=>g.value===o)||u(v[0].value)},[v]);const _=g=>{const b=g,x=it(b,r),I=x&&x[0].value;u(b),d(I),I&&p(t.createDefaultValue(b,I)),i(S({subType:b,operator:I}))},F=g=>{const b=g;d(b),i(S({operator:b}))},N=g=>{p(g),i(S({value:g}))},E=C.useMemo(()=>`${o}_${m}_${Math.random()}`,[o,m]);return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:o,options:v}),(c==null?void 0:c.length)&&l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",onChange:F,value:m||"",options:c})]}),l.jsx(Dt,{value:h,interceptorManager:e,type:o,operator:m,rule:s,onChange:N},E),l.jsx("div",{className:Re,children:l.jsx(de,{rule:S({})})}),l.jsx(nt,{style:s==null?void 0:s.style,className:"univer-ml-1",onChange:g=>{T(g),i(S({style:g}))}})]})},Ct=(n,e)=>(t.iconMap[n]||[])[Number(e)]||"",At=n=>{var d;const{error:e,type:i,onChange:r}=n,s=k.useDependency(a.IUniverInstanceService),o=s.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),u=(d=s.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),v=C.useRef(null),[c,m]=C.useState(!1);return k.useSidebarClick(h=>{var y;((y=v.current)==null?void 0:y.isClickOutSide(h))&&m(!1)}),l.jsx("div",{className:"univer-relative",children:i!==t.CFValueType.formula?l.jsxs(l.Fragment,{children:[l.jsx(w.InputNumber,{className:w.clsx({"univer-border-red-500":e}),value:Number(n.value)||0,onChange:h=>r(h!=null?h:0)}),e&&l.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):l.jsx("div",{className:"univer-w-full",children:l.jsx(xe.FormulaEditor,{ref:v,initValue:String(n.value),unitId:o,subUnitId:u,isFocus:c,onChange:(h="")=>{r(h||"")},onFocus:()=>m(!0)})})})},ot=(n,e,i)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(i.length-1-e)*10},iconType:n,iconId:String(e)}),Lt=C.forwardRef((n,e)=>{const{onClick:i}=n,r=k.useDependency(a.LocaleService),s=o=>{i(o)};return l.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((o,u)=>l.jsxs("div",{className:"univer-mb-3",children:[l.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(o.title)}),l.jsx("div",{className:"univer-flex univer-flex-wrap",children:o.group.map(v=>l.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{s(v.name)},children:l.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100",children:v.list.map((c,m)=>l.jsx("img",{className:"univer-size-5",src:c,draggable:!1},m))})},v.name))})]},u))})}),$t=n=>{const{onClick:e}=n,i=C.useMemo(()=>{const s=[];for(const o in t.iconMap){const u=t.iconMap[o],v=o;u.forEach((c,m)=>{s.push({iconType:v,base64:c,iconId:String(m)})})}return s},[]),r=s=>{e(s.iconType,s.iconId)};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[l.jsx(Te,{className:"univer-size-5"}),l.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),l.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:i.map(s=>l.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",children:l.jsx("img",{className:"univer-size-5",src:s.base64,draggable:!1,onClick:()=>r(s)})},`${s.iconType}_${s.iconId}`))})]})},Bt=n=>{const{onChange:e,configList:i,errorMap:r={}}=n,s=k.useDependency(a.LocaleService),o=[{label:s.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:s.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],u=[{label:s.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:s.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:s.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:s.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],v=(h,p)=>{e([String(p),"value","value"],h)},c=(h,p)=>{e([String(p),"operator"],h);const y=t.createDefaultValue(t.CFSubRuleType.number,h);v(y,p)},m=(h,p)=>{e([String(p),"value","type"],h);const y=i[p],T=t.createDefaultValue(t.CFSubRuleType.number,y.operator);v(T,p)};return C.useMemo(()=>i.map((h,p)=>{const y=r[p],T=Ct(h.iconType,h.iconId),S=p===i.length-1,_=p===0,F=i[p-1],N=(F==null?void 0:F.value.type)===t.CFValueType.formula?s.t("sheet.cf.valueType.formula"):F==null?void 0:F.value.value,E=(j,g)=>{const b={...h,iconId:g,iconType:j};e([String(p)],b)};return l.jsxs("div",{className:p?"univer-mt-6":"univer-mt-3",children:[l.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:[l.jsxs("div",{className:"univer-w-[45%]",children:[s.t("sheet.cf.iconSet.icon"),p+1]}),l.jsx("div",{className:"univer-w-[45%]",children:l.jsxs(l.Fragment,{children:[!_&&!S&&s.t("sheet.cf.iconSet.rule"),!_&&!S&&l.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:univer-text-gray-200",children:["(",s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,S?"":` ${s.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx("div",{className:"univer-flex univer-items-center",children:l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx($t,{onClick:E,iconId:h.iconId,iconType:h.iconType})}),children:l.jsxs("div",{className:w.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 dark:univer-text-gray-200 hover:univer-border-primary-600",w.borderClassName),children:[T?l.jsx("img",{src:T,className:"univer-size-4",draggable:!1}):l.jsx(Te,{className:"univer-size-4"}),l.jsx(Le,{})]})})}),S?l.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[s.t("sheet.cf.iconSet.rule"),l.jsxs("span",{className:"univer-font-medium",children:[s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,S?"":` ${s.t("sheet.cf.iconSet.and")} `]})]}):l.jsx(w.Select,{options:o,value:h.operator,onChange:j=>{c(j,p)}})]}),S?l.jsx("div",{}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:[l.jsx("div",{children:s.t("sheet.cf.iconSet.type")}),l.jsx("div",{children:s.t("sheet.cf.iconSet.value")})]}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:u,value:h.value.type,onChange:j=>{m(j,p)}}),l.jsx("div",{children:l.jsx(At,{id:p,type:h.value.type,error:y,value:h.value.value||"",onChange:j=>{v(j,p)}})})]})]})]},p)}),[i,r])},Ht=n=>{var j;const{interceptorManager:e}=n,i=((j=n.rule)==null?void 0:j.type)===t.CFRuleType.iconSet?n.rule:void 0,r=k.useDependency(a.LocaleService),[s,o]=C.useState({}),[u,v]=C.useState(()=>{const g=Object.keys(t.iconMap)[0];if(i&&i.config.length){const b=i.config[0].iconType;if(!i.config.some(I=>I.iconType!==b))return b}return g}),[c,m]=C.useState(()=>{if(i&&i.config.length)return a.Tools.deepClone(i==null?void 0:i.config);const g=t.iconMap[u]||[];return new Array(g.length).fill("").map((b,x,I)=>x===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:u,iconId:String(x)}:ot(u,x,I))}),[d,h]=C.useState(()=>i?!!i.isShowValue:!0),p=C.useMemo(()=>{const g=c.map(b=>Ct(b.iconType,b.iconId));return l.jsx("div",{className:"univer-flex univer-items-center",children:g.map((b,x)=>b?l.jsx("img",{className:"univer-size-5",src:b},x):l.jsx(Te,{className:"univer-size-5"},x))})},[c]),y=g=>{if(g.reduce((x,I,V)=>x.preType&&!x.result||g.length-1===V?x:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:x.preType?{result:x.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(g[0].value.type)){const x={};return g.forEach((I,V,M)=>{if(V-1<0||V===M.length-1)return;const P=g[V-1],f=t.getOppositeOperator(P.operator);t.compareWithNumber({operator:f,value:P.value.value},I.value.value)||(x[V]=`${r.t(`sheet.cf.form.${f}`,String(P.value.value))} `)}),x}return{}},T=(g,b)=>{a.get(c,g)!==b&&(a.set(c,g,b),m([...c]),o(y(c)))},S=g=>{v(g);const b=t.iconMap[g]||[],x=new Array(b.length).fill("").map((I,V,M)=>ot(g,V,M));m(x),o(y(x))};C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:d,config:c}}});return()=>{g()}},[d,c,e]),C.useEffect(()=>{const g=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(s).length===0}});return()=>{g()}},[d,c,e,s]);const _=()=>{const g=c.map(b=>({...b}));c.forEach((b,x)=>{const I=c.length-1-x,V=g[I];b.iconId=V.iconId,b.iconType=V.iconType}),m([...c])},F=k.useDependency(k.ILayoutService),[N,E]=C.useState();return k.useScrollYOverContainer(N,F.rootContainerElement),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(Lt,{ref:g=>{!N&&g&&E(g)},iconType:u,onClick:S})}),children:l.jsxs("div",{className:w.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",w.borderClassName),children:[p,l.jsx(Le,{})]})})}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[l.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{onChange:_}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),l.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{checked:!d,onChange:g=>{h(!g)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),l.jsx(Bt,{errorMap:s,onChange:T,configList:c})]})},Wt=n=>{var _;const{onChange:e,interceptorManager:i}=n,r=k.useDependency(a.LocaleService),s=((_=n.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?n.rule:void 0,o=[{label:r.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:r.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:r.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:r.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[u,v]=C.useState(()=>{const F=o[0].value,N=s==null?void 0:s.type;if(!s)return F;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(s.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(s.operator)?"lessThanAverage":F;case t.CFSubRuleType.rank:return s.isBottom?"isBottom":"isNotBottom"}}return F}),[c,m]=C.useState(()=>{const N=s==null?void 0:s.type;if(!s)return 10;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.value||10}}return 10}),[d,h]=C.useState(()=>{const N=s==null?void 0:s.type;if(!s)return!1;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.isPercent||!1}}return!1}),[p,y]=C.useState({}),T=F=>{const{type:N,isPercent:E,value:j,style:g}=F;if(N==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:j,style:g};if(N==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:j,style:g};if(N==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:g};if(N==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:g}};C.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return T({type:u,isPercent:d,value:c,style:p})}}),[u,d,c,p,i]);const S=F=>{e(T(F))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",value:u,options:o,onChange:F=>{v(F),S({type:F,isPercent:d,value:c,style:p})}}),["isNotBottom","isBottom"].includes(u)&&l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.InputNumber,{min:1,max:1e3,value:c,onChange:F=>{const N=F||0;m(N),S({type:u,isPercent:d,value:N,style:p})}}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{checked:d,onChange:F=>{h(!!F),S({type:u,isPercent:!!F,value:c,style:p})}}),r.t("sheet.cf.valueType.percent")]})]}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:T({type:u,isPercent:d,value:c,style:p})})}),l.jsx(nt,{style:s==null?void 0:s.style,className:"univer-mt-3",onChange:F=>{y(F),S({type:u,isPercent:d,value:c,style:F})}})]})},qt=a.createInterceptorKey("beforeSubmit"),Gt=a.createInterceptorKey("submit"),at=n=>n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),lt=n=>{var e;return(e=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},zt=n=>{var x,I,V;const e=k.useDependency(a.LocaleService),i=k.useDependency(a.ICommandService),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(t.ConditionalFormattingRuleModel),o=k.useDependency(U.SheetsSelectionsService),u=at(r),v=lt(r),[c,m]=C.useState(void 0),d=C.useRef((I=(x=n.rule)==null?void 0:x.ranges)!=null?I:[]),h=C.useMemo(()=>{var O,P,f;let M=(O=n.rule)==null?void 0:O.ranges;return M!=null&&M.length||(M=(f=(P=o.getCurrentSelections())==null?void 0:P.map(R=>R.range))!=null?f:[]),d.current=M,M!=null&&M.length?M.map(R=>{const A=Ge.serializeRange(R);return A==="NaN"?"":A}).filter(R=>!!R).join(","):""},[n.rule]),p=[{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"}],[y,T]=C.useState(()=>{var P,f;const M=(P=n.rule)==null?void 0:P.rule.type,O=p[0].value;if(!M)return O;switch(M){case t.CFRuleType.highlightCell:{switch((f=n.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}),S=C.useRef(void 0),_=C.useMemo(()=>new a.InterceptorManager({beforeSubmit:qt,submit:Gt}),[]),F=C.useMemo(()=>{switch(y){case"1":return st;case"2":return Wt;case"3":return kt;case"4":return Ut;case"5":return Pt;case"6":return Ht;default:return st}},[y]);C.useEffect(()=>{const M=i.onCommandExecuted(O=>{if(O.id===U.RemoveSheetMutation.id){const P=O.params;P.subUnitId===v&&P.unitId===u&&n.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>M.dispose()},[]);const N=M=>{S.current=M},E=M=>{const O=M.split(",").filter(P=>!!P).map(Ge.deserializeRangeWithSheet).map(P=>P.range);d.current=O},j=()=>{if(c)return;const O=(()=>{const f=r.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 R=at(r),A=lt(r);if(!R||!A)throw new Error("No active sheet found");let q={};n.rule&&n.rule.cfId?(q={...n.rule,ranges:O,rule:f},i.executeCommand(t.SetCfCommand.id,{unitId:R,subUnitId:A,rule:q}),n.onCancel()):(q={cfId:s.createCfId(R,A),ranges:O,rule:f,stopIfTrue:!1},i.executeCommand(t.AddCfCommand.id,{unitId:R,subUnitId:A,rule:q}),n.onCancel())}}},g=()=>{n.onCancel()},b=(M,O)=>{M?O.length<1?m(e.t("sheet.cf.errorMessage.rangeError")):m(void 0):m(e.t("sheet.cf.errorMessage.rangeError"))};return l.jsxs("div",{children:[l.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")}),l.jsxs("div",{className:"univer-mt-4",children:[l.jsx(xe.RangeSelector,{unitId:u,subUnitId:v,initialValue:h,onChange:(M,O)=>E(O),onVerify:b}),c&&l.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:c})]}),l.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")}),l.jsx(w.Select,{className:"univer-mt-4 univer-w-full",value:y,options:p,onChange:M=>T(M)}),l.jsx(F,{interceptorManager:_,rule:(V=n.rule)==null?void 0:V.rule,onChange:N}),l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[l.jsx(w.Button,{onClick:g,children:e.t("sheet.cf.panel.cancel")}),l.jsx(w.Button,{className:"univer-ml-3",variant:"primary",onClick:j,children:e.t("sheet.cf.panel.submit")})]})]})};var Yt=Object.getOwnPropertyDescriptor,Zt=(n,e,i,r)=>{for(var s=r>1?void 0:r?Yt(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},Kt=(n,e)=>(i,r)=>e(i,r,n);let ue=class extends a.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const i=/\{([^}]+)?\}/g,r=[];let s=i.exec(e);for(;s;)r.push({startIndex:s.index,key:Number(s[1]),endIndex:s.index+s[0].length-1}),s=i.exec(e);return r});this._localeService=e,this._initLocal()}tWithReactNode(e,...i){const r=this._localeService.getLocales(),s=e.split("."),o=r&&this._localeService.resolveKeyPath(r,s);if(typeof o=="string"){const u=[];return this._findReplaceIndex(o).forEach((v,c,m)=>{const d=m[c-1]||{endIndex:-1};if(d.endIndex+1<v.startIndex){const h=o.slice(d.endIndex+1,v.startIndex);h&&u.push(h)}if(i[v.key]&&u.push(i[v.key]),c===m.length-1){const h=o.slice(v.endIndex+1);h&&u.push(h)}}),u}return[]}};ue=Zt([Kt(0,a.Inject(a.LocaleService))],ue);const Xt=(n,e)=>{const i=n.rule;switch(i.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(i.subType){case t.CFSubRuleType.average:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,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 r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(i.value)?i.value.map(s=>String(s)):[String(i.value||"")])}case t.CFSubRuleType.text:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,i.value||"")}case t.CFSubRuleType.timePeriod:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`)}case t.CFSubRuleType.rank:return i.isPercent?i.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(i.value)):e.t("sheet.cf.preview.describe.topNPercent",String(i.value)):i.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(i.value)):e.t("sheet.cf.preview.describe.topN",String(i.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let ut=0;const Jt=n=>{const{onClick:e}=n,i=k.useDependency(t.ConditionalFormattingRuleModel),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(U.SheetsSelectionsService),o=k.useDependency(a.ICommandService),u=k.useDependency(a.LocaleService),v=k.useDependency(a.Injector),c=k.useDependency(k.ISidebarService),m=k.useDependency(ue),d=k.useObservable(()=>r.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),h=d.getUnitId(),p=d.getActiveSheet();if(!p)throw new Error("No active sheet found");const y=p.getSheetId(),[T,S]=C.useState([]),[_,F]=C.useState("2"),[N,E]=C.useState(0),[j,g]=C.useState(-1),[b,x]=C.useState(ut),I=C.useRef(null),V=[{label:u.t("sheet.cf.panel.workSheet"),value:"2"},{label:u.t("sheet.cf.panel.selectedRange"),value:"1"}],M=()=>{const D=i.getSubunitRules(h,y);if(!D||!D.length)return[];if(_==="1"){const L=s.getCurrentLastSelection();if(!L)return[];const B=L.range;return D.filter(G=>G.ranges.some(z=>a.Rectangle.intersects(z,B)))}else if(_==="2")return[...D];return[]},[O,P]=C.useState(M);H.useHighlightRange(T),C.useEffect(()=>{const D=o.onCommandExecuted(L=>{L.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{P(M)},[_,N,h,y]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(L=>{const B=[U.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],W=o.onCommandExecuted(G=>{const{id:z,params:ee}=G,te=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(z)&&ee.unitId===te&&L.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{P(M)});return()=>{D.unsubscribe()}},[r,_,h,y]),C.useEffect(()=>{const D=i.$ruleChange.subscribe(()=>{E(Math.random())});return()=>D.unsubscribe()},[i]),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 ut=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=_e=>{_e.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{x(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const L=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!L||!B)throw new Error("No active sheet found");o.executeCommand(t.DeleteCfCommand.id,{unitId:L,subUnitId:B,cfId:D.cfId})},R=(D,L)=>{g(L.y)},A=(D,L,B)=>{var _e;g(-1);const W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(_e=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_e.getSheetId();if(!W||!G)throw new Error("No active sheet found");const z=It=>{const xt=O.length;return Math.min(xt-1,Math.max(0,It))},ee=O[z(L.y)].cfId,te=O[z(B.y)].cfId;ee!==te&&o.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>L.y?"after":"before"}})},q=()=>{n.onCreate()},X=()=>{_==="2"?o.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(L=>({unitId:h,subUnitId:y,cfId:L.cfId})).forEach(L=>{o.executeCommand(t.DeleteCfCommand.id,L)})},J=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),L=D.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),L.getSheetId(),W)})},[O]),ie=J.map((D,L)=>({i:D.cfId,x:0,w:12,y:L,h:1,isResizable:!1})),se=C.useMemo(()=>{const D=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET),L=D.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(v,D.getUnitId(),L.getSheetId(),W)})},[O]);return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:m.tWithReactNode("sheet.cf.panel.managerRuleSelect",l.jsx(w.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{F(D)}})).map((D,L)=>l.jsx("span",{children:D},L))}),l.jsxs("div",{className:"univer-flex univer-justify-end",children:[l.jsx(w.Tooltip,{title:u.t("sheet.cf.panel.createRule"),placement:"bottom",children:l.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:l.jsx(gt,{})})}),O.length&&se?l.jsx(w.Tooltip,{title:u.t("sheet.cf.panel.clear"),placement:"bottom",children:l.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:l.jsx(Ve,{className:"univer-text-red-500"})})}):l.jsx("div",{children:l.jsx(Ve,{className:"univer-text-gray-300"})})]})]}),l.jsx("div",{ref:I,children:b>0&&l.jsx(w.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:b,margin:[0,10],onDragStop:A,onDragStart:R,children:J==null?void 0:J.map((D,L)=>l.jsx("div",{children:l.jsxs("div",{className:w.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",{"univer-bg-gray-100":j===L}),onMouseMove:()=>{D.ranges!==T&&S(D.ranges)},onMouseLeave:()=>S([]),onClick:()=>{e(D)},children:[l.jsx("div",{className:w.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:l.jsx(ft,{})}),l.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:univer-text-white",children:Xt(D,u)}),l.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(B=>Ge.serializeRange(B)).join(",")})]}),l.jsx("div",{children:l.jsx(de,{rule:D.rule})}),l.jsx("div",{className:w.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":j===L}),onClick:B=>{B.stopPropagation(),f(D),S([])},children:l.jsx(Ve,{})})]})},`${D.cfId}`))})})]})},Qt=n=>{const[e,i]=C.useState(n.rule),[r,s]=C.useState(!!n.rule),o=()=>{s(!0)},u=()=>{s(!1),i(void 0)},v=c=>{i(c),s(!0)};return l.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:r?l.jsx(zt,{onCancel:u,rule:e}):l.jsx(Jt,{onClick:v,onCreate:o})})};var en=Object.getOwnPropertyDescriptor,tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?en(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},me=(n,e)=>(i,r)=>e(i,r,n);const Me="sheet.conditional.formatting.panel";let Ce=class extends a.Disposable{constructor(e,i,r,s,o){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=i,this._componentManager=r,this._sidebarService=s,this._localeService=o,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{var v;u||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(u=>{u.id===Me&&(u.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const i={id:Me,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Me,rule:e,key:a.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(i)}_initPanel(){this._componentManager.register(Me,Qt)}};Ce=tn([me(0,a.IUniverInstanceService),me(1,a.Inject(a.Injector)),me(2,a.Inject(k.ComponentManager)),me(3,a.Inject(k.ISidebarService)),me(4,a.Inject(a.LocaleService))],Ce);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 Fe={id:"sheet.operation.open.conditional.formatting.panel",type:a.CommandType.OPERATION,handler:(n,e)=>{var v;const i=n.get(Ce),r=n.get(U.SheetsSelectionsService),s=n.get(a.ICommandService),o=((v=r.getCurrentSelections())==null?void 0:v.map(c=>c.range))||[];switch(e.value){case 3:{i.openPanel({...t.createDefaultRule(),ranges:o});break}case 4:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};i.openPanel(c);break}case 5:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};i.openPanel(c);break}case 6:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.colorScale,config:[]}};i.openPanel(c);break}case 7:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};i.openPanel(c);break}case 8:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};i.openPanel(c);break}case 2:{i.openPanel();break}case 1:{i.openPanel({...t.createDefaultRule(),ranges:o});break}case 9:{s.executeCommand(t.ClearRangeCfCommand.id,{ranges:o});break}case 10:{s.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var nn=Object.getOwnPropertyDescriptor,rn=(n,e,i,r)=>{for(var s=r>1?void 0:r?nn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},ve=(n,e)=>(i,r)=>e(i,r,n);let ye=class extends a.Disposable{constructor(e,i,r,s,o){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=i,this._injector=r,this._conditionalFormattingViewModel=s,this._univerInstanceService=o,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,i,r)=>this._collectConditionalRule(e,i,r),onPasteCells:(e,i,r,s)=>{const{copyType:o=H.COPY_TYPE.COPY,pasteType:u}=s,{range:v}=e||{},{range:c}=i;return this._generateConditionalFormattingMutations(c,{copyType:o,pasteType:u,copyRange:v})}}))}_collectConditionalRule(e,i,r){const s=new a.ObjectMatrix,o={};this._copyInfo={matrix:s,info:{unitId:e,subUnitId:i,cfMap:o}};const u=this._injector.invoke(d=>U.rangeToDiscreteRange(r,d,e,i));if(!u)return;const{rows:v,cols:c}=u,m=new Set;v.forEach((d,h)=>{c.forEach((p,y)=>{const T=this._conditionalFormattingViewModel.getCellCfs(e,i,d,p);T&&(T.forEach(S=>m.add(S.cfId)),s.setValue(h,y,T.map(S=>S.cfId)))})}),m.forEach(d=>{const h=this._conditionalFormattingRuleModel.getRule(e,i,d);h&&(o[d]=h.rule)})}_generateConditionalFormattingMutations(e,i){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),o=r.getUnitId();if(!s)return{redos:[],undos:[]};const u=s.getSheetId();if(i.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!i.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(i.pasteType))return{redos:[],undos:[]};const{ranges:[c,m],mapFunc:d}=H.virtualizeDiscreteRanges([i.copyRange,e]),h=H.getRepeatRange(c,m,!0),p={};a.Range.foreach(m,(g,b)=>{const{row:x,col:I}=d(g,b),V=this._conditionalFormattingViewModel.getCellCfs(o,u,x,I);V&&V.forEach(M=>{if(!p[M.cfId]){const O=new a.ObjectMatrix;p[M.cfId]=O;const P=this._conditionalFormattingRuleModel.getRule(o,u,M.cfId);P==null||P.ranges.forEach(f=>{a.Range.foreach(f,(R,A)=>{O.setValue(R,A,1)})})}p[M.cfId].realDeleteValue(x,I)})});const{matrix:y,info:T}=this._copyInfo,S=[];let _=this._conditionalFormattingRuleModel.createCfId(o,u);const F={},N=g=>{if(F[g])return F[g];const b=T==null?void 0:T.cfMap[g],x=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...S].find(I=>a.Tools.diffValue(I.rule,b));if(x)return F[g]=x,x;{const I={rule:b,cfId:_,ranges:[],stopIfTrue:!1};return F[g]=I,S.push(I),_=`${Number(_)+1}`,I}};h.forEach(g=>{y&&y.forValue((b,x,I)=>{const V=a.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:x,endColumn:x},g.startRange),{row:M,col:O}=d(V.startRow,V.startColumn);I.forEach(P=>{if(!p[P]){const f=N(P),R=new a.ObjectMatrix;p[P]=R,f.ranges.forEach(A=>{a.Range.foreach(A,(q,X)=>{R.setValue(q,X,1)})})}p[P].setValue(M,O,1)})})});const E=[],j=[];for(const g in p){const b=p[g],x=U.findAllRectangle(U.createTopMatrixFromMatrix(b));if(!x.length){const I={unitId:o,subUnitId:u,cfId:g};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),j.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(S.some(I=>I.cfId===g)){const I=N(g),V={unitId:o,subUnitId:u,rule:{...I,ranges:x}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),j.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(o,u,g);if(!I)continue;const V={unitId:o,subUnitId:u,rule:{...I,ranges:x}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),j.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:j}}};ye=rn([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))],ye);var sn=Object.getOwnPropertyDescriptor,on=(n,e,i,r)=>{for(var s=r>1?void 0:r?sn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},Be=(n,e)=>(i,r)=>e(i,r,n);let Se=class extends a.Disposable{constructor(n,e,i){super(),this._localeService=n,this._commandService=e,this._sheetPermissionCheckController=i,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{n.id===t.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},n.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Se=on([Be(0,a.Inject(a.LocaleService)),Be(1,a.ICommandService),Be(2,a.Inject(U.SheetPermissionCheckController))],Se);var an=Object.getOwnPropertyDescriptor,ln=(n,e,i,r)=>{for(var s=r>1?void 0:r?an(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},we=(n,e)=>(i,r)=>e(i,r,n);let be=class extends a.Disposable{constructor(n,e,i,r){super(),this._conditionalFormattingRuleModel=n,this._univerInstanceService=e,this._injector=i,this._refRangeService=r,this._initRefRange()}_initRefRange(){const n=new Map,e=(r,s,o)=>`${r}_${s}_${o}`,i=(r,s,o)=>{const u=c=>{const m=[...o.ranges],d=m.map(p=>U.handleDefaultRangeChangeWithEffectRefCommands(p,c)).filter(p=>!!p);if(t.isRangesEqual(d,m))return{redos:[],undos:[]};if(d.length){const p={unitId:r,subUnitId:s,rule:{...o,ranges:d}},y=[{id:t.SetConditionalRuleMutation.id,params:p}],T=t.setConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:T}}else{const p={unitId:r,subUnitId:s,cfId:o.cfId},y=[{id:t.DeleteConditionalRuleMutation.id,params:p}],T=t.DeleteConditionalRuleMutationUndoFactory(this._injector,p);return{redos:y,undos:T}}},v=[];o.ranges.forEach(c=>{const m=this._refRangeService.registerRefRange(c,u);v.push(()=>m.dispose())}),n.set(e(r,s,o.cfId),()=>v.forEach(c=>c()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(r=>{const{unitId:s,subUnitId:o,rule:u}=r,v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!(r.unitId!==v.getUnitId()||r.subUnitId!==(c==null?void 0:c.getSheetId())))switch(r.type){case"add":{i(r.unitId,r.subUnitId,r.rule);break}case"delete":{const m=n.get(e(s,o,u.cfId));m&&m();break}case"set":{const m=n.get(e(s,o,u.cfId));m&&m(),i(r.unitId,r.subUnitId,r.rule)}}})),this.disposeWithMe(a.toDisposable(()=>{n.forEach(r=>{r()}),n.clear()}))}};be=ln([we(0,a.Inject(t.ConditionalFormattingRuleModel)),we(1,a.Inject(a.IUniverInstanceService)),we(2,a.Inject(a.Injector)),we(3,a.Inject(U.RefRangeService))],be);var un=Object.getOwnPropertyDescriptor,cn=(n,e,i,r)=>{for(var s=r>1?void 0:r?un(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},ae=(n,e)=>(i,r)=>e(i,r,n);let Ie=class extends a.Disposable{constructor(e,i,r,s,o,u){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=i,this._univerInstanceService=r,this._renderManagerService=s,this._conditionalFormattingViewModel=o,this._conditionalFormattingRuleModel=u,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var i,r,s;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();(i=this._renderManagerService.getRenderById(e))==null||i.with(H.SheetSkeletonManagerService).reCalculate(),(s=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||s.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();return r?e.filter(s=>s.unitId===i.getUnitId()&&s.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,i,r)=>{const s=this._conditionalFormattingService.composeStyle(i.unitId,i.subUnitId,i.row,i.col);if(!s)return r(e);const o=i.workbook.getStyles(),v={...(typeof(e==null?void 0:e.s)=="string"?o.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},c={...e,s:v};return s.style&&Object.assign(v,s.style),c.fontRenderExtension||(c.fontRenderExtension={},s.isShowValue!==void 0&&(c.fontRenderExtension.isSkip=!s.isShowValue)),s.dataBar&&(c.dataBar=s.dataBar),s.iconSet&&(c.iconSet=s.iconSet,c.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(c)},priority:10}))}};Ie=cn([ae(0,a.Inject(U.SheetInterceptorService)),ae(1,a.Inject(t.ConditionalFormattingService)),ae(2,a.Inject(a.IUniverInstanceService)),ae(3,a.Inject(ht.IRenderManagerService)),ae(4,a.Inject(t.ConditionalFormattingViewModel)),ae(5,a.Inject(t.ConditionalFormattingRuleModel))],Ie);const yt="sheets-conditional-formatting-ui.config",Oe={};var dn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,vn=(n,e,i)=>e in n?dn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,hn=(n,e,i,r)=>{for(var s=r>1?void 0:r?mn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},He=(n,e)=>(i,r)=>e(i,r,n),St=(n,e,i)=>vn(n,typeof e!="symbol"?e+"":e,i);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends a.Plugin{constructor(e=Oe,i,r,s){super(),this._config=e,this._injector=i,this._commandService=r,this._configService=s;const{menu:o,...u}=a.merge({},Oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yt,u),this._initCommand(),this._injector.add([Ie]),this._injector.add([be]),this._injector.add([ye]),this._injector.add([Se]),this._injector.add([ue])}_initCommand(){[ze,Ye,Ze,Ke,Xe,Je,Qe,et,tt,Fe].forEach(e=>{this._commandService.registerCommand(e)})}};St(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);St(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=hn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),He(1,a.Inject(a.Injector)),He(2,a.Inject(a.ICommandService)),He(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var pn=Object.getOwnPropertyDescriptor,gn=(n,e,i,r)=>{for(var s=r>1?void 0:r?pn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},he=(n,e)=>(i,r)=>e(i,r,n);let Ue=class extends a.Disposable{constructor(n,e,i,r,s){super(),this._injector=n,this._univerInstanceService=e,this._autoFillService=i,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=s,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),e=(s,o,u,v,c)=>{var y;const m=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(y=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId();if(!m||!d)return;const h={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},p={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row};a.Range.foreach(u,(T,S)=>{const _=a.Rectangle.getPositionRange({startRow:T,startColumn:S,endColumn:S,endRow:T},h),F=a.Rectangle.getPositionRange({startRow:T,startColumn:S,endColumn:S,endRow:T},p),{row:N,col:E}=c(_.startRow,_.startColumn),j=this._conditionalFormattingViewModel.getCellCfs(m,d,N,E),{row:g,col:b}=c(F.startRow,F.startColumn),x=this._conditionalFormattingViewModel.getCellCfs(m,d,g,b);x&&x.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.realDeleteValue(g,b)}),j&&j.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(m,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.setValue(g,b,1)})})},i=(s,o)=>{var F,N,E;const u=(F=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:F.getUnitId(),v=(E=(N=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getActiveSheet())==null?void 0:E.getSheetId(),c=new Map,m=[],d=[];if(!u||!v)return n();const h=H.virtualizeDiscreteRanges([s,o]),[p,y]=h.ranges,{mapFunc:T}=h,S={row:p.startRow,col:p.startColumn};return H.getAutoFillRepeatRange(p,y).forEach(j=>{e(S,j.repeatStartCell,j.relativeRange,c,T)}),c.forEach((j,g)=>{const b=this._conditionalFormattingRuleModel.getRule(u,v,g);if(!b)return;const x=U.findAllRectangle(U.createTopMatrixFromMatrix(j));if(x.length){const I={unitId:u,subUnitId:v,rule:{...b,ranges:x}};m.push({id:t.SetConditionalRuleMutation.id,params:I}),d.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:u,subUnitId:v,cfId:b.cfId};m.push({id:t.DeleteConditionalRuleMutation.id,params:I}),d.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:m}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(s,o,u)=>{if(u===H.APPLY_TYPE.COPY||u===H.APPLY_TYPE.ONLY_FORMAT||u===H.APPLY_TYPE.SERIES){const{source:v,target:c}=s;return i(v,c)}return n()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ue=gn([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))],Ue);var fn=Object.getOwnPropertyDescriptor,Cn=(n,e,i,r)=>{for(var s=r>1?void 0:r?fn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},pe=(n,e)=>(i,r)=>e(i,r,n);exports.ConditionalFormattingClearController=class extends a.Disposable{constructor(e,i,r,s,o){super(),this._injector=e,this._univerInstanceService=i,this._sheetInterceptorService=r,this._selectionManagerService=s,this._conditionalFormattingRuleModel=o,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var o;const i=[],r=[],s={redos:i,undos:r};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(T=>T.range);if(!u)return s;const v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!c)return s;const m=v.getUnitId(),d=c.getSheetId(),h=this._conditionalFormattingRuleModel.getSubunitRules(m,d);if(!h||!h.length)return s;const{redos:p,undos:y}=ct(this._injector,h,u,m,d);i.push(...p),r.push(...y)}return s}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:i,ranges:r})=>{const s=[],o=[],u={redos:s,undos:o};if(!r||!r.length)return u;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,i);if(!v||!v.length)return u;const{redos:c,undos:m}=ct(this._injector,v,r,e,i);return s.push(...c),o.push(...m),u}}))}};exports.ConditionalFormattingClearController=Cn([pe(0,a.Inject(a.Injector)),pe(1,a.Inject(a.IUniverInstanceService)),pe(2,a.Inject(U.SheetInterceptorService)),pe(3,a.Inject(U.SheetsSelectionsService)),pe(4,a.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ct(n,e,i,r,s){const o=[],u=[];return e.filter(v=>i.some(c=>v.ranges.some(m=>a.Rectangle.getIntersects(m,c)))).forEach(v=>{const m=new U.RangeMergeUtil().add(...v.ranges).subtract(...i).merge();if(m.length){const d={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:s,rule:{...v,ranges:m}}},h=t.setConditionalRuleMutationUndoFactory(n,d.params);o.push(d),u.push(...h)}else{const d={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:s,cfId:v.cfId}},h=t.DeleteConditionalRuleMutationUndoFactory(n,d.params);o.push(d),u.push(...h)}}),{redos:o,undos:u}}var yn=Object.getOwnPropertyDescriptor,Sn=(n,e,i,r)=>{for(var s=r>1?void 0:r?yn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},dt=(n,e)=>(i,r)=>e(i,r,n);let ke=class extends a.Disposable{constructor(n,e){super(),this._sheetInterceptorService=n,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(n,e,i)=>{var u,v,c;n||i(n);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),s=(u=r==null?void 0:r.style)!=null?u:{},o=Object.keys(s);if(n!=null&&n.p)return(c=(v=n.p.body)==null?void 0:v.textRuns)==null||c.forEach(m=>{m.ts&&o.forEach(d=>{var h;(h=m.ts)==null||delete h[d]})}),i(n);{const m={...(typeof(n==null?void 0:n.s)=="string"?e.workbook.getStyles().get(n.s):n==null?void 0:n.s)||{}};o.forEach(h=>{delete m[h]});const d={...n,s:{...m}};return i(d)}}})))}};ke=Sn([dt(0,a.Inject(U.SheetInterceptorService)),dt(1,a.Inject(t.ConditionalFormattingService))],ke);const mt=[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: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}],bn=n=>{const e=n.get(U.SheetsSelectionsService),i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=n.get(t.ConditionalFormattingRuleModel),o=new K.Observable(c=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(m=>{const d=i.onCommandExecuted(h=>{var S;const{id:p,params:y}=h,T=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===T&&m.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var S;const m=((S=e.getCurrentSelections())==null?void 0:S.map(_=>_.range))||[],d=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d)return;const h=d.getActiveSheet();if(!h)return;const T=(s.getSubunitRules(d.getUnitId(),h.getSheetId())||[]).filter(_=>_.ranges.some(F=>m.some(N=>a.Rectangle.intersects(N,F)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(n,d.getUnitId(),h.getSheetId(),_));c.next(T)})),u=new K.Observable(c=>new K.Observable(m=>{const d=i.onCommandExecuted(h=>{var S;const{id:p,params:y}=h,T=(S=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:S.getUnitId();mt.includes(p)&&y.unitId===T&&m.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const m=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!m)return;const d=m.getActiveSheet();if(!d)return;const h=s.getSubunitRules(m.getUnitId(),d.getSheetId())||[];if(!h.length)return c.next(!1),!1;const p=h.map(y=>y.ranges).every(y=>U.checkRangesEditablePermission(n,m.getUnitId(),d.getSheetId(),y));c.next(p)})),v=new K.Observable(c=>{o.subscribe(m=>{const d=ge.find(h=>h.value===Y.clearRangeRules);d&&(d.disabled=!m,c.next(ge))}),u.subscribe(m=>{const d=ge.find(h=>h.value===Y.clearWorkSheetRules);d&&(d.disabled=!m,c.next(ge))}),c.next(ge)});return{id:Fe.id,type:k.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:v,hidden$:k.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(n,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},In={[k.RibbonStartGroup.FORMULAS_INSERT]:{[Fe.id]:{order:0,menuItemFactory:bn}}};var xn=Object.getOwnPropertyDescriptor,Tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?xn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},vt=(n,e)=>(i,r)=>e(i,r,n);let Pe=class extends a.Disposable{constructor(e,i){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=i,this._menuManagerService.mergeMenu(In)}};Pe=Tn([vt(0,a.Inject(a.Injector)),vt(1,k.IMenuManagerService)],Pe);var Rn=Object.getOwnPropertyDescriptor,Fn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Rn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},le=(n,e)=>(i,r)=>e(i,r,n);const _n=(n,e)=>{const i=d=>d.endRow-d.startRow+1,r=d=>d.endColumn-d.startColumn+1,s=i(e)%i(n),o=r(e)%r(n),u=Math.floor(i(e)/i(n)),v=Math.floor(r(e)/r(n)),c=[],m={startRow:0,endRow:i(n)-1,startColumn:0,endColumn:r(n)-1};if(i(e)===1&&r(e)===1){const d={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return c.push({repeatRelativeRange:m,startRange:d}),c}for(let d=0;d<u+(s?.1:0);d++)for(let h=0;h<v+(o?.1:0);h++){const p=i(n)*d,y=r(n)*h,T={startRow:p+e.startRow,endRow:p+e.startRow,startColumn:y+e.startColumn,endColumn:y+e.startColumn};let S=m;d===u&&s&&(S={...S},S.endRow=S.endRow-(i(n)-s)),h===v&&o&&(S={...S},S.endColumn=S.endColumn-(r(n)-o)),c.push({repeatRelativeRange:S,startRange:T})}return c};let De=class extends a.Disposable{constructor(e,i,r,s,o,u){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=i,this._formatPainterService=r,this._sheetsSelectionsService=s,this._conditionalFormattingRuleModel=o,this._conditionalFormattingViewModel=u,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),i=(o,u,v,c,m)=>{const{unitId:d,subUnitId:h}=this._painterConfig,{targetUnitId:p,targetSubUnitId:y}=m,T={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},S={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};a.Range.foreach(v,(_,F)=>{const N=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},T),E=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},S),j=this._conditionalFormattingViewModel.getCellCfs(d,h,N.startRow,N.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(p,y,E.startRow,E.startColumn);g&&g.forEach(b=>{let x=c.get(b.cfId);if(!c.get(b.cfId)){const I=this._conditionalFormattingRuleModel.getRule(p,y,b.cfId);if(!I)return;x=new a.ObjectMatrix,I.ranges.forEach(V=>{a.Range.foreach(V,(M,O)=>{x.setValue(M,O,1)})}),c.set(b.cfId,x)}x.realDeleteValue(E.startRow,E.startColumn)}),j&&j.forEach(b=>{const x=c.get(b.cfId);x&&x.setValue(E.startRow,E.startColumn,1)})})},r=(o,u,v)=>{var N;const{range:c,unitId:m,subUnitId:d}=this._painterConfig,h=o!==m||d!==u,p=new Map,y=[],T=[];if(!o||!u||!m||!d)return e();const S=(N=this._conditionalFormattingRuleModel.getSubunitRules(m,d))!=null?N:[];S==null||S.forEach(E=>{const{ranges:j,cfId:g}=E;if(j.some(b=>a.Rectangle.intersects(c,b))){const b=new a.ObjectMatrix;h||j.forEach(x=>{a.Range.foreach(x,(I,V)=>{b.setValue(I,V,1)})}),p.set(g,b)}});const _={row:c.startRow,col:c.startColumn};return _n(c,v).forEach(E=>{i(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,p,{targetUnitId:o,targetSubUnitId:u})}),p.forEach((E,j)=>{if(h){const g=this._conditionalFormattingRuleModel.getRule(o,u,j),b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(g)if(b.length){const x={unitId:o,subUnitId:u,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:x}),T.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:o,subUnitId:u,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:x}),T.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}else if(b.length){const x=this._conditionalFormattingRuleModel.getRule(m,d,j);if(x){const I={unitId:o,subUnitId:u,rule:{...a.Tools.deepClone(x),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:b}};y.push({id:t.AddConditionalRuleMutation.id,params:I}),T.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const g=this._conditionalFormattingRuleModel.getRule(m,d,j);if(!g)return;const b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(b.length){const x={unitId:m,subUnitId:d,rule:{...g,ranges:b}};y.push({id:t.SetConditionalRuleMutation.id,params:x}),T.push(...t.setConditionalRuleMutationUndoFactory(this._injector,x))}else{const x={unitId:m,subUnitId:d,cfId:g.cfId};y.push({id:t.DeleteConditionalRuleMutation.id,params:x}),T.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,x))}}}),{undos:T,redos:y}},s={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:o=>{var u,v,c;switch(o){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const m=(u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:u.getUnitId(),d=(c=(v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:c.getSheetId(),h=this._sheetsSelectionsService.getCurrentLastSelection(),p=h==null?void 0:h.range;m&&d&&p&&(this._painterConfig={unitId:m,subUnitId:d,range:p});break}case H.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(o,u,v)=>this._painterConfig?r(o,u,v):{redos:[],undos:[]}};this._formatPainterService.addHook(s)}};De=Fn([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 Nn=Object.getOwnPropertyDescriptor,jn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Nn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},We=(n,e)=>(i,r)=>e(i,r,n);let Ae=class extends a.Disposable{constructor(n,e,i){super(),this._conditionalFormattingViewModel=n,this._univerInstanceService=e,this._renderManagerService=i,this._init()}_init(){const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),e=i=>{const r=i.getUnitId(),s=this._renderManagerService.getRenderById(r);if(!s)return;const o=s.with(H.SheetSkeletonManagerService);this.disposeWithMe(o.currentSkeleton$.subscribe(u=>{if(u){const v=u.skeleton.rowColumnSegment,c=v.endColumn-v.startColumn+1,d=(v.endRow-v.startRow+1)*c*9,h=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,d);this._conditionalFormattingViewModel.setCacheLength(h)}}))};n&&e(n),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{i&&e(i)})}};Ae=jn([We(0,a.Inject(t.ConditionalFormattingViewModel)),We(1,a.IUniverInstanceService),We(2,ht.IRenderManagerService)],Ae);var En=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,wn=(n,e,i)=>e in n?En(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,Vn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Mn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},qe=(n,e)=>(i,r)=>e(i,r,n),bt=(n,e,i)=>wn(n,typeof e!="symbol"?e+"":e,i);exports.UniverSheetsConditionalFormattingUIPlugin=class extends a.Plugin{constructor(e=Oe,i,r,s){super(),this._config=e,this._injector=i,this._commandService=r,this._configService=s;const{menu:o,...u}=a.merge({},Oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yt,u),this._initCommand()}onStarting(){a.registerDependencies(this._injector,[[Ie],[be],[ye],[Ue],[Se],[Ce],[Pe],[ue],[ke],[exports.ConditionalFormattingClearController],[De],[Ae]]),a.touchDependencies(this._injector,[[Ie]])}onReady(){a.touchDependencies(this._injector,[[Pe],[Ce]])}onRendered(){a.touchDependencies(this._injector,[[Ue],[exports.ConditionalFormattingClearController],[ye],[ke],[ue],[De],[Se],[be],[Ae]])}_initCommand(){[ze,Ye,Ze,Ke,Xe,Je,Qe,et,tt,Fe].forEach(e=>{this._commandService.registerCommand(e)})}};bt(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);bt(exports.UniverSheetsConditionalFormattingUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Vn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),qe(1,a.Inject(a.Injector)),qe(2,a.Inject(a.ICommandService)),qe(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=ze;exports.AddColorScaleConditionalRuleCommand=Ye;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=Ke;exports.AddNumberCfCommand=Xe;exports.AddRankCfCommand=Je;exports.AddTextCfCommand=Qe;exports.AddTimePeriodCfCommand=et;exports.AddUniqueValuesCfCommand=tt;exports.OpenConditionalFormattingOperator=Fe;
|
|
1
|
+
"use strict";var Tt=Object.defineProperty;var Rt=(n,e,i)=>e in n?Tt(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var Q=(n,e,i)=>Rt(n,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@univerjs/core"),t=require("@univerjs/sheets-conditional-formatting"),U=require("@univerjs/sheets"),k=require("@univerjs/ui"),l=require("react/jsx-runtime"),y=require("react"),w=require("@univerjs/design"),Ge=require("@univerjs/engine-formula"),xe=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),ht=require("@univerjs/engine-render"),fe=require("rxjs/operators"),ze={type:a.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o}=e,u=n.get(t.ConditionalFormattingRuleModel),v=n.get(a.ICommandService),c=n.get(a.IUniverInstanceService),h=U.getSheetCommandTarget(c);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=u.createCfId(d,m),S={ranges:i,cfId:g,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:o,style:r}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:S})}},Ye={type:a.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,config:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.ICommandService),v=n.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=o.createCfId(h,d),g={ranges:i,cfId:m,stopIfTrue:!!s,rule:{type:t.CFRuleType.colorScale,config:r}};return u.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}},Ze={type:a.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,min:r,max:s,nativeColor:o,positiveColor:u,isGradient:v,stopIfTrue:c,isShowValue:h}=e,d=n.get(t.ConditionalFormattingRuleModel),m=n.get(a.IUniverInstanceService),g=U.getSheetCommandTarget(m);if(!g)return!1;const{unitId:S,subUnitId:x}=g,C=n.get(a.ICommandService),_=d.createCfId(S,x),F={ranges:i,cfId:_,stopIfTrue:!!c,rule:{type:t.CFRuleType.dataBar,isShowValue:h,config:{min:r,max:s,nativeColor:o,positiveColor:u,isGradient:v}}};return C.executeCommand(t.AddConditionalRuleMutation.id,{unitId:S,subUnitId:x,rule:F})}},Ke={type:a.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.ICommandService),v=n.get(a.IUniverInstanceService),c=U.getSheetCommandTarget(v);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=o.createCfId(h,d),g={ranges:i,cfId:m,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:r}};return u.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}},Xe={type:a.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o,value:u}=e,v=n.get(t.ConditionalFormattingRuleModel),c=n.get(a.ICommandService),h=n.get(a.IUniverInstanceService),d=U.getSheetCommandTarget(h);if(!d)return!1;const{unitId:m,subUnitId:g}=d,S=v.createCfId(m,g);let x;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(o)){const C=u;if(C.length!==2||!Array.isArray(C))return!1;x={ranges:i,cfId:S,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:o,style:r,value:C}}}else{const C=u;if(typeof C!="number")return!1;x={ranges:i,cfId:S,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:o,style:r,value:C}}}return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:m,subUnitId:g,rule:x})}},Je={type:a.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,isPercent:o,isBottom:u,value:v}=e,c=n.get(t.ConditionalFormattingRuleModel),h=n.get(a.IUniverInstanceService),d=n.get(a.ICommandService),m=U.getSheetCommandTarget(h);if(!m)return!1;const{unitId:g,subUnitId:S}=m,x=c.createCfId(g,S),C={ranges:i,cfId:x,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:o,isBottom:u,style:r,value:v}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:g,subUnitId:S,rule:C})}},Qe={type:a.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o,value:u}=e,v=n.get(t.ConditionalFormattingRuleModel),c=n.get(a.IUniverInstanceService),h=U.getSheetCommandTarget(c);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=n.get(a.ICommandService),S=v.createCfId(d,m),x={ranges:i,cfId:S,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:o,style:r,value:u}};return g.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:x})}},et={type:a.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s,operator:o}=e,u=n.get(t.ConditionalFormattingRuleModel),v=n.get(a.IUniverInstanceService),c=n.get(a.ICommandService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:d,subUnitId:m}=h,g=u.createCfId(d,m),S={ranges:i,cfId:g,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:o,style:r}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:d,subUnitId:m,rule:S})}},tt={type:a.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(n,e){if(!e)return!1;const{ranges:i,style:r,stopIfTrue:s}=e,o=n.get(t.ConditionalFormattingRuleModel),u=n.get(a.IUniverInstanceService),v=n.get(a.ICommandService),c=U.getSheetCommandTarget(u);if(!c)return!1;const{unitId:h,subUnitId:d}=c,m=o.createCfId(h,d),g={ranges:i,cfId:m,stopIfTrue:!!s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:r}};return v.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:d,rule:g})}};var Z=function(){return Z=Object.assign||function(n){for(var e,i=1,r=arguments.length;i<r;i++){e=arguments[i];for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=e[s])}return n},Z.apply(this,arguments)},Ft=function(n,e){var i={};for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&e.indexOf(r)<0&&(i[r]=n[r]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,r=Object.getOwnPropertySymbols(n);s<r.length;s++)e.indexOf(r[s])<0&&Object.prototype.propertyIsEnumerable.call(n,r[s])&&(i[r[s]]=n[r[s]]);return i},ce=y.forwardRef(function(n,e){var i=n.icon,r=n.id,s=n.className,o=n.extend,u=Ft(n,["icon","id","className","extend"]),v="univerjs-icon univerjs-icon-".concat(r," ").concat(s||"").trim(),c=y.useRef("_".concat(jt()));return pt(i,"".concat(r),{defIds:i.defIds,idSuffix:c.current},Z({ref:e,className:v},u),o)});function pt(n,e,i,r,s){return y.createElement(n.tag,Z(Z({key:e},_t(n,i,s)),r),(Nt(n,i).children||[]).map(function(o,u){return pt(o,"".concat(e,"-").concat(n.tag,"-").concat(u),i,void 0,s)}))}function _t(n,e,i){var r=Z({},n.attrs);i!=null&&i.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=i.colorChannel1),n.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(function(o){var u=o[0],v=o[1];u==="mask"&&typeof v=="string"&&(r[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))});var s=e.defIds;return!s||s.length===0||(n.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(function(o){var u=o[0],v=o[1];typeof v=="string"&&(r[u]=v.replace(/url\(#(.*)\)/,"url(#$1".concat(e.idSuffix,")")))})),r}function Nt(n,e){var i,r=e.defIds;return!r||r.length===0?n:n.tag==="defs"&&(!((i=n.children)===null||i===void 0)&&i.length)?Z(Z({},n),{children:n.children.map(function(s){return typeof s.attrs.id=="string"&&r&&r.indexOf(s.attrs.id)>-1?Z(Z({},s),{attrs:Z(Z({},s.attrs),{id:s.attrs.id+e.idSuffix})}):s})}):n}function jt(){return Math.random().toString(36).substring(2,8)}ce.displayName="UniverIcon";var Et={tag:"svg",attrs:{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.866699 5.9313.866699H10.069C10.4004.866699 10.669 1.13533 10.669 1.4667 10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667zM1.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.64443 14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443zM6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928 9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171 10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778 9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539 9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263 6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539 5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778 6.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"}}]},Ve=y.forwardRef(function(n,e){return y.createElement(ce,Object.assign({},n,{id:"delete-single",ref:e,icon:Et}))});Ve.displayName="DeleteSingle";var Mt={tag:"svg",attrs:{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"}}]},gt=y.forwardRef(function(n,e){return y.createElement(ce,Object.assign({},n,{id:"increase-single",ref:e,icon:Mt}))});gt.displayName="IncreaseSingle";var wt={tag:"svg",attrs:{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"}}]},Ae=y.forwardRef(function(n,e){return y.createElement(ce,Object.assign({},n,{id:"more-down-single",ref:e,icon:wt}))});Ae.displayName="MoreDownSingle";var Vt={tag:"svg",attrs:{fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_622_8",style:{maskType:"alpha"},width:16,height:16,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0 0H16V16H0z"}}]},{tag:"g",attrs:{fill:"currentColor",mask:"url(#mask0_622_8)"},children:[{tag:"path",attrs:{d:"M6 5C6.55228 5 7 4.55228 7 4 7 3.44772 6.55228 3 6 3 5.44772 3 5 3.44772 5 4 5 4.55228 5.44772 5 6 5zM6 9C6.55228 9 7 8.55229 7 8 7 7.44772 6.55228 7 6 7 5.44772 7 5 7.44772 5 8 5 8.55229 5.44772 9 6 9zM7 12C7 12.5523 6.55228 13 6 13 5.44772 13 5 12.5523 5 12 5 11.4477 5.44772 11 6 11 6.55228 11 7 11.4477 7 12zM10 5C10.5523 5 11 4.55228 11 4 11 3.44772 10.5523 3 10 3 9.44771 3 9 3.44772 9 4 9 4.55228 9.44771 5 10 5zM11 8C11 8.55229 10.5523 9 10 9 9.44771 9 9 8.55229 9 8 9 7.44772 9.44771 7 10 7 10.5523 7 11 7.44772 11 8zM10 13C10.5523 13 11 12.5523 11 12 11 11.4477 10.5523 11 10 11 9.44771 11 9 11.4477 9 12 9 12.5523 9.44771 13 10 13z"}}]}]},ft=y.forwardRef(function(n,e){return y.createElement(ce,Object.assign({},n,{id:"sequence-single",ref:e,icon:Vt}))});ft.displayName="SequenceSingle";var Ot={tag:"svg",attrs:{fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"mask",attrs:{id:"mask0_436_41",style:{maskType:"alpha"},width:17,height:17,x:0,y:0,maskUnits:"userSpaceOnUse"},children:[{tag:"path",attrs:{fill:"#D9D9D9",d:"M0.35 0.48H16.35V16.48H0.35z"}}]},{tag:"g",attrs:{mask:"url(#mask0_436_41)",fillRule:"evenodd",clipRule:"evenodd"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z"}},{tag:"path",attrs:{fill:"#E5E5E5",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"}}]}]},Te=y.forwardRef(function(n,e){return y.createElement(ce,Object.assign({},n,{id:"slash-single",ref:e,icon:Ot}))});Te.displayName="SlashSingle";const re=n=>{const{color:e,onChange:i,disable:r=!1,iconId:s="PaintBucket",className:o,isNeedDropdownIcon:u=!0}=n,v=k.useDependency(k.ComponentManager),c=y.useMemo(()=>new a.ColorKit(e),[e]),h=v.get(s);return h?r?l.jsx(h,{className:w.clsx("univer-fill-primary-600",o),extend:{colorChannel1:c.isValid?e:""}}):l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(w.ColorPicker,{value:e,onChange:i})}),children:l.jsxs("span",{className:w.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",o),children:[l.jsx(h,{className:"univer-fill-primary-600",extend:{colorChannel1:c.isValid?e:""}}),u&&l.jsx(Ae,{className:"univer-ml-1.5 univer-text-gray-400"})]})}):null},de=n=>{var o,u,v,c,h;const e=n.rule;if(!e)return null;const i=y.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const d=e.config.map((S,x)=>({color:new a.ColorKit(S.color),value:x})),m=d.length-1;return new Array(5).fill("").map((S,x,C)=>x*m/(C.length-1)).map(S=>t.getColorScaleFromValue(d,S))}return null},[e]),r=y.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]),s="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 l.jsxs("div",{className:s,children:[l.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(o=e.config.nativeColor)!=null?o:t.defaultDataBarNativeColor}}),l.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:m,borderColor:(u=e.config.positiveColor)!=null?u:t.defaultDataBarPositiveColor}})]})}case t.CFRuleType.colorScale:return i&&l.jsx("div",{className:s,children:i.map((d,m)=>l.jsx("div",{className:"univer-h-full",style:{width:`${100/i.length}%`,background:d}},m))});case t.CFRuleType.iconSet:return r&&l.jsx("div",{className:s,children:r.map((d,m)=>d?l.jsx("img",{className:"univer-h-full",src:d,draggable:!1},m):l.jsx(Te,{},m))});case t.CFRuleType.highlightCell:{const{ul:d,st:m,it:g,bl:S,bg:x,cl:C}=e.style,_=(d==null?void 0:d.s)===a.BooleanNumber.TRUE,F=(m==null?void 0:m.s)===a.BooleanNumber.TRUE,N=g===a.BooleanNumber.TRUE,E=S===a.BooleanNumber.TRUE,j=(v=x==null?void 0:x.rgb)!=null?v:t.DEFAULT_BG_COLOR,p=(c=C==null?void 0:C.rgb)!=null?c:t.DEFAULT_FONT_COLOR,b={textDecoration:(h=`${_?"underline":""} ${F?"line-through":""}`.replace(/^ /,""))!=null?h:void 0,backgroundColor:j,color:p};return l.jsx("div",{className:w.clsx(s,{"univer-font-bold":E,"univer-italic":N}),style:b,children:"123"})}}},Re=w.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",w.borderClassName),ne=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),$e=n=>{var x;const{type:e,className:i,onChange:r,id:s,value:o}=n,u=k.useDependency(a.IUniverInstanceService),v=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(x=u.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:x.getSheetId(),h=y.useMemo(()=>String(o).startsWith("=")?String(o):"=",[o]),d=y.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=y.useRef(null),[g,S]=y.useState(!1);return k.useSidebarClick(C=>{var F;((F=m.current)==null?void 0:F.isClickOutSide(C))&&S(!1)}),e===t.CFValueType.formula?l.jsx("div",{className:"univer-ml-1 univer-w-full",children:l.jsx(xe.FormulaEditor,{ref:m,className:w.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 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:h,unitId:v,subUnitId:c,isFocus:g,onChange:(C="")=>{r(C||"")},onFocus:()=>S(!0)})}):l.jsx(w.InputNumber,{className:i,value:Number(n.value)||0,onChange:C=>n.onChange(C||0),...d})},Ut=n=>{var P;const{interceptorManager:e}=n,i=k.useDependency(a.LocaleService),r=((P=n.rule)==null?void 0:P.type)===t.CFRuleType.colorScale?n.rule:void 0,s=[ne(t.CFValueType.num,i),ne(t.CFValueType.percent,i),ne(t.CFValueType.percentile,i),ne(t.CFValueType.formula,i)],o=[ne(t.CFValueType.min,i),...s],u=[ne("none",i),...s],v=[ne(t.CFValueType.max,i),...s],[c,h]=y.useState(()=>{var R;const f=t.CFValueType.min;return r&&((R=r.config[0])==null?void 0:R.value.type)||f}),[d,m]=y.useState(()=>{var R;const f="none";return!r||r.config.length!==3?f:((R=r.config[1])==null?void 0:R.value.type)||f}),[g,S]=y.useState(()=>{var R;const f=t.CFValueType.max;return r&&((R=r.config[r.config.length-1])==null?void 0:R.value.type)||f}),[x,C]=y.useState(()=>{if(!r)return 10;const R=r.config[0];return(R==null?void 0:R.value.value)===void 0?10:R==null?void 0:R.value.value}),[_,F]=y.useState(()=>{var L;if(!r||r.config.length!==3)return 50;const R=(L=r.config[1])==null?void 0:L.value.value;return R===void 0?50:R}),[N,E]=y.useState(()=>{var L;if(!r)return 90;const R=(L=r.config[r.config.length-1])==null?void 0:L.value.value;return R===void 0?90:R}),[j,p]=y.useState(()=>{var R;const f="#d0d9fb";return r&&((R=r.config[0])==null?void 0:R.color)||f}),[b,T]=y.useState(()=>{var R;const f="#7790f3";return!r||r.config.length!==3?f:((R=r.config[1])==null?void 0:R.color)||f}),[I,V]=y.useState(()=>{var R;const f="#2e55ef";return r&&((R=r.config[r.config.length-1])==null?void 0:R.color)||f}),M=y.useMemo(()=>f=>{const{minType:R,medianType:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:se,medianColor:D,maxColor:A}=f,B=[];return B.push({color:se,value:{type:R,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}},[]);y.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return M({minType:c,medianType:d,maxType:g,minValue:x,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),[M,c,d,g,x,_,N,j,b,I,e]);const O=f=>{n.onChange(M(f))};return l.jsxs("div",{children:[l.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")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:M({minType:c,medianType:d,maxType:g,minValue:x,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})})}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:o,value:c,onChange:f=>{h(f);const R=t.createDefaultValueByValueType(f,10);C(R),O({minType:f,medianType:d,maxType:g,minValue:R,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"min",className:"univer-ml-1",value:x,type:c,onChange:f=>{C(f),O({minType:c,medianType:d,maxType:g,minValue:f,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:j,onChange:f=>{p(f),O({minType:c,medianType:d,maxType:g,minValue:x,medianValue:_,maxValue:N,minColor:f,medianColor:b,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.medianValue")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:f=>{m(f);const R=t.createDefaultValueByValueType(f,50);F(R),O({minType:c,medianType:f,maxType:g,minValue:x,medianValue:R,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"median",className:"univer-ml-1",value:_,type:d,onChange:f=>{F(f),O({minType:c,medianType:d,maxType:g,minValue:x,medianValue:f,maxValue:N,minColor:j,medianColor:b,maxColor:I})}}),d!=="none"&&l.jsx(re,{className:"univer-ml-1",color:b,onChange:f=>{T(f),O({minType:c,medianType:d,maxType:g,minValue:x,medianValue:_,maxValue:N,minColor:j,medianColor:f,maxColor:I})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:v,value:g,onChange:f=>{S(f);const R=t.createDefaultValueByValueType(f,90);E(R),O({minType:c,medianType:d,maxType:f,minValue:x,medianValue:_,maxValue:R,minColor:j,medianColor:b,maxColor:I})}}),l.jsx($e,{id:"max",className:"univer-ml-1",value:N,type:g,onChange:f=>{E(f),O({minType:c,medianType:d,maxType:g,minValue:x,medianValue:_,maxValue:f,minColor:j,medianColor:b,maxColor:I})}}),l.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:c,medianType:d,maxType:g,minValue:x,medianValue:_,maxValue:N,minColor:j,medianColor:b,maxColor:f})}})]})]})},oe=(n,e)=>({label:e.t(`sheet.cf.valueType.${n}`),value:n}),rt=n=>{var C;const{onChange:e,className:i,value:r,type:s,id:o,disabled:u=!1}=n,v=k.useDependency(a.IUniverInstanceService),c=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(C=v.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:C.getSheetId(),d=y.useRef(null),[m,g]=y.useState(!1);k.useSidebarClick(_=>{var N;((N=d.current)==null?void 0:N.isClickOutSide(_))&&g(!1)});const S=y.useRef(r),x=y.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(s)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[s]);if(s===t.CFValueType.formula){const _=String(S.current).startsWith("=")?String(S.current)||"":"=";return l.jsx("div",{className:"univer-ml-3 univer-w-full",children:l.jsx(xe.FormulaEditor,{ref:d,className:w.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 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),initValue:_,unitId:c,subUnitId:h,isFocus:m,onChange:(F="")=>{e(F||"")},onFocus:()=>g(!0)})})}return l.jsx(w.InputNumber,{className:i,value:Number(r)||0,disabled:u,onChange:_=>{e(_||0)},...x})},kt=n=>{var P;const{interceptorManager:e}=n,i=k.useDependency(a.LocaleService),r=((P=n.rule)==null?void 0:P.type)===t.CFRuleType.dataBar?n.rule:void 0,[s,o]=y.useState(()=>{var R;const f="0";return r?(R=r.config)!=null&&R.isGradient?"1":"0":f}),[u,v]=y.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[c,h]=y.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),d=[oe(t.CFValueType.num,i),oe(t.CFValueType.percent,i),oe(t.CFValueType.percentile,i),oe(t.CFValueType.formula,i)],m=[oe(t.CFValueType.min,i),...d],g=[oe(t.CFValueType.max,i),...d],[S,x]=y.useState(()=>{var R;const f=m[0].value;return r&&((R=r.config)==null?void 0:R.min.type)||f}),[C,_]=y.useState(()=>{var R;const f=g[0].value;return r&&((R=r.config)==null?void 0:R.max.type)||f}),[F,N]=y.useState(()=>{var L;if(!r)return 0;const R=((L=r.config)==null?void 0:L.min)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value||0}),[E,j]=y.useState(()=>{var L;if(!r)return 100;const R=((L=r.config)==null?void 0:L.max)||{};return R.type===t.CFValueType.formula?R.value||"=":R.value===void 0?100:R.value}),[p,b]=y.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),T=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});y.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return T({isGradient:s,minValue:F,minValueType:S,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:p})}}),[s,F,S,E,C,u,c,e,p]);const I=f=>{n.onChange(T(f))},V=f=>{v(f),I({isGradient:s,minValue:F,minValueType:S,maxValue:E,maxValueType:C,positiveColor:f,nativeColor:c,isShowValue:p})},M=f=>{h(f),I({isGradient:s,minValue:F,minValueType:S,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:f,isShowValue:p})},O=f=>d.map(R=>R.value).includes(f);return l.jsxs("div",{children:[l.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")}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:T({isGradient:s,minValue:F,minValueType:S,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:p})})}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.fillType")}),l.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[l.jsxs(w.RadioGroup,{value:s,onChange:f=>{o(f),I({isGradient:f,minValue:F,minValueType:S,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:p})},children:[l.jsx(w.Radio,{value:"0",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.pureColor")})}),l.jsx(w.Radio,{value:"1",children:l.jsx("span",{className:"univer-text-xs",children:i.t("sheet.cf.panel.gradient")})})]}),l.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{checked:!p,onChange:f=>{b(!f),I({isGradient:f,minValue:F,minValueType:S,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:!f})}}),i.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.panel.colorSet")}),l.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[l.jsxs("div",{className:"univer-flex univer-items-center",children:[l.jsx("div",{className:"univer-text-xs",children:i.t("sheet.cf.panel.native")}),l.jsx(re,{color:c,onChange:M})]}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[l.jsx("div",{className:"univer-text-xs",children:i.t("sheet.cf.panel.positive")}),l.jsx(re,{color:u,onChange:V})]})]})]}),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.min")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:m,value:S,onChange:f=>{x(f);const R=t.createDefaultValueByValueType(f,10);N(R),I({isGradient:s,minValue:R,minValueType:f,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:p})}}),l.jsx(rt,{id:"min",className:"univer-ml-3",disabled:!O(S),type:S,value:F,onChange:f=>{N(f||0),I({isGradient:s,minValue:f||0,minValueType:S,maxValue:E,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:p})}})]}),l.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:i.t("sheet.cf.valueType.max")}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:C,onChange:f=>{_(f);const R=t.createDefaultValueByValueType(f,90);j(R),I({isGradient:s,minValue:F,minValueType:S,maxValue:R,maxValueType:f,positiveColor:u,nativeColor:c,isShowValue:p})}}),l.jsx(rt,{className:"univer-ml-3",disabled:!O(C),id:"max",type:C,value:E,onChange:f=>{j(f||0),I({isGradient:s,minValue:F,minValueType:S,maxValue:f||0,maxValueType:C,positiveColor:u,nativeColor:c,isShowValue:p})}})]})]})]})},Ne=n=>[a.BooleanNumber.FALSE,void 0].includes(n)?a.BooleanNumber.TRUE:a.BooleanNumber.FALSE,je=n=>n!==a.BooleanNumber.FALSE,nt=n=>{const{style:e,onChange:i,className:r}=n,s=k.useDependency(k.ComponentManager),[o,u]=y.useState(()=>{if(e!=null&&e.bl)return e.bl}),[v,c]=y.useState(()=>{if(e!=null&&e.it)return e.it}),[h,d]=y.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[m,g]=y.useState(()=>{if(e!=null&&e.st)return e.st.s}),[S,x]=y.useState(()=>{var T;const b="#2f56ef";return(T=e==null?void 0:e.cl)!=null&&T.rgb?e.cl.rgb:b}),[C,_]=y.useState(()=>{var T;const b="#e8ecfc";return(T=e==null?void 0:e.bg)!=null&&T.rgb?e.bg.rgb:b}),F=s.get("BoldSingle"),N=s.get("ItalicSingle"),E=s.get("UnderlineSingle"),j=s.get("StrikethroughSingle");y.useEffect(()=>{const b={bl:o,it:v};S!==void 0&&(b.cl={rgb:S}),C!==void 0&&(b.bg={rgb:C}),m!==void 0&&(b.st={s:m}),h!==void 0&&(b.ul={s:h}),i(t.removeUndefinedAttr(b))},[o,v,h,m,S,C]);const p="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return l.jsxs("div",{className:w.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[F&&l.jsx("div",{className:w.clsx(p,{"univer-bg-gray-100":je(o||a.BooleanNumber.FALSE)}),onClick:()=>u(Ne(o)),children:l.jsx(F,{})}),N&&l.jsx("div",{className:w.clsx(p,{"univer-bg-gray-100":je(v||a.BooleanNumber.FALSE)}),onClick:()=>c(Ne(v)),children:l.jsx(N,{})}),E&&l.jsx("div",{className:w.clsx(p,{"univer-bg-gray-100":je(h||a.BooleanNumber.FALSE)}),onClick:()=>d(Ne(h)),children:l.jsx(E,{})}),j&&l.jsx("div",{className:w.clsx(p,{"univer-bg-gray-100":je(m||a.BooleanNumber.FALSE)}),onClick:()=>g(Ne(m)),children:l.jsx(j,{})}),l.jsx(re,{color:S,onChange:x,iconId:"FontColor"}),l.jsx(re,{color:C,onChange:_,iconId:"PaintBucket"})]})},Pt=n=>{var j;const{onChange:e,interceptorManager:i}=n,r=k.useDependency(a.LocaleService),o=k.useDependency(a.IUniverInstanceService).getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),u=o.getActiveSheet(),v=((j=n.rule)==null?void 0:j.type)===t.CFRuleType.highlightCell?n.rule:void 0,c=y.useRef(null),[h,d]=y.useState(!1),m=y.useRef(null),[g,S]=y.useState({}),[x,C]=y.useState(()=>(v==null?void 0:v.subType)===t.CFSubRuleType.formula?v.value:"="),[_,F]=y.useState(void 0),N=p=>({style:p.style,value:x,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});y.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return N({style:g})}}),[g,x,i]),y.useEffect(()=>i.intercept(i.getInterceptPoints().beforeSubmit,{handler:(b,T,I)=>_||x.length===1||!x.startsWith("=")?(F(r.t("sheet.cf.errorMessage.formulaError")),!1):I(b)}),[_,x]);const E=p=>{e(N(p))};return k.useSidebarClick(p=>{var T;((T=m.current)==null?void 0:T.isClickOutSide(p))&&d(!1)}),l.jsxs("div",{ref:c,children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(xe.FormulaEditor,{ref:m,className:w.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 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent dark:!univer-bg-gray-700 dark:!univer-text-white hover:univer-border-primary-600",w.borderClassName),errorText:_,isFocus:h,initValue:x,unitId:o.getUnitId(),subUnitId:u==null?void 0:u.getSheetId(),onFocus:()=>{d(!0)},onChange:p=>{C(p),E({style:g})},onVerify:(p,b)=>{!p||b.length===1?F(r.t("sheet.cf.errorMessage.formulaError")):F(void 0)}})}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:N({style:g})})}),l.jsx(nt,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:p=>{S(p),E({style:p})}})]})},Ee=n=>l.jsxs("div",{className:"univer-relative",children:[l.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:n.errorText}),n.children]}),$=(n,e)=>({label:e.t(`sheet.cf.operator.${n}`),value:n}),Dt=n=>{const{type:e,operator:i,onChange:r,value:s,interceptorManager:o}=n,u=k.useDependency(a.LocaleService),[v,c]=y.useState(()=>typeof s=="number"?s:0),[h,d]=y.useState(""),[m,g]=y.useState(()=>typeof s=="string"?s:""),[S,x]=y.useState(""),[C,_]=y.useState(()=>Array.isArray(s)?s[0]===void 0?0:s[0]:0),[F,N]=y.useState(""),[E,j]=y.useState(()=>Array.isArray(s)?s[1]===void 0?100:s[1]:100),[p,b]=y.useState("");switch(y.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(i)&&r(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(i)&&r(v),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)&&r([C,E]);break}}},[e]),y.useEffect(()=>{const T=o.intercept(o.getInterceptPoints().beforeSubmit,{handler:(I,V,M)=>{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(i))return m?M(I):(x(u.t("sheet.cf.errorMessage.notBlank")),!1)}return M(I)}});return()=>{T()}},[e,v,m,i]),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(i)){const T=I=>{g(I),r(I)};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:S,children:l.jsx(w.Input,{value:m,onChange:I=>{x(""),T(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(i)){const T=I=>{c(I||0),r(I||0),d("")};return l.jsx("div",{className:"univer-mt-3",children:l.jsx(Ee,{errorText:h,children:l.jsx(w.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:T})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(i)){const T=V=>{_(V||0),r([V||0,E]),N("")},I=V=>{j(V||0),r([C,V||0]),b("")};return l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(Ee,{errorText:F,children:l.jsx(w.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:C,onChange:T})}),l.jsx(Ee,{errorText:p,children:l.jsx(w.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},it=(n,e)=>{switch(n){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)]}},st=n=>{var j;const{interceptorManager:e,onChange:i}=n,r=k.useDependency(a.LocaleService),s=((j=n.rule)==null?void 0:j.type)===t.CFRuleType.highlightCell?n.rule:void 0,[o,u]=y.useState(()=>{const p=t.CFSubRuleType.text;return s&&s.subType||p}),v=[{value:t.CFSubRuleType.text,label:r.t("sheet.cf.subRuleType.text")},{value:t.CFSubRuleType.number,label:r.t("sheet.cf.subRuleType.number")},{value:t.CFSubRuleType.timePeriod,label:r.t("sheet.cf.subRuleType.timePeriod")},{value:t.CFSubRuleType.duplicateValues,label:r.t("sheet.cf.subRuleType.duplicateValues")},{value:t.CFSubRuleType.uniqueValues,label:r.t("sheet.cf.subRuleType.uniqueValues")}],c=y.useMemo(()=>it(o,r),[o]),[h,d]=y.useState(()=>{const p=c?c[0].value:void 0;return s&&s.operator||p}),[m,g]=y.useState(()=>{var T;const p="";return s?(T=s.value)!=null?T:t.createDefaultValue(s.subType,s.operator):p}),[S,x]=y.useState({}),C=y.useMemo(()=>p=>{var b,T,I,V,M,O,P,f,R,L,q,X,J,ie,se;switch(p.subType||o){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:(b=p.subType)!=null?b:o,operator:(T=p.operator)!=null?T:h,style:(I=p.style)!=null?I:S,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:(M=p.subType)!=null?M:o,operator:(O=p.operator)!=null?O:h,style:(P=p.style)!=null?P:S,value:(f=p.value)!=null?f:m};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(h))return{type:t.CFRuleType.highlightCell,subType:(R=p.subType)!=null?R:o,operator:(L=p.operator)!=null?L:h,style:(q=p.style)!=null?q:S,value:(X=p.value)!=null?X:m};break}}return{type:t.CFRuleType.highlightCell,subType:(J=p.subType)!=null?J:o,operator:(ie=p.operator)!=null?ie:h,style:(se=p.style)!=null?se:S}},[o,h,m,S]);y.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return C({})}}),[C,e]),y.useEffect(()=>{v.some(p=>p.value===o)||u(v[0].value)},[v]);const _=p=>{const b=p,T=it(b,r),I=T&&T[0].value;u(b),d(I),I&&g(t.createDefaultValue(b,I)),i(C({subType:b,operator:I}))},F=p=>{const b=p;d(b),i(C({operator:b}))},N=p=>{g(p),i(C({value:p}))},E=y.useMemo(()=>`${o}_${h}_${Math.random()}`,[o,h]);return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:o,options:v}),(c==null?void 0:c.length)&&l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",onChange:F,value:h||"",options:c})]}),l.jsx(Dt,{value:m,interceptorManager:e,type:o,operator:h,rule:s,onChange:N},E),l.jsx("div",{className:Re,children:l.jsx(de,{rule:C({})})}),l.jsx(nt,{style:s==null?void 0:s.style,className:"univer-ml-1",onChange:p=>{x(p),i(C({style:p}))}})]})},Ct=(n,e)=>(t.iconMap[n]||[])[Number(e)]||"",Lt=n=>{var d;const{error:e,type:i,onChange:r}=n,s=k.useDependency(a.IUniverInstanceService),o=s.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),u=(d=s.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:d.getSheetId(),v=y.useRef(null),[c,h]=y.useState(!1);return k.useSidebarClick(m=>{var S;((S=v.current)==null?void 0:S.isClickOutSide(m))&&h(!1)}),l.jsx("div",{className:"univer-relative",children:i!==t.CFValueType.formula?l.jsxs(l.Fragment,{children:[l.jsx(w.InputNumber,{className:w.clsx({"univer-border-red-500":e}),value:Number(n.value)||0,onChange:m=>r(m!=null?m:0)}),e&&l.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):l.jsx("div",{className:"univer-w-full",children:l.jsx(xe.FormulaEditor,{ref:v,initValue:String(n.value),unitId:o,subUnitId:u,isFocus:c,onChange:(m="")=>{r(m||"")},onFocus:()=>h(!0)})})})},ot=(n,e,i)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(i.length-1-e)*10},iconType:n,iconId:String(e)}),At=y.forwardRef((n,e)=>{const{onClick:i}=n,r=k.useDependency(a.LocaleService),s=o=>{i(o)};return l.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((o,u)=>l.jsxs("div",{className:"univer-mb-3",children:[l.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(o.title)}),l.jsx("div",{className:"univer-flex univer-flex-wrap",children:o.group.map(v=>l.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{s(v.name)},children:l.jsx("a",{className:"univer-cursor-pointer univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:v.list.map((c,h)=>l.jsx("img",{className:"univer-size-5",src:c,draggable:!1},h))})},v.name))})]},u))})}),$t=n=>{const{onClick:e}=n,i=y.useMemo(()=>{const s=[];for(const o in t.iconMap){const u=t.iconMap[o],v=o;u.forEach((c,h)=>{s.push({iconType:v,base64:c,iconId:String(h)})})}return s},[]),r=s=>{e(s.iconType,s.iconId)};return l.jsxs("div",{children:[l.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[l.jsx(Te,{className:"univer-size-5"}),l.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),l.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:i.map(s=>l.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",children:l.jsx("img",{className:"univer-size-5",src:s.base64,draggable:!1,onClick:()=>r(s)})},`${s.iconType}_${s.iconId}`))})]})},Bt=n=>{const{onChange:e,configList:i,errorMap:r={}}=n,s=k.useDependency(a.LocaleService),o=[{label:s.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:s.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],u=[{label:s.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:s.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:s.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:s.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 S=t.createDefaultValue(t.CFSubRuleType.number,m);v(S,g)},h=(m,g)=>{e([String(g),"value","type"],m);const S=i[g],x=t.createDefaultValue(t.CFSubRuleType.number,S.operator);v(x,g)};return y.useMemo(()=>i.map((m,g)=>{const S=r[g],x=Ct(m.iconType,m.iconId),C=g===i.length-1,_=g===0,F=i[g-1],N=(F==null?void 0:F.value.type)===t.CFValueType.formula?s.t("sheet.cf.valueType.formula"):F==null?void 0:F.value.value,E=(j,p)=>{const b={...m,iconId:p,iconType:j};e([String(g)],b)};return l.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[l.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:[l.jsxs("div",{className:"univer-w-[45%]",children:[s.t("sheet.cf.iconSet.icon"),g+1]}),l.jsx("div",{className:"univer-w-[45%]",children:l.jsxs(l.Fragment,{children:[!_&&!C&&s.t("sheet.cf.iconSet.rule"),!_&&!C&&l.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:["(",s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,C?"":` ${s.t("sheet.cf.iconSet.and")} `,")"]})]})})]}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx("div",{className:"univer-flex univer-items-center",children:l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx($t,{onClick:E,iconId:m.iconId,iconType:m.iconType})}),children:l.jsxs("div",{className:w.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 dark:!univer-text-gray-200 hover:univer-border-primary-600",w.borderClassName),children:[x?l.jsx("img",{src:x,className:"univer-size-4",draggable:!1}):l.jsx(Te,{className:"univer-size-4"}),l.jsx(Ae,{})]})})}),C?l.jsxs("div",{className:"univer-mt-0 univer-w-[45%] univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[s.t("sheet.cf.iconSet.rule"),l.jsxs("span",{className:"univer-font-medium",children:[s.t("sheet.cf.iconSet.when"),s.t(`sheet.cf.symbol.${t.getOppositeOperator(F.operator)}`),N,C?"":` ${s.t("sheet.cf.iconSet.and")} `]})]}):l.jsx(w.Select,{options:o,value:m.operator,onChange:j=>{c(j,g)}})]}),C?l.jsx("div",{}):l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[l.jsx("div",{children:s.t("sheet.cf.iconSet.type")}),l.jsx("div",{children:s.t("sheet.cf.iconSet.value")})]}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-gap-4",children:[l.jsx(w.Select,{className:"univer-flex-shrink-0",options:u,value:m.value.type,onChange:j=>{h(j,g)}}),l.jsx("div",{children:l.jsx(Lt,{id:g,type:m.value.type,error:S,value:m.value.value||"",onChange:j=>{v(j,g)}})})]})]})]},g)}),[i,r])},Ht=n=>{var j;const{interceptorManager:e}=n,i=((j=n.rule)==null?void 0:j.type)===t.CFRuleType.iconSet?n.rule:void 0,r=k.useDependency(a.LocaleService),[s,o]=y.useState({}),[u,v]=y.useState(()=>{const p=Object.keys(t.iconMap)[0];if(i&&i.config.length){const b=i.config[0].iconType;if(!i.config.some(I=>I.iconType!==b))return b}return p}),[c,h]=y.useState(()=>{if(i&&i.config.length)return a.Tools.deepClone(i==null?void 0:i.config);const p=t.iconMap[u]||[];return new Array(p.length).fill("").map((b,T,I)=>T===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:u,iconId:String(T)}:ot(u,T,I))}),[d,m]=y.useState(()=>i?!!i.isShowValue:!0),g=y.useMemo(()=>{const p=c.map(b=>Ct(b.iconType,b.iconId));return l.jsx("div",{className:"univer-flex univer-items-center",children:p.map((b,T)=>b?l.jsx("img",{className:"univer-size-5",src:b},T):l.jsx(Te,{className:"univer-size-5"},T))})},[c]),S=p=>{if(p.reduce((T,I,V)=>T.preType&&!T.result||p.length-1===V?T:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:T.preType?{result:T.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 T={};return p.forEach((I,V,M)=>{if(V-1<0||V===M.length-1)return;const P=p[V-1],f=t.getOppositeOperator(P.operator);t.compareWithNumber({operator:f,value:P.value.value},I.value.value)||(T[V]=`${r.t(`sheet.cf.form.${f}`,String(P.value.value))} `)}),T}return{}},x=(p,b)=>{a.get(c,p)!==b&&(a.set(c,p,b),h([...c]),o(S(c)))},C=p=>{v(p);const b=t.iconMap[p]||[],T=new Array(b.length).fill("").map((I,V,M)=>ot(p,V,M));h(T),o(S(T))};y.useEffect(()=>{const p=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:d,config:c}}});return()=>{p()}},[d,c,e]),y.useEffect(()=>{const p=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(s).length===0}});return()=>{p()}},[d,c,e,s]);const _=()=>{const p=c.map(b=>({...b}));c.forEach((b,T)=>{const I=c.length-1-T,V=p[I];b.iconId=V.iconId,b.iconType=V.iconType}),h([...c])},F=k.useDependency(k.ILayoutService),[N,E]=y.useState();return k.useScrollYOverContainer(N,F.rootContainerElement),l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),l.jsx("div",{className:"univer-mt-3",children:l.jsx(w.Dropdown,{overlay:l.jsx("div",{className:"univer-rounded-lg univer-p-4",children:l.jsx(At,{ref:p=>{!N&&p&&E(p)},iconType:u,onClick:C})}),children:l.jsxs("div",{className:w.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",w.borderClassName),children:[g,l.jsx(Ae,{})]})})}),l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[l.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{onChange:_}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),l.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{checked:!d,onChange:p=>{m(!p)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),l.jsx(Bt,{errorMap:s,onChange:x,configList:c})]})},Wt=n=>{var _;const{onChange:e,interceptorManager:i}=n,r=k.useDependency(a.LocaleService),s=((_=n.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?n.rule:void 0,o=[{label:r.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:r.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:r.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:r.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[u,v]=y.useState(()=>{const F=o[0].value,N=s==null?void 0:s.type;if(!s)return F;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(s.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(s.operator)?"lessThanAverage":F;case t.CFSubRuleType.rank:return s.isBottom?"isBottom":"isNotBottom"}}return F}),[c,h]=y.useState(()=>{const N=s==null?void 0:s.type;if(!s)return 10;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.value||10}}return 10}),[d,m]=y.useState(()=>{const N=s==null?void 0:s.type;if(!s)return!1;switch(N){case t.CFRuleType.highlightCell:switch(s.subType){case t.CFSubRuleType.rank:return s.isPercent||!1}}return!1}),[g,S]=y.useState({}),x=F=>{const{type:N,isPercent:E,value:j,style:p}=F;if(N==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:j,style:p};if(N==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:j,style:p};if(N==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:p};if(N==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:p}};y.useEffect(()=>i.intercept(i.getInterceptPoints().submit,{handler(){return x({type:u,isPercent:d,value:c,style:g})}}),[u,d,c,g,i]);const C=F=>{e(x(F))};return l.jsxs("div",{children:[l.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),l.jsx(w.Select,{className:"univer-mt-3 univer-w-full",value:u,options:o,onChange:F=>{v(F),C({type:F,isPercent:d,value:c,style:g})}}),["isNotBottom","isBottom"].includes(u)&&l.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[l.jsx(w.InputNumber,{min:1,max:1e3,value:c,onChange:F=>{const N=F||0;h(N),C({type:u,isPercent:d,value:N,style:g})}}),l.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[l.jsx(w.Checkbox,{checked:d,onChange:F=>{m(!!F),C({type:u,isPercent:!!F,value:c,style:g})}}),r.t("sheet.cf.valueType.percent")]})]}),l.jsx("div",{className:Re,children:l.jsx(de,{rule:x({type:u,isPercent:d,value:c,style:g})})}),l.jsx(nt,{style:s==null?void 0:s.style,className:"univer-mt-3",onChange:F=>{S(F),C({type:u,isPercent:d,value:c,style:F})}})]})},qt=a.createInterceptorKey("beforeSubmit"),Gt=a.createInterceptorKey("submit"),at=n=>n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),lt=n=>{var e;return(e=n.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},zt=n=>{var T,I,V;const e=k.useDependency(a.LocaleService),i=k.useDependency(a.ICommandService),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(t.ConditionalFormattingRuleModel),o=k.useDependency(U.SheetsSelectionsService),u=at(r),v=lt(r),[c,h]=y.useState(void 0),d=y.useRef((I=(T=n.rule)==null?void 0:T.ranges)!=null?I:[]),m=y.useMemo(()=>{var O,P,f;let M=(O=n.rule)==null?void 0:O.ranges;return M!=null&&M.length||(M=(f=(P=o.getCurrentSelections())==null?void 0:P.map(R=>R.range))!=null?f:[]),d.current=M,M!=null&&M.length?M.map(R=>{const L=Ge.serializeRange(R);return L==="NaN"?"":L}).filter(R=>!!R).join(","):""},[n.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"}],[S,x]=y.useState(()=>{var P,f;const M=(P=n.rule)==null?void 0:P.rule.type,O=g[0].value;if(!M)return O;switch(M){case t.CFRuleType.highlightCell:{switch((f=n.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}),C=y.useRef(void 0),_=y.useMemo(()=>new a.InterceptorManager({beforeSubmit:qt,submit:Gt}),[]),F=y.useMemo(()=>{switch(S){case"1":return st;case"2":return Wt;case"3":return kt;case"4":return Ut;case"5":return Pt;case"6":return Ht;default:return st}},[S]);y.useEffect(()=>{const M=i.onCommandExecuted(O=>{if(O.id===U.RemoveSheetMutation.id){const P=O.params;P.subUnitId===v&&P.unitId===u&&n.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&n.onCancel()});return()=>M.dispose()},[]);const N=M=>{C.current=M},E=M=>{const O=M.split(",").filter(P=>!!P).map(Ge.deserializeRangeWithSheet).map(P=>P.range);d.current=O},j=()=>{if(c)return;const O=(()=>{const f=r.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 R=at(r),L=lt(r);if(!R||!L)throw new Error("No active sheet found");let q={};n.rule&&n.rule.cfId?(q={...n.rule,ranges:O,rule:f},i.executeCommand(t.SetCfCommand.id,{unitId:R,subUnitId:L,rule:q}),n.onCancel()):(q={cfId:s.createCfId(R,L),ranges:O,rule:f,stopIfTrue:!1},i.executeCommand(t.AddCfCommand.id,{unitId:R,subUnitId:L,rule:q}),n.onCancel())}}},p=()=>{n.onCancel()},b=(M,O)=>{M?O.length<1?h(e.t("sheet.cf.errorMessage.rangeError")):h(void 0):h(e.t("sheet.cf.errorMessage.rangeError"))};return l.jsxs("div",{children:[l.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")}),l.jsxs("div",{className:"univer-mt-4",children:[l.jsx(xe.RangeSelector,{unitId:u,subUnitId:v,initialValue:m,onChange:(M,O)=>E(O),onVerify:b}),c&&l.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:c})]}),l.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")}),l.jsx(w.Select,{className:"univer-mt-4 univer-w-full",value:S,options:g,onChange:M=>x(M)}),l.jsx(F,{interceptorManager:_,rule:(V=n.rule)==null?void 0:V.rule,onChange:N}),l.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[l.jsx(w.Button,{onClick:p,children:e.t("sheet.cf.panel.cancel")}),l.jsx(w.Button,{className:"univer-ml-3",variant:"primary",onClick:j,children:e.t("sheet.cf.panel.submit")})]})]})};var Yt=Object.getOwnPropertyDescriptor,Zt=(n,e,i,r)=>{for(var s=r>1?void 0:r?Yt(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},Kt=(n,e)=>(i,r)=>e(i,r,n);let ue=class extends a.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const i=/\{([^}]+)?\}/g,r=[];let s=i.exec(e);for(;s;)r.push({startIndex:s.index,key:Number(s[1]),endIndex:s.index+s[0].length-1}),s=i.exec(e);return r});this._localeService=e,this._initLocal()}tWithReactNode(e,...i){const r=this._localeService.getLocales(),s=e.split("."),o=r&&this._localeService.resolveKeyPath(r,s);if(typeof o=="string"){const u=[];return this._findReplaceIndex(o).forEach((v,c,h)=>{const d=h[c-1]||{endIndex:-1};if(d.endIndex+1<v.startIndex){const m=o.slice(d.endIndex+1,v.startIndex);m&&u.push(m)}if(i[v.key]&&u.push(i[v.key]),c===h.length-1){const m=o.slice(v.endIndex+1);m&&u.push(m)}}),u}return[]}};ue=Zt([Kt(0,a.Inject(a.LocaleService))],ue);const Xt=(n,e)=>{const i=n.rule;switch(i.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(i.subType){case t.CFSubRuleType.average:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,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 r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(i.value)?i.value.map(s=>String(s)):[String(i.value||"")])}case t.CFSubRuleType.text:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`,i.value||"")}case t.CFSubRuleType.timePeriod:{const r=i.operator;return e.t(`sheet.cf.preview.describe.${r}`)}case t.CFSubRuleType.rank:return i.isPercent?i.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(i.value)):e.t("sheet.cf.preview.describe.topNPercent",String(i.value)):i.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(i.value)):e.t("sheet.cf.preview.describe.topN",String(i.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let ut=0;const Jt=n=>{const{onClick:e}=n,i=k.useDependency(t.ConditionalFormattingRuleModel),r=k.useDependency(a.IUniverInstanceService),s=k.useDependency(U.SheetsSelectionsService),o=k.useDependency(a.ICommandService),u=k.useDependency(a.LocaleService),v=k.useDependency(a.Injector),c=k.useDependency(k.ISidebarService),h=k.useDependency(ue),d=k.useObservable(()=>r.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 S=g.getSheetId(),[x,C]=y.useState([]),[_,F]=y.useState("2"),[N,E]=y.useState(0),[j,p]=y.useState(-1),[b,T]=y.useState(ut),I=y.useRef(null),V=[{label:u.t("sheet.cf.panel.workSheet"),value:"2"},{label:u.t("sheet.cf.panel.selectedRange"),value:"1"}],M=()=>{const D=i.getSubunitRules(m,S);if(!D||!D.length)return[];if(_==="1"){const A=s.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,P]=y.useState(M);H.useHighlightRange(x),y.useEffect(()=>{const D=o.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),y.useEffect(()=>{P(M)},[_,N,m,S]),y.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=o.onCommandExecuted(G=>{const{id:z,params:ee}=G,te=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(z)&&ee.unitId===te&&A.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{P(M)});return()=>{D.unsubscribe()}},[r,_,m,S]),y.useEffect(()=>{const D=i.$ruleChange.subscribe(()=>{E(Math.random())});return()=>D.unsubscribe()},[i]),y.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 ut=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=_e=>{_e.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{T(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const A=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");o.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:D.cfId})},R=(D,A)=>{p(A.y)},L=(D,A,B)=>{var _e;p(-1);const W=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(_e=r.getCurrentUnitOfType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:_e.getSheetId();if(!W||!G)throw new Error("No active sheet found");const z=It=>{const xt=O.length;return Math.min(xt-1,Math.max(0,It))},ee=O[z(A.y)].cfId,te=O[z(B.y)].cfId;ee!==te&&o.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>A.y?"after":"before"}})},q=()=>{n.onCreate()},X=()=>{_==="2"?o.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:m,subUnitId:S,cfId:A.cfId})).forEach(A=>{o.executeCommand(t.DeleteCfCommand.id,A)})},J=y.useMemo(()=>{const D=r.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})),se=y.useMemo(()=>{const D=r.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 l.jsxs("div",{children:[l.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[l.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:h.tWithReactNode("sheet.cf.panel.managerRuleSelect",l.jsx(w.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{F(D)}})).map((D,A)=>l.jsx("span",{children:D},A))}),l.jsxs("div",{className:"univer-flex univer-justify-end",children:[l.jsx(w.Tooltip,{title:u.t("sheet.cf.panel.createRule"),placement:"bottom",children:l.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:l.jsx(gt,{})})}),O.length&&se?l.jsx(w.Tooltip,{title:u.t("sheet.cf.panel.clear"),placement:"bottom",children:l.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:l.jsx(Ve,{className:"univer-text-red-500"})})}):l.jsx("div",{children:l.jsx(Ve,{className:"univer-text-gray-300"})})]})]}),l.jsx("div",{ref:I,children:b>0&&l.jsx(w.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:b,margin:[0,10],onDragStop:L,onDragStart:R,children:J==null?void 0:J.map((D,A)=>l.jsx("div",{children:l.jsxs("div",{className:w.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 dark:hover:!univer-bg-gray-700 hover:univer-bg-gray-100",{"univer-bg-gray-100 dark:!univer-bg-gray-700":j===A}),onMouseMove:()=>{D.ranges!==x&&C(D.ranges)},onMouseLeave:()=>C([]),onClick:()=>{e(D)},children:[l.jsx("div",{className:w.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:l.jsx(ft,{})}),l.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[l.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:Xt(D,u)}),l.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(B=>Ge.serializeRange(B)).join(",")})]}),l.jsx("div",{children:l.jsx(de,{rule:D.rule})}),l.jsx("div",{className:w.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":j===A}),onClick:B=>{B.stopPropagation(),f(D),C([])},children:l.jsx(Ve,{})})]})},`${D.cfId}`))})})]})},Qt=n=>{const[e,i]=y.useState(n.rule),[r,s]=y.useState(!!n.rule),o=()=>{s(!0)},u=()=>{s(!1),i(void 0)},v=c=>{i(c),s(!0)};return l.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between",children:r?l.jsx(zt,{onCancel:u,rule:e}):l.jsx(Jt,{onClick:v,onCreate:o})})};var en=Object.getOwnPropertyDescriptor,tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?en(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},me=(n,e)=>(i,r)=>e(i,r,n);const Me="sheet.conditional.formatting.panel";let Ce=class extends a.Disposable{constructor(e,i,r,s,o){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=i,this._componentManager=r,this._sidebarService=s,this._localeService=o,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(u=>{var v;u||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(u=>{u.id===Me&&(u.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const i={id:Me,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Me,rule:e,key:a.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(i)}_initPanel(){this.disposeWithMe(this._componentManager.register(Me,Qt))}};Ce=tn([me(0,a.IUniverInstanceService),me(1,a.Inject(a.Injector)),me(2,a.Inject(k.ComponentManager)),me(3,a.Inject(k.ISidebarService)),me(4,a.Inject(a.LocaleService))],Ce);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 Fe={id:"sheet.operation.open.conditional.formatting.panel",type:a.CommandType.OPERATION,handler:(n,e)=>{var v;const i=n.get(Ce),r=n.get(U.SheetsSelectionsService),s=n.get(a.ICommandService),o=((v=r.getCurrentSelections())==null?void 0:v.map(c=>c.range))||[];switch(e.value){case 3:{i.openPanel({...t.createDefaultRule(),ranges:o});break}case 4:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};i.openPanel(c);break}case 5:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};i.openPanel(c);break}case 6:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.colorScale,config:[]}};i.openPanel(c);break}case 7:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};i.openPanel(c);break}case 8:{const c={...t.createDefaultRule,ranges:o,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};i.openPanel(c);break}case 2:{i.openPanel();break}case 1:{i.openPanel({...t.createDefaultRule(),ranges:o});break}case 9:{s.executeCommand(t.ClearRangeCfCommand.id,{ranges:o});break}case 10:{s.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var nn=Object.getOwnPropertyDescriptor,rn=(n,e,i,r)=>{for(var s=r>1?void 0:r?nn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},ve=(n,e)=>(i,r)=>e(i,r,n);let ye=class extends a.Disposable{constructor(e,i,r,s,o){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=i,this._injector=r,this._conditionalFormattingViewModel=s,this._univerInstanceService=o,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,i,r)=>this._collectConditionalRule(e,i,r),onPasteCells:(e,i,r,s)=>{const{copyType:o=H.COPY_TYPE.COPY,pasteType:u}=s,{range:v}=e||{},{range:c}=i;return this._generateConditionalFormattingMutations(c,{copyType:o,pasteType:u,copyRange:v})}}))}_collectConditionalRule(e,i,r){const s=new a.ObjectMatrix,o={};this._copyInfo={matrix:s,info:{unitId:e,subUnitId:i,cfMap:o}};const u=this._injector.invoke(d=>U.rangeToDiscreteRange(r,d,e,i));if(!u)return;const{rows:v,cols:c}=u,h=new Set;v.forEach((d,m)=>{c.forEach((g,S)=>{const x=this._conditionalFormattingViewModel.getCellCfs(e,i,d,g);x&&(x.forEach(C=>h.add(C.cfId)),s.setValue(m,S,x.map(C=>C.cfId)))})}),h.forEach(d=>{const m=this._conditionalFormattingRuleModel.getRule(e,i,d);m&&(o[d]=m.rule)})}_generateConditionalFormattingMutations(e,i){const r=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),s=r.getActiveSheet(),o=r.getUnitId();if(!s)return{redos:[],undos:[]};const u=s.getSheetId();if(i.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!i.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(i.pasteType))return{redos:[],undos:[]};const{ranges:[c,h],mapFunc:d}=H.virtualizeDiscreteRanges([i.copyRange,e]),m=H.getRepeatRange(c,h,!0),g={};a.Range.foreach(h,(p,b)=>{const{row:T,col:I}=d(p,b),V=this._conditionalFormattingViewModel.getCellCfs(o,u,T,I);V&&V.forEach(M=>{if(!g[M.cfId]){const O=new a.ObjectMatrix;g[M.cfId]=O;const P=this._conditionalFormattingRuleModel.getRule(o,u,M.cfId);P==null||P.ranges.forEach(f=>{a.Range.foreach(f,(R,L)=>{O.setValue(R,L,1)})})}g[M.cfId].realDeleteValue(T,I)})});const{matrix:S,info:x}=this._copyInfo,C=[];let _=this._conditionalFormattingRuleModel.createCfId(o,u);const F={},N=p=>{if(F[p])return F[p];const b=x==null?void 0:x.cfMap[p],T=[...this._conditionalFormattingRuleModel.getSubunitRules(o,u)||[],...C].find(I=>a.Tools.diffValue(I.rule,b));if(T)return F[p]=T,T;{const I={rule:b,cfId:_,ranges:[],stopIfTrue:!1};return F[p]=I,C.push(I),_=`${Number(_)+1}`,I}};m.forEach(p=>{S&&S.forValue((b,T,I)=>{const V=a.Rectangle.getPositionRange({startRow:b,endRow:b,startColumn:T,endColumn:T},p.startRange),{row:M,col:O}=d(V.startRow,V.startColumn);I.forEach(P=>{if(!g[P]){const f=N(P),R=new a.ObjectMatrix;g[P]=R,f.ranges.forEach(L=>{a.Range.foreach(L,(q,X)=>{R.setValue(q,X,1)})})}g[P].setValue(M,O,1)})})});const E=[],j=[];for(const p in g){const b=g[p],T=U.findAllRectangle(U.createTopMatrixFromMatrix(b));if(!T.length){const I={unitId:o,subUnitId:u,cfId:p};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),j.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(C.some(I=>I.cfId===p)){const I=N(p),V={unitId:o,subUnitId:u,rule:{...I,ranges:T}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),j.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(o,u,p);if(!I)continue;const V={unitId:o,subUnitId:u,rule:{...I,ranges:T}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),j.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:j}}};ye=rn([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))],ye);var sn=Object.getOwnPropertyDescriptor,on=(n,e,i,r)=>{for(var s=r>1?void 0:r?sn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},Be=(n,e)=>(i,r)=>e(i,r,n);let Se=class extends a.Disposable{constructor(n,e,i){super(),this._localeService=n,this._commandService=e,this._sheetPermissionCheckController=i,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(n=>{n.id===t.AddCfCommand.id&&(this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},n.params.rule.ranges)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr")))}))}};Se=on([Be(0,a.Inject(a.LocaleService)),Be(1,a.ICommandService),Be(2,a.Inject(U.SheetPermissionCheckController))],Se);var an=Object.getOwnPropertyDescriptor,ln=(n,e,i,r)=>{for(var s=r>1?void 0:r?an(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},we=(n,e)=>(i,r)=>e(i,r,n);let be=class extends a.Disposable{constructor(n,e,i,r){super(),this._conditionalFormattingRuleModel=n,this._univerInstanceService=e,this._injector=i,this._refRangeService=r,this._initRefRange()}_initRefRange(){const n=new Map,e=(r,s,o)=>`${r}_${s}_${o}`,i=(r,s,o)=>{const u=c=>{const h=[...o.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:r,subUnitId:s,rule:{...o,ranges:d}},S=[{id:t.SetConditionalRuleMutation.id,params:g}],x=t.setConditionalRuleMutationUndoFactory(this._injector,g);return{redos:S,undos:x}}else{const g={unitId:r,subUnitId:s,cfId:o.cfId},S=[{id:t.DeleteConditionalRuleMutation.id,params:g}],x=t.DeleteConditionalRuleMutationUndoFactory(this._injector,g);return{redos:S,undos:x}}},v=[];o.ranges.forEach(c=>{const h=this._refRangeService.registerRefRange(c,u);v.push(()=>h.dispose())}),n.set(e(r,s,o.cfId),()=>v.forEach(c=>c()))};this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(r=>{const{unitId:s,subUnitId:o,rule:u}=r,v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!(r.unitId!==v.getUnitId()||r.subUnitId!==(c==null?void 0:c.getSheetId())))switch(r.type){case"add":{i(r.unitId,r.subUnitId,r.rule);break}case"delete":{const h=n.get(e(s,o,u.cfId));h&&h();break}case"set":{const h=n.get(e(s,o,u.cfId));h&&h(),i(r.unitId,r.subUnitId,r.rule)}}})),this.disposeWithMe(a.toDisposable(()=>{n.forEach(r=>{r()}),n.clear()}))}};be=ln([we(0,a.Inject(t.ConditionalFormattingRuleModel)),we(1,a.Inject(a.IUniverInstanceService)),we(2,a.Inject(a.Injector)),we(3,a.Inject(U.RefRangeService))],be);var un=Object.getOwnPropertyDescriptor,cn=(n,e,i,r)=>{for(var s=r>1?void 0:r?un(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},ae=(n,e)=>(i,r)=>e(i,r,n);let Ie=class extends a.Disposable{constructor(e,i,r,s,o,u){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=i,this._univerInstanceService=r,this._renderManagerService=s,this._conditionalFormattingViewModel=o,this._conditionalFormattingRuleModel=u,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var i,r,s;const e=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId();(i=this._renderManagerService.getRenderById(e))==null||i.with(H.SheetSkeletonManagerService).reCalculate(),(s=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||s.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(fe.bufferTime(16),fe.filter(e=>!!e.length),fe.filter(e=>{const i=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!i)return!1;const r=i.getActiveSheet();return r?e.filter(s=>s.unitId===i.getUnitId()&&s.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:a.InterceptorEffectEnum.Style,handler:(e,i,r)=>{const s=this._conditionalFormattingService.composeStyle(i.unitId,i.subUnitId,i.row,i.col);if(!s)return r(e);const o=i.workbook.getStyles(),v={...(typeof(e==null?void 0:e.s)=="string"?o.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}},c={...e,s:v};return s.style&&Object.assign(v,s.style),c.fontRenderExtension||(c.fontRenderExtension={},s.isShowValue!==void 0&&(c.fontRenderExtension.isSkip=!s.isShowValue)),s.dataBar&&(c.dataBar=s.dataBar),s.iconSet&&(c.iconSet=s.iconSet,c.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(c)},priority:10}))}};Ie=cn([ae(0,a.Inject(U.SheetInterceptorService)),ae(1,a.Inject(t.ConditionalFormattingService)),ae(2,a.Inject(a.IUniverInstanceService)),ae(3,a.Inject(ht.IRenderManagerService)),ae(4,a.Inject(t.ConditionalFormattingViewModel)),ae(5,a.Inject(t.ConditionalFormattingRuleModel))],Ie);const yt="sheets-conditional-formatting-ui.config",Oe={};var dn=Object.defineProperty,mn=Object.getOwnPropertyDescriptor,vn=(n,e,i)=>e in n?dn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,hn=(n,e,i,r)=>{for(var s=r>1?void 0:r?mn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},He=(n,e)=>(i,r)=>e(i,r,n),St=(n,e,i)=>vn(n,typeof e!="symbol"?e+"":e,i);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends a.Plugin{constructor(e=Oe,i,r,s){super(),this._config=e,this._injector=i,this._commandService=r,this._configService=s;const{menu:o,...u}=a.merge({},Oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yt,u),this._initCommand(),this._injector.add([Ie]),this._injector.add([be]),this._injector.add([ye]),this._injector.add([Se]),this._injector.add([ue])}_initCommand(){[ze,Ye,Ze,Ke,Xe,Je,Qe,et,tt,Fe].forEach(e=>{this._commandService.registerCommand(e)})}};St(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);St(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=hn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),He(1,a.Inject(a.Injector)),He(2,a.Inject(a.ICommandService)),He(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var pn=Object.getOwnPropertyDescriptor,gn=(n,e,i,r)=>{for(var s=r>1?void 0:r?pn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},he=(n,e)=>(i,r)=>e(i,r,n);let Ue=class extends a.Disposable{constructor(n,e,i,r,s){super(),this._injector=n,this._univerInstanceService=e,this._autoFillService=i,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=s,this._initAutoFill()}_initAutoFill(){const n=()=>({redos:[],undos:[]}),e=(s,o,u,v,c)=>{var S;const h=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId();if(!h||!d)return;const m={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},g={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row};a.Range.foreach(u,(x,C)=>{const _=a.Rectangle.getPositionRange({startRow:x,startColumn:C,endColumn:C,endRow:x},m),F=a.Rectangle.getPositionRange({startRow:x,startColumn:C,endColumn:C,endRow:x},g),{row:N,col:E}=c(_.startRow,_.startColumn),j=this._conditionalFormattingViewModel.getCellCfs(h,d,N,E),{row:p,col:b}=c(F.startRow,F.startColumn),T=this._conditionalFormattingViewModel.getCellCfs(h,d,p,b);T&&T.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(h,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.realDeleteValue(p,b)}),j&&j.forEach(I=>{let V=v.get(I.cfId);if(!v.get(I.cfId)){const M=this._conditionalFormattingRuleModel.getRule(h,d,I.cfId);if(!M)return;V=new a.ObjectMatrix,M.ranges.forEach(O=>{a.Range.foreach(O,(P,f)=>{V.setValue(P,f,1)})}),v.set(I.cfId,V)}V.setValue(p,b,1)})})},i=(s,o)=>{var F,N,E;const u=(F=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:F.getUnitId(),v=(E=(N=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:N.getActiveSheet())==null?void 0:E.getSheetId(),c=new Map,h=[],d=[];if(!u||!v)return n();const m=H.virtualizeDiscreteRanges([s,o]),[g,S]=m.ranges,{mapFunc:x}=m,C={row:g.startRow,col:g.startColumn};return H.getAutoFillRepeatRange(g,S).forEach(j=>{e(C,j.repeatStartCell,j.relativeRange,c,x)}),c.forEach((j,p)=>{const b=this._conditionalFormattingRuleModel.getRule(u,v,p);if(!b)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(j));if(T.length){const I={unitId:u,subUnitId:v,rule:{...b,ranges:T}};h.push({id:t.SetConditionalRuleMutation.id,params:I}),d.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:u,subUnitId:v,cfId:b.cfId};h.push({id:t.DeleteConditionalRuleMutation.id,params:I}),d.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:d,redos:h}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(s,o,u)=>{if(u===H.APPLY_TYPE.COPY||u===H.APPLY_TYPE.ONLY_FORMAT||u===H.APPLY_TYPE.SERIES){const{source:v,target:c}=s;return i(v,c)}return n()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ue=gn([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))],Ue);var fn=Object.getOwnPropertyDescriptor,Cn=(n,e,i,r)=>{for(var s=r>1?void 0:r?fn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},pe=(n,e)=>(i,r)=>e(i,r,n);exports.ConditionalFormattingClearController=class extends a.Disposable{constructor(e,i,r,s,o){super(),this._injector=e,this._univerInstanceService=i,this._sheetInterceptorService=r,this._selectionManagerService=s,this._conditionalFormattingRuleModel=o,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var o;const i=[],r=[],s={redos:i,undos:r};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const u=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(x=>x.range);if(!u)return s;const v=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),c=v.getActiveSheet();if(!c)return s;const h=v.getUnitId(),d=c.getSheetId(),m=this._conditionalFormattingRuleModel.getSubunitRules(h,d);if(!m||!m.length)return s;const{redos:g,undos:S}=ct(this._injector,m,u,h,d);i.push(...g),r.push(...S)}return s}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:i,ranges:r})=>{const s=[],o=[],u={redos:s,undos:o};if(!r||!r.length)return u;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,i);if(!v||!v.length)return u;const{redos:c,undos:h}=ct(this._injector,v,r,e,i);return s.push(...c),o.push(...h),u}}))}};exports.ConditionalFormattingClearController=Cn([pe(0,a.Inject(a.Injector)),pe(1,a.Inject(a.IUniverInstanceService)),pe(2,a.Inject(U.SheetInterceptorService)),pe(3,a.Inject(U.SheetsSelectionsService)),pe(4,a.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ct(n,e,i,r,s){const o=[],u=[];return e.filter(v=>i.some(c=>v.ranges.some(h=>a.Rectangle.getIntersects(h,c)))).forEach(v=>{const h=new U.RangeMergeUtil().add(...v.ranges).subtract(...i).merge();if(h.length){const d={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:s,rule:{...v,ranges:h}}},m=t.setConditionalRuleMutationUndoFactory(n,d.params);o.push(d),u.push(...m)}else{const d={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:s,cfId:v.cfId}},m=t.DeleteConditionalRuleMutationUndoFactory(n,d.params);o.push(d),u.push(...m)}}),{redos:o,undos:u}}var yn=Object.getOwnPropertyDescriptor,Sn=(n,e,i,r)=>{for(var s=r>1?void 0:r?yn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},dt=(n,e)=>(i,r)=>e(i,r,n);let ke=class extends a.Disposable{constructor(n,e){super(),this._sheetInterceptorService=n,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(a.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(n,e,i)=>{var u,v,c;n||i(n);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),s=(u=r==null?void 0:r.style)!=null?u:{},o=Object.keys(s);if(n!=null&&n.p)return(c=(v=n.p.body)==null?void 0:v.textRuns)==null||c.forEach(h=>{h.ts&&o.forEach(d=>{var m;(m=h.ts)==null||delete m[d]})}),i(n);{const h={...(typeof(n==null?void 0:n.s)=="string"?e.workbook.getStyles().get(n.s):n==null?void 0:n.s)||{}};o.forEach(m=>{delete h[m]});const d={...n,s:{...h}};return i(d)}}})))}};ke=Sn([dt(0,a.Inject(U.SheetInterceptorService)),dt(1,a.Inject(t.ConditionalFormattingService))],ke);const mt=[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: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}],bn=n=>{const e=n.get(U.SheetsSelectionsService),i=n.get(a.ICommandService),r=n.get(a.IUniverInstanceService),s=n.get(t.ConditionalFormattingRuleModel),o=new K.Observable(c=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(h=>{const d=i.onCommandExecuted(m=>{var C;const{id:g,params:S}=m,x=(C=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:C.getUnitId();mt.includes(g)&&S.unitId===x&&h.next(null)});return()=>d.dispose()})).pipe(fe.debounceTime(16)).subscribe(()=>{var C;const h=((C=e.getCurrentSelections())==null?void 0:C.map(_=>_.range))||[],d=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!d)return;const m=d.getActiveSheet();if(!m)return;const x=(s.getSubunitRules(d.getUnitId(),m.getSheetId())||[]).filter(_=>_.ranges.some(F=>h.some(N=>a.Rectangle.intersects(N,F)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(n,d.getUnitId(),m.getSheetId(),_));c.next(x)})),u=new K.Observable(c=>new K.Observable(h=>{const d=i.onCommandExecuted(m=>{var C;const{id:g,params:S}=m,x=(C=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:C.getUnitId();mt.includes(g)&&S.unitId===x&&h.next(null)});return()=>d.dispose()}).pipe(fe.debounceTime(16)).subscribe(()=>{const h=r.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET);if(!h)return;const d=h.getActiveSheet();if(!d)return;const m=s.getSubunitRules(h.getUnitId(),d.getSheetId())||[];if(!m.length)return c.next(!1),!1;const g=m.map(S=>S.ranges).every(S=>U.checkRangesEditablePermission(n,h.getUnitId(),d.getSheetId(),S));c.next(g)})),v=new K.Observable(c=>{o.subscribe(h=>{const d=ge.find(m=>m.value===Y.clearRangeRules);d&&(d.disabled=!h,c.next(ge))}),u.subscribe(h=>{const d=ge.find(m=>m.value===Y.clearWorkSheetRules);d&&(d.disabled=!h,c.next(ge))}),c.next(ge)});return{id:Fe.id,type:k.MenuItemType.SELECTOR,icon:"Conditions",tooltip:"sheet.cf.title",selections:v,hidden$:k.getMenuHiddenObservable(n,a.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(n,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},In={[k.RibbonDataGroup.RULES]:{[Fe.id]:{order:1,menuItemFactory:bn}}};var xn=Object.getOwnPropertyDescriptor,Tn=(n,e,i,r)=>{for(var s=r>1?void 0:r?xn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},vt=(n,e)=>(i,r)=>e(i,r,n);let Pe=class extends a.Disposable{constructor(e,i){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=i,this._menuManagerService.mergeMenu(In)}};Pe=Tn([vt(0,a.Inject(a.Injector)),vt(1,k.IMenuManagerService)],Pe);var Rn=Object.getOwnPropertyDescriptor,Fn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Rn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},le=(n,e)=>(i,r)=>e(i,r,n);const _n=(n,e)=>{const i=d=>d.endRow-d.startRow+1,r=d=>d.endColumn-d.startColumn+1,s=i(e)%i(n),o=r(e)%r(n),u=Math.floor(i(e)/i(n)),v=Math.floor(r(e)/r(n)),c=[],h={startRow:0,endRow:i(n)-1,startColumn:0,endColumn:r(n)-1};if(i(e)===1&&r(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<u+(s?.1:0);d++)for(let m=0;m<v+(o?.1:0);m++){const g=i(n)*d,S=r(n)*m,x={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:S+e.startColumn,endColumn:S+e.startColumn};let C=h;d===u&&s&&(C={...C},C.endRow=C.endRow-(i(n)-s)),m===v&&o&&(C={...C},C.endColumn=C.endColumn-(r(n)-o)),c.push({repeatRelativeRange:C,startRange:x})}return c};let De=class extends a.Disposable{constructor(e,i,r,s,o,u){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=i,this._formatPainterService=r,this._sheetsSelectionsService=s,this._conditionalFormattingRuleModel=o,this._conditionalFormattingViewModel=u,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),i=(o,u,v,c,h)=>{const{unitId:d,subUnitId:m}=this._painterConfig,{targetUnitId:g,targetSubUnitId:S}=h,x={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},C={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};a.Range.foreach(v,(_,F)=>{const N=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},x),E=a.Rectangle.getPositionRange({startRow:_,startColumn:F,endColumn:F,endRow:_},C),j=this._conditionalFormattingViewModel.getCellCfs(d,m,N.startRow,N.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(g,S,E.startRow,E.startColumn);p&&p.forEach(b=>{let T=c.get(b.cfId);if(!c.get(b.cfId)){const I=this._conditionalFormattingRuleModel.getRule(g,S,b.cfId);if(!I)return;T=new a.ObjectMatrix,I.ranges.forEach(V=>{a.Range.foreach(V,(M,O)=>{T.setValue(M,O,1)})}),c.set(b.cfId,T)}T.realDeleteValue(E.startRow,E.startColumn)}),j&&j.forEach(b=>{const T=c.get(b.cfId);T&&T.setValue(E.startRow,E.startColumn,1)})})},r=(o,u,v)=>{var N;const{range:c,unitId:h,subUnitId:d}=this._painterConfig,m=o!==h||d!==u,g=new Map,S=[],x=[];if(!o||!u||!h||!d)return e();const C=(N=this._conditionalFormattingRuleModel.getSubunitRules(h,d))!=null?N:[];C==null||C.forEach(E=>{const{ranges:j,cfId:p}=E;if(j.some(b=>a.Rectangle.intersects(c,b))){const b=new a.ObjectMatrix;m||j.forEach(T=>{a.Range.foreach(T,(I,V)=>{b.setValue(I,V,1)})}),g.set(p,b)}});const _={row:c.startRow,col:c.startColumn};return _n(c,v).forEach(E=>{i(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,g,{targetUnitId:o,targetSubUnitId:u})}),g.forEach((E,j)=>{if(m){const p=this._conditionalFormattingRuleModel.getRule(o,u,j),b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(p)if(b.length){const T={unitId:o,subUnitId:u,rule:{...p,ranges:b}};S.push({id:t.SetConditionalRuleMutation.id,params:T}),x.push(...t.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:o,subUnitId:u,cfId:p.cfId};S.push({id:t.DeleteConditionalRuleMutation.id,params:T}),x.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}else if(b.length){const T=this._conditionalFormattingRuleModel.getRule(h,d,j);if(T){const I={unitId:o,subUnitId:u,rule:{...a.Tools.deepClone(T),cfId:this._conditionalFormattingRuleModel.createCfId(o,u),ranges:b}};S.push({id:t.AddConditionalRuleMutation.id,params:I}),x.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const p=this._conditionalFormattingRuleModel.getRule(h,d,j);if(!p)return;const b=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(b.length){const T={unitId:h,subUnitId:d,rule:{...p,ranges:b}};S.push({id:t.SetConditionalRuleMutation.id,params:T}),x.push(...t.setConditionalRuleMutationUndoFactory(this._injector,T))}else{const T={unitId:h,subUnitId:d,cfId:p.cfId};S.push({id:t.DeleteConditionalRuleMutation.id,params:T}),x.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,T))}}}),{undos:x,redos:S}},s={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:o=>{var u,v,c;switch(o){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const h=(u=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET))==null?void 0:u.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:(o,u,v)=>this._painterConfig?r(o,u,v):{redos:[],undos:[]}};this._formatPainterService.addHook(s)}};De=Fn([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 Nn=Object.getOwnPropertyDescriptor,jn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Nn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},We=(n,e)=>(i,r)=>e(i,r,n);let Le=class extends a.Disposable{constructor(n,e,i){super(),this._conditionalFormattingViewModel=n,this._univerInstanceService=e,this._renderManagerService=i,this._init()}_init(){const n=this._univerInstanceService.getCurrentUnitForType(a.UniverInstanceType.UNIVER_SHEET),e=i=>{const r=i.getUnitId(),s=this._renderManagerService.getRenderById(r);if(!s)return;const o=s.with(H.SheetSkeletonManagerService);this.disposeWithMe(o.currentSkeleton$.subscribe(u=>{if(u){const v=u.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)}}))};n&&e(n),this._univerInstanceService.getCurrentTypeOfUnit$(a.UniverInstanceType.UNIVER_SHEET).subscribe(i=>{i&&e(i)})}};Le=jn([We(0,a.Inject(t.ConditionalFormattingViewModel)),We(1,a.IUniverInstanceService),We(2,ht.IRenderManagerService)],Le);var En=Object.defineProperty,Mn=Object.getOwnPropertyDescriptor,wn=(n,e,i)=>e in n?En(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i,Vn=(n,e,i,r)=>{for(var s=r>1?void 0:r?Mn(e,i):e,o=n.length-1,u;o>=0;o--)(u=n[o])&&(s=u(s)||s);return s},qe=(n,e)=>(i,r)=>e(i,r,n),bt=(n,e,i)=>wn(n,typeof e!="symbol"?e+"":e,i);exports.UniverSheetsConditionalFormattingUIPlugin=class extends a.Plugin{constructor(e=Oe,i,r,s){super(),this._config=e,this._injector=i,this._commandService=r,this._configService=s;const{menu:o,...u}=a.merge({},Oe,this._config);o&&this._configService.setConfig("menu",o,{merge:!0}),this._configService.setConfig(yt,u),this._initCommand()}onStarting(){a.registerDependencies(this._injector,[[Ie],[be],[ye],[Ue],[Se],[Ce],[Pe],[ue],[ke],[exports.ConditionalFormattingClearController],[De],[Le]]),a.touchDependencies(this._injector,[[Ie]])}onReady(){a.touchDependencies(this._injector,[[Pe],[Ce]])}onRendered(){a.touchDependencies(this._injector,[[Ue],[exports.ConditionalFormattingClearController],[ye],[ke],[ue],[De],[Se],[be],[Le]])}_initCommand(){[ze,Ye,Ze,Ke,Xe,Je,Qe,et,tt,Fe].forEach(e=>{this._commandService.registerCommand(e)})}};bt(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);bt(exports.UniverSheetsConditionalFormattingUIPlugin,"type",a.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Vn([a.DependentOn(t.UniverSheetsConditionalFormattingPlugin),qe(1,a.Inject(a.Injector)),qe(2,a.Inject(a.ICommandService)),qe(3,a.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=ze;exports.AddColorScaleConditionalRuleCommand=Ye;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=Ke;exports.AddNumberCfCommand=Xe;exports.AddRankCfCommand=Je;exports.AddTextCfCommand=Qe;exports.AddTimePeriodCfCommand=et;exports.AddUniqueValuesCfCommand=tt;exports.OpenConditionalFormattingOperator=Fe;
|