@univerjs/sheets-conditional-formatting-ui 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Et=Object.defineProperty;var jt=(i,e,n)=>e in i?Et(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var Q=(i,e,n)=>jt(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),U=require("@univerjs/sheets"),t=require("@univerjs/sheets-conditional-formatting"),P=require("@univerjs/ui"),u=require("react/jsx-runtime"),C=require("react"),M=require("@univerjs/design"),We=require("@univerjs/engine-formula"),Se=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),ht=require("@univerjs/sheets-formula"),vt=require("@univerjs/engine-render"),ge=require("rxjs/operators"),qe={type:l.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s}=e,a=i.get(t.ConditionalFormattingRuleModel),m=i.get(l.ICommandService),d=i.get(l.IUniverInstanceService),p=U.getSheetCommandTarget(d);if(!p)return!1;const{unitId:c,subUnitId:h}=p,g=a.createCfId(c,h),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:s,style:r}};return m.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:h,rule:b})}},Ge={type:l.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,config:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.ICommandService),m=i.get(l.IUniverInstanceService),d=U.getSheetCommandTarget(m);if(!d)return!1;const{unitId:p,subUnitId:c}=d,h=s.createCfId(p,c),g={ranges:n,cfId:h,stopIfTrue:!!o,rule:{type:t.CFRuleType.colorScale,config:r}};return a.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:c,rule:g})}},Ze={type:l.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,min:r,max:o,nativeColor:s,positiveColor:a,isGradient:m,stopIfTrue:d,isShowValue:p}=e,c=i.get(t.ConditionalFormattingRuleModel),h=i.get(l.IUniverInstanceService),g=U.getSheetCommandTarget(h);if(!g)return!1;const{unitId:b,subUnitId:S}=g,y=i.get(l.ICommandService),_=c.createCfId(b,S),x={ranges:n,cfId:_,stopIfTrue:!!d,rule:{type:t.CFRuleType.dataBar,isShowValue:p,config:{min:r,max:o,nativeColor:s,positiveColor:a,isGradient:m}}};return y.executeCommand(t.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:x})}},ze={type:l.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.ICommandService),m=i.get(l.IUniverInstanceService),d=U.getSheetCommandTarget(m);if(!d)return!1;const{unitId:p,subUnitId:c}=d,h=s.createCfId(p,c),g={ranges:n,cfId:h,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:r}};return a.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:c,rule:g})}},Ye={type:l.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s,value:a}=e,m=i.get(t.ConditionalFormattingRuleModel),d=i.get(l.ICommandService),p=i.get(l.IUniverInstanceService),c=U.getSheetCommandTarget(p);if(!c)return!1;const{unitId:h,subUnitId:g}=c,b=m.createCfId(h,g);let S;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(s)){const y=a;if(y.length!==2||!Array.isArray(y))return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:r,value:y}}}else{const y=a;if(typeof y!="number")return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:r,value:y}}}return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:S})}},Ke={type:l.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,isPercent:s,isBottom:a,value:m}=e,d=i.get(t.ConditionalFormattingRuleModel),p=i.get(l.IUniverInstanceService),c=i.get(l.ICommandService),h=U.getSheetCommandTarget(p);if(!h)return!1;const{unitId:g,subUnitId:b}=h,S=d.createCfId(g,b),y={ranges:n,cfId:S,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:s,isBottom:a,style:r,value:m}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:y})}},Xe={type:l.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s,value:a}=e,m=i.get(t.ConditionalFormattingRuleModel),d=i.get(l.IUniverInstanceService),p=U.getSheetCommandTarget(d);if(!p)return!1;const{unitId:c,subUnitId:h}=p,g=i.get(l.ICommandService),b=m.createCfId(c,h),S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:s,style:r,value:a}};return g.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:h,rule:S})}},Je={type:l.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s}=e,a=i.get(t.ConditionalFormattingRuleModel),m=i.get(l.IUniverInstanceService),d=i.get(l.ICommandService),p=U.getSheetCommandTarget(m);if(!p)return!1;const{unitId:c,subUnitId:h}=p,g=a.createCfId(c,h),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:s,style:r}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:h,rule:b})}},Qe={type:l.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.IUniverInstanceService),m=i.get(l.ICommandService),d=U.getSheetCommandTarget(a);if(!d)return!1;const{unitId:p,subUnitId:c}=d,h=s.createCfId(p,c),g={ranges:n,cfId:h,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:r}};return m.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:c,rule:g})}};function Y({ref:i,...e}){const{icon:n,id:r,className:o,extend:s,...a}=e,m=`univerjs-icon univerjs-icon-${r} ${o||""}`.trim(),d=C.useRef(`_${Ot()}`);return pt(n,`${r}`,{defIds:n.defIds,idSuffix:d.current},{ref:i,className:m,...a},s)}function pt(i,e,n,r,o){return C.createElement(i.tag,{key:e,...Mt(i,n,o),...r},(Vt(i,n).children||[]).map((s,a)=>pt(s,`${e}-${i.tag}-${a}`,n,void 0,o)))}function Mt(i,e,n){const r={...i.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([s,a])=>{s==="mask"&&typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([s,a])=>{typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function Vt(i,e){var r;const{defIds:n}=e;return!n||n.length===0?i:i.tag==="defs"&&((r=i.children)!=null&&r.length)?{...i,children:i.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:i}function Ot(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const Ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"bold-icon",ref:n,icon:Ut}))});gt.displayName="BoldIcon";const kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},je=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"delete-icon",ref:n,icon:kt}))});je.displayName="DeleteIcon";const Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},ft=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"increase-icon",ref:n,icon:Pt}))});ft.displayName="IncreaseIcon";const Dt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},Ct=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"italic-icon",ref:n,icon:Dt}))});Ct.displayName="ItalicIcon";const Lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"more-down-icon",ref:n,icon:Lt}))});et.displayName="MoreDownIcon";const At={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},yt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"sequence-icon",ref:n,icon:At}))});yt.displayName="SequenceIcon";const $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},bt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"strikethrough-icon",ref:n,icon:$t}))});bt.displayName="StrikethroughIcon";const Bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},It=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"underline-icon",ref:n,icon:Bt}))});It.displayName="UnderlineIcon";const Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},St=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"font-color-double-icon",ref:n,icon:Ht}))});St.displayName="FontColorDoubleIcon";const Wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},Tt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"paint-bucket-double-icon",ref:n,icon:Wt}))});Tt.displayName="PaintBucketDoubleIcon";const qt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"slash-double-icon",ref:n,icon:qt}))});Te.displayName="SlashDoubleIcon";const re=i=>{const{color:e,onChange:n,disable:r=!1,Icon:o=Tt,className:s}=i,a=C.useMemo(()=>new l.ColorKit(e),[e]),m=()=>{const d={className:M.clsx("univer-fill-primary-600",r&&s),extend:{colorChannel1:a.isValid?e:""}};return u.jsx(o,{...d})};return r?m():u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(M.ColorPicker,{value:e,onChange:n})}),children:u.jsx("span",{className:M.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",s),children:m()})})},ce=i=>{var s,a,m,d,p;const e=i.rule;if(!e)return null;const n=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const c=e.config.map((b,S)=>({color:new l.ColorKit(b.color),value:S})),h=c.length-1;return new Array(5).fill("").map((b,S,y)=>S*h/(y.length-1)).map(b=>t.getColorScaleFromValue(c,b))}return null},[e]),r=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(c=>{const h=t.iconMap[c.iconType];return h&&h[Number(c.iconId)]})},[e]),o="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:c}=e.config,h=c?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=c?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return u.jsxs("div",{className:o,children:[u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(s=e.config.nativeColor)!=null?s:t.defaultDataBarNativeColor}}),u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:h,borderColor:(a=e.config.positiveColor)!=null?a:t.defaultDataBarPositiveColor}})]})}case t.CFRuleType.colorScale:return n&&u.jsx("div",{className:o,children:n.map((c,h)=>u.jsx("div",{className:"univer-h-full",style:{width:`${100/n.length}%`,background:c}},h))});case t.CFRuleType.iconSet:return r&&u.jsx("div",{className:o,children:r.map((c,h)=>c?u.jsx("img",{className:"univer-h-full",src:c,draggable:!1},h):u.jsx(Te,{},h))});case t.CFRuleType.highlightCell:{const{ul:c,st:h,it:g,bl:b,bg:S,cl:y}=e.style,_=(c==null?void 0:c.s)===l.BooleanNumber.TRUE,x=(h==null?void 0:h.s)===l.BooleanNumber.TRUE,w=g===l.BooleanNumber.TRUE,E=b===l.BooleanNumber.TRUE,N=(m=S==null?void 0:S.rgb)!=null?m:t.DEFAULT_BG_COLOR,v=(d=y==null?void 0:y.rgb)!=null?d:t.DEFAULT_FONT_COLOR,T={textDecoration:(p=`${_?"underline":""} ${x?"line-through":""}`.replace(/^ /,""))!=null?p:void 0,backgroundColor:N,color:v};return u.jsx("div",{className:M.clsx(o,{"univer-font-bold":E,"univer-italic":w}),style:T,children:"123"})}}},xe=M.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",M.borderClassName),ne=(i,e)=>({label:e.t(`sheet.cf.valueType.${i}`),value:i}),De=i=>{var S;const{type:e,className:n,onChange:r,id:o,value:s}=i,a=P.useDependency(l.IUniverInstanceService),m=a.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=a.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),p=C.useMemo(()=>String(s).startsWith("=")?String(s):"=",[s]),c=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),[g,b]=C.useState(!1);return P.useSidebarClick(y=>{var x;(x=h.current)!=null&&x.isClickOutSide(y)&&b(!1)}),e===t.CFValueType.formula?u.jsx("div",{className:"univer-ml-1 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:h,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:p,unitId:m,subUnitId:d,isFocus:g,onChange:(y="")=>{r(y||"")},onFocus:()=>b(!0)})}):u.jsx(M.InputNumber,{className:n,value:Number(i.value)||0,onChange:y=>i.onChange(y||0),...c})},Gt=i=>{var k;const{interceptorManager:e}=i,n=P.useDependency(l.LocaleService),r=((k=i.rule)==null?void 0:k.type)===t.CFRuleType.colorScale?i.rule:void 0,o=[ne(t.CFValueType.num,n),ne(t.CFValueType.percent,n),ne(t.CFValueType.percentile,n),ne(t.CFValueType.formula,n)],s=[ne(t.CFValueType.min,n),...o],a=[ne("none",n),...o],m=[ne(t.CFValueType.max,n),...o],[d,p]=C.useState(()=>{var F;const f=t.CFValueType.min;return r&&((F=r.config[0])==null?void 0:F.value.type)||f}),[c,h]=C.useState(()=>{var F;const f="none";return!r||r.config.length!==3?f:((F=r.config[1])==null?void 0:F.value.type)||f}),[g,b]=C.useState(()=>{var F;const f=t.CFValueType.max;return r&&((F=r.config[r.config.length-1])==null?void 0:F.value.type)||f}),[S,y]=C.useState(()=>{if(!r)return 10;const F=r.config[0];return(F==null?void 0:F.value.value)===void 0?10:F==null?void 0:F.value.value}),[_,x]=C.useState(()=>{var L;if(!r||r.config.length!==3)return 50;const F=(L=r.config[1])==null?void 0:L.value.value;return F===void 0?50:F}),[w,E]=C.useState(()=>{var L;if(!r)return 90;const F=(L=r.config[r.config.length-1])==null?void 0:L.value.value;return F===void 0?90:F}),[N,v]=C.useState(()=>{var F;const f="#d0d9fb";return r&&((F=r.config[0])==null?void 0:F.color)||f}),[T,R]=C.useState(()=>{var F;const f="#7790f3";return!r||r.config.length!==3?f:((F=r.config[1])==null?void 0:F.color)||f}),[I,V]=C.useState(()=>{var F;const f="#2e55ef";return r&&((F=r.config[r.config.length-1])==null?void 0:F.color)||f}),j=C.useMemo(()=>f=>{const{minType:F,medianType:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:oe,medianColor:D,maxColor:A}=f,B=[];return B.push({color:oe,value:{type:F,value:X}}),L!=="none"&&B.push({color:D,value:{type:L,value:J}}),B.push({color:A,value:{type:q,value:ie}}),{config:B.map((G,Z)=>({...G,index:Z})),type:t.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return j({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),[j,d,c,g,S,_,w,N,T,I,e]);const O=f=>{i.onChange(j(f))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:j({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})})}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:s,value:d,onChange:f=>{p(f);const F=t.createDefaultValueByValueType(f,10);y(F),O({minType:f,medianType:c,maxType:g,minValue:F,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"min",className:"univer-ml-1",value:S,type:d,onChange:f=>{y(f),O({minType:d,medianType:c,maxType:g,minValue:f,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:N,onChange:f=>{v(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:f,medianColor:T,maxColor:I})}})]}),u.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:n.t("sheet.cf.panel.medianValue")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:a,value:c,onChange:f=>{h(f);const F=t.createDefaultValueByValueType(f,50);x(F),O({minType:d,medianType:f,maxType:g,minValue:S,medianValue:F,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"median",className:"univer-ml-1",value:_,type:c,onChange:f=>{x(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:f,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),c!=="none"&&u.jsx(re,{className:"univer-ml-1",color:T,onChange:f=>{R(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:f,maxColor:I})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:m,value:g,onChange:f=>{b(f);const F=t.createDefaultValueByValueType(f,90);E(F),O({minType:d,medianType:c,maxType:f,minValue:S,medianValue:_,maxValue:F,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"max",className:"univer-ml-1",value:w,type:g,onChange:f=>{E(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:f,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:f})}})]})]})},se=(i,e)=>({label:e.t(`sheet.cf.valueType.${i}`),value:i}),nt=i=>{var y;const{onChange:e,className:n,value:r,type:o,id:s,disabled:a=!1}=i,m=P.useDependency(l.IUniverInstanceService),d=m.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),p=(y=m.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId(),c=C.useRef(null),[h,g]=C.useState(!1);P.useSidebarClick(_=>{var w;(w=c.current)!=null&&w.isClickOutSide(_)&&g(!1)});const b=C.useRef(r),S=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(o)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[o]);if(o===t.CFValueType.formula){const _=String(b.current).startsWith("=")?String(b.current)||"":"=";return u.jsx("div",{className:"univer-ml-3 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:c,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:_,unitId:d,subUnitId:p,isFocus:h,onChange:(x="")=>{e(x||"")},onFocus:()=>g(!0)})})}return u.jsx(M.InputNumber,{className:n,value:Number(r)||0,disabled:a,onChange:_=>{e(_||0)},...S})},Zt=i=>{var k;const{interceptorManager:e}=i,n=P.useDependency(l.LocaleService),r=((k=i.rule)==null?void 0:k.type)===t.CFRuleType.dataBar?i.rule:void 0,[o,s]=C.useState(()=>{var F;return r&&(F=r.config)!=null&&F.isGradient?"1":"0"}),[a,m]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[d,p]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),c=[se(t.CFValueType.num,n),se(t.CFValueType.percent,n),se(t.CFValueType.percentile,n),se(t.CFValueType.formula,n)],h=[se(t.CFValueType.min,n),...c],g=[se(t.CFValueType.max,n),...c],[b,S]=C.useState(()=>{var F;const f=h[0].value;return r&&((F=r.config)==null?void 0:F.min.type)||f}),[y,_]=C.useState(()=>{var F;const f=g[0].value;return r&&((F=r.config)==null?void 0:F.max.type)||f}),[x,w]=C.useState(()=>{var L;if(!r)return 0;const F=((L=r.config)==null?void 0:L.min)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value||0}),[E,N]=C.useState(()=>{var L;if(!r)return 100;const F=((L=r.config)==null?void 0:L.max)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value===void 0?100:F.value}),[v,T]=C.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),R=f=>({config:{min:{type:f.minValueType,value:f.minValue},max:{type:f.maxValueType,value:f.maxValue},isGradient:f.isGradient==="1",positiveColor:f.positiveColor||t.defaultDataBarPositiveColor,nativeColor:f.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:f.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return R({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}}),[o,x,b,E,y,a,d,e,v]);const I=f=>{i.onChange(R(f))},V=f=>{m(f),I({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:f,nativeColor:d,isShowValue:v})},j=f=>{p(f),I({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:f,isShowValue:v})},O=f=>c.map(F=>F.value).includes(f);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:R({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})})}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.fillType")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs(M.RadioGroup,{value:o,onChange:f=>{s(f),I({isGradient:f,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})},children:[u.jsx(M.Radio,{value:"0",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.pureColor")})}),u.jsx(M.Radio,{value:"1",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.gradient")})})]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!v,onChange:f=>{T(!f),I({isGradient:f,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:!f})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.colorSet")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs("div",{className:"univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.native")}),u.jsx(re,{color:d,onChange:j})]}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.positive")}),u.jsx(re,{color:a,onChange:V})]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:b,onChange:f=>{S(f);const F=t.createDefaultValueByValueType(f,10);w(F),I({isGradient:o,minValue:F,minValueType:f,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}}),u.jsx(nt,{id:"min",className:"univer-ml-3",disabled:!O(b),type:b,value:x,onChange:f=>{w(f||0),I({isGradient:o,minValue:f||0,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:y,onChange:f=>{_(f);const F=t.createDefaultValueByValueType(f,90);N(F),I({isGradient:o,minValue:x,minValueType:b,maxValue:F,maxValueType:f,positiveColor:a,nativeColor:d,isShowValue:v})}}),u.jsx(nt,{className:"univer-ml-3",disabled:!O(y),id:"max",type:y,value:E,onChange:f=>{N(f||0),I({isGradient:o,minValue:x,minValueType:b,maxValue:f||0,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}})]})]})]})},_e=i=>[l.BooleanNumber.FALSE,void 0].includes(i)?l.BooleanNumber.TRUE:l.BooleanNumber.FALSE,we=i=>i!==l.BooleanNumber.FALSE,tt=i=>{const{style:e,onChange:n,className:r}=i,[o,s]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[a,m]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[d,p]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[c,h]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[g,b]=C.useState(()=>{var w;const x="#2f56ef";return(w=e==null?void 0:e.cl)!=null&&w.rgb?e.cl.rgb:x}),[S,y]=C.useState(()=>{var w;const x="#e8ecfc";return(w=e==null?void 0:e.bg)!=null&&w.rgb?e.bg.rgb:x});C.useEffect(()=>{const x={bl:o,it:a};g!==void 0&&(x.cl={rgb:g}),S!==void 0&&(x.bg={rgb:S}),c!==void 0&&(x.st={s:c}),d!==void 0&&(x.ul={s:d}),n(t.removeUndefinedAttr(x))},[o,a,d,c,g,S]);const _="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return u.jsxs("div",{className:M.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(o||l.BooleanNumber.FALSE)}),onClick:()=>s(_e(o)),children:u.jsx(gt,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(a||l.BooleanNumber.FALSE)}),onClick:()=>m(_e(a)),children:u.jsx(Ct,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(d||l.BooleanNumber.FALSE)}),onClick:()=>p(_e(d)),children:u.jsx(It,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(c||l.BooleanNumber.FALSE)}),onClick:()=>h(_e(c)),children:u.jsx(bt,{})}),u.jsx(re,{color:g,onChange:b,Icon:St}),u.jsx(re,{color:S,onChange:y})]})},zt=i=>{var N;const{onChange:e,interceptorManager:n}=i,r=P.useDependency(l.LocaleService),s=P.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),a=s.getActiveSheet(),m=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?i.rule:void 0,d=C.useRef(null),[p,c]=C.useState(!1),h=C.useRef(null),[g,b]=C.useState({}),[S,y]=C.useState(()=>(m==null?void 0:m.subType)===t.CFSubRuleType.formula?m.value:"="),[_,x]=C.useState(void 0),w=v=>({style:v.style,value:S,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return w({style:g})}}),[g,S,n]),C.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(T,R,I)=>_||S.length===1||!S.startsWith("=")?(x(r.t("sheet.cf.errorMessage.formulaError")),!1):I(T)}),[_,S]);const E=v=>{e(w(v))};return P.useSidebarClick(v=>{var R;(R=h.current)!=null&&R.isClickOutSide(v)&&c(!1)}),u.jsxs("div",{ref:d,children:[u.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")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(Se.FormulaEditor,{ref:h,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),errorText:_,isFocus:p,initValue:S,unitId:s.getUnitId(),subUnitId:a==null?void 0:a.getSheetId(),onFocus:()=>{c(!0)},onChange:v=>{y(v),E({style:g})},onVerify:(v,T)=>{!v||T.length===1?x(r.t("sheet.cf.errorMessage.formulaError")):x(void 0)}})}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:w({style:g})})}),u.jsx(tt,{style:m==null?void 0:m.style,className:"univer-mt-3",onChange:v=>{b(v),E({style:v})}})]})},Ne=i=>u.jsxs("div",{className:"univer-relative",children:[u.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:i.errorText}),i.children]}),$=(i,e)=>({label:e.t(`sheet.cf.operator.${i}`),value:i}),Yt=i=>{const{type:e,operator:n,onChange:r,value:o,interceptorManager:s}=i,a=P.useDependency(l.LocaleService),[m,d]=C.useState(()=>typeof o=="number"?o:0),[p,c]=C.useState(""),[h,g]=C.useState(()=>typeof o=="string"?o:""),[b,S]=C.useState(""),[y,_]=C.useState(()=>Array.isArray(o)?o[0]===void 0?0:o[0]:0),[x,w]=C.useState(""),[E,N]=C.useState(()=>Array.isArray(o)?o[1]===void 0?100:o[1]:100),[v,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)&&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(n)&&r(m),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)&&r([y,E]);break}}},[e]),C.useEffect(()=>{const R=s.intercept(s.getInterceptPoints().beforeSubmit,{handler:(I,V,j)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(n))return h?j(I):(S(a.t("sheet.cf.errorMessage.notBlank")),!1)}return j(I)}});return()=>{R()}},[e,m,h,n]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)){const R=I=>{g(I),r(I)};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:b,children:u.jsx(M.Input,{value:h,onChange:I=>{S(""),R(I)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)){const R=I=>{d(I||0),r(I||0),c("")};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:p,children:u.jsx(M.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:R})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)){const R=V=>{_(V||0),r([V||0,E]),w("")},I=V=>{N(V||0),r([y,V||0]),T("")};return u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(Ne,{errorText:x,children:u.jsx(M.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:y,onChange:R})}),u.jsx(Ne,{errorText:v,children:u.jsx(M.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},rt=(i,e)=>{switch(i){case t.CFSubRuleType.text:return[$(t.CFTextOperator.containsText,e),$(t.CFTextOperator.notContainsText,e),$(t.CFTextOperator.beginsWith,e),$(t.CFTextOperator.endsWith,e),$(t.CFTextOperator.equal,e),$(t.CFTextOperator.notEqual,e),$(t.CFTextOperator.containsBlanks,e),$(t.CFTextOperator.notContainsBlanks,e),$(t.CFTextOperator.containsErrors,e),$(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[$(t.CFNumberOperator.between,e),$(t.CFNumberOperator.notBetween,e),$(t.CFNumberOperator.equal,e),$(t.CFNumberOperator.notEqual,e),$(t.CFNumberOperator.greaterThan,e),$(t.CFNumberOperator.greaterThanOrEqual,e),$(t.CFNumberOperator.lessThan,e),$(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[$(t.CFTimePeriodOperator.yesterday,e),$(t.CFTimePeriodOperator.today,e),$(t.CFTimePeriodOperator.tomorrow,e),$(t.CFTimePeriodOperator.last7Days,e),$(t.CFTimePeriodOperator.lastWeek,e),$(t.CFTimePeriodOperator.thisWeek,e),$(t.CFTimePeriodOperator.nextWeek,e),$(t.CFTimePeriodOperator.lastMonth,e),$(t.CFTimePeriodOperator.thisMonth,e),$(t.CFTimePeriodOperator.nextMonth,e)]}},it=i=>{var N;const{interceptorManager:e,onChange:n}=i,r=P.useDependency(l.LocaleService),o=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?i.rule:void 0,[s,a]=C.useState(()=>{const v=t.CFSubRuleType.text;return o&&o.subType||v}),m=[{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")}],d=C.useMemo(()=>rt(s,r),[s]),[p,c]=C.useState(()=>{const v=d?d[0].value:void 0;return o&&o.operator||v}),[h,g]=C.useState(()=>{var R;return o?(R=o.value)!=null?R:t.createDefaultValue(o.subType,o.operator):""}),[b,S]=C.useState({}),y=C.useMemo(()=>v=>{var T,R,I,V,j,O,k,f,F,L,q,X,J,ie,oe;switch(v.subType||s){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(p))return{type:t.CFRuleType.highlightCell,subType:(T=v.subType)!=null?T:s,operator:(R=v.operator)!=null?R:p,style:(I=v.style)!=null?I:b,value:(V=v.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(p))return{type:t.CFRuleType.highlightCell,subType:(j=v.subType)!=null?j:s,operator:(O=v.operator)!=null?O:p,style:(k=v.style)!=null?k:b,value:(f=v.value)!=null?f:h};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(p))return{type:t.CFRuleType.highlightCell,subType:(F=v.subType)!=null?F:s,operator:(L=v.operator)!=null?L:p,style:(q=v.style)!=null?q:b,value:(X=v.value)!=null?X:h};break}}return{type:t.CFRuleType.highlightCell,subType:(J=v.subType)!=null?J:s,operator:(ie=v.operator)!=null?ie:p,style:(oe=v.style)!=null?oe:b}},[s,p,h,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return y({})}}),[y,e]),C.useEffect(()=>{m.some(v=>v.value===s)||a(m[0].value)},[m]);const _=v=>{const T=v,R=rt(T,r),I=R&&R[0].value;a(T),c(I),I&&g(t.createDefaultValue(T,I)),n(y({subType:T,operator:I}))},x=v=>{const T=v;c(T),n(y({operator:T}))},w=v=>{g(v),n(y({value:v}))},E=C.useMemo(()=>`${s}_${p}_${Math.random()}`,[s,p]);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:s,options:m}),(d==null?void 0:d.length)&&u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:x,value:p||"",options:d})]}),u.jsx(Yt,{value:h,interceptorManager:e,type:s,operator:p,rule:o,onChange:w},E),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:y({})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-ml-1",onChange:v=>{S(v),n(y({style:v}))}})]})},xt=(i,e)=>(t.iconMap[i]||[])[Number(e)]||"",Kt=i=>{var c;const{error:e,type:n,onChange:r}=i,o=P.useDependency(l.IUniverInstanceService),s=o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=(c=o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:c.getSheetId(),m=C.useRef(null),[d,p]=C.useState(!1);return P.useSidebarClick(h=>{var b;(b=m.current)!=null&&b.isClickOutSide(h)&&p(!1)}),u.jsx("div",{className:"univer-relative",children:n!==t.CFValueType.formula?u.jsxs(u.Fragment,{children:[u.jsx(M.InputNumber,{className:M.clsx({"univer-border-red-500":e}),value:Number(i.value)||0,onChange:h=>r(h!=null?h:0)}),e&&u.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):u.jsx("div",{className:"univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:m,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:String(i.value),unitId:s,subUnitId:a,isFocus:d,onChange:(h="")=>{r(h||"")},onFocus:()=>p(!0)})})})},ot=(i,e,n)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(n.length-1-e)*10},iconType:i,iconId:String(e)}),Xt=C.forwardRef((i,e)=>{const{onClick:n}=i,r=P.useDependency(l.LocaleService),o=s=>{n(s)};return u.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((s,a)=>u.jsxs("div",{className:"univer-mb-3",children:[u.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(s.title)}),u.jsx("div",{className:"univer-flex univer-flex-wrap",children:s.group.map(m=>u.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{o(m.name)},children:u.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:m.list.map((d,p)=>u.jsx("img",{className:"univer-size-5",src:d,draggable:!1},p))})},m.name))})]},a))})}),Jt=i=>{const{onClick:e}=i,n=C.useMemo(()=>{const o=[];for(const s in t.iconMap){const a=t.iconMap[s],m=s;a.forEach((d,p)=>{o.push({iconType:m,base64:d,iconId:String(p)})})}return o},[]),r=o=>{e(o.iconType,o.iconId)};return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[u.jsx(Te,{className:"univer-size-5"}),u.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),u.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:n.map(o=>u.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:u.jsx("img",{className:"univer-size-5",src:o.base64,draggable:!1,onClick:()=>r(o)})},`${o.iconType}_${o.iconId}`))})]})},Qt=i=>{const{onChange:e,configList:n,errorMap:r={}}=i,o=P.useDependency(l.LocaleService),s=[{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],a=[{label:o.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:o.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],m=(h,g)=>{e([String(g),"value","value"],h)},d=(h,g)=>{e([String(g),"operator"],h);const b=t.createDefaultValue(t.CFSubRuleType.number,h);m(b,g)},p=(h,g)=>{e([String(g),"value","type"],h);const b=n[g],S=t.createDefaultValue(t.CFSubRuleType.number,b.operator);m(S,g)};return C.useMemo(()=>n.map((h,g)=>{const b=r[g],S=xt(h.iconType,h.iconId),y=g===n.length-1,_=g===0,x=n[g-1],w=(x==null?void 0:x.value.type)===t.CFValueType.formula?o.t("sheet.cf.valueType.formula"):x==null?void 0:x.value.value,E=(N,v)=>{const T={...h,iconId:v,iconType:N};e([String(g)],T)};return u.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsxs("div",{className:"univer-w-[45%]",children:[o.t("sheet.cf.iconSet.icon"),g+1]}),u.jsx("div",{className:"univer-w-[45%]",children:u.jsxs(u.Fragment,{children:[!_&&!y&&o.t("sheet.cf.iconSet.rule"),!_&&!y&&u.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(x.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]})})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx("div",{className:"univer-flex univer-items-center",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Jt,{onClick:E,iconId:h.iconId,iconType:h.iconType})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",M.borderClassName),children:[S?u.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):u.jsx(Te,{className:"univer-size-4"}),u.jsx(et,{})]})})}),y?u.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.rule"),u.jsxs("span",{className:"univer-font-medium",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(x.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]}):u.jsx(M.Select,{options:s,value:h.operator,onChange:N=>{d(N,g)}})]}),y?u.jsx("div",{}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsx("div",{children:o.t("sheet.cf.iconSet.type")}),u.jsx("div",{children:o.t("sheet.cf.iconSet.value")})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx(M.Select,{options:a,value:h.value.type,onChange:N=>{p(N,g)}}),u.jsx(Kt,{id:g,type:h.value.type,error:b,value:h.value.value||"",onChange:N=>{m(N,g)}})]})]})]},g)}),[n,r])},en=i=>{var N;const{interceptorManager:e}=i,n=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.iconSet?i.rule:void 0,r=P.useDependency(l.LocaleService),[o,s]=C.useState({}),[a,m]=C.useState(()=>{const v=Object.keys(t.iconMap)[0];if(n&&n.config.length){const T=n.config[0].iconType;if(!n.config.some(I=>I.iconType!==T))return T}return v}),[d,p]=C.useState(()=>{if(n&&n.config.length)return l.Tools.deepClone(n==null?void 0:n.config);const v=t.iconMap[a]||[];return new Array(v.length).fill("").map((T,R,I)=>R===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:a,iconId:String(R)}:ot(a,R,I))}),[c,h]=C.useState(()=>n?!!n.isShowValue:!0),g=C.useMemo(()=>{const v=d.map(T=>xt(T.iconType,T.iconId));return u.jsx("div",{className:"univer-flex univer-items-center",children:v.map((T,R)=>T?u.jsx("img",{className:"univer-size-5",src:T},R):u.jsx(Te,{className:"univer-size-5"},R))})},[d]),b=v=>{if(v.reduce((R,I,V)=>R.preType&&!R.result||v.length-1===V?R:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:R.preType?{result:R.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(v[0].value.type)){const R={};return v.forEach((I,V,j)=>{if(V-1<0||V===j.length-1)return;const k=v[V-1],f=t.getOppositeOperator(k.operator);t.compareWithNumber({operator:f,value:k.value.value},I.value.value)||(R[V]=`${r.t(`sheet.cf.form.${f}`,String(k.value.value))} `)}),R}return{}},S=(v,T)=>{l.get(d,v)!==T&&(l.set(d,v,T),p([...d]),s(b(d)))},y=v=>{m(v);const T=t.iconMap[v]||[],R=new Array(T.length).fill("").map((I,V,j)=>ot(v,V,j));p(R),s(b(R))};C.useEffect(()=>{const v=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:c,config:d}}});return()=>{v()}},[c,d,e]),C.useEffect(()=>{const v=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(o).length===0}});return()=>{v()}},[c,d,e,o]);const _=()=>{const v=d.map(T=>({...T}));d.forEach((T,R)=>{const I=d.length-1-R,V=v[I];T.iconId=V.iconId,T.iconType=V.iconType}),p([...d])},x=P.useDependency(P.ILayoutService),[w,E]=C.useState();return P.useScrollYOverContainer(w,x.rootContainerElement),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Xt,{ref:v=>{!w&&v&&E(v)},iconType:a,onClick:y})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",M.borderClassName),children:[g,u.jsx(et,{})]})})}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{onChange:_}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!c,onChange:v=>{h(!v)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),u.jsx(Qt,{errorMap:o,onChange:S,configList:d})]})},tn=i=>{var _;const{onChange:e,interceptorManager:n}=i,r=P.useDependency(l.LocaleService),o=((_=i.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?i.rule:void 0,s=[{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"}],[a,m]=C.useState(()=>{const x=s[0].value,w=o==null?void 0:o.type;if(!o)return x;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(o.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(o.operator)?"lessThanAverage":x;case t.CFSubRuleType.rank:return o.isBottom?"isBottom":"isNotBottom"}}return x}),[d,p]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return 10;switch(w){case t.CFRuleType.highlightCell:if(o.subType===t.CFSubRuleType.rank)return o.value||10}return 10}),[c,h]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return!1;switch(w){case t.CFRuleType.highlightCell:if(o.subType===t.CFSubRuleType.rank)return o.isPercent||!1}return!1}),[g,b]=C.useState({}),S=x=>{const{type:w,isPercent:E,value:N,style:v}=x;if(w==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:N,style:v};if(w==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:N,style:v};if(w==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:v};if(w==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:v}};C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return S({type:a,isPercent:c,value:d,style:g})}}),[a,c,d,g,n]);const y=x=>{e(S(x))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",value:a,options:s,onChange:x=>{m(x),y({type:x,isPercent:c,value:d,style:g})}}),["isNotBottom","isBottom"].includes(a)&&u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.InputNumber,{min:1,max:1e3,value:d,onChange:x=>{const w=x||0;p(w),y({type:a,isPercent:c,value:w,style:g})}}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:c,onChange:x=>{h(!!x),y({type:a,isPercent:!!x,value:d,style:g})}}),r.t("sheet.cf.valueType.percent")]})]}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:S({type:a,isPercent:c,value:d,style:g})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-mt-3",onChange:x=>{b(x),y({type:a,isPercent:c,value:d,style:x})}})]})},nn=l.createInterceptorKey("beforeSubmit"),rn=l.createInterceptorKey("submit"),st=i=>i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),at=i=>{var e;return(e=i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},on=i=>{var R,I,V;const e=P.useDependency(l.LocaleService),n=P.useDependency(l.ICommandService),r=P.useDependency(l.IUniverInstanceService),o=P.useDependency(t.ConditionalFormattingRuleModel),s=P.useDependency(U.SheetsSelectionsService),a=st(r),m=at(r),[d,p]=C.useState(void 0),c=C.useRef((I=(R=i.rule)==null?void 0:R.ranges)!=null?I:[]),h=C.useMemo(()=>{var O,k,f;let j=(O=i.rule)==null?void 0:O.ranges;return j!=null&&j.length||(j=(f=(k=s.getCurrentSelections())==null?void 0:k.map(F=>F.range))!=null?f:[]),c.current=j,j!=null&&j.length?j.map(F=>{const L=We.serializeRange(F);return L==="NaN"?"":L}).filter(F=>!!F).join(","):""},[i.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var k,f;const j=(k=i.rule)==null?void 0:k.rule.type,O=g[0].value;if(!j)return O;switch(j){case t.CFRuleType.highlightCell:{switch((f=i.rule)==null?void 0:f.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return O}),y=C.useRef(void 0),_=C.useMemo(()=>new l.InterceptorManager({beforeSubmit:nn,submit:rn}),[]),x=C.useMemo(()=>{switch(b){case"1":return it;case"2":return tn;case"3":return Zt;case"4":return Gt;case"5":return zt;case"6":return en;default:return it}},[b]);C.useEffect(()=>{const j=n.onCommandExecuted(O=>{if(O.id===U.RemoveSheetMutation.id){const k=O.params;k.subUnitId===m&&k.unitId===a&&i.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&i.onCancel()});return()=>j.dispose()},[]);const w=j=>{y.current=j},E=j=>{const O=j.split(",").filter(k=>!!k).map(We.deserializeRangeWithSheet).map(k=>k.range);c.current=O},N=()=>{if(d)return;const O=(()=>{const f=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return c.current.map(q=>U.setEndForRange(q,f.getRowCount(),f.getColumnCount())).filter(q=>!(Number.isNaN(q.startRow)||Number.isNaN(q.startColumn)))})();if(_.fetchThroughInterceptors(_.getInterceptPoints().beforeSubmit)(!0,null)){const f=_.fetchThroughInterceptors(_.getInterceptPoints().submit)(null,null);if(f){const F=st(r),L=at(r);if(!F||!L)throw new Error("No active sheet found");let q={};i.rule&&i.rule.cfId?(q={...i.rule,ranges:O,rule:f},n.executeCommand(t.SetCfCommand.id,{unitId:F,subUnitId:L,rule:q}),i.onCancel()):(q={cfId:o.createCfId(F,L),ranges:O,rule:f,stopIfTrue:!1},n.executeCommand(t.AddCfCommand.id,{unitId:F,subUnitId:L,rule:q}),i.onCancel())}}},v=()=>{i.onCancel()},T=(j,O)=>{j?O.length<1?p(e.t("sheet.cf.errorMessage.rangeError")):p(void 0):p(e.t("sheet.cf.errorMessage.rangeError"))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),u.jsxs("div",{className:"univer-mt-4",children:[u.jsx(Se.RangeSelector,{unitId:a,subUnitId:m,initialValue:h,onChange:(j,O)=>E(O),onVerify:T}),d&&u.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:d})]}),u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),u.jsx(M.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:j=>S(j)}),u.jsx(x,{interceptorManager:_,rule:(V=i.rule)==null?void 0:V.rule,onChange:w}),u.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[u.jsx(M.Button,{onClick:v,children:e.t("sheet.cf.panel.cancel")}),u.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:N,children:e.t("sheet.cf.panel.submit")})]})]})};var sn=Object.getOwnPropertyDescriptor,an=(i,e,n,r)=>{for(var o=r>1?void 0:r?sn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ln=(i,e)=>(n,r)=>e(n,r,i);let ue=class extends l.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const n=/\{([^}]+)?\}/g,r=[];let o=n.exec(e);for(;o;)r.push({startIndex:o.index,key:Number(o[1]),endIndex:o.index+o[0].length-1}),o=n.exec(e);return r});this._localeService=e,this._initLocal()}tWithReactNode(e,...n){const r=this._localeService.getLocales(),o=e.split("."),s=r&&this._localeService.resolveKeyPath(r,o);if(typeof s=="string"){const a=[];return this._findReplaceIndex(s).forEach((m,d,p)=>{const c=p[d-1]||{endIndex:-1};if(c.endIndex+1<m.startIndex){const h=s.slice(c.endIndex+1,m.startIndex);h&&a.push(h)}if(n[m.key]&&a.push(n[m.key]),d===p.length-1){const h=s.slice(m.endIndex+1);h&&a.push(h)}}),a}return[]}};ue=an([ln(0,l.Inject(l.LocaleService))],ue);const un=(i,e)=>{const n=i.rule;switch(n.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(n.subType){case t.CFSubRuleType.average:{const r=n.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=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(n.value)?n.value.map(o=>String(o)):[String(n.value||"")])}case t.CFSubRuleType.text:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,n.value||"")}case t.CFSubRuleType.timePeriod:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`)}case t.CFSubRuleType.rank:return n.isPercent?n.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(n.value)):e.t("sheet.cf.preview.describe.topNPercent",String(n.value)):n.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(n.value)):e.t("sheet.cf.preview.describe.topN",String(n.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let lt=0;const cn=i=>{const{onClick:e}=i,n=P.useDependency(t.ConditionalFormattingRuleModel),r=P.useDependency(l.IUniverInstanceService),o=P.useDependency(U.SheetsSelectionsService),s=P.useDependency(l.ICommandService),a=P.useDependency(l.LocaleService),m=P.useDependency(l.Injector),d=P.useDependency(P.ISidebarService),p=P.useDependency(ue),c=P.useObservable(()=>r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),h=c.getUnitId(),g=c.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[S,y]=C.useState([]),[_,x]=C.useState("2"),[w,E]=C.useState(0),[N,v]=C.useState(-1),[T,R]=C.useState(lt),I=C.useRef(null),V=[{label:a.t("sheet.cf.panel.workSheet"),value:"2"},{label:a.t("sheet.cf.panel.selectedRange"),value:"1"}],j=()=>{const D=n.getSubunitRules(h,b);if(!D||!D.length)return[];if(_==="1"){const A=o.getCurrentLastSelection();if(!A)return[];const B=A.range;return D.filter(G=>G.ranges.some(Z=>l.Rectangle.intersects(Z,B)))}else if(_==="2")return[...D];return[]},[O,k]=C.useState(j);H.useHighlightRange(S),C.useEffect(()=>{const D=s.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{k(j)},[_,w,h,b]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(A=>{const B=[U.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],W=s.onCommandExecuted(G=>{const{id:Z,params:ee}=G,te=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(Z)&&ee.unitId===te&&A.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{k(j)});return()=>{D.unsubscribe()}},[r,_,h,b]),C.useEffect(()=>{const D=n.$ruleChange.subscribe(()=>{E(Math.random())});return()=>D.unsubscribe()},[n]),C.useEffect(()=>{const D=()=>{var G,Z;const W=Math.max(0,((Z=(G=I.current)==null?void 0:G.getBoundingClientRect().width)!=null?Z:0)-8);return lt=W,W},B=new K.Observable(W=>{const G=d.getContainer();if(G){let Z=setTimeout(()=>{W.next(void 0)},150);const ee=()=>{Z&&clearTimeout(Z),Z=null},te=Fe=>{Fe.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{R(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const A=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");s.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:D.cfId})},F=(D,A)=>{v(A.y)},L=(D,A,B)=>{var Fe;v(-1);const W=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(Fe=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Fe.getSheetId();if(!W||!G)throw new Error("No active sheet found");const Z=wt=>{const Nt=O.length;return Math.min(Nt-1,Math.max(0,wt))},ee=O[Z(A.y)].cfId,te=O[Z(B.y)].cfId;ee!==te&&s.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>A.y?"after":"before"}})},q=()=>{i.onCreate()},X=()=>{_==="2"?s.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:h,subUnitId:b,cfId:A.cfId})).forEach(A=>{s.executeCommand(t.DeleteCfCommand.id,A)})},J=C.useMemo(()=>{const D=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(m,D.getUnitId(),A.getSheetId(),W)})},[O]),ie=J.map((D,A)=>({i:D.cfId,x:0,w:12,y:A,h:1,isResizable:!1})),oe=C.useMemo(()=>{const D=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(m,D.getUnitId(),A.getSheetId(),W)})},[O]);return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[u.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:p.tWithReactNode("sheet.cf.panel.managerRuleSelect",u.jsx(M.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{x(D)}})).map((D,A)=>u.jsx("span",{children:D},A))}),u.jsxs("div",{className:"univer-flex univer-justify-end",children:[u.jsx(M.Tooltip,{title:a.t("sheet.cf.panel.createRule"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:u.jsx(ft,{})})}),O.length&&oe?u.jsx(M.Tooltip,{title:a.t("sheet.cf.panel.clear"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:u.jsx(je,{className:"univer-text-red-500"})})}):u.jsx("div",{children:u.jsx(je,{className:"univer-text-gray-300"})})]})]}),u.jsx("div",{ref:I,children:T>0&&u.jsx(M.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:T,margin:[0,10],onDragStop:L,onDragStart:F,children:J==null?void 0:J.map((D,A)=>u.jsx("div",{children:u.jsxs("div",{className:M.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":N===A}),onMouseMove:()=>{D.ranges!==S&&y(D.ranges)},onMouseLeave:()=>y([]),onClick:()=>{e(D)},children:[u.jsx("div",{className:M.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:B=>B.stopPropagation(),children:u.jsx(yt,{})}),u.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[u.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:un(D,a)}),u.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(B=>We.serializeRange(B)).join(",")})]}),u.jsx("div",{children:u.jsx(ce,{rule:D.rule})}),u.jsx("div",{className:M.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":N===A}),onClick:B=>{B.stopPropagation(),f(D),y([])},children:u.jsx(je,{})})]})},`${D.cfId}`))})})]})},dn=i=>{const[e,n]=C.useState(i.rule),[r,o]=C.useState(!!i.rule),s=()=>{o(!0)},a=()=>{o(!1),n(void 0)},m=d=>{n(d),o(!0)};return u.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:r?u.jsx(on,{onCancel:a,rule:e}):u.jsx(cn,{onClick:m,onCreate:s})})};var mn=Object.getOwnPropertyDescriptor,hn=(i,e,n,r)=>{for(var o=r>1?void 0:r?mn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},de=(i,e)=>(n,r)=>e(n,r,i);const Ee="sheet.conditional.formatting.panel";let fe=class extends l.Disposable{constructor(e,n,r,o,s){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=o,this._localeService=s,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(a=>{var m;a||(m=this._sidebarDisposable)==null||m.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ee&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Ee,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ee,rule:e,key:l.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ee,dn))}};fe=hn([de(0,l.IUniverInstanceService),de(1,l.Inject(l.Injector)),de(2,l.Inject(P.ComponentManager)),de(3,l.Inject(P.ISidebarService)),de(4,l.Inject(l.LocaleService))],fe);var z=(i=>(i[i.createRule=1]="createRule",i[i.viewRule=2]="viewRule",i[i.highlightCell=3]="highlightCell",i[i.rank=4]="rank",i[i.formula=5]="formula",i[i.colorScale=6]="colorScale",i[i.dataBar=7]="dataBar",i[i.icon=8]="icon",i[i.clearRangeRules=9]="clearRangeRules",i[i.clearWorkSheetRules=10]="clearWorkSheetRules",i))(z||{});const Re={id:"sheet.operation.open.conditional.formatting.panel",type:l.CommandType.OPERATION,handler:(i,e)=>{var m;const n=i.get(fe),r=i.get(U.SheetsSelectionsService),o=i.get(l.ICommandService),s=((m=r.getCurrentSelections())==null?void 0:m.map(d=>d.range))||[];switch(e.value){case 3:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 4:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};n.openPanel(d);break}case 5:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};n.openPanel(d);break}case 6:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.colorScale,config:[]}};n.openPanel(d);break}case 7:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(d);break}case 8:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(d);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 9:{o.executeCommand(t.ClearRangeCfCommand.id,{ranges:s});break}case 10:{o.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var vn=Object.getOwnPropertyDescriptor,pn=(i,e,n,r)=>{for(var o=r>1?void 0:r?vn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},me=(i,e)=>(n,r)=>e(n,r,i);exports.ConditionalFormattingClearController=class extends l.Disposable{constructor(e,n,r,o,s){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=o,this._conditionalFormattingRuleModel=s,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var s;const n=[],r=[],o={redos:n,undos:r};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const a=(s=this._selectionManagerService.getCurrentSelections())==null?void 0:s.map(S=>S.range);if(!a)return o;const m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),d=m.getActiveSheet();if(!d)return o;const p=m.getUnitId(),c=d.getSheetId(),h=this._conditionalFormattingRuleModel.getSubunitRules(p,c);if(!h||!h.length)return o;const{redos:g,undos:b}=ut(this._injector,h,a,p,c);n.push(...g),r.push(...b)}return o}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:r})=>{const o=[],s=[],a={redos:o,undos:s};if(!r||!r.length)return a;const m=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!m||!m.length)return a;const{redos:d,undos:p}=ut(this._injector,m,r,e,n);return o.push(...d),s.push(...p),a}}))}};exports.ConditionalFormattingClearController=pn([me(0,l.Inject(l.Injector)),me(1,l.Inject(l.IUniverInstanceService)),me(2,l.Inject(U.SheetInterceptorService)),me(3,l.Inject(U.SheetsSelectionsService)),me(4,l.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ut(i,e,n,r,o){const s=[],a=[];return e.filter(m=>n.some(d=>m.ranges.some(p=>l.Rectangle.getIntersects(p,d)))).forEach(m=>{const p=new U.RangeMergeUtil().add(...m.ranges).subtract(...n).merge();if(p.length){const c={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,rule:{...m,ranges:p}}},h=t.setConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...h)}else{const c={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,cfId:m.cfId}},h=t.DeleteConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...h)}}),{redos:s,undos:a}}var gn=Object.getOwnPropertyDescriptor,fn=(i,e,n,r)=>{for(var o=r>1?void 0:r?gn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Le=(i,e)=>(n,r)=>e(n,r,i);let Ce=class extends l.Disposable{constructor(e,n,r){super();Q(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=n,this._injector=r,this._initRefRange()}_getIdWithUnitId(e,n,r){return`${e}_${n}_${r}`}_getRuleFormulas(e){const n=[],r=e.rule;switch(r.type){case t.CFRuleType.highlightCell:r.subType===t.CFSubRuleType.formula&&n.push(r.value);break;case t.CFRuleType.dataBar:{const o=r;o.config.min.type===t.CFValueType.formula&&n.push(o.config.min.value),o.config.max.type===t.CFValueType.formula&&n.push(o.config.max.value);break}case t.CFRuleType.colorScale:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}case t.CFRuleType.iconSet:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}}return n}_updateRuleFormulas(e,n){const r=l.Tools.deepClone(e),o=r.rule;let s=0;switch(o.type){case t.CFRuleType.highlightCell:o.subType===t.CFSubRuleType.formula&&(o.value=n[s++]);break;case t.CFRuleType.dataBar:{const a=o;a.config.min.type===t.CFValueType.formula&&(a.config.min.value=n[s++]),a.config.max.type===t.CFValueType.formula&&(a.config.max.value=n[s++]);break}case t.CFRuleType.colorScale:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}case t.CFRuleType.iconSet:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}}return r}register(e,n,r){const o=r.ranges,s=this._getRuleFormulas(r),a=this._formulaRefRangeService.registerRangeFormula(e,n,o,s,d=>{if(d.length===0)return{undos:[{id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:r}}],redos:[{id:t.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId}}]};const p=[],c=[],h=d[0],g=this._updateRuleFormulas(r,h.formulas);g.ranges=h.ranges,p.push({id:t.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId,rule:g}}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,cfId:r.cfId,rule:g}));for(let b=1;b<d.length;b++){const S=d[b],y=t.createCfId(),_=this._updateRuleFormulas(r,S.formulas);_.cfId=y,_.ranges=S.ranges,p.push({id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:_}}),c.push(t.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,rule:_}))}return{undos:c,redos:p}}),m=this._getIdWithUnitId(e,n,r.cfId);this._disposableMap.set(m,a)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[n,r]of e)for(const[o,s]of r)for(const a of s)this.register(n,o,a);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:r,subUnitId:o,rule:s}=n;switch(n.type){case"add":{this.register(r,o,s);break}case"delete":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a));break}case"set":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a)),this.register(r,o,s);break}}})),this.disposeWithMe(l.toDisposable(()=>{this._disposableMap.forEach(n=>{n.dispose()}),this._disposableMap.clear()}))}};Ce=fn([Le(0,l.Inject(t.ConditionalFormattingRuleModel)),Le(1,l.Inject(ht.FormulaRefRangeService)),Le(2,l.Inject(l.Injector))],Ce);var Cn=Object.getOwnPropertyDescriptor,yn=(i,e,n,r)=>{for(var o=r>1?void 0:r?Cn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},he=(i,e)=>(n,r)=>e(n,r,i);let ye=class extends l.Disposable{constructor(e,n,r,o,s){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=o,this._univerInstanceService=s,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,r)=>this._collectConditionalRule(e,n,r),onPasteCells:(e,n,r,o)=>{const{copyType:s=H.COPY_TYPE.COPY,pasteType:a}=o,{range:m}=e||{},{range:d}=n;return this._generateConditionalFormattingMutations(d,{copyType:s,pasteType:a,copyRange:m})}}))}_collectConditionalRule(e,n,r){const o=new l.ObjectMatrix,s={};this._copyInfo={matrix:o,info:{unitId:e,subUnitId:n,cfMap:s}};const a=this._injector.invoke(c=>U.rangeToDiscreteRange(r,c,e,n));if(!a)return;const{rows:m,cols:d}=a,p=new Set;m.forEach((c,h)=>{d.forEach((g,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,c,g);S&&(S.forEach(y=>p.add(y.cfId)),o.setValue(h,b,S.map(y=>y.cfId)))})}),p.forEach(c=>{const h=this._conditionalFormattingRuleModel.getRule(e,n,c);h&&(s[c]=h.rule)})}_generateConditionalFormattingMutations(e,n){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet(),s=r.getUnitId();if(!o)return{redos:[],undos:[]};const a=o.getSheetId();if(n.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[d,p],mapFunc:c}=H.virtualizeDiscreteRanges([n.copyRange,e]),h=H.getRepeatRange(d,p,!0),g={};l.Range.foreach(p,(v,T)=>{const{row:R,col:I}=c(v,T),V=this._conditionalFormattingViewModel.getCellCfs(s,a,R,I);V&&V.forEach(j=>{if(!g[j.cfId]){const O=new l.ObjectMatrix;g[j.cfId]=O;const k=this._conditionalFormattingRuleModel.getRule(s,a,j.cfId);k==null||k.ranges.forEach(f=>{l.Range.foreach(f,(F,L)=>{O.setValue(F,L,1)})})}g[j.cfId].realDeleteValue(R,I)})});const{matrix:b,info:S}=this._copyInfo,y=[];let _=this._conditionalFormattingRuleModel.createCfId(s,a);const x={},w=v=>{if(x[v])return x[v];const T=S==null?void 0:S.cfMap[v],R=[...this._conditionalFormattingRuleModel.getSubunitRules(s,a)||[],...y].find(I=>l.Tools.diffValue(I.rule,T));if(R)return x[v]=R,R;{const I={rule:T,cfId:_,ranges:[],stopIfTrue:!1};return x[v]=I,y.push(I),_=`${Number(_)+1}`,I}};h.forEach(v=>{b&&b.forValue((T,R,I)=>{const V=l.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:R,endColumn:R},v.startRange),{row:j,col:O}=c(V.startRow,V.startColumn);I.forEach(k=>{if(!g[k]){const f=w(k),F=new l.ObjectMatrix;g[k]=F,f.ranges.forEach(L=>{l.Range.foreach(L,(q,X)=>{F.setValue(q,X,1)})})}g[k].setValue(j,O,1)})})});const E=[],N=[];for(const v in g){const T=g[v],R=U.findAllRectangle(U.createTopMatrixFromMatrix(T));if(!R.length){const I={unitId:s,subUnitId:a,cfId:v};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),N.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(y.some(I=>I.cfId===v)){const I=w(v),V={unitId:s,subUnitId:a,rule:{...I,ranges:R}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),N.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(s,a,v);if(!I)continue;const V={unitId:s,subUnitId:a,rule:{...I,ranges:R}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),N.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:N}}};ye=yn([he(0,l.Inject(H.ISheetClipboardService)),he(1,l.Inject(t.ConditionalFormattingRuleModel)),he(2,l.Inject(l.Injector)),he(3,l.Inject(t.ConditionalFormattingViewModel)),he(4,l.Inject(l.IUniverInstanceService))],ye);var bn=Object.getOwnPropertyDescriptor,In=(i,e,n,r)=>{for(var o=r>1?void 0:r?bn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Ae=(i,e)=>(n,r)=>e(n,r,i);let be=class extends l.Disposable{constructor(i,e,n){super(),this._localeService=i,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{if(i.id===t.AddCfCommand.id){const{unitId:e,subUnitId:n,rule:{ranges:r}}=i.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},r,e,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};be=In([Ae(0,l.Inject(l.LocaleService)),Ae(1,l.ICommandService),Ae(2,l.Inject(U.SheetPermissionCheckController))],be);var Sn=Object.getOwnPropertyDescriptor,Tn=(i,e,n,r)=>{for(var o=r>1?void 0:r?Sn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ae=(i,e)=>(n,r)=>e(n,r,i);let Ie=class extends l.Disposable{constructor(e,n,r,o,s,a){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=o,this._conditionalFormattingViewModel=s,this._conditionalFormattingRuleModel=a,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,o;const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(H.SheetSkeletonManagerService).reCalculate(),(o=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||o.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(ge.bufferTime(16),ge.filter(e=>!!e.length),ge.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?e.filter(o=>o.unitId===n.getUnitId()&&o.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,handler:(e,n,r)=>{const o=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!o)return r(e);const s=n.workbook.getStyles(),a=(typeof(e==null?void 0:e.s)=="string"?s.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},m=e===n.rawData?{...n.rawData}:e;if(o.style){const d={...a,...o.style};Object.assign(m,{s:d})}return m.fontRenderExtension||(m.fontRenderExtension={},o.isShowValue!==void 0&&(m.fontRenderExtension.isSkip=!o.isShowValue)),o.dataBar&&(m.dataBar=o.dataBar),o.iconSet&&(m.iconSet=o.iconSet,m.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(m)},priority:10}))}};Ie=Tn([ae(0,l.Inject(U.SheetInterceptorService)),ae(1,l.Inject(t.ConditionalFormattingService)),ae(2,l.Inject(l.IUniverInstanceService)),ae(3,l.Inject(vt.IRenderManagerService)),ae(4,l.Inject(t.ConditionalFormattingViewModel)),ae(5,l.Inject(t.ConditionalFormattingRuleModel))],Ie);const Rt="sheets-conditional-formatting-ui.config",Me={};var xn=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,Fn=(i,e,n)=>e in i?xn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,_n=(i,e,n,r)=>{for(var o=r>1?void 0:r?Rn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},$e=(i,e)=>(n,r)=>e(n,r,i),Ft=(i,e,n)=>Fn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends l.Plugin{constructor(e=Me,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},Me,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Rt,a),this._initCommand(),this._injector.add([Ie]),this._injector.add([ye]),this._injector.add([be]),this._injector.add([ue]),this._injector.add([Ce])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};Ft(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);Ft(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=_n([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin),$e(1,l.Inject(l.Injector)),$e(2,l.Inject(l.ICommandService)),$e(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var wn=Object.getOwnPropertyDescriptor,Nn=(i,e,n,r)=>{for(var o=r>1?void 0:r?wn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ve=(i,e)=>(n,r)=>e(n,r,i);let Ve=class extends l.Disposable{constructor(i,e,n,r,o){super(),this._injector=i,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=o,this._initAutoFill()}_initAutoFill(){const i=()=>({redos:[],undos:[]}),e=(o,s,a,m,d)=>{var b;const p=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(b=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!p||!c)return;const h={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},g={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};l.Range.foreach(a,(S,y)=>{const _=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},h),x=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},g),{row:w,col:E}=d(_.startRow,_.startColumn),N=this._conditionalFormattingViewModel.getCellCfs(p,c,w,E),{row:v,col:T}=d(x.startRow,x.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(p,c,v,T);R&&R.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(p,c,I.cfId);if(!j)return;V=new l.ObjectMatrix,j.ranges.forEach(O=>{l.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),m.set(I.cfId,V)}V.realDeleteValue(v,T)}),N&&N.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(p,c,I.cfId);if(!j)return;V=new l.ObjectMatrix,j.ranges.forEach(O=>{l.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),m.set(I.cfId,V)}V.setValue(v,T,1)})})},n=(o,s)=>{var x,w,E;const a=(x=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:x.getUnitId(),m=(E=(w=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getActiveSheet())==null?void 0:E.getSheetId(),d=new Map,p=[],c=[];if(!a||!m)return i();const h=H.virtualizeDiscreteRanges([o,s]),[g,b]=h.ranges,{mapFunc:S}=h,y={row:g.startRow,col:g.startColumn};return H.getAutoFillRepeatRange(g,b).forEach(N=>{e(y,N.repeatStartCell,N.relativeRange,d,S)}),d.forEach((N,v)=>{const T=this._conditionalFormattingRuleModel.getRule(a,m,v);if(!T)return;const R=U.findAllRectangle(U.createTopMatrixFromMatrix(N));if(R.length){const I={unitId:a,subUnitId:m,rule:{...T,ranges:R}};p.push({id:t.SetConditionalRuleMutation.id,params:I}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:a,subUnitId:m,cfId:T.cfId};p.push({id:t.DeleteConditionalRuleMutation.id,params:I}),c.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:c,redos:p}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(o,s,a)=>{if(a===H.APPLY_TYPE.COPY||a===H.APPLY_TYPE.ONLY_FORMAT||a===H.APPLY_TYPE.SERIES){const{source:m,target:d}=o;return n(m,d)}return i()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ve=Nn([ve(0,l.Inject(l.Injector)),ve(1,l.Inject(l.IUniverInstanceService)),ve(2,l.Inject(H.IAutoFillService)),ve(3,l.Inject(t.ConditionalFormattingRuleModel)),ve(4,l.Inject(t.ConditionalFormattingViewModel))],Ve);var En=Object.getOwnPropertyDescriptor,jn=(i,e,n,r)=>{for(var o=r>1?void 0:r?En(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ct=(i,e)=>(n,r)=>e(n,r,i);let Oe=class extends l.Disposable{constructor(i,e){super(),this._sheetInterceptorService=i,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(l.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(i,e,n)=>{var a,m,d;i||n(i);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),o=(a=r==null?void 0:r.style)!=null?a:{},s=Object.keys(o);if(i!=null&&i.p)return(d=(m=i.p.body)==null?void 0:m.textRuns)==null||d.forEach(p=>{p.ts&&s.forEach(c=>{var h;(h=p.ts)==null||delete h[c]})}),n(i);{const p={...(typeof(i==null?void 0:i.s)=="string"?e.workbook.getStyles().get(i.s):i==null?void 0:i.s)||{}};s.forEach(h=>{delete p[h]});const c={...i,s:{...p}};return n(c)}}})))}};Oe=jn([ct(0,l.Inject(U.SheetInterceptorService)),ct(1,l.Inject(t.ConditionalFormattingService))],Oe);const dt=[U.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],pe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:z.clearWorkSheetRules}],Mn=i=>{const e=i.get(U.SheetsSelectionsService),n=i.get(l.ICommandService),r=i.get(l.IUniverInstanceService),o=i.get(t.ConditionalFormattingRuleModel),s=new K.Observable(d=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(p=>{const c=n.onCommandExecuted(h=>{var y;const{id:g,params:b}=h,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&p.next(null)});return()=>c.dispose()})).pipe(ge.debounceTime(16)).subscribe(()=>{var y;const p=((y=e.getCurrentSelections())==null?void 0:y.map(_=>_.range))||[],c=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!c)return;const h=c.getActiveSheet();if(!h)return;const S=(o.getSubunitRules(c.getUnitId(),h.getSheetId())||[]).filter(_=>_.ranges.some(x=>p.some(w=>l.Rectangle.intersects(w,x)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(i,c.getUnitId(),h.getSheetId(),_));d.next(S)})),a=new K.Observable(d=>new K.Observable(p=>{const c=n.onCommandExecuted(h=>{var y;const{id:g,params:b}=h,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&p.next(null)});return()=>c.dispose()}).pipe(ge.debounceTime(16)).subscribe(()=>{const p=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!p)return;const c=p.getActiveSheet();if(!c)return;const h=o.getSubunitRules(p.getUnitId(),c.getSheetId())||[];if(!h.length)return d.next(!1),!1;const g=h.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(i,p.getUnitId(),c.getSheetId(),b));d.next(g)})),m=new K.Observable(d=>{s.subscribe(p=>{const c=pe.find(h=>h.value===z.clearRangeRules);c&&(c.disabled=!p,d.next(pe))}),a.subscribe(p=>{const c=pe.find(h=>h.value===z.clearWorkSheetRules);c&&(c.disabled=!p,d.next(pe))}),d.next(pe)});return{id:Re.id,type:P.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:m,hidden$:P.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(i,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Vn={[P.RibbonDataGroup.RULES]:{[Re.id]:{order:1,menuItemFactory:Mn}}};var On=Object.getOwnPropertyDescriptor,Un=(i,e,n,r)=>{for(var o=r>1?void 0:r?On(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},mt=(i,e)=>(n,r)=>e(n,r,i);let Ue=class extends l.Disposable{constructor(e,n){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(Vn)}};Ue=Un([mt(0,l.Inject(l.Injector)),mt(1,P.IMenuManagerService)],Ue);var kn=Object.getOwnPropertyDescriptor,Pn=(i,e,n,r)=>{for(var o=r>1?void 0:r?kn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},le=(i,e)=>(n,r)=>e(n,r,i);const Dn=(i,e)=>{const n=c=>c.endRow-c.startRow+1,r=c=>c.endColumn-c.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a=Math.floor(n(e)/n(i)),m=Math.floor(r(e)/r(i)),d=[],p={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1};if(n(e)===1&&r(e)===1){const c={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:p,startRange:c}),d}for(let c=0;c<a+(o?.1:0);c++)for(let h=0;h<m+(s?.1:0);h++){const g=n(i)*c,b=r(i)*h,S={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let y=p;c===a&&o&&(y={...y},y.endRow=y.endRow-(n(i)-o)),h===m&&s&&(y={...y},y.endColumn=y.endColumn-(r(i)-s)),d.push({repeatRelativeRange:y,startRange:S})}return d};let ke=class extends l.Disposable{constructor(e,n,r,o,s,a){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=o,this._conditionalFormattingRuleModel=s,this._conditionalFormattingViewModel=a,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(s,a,m,d,p)=>{const{unitId:c,subUnitId:h}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=p,S={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},y={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row};l.Range.foreach(m,(_,x)=>{const w=l.Rectangle.getPositionRange({startRow:_,startColumn:x,endColumn:x,endRow:_},S),E=l.Rectangle.getPositionRange({startRow:_,startColumn:x,endColumn:x,endRow:_},y),N=this._conditionalFormattingViewModel.getCellCfs(c,h,w.startRow,w.startColumn),v=this._conditionalFormattingViewModel.getCellCfs(g,b,E.startRow,E.startColumn);v&&v.forEach(T=>{let R=d.get(T.cfId);if(!d.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(g,b,T.cfId);if(!I)return;R=new l.ObjectMatrix,I.ranges.forEach(V=>{l.Range.foreach(V,(j,O)=>{R.setValue(j,O,1)})}),d.set(T.cfId,R)}R.realDeleteValue(E.startRow,E.startColumn)}),N&&N.forEach(T=>{const R=d.get(T.cfId);R&&R.setValue(E.startRow,E.startColumn,1)})})},r=(s,a,m)=>{var w;const{range:d,unitId:p,subUnitId:c}=this._painterConfig,h=s!==p||c!==a,g=new Map,b=[],S=[];if(!s||!a||!p||!c)return e();const y=(w=this._conditionalFormattingRuleModel.getSubunitRules(p,c))!=null?w:[];y==null||y.forEach(E=>{const{ranges:N,cfId:v}=E;if(N.some(T=>l.Rectangle.intersects(d,T))){const T=new l.ObjectMatrix;h||N.forEach(R=>{l.Range.foreach(R,(I,V)=>{T.setValue(I,V,1)})}),g.set(v,T)}});const _={row:d.startRow,col:d.startColumn};return Dn(d,m).forEach(E=>{n(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,g,{targetUnitId:s,targetSubUnitId:a})}),g.forEach((E,N)=>{if(h){const v=this._conditionalFormattingRuleModel.getRule(s,a,N),T=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(v)if(T.length){const R={unitId:s,subUnitId:a,rule:{...v,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:s,subUnitId:a,cfId:v.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}else if(T.length){const R=this._conditionalFormattingRuleModel.getRule(p,c,N);if(R){const I={unitId:s,subUnitId:a,rule:{...l.Tools.deepClone(R),cfId:this._conditionalFormattingRuleModel.createCfId(s,a),ranges:T}};b.push({id:t.AddConditionalRuleMutation.id,params:I}),S.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const v=this._conditionalFormattingRuleModel.getRule(p,c,N);if(!v)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(T.length){const R={unitId:p,subUnitId:c,rule:{...v,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:p,subUnitId:c,cfId:v.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}}}),{undos:S,redos:b}},o={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:s=>{var a,m,d;switch(s){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const p=(a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getUnitId(),c=(d=(m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet())==null?void 0:d.getSheetId(),h=this._sheetsSelectionsService.getCurrentLastSelection(),g=h==null?void 0:h.range;p&&c&&g&&(this._painterConfig={unitId:p,subUnitId:c,range:g});break}case H.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(s,a,m)=>this._painterConfig?r(s,a,m):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};ke=Pn([le(0,l.Inject(l.Injector)),le(1,l.Inject(l.IUniverInstanceService)),le(2,l.Inject(H.IFormatPainterService)),le(3,l.Inject(U.SheetsSelectionsService)),le(4,l.Inject(t.ConditionalFormattingRuleModel)),le(5,l.Inject(t.ConditionalFormattingViewModel))],ke);var Ln=Object.getOwnPropertyDescriptor,An=(i,e,n,r)=>{for(var o=r>1?void 0:r?Ln(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Be=(i,e)=>(n,r)=>e(n,r,i);let Pe=class extends l.Disposable{constructor(i,e,n){super(),this._conditionalFormattingViewModel=i,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),e=n=>{const r=n.getUnitId(),o=this._renderManagerService.getRenderById(r);if(!o)return;const s=o.with(H.SheetSkeletonManagerService);this.disposeWithMe(s.currentSkeleton$.subscribe(a=>{if(a){const m=a.skeleton.rowColumnSegment,d=m.endColumn-m.startColumn+1,c=(m.endRow-m.startRow+1)*d*9,h=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,c);this._conditionalFormattingViewModel.setCacheLength(h)}}))};i&&e(i),this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Pe=An([Be(0,l.Inject(t.ConditionalFormattingViewModel)),Be(1,l.IUniverInstanceService),Be(2,vt.IRenderManagerService)],Pe);var $n=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,Hn=(i,e,n)=>e in i?$n(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,Wn=(i,e,n,r)=>{for(var o=r>1?void 0:r?Bn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},He=(i,e)=>(n,r)=>e(n,r,i),_t=(i,e,n)=>Hn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends l.Plugin{constructor(e=Me,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},Me,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Rt,a),this._initCommand()}onStarting(){l.registerDependencies(this._injector,[[Ie],[ye],[Ve],[be],[fe],[Ue],[ue],[Oe],[exports.ConditionalFormattingClearController],[ke],[Pe],[Ce]]),l.touchDependencies(this._injector,[[Ie],[Ce]])}onReady(){l.touchDependencies(this._injector,[[Ue],[fe]])}onRendered(){l.touchDependencies(this._injector,[[Ve],[exports.ConditionalFormattingClearController],[ye],[Oe],[ue],[ke],[be],[Pe]])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};_t(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);_t(exports.UniverSheetsConditionalFormattingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Wn([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin,ht.UniverSheetsFormulaPlugin),He(1,l.Inject(l.Injector)),He(2,l.Inject(l.ICommandService)),He(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=qe;exports.AddColorScaleConditionalRuleCommand=Ge;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=ze;exports.AddNumberCfCommand=Ye;exports.AddRankCfCommand=Ke;exports.AddTextCfCommand=Xe;exports.AddTimePeriodCfCommand=Je;exports.AddUniqueValuesCfCommand=Qe;exports.OpenConditionalFormattingOperator=Re;
|
|
1
|
+
"use strict";var Et=Object.defineProperty;var jt=(i,e,n)=>e in i?Et(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n;var Q=(i,e,n)=>jt(i,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@univerjs/core"),U=require("@univerjs/sheets"),t=require("@univerjs/sheets-conditional-formatting"),P=require("@univerjs/ui"),u=require("react/jsx-runtime"),C=require("react"),M=require("@univerjs/design"),We=require("@univerjs/engine-formula"),Se=require("@univerjs/sheets-formula-ui"),H=require("@univerjs/sheets-ui"),K=require("rxjs"),ht=require("@univerjs/sheets-formula"),vt=require("@univerjs/engine-render"),ge=require("rxjs/operators"),qe={type:l.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s}=e,a=i.get(t.ConditionalFormattingRuleModel),m=i.get(l.ICommandService),d=i.get(l.IUniverInstanceService),p=U.getSheetCommandTarget(d);if(!p)return!1;const{unitId:c,subUnitId:h}=p,g=a.createCfId(c,h),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:s,style:r}};return m.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:h,rule:b})}},Ge={type:l.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,config:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.ICommandService),m=i.get(l.IUniverInstanceService),d=U.getSheetCommandTarget(m);if(!d)return!1;const{unitId:p,subUnitId:c}=d,h=s.createCfId(p,c),g={ranges:n,cfId:h,stopIfTrue:!!o,rule:{type:t.CFRuleType.colorScale,config:r}};return a.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:c,rule:g})}},Ze={type:l.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,min:r,max:o,nativeColor:s,positiveColor:a,isGradient:m,stopIfTrue:d,isShowValue:p}=e,c=i.get(t.ConditionalFormattingRuleModel),h=i.get(l.IUniverInstanceService),g=U.getSheetCommandTarget(h);if(!g)return!1;const{unitId:b,subUnitId:S}=g,y=i.get(l.ICommandService),_=c.createCfId(b,S),x={ranges:n,cfId:_,stopIfTrue:!!d,rule:{type:t.CFRuleType.dataBar,isShowValue:p,config:{min:r,max:o,nativeColor:s,positiveColor:a,isGradient:m}}};return y.executeCommand(t.AddConditionalRuleMutation.id,{unitId:b,subUnitId:S,rule:x})}},ze={type:l.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.ICommandService),m=i.get(l.IUniverInstanceService),d=U.getSheetCommandTarget(m);if(!d)return!1;const{unitId:p,subUnitId:c}=d,h=s.createCfId(p,c),g={ranges:n,cfId:h,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.duplicateValues,style:r}};return a.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:c,rule:g})}},Ye={type:l.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s,value:a}=e,m=i.get(t.ConditionalFormattingRuleModel),d=i.get(l.ICommandService),p=i.get(l.IUniverInstanceService),c=U.getSheetCommandTarget(p);if(!c)return!1;const{unitId:h,subUnitId:g}=c,b=m.createCfId(h,g);let S;if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(s)){const y=a;if(y.length!==2||!Array.isArray(y))return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:r,value:y}}}else{const y=a;if(typeof y!="number")return!1;S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.number,operator:s,style:r,value:y}}}return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:S})}},Ke={type:l.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,isPercent:s,isBottom:a,value:m}=e,d=i.get(t.ConditionalFormattingRuleModel),p=i.get(l.IUniverInstanceService),c=i.get(l.ICommandService),h=U.getSheetCommandTarget(p);if(!h)return!1;const{unitId:g,subUnitId:b}=h,S=d.createCfId(g,b),y={ranges:n,cfId:S,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:s,isBottom:a,style:r,value:m}};return c.executeCommand(t.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:y})}},Xe={type:l.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s,value:a}=e,m=i.get(t.ConditionalFormattingRuleModel),d=i.get(l.IUniverInstanceService),p=U.getSheetCommandTarget(d);if(!p)return!1;const{unitId:c,subUnitId:h}=p,g=i.get(l.ICommandService),b=m.createCfId(c,h),S={ranges:n,cfId:b,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.text,operator:s,style:r,value:a}};return g.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:h,rule:S})}},Je={type:l.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o,operator:s}=e,a=i.get(t.ConditionalFormattingRuleModel),m=i.get(l.IUniverInstanceService),d=i.get(l.ICommandService),p=U.getSheetCommandTarget(m);if(!p)return!1;const{unitId:c,subUnitId:h}=p,g=a.createCfId(c,h),b={ranges:n,cfId:g,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.timePeriod,operator:s,style:r}};return d.executeCommand(t.AddConditionalRuleMutation.id,{unitId:c,subUnitId:h,rule:b})}},Qe={type:l.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(i,e){if(!e)return!1;const{ranges:n,style:r,stopIfTrue:o}=e,s=i.get(t.ConditionalFormattingRuleModel),a=i.get(l.IUniverInstanceService),m=i.get(l.ICommandService),d=U.getSheetCommandTarget(a);if(!d)return!1;const{unitId:p,subUnitId:c}=d,h=s.createCfId(p,c),g={ranges:n,cfId:h,stopIfTrue:!!o,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.uniqueValues,style:r}};return m.executeCommand(t.AddConditionalRuleMutation.id,{unitId:p,subUnitId:c,rule:g})}};function Y({ref:i,...e}){const{icon:n,id:r,className:o,extend:s,...a}=e,m=`univerjs-icon univerjs-icon-${r} ${o||""}`.trim(),d=C.useRef(`_${Ot()}`);return pt(n,`${r}`,{defIds:n.defIds,idSuffix:d.current},{ref:i,className:m,...a},s)}function pt(i,e,n,r,o){return C.createElement(i.tag,{key:e,...Mt(i,n,o),...r},(Vt(i,n).children||[]).map((s,a)=>pt(s,`${e}-${i.tag}-${a}`,n,void 0,o)))}function Mt(i,e,n){const r={...i.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),i.tag==="mask"&&r.id&&(r.id=r.id+e.idSuffix),Object.entries(r).forEach(([s,a])=>{s==="mask"&&typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:o}=e;return!o||o.length===0||(i.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+e.idSuffix),Object.entries(r).forEach(([s,a])=>{typeof a=="string"&&(r[s]=a.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),r}function Vt(i,e){var r;const{defIds:n}=e;return!n||n.length===0?i:i.tag==="defs"&&((r=i.children)!=null&&r.length)?{...i,children:i.children.map(o=>typeof o.attrs.id=="string"&&n&&n.includes(o.attrs.id)?{...o,attrs:{...o.attrs,id:o.attrs.id+e.idSuffix}}:o)}:i}function Ot(){return Math.random().toString(36).substring(2,8)}Y.displayName="UniverIcon";const Ut={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},gt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"bold-icon",ref:n,icon:Ut}))});gt.displayName="BoldIcon";const kt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},je=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"delete-icon",ref:n,icon:kt}))});je.displayName="DeleteIcon";const Pt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},ft=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"increase-icon",ref:n,icon:Pt}))});ft.displayName="IncreaseIcon";const Dt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},Ct=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"italic-icon",ref:n,icon:Dt}))});Ct.displayName="ItalicIcon";const Lt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"more-down-icon",ref:n,icon:Lt}))});et.displayName="MoreDownIcon";const At={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},yt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"sequence-icon",ref:n,icon:At}))});yt.displayName="SequenceIcon";const $t={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},bt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"strikethrough-icon",ref:n,icon:$t}))});bt.displayName="StrikethroughIcon";const Bt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},It=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"underline-icon",ref:n,icon:Bt}))});It.displayName="UnderlineIcon";const Ht={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},St=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"font-color-double-icon",ref:n,icon:Ht}))});St.displayName="FontColorDoubleIcon";const Wt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},Tt=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"paint-bucket-double-icon",ref:n,icon:Wt}))});Tt.displayName="PaintBucketDoubleIcon";const qt={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Te=C.forwardRef(function(e,n){return C.createElement(Y,Object.assign({},e,{id:"slash-double-icon",ref:n,icon:qt}))});Te.displayName="SlashDoubleIcon";const re=i=>{const{color:e,onChange:n,disable:r=!1,Icon:o=Tt,className:s}=i,a=C.useMemo(()=>new l.ColorKit(e),[e]),m=()=>{const d={className:M.clsx("univer-fill-primary-600",r&&s),extend:{colorChannel1:a.isValid?e:""}};return u.jsx(o,{...d})};return r?m():u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(M.ColorPicker,{value:e,onChange:n})}),children:u.jsx("span",{className:M.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",s),children:m()})})},ce=i=>{var s,a,m,d,p;const e=i.rule;if(!e)return null;const n=C.useMemo(()=>{if(e.type===t.CFRuleType.colorScale){const c=e.config.map((b,S)=>({color:new l.ColorKit(b.color),value:S})),h=c.length-1;return new Array(5).fill("").map((b,S,y)=>S*h/(y.length-1)).map(b=>t.getColorScaleFromValue(c,b))}return null},[e]),r=C.useMemo(()=>{if(e.type===t.CFRuleType.iconSet)return e.config.map(c=>{const h=t.iconMap[c.iconType];return h&&h[Number(c.iconId)]})},[e]),o="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case t.CFRuleType.dataBar:{const{isGradient:c}=e.config,h=c?`linear-gradient(to right, ${e.config.positiveColor||t.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=c?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||t.defaultDataBarNativeColor})`:e.config.nativeColor;return u.jsxs("div",{className:o,children:[u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(s=e.config.nativeColor)!=null?s:t.defaultDataBarNativeColor}}),u.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:h,borderColor:(a=e.config.positiveColor)!=null?a:t.defaultDataBarPositiveColor}})]})}case t.CFRuleType.colorScale:return n&&u.jsx("div",{className:o,children:n.map((c,h)=>u.jsx("div",{className:"univer-h-full",style:{width:`${100/n.length}%`,background:c}},h))});case t.CFRuleType.iconSet:return r&&u.jsx("div",{className:o,children:r.map((c,h)=>c?u.jsx("img",{className:"univer-h-full",src:c,draggable:!1},h):u.jsx(Te,{},h))});case t.CFRuleType.highlightCell:{const{ul:c,st:h,it:g,bl:b,bg:S,cl:y}=e.style,_=(c==null?void 0:c.s)===l.BooleanNumber.TRUE,x=(h==null?void 0:h.s)===l.BooleanNumber.TRUE,w=g===l.BooleanNumber.TRUE,E=b===l.BooleanNumber.TRUE,N=(m=S==null?void 0:S.rgb)!=null?m:t.DEFAULT_BG_COLOR,v=(d=y==null?void 0:y.rgb)!=null?d:t.DEFAULT_FONT_COLOR,T={textDecoration:(p=`${_?"underline":""} ${x?"line-through":""}`.replace(/^ /,""))!=null?p:void 0,backgroundColor:N,color:v};return u.jsx("div",{className:M.clsx(o,{"univer-font-bold":E,"univer-italic":w}),style:T,children:"123"})}}},xe=M.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",M.borderClassName),ne=(i,e)=>({label:e.t(`sheet.cf.valueType.${i}`),value:i}),De=i=>{var S;const{type:e,className:n,onChange:r,id:o,value:s}=i,a=P.useDependency(l.IUniverInstanceService),m=a.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(S=a.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:S.getSheetId(),p=C.useMemo(()=>String(s).startsWith("=")?String(s):"=",[s]),c=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),[g,b]=C.useState(!1);return P.useSidebarClick(y=>{var x;(x=h.current)!=null&&x.isClickOutSide(y)&&b(!1)}),e===t.CFValueType.formula?u.jsx("div",{className:"univer-ml-1 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:h,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:p,unitId:m,subUnitId:d,isFocus:g,onChange:(y="")=>{r(y||"")},onFocus:()=>b(!0)})}):u.jsx(M.InputNumber,{className:n,value:Number(i.value)||0,onChange:y=>i.onChange(y||0),...c})},Gt=i=>{var k;const{interceptorManager:e}=i,n=P.useDependency(l.LocaleService),r=((k=i.rule)==null?void 0:k.type)===t.CFRuleType.colorScale?i.rule:void 0,o=[ne(t.CFValueType.num,n),ne(t.CFValueType.percent,n),ne(t.CFValueType.percentile,n),ne(t.CFValueType.formula,n)],s=[ne(t.CFValueType.min,n),...o],a=[ne("none",n),...o],m=[ne(t.CFValueType.max,n),...o],[d,p]=C.useState(()=>{var F;const f=t.CFValueType.min;return r&&((F=r.config[0])==null?void 0:F.value.type)||f}),[c,h]=C.useState(()=>{var F;const f="none";return!r||r.config.length!==3?f:((F=r.config[1])==null?void 0:F.value.type)||f}),[g,b]=C.useState(()=>{var F;const f=t.CFValueType.max;return r&&((F=r.config[r.config.length-1])==null?void 0:F.value.type)||f}),[S,y]=C.useState(()=>{if(!r)return 10;const F=r.config[0];return(F==null?void 0:F.value.value)===void 0?10:F==null?void 0:F.value.value}),[_,x]=C.useState(()=>{var L;if(!r||r.config.length!==3)return 50;const F=(L=r.config[1])==null?void 0:L.value.value;return F===void 0?50:F}),[w,E]=C.useState(()=>{var L;if(!r)return 90;const F=(L=r.config[r.config.length-1])==null?void 0:L.value.value;return F===void 0?90:F}),[N,v]=C.useState(()=>{var F;const f="#d0d9fb";return r&&((F=r.config[0])==null?void 0:F.color)||f}),[T,R]=C.useState(()=>{var F;const f="#7790f3";return!r||r.config.length!==3?f:((F=r.config[1])==null?void 0:F.color)||f}),[I,V]=C.useState(()=>{var F;const f="#2e55ef";return r&&((F=r.config[r.config.length-1])==null?void 0:F.color)||f}),j=C.useMemo(()=>f=>{const{minType:F,medianType:L,maxType:q,minValue:X,medianValue:J,maxValue:ie,minColor:oe,medianColor:D,maxColor:A}=f,B=[];return B.push({color:oe,value:{type:F,value:X}}),L!=="none"&&B.push({color:D,value:{type:L,value:J}}),B.push({color:A,value:{type:q,value:ie}}),{config:B.map((G,Z)=>({...G,index:Z})),type:t.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return j({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),[j,d,c,g,S,_,w,N,T,I,e]);const O=f=>{i.onChange(j(f))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:j({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})})}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:s,value:d,onChange:f=>{p(f);const F=t.createDefaultValueByValueType(f,10);y(F),O({minType:f,medianType:c,maxType:g,minValue:F,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"min",className:"univer-ml-1",value:S,type:d,onChange:f=>{y(f),O({minType:d,medianType:c,maxType:g,minValue:f,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:N,onChange:f=>{v(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:f,medianColor:T,maxColor:I})}})]}),u.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:n.t("sheet.cf.panel.medianValue")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:a,value:c,onChange:f=>{h(f);const F=t.createDefaultValueByValueType(f,50);x(F),O({minType:d,medianType:f,maxType:g,minValue:S,medianValue:F,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"median",className:"univer-ml-1",value:_,type:c,onChange:f=>{x(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:f,maxValue:w,minColor:N,medianColor:T,maxColor:I})}}),c!=="none"&&u.jsx(re,{className:"univer-ml-1",color:T,onChange:f=>{R(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:f,maxColor:I})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[u.jsx(M.Select,{className:"univer-flex-shrink-0",options:m,value:g,onChange:f=>{b(f);const F=t.createDefaultValueByValueType(f,90);E(F),O({minType:d,medianType:c,maxType:f,minValue:S,medianValue:_,maxValue:F,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(De,{id:"max",className:"univer-ml-1",value:w,type:g,onChange:f=>{E(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:f,minColor:N,medianColor:T,maxColor:I})}}),u.jsx(re,{className:"univer-ml-1",color:I,onChange:f=>{V(f),O({minType:d,medianType:c,maxType:g,minValue:S,medianValue:_,maxValue:w,minColor:N,medianColor:T,maxColor:f})}})]})]})},se=(i,e)=>({label:e.t(`sheet.cf.valueType.${i}`),value:i}),nt=i=>{var y;const{onChange:e,className:n,value:r,type:o,id:s,disabled:a=!1}=i,m=P.useDependency(l.IUniverInstanceService),d=m.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),p=(y=m.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:y.getSheetId(),c=C.useRef(null),[h,g]=C.useState(!1);P.useSidebarClick(_=>{var w;(w=c.current)!=null&&w.isClickOutSide(_)&&g(!1)});const b=C.useRef(r),S=C.useMemo(()=>[t.CFValueType.percentile,t.CFValueType.percent].includes(o)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[o]);if(o===t.CFValueType.formula){const _=String(b.current).startsWith("=")?String(b.current)||"":"=";return u.jsx("div",{className:"univer-ml-3 univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:c,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:_,unitId:d,subUnitId:p,isFocus:h,onChange:(x="")=>{e(x||"")},onFocus:()=>g(!0)})})}return u.jsx(M.InputNumber,{className:n,value:Number(r)||0,disabled:a,onChange:_=>{e(_||0)},...S})},Zt=i=>{var k;const{interceptorManager:e}=i,n=P.useDependency(l.LocaleService),r=((k=i.rule)==null?void 0:k.type)===t.CFRuleType.dataBar?i.rule:void 0,[o,s]=C.useState(()=>{var F;return r&&(F=r.config)!=null&&F.isGradient?"1":"0"}),[a,m]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.positiveColor)||t.defaultDataBarPositiveColor}),[d,p]=C.useState(()=>{var f;return r&&((f=r.config)==null?void 0:f.nativeColor)||t.defaultDataBarNativeColor}),c=[se(t.CFValueType.num,n),se(t.CFValueType.percent,n),se(t.CFValueType.percentile,n),se(t.CFValueType.formula,n)],h=[se(t.CFValueType.min,n),...c],g=[se(t.CFValueType.max,n),...c],[b,S]=C.useState(()=>{var F;const f=h[0].value;return r&&((F=r.config)==null?void 0:F.min.type)||f}),[y,_]=C.useState(()=>{var F;const f=g[0].value;return r&&((F=r.config)==null?void 0:F.max.type)||f}),[x,w]=C.useState(()=>{var L;if(!r)return 0;const F=((L=r.config)==null?void 0:L.min)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value||0}),[E,N]=C.useState(()=>{var L;if(!r)return 100;const F=((L=r.config)==null?void 0:L.max)||{};return F.type===t.CFValueType.formula?F.value||"=":F.value===void 0?100:F.value}),[v,T]=C.useState(()=>r?r.isShowValue===void 0?!0:!!r.isShowValue:!0),R=f=>({config:{min:{type:f.minValueType,value:f.minValue},max:{type:f.maxValueType,value:f.maxValue},isGradient:f.isGradient==="1",positiveColor:f.positiveColor||t.defaultDataBarPositiveColor,nativeColor:f.nativeColor||t.defaultDataBarNativeColor},type:t.CFRuleType.dataBar,isShowValue:f.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return R({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}}),[o,x,b,E,y,a,d,e,v]);const I=f=>{i.onChange(R(f))},V=f=>{m(f),I({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:f,nativeColor:d,isShowValue:v})},j=f=>{p(f),I({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:f,isShowValue:v})},O=f=>c.map(F=>F.value).includes(f);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:R({isGradient:o,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})})}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.fillType")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs(M.RadioGroup,{value:o,onChange:f=>{s(f),I({isGradient:f,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})},children:[u.jsx(M.Radio,{value:"0",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.pureColor")})}),u.jsx(M.Radio,{value:"1",children:u.jsx("span",{className:"univer-text-xs",children:n.t("sheet.cf.panel.gradient")})})]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!v,onChange:f=>{T(!f),I({isGradient:f,minValue:x,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:!f})}}),n.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.colorSet")}),u.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[u.jsxs("div",{className:"univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.native")}),u.jsx(re,{color:d,onChange:j})]}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[u.jsx("div",{className:"univer-text-xs",children:n.t("sheet.cf.panel.positive")}),u.jsx(re,{color:a,onChange:V})]})]})]}),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.min")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:h,value:b,onChange:f=>{S(f);const F=t.createDefaultValueByValueType(f,10);w(F),I({isGradient:o,minValue:F,minValueType:f,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}}),u.jsx(nt,{id:"min",className:"univer-ml-3",disabled:!O(b),type:b,value:x,onChange:f=>{w(f||0),I({isGradient:o,minValue:f||0,minValueType:b,maxValue:E,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}})]}),u.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.valueType.max")}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:y,onChange:f=>{_(f);const F=t.createDefaultValueByValueType(f,90);N(F),I({isGradient:o,minValue:x,minValueType:b,maxValue:F,maxValueType:f,positiveColor:a,nativeColor:d,isShowValue:v})}}),u.jsx(nt,{className:"univer-ml-3",disabled:!O(y),id:"max",type:y,value:E,onChange:f=>{N(f||0),I({isGradient:o,minValue:x,minValueType:b,maxValue:f||0,maxValueType:y,positiveColor:a,nativeColor:d,isShowValue:v})}})]})]})]})},_e=i=>[l.BooleanNumber.FALSE,void 0].includes(i)?l.BooleanNumber.TRUE:l.BooleanNumber.FALSE,we=i=>i!==l.BooleanNumber.FALSE,tt=i=>{const{style:e,onChange:n,className:r}=i,[o,s]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[a,m]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[d,p]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[c,h]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[g,b]=C.useState(()=>{var w;const x="#2f56ef";return(w=e==null?void 0:e.cl)!=null&&w.rgb?e.cl.rgb:x}),[S,y]=C.useState(()=>{var w;const x="#e8ecfc";return(w=e==null?void 0:e.bg)!=null&&w.rgb?e.bg.rgb:x});C.useEffect(()=>{const x={bl:o,it:a};g!==void 0&&(x.cl={rgb:g}),S!==void 0&&(x.bg={rgb:S}),c!==void 0&&(x.st={s:c}),d!==void 0&&(x.ul={s:d}),n(t.removeUndefinedAttr(x))},[o,a,d,c,g,S]);const _="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return u.jsxs("div",{className:M.clsx("univer-my-2.5 univer-flex univer-justify-between",r),children:[u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(o||l.BooleanNumber.FALSE)}),onClick:()=>s(_e(o)),children:u.jsx(gt,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(a||l.BooleanNumber.FALSE)}),onClick:()=>m(_e(a)),children:u.jsx(Ct,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(d||l.BooleanNumber.FALSE)}),onClick:()=>p(_e(d)),children:u.jsx(It,{})}),u.jsx("div",{className:M.clsx(_,{"univer-bg-gray-100 dark:!univer-bg-gray-700":we(c||l.BooleanNumber.FALSE)}),onClick:()=>h(_e(c)),children:u.jsx(bt,{})}),u.jsx(re,{color:g,onChange:b,Icon:St}),u.jsx(re,{color:S,onChange:y})]})},zt=i=>{var N;const{onChange:e,interceptorManager:n}=i,r=P.useDependency(l.LocaleService),s=P.useDependency(l.IUniverInstanceService).getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),a=s.getActiveSheet(),m=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?i.rule:void 0,d=C.useRef(null),[p,c]=C.useState(!1),h=C.useRef(null),[g,b]=C.useState({}),[S,y]=C.useState(()=>(m==null?void 0:m.subType)===t.CFSubRuleType.formula?m.value:"="),[_,x]=C.useState(void 0),w=v=>({style:v.style,value:S,type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula});C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return w({style:g})}}),[g,S,n]),C.useEffect(()=>n.intercept(n.getInterceptPoints().beforeSubmit,{handler:(T,R,I)=>_||S.length===1||!S.startsWith("=")?(x(r.t("sheet.cf.errorMessage.formulaError")),!1):I(T)}),[_,S]);const E=v=>{e(w(v))};return P.useSidebarClick(v=>{var R;(R=h.current)!=null&&R.isClickOutSide(v)&&c(!1)}),u.jsxs("div",{ref:d,children:[u.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")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(Se.FormulaEditor,{ref:h,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),errorText:_,isFocus:p,initValue:S,unitId:s.getUnitId(),subUnitId:a==null?void 0:a.getSheetId(),onFocus:()=>{c(!0)},onChange:v=>{y(v),E({style:g})},onVerify:(v,T)=>{!v||T.length===1?x(r.t("sheet.cf.errorMessage.formulaError")):x(void 0)}})}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:w({style:g})})}),u.jsx(tt,{style:m==null?void 0:m.style,className:"univer-mt-3",onChange:v=>{b(v),E({style:v})}})]})},Ne=i=>u.jsxs("div",{className:"univer-relative",children:[u.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:i.errorText}),i.children]}),$=(i,e)=>({label:e.t(`sheet.cf.operator.${i}`),value:i}),Yt=i=>{const{type:e,operator:n,onChange:r,value:o,interceptorManager:s}=i,a=P.useDependency(l.LocaleService),[m,d]=C.useState(()=>typeof o=="number"?o:0),[p,c]=C.useState(""),[h,g]=C.useState(()=>typeof o=="string"?o:""),[b,S]=C.useState(""),[y,_]=C.useState(()=>Array.isArray(o)?o[0]===void 0?0:o[0]:0),[x,w]=C.useState(""),[E,N]=C.useState(()=>Array.isArray(o)?o[1]===void 0?100:o[1]:100),[v,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case t.CFSubRuleType.text:{[t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)&&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(n)&&r(m),[t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)&&r([y,E]);break}}},[e]),C.useEffect(()=>{const R=s.intercept(s.getInterceptPoints().beforeSubmit,{handler:(I,V,j)=>{switch(e){case t.CFSubRuleType.text:if([t.CFTextOperator.beginsWith,t.CFTextOperator.containsText,t.CFTextOperator.endsWith,t.CFTextOperator.notEqual,t.CFTextOperator.notContainsText,t.CFTextOperator.equal].includes(n))return h?j(I):(S(a.t("sheet.cf.errorMessage.notBlank")),!1)}return j(I)}});return()=>{R()}},[e,m,h,n]),e){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(n)){const R=I=>{g(I),r(I)};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:b,children:u.jsx(M.Input,{value:h,onChange:I=>{S(""),R(I)}})})})}break}case t.CFSubRuleType.number:{if([t.CFNumberOperator.equal,t.CFNumberOperator.notEqual,t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual,t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(n)){const R=I=>{d(I||0),r(I||0),c("")};return u.jsx("div",{className:"univer-mt-3",children:u.jsx(Ne,{errorText:p,children:u.jsx(M.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:R})})})}if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(n)){const R=V=>{_(V||0),r([V||0,E]),w("")},I=V=>{N(V||0),r([y,V||0]),T("")};return u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(Ne,{errorText:x,children:u.jsx(M.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:y,onChange:R})}),u.jsx(Ne,{errorText:v,children:u.jsx(M.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:E,onChange:I})})]})}}}return null},rt=(i,e)=>{switch(i){case t.CFSubRuleType.text:return[$(t.CFTextOperator.containsText,e),$(t.CFTextOperator.notContainsText,e),$(t.CFTextOperator.beginsWith,e),$(t.CFTextOperator.endsWith,e),$(t.CFTextOperator.equal,e),$(t.CFTextOperator.notEqual,e),$(t.CFTextOperator.containsBlanks,e),$(t.CFTextOperator.notContainsBlanks,e),$(t.CFTextOperator.containsErrors,e),$(t.CFTextOperator.notContainsErrors,e)];case t.CFSubRuleType.number:return[$(t.CFNumberOperator.between,e),$(t.CFNumberOperator.notBetween,e),$(t.CFNumberOperator.equal,e),$(t.CFNumberOperator.notEqual,e),$(t.CFNumberOperator.greaterThan,e),$(t.CFNumberOperator.greaterThanOrEqual,e),$(t.CFNumberOperator.lessThan,e),$(t.CFNumberOperator.lessThanOrEqual,e)];case t.CFSubRuleType.timePeriod:return[$(t.CFTimePeriodOperator.yesterday,e),$(t.CFTimePeriodOperator.today,e),$(t.CFTimePeriodOperator.tomorrow,e),$(t.CFTimePeriodOperator.last7Days,e),$(t.CFTimePeriodOperator.lastWeek,e),$(t.CFTimePeriodOperator.thisWeek,e),$(t.CFTimePeriodOperator.nextWeek,e),$(t.CFTimePeriodOperator.lastMonth,e),$(t.CFTimePeriodOperator.thisMonth,e),$(t.CFTimePeriodOperator.nextMonth,e)]}},it=i=>{var N;const{interceptorManager:e,onChange:n}=i,r=P.useDependency(l.LocaleService),o=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.highlightCell?i.rule:void 0,[s,a]=C.useState(()=>{const v=t.CFSubRuleType.text;return o&&o.subType||v}),m=[{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")}],d=C.useMemo(()=>rt(s,r),[s]),[p,c]=C.useState(()=>{const v=d?d[0].value:void 0;return o&&o.operator||v}),[h,g]=C.useState(()=>{var R;return o?(R=o.value)!=null?R:t.createDefaultValue(o.subType,o.operator):""}),[b,S]=C.useState({}),y=C.useMemo(()=>v=>{var T,R,I,V,j,O,k,f,F,L,q,X,J,ie,oe;switch(v.subType||s){case t.CFSubRuleType.text:{if([t.CFTextOperator.beginsWith,t.CFTextOperator.endsWith,t.CFTextOperator.containsText,t.CFTextOperator.notContainsText,t.CFTextOperator.equal,t.CFTextOperator.notEqual].includes(p))return{type:t.CFRuleType.highlightCell,subType:(T=v.subType)!=null?T:s,operator:(R=v.operator)!=null?R:p,style:(I=v.style)!=null?I:b,value:(V=v.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(p))return{type:t.CFRuleType.highlightCell,subType:(j=v.subType)!=null?j:s,operator:(O=v.operator)!=null?O:p,style:(k=v.style)!=null?k:b,value:(f=v.value)!=null?f:h};if([t.CFNumberOperator.between,t.CFNumberOperator.notBetween].includes(p))return{type:t.CFRuleType.highlightCell,subType:(F=v.subType)!=null?F:s,operator:(L=v.operator)!=null?L:p,style:(q=v.style)!=null?q:b,value:(X=v.value)!=null?X:h};break}}return{type:t.CFRuleType.highlightCell,subType:(J=v.subType)!=null?J:s,operator:(ie=v.operator)!=null?ie:p,style:(oe=v.style)!=null?oe:b}},[s,p,h,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return y({})}}),[y,e]),C.useEffect(()=>{m.some(v=>v.value===s)||a(m[0].value)},[m]);const _=v=>{const T=v,R=rt(T,r),I=R&&R[0].value;a(T),c(I),I&&g(t.createDefaultValue(T,I)),n(y({subType:T,operator:I}))},x=v=>{const T=v;c(T),n(y({operator:T}))},w=v=>{g(v),n(y({value:v}))},E=C.useMemo(()=>`${s}_${p}_${Math.random()}`,[s,p]);return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:s,options:m}),(d==null?void 0:d.length)&&u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",onChange:x,value:p||"",options:d})]}),u.jsx(Yt,{value:h,interceptorManager:e,type:s,operator:p,rule:o,onChange:w},E),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:y({})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-ml-1",onChange:v=>{S(v),n(y({style:v}))}})]})},xt=(i,e)=>(t.iconMap[i]||[])[Number(e)]||"",Kt=i=>{var c;const{error:e,type:n,onChange:r}=i,o=P.useDependency(l.IUniverInstanceService),s=o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=(c=o.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:c.getSheetId(),m=C.useRef(null),[d,p]=C.useState(!1);return P.useSidebarClick(h=>{var b;(b=m.current)!=null&&b.isClickOutSide(h)&&p(!1)}),u.jsx("div",{className:"univer-relative",children:n!==t.CFValueType.formula?u.jsxs(u.Fragment,{children:[u.jsx(M.InputNumber,{className:M.clsx({"univer-border-red-500":e}),value:Number(i.value)||0,onChange:h=>r(h!=null?h:0)}),e&&u.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):u.jsx("div",{className:"univer-w-full",children:u.jsx(Se.FormulaEditor,{ref:m,className:M.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",M.borderClassName),initValue:String(i.value),unitId:s,subUnitId:a,isFocus:d,onChange:(h="")=>{r(h||"")},onFocus:()=>p(!0)})})})},ot=(i,e,n)=>({operator:t.CFNumberOperator.greaterThan,value:{type:t.CFValueType.num,value:(n.length-1-e)*10},iconType:i,iconId:String(e)}),Xt=C.forwardRef((i,e)=>{const{onClick:n}=i,r=P.useDependency(l.LocaleService),o=s=>{n(s)};return u.jsx("div",{ref:e,className:"univer-w-80",children:t.iconGroup.map((s,a)=>u.jsxs("div",{className:"univer-mb-3",children:[u.jsx("div",{className:"univer-mb-1 univer-text-sm",children:r.t(s.title)}),u.jsx("div",{className:"univer-flex univer-flex-wrap",children:s.group.map(m=>u.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{o(m.name)},children:u.jsx("a",{className:"univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:m.list.map((d,p)=>u.jsx("img",{className:"univer-size-5",src:d,draggable:!1},p))})},m.name))})]},a))})}),Jt=i=>{const{onClick:e}=i,n=C.useMemo(()=>{const o=[];for(const s in t.iconMap){const a=t.iconMap[s],m=s;a.forEach((d,p)=>{o.push({iconType:m,base64:d,iconId:String(p)})})}return o},[]),r=o=>{e(o.iconType,o.iconId)};return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>r({iconType:t.EMPTY_ICON_TYPE,iconId:""}),children:[u.jsx(Te,{className:"univer-size-5"}),u.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),u.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:n.map(o=>u.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:u.jsx("img",{className:"univer-size-5",src:o.base64,draggable:!1,onClick:()=>r(o)})},`${o.iconType}_${o.iconId}`))})]})},Qt=i=>{const{onChange:e,configList:n,errorMap:r={}}=i,o=P.useDependency(l.LocaleService),s=[{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThan}`),value:t.CFNumberOperator.greaterThan},{label:o.t(`sheet.cf.symbol.${t.CFNumberOperator.greaterThanOrEqual}`),value:t.CFNumberOperator.greaterThanOrEqual}],a=[{label:o.t(`sheet.cf.valueType.${t.CFValueType.num}`),value:t.CFValueType.num},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percent}`),value:t.CFValueType.percent},{label:o.t(`sheet.cf.valueType.${t.CFValueType.percentile}`),value:t.CFValueType.percentile},{label:o.t(`sheet.cf.valueType.${t.CFValueType.formula}`),value:t.CFValueType.formula}],m=(h,g)=>{e([String(g),"value","value"],h)},d=(h,g)=>{e([String(g),"operator"],h);const b=t.createDefaultValue(t.CFSubRuleType.number,h);m(b,g)},p=(h,g)=>{e([String(g),"value","type"],h);const b=n[g],S=t.createDefaultValue(t.CFSubRuleType.number,b.operator);m(S,g)};return C.useMemo(()=>n.map((h,g)=>{const b=r[g],S=xt(h.iconType,h.iconId),y=g===n.length-1,_=g===0,x=n[g-1],w=(x==null?void 0:x.value.type)===t.CFValueType.formula?o.t("sheet.cf.valueType.formula"):x==null?void 0:x.value.value,E=(N,v)=>{const T={...h,iconId:v,iconType:N};e([String(g)],T)};return u.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsxs("div",{className:"univer-w-[45%]",children:[o.t("sheet.cf.iconSet.icon"),g+1]}),u.jsx("div",{className:"univer-w-[45%]",children:u.jsxs(u.Fragment,{children:[!_&&!y&&o.t("sheet.cf.iconSet.rule"),!_&&!y&&u.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(x.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]})})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx("div",{className:"univer-flex univer-items-center",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Jt,{onClick:E,iconId:h.iconId,iconType:h.iconType})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",M.borderClassName),children:[S?u.jsx("img",{src:S,className:"univer-size-4",draggable:!1}):u.jsx(Te,{className:"univer-size-4"}),u.jsx(et,{})]})})}),y?u.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[o.t("sheet.cf.iconSet.rule"),u.jsxs("span",{className:"univer-font-medium",children:[o.t("sheet.cf.iconSet.when"),o.t(`sheet.cf.symbol.${t.getOppositeOperator(x.operator)}`),w,y?"":` ${o.t("sheet.cf.iconSet.and")} `]})]}):u.jsx(M.Select,{options:s,value:h.operator,onChange:N=>{d(N,g)}})]}),y?u.jsx("div",{}):u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[u.jsx("div",{children:o.t("sheet.cf.iconSet.type")}),u.jsx("div",{children:o.t("sheet.cf.iconSet.value")})]}),u.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[u.jsx(M.Select,{options:a,value:h.value.type,onChange:N=>{p(N,g)}}),u.jsx(Kt,{id:g,type:h.value.type,error:b,value:h.value.value||"",onChange:N=>{m(N,g)}})]})]})]},g)}),[n,r])},en=i=>{var N;const{interceptorManager:e}=i,n=((N=i.rule)==null?void 0:N.type)===t.CFRuleType.iconSet?i.rule:void 0,r=P.useDependency(l.LocaleService),[o,s]=C.useState({}),[a,m]=C.useState(()=>{const v=Object.keys(t.iconMap)[0];if(n&&n.config.length){const T=n.config[0].iconType;if(!n.config.some(I=>I.iconType!==T))return T}return v}),[d,p]=C.useState(()=>{if(n&&n.config.length)return l.Tools.deepClone(n==null?void 0:n.config);const v=t.iconMap[a]||[];return new Array(v.length).fill("").map((T,R,I)=>R===I.length-1?{operator:t.CFNumberOperator.lessThanOrEqual,value:{type:t.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:a,iconId:String(R)}:ot(a,R,I))}),[c,h]=C.useState(()=>n?!!n.isShowValue:!0),g=C.useMemo(()=>{const v=d.map(T=>xt(T.iconType,T.iconId));return u.jsx("div",{className:"univer-flex univer-items-center",children:v.map((T,R)=>T?u.jsx("img",{className:"univer-size-5",src:T},R):u.jsx(Te,{className:"univer-size-5"},R))})},[d]),b=v=>{if(v.reduce((R,I,V)=>R.preType&&!R.result||v.length-1===V?R:I.value.type===t.CFValueType.formula?{preType:t.CFValueType.formula,result:!1}:R.preType?{result:R.preType===I.value.type,preType:I.value.type}:{result:!0,preType:I.value.type},{result:!0,preType:""}).result&&[t.CFValueType.num,t.CFValueType.percent,t.CFValueType.percentile].includes(v[0].value.type)){const R={};return v.forEach((I,V,j)=>{if(V-1<0||V===j.length-1)return;const k=v[V-1],f=t.getOppositeOperator(k.operator);t.compareWithNumber({operator:f,value:k.value.value},I.value.value)||(R[V]=`${r.t(`sheet.cf.form.${f}`,String(k.value.value))} `)}),R}return{}},S=(v,T)=>{l.get(d,v)!==T&&(l.set(d,v,T),p([...d]),s(b(d)))},y=v=>{m(v);const T=t.iconMap[v]||[],R=new Array(T.length).fill("").map((I,V,j)=>ot(v,V,j));p(R),s(b(R))};C.useEffect(()=>{const v=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:t.CFRuleType.iconSet,isShowValue:c,config:d}}});return()=>{v()}},[c,d,e]),C.useEffect(()=>{const v=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(o).length===0}});return()=>{v()}},[c,d,e,o]);const _=()=>{const v=d.map(T=>({...T}));d.forEach((T,R)=>{const I=d.length-1-R,V=v[I];T.iconId=V.iconId,T.iconType=V.iconType}),p([...d])},x=P.useDependency(P.ILayoutService),[w,E]=C.useState();return P.useScrollYOverContainer(w,x.rootContainerElement),u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:r.t("sheet.cf.panel.styleRule")}),u.jsx("div",{className:"univer-mt-3",children:u.jsx(M.Dropdown,{overlay:u.jsx("div",{className:"univer-rounded-lg univer-p-4",children:u.jsx(Xt,{ref:v=>{!w&&v&&E(v)},iconType:a,onClick:y})}),children:u.jsxs("div",{className:M.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",M.borderClassName),children:[g,u.jsx(et,{})]})})}),u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{onChange:_}),r.t("sheet.cf.iconSet.reverseIconOrder")]}),u.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:!c,onChange:v=>{h(!v)}}),r.t("sheet.cf.iconSet.onlyShowIcon")]})]}),u.jsx(Qt,{errorMap:o,onChange:S,configList:d})]})},tn=i=>{var _;const{onChange:e,interceptorManager:n}=i,r=P.useDependency(l.LocaleService),o=((_=i.rule)==null?void 0:_.type)===t.CFRuleType.highlightCell?i.rule:void 0,s=[{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"}],[a,m]=C.useState(()=>{const x=s[0].value,w=o==null?void 0:o.type;if(!o)return x;switch(w){case t.CFRuleType.highlightCell:switch(o.subType){case t.CFSubRuleType.average:return[t.CFNumberOperator.greaterThan,t.CFNumberOperator.greaterThanOrEqual].includes(o.operator)?"greaterThanAverage":[t.CFNumberOperator.lessThan,t.CFNumberOperator.lessThanOrEqual].includes(o.operator)?"lessThanAverage":x;case t.CFSubRuleType.rank:return o.isBottom?"isBottom":"isNotBottom"}}return x}),[d,p]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return 10;switch(w){case t.CFRuleType.highlightCell:if(o.subType===t.CFSubRuleType.rank)return o.value||10}return 10}),[c,h]=C.useState(()=>{const w=o==null?void 0:o.type;if(!o)return!1;switch(w){case t.CFRuleType.highlightCell:if(o.subType===t.CFSubRuleType.rank)return o.isPercent||!1}return!1}),[g,b]=C.useState({}),S=x=>{const{type:w,isPercent:E,value:N,style:v}=x;if(w==="isNotBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!1,value:N,style:v};if(w==="isBottom")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank,isPercent:E,isBottom:!0,value:N,style:v};if(w==="greaterThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.greaterThan,style:v};if(w==="lessThanAverage")return{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.average,operator:t.CFNumberOperator.lessThan,style:v}};C.useEffect(()=>n.intercept(n.getInterceptPoints().submit,{handler(){return S({type:a,isPercent:c,value:d,style:g})}}),[a,c,d,g,n]);const y=x=>{e(S(x))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:r.t("sheet.cf.panel.styleRule")}),u.jsx(M.Select,{className:"univer-mt-3 univer-w-full",value:a,options:s,onChange:x=>{m(x),y({type:x,isPercent:c,value:d,style:g})}}),["isNotBottom","isBottom"].includes(a)&&u.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[u.jsx(M.InputNumber,{min:1,max:1e3,value:d,onChange:x=>{const w=x||0;p(w),y({type:a,isPercent:c,value:w,style:g})}}),u.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[u.jsx(M.Checkbox,{checked:c,onChange:x=>{h(!!x),y({type:a,isPercent:!!x,value:d,style:g})}}),r.t("sheet.cf.valueType.percent")]})]}),u.jsx("div",{className:xe,children:u.jsx(ce,{rule:S({type:a,isPercent:c,value:d,style:g})})}),u.jsx(tt,{style:o==null?void 0:o.style,className:"univer-mt-3",onChange:x=>{b(x),y({type:a,isPercent:c,value:d,style:x})}})]})},nn=l.createInterceptorKey("beforeSubmit"),rn=l.createInterceptorKey("submit"),st=i=>i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),at=i=>{var e;return(e=i.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},on=i=>{var R,I,V;const e=P.useDependency(l.LocaleService),n=P.useDependency(l.ICommandService),r=P.useDependency(l.IUniverInstanceService),o=P.useDependency(t.ConditionalFormattingRuleModel),s=P.useDependency(U.SheetsSelectionsService),a=st(r),m=at(r),[d,p]=C.useState(void 0),c=C.useRef((I=(R=i.rule)==null?void 0:R.ranges)!=null?I:[]),h=C.useMemo(()=>{var O,k,f;let j=(O=i.rule)==null?void 0:O.ranges;return j!=null&&j.length||(j=(f=(k=s.getCurrentSelections())==null?void 0:k.map(F=>F.range))!=null?f:[]),c.current=j,j!=null&&j.length?j.map(F=>{const L=We.serializeRange(F);return L==="NaN"?"":L}).filter(F=>!!F).join(","):""},[i.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,S]=C.useState(()=>{var k,f;const j=(k=i.rule)==null?void 0:k.rule.type,O=g[0].value;if(!j)return O;switch(j){case t.CFRuleType.highlightCell:{switch((f=i.rule)==null?void 0:f.rule.subType){case t.CFSubRuleType.number:case t.CFSubRuleType.text:case t.CFSubRuleType.duplicateValues:case t.CFSubRuleType.uniqueValues:case t.CFSubRuleType.timePeriod:return"1";case t.CFSubRuleType.average:case t.CFSubRuleType.rank:return"2";case t.CFSubRuleType.formula:return"5"}break}case t.CFRuleType.dataBar:return"3";case t.CFRuleType.colorScale:return"4";case t.CFRuleType.iconSet:return"6"}return O}),y=C.useRef(void 0),_=C.useMemo(()=>new l.InterceptorManager({beforeSubmit:nn,submit:rn}),[]),x=C.useMemo(()=>{switch(b){case"1":return it;case"2":return tn;case"3":return Zt;case"4":return Gt;case"5":return zt;case"6":return en;default:return it}},[b]);C.useEffect(()=>{const j=n.onCommandExecuted(O=>{if(O.id===U.RemoveSheetMutation.id){const k=O.params;k.subUnitId===m&&k.unitId===a&&i.onCancel()}O.id===U.SetWorksheetActiveOperation.id&&i.onCancel()});return()=>j.dispose()},[]);const w=j=>{y.current=j},E=j=>{const O=j.split(",").filter(k=>!!k).map(We.deserializeRangeWithSheet).map(k=>k.range);c.current=O},N=()=>{if(d)return;const O=(()=>{const f=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!f)throw new Error("No active sheet found");return c.current.map(q=>U.setEndForRange(q,f.getRowCount(),f.getColumnCount())).filter(q=>!(Number.isNaN(q.startRow)||Number.isNaN(q.startColumn)))})();if(_.fetchThroughInterceptors(_.getInterceptPoints().beforeSubmit)(!0,null)){const f=_.fetchThroughInterceptors(_.getInterceptPoints().submit)(null,null);if(f){const F=st(r),L=at(r);if(!F||!L)throw new Error("No active sheet found");let q={};i.rule&&i.rule.cfId?(q={...i.rule,ranges:O,rule:f},n.executeCommand(t.SetCfCommand.id,{unitId:F,subUnitId:L,rule:q}),i.onCancel()):(q={cfId:o.createCfId(F,L),ranges:O,rule:f,stopIfTrue:!1},n.executeCommand(t.AddCfCommand.id,{unitId:F,subUnitId:L,rule:q}),i.onCancel())}}},v=()=>{i.onCancel()},T=(j,O)=>{j?O.length<1?p(e.t("sheet.cf.errorMessage.rangeError")):p(void 0):p(e.t("sheet.cf.errorMessage.rangeError"))};return u.jsxs("div",{children:[u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),u.jsxs("div",{className:"univer-mt-4",children:[u.jsx(Se.RangeSelector,{unitId:a,subUnitId:m,initialValue:h,onChange:(j,O)=>E(O),onVerify:T}),d&&u.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:d})]}),u.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),u.jsx(M.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:j=>S(j)}),u.jsx(x,{interceptorManager:_,rule:(V=i.rule)==null?void 0:V.rule,onChange:w}),u.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[u.jsx(M.Button,{onClick:v,children:e.t("sheet.cf.panel.cancel")}),u.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:N,children:e.t("sheet.cf.panel.submit")})]})]})};var sn=Object.getOwnPropertyDescriptor,an=(i,e,n,r)=>{for(var o=r>1?void 0:r?sn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ln=(i,e)=>(n,r)=>e(n,r,i);let ue=class extends l.Disposable{constructor(e){super();Q(this,"_initLocal",()=>{});Q(this,"_findReplaceIndex",e=>{const n=/\{([^}]+)?\}/g,r=[];let o=n.exec(e);for(;o;)r.push({startIndex:o.index,key:Number(o[1]),endIndex:o.index+o[0].length-1}),o=n.exec(e);return r});this._localeService=e,this._initLocal()}tWithReactNode(e,...n){const r=this._localeService.getLocales(),o=e.split("."),s=r&&this._localeService.resolveKeyPath(r,o);if(typeof s=="string"){const a=[];return this._findReplaceIndex(s).forEach((m,d,p)=>{const c=p[d-1]||{endIndex:-1};if(c.endIndex+1<m.startIndex){const h=s.slice(c.endIndex+1,m.startIndex);h&&a.push(h)}if(n[m.key]&&a.push(n[m.key]),d===p.length-1){const h=s.slice(m.endIndex+1);h&&a.push(h)}}),a}return[]}};ue=an([ln(0,l.Inject(l.LocaleService))],ue);const un=(i,e)=>{const n=i.rule;switch(n.type){case t.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case t.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case t.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case t.CFRuleType.highlightCell:switch(n.subType){case t.CFSubRuleType.average:{const r=n.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=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,...Array.isArray(n.value)?n.value.map(o=>String(o)):[String(n.value||"")])}case t.CFSubRuleType.text:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`,n.value||"")}case t.CFSubRuleType.timePeriod:{const r=n.operator;return e.t(`sheet.cf.preview.describe.${r}`)}case t.CFSubRuleType.rank:return n.isPercent?n.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(n.value)):e.t("sheet.cf.preview.describe.topNPercent",String(n.value)):n.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(n.value)):e.t("sheet.cf.preview.describe.topN",String(n.value));case t.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let lt=0;const cn=i=>{const{onClick:e}=i,n=P.useDependency(t.ConditionalFormattingRuleModel),r=P.useDependency(l.IUniverInstanceService),o=P.useDependency(U.SheetsSelectionsService),s=P.useDependency(l.ICommandService),a=P.useDependency(l.LocaleService),m=P.useDependency(l.Injector),d=P.useDependency(P.ISidebarService),p=P.useDependency(ue),c=P.useObservable(()=>r.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),h=c.getUnitId(),g=c.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[S,y]=C.useState([]),[_,x]=C.useState("2"),[w,E]=C.useState(0),[N,v]=C.useState(-1),[T,R]=C.useState(lt),I=C.useRef(null),V=[{label:a.t("sheet.cf.panel.workSheet"),value:"2"},{label:a.t("sheet.cf.panel.selectedRange"),value:"1"}],j=()=>{const D=n.getSubunitRules(h,b);if(!D||!D.length)return[];if(_==="1"){const A=o.getCurrentLastSelection();if(!A)return[];const B=A.range;return D.filter(G=>G.ranges.some(Z=>l.Rectangle.intersects(Z,B)))}else if(_==="2")return[...D];return[]},[O,k]=C.useState(j);H.useHighlightRange(S),C.useEffect(()=>{const D=s.onCommandExecuted(A=>{A.id===U.SetWorksheetActiveOperation.id&&E(Math.random())});return()=>D.dispose()}),C.useEffect(()=>{k(j)},[_,w,h,b]),C.useEffect(()=>{if(_==="2")return;const D=new K.Observable(A=>{const B=[U.SetSelectionsOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],W=s.onCommandExecuted(G=>{const{id:Z,params:ee}=G,te=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();B.includes(Z)&&ee.unitId===te&&A.next(null)});return()=>W.dispose()}).pipe(K.debounceTime(16)).subscribe(()=>{k(j)});return()=>{D.unsubscribe()}},[r,_,h,b]),C.useEffect(()=>{const D=n.$ruleChange.subscribe(()=>{E(Math.random())});return()=>D.unsubscribe()},[n]),C.useEffect(()=>{const D=()=>{var G,Z;const W=Math.max(0,((Z=(G=I.current)==null?void 0:G.getBoundingClientRect().width)!=null?Z:0)-8);return lt=W,W},B=new K.Observable(W=>{const G=d.getContainer();if(G){let Z=setTimeout(()=>{W.next(void 0)},150);const ee=()=>{Z&&clearTimeout(Z),Z=null},te=Fe=>{Fe.propertyName==="width"&&(ee(),W.next(void 0))};return G.addEventListener("transitionend",te),()=>{ee(),G.removeEventListener("transitionend",te)}}}).pipe(K.debounceTime(16)).subscribe(()=>{R(D())});return()=>{B.unsubscribe()}},[]);const f=D=>{var W;const A=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),B=(W=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:W.getSheetId();if(!A||!B)throw new Error("No active sheet found");s.executeCommand(t.DeleteCfCommand.id,{unitId:A,subUnitId:B,cfId:D.cfId})},F=(D,A)=>{v(A.y)},L=(D,A,B)=>{var Fe;v(-1);const W=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),G=(Fe=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:Fe.getSheetId();if(!W||!G)throw new Error("No active sheet found");const Z=wt=>{const Nt=O.length;return Math.min(Nt-1,Math.max(0,wt))},ee=O[Z(A.y)].cfId,te=O[Z(B.y)].cfId;ee!==te&&s.executeCommand(t.MoveCfCommand.id,{unitId:W,subUnitId:G,start:{id:ee,type:"self"},end:{id:te,type:B.y>A.y?"after":"before"}})},q=()=>{i.onCreate()},X=()=>{_==="2"?s.executeCommand(t.ClearWorksheetCfCommand.id):_==="1"&&O.map(A=>({unitId:h,subUnitId:b,cfId:A.cfId})).forEach(A=>{s.executeCommand(t.DeleteCfCommand.id,A)})},J=C.useMemo(()=>{const D=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.filter(B=>{const W=B.ranges;return U.checkRangesEditablePermission(m,D.getUnitId(),A.getSheetId(),W)})},[O]),ie=J.map((D,A)=>({i:D.cfId,x:0,w:12,y:A,h:1,isResizable:!1})),oe=C.useMemo(()=>{const D=r.getCurrentUnitOfType(l.UniverInstanceType.UNIVER_SHEET),A=D.getActiveSheet();return O.every(B=>{const W=B.ranges;return U.checkRangesEditablePermission(m,D.getUnitId(),A.getSheetId(),W)})},[O]);return u.jsxs("div",{children:[u.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[u.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:p.tWithReactNode("sheet.cf.panel.managerRuleSelect",u.jsx(M.Select,{className:"univer-w-36",options:V,value:_,onChange:D=>{x(D)}})).map((D,A)=>u.jsx("span",{children:D},A))}),u.jsxs("div",{className:"univer-flex univer-justify-end",children:[u.jsx(M.Tooltip,{title:a.t("sheet.cf.panel.createRule"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:q,children:u.jsx(ft,{})})}),O.length&&oe?u.jsx(M.Tooltip,{title:a.t("sheet.cf.panel.clear"),placement:"bottom",children:u.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:X,children:u.jsx(je,{className:"univer-text-red-500"})})}):u.jsx("div",{children:u.jsx(je,{className:"univer-text-gray-300"})})]})]}),u.jsx("div",{ref:I,children:T>0&&u.jsx(M.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:ie,cols:12,rowHeight:60,width:T,margin:[0,10],onDragStop:L,onDragStart:F,children:J==null?void 0:J.map((D,A)=>u.jsx("div",{children:u.jsxs("div",{className:M.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":N===A}),onMouseMove:()=>{D.ranges!==S&&y(D.ranges)},onMouseLeave:()=>y([]),onClick:()=>{e(D)},children:[u.jsx("div",{className:M.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:B=>B.stopPropagation(),children:u.jsx(yt,{})}),u.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[u.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:un(D,a)}),u.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:D.ranges.map(B=>We.serializeRange(B)).join(",")})]}),u.jsx("div",{children:u.jsx(ce,{rule:D.rule})}),u.jsx("div",{className:M.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":N===A}),onClick:B=>{B.stopPropagation(),f(D),y([])},children:u.jsx(je,{})})]})},`${D.cfId}`))})})]})},dn=i=>{const[e,n]=C.useState(i.rule),[r,o]=C.useState(!!i.rule),s=()=>{o(!0)},a=()=>{o(!1),n(void 0)},m=d=>{n(d),o(!0)};return u.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:r?u.jsx(on,{onCancel:a,rule:e}):u.jsx(cn,{onClick:m,onCreate:s})})};var mn=Object.getOwnPropertyDescriptor,hn=(i,e,n,r)=>{for(var o=r>1?void 0:r?mn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},de=(i,e)=>(n,r)=>e(n,r,i);const Ee="sheet.conditional.formatting.panel";let fe=class extends l.Disposable{constructor(e,n,r,o,s){super();Q(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=o,this._localeService=s,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(a=>{var m;a||(m=this._sidebarDisposable)==null||m.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ee&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const n={id:Ee,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ee,rule:e,key:l.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ee,dn))}};fe=hn([de(0,l.IUniverInstanceService),de(1,l.Inject(l.Injector)),de(2,l.Inject(P.ComponentManager)),de(3,l.Inject(P.ISidebarService)),de(4,l.Inject(l.LocaleService))],fe);var z=(i=>(i[i.createRule=1]="createRule",i[i.viewRule=2]="viewRule",i[i.highlightCell=3]="highlightCell",i[i.rank=4]="rank",i[i.formula=5]="formula",i[i.colorScale=6]="colorScale",i[i.dataBar=7]="dataBar",i[i.icon=8]="icon",i[i.clearRangeRules=9]="clearRangeRules",i[i.clearWorkSheetRules=10]="clearWorkSheetRules",i))(z||{});const Re={id:"sheet.operation.open.conditional.formatting.panel",type:l.CommandType.OPERATION,handler:(i,e)=>{var m;const n=i.get(fe),r=i.get(U.SheetsSelectionsService),o=i.get(l.ICommandService),s=((m=r.getCurrentSelections())==null?void 0:m.map(d=>d.range))||[];switch(e.value){case 3:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 4:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.rank}};n.openPanel(d);break}case 5:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.highlightCell,subType:t.CFSubRuleType.formula,value:"="}};n.openPanel(d);break}case 6:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.colorScale,config:[]}};n.openPanel(d);break}case 7:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.dataBar,isShowValue:!0}};n.openPanel(d);break}case 8:{const d={...t.createDefaultRule,ranges:s,rule:{type:t.CFRuleType.iconSet,config:[],isShowValue:!0}};n.openPanel(d);break}case 2:{n.openPanel();break}case 1:{n.openPanel({...t.createDefaultRule(),ranges:s});break}case 9:{o.executeCommand(t.ClearRangeCfCommand.id,{ranges:s});break}case 10:{o.executeCommand(t.ClearWorksheetCfCommand.id);break}}return!0}};var vn=Object.getOwnPropertyDescriptor,pn=(i,e,n,r)=>{for(var o=r>1?void 0:r?vn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},me=(i,e)=>(n,r)=>e(n,r,i);exports.ConditionalFormattingClearController=class extends l.Disposable{constructor(e,n,r,o,s){super(),this._injector=e,this._univerInstanceService=n,this._sheetInterceptorService=r,this._selectionManagerService=o,this._conditionalFormattingRuleModel=s,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var s;const n=[],r=[],o={redos:n,undos:r};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const a=(s=this._selectionManagerService.getCurrentSelections())==null?void 0:s.map(S=>S.range);if(!a)return o;const m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),d=m.getActiveSheet();if(!d)return o;const p=m.getUnitId(),c=d.getSheetId(),h=this._conditionalFormattingRuleModel.getSubunitRules(p,c);if(!h||!h.length)return o;const{redos:g,undos:b}=ut(this._injector,h,a,p,c);n.push(...g),r.push(...b)}return o}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:n,ranges:r})=>{const o=[],s=[],a={redos:o,undos:s};if(!r||!r.length)return a;const m=this._conditionalFormattingRuleModel.getSubunitRules(e,n);if(!m||!m.length)return a;const{redos:d,undos:p}=ut(this._injector,m,r,e,n);return o.push(...d),s.push(...p),a}}))}};exports.ConditionalFormattingClearController=pn([me(0,l.Inject(l.Injector)),me(1,l.Inject(l.IUniverInstanceService)),me(2,l.Inject(U.SheetInterceptorService)),me(3,l.Inject(U.SheetsSelectionsService)),me(4,l.Inject(t.ConditionalFormattingRuleModel))],exports.ConditionalFormattingClearController);function ut(i,e,n,r,o){const s=[],a=[];return e.filter(m=>n.some(d=>m.ranges.some(p=>l.Rectangle.getIntersects(p,d)))).forEach(m=>{const p=new U.RangeMergeUtil().add(...m.ranges).subtract(...n).merge();if(p.length){const c={id:t.SetConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,rule:{...m,ranges:p}}},h=t.setConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...h)}else{const c={id:t.DeleteConditionalRuleMutation.id,params:{unitId:r,subUnitId:o,cfId:m.cfId}},h=t.DeleteConditionalRuleMutationUndoFactory(i,c.params);s.push(c),a.push(...h)}}),{redos:s,undos:a}}var gn=Object.getOwnPropertyDescriptor,fn=(i,e,n,r)=>{for(var o=r>1?void 0:r?gn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Le=(i,e)=>(n,r)=>e(n,r,i);let Ce=class extends l.Disposable{constructor(e,n,r){super();Q(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=n,this._injector=r,this._initRefRange()}_getIdWithUnitId(e,n,r){return`${e}_${n}_${r}`}_getRuleFormulas(e){const n=[],r=e.rule;switch(r.type){case t.CFRuleType.highlightCell:r.subType===t.CFSubRuleType.formula&&n.push(r.value);break;case t.CFRuleType.dataBar:{const o=r;o.config.min.type===t.CFValueType.formula&&n.push(o.config.min.value),o.config.max.type===t.CFValueType.formula&&n.push(o.config.max.value);break}case t.CFRuleType.colorScale:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}case t.CFRuleType.iconSet:{r.config.forEach(s=>{s.value.type===t.CFValueType.formula&&n.push(s.value.value)});break}}return n}_updateRuleFormulas(e,n){const r=l.Tools.deepClone(e),o=r.rule;let s=0;switch(o.type){case t.CFRuleType.highlightCell:o.subType===t.CFSubRuleType.formula&&(o.value=n[s++]);break;case t.CFRuleType.dataBar:{const a=o;a.config.min.type===t.CFValueType.formula&&(a.config.min.value=n[s++]),a.config.max.type===t.CFValueType.formula&&(a.config.max.value=n[s++]);break}case t.CFRuleType.colorScale:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}case t.CFRuleType.iconSet:{o.config.forEach(m=>{m.value.type===t.CFValueType.formula&&(m.value.value=n[s++])});break}}return r}register(e,n,r){const o=r.ranges,s=this._getRuleFormulas(r),a=this._formulaRefRangeService.registerRangeFormula(e,n,o,s,d=>{if(d.length===0)return{undos:[{id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:r}}],redos:[{id:t.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId}}]};const p=[],c=[],h=d[0],g=this._updateRuleFormulas(r,h.formulas);g.ranges=h.ranges,p.push({id:t.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,cfId:r.cfId,rule:g}}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,cfId:r.cfId,rule:g}));for(let b=1;b<d.length;b++){const S=d[b],y=t.createCfId(),_=this._updateRuleFormulas(r,S.formulas);_.cfId=y,_.ranges=S.ranges,p.push({id:t.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:n,rule:_}}),c.push(t.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:n,rule:_}))}return{undos:c,redos:p}}),m=this._getIdWithUnitId(e,n,r.cfId);this._disposableMap.set(m,a)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[n,r]of e)for(const[o,s]of r)for(const a of s)this.register(n,o,a);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(n=>{const{unitId:r,subUnitId:o,rule:s}=n;switch(n.type){case"add":{this.register(r,o,s);break}case"delete":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a));break}case"set":{const a=this._getIdWithUnitId(r,o,s.cfId),m=this._disposableMap.get(a);m&&(m.dispose(),this._disposableMap.delete(a)),this.register(r,o,s);break}}})),this.disposeWithMe(l.toDisposable(()=>{this._disposableMap.forEach(n=>{n.dispose()}),this._disposableMap.clear()}))}};Ce=fn([Le(0,l.Inject(t.ConditionalFormattingRuleModel)),Le(1,l.Inject(ht.FormulaRefRangeService)),Le(2,l.Inject(l.Injector))],Ce);var Cn=Object.getOwnPropertyDescriptor,yn=(i,e,n,r)=>{for(var o=r>1?void 0:r?Cn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},he=(i,e)=>(n,r)=>e(n,r,i);let ye=class extends l.Disposable{constructor(e,n,r,o,s){super();Q(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=n,this._injector=r,this._conditionalFormattingViewModel=o,this._univerInstanceService=s,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,n,r)=>this._collectConditionalRule(e,n,r),onPasteCells:(e,n,r,o)=>{const{copyType:s=H.COPY_TYPE.COPY,pasteType:a}=o,{range:m}=e||{},{range:d}=n;return this._generateConditionalFormattingMutations(d,{copyType:s,pasteType:a,copyRange:m})}}))}_collectConditionalRule(e,n,r){const o=new l.ObjectMatrix,s={};this._copyInfo={matrix:o,info:{unitId:e,subUnitId:n,cfMap:s}};const a=this._injector.invoke(c=>U.rangeToDiscreteRange(r,c,e,n));if(!a)return;const{rows:m,cols:d}=a,p=new Set;m.forEach((c,h)=>{d.forEach((g,b)=>{const S=this._conditionalFormattingViewModel.getCellCfs(e,n,c,g);S&&(S.forEach(y=>p.add(y.cfId)),o.setValue(h,b,S.map(y=>y.cfId)))})}),p.forEach(c=>{const h=this._conditionalFormattingRuleModel.getRule(e,n,c);h&&(s[c]=h.rule)})}_generateConditionalFormattingMutations(e,n){const r=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),o=r.getActiveSheet(),s=r.getUnitId();if(!o)return{redos:[],undos:[]};const a=o.getSheetId();if(n.copyType===H.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!n.copyRange)return{redos:[],undos:[]};if(![H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,H.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,H.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(n.pasteType))return{redos:[],undos:[]};const{ranges:[d,p],mapFunc:c}=H.virtualizeDiscreteRanges([n.copyRange,e]),h=H.getRepeatRange(d,p,!0),g={};l.Range.foreach(p,(v,T)=>{const{row:R,col:I}=c(v,T),V=this._conditionalFormattingViewModel.getCellCfs(s,a,R,I);V&&V.forEach(j=>{if(!g[j.cfId]){const O=new l.ObjectMatrix;g[j.cfId]=O;const k=this._conditionalFormattingRuleModel.getRule(s,a,j.cfId);k==null||k.ranges.forEach(f=>{l.Range.foreach(f,(F,L)=>{O.setValue(F,L,1)})})}g[j.cfId].realDeleteValue(R,I)})});const{matrix:b,info:S}=this._copyInfo,y=[];let _=this._conditionalFormattingRuleModel.createCfId(s,a);const x={},w=v=>{if(x[v])return x[v];const T=S==null?void 0:S.cfMap[v],R=[...this._conditionalFormattingRuleModel.getSubunitRules(s,a)||[],...y].find(I=>l.Tools.diffValue(I.rule,T));if(R)return x[v]=R,R;{const I={rule:T,cfId:_,ranges:[],stopIfTrue:!1};return x[v]=I,y.push(I),_=`${Number(_)+1}`,I}};h.forEach(v=>{b&&b.forValue((T,R,I)=>{const V=l.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:R,endColumn:R},v.startRange),{row:j,col:O}=c(V.startRow,V.startColumn);I.forEach(k=>{if(!g[k]){const f=w(k),F=new l.ObjectMatrix;g[k]=F,f.ranges.forEach(L=>{l.Range.foreach(L,(q,X)=>{F.setValue(q,X,1)})})}g[k].setValue(j,O,1)})})});const E=[],N=[];for(const v in g){const T=g[v],R=U.findAllRectangle(U.createTopMatrixFromMatrix(T));if(!R.length){const I={unitId:s,subUnitId:a,cfId:v};E.push({id:t.DeleteConditionalRuleMutation.id,params:I}),N.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}if(y.some(I=>I.cfId===v)){const I=w(v),V={unitId:s,subUnitId:a,rule:{...I,ranges:R}};E.push({id:t.AddConditionalRuleMutation.id,params:V}),N.push(t.AddConditionalRuleMutationUndoFactory(this._injector,V))}else{const I=this._conditionalFormattingRuleModel.getRule(s,a,v);if(!I)continue;const V={unitId:s,subUnitId:a,rule:{...I,ranges:R}};E.push({id:t.SetConditionalRuleMutation.id,params:V}),N.push(...t.setConditionalRuleMutationUndoFactory(this._injector,V))}}return{redos:E,undos:N}}};ye=yn([he(0,l.Inject(H.ISheetClipboardService)),he(1,l.Inject(t.ConditionalFormattingRuleModel)),he(2,l.Inject(l.Injector)),he(3,l.Inject(t.ConditionalFormattingViewModel)),he(4,l.Inject(l.IUniverInstanceService))],ye);var bn=Object.getOwnPropertyDescriptor,In=(i,e,n,r)=>{for(var o=r>1?void 0:r?bn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Ae=(i,e)=>(n,r)=>e(n,r,i);let be=class extends l.Disposable{constructor(i,e,n){super(),this._localeService=i,this._commandService=e,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(i=>{if(i.id===t.AddCfCommand.id){const{unitId:e,subUnitId:n,rule:{ranges:r}}=i.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},r,e,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};be=In([Ae(0,l.Inject(l.LocaleService)),Ae(1,l.ICommandService),Ae(2,l.Inject(U.SheetPermissionCheckController))],be);var Sn=Object.getOwnPropertyDescriptor,Tn=(i,e,n,r)=>{for(var o=r>1?void 0:r?Sn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ae=(i,e)=>(n,r)=>e(n,r,i);let Ie=class extends l.Disposable{constructor(e,n,r,o,s,a){super();Q(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=n,this._univerInstanceService=r,this._renderManagerService=o,this._conditionalFormattingViewModel=s,this._conditionalFormattingRuleModel=a,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var n,r,o;const e=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId();(n=this._renderManagerService.getRenderById(e))==null||n.with(H.SheetSkeletonManagerService).reCalculate(),(o=(r=this._renderManagerService.getRenderById(e))==null?void 0:r.mainComponent)==null||o.makeDirty()}_initSkeleton(){this.disposeWithMe(K.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(ge.bufferTime(16),ge.filter(e=>!!e.length),ge.filter(e=>{const n=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;const r=n.getActiveSheet();return r?e.filter(o=>o.unitId===n.getUnitId()&&o.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:l.InterceptorEffectEnum.Style,handler:(e,n,r)=>{const o=this._conditionalFormattingService.composeStyle(n.unitId,n.subUnitId,n.row,n.col);if(!o)return r(e);const s=n.workbook.getStyles(),a=(typeof(e==null?void 0:e.s)=="string"?s.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},m=e===n.rawData?{...n.rawData}:e;if(o.style){const d={...a,...o.style};Object.assign(m,{s:d})}return m.fontRenderExtension||(m.fontRenderExtension={},o.isShowValue!==void 0&&(m.fontRenderExtension.isSkip=!o.isShowValue)),o.dataBar&&(m.dataBar=o.dataBar),o.iconSet&&(m.iconSet=o.iconSet,m.fontRenderExtension.leftOffset=t.DEFAULT_PADDING+t.DEFAULT_WIDTH),r(m)},priority:10}))}};Ie=Tn([ae(0,l.Inject(U.SheetInterceptorService)),ae(1,l.Inject(t.ConditionalFormattingService)),ae(2,l.Inject(l.IUniverInstanceService)),ae(3,l.Inject(vt.IRenderManagerService)),ae(4,l.Inject(t.ConditionalFormattingViewModel)),ae(5,l.Inject(t.ConditionalFormattingRuleModel))],Ie);const Rt="sheets-conditional-formatting-ui.config",Me={};var xn=Object.defineProperty,Rn=Object.getOwnPropertyDescriptor,Fn=(i,e,n)=>e in i?xn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,_n=(i,e,n,r)=>{for(var o=r>1?void 0:r?Rn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},$e=(i,e)=>(n,r)=>e(n,r,i),Ft=(i,e,n)=>Fn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingMobileUIPlugin=class extends l.Plugin{constructor(e=Me,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},Me,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Rt,a),this._initCommand(),this._injector.add([Ie]),this._injector.add([ye]),this._injector.add([be]),this._injector.add([ue]),this._injector.add([Ce])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};Ft(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`);Ft(exports.UniverSheetsConditionalFormattingMobileUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingMobileUIPlugin=_n([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin),$e(1,l.Inject(l.Injector)),$e(2,l.Inject(l.ICommandService)),$e(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingMobileUIPlugin);var wn=Object.getOwnPropertyDescriptor,Nn=(i,e,n,r)=>{for(var o=r>1?void 0:r?wn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ve=(i,e)=>(n,r)=>e(n,r,i);let Ve=class extends l.Disposable{constructor(i,e,n,r,o){super(),this._injector=i,this._univerInstanceService=e,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=o,this._initAutoFill()}_initAutoFill(){const i=()=>({redos:[],undos:[]}),e=(o,s,a,m,d)=>{var b;const p=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(b=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!p||!c)return;const h={startRow:o.row,startColumn:o.col,endColumn:o.col,endRow:o.row},g={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};l.Range.foreach(a,(S,y)=>{const _=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},h),x=l.Rectangle.getPositionRange({startRow:S,startColumn:y,endColumn:y,endRow:S},g),{row:w,col:E}=d(_.startRow,_.startColumn),N=this._conditionalFormattingViewModel.getCellCfs(p,c,w,E),{row:v,col:T}=d(x.startRow,x.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(p,c,v,T);R&&R.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(p,c,I.cfId);if(!j)return;V=new l.ObjectMatrix,j.ranges.forEach(O=>{l.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),m.set(I.cfId,V)}V.realDeleteValue(v,T)}),N&&N.forEach(I=>{let V=m.get(I.cfId);if(!m.get(I.cfId)){const j=this._conditionalFormattingRuleModel.getRule(p,c,I.cfId);if(!j)return;V=new l.ObjectMatrix,j.ranges.forEach(O=>{l.Range.foreach(O,(k,f)=>{V.setValue(k,f,1)})}),m.set(I.cfId,V)}V.setValue(v,T,1)})})},n=(o,s)=>{var x,w,E;const a=(x=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:x.getUnitId(),m=(E=(w=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:w.getActiveSheet())==null?void 0:E.getSheetId(),d=new Map,p=[],c=[];if(!a||!m)return i();const h=H.virtualizeDiscreteRanges([o,s]),[g,b]=h.ranges,{mapFunc:S}=h,y={row:g.startRow,col:g.startColumn};return H.getAutoFillRepeatRange(g,b).forEach(N=>{e(y,N.repeatStartCell,N.relativeRange,d,S)}),d.forEach((N,v)=>{const T=this._conditionalFormattingRuleModel.getRule(a,m,v);if(!T)return;const R=U.findAllRectangle(U.createTopMatrixFromMatrix(N));if(R.length){const I={unitId:a,subUnitId:m,rule:{...T,ranges:R}};p.push({id:t.SetConditionalRuleMutation.id,params:I}),c.push(...t.setConditionalRuleMutationUndoFactory(this._injector,I))}else{const I={unitId:a,subUnitId:m,cfId:T.cfId};p.push({id:t.DeleteConditionalRuleMutation.id,params:I}),c.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,I))}}),{undos:c,redos:p}},r={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(o,s,a)=>{if(a===H.APPLY_TYPE.COPY||a===H.APPLY_TYPE.ONLY_FORMAT||a===H.APPLY_TYPE.SERIES){const{source:m,target:d}=o;return n(m,d)}return i()}};this.disposeWithMe(this._autoFillService.addHook(r))}};Ve=Nn([ve(0,l.Inject(l.Injector)),ve(1,l.Inject(l.IUniverInstanceService)),ve(2,l.Inject(H.IAutoFillService)),ve(3,l.Inject(t.ConditionalFormattingRuleModel)),ve(4,l.Inject(t.ConditionalFormattingViewModel))],Ve);var En=Object.getOwnPropertyDescriptor,jn=(i,e,n,r)=>{for(var o=r>1?void 0:r?En(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},ct=(i,e)=>(n,r)=>e(n,r,i);let Oe=class extends l.Disposable{constructor(i,e){super(),this._sheetInterceptorService=i,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(l.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(i,e,n)=>{var a,m,d;i||n(i);const r=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),o=(a=r==null?void 0:r.style)!=null?a:{},s=Object.keys(o);if(i!=null&&i.p)return(d=(m=i.p.body)==null?void 0:m.textRuns)==null||d.forEach(p=>{p.ts&&s.forEach(c=>{var h;(h=p.ts)==null||delete h[c]})}),n(i);{const p={...(typeof(i==null?void 0:i.s)=="string"?e.workbook.getStyles().get(i.s):i==null?void 0:i.s)||{}};s.forEach(h=>{delete p[h]});const c={...i,s:{...p}};return n(c)}}})))}};Oe=jn([ct(0,l.Inject(U.SheetInterceptorService)),ct(1,l.Inject(t.ConditionalFormattingService))],Oe);const dt=[U.SetWorksheetActiveOperation.id,t.AddConditionalRuleMutation.id,t.SetConditionalRuleMutation.id,t.DeleteConditionalRuleMutation.id,t.MoveConditionalRuleMutation.id],pe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:z.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:z.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:z.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:z.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:z.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:z.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:z.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:z.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:z.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:z.clearWorkSheetRules}],Mn=i=>{const e=i.get(U.SheetsSelectionsService),n=i.get(l.ICommandService),r=i.get(l.IUniverInstanceService),o=i.get(t.ConditionalFormattingRuleModel),s=new K.Observable(d=>K.merge(e.selectionMoveEnd$,e.selectionSet$,new K.Observable(p=>{const c=n.onCommandExecuted(h=>{var y;const{id:g,params:b}=h,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&p.next(null)});return()=>c.dispose()})).pipe(ge.debounceTime(16)).subscribe(()=>{var y;const p=((y=e.getCurrentSelections())==null?void 0:y.map(_=>_.range))||[],c=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!c)return;const h=c.getActiveSheet();if(!h)return;const S=(o.getSubunitRules(c.getUnitId(),h.getSheetId())||[]).filter(_=>_.ranges.some(x=>p.some(w=>l.Rectangle.intersects(w,x)))).map(_=>_.ranges).every(_=>U.checkRangesEditablePermission(i,c.getUnitId(),h.getSheetId(),_));d.next(S)})),a=new K.Observable(d=>new K.Observable(p=>{const c=n.onCommandExecuted(h=>{var y;const{id:g,params:b}=h,S=(y=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:y.getUnitId();dt.includes(g)&&b.unitId===S&&p.next(null)});return()=>c.dispose()}).pipe(ge.debounceTime(16)).subscribe(()=>{const p=r.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET);if(!p)return;const c=p.getActiveSheet();if(!c)return;const h=o.getSubunitRules(p.getUnitId(),c.getSheetId())||[];if(!h.length)return d.next(!1),!1;const g=h.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(i,p.getUnitId(),c.getSheetId(),b));d.next(g)})),m=new K.Observable(d=>{s.subscribe(p=>{const c=pe.find(h=>h.value===z.clearRangeRules);c&&(c.disabled=!p,d.next(pe))}),a.subscribe(p=>{const c=pe.find(h=>h.value===z.clearWorkSheetRules);c&&(c.disabled=!p,d.next(pe))}),d.next(pe)});return{id:Re.id,type:P.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:m,hidden$:P.getMenuHiddenObservable(i,l.UniverInstanceType.UNIVER_SHEET),disabled$:H.getCurrentRangeDisable$(i,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Vn={[P.RibbonDataGroup.RULES]:{[Re.id]:{order:1,menuItemFactory:Mn}}};var On=Object.getOwnPropertyDescriptor,Un=(i,e,n,r)=>{for(var o=r>1?void 0:r?On(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},mt=(i,e)=>(n,r)=>e(n,r,i);let Ue=class extends l.Disposable{constructor(e,n){super();Q(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=n,this._menuManagerService.mergeMenu(Vn)}};Ue=Un([mt(0,l.Inject(l.Injector)),mt(1,P.IMenuManagerService)],Ue);var kn=Object.getOwnPropertyDescriptor,Pn=(i,e,n,r)=>{for(var o=r>1?void 0:r?kn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},le=(i,e)=>(n,r)=>e(n,r,i);const Dn=(i,e)=>{const n=c=>c.endRow-c.startRow+1,r=c=>c.endColumn-c.startColumn+1,o=n(e)%n(i),s=r(e)%r(i),a=Math.floor(n(e)/n(i)),m=Math.floor(r(e)/r(i)),d=[],p={startRow:0,endRow:n(i)-1,startColumn:0,endColumn:r(i)-1};if(n(e)===1&&r(e)===1){const c={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:p,startRange:c}),d}for(let c=0;c<a+(o?.1:0);c++)for(let h=0;h<m+(s?.1:0);h++){const g=n(i)*c,b=r(i)*h,S={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let y=p;c===a&&o&&(y={...y},y.endRow=y.endRow-(n(i)-o)),h===m&&s&&(y={...y},y.endColumn=y.endColumn-(r(i)-s)),d.push({repeatRelativeRange:y,startRange:S})}return d};let ke=class extends l.Disposable{constructor(e,n,r,o,s,a){super();Q(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=n,this._formatPainterService=r,this._sheetsSelectionsService=o,this._conditionalFormattingRuleModel=s,this._conditionalFormattingViewModel=a,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),n=(s,a,m,d,p)=>{const{unitId:c,subUnitId:h}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=p,S={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row},y={startRow:a.row,startColumn:a.col,endColumn:a.col,endRow:a.row};l.Range.foreach(m,(_,x)=>{const w=l.Rectangle.getPositionRange({startRow:_,startColumn:x,endColumn:x,endRow:_},S),E=l.Rectangle.getPositionRange({startRow:_,startColumn:x,endColumn:x,endRow:_},y),N=this._conditionalFormattingViewModel.getCellCfs(c,h,w.startRow,w.startColumn),v=this._conditionalFormattingViewModel.getCellCfs(g,b,E.startRow,E.startColumn);v&&v.forEach(T=>{let R=d.get(T.cfId);if(!d.get(T.cfId)){const I=this._conditionalFormattingRuleModel.getRule(g,b,T.cfId);if(!I)return;R=new l.ObjectMatrix,I.ranges.forEach(V=>{l.Range.foreach(V,(j,O)=>{R.setValue(j,O,1)})}),d.set(T.cfId,R)}R.realDeleteValue(E.startRow,E.startColumn)}),N&&N.forEach(T=>{const R=d.get(T.cfId);R&&R.setValue(E.startRow,E.startColumn,1)})})},r=(s,a,m)=>{var w;const{range:d,unitId:p,subUnitId:c}=this._painterConfig,h=s!==p||c!==a,g=new Map,b=[],S=[];if(!s||!a||!p||!c)return e();const y=(w=this._conditionalFormattingRuleModel.getSubunitRules(p,c))!=null?w:[];y==null||y.forEach(E=>{const{ranges:N,cfId:v}=E;if(N.some(T=>l.Rectangle.intersects(d,T))){const T=new l.ObjectMatrix;h||N.forEach(R=>{l.Range.foreach(R,(I,V)=>{T.setValue(I,V,1)})}),g.set(v,T)}});const _={row:d.startRow,col:d.startColumn};return Dn(d,m).forEach(E=>{n(_,{row:E.startRange.startRow,col:E.startRange.startColumn},E.repeatRelativeRange,g,{targetUnitId:s,targetSubUnitId:a})}),g.forEach((E,N)=>{if(h){const v=this._conditionalFormattingRuleModel.getRule(s,a,N),T=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(v)if(T.length){const R={unitId:s,subUnitId:a,rule:{...v,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:s,subUnitId:a,cfId:v.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}else if(T.length){const R=this._conditionalFormattingRuleModel.getRule(p,c,N);if(R){const I={unitId:s,subUnitId:a,rule:{...l.Tools.deepClone(R),cfId:this._conditionalFormattingRuleModel.createCfId(s,a),ranges:T}};b.push({id:t.AddConditionalRuleMutation.id,params:I}),S.push(t.AddConditionalRuleMutationUndoFactory(this._injector,I))}}}else{const v=this._conditionalFormattingRuleModel.getRule(p,c,N);if(!v)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(E));if(T.length){const R={unitId:p,subUnitId:c,rule:{...v,ranges:T}};b.push({id:t.SetConditionalRuleMutation.id,params:R}),S.push(...t.setConditionalRuleMutationUndoFactory(this._injector,R))}else{const R={unitId:p,subUnitId:c,cfId:v.cfId};b.push({id:t.DeleteConditionalRuleMutation.id,params:R}),S.push(...t.DeleteConditionalRuleMutationUndoFactory(this._injector,R))}}}),{undos:S,redos:b}},o={id:t.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:s=>{var a,m,d;switch(s){case H.FormatPainterStatus.INFINITE:case H.FormatPainterStatus.ONCE:{const p=(a=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:a.getUnitId(),c=(d=(m=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getActiveSheet())==null?void 0:d.getSheetId(),h=this._sheetsSelectionsService.getCurrentLastSelection(),g=h==null?void 0:h.range;p&&c&&g&&(this._painterConfig={unitId:p,subUnitId:c,range:g});break}case H.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(s,a,m)=>this._painterConfig?r(s,a,m):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};ke=Pn([le(0,l.Inject(l.Injector)),le(1,l.Inject(l.IUniverInstanceService)),le(2,l.Inject(H.IFormatPainterService)),le(3,l.Inject(U.SheetsSelectionsService)),le(4,l.Inject(t.ConditionalFormattingRuleModel)),le(5,l.Inject(t.ConditionalFormattingViewModel))],ke);var Ln=Object.getOwnPropertyDescriptor,An=(i,e,n,r)=>{for(var o=r>1?void 0:r?Ln(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},Be=(i,e)=>(n,r)=>e(n,r,i);let Pe=class extends l.Disposable{constructor(i,e,n){super(),this._conditionalFormattingViewModel=i,this._univerInstanceService=e,this._renderManagerService=n,this._init()}_init(){const i=this._univerInstanceService.getCurrentUnitForType(l.UniverInstanceType.UNIVER_SHEET),e=n=>{const r=n.getUnitId(),o=this._renderManagerService.getRenderById(r);if(!o)return;const s=o.with(H.SheetSkeletonManagerService);this.disposeWithMe(s.currentSkeleton$.subscribe(a=>{if(a){const m=a.skeleton.rowColumnSegment,d=m.endColumn-m.startColumn+1,c=(m.endRow-m.startRow+1)*d*9,h=Math.max(t.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,c);this._conditionalFormattingViewModel.setCacheLength(h)}}))};i&&e(i),this._univerInstanceService.getCurrentTypeOfUnit$(l.UniverInstanceType.UNIVER_SHEET).subscribe(n=>{n&&e(n)})}};Pe=An([Be(0,l.Inject(t.ConditionalFormattingViewModel)),Be(1,l.IUniverInstanceService),Be(2,vt.IRenderManagerService)],Pe);var $n=Object.defineProperty,Bn=Object.getOwnPropertyDescriptor,Hn=(i,e,n)=>e in i?$n(i,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):i[e]=n,Wn=(i,e,n,r)=>{for(var o=r>1?void 0:r?Bn(e,n):e,s=i.length-1,a;s>=0;s--)(a=i[s])&&(o=a(o)||o);return o},He=(i,e)=>(n,r)=>e(n,r,i),_t=(i,e,n)=>Hn(i,typeof e!="symbol"?e+"":e,n);exports.UniverSheetsConditionalFormattingUIPlugin=class extends l.Plugin{constructor(e=Me,n,r,o){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=o;const{menu:s,...a}=l.merge({},Me,this._config);s&&this._configService.setConfig("menu",s,{merge:!0}),this._configService.setConfig(Rt,a),this._initCommand()}onStarting(){l.registerDependencies(this._injector,[[Ie],[ye],[Ve],[be],[fe],[Ue],[ue],[Oe],[exports.ConditionalFormattingClearController],[ke],[Pe],[Ce]]),l.touchDependencies(this._injector,[[Ie],[Ce]])}onReady(){l.touchDependencies(this._injector,[[Ue],[fe]])}onRendered(){l.touchDependencies(this._injector,[[Ve],[exports.ConditionalFormattingClearController],[ye],[Oe],[ue],[ke],[be],[Pe]])}_initCommand(){[qe,Ge,Ze,ze,Ye,Ke,Xe,Je,Qe,Re].forEach(e=>{this._commandService.registerCommand(e)})}};_t(exports.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${t.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`);_t(exports.UniverSheetsConditionalFormattingUIPlugin,"type",l.UniverInstanceType.UNIVER_SHEET);exports.UniverSheetsConditionalFormattingUIPlugin=Wn([l.DependentOn(t.UniverSheetsConditionalFormattingPlugin,ht.UniverSheetsFormulaPlugin),He(1,l.Inject(l.Injector)),He(2,l.Inject(l.ICommandService)),He(3,l.IConfigService)],exports.UniverSheetsConditionalFormattingUIPlugin);exports.AddAverageCfCommand=qe;exports.AddColorScaleConditionalRuleCommand=Ge;exports.AddDataBarConditionalRuleCommand=Ze;exports.AddDuplicateValuesCfCommand=ze;exports.AddNumberCfCommand=Ye;exports.AddRankCfCommand=Ke;exports.AddTextCfCommand=Xe;exports.AddTimePeriodCfCommand=Je;exports.AddUniqueValuesCfCommand=Qe;exports.OpenConditionalFormattingOperator=Re;
|
package/lib/es/index.js
CHANGED
|
@@ -1857,7 +1857,7 @@ const ke = (n) => {
|
|
|
1857
1857
|
children: /* @__PURE__ */ c(
|
|
1858
1858
|
"a",
|
|
1859
1859
|
{
|
|
1860
|
-
className: "univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
1860
|
+
className: "univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
1861
1861
|
children: u.list.map((l, m) => /* @__PURE__ */ c(
|
|
1862
1862
|
"img",
|
|
1863
1863
|
{
|
package/lib/index.js
CHANGED
|
@@ -1857,7 +1857,7 @@ const ke = (n) => {
|
|
|
1857
1857
|
children: /* @__PURE__ */ c(
|
|
1858
1858
|
"a",
|
|
1859
1859
|
{
|
|
1860
|
-
className: "univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
1860
|
+
className: "univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",
|
|
1861
1861
|
children: u.list.map((l, m) => /* @__PURE__ */ c(
|
|
1862
1862
|
"img",
|
|
1863
1863
|
{
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(D,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/sheets-formula"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-conditional-formatting","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/sheets-formula","@univerjs/engine-render","rxjs/operators"],i):(D=typeof globalThis<"u"?globalThis:D||self,i(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheets,D.UniverSheetsConditionalFormatting,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverSheetsFormula,D.UniverEngineRender,D.rxjs.operators))})(this,(function(D,i,U,r,j,c,C,O,Ae,ve,W,X,nr,lr,pe){"use strict";var Ht=Object.defineProperty;var Wt=(D,i,U)=>i in D?Ht(D,i,{enumerable:!0,configurable:!0,writable:!0,value:U}):D[i]=U;var ee=(D,i,U)=>Wt(D,typeof i!="symbol"?i+"":i,U);const $e={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u}=e,s=a.get(r.ConditionalFormattingRuleModel),v=a.get(i.ICommandService),d=a.get(i.IUniverInstanceService),h=U.getSheetCommandTarget(d);if(!h)return!1;const{unitId:o,subUnitId:p}=h,g=s.createCfId(o,p),b={ranges:t,cfId:g,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:n}};return v.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:b})}},Fe={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,config:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),s=a.get(i.ICommandService),v=a.get(i.IUniverInstanceService),d=U.getSheetCommandTarget(v);if(!d)return!1;const{unitId:h,subUnitId:o}=d,p=u.createCfId(h,o),g={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.colorScale,config:n}};return s.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:o,rule:g})}},Be={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,min:n,max:l,nativeColor:u,positiveColor:s,isGradient:v,stopIfTrue:d,isShowValue:h}=e,o=a.get(r.ConditionalFormattingRuleModel),p=a.get(i.IUniverInstanceService),g=U.getSheetCommandTarget(p);if(!g)return!1;const{unitId:b,subUnitId:I}=g,m=a.get(i.ICommandService),N=o.createCfId(b,I),_={ranges:t,cfId:N,stopIfTrue:!!d,rule:{type:r.CFRuleType.dataBar,isShowValue:h,config:{min:n,max:l,nativeColor:u,positiveColor:s,isGradient:v}}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:b,subUnitId:I,rule:_})}},He={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),s=a.get(i.ICommandService),v=a.get(i.IUniverInstanceService),d=U.getSheetCommandTarget(v);if(!d)return!1;const{unitId:h,subUnitId:o}=d,p=u.createCfId(h,o),g={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return s.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:o,rule:g})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u,value:s}=e,v=a.get(r.ConditionalFormattingRuleModel),d=a.get(i.ICommandService),h=a.get(i.IUniverInstanceService),o=U.getSheetCommandTarget(h);if(!o)return!1;const{unitId:p,subUnitId:g}=o,b=v.createCfId(p,g);let I;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const m=s;if(m.length!==2||!Array.isArray(m))return!1;I={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:m}}}else{const m=s;if(typeof m!="number")return!1;I={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:m}}}return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:g,rule:I})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,isPercent:u,isBottom:s,value:v}=e,d=a.get(r.ConditionalFormattingRuleModel),h=a.get(i.IUniverInstanceService),o=a.get(i.ICommandService),p=U.getSheetCommandTarget(h);if(!p)return!1;const{unitId:g,subUnitId:b}=p,I=d.createCfId(g,b),m={ranges:t,cfId:I,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:s,style:n,value:v}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:m})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u,value:s}=e,v=a.get(r.ConditionalFormattingRuleModel),d=a.get(i.IUniverInstanceService),h=U.getSheetCommandTarget(d);if(!h)return!1;const{unitId:o,subUnitId:p}=h,g=a.get(i.ICommandService),b=v.createCfId(o,p),I={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:n,value:s}};return g.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:I})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u}=e,s=a.get(r.ConditionalFormattingRuleModel),v=a.get(i.IUniverInstanceService),d=a.get(i.ICommandService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:o,subUnitId:p}=h,g=s.createCfId(o,p),b={ranges:t,cfId:g,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:n}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:b})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),s=a.get(i.IUniverInstanceService),v=a.get(i.ICommandService),d=U.getSheetCommandTarget(s);if(!d)return!1;const{unitId:h,subUnitId:o}=d,p=u.createCfId(h,o),g={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return v.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:o,rule:g})}};function K({ref:a,...e}){const{icon:t,id:n,className:l,extend:u,...s}=e,v=`univerjs-icon univerjs-icon-${n} ${l||""}`.trim(),d=C.useRef(`_${Vr()}`);return ar(t,`${n}`,{defIds:t.defIds,idSuffix:d.current},{ref:a,className:v,...s},u)}function ar(a,e,t,n,l){return C.createElement(a.tag,{key:e,...Rr(a,t,l),...n},(Mr(a,t).children||[]).map((u,s)=>ar(u,`${e}-${a.tag}-${s}`,t,void 0,l)))}function Rr(a,e,t){const n={...a.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),a.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([u,s])=>{u==="mask"&&typeof s=="string"&&(n[u]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:l}=e;return!l||l.length===0||(a.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([u,s])=>{typeof s=="string"&&(n[u]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function Mr(a,e){var n;const{defIds:t}=e;return!t||t.length===0?a:a.tag==="defs"&&((n=a.children)!=null&&n.length)?{...a,children:a.children.map(l=>typeof l.attrs.id=="string"&&t&&t.includes(l.attrs.id)?{...l,attrs:{...l.attrs,id:l.attrs.id+e.idSuffix}}:l)}:a}function Vr(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";const Or={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ur=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"bold-icon",ref:t,icon:Or}))});ur.displayName="BoldIcon";const Ur={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ne=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"delete-icon",ref:t,icon:Ur}))});Ne.displayName="DeleteIcon";const kr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},sr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"increase-icon",ref:t,icon:kr}))});sr.displayName="IncreaseIcon";const Pr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},ir=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"italic-icon",ref:t,icon:Pr}))});ir.displayName="ItalicIcon";const Dr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ye=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Dr}))});Ye.displayName="MoreDownIcon";const Lr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},cr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Lr}))});cr.displayName="SequenceIcon";const jr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},or=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"strikethrough-icon",ref:t,icon:jr}))});or.displayName="StrikethroughIcon";const Ar={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},dr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"underline-icon",ref:t,icon:Ar}))});dr.displayName="UnderlineIcon";const $r={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},vr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"font-color-double-icon",ref:t,icon:$r}))});vr.displayName="FontColorDoubleIcon";const Fr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},pr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"paint-bucket-double-icon",ref:t,icon:Fr}))});pr.displayName="PaintBucketDoubleIcon";const Br={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fe=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"slash-double-icon",ref:t,icon:Br}))});fe.displayName="SlashDoubleIcon";const re=a=>{const{color:e,onChange:t,disable:n=!1,Icon:l=pr,className:u}=a,s=C.useMemo(()=>new i.ColorKit(e),[e]),v=()=>{const d={className:O.clsx("univer-fill-primary-600",n&&u),extend:{colorChannel1:s.isValid?e:""}};return c.jsx(l,{...d})};return n?v():c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(O.ColorPicker,{value:e,onChange:t})}),children:c.jsx("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",u),children:v()})})},ae=a=>{var u,s,v,d,h;const e=a.rule;if(!e)return null;const t=C.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const o=e.config.map((b,I)=>({color:new i.ColorKit(b.color),value:I})),p=o.length-1;return new Array(5).fill("").map((b,I,m)=>I*p/(m.length-1)).map(b=>r.getColorScaleFromValue(o,b))}return null},[e]),n=C.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(o=>{const p=r.iconMap[o.iconType];return p&&p[Number(o.iconId)]})},[e]),l="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:o}=e.config,p=o?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return c.jsxs("div",{className:l,children:[c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(u=e.config.nativeColor)!=null?u:r.defaultDataBarNativeColor}}),c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:p,borderColor:(s=e.config.positiveColor)!=null?s:r.defaultDataBarPositiveColor}})]})}case r.CFRuleType.colorScale:return t&&c.jsx("div",{className:l,children:t.map((o,p)=>c.jsx("div",{className:"univer-h-full",style:{width:`${100/t.length}%`,background:o}},p))});case r.CFRuleType.iconSet:return n&&c.jsx("div",{className:l,children:n.map((o,p)=>o?c.jsx("img",{className:"univer-h-full",src:o,draggable:!1},p):c.jsx(fe,{},p))});case r.CFRuleType.highlightCell:{const{ul:o,st:p,it:g,bl:b,bg:I,cl:m}=e.style,N=(o==null?void 0:o.s)===i.BooleanNumber.TRUE,_=(p==null?void 0:p.s)===i.BooleanNumber.TRUE,E=g===i.BooleanNumber.TRUE,M=b===i.BooleanNumber.TRUE,R=(v=I==null?void 0:I.rgb)!=null?v:r.DEFAULT_BG_COLOR,f=(d=m==null?void 0:m.rgb)!=null?d:r.DEFAULT_FONT_COLOR,T={textDecoration:(h=`${N?"underline":""} ${_?"line-through":""}`.replace(/^ /,""))!=null?h:void 0,backgroundColor:R,color:f};return c.jsx("div",{className:O.clsx(l,{"univer-font-bold":M,"univer-italic":E}),style:T,children:"123"})}}},he=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(a,e)=>({label:e.t(`sheet.cf.valueType.${a}`),value:a}),Ke=a=>{var I;const{type:e,className:t,onChange:n,id:l,value:u}=a,s=j.useDependency(i.IUniverInstanceService),v=s.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(I=s.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:I.getSheetId(),h=C.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),o=C.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),p=C.useRef(null),[g,b]=C.useState(!1);return j.useSidebarClick(m=>{var _;(_=p.current)!=null&&_.isClickOutSide(m)&&b(!1)}),e===r.CFValueType.formula?c.jsx("div",{className:"univer-ml-1 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:p,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:h,unitId:v,subUnitId:d,isFocus:g,onChange:(m="")=>{n(m||"")},onFocus:()=>b(!0)})}):c.jsx(O.InputNumber,{className:t,value:Number(a.value)||0,onChange:m=>a.onChange(m||0),...o})},Hr=a=>{var L;const{interceptorManager:e}=a,t=j.useDependency(i.LocaleService),n=((L=a.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?a.rule:void 0,l=[te(r.CFValueType.num,t),te(r.CFValueType.percent,t),te(r.CFValueType.percentile,t),te(r.CFValueType.formula,t)],u=[te(r.CFValueType.min,t),...l],s=[te("none",t),...l],v=[te(r.CFValueType.max,t),...l],[d,h]=C.useState(()=>{var x;const y=r.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||y}),[o,p]=C.useState(()=>{var x;const y="none";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.value.type)||y}),[g,b]=C.useState(()=>{var x;const y=r.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||y}),[I,m]=C.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[N,_]=C.useState(()=>{var $;if(!n||n.config.length!==3)return 50;const x=($=n.config[1])==null?void 0:$.value.value;return x===void 0?50:x}),[E,M]=C.useState(()=>{var $;if(!n)return 90;const x=($=n.config[n.config.length-1])==null?void 0:$.value.value;return x===void 0?90:x}),[R,f]=C.useState(()=>{var x;const y="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||y}),[T,w]=C.useState(()=>{var x;const y="#7790f3";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.color)||y}),[S,k]=C.useState(()=>{var x;const y="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||y}),V=C.useMemo(()=>y=>{const{minType:x,medianType:$,maxType:G,minValue:J,medianValue:Q,maxValue:oe,minColor:de,medianColor:A,maxColor:F}=y,H=[];return H.push({color:de,value:{type:x,value:J}}),$!=="none"&&H.push({color:A,value:{type:$,value:Q}}),H.push({color:F,value:{type:G,value:oe}}),{config:H.map((Z,z)=>({...Z,index:z})),type:r.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),[V,d,o,g,I,N,E,R,T,S,e]);const P=y=>{a.onChange(V(y))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:V({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})})}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:y=>{h(y);const x=r.createDefaultValueByValueType(y,10);m(x),P({minType:y,medianType:o,maxType:g,minValue:x,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(Ke,{id:"min",className:"univer-ml-1",value:I,type:d,onChange:y=>{m(y),P({minType:d,medianType:o,maxType:g,minValue:y,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(re,{className:"univer-ml-1",color:R,onChange:y=>{f(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:y,medianColor:T,maxColor:S})}})]}),c.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:t.t("sheet.cf.panel.medianValue")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:s,value:o,onChange:y=>{p(y);const x=r.createDefaultValueByValueType(y,50);_(x),P({minType:d,medianType:y,maxType:g,minValue:I,medianValue:x,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(Ke,{id:"median",className:"univer-ml-1",value:N,type:o,onChange:y=>{_(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:y,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),o!=="none"&&c.jsx(re,{className:"univer-ml-1",color:T,onChange:y=>{w(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:y,maxColor:S})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:v,value:g,onChange:y=>{b(y);const x=r.createDefaultValueByValueType(y,90);M(x),P({minType:d,medianType:o,maxType:y,minValue:I,medianValue:N,maxValue:x,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(Ke,{id:"max",className:"univer-ml-1",value:E,type:g,onChange:y=>{M(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:y,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(re,{className:"univer-ml-1",color:S,onChange:y=>{k(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:y})}})]})]})},ue=(a,e)=>({label:e.t(`sheet.cf.valueType.${a}`),value:a}),fr=a=>{var m;const{onChange:e,className:t,value:n,type:l,id:u,disabled:s=!1}=a,v=j.useDependency(i.IUniverInstanceService),d=v.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(m=v.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),o=C.useRef(null),[p,g]=C.useState(!1);j.useSidebarClick(N=>{var E;(E=o.current)!=null&&E.isClickOutSide(N)&&g(!1)});const b=C.useRef(n),I=C.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(l)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[l]);if(l===r.CFValueType.formula){const N=String(b.current).startsWith("=")?String(b.current)||"":"=";return c.jsx("div",{className:"univer-ml-3 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:o,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:N,unitId:d,subUnitId:h,isFocus:p,onChange:(_="")=>{e(_||"")},onFocus:()=>g(!0)})})}return c.jsx(O.InputNumber,{className:t,value:Number(n)||0,disabled:s,onChange:N=>{e(N||0)},...I})},Wr=a=>{var L;const{interceptorManager:e}=a,t=j.useDependency(i.LocaleService),n=((L=a.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?a.rule:void 0,[l,u]=C.useState(()=>{var x;return n&&(x=n.config)!=null&&x.isGradient?"1":"0"}),[s,v]=C.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[d,h]=C.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),o=[ue(r.CFValueType.num,t),ue(r.CFValueType.percent,t),ue(r.CFValueType.percentile,t),ue(r.CFValueType.formula,t)],p=[ue(r.CFValueType.min,t),...o],g=[ue(r.CFValueType.max,t),...o],[b,I]=C.useState(()=>{var x;const y=p[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||y}),[m,N]=C.useState(()=>{var x;const y=g[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||y}),[_,E]=C.useState(()=>{var $;if(!n)return 0;const x=(($=n.config)==null?void 0:$.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[M,R]=C.useState(()=>{var $;if(!n)return 100;const x=(($=n.config)==null?void 0:$.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[f,T]=C.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),w=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return w({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}}),[l,_,b,M,m,s,d,e,f]);const S=y=>{a.onChange(w(y))},k=y=>{v(y),S({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:y,nativeColor:d,isShowValue:f})},V=y=>{h(y),S({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:y,isShowValue:f})},P=y=>o.map(x=>x.value).includes(y);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:w({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})})}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.fillType")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs(O.RadioGroup,{value:l,onChange:y=>{u(y),S({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})},children:[c.jsx(O.Radio,{value:"0",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.pureColor")})}),c.jsx(O.Radio,{value:"1",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.gradient")})})]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!f,onChange:y=>{T(!y),S({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:!y})}}),t.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.colorSet")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.native")}),c.jsx(re,{color:d,onChange:V})]}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.positive")}),c.jsx(re,{color:s,onChange:k})]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:b,onChange:y=>{I(y);const x=r.createDefaultValueByValueType(y,10);E(x),S({isGradient:l,minValue:x,minValueType:y,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}}),c.jsx(fr,{id:"min",className:"univer-ml-3",disabled:!P(b),type:b,value:_,onChange:y=>{E(y||0),S({isGradient:l,minValue:y||0,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:m,onChange:y=>{N(y);const x=r.createDefaultValueByValueType(y,90);R(x),S({isGradient:l,minValue:_,minValueType:b,maxValue:x,maxValueType:y,positiveColor:s,nativeColor:d,isShowValue:f})}}),c.jsx(fr,{className:"univer-ml-3",disabled:!P(m),id:"max",type:m,value:M,onChange:y=>{R(y||0),S({isGradient:l,minValue:_,minValueType:b,maxValue:y||0,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}})]})]})]})},Ee=a=>[i.BooleanNumber.FALSE,void 0].includes(a)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Re=a=>a!==i.BooleanNumber.FALSE,Xe=a=>{const{style:e,onChange:t,className:n}=a,[l,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[s,v]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[d,h]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[o,p]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[g,b]=C.useState(()=>{var E;const _="#2f56ef";return(E=e==null?void 0:e.cl)!=null&&E.rgb?e.cl.rgb:_}),[I,m]=C.useState(()=>{var E;const _="#e8ecfc";return(E=e==null?void 0:e.bg)!=null&&E.rgb?e.bg.rgb:_});C.useEffect(()=>{const _={bl:l,it:s};g!==void 0&&(_.cl={rgb:g}),I!==void 0&&(_.bg={rgb:I}),o!==void 0&&(_.st={s:o}),d!==void 0&&(_.ul={s:d}),t(r.removeUndefinedAttr(_))},[l,s,d,o,g,I]);const N="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return c.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(l||i.BooleanNumber.FALSE)}),onClick:()=>u(Ee(l)),children:c.jsx(ur,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(s||i.BooleanNumber.FALSE)}),onClick:()=>v(Ee(s)),children:c.jsx(ir,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(d||i.BooleanNumber.FALSE)}),onClick:()=>h(Ee(d)),children:c.jsx(dr,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(o||i.BooleanNumber.FALSE)}),onClick:()=>p(Ee(o)),children:c.jsx(or,{})}),c.jsx(re,{color:g,onChange:b,Icon:vr}),c.jsx(re,{color:I,onChange:m})]})},qr=a=>{var R;const{onChange:e,interceptorManager:t}=a,n=j.useDependency(i.LocaleService),u=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),s=u.getActiveSheet(),v=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?a.rule:void 0,d=C.useRef(null),[h,o]=C.useState(!1),p=C.useRef(null),[g,b]=C.useState({}),[I,m]=C.useState(()=>(v==null?void 0:v.subType)===r.CFSubRuleType.formula?v.value:"="),[N,_]=C.useState(void 0),E=f=>({style:f.style,value:I,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return E({style:g})}}),[g,I,t]),C.useEffect(()=>t.intercept(t.getInterceptPoints().beforeSubmit,{handler:(T,w,S)=>N||I.length===1||!I.startsWith("=")?(_(n.t("sheet.cf.errorMessage.formulaError")),!1):S(T)}),[N,I]);const M=f=>{e(E(f))};return j.useSidebarClick(f=>{var w;(w=p.current)!=null&&w.isClickOutSide(f)&&o(!1)}),c.jsxs("div",{ref:d,children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(ve.FormulaEditor,{ref:p,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),errorText:N,isFocus:h,initValue:I,unitId:u.getUnitId(),subUnitId:s==null?void 0:s.getSheetId(),onFocus:()=>{o(!0)},onChange:f=>{m(f),M({style:g})},onVerify:(f,T)=>{!f||T.length===1?_(n.t("sheet.cf.errorMessage.formulaError")):_(void 0)}})}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:E({style:g})})}),c.jsx(Xe,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:f=>{b(f),M({style:f})}})]})},Me=a=>c.jsxs("div",{className:"univer-relative",children:[c.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:a.errorText}),a.children]}),B=(a,e)=>({label:e.t(`sheet.cf.operator.${a}`),value:a}),Gr=a=>{const{type:e,operator:t,onChange:n,value:l,interceptorManager:u}=a,s=j.useDependency(i.LocaleService),[v,d]=C.useState(()=>typeof l=="number"?l:0),[h,o]=C.useState(""),[p,g]=C.useState(()=>typeof l=="string"?l:""),[b,I]=C.useState(""),[m,N]=C.useState(()=>Array.isArray(l)?l[0]===void 0?0:l[0]:0),[_,E]=C.useState(""),[M,R]=C.useState(()=>Array.isArray(l)?l[1]===void 0?100:l[1]:100),[f,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)&&n(p);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)&&n(v),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)&&n([m,M]);break}}},[e]),C.useEffect(()=>{const w=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(S,k,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(t))return p?V(S):(I(s.t("sheet.cf.errorMessage.notBlank")),!1)}return V(S)}});return()=>{w()}},[e,v,p,t]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)){const w=S=>{g(S),n(S)};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:b,children:c.jsx(O.Input,{value:p,onChange:S=>{I(""),w(S)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)){const w=S=>{d(S||0),n(S||0),o("")};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:h,children:c.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:w})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)){const w=k=>{N(k||0),n([k||0,M]),E("")},S=k=>{R(k||0),n([m,k||0]),T("")};return c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(Me,{errorText:_,children:c.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:w})}),c.jsx(Me,{errorText:f,children:c.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:M,onChange:S})})]})}}}return null},hr=(a,e)=>{switch(a){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},gr=a=>{var R;const{interceptorManager:e,onChange:t}=a,n=j.useDependency(i.LocaleService),l=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?a.rule:void 0,[u,s]=C.useState(()=>{const f=r.CFSubRuleType.text;return l&&l.subType||f}),v=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],d=C.useMemo(()=>hr(u,n),[u]),[h,o]=C.useState(()=>{const f=d?d[0].value:void 0;return l&&l.operator||f}),[p,g]=C.useState(()=>{var w;return l?(w=l.value)!=null?w:r.createDefaultValue(l.subType,l.operator):""}),[b,I]=C.useState({}),m=C.useMemo(()=>f=>{var T,w,S,k,V,P,L,y,x,$,G,J,Q,oe,de;switch(f.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(h))return{type:r.CFRuleType.highlightCell,subType:(T=f.subType)!=null?T:u,operator:(w=f.operator)!=null?w:h,style:(S=f.style)!=null?S:b,value:(k=f.value)!=null?k:p};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(h))return{type:r.CFRuleType.highlightCell,subType:(V=f.subType)!=null?V:u,operator:(P=f.operator)!=null?P:h,style:(L=f.style)!=null?L:b,value:(y=f.value)!=null?y:p};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(h))return{type:r.CFRuleType.highlightCell,subType:(x=f.subType)!=null?x:u,operator:($=f.operator)!=null?$:h,style:(G=f.style)!=null?G:b,value:(J=f.value)!=null?J:p};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=f.subType)!=null?Q:u,operator:(oe=f.operator)!=null?oe:h,style:(de=f.style)!=null?de:b}},[u,h,p,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return m({})}}),[m,e]),C.useEffect(()=>{v.some(f=>f.value===u)||s(v[0].value)},[v]);const N=f=>{const T=f,w=hr(T,n),S=w&&w[0].value;s(T),o(S),S&&g(r.createDefaultValue(T,S)),t(m({subType:T,operator:S}))},_=f=>{const T=f;o(T),t(m({operator:T}))},E=f=>{g(f),t(m({value:f}))},M=C.useMemo(()=>`${u}_${h}_${Math.random()}`,[u,h]);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:u,options:v}),(d==null?void 0:d.length)&&c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:h||"",options:d})]}),c.jsx(Gr,{value:p,interceptorManager:e,type:u,operator:h,rule:l,onChange:E},M),c.jsx("div",{className:he,children:c.jsx(ae,{rule:m({})})}),c.jsx(Xe,{style:l==null?void 0:l.style,className:"univer-ml-1",onChange:f=>{I(f),t(m({style:f}))}})]})},yr=(a,e)=>(r.iconMap[a]||[])[Number(e)]||"",Zr=a=>{var o;const{error:e,type:t,onChange:n}=a,l=j.useDependency(i.IUniverInstanceService),u=l.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=(o=l.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId(),v=C.useRef(null),[d,h]=C.useState(!1);return j.useSidebarClick(p=>{var b;(b=v.current)!=null&&b.isClickOutSide(p)&&h(!1)}),c.jsx("div",{className:"univer-relative",children:t!==r.CFValueType.formula?c.jsxs(c.Fragment,{children:[c.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(a.value)||0,onChange:p=>n(p!=null?p:0)}),e&&c.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):c.jsx("div",{className:"univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:String(a.value),unitId:u,subUnitId:s,isFocus:d,onChange:(p="")=>{n(p||"")},onFocus:()=>h(!0)})})})},Cr=(a,e,t)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(t.length-1-e)*10},iconType:a,iconId:String(e)}),zr=C.forwardRef((a,e)=>{const{onClick:t}=a,n=j.useDependency(i.LocaleService),l=u=>{t(u)};return c.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,s)=>c.jsxs("div",{className:"univer-mb-3",children:[c.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(u.title)}),c.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(v=>c.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{l(v.name)},children:c.jsx("a",{className:"univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:v.list.map((d,h)=>c.jsx("img",{className:"univer-size-5",src:d,draggable:!1},h))})},v.name))})]},s))})}),Yr=a=>{const{onClick:e}=a,t=C.useMemo(()=>{const l=[];for(const u in r.iconMap){const s=r.iconMap[u],v=u;s.forEach((d,h)=>{l.push({iconType:v,base64:d,iconId:String(h)})})}return l},[]),n=l=>{e(l.iconType,l.iconId)};return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[c.jsx(fe,{className:"univer-size-5"}),c.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),c.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:t.map(l=>c.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:c.jsx("img",{className:"univer-size-5",src:l.base64,draggable:!1,onClick:()=>n(l)})},`${l.iconType}_${l.iconId}`))})]})},Kr=a=>{const{onChange:e,configList:t,errorMap:n={}}=a,l=j.useDependency(i.LocaleService),u=[{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],s=[{label:l.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:l.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],v=(p,g)=>{e([String(g),"value","value"],p)},d=(p,g)=>{e([String(g),"operator"],p);const b=r.createDefaultValue(r.CFSubRuleType.number,p);v(b,g)},h=(p,g)=>{e([String(g),"value","type"],p);const b=t[g],I=r.createDefaultValue(r.CFSubRuleType.number,b.operator);v(I,g)};return C.useMemo(()=>t.map((p,g)=>{const b=n[g],I=yr(p.iconType,p.iconId),m=g===t.length-1,N=g===0,_=t[g-1],E=(_==null?void 0:_.value.type)===r.CFValueType.formula?l.t("sheet.cf.valueType.formula"):_==null?void 0:_.value.value,M=(R,f)=>{const T={...p,iconId:f,iconType:R};e([String(g)],T)};return c.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsxs("div",{className:"univer-w-[45%]",children:[l.t("sheet.cf.iconSet.icon"),g+1]}),c.jsx("div",{className:"univer-w-[45%]",children:c.jsxs(c.Fragment,{children:[!N&&!m&&l.t("sheet.cf.iconSet.rule"),!N&&!m&&c.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),E,m?"":` ${l.t("sheet.cf.iconSet.and")} `]})]})})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx("div",{className:"univer-flex univer-items-center",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(Yr,{onClick:M,iconId:p.iconId,iconType:p.iconType})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",O.borderClassName),children:[I?c.jsx("img",{src:I,className:"univer-size-4",draggable:!1}):c.jsx(fe,{className:"univer-size-4"}),c.jsx(Ye,{})]})})}),m?c.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[l.t("sheet.cf.iconSet.rule"),c.jsxs("span",{className:"univer-font-medium",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),E,m?"":` ${l.t("sheet.cf.iconSet.and")} `]})]}):c.jsx(O.Select,{options:u,value:p.operator,onChange:R=>{d(R,g)}})]}),m?c.jsx("div",{}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsx("div",{children:l.t("sheet.cf.iconSet.type")}),c.jsx("div",{children:l.t("sheet.cf.iconSet.value")})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx(O.Select,{options:s,value:p.value.type,onChange:R=>{h(R,g)}}),c.jsx(Zr,{id:g,type:p.value.type,error:b,value:p.value.value||"",onChange:R=>{v(R,g)}})]})]})]},g)}),[t,n])},Xr=a=>{var R;const{interceptorManager:e}=a,t=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?a.rule:void 0,n=j.useDependency(i.LocaleService),[l,u]=C.useState({}),[s,v]=C.useState(()=>{const f=Object.keys(r.iconMap)[0];if(t&&t.config.length){const T=t.config[0].iconType;if(!t.config.some(S=>S.iconType!==T))return T}return f}),[d,h]=C.useState(()=>{if(t&&t.config.length)return i.Tools.deepClone(t==null?void 0:t.config);const f=r.iconMap[s]||[];return new Array(f.length).fill("").map((T,w,S)=>w===S.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:s,iconId:String(w)}:Cr(s,w,S))}),[o,p]=C.useState(()=>t?!!t.isShowValue:!0),g=C.useMemo(()=>{const f=d.map(T=>yr(T.iconType,T.iconId));return c.jsx("div",{className:"univer-flex univer-items-center",children:f.map((T,w)=>T?c.jsx("img",{className:"univer-size-5",src:T},w):c.jsx(fe,{className:"univer-size-5"},w))})},[d]),b=f=>{if(f.reduce((w,S,k)=>w.preType&&!w.result||f.length-1===k?w:S.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:w.preType?{result:w.preType===S.value.type,preType:S.value.type}:{result:!0,preType:S.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(f[0].value.type)){const w={};return f.forEach((S,k,V)=>{if(k-1<0||k===V.length-1)return;const L=f[k-1],y=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:y,value:L.value.value},S.value.value)||(w[k]=`${n.t(`sheet.cf.form.${y}`,String(L.value.value))} `)}),w}return{}},I=(f,T)=>{i.get(d,f)!==T&&(i.set(d,f,T),h([...d]),u(b(d)))},m=f=>{v(f);const T=r.iconMap[f]||[],w=new Array(T.length).fill("").map((S,k,V)=>Cr(f,k,V));h(w),u(b(w))};C.useEffect(()=>{const f=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:o,config:d}}});return()=>{f()}},[o,d,e]),C.useEffect(()=>{const f=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(l).length===0}});return()=>{f()}},[o,d,e,l]);const N=()=>{const f=d.map(T=>({...T}));d.forEach((T,w)=>{const S=d.length-1-w,k=f[S];T.iconId=k.iconId,T.iconType=k.iconType}),h([...d])},_=j.useDependency(j.ILayoutService),[E,M]=C.useState();return j.useScrollYOverContainer(E,_.rootContainerElement),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(zr,{ref:f=>{!E&&f&&M(f)},iconType:s,onClick:m})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[g,c.jsx(Ye,{})]})})}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{onChange:N}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!o,onChange:f=>{p(!f)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),c.jsx(Kr,{errorMap:l,onChange:I,configList:d})]})},Jr=a=>{var N;const{onChange:e,interceptorManager:t}=a,n=j.useDependency(i.LocaleService),l=((N=a.rule)==null?void 0:N.type)===r.CFRuleType.highlightCell?a.rule:void 0,u=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[s,v]=C.useState(()=>{const _=u[0].value,E=l==null?void 0:l.type;if(!l)return _;switch(E){case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(l.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l.operator)?"lessThanAverage":_;case r.CFSubRuleType.rank:return l.isBottom?"isBottom":"isNotBottom"}}return _}),[d,h]=C.useState(()=>{const E=l==null?void 0:l.type;if(!l)return 10;switch(E){case r.CFRuleType.highlightCell:if(l.subType===r.CFSubRuleType.rank)return l.value||10}return 10}),[o,p]=C.useState(()=>{const E=l==null?void 0:l.type;if(!l)return!1;switch(E){case r.CFRuleType.highlightCell:if(l.subType===r.CFSubRuleType.rank)return l.isPercent||!1}return!1}),[g,b]=C.useState({}),I=_=>{const{type:E,isPercent:M,value:R,style:f}=_;if(E==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!1,value:R,style:f};if(E==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!0,value:R,style:f};if(E==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:f};if(E==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:f}};C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return I({type:s,isPercent:o,value:d,style:g})}}),[s,o,d,g,t]);const m=_=>{e(I(_))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:s,options:u,onChange:_=>{v(_),m({type:_,isPercent:o,value:d,style:g})}}),["isNotBottom","isBottom"].includes(s)&&c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.InputNumber,{min:1,max:1e3,value:d,onChange:_=>{const E=_||0;h(E),m({type:s,isPercent:o,value:E,style:g})}}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:o,onChange:_=>{p(!!_),m({type:s,isPercent:!!_,value:d,style:g})}}),n.t("sheet.cf.valueType.percent")]})]}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:I({type:s,isPercent:o,value:d,style:g})})}),c.jsx(Xe,{style:l==null?void 0:l.style,className:"univer-mt-3",onChange:_=>{b(_),m({type:s,isPercent:o,value:d,style:_})}})]})},Qr=i.createInterceptorKey("beforeSubmit"),et=i.createInterceptorKey("submit"),mr=a=>a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),br=a=>{var e;return(e=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},rt=a=>{var w,S,k;const e=j.useDependency(i.LocaleService),t=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),l=j.useDependency(r.ConditionalFormattingRuleModel),u=j.useDependency(U.SheetsSelectionsService),s=mr(n),v=br(n),[d,h]=C.useState(void 0),o=C.useRef((S=(w=a.rule)==null?void 0:w.ranges)!=null?S:[]),p=C.useMemo(()=>{var P,L,y;let V=(P=a.rule)==null?void 0:P.ranges;return V!=null&&V.length||(V=(y=(L=u.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?y:[]),o.current=V,V!=null&&V.length?V.map(x=>{const $=Ae.serializeRange(x);return $==="NaN"?"":$}).filter(x=>!!x).join(","):""},[a.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,I]=C.useState(()=>{var L,y;const V=(L=a.rule)==null?void 0:L.rule.type,P=g[0].value;if(!V)return P;switch(V){case r.CFRuleType.highlightCell:{switch((y=a.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return P}),m=C.useRef(void 0),N=C.useMemo(()=>new i.InterceptorManager({beforeSubmit:Qr,submit:et}),[]),_=C.useMemo(()=>{switch(b){case"1":return gr;case"2":return Jr;case"3":return Wr;case"4":return Hr;case"5":return qr;case"6":return Xr;default:return gr}},[b]);C.useEffect(()=>{const V=t.onCommandExecuted(P=>{if(P.id===U.RemoveSheetMutation.id){const L=P.params;L.subUnitId===v&&L.unitId===s&&a.onCancel()}P.id===U.SetWorksheetActiveOperation.id&&a.onCancel()});return()=>V.dispose()},[]);const E=V=>{m.current=V},M=V=>{const P=V.split(",").filter(L=>!!L).map(Ae.deserializeRangeWithSheet).map(L=>L.range);o.current=P},R=()=>{if(d)return;const P=(()=>{const y=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return o.current.map(G=>U.setEndForRange(G,y.getRowCount(),y.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(N.fetchThroughInterceptors(N.getInterceptPoints().beforeSubmit)(!0,null)){const y=N.fetchThroughInterceptors(N.getInterceptPoints().submit)(null,null);if(y){const x=mr(n),$=br(n);if(!x||!$)throw new Error("No active sheet found");let G={};a.rule&&a.rule.cfId?(G={...a.rule,ranges:P,rule:y},t.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:$,rule:G}),a.onCancel()):(G={cfId:l.createCfId(x,$),ranges:P,rule:y,stopIfTrue:!1},t.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:$,rule:G}),a.onCancel())}}},f=()=>{a.onCancel()},T=(V,P)=>{V?P.length<1?h(e.t("sheet.cf.errorMessage.rangeError")):h(void 0):h(e.t("sheet.cf.errorMessage.rangeError"))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),c.jsxs("div",{className:"univer-mt-4",children:[c.jsx(ve.RangeSelector,{unitId:s,subUnitId:v,initialValue:p,onChange:(V,P)=>M(P),onVerify:T}),d&&c.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:d})]}),c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),c.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:V=>I(V)}),c.jsx(_,{interceptorManager:N,rule:(k=a.rule)==null?void 0:k.rule,onChange:E}),c.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[c.jsx(O.Button,{onClick:f,children:e.t("sheet.cf.panel.cancel")}),c.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var tt=Object.getOwnPropertyDescriptor,nt=(a,e,t,n)=>{for(var l=n>1?void 0:n?tt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},lt=(a,e)=>(t,n)=>e(t,n,a);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const t=/\{([^}]+)?\}/g,n=[];let l=t.exec(e);for(;l;)n.push({startIndex:l.index,key:Number(l[1]),endIndex:l.index+l[0].length-1}),l=t.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...t){const n=this._localeService.getLocales(),l=e.split("."),u=n&&this._localeService.resolveKeyPath(n,l);if(typeof u=="string"){const s=[];return this._findReplaceIndex(u).forEach((v,d,h)=>{const o=h[d-1]||{endIndex:-1};if(o.endIndex+1<v.startIndex){const p=u.slice(o.endIndex+1,v.startIndex);p&&s.push(p)}if(t[v.key]&&s.push(t[v.key]),d===h.length-1){const p=u.slice(v.endIndex+1);p&&s.push(p)}}),s}return[]}};se=nt([lt(0,i.Inject(i.LocaleService))],se);const at=(a,e)=>{const t=a.rule;switch(t.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(t.subType){case r.CFSubRuleType.average:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(t.value)?t.value.map(l=>String(l)):[String(t.value||"")])}case r.CFSubRuleType.text:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,t.value||"")}case r.CFSubRuleType.timePeriod:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return t.isPercent?t.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(t.value)):e.t("sheet.cf.preview.describe.topNPercent",String(t.value)):t.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(t.value)):e.t("sheet.cf.preview.describe.topN",String(t.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let Sr=0;const ut=a=>{const{onClick:e}=a,t=j.useDependency(r.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),l=j.useDependency(U.SheetsSelectionsService),u=j.useDependency(i.ICommandService),s=j.useDependency(i.LocaleService),v=j.useDependency(i.Injector),d=j.useDependency(j.ISidebarService),h=j.useDependency(se),o=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),p=o.getUnitId(),g=o.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[I,m]=C.useState([]),[N,_]=C.useState("2"),[E,M]=C.useState(0),[R,f]=C.useState(-1),[T,w]=C.useState(Sr),S=C.useRef(null),k=[{label:s.t("sheet.cf.panel.workSheet"),value:"2"},{label:s.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=t.getSubunitRules(p,b);if(!A||!A.length)return[];if(N==="1"){const F=l.getCurrentLastSelection();if(!F)return[];const H=F.range;return A.filter(Z=>Z.ranges.some(z=>i.Rectangle.intersects(z,H)))}else if(N==="2")return[...A];return[]},[P,L]=C.useState(V);W.useHighlightRange(I),C.useEffect(()=>{const A=u.onCommandExecuted(F=>{F.id===U.SetWorksheetActiveOperation.id&&M(Math.random())});return()=>A.dispose()}),C.useEffect(()=>{L(V)},[N,E,p,b]),C.useEffect(()=>{if(N==="2")return;const A=new X.Observable(F=>{const H=[U.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(Z=>{const{id:z,params:ne}=Z,le=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(z)&&ne.unitId===le&&F.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[n,N,p,b]),C.useEffect(()=>{const A=t.$ruleChange.subscribe(()=>{M(Math.random())});return()=>A.unsubscribe()},[t]),C.useEffect(()=>{const A=()=>{var Z,z;const q=Math.max(0,((z=(Z=S.current)==null?void 0:Z.getBoundingClientRect().width)!=null?z:0)-8);return Sr=q,q},H=new X.Observable(q=>{const Z=d.getContainer();if(Z){let z=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{z&&clearTimeout(z),z=null},le=je=>{je.propertyName==="width"&&(ne(),q.next(void 0))};return Z.addEventListener("transitionend",le),()=>{ne(),Z.removeEventListener("transitionend",le)}}}).pipe(X.debounceTime(16)).subscribe(()=>{w(A())});return()=>{H.unsubscribe()}},[]);const y=A=>{var q;const F=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!F||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:F,subUnitId:H,cfId:A.cfId})},x=(A,F)=>{f(F.y)},$=(A,F,H)=>{var je;f(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),Z=(je=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:je.getSheetId();if(!q||!Z)throw new Error("No active sheet found");const z=Ft=>{const Bt=P.length;return Math.min(Bt-1,Math.max(0,Ft))},ne=P[z(F.y)].cfId,le=P[z(H.y)].cfId;ne!==le&&u.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:Z,start:{id:ne,type:"self"},end:{id:le,type:H.y>F.y?"after":"before"}})},G=()=>{a.onCreate()},J=()=>{N==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):N==="1"&&P.map(F=>({unitId:p,subUnitId:b,cfId:F.cfId})).forEach(F=>{u.executeCommand(r.DeleteCfCommand.id,F)})},Q=C.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return P.filter(H=>{const q=H.ranges;return U.checkRangesEditablePermission(v,A.getUnitId(),F.getSheetId(),q)})},[P]),oe=Q.map((A,F)=>({i:A.cfId,x:0,w:12,y:F,h:1,isResizable:!1})),de=C.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return P.every(H=>{const q=H.ranges;return U.checkRangesEditablePermission(v,A.getUnitId(),F.getSheetId(),q)})},[P]);return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[c.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:h.tWithReactNode("sheet.cf.panel.managerRuleSelect",c.jsx(O.Select,{className:"univer-w-36",options:k,value:N,onChange:A=>{_(A)}})).map((A,F)=>c.jsx("span",{children:A},F))}),c.jsxs("div",{className:"univer-flex univer-justify-end",children:[c.jsx(O.Tooltip,{title:s.t("sheet.cf.panel.createRule"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:c.jsx(sr,{})})}),P.length&&de?c.jsx(O.Tooltip,{title:s.t("sheet.cf.panel.clear"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:c.jsx(Ne,{className:"univer-text-red-500"})})}):c.jsx("div",{children:c.jsx(Ne,{className:"univer-text-gray-300"})})]})]}),c.jsx("div",{ref:S,children:T>0&&c.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:oe,cols:12,rowHeight:60,width:T,margin:[0,10],onDragStop:$,onDragStart:x,children:Q==null?void 0:Q.map((A,F)=>c.jsx("div",{children:c.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":R===F}),onMouseMove:()=>{A.ranges!==I&&m(A.ranges)},onMouseLeave:()=>m([]),onClick:()=>{e(A)},children:[c.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:c.jsx(cr,{})}),c.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[c.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:at(A,s)}),c.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>Ae.serializeRange(H)).join(",")})]}),c.jsx("div",{children:c.jsx(ae,{rule:A.rule})}),c.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":R===F}),onClick:H=>{H.stopPropagation(),y(A),m([])},children:c.jsx(Ne,{})})]})},`${A.cfId}`))})})]})},st=a=>{const[e,t]=C.useState(a.rule),[n,l]=C.useState(!!a.rule),u=()=>{l(!0)},s=()=>{l(!1),t(void 0)},v=d=>{t(d),l(!0)};return c.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:n?c.jsx(rt,{onCancel:s,rule:e}):c.jsx(ut,{onClick:v,onCreate:u})})};var it=Object.getOwnPropertyDescriptor,ct=(a,e,t,n)=>{for(var l=n>1?void 0:n?it(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},ge=(a,e)=>(t,n)=>e(t,n,a);const Ve="sheet.conditional.formatting.panel";let ye=class extends i.Disposable{constructor(e,t,n,l,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=t,this._componentManager=n,this._sidebarService=l,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(s=>{var v;s||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(s=>{s.id===Ve&&(s.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const t={id:Ve,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ve,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(t)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ve,st))}};ye=ct([ge(0,i.IUniverInstanceService),ge(1,i.Inject(i.Injector)),ge(2,i.Inject(j.ComponentManager)),ge(3,i.Inject(j.ISidebarService)),ge(4,i.Inject(i.LocaleService))],ye);var Y=(a=>(a[a.createRule=1]="createRule",a[a.viewRule=2]="viewRule",a[a.highlightCell=3]="highlightCell",a[a.rank=4]="rank",a[a.formula=5]="formula",a[a.colorScale=6]="colorScale",a[a.dataBar=7]="dataBar",a[a.icon=8]="icon",a[a.clearRangeRules=9]="clearRangeRules",a[a.clearWorkSheetRules=10]="clearWorkSheetRules",a))(Y||{});const Ce={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(a,e)=>{var v;const t=a.get(ye),n=a.get(U.SheetsSelectionsService),l=a.get(i.ICommandService),u=((v=n.getCurrentSelections())==null?void 0:v.map(d=>d.range))||[];switch(e.value){case 3:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};t.openPanel(d);break}case 5:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};t.openPanel(d);break}case 6:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};t.openPanel(d);break}case 7:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};t.openPanel(d);break}case 8:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};t.openPanel(d);break}case 2:{t.openPanel();break}case 1:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{l.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{l.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var ot=Object.getOwnPropertyDescriptor,dt=(a,e,t,n)=>{for(var l=n>1?void 0:n?ot(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},me=(a,e)=>(t,n)=>e(t,n,a);D.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,t,n,l,u){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=l,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const t=[],n=[],l={redos:t,undos:n};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const s=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(I=>I.range);if(!s)return l;const v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),d=v.getActiveSheet();if(!d)return l;const h=v.getUnitId(),o=d.getSheetId(),p=this._conditionalFormattingRuleModel.getSubunitRules(h,o);if(!p||!p.length)return l;const{redos:g,undos:b}=Ir(this._injector,p,s,h,o);t.push(...g),n.push(...b)}return l}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{const l=[],u=[],s={redos:l,undos:u};if(!n||!n.length)return s;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!v||!v.length)return s;const{redos:d,undos:h}=Ir(this._injector,v,n,e,t);return l.push(...d),u.push(...h),s}}))}},D.ConditionalFormattingClearController=dt([me(0,i.Inject(i.Injector)),me(1,i.Inject(i.IUniverInstanceService)),me(2,i.Inject(U.SheetInterceptorService)),me(3,i.Inject(U.SheetsSelectionsService)),me(4,i.Inject(r.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function Ir(a,e,t,n,l){const u=[],s=[];return e.filter(v=>t.some(d=>v.ranges.some(h=>i.Rectangle.getIntersects(h,d)))).forEach(v=>{const h=new U.RangeMergeUtil().add(...v.ranges).subtract(...t).merge();if(h.length){const o={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,rule:{...v,ranges:h}}},p=r.setConditionalRuleMutationUndoFactory(a,o.params);u.push(o),s.push(...p)}else{const o={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,cfId:v.cfId}},p=r.DeleteConditionalRuleMutationUndoFactory(a,o.params);u.push(o),s.push(...p)}}),{redos:u,undos:s}}var vt=Object.getOwnPropertyDescriptor,pt=(a,e,t,n)=>{for(var l=n>1?void 0:n?vt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Je=(a,e)=>(t,n)=>e(t,n,a);let be=class extends i.Disposable{constructor(e,t,n){super();ee(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){const t=[],n=e.rule;switch(n.type){case r.CFRuleType.highlightCell:n.subType===r.CFSubRuleType.formula&&t.push(n.value);break;case r.CFRuleType.dataBar:{const l=n;l.config.min.type===r.CFValueType.formula&&t.push(l.config.min.value),l.config.max.type===r.CFValueType.formula&&t.push(l.config.max.value);break}case r.CFRuleType.colorScale:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}case r.CFRuleType.iconSet:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}}return t}_updateRuleFormulas(e,t){const n=i.Tools.deepClone(e),l=n.rule;let u=0;switch(l.type){case r.CFRuleType.highlightCell:l.subType===r.CFSubRuleType.formula&&(l.value=t[u++]);break;case r.CFRuleType.dataBar:{const s=l;s.config.min.type===r.CFValueType.formula&&(s.config.min.value=t[u++]),s.config.max.type===r.CFValueType.formula&&(s.config.max.value=t[u++]);break}case r.CFRuleType.colorScale:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}case r.CFRuleType.iconSet:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}}return n}register(e,t,n){const l=n.ranges,u=this._getRuleFormulas(n),s=this._formulaRefRangeService.registerRangeFormula(e,t,l,u,d=>{if(d.length===0)return{undos:[{id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:n}}],redos:[{id:r.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId}}]};const h=[],o=[],p=d[0],g=this._updateRuleFormulas(n,p.formulas);g.ranges=p.ranges,h.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:g}}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:g}));for(let b=1;b<d.length;b++){const I=d[b],m=r.createCfId(),N=this._updateRuleFormulas(n,I.formulas);N.cfId=m,N.ranges=I.ranges,h.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:N}}),o.push(r.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,rule:N}))}return{undos:o,redos:h}}),v=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(v,s)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[t,n]of e)for(const[l,u]of n)for(const s of u)this.register(t,l,s);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(t=>{const{unitId:n,subUnitId:l,rule:u}=t;switch(t.type){case"add":{this.register(n,l,u);break}case"delete":{const s=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(s);v&&(v.dispose(),this._disposableMap.delete(s));break}case"set":{const s=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(s);v&&(v.dispose(),this._disposableMap.delete(s)),this.register(n,l,u);break}}})),this.disposeWithMe(i.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};be=pt([Je(0,i.Inject(r.ConditionalFormattingRuleModel)),Je(1,i.Inject(nr.FormulaRefRangeService)),Je(2,i.Inject(i.Injector))],be);var ft=Object.getOwnPropertyDescriptor,ht=(a,e,t,n)=>{for(var l=n>1?void 0:n?ft(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Se=(a,e)=>(t,n)=>e(t,n,a);let Ie=class extends i.Disposable{constructor(e,t,n,l,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=l,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,n)=>this._collectConditionalRule(e,t,n),onPasteCells:(e,t,n,l)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:s}=l,{range:v}=e||{},{range:d}=t;return this._generateConditionalFormattingMutations(d,{copyType:u,pasteType:s,copyRange:v})}}))}_collectConditionalRule(e,t,n){const l=new i.ObjectMatrix,u={};this._copyInfo={matrix:l,info:{unitId:e,subUnitId:t,cfMap:u}};const s=this._injector.invoke(o=>U.rangeToDiscreteRange(n,o,e,t));if(!s)return;const{rows:v,cols:d}=s,h=new Set;v.forEach((o,p)=>{d.forEach((g,b)=>{const I=this._conditionalFormattingViewModel.getCellCfs(e,t,o,g);I&&(I.forEach(m=>h.add(m.cfId)),l.setValue(p,b,I.map(m=>m.cfId)))})}),h.forEach(o=>{const p=this._conditionalFormattingRuleModel.getRule(e,t,o);p&&(u[o]=p.rule)})}_generateConditionalFormattingMutations(e,t){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),l=n.getActiveSheet(),u=n.getUnitId();if(!l)return{redos:[],undos:[]};const s=l.getSheetId();if(t.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!t.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(t.pasteType))return{redos:[],undos:[]};const{ranges:[d,h],mapFunc:o}=W.virtualizeDiscreteRanges([t.copyRange,e]),p=W.getRepeatRange(d,h,!0),g={};i.Range.foreach(h,(f,T)=>{const{row:w,col:S}=o(f,T),k=this._conditionalFormattingViewModel.getCellCfs(u,s,w,S);k&&k.forEach(V=>{if(!g[V.cfId]){const P=new i.ObjectMatrix;g[V.cfId]=P;const L=this._conditionalFormattingRuleModel.getRule(u,s,V.cfId);L==null||L.ranges.forEach(y=>{i.Range.foreach(y,(x,$)=>{P.setValue(x,$,1)})})}g[V.cfId].realDeleteValue(w,S)})});const{matrix:b,info:I}=this._copyInfo,m=[];let N=this._conditionalFormattingRuleModel.createCfId(u,s);const _={},E=f=>{if(_[f])return _[f];const T=I==null?void 0:I.cfMap[f],w=[...this._conditionalFormattingRuleModel.getSubunitRules(u,s)||[],...m].find(S=>i.Tools.diffValue(S.rule,T));if(w)return _[f]=w,w;{const S={rule:T,cfId:N,ranges:[],stopIfTrue:!1};return _[f]=S,m.push(S),N=`${Number(N)+1}`,S}};p.forEach(f=>{b&&b.forValue((T,w,S)=>{const k=i.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:w,endColumn:w},f.startRange),{row:V,col:P}=o(k.startRow,k.startColumn);S.forEach(L=>{if(!g[L]){const y=E(L),x=new i.ObjectMatrix;g[L]=x,y.ranges.forEach($=>{i.Range.foreach($,(G,J)=>{x.setValue(G,J,1)})})}g[L].setValue(V,P,1)})})});const M=[],R=[];for(const f in g){const T=g[f],w=U.findAllRectangle(U.createTopMatrixFromMatrix(T));if(!w.length){const S={unitId:u,subUnitId:s,cfId:f};M.push({id:r.DeleteConditionalRuleMutation.id,params:S}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,S))}if(m.some(S=>S.cfId===f)){const S=E(f),k={unitId:u,subUnitId:s,rule:{...S,ranges:w}};M.push({id:r.AddConditionalRuleMutation.id,params:k}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,k))}else{const S=this._conditionalFormattingRuleModel.getRule(u,s,f);if(!S)continue;const k={unitId:u,subUnitId:s,rule:{...S,ranges:w}};M.push({id:r.SetConditionalRuleMutation.id,params:k}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,k))}}return{redos:M,undos:R}}};Ie=ht([Se(0,i.Inject(W.ISheetClipboardService)),Se(1,i.Inject(r.ConditionalFormattingRuleModel)),Se(2,i.Inject(i.Injector)),Se(3,i.Inject(r.ConditionalFormattingViewModel)),Se(4,i.Inject(i.IUniverInstanceService))],Ie);var gt=Object.getOwnPropertyDescriptor,yt=(a,e,t,n)=>{for(var l=n>1?void 0:n?gt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Qe=(a,e)=>(t,n)=>e(t,n,a);let Te=class extends i.Disposable{constructor(a,e,t){super(),this._localeService=a,this._commandService=e,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(a=>{if(a.id===r.AddCfCommand.id){const{unitId:e,subUnitId:t,rule:{ranges:n}}=a.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},n,e,t)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Te=yt([Qe(0,i.Inject(i.LocaleService)),Qe(1,i.ICommandService),Qe(2,i.Inject(U.SheetPermissionCheckController))],Te);var Ct=Object.getOwnPropertyDescriptor,mt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ct(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},ie=(a,e)=>(t,n)=>e(t,n,a);let _e=class extends i.Disposable{constructor(e,t,n,l,u,s){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=l,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=s,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var t,n,l;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(t=this._renderManagerService.getRenderById(e))==null||t.with(W.SheetSkeletonManagerService).reCalculate(),(l=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||l.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(pe.bufferTime(16),pe.filter(e=>!!e.length),pe.filter(e=>{const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const n=t.getActiveSheet();return n?e.filter(l=>l.unitId===t.getUnitId()&&l.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const l=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!l)return n(e);const u=t.workbook.getStyles(),s=(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},v=e===t.rawData?{...t.rawData}:e;if(l.style){const d={...s,...l.style};Object.assign(v,{s:d})}return v.fontRenderExtension||(v.fontRenderExtension={},l.isShowValue!==void 0&&(v.fontRenderExtension.isSkip=!l.isShowValue)),l.dataBar&&(v.dataBar=l.dataBar),l.iconSet&&(v.iconSet=l.iconSet,v.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(v)},priority:10}))}};_e=mt([ie(0,i.Inject(U.SheetInterceptorService)),ie(1,i.Inject(r.ConditionalFormattingService)),ie(2,i.Inject(i.IUniverInstanceService)),ie(3,i.Inject(lr.IRenderManagerService)),ie(4,i.Inject(r.ConditionalFormattingViewModel)),ie(5,i.Inject(r.ConditionalFormattingRuleModel))],_e);const Tr="sheets-conditional-formatting-ui.config",Oe={};var bt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,It=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Tt=(a,e,t,n)=>{for(var l=n>1?void 0:n?St(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},er=(a,e)=>(t,n)=>e(t,n,a),_r=(a,e,t)=>It(a,typeof e!="symbol"?e+"":e,t);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Oe,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...s}=i.merge({},Oe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Tr,s),this._initCommand(),this._injector.add([_e]),this._injector.add([Ie]),this._injector.add([Te]),this._injector.add([se]),this._injector.add([be])}_initCommand(){[$e,Fe,Be,He,We,qe,Ge,Ze,ze,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},_r(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),_r(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=Tt([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),er(1,i.Inject(i.Injector)),er(2,i.Inject(i.ICommandService)),er(3,i.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var _t=Object.getOwnPropertyDescriptor,wt=(a,e,t,n)=>{for(var l=n>1?void 0:n?_t(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},we=(a,e)=>(t,n)=>e(t,n,a);let Ue=class extends i.Disposable{constructor(a,e,t,n,l){super(),this._injector=a,this._univerInstanceService=e,this._autoFillService=t,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=l,this._initAutoFill()}_initAutoFill(){const a=()=>({redos:[],undos:[]}),e=(l,u,s,v,d)=>{var b;const h=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(b=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!h||!o)return;const p={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row},g={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};i.Range.foreach(s,(I,m)=>{const N=i.Rectangle.getPositionRange({startRow:I,startColumn:m,endColumn:m,endRow:I},p),_=i.Rectangle.getPositionRange({startRow:I,startColumn:m,endColumn:m,endRow:I},g),{row:E,col:M}=d(N.startRow,N.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(h,o,E,M),{row:f,col:T}=d(_.startRow,_.startColumn),w=this._conditionalFormattingViewModel.getCellCfs(h,o,f,T);w&&w.forEach(S=>{let k=v.get(S.cfId);if(!v.get(S.cfId)){const V=this._conditionalFormattingRuleModel.getRule(h,o,S.cfId);if(!V)return;k=new i.ObjectMatrix,V.ranges.forEach(P=>{i.Range.foreach(P,(L,y)=>{k.setValue(L,y,1)})}),v.set(S.cfId,k)}k.realDeleteValue(f,T)}),R&&R.forEach(S=>{let k=v.get(S.cfId);if(!v.get(S.cfId)){const V=this._conditionalFormattingRuleModel.getRule(h,o,S.cfId);if(!V)return;k=new i.ObjectMatrix,V.ranges.forEach(P=>{i.Range.foreach(P,(L,y)=>{k.setValue(L,y,1)})}),v.set(S.cfId,k)}k.setValue(f,T,1)})})},t=(l,u)=>{var _,E,M;const s=(_=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getUnitId(),v=(M=(E=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:E.getActiveSheet())==null?void 0:M.getSheetId(),d=new Map,h=[],o=[];if(!s||!v)return a();const p=W.virtualizeDiscreteRanges([l,u]),[g,b]=p.ranges,{mapFunc:I}=p,m={row:g.startRow,col:g.startColumn};return W.getAutoFillRepeatRange(g,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,d,I)}),d.forEach((R,f)=>{const T=this._conditionalFormattingRuleModel.getRule(s,v,f);if(!T)return;const w=U.findAllRectangle(U.createTopMatrixFromMatrix(R));if(w.length){const S={unitId:s,subUnitId:v,rule:{...T,ranges:w}};h.push({id:r.SetConditionalRuleMutation.id,params:S}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,S))}else{const S={unitId:s,subUnitId:v,cfId:T.cfId};h.push({id:r.DeleteConditionalRuleMutation.id,params:S}),o.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,S))}}),{undos:o,redos:h}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(l,u,s)=>{if(s===W.APPLY_TYPE.COPY||s===W.APPLY_TYPE.ONLY_FORMAT||s===W.APPLY_TYPE.SERIES){const{source:v,target:d}=l;return t(v,d)}return a()}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ue=wt([we(0,i.Inject(i.Injector)),we(1,i.Inject(i.IUniverInstanceService)),we(2,i.Inject(W.IAutoFillService)),we(3,i.Inject(r.ConditionalFormattingRuleModel)),we(4,i.Inject(r.ConditionalFormattingViewModel))],Ue);var xt=Object.getOwnPropertyDescriptor,Nt=(a,e,t,n)=>{for(var l=n>1?void 0:n?xt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},wr=(a,e)=>(t,n)=>e(t,n,a);let ke=class extends i.Disposable{constructor(a,e){super(),this._sheetInterceptorService=a,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(a,e,t)=>{var s,v,d;a||t(a);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),l=(s=n==null?void 0:n.style)!=null?s:{},u=Object.keys(l);if(a!=null&&a.p)return(d=(v=a.p.body)==null?void 0:v.textRuns)==null||d.forEach(h=>{h.ts&&u.forEach(o=>{var p;(p=h.ts)==null||delete p[o]})}),t(a);{const h={...(typeof(a==null?void 0:a.s)=="string"?e.workbook.getStyles().get(a.s):a==null?void 0:a.s)||{}};u.forEach(p=>{delete h[p]});const o={...a,s:{...h}};return t(o)}}})))}};ke=Nt([wr(0,i.Inject(U.SheetInterceptorService)),wr(1,i.Inject(r.ConditionalFormattingService))],ke);const xr=[U.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],xe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Y.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Y.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Y.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Y.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Y.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Y.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Y.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Y.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Y.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Y.clearWorkSheetRules}],Et=a=>{const e=a.get(U.SheetsSelectionsService),t=a.get(i.ICommandService),n=a.get(i.IUniverInstanceService),l=a.get(r.ConditionalFormattingRuleModel),u=new X.Observable(d=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(h=>{const o=t.onCommandExecuted(p=>{var m;const{id:g,params:b}=p,I=(m=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();xr.includes(g)&&b.unitId===I&&h.next(null)});return()=>o.dispose()})).pipe(pe.debounceTime(16)).subscribe(()=>{var m;const h=((m=e.getCurrentSelections())==null?void 0:m.map(N=>N.range))||[],o=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!o)return;const p=o.getActiveSheet();if(!p)return;const I=(l.getSubunitRules(o.getUnitId(),p.getSheetId())||[]).filter(N=>N.ranges.some(_=>h.some(E=>i.Rectangle.intersects(E,_)))).map(N=>N.ranges).every(N=>U.checkRangesEditablePermission(a,o.getUnitId(),p.getSheetId(),N));d.next(I)})),s=new X.Observable(d=>new X.Observable(h=>{const o=t.onCommandExecuted(p=>{var m;const{id:g,params:b}=p,I=(m=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();xr.includes(g)&&b.unitId===I&&h.next(null)});return()=>o.dispose()}).pipe(pe.debounceTime(16)).subscribe(()=>{const h=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!h)return;const o=h.getActiveSheet();if(!o)return;const p=l.getSubunitRules(h.getUnitId(),o.getSheetId())||[];if(!p.length)return d.next(!1),!1;const g=p.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(a,h.getUnitId(),o.getSheetId(),b));d.next(g)})),v=new X.Observable(d=>{u.subscribe(h=>{const o=xe.find(p=>p.value===Y.clearRangeRules);o&&(o.disabled=!h,d.next(xe))}),s.subscribe(h=>{const o=xe.find(p=>p.value===Y.clearWorkSheetRules);o&&(o.disabled=!h,d.next(xe))}),d.next(xe)});return{id:Ce.id,type:j.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:v,hidden$:j.getMenuHiddenObservable(a,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(a,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Rt={[j.RibbonDataGroup.RULES]:{[Ce.id]:{order:1,menuItemFactory:Et}}};var Mt=Object.getOwnPropertyDescriptor,Vt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Mt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Nr=(a,e)=>(t,n)=>e(t,n,a);let Pe=class extends i.Disposable{constructor(e,t){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=t,this._menuManagerService.mergeMenu(Rt)}};Pe=Vt([Nr(0,i.Inject(i.Injector)),Nr(1,j.IMenuManagerService)],Pe);var Ot=Object.getOwnPropertyDescriptor,Ut=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ot(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},ce=(a,e)=>(t,n)=>e(t,n,a);const kt=(a,e)=>{const t=o=>o.endRow-o.startRow+1,n=o=>o.endColumn-o.startColumn+1,l=t(e)%t(a),u=n(e)%n(a),s=Math.floor(t(e)/t(a)),v=Math.floor(n(e)/n(a)),d=[],h={startRow:0,endRow:t(a)-1,startColumn:0,endColumn:n(a)-1};if(t(e)===1&&n(e)===1){const o={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:h,startRange:o}),d}for(let o=0;o<s+(l?.1:0);o++)for(let p=0;p<v+(u?.1:0);p++){const g=t(a)*o,b=n(a)*p,I={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=h;o===s&&l&&(m={...m},m.endRow=m.endRow-(t(a)-l)),p===v&&u&&(m={...m},m.endColumn=m.endColumn-(n(a)-u)),d.push({repeatRelativeRange:m,startRange:I})}return d};let De=class extends i.Disposable{constructor(e,t,n,l,u,s){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=l,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=s,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),t=(u,s,v,d,h)=>{const{unitId:o,subUnitId:p}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=h,I={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},m={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};i.Range.foreach(v,(N,_)=>{const E=i.Rectangle.getPositionRange({startRow:N,startColumn:_,endColumn:_,endRow:N},I),M=i.Rectangle.getPositionRange({startRow:N,startColumn:_,endColumn:_,endRow:N},m),R=this._conditionalFormattingViewModel.getCellCfs(o,p,E.startRow,E.startColumn),f=this._conditionalFormattingViewModel.getCellCfs(g,b,M.startRow,M.startColumn);f&&f.forEach(T=>{let w=d.get(T.cfId);if(!d.get(T.cfId)){const S=this._conditionalFormattingRuleModel.getRule(g,b,T.cfId);if(!S)return;w=new i.ObjectMatrix,S.ranges.forEach(k=>{i.Range.foreach(k,(V,P)=>{w.setValue(V,P,1)})}),d.set(T.cfId,w)}w.realDeleteValue(M.startRow,M.startColumn)}),R&&R.forEach(T=>{const w=d.get(T.cfId);w&&w.setValue(M.startRow,M.startColumn,1)})})},n=(u,s,v)=>{var E;const{range:d,unitId:h,subUnitId:o}=this._painterConfig,p=u!==h||o!==s,g=new Map,b=[],I=[];if(!u||!s||!h||!o)return e();const m=(E=this._conditionalFormattingRuleModel.getSubunitRules(h,o))!=null?E:[];m==null||m.forEach(M=>{const{ranges:R,cfId:f}=M;if(R.some(T=>i.Rectangle.intersects(d,T))){const T=new i.ObjectMatrix;p||R.forEach(w=>{i.Range.foreach(w,(S,k)=>{T.setValue(S,k,1)})}),g.set(f,T)}});const N={row:d.startRow,col:d.startColumn};return kt(d,v).forEach(M=>{t(N,{row:M.startRange.startRow,col:M.startRange.startColumn},M.repeatRelativeRange,g,{targetUnitId:u,targetSubUnitId:s})}),g.forEach((M,R)=>{if(p){const f=this._conditionalFormattingRuleModel.getRule(u,s,R),T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(f)if(T.length){const w={unitId:u,subUnitId:s,rule:{...f,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),I.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:u,subUnitId:s,cfId:f.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),I.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}else if(T.length){const w=this._conditionalFormattingRuleModel.getRule(h,o,R);if(w){const S={unitId:u,subUnitId:s,rule:{...i.Tools.deepClone(w),cfId:this._conditionalFormattingRuleModel.createCfId(u,s),ranges:T}};b.push({id:r.AddConditionalRuleMutation.id,params:S}),I.push(r.AddConditionalRuleMutationUndoFactory(this._injector,S))}}}else{const f=this._conditionalFormattingRuleModel.getRule(h,o,R);if(!f)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(T.length){const w={unitId:h,subUnitId:o,rule:{...f,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),I.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:h,subUnitId:o,cfId:f.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),I.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}}}),{undos:I,redos:b}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var s,v,d;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const h=(s=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),o=(d=(v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:d.getSheetId(),p=this._sheetsSelectionsService.getCurrentLastSelection(),g=p==null?void 0:p.range;h&&o&&g&&(this._painterConfig={unitId:h,subUnitId:o,range:g});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,s,v)=>this._painterConfig?n(u,s,v):{redos:[],undos:[]}};this._formatPainterService.addHook(l)}};De=Ut([ce(0,i.Inject(i.Injector)),ce(1,i.Inject(i.IUniverInstanceService)),ce(2,i.Inject(W.IFormatPainterService)),ce(3,i.Inject(U.SheetsSelectionsService)),ce(4,i.Inject(r.ConditionalFormattingRuleModel)),ce(5,i.Inject(r.ConditionalFormattingViewModel))],De);var Pt=Object.getOwnPropertyDescriptor,Dt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Pt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},rr=(a,e)=>(t,n)=>e(t,n,a);let Le=class extends i.Disposable{constructor(a,e,t){super(),this._conditionalFormattingViewModel=a,this._univerInstanceService=e,this._renderManagerService=t,this._init()}_init(){const a=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=t=>{const n=t.getUnitId(),l=this._renderManagerService.getRenderById(n);if(!l)return;const u=l.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(s=>{if(s){const v=s.skeleton.rowColumnSegment,d=v.endColumn-v.startColumn+1,o=(v.endRow-v.startRow+1)*d*9,p=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,o);this._conditionalFormattingViewModel.setCacheLength(p)}}))};a&&e(a),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{t&&e(t)})}};Le=Dt([rr(0,i.Inject(r.ConditionalFormattingViewModel)),rr(1,i.IUniverInstanceService),rr(2,lr.IRenderManagerService)],Le);var Lt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,At=(a,e,t)=>e in a?Lt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,$t=(a,e,t,n)=>{for(var l=n>1?void 0:n?jt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},tr=(a,e)=>(t,n)=>e(t,n,a),Er=(a,e,t)=>At(a,typeof e!="symbol"?e+"":e,t);D.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Oe,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...s}=i.merge({},Oe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Tr,s),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Ie],[Ue],[Te],[ye],[Pe],[se],[ke],[D.ConditionalFormattingClearController],[De],[Le],[be]]),i.touchDependencies(this._injector,[[_e],[be]])}onReady(){i.touchDependencies(this._injector,[[Pe],[ye]])}onRendered(){i.touchDependencies(this._injector,[[Ue],[D.ConditionalFormattingClearController],[Ie],[ke],[se],[De],[Te],[Le]])}_initCommand(){[$e,Fe,Be,He,We,qe,Ge,Ze,ze,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},Er(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Er(D.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=$t([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin,nr.UniverSheetsFormulaPlugin),tr(1,i.Inject(i.Injector)),tr(2,i.Inject(i.ICommandService)),tr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=$e,D.AddColorScaleConditionalRuleCommand=Fe,D.AddDataBarConditionalRuleCommand=Be,D.AddDuplicateValuesCfCommand=He,D.AddNumberCfCommand=We,D.AddRankCfCommand=qe,D.AddTextCfCommand=Ge,D.AddTimePeriodCfCommand=Ze,D.AddUniqueValuesCfCommand=ze,D.OpenConditionalFormattingOperator=Ce,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(D,i){typeof exports=="object"&&typeof module<"u"?i(exports,require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-conditional-formatting"),require("@univerjs/ui"),require("react/jsx-runtime"),require("react"),require("@univerjs/design"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui"),require("@univerjs/sheets-ui"),require("rxjs"),require("@univerjs/sheets-formula"),require("@univerjs/engine-render"),require("rxjs/operators")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","@univerjs/sheets","@univerjs/sheets-conditional-formatting","@univerjs/ui","react/jsx-runtime","react","@univerjs/design","@univerjs/engine-formula","@univerjs/sheets-formula-ui","@univerjs/sheets-ui","rxjs","@univerjs/sheets-formula","@univerjs/engine-render","rxjs/operators"],i):(D=typeof globalThis<"u"?globalThis:D||self,i(D.UniverSheetsConditionalFormattingUi={},D.UniverCore,D.UniverSheets,D.UniverSheetsConditionalFormatting,D.UniverUi,D.React,D.React,D.UniverDesign,D.UniverEngineFormula,D.UniverSheetsFormulaUi,D.UniverSheetsUi,D.rxjs,D.UniverSheetsFormula,D.UniverEngineRender,D.rxjs.operators))})(this,(function(D,i,U,r,j,c,C,O,Ae,ve,W,X,nr,lr,pe){"use strict";var Ht=Object.defineProperty;var Wt=(D,i,U)=>i in D?Ht(D,i,{enumerable:!0,configurable:!0,writable:!0,value:U}):D[i]=U;var ee=(D,i,U)=>Wt(D,typeof i!="symbol"?i+"":i,U);const $e={type:i.CommandType.COMMAND,id:"sheet.command.add-average-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u}=e,s=a.get(r.ConditionalFormattingRuleModel),v=a.get(i.ICommandService),d=a.get(i.IUniverInstanceService),h=U.getSheetCommandTarget(d);if(!h)return!1;const{unitId:o,subUnitId:p}=h,g=s.createCfId(o,p),b={ranges:t,cfId:g,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:u,style:n}};return v.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:b})}},Fe={type:i.CommandType.COMMAND,id:"sheet.command.add-color-scale-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,config:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),s=a.get(i.ICommandService),v=a.get(i.IUniverInstanceService),d=U.getSheetCommandTarget(v);if(!d)return!1;const{unitId:h,subUnitId:o}=d,p=u.createCfId(h,o),g={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.colorScale,config:n}};return s.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:o,rule:g})}},Be={type:i.CommandType.COMMAND,id:"sheet.command.add-data-bar-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,min:n,max:l,nativeColor:u,positiveColor:s,isGradient:v,stopIfTrue:d,isShowValue:h}=e,o=a.get(r.ConditionalFormattingRuleModel),p=a.get(i.IUniverInstanceService),g=U.getSheetCommandTarget(p);if(!g)return!1;const{unitId:b,subUnitId:I}=g,m=a.get(i.ICommandService),N=o.createCfId(b,I),_={ranges:t,cfId:N,stopIfTrue:!!d,rule:{type:r.CFRuleType.dataBar,isShowValue:h,config:{min:n,max:l,nativeColor:u,positiveColor:s,isGradient:v}}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:b,subUnitId:I,rule:_})}},He={type:i.CommandType.COMMAND,id:"sheet.command.add-duplicate-values-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),s=a.get(i.ICommandService),v=a.get(i.IUniverInstanceService),d=U.getSheetCommandTarget(v);if(!d)return!1;const{unitId:h,subUnitId:o}=d,p=u.createCfId(h,o),g={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:n}};return s.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:o,rule:g})}},We={type:i.CommandType.COMMAND,id:"sheet.command.add-number-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u,value:s}=e,v=a.get(r.ConditionalFormattingRuleModel),d=a.get(i.ICommandService),h=a.get(i.IUniverInstanceService),o=U.getSheetCommandTarget(h);if(!o)return!1;const{unitId:p,subUnitId:g}=o,b=v.createCfId(p,g);let I;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(u)){const m=s;if(m.length!==2||!Array.isArray(m))return!1;I={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:m}}}else{const m=s;if(typeof m!="number")return!1;I={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:u,style:n,value:m}}}return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:g,rule:I})}},qe={type:i.CommandType.COMMAND,id:"sheet.command.add-rank-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,isPercent:u,isBottom:s,value:v}=e,d=a.get(r.ConditionalFormattingRuleModel),h=a.get(i.IUniverInstanceService),o=a.get(i.ICommandService),p=U.getSheetCommandTarget(h);if(!p)return!1;const{unitId:g,subUnitId:b}=p,I=d.createCfId(g,b),m={ranges:t,cfId:I,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:u,isBottom:s,style:n,value:v}};return o.executeCommand(r.AddConditionalRuleMutation.id,{unitId:g,subUnitId:b,rule:m})}},Ge={type:i.CommandType.COMMAND,id:"sheet.command.add-text-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u,value:s}=e,v=a.get(r.ConditionalFormattingRuleModel),d=a.get(i.IUniverInstanceService),h=U.getSheetCommandTarget(d);if(!h)return!1;const{unitId:o,subUnitId:p}=h,g=a.get(i.ICommandService),b=v.createCfId(o,p),I={ranges:t,cfId:b,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:u,style:n,value:s}};return g.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:I})}},Ze={type:i.CommandType.COMMAND,id:"sheet.command.add-time-period-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l,operator:u}=e,s=a.get(r.ConditionalFormattingRuleModel),v=a.get(i.IUniverInstanceService),d=a.get(i.ICommandService),h=U.getSheetCommandTarget(v);if(!h)return!1;const{unitId:o,subUnitId:p}=h,g=s.createCfId(o,p),b={ranges:t,cfId:g,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:u,style:n}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:o,subUnitId:p,rule:b})}},ze={type:i.CommandType.COMMAND,id:"sheet.command.add-uniqueValues-conditional-rule",handler(a,e){if(!e)return!1;const{ranges:t,style:n,stopIfTrue:l}=e,u=a.get(r.ConditionalFormattingRuleModel),s=a.get(i.IUniverInstanceService),v=a.get(i.ICommandService),d=U.getSheetCommandTarget(s);if(!d)return!1;const{unitId:h,subUnitId:o}=d,p=u.createCfId(h,o),g={ranges:t,cfId:p,stopIfTrue:!!l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:n}};return v.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:o,rule:g})}};function K({ref:a,...e}){const{icon:t,id:n,className:l,extend:u,...s}=e,v=`univerjs-icon univerjs-icon-${n} ${l||""}`.trim(),d=C.useRef(`_${Vr()}`);return ar(t,`${n}`,{defIds:t.defIds,idSuffix:d.current},{ref:a,className:v,...s},u)}function ar(a,e,t,n,l){return C.createElement(a.tag,{key:e,...Rr(a,t,l),...n},(Mr(a,t).children||[]).map((u,s)=>ar(u,`${e}-${a.tag}-${s}`,t,void 0,l)))}function Rr(a,e,t){const n={...a.attrs};t!=null&&t.colorChannel1&&n.fill==="colorChannel1"&&(n.fill=t.colorChannel1),a.tag==="mask"&&n.id&&(n.id=n.id+e.idSuffix),Object.entries(n).forEach(([u,s])=>{u==="mask"&&typeof s=="string"&&(n[u]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))});const{defIds:l}=e;return!l||l.length===0||(a.tag==="use"&&n["xlink:href"]&&(n["xlink:href"]=n["xlink:href"]+e.idSuffix),Object.entries(n).forEach(([u,s])=>{typeof s=="string"&&(n[u]=s.replace(/url\(#(.*)\)/,`url(#$1${e.idSuffix})`))})),n}function Mr(a,e){var n;const{defIds:t}=e;return!t||t.length===0?a:a.tag==="defs"&&((n=a.children)!=null&&n.length)?{...a,children:a.children.map(l=>typeof l.attrs.id=="string"&&t&&t.includes(l.attrs.id)?{...l,attrs:{...l.attrs,id:l.attrs.id+e.idSuffix}}:l)}:a}function Vr(){return Math.random().toString(36).substring(2,8)}K.displayName="UniverIcon";const Or={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.65791 1.30005C3.77355 1.30005 3.05664 2.01696 3.05664 2.90132V12.8588C3.05664 13.8755 3.88086 14.6998 4.89759 14.6998H9.1016C11.2233 14.6998 12.9433 12.9798 12.9433 10.8581C12.9433 9.13925 11.8145 7.68407 10.2578 7.1934C10.8806 6.56856 11.2655 5.70659 11.2655 4.75472C11.2655 2.84676 9.71883 1.30005 7.81087 1.30005H4.65791ZM4.25664 2.90132C4.25664 2.6797 4.4363 2.50005 4.65791 2.50005H7.81087C9.05609 2.50005 10.0655 3.5095 10.0655 4.75472C10.0655 5.99993 9.05609 7.00938 7.81087 7.00938H4.25664V2.90132ZM4.25664 12.8588V8.21636H9.1016C10.5606 8.21636 11.7433 9.39909 11.7433 10.8581C11.7433 12.317 10.5606 13.4998 9.1016 13.4998H4.89759C4.5436 13.4998 4.25664 13.2128 4.25664 12.8588Z",fillRule:"evenodd",clipRule:"evenodd"}}]},ur=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"bold-icon",ref:t,icon:Or}))});ur.displayName="BoldIcon";const Ur={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ne=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"delete-icon",ref:t,icon:Ur}))});Ne.displayName="DeleteIcon";const kr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"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"}}]},sr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"increase-icon",ref:t,icon:kr}))});sr.displayName="IncreaseIcon";const Pr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M9.80385 1.40005H11.9997C12.3311 1.40005 12.5997 1.66868 12.5997 2.00005C12.5997 2.33143 12.3311 2.60005 11.9997 2.60005H10.1185L7.12251 13.4001H9.33324C9.66461 13.4001 9.93324 13.6687 9.93324 14.0001C9.93324 14.3314 9.66461 14.6001 9.33324 14.6001H6.34785C6.33847 14.6003 6.32905 14.6003 6.31962 14.6001H3.9999C3.66853 14.6001 3.3999 14.3314 3.3999 14.0001C3.3999 13.6687 3.66853 13.4001 3.9999 13.4001H5.87719L8.87322 2.60005H6.66641C6.33504 2.60005 6.06641 2.33143 6.06641 2.00005C6.06641 1.66868 6.33504 1.40005 6.66641 1.40005H9.52916C9.61698 1.37929 9.71064 1.3781 9.80385 1.40005Z"}}]},ir=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"italic-icon",ref:t,icon:Pr}))});ir.displayName="ItalicIcon";const Dr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},Ye=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"more-down-icon",ref:t,icon:Dr}))});Ye.displayName="MoreDownIcon";const Lr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},cr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"sequence-icon",ref:t,icon:Lr}))});cr.displayName="SequenceIcon";const jr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.00033 1.20996C6.43345 1.20996 5.23596 1.88077 4.64804 2.94304C4.06338 3.99943 4.15123 5.32084 4.90099 6.47062C5.08199 6.7482 5.45374 6.82648 5.73131 6.64548C6.00888 6.46448 6.08716 6.09273 5.90616 5.81516C5.36418 4.98402 5.35768 4.13897 5.69797 3.52412C6.035 2.91515 6.78176 2.40996 8.00033 2.40996C9.19423 2.40996 10.0017 2.93409 10.5236 3.46755C10.7871 3.73682 10.9756 4.00712 11.0974 4.20903C11.158 4.30951 11.2013 4.39164 11.2284 4.44625C11.2419 4.47351 11.2514 4.49377 11.2568 4.50588L11.2621 4.51771C11.3901 4.82216 11.7407 4.96686 12.046 4.83992C12.3519 4.71267 12.4968 4.36149 12.3695 4.05552L11.8231 4.28278C12.3695 4.05552 12.3697 4.0558 12.3695 4.05552L12.3691 4.05437L12.3685 4.05298L12.367 4.04953L12.3629 4.03993L12.3498 4.01036C12.3388 3.98619 12.3234 3.95326 12.3033 3.91282C12.2632 3.83203 12.2043 3.72072 12.1249 3.58908C11.9666 3.32674 11.7235 2.97805 11.3814 2.62834C10.6921 1.92381 9.59192 1.20996 8.00033 1.20996Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.11953 8.5999H7.88935C10.1109 9.46549 10.5895 10.7649 10.4268 11.6869C10.2475 12.703 9.26939 13.5898 8.00009 13.5898C6.63323 13.5898 5.77631 13.0502 5.25534 12.528C4.99021 12.2623 4.80823 11.9965 4.69365 11.7993C4.63659 11.7011 4.59698 11.6211 4.5727 11.5686C4.56059 11.5424 4.55236 11.5231 4.54774 11.512L4.54352 11.5016C4.4267 11.193 4.0823 11.0363 3.77279 11.1516C3.46228 11.2673 3.30438 11.6129 3.4201 11.9234L3.9649 11.7203C3.4201 11.9234 3.41998 11.9231 3.4201 11.9234L3.4206 11.9247L3.42118 11.9263L3.42262 11.9301L3.42661 11.9403C3.42977 11.9484 3.43394 11.9588 3.43914 11.9713C3.44956 11.9965 3.46418 12.0304 3.48334 12.0719C3.52161 12.1547 3.57828 12.2682 3.65608 12.4021C3.81124 12.6692 4.0534 13.0223 4.40584 13.3756C5.12 14.0914 6.27196 14.7898 8.00009 14.7898C9.82574 14.7898 11.3236 13.5101 11.6085 11.8955C11.812 10.7422 11.3901 9.55402 10.2665 8.5999H13.8804C14.2117 8.5999 14.4803 8.33127 14.4803 7.9999C14.4803 7.66853 14.2117 7.3999 13.8804 7.3999H8.01411C8.0048 7.39968 7.99551 7.39969 7.98625 7.3999H2.11953C1.78816 7.3999 1.51953 7.66853 1.51953 7.9999C1.51953 8.33127 1.78816 8.5999 2.11953 8.5999Z"}}]},or=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"strikethrough-icon",ref:t,icon:jr}))});or.displayName="StrikethroughIcon";const Ar={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M4.46416 2.03237C4.46416 1.701 4.19553 1.43237 3.86416 1.43237C3.53279 1.43237 3.26416 1.701 3.26416 2.03237V7.33338C3.26416 10.0313 5.35834 12.2667 7.9999 12.2667C10.6415 12.2667 12.7356 10.0313 12.7356 7.33338V2.03237C12.7356 1.701 12.467 1.43237 12.1356 1.43237C11.8043 1.43237 11.5356 1.701 11.5356 2.03237V7.33338C11.5356 9.42194 9.92656 11.0667 7.9999 11.0667C6.07325 11.0667 4.46416 9.42194 4.46416 7.33338V2.03237Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M2.66641 13.4663C2.33504 13.4663 2.06641 13.7349 2.06641 14.0663C2.06641 14.3977 2.33504 14.6663 2.66641 14.6663H13.3331C13.6644 14.6663 13.9331 14.3977 13.9331 14.0663C13.9331 13.7349 13.6644 13.4663 13.3331 13.4663H2.66641Z"}}]},dr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"underline-icon",ref:t,icon:Ar}))});dr.displayName="UnderlineIcon";const $r={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10.3014 1.70389C9.85268 0.479568 8.12109 0.479557 7.67238 1.70389L4.72235 9.75326C4.60832 10.0644 4.76811 10.4091 5.07924 10.5231C5.39038 10.6371 5.73504 10.4773 5.84907 10.1662L6.99975 7.02646C7.03588 7.03324 7.07314 7.03679 7.11123 7.03679H10.9778L12.1247 10.1662C12.2387 10.4773 12.5834 10.6371 12.8945 10.5231C13.2057 10.4091 13.3654 10.0644 13.2514 9.75326L10.3014 1.70389ZM10.538 5.83679L9.17467 2.11682C9.11057 1.94192 8.8632 1.94192 8.7991 2.11682L7.43576 5.83679H10.538Z",fillRule:"evenodd",clipRule:"evenodd"}}]},vr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"font-color-double-icon",ref:t,icon:$r}))});vr.displayName="FontColorDoubleIcon";const Fr={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M8.01281 1.36643C8.79386 0.585377 10.0602 0.585378 10.8412 1.36643L12.9223 3.44752C13.7034 4.22857 13.7034 5.4949 12.9223 6.27595L9.36445 9.83383C8.5834 10.6149 7.31707 10.6149 6.53602 9.83383L4.45493 7.75273C3.67388 6.97168 3.67388 5.70535 4.45493 4.9243L8.01281 1.36643ZM9.9927 2.21495C9.68028 1.90253 9.17375 1.90253 8.86133 2.21495L5.30346 5.77283L5.29671 5.77966L10.839 6.66224L12.0738 5.42742C12.3862 5.115 12.3862 4.60847 12.0738 4.29605L9.9927 2.21495Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"currentColor",d:"M14.5179 9.48875C14.5179 9.99175 14.1101 10.3995 13.607 10.3995C13.1041 10.3995 12.6963 9.99175 12.6963 9.48875C12.6963 9.1773 13.0455 8.59966 13.3114 8.20487C13.4549 7.99177 13.7591 7.99177 13.9027 8.20486C14.1687 8.59965 14.5179 9.1773 14.5179 9.48875Z"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M1.98682 13.4992C1.98682 12.5603 2.74793 11.7992 3.68682 11.7992H14.2868C15.2257 11.7992 15.9868 12.5603 15.9868 13.4992V13.4992C15.9868 14.4381 15.2257 15.1992 14.2868 15.1992H3.68682C2.74793 15.1992 1.98682 14.4381 1.98682 13.4992V13.4992Z"}}]},pr=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"paint-bucket-double-icon",ref:t,icon:Fr}))});pr.displayName="PaintBucketDoubleIcon";const Br={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 17 17",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M2.27177 13.714L13.5855 2.40025L14.434 3.24878L3.1203 14.5625L2.27177 13.714Z",fillRule:"evenodd",clipRule:"evenodd"}},{tag:"path",attrs:{fill:"colorChannel1",d:"M4.2603 1.82495L2.89617 1.82495C2.23343 1.82495 1.69617 2.36221 1.69617 3.02495L1.69617 4.38908L3.02617 4.38908L3.02617 3.15495L4.2603 3.15495L4.2603 1.82495ZM15.0092 4.38908L15.0092 3.02495C15.0092 2.36221 14.4719 1.82495 13.8092 1.82495L12.4451 1.82495L12.4451 3.15495L13.6792 3.15495L13.6792 4.38908L15.0092 4.38908ZM6.98856 1.82495L6.98856 3.15495L9.71681 3.15495L9.71681 1.82495L6.98856 1.82495ZM15.0092 7.11734L13.6792 7.11734L13.6792 9.84559L15.0092 9.84559L15.0092 7.11734ZM15.0092 12.5739L13.6792 12.5739L13.6792 13.808L12.4451 13.808L12.4451 15.138L13.8092 15.138C14.4719 15.138 15.0092 14.6007 15.0092 13.938L15.0092 12.5739ZM9.71681 15.138L9.71681 13.808L6.98856 13.808L6.98856 15.138L9.71681 15.138ZM4.2603 15.138L4.2603 13.808L3.02617 13.808L3.02617 12.5739L1.69617 12.5739L1.69617 13.938C1.69617 14.6007 2.23343 15.138 2.89617 15.138L4.2603 15.138ZM1.69617 9.8456L3.02617 9.8456L3.02617 7.11734L1.69617 7.11734L1.69617 9.8456Z",fillRule:"evenodd",clipRule:"evenodd"}}]},fe=C.forwardRef(function(e,t){return C.createElement(K,Object.assign({},e,{id:"slash-double-icon",ref:t,icon:Br}))});fe.displayName="SlashDoubleIcon";const re=a=>{const{color:e,onChange:t,disable:n=!1,Icon:l=pr,className:u}=a,s=C.useMemo(()=>new i.ColorKit(e),[e]),v=()=>{const d={className:O.clsx("univer-fill-primary-600",n&&u),extend:{colorChannel1:s.isValid?e:""}};return c.jsx(l,{...d})};return n?v():c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(O.ColorPicker,{value:e,onChange:t})}),children:c.jsx("span",{className:O.clsx("univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-p-1 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",u),children:v()})})},ae=a=>{var u,s,v,d,h;const e=a.rule;if(!e)return null;const t=C.useMemo(()=>{if(e.type===r.CFRuleType.colorScale){const o=e.config.map((b,I)=>({color:new i.ColorKit(b.color),value:I})),p=o.length-1;return new Array(5).fill("").map((b,I,m)=>I*p/(m.length-1)).map(b=>r.getColorScaleFromValue(o,b))}return null},[e]),n=C.useMemo(()=>{if(e.type===r.CFRuleType.iconSet)return e.config.map(o=>{const p=r.iconMap[o.iconType];return p&&p[Number(o.iconId)]})},[e]),l="univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs";switch(e.type){case r.CFRuleType.dataBar:{const{isGradient:o}=e.config,p=o?`linear-gradient(to right, ${e.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:e.config.positiveColor,g=o?`linear-gradient(to right, rgb(255 255 255),${e.config.nativeColor||r.defaultDataBarNativeColor})`:e.config.nativeColor;return c.jsxs("div",{className:l,children:[c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:g,borderColor:(u=e.config.nativeColor)!=null?u:r.defaultDataBarNativeColor}}),c.jsx("div",{className:"univer-h-full univer-w-1/2 univer-border univer-border-solid",style:{background:p,borderColor:(s=e.config.positiveColor)!=null?s:r.defaultDataBarPositiveColor}})]})}case r.CFRuleType.colorScale:return t&&c.jsx("div",{className:l,children:t.map((o,p)=>c.jsx("div",{className:"univer-h-full",style:{width:`${100/t.length}%`,background:o}},p))});case r.CFRuleType.iconSet:return n&&c.jsx("div",{className:l,children:n.map((o,p)=>o?c.jsx("img",{className:"univer-h-full",src:o,draggable:!1},p):c.jsx(fe,{},p))});case r.CFRuleType.highlightCell:{const{ul:o,st:p,it:g,bl:b,bg:I,cl:m}=e.style,N=(o==null?void 0:o.s)===i.BooleanNumber.TRUE,_=(p==null?void 0:p.s)===i.BooleanNumber.TRUE,E=g===i.BooleanNumber.TRUE,M=b===i.BooleanNumber.TRUE,R=(v=I==null?void 0:I.rgb)!=null?v:r.DEFAULT_BG_COLOR,f=(d=m==null?void 0:m.rgb)!=null?d:r.DEFAULT_FONT_COLOR,T={textDecoration:(h=`${N?"underline":""} ${_?"line-through":""}`.replace(/^ /,""))!=null?h:void 0,backgroundColor:R,color:f};return c.jsx("div",{className:O.clsx(l,{"univer-font-bold":M,"univer-italic":E}),style:T,children:"123"})}}},he=O.clsx("univer-mt-5 univer-px-1 univer-py-2 univer-rounded",O.borderClassName),te=(a,e)=>({label:e.t(`sheet.cf.valueType.${a}`),value:a}),Ke=a=>{var I;const{type:e,className:t,onChange:n,id:l,value:u}=a,s=j.useDependency(i.IUniverInstanceService),v=s.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),d=(I=s.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:I.getSheetId(),h=C.useMemo(()=>String(u).startsWith("=")?String(u):"=",[u]),o=C.useMemo(()=>[r.CFValueType.max,r.CFValueType.min,"none"].includes(e)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(e)?{min:0,max:100}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[e]),p=C.useRef(null),[g,b]=C.useState(!1);return j.useSidebarClick(m=>{var _;(_=p.current)!=null&&_.isClickOutSide(m)&&b(!1)}),e===r.CFValueType.formula?c.jsx("div",{className:"univer-ml-1 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:p,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:h,unitId:v,subUnitId:d,isFocus:g,onChange:(m="")=>{n(m||"")},onFocus:()=>b(!0)})}):c.jsx(O.InputNumber,{className:t,value:Number(a.value)||0,onChange:m=>a.onChange(m||0),...o})},Hr=a=>{var L;const{interceptorManager:e}=a,t=j.useDependency(i.LocaleService),n=((L=a.rule)==null?void 0:L.type)===r.CFRuleType.colorScale?a.rule:void 0,l=[te(r.CFValueType.num,t),te(r.CFValueType.percent,t),te(r.CFValueType.percentile,t),te(r.CFValueType.formula,t)],u=[te(r.CFValueType.min,t),...l],s=[te("none",t),...l],v=[te(r.CFValueType.max,t),...l],[d,h]=C.useState(()=>{var x;const y=r.CFValueType.min;return n&&((x=n.config[0])==null?void 0:x.value.type)||y}),[o,p]=C.useState(()=>{var x;const y="none";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.value.type)||y}),[g,b]=C.useState(()=>{var x;const y=r.CFValueType.max;return n&&((x=n.config[n.config.length-1])==null?void 0:x.value.type)||y}),[I,m]=C.useState(()=>{if(!n)return 10;const x=n.config[0];return(x==null?void 0:x.value.value)===void 0?10:x==null?void 0:x.value.value}),[N,_]=C.useState(()=>{var $;if(!n||n.config.length!==3)return 50;const x=($=n.config[1])==null?void 0:$.value.value;return x===void 0?50:x}),[E,M]=C.useState(()=>{var $;if(!n)return 90;const x=($=n.config[n.config.length-1])==null?void 0:$.value.value;return x===void 0?90:x}),[R,f]=C.useState(()=>{var x;const y="#d0d9fb";return n&&((x=n.config[0])==null?void 0:x.color)||y}),[T,w]=C.useState(()=>{var x;const y="#7790f3";return!n||n.config.length!==3?y:((x=n.config[1])==null?void 0:x.color)||y}),[S,k]=C.useState(()=>{var x;const y="#2e55ef";return n&&((x=n.config[n.config.length-1])==null?void 0:x.color)||y}),V=C.useMemo(()=>y=>{const{minType:x,medianType:$,maxType:G,minValue:J,medianValue:Q,maxValue:oe,minColor:de,medianColor:A,maxColor:F}=y,H=[];return H.push({color:de,value:{type:x,value:J}}),$!=="none"&&H.push({color:A,value:{type:$,value:Q}}),H.push({color:F,value:{type:G,value:oe}}),{config:H.map((Z,z)=>({...Z,index:z})),type:r.CFRuleType.colorScale}},[]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return V({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),[V,d,o,g,I,N,E,R,T,S,e]);const P=y=>{a.onChange(V(y))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:V({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})})}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:u,value:d,onChange:y=>{h(y);const x=r.createDefaultValueByValueType(y,10);m(x),P({minType:y,medianType:o,maxType:g,minValue:x,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(Ke,{id:"min",className:"univer-ml-1",value:I,type:d,onChange:y=>{m(y),P({minType:d,medianType:o,maxType:g,minValue:y,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(re,{className:"univer-ml-1",color:R,onChange:y=>{f(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:y,medianColor:T,maxColor:S})}})]}),c.jsx("div",{className:"univer-text-gray-600dark:!univer-text-gray-200 univer-mt-3 univer-text-xs",children:t.t("sheet.cf.panel.medianValue")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:s,value:o,onChange:y=>{p(y);const x=r.createDefaultValueByValueType(y,50);_(x),P({minType:d,medianType:y,maxType:g,minValue:I,medianValue:x,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(Ke,{id:"median",className:"univer-ml-1",value:N,type:o,onChange:y=>{_(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:y,maxValue:E,minColor:R,medianColor:T,maxColor:S})}}),o!=="none"&&c.jsx(re,{className:"univer-ml-1",color:T,onChange:y=>{w(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:y,maxColor:S})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-h-8 univer-items-center",children:[c.jsx(O.Select,{className:"univer-flex-shrink-0",options:v,value:g,onChange:y=>{b(y);const x=r.createDefaultValueByValueType(y,90);M(x),P({minType:d,medianType:o,maxType:y,minValue:I,medianValue:N,maxValue:x,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(Ke,{id:"max",className:"univer-ml-1",value:E,type:g,onChange:y=>{M(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:y,minColor:R,medianColor:T,maxColor:S})}}),c.jsx(re,{className:"univer-ml-1",color:S,onChange:y=>{k(y),P({minType:d,medianType:o,maxType:g,minValue:I,medianValue:N,maxValue:E,minColor:R,medianColor:T,maxColor:y})}})]})]})},ue=(a,e)=>({label:e.t(`sheet.cf.valueType.${a}`),value:a}),fr=a=>{var m;const{onChange:e,className:t,value:n,type:l,id:u,disabled:s=!1}=a,v=j.useDependency(i.IUniverInstanceService),d=v.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),h=(m=v.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:m.getSheetId(),o=C.useRef(null),[p,g]=C.useState(!1);j.useSidebarClick(N=>{var E;(E=o.current)!=null&&E.isClickOutSide(N)&&g(!1)});const b=C.useRef(n),I=C.useMemo(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(l)?{max:100,min:0}:{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER},[l]);if(l===r.CFValueType.formula){const N=String(b.current).startsWith("=")?String(b.current)||"":"=";return c.jsx("div",{className:"univer-ml-3 univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:o,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:N,unitId:d,subUnitId:h,isFocus:p,onChange:(_="")=>{e(_||"")},onFocus:()=>g(!0)})})}return c.jsx(O.InputNumber,{className:t,value:Number(n)||0,disabled:s,onChange:N=>{e(N||0)},...I})},Wr=a=>{var L;const{interceptorManager:e}=a,t=j.useDependency(i.LocaleService),n=((L=a.rule)==null?void 0:L.type)===r.CFRuleType.dataBar?a.rule:void 0,[l,u]=C.useState(()=>{var x;return n&&(x=n.config)!=null&&x.isGradient?"1":"0"}),[s,v]=C.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.positiveColor)||r.defaultDataBarPositiveColor}),[d,h]=C.useState(()=>{var y;return n&&((y=n.config)==null?void 0:y.nativeColor)||r.defaultDataBarNativeColor}),o=[ue(r.CFValueType.num,t),ue(r.CFValueType.percent,t),ue(r.CFValueType.percentile,t),ue(r.CFValueType.formula,t)],p=[ue(r.CFValueType.min,t),...o],g=[ue(r.CFValueType.max,t),...o],[b,I]=C.useState(()=>{var x;const y=p[0].value;return n&&((x=n.config)==null?void 0:x.min.type)||y}),[m,N]=C.useState(()=>{var x;const y=g[0].value;return n&&((x=n.config)==null?void 0:x.max.type)||y}),[_,E]=C.useState(()=>{var $;if(!n)return 0;const x=(($=n.config)==null?void 0:$.min)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value||0}),[M,R]=C.useState(()=>{var $;if(!n)return 100;const x=(($=n.config)==null?void 0:$.max)||{};return x.type===r.CFValueType.formula?x.value||"=":x.value===void 0?100:x.value}),[f,T]=C.useState(()=>n?n.isShowValue===void 0?!0:!!n.isShowValue:!0),w=y=>({config:{min:{type:y.minValueType,value:y.minValue},max:{type:y.maxValueType,value:y.maxValue},isGradient:y.isGradient==="1",positiveColor:y.positiveColor||r.defaultDataBarPositiveColor,nativeColor:y.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:y.isShowValue});C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return w({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}}),[l,_,b,M,m,s,d,e,f]);const S=y=>{a.onChange(w(y))},k=y=>{v(y),S({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:y,nativeColor:d,isShowValue:f})},V=y=>{h(y),S({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:y,isShowValue:f})},P=y=>o.map(x=>x.value).includes(y);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:w({isGradient:l,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})})}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.fillType")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs(O.RadioGroup,{value:l,onChange:y=>{u(y),S({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})},children:[c.jsx(O.Radio,{value:"0",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.pureColor")})}),c.jsx(O.Radio,{value:"1",children:c.jsx("span",{className:"univer-text-xs",children:t.t("sheet.cf.panel.gradient")})})]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!f,onChange:y=>{T(!y),S({isGradient:y,minValue:_,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:!y})}}),t.t("sheet.cf.panel.onlyShowDataBar")]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.panel.colorSet")}),c.jsxs("div",{className:"univer-ml-1 univer-mt-3 univer-flex univer-items-center",children:[c.jsxs("div",{className:"univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.native")}),c.jsx(re,{color:d,onChange:V})]}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center",children:[c.jsx("div",{className:"univer-text-xs",children:t.t("sheet.cf.panel.positive")}),c.jsx(re,{color:s,onChange:k})]})]})]}),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.min")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:p,value:b,onChange:y=>{I(y);const x=r.createDefaultValueByValueType(y,10);E(x),S({isGradient:l,minValue:x,minValueType:y,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}}),c.jsx(fr,{id:"min",className:"univer-ml-3",disabled:!P(b),type:b,value:_,onChange:y=>{E(y||0),S({isGradient:l,minValue:y||0,minValueType:b,maxValue:M,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}})]}),c.jsx("div",{className:"univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:t.t("sheet.cf.valueType.max")}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.Select,{className:"univer-w-1/2 univer-flex-shrink-0",options:g,value:m,onChange:y=>{N(y);const x=r.createDefaultValueByValueType(y,90);R(x),S({isGradient:l,minValue:_,minValueType:b,maxValue:x,maxValueType:y,positiveColor:s,nativeColor:d,isShowValue:f})}}),c.jsx(fr,{className:"univer-ml-3",disabled:!P(m),id:"max",type:m,value:M,onChange:y=>{R(y||0),S({isGradient:l,minValue:_,minValueType:b,maxValue:y||0,maxValueType:m,positiveColor:s,nativeColor:d,isShowValue:f})}})]})]})]})},Ee=a=>[i.BooleanNumber.FALSE,void 0].includes(a)?i.BooleanNumber.TRUE:i.BooleanNumber.FALSE,Re=a=>a!==i.BooleanNumber.FALSE,Xe=a=>{const{style:e,onChange:t,className:n}=a,[l,u]=C.useState(()=>{if(e!=null&&e.bl)return e.bl}),[s,v]=C.useState(()=>{if(e!=null&&e.it)return e.it}),[d,h]=C.useState(()=>{if(e!=null&&e.ul)return e.ul.s}),[o,p]=C.useState(()=>{if(e!=null&&e.st)return e.st.s}),[g,b]=C.useState(()=>{var E;const _="#2f56ef";return(E=e==null?void 0:e.cl)!=null&&E.rgb?e.cl.rgb:_}),[I,m]=C.useState(()=>{var E;const _="#e8ecfc";return(E=e==null?void 0:e.bg)!=null&&E.rgb?e.bg.rgb:_});C.useEffect(()=>{const _={bl:l,it:s};g!==void 0&&(_.cl={rgb:g}),I!==void 0&&(_.bg={rgb:I}),o!==void 0&&(_.st={s:o}),d!==void 0&&(_.ul={s:d}),t(r.removeUndefinedAttr(_))},[l,s,d,o,g,I]);const N="univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1";return c.jsxs("div",{className:O.clsx("univer-my-2.5 univer-flex univer-justify-between",n),children:[c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(l||i.BooleanNumber.FALSE)}),onClick:()=>u(Ee(l)),children:c.jsx(ur,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(s||i.BooleanNumber.FALSE)}),onClick:()=>v(Ee(s)),children:c.jsx(ir,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(d||i.BooleanNumber.FALSE)}),onClick:()=>h(Ee(d)),children:c.jsx(dr,{})}),c.jsx("div",{className:O.clsx(N,{"univer-bg-gray-100 dark:!univer-bg-gray-700":Re(o||i.BooleanNumber.FALSE)}),onClick:()=>p(Ee(o)),children:c.jsx(or,{})}),c.jsx(re,{color:g,onChange:b,Icon:vr}),c.jsx(re,{color:I,onChange:m})]})},qr=a=>{var R;const{onChange:e,interceptorManager:t}=a,n=j.useDependency(i.LocaleService),u=j.useDependency(i.IUniverInstanceService).getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),s=u.getActiveSheet(),v=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?a.rule:void 0,d=C.useRef(null),[h,o]=C.useState(!1),p=C.useRef(null),[g,b]=C.useState({}),[I,m]=C.useState(()=>(v==null?void 0:v.subType)===r.CFSubRuleType.formula?v.value:"="),[N,_]=C.useState(void 0),E=f=>({style:f.style,value:I,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return E({style:g})}}),[g,I,t]),C.useEffect(()=>t.intercept(t.getInterceptPoints().beforeSubmit,{handler:(T,w,S)=>N||I.length===1||!I.startsWith("=")?(_(n.t("sheet.cf.errorMessage.formulaError")),!1):S(T)}),[N,I]);const M=f=>{e(E(f))};return j.useSidebarClick(f=>{var w;(w=p.current)!=null&&w.isClickOutSide(f)&&o(!1)}),c.jsxs("div",{ref:d,children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(ve.FormulaEditor,{ref:p,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),errorText:N,isFocus:h,initValue:I,unitId:u.getUnitId(),subUnitId:s==null?void 0:s.getSheetId(),onFocus:()=>{o(!0)},onChange:f=>{m(f),M({style:g})},onVerify:(f,T)=>{!f||T.length===1?_(n.t("sheet.cf.errorMessage.formulaError")):_(void 0)}})}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:E({style:g})})}),c.jsx(Xe,{style:v==null?void 0:v.style,className:"univer-mt-3",onChange:f=>{b(f),M({style:f})}})]})},Me=a=>c.jsxs("div",{className:"univer-relative",children:[c.jsx("div",{className:"univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500",children:a.errorText}),a.children]}),B=(a,e)=>({label:e.t(`sheet.cf.operator.${a}`),value:a}),Gr=a=>{const{type:e,operator:t,onChange:n,value:l,interceptorManager:u}=a,s=j.useDependency(i.LocaleService),[v,d]=C.useState(()=>typeof l=="number"?l:0),[h,o]=C.useState(""),[p,g]=C.useState(()=>typeof l=="string"?l:""),[b,I]=C.useState(""),[m,N]=C.useState(()=>Array.isArray(l)?l[0]===void 0?0:l[0]:0),[_,E]=C.useState(""),[M,R]=C.useState(()=>Array.isArray(l)?l[1]===void 0?100:l[1]:100),[f,T]=C.useState("");switch(C.useEffect(()=>{switch(e){case r.CFSubRuleType.text:{[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)&&n(p);break}case r.CFSubRuleType.number:{[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)&&n(v),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)&&n([m,M]);break}}},[e]),C.useEffect(()=>{const w=u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(S,k,V)=>{switch(e){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(t))return p?V(S):(I(s.t("sheet.cf.errorMessage.notBlank")),!1)}return V(S)}});return()=>{w()}},[e,v,p,t]),e){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(t)){const w=S=>{g(S),n(S)};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:b,children:c.jsx(O.Input,{value:p,onChange:S=>{I(""),w(S)}})})})}break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(t)){const w=S=>{d(S||0),n(S||0),o("")};return c.jsx("div",{className:"univer-mt-3",children:c.jsx(Me,{errorText:h,children:c.jsx(O.InputNumber,{className:"univer-w-full",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:v,onChange:w})})})}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(t)){const w=k=>{N(k||0),n([k||0,M]),E("")},S=k=>{R(k||0),n([m,k||0]),T("")};return c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(Me,{errorText:_,children:c.jsx(O.InputNumber,{min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:m,onChange:w})}),c.jsx(Me,{errorText:f,children:c.jsx(O.InputNumber,{className:"univer-ml-3",min:Number.MIN_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER,value:M,onChange:S})})]})}}}return null},hr=(a,e)=>{switch(a){case r.CFSubRuleType.text:return[B(r.CFTextOperator.containsText,e),B(r.CFTextOperator.notContainsText,e),B(r.CFTextOperator.beginsWith,e),B(r.CFTextOperator.endsWith,e),B(r.CFTextOperator.equal,e),B(r.CFTextOperator.notEqual,e),B(r.CFTextOperator.containsBlanks,e),B(r.CFTextOperator.notContainsBlanks,e),B(r.CFTextOperator.containsErrors,e),B(r.CFTextOperator.notContainsErrors,e)];case r.CFSubRuleType.number:return[B(r.CFNumberOperator.between,e),B(r.CFNumberOperator.notBetween,e),B(r.CFNumberOperator.equal,e),B(r.CFNumberOperator.notEqual,e),B(r.CFNumberOperator.greaterThan,e),B(r.CFNumberOperator.greaterThanOrEqual,e),B(r.CFNumberOperator.lessThan,e),B(r.CFNumberOperator.lessThanOrEqual,e)];case r.CFSubRuleType.timePeriod:return[B(r.CFTimePeriodOperator.yesterday,e),B(r.CFTimePeriodOperator.today,e),B(r.CFTimePeriodOperator.tomorrow,e),B(r.CFTimePeriodOperator.last7Days,e),B(r.CFTimePeriodOperator.lastWeek,e),B(r.CFTimePeriodOperator.thisWeek,e),B(r.CFTimePeriodOperator.nextWeek,e),B(r.CFTimePeriodOperator.lastMonth,e),B(r.CFTimePeriodOperator.thisMonth,e),B(r.CFTimePeriodOperator.nextMonth,e)]}},gr=a=>{var R;const{interceptorManager:e,onChange:t}=a,n=j.useDependency(i.LocaleService),l=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.highlightCell?a.rule:void 0,[u,s]=C.useState(()=>{const f=r.CFSubRuleType.text;return l&&l.subType||f}),v=[{value:r.CFSubRuleType.text,label:n.t("sheet.cf.subRuleType.text")},{value:r.CFSubRuleType.number,label:n.t("sheet.cf.subRuleType.number")},{value:r.CFSubRuleType.timePeriod,label:n.t("sheet.cf.subRuleType.timePeriod")},{value:r.CFSubRuleType.duplicateValues,label:n.t("sheet.cf.subRuleType.duplicateValues")},{value:r.CFSubRuleType.uniqueValues,label:n.t("sheet.cf.subRuleType.uniqueValues")}],d=C.useMemo(()=>hr(u,n),[u]),[h,o]=C.useState(()=>{const f=d?d[0].value:void 0;return l&&l.operator||f}),[p,g]=C.useState(()=>{var w;return l?(w=l.value)!=null?w:r.createDefaultValue(l.subType,l.operator):""}),[b,I]=C.useState({}),m=C.useMemo(()=>f=>{var T,w,S,k,V,P,L,y,x,$,G,J,Q,oe,de;switch(f.subType||u){case r.CFSubRuleType.text:{if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(h))return{type:r.CFRuleType.highlightCell,subType:(T=f.subType)!=null?T:u,operator:(w=f.operator)!=null?w:h,style:(S=f.style)!=null?S:b,value:(k=f.value)!=null?k:p};break}case r.CFSubRuleType.number:{if([r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(h))return{type:r.CFRuleType.highlightCell,subType:(V=f.subType)!=null?V:u,operator:(P=f.operator)!=null?P:h,style:(L=f.style)!=null?L:b,value:(y=f.value)!=null?y:p};if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(h))return{type:r.CFRuleType.highlightCell,subType:(x=f.subType)!=null?x:u,operator:($=f.operator)!=null?$:h,style:(G=f.style)!=null?G:b,value:(J=f.value)!=null?J:p};break}}return{type:r.CFRuleType.highlightCell,subType:(Q=f.subType)!=null?Q:u,operator:(oe=f.operator)!=null?oe:h,style:(de=f.style)!=null?de:b}},[u,h,p,b]);C.useEffect(()=>e.intercept(e.getInterceptPoints().submit,{handler(){return m({})}}),[m,e]),C.useEffect(()=>{v.some(f=>f.value===u)||s(v[0].value)},[v]);const N=f=>{const T=f,w=hr(T,n),S=w&&w[0].value;s(T),o(S),S&&g(r.createDefaultValue(T,S)),t(m({subType:T,operator:S}))},_=f=>{const T=f;o(T),t(m({operator:T}))},E=f=>{g(f),t(m({value:f}))},M=C.useMemo(()=>`${u}_${h}_${Math.random()}`,[u,h]);return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsxs("div",{className:"univer-flex univer-justify-between univer-gap-4",children:[c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:N,value:u,options:v}),(d==null?void 0:d.length)&&c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",onChange:_,value:h||"",options:d})]}),c.jsx(Gr,{value:p,interceptorManager:e,type:u,operator:h,rule:l,onChange:E},M),c.jsx("div",{className:he,children:c.jsx(ae,{rule:m({})})}),c.jsx(Xe,{style:l==null?void 0:l.style,className:"univer-ml-1",onChange:f=>{I(f),t(m({style:f}))}})]})},yr=(a,e)=>(r.iconMap[a]||[])[Number(e)]||"",Zr=a=>{var o;const{error:e,type:t,onChange:n}=a,l=j.useDependency(i.IUniverInstanceService),u=l.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),s=(o=l.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId(),v=C.useRef(null),[d,h]=C.useState(!1);return j.useSidebarClick(p=>{var b;(b=v.current)!=null&&b.isClickOutSide(p)&&h(!1)}),c.jsx("div",{className:"univer-relative",children:t!==r.CFValueType.formula?c.jsxs(c.Fragment,{children:[c.jsx(O.InputNumber,{className:O.clsx({"univer-border-red-500":e}),value:Number(a.value)||0,onChange:p=>n(p!=null?p:0)}),e&&c.jsx("div",{className:"univer-absolute univer-text-xs univer-text-red-500",children:e})]}):c.jsx("div",{className:"univer-w-full",children:c.jsx(ve.FormulaEditor,{ref:v,className:O.clsx("univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent",O.borderClassName),initValue:String(a.value),unitId:u,subUnitId:s,isFocus:d,onChange:(p="")=>{n(p||"")},onFocus:()=>h(!0)})})})},Cr=(a,e,t)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(t.length-1-e)*10},iconType:a,iconId:String(e)}),zr=C.forwardRef((a,e)=>{const{onClick:t}=a,n=j.useDependency(i.LocaleService),l=u=>{t(u)};return c.jsx("div",{ref:e,className:"univer-w-80",children:r.iconGroup.map((u,s)=>c.jsxs("div",{className:"univer-mb-3",children:[c.jsx("div",{className:"univer-mb-1 univer-text-sm",children:n.t(u.title)}),c.jsx("div",{className:"univer-flex univer-flex-wrap",children:u.group.map(v=>c.jsx("div",{className:"univer-mb-1 univer-flex univer-w-1/2 univer-items-center",onClick:()=>{l(v.name)},children:c.jsx("a",{className:"univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:v.list.map((d,h)=>c.jsx("img",{className:"univer-size-5",src:d,draggable:!1},h))})},v.name))})]},s))})}),Yr=a=>{const{onClick:e}=a,t=C.useMemo(()=>{const l=[];for(const u in r.iconMap){const s=r.iconMap[u],v=u;s.forEach((d,h)=>{l.push({iconType:v,base64:d,iconId:String(h)})})}return l},[]),n=l=>{e(l.iconType,l.iconId)};return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1",onClick:()=>n({iconType:r.EMPTY_ICON_TYPE,iconId:""}),children:[c.jsx(fe,{className:"univer-size-5"}),c.jsx("span",{className:"univer-ml-2",children:"无单元格图标"})]}),c.jsx("div",{className:"univer-flex univer-w-64 univer-flex-wrap",children:t.map(l=>c.jsx("div",{className:"univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",children:c.jsx("img",{className:"univer-size-5",src:l.base64,draggable:!1,onClick:()=>n(l)})},`${l.iconType}_${l.iconId}`))})]})},Kr=a=>{const{onChange:e,configList:t,errorMap:n={}}=a,l=j.useDependency(i.LocaleService),u=[{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:l.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],s=[{label:l.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:l.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:l.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],v=(p,g)=>{e([String(g),"value","value"],p)},d=(p,g)=>{e([String(g),"operator"],p);const b=r.createDefaultValue(r.CFSubRuleType.number,p);v(b,g)},h=(p,g)=>{e([String(g),"value","type"],p);const b=t[g],I=r.createDefaultValue(r.CFSubRuleType.number,b.operator);v(I,g)};return C.useMemo(()=>t.map((p,g)=>{const b=n[g],I=yr(p.iconType,p.iconId),m=g===t.length-1,N=g===0,_=t[g-1],E=(_==null?void 0:_.value.type)===r.CFValueType.formula?l.t("sheet.cf.valueType.formula"):_==null?void 0:_.value.value,M=(R,f)=>{const T={...p,iconId:f,iconType:R};e([String(g)],T)};return c.jsxs("div",{className:g?"univer-mt-6":"univer-mt-3",children:[c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsxs("div",{className:"univer-w-[45%]",children:[l.t("sheet.cf.iconSet.icon"),g+1]}),c.jsx("div",{className:"univer-w-[45%]",children:c.jsxs(c.Fragment,{children:[!N&&!m&&l.t("sheet.cf.iconSet.rule"),!N&&!m&&c.jsxs("span",{className:"univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),E,m?"":` ${l.t("sheet.cf.iconSet.and")} `]})]})})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx("div",{className:"univer-flex univer-items-center",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(Yr,{onClick:M,iconId:p.iconId,iconType:p.iconType})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600 dark:!univer-text-gray-200",O.borderClassName),children:[I?c.jsx("img",{src:I,className:"univer-size-4",draggable:!1}):c.jsx(fe,{className:"univer-size-4"}),c.jsx(Ye,{})]})})}),m?c.jsxs("div",{className:"univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[l.t("sheet.cf.iconSet.rule"),c.jsxs("span",{className:"univer-font-medium",children:[l.t("sheet.cf.iconSet.when"),l.t(`sheet.cf.symbol.${r.getOppositeOperator(_.operator)}`),E,m?"":` ${l.t("sheet.cf.iconSet.and")} `]})]}):c.jsx(O.Select,{options:u,value:p.operator,onChange:R=>{d(R,g)}})]}),m?c.jsx("div",{}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:[c.jsx("div",{children:l.t("sheet.cf.iconSet.type")}),c.jsx("div",{children:l.t("sheet.cf.iconSet.value")})]}),c.jsxs("div",{className:"univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4",children:[c.jsx(O.Select,{options:s,value:p.value.type,onChange:R=>{h(R,g)}}),c.jsx(Zr,{id:g,type:p.value.type,error:b,value:p.value.value||"",onChange:R=>{v(R,g)}})]})]})]},g)}),[t,n])},Xr=a=>{var R;const{interceptorManager:e}=a,t=((R=a.rule)==null?void 0:R.type)===r.CFRuleType.iconSet?a.rule:void 0,n=j.useDependency(i.LocaleService),[l,u]=C.useState({}),[s,v]=C.useState(()=>{const f=Object.keys(r.iconMap)[0];if(t&&t.config.length){const T=t.config[0].iconType;if(!t.config.some(S=>S.iconType!==T))return T}return f}),[d,h]=C.useState(()=>{if(t&&t.config.length)return i.Tools.deepClone(t==null?void 0:t.config);const f=r.iconMap[s]||[];return new Array(f.length).fill("").map((T,w,S)=>w===S.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:Number.MAX_SAFE_INTEGER},iconType:s,iconId:String(w)}:Cr(s,w,S))}),[o,p]=C.useState(()=>t?!!t.isShowValue:!0),g=C.useMemo(()=>{const f=d.map(T=>yr(T.iconType,T.iconId));return c.jsx("div",{className:"univer-flex univer-items-center",children:f.map((T,w)=>T?c.jsx("img",{className:"univer-size-5",src:T},w):c.jsx(fe,{className:"univer-size-5"},w))})},[d]),b=f=>{if(f.reduce((w,S,k)=>w.preType&&!w.result||f.length-1===k?w:S.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:w.preType?{result:w.preType===S.value.type,preType:S.value.type}:{result:!0,preType:S.value.type},{result:!0,preType:""}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(f[0].value.type)){const w={};return f.forEach((S,k,V)=>{if(k-1<0||k===V.length-1)return;const L=f[k-1],y=r.getOppositeOperator(L.operator);r.compareWithNumber({operator:y,value:L.value.value},S.value.value)||(w[k]=`${n.t(`sheet.cf.form.${y}`,String(L.value.value))} `)}),w}return{}},I=(f,T)=>{i.get(d,f)!==T&&(i.set(d,f,T),h([...d]),u(b(d)))},m=f=>{v(f);const T=r.iconMap[f]||[],w=new Array(T.length).fill("").map((S,k,V)=>Cr(f,k,V));h(w),u(b(w))};C.useEffect(()=>{const f=e.intercept(e.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:o,config:d}}});return()=>{f()}},[o,d,e]),C.useEffect(()=>{const f=e.intercept(e.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(l).length===0}});return()=>{f()}},[o,d,e,l]);const N=()=>{const f=d.map(T=>({...T}));d.forEach((T,w)=>{const S=d.length-1-w,k=f[S];T.iconId=k.iconId,T.iconType=k.iconType}),h([...d])},_=j.useDependency(j.ILayoutService),[E,M]=C.useState();return j.useScrollYOverContainer(E,_.rootContainerElement),c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600",children:n.t("sheet.cf.panel.styleRule")}),c.jsx("div",{className:"univer-mt-3",children:c.jsx(O.Dropdown,{overlay:c.jsx("div",{className:"univer-rounded-lg univer-p-4",children:c.jsx(zr,{ref:f=>{!E&&f&&M(f)},iconType:s,onClick:m})}),children:c.jsxs("div",{className:O.clsx("univer-box-border univer-flex univer-h-8 univer-w-full univer-items-center univer-justify-between univer-rounded-md univer-bg-white univer-px-4 univer-py-2 univer-text-xs univer-text-gray-600 univer-transition-all hover:univer-border-primary-600",O.borderClassName),children:[g,c.jsx(Ye,{})]})})}),c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center univer-text-xs",children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{onChange:N}),n.t("sheet.cf.iconSet.reverseIconOrder")]}),c.jsxs("div",{className:"univer-ml-6 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:!o,onChange:f=>{p(!f)}}),n.t("sheet.cf.iconSet.onlyShowIcon")]})]}),c.jsx(Kr,{errorMap:l,onChange:I,configList:d})]})},Jr=a=>{var N;const{onChange:e,interceptorManager:t}=a,n=j.useDependency(i.LocaleService),l=((N=a.rule)==null?void 0:N.type)===r.CFRuleType.highlightCell?a.rule:void 0,u=[{label:n.t("sheet.cf.panel.isNotBottom"),value:"isNotBottom"},{label:n.t("sheet.cf.panel.isBottom"),value:"isBottom"},{label:n.t("sheet.cf.panel.greaterThanAverage"),value:"greaterThanAverage"},{label:n.t("sheet.cf.panel.lessThanAverage"),value:"lessThanAverage"}],[s,v]=C.useState(()=>{const _=u[0].value,E=l==null?void 0:l.type;if(!l)return _;switch(E){case r.CFRuleType.highlightCell:switch(l.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(l.operator)?"greaterThanAverage":[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(l.operator)?"lessThanAverage":_;case r.CFSubRuleType.rank:return l.isBottom?"isBottom":"isNotBottom"}}return _}),[d,h]=C.useState(()=>{const E=l==null?void 0:l.type;if(!l)return 10;switch(E){case r.CFRuleType.highlightCell:if(l.subType===r.CFSubRuleType.rank)return l.value||10}return 10}),[o,p]=C.useState(()=>{const E=l==null?void 0:l.type;if(!l)return!1;switch(E){case r.CFRuleType.highlightCell:if(l.subType===r.CFSubRuleType.rank)return l.isPercent||!1}return!1}),[g,b]=C.useState({}),I=_=>{const{type:E,isPercent:M,value:R,style:f}=_;if(E==="isNotBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!1,value:R,style:f};if(E==="isBottom")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:M,isBottom:!0,value:R,style:f};if(E==="greaterThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:f};if(E==="lessThanAverage")return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:f}};C.useEffect(()=>t.intercept(t.getInterceptPoints().submit,{handler(){return I({type:s,isPercent:o,value:d,style:g})}}),[s,o,d,g,t]);const m=_=>{e(I(_))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:n.t("sheet.cf.panel.styleRule")}),c.jsx(O.Select,{className:"univer-mt-3 univer-w-full",value:s,options:u,onChange:_=>{v(_),m({type:_,isPercent:o,value:d,style:g})}}),["isNotBottom","isBottom"].includes(s)&&c.jsxs("div",{className:"univer-mt-3 univer-flex univer-items-center",children:[c.jsx(O.InputNumber,{min:1,max:1e3,value:d,onChange:_=>{const E=_||0;h(E),m({type:s,isPercent:o,value:E,style:g})}}),c.jsxs("div",{className:"univer-ml-3 univer-flex univer-items-center univer-text-xs",children:[c.jsx(O.Checkbox,{checked:o,onChange:_=>{p(!!_),m({type:s,isPercent:!!_,value:d,style:g})}}),n.t("sheet.cf.valueType.percent")]})]}),c.jsx("div",{className:he,children:c.jsx(ae,{rule:I({type:s,isPercent:o,value:d,style:g})})}),c.jsx(Xe,{style:l==null?void 0:l.style,className:"univer-mt-3",onChange:_=>{b(_),m({type:s,isPercent:o,value:d,style:_})}})]})},Qr=i.createInterceptorKey("beforeSubmit"),et=i.createInterceptorKey("submit"),mr=a=>a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),br=a=>{var e;return(e=a.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:e.getSheetId()},rt=a=>{var w,S,k;const e=j.useDependency(i.LocaleService),t=j.useDependency(i.ICommandService),n=j.useDependency(i.IUniverInstanceService),l=j.useDependency(r.ConditionalFormattingRuleModel),u=j.useDependency(U.SheetsSelectionsService),s=mr(n),v=br(n),[d,h]=C.useState(void 0),o=C.useRef((S=(w=a.rule)==null?void 0:w.ranges)!=null?S:[]),p=C.useMemo(()=>{var P,L,y;let V=(P=a.rule)==null?void 0:P.ranges;return V!=null&&V.length||(V=(y=(L=u.getCurrentSelections())==null?void 0:L.map(x=>x.range))!=null?y:[]),o.current=V,V!=null&&V.length?V.map(x=>{const $=Ae.serializeRange(x);return $==="NaN"?"":$}).filter(x=>!!x).join(","):""},[a.rule]),g=[{label:e.t("sheet.cf.ruleType.highlightCell"),value:"1"},{label:e.t("sheet.cf.panel.rankAndAverage"),value:"2"},{label:e.t("sheet.cf.ruleType.dataBar"),value:"3"},{label:e.t("sheet.cf.ruleType.colorScale"),value:"4"},{label:e.t("sheet.cf.ruleType.formula"),value:"5"},{label:e.t("sheet.cf.ruleType.iconSet"),value:"6"}],[b,I]=C.useState(()=>{var L,y;const V=(L=a.rule)==null?void 0:L.rule.type,P=g[0].value;if(!V)return P;switch(V){case r.CFRuleType.highlightCell:{switch((y=a.rule)==null?void 0:y.rule.subType){case r.CFSubRuleType.number:case r.CFSubRuleType.text:case r.CFSubRuleType.duplicateValues:case r.CFSubRuleType.uniqueValues:case r.CFSubRuleType.timePeriod:return"1";case r.CFSubRuleType.average:case r.CFSubRuleType.rank:return"2";case r.CFSubRuleType.formula:return"5"}break}case r.CFRuleType.dataBar:return"3";case r.CFRuleType.colorScale:return"4";case r.CFRuleType.iconSet:return"6"}return P}),m=C.useRef(void 0),N=C.useMemo(()=>new i.InterceptorManager({beforeSubmit:Qr,submit:et}),[]),_=C.useMemo(()=>{switch(b){case"1":return gr;case"2":return Jr;case"3":return Wr;case"4":return Hr;case"5":return qr;case"6":return Xr;default:return gr}},[b]);C.useEffect(()=>{const V=t.onCommandExecuted(P=>{if(P.id===U.RemoveSheetMutation.id){const L=P.params;L.subUnitId===v&&L.unitId===s&&a.onCancel()}P.id===U.SetWorksheetActiveOperation.id&&a.onCancel()});return()=>V.dispose()},[]);const E=V=>{m.current=V},M=V=>{const P=V.split(",").filter(L=>!!L).map(Ae.deserializeRangeWithSheet).map(L=>L.range);o.current=P},R=()=>{if(d)return;const P=(()=>{const y=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!y)throw new Error("No active sheet found");return o.current.map(G=>U.setEndForRange(G,y.getRowCount(),y.getColumnCount())).filter(G=>!(Number.isNaN(G.startRow)||Number.isNaN(G.startColumn)))})();if(N.fetchThroughInterceptors(N.getInterceptPoints().beforeSubmit)(!0,null)){const y=N.fetchThroughInterceptors(N.getInterceptPoints().submit)(null,null);if(y){const x=mr(n),$=br(n);if(!x||!$)throw new Error("No active sheet found");let G={};a.rule&&a.rule.cfId?(G={...a.rule,ranges:P,rule:y},t.executeCommand(r.SetCfCommand.id,{unitId:x,subUnitId:$,rule:G}),a.onCancel()):(G={cfId:l.createCfId(x,$),ranges:P,rule:y,stopIfTrue:!1},t.executeCommand(r.AddCfCommand.id,{unitId:x,subUnitId:$,rule:G}),a.onCancel())}}},f=()=>{a.onCancel()},T=(V,P)=>{V?P.length<1?h(e.t("sheet.cf.errorMessage.rangeError")):h(void 0):h(e.t("sheet.cf.errorMessage.rangeError"))};return c.jsxs("div",{children:[c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.range")}),c.jsxs("div",{className:"univer-mt-4",children:[c.jsx(ve.RangeSelector,{unitId:s,subUnitId:v,initialValue:p,onChange:(V,P)=>M(P),onVerify:T}),d&&c.jsx("div",{className:"univer-mt-1 univer-text-xs univer-text-red-500",children:d})]}),c.jsx("div",{className:"univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200",children:e.t("sheet.cf.panel.styleType")}),c.jsx(O.Select,{className:"univer-mt-4 univer-w-full",value:b,options:g,onChange:V=>I(V)}),c.jsx(_,{interceptorManager:N,rule:(k=a.rule)==null?void 0:k.rule,onChange:E}),c.jsxs("div",{className:"univer-mt-4 univer-flex univer-justify-end",children:[c.jsx(O.Button,{onClick:f,children:e.t("sheet.cf.panel.cancel")}),c.jsx(O.Button,{className:"univer-ml-3",variant:"primary",onClick:R,children:e.t("sheet.cf.panel.submit")})]})]})};var tt=Object.getOwnPropertyDescriptor,nt=(a,e,t,n)=>{for(var l=n>1?void 0:n?tt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},lt=(a,e)=>(t,n)=>e(t,n,a);let se=class extends i.Disposable{constructor(e){super();ee(this,"_initLocal",()=>{});ee(this,"_findReplaceIndex",e=>{const t=/\{([^}]+)?\}/g,n=[];let l=t.exec(e);for(;l;)n.push({startIndex:l.index,key:Number(l[1]),endIndex:l.index+l[0].length-1}),l=t.exec(e);return n});this._localeService=e,this._initLocal()}tWithReactNode(e,...t){const n=this._localeService.getLocales(),l=e.split("."),u=n&&this._localeService.resolveKeyPath(n,l);if(typeof u=="string"){const s=[];return this._findReplaceIndex(u).forEach((v,d,h)=>{const o=h[d-1]||{endIndex:-1};if(o.endIndex+1<v.startIndex){const p=u.slice(o.endIndex+1,v.startIndex);p&&s.push(p)}if(t[v.key]&&s.push(t[v.key]),d===h.length-1){const p=u.slice(v.endIndex+1);p&&s.push(p)}}),s}return[]}};se=nt([lt(0,i.Inject(i.LocaleService))],se);const at=(a,e)=>{const t=a.rule;switch(t.type){case r.CFRuleType.colorScale:return e.t("sheet.cf.ruleType.colorScale");case r.CFRuleType.dataBar:return e.t("sheet.cf.ruleType.dataBar");case r.CFRuleType.iconSet:return e.t("sheet.cf.ruleType.iconSet");case r.CFRuleType.highlightCell:switch(t.subType){case r.CFSubRuleType.average:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,e.t("sheet.cf.subRuleType.average"))}case r.CFSubRuleType.duplicateValues:return e.t("sheet.cf.subRuleType.duplicateValues");case r.CFSubRuleType.uniqueValues:return e.t("sheet.cf.subRuleType.uniqueValues");case r.CFSubRuleType.number:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,...Array.isArray(t.value)?t.value.map(l=>String(l)):[String(t.value||"")])}case r.CFSubRuleType.text:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`,t.value||"")}case r.CFSubRuleType.timePeriod:{const n=t.operator;return e.t(`sheet.cf.preview.describe.${n}`)}case r.CFSubRuleType.rank:return t.isPercent?t.isBottom?e.t("sheet.cf.preview.describe.bottomNPercent",String(t.value)):e.t("sheet.cf.preview.describe.topNPercent",String(t.value)):t.isBottom?e.t("sheet.cf.preview.describe.bottomN",String(t.value)):e.t("sheet.cf.preview.describe.topN",String(t.value));case r.CFSubRuleType.formula:return e.t("sheet.cf.ruleType.formula")}}};let Sr=0;const ut=a=>{const{onClick:e}=a,t=j.useDependency(r.ConditionalFormattingRuleModel),n=j.useDependency(i.IUniverInstanceService),l=j.useDependency(U.SheetsSelectionsService),u=j.useDependency(i.ICommandService),s=j.useDependency(i.LocaleService),v=j.useDependency(i.Injector),d=j.useDependency(j.ISidebarService),h=j.useDependency(se),o=j.useObservable(()=>n.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),p=o.getUnitId(),g=o.getActiveSheet();if(!g)throw new Error("No active sheet found");const b=g.getSheetId(),[I,m]=C.useState([]),[N,_]=C.useState("2"),[E,M]=C.useState(0),[R,f]=C.useState(-1),[T,w]=C.useState(Sr),S=C.useRef(null),k=[{label:s.t("sheet.cf.panel.workSheet"),value:"2"},{label:s.t("sheet.cf.panel.selectedRange"),value:"1"}],V=()=>{const A=t.getSubunitRules(p,b);if(!A||!A.length)return[];if(N==="1"){const F=l.getCurrentLastSelection();if(!F)return[];const H=F.range;return A.filter(Z=>Z.ranges.some(z=>i.Rectangle.intersects(z,H)))}else if(N==="2")return[...A];return[]},[P,L]=C.useState(V);W.useHighlightRange(I),C.useEffect(()=>{const A=u.onCommandExecuted(F=>{F.id===U.SetWorksheetActiveOperation.id&&M(Math.random())});return()=>A.dispose()}),C.useEffect(()=>{L(V)},[N,E,p,b]),C.useEffect(()=>{if(N==="2")return;const A=new X.Observable(F=>{const H=[U.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],q=u.onCommandExecuted(Z=>{const{id:z,params:ne}=Z,le=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();H.includes(z)&&ne.unitId===le&&F.next(null)});return()=>q.dispose()}).pipe(X.debounceTime(16)).subscribe(()=>{L(V)});return()=>{A.unsubscribe()}},[n,N,p,b]),C.useEffect(()=>{const A=t.$ruleChange.subscribe(()=>{M(Math.random())});return()=>A.unsubscribe()},[t]),C.useEffect(()=>{const A=()=>{var Z,z;const q=Math.max(0,((z=(Z=S.current)==null?void 0:Z.getBoundingClientRect().width)!=null?z:0)-8);return Sr=q,q},H=new X.Observable(q=>{const Z=d.getContainer();if(Z){let z=setTimeout(()=>{q.next(void 0)},150);const ne=()=>{z&&clearTimeout(z),z=null},le=je=>{je.propertyName==="width"&&(ne(),q.next(void 0))};return Z.addEventListener("transitionend",le),()=>{ne(),Z.removeEventListener("transitionend",le)}}}).pipe(X.debounceTime(16)).subscribe(()=>{w(A())});return()=>{H.unsubscribe()}},[]);const y=A=>{var q;const F=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),H=(q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:q.getSheetId();if(!F||!H)throw new Error("No active sheet found");u.executeCommand(r.DeleteCfCommand.id,{unitId:F,subUnitId:H,cfId:A.cfId})},x=(A,F)=>{f(F.y)},$=(A,F,H)=>{var je;f(-1);const q=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),Z=(je=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:je.getSheetId();if(!q||!Z)throw new Error("No active sheet found");const z=Ft=>{const Bt=P.length;return Math.min(Bt-1,Math.max(0,Ft))},ne=P[z(F.y)].cfId,le=P[z(H.y)].cfId;ne!==le&&u.executeCommand(r.MoveCfCommand.id,{unitId:q,subUnitId:Z,start:{id:ne,type:"self"},end:{id:le,type:H.y>F.y?"after":"before"}})},G=()=>{a.onCreate()},J=()=>{N==="2"?u.executeCommand(r.ClearWorksheetCfCommand.id):N==="1"&&P.map(F=>({unitId:p,subUnitId:b,cfId:F.cfId})).forEach(F=>{u.executeCommand(r.DeleteCfCommand.id,F)})},Q=C.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return P.filter(H=>{const q=H.ranges;return U.checkRangesEditablePermission(v,A.getUnitId(),F.getSheetId(),q)})},[P]),oe=Q.map((A,F)=>({i:A.cfId,x:0,w:12,y:F,h:1,isResizable:!1})),de=C.useMemo(()=>{const A=n.getCurrentUnitOfType(i.UniverInstanceType.UNIVER_SHEET),F=A.getActiveSheet();return P.every(H=>{const q=H.ranges;return U.checkRangesEditablePermission(v,A.getUnitId(),F.getSheetId(),q)})},[P]);return c.jsxs("div",{children:[c.jsxs("div",{className:"univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm",children:[c.jsx("div",{className:"univer-flex univer-items-center univer-gap-2",children:h.tWithReactNode("sheet.cf.panel.managerRuleSelect",c.jsx(O.Select,{className:"univer-w-36",options:k,value:N,onChange:A=>{_(A)}})).map((A,F)=>c.jsx("span",{children:A},F))}),c.jsxs("div",{className:"univer-flex univer-justify-end",children:[c.jsx(O.Tooltip,{title:s.t("sheet.cf.panel.createRule"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:G,children:c.jsx(sr,{})})}),P.length&&de?c.jsx(O.Tooltip,{title:s.t("sheet.cf.panel.clear"),placement:"bottom",children:c.jsx("a",{className:"univer-size-5 univer-cursor-pointer",onClick:J,children:c.jsx(Ne,{className:"univer-text-red-500"})})}):c.jsx("div",{children:c.jsx(Ne,{className:"univer-text-gray-300"})})]})]}),c.jsx("div",{ref:S,children:T>0&&c.jsx(O.ReactGridLayout,{className:"[&_.react-grid-item]:univer-transition-none [&_.react-grid-placeholder]:univer-rounded [&_.react-grid-placeholder]:!univer-bg-gray-200",draggableHandle:".draggableHandle",layout:oe,cols:12,rowHeight:60,width:T,margin:[0,10],onDragStop:$,onDragStart:x,children:Q==null?void 0:Q.map((A,F)=>c.jsx("div",{children:c.jsxs("div",{className:O.clsx("univer-group univer-relative univer-flex univer-items-center univer-justify-between univer-rounded univer-py-2 univer-pl-5 univer-pr-8 hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700",{"univer-bg-gray-100 dark:!univer-bg-gray-700":R===F}),onMouseMove:()=>{A.ranges!==I&&m(A.ranges)},onMouseLeave:()=>m([]),onClick:()=>{e(A)},children:[c.jsx("div",{className:O.clsx("univer-absolute univer-left-0 univer-hidden univer-size-5 univer-cursor-grab univer-items-center univer-justify-center univer-rounded group-hover:univer-flex","draggableHandle"),onClick:H=>H.stopPropagation(),children:c.jsx(cr,{})}),c.jsxs("div",{className:"univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden",children:[c.jsx("div",{className:"univer-text-sm univer-text-gray-900 dark:!univer-text-white",children:at(A,s)}),c.jsx("div",{className:"univer-text-xs univer-text-gray-400",children:A.ranges.map(H=>Ae.serializeRange(H)).join(",")})]}),c.jsx("div",{children:c.jsx(ae,{rule:A.rule})}),c.jsx("div",{className:O.clsx("univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded group-hover:univer-flex hover:univer-bg-gray-200",{"univer-flex univer-items-center univer-justify-center":R===F}),onClick:H=>{H.stopPropagation(),y(A),m([])},children:c.jsx(Ne,{})})]})},`${A.cfId}`))})})]})},st=a=>{const[e,t]=C.useState(a.rule),[n,l]=C.useState(!!a.rule),u=()=>{l(!0)},s=()=>{l(!1),t(void 0)},v=d=>{t(d),l(!0)};return c.jsx("div",{className:"univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4",children:n?c.jsx(rt,{onCancel:s,rule:e}):c.jsx(ut,{onClick:v,onCreate:u})})};var it=Object.getOwnPropertyDescriptor,ct=(a,e,t,n)=>{for(var l=n>1?void 0:n?it(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},ge=(a,e)=>(t,n)=>e(t,n,a);const Ve="sheet.conditional.formatting.panel";let ye=class extends i.Disposable{constructor(e,t,n,l,u){super();ee(this,"_sidebarDisposable",null);this._univerInstanceService=e,this._injector=t,this._componentManager=n,this._sidebarService=l,this._localeService=u,this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(s=>{var v;s||(v=this._sidebarDisposable)==null||v.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(s=>{s.id===Ve&&(s.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){const t={id:Ve,header:{title:this._localeService.t("sheet.cf.title")},children:{label:Ve,rule:e,key:i.generateRandomId(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(t)}_initPanel(){this.disposeWithMe(this._componentManager.register(Ve,st))}};ye=ct([ge(0,i.IUniverInstanceService),ge(1,i.Inject(i.Injector)),ge(2,i.Inject(j.ComponentManager)),ge(3,i.Inject(j.ISidebarService)),ge(4,i.Inject(i.LocaleService))],ye);var Y=(a=>(a[a.createRule=1]="createRule",a[a.viewRule=2]="viewRule",a[a.highlightCell=3]="highlightCell",a[a.rank=4]="rank",a[a.formula=5]="formula",a[a.colorScale=6]="colorScale",a[a.dataBar=7]="dataBar",a[a.icon=8]="icon",a[a.clearRangeRules=9]="clearRangeRules",a[a.clearWorkSheetRules=10]="clearWorkSheetRules",a))(Y||{});const Ce={id:"sheet.operation.open.conditional.formatting.panel",type:i.CommandType.OPERATION,handler:(a,e)=>{var v;const t=a.get(ye),n=a.get(U.SheetsSelectionsService),l=a.get(i.ICommandService),u=((v=n.getCurrentSelections())==null?void 0:v.map(d=>d.range))||[];switch(e.value){case 3:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 4:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};t.openPanel(d);break}case 5:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:"="}};t.openPanel(d);break}case 6:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.colorScale,config:[]}};t.openPanel(d);break}case 7:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};t.openPanel(d);break}case 8:{const d={...r.createDefaultRule,ranges:u,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};t.openPanel(d);break}case 2:{t.openPanel();break}case 1:{t.openPanel({...r.createDefaultRule(),ranges:u});break}case 9:{l.executeCommand(r.ClearRangeCfCommand.id,{ranges:u});break}case 10:{l.executeCommand(r.ClearWorksheetCfCommand.id);break}}return!0}};var ot=Object.getOwnPropertyDescriptor,dt=(a,e,t,n)=>{for(var l=n>1?void 0:n?ot(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},me=(a,e)=>(t,n)=>e(t,n,a);D.ConditionalFormattingClearController=class extends i.Disposable{constructor(e,t,n,l,u){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=l,this._conditionalFormattingRuleModel=u,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{var u;const t=[],n=[],l={redos:t,undos:n};if([U.ClearSelectionFormatCommand.id,U.ClearSelectionAllCommand.id].includes(e.id)){const s=(u=this._selectionManagerService.getCurrentSelections())==null?void 0:u.map(I=>I.range);if(!s)return l;const v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),d=v.getActiveSheet();if(!d)return l;const h=v.getUnitId(),o=d.getSheetId(),p=this._conditionalFormattingRuleModel.getSubunitRules(h,o);if(!p||!p.length)return l;const{redos:g,undos:b}=Ir(this._injector,p,s,h,o);t.push(...g),n.push(...b)}return l}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{const l=[],u=[],s={redos:l,undos:u};if(!n||!n.length)return s;const v=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!v||!v.length)return s;const{redos:d,undos:h}=Ir(this._injector,v,n,e,t);return l.push(...d),u.push(...h),s}}))}},D.ConditionalFormattingClearController=dt([me(0,i.Inject(i.Injector)),me(1,i.Inject(i.IUniverInstanceService)),me(2,i.Inject(U.SheetInterceptorService)),me(3,i.Inject(U.SheetsSelectionsService)),me(4,i.Inject(r.ConditionalFormattingRuleModel))],D.ConditionalFormattingClearController);function Ir(a,e,t,n,l){const u=[],s=[];return e.filter(v=>t.some(d=>v.ranges.some(h=>i.Rectangle.getIntersects(h,d)))).forEach(v=>{const h=new U.RangeMergeUtil().add(...v.ranges).subtract(...t).merge();if(h.length){const o={id:r.SetConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,rule:{...v,ranges:h}}},p=r.setConditionalRuleMutationUndoFactory(a,o.params);u.push(o),s.push(...p)}else{const o={id:r.DeleteConditionalRuleMutation.id,params:{unitId:n,subUnitId:l,cfId:v.cfId}},p=r.DeleteConditionalRuleMutationUndoFactory(a,o.params);u.push(o),s.push(...p)}}),{redos:u,undos:s}}var vt=Object.getOwnPropertyDescriptor,pt=(a,e,t,n)=>{for(var l=n>1?void 0:n?vt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Je=(a,e)=>(t,n)=>e(t,n,a);let be=class extends i.Disposable{constructor(e,t,n){super();ee(this,"_disposableMap",new Map);this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){const t=[],n=e.rule;switch(n.type){case r.CFRuleType.highlightCell:n.subType===r.CFSubRuleType.formula&&t.push(n.value);break;case r.CFRuleType.dataBar:{const l=n;l.config.min.type===r.CFValueType.formula&&t.push(l.config.min.value),l.config.max.type===r.CFValueType.formula&&t.push(l.config.max.value);break}case r.CFRuleType.colorScale:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}case r.CFRuleType.iconSet:{n.config.forEach(u=>{u.value.type===r.CFValueType.formula&&t.push(u.value.value)});break}}return t}_updateRuleFormulas(e,t){const n=i.Tools.deepClone(e),l=n.rule;let u=0;switch(l.type){case r.CFRuleType.highlightCell:l.subType===r.CFSubRuleType.formula&&(l.value=t[u++]);break;case r.CFRuleType.dataBar:{const s=l;s.config.min.type===r.CFValueType.formula&&(s.config.min.value=t[u++]),s.config.max.type===r.CFValueType.formula&&(s.config.max.value=t[u++]);break}case r.CFRuleType.colorScale:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}case r.CFRuleType.iconSet:{l.config.forEach(v=>{v.value.type===r.CFValueType.formula&&(v.value.value=t[u++])});break}}return n}register(e,t,n){const l=n.ranges,u=this._getRuleFormulas(n),s=this._formulaRefRangeService.registerRangeFormula(e,t,l,u,d=>{if(d.length===0)return{undos:[{id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:n}}],redos:[{id:r.DeleteConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId}}]};const h=[],o=[],p=d[0],g=this._updateRuleFormulas(n,p.formulas);g.ranges=p.ranges,h.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:g}}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:g}));for(let b=1;b<d.length;b++){const I=d[b],m=r.createCfId(),N=this._updateRuleFormulas(n,I.formulas);N.cfId=m,N.ranges=I.ranges,h.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:N}}),o.push(r.AddConditionalRuleMutationUndoFactory(this._injector,{unitId:e,subUnitId:t,rule:N}))}return{undos:o,redos:h}}),v=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(v,s)}_initRefRange(){const e=this._conditionalFormattingRuleModel.getAll();for(const[t,n]of e)for(const[l,u]of n)for(const s of u)this.register(t,l,s);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(t=>{const{unitId:n,subUnitId:l,rule:u}=t;switch(t.type){case"add":{this.register(n,l,u);break}case"delete":{const s=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(s);v&&(v.dispose(),this._disposableMap.delete(s));break}case"set":{const s=this._getIdWithUnitId(n,l,u.cfId),v=this._disposableMap.get(s);v&&(v.dispose(),this._disposableMap.delete(s)),this.register(n,l,u);break}}})),this.disposeWithMe(i.toDisposable(()=>{this._disposableMap.forEach(t=>{t.dispose()}),this._disposableMap.clear()}))}};be=pt([Je(0,i.Inject(r.ConditionalFormattingRuleModel)),Je(1,i.Inject(nr.FormulaRefRangeService)),Je(2,i.Inject(i.Injector))],be);var ft=Object.getOwnPropertyDescriptor,ht=(a,e,t,n)=>{for(var l=n>1?void 0:n?ft(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Se=(a,e)=>(t,n)=>e(t,n,a);let Ie=class extends i.Disposable{constructor(e,t,n,l,u){super();ee(this,"_copyInfo");this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=l,this._univerInstanceService=u,this._initClipboardHook()}_initClipboardHook(){this.disposeWithMe(this._sheetClipboardService.addClipboardHook({id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onBeforeCopy:(e,t,n)=>this._collectConditionalRule(e,t,n),onPasteCells:(e,t,n,l)=>{const{copyType:u=W.COPY_TYPE.COPY,pasteType:s}=l,{range:v}=e||{},{range:d}=t;return this._generateConditionalFormattingMutations(d,{copyType:u,pasteType:s,copyRange:v})}}))}_collectConditionalRule(e,t,n){const l=new i.ObjectMatrix,u={};this._copyInfo={matrix:l,info:{unitId:e,subUnitId:t,cfMap:u}};const s=this._injector.invoke(o=>U.rangeToDiscreteRange(n,o,e,t));if(!s)return;const{rows:v,cols:d}=s,h=new Set;v.forEach((o,p)=>{d.forEach((g,b)=>{const I=this._conditionalFormattingViewModel.getCellCfs(e,t,o,g);I&&(I.forEach(m=>h.add(m.cfId)),l.setValue(p,b,I.map(m=>m.cfId)))})}),h.forEach(o=>{const p=this._conditionalFormattingRuleModel.getRule(e,t,o);p&&(u[o]=p.rule)})}_generateConditionalFormattingMutations(e,t){const n=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),l=n.getActiveSheet(),u=n.getUnitId();if(!l)return{redos:[],undos:[]};const s=l.getSheetId();if(t.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!t.copyRange)return{redos:[],undos:[]};if(![W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER].includes(t.pasteType))return{redos:[],undos:[]};const{ranges:[d,h],mapFunc:o}=W.virtualizeDiscreteRanges([t.copyRange,e]),p=W.getRepeatRange(d,h,!0),g={};i.Range.foreach(h,(f,T)=>{const{row:w,col:S}=o(f,T),k=this._conditionalFormattingViewModel.getCellCfs(u,s,w,S);k&&k.forEach(V=>{if(!g[V.cfId]){const P=new i.ObjectMatrix;g[V.cfId]=P;const L=this._conditionalFormattingRuleModel.getRule(u,s,V.cfId);L==null||L.ranges.forEach(y=>{i.Range.foreach(y,(x,$)=>{P.setValue(x,$,1)})})}g[V.cfId].realDeleteValue(w,S)})});const{matrix:b,info:I}=this._copyInfo,m=[];let N=this._conditionalFormattingRuleModel.createCfId(u,s);const _={},E=f=>{if(_[f])return _[f];const T=I==null?void 0:I.cfMap[f],w=[...this._conditionalFormattingRuleModel.getSubunitRules(u,s)||[],...m].find(S=>i.Tools.diffValue(S.rule,T));if(w)return _[f]=w,w;{const S={rule:T,cfId:N,ranges:[],stopIfTrue:!1};return _[f]=S,m.push(S),N=`${Number(N)+1}`,S}};p.forEach(f=>{b&&b.forValue((T,w,S)=>{const k=i.Rectangle.getPositionRange({startRow:T,endRow:T,startColumn:w,endColumn:w},f.startRange),{row:V,col:P}=o(k.startRow,k.startColumn);S.forEach(L=>{if(!g[L]){const y=E(L),x=new i.ObjectMatrix;g[L]=x,y.ranges.forEach($=>{i.Range.foreach($,(G,J)=>{x.setValue(G,J,1)})})}g[L].setValue(V,P,1)})})});const M=[],R=[];for(const f in g){const T=g[f],w=U.findAllRectangle(U.createTopMatrixFromMatrix(T));if(!w.length){const S={unitId:u,subUnitId:s,cfId:f};M.push({id:r.DeleteConditionalRuleMutation.id,params:S}),R.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,S))}if(m.some(S=>S.cfId===f)){const S=E(f),k={unitId:u,subUnitId:s,rule:{...S,ranges:w}};M.push({id:r.AddConditionalRuleMutation.id,params:k}),R.push(r.AddConditionalRuleMutationUndoFactory(this._injector,k))}else{const S=this._conditionalFormattingRuleModel.getRule(u,s,f);if(!S)continue;const k={unitId:u,subUnitId:s,rule:{...S,ranges:w}};M.push({id:r.SetConditionalRuleMutation.id,params:k}),R.push(...r.setConditionalRuleMutationUndoFactory(this._injector,k))}}return{redos:M,undos:R}}};Ie=ht([Se(0,i.Inject(W.ISheetClipboardService)),Se(1,i.Inject(r.ConditionalFormattingRuleModel)),Se(2,i.Inject(i.Injector)),Se(3,i.Inject(r.ConditionalFormattingViewModel)),Se(4,i.Inject(i.IUniverInstanceService))],Ie);var gt=Object.getOwnPropertyDescriptor,yt=(a,e,t,n)=>{for(var l=n>1?void 0:n?gt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Qe=(a,e)=>(t,n)=>e(t,n,a);let Te=class extends i.Disposable{constructor(a,e,t){super(),this._localeService=a,this._commandService=e,this._sheetPermissionCheckController=t,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(a=>{if(a.id===r.AddCfCommand.id){const{unitId:e,subUnitId:t,rule:{ranges:n}}=a.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[U.WorkbookEditablePermission],rangeTypes:[U.RangeProtectionPermissionEditPoint],worksheetTypes:[U.WorksheetEditPermission,U.WorksheetSetCellStylePermission]},n,e,t)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Te=yt([Qe(0,i.Inject(i.LocaleService)),Qe(1,i.ICommandService),Qe(2,i.Inject(U.SheetPermissionCheckController))],Te);var Ct=Object.getOwnPropertyDescriptor,mt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ct(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},ie=(a,e)=>(t,n)=>e(t,n,a);let _e=class extends i.Disposable{constructor(e,t,n,l,u,s){super();ee(this,"_ruleChangeCacheMap",new Map);this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=l,this._conditionalFormattingViewModel=u,this._conditionalFormattingRuleModel=s,this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var t,n,l;const e=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId();(t=this._renderManagerService.getRenderById(e))==null||t.with(W.SheetSkeletonManagerService).reCalculate(),(l=(n=this._renderManagerService.getRenderById(e))==null?void 0:n.mainComponent)==null||l.makeDirty()}_initSkeleton(){this.disposeWithMe(X.merge(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe(pe.bufferTime(16),pe.filter(e=>!!e.length),pe.filter(e=>{const t=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!t)return!1;const n=t.getActiveSheet();return n?e.filter(l=>l.unitId===t.getUnitId()&&l.subUnitId===n.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(U.INTERCEPTOR_POINT.CELL_CONTENT,{effect:i.InterceptorEffectEnum.Style,handler:(e,t,n)=>{const l=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!l)return n(e);const u=t.workbook.getStyles(),s=(typeof(e==null?void 0:e.s)=="string"?u.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},v=e===t.rawData?{...t.rawData}:e;if(l.style){const d={...s,...l.style};Object.assign(v,{s:d})}return v.fontRenderExtension||(v.fontRenderExtension={},l.isShowValue!==void 0&&(v.fontRenderExtension.isSkip=!l.isShowValue)),l.dataBar&&(v.dataBar=l.dataBar),l.iconSet&&(v.iconSet=l.iconSet,v.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(v)},priority:10}))}};_e=mt([ie(0,i.Inject(U.SheetInterceptorService)),ie(1,i.Inject(r.ConditionalFormattingService)),ie(2,i.Inject(i.IUniverInstanceService)),ie(3,i.Inject(lr.IRenderManagerService)),ie(4,i.Inject(r.ConditionalFormattingViewModel)),ie(5,i.Inject(r.ConditionalFormattingRuleModel))],_e);const Tr="sheets-conditional-formatting-ui.config",Oe={};var bt=Object.defineProperty,St=Object.getOwnPropertyDescriptor,It=(a,e,t)=>e in a?bt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,Tt=(a,e,t,n)=>{for(var l=n>1?void 0:n?St(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},er=(a,e)=>(t,n)=>e(t,n,a),_r=(a,e,t)=>It(a,typeof e!="symbol"?e+"":e,t);D.UniverSheetsConditionalFormattingMobileUIPlugin=class extends i.Plugin{constructor(e=Oe,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...s}=i.merge({},Oe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Tr,s),this._initCommand(),this._injector.add([_e]),this._injector.add([Ie]),this._injector.add([Te]),this._injector.add([se]),this._injector.add([be])}_initCommand(){[$e,Fe,Be,He,We,qe,Ge,Ze,ze,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},_r(D.UniverSheetsConditionalFormattingMobileUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),_r(D.UniverSheetsConditionalFormattingMobileUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingMobileUIPlugin=Tt([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin),er(1,i.Inject(i.Injector)),er(2,i.Inject(i.ICommandService)),er(3,i.IConfigService)],D.UniverSheetsConditionalFormattingMobileUIPlugin);var _t=Object.getOwnPropertyDescriptor,wt=(a,e,t,n)=>{for(var l=n>1?void 0:n?_t(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},we=(a,e)=>(t,n)=>e(t,n,a);let Ue=class extends i.Disposable{constructor(a,e,t,n,l){super(),this._injector=a,this._univerInstanceService=e,this._autoFillService=t,this._conditionalFormattingRuleModel=n,this._conditionalFormattingViewModel=l,this._initAutoFill()}_initAutoFill(){const a=()=>({redos:[],undos:[]}),e=(l,u,s,v,d)=>{var b;const h=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getUnitId(),o=(b=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:b.getSheetId();if(!h||!o)return;const p={startRow:l.row,startColumn:l.col,endColumn:l.col,endRow:l.row},g={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row};i.Range.foreach(s,(I,m)=>{const N=i.Rectangle.getPositionRange({startRow:I,startColumn:m,endColumn:m,endRow:I},p),_=i.Rectangle.getPositionRange({startRow:I,startColumn:m,endColumn:m,endRow:I},g),{row:E,col:M}=d(N.startRow,N.startColumn),R=this._conditionalFormattingViewModel.getCellCfs(h,o,E,M),{row:f,col:T}=d(_.startRow,_.startColumn),w=this._conditionalFormattingViewModel.getCellCfs(h,o,f,T);w&&w.forEach(S=>{let k=v.get(S.cfId);if(!v.get(S.cfId)){const V=this._conditionalFormattingRuleModel.getRule(h,o,S.cfId);if(!V)return;k=new i.ObjectMatrix,V.ranges.forEach(P=>{i.Range.foreach(P,(L,y)=>{k.setValue(L,y,1)})}),v.set(S.cfId,k)}k.realDeleteValue(f,T)}),R&&R.forEach(S=>{let k=v.get(S.cfId);if(!v.get(S.cfId)){const V=this._conditionalFormattingRuleModel.getRule(h,o,S.cfId);if(!V)return;k=new i.ObjectMatrix,V.ranges.forEach(P=>{i.Range.foreach(P,(L,y)=>{k.setValue(L,y,1)})}),v.set(S.cfId,k)}k.setValue(f,T,1)})})},t=(l,u)=>{var _,E,M;const s=(_=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:_.getUnitId(),v=(M=(E=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:E.getActiveSheet())==null?void 0:M.getSheetId(),d=new Map,h=[],o=[];if(!s||!v)return a();const p=W.virtualizeDiscreteRanges([l,u]),[g,b]=p.ranges,{mapFunc:I}=p,m={row:g.startRow,col:g.startColumn};return W.getAutoFillRepeatRange(g,b).forEach(R=>{e(m,R.repeatStartCell,R.relativeRange,d,I)}),d.forEach((R,f)=>{const T=this._conditionalFormattingRuleModel.getRule(s,v,f);if(!T)return;const w=U.findAllRectangle(U.createTopMatrixFromMatrix(R));if(w.length){const S={unitId:s,subUnitId:v,rule:{...T,ranges:w}};h.push({id:r.SetConditionalRuleMutation.id,params:S}),o.push(...r.setConditionalRuleMutationUndoFactory(this._injector,S))}else{const S={unitId:s,subUnitId:v,cfId:T.cfId};h.push({id:r.DeleteConditionalRuleMutation.id,params:S}),o.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,S))}}),{undos:o,redos:h}},n={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(l,u,s)=>{if(s===W.APPLY_TYPE.COPY||s===W.APPLY_TYPE.ONLY_FORMAT||s===W.APPLY_TYPE.SERIES){const{source:v,target:d}=l;return t(v,d)}return a()}};this.disposeWithMe(this._autoFillService.addHook(n))}};Ue=wt([we(0,i.Inject(i.Injector)),we(1,i.Inject(i.IUniverInstanceService)),we(2,i.Inject(W.IAutoFillService)),we(3,i.Inject(r.ConditionalFormattingRuleModel)),we(4,i.Inject(r.ConditionalFormattingViewModel))],Ue);var xt=Object.getOwnPropertyDescriptor,Nt=(a,e,t,n)=>{for(var l=n>1?void 0:n?xt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},wr=(a,e)=>(t,n)=>e(t,n,a);let ke=class extends i.Disposable{constructor(a,e){super(),this._sheetInterceptorService=a,this._conditionalFormattingService=e,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe(i.toDisposable(this._sheetInterceptorService.writeCellInterceptor.intercept(U.AFTER_CELL_EDIT,{handler:(a,e,t)=>{var s,v,d;a||t(a);const n=this._conditionalFormattingService.composeStyle(e.unitId,e.subUnitId,e.row,e.col),l=(s=n==null?void 0:n.style)!=null?s:{},u=Object.keys(l);if(a!=null&&a.p)return(d=(v=a.p.body)==null?void 0:v.textRuns)==null||d.forEach(h=>{h.ts&&u.forEach(o=>{var p;(p=h.ts)==null||delete p[o]})}),t(a);{const h={...(typeof(a==null?void 0:a.s)=="string"?e.workbook.getStyles().get(a.s):a==null?void 0:a.s)||{}};u.forEach(p=>{delete h[p]});const o={...a,s:{...h}};return t(o)}}})))}};ke=Nt([wr(0,i.Inject(U.SheetInterceptorService)),wr(1,i.Inject(r.ConditionalFormattingService))],ke);const xr=[U.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],xe=[{label:{name:"sheet.cf.ruleType.highlightCell",selectable:!1},value:Y.highlightCell},{label:{name:"sheet.cf.panel.rankAndAverage",selectable:!1},value:Y.rank},{label:{name:"sheet.cf.ruleType.formula",selectable:!1},value:Y.formula},{label:{name:"sheet.cf.ruleType.colorScale",selectable:!1},value:Y.colorScale},{label:{name:"sheet.cf.ruleType.dataBar",selectable:!1},value:Y.dataBar},{label:{name:"sheet.cf.ruleType.iconSet",selectable:!1},value:Y.icon},{label:{name:"sheet.cf.menu.manageConditionalFormatting",selectable:!1},value:Y.viewRule},{label:{name:"sheet.cf.menu.createConditionalFormatting",selectable:!1},value:Y.createRule},{label:{name:"sheet.cf.menu.clearRangeRules",selectable:!1},value:Y.clearRangeRules,disabled:!1},{label:{name:"sheet.cf.menu.clearWorkSheetRules",selectable:!1},value:Y.clearWorkSheetRules}],Et=a=>{const e=a.get(U.SheetsSelectionsService),t=a.get(i.ICommandService),n=a.get(i.IUniverInstanceService),l=a.get(r.ConditionalFormattingRuleModel),u=new X.Observable(d=>X.merge(e.selectionMoveEnd$,e.selectionSet$,new X.Observable(h=>{const o=t.onCommandExecuted(p=>{var m;const{id:g,params:b}=p,I=(m=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();xr.includes(g)&&b.unitId===I&&h.next(null)});return()=>o.dispose()})).pipe(pe.debounceTime(16)).subscribe(()=>{var m;const h=((m=e.getCurrentSelections())==null?void 0:m.map(N=>N.range))||[],o=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!o)return;const p=o.getActiveSheet();if(!p)return;const I=(l.getSubunitRules(o.getUnitId(),p.getSheetId())||[]).filter(N=>N.ranges.some(_=>h.some(E=>i.Rectangle.intersects(E,_)))).map(N=>N.ranges).every(N=>U.checkRangesEditablePermission(a,o.getUnitId(),p.getSheetId(),N));d.next(I)})),s=new X.Observable(d=>new X.Observable(h=>{const o=t.onCommandExecuted(p=>{var m;const{id:g,params:b}=p,I=(m=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:m.getUnitId();xr.includes(g)&&b.unitId===I&&h.next(null)});return()=>o.dispose()}).pipe(pe.debounceTime(16)).subscribe(()=>{const h=n.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET);if(!h)return;const o=h.getActiveSheet();if(!o)return;const p=l.getSubunitRules(h.getUnitId(),o.getSheetId())||[];if(!p.length)return d.next(!1),!1;const g=p.map(b=>b.ranges).every(b=>U.checkRangesEditablePermission(a,h.getUnitId(),o.getSheetId(),b));d.next(g)})),v=new X.Observable(d=>{u.subscribe(h=>{const o=xe.find(p=>p.value===Y.clearRangeRules);o&&(o.disabled=!h,d.next(xe))}),s.subscribe(h=>{const o=xe.find(p=>p.value===Y.clearWorkSheetRules);o&&(o.disabled=!h,d.next(xe))}),d.next(xe)});return{id:Ce.id,type:j.MenuItemType.SELECTOR,icon:"ConditionsDoubleIcon",tooltip:"sheet.cf.title",selections:v,hidden$:j.getMenuHiddenObservable(a,i.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(a,{workbookTypes:[U.WorkbookEditablePermission],worksheetTypes:[U.WorksheetSetCellStylePermission,U.WorksheetEditPermission],rangeTypes:[U.RangeProtectionPermissionEditPoint]})}},Rt={[j.RibbonDataGroup.RULES]:{[Ce.id]:{order:1,menuItemFactory:Et}}};var Mt=Object.getOwnPropertyDescriptor,Vt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Mt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},Nr=(a,e)=>(t,n)=>e(t,n,a);let Pe=class extends i.Disposable{constructor(e,t){super();ee(this,"_sidebarDisposable",null);this._injector=e,this._menuManagerService=t,this._menuManagerService.mergeMenu(Rt)}};Pe=Vt([Nr(0,i.Inject(i.Injector)),Nr(1,j.IMenuManagerService)],Pe);var Ot=Object.getOwnPropertyDescriptor,Ut=(a,e,t,n)=>{for(var l=n>1?void 0:n?Ot(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},ce=(a,e)=>(t,n)=>e(t,n,a);const kt=(a,e)=>{const t=o=>o.endRow-o.startRow+1,n=o=>o.endColumn-o.startColumn+1,l=t(e)%t(a),u=n(e)%n(a),s=Math.floor(t(e)/t(a)),v=Math.floor(n(e)/n(a)),d=[],h={startRow:0,endRow:t(a)-1,startColumn:0,endColumn:n(a)-1};if(t(e)===1&&n(e)===1){const o={startRow:e.startRow,endRow:e.startRow,startColumn:e.startColumn,endColumn:e.startColumn};return d.push({repeatRelativeRange:h,startRange:o}),d}for(let o=0;o<s+(l?.1:0);o++)for(let p=0;p<v+(u?.1:0);p++){const g=t(a)*o,b=n(a)*p,I={startRow:g+e.startRow,endRow:g+e.startRow,startColumn:b+e.startColumn,endColumn:b+e.startColumn};let m=h;o===s&&l&&(m={...m},m.endRow=m.endRow-(t(a)-l)),p===v&&u&&(m={...m},m.endColumn=m.endColumn-(n(a)-u)),d.push({repeatRelativeRange:m,startRange:I})}return d};let De=class extends i.Disposable{constructor(e,t,n,l,u,s){super();ee(this,"_painterConfig",null);this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=l,this._conditionalFormattingRuleModel=u,this._conditionalFormattingViewModel=s,this._initFormattingPainter()}_initFormattingPainter(){const e=()=>({redos:[],undos:[]}),t=(u,s,v,d,h)=>{const{unitId:o,subUnitId:p}=this._painterConfig,{targetUnitId:g,targetSubUnitId:b}=h,I={startRow:u.row,startColumn:u.col,endColumn:u.col,endRow:u.row},m={startRow:s.row,startColumn:s.col,endColumn:s.col,endRow:s.row};i.Range.foreach(v,(N,_)=>{const E=i.Rectangle.getPositionRange({startRow:N,startColumn:_,endColumn:_,endRow:N},I),M=i.Rectangle.getPositionRange({startRow:N,startColumn:_,endColumn:_,endRow:N},m),R=this._conditionalFormattingViewModel.getCellCfs(o,p,E.startRow,E.startColumn),f=this._conditionalFormattingViewModel.getCellCfs(g,b,M.startRow,M.startColumn);f&&f.forEach(T=>{let w=d.get(T.cfId);if(!d.get(T.cfId)){const S=this._conditionalFormattingRuleModel.getRule(g,b,T.cfId);if(!S)return;w=new i.ObjectMatrix,S.ranges.forEach(k=>{i.Range.foreach(k,(V,P)=>{w.setValue(V,P,1)})}),d.set(T.cfId,w)}w.realDeleteValue(M.startRow,M.startColumn)}),R&&R.forEach(T=>{const w=d.get(T.cfId);w&&w.setValue(M.startRow,M.startColumn,1)})})},n=(u,s,v)=>{var E;const{range:d,unitId:h,subUnitId:o}=this._painterConfig,p=u!==h||o!==s,g=new Map,b=[],I=[];if(!u||!s||!h||!o)return e();const m=(E=this._conditionalFormattingRuleModel.getSubunitRules(h,o))!=null?E:[];m==null||m.forEach(M=>{const{ranges:R,cfId:f}=M;if(R.some(T=>i.Rectangle.intersects(d,T))){const T=new i.ObjectMatrix;p||R.forEach(w=>{i.Range.foreach(w,(S,k)=>{T.setValue(S,k,1)})}),g.set(f,T)}});const N={row:d.startRow,col:d.startColumn};return kt(d,v).forEach(M=>{t(N,{row:M.startRange.startRow,col:M.startRange.startColumn},M.repeatRelativeRange,g,{targetUnitId:u,targetSubUnitId:s})}),g.forEach((M,R)=>{if(p){const f=this._conditionalFormattingRuleModel.getRule(u,s,R),T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(f)if(T.length){const w={unitId:u,subUnitId:s,rule:{...f,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),I.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:u,subUnitId:s,cfId:f.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),I.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}else if(T.length){const w=this._conditionalFormattingRuleModel.getRule(h,o,R);if(w){const S={unitId:u,subUnitId:s,rule:{...i.Tools.deepClone(w),cfId:this._conditionalFormattingRuleModel.createCfId(u,s),ranges:T}};b.push({id:r.AddConditionalRuleMutation.id,params:S}),I.push(r.AddConditionalRuleMutationUndoFactory(this._injector,S))}}}else{const f=this._conditionalFormattingRuleModel.getRule(h,o,R);if(!f)return;const T=U.findAllRectangle(U.createTopMatrixFromMatrix(M));if(T.length){const w={unitId:h,subUnitId:o,rule:{...f,ranges:T}};b.push({id:r.SetConditionalRuleMutation.id,params:w}),I.push(...r.setConditionalRuleMutationUndoFactory(this._injector,w))}else{const w={unitId:h,subUnitId:o,cfId:f.cfId};b.push({id:r.DeleteConditionalRuleMutation.id,params:w}),I.push(...r.DeleteConditionalRuleMutationUndoFactory(this._injector,w))}}}),{undos:I,redos:b}},l={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:u=>{var s,v,d;switch(u){case W.FormatPainterStatus.INFINITE:case W.FormatPainterStatus.ONCE:{const h=(s=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),o=(d=(v=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET))==null?void 0:v.getActiveSheet())==null?void 0:d.getSheetId(),p=this._sheetsSelectionsService.getCurrentLastSelection(),g=p==null?void 0:p.range;h&&o&&g&&(this._painterConfig={unitId:h,subUnitId:o,range:g});break}case W.FormatPainterStatus.OFF:{this._painterConfig=null;break}}},onApply:(u,s,v)=>this._painterConfig?n(u,s,v):{redos:[],undos:[]}};this._formatPainterService.addHook(l)}};De=Ut([ce(0,i.Inject(i.Injector)),ce(1,i.Inject(i.IUniverInstanceService)),ce(2,i.Inject(W.IFormatPainterService)),ce(3,i.Inject(U.SheetsSelectionsService)),ce(4,i.Inject(r.ConditionalFormattingRuleModel)),ce(5,i.Inject(r.ConditionalFormattingViewModel))],De);var Pt=Object.getOwnPropertyDescriptor,Dt=(a,e,t,n)=>{for(var l=n>1?void 0:n?Pt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},rr=(a,e)=>(t,n)=>e(t,n,a);let Le=class extends i.Disposable{constructor(a,e,t){super(),this._conditionalFormattingViewModel=a,this._univerInstanceService=e,this._renderManagerService=t,this._init()}_init(){const a=this._univerInstanceService.getCurrentUnitForType(i.UniverInstanceType.UNIVER_SHEET),e=t=>{const n=t.getUnitId(),l=this._renderManagerService.getRenderById(n);if(!l)return;const u=l.with(W.SheetSkeletonManagerService);this.disposeWithMe(u.currentSkeleton$.subscribe(s=>{if(s){const v=s.skeleton.rowColumnSegment,d=v.endColumn-v.startColumn+1,o=(v.endRow-v.startRow+1)*d*9,p=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,o);this._conditionalFormattingViewModel.setCacheLength(p)}}))};a&&e(a),this._univerInstanceService.getCurrentTypeOfUnit$(i.UniverInstanceType.UNIVER_SHEET).subscribe(t=>{t&&e(t)})}};Le=Dt([rr(0,i.Inject(r.ConditionalFormattingViewModel)),rr(1,i.IUniverInstanceService),rr(2,lr.IRenderManagerService)],Le);var Lt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,At=(a,e,t)=>e in a?Lt(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t,$t=(a,e,t,n)=>{for(var l=n>1?void 0:n?jt(e,t):e,u=a.length-1,s;u>=0;u--)(s=a[u])&&(l=s(l)||l);return l},tr=(a,e)=>(t,n)=>e(t,n,a),Er=(a,e,t)=>At(a,typeof e!="symbol"?e+"":e,t);D.UniverSheetsConditionalFormattingUIPlugin=class extends i.Plugin{constructor(e=Oe,t,n,l){super(),this._config=e,this._injector=t,this._commandService=n,this._configService=l;const{menu:u,...s}=i.merge({},Oe,this._config);u&&this._configService.setConfig("menu",u,{merge:!0}),this._configService.setConfig(Tr,s),this._initCommand()}onStarting(){i.registerDependencies(this._injector,[[_e],[Ie],[Ue],[Te],[ye],[Pe],[se],[ke],[D.ConditionalFormattingClearController],[De],[Le],[be]]),i.touchDependencies(this._injector,[[_e],[be]])}onReady(){i.touchDependencies(this._injector,[[Pe],[ye]])}onRendered(){i.touchDependencies(this._injector,[[Ue],[D.ConditionalFormattingClearController],[Ie],[ke],[se],[De],[Te],[Le]])}_initCommand(){[$e,Fe,Be,He,We,qe,Ge,Ze,ze,Ce].forEach(e=>{this._commandService.registerCommand(e)})}},Er(D.UniverSheetsConditionalFormattingUIPlugin,"pluginName",`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),Er(D.UniverSheetsConditionalFormattingUIPlugin,"type",i.UniverInstanceType.UNIVER_SHEET),D.UniverSheetsConditionalFormattingUIPlugin=$t([i.DependentOn(r.UniverSheetsConditionalFormattingPlugin,nr.UniverSheetsFormulaPlugin),tr(1,i.Inject(i.Injector)),tr(2,i.Inject(i.ICommandService)),tr(3,i.IConfigService)],D.UniverSheetsConditionalFormattingUIPlugin),D.AddAverageCfCommand=$e,D.AddColorScaleConditionalRuleCommand=Fe,D.AddDataBarConditionalRuleCommand=Be,D.AddDuplicateValuesCfCommand=He,D.AddNumberCfCommand=We,D.AddRankCfCommand=qe,D.AddTextCfCommand=Ge,D.AddTimePeriodCfCommand=Ze,D.AddUniqueValuesCfCommand=ze,D.OpenConditionalFormattingOperator=Ce,Object.defineProperty(D,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-conditional-formatting-ui",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Conditional formatting plugin for Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"rxjs": ">=7.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@univerjs/icons": "^1.1.
|
|
58
|
-
"@univerjs/
|
|
59
|
-
"@univerjs/
|
|
60
|
-
"@univerjs/engine-render": "0.15.
|
|
61
|
-
"@univerjs/sheets": "0.15.
|
|
62
|
-
"@univerjs/
|
|
63
|
-
"@univerjs/sheets-formula": "0.15.
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/sheets-
|
|
66
|
-
"@univerjs/ui": "0.15.
|
|
67
|
-
"@univerjs/
|
|
57
|
+
"@univerjs/icons": "^1.1.1",
|
|
58
|
+
"@univerjs/core": "0.15.1",
|
|
59
|
+
"@univerjs/engine-formula": "0.15.1",
|
|
60
|
+
"@univerjs/engine-render": "0.15.1",
|
|
61
|
+
"@univerjs/sheets": "0.15.1",
|
|
62
|
+
"@univerjs/design": "0.15.1",
|
|
63
|
+
"@univerjs/sheets-formula": "0.15.1",
|
|
64
|
+
"@univerjs/sheets-formula-ui": "0.15.1",
|
|
65
|
+
"@univerjs/sheets-conditional-formatting": "0.15.1",
|
|
66
|
+
"@univerjs/sheets-ui": "0.15.1",
|
|
67
|
+
"@univerjs/ui": "0.15.1"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"postcss": "^8.5.6",
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
"rxjs": "^7.8.2",
|
|
73
73
|
"tailwindcss": "3.4.18",
|
|
74
74
|
"typescript": "^5.9.3",
|
|
75
|
-
"vite": "^7.3.
|
|
75
|
+
"vite": "^7.3.1",
|
|
76
76
|
"vitest": "^4.0.16",
|
|
77
|
-
"@univerjs-infra/shared": "0.15.
|
|
77
|
+
"@univerjs-infra/shared": "0.15.1"
|
|
78
78
|
},
|
|
79
79
|
"scripts": {
|
|
80
80
|
"test": "vitest run",
|