@univerjs/sheets-conditional-formatting-ui 0.21.0 → 0.21.1-insiders.20260429-a0b1161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/cjs/index.js CHANGED
@@ -3121,7 +3121,7 @@ const RuleList = (props) => {
3121
3121
  className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
3122
3122
  children: getRuleDescribe(rule, localeService)
3123
3123
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
3124
- className: "univer-text-xs univer-text-gray-400",
3124
+ className: "\n univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs\n univer-text-gray-400\n ",
3125
3125
  children: rule.ranges.map((range) => (0, _univerjs_engine_formula.serializeRange)(range)).join(",")
3126
3126
  })]
3127
3127
  }),
@@ -3437,7 +3437,7 @@ function generateClearCfMutations(injector, allRules, ranges, unitId, subUnitId)
3437
3437
  //#endregion
3438
3438
  //#region package.json
3439
3439
  var name = "@univerjs/sheets-conditional-formatting-ui";
3440
- var version = "0.21.0";
3440
+ var version = "0.21.1-insiders.20260429-a0b1161";
3441
3441
 
3442
3442
  //#endregion
3443
3443
  //#region src/config/config.ts
package/lib/es/index.js CHANGED
@@ -3120,7 +3120,7 @@ const RuleList = (props) => {
3120
3120
  className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
3121
3121
  children: getRuleDescribe(rule, localeService)
3122
3122
  }), /* @__PURE__ */ jsx("div", {
3123
- className: "univer-text-xs univer-text-gray-400",
3123
+ className: "\n univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs\n univer-text-gray-400\n ",
3124
3124
  children: rule.ranges.map((range) => serializeRange(range)).join(",")
3125
3125
  })]
3126
3126
  }),
@@ -3436,7 +3436,7 @@ function generateClearCfMutations(injector, allRules, ranges, unitId, subUnitId)
3436
3436
  //#endregion
3437
3437
  //#region package.json
3438
3438
  var name = "@univerjs/sheets-conditional-formatting-ui";
3439
- var version = "0.21.0";
3439
+ var version = "0.21.1-insiders.20260429-a0b1161";
3440
3440
 
3441
3441
  //#endregion
3442
3442
  //#region src/config/config.ts
package/lib/index.css CHANGED
@@ -166,6 +166,10 @@
166
166
  min-width: 72px;
167
167
  }
168
168
 
169
+ .univer-max-w-\[250px\] {
170
+ max-width: 250px;
171
+ }
172
+
169
173
  .univer-max-w-full {
170
174
  max-width: 100%;
171
175
  }
@@ -236,6 +240,10 @@
236
240
  overflow: hidden;
237
241
  }
238
242
 
243
+ .univer-text-ellipsis {
244
+ text-overflow: ellipsis;
245
+ }
246
+
239
247
  .univer-rounded {
240
248
  border-radius: .25rem;
241
249
  }
package/lib/index.js CHANGED
@@ -3120,7 +3120,7 @@ const RuleList = (props) => {
3120
3120
  className: "univer-text-sm univer-text-gray-900 dark:!univer-text-white",
3121
3121
  children: getRuleDescribe(rule, localeService)
3122
3122
  }), /* @__PURE__ */ jsx("div", {
3123
- className: "univer-text-xs univer-text-gray-400",
3123
+ className: "\n univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs\n univer-text-gray-400\n ",
3124
3124
  children: rule.ranges.map((range) => serializeRange(range)).join(",")
3125
3125
  })]
3126
3126
  }),
@@ -3436,7 +3436,7 @@ function generateClearCfMutations(injector, allRules, ranges, unitId, subUnitId)
3436
3436
  //#endregion
3437
3437
  //#region package.json
3438
3438
  var name = "@univerjs/sheets-conditional-formatting-ui";
3439
- var version = "0.21.0";
3439
+ var version = "0.21.1-insiders.20260429-a0b1161";
3440
3440
 
3441
3441
  //#endregion
3442
3442
  //#region src/config/config.ts
package/lib/umd/index.js CHANGED
@@ -1,3 +1,6 @@
1
1
  (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`@univerjs/core`),require(`@univerjs/sheets`),require(`@univerjs/sheets-conditional-formatting`),require(`@univerjs/ui`),require(`react`),require(`@univerjs/design`),require(`@univerjs/engine-formula`),require(`@univerjs/sheets-formula-ui`),require(`react/jsx-runtime`),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`,`@univerjs/design`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`,`react/jsx-runtime`,`@univerjs/sheets-ui`,`rxjs`,`@univerjs/sheets-formula`,`@univerjs/engine-render`,`rxjs/operators`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsConditionalFormattingUi={},e.UniverCore,e.UniverSheets,e.UniverSheetsConditionalFormatting,e.UniverUi,e.React,e.UniverDesign,e.UniverEngineFormula,e.UniverSheetsFormulaUi,e.React,e.UniverSheetsUi,e.rxjs,e.UniverSheetsFormula,e.UniverEngineRender,e.rxjs.operators))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});let h={type:t.CommandType.COMMAND,id:`sheet.command.add-average-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c}=i,l=e.get(r.ConditionalFormattingRuleModel),u=e.get(t.ICommandService),d=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!d)return!1;let{unitId:f,subUnitId:p}=d,m={ranges:a,cfId:l.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:c,style:o}};return u.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:m})}},g={type:t.CommandType.COMMAND,id:`sheet.command.add-color-scale-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,config:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.ICommandService),u=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!u)return!1;let{unitId:d,subUnitId:f}=u,p={ranges:a,cfId:c.createCfId(d,f),stopIfTrue:!!s,rule:{type:r.CFRuleType.colorScale,config:o}};return l.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:p})}},_={type:t.CommandType.COMMAND,id:`sheet.command.add-data-bar-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,min:o,max:s,nativeColor:c,positiveColor:l,isGradient:u,stopIfTrue:d,isShowValue:f}=i,p=e.get(r.ConditionalFormattingRuleModel),m=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!m)return!1;let{unitId:h,subUnitId:g}=m,_=e.get(t.ICommandService),v={ranges:a,cfId:p.createCfId(h,g),stopIfTrue:!!d,rule:{type:r.CFRuleType.dataBar,isShowValue:f,config:{min:o,max:s,nativeColor:c,positiveColor:l,isGradient:u}}};return _.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:v})}},v={type:t.CommandType.COMMAND,id:`sheet.command.add-duplicate-values-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.ICommandService),u=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!u)return!1;let{unitId:d,subUnitId:f}=u,p={ranges:a,cfId:c.createCfId(d,f),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.duplicateValues,style:o}};return l.executeCommand(r.AddConditionalRuleMutation.id,{unitId:d,subUnitId:f,rule:p})}},y={type:t.CommandType.COMMAND,id:`sheet.command.add-number-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c,value:l}=i,u=e.get(r.ConditionalFormattingRuleModel),d=e.get(t.ICommandService),f=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=u.createCfId(p,m),g;if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(c)){let e=l;if(e.length!==2||!Array.isArray(e))return!1;g={ranges:a,cfId:h,stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:c,style:o,value:e}}}else{let e=l;if(typeof e!=`number`)return!1;g={ranges:a,cfId:h,stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.number,operator:c,style:o,value:e}}}return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:m,rule:g})}},b={type:t.CommandType.COMMAND,id:`sheet.command.add-rank-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,isPercent:c,isBottom:l,value:u}=i,d=e.get(r.ConditionalFormattingRuleModel),f=e.get(t.IUniverInstanceService),p=e.get(t.ICommandService),m=(0,n.getSheetCommandTarget)(f);if(!m)return!1;let{unitId:h,subUnitId:g}=m,_={ranges:a,cfId:d.createCfId(h,g),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:c,isBottom:l,style:o,value:u}};return p.executeCommand(r.AddConditionalRuleMutation.id,{unitId:h,subUnitId:g,rule:_})}},x={type:t.CommandType.COMMAND,id:`sheet.command.add-text-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c,value:l}=i,u=e.get(r.ConditionalFormattingRuleModel),d=(0,n.getSheetCommandTarget)(e.get(t.IUniverInstanceService));if(!d)return!1;let{unitId:f,subUnitId:p}=d,m=e.get(t.ICommandService),h={ranges:a,cfId:u.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.text,operator:c,style:o,value:l}};return m.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:h})}},S={type:t.CommandType.COMMAND,id:`sheet.command.add-time-period-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s,operator:c}=i,l=e.get(r.ConditionalFormattingRuleModel),u=e.get(t.IUniverInstanceService),d=e.get(t.ICommandService),f=(0,n.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h={ranges:a,cfId:l.createCfId(p,m),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.timePeriod,operator:c,style:o}};return d.executeCommand(r.AddConditionalRuleMutation.id,{unitId:p,subUnitId:m,rule:h})}},C={type:t.CommandType.COMMAND,id:`sheet.command.add-uniqueValues-conditional-rule`,handler(e,i){if(!i)return!1;let{ranges:a,style:o,stopIfTrue:s}=i,c=e.get(r.ConditionalFormattingRuleModel),l=e.get(t.IUniverInstanceService),u=e.get(t.ICommandService),d=(0,n.getSheetCommandTarget)(l);if(!d)return!1;let{unitId:f,subUnitId:p}=d,m={ranges:a,cfId:c.createCfId(f,p),stopIfTrue:!!s,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.uniqueValues,style:o}};return u.executeCommand(r.AddConditionalRuleMutation.id,{unitId:f,subUnitId:p,rule:m})}};function w({ref:e,...t}){let{icon:n,id:r,className:i,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),l=(0,a.useRef)(`_${O()}`);return T(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},o)}function T(e,t,n,r,i){return(0,a.createElement)(e.tag,{key:t,...E(e,n,i),...r},(D(e,n).children||[]).map((r,a)=>T(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function E(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function D(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function O(){return Math.random().toString(36).substring(2,8)}w.displayName=`UniverIcon`;let k={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`}}]},A=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`bold-icon`,ref:t,icon:k}))});A.displayName=`BoldIcon`;let j={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`}}]},M=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`delete-icon`,ref:t,icon:j}))});M.displayName=`DeleteIcon`;let N={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`}}]},P=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`increase-icon`,ref:t,icon:N}))});P.displayName=`IncreaseIcon`;let F={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`}}]},ee=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`italic-icon`,ref:t,icon:F}))});ee.displayName=`ItalicIcon`;let te={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`}}]},ne=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:te}))});ne.displayName=`MoreDownIcon`;let re={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`}}]},ie=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`sequence-icon`,ref:t,icon:re}))});ie.displayName=`SequenceIcon`;let ae={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`}}]},oe=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`strikethrough-icon`,ref:t,icon:ae}))});oe.displayName=`StrikethroughIcon`;let I={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`}}]},se=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`underline-icon`,ref:t,icon:I}))});se.displayName=`UnderlineIcon`;let ce={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`}}]},le=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`font-color-double-icon`,ref:t,icon:ce}))});le.displayName=`FontColorDoubleIcon`;let ue={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`}}]},de=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`paint-bucket-double-icon`,ref:t,icon:ue}))});de.displayName=`PaintBucketDoubleIcon`;let fe={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`}}]},pe=(0,a.forwardRef)(function(e,t){return(0,a.createElement)(w,Object.assign({},e,{id:`slash-double-icon`,ref:t,icon:fe}))});pe.displayName=`SlashDoubleIcon`;let L=e=>{let{color:n,onChange:r,disable:i=!1,Icon:s=de,className:c}=e,u=(0,a.useMemo)(()=>new t.ColorKit(n),[n]),d=()=>(0,l.jsx)(s,{className:(0,o.clsx)(`univer-fill-primary-600`,i&&c),extend:{colorChannel1:u.isValid?n:``}});return i?d():(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(o.ColorPicker,{value:n,onChange:r})}),children:(0,l.jsx)(`span`,{className:(0,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`,c),children:d()})})},R=e=>{let n=e.rule;if(!n)return null;let i=(0,a.useMemo)(()=>{if(n.type===r.CFRuleType.colorScale){let e=n.config.map((e,n)=>({color:new t.ColorKit(e.color),value:n})),i=e.length-1;return[,,,,,].fill(``).map((e,t,n)=>t*i/(n.length-1)).map(t=>(0,r.getColorScaleFromValue)(e,t))}return null},[n]),s=(0,a.useMemo)(()=>{if(n.type===r.CFRuleType.iconSet)return n.config.map(e=>{let t=r.iconMap[e.iconType];return t&&t[Number(e.iconId)]})},[n]),c=`univer-pointer-events-none univer-flex univer-h-5 univer-min-w-[72px] univer-items-center univer-justify-center univer-text-xs`;switch(n.type){case r.CFRuleType.dataBar:{var u,d;let{isGradient:e}=n.config,t=e?`linear-gradient(to right, ${n.config.positiveColor||r.defaultDataBarPositiveColor}, rgb(255 255 255))`:n.config.positiveColor;return(0,l.jsxs)(`div`,{className:c,children:[(0,l.jsx)(`div`,{className:`univer-h-full univer-w-1/2 univer-border univer-border-solid`,style:{background:e?`linear-gradient(to right, rgb(255 255 255),${n.config.nativeColor||r.defaultDataBarNativeColor})`:n.config.nativeColor,borderColor:(u=n.config.nativeColor)==null?r.defaultDataBarNativeColor:u}}),(0,l.jsx)(`div`,{className:`univer-h-full univer-w-1/2 univer-border univer-border-solid`,style:{background:t,borderColor:(d=n.config.positiveColor)==null?r.defaultDataBarPositiveColor:d}})]})}case r.CFRuleType.colorScale:return i&&(0,l.jsx)(`div`,{className:c,children:i.map((e,t)=>(0,l.jsx)(`div`,{className:`univer-h-full`,style:{width:`${100/i.length}%`,background:e}},t))});case r.CFRuleType.iconSet:return s&&(0,l.jsx)(`div`,{className:c,children:s.map((e,t)=>e?(0,l.jsx)(`img`,{className:`univer-h-full`,src:e,draggable:!1},t):(0,l.jsx)(pe,{},t))});case r.CFRuleType.highlightCell:{var f,p,m;let{ul:e,st:i,it:a,bl:s,bg:u,cl:d}=n.style,h=(e==null?void 0:e.s)===t.BooleanNumber.TRUE,g=(i==null?void 0:i.s)===t.BooleanNumber.TRUE,_=a===t.BooleanNumber.TRUE,v=s===t.BooleanNumber.TRUE,y=(f=u==null?void 0:u.rgb)==null?r.DEFAULT_BG_COLOR:f,b=(p=d==null?void 0:d.rgb)==null?r.DEFAULT_FONT_COLOR:p,x={textDecoration:(m=`${h?`underline`:``} ${g?`line-through`:``}`.replace(/^ /,``))==null?void 0:m,backgroundColor:y,color:b};return(0,l.jsx)(`div`,{className:(0,o.clsx)(c,{"univer-font-bold":v,"univer-italic":_}),style:x,children:`123`})}}},z=(0,o.clsx)(`univer-mt-5 univer-px-1 univer-py-2 univer-rounded`,o.borderClassName),B=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),me=e=>{var n;let{type:s,className:u,onChange:d,id:f,value:p}=e,m=(0,i.useDependency)(t.IUniverInstanceService),h=m.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),g=(n=m.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),_=(0,a.useMemo)(()=>String(p).startsWith(`=`)?String(p):`=`,[p]),v=(0,a.useMemo)(()=>[r.CFValueType.max,r.CFValueType.min,`none`].includes(s)?{disabled:!0}:[r.CFValueType.percent,r.CFValueType.percentile].includes(s)?{min:0,max:100}:{min:-(2**53-1),max:2**53-1},[s]),y=(0,a.useRef)(null),[b,x]=(0,a.useState)(!1);return(0,i.useSidebarClick)(e=>{var t;(t=y.current)!=null&&t.isClickOutSide(e)&&x(!1)}),s===r.CFValueType.formula?(0,l.jsx)(`div`,{className:`univer-ml-1 univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:y,className:(0,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:_,unitId:h,subUnitId:g,isFocus:b,onChange:(e=``)=>{d(e||``)},onFocus:()=>x(!0)})}):(0,l.jsx)(o.InputNumber,{className:u,value:Number(e.value)||0,onChange:t=>e.onChange(t||0),...v})},he=e=>{var n;let{interceptorManager:s}=e,c=(0,i.useDependency)(t.LocaleService),u=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.colorScale?e.rule:void 0,d=[B(r.CFValueType.num,c),B(r.CFValueType.percent,c),B(r.CFValueType.percentile,c),B(r.CFValueType.formula,c)],f=[B(r.CFValueType.min,c),...d],p=[B(`none`,c),...d],m=[B(r.CFValueType.max,c),...d],[h,g]=(0,a.useState)(()=>{var e;let t=r.CFValueType.min;return u&&((e=u.config[0])==null?void 0:e.value.type)||t}),[_,v]=(0,a.useState)(()=>{var e;let t=`none`;return!u||u.config.length!==3?t:((e=u.config[1])==null?void 0:e.value.type)||t}),[y,b]=(0,a.useState)(()=>{var e;let t=r.CFValueType.max;return u&&((e=u.config[u.config.length-1])==null?void 0:e.value.type)||t}),[x,S]=(0,a.useState)(()=>{if(!u)return 10;let e=u.config[0];return(e==null?void 0:e.value.value)===void 0?10:e==null?void 0:e.value.value}),[C,w]=(0,a.useState)(()=>{var e;if(!u||u.config.length!==3)return 50;let t=(e=u.config[1])==null?void 0:e.value.value;return t===void 0?50:t}),[T,E]=(0,a.useState)(()=>{var e;if(!u)return 90;let t=(e=u.config[u.config.length-1])==null?void 0:e.value.value;return t===void 0?90:t}),[D,O]=(0,a.useState)(()=>{var e;return u&&((e=u.config[0])==null?void 0:e.color)||`#d0d9fb`}),[k,A]=(0,a.useState)(()=>{var e;let t=`#7790f3`;return!u||u.config.length!==3?t:((e=u.config[1])==null?void 0:e.color)||t}),[j,M]=(0,a.useState)(()=>{var e;return u&&((e=u.config[u.config.length-1])==null?void 0:e.color)||`#2e55ef`}),N=(0,a.useMemo)(()=>e=>{let{minType:t,medianType:n,maxType:i,minValue:a,medianValue:o,maxValue:s,minColor:c,medianColor:l,maxColor:u}=e,d=[];return d.push({color:c,value:{type:t,value:a}}),n!==`none`&&d.push({color:l,value:{type:n,value:o}}),d.push({color:u,value:{type:i,value:s}}),{config:d.map((e,t)=>({...e,index:t})),type:r.CFRuleType.colorScale}},[]);(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return N({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),[N,h,_,y,x,C,T,D,k,j,s]);let P=t=>{e.onChange(N(t))};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:N({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})})}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.min`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:f,value:h,onChange:e=>{g(e);let t=(0,r.createDefaultValueByValueType)(e,10);S(t),P({minType:e,medianType:_,maxType:y,minValue:t,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(me,{id:`min`,className:`univer-ml-1`,value:x,type:h,onChange:e=>{S(e),P({minType:h,medianType:_,maxType:y,minValue:e,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(L,{className:`univer-ml-1`,color:D,onChange:e=>{O(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:e,medianColor:k,maxColor:j})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.medianValue`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:p,value:_,onChange:e=>{v(e);let t=(0,r.createDefaultValueByValueType)(e,50);w(t),P({minType:h,medianType:e,maxType:y,minValue:x,medianValue:t,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(me,{id:`median`,className:`univer-ml-1`,value:C,type:_,onChange:e=>{w(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:e,maxValue:T,minColor:D,medianColor:k,maxColor:j})}}),_!==`none`&&(0,l.jsx)(L,{className:`univer-ml-1`,color:k,onChange:e=>{A(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:e,maxColor:j})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-xs univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.max`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-h-8 univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-flex-shrink-0`,options:m,value:y,onChange:e=>{b(e);let t=(0,r.createDefaultValueByValueType)(e,90);E(t),P({minType:h,medianType:_,maxType:e,minValue:x,medianValue:C,maxValue:t,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(me,{id:`max`,className:`univer-ml-1`,value:T,type:y,onChange:e=>{E(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:e,minColor:D,medianColor:k,maxColor:j})}}),(0,l.jsx)(L,{className:`univer-ml-1`,color:j,onChange:e=>{M(e),P({minType:h,medianType:_,maxType:y,minValue:x,medianValue:C,maxValue:T,minColor:D,medianColor:k,maxColor:e})}})]})]})},V=(e,t)=>({label:t.t(`sheet.cf.valueType.${e}`),value:e}),ge=e=>{var n;let{onChange:s,className:u,value:d,type:f,id:p,disabled:m=!1}=e,h=(0,i.useDependency)(t.IUniverInstanceService),g=h.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),_=(n=h.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),v=(0,a.useRef)(null),[y,b]=(0,a.useState)(!1);(0,i.useSidebarClick)(e=>{var t;(t=v.current)!=null&&t.isClickOutSide(e)&&b(!1)});let x=(0,a.useRef)(d),S=(0,a.useMemo)(()=>[r.CFValueType.percentile,r.CFValueType.percent].includes(f)?{max:100,min:0}:{min:-(2**53-1),max:2**53-1},[f]);if(f===r.CFValueType.formula){let e=String(x.current).startsWith(`=`)?String(x.current)||``:`=`;return(0,l.jsx)(`div`,{className:`univer-ml-3 univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:v,className:(0,o.clsx)(`univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-white univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-white [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,o.borderClassName),initValue:e,unitId:g,subUnitId:_,isFocus:y,onChange:(e=``)=>{s(e||``)},onFocus:()=>b(!0)})})}return(0,l.jsx)(o.InputNumber,{className:u,value:Number(d)||0,disabled:m,onChange:e=>{s(e||0)},...S})},_e=e=>{var n;let{interceptorManager:s}=e,c=(0,i.useDependency)(t.LocaleService),u=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.dataBar?e.rule:void 0,[d,f]=(0,a.useState)(()=>{var e;return u&&(e=u.config)!=null&&e.isGradient?`1`:`0`}),[p,m]=(0,a.useState)(()=>{var e;return u&&((e=u.config)==null?void 0:e.positiveColor)||r.defaultDataBarPositiveColor}),[h,g]=(0,a.useState)(()=>{var e;return u&&((e=u.config)==null?void 0:e.nativeColor)||r.defaultDataBarNativeColor}),_=[V(r.CFValueType.num,c),V(r.CFValueType.percent,c),V(r.CFValueType.percentile,c),V(r.CFValueType.formula,c)],v=[V(r.CFValueType.min,c),..._],y=[V(r.CFValueType.max,c),..._],[b,x]=(0,a.useState)(()=>{var e;let t=v[0].value;return u&&((e=u.config)==null?void 0:e.min.type)||t}),[S,C]=(0,a.useState)(()=>{var e;let t=y[0].value;return u&&((e=u.config)==null?void 0:e.max.type)||t}),[w,T]=(0,a.useState)(()=>{var e;if(!u)return 0;let t=((e=u.config)==null?void 0:e.min)||{};return t.type===r.CFValueType.formula?t.value||`=`:t.value||0}),[E,D]=(0,a.useState)(()=>{var e;if(!u)return 100;let t=((e=u.config)==null?void 0:e.max)||{};return t.type===r.CFValueType.formula?t.value||`=`:t.value===void 0?100:t.value}),[O,k]=(0,a.useState)(()=>u?u.isShowValue===void 0?!0:!!u.isShowValue:!0),A=e=>({config:{min:{type:e.minValueType,value:e.minValue},max:{type:e.maxValueType,value:e.maxValue},isGradient:e.isGradient===`1`,positiveColor:e.positiveColor||r.defaultDataBarPositiveColor,nativeColor:e.nativeColor||r.defaultDataBarNativeColor},type:r.CFRuleType.dataBar,isShowValue:e.isShowValue});(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return A({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}}),[d,w,b,E,S,p,h,s,O]);let j=t=>{e.onChange(A(t))},M=e=>{m(e),j({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:e,nativeColor:h,isShowValue:O})},N=e=>{g(e),j({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:e,isShowValue:O})},P=e=>_.map(e=>e.value).includes(e);return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:A({isGradient:d,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})})}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.fillType`)}),(0,l.jsxs)(`div`,{className:`univer-ml-1 univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsxs)(o.RadioGroup,{value:d,onChange:e=>{f(e),j({isGradient:e,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})},children:[(0,l.jsx)(o.Radio,{value:`0`,children:(0,l.jsx)(`span`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.pureColor`)})}),(0,l.jsx)(o.Radio,{value:`1`,children:(0,l.jsx)(`span`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.gradient`)})})]}),(0,l.jsxs)(`div`,{className:`univer-ml-6 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:!O,onChange:e=>{k(!e),j({isGradient:e,minValue:w,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:!e})}}),c.t(`sheet.cf.panel.onlyShowDataBar`)]})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.panel.colorSet`)}),(0,l.jsxs)(`div`,{className:`univer-ml-1 univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-items-center`,children:[(0,l.jsx)(`div`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.native`)}),(0,l.jsx)(L,{color:h,onChange:N})]}),(0,l.jsxs)(`div`,{className:`univer-ml-3 univer-flex univer-items-center`,children:[(0,l.jsx)(`div`,{className:`univer-text-xs`,children:c.t(`sheet.cf.panel.positive`)}),(0,l.jsx)(L,{color:p,onChange:M})]})]})]}),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.min`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-w-1/2 univer-flex-shrink-0`,options:v,value:b,onChange:e=>{x(e);let t=(0,r.createDefaultValueByValueType)(e,10);T(t),j({isGradient:d,minValue:t,minValueType:e,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}}),(0,l.jsx)(ge,{id:`min`,className:`univer-ml-3`,disabled:!P(b),type:b,value:w,onChange:e=>{T(e||0),j({isGradient:d,minValue:e||0,minValueType:b,maxValue:E,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}})]}),(0,l.jsx)(`div`,{className:`univer-mt-3 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:c.t(`sheet.cf.valueType.max`)}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.Select,{className:`univer-w-1/2 univer-flex-shrink-0`,options:y,value:S,onChange:e=>{C(e);let t=(0,r.createDefaultValueByValueType)(e,90);D(t),j({isGradient:d,minValue:w,minValueType:b,maxValue:t,maxValueType:e,positiveColor:p,nativeColor:h,isShowValue:O})}}),(0,l.jsx)(ge,{className:`univer-ml-3`,disabled:!P(S),id:`max`,type:S,value:E,onChange:e=>{D(e||0),j({isGradient:d,minValue:w,minValueType:b,maxValue:e||0,maxValueType:S,positiveColor:p,nativeColor:h,isShowValue:O})}})]})]})]})},ve=e=>[t.BooleanNumber.FALSE,void 0].includes(e)?t.BooleanNumber.TRUE:t.BooleanNumber.FALSE,ye=e=>e!==t.BooleanNumber.FALSE,be=e=>{let{style:n,onChange:i,className:s}=e,[c,u]=(0,a.useState)(()=>{if(n!=null&&n.bl)return n.bl}),[d,f]=(0,a.useState)(()=>{if(n!=null&&n.it)return n.it}),[p,m]=(0,a.useState)(()=>{if(n!=null&&n.ul)return n.ul.s}),[h,g]=(0,a.useState)(()=>{if(n!=null&&n.st)return n.st.s}),[_,v]=(0,a.useState)(()=>{var e;return!(n==null||(e=n.cl)==null)&&e.rgb?n.cl.rgb:`#2f56ef`}),[y,b]=(0,a.useState)(()=>{var e;return!(n==null||(e=n.bg)==null)&&e.rgb?n.bg.rgb:`#e8ecfc`});(0,a.useEffect)(()=>{let e={bl:c,it:d};_!==void 0&&(e.cl={rgb:_}),y!==void 0&&(e.bg={rgb:y}),h!==void 0&&(e.st={s:h}),p!==void 0&&(e.ul={s:p}),i((0,r.removeUndefinedAttr)(e))},[c,d,p,h,_,y]);let x=`univer-flex univer-cursor-pointer univer-items-center univer-rounded univer-px-1`;return(0,l.jsxs)(`div`,{className:(0,o.clsx)(`univer-my-2.5 univer-flex univer-justify-between`,s),children:[(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(c||t.BooleanNumber.FALSE)}),onClick:()=>u(ve(c)),children:(0,l.jsx)(A,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(d||t.BooleanNumber.FALSE)}),onClick:()=>f(ve(d)),children:(0,l.jsx)(ee,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(p||t.BooleanNumber.FALSE)}),onClick:()=>m(ve(p)),children:(0,l.jsx)(se,{})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(x,{"univer-bg-gray-100 dark:!univer-bg-gray-700":ye(h||t.BooleanNumber.FALSE)}),onClick:()=>g(ve(h)),children:(0,l.jsx)(oe,{})}),(0,l.jsx)(L,{color:_,onChange:v,Icon:le}),(0,l.jsx)(L,{color:y,onChange:b})]})},xe=e=>{var n;let{onChange:s,interceptorManager:u}=e,d=(0,i.useDependency)(t.LocaleService),f=(0,i.useDependency)(t.IUniverInstanceService).getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),p=f.getActiveSheet(),m=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1),v=(0,a.useRef)(null),[y,b]=(0,a.useState)({}),[x,S]=(0,a.useState)(()=>(m==null?void 0:m.subType)===r.CFSubRuleType.formula?m.value:`=`),[C,w]=(0,a.useState)(void 0),T=e=>({style:e.style,value:x,type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula});(0,a.useEffect)(()=>u.intercept(u.getInterceptPoints().submit,{handler(){return T({style:y,formula:x})}}),[y,x,u]),(0,a.useEffect)(()=>u.intercept(u.getInterceptPoints().beforeSubmit,{handler:(e,t,n)=>C||x.length===1||!x.startsWith(`=`)?(w(d.t(`sheet.cf.errorMessage.formulaError`)),!1):n(e)}),[C,x]);let E=e=>{s(T(e))};return(0,i.useSidebarClick)(e=>{var t;(t=v.current)!=null&&t.isClickOutSide(e)&&_(!1)}),(0,l.jsxs)(`div`,{ref:h,children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:d.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(c.FormulaEditor,{ref:v,className:(0,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:C,isFocus:g,initValue:x,unitId:f.getUnitId(),subUnitId:p==null?void 0:p.getSheetId(),onFocus:()=>{_(!0)},onChange:e=>{S(e),E({style:y,formula:e})},onVerify:(e,t)=>{!e||t.length===1?w(d.t(`sheet.cf.errorMessage.formulaError`)):w(void 0)}})}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:T({style:y,formula:x})})}),(0,l.jsx)(be,{style:m==null?void 0:m.style,className:`univer-mt-3`,onChange:e=>{b(e),E({style:e,formula:x})}})]})},Se=e=>(0,l.jsxs)(`div`,{className:`univer-relative`,children:[(0,l.jsx)(`div`,{className:`univer-absolute univer-bottom-[-13px] univer-z-[999] univer-text-[10px] univer-text-red-500`,children:e.errorText}),e.children]}),H=(e,t)=>({label:t.t(`sheet.cf.operator.${e}`),value:e}),Ce=e=>{let{type:n,operator:s,onChange:c,value:u,interceptorManager:d}=e,f=(0,i.useDependency)(t.LocaleService),[p,m]=(0,a.useState)(()=>typeof u==`number`?u:0),[h,g]=(0,a.useState)(``),[_,v]=(0,a.useState)(()=>typeof u==`string`?u:``),[y,b]=(0,a.useState)(``),[x,S]=(0,a.useState)(()=>Array.isArray(u)?u[0]===void 0?0:u[0]:0),[C,w]=(0,a.useState)(``),[T,E]=(0,a.useState)(()=>Array.isArray(u)?u[1]===void 0?100:u[1]:100),[D,O]=(0,a.useState)(``);switch((0,a.useEffect)(()=>{switch(n){case r.CFSubRuleType.text:[r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(s)&&c(_);break;case r.CFSubRuleType.number:[r.CFNumberOperator.equal,r.CFNumberOperator.notEqual,r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual,r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(s)&&c(p),[r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(s)&&c([x,T]);break}},[n]),(0,a.useEffect)(()=>{let e=d.intercept(d.getInterceptPoints().beforeSubmit,{handler:(e,t,i)=>{switch(n){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.containsText,r.CFTextOperator.endsWith,r.CFTextOperator.notEqual,r.CFTextOperator.notContainsText,r.CFTextOperator.equal].includes(s))return _?i(e):(b(f.t(`sheet.cf.errorMessage.notBlank`)),!1)}return i(e)}});return()=>{e()}},[n,p,_,s]),n){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(s)){let e=e=>{v(e),c(e)};return(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(Se,{errorText:y,children:(0,l.jsx)(o.Input,{value:_,onChange:t=>{b(``),e(t)}})})})}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(s))return(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(Se,{errorText:h,children:(0,l.jsx)(o.InputNumber,{className:`univer-w-full`,min:-(2**53-1),max:2**53-1,value:p,onChange:e=>{m(e||0),c(e||0),g(``)}})})});if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(s))return(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(Se,{errorText:C,children:(0,l.jsx)(o.InputNumber,{min:-(2**53-1),max:2**53-1,value:x,onChange:e=>{S(e||0),c([e||0,T]),w(``)}})}),(0,l.jsx)(Se,{errorText:D,children:(0,l.jsx)(o.InputNumber,{className:`univer-ml-3`,min:-(2**53-1),max:2**53-1,value:T,onChange:e=>{E(e||0),c([x,e||0]),O(``)}})})]})}return null},we=(e,t)=>{switch(e){case r.CFSubRuleType.text:return[H(r.CFTextOperator.containsText,t),H(r.CFTextOperator.notContainsText,t),H(r.CFTextOperator.beginsWith,t),H(r.CFTextOperator.endsWith,t),H(r.CFTextOperator.equal,t),H(r.CFTextOperator.notEqual,t),H(r.CFTextOperator.containsBlanks,t),H(r.CFTextOperator.notContainsBlanks,t),H(r.CFTextOperator.containsErrors,t),H(r.CFTextOperator.notContainsErrors,t)];case r.CFSubRuleType.number:return[H(r.CFNumberOperator.between,t),H(r.CFNumberOperator.notBetween,t),H(r.CFNumberOperator.equal,t),H(r.CFNumberOperator.notEqual,t),H(r.CFNumberOperator.greaterThan,t),H(r.CFNumberOperator.greaterThanOrEqual,t),H(r.CFNumberOperator.lessThan,t),H(r.CFNumberOperator.lessThanOrEqual,t)];case r.CFSubRuleType.timePeriod:return[H(r.CFTimePeriodOperator.yesterday,t),H(r.CFTimePeriodOperator.today,t),H(r.CFTimePeriodOperator.tomorrow,t),H(r.CFTimePeriodOperator.last7Days,t),H(r.CFTimePeriodOperator.lastWeek,t),H(r.CFTimePeriodOperator.thisWeek,t),H(r.CFTimePeriodOperator.nextWeek,t),H(r.CFTimePeriodOperator.lastMonth,t),H(r.CFTimePeriodOperator.thisMonth,t),H(r.CFTimePeriodOperator.nextMonth,t)]}},Te=e=>{var n;let{interceptorManager:s,onChange:c}=e,u=(0,i.useDependency)(t.LocaleService),d=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,[f,p]=(0,a.useState)(()=>{let e=r.CFSubRuleType.text;return d&&d.subType||e}),m=[{value:r.CFSubRuleType.text,label:u.t(`sheet.cf.subRuleType.text`)},{value:r.CFSubRuleType.number,label:u.t(`sheet.cf.subRuleType.number`)},{value:r.CFSubRuleType.timePeriod,label:u.t(`sheet.cf.subRuleType.timePeriod`)},{value:r.CFSubRuleType.duplicateValues,label:u.t(`sheet.cf.subRuleType.duplicateValues`)},{value:r.CFSubRuleType.uniqueValues,label:u.t(`sheet.cf.subRuleType.uniqueValues`)}],h=(0,a.useMemo)(()=>we(f,u),[f]),[g,_]=(0,a.useState)(()=>{let e=h?h[0].value:void 0;return d&&d.operator||e}),[v,y]=(0,a.useState)(()=>{var e;return d?(e=d.value)==null?(0,r.createDefaultValue)(d.subType,d.operator):e:``}),[b,x]=(0,a.useState)({}),S=(0,a.useMemo)(()=>e=>{var t,n,i;switch(e.subType||f){case r.CFSubRuleType.text:if([r.CFTextOperator.beginsWith,r.CFTextOperator.endsWith,r.CFTextOperator.containsText,r.CFTextOperator.notContainsText,r.CFTextOperator.equal,r.CFTextOperator.notEqual].includes(g)){var a,o,s,c;return{type:r.CFRuleType.highlightCell,subType:(a=e.subType)==null?f:a,operator:(o=e.operator)==null?g:o,style:(s=e.style)==null?b:s,value:(c=e.value)==null?v:c}}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(g)){var l,u,d,p;return{type:r.CFRuleType.highlightCell,subType:(l=e.subType)==null?f:l,operator:(u=e.operator)==null?g:u,style:(d=e.style)==null?b:d,value:(p=e.value)==null?v:p}}if([r.CFNumberOperator.between,r.CFNumberOperator.notBetween].includes(g)){var m,h,_,y;return{type:r.CFRuleType.highlightCell,subType:(m=e.subType)==null?f:m,operator:(h=e.operator)==null?g:h,style:(_=e.style)==null?b:_,value:(y=e.value)==null?v:y}}break}return{type:r.CFRuleType.highlightCell,subType:(t=e.subType)==null?f:t,operator:(n=e.operator)==null?g:n,style:(i=e.style)==null?b:i}},[f,g,v,b]);(0,a.useEffect)(()=>s.intercept(s.getInterceptPoints().submit,{handler(){return S({})}}),[S,s]),(0,a.useEffect)(()=>{m.some(e=>e.value===f)||p(m[0].value)},[m]);let C=e=>{let t=e,n=we(t,u),i=n&&n[0].value;p(t),_(i),i&&y((0,r.createDefaultValue)(t,i)),c(S({subType:t,operator:i}))},w=e=>{let t=e;_(t),c(S({operator:t}))},T=e=>{y(e),c(S({value:e}))},E=(0,a.useMemo)(()=>`${f}_${g}_${Math.random()}`,[f,g]);return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-between univer-gap-4`,children:[(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,onChange:C,value:f,options:m}),(h==null?void 0:h.length)&&(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,onChange:w,value:g||``,options:h})]}),(0,l.jsx)(Ce,{value:v,interceptorManager:s,type:f,operator:g,rule:d,onChange:T},E),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:S({})})}),(0,l.jsx)(be,{style:d==null?void 0:d.style,className:`univer-ml-1`,onChange:e=>{x(e),c(S({style:e}))}})]})},Ee=(e,t)=>(r.iconMap[e]||[])[Number(t)]||``,De=e=>{var n;let{error:s,type:u,onChange:d}=e,f=(0,i.useDependency)(t.IUniverInstanceService),p=f.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),m=(n=f.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId(),h=(0,a.useRef)(null),[g,_]=(0,a.useState)(!1);return(0,i.useSidebarClick)(e=>{var t;(t=h.current)!=null&&t.isClickOutSide(e)&&_(!1)}),(0,l.jsx)(`div`,{className:`univer-relative`,children:u===r.CFValueType.formula?(0,l.jsx)(`div`,{className:`univer-w-full`,children:(0,l.jsx)(c.FormulaEditor,{ref:h,className:(0,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(e.value),unitId:p,subUnitId:m,isFocus:g,onChange:(e=``)=>{d(e||``)},onFocus:()=>_(!0)})}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(o.InputNumber,{className:(0,o.clsx)({"univer-border-red-500":s}),value:Number(e.value)||0,onChange:e=>d(e==null?0:e)}),s&&(0,l.jsx)(`div`,{className:`univer-absolute univer-text-xs univer-text-red-500`,children:s})]})})},Oe=(e,t,n)=>({operator:r.CFNumberOperator.greaterThan,value:{type:r.CFValueType.num,value:(n.length-1-t)*10},iconType:e,iconId:String(t)}),ke=(0,a.forwardRef)((e,n)=>{let{onClick:a}=e,o=(0,i.useDependency)(t.LocaleService),s=e=>{a(e)};return(0,l.jsx)(`div`,{ref:n,className:`univer-w-80`,children:r.iconGroup.map((e,t)=>(0,l.jsxs)(`div`,{className:`univer-mb-3`,children:[(0,l.jsx)(`div`,{className:`univer-mb-1 univer-text-sm`,children:o.t(e.title)}),(0,l.jsx)(`div`,{className:`univer-flex univer-flex-wrap`,children:e.group.map(e=>(0,l.jsx)(`div`,{className:`univer-mb-1 univer-flex univer-w-1/2 univer-items-center`,onClick:()=>{s(e.name)},children:(0,l.jsx)(`a`,{className:`univer-flex univer-cursor-pointer univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,children:e.list.map((e,t)=>(0,l.jsx)(`img`,{className:`univer-size-5`,src:e,draggable:!1},t))})},e.name))})]},t))})}),Ae=e=>{let{onClick:t}=e,n=(0,a.useMemo)(()=>{let e=[];for(let t in r.iconMap){let n=r.iconMap[t],i=t;n.forEach((t,n)=>{e.push({iconType:i,base64:t,iconId:String(n)})})}return e},[]),i=e=>{t(e.iconType,e.iconId)};return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`univer-mb-2.5 univer-flex univer-cursor-pointer univer-items-center univer-pl-1`,onClick:()=>i({iconType:r.EMPTY_ICON_TYPE,iconId:``,base64:``}),children:[(0,l.jsx)(pe,{className:`univer-size-5`}),(0,l.jsx)(`span`,{className:`univer-ml-2`,children:`无单元格图标`})]}),(0,l.jsx)(`div`,{className:`univer-flex univer-w-64 univer-flex-wrap`,children:n.map(e=>(0,l.jsx)(`div`,{className:`univer-mb-2 univer-mr-2 univer-flex univer-cursor-pointer univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-100 dark:hover:!univer-bg-gray-700`,children:(0,l.jsx)(`img`,{className:`univer-size-5`,src:e.base64,draggable:!1,onClick:()=>i(e)})},`${e.iconType}_${e.iconId}`))})]})},je=e=>{let{onChange:n,configList:s,errorMap:c={}}=e,u=(0,i.useDependency)(t.LocaleService),d=[{label:u.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThan}`),value:r.CFNumberOperator.greaterThan},{label:u.t(`sheet.cf.symbol.${r.CFNumberOperator.greaterThanOrEqual}`),value:r.CFNumberOperator.greaterThanOrEqual}],f=[{label:u.t(`sheet.cf.valueType.${r.CFValueType.num}`),value:r.CFValueType.num},{label:u.t(`sheet.cf.valueType.${r.CFValueType.percent}`),value:r.CFValueType.percent},{label:u.t(`sheet.cf.valueType.${r.CFValueType.percentile}`),value:r.CFValueType.percentile},{label:u.t(`sheet.cf.valueType.${r.CFValueType.formula}`),value:r.CFValueType.formula}],p=(e,t)=>{n([String(t),`value`,`value`],e)},m=(e,t)=>{n([String(t),`operator`],e),p((0,r.createDefaultValue)(r.CFSubRuleType.number,e),t)},h=(e,t)=>{n([String(t),`value`,`type`],e);let i=s[t];p((0,r.createDefaultValue)(r.CFSubRuleType.number,i.operator),t)};return(0,a.useMemo)(()=>s.map((e,t)=>{let i=c[t],a=Ee(e.iconType,e.iconId),g=t===s.length-1,_=t===0,v=s[t-1],y=(v==null?void 0:v.value.type)===r.CFValueType.formula?u.t(`sheet.cf.valueType.formula`):v==null?void 0:v.value.value;return(0,l.jsxs)(`div`,{className:t?`univer-mt-6`:`univer-mt-3`,children:[(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center univer-justify-between univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[(0,l.jsxs)(`div`,{className:`univer-w-[45%]`,children:[u.t(`sheet.cf.iconSet.icon`),t+1]}),(0,l.jsx)(`div`,{className:`univer-w-[45%]`,children:(0,l.jsxs)(l.Fragment,{children:[!_&&!g&&u.t(`sheet.cf.iconSet.rule`),!_&&!g&&(0,l.jsxs)(`span`,{className:`univer-font-medium univer-text-gray-600 dark:!univer-text-gray-200`,children:[u.t(`sheet.cf.iconSet.when`),u.t(`sheet.cf.symbol.${(0,r.getOppositeOperator)(v.operator)}`),y,g?``:` ${u.t(`sheet.cf.iconSet.and`)} `]})]})})]}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4`,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center`,children:(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(Ae,{onClick:(r,i)=>{let a={...e,iconId:i,iconType:r};n([String(t)],a)},iconId:e.iconId,iconType:e.iconType})}),children:(0,l.jsxs)(`div`,{className:(0,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:[a?(0,l.jsx)(`img`,{src:a,className:`univer-size-4`,draggable:!1}):(0,l.jsx)(pe,{className:`univer-size-4`}),(0,l.jsx)(ne,{})]})})}),g?(0,l.jsxs)(`div`,{className:`univer-mt-0 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:[u.t(`sheet.cf.iconSet.rule`),(0,l.jsxs)(`span`,{className:`univer-font-medium`,children:[u.t(`sheet.cf.iconSet.when`),u.t(`sheet.cf.symbol.${(0,r.getOppositeOperator)(v.operator)}`),y,g?``:` ${u.t(`sheet.cf.iconSet.and`)} `]})]}):(0,l.jsx)(o.Select,{options:d,value:e.operator,onChange:e=>{m(e,t)}})]}),g?(0,l.jsx)(`div`,{}):(0,l.jsxs)(l.Fragment,{children:[(0,l.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:[(0,l.jsx)(`div`,{children:u.t(`sheet.cf.iconSet.type`)}),(0,l.jsx)(`div`,{children:u.t(`sheet.cf.iconSet.value`)})]}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-grid univer-grid-cols-2 univer-gap-4`,children:[(0,l.jsx)(o.Select,{options:f,value:e.value.type,onChange:e=>{h(e,t)}}),(0,l.jsx)(De,{id:t,type:e.value.type,error:i,value:e.value.value||``,onChange:e=>{p(e,t)}})]})]})]},t)}),[s,c])},Me=e=>{var n;let{interceptorManager:s}=e,c=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.iconSet?e.rule:void 0,u=(0,i.useDependency)(t.LocaleService),[d,f]=(0,a.useState)({}),[p,m]=(0,a.useState)(()=>{let e=Object.keys(r.iconMap)[0];if(c&&c.config.length){let e=c.config[0].iconType;if(!c.config.some(t=>t.iconType!==e))return e}return e}),[h,g]=(0,a.useState)(()=>{if(c&&c.config.length)return t.Tools.deepClone(c==null?void 0:c.config);let e=r.iconMap[p]||[];return Array(e.length).fill(``).map((e,t,n)=>t===n.length-1?{operator:r.CFNumberOperator.lessThanOrEqual,value:{type:r.CFValueType.num,value:2**53-1},iconType:p,iconId:String(t)}:Oe(p,t,n))}),[_,v]=(0,a.useState)(()=>c?!!c.isShowValue:!0),y=(0,a.useMemo)(()=>(0,l.jsx)(`div`,{className:`univer-flex univer-items-center`,children:h.map(e=>Ee(e.iconType,e.iconId)).map((e,t)=>e?(0,l.jsx)(`img`,{className:`univer-size-5`,src:e},t):(0,l.jsx)(pe,{className:`univer-size-5`},t))}),[h]),b=e=>{if(e.reduce((t,n,i)=>t.preType&&!t.result||e.length-1===i?t:n.value.type===r.CFValueType.formula?{preType:r.CFValueType.formula,result:!1}:t.preType?{result:t.preType===n.value.type,preType:n.value.type}:{result:!0,preType:n.value.type},{result:!0,preType:``}).result&&[r.CFValueType.num,r.CFValueType.percent,r.CFValueType.percentile].includes(e[0].value.type)){let t={};return e.forEach((n,i,a)=>{if(i-1<0||i===a.length-1)return;let o=e[i-1],s=(0,r.getOppositeOperator)(o.operator);(0,r.compareWithNumber)({operator:s,value:o.value.value},n.value.value)||(t[i]=`${u.t(`sheet.cf.form.${s}`,String(o.value.value))} `)}),t}return{}},x=(e,n)=>{(0,t.get)(h,e)!==n&&((0,t.set)(h,e,n),g([...h]),f(b(h)))},S=e=>{m(e);let t=r.iconMap[e]||[],n=Array(t.length).fill(``).map((t,n,r)=>Oe(e,n,r));g(n),f(b(n))};(0,a.useEffect)(()=>{let e=s.intercept(s.getInterceptPoints().submit,{handler(){return{type:r.CFRuleType.iconSet,isShowValue:_,config:h}}});return()=>{e()}},[_,h,s]),(0,a.useEffect)(()=>{let e=s.intercept(s.getInterceptPoints().beforeSubmit,{handler(){return Object.keys(d).length===0}});return()=>{e()}},[_,h,s,d]);let C=()=>{let e=h.map(e=>({...e}));h.forEach((t,n)=>{let r=e[h.length-1-n];t.iconId=r.iconId,t.iconType=r.iconType}),g([...h])},w=(0,i.useDependency)(i.ILayoutService),[T,E]=(0,a.useState)();return(0,i.useScrollYOverContainer)(T,w.rootContainerElement),(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(`div`,{className:`univer-mt-3`,children:(0,l.jsx)(o.Dropdown,{overlay:(0,l.jsx)(`div`,{className:`univer-rounded-lg univer-p-4`,children:(0,l.jsx)(ke,{ref:e=>{!T&&e&&E(e)},iconType:p,onClick:S})}),children:(0,l.jsxs)(`div`,{className:(0,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:[y,(0,l.jsx)(ne,{})]})})}),(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsxs)(`div`,{className:`univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{onChange:C}),u.t(`sheet.cf.iconSet.reverseIconOrder`)]}),(0,l.jsxs)(`div`,{className:`univer-ml-6 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:!_,onChange:e=>{v(!e)}}),u.t(`sheet.cf.iconSet.onlyShowIcon`)]})]}),(0,l.jsx)(je,{errorMap:d,onChange:x,configList:h})]})},Ne=e=>{var n;let{onChange:s,interceptorManager:c}=e,u=(0,i.useDependency)(t.LocaleService),d=((n=e.rule)==null?void 0:n.type)===r.CFRuleType.highlightCell?e.rule:void 0,f=[{label:u.t(`sheet.cf.panel.isNotBottom`),value:`isNotBottom`},{label:u.t(`sheet.cf.panel.isBottom`),value:`isBottom`},{label:u.t(`sheet.cf.panel.greaterThanAverage`),value:`greaterThanAverage`},{label:u.t(`sheet.cf.panel.lessThanAverage`),value:`lessThanAverage`}],[p,m]=(0,a.useState)(()=>{let e=f[0].value,t=d==null?void 0:d.type;if(!d)return e;switch(t){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.average:return[r.CFNumberOperator.greaterThan,r.CFNumberOperator.greaterThanOrEqual].includes(d.operator)?`greaterThanAverage`:[r.CFNumberOperator.lessThan,r.CFNumberOperator.lessThanOrEqual].includes(d.operator)?`lessThanAverage`:e;case r.CFSubRuleType.rank:return d.isBottom?`isBottom`:`isNotBottom`}}return e}),[h,g]=(0,a.useState)(()=>{let e=d==null?void 0:d.type;if(!d)return 10;switch(e){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.rank:return d.value||10}}return 10}),[_,v]=(0,a.useState)(()=>{let e=d==null?void 0:d.type;if(!d)return!1;switch(e){case r.CFRuleType.highlightCell:switch(d.subType){case r.CFSubRuleType.rank:return d.isPercent||!1}}return!1}),[y,b]=(0,a.useState)({}),x=e=>{let{type:t,isPercent:n,value:i,style:a}=e;if(t===`isNotBottom`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:n,isBottom:!1,value:i,style:a};if(t===`isBottom`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank,isPercent:n,isBottom:!0,value:i,style:a};if(t===`greaterThanAverage`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.greaterThan,style:a};if(t===`lessThanAverage`)return{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.average,operator:r.CFNumberOperator.lessThan,style:a}};(0,a.useEffect)(()=>c.intercept(c.getInterceptPoints().submit,{handler(){return x({type:p,isPercent:_,value:h,style:y})}}),[p,_,h,y,c]);let S=e=>{s(x(e))};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:u.t(`sheet.cf.panel.styleRule`)}),(0,l.jsx)(o.Select,{className:`univer-mt-3 univer-w-full`,value:p,options:f,onChange:e=>{m(e),S({type:e,isPercent:_,value:h,style:y})}}),[`isNotBottom`,`isBottom`].includes(p)&&(0,l.jsxs)(`div`,{className:`univer-mt-3 univer-flex univer-items-center`,children:[(0,l.jsx)(o.InputNumber,{min:1,max:1e3,value:h,onChange:e=>{let t=e||0;g(t),S({type:p,isPercent:_,value:t,style:y})}}),(0,l.jsxs)(`div`,{className:`univer-ml-3 univer-flex univer-items-center univer-text-xs`,children:[(0,l.jsx)(o.Checkbox,{checked:_,onChange:e=>{v(!!e),S({type:p,isPercent:!!e,value:h,style:y})}}),u.t(`sheet.cf.valueType.percent`)]})]}),(0,l.jsx)(`div`,{className:z,children:(0,l.jsx)(R,{rule:x({type:p,isPercent:_,value:h,style:y})})}),(0,l.jsx)(be,{style:d==null?void 0:d.style,className:`univer-mt-3`,onChange:e=>{b(e),S({type:p,isPercent:_,value:h,style:e})}})]})},Pe=(0,t.createInterceptorKey)(`beforeSubmit`),Fe=(0,t.createInterceptorKey)(`submit`),Ie=e=>e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),Le=e=>{var n;return(n=e.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId()},Re=e=>{var u,d,f;let p=(0,i.useDependency)(t.LocaleService),m=(0,i.useDependency)(t.ICommandService),h=(0,i.useDependency)(t.IUniverInstanceService),g=(0,i.useDependency)(r.ConditionalFormattingRuleModel),_=(0,i.useDependency)(n.SheetsSelectionsService),v=Ie(h),y=Le(h),[b,x]=(0,a.useState)(void 0),S=(0,a.useRef)((u=(d=e.rule)==null?void 0:d.ranges)==null?[]:u),C=(0,a.useMemo)(()=>{var t;let n=(t=e.rule)==null?void 0:t.ranges;if(!(n!=null&&n.length)){var r,i;n=(r=(i=_.getCurrentSelections())==null?void 0:i.map(e=>e.range))==null?[]:r}return S.current=n,n!=null&&n.length?n.map(e=>{let t=(0,s.serializeRange)(e);return t===`NaN`?``:t}).filter(e=>!!e).join(`,`):``},[e.rule]),w=[{label:p.t(`sheet.cf.ruleType.highlightCell`),value:`1`},{label:p.t(`sheet.cf.panel.rankAndAverage`),value:`2`},{label:p.t(`sheet.cf.ruleType.dataBar`),value:`3`},{label:p.t(`sheet.cf.ruleType.colorScale`),value:`4`},{label:p.t(`sheet.cf.ruleType.formula`),value:`5`},{label:p.t(`sheet.cf.ruleType.iconSet`),value:`6`}],[T,E]=(0,a.useState)(()=>{var t;let n=(t=e.rule)==null?void 0:t.rule.type,i=w[0].value;if(!n)return i;switch(n){case r.CFRuleType.highlightCell:var a;switch((a=e.rule)==null?void 0:a.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 i}),D=(0,a.useRef)(void 0),O=(0,a.useMemo)(()=>new t.InterceptorManager({beforeSubmit:Pe,submit:Fe}),[]),k=(0,a.useMemo)(()=>{switch(T){case`1`:return Te;case`2`:return Ne;case`3`:return _e;case`4`:return he;case`5`:return xe;case`6`:return Me;default:return Te}},[T]);(0,a.useEffect)(()=>{let t=m.onCommandExecuted(t=>{if(t.id===n.RemoveSheetMutation.id){let n=t.params;n.subUnitId===y&&n.unitId===v&&e.onCancel()}t.id===n.SetWorksheetActiveOperation.id&&e.onCancel()});return()=>t.dispose()},[]);let A=e=>{D.current=e},j=e=>{S.current=e.split(`,`).filter(e=>!!e).map(s.deserializeRangeWithSheet).map(e=>e.range)};return(0,l.jsxs)(`div`,{children:[(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:p.t(`sheet.cf.panel.range`)}),(0,l.jsxs)(`div`,{className:`univer-mt-4`,children:[(0,l.jsx)(c.RangeSelector,{unitId:v,subUnitId:y,initialValue:C,onChange:(e,t)=>j(t),onVerify:(e,t)=>{e?t.length<1?x(p.t(`sheet.cf.errorMessage.rangeError`)):x(void 0):x(p.t(`sheet.cf.errorMessage.rangeError`))}}),b&&(0,l.jsx)(`div`,{className:`univer-mt-1 univer-text-xs univer-text-red-500`,children:b})]}),(0,l.jsx)(`div`,{className:`univer-mt-4 univer-text-sm univer-text-gray-600 dark:!univer-text-gray-200`,children:p.t(`sheet.cf.panel.styleType`)}),(0,l.jsx)(o.Select,{className:`univer-mt-4 univer-w-full`,value:T,options:w,onChange:e=>E(e)}),(0,l.jsx)(k,{interceptorManager:O,rule:(f=e.rule)==null?void 0:f.rule,onChange:A}),(0,l.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-justify-end`,children:[(0,l.jsx)(o.Button,{onClick:()=>{e.onCancel()},children:p.t(`sheet.cf.panel.cancel`)}),(0,l.jsx)(o.Button,{className:`univer-ml-3`,variant:`primary`,onClick:()=>{if(b)return;let i=(()=>{let e=h.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet();if(!e)throw Error(`No active sheet found`);return S.current.map(t=>(0,n.setEndForRange)(t,e.getRowCount(),e.getColumnCount())).filter(e=>!(Number.isNaN(e.startRow)||Number.isNaN(e.startColumn)))})();if(O.fetchThroughInterceptors(O.getInterceptPoints().beforeSubmit)(!0,null)){let t=O.fetchThroughInterceptors(O.getInterceptPoints().submit)(null,null);if(t){let n=Ie(h),a=Le(h);if(!n||!a)throw Error(`No active sheet found`);let o={};e.rule&&e.rule.cfId?(o={...e.rule,ranges:i,rule:t},m.executeCommand(r.SetCfCommand.id,{unitId:n,subUnitId:a,rule:o}),e.onCancel()):(o={cfId:g.createCfId(n,a),ranges:i,rule:t,stopIfTrue:!1},m.executeCommand(r.AddCfCommand.id,{unitId:n,subUnitId:a,rule:o}),e.onCancel())}}},children:p.t(`sheet.cf.panel.submit`)})]})]})};function U(e){"@babel/helpers - typeof";return U=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},U(e)}function ze(e,t){if(U(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(U(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Be(e){var t=ze(e,`string`);return U(t)==`symbol`?t:t+``}function W(e,t,n){return(t=Be(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function G(e,t){return function(n,r){t(n,r,e)}}function K(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let q=class extends t.Disposable{constructor(e){super(),this._localeService=e,W(this,`_initLocal`,()=>{}),W(this,`_findReplaceIndex`,e=>{let t=/\{([^}]+)?\}/g,n=[],r=t.exec(e);for(;r;)n.push({startIndex:r.index,key:Number(r[1]),endIndex:r.index+r[0].length-1}),r=t.exec(e);return n}),this._initLocal()}tWithReactNode(e,...t){let n=this._localeService.getLocales(),r=e.split(`.`),i=n&&this._localeService.resolveKeyPath(n,r);if(typeof i==`string`){let e=[];return this._findReplaceIndex(i).forEach((n,r,a)=>{let o=a[r-1]||{startIndex:0,endIndex:-1};if(o.endIndex+1<n.startIndex){let t=i.slice(o.endIndex+1,n.startIndex);t&&e.push(t)}if(t[n.key]&&e.push(t[n.key]),r===a.length-1){let t=i.slice(n.endIndex+1);t&&e.push(t)}}),e}return[]}};q=K([G(0,(0,t.Inject)(t.LocaleService))],q);let Ve=(e,t)=>{let n=e.rule;switch(n.type){case r.CFRuleType.colorScale:return t.t(`sheet.cf.ruleType.colorScale`);case r.CFRuleType.dataBar:return t.t(`sheet.cf.ruleType.dataBar`);case r.CFRuleType.iconSet:return t.t(`sheet.cf.ruleType.iconSet`);case r.CFRuleType.highlightCell:switch(n.subType){case r.CFSubRuleType.average:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,t.t(`sheet.cf.subRuleType.average`))}case r.CFSubRuleType.duplicateValues:return t.t(`sheet.cf.subRuleType.duplicateValues`);case r.CFSubRuleType.uniqueValues:return t.t(`sheet.cf.subRuleType.uniqueValues`);case r.CFSubRuleType.number:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,...Array.isArray(n.value)?n.value.map(e=>String(e)):[String(n.value||``)])}case r.CFSubRuleType.text:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`,n.value||``)}case r.CFSubRuleType.timePeriod:{let e=n.operator;return t.t(`sheet.cf.preview.describe.${e}`)}case r.CFSubRuleType.rank:return n.isPercent?n.isBottom?t.t(`sheet.cf.preview.describe.bottomNPercent`,String(n.value)):t.t(`sheet.cf.preview.describe.topNPercent`,String(n.value)):n.isBottom?t.t(`sheet.cf.preview.describe.bottomN`,String(n.value)):t.t(`sheet.cf.preview.describe.topN`,String(n.value));case r.CFSubRuleType.formula:return t.t(`sheet.cf.ruleType.formula`)}}},He=e=>{let{onClick:c}=e,f=(0,i.useDependency)(r.ConditionalFormattingRuleModel),p=(0,i.useDependency)(t.IUniverInstanceService),m=(0,i.useDependency)(n.SheetsSelectionsService),h=(0,i.useDependency)(t.ICommandService),g=(0,i.useDependency)(t.LocaleService),_=(0,i.useDependency)(t.Injector),v=(0,i.useDependency)(q),y=(0,i.useObservable)(()=>p.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),b=y.getUnitId(),x=y.getActiveSheet();if(!x)throw Error(`No active sheet found`);let S=x.getSheetId(),[C,w]=(0,a.useState)([]),[T,E]=(0,a.useState)(`2`),[D,O]=(0,a.useState)(0),[k,A]=(0,a.useState)(``),j=[{label:g.t(`sheet.cf.panel.workSheet`),value:`2`},{label:g.t(`sheet.cf.panel.selectedRange`),value:`1`}],N=()=>{let e=f.getSubunitRules(b,S);if(!e||!e.length)return[];if(T===`1`){let n=m.getCurrentLastSelection();if(!n)return[];let r=n.range;return e.filter(e=>e.ranges.some(e=>t.Rectangle.intersects(e,r)))}else if(T===`2`)return[...e];return[]},[F,ee]=(0,a.useState)(N);(0,u.useHighlightRange)(C),(0,a.useEffect)(()=>{let e=h.onCommandExecuted(e=>{e.id===n.SetWorksheetActiveOperation.id&&O(Math.random())});return()=>e.dispose()}),(0,a.useEffect)(()=>{ee(N)},[T,D,b,S]),(0,a.useEffect)(()=>{if(T===`2`)return;let e=new d.Observable(e=>{let i=[n.SetSelectionsOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],a=h.onCommandExecuted(n=>{let{id:r,params:a}=n,o=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();i.includes(r)&&a.unitId===o&&e.next(null)});return()=>a.dispose()}).pipe((0,d.debounceTime)(16)).subscribe(()=>{ee(N)});return()=>{e.unsubscribe()}},[p,T,b,S]),(0,a.useEffect)(()=>{let e=f.$ruleChange.subscribe(()=>{O(Math.random())});return()=>e.unsubscribe()},[f]);let te=e=>{var n;let i=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),a=(n=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:n.getSheetId();if(!i||!a)throw Error(`No active sheet found`);h.executeCommand(r.DeleteCfCommand.id,{unitId:i,subUnitId:a,cfId:e.cfId})},ne=(e,t)=>{var n;let r=I[t.y];A((n=r==null?void 0:r.cfId)==null?``:n)},re=(e,n,i)=>{var a,o,s;A(``);let c=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),l=(a=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:a.getSheetId();if(!c||!l)throw Error(`No active sheet found`);let u=e=>{let t=I.length;return Math.min(t-1,Math.max(0,e))},d=(o=I[u(n.y)])==null?void 0:o.cfId,f=(s=I[u(i.y)])==null?void 0:s.cfId;!d||!f||d!==f&&h.executeCommand(r.MoveCfCommand.id,{unitId:c,subUnitId:l,start:{id:d,type:`self`},end:{id:f,type:i.y>n.y?`after`:`before`}})},ae=()=>{e.onCreate()},oe=()=>{T===`2`?h.executeCommand(r.ClearWorksheetCfCommand.id):T===`1`&&F.map(e=>({unitId:b,subUnitId:S,cfId:e.cfId})).forEach(e=>{h.executeCommand(r.DeleteCfCommand.id,e)})},I=(0,a.useMemo)(()=>{let e=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e.getActiveSheet();return F.filter(t=>{let i=t.ranges;return(0,n.checkRangesEditablePermission)(_,e.getUnitId(),r.getSheetId(),i)})},[F]),se=(0,a.useMemo)(()=>{let e=p.getCurrentUnitOfType(t.UniverInstanceType.UNIVER_SHEET),r=e.getActiveSheet();return F.every(t=>{let i=t.ranges;return(0,n.checkRangesEditablePermission)(_,e.getUnitId(),r.getSheetId(),i)})},[F]);return(0,l.jsxs)(`div`,{children:[(0,l.jsxs)(`div`,{className:`
2
2
  univer-mb-2 univer-flex univer-items-center univer-justify-between univer-gap-2 univer-text-sm
3
- `,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:v.tWithReactNode(`sheet.cf.panel.managerRuleSelect`,(0,l.jsx)(o.Select,{className:`univer-w-36`,options:j,value:T,onChange:e=>{E(e)}})).map((e,t)=>(0,l.jsx)(`span`,{children:e},t))}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-space-x-2`,children:[(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.createRule`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:ae,children:(0,l.jsx)(P,{})})}),F.length&&se?(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.clear`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:oe,children:(0,l.jsx)(M,{className:`univer-text-red-500`})})}):(0,l.jsx)(`div`,{children:(0,l.jsx)(M,{className:`univer-text-gray-300`})})]})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(o.DraggableList,{className:`univer-w-full`,draggableHandle:`.draggableHandle`,list:I,onListChange:()=>void 0,idKey:`cfId`,rowHeight:60,margin:[0,10],onDragStop:re,onDragStart:ne,itemRender:e=>(0,l.jsxs)(`div`,{className:(0,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":k===e.cfId}),onMouseMove:()=>{e.ranges!==C&&w(e.ranges)},onMouseLeave:()=>w([]),onClick:()=>{c(e)},children:[(0,l.jsx)(`div`,{className:(0,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:e=>e.stopPropagation(),children:(0,l.jsx)(ie,{})}),(0,l.jsxs)(`div`,{className:`univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:Ve(e,g)}),(0,l.jsx)(`div`,{className:`univer-text-xs univer-text-gray-400`,children:e.ranges.map(e=>(0,s.serializeRange)(e)).join(`,`)})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(R,{rule:e.rule})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(`univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200`,{"univer-flex univer-items-center univer-justify-center":k===e.cfId}),onClick:t=>{t.stopPropagation(),te(e),w([])},children:(0,l.jsx)(M,{})})]})})})]})},Ue=e=>{let[t,n]=(0,a.useState)(e.rule),[r,i]=(0,a.useState)(!!e.rule);return(0,l.jsx)(`div`,{className:`univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4`,children:r?(0,l.jsx)(Re,{onCancel:()=>{i(!1),n(void 0)},rule:t}):(0,l.jsx)(He,{onClick:e=>{n(e),i(!0)},onCreate:()=>{i(!0)}})})},We=`sheet.conditional.formatting.panel`,J=class extends t.Disposable{constructor(e,n,r,i,a){super(),this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=i,this._localeService=a,W(this,`_sidebarDisposable`,null),this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var t;e||(t=this._sidebarDisposable)==null||t.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===We&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){let n={id:We,header:{title:this._localeService.t(`sheet.cf.title`)},children:{label:We,rule:e,key:(0,t.generateRandomId)(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(We,Ue))}};J=K([G(0,t.IUniverInstanceService),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(i.ComponentManager)),G(3,(0,t.Inject)(i.ISidebarService)),G(4,(0,t.Inject)(t.LocaleService))],J);let Y=function(e){return e[e.createRule=1]=`createRule`,e[e.viewRule=2]=`viewRule`,e[e.highlightCell=3]=`highlightCell`,e[e.rank=4]=`rank`,e[e.formula=5]=`formula`,e[e.colorScale=6]=`colorScale`,e[e.dataBar=7]=`dataBar`,e[e.icon=8]=`icon`,e[e.clearRangeRules=9]=`clearRangeRules`,e[e.clearWorkSheetRules=10]=`clearWorkSheetRules`,e}({}),X={id:`sheet.operation.open.conditional.formatting.panel`,type:t.CommandType.OPERATION,handler:(e,i)=>{var a;let o=e.get(J),s=e.get(n.SheetsSelectionsService),c=e.get(t.ICommandService),l=((a=s.getCurrentSelections())==null?void 0:a.map(e=>e.range))||[];switch(i.value){case Y.highlightCell:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case Y.rank:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};o.openPanel(e);break}case Y.formula:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:`=`}};o.openPanel(e);break}case Y.colorScale:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.colorScale,config:[]}};o.openPanel(e);break}case Y.dataBar:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};o.openPanel(e);break}case Y.icon:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};o.openPanel(e);break}case Y.viewRule:o.openPanel();break;case Y.createRule:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case Y.clearRangeRules:c.executeCommand(r.ClearRangeCfCommand.id,{ranges:l});break;case Y.clearWorkSheetRules:c.executeCommand(r.ClearWorksheetCfCommand.id);break}return!0}},Ge=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=r,this._conditionalFormattingRuleModel=i,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{let r=[],i=[],a={redos:r,undos:i};if([n.ClearSelectionFormatCommand.id,n.ClearSelectionAllCommand.id].includes(e.id)){var o;let e=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(e=>e.range);if(!e)return a;let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),s=n.getActiveSheet();if(!s)return a;let c=n.getUnitId(),l=s.getSheetId(),u=this._conditionalFormattingRuleModel.getSubunitRules(c,l);if(!u||!u.length)return a;let{redos:d,undos:f}=Ke(this._injector,u,e,c,l);r.push(...d),i.push(...f)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{let r=[],i=[],a={redos:r,undos:i};if(!n||!n.length)return a;let o=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!o||!o.length)return a;let{redos:s,undos:c}=Ke(this._injector,o,n,e,t);return r.push(...s),i.push(...c),a}}))}};Ge=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(n.SheetInterceptorService)),G(3,(0,t.Inject)(n.SheetsSelectionsService)),G(4,(0,t.Inject)(r.ConditionalFormattingRuleModel))],Ge);function Ke(e,i,a,o,s){let c=[],l=[];return i.filter(e=>a.some(n=>e.ranges.some(e=>t.Rectangle.getIntersects(e,n)))).forEach(t=>{let i=new n.RangeMergeUtil().add(...t.ranges).subtract(...a).merge();if(i.length){let n={id:r.SetConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,rule:{...t,ranges:i}}},a=(0,r.setConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...a)}else{let n={id:r.DeleteConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,cfId:t.cfId}},i=(0,r.DeleteConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...i)}}),{redos:c,undos:l}}var qe=`@univerjs/sheets-conditional-formatting-ui`,Je=`0.21.0`;let Ye=`sheets-conditional-formatting-ui.config`;Symbol(Ye);let Xe={},Z=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,W(this,`_disposableMap`,new Map),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){let 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:{let e=n;e.config.min.type===r.CFValueType.formula&&t.push(e.config.min.value),e.config.max.type===r.CFValueType.formula&&t.push(e.config.max.value);break}case r.CFRuleType.colorScale:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break;case r.CFRuleType.iconSet:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break}return t}_updateRuleFormulas(e,n){let i=t.Tools.deepClone(e),a=i.rule,o=0;switch(a.type){case r.CFRuleType.highlightCell:a.subType===r.CFSubRuleType.formula&&(a.value=n[o++]);break;case r.CFRuleType.dataBar:{let e=a;e.config.min.type===r.CFValueType.formula&&(e.config.min.value=n[o++]),e.config.max.type===r.CFValueType.formula&&(e.config.max.value=n[o++]);break}case r.CFRuleType.colorScale:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break;case r.CFRuleType.iconSet:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break}return i}register(e,t,n){let i=n.ranges,a=this._getRuleFormulas(n),o=this._formulaRefRangeService.registerRangeFormula(e,t,i,a,i=>{if(i.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}}]};let a=[],o=[],s=i[0],c=this._updateRuleFormulas(n,s.formulas);c.ranges=s.ranges,a.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}}),o.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}));for(let s=1;s<i.length;s++){let c=i[s],l=(0,r.createCfId)(),u=this._updateRuleFormulas(n,c.formulas);u.cfId=l,u.ranges=c.ranges,a.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:u}}),o.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,rule:u}))}return{undos:o,redos:a}}),s=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(s,o)}_initRefRange(){let e=this._conditionalFormattingRuleModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this.register(t,e,n);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r}=e;switch(e.type){case`add`:this.register(t,n,r);break;case`delete`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e));break}case`set`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e)),this.register(t,n,r);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};Z=K([G(0,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(1,(0,t.Inject)(f.FormulaRefRangeService)),G(2,(0,t.Inject)(t.Injector))],Z);let Ze=[u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,u.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER],Qe=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=r,this._univerInstanceService=i,W(this,`_copyInfo`,void 0),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,r)=>!e||!this._copyInfo||!Ze.includes(r.pasteType)?{redos:[],undos:[]}:this._generateConditionalFormattingMutations(e,t,r)}))}_collectConditionalRule(e,r,i){let a=new t.ObjectMatrix,o={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:r,cfMap:o}};let s=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!s)return;let{rows:c,cols:l}=s,u=new Set;c.forEach((t,n)=>{l.forEach((i,o)=>{let s=this._conditionalFormattingViewModel.getCellCfs(e,r,t,i);s&&(s.forEach(e=>u.add(e.cfId)),a.setValue(n,o,s.map(e=>e.cfId)))})}),u.forEach(t=>{let n=this._conditionalFormattingRuleModel.getRule(e,r,t);n&&(o[t]=n.rule)})}_generateConditionalFormattingMutations(e,i,a){let{unitId:o,subUnitId:s,range:c}=e,{unitId:l,subUnitId:d,range:f}=i,{copyType:p=u.COPY_TYPE.COPY}=a;if(!(0,n.getSheetCommandTarget)(this._univerInstanceService,{unitId:l,subUnitId:d}))return{redos:[],undos:[]};if(p===u.COPY_TYPE.CUT&&l===o&&d===s)return this._copyInfo=null,{redos:[],undos:[]};let{ranges:[m,h],mapFunc:g}=(0,u.virtualizeDiscreteRanges)([c,f]),_=(0,u.getRepeatRange)(m,h,!0),v={};t.Range.foreach(h,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(l,d,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:l,subUnitId:d,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(l,d,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})}),p===u.COPY_TYPE.CUT&&(l!==o||d!==s)&&t.Range.foreach(m,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(o,s,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:o,subUnitId:s,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(o,s,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})});let{matrix:y,info:b}=this._copyInfo,x=[],S={},C=e=>{let n=b==null?void 0:b.cfMap[e],r=[...this._conditionalFormattingRuleModel.getSubunitRules(l,d)||[],...x].find(e=>t.Tools.diffValue(e.rule,n));if(r)return S[e]=r,r;{let t={rule:n,cfId:this._conditionalFormattingRuleModel.createCfId(l,d),ranges:[],stopIfTrue:!1};return S[e]=t,x.push(t),t}};_.forEach(e=>{y&&y.forValue((n,r,i)=>{let a=t.Rectangle.getPositionRange({startRow:n,endRow:n,startColumn:r,endColumn:r},e.startRange),{row:o,col:s}=g(a.startRow,a.startColumn);i.forEach(e=>{let n=S[e]||C(e);if(!v[n.cfId]){let e=new t.ObjectMatrix;v[n.cfId]={unitId:l,subUnitId:d,ruleMatrix:e},n.ranges.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})})}v[n.cfId].ruleMatrix.setValue(o,s,1)})})});let w=[],T=[];for(let e in v){let{unitId:t,subUnitId:i,ruleMatrix:a}=v[e],o=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(a));if(!o.length){let n={unitId:t,subUnitId:i,cfId:e};w.push({id:r.DeleteConditionalRuleMutation.id,params:n}),T.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,n))}if(x.some(t=>t.cfId===e)){let t={unitId:l,subUnitId:d,rule:{...x.find(t=>t.cfId===e),ranges:o}};w.push({id:r.AddConditionalRuleMutation.id,params:t}),T.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,t))}else{let n=this._conditionalFormattingRuleModel.getRule(t,i,e);if(!n)continue;let a={unitId:t,subUnitId:i,rule:{...n,ranges:o}};w.push({id:r.SetConditionalRuleMutation.id,params:a}),T.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,a))}}return{redos:w,undos:T}}};Qe=K([G(0,(0,t.Inject)(u.ISheetClipboardService)),G(1,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(2,(0,t.Inject)(t.Injector)),G(3,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(4,(0,t.Inject)(t.IUniverInstanceService))],Qe);let $e=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===r.AddCfCommand.id){let{unitId:t,subUnitId:r,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellStylePermission]},i,t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};$e=K([G(0,(0,t.Inject)(t.LocaleService)),G(1,t.ICommandService),G(2,(0,t.Inject)(n.SheetPermissionCheckController))],$e);let et=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=r,this._conditionalFormattingViewModel=i,this._conditionalFormattingRuleModel=a,W(this,`_ruleChangeCacheMap`,new Map),this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var e,n;let r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();(e=this._renderManagerService.getRenderById(r))==null||e.with(u.SheetSkeletonManagerService).reCalculate(),(n=this._renderManagerService.getRenderById(r))==null||(n=n.mainComponent)==null||n.makeDirty()}_initSkeleton(){this.disposeWithMe((0,d.merge)(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe((0,m.bufferTime)(16),(0,m.filter)(e=>!!e.length),(0,m.filter)(e=>{let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;let r=n.getActiveSheet();return r?e.filter(e=>e.unitId===n.getUnitId()&&e.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!i)return n(e);let a=t.workbook.getStyles(),o=(typeof(e==null?void 0:e.s)==`string`?a.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},s=e===t.rawData?{...t.rawData}:e;if(i.style){let e={...o,...i.style};Object.assign(s,{s:e})}return s.fontRenderExtension||(s.fontRenderExtension={},i.isShowValue!==void 0&&(s.fontRenderExtension.isSkip=!i.isShowValue)),i.dataBar&&(s.dataBar=i.dataBar),i.iconSet&&(s.iconSet=i.iconSet,s.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(s)},priority:10}))}};et=K([G(0,(0,t.Inject)(n.SheetInterceptorService)),G(1,(0,t.Inject)(r.ConditionalFormattingService)),G(2,(0,t.Inject)(t.IUniverInstanceService)),G(3,(0,t.Inject)(p.IRenderManagerService)),G(4,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(5,(0,t.Inject)(r.ConditionalFormattingRuleModel))],et);let Q=class extends t.Plugin{constructor(e=Xe,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Xe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(Ye,o),this._initCommand(),this._injector.add([et]),this._injector.add([Qe]),this._injector.add([$e]),this._injector.add([q]),this._injector.add([Z])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};W(Q,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),W(Q,`packageName`,qe),W(Q,`version`,Je),W(Q,`type`,t.UniverInstanceType.UNIVER_SHEET),Q=K([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(t.ICommandService)),G(3,t.IConfigService)],Q);let tt=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=i,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{var o;let s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(o=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId();if(!s||!c)return;let l={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},u={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},l),o=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),{row:d,col:f}=a(r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(s,c,d,f),{row:m,col:h}=a(o.startRow,o.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(s,c,m,h);g&&g.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(m,h)}),p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.setValue(m,h,1)})})},a=(a,o)=>{var s,c;let l=(s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),d=(c=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(c=c.getActiveSheet())==null?void 0:c.getSheetId(),f=new Map,p=[],m=[];if(!l||!d)return e();let h=(0,u.virtualizeDiscreteRanges)([a,o]),[g,_]=h.ranges,{mapFunc:v}=h,y={row:g.startRow,col:g.startColumn};return n.AutoFillTools.getAutoFillRepeatRange(g,_).forEach(e=>{i(y,e.repeatStartCell,e.relativeRange,f,v)}),f.forEach((e,t)=>{let i=this._conditionalFormattingRuleModel.getRule(l,d,t);if(!i)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:l,subUnitId:d,rule:{...i,ranges:a}};p.push({id:r.SetConditionalRuleMutation.id,params:e}),m.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:l,subUnitId:d,cfId:i.cfId};p.push({id:r.DeleteConditionalRuleMutation.id,params:e}),m.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}),{undos:m,redos:p}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(t,r,i)=>{if(i===n.AUTO_FILL_APPLY_TYPE.COPY||i===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===n.AUTO_FILL_APPLY_TYPE.SERIES){let{source:e,target:n}=t;return a(e,n)}return e()}};this.disposeWithMe(this._autoFillService.addHook(o))}};tt=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(n.IAutoFillService)),G(3,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(4,(0,t.Inject)(r.ConditionalFormattingViewModel))],tt);let nt=class extends t.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe((0,t.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(n.AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r;e||n(e);let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col),a=(r=i==null?void 0:i.style)==null?{}:r,o=Object.keys(a);if(e!=null&&e.p){var s;return(s=e.p.body)==null||(s=s.textRuns)==null||s.forEach(e=>{e.ts&&o.forEach(t=>{var n;(n=e.ts)==null||delete n[t]})}),n(e)}else{let r={...(typeof(e==null?void 0:e.s)==`string`?t.workbook.getStyles().get(e.s):e==null?void 0:e.s)||{}};return o.forEach(e=>{delete r[e]}),n({...e,s:{...r}})}}})))}};nt=K([G(0,(0,t.Inject)(n.SheetInterceptorService)),G(1,(0,t.Inject)(r.ConditionalFormattingService))],nt);let rt=(e,t)=>{let n=e=>e.endRow-e.startRow+1,r=e=>e.endColumn-e.startColumn+1,i=n(t)%n(e),a=r(t)%r(e),o=Math.floor(n(t)/n(e)),s=Math.floor(r(t)/r(e)),c=[],l={startRow:0,endRow:n(e)-1,startColumn:0,endColumn:r(e)-1};if(n(t)===1&&r(t)===1){let e={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};return c.push({repeatRelativeRange:l,startRange:e}),c}for(let u=0;u<o+(i?.1:0);u++)for(let d=0;d<s+(a?.1:0);d++){let f=n(e)*u,p=r(e)*d,m={startRow:f+t.startRow,endRow:f+t.startRow,startColumn:p+t.startColumn,endColumn:p+t.startColumn},h=l;u===o&&i&&(h={...h},h.endRow-=n(e)-i),d===s&&a&&(h={...h},h.endColumn-=r(e)-a),c.push({repeatRelativeRange:h,startRange:m})}return c},it=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=r,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=a,W(this,`_painterConfig`,null),this._initFormattingPainter()}_initFormattingPainter(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{let{unitId:o,subUnitId:s}=this._painterConfig,{targetUnitId:c,targetSubUnitId:l}=a,u={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},d={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),a=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},d),f=this._conditionalFormattingViewModel.getCellCfs(o,s,r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(c,l,a.startRow,a.startColumn);p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(c,l,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(a.startRow,a.startColumn)}),f&&f.forEach(e=>{let t=i.get(e.cfId);t&&t.setValue(a.startRow,a.startColumn,1)})})},a=(a,o,s)=>{var c;let{range:l,unitId:u,subUnitId:d}=this._painterConfig,f=a!==u||d!==o,p=new Map,m=[],h=[];if(!a||!o||!u||!d)return e();let g=(c=this._conditionalFormattingRuleModel.getSubunitRules(u,d))==null?[]:c;g==null||g.forEach(e=>{let{ranges:n,cfId:r}=e;if(n.some(e=>t.Rectangle.intersects(l,e))){let e=new t.ObjectMatrix;f||n.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})}),p.set(r,e)}});let _={row:l.startRow,col:l.startColumn};return rt(l,s).forEach(e=>{i(_,{row:e.startRange.startRow,col:e.startRange.startColumn},e.repeatRelativeRange,p,{targetUnitId:a,targetSubUnitId:o})}),p.forEach((e,i)=>{if(f){let s=this._conditionalFormattingRuleModel.getRule(a,o,i),c=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(!s){if(c.length){let e=this._conditionalFormattingRuleModel.getRule(u,d,i);if(e){let n={unitId:a,subUnitId:o,rule:{...t.Tools.deepClone(e),cfId:this._conditionalFormattingRuleModel.createCfId(a,o),ranges:c}};m.push({id:r.AddConditionalRuleMutation.id,params:n}),h.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,n))}}}else if(c.length){let e={unitId:a,subUnitId:o,rule:{...s,ranges:c}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:a,subUnitId:o,cfId:s.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}else{let t=this._conditionalFormattingRuleModel.getRule(u,d,i);if(!t)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:u,subUnitId:d,rule:{...t,ranges:a}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:u,subUnitId:d,cfId:t.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}}),{undos:h,redos:m}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:e=>{switch(e){case u.FormatPainterStatus.INFINITE:case u.FormatPainterStatus.ONCE:{var n,r;let e=(n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getUnitId(),i=(r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(r=r.getActiveSheet())==null?void 0:r.getSheetId(),a=this._sheetsSelectionsService.getCurrentLastSelection(),o=a==null?void 0:a.range;e&&i&&o&&(this._painterConfig={unitId:e,subUnitId:i,range:o});break}case u.FormatPainterStatus.OFF:this._painterConfig=null;break}},onApply:(e,t,n)=>this._painterConfig?a(e,t,n):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};it=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(u.IFormatPainterService)),G(3,(0,t.Inject)(n.SheetsSelectionsService)),G(4,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(5,(0,t.Inject)(r.ConditionalFormattingViewModel))],it);let at=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingViewModel=e,this._univerInstanceService=t,this._renderManagerService=n,this._init()}_init(){let e=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),n=e=>{let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);if(!n)return;let i=n.with(u.SheetSkeletonManagerService);this.disposeWithMe(i.currentSkeleton$.subscribe(e=>{if(e){let t=e.skeleton.rowColumnSegment,n=t.endColumn-t.startColumn+1,i=(t.endRow-t.startRow+1)*n*9,a=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,i);this._conditionalFormattingViewModel.setCacheLength(a)}}))};e&&n(e),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&n(e)})}};at=K([G(0,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(1,t.IUniverInstanceService),G(2,p.IRenderManagerService)],at);let ot=[n.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],st=[{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}],ct=e=>{let a=e.get(n.SheetsSelectionsService),o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.ConditionalFormattingRuleModel),l=new d.Observable(r=>(0,d.merge)(a.selectionMoveEnd$,a.selectionSet$,new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();ot.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()})).pipe((0,m.debounceTime)(16)).subscribe(()=>{var i;let o=((i=a.getCurrentSelections())==null?void 0:i.map(e=>e.range))||[],l=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!l)return;let u=l.getActiveSheet();if(!u)return;let d=(c.getSubunitRules(l.getUnitId(),u.getSheetId())||[]).filter(e=>e.ranges.some(e=>o.some(n=>t.Rectangle.intersects(n,e)))).map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,l.getUnitId(),u.getSheetId(),t));r.next(d)})),f=new d.Observable(r=>new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();ot.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()}).pipe((0,m.debounceTime)(16)).subscribe(()=>{let i=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return;let a=i.getActiveSheet();if(!a)return;let o=c.getSubunitRules(i.getUnitId(),a.getSheetId())||[];if(!o.length)return r.next(!1),!1;let l=o.map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,i.getUnitId(),a.getSheetId(),t));r.next(l)})),p=new d.Observable(e=>{l.subscribe(t=>{let n=st.find(e=>e.value===Y.clearRangeRules);n&&(n.disabled=!t,e.next(st))}),f.subscribe(t=>{let n=st.find(e=>e.value===Y.clearWorkSheetRules);n&&(n.disabled=!t,e.next(st))}),e.next(st)});return{id:X.id,type:i.MenuItemType.SELECTOR,icon:`ConditionsDoubleIcon`,tooltip:`sheet.cf.title`,selections:p,hidden$:(0,i.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,u.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetSetCellStylePermission,n.WorksheetEditPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]})}},lt={[i.RibbonDataGroup.RULES]:{[X.id]:{order:1,menuItemFactory:ct}}},ut=class extends t.Disposable{constructor(e,t){super(),this._injector=e,this._menuManagerService=t,W(this,`_sidebarDisposable`,null),this._menuManagerService.mergeMenu(lt)}};ut=K([G(0,(0,t.Inject)(t.Injector)),G(1,i.IMenuManagerService)],ut);let $=class extends t.Plugin{constructor(e=Xe,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Xe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(Ye,o),this._initCommand()}onStarting(){(0,t.registerDependencies)(this._injector,[[et],[Qe],[tt],[$e],[J],[ut],[q],[nt],[Ge],[it],[at],[Z]]),(0,t.touchDependencies)(this._injector,[[et],[Z]])}onReady(){(0,t.touchDependencies)(this._injector,[[ut],[J]])}onRendered(){(0,t.touchDependencies)(this._injector,[[tt],[Ge],[Qe],[nt],[q],[it],[$e],[at]])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};W($,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),W($,`packageName`,qe),W($,`version`,Je),W($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=K([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin,f.UniverSheetsFormulaPlugin),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(t.ICommandService)),G(3,t.IConfigService)],$),e.AddAverageCfCommand=h,e.AddColorScaleConditionalRuleCommand=g,e.AddDataBarConditionalRuleCommand=_,e.AddDuplicateValuesCfCommand=v,e.AddNumberCfCommand=y,e.AddRankCfCommand=b,e.AddTextCfCommand=x,e.AddTimePeriodCfCommand=S,e.AddUniqueValuesCfCommand=C,Object.defineProperty(e,`ConditionalFormattingClearController`,{enumerable:!0,get:function(){return Ge}}),e.OpenConditionalFormattingOperator=X,Object.defineProperty(e,`UniverSheetsConditionalFormattingMobileUIPlugin`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`UniverSheetsConditionalFormattingUIPlugin`,{enumerable:!0,get:function(){return $}})});
3
+ `,children:[(0,l.jsx)(`div`,{className:`univer-flex univer-items-center univer-gap-2`,children:v.tWithReactNode(`sheet.cf.panel.managerRuleSelect`,(0,l.jsx)(o.Select,{className:`univer-w-36`,options:j,value:T,onChange:e=>{E(e)}})).map((e,t)=>(0,l.jsx)(`span`,{children:e},t))}),(0,l.jsxs)(`div`,{className:`univer-flex univer-justify-end univer-space-x-2`,children:[(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.createRule`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:ae,children:(0,l.jsx)(P,{})})}),F.length&&se?(0,l.jsx)(o.Tooltip,{title:g.t(`sheet.cf.panel.clear`),placement:`bottom`,children:(0,l.jsx)(`a`,{className:`univer-size-5 univer-cursor-pointer`,onClick:oe,children:(0,l.jsx)(M,{className:`univer-text-red-500`})})}):(0,l.jsx)(`div`,{children:(0,l.jsx)(M,{className:`univer-text-gray-300`})})]})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(o.DraggableList,{className:`univer-w-full`,draggableHandle:`.draggableHandle`,list:I,onListChange:()=>void 0,idKey:`cfId`,rowHeight:60,margin:[0,10],onDragStop:re,onDragStart:ne,itemRender:e=>(0,l.jsxs)(`div`,{className:(0,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":k===e.cfId}),onMouseMove:()=>{e.ranges!==C&&w(e.ranges)},onMouseLeave:()=>w([]),onClick:()=>{c(e)},children:[(0,l.jsx)(`div`,{className:(0,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:e=>e.stopPropagation(),children:(0,l.jsx)(ie,{})}),(0,l.jsxs)(`div`,{className:`univer-min-w-0 univer-max-w-full univer-flex-shrink univer-overflow-hidden`,children:[(0,l.jsx)(`div`,{className:`univer-text-sm univer-text-gray-900 dark:!univer-text-white`,children:Ve(e,g)}),(0,l.jsx)(`div`,{className:`
4
+ univer-max-w-[250px] univer-overflow-hidden univer-text-ellipsis univer-text-xs
5
+ univer-text-gray-400
6
+ `,children:e.ranges.map(e=>(0,s.serializeRange)(e)).join(`,`)})]}),(0,l.jsx)(`div`,{children:(0,l.jsx)(R,{rule:e.rule})}),(0,l.jsx)(`div`,{className:(0,o.clsx)(`univer-absolute univer-right-1 univer-hidden univer-size-6 univer-cursor-pointer univer-items-center univer-justify-center univer-rounded univer-text-red-500 group-hover:univer-flex hover:univer-bg-gray-200`,{"univer-flex univer-items-center univer-justify-center":k===e.cfId}),onClick:t=>{t.stopPropagation(),te(e),w([])},children:(0,l.jsx)(M,{})})]})})})]})},Ue=e=>{let[t,n]=(0,a.useState)(e.rule),[r,i]=(0,a.useState)(!!e.rule);return(0,l.jsx)(`div`,{className:`univer-flex univer-h-full univer-flex-col univer-justify-between univer-py-4`,children:r?(0,l.jsx)(Re,{onCancel:()=>{i(!1),n(void 0)},rule:t}):(0,l.jsx)(He,{onClick:e=>{n(e),i(!0)},onCreate:()=>{i(!0)}})})},We=`sheet.conditional.formatting.panel`,J=class extends t.Disposable{constructor(e,n,r,i,a){super(),this._univerInstanceService=e,this._injector=n,this._componentManager=r,this._sidebarService=i,this._localeService=a,W(this,`_sidebarDisposable`,null),this._initPanel(),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{var t;e||(t=this._sidebarDisposable)==null||t.dispose()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===We&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}openPanel(e){let n={id:We,header:{title:this._localeService.t(`sheet.cf.title`)},children:{label:We,rule:e,key:(0,t.generateRandomId)(4)},onClose:()=>this._sidebarDisposable=null};this._sidebarDisposable=this._sidebarService.open(n)}_initPanel(){this.disposeWithMe(this._componentManager.register(We,Ue))}};J=K([G(0,t.IUniverInstanceService),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(i.ComponentManager)),G(3,(0,t.Inject)(i.ISidebarService)),G(4,(0,t.Inject)(t.LocaleService))],J);let Y=function(e){return e[e.createRule=1]=`createRule`,e[e.viewRule=2]=`viewRule`,e[e.highlightCell=3]=`highlightCell`,e[e.rank=4]=`rank`,e[e.formula=5]=`formula`,e[e.colorScale=6]=`colorScale`,e[e.dataBar=7]=`dataBar`,e[e.icon=8]=`icon`,e[e.clearRangeRules=9]=`clearRangeRules`,e[e.clearWorkSheetRules=10]=`clearWorkSheetRules`,e}({}),X={id:`sheet.operation.open.conditional.formatting.panel`,type:t.CommandType.OPERATION,handler:(e,i)=>{var a;let o=e.get(J),s=e.get(n.SheetsSelectionsService),c=e.get(t.ICommandService),l=((a=s.getCurrentSelections())==null?void 0:a.map(e=>e.range))||[];switch(i.value){case Y.highlightCell:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case Y.rank:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.rank}};o.openPanel(e);break}case Y.formula:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.highlightCell,subType:r.CFSubRuleType.formula,value:`=`}};o.openPanel(e);break}case Y.colorScale:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.colorScale,config:[]}};o.openPanel(e);break}case Y.dataBar:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.dataBar,isShowValue:!0}};o.openPanel(e);break}case Y.icon:{let e={...r.createDefaultRule,ranges:l,rule:{type:r.CFRuleType.iconSet,config:[],isShowValue:!0}};o.openPanel(e);break}case Y.viewRule:o.openPanel();break;case Y.createRule:o.openPanel({...(0,r.createDefaultRule)(),ranges:l});break;case Y.clearRangeRules:c.executeCommand(r.ClearRangeCfCommand.id,{ranges:l});break;case Y.clearWorkSheetRules:c.executeCommand(r.ClearWorksheetCfCommand.id);break}return!0}},Ge=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._sheetInterceptorService=n,this._selectionManagerService=r,this._conditionalFormattingRuleModel=i,this._init()}_init(){this.disposeWithMe(this._sheetInterceptorService.interceptCommand({getMutations:e=>{let r=[],i=[],a={redos:r,undos:i};if([n.ClearSelectionFormatCommand.id,n.ClearSelectionAllCommand.id].includes(e.id)){var o;let e=(o=this._selectionManagerService.getCurrentSelections())==null?void 0:o.map(e=>e.range);if(!e)return a;let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),s=n.getActiveSheet();if(!s)return a;let c=n.getUnitId(),l=s.getSheetId(),u=this._conditionalFormattingRuleModel.getSubunitRules(c,l);if(!u||!u.length)return a;let{redos:d,undos:f}=Ke(this._injector,u,e,c,l);r.push(...d),i.push(...f)}return a}})),this.disposeWithMe(this._sheetInterceptorService.interceptRanges({getMutations:({unitId:e,subUnitId:t,ranges:n})=>{let r=[],i=[],a={redos:r,undos:i};if(!n||!n.length)return a;let o=this._conditionalFormattingRuleModel.getSubunitRules(e,t);if(!o||!o.length)return a;let{redos:s,undos:c}=Ke(this._injector,o,n,e,t);return r.push(...s),i.push(...c),a}}))}};Ge=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(n.SheetInterceptorService)),G(3,(0,t.Inject)(n.SheetsSelectionsService)),G(4,(0,t.Inject)(r.ConditionalFormattingRuleModel))],Ge);function Ke(e,i,a,o,s){let c=[],l=[];return i.filter(e=>a.some(n=>e.ranges.some(e=>t.Rectangle.getIntersects(e,n)))).forEach(t=>{let i=new n.RangeMergeUtil().add(...t.ranges).subtract(...a).merge();if(i.length){let n={id:r.SetConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,rule:{...t,ranges:i}}},a=(0,r.setConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...a)}else{let n={id:r.DeleteConditionalRuleMutation.id,params:{unitId:o,subUnitId:s,cfId:t.cfId}},i=(0,r.DeleteConditionalRuleMutationUndoFactory)(e,n.params);c.push(n),l.push(...i)}}),{redos:c,undos:l}}var qe=`@univerjs/sheets-conditional-formatting-ui`,Je=`0.21.1-insiders.20260429-a0b1161`;let Ye=`sheets-conditional-formatting-ui.config`;Symbol(Ye);let Xe={},Z=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingRuleModel=e,this._formulaRefRangeService=t,this._injector=n,W(this,`_disposableMap`,new Map),this._initRefRange()}_getIdWithUnitId(e,t,n){return`${e}_${t}_${n}`}_getRuleFormulas(e){let 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:{let e=n;e.config.min.type===r.CFValueType.formula&&t.push(e.config.min.value),e.config.max.type===r.CFValueType.formula&&t.push(e.config.max.value);break}case r.CFRuleType.colorScale:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break;case r.CFRuleType.iconSet:n.config.forEach(e=>{e.value.type===r.CFValueType.formula&&t.push(e.value.value)});break}return t}_updateRuleFormulas(e,n){let i=t.Tools.deepClone(e),a=i.rule,o=0;switch(a.type){case r.CFRuleType.highlightCell:a.subType===r.CFSubRuleType.formula&&(a.value=n[o++]);break;case r.CFRuleType.dataBar:{let e=a;e.config.min.type===r.CFValueType.formula&&(e.config.min.value=n[o++]),e.config.max.type===r.CFValueType.formula&&(e.config.max.value=n[o++]);break}case r.CFRuleType.colorScale:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break;case r.CFRuleType.iconSet:a.config.forEach(e=>{e.value.type===r.CFValueType.formula&&(e.value.value=n[o++])});break}return i}register(e,t,n){let i=n.ranges,a=this._getRuleFormulas(n),o=this._formulaRefRangeService.registerRangeFormula(e,t,i,a,i=>{if(i.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}}]};let a=[],o=[],s=i[0],c=this._updateRuleFormulas(n,s.formulas);c.ranges=s.ranges,a.push({id:r.SetConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}}),o.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,cfId:n.cfId,rule:c}));for(let s=1;s<i.length;s++){let c=i[s],l=(0,r.createCfId)(),u=this._updateRuleFormulas(n,c.formulas);u.cfId=l,u.ranges=c.ranges,a.push({id:r.AddConditionalRuleMutation.id,params:{unitId:e,subUnitId:t,rule:u}}),o.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,{unitId:e,subUnitId:t,rule:u}))}return{undos:o,redos:a}}),s=this._getIdWithUnitId(e,t,n.cfId);this._disposableMap.set(s,o)}_initRefRange(){let e=this._conditionalFormattingRuleModel.getAll();for(let[t,n]of e)for(let[e,r]of n)for(let n of r)this.register(t,e,n);this.disposeWithMe(this._conditionalFormattingRuleModel.$ruleChange.subscribe(e=>{let{unitId:t,subUnitId:n,rule:r}=e;switch(e.type){case`add`:this.register(t,n,r);break;case`delete`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e));break}case`set`:{let e=this._getIdWithUnitId(t,n,r.cfId),i=this._disposableMap.get(e);i&&(i.dispose(),this._disposableMap.delete(e)),this.register(t,n,r);break}}})),this.disposeWithMe((0,t.toDisposable)(()=>{this._disposableMap.forEach(e=>{e.dispose()}),this._disposableMap.clear()}))}};Z=K([G(0,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(1,(0,t.Inject)(f.FormulaRefRangeService)),G(2,(0,t.Inject)(t.Injector))],Z);let Ze=[u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,u.PREDEFINED_HOOK_NAME_PASTE.DEFAULT_PASTE,u.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_BESIDES_BORDER],Qe=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._sheetClipboardService=e,this._conditionalFormattingRuleModel=t,this._injector=n,this._conditionalFormattingViewModel=r,this._univerInstanceService=i,W(this,`_copyInfo`,void 0),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,r)=>!e||!this._copyInfo||!Ze.includes(r.pasteType)?{redos:[],undos:[]}:this._generateConditionalFormattingMutations(e,t,r)}))}_collectConditionalRule(e,r,i){let a=new t.ObjectMatrix,o={};this._copyInfo={matrix:a,info:{unitId:e,subUnitId:r,cfMap:o}};let s=this._injector.invoke(t=>(0,n.rangeToDiscreteRange)(i,t,e,r));if(!s)return;let{rows:c,cols:l}=s,u=new Set;c.forEach((t,n)=>{l.forEach((i,o)=>{let s=this._conditionalFormattingViewModel.getCellCfs(e,r,t,i);s&&(s.forEach(e=>u.add(e.cfId)),a.setValue(n,o,s.map(e=>e.cfId)))})}),u.forEach(t=>{let n=this._conditionalFormattingRuleModel.getRule(e,r,t);n&&(o[t]=n.rule)})}_generateConditionalFormattingMutations(e,i,a){let{unitId:o,subUnitId:s,range:c}=e,{unitId:l,subUnitId:d,range:f}=i,{copyType:p=u.COPY_TYPE.COPY}=a;if(!(0,n.getSheetCommandTarget)(this._univerInstanceService,{unitId:l,subUnitId:d}))return{redos:[],undos:[]};if(p===u.COPY_TYPE.CUT&&l===o&&d===s)return this._copyInfo=null,{redos:[],undos:[]};let{ranges:[m,h],mapFunc:g}=(0,u.virtualizeDiscreteRanges)([c,f]),_=(0,u.getRepeatRange)(m,h,!0),v={};t.Range.foreach(h,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(l,d,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:l,subUnitId:d,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(l,d,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})}),p===u.COPY_TYPE.CUT&&(l!==o||d!==s)&&t.Range.foreach(m,(e,n)=>{let{row:r,col:i}=g(e,n),a=this._conditionalFormattingViewModel.getCellCfs(o,s,r,i);a&&a.forEach(e=>{if(!v[e.cfId]){let n=new t.ObjectMatrix;v[e.cfId]={unitId:o,subUnitId:s,ruleMatrix:n};let r=this._conditionalFormattingRuleModel.getRule(o,s,e.cfId);r==null||r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})})}v[e.cfId].ruleMatrix.realDeleteValue(r,i)})});let{matrix:y,info:b}=this._copyInfo,x=[],S={},C=e=>{let n=b==null?void 0:b.cfMap[e],r=[...this._conditionalFormattingRuleModel.getSubunitRules(l,d)||[],...x].find(e=>t.Tools.diffValue(e.rule,n));if(r)return S[e]=r,r;{let t={rule:n,cfId:this._conditionalFormattingRuleModel.createCfId(l,d),ranges:[],stopIfTrue:!1};return S[e]=t,x.push(t),t}};_.forEach(e=>{y&&y.forValue((n,r,i)=>{let a=t.Rectangle.getPositionRange({startRow:n,endRow:n,startColumn:r,endColumn:r},e.startRange),{row:o,col:s}=g(a.startRow,a.startColumn);i.forEach(e=>{let n=S[e]||C(e);if(!v[n.cfId]){let e=new t.ObjectMatrix;v[n.cfId]={unitId:l,subUnitId:d,ruleMatrix:e},n.ranges.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})})}v[n.cfId].ruleMatrix.setValue(o,s,1)})})});let w=[],T=[];for(let e in v){let{unitId:t,subUnitId:i,ruleMatrix:a}=v[e],o=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(a));if(!o.length){let n={unitId:t,subUnitId:i,cfId:e};w.push({id:r.DeleteConditionalRuleMutation.id,params:n}),T.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,n))}if(x.some(t=>t.cfId===e)){let t={unitId:l,subUnitId:d,rule:{...x.find(t=>t.cfId===e),ranges:o}};w.push({id:r.AddConditionalRuleMutation.id,params:t}),T.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,t))}else{let n=this._conditionalFormattingRuleModel.getRule(t,i,e);if(!n)continue;let a={unitId:t,subUnitId:i,rule:{...n,ranges:o}};w.push({id:r.SetConditionalRuleMutation.id,params:a}),T.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,a))}}return{redos:w,undos:T}}};Qe=K([G(0,(0,t.Inject)(u.ISheetClipboardService)),G(1,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(2,(0,t.Inject)(t.Injector)),G(3,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(4,(0,t.Inject)(t.IUniverInstanceService))],Qe);let $e=class extends t.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===r.AddCfCommand.id){let{unitId:t,subUnitId:r,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[n.WorkbookEditablePermission],rangeTypes:[n.RangeProtectionPermissionEditPoint],worksheetTypes:[n.WorksheetEditPermission,n.WorksheetSetCellStylePermission]},i,t,r)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`permission.dialog.setStyleErr`))}}))}};$e=K([G(0,(0,t.Inject)(t.LocaleService)),G(1,t.ICommandService),G(2,(0,t.Inject)(n.SheetPermissionCheckController))],$e);let et=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._univerInstanceService=n,this._renderManagerService=r,this._conditionalFormattingViewModel=i,this._conditionalFormattingRuleModel=a,W(this,`_ruleChangeCacheMap`,new Map),this._initViewModelInterceptor(),this._initSkeleton(),this.disposeWithMe(()=>{this._ruleChangeCacheMap.clear()})}_markDirtySkeleton(){var e,n;let r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId();(e=this._renderManagerService.getRenderById(r))==null||e.with(u.SheetSkeletonManagerService).reCalculate(),(n=this._renderManagerService.getRenderById(r))==null||(n=n.mainComponent)==null||n.makeDirty()}_initSkeleton(){this.disposeWithMe((0,d.merge)(this._conditionalFormattingRuleModel.$ruleChange,this._conditionalFormattingViewModel.markDirty$).pipe((0,m.bufferTime)(16),(0,m.filter)(e=>!!e.length),(0,m.filter)(e=>{let n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!n)return!1;let r=n.getActiveSheet();return r?e.filter(e=>e.unitId===n.getUnitId()&&e.subUnitId===r.getSheetId()).length>0:!1})).subscribe(()=>this._markDirtySkeleton()))}_initViewModelInterceptor(){this.disposeWithMe(this._sheetInterceptorService.intercept(n.INTERCEPTOR_POINT.CELL_CONTENT,{effect:t.InterceptorEffectEnum.Style,handler:(e,t,n)=>{let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col);if(!i)return n(e);let a=t.workbook.getStyles(),o=(typeof(e==null?void 0:e.s)==`string`?a.get(e==null?void 0:e.s):e==null?void 0:e.s)||{},s=e===t.rawData?{...t.rawData}:e;if(i.style){let e={...o,...i.style};Object.assign(s,{s:e})}return s.fontRenderExtension||(s.fontRenderExtension={},i.isShowValue!==void 0&&(s.fontRenderExtension.isSkip=!i.isShowValue)),i.dataBar&&(s.dataBar=i.dataBar),i.iconSet&&(s.iconSet=i.iconSet,s.fontRenderExtension.leftOffset=r.DEFAULT_PADDING+r.DEFAULT_WIDTH),n(s)},priority:10}))}};et=K([G(0,(0,t.Inject)(n.SheetInterceptorService)),G(1,(0,t.Inject)(r.ConditionalFormattingService)),G(2,(0,t.Inject)(t.IUniverInstanceService)),G(3,(0,t.Inject)(p.IRenderManagerService)),G(4,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(5,(0,t.Inject)(r.ConditionalFormattingRuleModel))],et);let Q=class extends t.Plugin{constructor(e=Xe,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Xe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(Ye,o),this._initCommand(),this._injector.add([et]),this._injector.add([Qe]),this._injector.add([$e]),this._injector.add([q]),this._injector.add([Z])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};W(Q,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_MOBILE_UI_PLUGIN`),W(Q,`packageName`,qe),W(Q,`version`,Je),W(Q,`type`,t.UniverInstanceType.UNIVER_SHEET),Q=K([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(t.ICommandService)),G(3,t.IConfigService)],Q);let tt=class extends t.Disposable{constructor(e,t,n,r,i){super(),this._injector=e,this._univerInstanceService=t,this._autoFillService=n,this._conditionalFormattingRuleModel=r,this._conditionalFormattingViewModel=i,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{var o;let s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getUnitId(),c=(o=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET).getActiveSheet())==null?void 0:o.getSheetId();if(!s||!c)return;let l={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},u={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},l),o=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),{row:d,col:f}=a(r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(s,c,d,f),{row:m,col:h}=a(o.startRow,o.startColumn),g=this._conditionalFormattingViewModel.getCellCfs(s,c,m,h);g&&g.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(m,h)}),p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(s,c,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.setValue(m,h,1)})})},a=(a,o)=>{var s,c;let l=(s=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:s.getUnitId(),d=(c=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(c=c.getActiveSheet())==null?void 0:c.getSheetId(),f=new Map,p=[],m=[];if(!l||!d)return e();let h=(0,u.virtualizeDiscreteRanges)([a,o]),[g,_]=h.ranges,{mapFunc:v}=h,y={row:g.startRow,col:g.startColumn};return n.AutoFillTools.getAutoFillRepeatRange(g,_).forEach(e=>{i(y,e.repeatStartCell,e.relativeRange,f,v)}),f.forEach((e,t)=>{let i=this._conditionalFormattingRuleModel.getRule(l,d,t);if(!i)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:l,subUnitId:d,rule:{...i,ranges:a}};p.push({id:r.SetConditionalRuleMutation.id,params:e}),m.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:l,subUnitId:d,cfId:i.cfId};p.push({id:r.DeleteConditionalRuleMutation.id,params:e}),m.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}),{undos:m,redos:p}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onFillData:(t,r,i)=>{if(i===n.AUTO_FILL_APPLY_TYPE.COPY||i===n.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||i===n.AUTO_FILL_APPLY_TYPE.SERIES){let{source:e,target:n}=t;return a(e,n)}return e()}};this.disposeWithMe(this._autoFillService.addHook(o))}};tt=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(n.IAutoFillService)),G(3,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(4,(0,t.Inject)(r.ConditionalFormattingViewModel))],tt);let nt=class extends t.Disposable{constructor(e,t){super(),this._sheetInterceptorService=e,this._conditionalFormattingService=t,this._initInterceptorEditorEnd()}_initInterceptorEditorEnd(){this.disposeWithMe((0,t.toDisposable)(this._sheetInterceptorService.writeCellInterceptor.intercept(n.AFTER_CELL_EDIT,{handler:(e,t,n)=>{var r;e||n(e);let i=this._conditionalFormattingService.composeStyle(t.unitId,t.subUnitId,t.row,t.col),a=(r=i==null?void 0:i.style)==null?{}:r,o=Object.keys(a);if(e!=null&&e.p){var s;return(s=e.p.body)==null||(s=s.textRuns)==null||s.forEach(e=>{e.ts&&o.forEach(t=>{var n;(n=e.ts)==null||delete n[t]})}),n(e)}else{let r={...(typeof(e==null?void 0:e.s)==`string`?t.workbook.getStyles().get(e.s):e==null?void 0:e.s)||{}};return o.forEach(e=>{delete r[e]}),n({...e,s:{...r}})}}})))}};nt=K([G(0,(0,t.Inject)(n.SheetInterceptorService)),G(1,(0,t.Inject)(r.ConditionalFormattingService))],nt);let rt=(e,t)=>{let n=e=>e.endRow-e.startRow+1,r=e=>e.endColumn-e.startColumn+1,i=n(t)%n(e),a=r(t)%r(e),o=Math.floor(n(t)/n(e)),s=Math.floor(r(t)/r(e)),c=[],l={startRow:0,endRow:n(e)-1,startColumn:0,endColumn:r(e)-1};if(n(t)===1&&r(t)===1){let e={startRow:t.startRow,endRow:t.startRow,startColumn:t.startColumn,endColumn:t.startColumn};return c.push({repeatRelativeRange:l,startRange:e}),c}for(let u=0;u<o+(i?.1:0);u++)for(let d=0;d<s+(a?.1:0);d++){let f=n(e)*u,p=r(e)*d,m={startRow:f+t.startRow,endRow:f+t.startRow,startColumn:p+t.startColumn,endColumn:p+t.startColumn},h=l;u===o&&i&&(h={...h},h.endRow-=n(e)-i),d===s&&a&&(h={...h},h.endColumn-=r(e)-a),c.push({repeatRelativeRange:h,startRange:m})}return c},it=class extends t.Disposable{constructor(e,t,n,r,i,a){super(),this._injector=e,this._univerInstanceService=t,this._formatPainterService=n,this._sheetsSelectionsService=r,this._conditionalFormattingRuleModel=i,this._conditionalFormattingViewModel=a,W(this,`_painterConfig`,null),this._initFormattingPainter()}_initFormattingPainter(){let e=()=>({redos:[],undos:[]}),i=(e,n,r,i,a)=>{let{unitId:o,subUnitId:s}=this._painterConfig,{targetUnitId:c,targetSubUnitId:l}=a,u={startRow:e.row,startColumn:e.col,endColumn:e.col,endRow:e.row},d={startRow:n.row,startColumn:n.col,endColumn:n.col,endRow:n.row};t.Range.foreach(r,(e,n)=>{let r=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},u),a=t.Rectangle.getPositionRange({startRow:e,startColumn:n,endColumn:n,endRow:e},d),f=this._conditionalFormattingViewModel.getCellCfs(o,s,r.startRow,r.startColumn),p=this._conditionalFormattingViewModel.getCellCfs(c,l,a.startRow,a.startColumn);p&&p.forEach(e=>{let n=i.get(e.cfId);if(!i.get(e.cfId)){let r=this._conditionalFormattingRuleModel.getRule(c,l,e.cfId);if(!r)return;n=new t.ObjectMatrix,r.ranges.forEach(e=>{t.Range.foreach(e,(e,t)=>{n.setValue(e,t,1)})}),i.set(e.cfId,n)}n.realDeleteValue(a.startRow,a.startColumn)}),f&&f.forEach(e=>{let t=i.get(e.cfId);t&&t.setValue(a.startRow,a.startColumn,1)})})},a=(a,o,s)=>{var c;let{range:l,unitId:u,subUnitId:d}=this._painterConfig,f=a!==u||d!==o,p=new Map,m=[],h=[];if(!a||!o||!u||!d)return e();let g=(c=this._conditionalFormattingRuleModel.getSubunitRules(u,d))==null?[]:c;g==null||g.forEach(e=>{let{ranges:n,cfId:r}=e;if(n.some(e=>t.Rectangle.intersects(l,e))){let e=new t.ObjectMatrix;f||n.forEach(n=>{t.Range.foreach(n,(t,n)=>{e.setValue(t,n,1)})}),p.set(r,e)}});let _={row:l.startRow,col:l.startColumn};return rt(l,s).forEach(e=>{i(_,{row:e.startRange.startRow,col:e.startRange.startColumn},e.repeatRelativeRange,p,{targetUnitId:a,targetSubUnitId:o})}),p.forEach((e,i)=>{if(f){let s=this._conditionalFormattingRuleModel.getRule(a,o,i),c=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(!s){if(c.length){let e=this._conditionalFormattingRuleModel.getRule(u,d,i);if(e){let n={unitId:a,subUnitId:o,rule:{...t.Tools.deepClone(e),cfId:this._conditionalFormattingRuleModel.createCfId(a,o),ranges:c}};m.push({id:r.AddConditionalRuleMutation.id,params:n}),h.push((0,r.AddConditionalRuleMutationUndoFactory)(this._injector,n))}}}else if(c.length){let e={unitId:a,subUnitId:o,rule:{...s,ranges:c}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:a,subUnitId:o,cfId:s.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}else{let t=this._conditionalFormattingRuleModel.getRule(u,d,i);if(!t)return;let a=(0,n.findAllRectangle)((0,n.createTopMatrixFromMatrix)(e));if(a.length){let e={unitId:u,subUnitId:d,rule:{...t,ranges:a}};m.push({id:r.SetConditionalRuleMutation.id,params:e}),h.push(...(0,r.setConditionalRuleMutationUndoFactory)(this._injector,e))}else{let e={unitId:u,subUnitId:d,cfId:t.cfId};m.push({id:r.DeleteConditionalRuleMutation.id,params:e}),h.push(...(0,r.DeleteConditionalRuleMutationUndoFactory)(this._injector,e))}}}),{undos:h,redos:m}},o={id:r.SHEET_CONDITIONAL_FORMATTING_PLUGIN,onStatusChange:e=>{switch(e){case u.FormatPainterStatus.INFINITE:case u.FormatPainterStatus.ONCE:{var n,r;let e=(n=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:n.getUnitId(),i=(r=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null||(r=r.getActiveSheet())==null?void 0:r.getSheetId(),a=this._sheetsSelectionsService.getCurrentLastSelection(),o=a==null?void 0:a.range;e&&i&&o&&(this._painterConfig={unitId:e,subUnitId:i,range:o});break}case u.FormatPainterStatus.OFF:this._painterConfig=null;break}},onApply:(e,t,n)=>this._painterConfig?a(e,t,n):{redos:[],undos:[]}};this._formatPainterService.addHook(o)}};it=K([G(0,(0,t.Inject)(t.Injector)),G(1,(0,t.Inject)(t.IUniverInstanceService)),G(2,(0,t.Inject)(u.IFormatPainterService)),G(3,(0,t.Inject)(n.SheetsSelectionsService)),G(4,(0,t.Inject)(r.ConditionalFormattingRuleModel)),G(5,(0,t.Inject)(r.ConditionalFormattingViewModel))],it);let at=class extends t.Disposable{constructor(e,t,n){super(),this._conditionalFormattingViewModel=e,this._univerInstanceService=t,this._renderManagerService=n,this._init()}_init(){let e=this._univerInstanceService.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET),n=e=>{let t=e.getUnitId(),n=this._renderManagerService.getRenderById(t);if(!n)return;let i=n.with(u.SheetSkeletonManagerService);this.disposeWithMe(i.currentSkeleton$.subscribe(e=>{if(e){let t=e.skeleton.rowColumnSegment,n=t.endColumn-t.startColumn+1,i=(t.endRow-t.startRow+1)*n*9,a=Math.max(r.CONDITIONAL_FORMATTING_VIEWPORT_CACHE_LENGTH,i);this._conditionalFormattingViewModel.setCacheLength(a)}}))};e&&n(e),this._univerInstanceService.getCurrentTypeOfUnit$(t.UniverInstanceType.UNIVER_SHEET).subscribe(e=>{e&&n(e)})}};at=K([G(0,(0,t.Inject)(r.ConditionalFormattingViewModel)),G(1,t.IUniverInstanceService),G(2,p.IRenderManagerService)],at);let ot=[n.SetWorksheetActiveOperation.id,r.AddConditionalRuleMutation.id,r.SetConditionalRuleMutation.id,r.DeleteConditionalRuleMutation.id,r.MoveConditionalRuleMutation.id],st=[{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}],ct=e=>{let a=e.get(n.SheetsSelectionsService),o=e.get(t.ICommandService),s=e.get(t.IUniverInstanceService),c=e.get(r.ConditionalFormattingRuleModel),l=new d.Observable(r=>(0,d.merge)(a.selectionMoveEnd$,a.selectionSet$,new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();ot.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()})).pipe((0,m.debounceTime)(16)).subscribe(()=>{var i;let o=((i=a.getCurrentSelections())==null?void 0:i.map(e=>e.range))||[],l=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!l)return;let u=l.getActiveSheet();if(!u)return;let d=(c.getSubunitRules(l.getUnitId(),u.getSheetId())||[]).filter(e=>e.ranges.some(e=>o.some(n=>t.Rectangle.intersects(n,e)))).map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,l.getUnitId(),u.getSheetId(),t));r.next(d)})),f=new d.Observable(r=>new d.Observable(e=>{let n=o.onCommandExecuted(n=>{var r;let{id:i,params:a}=n,o=(r=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET))==null?void 0:r.getUnitId();ot.includes(i)&&a.unitId===o&&e.next(null)});return()=>n.dispose()}).pipe((0,m.debounceTime)(16)).subscribe(()=>{let i=s.getCurrentUnitForType(t.UniverInstanceType.UNIVER_SHEET);if(!i)return;let a=i.getActiveSheet();if(!a)return;let o=c.getSubunitRules(i.getUnitId(),a.getSheetId())||[];if(!o.length)return r.next(!1),!1;let l=o.map(e=>e.ranges).every(t=>(0,n.checkRangesEditablePermission)(e,i.getUnitId(),a.getSheetId(),t));r.next(l)})),p=new d.Observable(e=>{l.subscribe(t=>{let n=st.find(e=>e.value===Y.clearRangeRules);n&&(n.disabled=!t,e.next(st))}),f.subscribe(t=>{let n=st.find(e=>e.value===Y.clearWorkSheetRules);n&&(n.disabled=!t,e.next(st))}),e.next(st)});return{id:X.id,type:i.MenuItemType.SELECTOR,icon:`ConditionsDoubleIcon`,tooltip:`sheet.cf.title`,selections:p,hidden$:(0,i.getMenuHiddenObservable)(e,t.UniverInstanceType.UNIVER_SHEET),disabled$:(0,u.getCurrentRangeDisable$)(e,{workbookTypes:[n.WorkbookEditablePermission],worksheetTypes:[n.WorksheetSetCellStylePermission,n.WorksheetEditPermission],rangeTypes:[n.RangeProtectionPermissionEditPoint]})}},lt={[i.RibbonDataGroup.RULES]:{[X.id]:{order:1,menuItemFactory:ct}}},ut=class extends t.Disposable{constructor(e,t){super(),this._injector=e,this._menuManagerService=t,W(this,`_sidebarDisposable`,null),this._menuManagerService.mergeMenu(lt)}};ut=K([G(0,(0,t.Inject)(t.Injector)),G(1,i.IMenuManagerService)],ut);let $=class extends t.Plugin{constructor(e=Xe,n,r,i){super(),this._config=e,this._injector=n,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,t.merge)({},Xe,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(Ye,o),this._initCommand()}onStarting(){(0,t.registerDependencies)(this._injector,[[et],[Qe],[tt],[$e],[J],[ut],[q],[nt],[Ge],[it],[at],[Z]]),(0,t.touchDependencies)(this._injector,[[et],[Z]])}onReady(){(0,t.touchDependencies)(this._injector,[[ut],[J]])}onRendered(){(0,t.touchDependencies)(this._injector,[[tt],[Ge],[Qe],[nt],[q],[it],[$e],[at]])}_initCommand(){[h,g,_,v,y,b,x,S,C,X].forEach(e=>{this._commandService.registerCommand(e)})}};W($,`pluginName`,`${r.SHEET_CONDITIONAL_FORMATTING_PLUGIN}_UI_PLUGIN`),W($,`packageName`,qe),W($,`version`,Je),W($,`type`,t.UniverInstanceType.UNIVER_SHEET),$=K([(0,t.DependentOn)(r.UniverSheetsConditionalFormattingPlugin,f.UniverSheetsFormulaPlugin),G(1,(0,t.Inject)(t.Injector)),G(2,(0,t.Inject)(t.ICommandService)),G(3,t.IConfigService)],$),e.AddAverageCfCommand=h,e.AddColorScaleConditionalRuleCommand=g,e.AddDataBarConditionalRuleCommand=_,e.AddDuplicateValuesCfCommand=v,e.AddNumberCfCommand=y,e.AddRankCfCommand=b,e.AddTextCfCommand=x,e.AddTimePeriodCfCommand=S,e.AddUniqueValuesCfCommand=C,Object.defineProperty(e,`ConditionalFormattingClearController`,{enumerable:!0,get:function(){return Ge}}),e.OpenConditionalFormattingOperator=X,Object.defineProperty(e,`UniverSheetsConditionalFormattingMobileUIPlugin`,{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,`UniverSheetsConditionalFormattingUIPlugin`,{enumerable:!0,get:function(){return $}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/sheets-conditional-formatting-ui",
3
- "version": "0.21.0",
3
+ "version": "0.21.1-insiders.20260429-a0b1161",
4
4
  "private": false,
5
5
  "description": "Conditional formatting plugin for Univer Sheets",
6
6
  "author": "DreamNum <developer@univer.ai>",
@@ -55,16 +55,16 @@
55
55
  },
56
56
  "dependencies": {
57
57
  "@univerjs/icons": "^1.1.1",
58
- "@univerjs/core": "0.21.0",
59
- "@univerjs/design": "0.21.0",
60
- "@univerjs/engine-formula": "0.21.0",
61
- "@univerjs/sheets": "0.21.0",
62
- "@univerjs/engine-render": "0.21.0",
63
- "@univerjs/sheets-formula": "0.21.0",
64
- "@univerjs/sheets-formula-ui": "0.21.0",
65
- "@univerjs/sheets-conditional-formatting": "0.21.0",
66
- "@univerjs/sheets-ui": "0.21.0",
67
- "@univerjs/ui": "0.21.0"
58
+ "@univerjs/core": "0.21.1-insiders.20260429-a0b1161",
59
+ "@univerjs/design": "0.21.1-insiders.20260429-a0b1161",
60
+ "@univerjs/engine-formula": "0.21.1-insiders.20260429-a0b1161",
61
+ "@univerjs/engine-render": "0.21.1-insiders.20260429-a0b1161",
62
+ "@univerjs/sheets-conditional-formatting": "0.21.1-insiders.20260429-a0b1161",
63
+ "@univerjs/sheets-formula-ui": "0.21.1-insiders.20260429-a0b1161",
64
+ "@univerjs/sheets-formula": "0.21.1-insiders.20260429-a0b1161",
65
+ "@univerjs/sheets-ui": "0.21.1-insiders.20260429-a0b1161",
66
+ "@univerjs/ui": "0.21.1-insiders.20260429-a0b1161",
67
+ "@univerjs/sheets": "0.21.1-insiders.20260429-a0b1161"
68
68
  },
69
69
  "devDependencies": {
70
70
  "postcss": "^8.5.10",
@@ -73,7 +73,7 @@
73
73
  "tailwindcss": "3.4.18",
74
74
  "typescript": "^6.0.2",
75
75
  "vitest": "^4.1.4",
76
- "@univerjs-infra/shared": "0.21.0"
76
+ "@univerjs-infra/shared": "0.21.1"
77
77
  },
78
78
  "scripts": {
79
79
  "test": "vitest run",
package/LICENSE DELETED
@@ -1,176 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS