@univerjs/sheets 0.2.15 → 0.3.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/es/index.js CHANGED
@@ -2,18 +2,18 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
3
  var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
5
- import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, toDisposable, remove, composeInterceptors, DisposableCollection, Tools, normalizeTextRuns, CellValueType, isRealNum, isBooleanString, isSafeNumeric, CommandType, ObjectMatrix, ICommandService, IUndoRedoService, sequenceExecute, LocaleService, createIdentifier, IContextService, selectionToArray, Rectangle, RANGE_TYPE, ErrorService, Range, cellToRange, PermissionStatus, IPermissionService, isICellData, Dimension, getArrayLength, insertMatrixArray, spliceArray, sliceMatrixArray, concatMatrixArray, BooleanNumber, Direction, mergeWorksheetSnapshotWithDefault, moveMatrixArray, BorderType, BorderStyleTypes, FontWeight, FontItalic, runOnLifecycle, LifecycleStages, OnLifecycle, Inject, Injector, IResourceManagerService, Optional, IConfigService, queryObjectMatrix, InterceptorManager, ILogService, LRUMap, DependentOn, Plugin, mergeOverrideWithDependencies, ColorKit, getCellInfoInMergeData, makeCellRangeToRangeData, createRowColIter } from "@univerjs/core";
5
+ import { RxDisposable, UniverInstanceType, Disposable, IUniverInstanceService, createInterceptorKey, InterceptorEffectEnum, toDisposable, remove, composeInterceptors, DisposableCollection, Tools, normalizeTextRuns, CellValueType, isRealNum, isBooleanString, isSafeNumeric, CommandType, ObjectMatrix, ICommandService, IUndoRedoService, sequenceExecute, LocaleService, createIdentifier, IContextService, selectionToArray, Rectangle, RANGE_TYPE, ErrorService, Range, cellToRange, PermissionStatus, IPermissionService, isICellData, Dimension, getArrayLength, insertMatrixArray, spliceArray, sliceMatrixArray, concatMatrixArray, BooleanNumber, Direction, mergeWorksheetSnapshotWithDefault, moveMatrixArray, BorderType, BorderStyleTypes, FontWeight, FontItalic, runOnLifecycle, LifecycleStages, OnLifecycle, Inject, Injector, IResourceManagerService, Optional, IConfigService, queryObjectMatrix, InterceptorManager, LRUMap, ILogService, DependentOn, Plugin, mergeOverrideWithDependencies, ColorKit, getCellInfoInMergeData, makeCellRangeToRangeData, createRowColIter } from "@univerjs/core";
6
6
  import { SetDefinedNameMutation, RemoveDefinedNameMutation, SetFormulaCalculationResultMutation, handleNumfmtInCell, IDefinedNamesService, stripErrorMargin, UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
7
7
  import { DataSyncPrimaryController } from "@univerjs/rpc";
8
- import { shareReplay, takeUntil, switchMap, of, Subject, BehaviorSubject, merge, map } from "rxjs";
8
+ import { shareReplay, takeUntil, switchMap, of, Subject, BehaviorSubject, merge, map, first, filter } from "rxjs";
9
9
  import { DEFAULT_TEXT_FORMAT } from "@univerjs/engine-numfmt";
10
- import { takeUntil as takeUntil$1, filter, map as map$1 } from "rxjs/operators";
10
+ import { takeUntil as takeUntil$1, filter as filter$1, map as map$1 } from "rxjs/operators";
11
11
  import { RangeProtectionRuleModel as RangeProtectionRuleModel$1, WorkbookEditablePermission as WorkbookEditablePermission$1, WorksheetEditPermission as WorksheetEditPermission$1, RangeProtectionPermissionEditPoint as RangeProtectionPermissionEditPoint$1 } from "@univerjs/sheets";
12
- var __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
13
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
12
+ var __defProp$j = Object.defineProperty, __getOwnPropDesc$j = Object.getOwnPropertyDescriptor, __decorateClass$j = /* @__PURE__ */ __name((decorators, target, key, kind) => {
13
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$j(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
14
14
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
15
- return kind && result && __defProp$i(target, key, result), result;
16
- }, "__decorateClass$i"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), SelectionMoveType = /* @__PURE__ */ ((SelectionMoveType2) => (SelectionMoveType2[SelectionMoveType2.MOVE_START = 0] = "MOVE_START", SelectionMoveType2[SelectionMoveType2.MOVING = 1] = "MOVING", SelectionMoveType2[SelectionMoveType2.MOVE_END = 2] = "MOVE_END", SelectionMoveType2))(SelectionMoveType || {}), _a;
15
+ return kind && result && __defProp$j(target, key, result), result;
16
+ }, "__decorateClass$j"), __decorateParam$g = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$g"), SelectionMoveType = /* @__PURE__ */ ((SelectionMoveType2) => (SelectionMoveType2[SelectionMoveType2.MOVE_START = 0] = "MOVE_START", SelectionMoveType2[SelectionMoveType2.MOVING = 1] = "MOVING", SelectionMoveType2[SelectionMoveType2.MOVE_END = 2] = "MOVE_END", SelectionMoveType2))(SelectionMoveType || {}), _a;
17
17
  let SheetsSelectionsService = (_a = class extends RxDisposable {
18
18
  constructor(_instanceSrv) {
19
19
  super();
@@ -130,8 +130,8 @@ let SheetsSelectionsService = (_a = class extends RxDisposable {
130
130
  this._workbookSelections.delete(unitId);
131
131
  }
132
132
  }, __name(_a, "SheetsSelectionsService"), _a);
133
- SheetsSelectionsService = __decorateClass$i([
134
- __decorateParam$f(0, IUniverInstanceService)
133
+ SheetsSelectionsService = __decorateClass$j([
134
+ __decorateParam$g(0, IUniverInstanceService)
135
135
  ], SheetsSelectionsService);
136
136
  const _WorkbookSelections = class _WorkbookSelections extends Disposable {
137
137
  constructor(_workbook) {
@@ -213,11 +213,11 @@ const DISABLE_NORMAL_SELECTIONS = "DISABLE_NORMAL_SELECTIONS", CELL_CONTENT = cr
213
213
  CELL_CONTENT,
214
214
  ROW_FILTERED
215
215
  };
216
- var InterceptCellContentPriority = /* @__PURE__ */ ((InterceptCellContentPriority2) => (InterceptCellContentPriority2[InterceptCellContentPriority2.DATA_VALIDATION = 9] = "DATA_VALIDATION", InterceptCellContentPriority2[InterceptCellContentPriority2.NUMFMT = 10] = "NUMFMT", InterceptCellContentPriority2))(InterceptCellContentPriority || {}), __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
217
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
216
+ var InterceptCellContentPriority = /* @__PURE__ */ ((InterceptCellContentPriority2) => (InterceptCellContentPriority2[InterceptCellContentPriority2.DATA_VALIDATION = 9] = "DATA_VALIDATION", InterceptCellContentPriority2[InterceptCellContentPriority2.NUMFMT = 10] = "NUMFMT", InterceptCellContentPriority2))(InterceptCellContentPriority || {}), __defProp$i = Object.defineProperty, __getOwnPropDesc$i = Object.getOwnPropertyDescriptor, __decorateClass$i = /* @__PURE__ */ __name((decorators, target, key, kind) => {
217
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$i(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
218
218
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
219
- return kind && result && __defProp$h(target, key, result), result;
220
- }, "__decorateClass$h"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e"), _a2;
219
+ return kind && result && __defProp$i(target, key, result), result;
220
+ }, "__decorateClass$i"), __decorateParam$f = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$f"), _a2;
221
221
  let SheetInterceptorService = (_a2 = class extends Disposable {
222
222
  /** @ignore */
223
223
  constructor(_univerInstanceService) {
@@ -234,6 +234,7 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
234
234
  (workbook) => this._disposeWorkbookInterceptor(workbook)
235
235
  )), this.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
236
236
  priority: -1,
237
+ effect: InterceptorEffectEnum.Style | InterceptorEffectEnum.Value,
237
238
  handler(value, context) {
238
239
  const rawData = context.worksheet.getCellRaw(context.row, context.col);
239
240
  return value ? { ...rawData, ...value } : rawData;
@@ -247,8 +248,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
247
248
  if (this._commandInterceptors.includes(interceptor))
248
249
  throw new Error("[SheetInterceptorService]: Interceptor already exists!");
249
250
  return this._commandInterceptors.push(interceptor), this._commandInterceptors.sort((a, b) => {
250
- var _a20, _b;
251
- return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
251
+ var _a21, _b;
252
+ return ((_a21 = b.priority) != null ? _a21 : 0) - ((_b = a.priority) != null ? _b : 0);
252
253
  }), this.disposeWithMe(toDisposable(() => remove(this._commandInterceptors, interceptor)));
253
254
  }
254
255
  // Add a listener function to the command, which will be run before the command is run to get whether it can be executed the command
@@ -256,8 +257,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
256
257
  if (this._beforeCommandInterceptor.includes(interceptor))
257
258
  throw new Error("[SheetInterceptorService]: Interceptor already exists!");
258
259
  return this._beforeCommandInterceptor.push(interceptor), this._beforeCommandInterceptor.sort((a, b) => {
259
- var _a20, _b;
260
- return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
260
+ var _a21, _b;
261
+ return ((_a21 = b.priority) != null ? _a21 : 0) - ((_b = a.priority) != null ? _b : 0);
261
262
  }), this.disposeWithMe(toDisposable(() => remove(this._beforeCommandInterceptor, interceptor)));
262
263
  }
263
264
  /**
@@ -277,8 +278,8 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
277
278
  if (this._rangeInterceptors.includes(interceptor))
278
279
  throw new Error("[SheetInterceptorService]: Interceptor already exists!");
279
280
  return this._rangeInterceptors.push(interceptor), this._rangeInterceptors.sort((a, b) => {
280
- var _a20, _b;
281
- return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
281
+ var _a21, _b;
282
+ return ((_a21 = b.priority) != null ? _a21 : 0) - ((_b = a.priority) != null ? _b : 0);
282
283
  }), this.disposeWithMe(toDisposable(() => remove(this._rangeInterceptors, interceptor)));
283
284
  }
284
285
  /**
@@ -290,13 +291,13 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
290
291
  const infos = this._commandInterceptors.map((i) => i.getMutations(info));
291
292
  return {
292
293
  preUndos: infos.map((i) => {
293
- var _a20;
294
- return (_a20 = i.preUndos) != null ? _a20 : [];
294
+ var _a21;
295
+ return (_a21 = i.preUndos) != null ? _a21 : [];
295
296
  }).flat(),
296
297
  undos: infos.map((i) => i.undos).flat(),
297
298
  preRedos: infos.map((i) => {
298
- var _a20;
299
- return (_a20 = i.preRedos) != null ? _a20 : [];
299
+ var _a21;
300
+ return (_a21 = i.preRedos) != null ? _a21 : [];
300
301
  }).flat(),
301
302
  redos: infos.map((i) => i.redos).flat()
302
303
  };
@@ -305,13 +306,13 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
305
306
  const infos = this._rangeInterceptors.map((i) => i.getMutations(info));
306
307
  return {
307
308
  preUndos: infos.map((i) => {
308
- var _a20;
309
- return (_a20 = i.preUndos) != null ? _a20 : [];
309
+ var _a21;
310
+ return (_a21 = i.preUndos) != null ? _a21 : [];
310
311
  }).flat(),
311
312
  undos: infos.map((i) => i.undos).flat(),
312
313
  preRedos: infos.map((i) => {
313
- var _a20;
314
- return (_a20 = i.preRedos) != null ? _a20 : [];
314
+ var _a21;
315
+ return (_a21 = i.preRedos) != null ? _a21 : [];
315
316
  }).flat(),
316
317
  redos: infos.map((i) => i.redos).flat()
317
318
  };
@@ -320,16 +321,27 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
320
321
  const key = name;
321
322
  this._interceptorsByName.has(key) || this._interceptorsByName.set(key, []);
322
323
  const interceptors = this._interceptorsByName.get(key);
323
- return interceptors.push(interceptor), this._interceptorsByName.set(
324
+ interceptors.push(interceptor);
325
+ const sortedInterceptors = interceptors.sort((a, b) => {
326
+ var _a21, _b;
327
+ return ((_a21 = b.priority) != null ? _a21 : 0) - ((_b = a.priority) != null ? _b : 0);
328
+ });
329
+ return key === INTERCEPTOR_POINT.CELL_CONTENT ? (this._interceptorsByName.set(
330
+ `${key}-${InterceptorEffectEnum.Style | InterceptorEffectEnum.Value}`,
331
+ sortedInterceptors
332
+ ), this._interceptorsByName.set(
333
+ `${key}-${InterceptorEffectEnum.Style}`,
334
+ sortedInterceptors.filter((i) => ((i.effect || 3) & InterceptorEffectEnum.Style) > 0)
335
+ ), this._interceptorsByName.set(
336
+ `${key}-${InterceptorEffectEnum.Value}`,
337
+ sortedInterceptors.filter((i) => ((i.effect || 3) & InterceptorEffectEnum.Value) > 0)
338
+ )) : this._interceptorsByName.set(
324
339
  key,
325
- interceptors.sort((a, b) => {
326
- var _a20, _b;
327
- return ((_a20 = b.priority) != null ? _a20 : 0) - ((_b = a.priority) != null ? _b : 0);
328
- })
340
+ sortedInterceptors
329
341
  ), this.disposeWithMe(toDisposable(() => remove(this._interceptorsByName.get(key), interceptor)));
330
342
  }
331
- fetchThroughInterceptors(name) {
332
- const key = name, interceptors = this._interceptorsByName.get(key);
343
+ fetchThroughInterceptors(name, effect) {
344
+ const key = effect === void 0 ? name : `${name}-${effect}`, interceptors = this._interceptorsByName.get(key);
333
345
  return composeInterceptors(interceptors || []);
334
346
  }
335
347
  _interceptWorkbook(workbook) {
@@ -338,16 +350,18 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
338
350
  worksheet.__interceptViewModel((viewModel) => {
339
351
  const sheetDisposables = new DisposableCollection();
340
352
  sheetInterceptorService._worksheetDisposables.set(getWorksheetDisposableID(unitId, worksheet), sheetDisposables), sheetDisposables.add(viewModel.registerCellContentInterceptor({
341
- getCell(row, col) {
342
- return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT)(
343
- worksheet.getCellRaw(row, col),
353
+ getCell(row, col, effect) {
354
+ const rawData = worksheet.getCellRaw(row, col);
355
+ return sheetInterceptorService.fetchThroughInterceptors(INTERCEPTOR_POINT.CELL_CONTENT, effect)(
356
+ rawData,
344
357
  {
345
358
  unitId,
346
359
  subUnitId,
347
360
  row,
348
361
  col,
349
362
  worksheet,
350
- workbook
363
+ workbook,
364
+ rawData
351
365
  }
352
366
  );
353
367
  }
@@ -378,22 +392,22 @@ let SheetInterceptorService = (_a2 = class extends Disposable {
378
392
  disposable && (disposable.dispose(), this._worksheetDisposables.delete(disposableId));
379
393
  }
380
394
  }, __name(_a2, "SheetInterceptorService"), _a2);
381
- SheetInterceptorService = __decorateClass$h([
382
- __decorateParam$e(0, IUniverInstanceService)
395
+ SheetInterceptorService = __decorateClass$i([
396
+ __decorateParam$f(0, IUniverInstanceService)
383
397
  ], SheetInterceptorService);
384
398
  function getWorksheetDisposableID(unitId, worksheet) {
385
399
  return `${unitId}|${worksheet.getSheetId()}`;
386
400
  }
387
401
  __name(getWorksheetDisposableID, "getWorksheetDisposableID");
388
402
  function handleStyle(styles, oldVal, newVal) {
389
- var _a20;
403
+ var _a21;
390
404
  const oldStyle = styles.getStyleByCell(oldVal);
391
405
  oldStyle == null && delete oldVal.s, typeof newVal.s == "string" && (newVal.s = styles.get(newVal.s));
392
406
  const merge2 = mergeStyle(oldStyle, newVal.s ? newVal.s : null);
393
407
  merge2 && Tools.removeNull(merge2), Tools.isEmptyObject(merge2) ? delete oldVal.s : oldVal.s = styles.setValue(merge2);
394
408
  const newValueStream = newVal.v ? `${newVal.v}\r
395
409
  ` : "";
396
- !newVal.p && oldVal.p && (newValueStream && newValueStream !== ((_a20 = oldVal.p.body) == null ? void 0 : _a20.dataStream) ? delete oldVal.p : mergeRichTextStyle(oldVal.p, newVal.s ? newVal.s : null));
410
+ !newVal.p && oldVal.p && (newValueStream && newValueStream !== ((_a21 = oldVal.p.body) == null ? void 0 : _a21.dataStream) ? delete oldVal.p : mergeRichTextStyle(oldVal.p, newVal.s ? newVal.s : null));
397
411
  }
398
412
  __name(handleStyle, "handleStyle");
399
413
  function transformStyle(oldStyle, newStyle) {
@@ -427,12 +441,12 @@ function skipParagraphs(paragraphs, offset) {
427
441
  }
428
442
  __name(skipParagraphs, "skipParagraphs");
429
443
  function mergeRichTextStyle(p, newStyle) {
430
- var _a20;
444
+ var _a21;
431
445
  if (p.body == null)
432
446
  return;
433
447
  Array.isArray(p.body.textRuns) || (p.body.textRuns = []);
434
448
  let index = 0;
435
- const newTextRuns = [], paragraphs = ((_a20 = p.body) == null ? void 0 : _a20.paragraphs) || [];
449
+ const newTextRuns = [], paragraphs = ((_a21 = p.body) == null ? void 0 : _a21.paragraphs) || [];
436
450
  for (const textRun of p.body.textRuns) {
437
451
  const { st, ed, ts = {} } = textRun;
438
452
  if (index < st) {
@@ -478,13 +492,13 @@ function checkCellValueTypeByValue(newVal, oldVal) {
478
492
  }
479
493
  __name(checkCellValueTypeByValue, "checkCellValueTypeByValue");
480
494
  function hasNumberFormat(style) {
481
- var _a20;
482
- return !!((_a20 = style == null ? void 0 : style.n) != null && _a20.pattern);
495
+ var _a21;
496
+ return !!((_a21 = style == null ? void 0 : style.n) != null && _a21.pattern);
483
497
  }
484
498
  __name(hasNumberFormat, "hasNumberFormat");
485
499
  function isTextFormat(style) {
486
- var _a20;
487
- return ((_a20 = style == null ? void 0 : style.n) == null ? void 0 : _a20.pattern) === DEFAULT_TEXT_FORMAT;
500
+ var _a21;
501
+ return ((_a21 = style == null ? void 0 : style.n) == null ? void 0 : _a21.pattern) === DEFAULT_TEXT_FORMAT;
488
502
  }
489
503
  __name(isTextFormat, "isTextFormat");
490
504
  function checkCellValueType(v, type) {
@@ -615,12 +629,12 @@ const ClearSelectionAllCommand = {
615
629
  id: "sheet.command.clear-selection-all",
616
630
  type: CommandType.COMMAND,
617
631
  handler: /* @__PURE__ */ __name(async (accessor) => {
618
- var _a20;
632
+ var _a21;
619
633
  const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
620
634
  if (!workbook) return !1;
621
635
  const unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
622
636
  if (!worksheet) return !1;
623
- const subUnitId = worksheet.getSheetId(), selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
637
+ const subUnitId = worksheet.getSheetId(), selections = (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
624
638
  if (!(selections != null && selections.length))
625
639
  return !1;
626
640
  const sequenceExecuteList = [], sequenceExecuteUndoList = [], clearMutationParams = {
@@ -651,12 +665,12 @@ const ClearSelectionAllCommand = {
651
665
  id: "sheet.command.clear-selection-content",
652
666
  type: CommandType.COMMAND,
653
667
  handler: /* @__PURE__ */ __name(async (accessor) => {
654
- var _a20;
668
+ var _a21;
655
669
  const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
656
670
  if (!workbook) return !1;
657
671
  const unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
658
672
  if (!worksheet) return !1;
659
- const subUnitId = worksheet.getSheetId(), selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
673
+ const subUnitId = worksheet.getSheetId(), selections = (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
660
674
  if (!(selections != null && selections.length))
661
675
  return !1;
662
676
  const clearMutationParams = {
@@ -679,12 +693,12 @@ const ClearSelectionAllCommand = {
679
693
  id: "sheet.command.clear-selection-format",
680
694
  type: CommandType.COMMAND,
681
695
  handler: /* @__PURE__ */ __name(async (accessor) => {
682
- var _a20;
696
+ var _a21;
683
697
  const univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), selectionManagerService = accessor.get(SheetsSelectionsService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
684
698
  if (!workbook) return !1;
685
699
  const unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
686
700
  if (!worksheet) return !1;
687
- const subUnitId = worksheet.getSheetId(), selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
701
+ const subUnitId = worksheet.getSheetId(), selections = (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
688
702
  if (!(selections != null && selections.length))
689
703
  return !1;
690
704
  const sequenceExecuteList = [], sequenceExecuteUndoList = [], clearMutationParams = {
@@ -774,10 +788,11 @@ const RemoveSheetUndoMutationFactory = /* @__PURE__ */ __name((accessor, params)
774
788
  type: CommandType.COMMAND,
775
789
  id: "sheet.command.copy-sheet",
776
790
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
777
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), localeService = accessor.get(LocaleService), target = getSheetCommandTarget(univerInstanceService, params);
791
+ var _a21, _b;
792
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), localeService = accessor.get(LocaleService), target = getSheetCommandTarget(univerInstanceService, params);
778
793
  if (!target)
779
794
  return !1;
780
- const { workbook, worksheet, unitId } = target, config = Tools.deepClone(worksheet.getConfig());
795
+ const { workbook, worksheet, unitId, subUnitId } = target, config = Tools.deepClone(worksheet.getConfig());
781
796
  config.name = getCopyUniqueSheetName(workbook, localeService, config.name), config.id = Tools.generateRandomId();
782
797
  const insertSheetMutationParams = {
783
798
  index: workbook.getSheetIndex(worksheet) + 1,
@@ -786,11 +801,22 @@ const RemoveSheetUndoMutationFactory = /* @__PURE__ */ __name((accessor, params)
786
801
  }, removeSheetMutationParams = InsertSheetUndoMutationFactory(
787
802
  accessor,
788
803
  insertSheetMutationParams
789
- );
790
- return commandService.syncExecuteCommand(InsertSheetMutation.id, insertSheetMutationParams) ? (undoRedoService.pushUndoRedo({
804
+ ), intercepted = sheetInterceptorService.onCommandExecute({
805
+ id: CopySheetCommand.id,
806
+ params: { unitId, subUnitId, targetSubUnitId: config.id }
807
+ }), redos = [
808
+ ...(_a21 = intercepted.preRedos) != null ? _a21 : [],
809
+ { id: InsertSheetMutation.id, params: insertSheetMutationParams },
810
+ ...intercepted.redos
811
+ ], undos = [
812
+ ...(_b = intercepted.preUndos) != null ? _b : [],
813
+ { id: RemoveSheetMutation.id, params: removeSheetMutationParams },
814
+ ...intercepted.undos
815
+ ];
816
+ return sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
791
817
  unitID: unitId,
792
- undoMutations: [{ id: RemoveSheetMutation.id, params: removeSheetMutationParams }],
793
- redoMutations: [{ id: InsertSheetMutation.id, params: insertSheetMutationParams }]
818
+ undoMutations: undos,
819
+ redoMutations: redos
794
820
  }), !0) : !1;
795
821
  }, "handler")
796
822
  };
@@ -822,11 +848,11 @@ const MoveRangeMutation = {
822
848
  }), !0;
823
849
  }, "handler")
824
850
  };
825
- var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
826
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
851
+ var __defProp$h = Object.defineProperty, __getOwnPropDesc$h = Object.getOwnPropertyDescriptor, __decorateClass$h = /* @__PURE__ */ __name((decorators, target, key, kind) => {
852
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$h(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
827
853
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
828
- return kind && result && __defProp$g(target, key, result), result;
829
- }, "__decorateClass$g"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d");
854
+ return kind && result && __defProp$h(target, key, result), result;
855
+ }, "__decorateClass$h"), __decorateParam$e = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$e");
830
856
  const IRefSelectionsService = createIdentifier("sheets-formula.ref-selections.service");
831
857
  var _a3;
832
858
  let RefSelectionsService = (_a3 = class extends SheetsSelectionsService {
@@ -848,8 +874,8 @@ let RefSelectionsService = (_a3 = class extends SheetsSelectionsService {
848
874
  })), workbooks$.pipe(map((workbooks) => workbooks.map((w) => this._ensureWorkbookSelection(w.getUnitId()))));
849
875
  }
850
876
  }, __name(_a3, "RefSelectionsService"), _a3);
851
- RefSelectionsService = __decorateClass$g([
852
- __decorateParam$d(0, IUniverInstanceService)
877
+ RefSelectionsService = __decorateClass$h([
878
+ __decorateParam$e(0, IUniverInstanceService)
853
879
  ], RefSelectionsService);
854
880
  function getSelectionsService(accessor) {
855
881
  const disabledNormalSelections = accessor.get(IContextService).getContextValue(DISABLE_NORMAL_SELECTIONS);
@@ -940,6 +966,7 @@ const followSelectionOperation = /* @__PURE__ */ __name((range, workbook, worksh
940
966
  params: {
941
967
  unitId: workbook.getUnitId(),
942
968
  subUnitId: worksheet.getSheetId(),
969
+ reveal: !0,
943
970
  selections: [{ range, primary: getPrimaryForRange(range, worksheet) }]
944
971
  }
945
972
  }), "followSelectionOperation");
@@ -979,7 +1006,7 @@ const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
979
1006
  type: CommandType.COMMAND,
980
1007
  id: MoveRangeCommandId,
981
1008
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
982
- var _a20, _b;
1009
+ var _a21, _b;
983
1010
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
984
1011
  if (!target || !await sheetInterceptorService.beforeCommandExecute({ id: MoveRangeCommand.id, params }))
985
1012
  return !1;
@@ -994,7 +1021,7 @@ const MoveRangeCommandId = "sheet.command.move-range", MoveRangeCommand = {
994
1021
  id: MoveRangeCommand.id,
995
1022
  params: { ...params }
996
1023
  }), redos = [
997
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
1024
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
998
1025
  ...moveRangeMutations.redos,
999
1026
  ...interceptorCommands.redos,
1000
1027
  {
@@ -1076,270 +1103,180 @@ function getMoveRangeUndoRedoMutations(accessor, from, to, ignoreMerge = !1) {
1076
1103
  }
1077
1104
  __name(getMoveRangeUndoRedoMutations, "getMoveRangeUndoRedoMutations");
1078
1105
  var I = /* @__PURE__ */ ((E) => (E[E.UNIVER_UNKNOWN = 0] = "UNIVER_UNKNOWN", E[E.UNIVER_DOC = 1] = "UNIVER_DOC", E[E.UNIVER_SHEET = 2] = "UNIVER_SHEET", E[E.UNIVER_SLIDE = 3] = "UNIVER_SLIDE", E[E.UNIVER_PROJECT = 4] = "UNIVER_PROJECT", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(I || {}), P = /* @__PURE__ */ ((E) => (E[E.View = 0] = "View", E[E.Edit = 1] = "Edit", E[E.ManageCollaborator = 2] = "ManageCollaborator", E[E.Print = 3] = "Print", E[E.Duplicate = 4] = "Duplicate", E[E.Comment = 5] = "Comment", E[E.Copy = 6] = "Copy", E[E.Share = 7] = "Share", E[E.Export = 8] = "Export", E[E.MoveWorksheet = 9] = "MoveWorksheet", E[E.DeleteWorksheet = 10] = "DeleteWorksheet", E[E.HideWorksheet = 11] = "HideWorksheet", E[E.RenameWorksheet = 12] = "RenameWorksheet", E[E.CreateWorksheet = 13] = "CreateWorksheet", E[E.SetWorksheetStyle = 14] = "SetWorksheetStyle", E[E.EditWorksheetCell = 15] = "EditWorksheetCell", E[E.InsertHyperlink = 16] = "InsertHyperlink", E[E.Sort = 17] = "Sort", E[E.Filter = 18] = "Filter", E[E.PivotTable = 19] = "PivotTable", E[E.FloatImg = 20] = "FloatImg", E[E.History = 21] = "History", E[E.RwHgtClWdt = 22] = "RwHgtClWdt", E[E.ViemRwHgtClWdt = 23] = "ViemRwHgtClWdt", E[E.ViewFilter = 24] = "ViewFilter", E[E.MoveSheet = 25] = "MoveSheet", E[E.DeleteSheet = 26] = "DeleteSheet", E[E.HideSheet = 27] = "HideSheet", E[E.CopySheet = 28] = "CopySheet", E[E.RenameSheet = 29] = "RenameSheet", E[E.CreateSheet = 30] = "CreateSheet", E[E.SelectProtectedCells = 31] = "SelectProtectedCells", E[E.SelectUnProtectedCells = 32] = "SelectUnProtectedCells", E[E.SetCellStyle = 33] = "SetCellStyle", E[E.SetCellValue = 34] = "SetCellValue", E[E.SetRowStyle = 35] = "SetRowStyle", E[E.SetColumnStyle = 36] = "SetColumnStyle", E[E.InsertRow = 37] = "InsertRow", E[E.InsertColumn = 38] = "InsertColumn", E[E.DeleteRow = 39] = "DeleteRow", E[E.DeleteColumn = 40] = "DeleteColumn", E[E.EditExtraObject = 41] = "EditExtraObject", E[E.Delete = 42] = "Delete", E[E.RecoverHistory = 43] = "RecoverHistory", E[E.ViewHistory = 44] = "ViewHistory", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(P || {}), M = /* @__PURE__ */ ((E) => (E[E.Unkonwn = 0] = "Unkonwn", E[E.Workbook = 1] = "Workbook", E[E.Worksheet = 2] = "Worksheet", E[E.SelectRange = 3] = "SelectRange", E[E.Document = 4] = "Document", E[E.Slide = 5] = "Slide", E[E.UNRECOGNIZED = -1] = "UNRECOGNIZED", E))(M || {});
1079
- const _WorksheetCopyPermission = class _WorksheetCopyPermission {
1080
- constructor(unitId, subUnitId) {
1081
- __publicField(this, "value", !0);
1082
- __publicField(this, "type", M.Worksheet);
1106
+ const _RangeProtectionPermissionEditPoint = class _RangeProtectionPermissionEditPoint {
1107
+ constructor(unitId, subUnitId, permissionId) {
1108
+ __publicField(this, "type", M.SelectRange);
1109
+ __publicField(this, "subType", P.Edit);
1083
1110
  __publicField(this, "status", PermissionStatus.INIT);
1111
+ __publicField(this, "value", !0);
1084
1112
  __publicField(this, "id");
1085
- __publicField(this, "subType", P.Copy);
1086
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Copy}_${unitId}_${subUnitId}`;
1113
+ __publicField(this, "unitId");
1114
+ __publicField(this, "subUnitId");
1115
+ __publicField(this, "permissionId");
1116
+ this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${P.Edit}.${permissionId}`;
1087
1117
  }
1088
1118
  };
1089
- __name(_WorksheetCopyPermission, "WorksheetCopyPermission");
1090
- let WorksheetCopyPermission = _WorksheetCopyPermission;
1091
- const _WorksheetSelectProtectedCellsPermission = class _WorksheetSelectProtectedCellsPermission {
1092
- constructor(unitId, subUnitId) {
1093
- __publicField(this, "value", !0);
1094
- __publicField(this, "type", M.Worksheet);
1119
+ __name(_RangeProtectionPermissionEditPoint, "RangeProtectionPermissionEditPoint");
1120
+ let RangeProtectionPermissionEditPoint = _RangeProtectionPermissionEditPoint;
1121
+ const _RangeProtectionPermissionViewPoint = class _RangeProtectionPermissionViewPoint {
1122
+ constructor(unitId, subUnitId, permissionId) {
1123
+ __publicField(this, "type", M.SelectRange);
1124
+ __publicField(this, "subType", P.View);
1095
1125
  __publicField(this, "status", PermissionStatus.INIT);
1126
+ __publicField(this, "value", !0);
1096
1127
  __publicField(this, "id");
1097
- __publicField(this, "subType", P.SelectProtectedCells);
1098
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SelectProtectedCells}_${unitId}_${subUnitId}`;
1128
+ __publicField(this, "unitId");
1129
+ __publicField(this, "subUnitId");
1130
+ __publicField(this, "permissionId");
1131
+ this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${P.View}.${permissionId}`;
1099
1132
  }
1100
1133
  };
1101
- __name(_WorksheetSelectProtectedCellsPermission, "WorksheetSelectProtectedCellsPermission");
1102
- let WorksheetSelectProtectedCellsPermission = _WorksheetSelectProtectedCellsPermission;
1103
- const _WorksheetSelectUnProtectedCellsPermission = class _WorksheetSelectUnProtectedCellsPermission {
1104
- constructor(unitId, subUnitId) {
1134
+ __name(_RangeProtectionPermissionViewPoint, "RangeProtectionPermissionViewPoint");
1135
+ let RangeProtectionPermissionViewPoint = _RangeProtectionPermissionViewPoint;
1136
+ const _WorkbookCommentPermission = class _WorkbookCommentPermission {
1137
+ constructor(unitId) {
1138
+ __publicField(this, "id");
1105
1139
  __publicField(this, "value", !0);
1106
- __publicField(this, "type", M.Worksheet);
1140
+ __publicField(this, "type", M.Workbook);
1107
1141
  __publicField(this, "status", PermissionStatus.INIT);
1108
- __publicField(this, "id");
1109
- __publicField(this, "subType", P.SelectUnProtectedCells);
1110
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SelectUnProtectedCells}_${unitId}_${subUnitId}`;
1142
+ __publicField(this, "subType", P.Comment);
1143
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Comment}_${unitId}`;
1111
1144
  }
1112
1145
  };
1113
- __name(_WorksheetSelectUnProtectedCellsPermission, "WorksheetSelectUnProtectedCellsPermission");
1114
- let WorksheetSelectUnProtectedCellsPermission = _WorksheetSelectUnProtectedCellsPermission;
1115
- const _WorksheetSetCellStylePermission = class _WorksheetSetCellStylePermission {
1116
- constructor(unitId, subUnitId) {
1146
+ __name(_WorkbookCommentPermission, "WorkbookCommentPermission");
1147
+ let WorkbookCommentPermission = _WorkbookCommentPermission;
1148
+ const _WorkbookCopyPermission = class _WorkbookCopyPermission {
1149
+ constructor(unitId) {
1150
+ __publicField(this, "id");
1117
1151
  __publicField(this, "value", !0);
1118
- __publicField(this, "type", M.Worksheet);
1152
+ __publicField(this, "type", M.Workbook);
1119
1153
  __publicField(this, "status", PermissionStatus.INIT);
1120
- __publicField(this, "id");
1121
- __publicField(this, "subType", P.SetCellStyle);
1122
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetCellStyle}_${unitId}_${subUnitId}`;
1154
+ __publicField(this, "subType", P.Copy);
1155
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Copy}_${unitId}`;
1123
1156
  }
1124
1157
  };
1125
- __name(_WorksheetSetCellStylePermission, "WorksheetSetCellStylePermission");
1126
- let WorksheetSetCellStylePermission = _WorksheetSetCellStylePermission;
1127
- const _WorksheetSetCellValuePermission = class _WorksheetSetCellValuePermission {
1128
- constructor(unitId, subUnitId) {
1158
+ __name(_WorkbookCopyPermission, "WorkbookCopyPermission");
1159
+ let WorkbookCopyPermission = _WorkbookCopyPermission;
1160
+ const _WorkbookCopySheetPermission = class _WorkbookCopySheetPermission {
1161
+ constructor(unitId) {
1162
+ __publicField(this, "id");
1129
1163
  __publicField(this, "value", !0);
1130
- __publicField(this, "type", M.Worksheet);
1164
+ __publicField(this, "type", M.Workbook);
1165
+ __publicField(this, "subType", P.CopySheet);
1131
1166
  __publicField(this, "status", PermissionStatus.INIT);
1132
- __publicField(this, "id");
1133
- __publicField(this, "subType", P.SetCellValue);
1134
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetCellValue}_${unitId}_${subUnitId}`;
1167
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CopySheet}_${unitId}`;
1135
1168
  }
1136
1169
  };
1137
- __name(_WorksheetSetCellValuePermission, "WorksheetSetCellValuePermission");
1138
- let WorksheetSetCellValuePermission = _WorksheetSetCellValuePermission;
1139
- const _WorksheetViewPermission = class _WorksheetViewPermission {
1140
- constructor(unitId, subUnitId) {
1170
+ __name(_WorkbookCopySheetPermission, "WorkbookCopySheetPermission");
1171
+ let WorkbookCopySheetPermission = _WorkbookCopySheetPermission;
1172
+ const _WorkbookCreateSheetPermission = class _WorkbookCreateSheetPermission {
1173
+ constructor(unitId) {
1174
+ __publicField(this, "id");
1141
1175
  __publicField(this, "value", !0);
1142
- __publicField(this, "type", M.Worksheet);
1176
+ __publicField(this, "type", M.Workbook);
1143
1177
  __publicField(this, "status", PermissionStatus.INIT);
1144
- __publicField(this, "id");
1145
- __publicField(this, "subType", P.View);
1146
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.View}_${unitId}_${subUnitId}`;
1178
+ __publicField(this, "subType", P.CreateSheet);
1179
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CreateSheet}_${unitId}`;
1147
1180
  }
1148
1181
  };
1149
- __name(_WorksheetViewPermission, "WorksheetViewPermission");
1150
- let WorksheetViewPermission = _WorksheetViewPermission;
1151
- const _WorksheetSetRowStylePermission = class _WorksheetSetRowStylePermission {
1152
- constructor(unitId, subUnitId) {
1182
+ __name(_WorkbookCreateSheetPermission, "WorkbookCreateSheetPermission");
1183
+ let WorkbookCreateSheetPermission = _WorkbookCreateSheetPermission;
1184
+ const _WorkbookDeleteSheetPermission = class _WorkbookDeleteSheetPermission {
1185
+ constructor(unitId) {
1186
+ __publicField(this, "id");
1153
1187
  __publicField(this, "value", !0);
1154
- __publicField(this, "type", M.Worksheet);
1188
+ __publicField(this, "type", M.Workbook);
1155
1189
  __publicField(this, "status", PermissionStatus.INIT);
1156
- __publicField(this, "id");
1157
- __publicField(this, "subType", P.SetRowStyle);
1158
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetRowStyle}_${unitId}_${subUnitId}`;
1190
+ __publicField(this, "subType", P.DeleteSheet);
1191
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.DeleteSheet}_${unitId}`;
1159
1192
  }
1160
1193
  };
1161
- __name(_WorksheetSetRowStylePermission, "WorksheetSetRowStylePermission");
1162
- let WorksheetSetRowStylePermission = _WorksheetSetRowStylePermission;
1163
- const _WorksheetSetColumnStylePermission = class _WorksheetSetColumnStylePermission {
1164
- constructor(unitId, subUnitId) {
1194
+ __name(_WorkbookDeleteSheetPermission, "WorkbookDeleteSheetPermission");
1195
+ let WorkbookDeleteSheetPermission = _WorkbookDeleteSheetPermission;
1196
+ const _WorkbookDuplicatePermission = class _WorkbookDuplicatePermission {
1197
+ constructor(unitId) {
1198
+ __publicField(this, "id");
1165
1199
  __publicField(this, "value", !0);
1166
- __publicField(this, "type", M.Worksheet);
1200
+ __publicField(this, "type", M.Workbook);
1167
1201
  __publicField(this, "status", PermissionStatus.INIT);
1168
- __publicField(this, "id");
1169
- __publicField(this, "subType", P.SetColumnStyle);
1170
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetColumnStyle}_${unitId}_${subUnitId}`;
1202
+ __publicField(this, "subType", P.Duplicate);
1203
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Duplicate}_${unitId}`;
1171
1204
  }
1172
1205
  };
1173
- __name(_WorksheetSetColumnStylePermission, "WorksheetSetColumnStylePermission");
1174
- let WorksheetSetColumnStylePermission = _WorksheetSetColumnStylePermission;
1175
- const _WorksheetInsertRowPermission = class _WorksheetInsertRowPermission {
1176
- constructor(unitId, subUnitId) {
1206
+ __name(_WorkbookDuplicatePermission, "WorkbookDuplicatePermission");
1207
+ let WorkbookDuplicatePermission = _WorkbookDuplicatePermission;
1208
+ const _WorkbookEditablePermission = class _WorkbookEditablePermission {
1209
+ constructor(unitId) {
1210
+ __publicField(this, "id");
1177
1211
  __publicField(this, "value", !0);
1178
- __publicField(this, "type", M.Worksheet);
1212
+ __publicField(this, "type", M.Workbook);
1179
1213
  __publicField(this, "status", PermissionStatus.INIT);
1180
- __publicField(this, "id");
1181
- __publicField(this, "subType", P.InsertRow);
1182
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertRow}_${unitId}_${subUnitId}`;
1214
+ __publicField(this, "subType", P.Edit);
1215
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Edit}_${unitId}`;
1183
1216
  }
1184
1217
  };
1185
- __name(_WorksheetInsertRowPermission, "WorksheetInsertRowPermission");
1186
- let WorksheetInsertRowPermission = _WorksheetInsertRowPermission;
1187
- const _WorksheetInsertColumnPermission = class _WorksheetInsertColumnPermission {
1188
- constructor(unitId, subUnitId) {
1218
+ __name(_WorkbookEditablePermission, "WorkbookEditablePermission");
1219
+ let WorkbookEditablePermission = _WorkbookEditablePermission;
1220
+ const _WorkbookExportPermission = class _WorkbookExportPermission {
1221
+ constructor(unitId) {
1222
+ __publicField(this, "id");
1189
1223
  __publicField(this, "value", !0);
1190
- __publicField(this, "type", M.Worksheet);
1224
+ __publicField(this, "type", M.Workbook);
1191
1225
  __publicField(this, "status", PermissionStatus.INIT);
1192
- __publicField(this, "id");
1193
- __publicField(this, "subType", P.InsertColumn);
1194
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertColumn}_${unitId}_${subUnitId}`;
1226
+ __publicField(this, "subType", P.Export);
1227
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Export}_${unitId}`;
1195
1228
  }
1196
1229
  };
1197
- __name(_WorksheetInsertColumnPermission, "WorksheetInsertColumnPermission");
1198
- let WorksheetInsertColumnPermission = _WorksheetInsertColumnPermission;
1199
- const _WorksheetInsertHyperlinkPermission = class _WorksheetInsertHyperlinkPermission {
1200
- constructor(unitId, subUnitId) {
1230
+ __name(_WorkbookExportPermission, "WorkbookExportPermission");
1231
+ let WorkbookExportPermission = _WorkbookExportPermission;
1232
+ const _WorkbookHideSheetPermission = class _WorkbookHideSheetPermission {
1233
+ constructor(unitId) {
1234
+ __publicField(this, "id");
1201
1235
  __publicField(this, "value", !0);
1202
- __publicField(this, "type", M.Worksheet);
1236
+ __publicField(this, "type", M.Workbook);
1203
1237
  __publicField(this, "status", PermissionStatus.INIT);
1204
- __publicField(this, "id");
1205
- __publicField(this, "subType", P.InsertHyperlink);
1206
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertHyperlink}_${unitId}_${subUnitId}`;
1238
+ __publicField(this, "subType", P.HideSheet);
1239
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.HideSheet}_${unitId}`;
1207
1240
  }
1208
1241
  };
1209
- __name(_WorksheetInsertHyperlinkPermission, "WorksheetInsertHyperlinkPermission");
1210
- let WorksheetInsertHyperlinkPermission = _WorksheetInsertHyperlinkPermission;
1211
- const _WorksheetDeleteRowPermission = class _WorksheetDeleteRowPermission {
1212
- constructor(unitId, subUnitId) {
1242
+ __name(_WorkbookHideSheetPermission, "WorkbookHideSheetPermission");
1243
+ let WorkbookHideSheetPermission = _WorkbookHideSheetPermission;
1244
+ const _WorkbookHistoryPermission = class _WorkbookHistoryPermission {
1245
+ constructor(unitId) {
1246
+ __publicField(this, "id");
1213
1247
  __publicField(this, "value", !0);
1214
- __publicField(this, "type", M.Worksheet);
1248
+ __publicField(this, "type", M.Workbook);
1215
1249
  __publicField(this, "status", PermissionStatus.INIT);
1216
- __publicField(this, "id");
1217
- __publicField(this, "subType", P.DeleteRow);
1218
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.DeleteRow}_${unitId}_${subUnitId}`;
1250
+ __publicField(this, "subType", P.History);
1251
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.History}_${unitId}`;
1219
1252
  }
1220
1253
  };
1221
- __name(_WorksheetDeleteRowPermission, "WorksheetDeleteRowPermission");
1222
- let WorksheetDeleteRowPermission = _WorksheetDeleteRowPermission;
1223
- const _WorksheetDeleteColumnPermission = class _WorksheetDeleteColumnPermission {
1224
- constructor(unitId, subUnitId) {
1254
+ __name(_WorkbookHistoryPermission, "WorkbookHistoryPermission");
1255
+ let WorkbookHistoryPermission = _WorkbookHistoryPermission;
1256
+ const _WorkbookManageCollaboratorPermission = class _WorkbookManageCollaboratorPermission {
1257
+ constructor(unitId) {
1258
+ __publicField(this, "id");
1225
1259
  __publicField(this, "value", !0);
1226
- __publicField(this, "type", M.Worksheet);
1260
+ __publicField(this, "type", M.Workbook);
1227
1261
  __publicField(this, "status", PermissionStatus.INIT);
1228
- __publicField(this, "id");
1229
- __publicField(this, "subType", P.DeleteColumn);
1230
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.DeleteColumn}_${unitId}_${subUnitId}`;
1262
+ __publicField(this, "subType", P.ManageCollaborator);
1263
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}`;
1231
1264
  }
1232
1265
  };
1233
- __name(_WorksheetDeleteColumnPermission, "WorksheetDeleteColumnPermission");
1234
- let WorksheetDeleteColumnPermission = _WorksheetDeleteColumnPermission;
1235
- const _WorksheetSortPermission = class _WorksheetSortPermission {
1236
- constructor(unitId, subUnitId) {
1266
+ __name(_WorkbookManageCollaboratorPermission, "WorkbookManageCollaboratorPermission");
1267
+ let WorkbookManageCollaboratorPermission = _WorkbookManageCollaboratorPermission;
1268
+ const _WorkbookMoveSheetPermission = class _WorkbookMoveSheetPermission {
1269
+ constructor(unitId) {
1270
+ __publicField(this, "id");
1237
1271
  __publicField(this, "value", !0);
1238
- __publicField(this, "type", M.Worksheet);
1272
+ __publicField(this, "type", M.Workbook);
1239
1273
  __publicField(this, "status", PermissionStatus.INIT);
1240
- __publicField(this, "id");
1241
- __publicField(this, "subType", P.Sort);
1242
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Sort}_${unitId}_${subUnitId}`;
1243
- }
1244
- };
1245
- __name(_WorksheetSortPermission, "WorksheetSortPermission");
1246
- let WorksheetSortPermission = _WorksheetSortPermission;
1247
- const _WorksheetFilterPermission = class _WorksheetFilterPermission {
1248
- constructor(unitId, subUnitId) {
1249
- __publicField(this, "value", !0);
1250
- __publicField(this, "type", M.Worksheet);
1251
- __publicField(this, "status", PermissionStatus.INIT);
1252
- __publicField(this, "id");
1253
- __publicField(this, "subType", P.Filter);
1254
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Filter}_${unitId}_${subUnitId}`;
1255
- }
1256
- };
1257
- __name(_WorksheetFilterPermission, "WorksheetFilterPermission");
1258
- let WorksheetFilterPermission = _WorksheetFilterPermission;
1259
- const _WorksheetPivotTablePermission = class _WorksheetPivotTablePermission {
1260
- constructor(unitId, subUnitId) {
1261
- __publicField(this, "value", !0);
1262
- __publicField(this, "type", M.Worksheet);
1263
- __publicField(this, "status", PermissionStatus.INIT);
1264
- __publicField(this, "id");
1265
- __publicField(this, "subType", P.PivotTable);
1266
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.PivotTable}_${unitId}_${subUnitId}`;
1267
- }
1268
- };
1269
- __name(_WorksheetPivotTablePermission, "WorksheetPivotTablePermission");
1270
- let WorksheetPivotTablePermission = _WorksheetPivotTablePermission;
1271
- const _WorksheetEditExtraObjectPermission = class _WorksheetEditExtraObjectPermission {
1272
- constructor(unitId, subUnitId) {
1273
- __publicField(this, "value", !0);
1274
- __publicField(this, "type", M.Worksheet);
1275
- __publicField(this, "status", PermissionStatus.INIT);
1276
- __publicField(this, "id");
1277
- __publicField(this, "subType", P.EditExtraObject);
1278
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.EditExtraObject}_${unitId}_${subUnitId}`;
1279
- }
1280
- };
1281
- __name(_WorksheetEditExtraObjectPermission, "WorksheetEditExtraObjectPermission");
1282
- let WorksheetEditExtraObjectPermission = _WorksheetEditExtraObjectPermission;
1283
- const _WorksheetManageCollaboratorPermission = class _WorksheetManageCollaboratorPermission {
1284
- constructor(unitId, subUnitId) {
1285
- __publicField(this, "value", !0);
1286
- __publicField(this, "type", M.Worksheet);
1287
- __publicField(this, "status", PermissionStatus.INIT);
1288
- __publicField(this, "id");
1289
- __publicField(this, "subType", P.ManageCollaborator);
1290
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}_${subUnitId}`;
1291
- }
1292
- };
1293
- __name(_WorksheetManageCollaboratorPermission, "WorksheetManageCollaboratorPermission");
1294
- let WorksheetManageCollaboratorPermission = _WorksheetManageCollaboratorPermission;
1295
- const _WorksheetEditPermission = class _WorksheetEditPermission {
1296
- constructor(unitId, subUnitId) {
1297
- __publicField(this, "value", !0);
1298
- __publicField(this, "type", M.Worksheet);
1299
- __publicField(this, "status", PermissionStatus.INIT);
1300
- __publicField(this, "id");
1301
- __publicField(this, "subType", P.Edit);
1302
- this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Edit}_${unitId}_${subUnitId}`;
1303
- }
1304
- };
1305
- __name(_WorksheetEditPermission, "WorksheetEditPermission");
1306
- let WorksheetEditPermission = _WorksheetEditPermission;
1307
- const _WorkbookCommentPermission = class _WorkbookCommentPermission {
1308
- constructor(unitId) {
1309
- __publicField(this, "id");
1310
- __publicField(this, "value", !0);
1311
- __publicField(this, "type", M.Workbook);
1312
- __publicField(this, "status", PermissionStatus.INIT);
1313
- __publicField(this, "subType", P.Comment);
1314
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Comment}_${unitId}`;
1315
- }
1316
- };
1317
- __name(_WorkbookCommentPermission, "WorkbookCommentPermission");
1318
- let WorkbookCommentPermission = _WorkbookCommentPermission;
1319
- const _WorkbookEditablePermission = class _WorkbookEditablePermission {
1320
- constructor(unitId) {
1321
- __publicField(this, "id");
1322
- __publicField(this, "value", !0);
1323
- __publicField(this, "type", M.Workbook);
1324
- __publicField(this, "status", PermissionStatus.INIT);
1325
- __publicField(this, "subType", P.Edit);
1326
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Edit}_${unitId}`;
1327
- }
1328
- };
1329
- __name(_WorkbookEditablePermission, "WorkbookEditablePermission");
1330
- let WorkbookEditablePermission = _WorkbookEditablePermission;
1331
- const _WorkbookDuplicatePermission = class _WorkbookDuplicatePermission {
1332
- constructor(unitId) {
1333
- __publicField(this, "id");
1334
- __publicField(this, "value", !0);
1335
- __publicField(this, "type", M.Workbook);
1336
- __publicField(this, "status", PermissionStatus.INIT);
1337
- __publicField(this, "subType", P.Duplicate);
1338
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Duplicate}_${unitId}`;
1274
+ __publicField(this, "subType", P.MoveSheet);
1275
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.MoveSheet}_${unitId}`;
1339
1276
  }
1340
1277
  };
1341
- __name(_WorkbookDuplicatePermission, "WorkbookDuplicatePermission");
1342
- let WorkbookDuplicatePermission = _WorkbookDuplicatePermission;
1278
+ __name(_WorkbookMoveSheetPermission, "WorkbookMoveSheetPermission");
1279
+ let WorkbookMoveSheetPermission = _WorkbookMoveSheetPermission;
1343
1280
  const _WorkbookPrintPermission = class _WorkbookPrintPermission {
1344
1281
  constructor(unitId) {
1345
1282
  __publicField(this, "id");
@@ -1352,54 +1289,18 @@ const _WorkbookPrintPermission = class _WorkbookPrintPermission {
1352
1289
  };
1353
1290
  __name(_WorkbookPrintPermission, "WorkbookPrintPermission");
1354
1291
  let WorkbookPrintPermission = _WorkbookPrintPermission;
1355
- const _WorkbookExportPermission = class _WorkbookExportPermission {
1356
- constructor(unitId) {
1357
- __publicField(this, "id");
1358
- __publicField(this, "value", !0);
1359
- __publicField(this, "type", M.Workbook);
1360
- __publicField(this, "status", PermissionStatus.INIT);
1361
- __publicField(this, "subType", P.Export);
1362
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Export}_${unitId}`;
1363
- }
1364
- };
1365
- __name(_WorkbookExportPermission, "WorkbookExportPermission");
1366
- let WorkbookExportPermission = _WorkbookExportPermission;
1367
- const _WorkbookMoveSheetPermission = class _WorkbookMoveSheetPermission {
1368
- constructor(unitId) {
1369
- __publicField(this, "id");
1370
- __publicField(this, "value", !0);
1371
- __publicField(this, "type", M.Workbook);
1372
- __publicField(this, "status", PermissionStatus.INIT);
1373
- __publicField(this, "subType", P.MoveSheet);
1374
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.MoveSheet}_${unitId}`;
1375
- }
1376
- };
1377
- __name(_WorkbookMoveSheetPermission, "WorkbookMoveSheetPermission");
1378
- let WorkbookMoveSheetPermission = _WorkbookMoveSheetPermission;
1379
- const _WorkbookDeleteSheetPermission = class _WorkbookDeleteSheetPermission {
1380
- constructor(unitId) {
1381
- __publicField(this, "id");
1382
- __publicField(this, "value", !0);
1383
- __publicField(this, "type", M.Workbook);
1384
- __publicField(this, "status", PermissionStatus.INIT);
1385
- __publicField(this, "subType", P.DeleteSheet);
1386
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.DeleteSheet}_${unitId}`;
1387
- }
1388
- };
1389
- __name(_WorkbookDeleteSheetPermission, "WorkbookDeleteSheetPermission");
1390
- let WorkbookDeleteSheetPermission = _WorkbookDeleteSheetPermission;
1391
- const _WorkbookHideSheetPermission = class _WorkbookHideSheetPermission {
1292
+ const _WorkbookRecoverHistoryPermission = class _WorkbookRecoverHistoryPermission {
1392
1293
  constructor(unitId) {
1393
1294
  __publicField(this, "id");
1394
1295
  __publicField(this, "value", !0);
1395
1296
  __publicField(this, "type", M.Workbook);
1396
1297
  __publicField(this, "status", PermissionStatus.INIT);
1397
- __publicField(this, "subType", P.HideSheet);
1398
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.HideSheet}_${unitId}`;
1298
+ __publicField(this, "subType", P.RecoverHistory);
1299
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.RecoverHistory}_${unitId}`;
1399
1300
  }
1400
1301
  };
1401
- __name(_WorkbookHideSheetPermission, "WorkbookHideSheetPermission");
1402
- let WorkbookHideSheetPermission = _WorkbookHideSheetPermission;
1302
+ __name(_WorkbookRecoverHistoryPermission, "WorkbookRecoverHistoryPermission");
1303
+ let WorkbookRecoverHistoryPermission = _WorkbookRecoverHistoryPermission;
1403
1304
  const _WorkbookRenameSheetPermission = class _WorkbookRenameSheetPermission {
1404
1305
  constructor(unitId) {
1405
1306
  __publicField(this, "id");
@@ -1412,30 +1313,18 @@ const _WorkbookRenameSheetPermission = class _WorkbookRenameSheetPermission {
1412
1313
  };
1413
1314
  __name(_WorkbookRenameSheetPermission, "WorkbookRenameSheetPermission");
1414
1315
  let WorkbookRenameSheetPermission = _WorkbookRenameSheetPermission;
1415
- const _WorkbookCreateSheetPermission = class _WorkbookCreateSheetPermission {
1416
- constructor(unitId) {
1417
- __publicField(this, "id");
1418
- __publicField(this, "value", !0);
1419
- __publicField(this, "type", M.Workbook);
1420
- __publicField(this, "status", PermissionStatus.INIT);
1421
- __publicField(this, "subType", P.CreateSheet);
1422
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CreateSheet}_${unitId}`;
1423
- }
1424
- };
1425
- __name(_WorkbookCreateSheetPermission, "WorkbookCreateSheetPermission");
1426
- let WorkbookCreateSheetPermission = _WorkbookCreateSheetPermission;
1427
- const _WorkbookHistoryPermission = class _WorkbookHistoryPermission {
1316
+ const _WorkbookSharePermission = class _WorkbookSharePermission {
1428
1317
  constructor(unitId) {
1429
1318
  __publicField(this, "id");
1430
1319
  __publicField(this, "value", !0);
1431
1320
  __publicField(this, "type", M.Workbook);
1432
1321
  __publicField(this, "status", PermissionStatus.INIT);
1433
- __publicField(this, "subType", P.History);
1434
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.History}_${unitId}`;
1322
+ __publicField(this, "subType", P.Share);
1323
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Share}_${unitId}`;
1435
1324
  }
1436
1325
  };
1437
- __name(_WorkbookHistoryPermission, "WorkbookHistoryPermission");
1438
- let WorkbookHistoryPermission = _WorkbookHistoryPermission;
1326
+ __name(_WorkbookSharePermission, "WorkbookSharePermission");
1327
+ let WorkbookSharePermission = _WorkbookSharePermission;
1439
1328
  const _WorkbookViewPermission = class _WorkbookViewPermission {
1440
1329
  constructor(unitId) {
1441
1330
  __publicField(this, "id");
@@ -1448,123 +1337,255 @@ const _WorkbookViewPermission = class _WorkbookViewPermission {
1448
1337
  };
1449
1338
  __name(_WorkbookViewPermission, "WorkbookViewPermission");
1450
1339
  let WorkbookViewPermission = _WorkbookViewPermission;
1451
- const _WorkbookSharePermission = class _WorkbookSharePermission {
1340
+ const _WorkbookViewHistoryPermission = class _WorkbookViewHistoryPermission {
1452
1341
  constructor(unitId) {
1453
1342
  __publicField(this, "id");
1454
1343
  __publicField(this, "value", !0);
1455
1344
  __publicField(this, "type", M.Workbook);
1456
1345
  __publicField(this, "status", PermissionStatus.INIT);
1457
- __publicField(this, "subType", P.Share);
1458
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Share}_${unitId}`;
1346
+ __publicField(this, "subType", P.ViewHistory);
1347
+ this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ViewHistory}_${unitId}`;
1459
1348
  }
1460
1349
  };
1461
- __name(_WorkbookSharePermission, "WorkbookSharePermission");
1462
- let WorkbookSharePermission = _WorkbookSharePermission;
1463
- const _WorkbookCopyPermission = class _WorkbookCopyPermission {
1464
- constructor(unitId) {
1465
- __publicField(this, "id");
1350
+ __name(_WorkbookViewHistoryPermission, "WorkbookViewHistoryPermission");
1351
+ let WorkbookViewHistoryPermission = _WorkbookViewHistoryPermission;
1352
+ const _WorksheetCopyPermission = class _WorksheetCopyPermission {
1353
+ constructor(unitId, subUnitId) {
1466
1354
  __publicField(this, "value", !0);
1467
- __publicField(this, "type", M.Workbook);
1355
+ __publicField(this, "type", M.Worksheet);
1468
1356
  __publicField(this, "status", PermissionStatus.INIT);
1357
+ __publicField(this, "id");
1469
1358
  __publicField(this, "subType", P.Copy);
1470
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.Copy}_${unitId}`;
1359
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Copy}_${unitId}_${subUnitId}`;
1471
1360
  }
1472
1361
  };
1473
- __name(_WorkbookCopyPermission, "WorkbookCopyPermission");
1474
- let WorkbookCopyPermission = _WorkbookCopyPermission;
1475
- const _WorkbookCopySheetPermission = class _WorkbookCopySheetPermission {
1476
- constructor(unitId) {
1477
- __publicField(this, "id");
1362
+ __name(_WorksheetCopyPermission, "WorksheetCopyPermission");
1363
+ let WorksheetCopyPermission = _WorksheetCopyPermission;
1364
+ const _WorksheetDeleteColumnPermission = class _WorksheetDeleteColumnPermission {
1365
+ constructor(unitId, subUnitId) {
1478
1366
  __publicField(this, "value", !0);
1479
- __publicField(this, "type", M.Workbook);
1480
- __publicField(this, "subType", P.CopySheet);
1367
+ __publicField(this, "type", M.Worksheet);
1481
1368
  __publicField(this, "status", PermissionStatus.INIT);
1482
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.CopySheet}_${unitId}`;
1369
+ __publicField(this, "id");
1370
+ __publicField(this, "subType", P.DeleteColumn);
1371
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.DeleteColumn}_${unitId}_${subUnitId}`;
1483
1372
  }
1484
1373
  };
1485
- __name(_WorkbookCopySheetPermission, "WorkbookCopySheetPermission");
1486
- let WorkbookCopySheetPermission = _WorkbookCopySheetPermission;
1487
- const _WorkbookManageCollaboratorPermission = class _WorkbookManageCollaboratorPermission {
1488
- constructor(unitId) {
1489
- __publicField(this, "id");
1374
+ __name(_WorksheetDeleteColumnPermission, "WorksheetDeleteColumnPermission");
1375
+ let WorksheetDeleteColumnPermission = _WorksheetDeleteColumnPermission;
1376
+ const _WorksheetDeleteRowPermission = class _WorksheetDeleteRowPermission {
1377
+ constructor(unitId, subUnitId) {
1490
1378
  __publicField(this, "value", !0);
1491
- __publicField(this, "type", M.Workbook);
1379
+ __publicField(this, "type", M.Worksheet);
1492
1380
  __publicField(this, "status", PermissionStatus.INIT);
1493
- __publicField(this, "subType", P.ManageCollaborator);
1494
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}`;
1381
+ __publicField(this, "id");
1382
+ __publicField(this, "subType", P.DeleteRow);
1383
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.DeleteRow}_${unitId}_${subUnitId}`;
1495
1384
  }
1496
1385
  };
1497
- __name(_WorkbookManageCollaboratorPermission, "WorkbookManageCollaboratorPermission");
1498
- let WorkbookManageCollaboratorPermission = _WorkbookManageCollaboratorPermission;
1499
- const _WorkbookViewHistoryPermission = class _WorkbookViewHistoryPermission {
1500
- constructor(unitId) {
1501
- __publicField(this, "id");
1386
+ __name(_WorksheetDeleteRowPermission, "WorksheetDeleteRowPermission");
1387
+ let WorksheetDeleteRowPermission = _WorksheetDeleteRowPermission;
1388
+ const _WorksheetEditPermission = class _WorksheetEditPermission {
1389
+ constructor(unitId, subUnitId) {
1502
1390
  __publicField(this, "value", !0);
1503
- __publicField(this, "type", M.Workbook);
1391
+ __publicField(this, "type", M.Worksheet);
1504
1392
  __publicField(this, "status", PermissionStatus.INIT);
1505
- __publicField(this, "subType", P.ViewHistory);
1506
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.ViewHistory}_${unitId}`;
1393
+ __publicField(this, "id");
1394
+ __publicField(this, "subType", P.Edit);
1395
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Edit}_${unitId}_${subUnitId}`;
1507
1396
  }
1508
1397
  };
1509
- __name(_WorkbookViewHistoryPermission, "WorkbookViewHistoryPermission");
1510
- let WorkbookViewHistoryPermission = _WorkbookViewHistoryPermission;
1511
- const _WorkbookRecoverHistoryPermission = class _WorkbookRecoverHistoryPermission {
1512
- constructor(unitId) {
1513
- __publicField(this, "id");
1398
+ __name(_WorksheetEditPermission, "WorksheetEditPermission");
1399
+ let WorksheetEditPermission = _WorksheetEditPermission;
1400
+ const _WorksheetEditExtraObjectPermission = class _WorksheetEditExtraObjectPermission {
1401
+ constructor(unitId, subUnitId) {
1514
1402
  __publicField(this, "value", !0);
1515
- __publicField(this, "type", M.Workbook);
1403
+ __publicField(this, "type", M.Worksheet);
1516
1404
  __publicField(this, "status", PermissionStatus.INIT);
1517
- __publicField(this, "subType", P.RecoverHistory);
1518
- this.unitId = unitId, this.unitId = unitId, this.id = `${this.type}.${P.RecoverHistory}_${unitId}`;
1405
+ __publicField(this, "id");
1406
+ __publicField(this, "subType", P.EditExtraObject);
1407
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.EditExtraObject}_${unitId}_${subUnitId}`;
1519
1408
  }
1520
1409
  };
1521
- __name(_WorkbookRecoverHistoryPermission, "WorkbookRecoverHistoryPermission");
1522
- let WorkbookRecoverHistoryPermission = _WorkbookRecoverHistoryPermission;
1523
- const _RangeProtectionPermissionEditPoint = class _RangeProtectionPermissionEditPoint {
1524
- constructor(unitId, subUnitId, permissionId) {
1525
- __publicField(this, "type", M.SelectRange);
1526
- __publicField(this, "subType", P.Edit);
1410
+ __name(_WorksheetEditExtraObjectPermission, "WorksheetEditExtraObjectPermission");
1411
+ let WorksheetEditExtraObjectPermission = _WorksheetEditExtraObjectPermission;
1412
+ const _WorksheetFilterPermission = class _WorksheetFilterPermission {
1413
+ constructor(unitId, subUnitId) {
1414
+ __publicField(this, "value", !0);
1415
+ __publicField(this, "type", M.Worksheet);
1527
1416
  __publicField(this, "status", PermissionStatus.INIT);
1417
+ __publicField(this, "id");
1418
+ __publicField(this, "subType", P.Filter);
1419
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Filter}_${unitId}_${subUnitId}`;
1420
+ }
1421
+ };
1422
+ __name(_WorksheetFilterPermission, "WorksheetFilterPermission");
1423
+ let WorksheetFilterPermission = _WorksheetFilterPermission;
1424
+ const _WorksheetInsertColumnPermission = class _WorksheetInsertColumnPermission {
1425
+ constructor(unitId, subUnitId) {
1528
1426
  __publicField(this, "value", !0);
1427
+ __publicField(this, "type", M.Worksheet);
1428
+ __publicField(this, "status", PermissionStatus.INIT);
1529
1429
  __publicField(this, "id");
1530
- __publicField(this, "unitId");
1531
- __publicField(this, "subUnitId");
1532
- __publicField(this, "permissionId");
1533
- this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${P.Edit}.${permissionId}`;
1430
+ __publicField(this, "subType", P.InsertColumn);
1431
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertColumn}_${unitId}_${subUnitId}`;
1534
1432
  }
1535
1433
  };
1536
- __name(_RangeProtectionPermissionEditPoint, "RangeProtectionPermissionEditPoint");
1537
- let RangeProtectionPermissionEditPoint = _RangeProtectionPermissionEditPoint;
1538
- const _RangeProtectionPermissionViewPoint = class _RangeProtectionPermissionViewPoint {
1539
- constructor(unitId, subUnitId, permissionId) {
1540
- __publicField(this, "type", M.SelectRange);
1541
- __publicField(this, "subType", P.View);
1434
+ __name(_WorksheetInsertColumnPermission, "WorksheetInsertColumnPermission");
1435
+ let WorksheetInsertColumnPermission = _WorksheetInsertColumnPermission;
1436
+ const _WorksheetInsertHyperlinkPermission = class _WorksheetInsertHyperlinkPermission {
1437
+ constructor(unitId, subUnitId) {
1438
+ __publicField(this, "value", !0);
1439
+ __publicField(this, "type", M.Worksheet);
1542
1440
  __publicField(this, "status", PermissionStatus.INIT);
1441
+ __publicField(this, "id");
1442
+ __publicField(this, "subType", P.InsertHyperlink);
1443
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertHyperlink}_${unitId}_${subUnitId}`;
1444
+ }
1445
+ };
1446
+ __name(_WorksheetInsertHyperlinkPermission, "WorksheetInsertHyperlinkPermission");
1447
+ let WorksheetInsertHyperlinkPermission = _WorksheetInsertHyperlinkPermission;
1448
+ const _WorksheetInsertRowPermission = class _WorksheetInsertRowPermission {
1449
+ constructor(unitId, subUnitId) {
1543
1450
  __publicField(this, "value", !0);
1451
+ __publicField(this, "type", M.Worksheet);
1452
+ __publicField(this, "status", PermissionStatus.INIT);
1544
1453
  __publicField(this, "id");
1545
- __publicField(this, "unitId");
1546
- __publicField(this, "subUnitId");
1547
- __publicField(this, "permissionId");
1548
- this.unitId = unitId, this.subUnitId = subUnitId, this.permissionId = permissionId, this.id = `${M.SelectRange}.${P.View}.${permissionId}`;
1454
+ __publicField(this, "subType", P.InsertRow);
1455
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.InsertRow}_${unitId}_${subUnitId}`;
1549
1456
  }
1550
1457
  };
1551
- __name(_RangeProtectionPermissionViewPoint, "RangeProtectionPermissionViewPoint");
1552
- let RangeProtectionPermissionViewPoint = _RangeProtectionPermissionViewPoint;
1458
+ __name(_WorksheetInsertRowPermission, "WorksheetInsertRowPermission");
1459
+ let WorksheetInsertRowPermission = _WorksheetInsertRowPermission;
1460
+ const _WorksheetManageCollaboratorPermission = class _WorksheetManageCollaboratorPermission {
1461
+ constructor(unitId, subUnitId) {
1462
+ __publicField(this, "value", !0);
1463
+ __publicField(this, "type", M.Worksheet);
1464
+ __publicField(this, "status", PermissionStatus.INIT);
1465
+ __publicField(this, "id");
1466
+ __publicField(this, "subType", P.ManageCollaborator);
1467
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.ManageCollaborator}_${unitId}_${subUnitId}`;
1468
+ }
1469
+ };
1470
+ __name(_WorksheetManageCollaboratorPermission, "WorksheetManageCollaboratorPermission");
1471
+ let WorksheetManageCollaboratorPermission = _WorksheetManageCollaboratorPermission;
1472
+ const _WorksheetPivotTablePermission = class _WorksheetPivotTablePermission {
1473
+ constructor(unitId, subUnitId) {
1474
+ __publicField(this, "value", !0);
1475
+ __publicField(this, "type", M.Worksheet);
1476
+ __publicField(this, "status", PermissionStatus.INIT);
1477
+ __publicField(this, "id");
1478
+ __publicField(this, "subType", P.PivotTable);
1479
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.PivotTable}_${unitId}_${subUnitId}`;
1480
+ }
1481
+ };
1482
+ __name(_WorksheetPivotTablePermission, "WorksheetPivotTablePermission");
1483
+ let WorksheetPivotTablePermission = _WorksheetPivotTablePermission;
1484
+ const _WorksheetSelectProtectedCellsPermission = class _WorksheetSelectProtectedCellsPermission {
1485
+ constructor(unitId, subUnitId) {
1486
+ __publicField(this, "value", !0);
1487
+ __publicField(this, "type", M.Worksheet);
1488
+ __publicField(this, "status", PermissionStatus.INIT);
1489
+ __publicField(this, "id");
1490
+ __publicField(this, "subType", P.SelectProtectedCells);
1491
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SelectProtectedCells}_${unitId}_${subUnitId}`;
1492
+ }
1493
+ };
1494
+ __name(_WorksheetSelectProtectedCellsPermission, "WorksheetSelectProtectedCellsPermission");
1495
+ let WorksheetSelectProtectedCellsPermission = _WorksheetSelectProtectedCellsPermission;
1496
+ const _WorksheetSelectUnProtectedCellsPermission = class _WorksheetSelectUnProtectedCellsPermission {
1497
+ constructor(unitId, subUnitId) {
1498
+ __publicField(this, "value", !0);
1499
+ __publicField(this, "type", M.Worksheet);
1500
+ __publicField(this, "status", PermissionStatus.INIT);
1501
+ __publicField(this, "id");
1502
+ __publicField(this, "subType", P.SelectUnProtectedCells);
1503
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SelectUnProtectedCells}_${unitId}_${subUnitId}`;
1504
+ }
1505
+ };
1506
+ __name(_WorksheetSelectUnProtectedCellsPermission, "WorksheetSelectUnProtectedCellsPermission");
1507
+ let WorksheetSelectUnProtectedCellsPermission = _WorksheetSelectUnProtectedCellsPermission;
1508
+ const _WorksheetSetCellStylePermission = class _WorksheetSetCellStylePermission {
1509
+ constructor(unitId, subUnitId) {
1510
+ __publicField(this, "value", !0);
1511
+ __publicField(this, "type", M.Worksheet);
1512
+ __publicField(this, "status", PermissionStatus.INIT);
1513
+ __publicField(this, "id");
1514
+ __publicField(this, "subType", P.SetCellStyle);
1515
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetCellStyle}_${unitId}_${subUnitId}`;
1516
+ }
1517
+ };
1518
+ __name(_WorksheetSetCellStylePermission, "WorksheetSetCellStylePermission");
1519
+ let WorksheetSetCellStylePermission = _WorksheetSetCellStylePermission;
1520
+ const _WorksheetSetCellValuePermission = class _WorksheetSetCellValuePermission {
1521
+ constructor(unitId, subUnitId) {
1522
+ __publicField(this, "value", !0);
1523
+ __publicField(this, "type", M.Worksheet);
1524
+ __publicField(this, "status", PermissionStatus.INIT);
1525
+ __publicField(this, "id");
1526
+ __publicField(this, "subType", P.SetCellValue);
1527
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetCellValue}_${unitId}_${subUnitId}`;
1528
+ }
1529
+ };
1530
+ __name(_WorksheetSetCellValuePermission, "WorksheetSetCellValuePermission");
1531
+ let WorksheetSetCellValuePermission = _WorksheetSetCellValuePermission;
1532
+ const _WorksheetSetColumnStylePermission = class _WorksheetSetColumnStylePermission {
1533
+ constructor(unitId, subUnitId) {
1534
+ __publicField(this, "value", !0);
1535
+ __publicField(this, "type", M.Worksheet);
1536
+ __publicField(this, "status", PermissionStatus.INIT);
1537
+ __publicField(this, "id");
1538
+ __publicField(this, "subType", P.SetColumnStyle);
1539
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetColumnStyle}_${unitId}_${subUnitId}`;
1540
+ }
1541
+ };
1542
+ __name(_WorksheetSetColumnStylePermission, "WorksheetSetColumnStylePermission");
1543
+ let WorksheetSetColumnStylePermission = _WorksheetSetColumnStylePermission;
1544
+ const _WorksheetSetRowStylePermission = class _WorksheetSetRowStylePermission {
1545
+ constructor(unitId, subUnitId) {
1546
+ __publicField(this, "value", !0);
1547
+ __publicField(this, "type", M.Worksheet);
1548
+ __publicField(this, "status", PermissionStatus.INIT);
1549
+ __publicField(this, "id");
1550
+ __publicField(this, "subType", P.SetRowStyle);
1551
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.SetRowStyle}_${unitId}_${subUnitId}`;
1552
+ }
1553
+ };
1554
+ __name(_WorksheetSetRowStylePermission, "WorksheetSetRowStylePermission");
1555
+ let WorksheetSetRowStylePermission = _WorksheetSetRowStylePermission;
1556
+ const _WorksheetSortPermission = class _WorksheetSortPermission {
1557
+ constructor(unitId, subUnitId) {
1558
+ __publicField(this, "value", !0);
1559
+ __publicField(this, "type", M.Worksheet);
1560
+ __publicField(this, "status", PermissionStatus.INIT);
1561
+ __publicField(this, "id");
1562
+ __publicField(this, "subType", P.Sort);
1563
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.Sort}_${unitId}_${subUnitId}`;
1564
+ }
1565
+ };
1566
+ __name(_WorksheetSortPermission, "WorksheetSortPermission");
1567
+ let WorksheetSortPermission = _WorksheetSortPermission;
1568
+ const _WorksheetViewPermission = class _WorksheetViewPermission {
1569
+ constructor(unitId, subUnitId) {
1570
+ __publicField(this, "value", !0);
1571
+ __publicField(this, "type", M.Worksheet);
1572
+ __publicField(this, "status", PermissionStatus.INIT);
1573
+ __publicField(this, "id");
1574
+ __publicField(this, "subType", P.View);
1575
+ this.unitId = unitId, this.subUnitId = subUnitId, this.id = `${this.type}.${P.View}_${unitId}_${subUnitId}`;
1576
+ }
1577
+ };
1578
+ __name(_WorksheetViewPermission, "WorksheetViewPermission");
1579
+ let WorksheetViewPermission = _WorksheetViewPermission;
1553
1580
  const SetRangeValuesCommand = {
1554
1581
  id: "sheet.command.set-range-values",
1555
1582
  type: CommandType.COMMAND,
1556
- // eslint-disable-next-line max-lines-per-function
1557
1583
  handler: /* @__PURE__ */ __name((accessor, params) => {
1558
- var _a20;
1559
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), permissionService = accessor.get(IPermissionService), target = getSheetCommandTarget(univerInstanceService, {
1560
- subUnitId: params.subUnitId,
1561
- unitId: params.unitId
1562
- });
1563
- if (!target)
1564
- return !1;
1565
- const { subUnitId, unitId } = target, { value, range } = params, currentSelections = range ? [range] : (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
1566
- if (!currentSelections || !currentSelections.length || !permissionService.getPermissionPoint(new WorksheetEditPermission(unitId, subUnitId).id))
1567
- return !1;
1584
+ var _a21;
1585
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), permissionService = accessor.get(IPermissionService), target = getSheetCommandTarget(univerInstanceService, params);
1586
+ if (!target) return !1;
1587
+ const { subUnitId, unitId, workbook, worksheet } = target, { value, range } = params, currentSelections = range ? [range] : (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
1588
+ if (!currentSelections || !currentSelections.length || !permissionService.getPermissionPoint(new WorksheetEditPermission(unitId, subUnitId).id)) return !1;
1568
1589
  const cellValue = new ObjectMatrix();
1569
1590
  let realCellValue;
1570
1591
  if (Tools.isArray(value))
@@ -1583,22 +1604,29 @@ const SetRangeValuesCommand = {
1583
1604
  }
1584
1605
  else
1585
1606
  realCellValue = value;
1586
- const setRangeValuesMutationParams = {
1587
- subUnitId,
1588
- unitId,
1589
- cellValue: realCellValue != null ? realCellValue : cellValue.getMatrix()
1590
- }, undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams), setValueMutationResult = commandService.syncExecuteCommand(
1591
- SetRangeValuesMutation.id,
1592
- setRangeValuesMutationParams
1593
- ), { undos, redos } = sheetInterceptorService.onCommandExecute({
1607
+ const setRangeValuesMutationParams = { subUnitId, unitId, cellValue: realCellValue != null ? realCellValue : cellValue.getMatrix() }, redoParams = SetRangeValuesUndoMutationFactory(accessor, setRangeValuesMutationParams);
1608
+ if (!commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams)) return !1;
1609
+ const { undos, redos } = sheetInterceptorService.onCommandExecute({
1594
1610
  id: SetRangeValuesCommand.id,
1595
1611
  params: { ...setRangeValuesMutationParams, range: currentSelections }
1596
- }), result = sequenceExecute([...redos], commandService);
1597
- return setValueMutationResult && result.result ? (undoRedoService.pushUndoRedo({
1598
- unitID: unitId,
1599
- undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }, ...undos],
1600
- redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }, ...redos]
1601
- }), !0) : !1;
1612
+ });
1613
+ if (sequenceExecute([...redos], commandService).result) {
1614
+ const selectionOperation = followSelectionOperation(range != null ? range : cellValue.getRange(), workbook, worksheet);
1615
+ return undoRedoService.pushUndoRedo({
1616
+ unitID: unitId,
1617
+ undoMutations: [
1618
+ { id: SetRangeValuesMutation.id, params: redoParams },
1619
+ ...undos,
1620
+ selectionOperation
1621
+ ],
1622
+ redoMutations: [
1623
+ { id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams },
1624
+ ...redos,
1625
+ Tools.deepClone(selectionOperation)
1626
+ ]
1627
+ }), !0;
1628
+ }
1629
+ return !1;
1602
1630
  }, "handler")
1603
1631
  };
1604
1632
  function getInsertRangeMutations(accessor, params) {
@@ -1794,12 +1822,12 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1794
1822
  type: CommandType.COMMAND,
1795
1823
  id: DeleteRangeMoveLeftCommandId,
1796
1824
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
1797
- var _a20, _b, _c;
1825
+ var _a21, _b, _c;
1798
1826
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
1799
1827
  if (!target) return !1;
1800
1828
  const { worksheet, workbook, subUnitId, unitId } = target;
1801
1829
  let range = params == null ? void 0 : params.range;
1802
- if (range || (range = (_a20 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a20.range), !range) return !1;
1830
+ if (range || (range = (_a21 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a21.range), !range) return !1;
1803
1831
  const deleteRangeMutationParams = {
1804
1832
  range,
1805
1833
  subUnitId,
@@ -1824,12 +1852,12 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1824
1852
  type: CommandType.COMMAND,
1825
1853
  id: DeleteRangeMoveUpCommandId,
1826
1854
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
1827
- var _a20, _b, _c;
1855
+ var _a21, _b, _c;
1828
1856
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService);
1829
1857
  if (!target) return !1;
1830
1858
  const { unitId, subUnitId, workbook, worksheet } = target;
1831
1859
  let range = params == null ? void 0 : params.range;
1832
- if (range || (range = (_a20 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a20.range), !range) return !1;
1860
+ if (range || (range = (_a21 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a21.range), !range) return !1;
1833
1861
  const deleteRangeMutationParams = {
1834
1862
  range,
1835
1863
  subUnitId,
@@ -1862,7 +1890,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1862
1890
  id: "sheet.mutation.insert-row",
1863
1891
  type: CommandType.MUTATION,
1864
1892
  handler: /* @__PURE__ */ __name((accessor, params) => {
1865
- var _a20;
1893
+ var _a21;
1866
1894
  const { unitId, subUnitId, range, rowInfo } = params, universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(unitId);
1867
1895
  if (universheet == null)
1868
1896
  throw new Error("universheet is null error!");
@@ -1874,7 +1902,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1874
1902
  hd: 0
1875
1903
  }, rowIndex = range.startRow, rowCount = range.endRow - range.startRow + 1;
1876
1904
  for (let j = rowIndex; j < rowIndex + rowCount; j++)
1877
- rowInfo ? insertMatrixArray(j, (_a20 = rowInfo[j - range.startRow]) != null ? _a20 : defaultRowInfo, rowWrapper) : insertMatrixArray(j, defaultRowInfo, rowWrapper);
1905
+ rowInfo ? insertMatrixArray(j, (_a21 = rowInfo[j - range.startRow]) != null ? _a21 : defaultRowInfo, rowWrapper) : insertMatrixArray(j, defaultRowInfo, rowWrapper);
1878
1906
  return worksheet.setRowCount(worksheet.getRowCount() + range.endRow - range.startRow + 1), worksheet.getCellMatrix().insertRows(range.startRow, rowCount), !0;
1879
1907
  }, "handler")
1880
1908
  }, InsertColMutationUndoFactory = /* @__PURE__ */ __name((accessor, params) => {
@@ -1889,7 +1917,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1889
1917
  id: "sheet.mutation.insert-col",
1890
1918
  type: CommandType.MUTATION,
1891
1919
  handler: /* @__PURE__ */ __name((accessor, params) => {
1892
- var _a20;
1920
+ var _a21;
1893
1921
  const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);
1894
1922
  if (universheet == null)
1895
1923
  throw new Error("universheet is null error!");
@@ -1901,7 +1929,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1901
1929
  w: defaultColWidth,
1902
1930
  hd: 0
1903
1931
  };
1904
- colInfo ? insertMatrixArray(j, (_a20 = colInfo[j - range.startColumn]) != null ? _a20 : defaultColInfo, columnWrapper) : insertMatrixArray(j, defaultColInfo, columnWrapper);
1932
+ colInfo ? insertMatrixArray(j, (_a21 = colInfo[j - range.startColumn]) != null ? _a21 : defaultColInfo, columnWrapper) : insertMatrixArray(j, defaultColInfo, columnWrapper);
1905
1933
  }
1906
1934
  return worksheet.setColumnCount(worksheet.getColumnCount() + range.endColumn - range.startColumn + 1), worksheet.getCellMatrix().insertColumns(range.startColumn, colCount), !0;
1907
1935
  }, "handler")
@@ -1959,7 +1987,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1959
1987
  id: "sheet.command.insert-range-move-down",
1960
1988
  // eslint-disable-next-line max-lines-per-function
1961
1989
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
1962
- var _a20, _b, _c;
1990
+ var _a21, _b, _c;
1963
1991
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService);
1964
1992
  if (selectionManagerService.isOverlapping())
1965
1993
  return errorService.emit(localeService.t("sheets.info.overlappingSelections")), !1;
@@ -1967,7 +1995,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
1967
1995
  if (!target) return !1;
1968
1996
  const { unitId, subUnitId, worksheet, workbook } = target;
1969
1997
  let range = params == null ? void 0 : params.range;
1970
- if (range || (range = (_a20 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a20.range), !range) return !1;
1998
+ if (range || (range = (_a21 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a21.range), !range) return !1;
1971
1999
  const redoMutations = [], undoMutations = [], cellMatrix = worksheet.getCellMatrix(), dataRange = cellMatrix.getDataRange(), sliceMaxRow = cellMatrix.getSlice(dataRange.startRow, dataRange.endRow, range.startColumn, range.endColumn).getDataRange().endRow, insertRowCount = Math.max(sliceMaxRow + (range.endRow - range.startRow + 1) - dataRange.endRow, 0);
1972
2000
  if (insertRowCount > 0) {
1973
2001
  const anchorRow = range.startRow - 1, height = worksheet.getRowHeight(anchorRow), insertRowParams = {
@@ -2027,7 +2055,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2027
2055
  id: InsertRangeMoveRightCommandId,
2028
2056
  // eslint-disable-next-line max-lines-per-function
2029
2057
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2030
- var _a20, _b, _c;
2058
+ var _a21, _b, _c;
2031
2059
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), errorService = accessor.get(ErrorService), localeService = accessor.get(LocaleService);
2032
2060
  if (selectionManagerService.isOverlapping())
2033
2061
  return errorService.emit(localeService.t("sheets.info.overlappingSelections")), !1;
@@ -2035,7 +2063,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2035
2063
  if (!target) return !1;
2036
2064
  const { workbook, worksheet, unitId, subUnitId } = target;
2037
2065
  let range = params == null ? void 0 : params.range;
2038
- if (range || (range = (_a20 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a20.range), !range) return !1;
2066
+ if (range || (range = (_a21 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a21.range), !range) return !1;
2039
2067
  const redoMutations = [], undoMutations = [], cellMatrix = worksheet.getCellMatrix(), dataRange = cellMatrix.getDataRange(), sliceMaxCol = cellMatrix.getSlice(range.startRow, range.endRow, dataRange.startColumn, dataRange.endColumn).getDataRange().endColumn, insertColCount = Math.max(
2040
2068
  sliceMaxCol + (range.endColumn - range.startColumn + 1) - dataRange.endColumn,
2041
2069
  0
@@ -2097,8 +2125,12 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2097
2125
  type: CommandType.COMMAND,
2098
2126
  id: InsertRowCommandId,
2099
2127
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2100
- var _a20, _b, _c, _d;
2101
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), workbook = univerInstanceService.getUniverSheetInstance(params.unitId), worksheet = workbook.getSheetBySheetId(params.subUnitId), { range, direction, unitId, subUnitId, cellValue } = params, { startRow, endRow } = range, anchorRow = direction === Direction.UP ? startRow : startRow - 1, height = worksheet.getRowHeight(anchorRow), insertRowParams = {
2128
+ var _a21, _b, _c, _d;
2129
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService, params);
2130
+ if (!target) return !1;
2131
+ const { workbook, worksheet } = target, { range, direction, unitId, subUnitId, cellValue } = params, { startRow, endRow } = range;
2132
+ range.rangeType = RANGE_TYPE.ROW;
2133
+ const anchorRow = direction === Direction.UP ? startRow : startRow - 1, height = worksheet.getRowHeight(anchorRow), insertRowParams = {
2102
2134
  unitId,
2103
2135
  subUnitId,
2104
2136
  range,
@@ -2111,11 +2143,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2111
2143
  accessor,
2112
2144
  insertRowParams
2113
2145
  );
2114
- if (!await sheetInterceptorService.beforeCommandExecute({
2115
- id: InsertRowCommand.id,
2116
- params: insertRowParams
2117
- }))
2118
- return !1;
2146
+ if (!await sheetInterceptorService.beforeCommandExecute({ id: InsertRowCommand.id, params: insertRowParams })) return !1;
2119
2147
  const redos = [{ id: InsertRowMutation.id, params: insertRowParams }], undos = [{ id: RemoveRowMutation.id, params: undoRowInsertionParams }];
2120
2148
  cellValue && redos.push({
2121
2149
  id: SetRangeValuesMutation.id,
@@ -2129,7 +2157,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2129
2157
  id: InsertRowCommand.id,
2130
2158
  params
2131
2159
  });
2132
- return redos.unshift(...(_a20 = intercepted.preRedos) != null ? _a20 : []), redos.push(...(_b = intercepted.redos) != null ? _b : []), redos.push(followSelectionOperation(range, workbook, worksheet)), undos.unshift(...(_c = intercepted.preUndos) != null ? _c : []), undos.push(...(_d = intercepted.undos) != null ? _d : []), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
2160
+ return redos.unshift(...(_a21 = intercepted.preRedos) != null ? _a21 : []), redos.push(...(_b = intercepted.redos) != null ? _b : []), redos.push(followSelectionOperation(range, workbook, worksheet)), undos.unshift(...(_c = intercepted.preUndos) != null ? _c : []), undos.push(...(_d = intercepted.undos) != null ? _d : []), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
2133
2161
  unitID: params.unitId,
2134
2162
  undoMutations: undos,
2135
2163
  redoMutations: redos
@@ -2139,20 +2167,16 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2139
2167
  type: CommandType.COMMAND,
2140
2168
  id: "sheet.command.insert-row-before",
2141
2169
  handler: /* @__PURE__ */ __name(async (accessor) => {
2142
- var _a20;
2143
- const selections = (_a20 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
2170
+ var _a21;
2171
+ const selections = (_a21 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
2144
2172
  let range;
2145
2173
  if ((selections == null ? void 0 : selections.length) === 1)
2146
2174
  range = selections[0];
2147
2175
  else
2148
2176
  return !1;
2149
- const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2150
- if (!workbook)
2151
- return !1;
2152
- const worksheet = workbook.getActiveSheet();
2153
- if (!worksheet)
2154
- return !1;
2155
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), { startRow, endRow } = range, startColumn = 0, endColumn = worksheet.getColumnCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !0, startRow - 1), insertRowParams = {
2177
+ const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
2178
+ if (!target) return !1;
2179
+ const { worksheet, subUnitId, unitId } = target, { startRow, endRow } = range, startColumn = 0, endColumn = worksheet.getColumnCount() - 1, insertRowParams = {
2156
2180
  unitId,
2157
2181
  subUnitId,
2158
2182
  direction: Direction.UP,
@@ -2162,7 +2186,8 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2162
2186
  startColumn,
2163
2187
  endColumn
2164
2188
  },
2165
- cellValue
2189
+ // copy styles from the row above
2190
+ cellValue: copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !0, startRow - 1)
2166
2191
  };
2167
2192
  return accessor.get(ICommandService).executeCommand(InsertRowCommand.id, insertRowParams);
2168
2193
  }, "handler")
@@ -2170,20 +2195,16 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2170
2195
  type: CommandType.COMMAND,
2171
2196
  id: "sheet.command.insert-row-after",
2172
2197
  handler: /* @__PURE__ */ __name(async (accessor) => {
2173
- var _a20;
2174
- const selections = (_a20 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
2198
+ var _a21;
2199
+ const selections = (_a21 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
2175
2200
  let range;
2176
2201
  if ((selections == null ? void 0 : selections.length) === 1)
2177
2202
  range = selections[0];
2178
2203
  else
2179
2204
  return !1;
2180
- const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2181
- if (!workbook)
2182
- return !1;
2183
- const worksheet = workbook.getActiveSheet();
2184
- if (!worksheet)
2185
- return !1;
2186
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endRow - range.startRow + 1, startRow = range.endRow + 1, endRow = range.endRow + count, startColumn = 0, endColumn = worksheet.getColumnCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !0, range.endRow), insertRowParams = {
2205
+ const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
2206
+ if (!target) return !1;
2207
+ const { worksheet, unitId, subUnitId } = target, count = range.endRow - range.startRow + 1, startRow = range.endRow + 1, endRow = range.endRow + count, startColumn = 0, endColumn = worksheet.getColumnCount() - 1, insertRowParams = {
2187
2208
  unitId,
2188
2209
  subUnitId,
2189
2210
  direction: Direction.DOWN,
@@ -2194,7 +2215,8 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2194
2215
  endColumn,
2195
2216
  rangeType: RANGE_TYPE.ROW
2196
2217
  },
2197
- cellValue
2218
+ // copy styles from the row below
2219
+ cellValue: copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !0, range.endRow)
2198
2220
  };
2199
2221
  return accessor.get(ICommandService).executeCommand(InsertRowCommand.id, insertRowParams);
2200
2222
  }, "handler")
@@ -2202,8 +2224,10 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2202
2224
  type: CommandType.COMMAND,
2203
2225
  id: InsertColCommandId,
2204
2226
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2205
- var _a20, _b, _c, _d;
2206
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), { range, direction, subUnitId, unitId, cellValue } = params, { startColumn, endColumn } = params.range, workbook = univerInstanceService.getUniverSheetInstance(params.unitId), worksheet = workbook.getSheetBySheetId(params.subUnitId), anchorCol = direction === Direction.LEFT ? startColumn : startColumn - 1, width = worksheet.getColumnWidth(anchorCol), insertColParams = {
2227
+ var _a21, _b, _c, _d;
2228
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), { range, direction, subUnitId, unitId, cellValue } = params, { startColumn, endColumn } = params.range;
2229
+ range.rangeType = RANGE_TYPE.COLUMN;
2230
+ const workbook = univerInstanceService.getUniverSheetInstance(params.unitId), worksheet = workbook.getSheetBySheetId(params.subUnitId), anchorCol = direction === Direction.LEFT ? startColumn : startColumn - 1, width = worksheet.getColumnWidth(anchorCol), insertColParams = {
2207
2231
  unitId,
2208
2232
  subUnitId,
2209
2233
  range,
@@ -2233,7 +2257,7 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2233
2257
  id: InsertColCommand.id,
2234
2258
  params
2235
2259
  });
2236
- return redos.unshift(...(_a20 = intercepted.preRedos) != null ? _a20 : []), redos.push(...(_b = intercepted.redos) != null ? _b : []), redos.push(followSelectionOperation(range, workbook, worksheet)), undos.unshift(...(_c = intercepted.preUndos) != null ? _c : []), undos.push(...(_d = intercepted.undos) != null ? _d : []), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
2260
+ return redos.unshift(...(_a21 = intercepted.preRedos) != null ? _a21 : []), redos.push(...(_b = intercepted.redos) != null ? _b : []), redos.push(followSelectionOperation(range, workbook, worksheet)), undos.unshift(...(_c = intercepted.preUndos) != null ? _c : []), undos.push(...(_d = intercepted.undos) != null ? _d : []), sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
2237
2261
  unitID: params.unitId,
2238
2262
  undoMutations: undos.filter(Boolean),
2239
2263
  redoMutations: redos.filter(Boolean)
@@ -2249,13 +2273,9 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2249
2273
  range = selections[0].range;
2250
2274
  else
2251
2275
  return !1;
2252
- const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2253
- if (!workbook)
2254
- return !1;
2255
- const worksheet = workbook.getActiveSheet();
2256
- if (!worksheet)
2257
- return !1;
2258
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), { startColumn, endColumn } = range, startRow = 0, endRow = worksheet.getRowCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !1, startColumn - 1), insertColParams = {
2276
+ const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
2277
+ if (!target) return !1;
2278
+ const { worksheet, unitId, subUnitId } = target, { startColumn, endColumn } = range, startRow = 0, endRow = worksheet.getRowCount() - 1, insertColParams = {
2259
2279
  unitId,
2260
2280
  subUnitId,
2261
2281
  direction: Direction.LEFT,
@@ -2266,7 +2286,8 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2266
2286
  endRow,
2267
2287
  rangeType: RANGE_TYPE.COLUMN
2268
2288
  },
2269
- cellValue
2289
+ // copy styles from the column before
2290
+ cellValue: copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !1, startColumn - 1)
2270
2291
  };
2271
2292
  return accessor.get(ICommandService).executeCommand(InsertColCommand.id, insertColParams);
2272
2293
  }, "handler")
@@ -2280,13 +2301,9 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2280
2301
  range = selections[0].range;
2281
2302
  else
2282
2303
  return !1;
2283
- const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
2284
- if (!workbook)
2285
- return !1;
2286
- const worksheet = workbook.getActiveSheet();
2287
- if (!worksheet)
2288
- return !1;
2289
- const unitId = workbook.getUnitId(), subUnitId = worksheet.getSheetId(), count = range.endColumn - range.startColumn + 1, startColumn = range.endColumn + 1, endColumn = range.endColumn + count, startRow = 0, endRow = worksheet.getRowCount() - 1, cellValue = copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !1, range.endColumn), insertColParams = {
2304
+ const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
2305
+ if (!target) return !1;
2306
+ const { worksheet, unitId, subUnitId } = target, count = range.endColumn - range.startColumn + 1, startColumn = range.endColumn + 1, endColumn = range.endColumn + count, startRow = 0, endRow = worksheet.getRowCount() - 1, insertColParams = {
2290
2307
  unitId,
2291
2308
  subUnitId,
2292
2309
  direction: Direction.RIGHT,
@@ -2296,7 +2313,8 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2296
2313
  startRow,
2297
2314
  endRow
2298
2315
  },
2299
- cellValue
2316
+ // copy styles from the column after
2317
+ cellValue: copyRangeStyles(worksheet, startRow, endRow, startColumn, endColumn, !1, range.endColumn)
2300
2318
  };
2301
2319
  return accessor.get(ICommandService).executeCommand(InsertColCommand.id, insertColParams);
2302
2320
  }, "handler")
@@ -2304,13 +2322,13 @@ const DeleteRangeMoveLeftCommandId = "sheet.command.delete-range-move-left", Del
2304
2322
  id: "sheet.command.insert-sheet",
2305
2323
  type: CommandType.COMMAND,
2306
2324
  handler: /* @__PURE__ */ __name((accessor, params) => {
2307
- var _a20;
2325
+ var _a21;
2308
2326
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), localeService = accessor.get(LocaleService), target = getSheetCommandTargetWorkbook(univerInstanceService, { unitId: params == null ? void 0 : params.unitId });
2309
2327
  if (!target) return !1;
2310
2328
  const { unitId, workbook } = target;
2311
2329
  let index = workbook.getSheets().length;
2312
2330
  const sheet = params == null ? void 0 : params.sheet, sheetId = sheet == null ? void 0 : sheet.id, sheetConfig = mergeWorksheetSnapshotWithDefault(sheet || {});
2313
- params ? (index = (_a20 = params.index) != null ? _a20 : index, sheetConfig.id = sheetId || Tools.generateRandomId(), sheetConfig.name = (sheet == null ? void 0 : sheet.name) || workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`)) : (sheetConfig.id = Tools.generateRandomId(), sheetConfig.name = workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`));
2331
+ params ? (index = (_a21 = params.index) != null ? _a21 : index, sheetConfig.id = sheetId || Tools.generateRandomId(), sheetConfig.name = (sheet == null ? void 0 : sheet.name) || workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`)) : (sheetConfig.id = Tools.generateRandomId(), sheetConfig.name = workbook.generateNewSheetName(`${localeService.t("sheets.tabs.sheet")}`));
2314
2332
  const insertSheetMutationParams = {
2315
2333
  index,
2316
2334
  sheet: sheetConfig,
@@ -2413,7 +2431,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2413
2431
  type: CommandType.COMMAND,
2414
2432
  // eslint-disable-next-line max-lines-per-function
2415
2433
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2416
- var _a20, _b;
2434
+ var _a21, _b;
2417
2435
  const selectionManagerService = accessor.get(SheetsSelectionsService), {
2418
2436
  fromRange: { startRow: fromRow },
2419
2437
  toRange: { startRow: toRow },
@@ -2440,7 +2458,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2440
2458
  sourceRange: rangeToMove,
2441
2459
  targetRange: destinationRange
2442
2460
  }, undoMoveRowsParams = MoveRowsMutationUndoFactory(accessor, moveRowsParams), commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveRowsCommand.id, params }), redos = [
2443
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
2461
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
2444
2462
  { id: MoveRowsMutation.id, params: moveRowsParams }
2445
2463
  ], undos = [
2446
2464
  ...(_b = interceptorCommands.preUndos) != null ? _b : [],
@@ -2473,7 +2491,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2473
2491
  type: CommandType.COMMAND,
2474
2492
  // eslint-disable-next-line max-lines-per-function
2475
2493
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2476
- var _a20, _b;
2494
+ var _a21, _b;
2477
2495
  const selectionManagerService = accessor.get(SheetsSelectionsService), {
2478
2496
  fromRange: { startColumn: fromCol },
2479
2497
  toRange: { startColumn: toCol },
@@ -2500,7 +2518,7 @@ const MoveRowsCommandId = "sheet.command.move-rows", MoveRowsCommand = {
2500
2518
  sourceRange: rangeToMove,
2501
2519
  targetRange: destinationRange
2502
2520
  }, undoMoveColsParams = MoveColsMutationUndoFactory(accessor, moveColsParams), commandService = accessor.get(ICommandService), interceptorCommands = sheetInterceptorService.onCommandExecute({ id: MoveColsCommand.id, params }), redos = [
2503
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
2521
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
2504
2522
  { id: MoveColsMutation.id, params: moveColsParams }
2505
2523
  ], undos = [
2506
2524
  ...(_b = interceptorCommands.preUndos) != null ? _b : [],
@@ -2542,10 +2560,10 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2542
2560
  id: RemoveRowCommandId,
2543
2561
  // eslint-disable-next-line max-lines-per-function
2544
2562
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2545
- var _a20, _b, _c, _d;
2563
+ var _a21, _b, _c, _d;
2546
2564
  const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService);
2547
2565
  let totalRange = params == null ? void 0 : params.range;
2548
- if (totalRange || (totalRange = (_a20 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a20.range), !totalRange) return !1;
2566
+ if (totalRange || (totalRange = (_a21 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a21.range), !totalRange) return !1;
2549
2567
  const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
2550
2568
  if (!target) return !1;
2551
2569
  const { workbook, worksheet, subUnitId, unitId } = target;
@@ -2620,10 +2638,10 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2620
2638
  type: CommandType.COMMAND,
2621
2639
  id: RemoveColCommandId,
2622
2640
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2623
- var _a20, _b, _c, _d;
2641
+ var _a21, _b, _c, _d;
2624
2642
  const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService);
2625
2643
  let range = params == null ? void 0 : params.range;
2626
- if (range || (range = (_a20 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a20.range), !range) return !1;
2644
+ if (range || (range = (_a21 = selectionManagerService.getCurrentLastSelection()) == null ? void 0 : _a21.range), !range) return !1;
2627
2645
  const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
2628
2646
  if (!target) return !1;
2629
2647
  const { workbook, worksheet, subUnitId, unitId } = target;
@@ -2677,7 +2695,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2677
2695
  id: "sheet.command.remove-sheet",
2678
2696
  type: CommandType.COMMAND,
2679
2697
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2680
- var _a20, _b;
2698
+ var _a21, _b;
2681
2699
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(univerInstanceService, params);
2682
2700
  if (!target) return !1;
2683
2701
  const { unitId, subUnitId, workbook, worksheet } = target;
@@ -2692,7 +2710,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2692
2710
  ), intercepted = sheetInterceptorService.onCommandExecute({
2693
2711
  id: RemoveSheetCommand.id,
2694
2712
  params: { unitId, subUnitId }
2695
- }), redos = [...(_a20 = intercepted.preRedos) != null ? _a20 : [], { id: RemoveSheetMutation.id, params: RemoveSheetMutationParams }, ...intercepted.redos], undos = [...(_b = intercepted.preUndos) != null ? _b : [], { id: InsertSheetMutation.id, params: InsertSheetMutationParams }, ...intercepted.undos];
2713
+ }), redos = [...(_a21 = intercepted.preRedos) != null ? _a21 : [], { id: RemoveSheetMutation.id, params: RemoveSheetMutationParams }, ...intercepted.redos], undos = [...(_b = intercepted.preUndos) != null ? _b : [], { id: InsertSheetMutation.id, params: InsertSheetMutationParams }, ...intercepted.undos];
2696
2714
  return sequenceExecute(redos, commandService).result ? (undoRedoService.pushUndoRedo({
2697
2715
  unitID: unitId,
2698
2716
  undoMutations: undos,
@@ -2705,7 +2723,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2705
2723
  return {
2706
2724
  unitId: params.unitId,
2707
2725
  subUnitId: params.subUnitId,
2708
- ranges: params.ranges
2726
+ ranges: Tools.deepClone(params.ranges)
2709
2727
  };
2710
2728
  }, "AddMergeUndoMutationFactory"), AddWorksheetMergeMutation = {
2711
2729
  id: "sheet.mutation.add-worksheet-merge",
@@ -2761,8 +2779,8 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2761
2779
  id: "sheet.command.remove-worksheet-merge",
2762
2780
  // eslint-disable-next-line max-lines-per-function
2763
2781
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2764
- var _a20;
2765
- const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (params == null ? void 0 : params.ranges) || ((_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range));
2782
+ var _a21;
2783
+ const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selections = (params == null ? void 0 : params.ranges) || ((_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range));
2766
2784
  if (!(selections != null && selections.length)) return !1;
2767
2785
  const target = getSheetCommandTarget(univerInstanceService);
2768
2786
  if (!target) return !1;
@@ -2868,15 +2886,308 @@ function forEach(range, action) {
2868
2886
  action(i, j);
2869
2887
  }
2870
2888
  __name(forEach, "forEach");
2871
- const SetBorderBasicCommand = {
2872
- id: "sheet.command.set-border-basic",
2873
- type: CommandType.COMMAND,
2874
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
2875
- const { unitId, subUnitId, value } = params, { type, color, style } = value, commandService = accessor.get(ICommandService), borderManager = accessor.get(BorderStyleManagerService);
2876
- return borderManager.setType(type), borderManager.setColor(color), borderManager.setStyle(style), commandService.executeCommand(SetBorderCommand.id, {
2889
+ const setBorderStyleForRange = /* @__PURE__ */ __name((borderContext, range, defaultStyle, reserve) => {
2890
+ const { mr, worksheet } = borderContext;
2891
+ range.startRow < 0 || range.startColumn < 0 || forEach(range, (row, column) => {
2892
+ var _a21, _b;
2893
+ const rectangle = worksheet.getMergedCell(row, column);
2894
+ let bdStyle = defaultStyle;
2895
+ if (rectangle && (defaultStyle.bc_tr || defaultStyle.ml_tr || defaultStyle.bl_tr || defaultStyle.tl_mr || defaultStyle.tl_bc || defaultStyle.tl_br)) {
2896
+ if (reserve) {
2897
+ const style = Tools.deepClone(
2898
+ (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s
2899
+ );
2900
+ bdStyle = style != null && style.bd ? Object.assign(style.bd, defaultStyle) : defaultStyle;
2901
+ }
2902
+ mr.setValue(rectangle.startRow, rectangle.startColumn, {
2903
+ s: {
2904
+ bd: bdStyle
2905
+ }
2906
+ });
2907
+ } else {
2908
+ if (reserve) {
2909
+ const style = Tools.deepClone((_b = mr.getValue(row, column)) == null ? void 0 : _b.s);
2910
+ bdStyle = style != null && style.bd ? Object.assign(style.bd, defaultStyle) : defaultStyle;
2911
+ }
2912
+ mr.setValue(row, column, { s: { bd: bdStyle } });
2913
+ }
2914
+ });
2915
+ }, "setBorderStyleForRange"), prepareEdgeRange = /* @__PURE__ */ __name((range) => {
2916
+ const topRangeOut = {
2917
+ startRow: range.startRow - 1,
2918
+ startColumn: range.startColumn,
2919
+ endRow: range.startRow - 1,
2920
+ endColumn: range.endColumn
2921
+ }, leftRangeOut = {
2922
+ startRow: range.startRow,
2923
+ startColumn: range.startColumn - 1,
2924
+ endRow: range.endRow,
2925
+ endColumn: range.startColumn - 1
2926
+ }, bottomRangeOut = {
2927
+ startRow: range.endRow + 1,
2928
+ startColumn: range.startColumn,
2929
+ endRow: range.endRow + 1,
2930
+ endColumn: range.endColumn
2931
+ }, rightRangeOut = {
2932
+ startRow: range.startRow,
2933
+ startColumn: range.endColumn + 1,
2934
+ endRow: range.endRow,
2935
+ endColumn: range.endColumn + 1
2936
+ }, topRange = {
2937
+ startRow: range.startRow,
2938
+ startColumn: range.startColumn,
2939
+ endRow: range.startRow,
2940
+ endColumn: range.endColumn
2941
+ }, leftRange = {
2942
+ startRow: range.startRow,
2943
+ startColumn: range.startColumn,
2944
+ endRow: range.endRow,
2945
+ endColumn: range.startColumn
2946
+ }, bottomRange = {
2947
+ startRow: range.endRow,
2948
+ startColumn: range.startColumn,
2949
+ endRow: range.endRow,
2950
+ endColumn: range.endColumn
2951
+ }, rightRange = {
2952
+ startRow: range.startRow,
2953
+ startColumn: range.endColumn,
2954
+ endRow: range.endRow,
2955
+ endColumn: range.endColumn
2956
+ };
2957
+ return {
2958
+ topRangeOut,
2959
+ leftRangeOut,
2960
+ bottomRangeOut,
2961
+ rightRangeOut,
2962
+ topRange,
2963
+ leftRange,
2964
+ bottomRange,
2965
+ rightRange
2966
+ };
2967
+ }, "prepareEdgeRange");
2968
+ function getBorderContext(borderStyleManagerService, target, selections) {
2969
+ const { style, color, type } = borderStyleManagerService.getBorderInfo(), top = type === BorderType.TOP || type === BorderType.ALL || type === BorderType.OUTSIDE, left = type === BorderType.LEFT || type === BorderType.ALL || type === BorderType.OUTSIDE, bottom = type === BorderType.BOTTOM || type === BorderType.ALL || type === BorderType.OUTSIDE, right = type === BorderType.RIGHT || type === BorderType.ALL || type === BorderType.OUTSIDE, vertical = type === BorderType.VERTICAL || type === BorderType.ALL || type === BorderType.INSIDE, horizontal = type === BorderType.HORIZONTAL || type === BorderType.ALL || type === BorderType.INSIDE, tl_br = type.indexOf("tlbr") > -1, tl_bc = type.indexOf("tlbc") > -1, tl_mr = type.indexOf("tlmr") > -1, bl_tr = type.indexOf("bltr") > -1, ml_tr = type.indexOf("mltr") > -1, bc_tr = type.indexOf("bctr") > -1, range = selections[0], {
2970
+ topRangeOut,
2971
+ leftRangeOut,
2972
+ bottomRangeOut,
2973
+ rightRangeOut,
2974
+ topRange,
2975
+ leftRange,
2976
+ bottomRange,
2977
+ rightRange
2978
+ } = prepareEdgeRange(range), mr = new ObjectMatrix(), { worksheet, unitId, subUnitId } = target;
2979
+ return {
2980
+ worksheet,
2981
+ unitId,
2982
+ subUnitId,
2983
+ style,
2984
+ color,
2985
+ type,
2986
+ top,
2987
+ left,
2988
+ right,
2989
+ bottom,
2990
+ vertical,
2991
+ horizontal,
2992
+ tl_br,
2993
+ tl_bc,
2994
+ tl_mr,
2995
+ bl_tr,
2996
+ ml_tr,
2997
+ bc_tr,
2998
+ topRangeOut,
2999
+ leftRangeOut,
3000
+ bottomRangeOut,
3001
+ rightRangeOut,
3002
+ topRange,
3003
+ leftRange,
3004
+ bottomRange,
3005
+ rightRange,
3006
+ range,
3007
+ mr,
3008
+ borderStyle: {
3009
+ s: style,
3010
+ cl: {
3011
+ rgb: color
3012
+ }
3013
+ }
3014
+ };
3015
+ }
3016
+ __name(getBorderContext, "getBorderContext");
3017
+ const innerBorder = /* @__PURE__ */ __name((borderContext) => {
3018
+ const { range, mr, borderStyle, vertical, horizontal, worksheet } = borderContext;
3019
+ vertical && forEach(range, (row, column) => {
3020
+ var _a21, _b, _c;
3021
+ const mergedRange = worksheet.getMergedCell(row, column);
3022
+ if (mergedRange) {
3023
+ const topLeftStyle = (_a21 = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _a21.s;
3024
+ mergedRange.startColumn !== range.startColumn && mr.setValue(row, column, {
3025
+ s: {
3026
+ bd: topLeftStyle != null && topLeftStyle.bd ? Object.assign(topLeftStyle.bd, { l: Tools.deepClone(borderStyle) }) : { l: Tools.deepClone(borderStyle) }
3027
+ }
3028
+ });
3029
+ } else {
3030
+ if (column !== range.endColumn) {
3031
+ const style = (_b = mr.getValue(row, column)) == null ? void 0 : _b.s;
3032
+ mr.setValue(row, column, {
3033
+ s: {
3034
+ bd: style != null && style.bd ? Object.assign(style.bd, { r: Tools.deepClone(borderStyle) }) : { r: Tools.deepClone(borderStyle) }
3035
+ }
3036
+ });
3037
+ }
3038
+ if (column !== range.startColumn) {
3039
+ const style = (_c = mr.getValue(row, column)) == null ? void 0 : _c.s;
3040
+ mr.setValue(row, column, {
3041
+ s: {
3042
+ bd: style != null && style.bd ? Object.assign(style.bd, { l: Tools.deepClone(borderStyle) }) : { l: Tools.deepClone(borderStyle) }
3043
+ }
3044
+ });
3045
+ }
3046
+ }
3047
+ }), horizontal && forEach(range, (row, column) => {
3048
+ var _a21, _b, _c;
3049
+ const mergedRange = worksheet.getMergedCell(row, column);
3050
+ if (mergedRange) {
3051
+ const topLeftStyle = (_a21 = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _a21.s;
3052
+ mergedRange.startRow !== range.startRow && mr.setValue(row, column, {
3053
+ s: {
3054
+ bd: topLeftStyle != null && topLeftStyle.bd ? Object.assign(topLeftStyle.bd, { t: Tools.deepClone(borderStyle) }) : { t: Tools.deepClone(borderStyle) }
3055
+ }
3056
+ });
3057
+ } else {
3058
+ if (row !== range.endRow) {
3059
+ const style = (_b = mr.getValue(row, column)) == null ? void 0 : _b.s;
3060
+ mr.setValue(row, column, {
3061
+ s: {
3062
+ bd: style != null && style.bd ? Object.assign(style.bd, { b: Tools.deepClone(borderStyle) }) : { b: Tools.deepClone(borderStyle) }
3063
+ }
3064
+ });
3065
+ }
3066
+ if (row !== range.startRow) {
3067
+ const style = (_c = mr.getValue(row, column)) == null ? void 0 : _c.s;
3068
+ mr.setValue(row, column, {
3069
+ s: {
3070
+ bd: style != null && style.bd ? Object.assign(style.bd, { t: Tools.deepClone(borderStyle) }) : { t: Tools.deepClone(borderStyle) }
3071
+ }
3072
+ });
3073
+ }
3074
+ }
3075
+ });
3076
+ }, "innerBorder");
3077
+ function otherBorders(borderContext) {
3078
+ const { borderStyle, tl_br, tl_bc, tl_mr, bl_tr, ml_tr, bc_tr } = borderContext, setBorderStyle = /* @__PURE__ */ __name((range, defaultStyle, reserve) => {
3079
+ setBorderStyleForRange(borderContext, range, defaultStyle, reserve);
3080
+ }, "setBorderStyle");
3081
+ tl_br && setBorderStyle(borderContext.range, { tl_br: Tools.deepClone(borderStyle) }, !0), tl_bc && setBorderStyle(borderContext.range, { tl_bc: Tools.deepClone(borderStyle) }, !0), tl_mr && setBorderStyle(borderContext.range, { tl_mr: Tools.deepClone(borderStyle) }, !0), bl_tr && setBorderStyle(borderContext.range, { bl_tr: Tools.deepClone(borderStyle) }, !0), ml_tr && setBorderStyle(borderContext.range, { ml_tr: Tools.deepClone(borderStyle) }, !0), bc_tr && setBorderStyle(borderContext.range, { bc_tr: Tools.deepClone(borderStyle) }, !0);
3082
+ }
3083
+ __name(otherBorders, "otherBorders");
3084
+ const outlineBorder = /* @__PURE__ */ __name((borderContext) => {
3085
+ const { top, left, right, bottom, borderStyle, bottomRange, topRange, leftRange, rightRange, bottomRangeOut, topRangeOut, leftRangeOut, rightRangeOut } = borderContext, setBorderStyle = /* @__PURE__ */ __name((range, defaultStyle, reserve) => {
3086
+ setBorderStyleForRange(borderContext, range, defaultStyle, reserve);
3087
+ }, "setBorderStyle");
3088
+ top && (setBorderStyle(topRangeOut, { b: null }), setBorderStyle(topRange, { t: Tools.deepClone(borderStyle) }, !0)), bottom && (setBorderStyle(bottomRangeOut, { t: null }), setBorderStyle(bottomRange, { b: Tools.deepClone(borderStyle) }, !0)), left && (setBorderStyle(leftRangeOut, { r: null }), setBorderStyle(leftRange, { l: Tools.deepClone(borderStyle) }, !0)), right && (setBorderStyle(rightRangeOut, { l: null }), setBorderStyle(rightRange, { r: Tools.deepClone(borderStyle) }, !0));
3089
+ }, "outlineBorder"), clearBorder = /* @__PURE__ */ __name((borderContext) => {
3090
+ const { range, worksheet, mr, top, bottom, left, right, vertical, horizontal, tl_br, tl_bc, tl_mr, bl_tr, ml_tr, bc_tr, topRange, bottomRange, leftRange, rightRange, topRangeOut, bottomRangeOut, leftRangeOut, rightRangeOut } = borderContext, setBorderStyle = /* @__PURE__ */ __name((range2, defaultStyle, reserve) => {
3091
+ setBorderStyleForRange(borderContext, range2, defaultStyle, reserve);
3092
+ }, "setBorderStyle");
3093
+ !top && !bottom && !left && !right && !vertical && !horizontal && !tl_br && !tl_bc && !tl_mr && !bl_tr && !ml_tr && !bc_tr && (forEach(range, (row, column) => {
3094
+ var _a21, _b, _c, _d, _e, _f, _g, _h;
3095
+ const mergedRange = worksheet.getMergedCell(row, column);
3096
+ if (mergedRange) {
3097
+ if (mergedRange.endColumn !== range.endColumn) {
3098
+ const style = (_a21 = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _a21.s;
3099
+ mr.setValue(row, column, {
3100
+ s: {
3101
+ bd: style != null && style.bd ? Object.assign(style.bd, { r: null }) : { r: null }
3102
+ }
3103
+ });
3104
+ }
3105
+ if (mergedRange.startColumn !== range.startColumn) {
3106
+ const style = (_b = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _b.s;
3107
+ mr.setValue(row, column, {
3108
+ s: {
3109
+ bd: style != null && style.bd ? Object.assign(style.bd, { l: null }) : { l: null }
3110
+ }
3111
+ });
3112
+ }
3113
+ if (mergedRange.endRow !== range.endRow) {
3114
+ const style = (_c = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _c.s;
3115
+ mr.setValue(row, column, {
3116
+ s: {
3117
+ bd: style != null && style.bd ? Object.assign(style.bd, { b: null }) : { b: null }
3118
+ }
3119
+ });
3120
+ }
3121
+ if (mergedRange.startRow !== range.startRow) {
3122
+ const style = (_d = mr.getValue(mergedRange.startRow, mergedRange.startColumn)) == null ? void 0 : _d.s;
3123
+ mr.setValue(row, column, {
3124
+ s: {
3125
+ bd: style != null && style.bd ? Object.assign(style.bd, { t: null }) : { t: null }
3126
+ }
3127
+ });
3128
+ }
3129
+ } else {
3130
+ if (column !== range.endColumn) {
3131
+ const style = (_e = mr.getValue(row, column)) == null ? void 0 : _e.s;
3132
+ mr.setValue(row, column, {
3133
+ s: {
3134
+ bd: style != null && style.bd ? Object.assign(style.bd, { r: null }) : { r: null }
3135
+ }
3136
+ });
3137
+ }
3138
+ if (column !== range.startColumn) {
3139
+ const style = (_f = mr.getValue(row, column)) == null ? void 0 : _f.s;
3140
+ mr.setValue(row, column, {
3141
+ s: {
3142
+ bd: style != null && style.bd ? Object.assign(style.bd, { l: null }) : { l: null }
3143
+ }
3144
+ });
3145
+ }
3146
+ if (row !== range.endRow) {
3147
+ const style = (_g = mr.getValue(row, column)) == null ? void 0 : _g.s;
3148
+ mr.setValue(row, column, {
3149
+ s: {
3150
+ bd: style != null && style.bd ? Object.assign(style.bd, { b: null }) : { b: null }
3151
+ }
3152
+ });
3153
+ }
3154
+ if (row !== range.startRow) {
3155
+ const style = (_h = mr.getValue(row, column)) == null ? void 0 : _h.s;
3156
+ mr.setValue(row, column, {
3157
+ s: {
3158
+ bd: style != null && style.bd ? Object.assign(style.bd, { t: null }) : { t: null }
3159
+ }
3160
+ });
3161
+ }
3162
+ }
3163
+ }), setBorderStyle(topRangeOut, { b: null }), setBorderStyle(topRange, { t: null }, !0), setBorderStyle(bottomRangeOut, { t: null }), setBorderStyle(bottomRange, { b: null }, !0), setBorderStyle(leftRangeOut, { r: null }), setBorderStyle(leftRange, { l: null }, !0), setBorderStyle(rightRangeOut, { l: null }), setBorderStyle(rightRange, { r: null }, !0), setBorderStyle(range, { tl_br: null }, !0), setBorderStyle(range, { tl_bc: null }, !0), setBorderStyle(range, { tl_mr: null }, !0), setBorderStyle(range, { bl_tr: null }, !0), setBorderStyle(range, { ml_tr: null }, !0), setBorderStyle(range, { bc_tr: null }, !0));
3164
+ }, "clearBorder"), SetBorderCommand = {
3165
+ id: "sheet.command.set-border",
3166
+ type: CommandType.COMMAND,
3167
+ handler: /* @__PURE__ */ __name(async (accessor, params) => {
3168
+ var _a21;
3169
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), borderStyleManagerService = accessor.get(BorderStyleManagerService), target = getSheetCommandTarget(univerInstanceService, params);
3170
+ if (!target) return !1;
3171
+ const selections = (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
3172
+ if (!(selections != null && selections.length))
3173
+ return !1;
3174
+ const { activeBorderType } = borderStyleManagerService.getBorderInfo();
3175
+ if (!activeBorderType) return !1;
3176
+ const borderContext = getBorderContext(borderStyleManagerService, target, selections);
3177
+ innerBorder(borderContext), outlineBorder(borderContext), otherBorders(borderContext), clearBorder(borderContext);
3178
+ const { unitId, subUnitId, mr } = borderContext, setRangeValuesMutationParams = {
2877
3179
  unitId,
2878
- subUnitId
2879
- });
3180
+ subUnitId,
3181
+ cellValue: mr.getData()
3182
+ }, undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(
3183
+ accessor,
3184
+ setRangeValuesMutationParams
3185
+ );
3186
+ return commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams) ? (undoRedoService.pushUndoRedo({
3187
+ unitID: unitId,
3188
+ undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }],
3189
+ redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }]
3190
+ }), !0) : !1;
2880
3191
  }, "handler")
2881
3192
  }, SetBorderPositionCommand = {
2882
3193
  id: "sheet.command.set-border-position",
@@ -2900,250 +3211,15 @@ const SetBorderBasicCommand = {
2900
3211
  const commandService = accessor.get(ICommandService);
2901
3212
  return accessor.get(BorderStyleManagerService).setColor(params.value), commandService.executeCommand(SetBorderCommand.id);
2902
3213
  }, "handler")
2903
- }, SetBorderCommand = {
2904
- id: "sheet.command.set-border",
3214
+ }, SetBorderBasicCommand = {
3215
+ id: "sheet.command.set-border-basic",
2905
3216
  type: CommandType.COMMAND,
2906
3217
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
2907
- var _a20;
2908
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), selectionManagerService = accessor.get(SheetsSelectionsService), borderStyleManagerService = accessor.get(BorderStyleManagerService), target = getSheetCommandTarget(univerInstanceService, params);
2909
- if (!target) return !1;
2910
- const { worksheet, unitId, subUnitId } = target, selections = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
2911
- if (!(selections != null && selections.length))
2912
- return !1;
2913
- const { style, color, type, activeBorderType } = borderStyleManagerService.getBorderInfo();
2914
- if (!activeBorderType) return !1;
2915
- const top = type === BorderType.TOP || type === BorderType.ALL || type === BorderType.OUTSIDE, left = type === BorderType.LEFT || type === BorderType.ALL || type === BorderType.OUTSIDE, bottom = type === BorderType.BOTTOM || type === BorderType.ALL || type === BorderType.OUTSIDE, right = type === BorderType.RIGHT || type === BorderType.ALL || type === BorderType.OUTSIDE, vertical = type === BorderType.VERTICAL || type === BorderType.ALL || type === BorderType.INSIDE, horizontal = type === BorderType.HORIZONTAL || type === BorderType.ALL || type === BorderType.INSIDE, tl_br = type.indexOf("tlbr") > -1, tl_bc = type.indexOf("tlbc") > -1, tl_mr = type.indexOf("tlmr") > -1, bl_tr = type.indexOf("bltr") > -1, ml_tr = type.indexOf("mltr") > -1, bc_tr = type.indexOf("bctr") > -1, range = selections[0], topRangeOut = {
2916
- startRow: range.startRow - 1,
2917
- startColumn: range.startColumn,
2918
- endRow: range.startRow - 1,
2919
- endColumn: range.endColumn
2920
- }, leftRangeOut = {
2921
- startRow: range.startRow,
2922
- startColumn: range.startColumn - 1,
2923
- endRow: range.endRow,
2924
- endColumn: range.startColumn - 1
2925
- }, bottomRangeOut = {
2926
- startRow: range.endRow + 1,
2927
- startColumn: range.startColumn,
2928
- endRow: range.endRow + 1,
2929
- endColumn: range.endColumn
2930
- }, rightRangeOut = {
2931
- startRow: range.startRow,
2932
- startColumn: range.endColumn + 1,
2933
- endRow: range.endRow,
2934
- endColumn: range.endColumn + 1
2935
- }, topRange = {
2936
- startRow: range.startRow,
2937
- startColumn: range.startColumn,
2938
- endRow: range.startRow,
2939
- endColumn: range.endColumn
2940
- }, leftRange = {
2941
- startRow: range.startRow,
2942
- startColumn: range.startColumn,
2943
- endRow: range.endRow,
2944
- endColumn: range.startColumn
2945
- }, bottomRange = {
2946
- startRow: range.endRow,
2947
- startColumn: range.startColumn,
2948
- endRow: range.endRow,
2949
- endColumn: range.endColumn
2950
- }, rightRange = {
2951
- startRow: range.startRow,
2952
- startColumn: range.endColumn,
2953
- endRow: range.endRow,
2954
- endColumn: range.endColumn
2955
- }, mr = new ObjectMatrix(), border = {
2956
- s: style,
2957
- cl: {
2958
- rgb: color
2959
- }
2960
- };
2961
- function setBorderStyle(range2, defaultStyle, reserve) {
2962
- range2.startRow < 0 || range2.startColumn < 0 || forEach(range2, (row, column) => {
2963
- var _a21, _b;
2964
- const rectangle = worksheet.getMergedCell(row, column);
2965
- let bdStyle = defaultStyle;
2966
- if (rectangle && (defaultStyle.bc_tr || defaultStyle.ml_tr || defaultStyle.bl_tr || defaultStyle.tl_mr || defaultStyle.tl_bc || defaultStyle.tl_br)) {
2967
- if (reserve) {
2968
- const style2 = Tools.deepClone(
2969
- (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s
2970
- );
2971
- bdStyle = style2 != null && style2.bd ? Object.assign(style2.bd, defaultStyle) : defaultStyle;
2972
- }
2973
- mr.setValue(rectangle.startRow, rectangle.startColumn, {
2974
- s: {
2975
- bd: bdStyle
2976
- }
2977
- });
2978
- } else {
2979
- if (reserve) {
2980
- const style2 = Tools.deepClone((_b = mr.getValue(row, column)) == null ? void 0 : _b.s);
2981
- bdStyle = style2 != null && style2.bd ? Object.assign(style2.bd, defaultStyle) : defaultStyle;
2982
- }
2983
- mr.setValue(row, column, { s: { bd: bdStyle } });
2984
- }
2985
- });
2986
- }
2987
- __name(setBorderStyle, "setBorderStyle"), top && (setBorderStyle(topRangeOut, { b: null }), setBorderStyle(topRange, { t: Tools.deepClone(border) }, !0)), bottom && (setBorderStyle(bottomRangeOut, { t: null }), setBorderStyle(bottomRange, { b: Tools.deepClone(border) }, !0)), left && (setBorderStyle(leftRangeOut, { r: null }), setBorderStyle(leftRange, { l: Tools.deepClone(border) }, !0)), right && (setBorderStyle(rightRangeOut, { l: null }), setBorderStyle(rightRange, { r: Tools.deepClone(border) }, !0)), tl_br && setBorderStyle(range, { tl_br: Tools.deepClone(border) }, !0), tl_bc && setBorderStyle(range, { tl_bc: Tools.deepClone(border) }, !0), tl_mr && setBorderStyle(range, { tl_mr: Tools.deepClone(border) }, !0), bl_tr && setBorderStyle(range, { bl_tr: Tools.deepClone(border) }, !0), ml_tr && setBorderStyle(range, { ml_tr: Tools.deepClone(border) }, !0), bc_tr && setBorderStyle(range, { bc_tr: Tools.deepClone(border) }, !0), vertical && forEach(range, (row, column) => {
2988
- var _a21, _b, _c, _d;
2989
- const rectangle = worksheet.getMergedCell(row, column);
2990
- if (rectangle) {
2991
- if (rectangle.endColumn !== range.endColumn) {
2992
- const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
2993
- mr.setValue(row, column, {
2994
- s: {
2995
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: Tools.deepClone(border) }) : { r: Tools.deepClone(border) }
2996
- }
2997
- });
2998
- }
2999
- if (rectangle.startColumn !== range.startColumn) {
3000
- const style2 = (_b = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _b.s;
3001
- mr.setValue(row, column, {
3002
- s: {
3003
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: Tools.deepClone(border) }) : { l: Tools.deepClone(border) }
3004
- }
3005
- });
3006
- }
3007
- } else {
3008
- if (column !== range.endColumn) {
3009
- const style2 = (_c = mr.getValue(row, column)) == null ? void 0 : _c.s;
3010
- mr.setValue(row, column, {
3011
- s: {
3012
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: Tools.deepClone(border) }) : { r: Tools.deepClone(border) }
3013
- }
3014
- });
3015
- }
3016
- if (column !== range.startColumn) {
3017
- const style2 = (_d = mr.getValue(row, column)) == null ? void 0 : _d.s;
3018
- mr.setValue(row, column, {
3019
- s: {
3020
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: Tools.deepClone(border) }) : { l: Tools.deepClone(border) }
3021
- }
3022
- });
3023
- }
3024
- }
3025
- }), horizontal && forEach(range, (row, column) => {
3026
- var _a21, _b, _c, _d;
3027
- const rectangle = worksheet.getMergedCell(row, column);
3028
- if (rectangle) {
3029
- if (rectangle.endRow !== range.endRow) {
3030
- const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
3031
- mr.setValue(row, column, {
3032
- s: {
3033
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: Tools.deepClone(border) }) : { b: Tools.deepClone(border) }
3034
- }
3035
- });
3036
- }
3037
- if (rectangle.startRow !== range.startRow) {
3038
- const style2 = (_b = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _b.s;
3039
- mr.setValue(row, column, {
3040
- s: {
3041
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: Tools.deepClone(border) }) : { t: Tools.deepClone(border) }
3042
- }
3043
- });
3044
- }
3045
- } else {
3046
- if (row !== range.endRow) {
3047
- const style2 = (_c = mr.getValue(row, column)) == null ? void 0 : _c.s;
3048
- mr.setValue(row, column, {
3049
- s: {
3050
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: Tools.deepClone(border) }) : { b: Tools.deepClone(border) }
3051
- }
3052
- });
3053
- }
3054
- if (row !== range.startRow) {
3055
- const style2 = (_d = mr.getValue(row, column)) == null ? void 0 : _d.s;
3056
- mr.setValue(row, column, {
3057
- s: {
3058
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: Tools.deepClone(border) }) : { t: Tools.deepClone(border) }
3059
- }
3060
- });
3061
- }
3062
- }
3063
- }), !top && !bottom && !left && !right && !vertical && !horizontal && !tl_br && !tl_bc && !tl_mr && !bl_tr && !ml_tr && !bc_tr && (setBorderStyle(topRangeOut, { b: null }), setBorderStyle(topRange, { t: null }, !0), setBorderStyle(bottomRangeOut, { t: null }), setBorderStyle(bottomRange, { b: null }, !0), setBorderStyle(leftRangeOut, { r: null }), setBorderStyle(leftRange, { l: null }, !0), setBorderStyle(rightRangeOut, { l: null }), setBorderStyle(rightRange, { r: null }, !0), setBorderStyle(range, { tl_br: null }, !0), setBorderStyle(range, { tl_bc: null }, !0), setBorderStyle(range, { tl_mr: null }, !0), setBorderStyle(range, { bl_tr: null }, !0), setBorderStyle(range, { ml_tr: null }, !0), setBorderStyle(range, { bc_tr: null }, !0), forEach(range, (row, column) => {
3064
- var _a21, _b, _c, _d, _e, _f, _g, _h;
3065
- const rectangle = worksheet.getMergedCell(row, column);
3066
- if (rectangle) {
3067
- if (rectangle.endColumn !== range.endColumn) {
3068
- const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
3069
- mr.setValue(row, column, {
3070
- s: {
3071
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: null }) : { r: null }
3072
- }
3073
- });
3074
- }
3075
- if (rectangle.startColumn !== range.startColumn) {
3076
- const style2 = (_b = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _b.s;
3077
- mr.setValue(row, column, {
3078
- s: {
3079
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: null }) : { l: null }
3080
- }
3081
- });
3082
- }
3083
- if (rectangle.endRow !== range.endRow) {
3084
- const style2 = (_c = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _c.s;
3085
- mr.setValue(row, column, {
3086
- s: {
3087
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: null }) : { b: null }
3088
- }
3089
- });
3090
- }
3091
- if (rectangle.startRow !== range.startRow) {
3092
- const style2 = (_d = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _d.s;
3093
- mr.setValue(row, column, {
3094
- s: {
3095
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: null }) : { t: null }
3096
- }
3097
- });
3098
- }
3099
- } else {
3100
- if (column !== range.endColumn) {
3101
- const style2 = (_e = mr.getValue(row, column)) == null ? void 0 : _e.s;
3102
- mr.setValue(row, column, {
3103
- s: {
3104
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: null }) : { r: null }
3105
- }
3106
- });
3107
- }
3108
- if (column !== range.startColumn) {
3109
- const style2 = (_f = mr.getValue(row, column)) == null ? void 0 : _f.s;
3110
- mr.setValue(row, column, {
3111
- s: {
3112
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: null }) : { l: null }
3113
- }
3114
- });
3115
- }
3116
- if (row !== range.endRow) {
3117
- const style2 = (_g = mr.getValue(row, column)) == null ? void 0 : _g.s;
3118
- mr.setValue(row, column, {
3119
- s: {
3120
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: null }) : { b: null }
3121
- }
3122
- });
3123
- }
3124
- if (row !== range.startRow) {
3125
- const style2 = (_h = mr.getValue(row, column)) == null ? void 0 : _h.s;
3126
- mr.setValue(row, column, {
3127
- s: {
3128
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: null }) : { t: null }
3129
- }
3130
- });
3131
- }
3132
- }
3133
- }));
3134
- const setRangeValuesMutationParams = {
3218
+ const { unitId, subUnitId, value } = params, { type, color, style } = value, commandService = accessor.get(ICommandService), borderManager = accessor.get(BorderStyleManagerService);
3219
+ return borderManager.setType(type), color && borderManager.setColor(color), borderManager.setStyle(style), commandService.executeCommand(SetBorderCommand.id, {
3135
3220
  unitId,
3136
- subUnitId,
3137
- cellValue: mr.getData()
3138
- }, undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(
3139
- accessor,
3140
- setRangeValuesMutationParams
3141
- );
3142
- return commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams) ? (undoRedoService.pushUndoRedo({
3143
- unitID: unitId,
3144
- undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }],
3145
- redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }]
3146
- }), !0) : !1;
3221
+ subUnitId
3222
+ });
3147
3223
  }, "handler")
3148
3224
  }, SetColHiddenUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3149
3225
  if (accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId) == null)
@@ -3199,7 +3275,7 @@ const SetBorderBasicCommand = {
3199
3275
  type: CommandType.COMMAND,
3200
3276
  id: "sheet.command.set-col-visible-on-cols",
3201
3277
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3202
- var _a20, _b;
3278
+ var _a21, _b;
3203
3279
  const { unitId, subUnitId, ranges } = params, sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), instanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(instanceService, { unitId, subUnitId });
3204
3280
  if (!target) return !1;
3205
3281
  const { worksheet } = target, redoMutationParams = {
@@ -3231,7 +3307,7 @@ const SetBorderBasicCommand = {
3231
3307
  undoMutations: [
3232
3308
  { id: SetColHiddenMutation.id, params: undoMutationParams },
3233
3309
  { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
3234
- ...(_a20 = intercepted.undos) != null ? _a20 : []
3310
+ ...(_a21 = intercepted.undos) != null ? _a21 : []
3235
3311
  ],
3236
3312
  redoMutations: [
3237
3313
  ...(_b = intercepted.preRedos) != null ? _b : [],
@@ -3245,8 +3321,8 @@ const SetBorderBasicCommand = {
3245
3321
  type: CommandType.COMMAND,
3246
3322
  id: "sheet.command.set-selected-cols-visible",
3247
3323
  handler: /* @__PURE__ */ __name(async (accessor) => {
3248
- var _a20;
3249
- const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), ranges = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
3324
+ var _a21;
3325
+ const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), ranges = (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
3250
3326
  if (!(ranges != null && ranges.length)) return !1;
3251
3327
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
3252
3328
  if (!target) return !1;
@@ -3261,9 +3337,9 @@ const SetBorderBasicCommand = {
3261
3337
  type: CommandType.COMMAND,
3262
3338
  id: "sheet.command.set-col-hidden",
3263
3339
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3264
- var _a20, _b, _c, _d;
3340
+ var _a21, _b, _c, _d;
3265
3341
  const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
3266
- let ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
3342
+ let ranges = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.COLUMN);
3267
3343
  if (!(ranges != null && ranges.length)) return !1;
3268
3344
  const target = getSheetCommandTarget(univerInstanceService, params);
3269
3345
  if (!target) return !1;
@@ -3374,8 +3450,8 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3374
3450
  }, SetFrozenCommand = {
3375
3451
  type: CommandType.COMMAND,
3376
3452
  id: "sheet.command.set-frozen",
3377
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
3378
- const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
3453
+ handler: /* @__PURE__ */ __name((accessor, params) => {
3454
+ const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, { unitId: params.unitId, subUnitId: params.subUnitId });
3379
3455
  if (!target) return !1;
3380
3456
  const { unitId, subUnitId, worksheet } = target, { startColumn, startRow, xSplit, ySplit } = params;
3381
3457
  if (startRow >= worksheet.getRowCount() || startColumn >= worksheet.getColumnCount() || xSplit >= worksheet.getColumnCount() || ySplit >= worksheet.getRowCount())
@@ -3394,7 +3470,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3394
3470
  }, SetFrozenCancelCommand = {
3395
3471
  type: CommandType.COMMAND,
3396
3472
  id: "sheet.command.set-frozen-cancel",
3397
- handler: /* @__PURE__ */ __name(async (accessor) => {
3473
+ handler: /* @__PURE__ */ __name((accessor) => {
3398
3474
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
3399
3475
  if (!target) return !1;
3400
3476
  const { unitId, subUnitId } = target, redoMutationParams = {
@@ -3465,7 +3541,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3465
3541
  type: CommandType.COMMAND,
3466
3542
  id: "sheet.command.set-specific-rows-visible",
3467
3543
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3468
- var _a20, _b, _c;
3544
+ var _a21, _b, _c;
3469
3545
  const { unitId, subUnitId, ranges } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), { unitId, subUnitId });
3470
3546
  if (!target) return !1;
3471
3547
  const { worksheet } = target, redoMutationParams = { unitId, subUnitId, ranges }, setSelectionOperationParams = {
@@ -3498,7 +3574,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3498
3574
  return result.result && interceptedResult.result && undoRedoService.pushUndoRedo({
3499
3575
  unitID: unitId,
3500
3576
  undoMutations: [
3501
- ...(_a20 = intercepted.preUndos) != null ? _a20 : [],
3577
+ ...(_a21 = intercepted.preUndos) != null ? _a21 : [],
3502
3578
  { id: SetRowHiddenMutation.id, params: undoMutationParams },
3503
3579
  { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
3504
3580
  ...(_b = intercepted.undos) != null ? _b : []
@@ -3515,8 +3591,8 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3515
3591
  type: CommandType.COMMAND,
3516
3592
  id: "sheet.command.set-selected-rows-visible",
3517
3593
  handler: /* @__PURE__ */ __name(async (accessor) => {
3518
- var _a20;
3519
- const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), ranges = (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
3594
+ var _a21;
3595
+ const selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService), ranges = (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
3520
3596
  if (!(ranges != null && ranges.length)) return !1;
3521
3597
  const target = getSheetCommandTarget(univerInstanceService);
3522
3598
  if (!target) return !1;
@@ -3531,9 +3607,9 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3531
3607
  type: CommandType.COMMAND,
3532
3608
  id: "sheet.command.set-rows-hidden",
3533
3609
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3534
- var _a20, _b, _c, _d, _e, _f;
3610
+ var _a21, _b, _c, _d, _e, _f;
3535
3611
  const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService);
3536
- let ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
3612
+ let ranges = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range).filter((r) => r.rangeType === RANGE_TYPE.ROW);
3537
3613
  if (!(ranges != null && ranges.length)) return !1;
3538
3614
  const target = getSheetCommandTarget(univerInstanceService, params);
3539
3615
  if (!target) return !1;
@@ -3619,10 +3695,10 @@ const SetStyleCommand = {
3619
3695
  type: CommandType.COMMAND,
3620
3696
  id: "sheet.command.set-style",
3621
3697
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3622
- var _a20;
3698
+ var _a21;
3623
3699
  const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
3624
3700
  if (!target) return !1;
3625
- const { unitId, subUnitId, worksheet } = target, { range, style } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), ranges = range ? [range] : (_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
3701
+ const { unitId, subUnitId, worksheet } = target, { range, style } = params, commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), ranges = range ? [range] : (_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
3626
3702
  if (!(ranges != null && ranges.length))
3627
3703
  return !1;
3628
3704
  const cellValue = new ObjectMatrix(), iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
@@ -3998,7 +4074,7 @@ const SetStyleCommand = {
3998
4074
  id: "sheet.mutation.set-worksheet-col-width",
3999
4075
  type: CommandType.MUTATION,
4000
4076
  handler: /* @__PURE__ */ __name((accessor, params) => {
4001
- var _a20;
4077
+ var _a21;
4002
4078
  const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4003
4079
  if (!target) return !1;
4004
4080
  const { worksheet } = target, defaultColumnWidth = worksheet.getConfig().defaultColumnWidth, manager = worksheet.getColumnManager(), ranges = params.ranges;
@@ -4006,7 +4082,7 @@ const SetStyleCommand = {
4006
4082
  const range = ranges[i];
4007
4083
  for (let j = range.startColumn; j < range.endColumn + 1; j++) {
4008
4084
  const column = manager.getColumnOrCreate(j);
4009
- typeof params.colWidth == "number" ? column.w = params.colWidth : column.w = (_a20 = params.colWidth[j]) != null ? _a20 : defaultColumnWidth;
4085
+ typeof params.colWidth == "number" ? column.w = params.colWidth : column.w = (_a21 = params.colWidth[j]) != null ? _a21 : defaultColumnWidth;
4010
4086
  }
4011
4087
  }
4012
4088
  return !0;
@@ -4074,8 +4150,8 @@ const SetStyleCommand = {
4074
4150
  type: CommandType.COMMAND,
4075
4151
  id: "sheet.command.set-worksheet-col-width",
4076
4152
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4077
- var _a20, _b, _c, _d;
4078
- const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4153
+ var _a21, _b, _c, _d;
4154
+ const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4079
4155
  if (!(selections != null && selections.length)) return !1;
4080
4156
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
4081
4157
  if (!target) return !1;
@@ -4160,7 +4236,7 @@ const SetStyleCommand = {
4160
4236
  type: CommandType.COMMAND,
4161
4237
  id: "sheet.command.set-worksheet-name",
4162
4238
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4163
- var _a20, _b;
4239
+ var _a21, _b;
4164
4240
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
4165
4241
  if (!target) return !1;
4166
4242
  const { unitId, subUnitId } = target, redoMutationParams = {
@@ -4174,7 +4250,7 @@ const SetStyleCommand = {
4174
4250
  id: SetWorksheetNameCommand.id,
4175
4251
  params
4176
4252
  }), redos = [
4177
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
4253
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
4178
4254
  { id: SetWorksheetNameMutation.id, params: redoMutationParams },
4179
4255
  ...interceptorCommands.redos
4180
4256
  ], undos = [
@@ -4260,14 +4336,14 @@ const SetStyleCommand = {
4260
4336
  id: "sheet.mutation.set-worksheet-row-height",
4261
4337
  type: CommandType.MUTATION,
4262
4338
  handler: /* @__PURE__ */ __name((accessor, params) => {
4263
- var _a20;
4339
+ var _a21;
4264
4340
  const { ranges, rowHeight } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4265
4341
  if (!target) return !1;
4266
4342
  const { worksheet } = target, manager = worksheet.getRowManager(), defaultRowHeight = worksheet.getConfig().defaultRowHeight;
4267
4343
  for (const { startRow, endRow } of ranges)
4268
4344
  for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
4269
4345
  const row = manager.getRowOrCreate(rowIndex);
4270
- typeof rowHeight == "number" ? row.h = rowHeight : row.h = (_a20 = rowHeight[rowIndex]) != null ? _a20 : defaultRowHeight, row.h = Math.min(MAXIMUM_ROW_HEIGHT, row.h);
4346
+ typeof rowHeight == "number" ? row.h = rowHeight : row.h = (_a21 = rowHeight[rowIndex]) != null ? _a21 : defaultRowHeight, row.h = Math.min(MAXIMUM_ROW_HEIGHT, row.h);
4271
4347
  }
4272
4348
  return !0;
4273
4349
  }, "handler")
@@ -4275,14 +4351,14 @@ const SetStyleCommand = {
4275
4351
  id: "sheet.mutation.set-worksheet-row-is-auto-height",
4276
4352
  type: CommandType.MUTATION,
4277
4353
  handler: /* @__PURE__ */ __name((accessor, params) => {
4278
- var _a20;
4354
+ var _a21;
4279
4355
  const { ranges, autoHeightInfo } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4280
4356
  if (!target) return !1;
4281
4357
  const manager = target.worksheet.getRowManager();
4282
4358
  for (const { startRow, endRow } of ranges)
4283
4359
  for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
4284
4360
  const row = manager.getRowOrCreate(rowIndex);
4285
- typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a20 = autoHeightInfo[rowIndex]) != null ? _a20 : void 0;
4361
+ typeof autoHeightInfo == "number" ? row.ia = autoHeightInfo : row.ia = (_a21 = autoHeightInfo[rowIndex]) != null ? _a21 : void 0;
4286
4362
  }
4287
4363
  return !0;
4288
4364
  }, "handler")
@@ -4304,7 +4380,7 @@ const SetStyleCommand = {
4304
4380
  id: "sheet.command.delta-row-height",
4305
4381
  // eslint-disable-next-line max-lines-per-function
4306
4382
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4307
- var _a20, _b;
4383
+ var _a21, _b;
4308
4384
  const selections = accessor.get(SheetsSelectionsService).getCurrentSelections(), sheetInterceptorService = accessor.get(SheetInterceptorService);
4309
4385
  if (!(selections != null && selections.length))
4310
4386
  return !1;
@@ -4364,7 +4440,7 @@ const SetStyleCommand = {
4364
4440
  return result.result && interceptedResult.result ? (undoRedoService.pushUndoRedo({
4365
4441
  unitID: unitId,
4366
4442
  undoMutations: [
4367
- ...(_a20 = intercepted.preUndos) != null ? _a20 : [],
4443
+ ...(_a21 = intercepted.preUndos) != null ? _a21 : [],
4368
4444
  {
4369
4445
  id: SetWorksheetRowHeightMutation.id,
4370
4446
  params: undoMutationParams
@@ -4394,8 +4470,8 @@ const SetStyleCommand = {
4394
4470
  id: "sheet.command.set-row-height",
4395
4471
  // eslint-disable-next-line max-lines-per-function
4396
4472
  handler: /* @__PURE__ */ __name((accessor, params) => {
4397
- var _a20, _b, _c, _d;
4398
- const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4473
+ var _a21, _b, _c, _d;
4474
+ const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService), selections = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4399
4475
  if (!(selections != null && selections.length))
4400
4476
  return !1;
4401
4477
  const target = getSheetCommandTarget(univerInstanceService, params);
@@ -4455,10 +4531,10 @@ const SetStyleCommand = {
4455
4531
  type: CommandType.COMMAND,
4456
4532
  id: "sheet.command.set-row-is-auto-height",
4457
4533
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4458
- var _a20, _b;
4534
+ var _a21, _b;
4459
4535
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4460
4536
  if (!target) return !1;
4461
- const { unitId, subUnitId, worksheet } = target, ranges = (_a20 = params == null ? void 0 : params.ranges) != null && _a20.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4537
+ const { unitId, subUnitId, worksheet } = target, ranges = (_a21 = params == null ? void 0 : params.ranges) != null && _a21.length ? params.ranges : (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range);
4462
4538
  if (!(ranges != null && ranges.length))
4463
4539
  return !1;
4464
4540
  const redoMutationParams = {
@@ -4751,7 +4827,7 @@ const factorySetNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) =
4751
4827
  type: CommandType.COMMAND,
4752
4828
  id: "sheet.command.set-workbook-name",
4753
4829
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4754
- var _a20;
4830
+ var _a21;
4755
4831
  if (!accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET)) return !1;
4756
4832
  const interceptedCommands = accessor.get(SheetInterceptorService).onCommandExecute({
4757
4833
  id: SetWorkbookNameCommand.id,
@@ -4760,18 +4836,18 @@ const factorySetNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) =
4760
4836
  name: params.name,
4761
4837
  unitId: params.unitId
4762
4838
  }, redos = [
4763
- ...(_a20 = interceptedCommands.preRedos) != null ? _a20 : [],
4839
+ ...(_a21 = interceptedCommands.preRedos) != null ? _a21 : [],
4764
4840
  { id: SetWorkbookNameMutation.id, params: redoMutationParams },
4765
4841
  ...interceptedCommands.redos
4766
4842
  ], commandService = accessor.get(ICommandService);
4767
4843
  return sequenceExecute(redos, commandService).result;
4768
4844
  }, "handler")
4769
4845
  };
4770
- var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4771
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4846
+ var __defProp$g = Object.defineProperty, __getOwnPropDesc$g = Object.getOwnPropertyDescriptor, __decorateClass$g = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4847
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$g(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4772
4848
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4773
- return kind && result && __defProp$f(target, key, result), result;
4774
- }, "__decorateClass$f"), _a4;
4849
+ return kind && result && __defProp$g(target, key, result), result;
4850
+ }, "__decorateClass$g"), _a4;
4775
4851
  let WorksheetProtectionRuleModel = (_a4 = class {
4776
4852
  constructor() {
4777
4853
  /**
@@ -4798,18 +4874,18 @@ let WorksheetProtectionRuleModel = (_a4 = class {
4798
4874
  this._ensureSubUnitMap(unitId).set(rule.subUnitId, rule), this._ruleChange.next({ unitId, rule, type: "add", subUnitId: rule.subUnitId });
4799
4875
  }
4800
4876
  deleteRule(unitId, subUnitId) {
4801
- var _a20, _b, _c;
4802
- const rule = (_b = (_a20 = this._model) == null ? void 0 : _a20.get(unitId)) == null ? void 0 : _b.get(subUnitId);
4877
+ var _a21, _b, _c;
4878
+ const rule = (_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null ? void 0 : _b.get(subUnitId);
4803
4879
  rule && ((_c = this._model.get(unitId)) == null || _c.delete(subUnitId), this._ruleChange.next({ unitId, rule, type: "delete", subUnitId }));
4804
4880
  }
4805
4881
  setRule(unitId, subUnitId, rule) {
4806
- var _a20, _b;
4882
+ var _a21, _b;
4807
4883
  const oldRule = this.getRule(unitId, subUnitId);
4808
- oldRule && ((_b = (_a20 = this._model) == null ? void 0 : _a20.get(unitId)) == null || _b.set(subUnitId, rule), this._ruleChange.next({ unitId, oldRule, rule, type: "set", subUnitId }));
4884
+ oldRule && ((_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null || _b.set(subUnitId, rule), this._ruleChange.next({ unitId, oldRule, rule, type: "set", subUnitId }));
4809
4885
  }
4810
4886
  getRule(unitId, subUnitId) {
4811
- var _a20, _b;
4812
- return (_b = (_a20 = this._model) == null ? void 0 : _a20.get(unitId)) == null ? void 0 : _b.get(subUnitId);
4887
+ var _a21, _b;
4888
+ return (_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null ? void 0 : _b.get(subUnitId);
4813
4889
  }
4814
4890
  toObject() {
4815
4891
  const result = {};
@@ -4854,7 +4930,7 @@ let WorksheetProtectionRuleModel = (_a4 = class {
4854
4930
  return [unitId, subUnitId];
4855
4931
  }
4856
4932
  }, __name(_a4, "WorksheetProtectionRuleModel"), _a4);
4857
- WorksheetProtectionRuleModel = __decorateClass$f([
4933
+ WorksheetProtectionRuleModel = __decorateClass$g([
4858
4934
  OnLifecycle(LifecycleStages.Starting, WorksheetProtectionRuleModel)
4859
4935
  ], WorksheetProtectionRuleModel);
4860
4936
  const AddWorksheetProtectionMutation = {
@@ -4879,11 +4955,11 @@ const AddWorksheetProtectionMutation = {
4879
4955
  return accessor.get(WorksheetProtectionRuleModel).deleteRule(unitId, subUnitId), !0;
4880
4956
  }, "handler")
4881
4957
  };
4882
- var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4883
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4958
+ var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4959
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$f(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
4884
4960
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4885
- return kind && result && __defProp$e(target, key, result), result;
4886
- }, "__decorateClass$e"), _a5;
4961
+ return kind && result && __defProp$f(target, key, result), result;
4962
+ }, "__decorateClass$f"), _a5;
4887
4963
  let RangeProtectionRuleModel = (_a5 = class {
4888
4964
  constructor() {
4889
4965
  /**
@@ -4911,22 +4987,27 @@ let RangeProtectionRuleModel = (_a5 = class {
4911
4987
  this._ensureRuleMap(unitId, subUnitId).set(rule.id, rule), this._ruleChange.next({ unitId, subUnitId, rule, type: "add" });
4912
4988
  }
4913
4989
  deleteRule(unitId, subUnitId, id) {
4914
- var _a20, _b, _c, _d;
4915
- const rule = (_b = (_a20 = this._model.get(unitId)) == null ? void 0 : _a20.get(subUnitId)) == null ? void 0 : _b.get(id);
4990
+ var _a21, _b, _c, _d;
4991
+ const rule = (_b = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null ? void 0 : _b.get(id);
4916
4992
  rule && ((_d = (_c = this._model.get(unitId)) == null ? void 0 : _c.get(subUnitId)) == null || _d.delete(id), this._ruleChange.next({ unitId, subUnitId, rule, type: "delete" }));
4917
4993
  }
4918
4994
  setRule(unitId, subUnitId, id, rule) {
4919
- var _a20, _b;
4995
+ var _a21, _b;
4920
4996
  const oldRule = this.getRule(unitId, subUnitId, id);
4921
- oldRule && ((_b = (_a20 = this._model.get(unitId)) == null ? void 0 : _a20.get(subUnitId)) == null || _b.set(id, rule), this._ruleChange.next({ unitId, subUnitId, oldRule, rule, type: "set" }));
4997
+ oldRule && ((_b = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null || _b.set(id, rule), this._ruleChange.next({ unitId, subUnitId, oldRule, rule, type: "set" }));
4922
4998
  }
4923
4999
  getRule(unitId, subUnitId, id) {
4924
- var _a20, _b;
4925
- return (_b = (_a20 = this._model.get(unitId)) == null ? void 0 : _a20.get(subUnitId)) == null ? void 0 : _b.get(id);
5000
+ var _a21, _b;
5001
+ return (_b = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null ? void 0 : _b.get(id);
4926
5002
  }
4927
5003
  getSubunitRuleList(unitId, subUnitId) {
4928
- var _a20;
4929
- return [...(((_a20 = this._model.get(unitId)) == null ? void 0 : _a20.get(subUnitId)) || /* @__PURE__ */ new Map()).values()];
5004
+ var _a21;
5005
+ return [...(((_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) || /* @__PURE__ */ new Map()).values()];
5006
+ }
5007
+ getSubunitRuleListLength(unitId, subUnitId) {
5008
+ var _a21;
5009
+ const map2 = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId);
5010
+ return map2 ? map2.size : 0;
4930
5011
  }
4931
5012
  _ensureRuleMap(unitId, subUnitId) {
4932
5013
  let subUnitMap = this._model.get(unitId);
@@ -4974,7 +5055,7 @@ let RangeProtectionRuleModel = (_a5 = class {
4974
5055
  return null;
4975
5056
  }
4976
5057
  }, __name(_a5, "RangeProtectionRuleModel"), _a5);
4977
- RangeProtectionRuleModel = __decorateClass$e([
5058
+ RangeProtectionRuleModel = __decorateClass$f([
4978
5059
  OnLifecycle(LifecycleStages.Starting, RangeProtectionRuleModel)
4979
5060
  ], RangeProtectionRuleModel);
4980
5061
  const getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
@@ -5011,11 +5092,11 @@ const getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
5011
5092
  P.SetRowStyle,
5012
5093
  P.Sort
5013
5094
  ];
5014
- var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5015
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5095
+ var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5096
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$e(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5016
5097
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5017
- return kind && result && __defProp$d(target, key, result), result;
5018
- }, "__decorateClass$d"), _a6;
5098
+ return kind && result && __defProp$e(target, key, result), result;
5099
+ }, "__decorateClass$e"), _a6;
5019
5100
  let WorksheetProtectionPointModel = (_a6 = class {
5020
5101
  constructor() {
5021
5102
  __publicField(this, "_model", /* @__PURE__ */ new Map());
@@ -5026,13 +5107,13 @@ let WorksheetProtectionPointModel = (_a6 = class {
5026
5107
  this._ensureSubUnitMap(rule.unitId).set(rule.subUnitId, rule), this._pointChange.next(rule);
5027
5108
  }
5028
5109
  deleteRule(unitId, subUnitId) {
5029
- var _a20, _b, _c;
5030
- const rule = (_a20 = this._model.get(unitId)) == null ? void 0 : _a20.get(subUnitId);
5110
+ var _a21, _b, _c;
5111
+ const rule = (_a21 = this._model.get(unitId)) == null ? void 0 : _a21.get(subUnitId);
5031
5112
  rule && ((_c = (_b = this._model) == null ? void 0 : _b.get(unitId)) == null || _c.delete(subUnitId), this._pointChange.next(rule));
5032
5113
  }
5033
5114
  getRule(unitId, subUnitId) {
5034
- var _a20, _b;
5035
- return (_b = (_a20 = this._model) == null ? void 0 : _a20.get(unitId)) == null ? void 0 : _b.get(subUnitId);
5115
+ var _a21, _b;
5116
+ return (_b = (_a21 = this._model) == null ? void 0 : _a21.get(unitId)) == null ? void 0 : _b.get(subUnitId);
5036
5117
  }
5037
5118
  toObject() {
5038
5119
  const result = {};
@@ -5071,14 +5152,14 @@ let WorksheetProtectionPointModel = (_a6 = class {
5071
5152
  return [unitId, subUnitId];
5072
5153
  }
5073
5154
  }, __name(_a6, "WorksheetProtectionPointModel"), _a6);
5074
- WorksheetProtectionPointModel = __decorateClass$d([
5155
+ WorksheetProtectionPointModel = __decorateClass$e([
5075
5156
  OnLifecycle(LifecycleStages.Starting, WorksheetProtectionPointModel)
5076
5157
  ], WorksheetProtectionPointModel);
5077
- var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5078
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5158
+ var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5159
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$d(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5079
5160
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5080
- return kind && result && __defProp$c(target, key, result), result;
5081
- }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c");
5161
+ return kind && result && __defProp$d(target, key, result), result;
5162
+ }, "__decorateClass$d"), __decorateParam$d = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$d");
5082
5163
  const RULE_MODEL_PLUGIN_NAME = "SHEET_WORKSHEET_PROTECTION_PLUGIN", POINT_MODEL_PLUGIN_NAME = "SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN";
5083
5164
  var _a7;
5084
5165
  let WorksheetPermissionService = (_a7 = class extends RxDisposable {
@@ -5214,15 +5295,15 @@ let WorksheetPermissionService = (_a7 = class extends RxDisposable {
5214
5295
  );
5215
5296
  }
5216
5297
  }, __name(_a7, "WorksheetPermissionService"), _a7);
5217
- WorksheetPermissionService = __decorateClass$c([
5298
+ WorksheetPermissionService = __decorateClass$d([
5218
5299
  OnLifecycle(LifecycleStages.Starting, WorksheetPermissionService),
5219
- __decorateParam$c(0, Inject(IPermissionService)),
5220
- __decorateParam$c(1, Inject(IUniverInstanceService)),
5221
- __decorateParam$c(2, Inject(Injector)),
5222
- __decorateParam$c(3, Inject(WorksheetProtectionRuleModel)),
5223
- __decorateParam$c(4, Inject(WorksheetProtectionPointModel)),
5224
- __decorateParam$c(5, Inject(IResourceManagerService)),
5225
- __decorateParam$c(6, Inject(RangeProtectionRuleModel))
5300
+ __decorateParam$d(0, Inject(IPermissionService)),
5301
+ __decorateParam$d(1, Inject(IUniverInstanceService)),
5302
+ __decorateParam$d(2, Inject(Injector)),
5303
+ __decorateParam$d(3, Inject(WorksheetProtectionRuleModel)),
5304
+ __decorateParam$d(4, Inject(WorksheetProtectionPointModel)),
5305
+ __decorateParam$d(5, Inject(IResourceManagerService)),
5306
+ __decorateParam$d(6, Inject(RangeProtectionRuleModel))
5226
5307
  ], WorksheetPermissionService);
5227
5308
  const SetWorksheetPermissionPointsMutation = {
5228
5309
  id: "sheet.mutation.set-worksheet-permission-points",
@@ -5404,7 +5485,7 @@ const SetWorksheetPermissionPointsMutation = {
5404
5485
  id: ReorderRangeCommandId,
5405
5486
  type: CommandType.COMMAND,
5406
5487
  handler: /* @__PURE__ */ __name((accessor, params) => {
5407
- var _a20, _b;
5488
+ var _a21, _b;
5408
5489
  const { subUnitId, unitId, range, order } = params, commandService = accessor.get(ICommandService), reorderMutation = {
5409
5490
  id: ReorderRangeMutation.id,
5410
5491
  params: {
@@ -5417,7 +5498,7 @@ const SetWorksheetPermissionPointsMutation = {
5417
5498
  id: ReorderRangeMutation.id,
5418
5499
  params: ReorderRangeUndoMutationFactory(reorderMutation.params)
5419
5500
  }, interceptorCommands = accessor.get(SheetInterceptorService).onCommandExecute({ id: ReorderRangeCommand.id, params }), redos = [
5420
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
5501
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
5421
5502
  reorderMutation,
5422
5503
  ...interceptorCommands.redos
5423
5504
  ], undos = [
@@ -5432,15 +5513,15 @@ const SetWorksheetPermissionPointsMutation = {
5432
5513
  }), !0) : !1;
5433
5514
  }, "handler")
5434
5515
  }, MAX_CELL_PER_SHEET_KEY = "maxCellsPerSheet", MAX_CELL_PER_SHEET_DEFAULT = 3e6, ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY = "ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY";
5435
- var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5436
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5516
+ var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5517
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$c(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5437
5518
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5438
- return kind && result && __defProp$b(target, key, result), result;
5439
- }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a8;
5519
+ return kind && result && __defProp$c(target, key, result), result;
5520
+ }, "__decorateClass$c"), __decorateParam$c = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$c"), _a8;
5440
5521
  let BasicWorksheetController = (_a8 = class extends Disposable {
5441
5522
  // eslint-disable-next-line max-lines-per-function
5442
5523
  constructor(_commandService, _configService, _dataSyncPrimaryController) {
5443
- var _a20;
5524
+ var _a21;
5444
5525
  super(), this._commandService = _commandService, this._configService = _configService, this._dataSyncPrimaryController = _dataSyncPrimaryController, [
5445
5526
  SetRangeValuesMutation,
5446
5527
  InsertColMutation,
@@ -5462,9 +5543,9 @@ let BasicWorksheetController = (_a8 = class extends Disposable {
5462
5543
  EmptyMutation,
5463
5544
  SetWorksheetColWidthMutation
5464
5545
  ].forEach((mutation) => {
5465
- var _a21;
5466
- this._commandService.registerCommand(mutation), (_a21 = this._dataSyncPrimaryController) == null || _a21.registerSyncingMutations(mutation);
5467
- }), ((_a20 = this._configService.getConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY)) != null ? _a20 : !1) || [
5546
+ var _a22;
5547
+ this._commandService.registerCommand(mutation), (_a22 = this._dataSyncPrimaryController) == null || _a22.registerSyncingMutations(mutation);
5548
+ }), ((_a21 = this._configService.getConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY)) != null ? _a21 : !1) || [
5468
5549
  ClearSelectionAllCommand,
5469
5550
  ClearSelectionContentCommand,
5470
5551
  ClearSelectionFormatCommand,
@@ -5555,17 +5636,17 @@ let BasicWorksheetController = (_a8 = class extends Disposable {
5555
5636
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command))), this._configService.setConfig(MAX_CELL_PER_SHEET_KEY, MAX_CELL_PER_SHEET_DEFAULT);
5556
5637
  }
5557
5638
  }, __name(_a8, "BasicWorksheetController"), _a8);
5558
- BasicWorksheetController = __decorateClass$b([
5639
+ BasicWorksheetController = __decorateClass$c([
5559
5640
  OnLifecycle(LifecycleStages.Starting, BasicWorksheetController),
5560
- __decorateParam$b(0, ICommandService),
5561
- __decorateParam$b(1, IConfigService),
5562
- __decorateParam$b(2, Optional(DataSyncPrimaryController))
5641
+ __decorateParam$c(0, ICommandService),
5642
+ __decorateParam$c(1, IConfigService),
5643
+ __decorateParam$c(2, Optional(DataSyncPrimaryController))
5563
5644
  ], BasicWorksheetController);
5564
- var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5565
- for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5645
+ var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5646
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$b(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5566
5647
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5567
- return kind && result && __defProp$a(target, key, result), result;
5568
- }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a"), _a9;
5648
+ return kind && result && __defProp$b(target, key, result), result;
5649
+ }, "__decorateClass$b"), __decorateParam$b = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$b"), _a9;
5569
5650
  let CalculateResultApplyController = (_a9 = class extends Disposable {
5570
5651
  constructor(_univerInstanceService, _commandService) {
5571
5652
  super(), this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._initialize();
@@ -5617,11 +5698,60 @@ let CalculateResultApplyController = (_a9 = class extends Disposable {
5617
5698
  }), cellDataMatrix.clone();
5618
5699
  }
5619
5700
  }, __name(_a9, "CalculateResultApplyController"), _a9);
5620
- CalculateResultApplyController = __decorateClass$a([
5701
+ CalculateResultApplyController = __decorateClass$b([
5621
5702
  OnLifecycle(LifecycleStages.Ready, CalculateResultApplyController),
5622
- __decorateParam$a(0, Inject(IUniverInstanceService)),
5623
- __decorateParam$a(1, ICommandService)
5703
+ __decorateParam$b(0, Inject(IUniverInstanceService)),
5704
+ __decorateParam$b(1, ICommandService)
5624
5705
  ], CalculateResultApplyController);
5706
+ const PLUGIN_CONFIG_KEY = "sheets.config", defaultPluginConfig = {};
5707
+ var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5708
+ for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$a(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
5709
+ (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5710
+ return kind && result && __defProp$a(target, key, result), result;
5711
+ }, "__decorateClass$a"), __decorateParam$a = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$a");
5712
+ const SHEET_DEFINED_NAME_PLUGIN = "SHEET_DEFINED_NAME_PLUGIN";
5713
+ var _a10;
5714
+ let DefinedNameDataController = (_a10 = class extends Disposable {
5715
+ constructor(_definedNamesService, _resourceManagerService) {
5716
+ super(), this._definedNamesService = _definedNamesService, this._resourceManagerService = _resourceManagerService, this._initialize();
5717
+ }
5718
+ _initialize() {
5719
+ this._initSnapshot();
5720
+ }
5721
+ _initSnapshot() {
5722
+ const toJson = /* @__PURE__ */ __name((unitId) => {
5723
+ const map2 = this._definedNamesService.getDefinedNameMap(unitId);
5724
+ return map2 ? JSON.stringify(map2) : "";
5725
+ }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
5726
+ if (!json)
5727
+ return {};
5728
+ try {
5729
+ return JSON.parse(json);
5730
+ } catch {
5731
+ return {};
5732
+ }
5733
+ }, "parseJson");
5734
+ this.disposeWithMe(
5735
+ this._resourceManagerService.registerPluginResource({
5736
+ pluginName: SHEET_DEFINED_NAME_PLUGIN,
5737
+ businesses: [UniverInstanceType.UNIVER_SHEET],
5738
+ toJson: /* @__PURE__ */ __name((unitId) => toJson(unitId), "toJson"),
5739
+ parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
5740
+ onUnLoad: /* @__PURE__ */ __name((unitId) => {
5741
+ this._definedNamesService.removeUnitDefinedName(unitId);
5742
+ }, "onUnLoad"),
5743
+ onLoad: /* @__PURE__ */ __name((unitId, value) => {
5744
+ this._definedNamesService.registerDefinedNames(unitId, value);
5745
+ }, "onLoad")
5746
+ })
5747
+ );
5748
+ }
5749
+ }, __name(_a10, "DefinedNameDataController"), _a10);
5750
+ DefinedNameDataController = __decorateClass$a([
5751
+ OnLifecycle(LifecycleStages.Ready, DefinedNameDataController),
5752
+ __decorateParam$a(0, IDefinedNamesService),
5753
+ __decorateParam$a(1, IResourceManagerService)
5754
+ ], DefinedNameDataController);
5625
5755
  const EffectRefRangId = {
5626
5756
  MoveRangeCommandId,
5627
5757
  InsertRowCommandId,
@@ -5717,9 +5847,9 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5717
5847
  });
5718
5848
  const cacheMatrix = new ObjectMatrix();
5719
5849
  return Range.foreach(range, (row, col) => {
5720
- var _a20;
5850
+ var _a21;
5721
5851
  if (order.hasOwnProperty(row)) {
5722
- const targetRow = order[row], cloneCell = (_a20 = matrix.getValue(targetRow, col)) != null ? _a20 : 0;
5852
+ const targetRow = order[row], cloneCell = (_a21 = matrix.getValue(targetRow, col)) != null ? _a21 : 0;
5723
5853
  cacheMatrix.setValue(row, col, cloneCell);
5724
5854
  }
5725
5855
  }), cacheMatrix.forValue((row, col, cellData) => {
@@ -5754,8 +5884,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5754
5884
  matrix.setValue(row, col, 1);
5755
5885
  }), matrix.moveColumns(fromCol, count, toCol), queryObjectMatrix(matrix, (value) => value === 1);
5756
5886
  }, "handleMoveColsCommon"), handleMoveRange = /* @__PURE__ */ __name((param, targetRange) => {
5757
- var _a20, _b;
5758
- const toRange = (_a20 = param.params) == null ? void 0 : _a20.toRange, fromRange = (_b = param.params) == null ? void 0 : _b.fromRange;
5887
+ var _a21, _b;
5888
+ const toRange = (_a21 = param.params) == null ? void 0 : _a21.toRange, fromRange = (_b = param.params) == null ? void 0 : _b.fromRange;
5759
5889
  if (!toRange || !fromRange)
5760
5890
  return [];
5761
5891
  const operators = [];
@@ -5775,8 +5905,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5775
5905
  }
5776
5906
  return operators;
5777
5907
  }, "handleMoveRange"), handleMoveRangeCommon = /* @__PURE__ */ __name((param, targetRange) => {
5778
- var _a20, _b;
5779
- const toRange = (_a20 = param.params) == null ? void 0 : _a20.toRange, fromRange = (_b = param.params) == null ? void 0 : _b.fromRange;
5908
+ var _a21, _b;
5909
+ const toRange = (_a21 = param.params) == null ? void 0 : _a21.toRange, fromRange = (_b = param.params) == null ? void 0 : _b.fromRange;
5780
5910
  if (!toRange || !fromRange)
5781
5911
  return [targetRange];
5782
5912
  if (!Rectangle.intersects(fromRange, targetRange) && !Rectangle.intersects(toRange, targetRange))
@@ -5800,9 +5930,9 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5800
5930
  endRow: toRange.endRow - rowOffset
5801
5931
  };
5802
5932
  return loopToRange && Range.foreach(loopToRange, (row, col) => {
5803
- var _a21;
5933
+ var _a22;
5804
5934
  const targetRow = row + rowOffset, targetCol = col + columnOffset;
5805
- matrix.setValue(targetRow, targetCol, (_a21 = fromMatrix.getValue(row, col)) != null ? _a21 : 0);
5935
+ matrix.setValue(targetRow, targetCol, (_a22 = fromMatrix.getValue(row, col)) != null ? _a22 : 0);
5806
5936
  }), queryObjectMatrix(matrix, (value) => value === 1);
5807
5937
  }, "handleMoveRangeCommon"), handleBaseRemoveRange = /* @__PURE__ */ __name((_removeRange, _targetRange) => {
5808
5938
  const removeRange = handleRangeTypeInput(_removeRange), targetRange = handleRangeTypeInput(_targetRange), getLength = /* @__PURE__ */ __name((range) => range.endColumn - range.startColumn + 1, "getLength"), getRowLength = /* @__PURE__ */ __name((range) => range.endRow - range.startRow + 1, "getRowLength");
@@ -5830,8 +5960,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5830
5960
  }
5831
5961
  return { step: 0, length: 0 };
5832
5962
  }, "handleBaseRemoveRange"), handleIRemoveCol = /* @__PURE__ */ __name((param, targetRange) => {
5833
- var _a20;
5834
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
5963
+ var _a21;
5964
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5835
5965
  if (!range)
5836
5966
  return [];
5837
5967
  const operators = [], result = handleBaseRemoveRange(range, targetRange);
@@ -5847,8 +5977,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5847
5977
  }
5848
5978
  return operators;
5849
5979
  }, "handleIRemoveCol"), handleIRemoveRow = /* @__PURE__ */ __name((param, targetRange) => {
5850
- var _a20;
5851
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
5980
+ var _a21;
5981
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5852
5982
  if (!range)
5853
5983
  return [];
5854
5984
  const operators = [], result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
@@ -5920,8 +6050,8 @@ function handleBaseMoveRange(fromRange, toRange, targetRange) {
5920
6050
  }
5921
6051
  __name(handleBaseMoveRange, "handleBaseMoveRange");
5922
6052
  const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5923
- var _a20;
5924
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6053
+ var _a21;
6054
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5925
6055
  if (!range)
5926
6056
  return [];
5927
6057
  const operators = [], result = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange)), { step, length } = result;
@@ -5931,8 +6061,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5931
6061
  length
5932
6062
  }), operators;
5933
6063
  }, "handleInsertRow"), handleInsertCol = /* @__PURE__ */ __name((param, targetRange) => {
5934
- var _a20;
5935
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6064
+ var _a21;
6065
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5936
6066
  if (!range)
5937
6067
  return [];
5938
6068
  const operators = [], result = handleBaseInsertRange(range, targetRange), { step, length } = result;
@@ -5942,8 +6072,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5942
6072
  length
5943
6073
  }), operators;
5944
6074
  }, "handleInsertCol"), handleInsertRangeMoveDown = /* @__PURE__ */ __name((param, targetRange) => {
5945
- var _a20;
5946
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6075
+ var _a21;
6076
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5947
6077
  if (!range)
5948
6078
  return [];
5949
6079
  const operators = [], result = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange)), { step, length } = result;
@@ -5953,8 +6083,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5953
6083
  length
5954
6084
  }), operators;
5955
6085
  }, "handleInsertRangeMoveDown"), handleInsertRangeMoveDownCommon = /* @__PURE__ */ __name((param, targetRange) => {
5956
- var _a20;
5957
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6086
+ var _a21;
6087
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5958
6088
  if (!range)
5959
6089
  return [targetRange];
5960
6090
  const moveCount = range.endRow - range.startRow + 1, bottomRange = {
@@ -5973,8 +6103,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5973
6103
  matrix.setValue(row + moveCount, col, 1);
5974
6104
  }), queryObjectMatrix(matrix, (v) => v === 1);
5975
6105
  }, "handleInsertRangeMoveDownCommon"), handleInsertRangeMoveRight = /* @__PURE__ */ __name((param, targetRange) => {
5976
- var _a20;
5977
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6106
+ var _a21;
6107
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5978
6108
  if (!range)
5979
6109
  return [];
5980
6110
  const operators = [], result = handleBaseInsertRange(range, targetRange), { step, length } = result;
@@ -5984,8 +6114,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5984
6114
  length
5985
6115
  }), operators;
5986
6116
  }, "handleInsertRangeMoveRight"), handleInsertRangeMoveRightCommon = /* @__PURE__ */ __name((param, targetRange) => {
5987
- var _a20;
5988
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6117
+ var _a21;
6118
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5989
6119
  if (!range)
5990
6120
  return [targetRange];
5991
6121
  const moveCount = range.endColumn - range.startColumn + 1, bottomRange = {
@@ -6004,8 +6134,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6004
6134
  matrix.setValue(row, col + moveCount, 1);
6005
6135
  }), queryObjectMatrix(matrix, (v) => v === 1);
6006
6136
  }, "handleInsertRangeMoveRightCommon"), handleDeleteRangeMoveLeft = /* @__PURE__ */ __name((param, targetRange) => {
6007
- var _a20;
6008
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6137
+ var _a21;
6138
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6009
6139
  if (!range)
6010
6140
  return [];
6011
6141
  const operators = [], result = handleBaseRemoveRange(range, targetRange);
@@ -6021,8 +6151,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6021
6151
  }
6022
6152
  return operators;
6023
6153
  }, "handleDeleteRangeMoveLeft"), handleDeleteRangeMoveLeftCommon = /* @__PURE__ */ __name((param, targetRange) => {
6024
- var _a20;
6025
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6154
+ var _a21;
6155
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6026
6156
  if (!range)
6027
6157
  return [targetRange];
6028
6158
  const rightRange = {
@@ -6044,8 +6174,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6044
6174
  });
6045
6175
  }), queryObjectMatrix(matrix, (v) => v === 1);
6046
6176
  }, "handleDeleteRangeMoveLeftCommon"), handleDeleteRangeMoveUp = /* @__PURE__ */ __name((param, targetRange) => {
6047
- var _a20;
6048
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6177
+ var _a21;
6178
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6049
6179
  if (!range)
6050
6180
  return [];
6051
6181
  const operators = [], result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
@@ -6061,8 +6191,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6061
6191
  }
6062
6192
  return operators;
6063
6193
  }, "handleDeleteRangeMoveUp"), handleDeleteRangeMoveUpCommon = /* @__PURE__ */ __name((param, targetRange) => {
6064
- var _a20;
6065
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6194
+ var _a21;
6195
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6066
6196
  if (!range)
6067
6197
  return [targetRange];
6068
6198
  const bottomRange = {
@@ -6083,8 +6213,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6083
6213
  });
6084
6214
  }), queryObjectMatrix(matrix, (v) => v === 1);
6085
6215
  }, "handleDeleteRangeMoveUpCommon"), handleRemoveRowCommon = /* @__PURE__ */ __name((param, targetRange) => {
6086
- var _a20;
6087
- const ranges = (_a20 = param.ranges) != null ? _a20 : [param.range], matrix = new ObjectMatrix();
6216
+ var _a21;
6217
+ const ranges = (_a21 = param.ranges) != null ? _a21 : [param.range], matrix = new ObjectMatrix();
6088
6218
  return Range.foreach(targetRange, (row, col) => {
6089
6219
  matrix.setValue(row, col, 1);
6090
6220
  }), ranges.forEach((range) => {
@@ -6204,7 +6334,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6204
6334
  case EffectRefRangId.RemoveRowCommandId:
6205
6335
  return handleRemoveRowCommon(commandInfo.params, range);
6206
6336
  }
6207
- return runRefRangeMutations(operator, range);
6337
+ const resultRange = runRefRangeMutations(operator, range);
6338
+ return resultRange ? [resultRange] : [];
6208
6339
  }, "handleCommonDefaultRangeChangeWithEffectRefCommands"), handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests = /* @__PURE__ */ __name((range, commandInfo, deps) => [DeleteRangeMoveLeftCommand.id, DeleteRangeMoveUpCommand.id, InsertRangeMoveDownCommand.id, InsertRangeMoveRightCommandId].includes(commandInfo.id) || getEffectedRangesOnCommand(commandInfo, deps).some((effectRange) => Rectangle.intersects(effectRange, range)) ? handleCommonDefaultRangeChangeWithEffectRefCommands(range, commandInfo) : range, "handleCommonRangeChangeWithEffectRefCommandsSkipNoInterests");
6209
6340
  function adjustRangeOnMutation(range, mutation) {
6210
6341
  const { id, params } = mutation;
@@ -6258,7 +6389,7 @@ function adjustRangeOnMutation(range, mutation) {
6258
6389
  }
6259
6390
  __name(adjustRangeOnMutation, "adjustRangeOnMutation");
6260
6391
  function getEffectedRangesOnCommand(command, deps) {
6261
- var _a20, _b, _c, _d, _e, _f;
6392
+ var _a21, _b, _c, _d, _e, _f;
6262
6393
  const { selectionManagerService } = deps;
6263
6394
  switch (command.id) {
6264
6395
  case EffectRefRangId.MoveColsCommandId: {
@@ -6313,7 +6444,7 @@ function getEffectedRangesOnCommand(command, deps) {
6313
6444
  return [command.params.range];
6314
6445
  case EffectRefRangId.DeleteRangeMoveUpCommandId:
6315
6446
  case EffectRefRangId.InsertRangeMoveDownCommandId: {
6316
- const range = ((_a20 = command.params) == null ? void 0 : _a20.range) || ((_c = (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range)) == null ? void 0 : _c[0]);
6447
+ const range = ((_a21 = command.params) == null ? void 0 : _a21.range) || ((_c = (_b = selectionManagerService.getCurrentSelections()) == null ? void 0 : _b.map((s) => s.range)) == null ? void 0 : _c[0]);
6317
6448
  return range ? [range] : [];
6318
6449
  }
6319
6450
  case EffectRefRangId.DeleteRangeMoveLeftCommandId:
@@ -6400,8 +6531,8 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
6400
6531
  super(), this._unitId = _unitId, this._subUnitId = _subUnitId, this._range = _range, this._callback = _callback, this._skipIntersects = _skipIntersects;
6401
6532
  }
6402
6533
  onMutation(mutation) {
6403
- var _a20, _b;
6404
- if (((_a20 = mutation.params) == null ? void 0 : _a20.unitId) !== this._unitId)
6534
+ var _a21, _b;
6535
+ if (((_a21 = mutation.params) == null ? void 0 : _a21.unitId) !== this._unitId)
6405
6536
  return;
6406
6537
  if (mutation.id === MoveRangeMutation.id) {
6407
6538
  const params = mutation.params;
@@ -6427,8 +6558,8 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
6427
6558
  };
6428
6559
  __name(_WatchRange, "WatchRange");
6429
6560
  let WatchRange = _WatchRange;
6430
- var _a10;
6431
- let RefRangeService = (_a10 = class extends Disposable {
6561
+ var _a11;
6562
+ let RefRangeService = (_a11 = class extends Disposable {
6432
6563
  constructor(_commandService, _sheetInterceptorService, _univerInstanceService, _selectionManagerService) {
6433
6564
  super();
6434
6565
  __publicField(this, "interceptor", new InterceptorManager({ MERGE_REDO, MERGE_UNDO }));
@@ -6549,8 +6680,8 @@ let RefRangeService = (_a10 = class extends Disposable {
6549
6680
  []
6550
6681
  ).reduce(
6551
6682
  (result2, currentValue) => {
6552
- var _a20, _b;
6553
- return result2.redos.push(...currentValue.redos), result2.undos.push(...currentValue.undos), result2.preRedos.push(...(_a20 = currentValue.preRedos) != null ? _a20 : []), result2.preUndos.push(...(_b = currentValue.preUndos) != null ? _b : []), result2;
6683
+ var _a21, _b;
6684
+ return result2.redos.push(...currentValue.redos), result2.undos.push(...currentValue.undos), result2.preRedos.push(...(_a21 = currentValue.preRedos) != null ? _a21 : []), result2.preUndos.push(...(_b = currentValue.preUndos) != null ? _b : []), result2;
6554
6685
  },
6555
6686
  { redos: [], undos: [], preUndos: [], preRedos: [] }
6556
6687
  ), preRedos = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(
@@ -6636,7 +6767,7 @@ let RefRangeService = (_a10 = class extends Disposable {
6636
6767
  registerToService.dispose(), teardownWatching.dispose();
6637
6768
  });
6638
6769
  }
6639
- }, __name(_a10, "RefRangeService"), _a10);
6770
+ }, __name(_a11, "RefRangeService"), _a11);
6640
6771
  RefRangeService = __decorateClass$9([
6641
6772
  OnLifecycle(LifecycleStages.Ready, RefRangeService),
6642
6773
  __decorateParam$9(0, ICommandService),
@@ -6649,13 +6780,13 @@ function getUnitId(univerInstanceService) {
6649
6780
  }
6650
6781
  __name(getUnitId, "getUnitId");
6651
6782
  function getSubUnitId(univerInstanceService) {
6652
- var _a20;
6653
- return (_a20 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : _a20.getSheetId();
6783
+ var _a21;
6784
+ return (_a21 = univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET).getActiveSheet()) == null ? void 0 : _a21.getSheetId();
6654
6785
  }
6655
6786
  __name(getSubUnitId, "getSubUnitId");
6656
6787
  function getSelectionRanges(selectionManagerService) {
6657
- var _a20;
6658
- return ((_a20 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range)) || [];
6788
+ var _a21;
6789
+ return ((_a21 = selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range)) || [];
6659
6790
  }
6660
6791
  __name(getSelectionRanges, "getSelectionRanges");
6661
6792
  function getRefRangId(unitId, subUnitId) {
@@ -6724,8 +6855,8 @@ function getAddMergeMutationRangeByType(selection, type) {
6724
6855
  }
6725
6856
  __name(getAddMergeMutationRangeByType, "getAddMergeMutationRangeByType");
6726
6857
  const MERGE_CELL_INTERCEPTOR_CHECK = createInterceptorKey("mergeCellPermissionCheck");
6727
- var _a11;
6728
- let MergeCellController = (_a11 = class extends Disposable {
6858
+ var _a12;
6859
+ let MergeCellController = (_a12 = class extends Disposable {
6729
6860
  constructor(_commandService, _refRangeService, _univerInstanceService, _injector, _sheetInterceptorService, _selectionManagerService) {
6730
6861
  super();
6731
6862
  __publicField(this, "disposableCollection", new DisposableCollection());
@@ -6736,14 +6867,14 @@ let MergeCellController = (_a11 = class extends Disposable {
6736
6867
  const self = this;
6737
6868
  this._sheetInterceptorService.interceptCommand({
6738
6869
  getMutations(commandInfo) {
6739
- var _a20;
6870
+ var _a21;
6740
6871
  switch (commandInfo.id) {
6741
6872
  case ClearSelectionAllCommand.id:
6742
6873
  case ClearSelectionFormatCommand.id: {
6743
- const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook.getActiveSheet();
6874
+ const workbook = self._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET), unitId = workbook.getUnitId(), worksheet = workbook == null ? void 0 : workbook.getActiveSheet();
6744
6875
  if (!worksheet)
6745
6876
  return { redos: [], undos: [] };
6746
- const subUnitId = worksheet.getSheetId(), mergeData = worksheet.getConfig().mergeData, selections = (_a20 = self._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
6877
+ const subUnitId = worksheet.getSheetId(), mergeData = worksheet.getConfig().mergeData, selections = (_a21 = self._selectionManagerService.getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
6747
6878
  if (selections && selections.length > 0 && selections.some(
6748
6879
  (range) => mergeData.some((item) => Rectangle.intersects(item, range))
6749
6880
  )) {
@@ -6840,10 +6971,10 @@ let MergeCellController = (_a11 = class extends Disposable {
6840
6971
  }
6841
6972
  _onRefRangeChange() {
6842
6973
  const registerRefRange = /* @__PURE__ */ __name((unitId, subUnitId) => {
6843
- const workbook2 = this._univerInstanceService.getUniverSheetInstance(unitId);
6844
- if (!workbook2)
6974
+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
6975
+ if (!workbook)
6845
6976
  return;
6846
- const workSheet = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(subUnitId);
6977
+ const workSheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
6847
6978
  if (!workSheet)
6848
6979
  return;
6849
6980
  this.disposableCollection.dispose();
@@ -6854,7 +6985,7 @@ let MergeCellController = (_a11 = class extends Disposable {
6854
6985
  }, "registerRefRange");
6855
6986
  this.disposeWithMe(
6856
6987
  this._commandService.onCommandExecuted((commandInfo) => {
6857
- if (commandInfo.id === SetWorksheetActivateCommand.id) {
6988
+ if (commandInfo.id === SetWorksheetActiveOperation.id) {
6858
6989
  const params = commandInfo.params, sheetId = params.subUnitId, unitId = params.unitId;
6859
6990
  if (!sheetId || !unitId)
6860
6991
  return;
@@ -6867,13 +6998,10 @@ let MergeCellController = (_a11 = class extends Disposable {
6867
6998
  registerRefRange(params.unitId, params.subUnitId);
6868
6999
  }
6869
7000
  })
6870
- );
6871
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
6872
- if (workbook) {
7001
+ ), this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(first((workbook) => !!workbook)).subscribe((workbook) => {
6873
7002
  const sheet = workbook.getActiveSheet();
6874
- if (!sheet) return;
6875
- registerRefRange(workbook.getUnitId(), sheet.getSheetId());
6876
- }
7003
+ sheet && registerRefRange(workbook.getUnitId(), sheet.getSheetId());
7004
+ });
6877
7005
  }
6878
7006
  _handleMoveRowsCommand(params, unitId, subUnitId) {
6879
7007
  const workbook = getWorkbook(this._univerInstanceService, unitId);
@@ -7203,19 +7331,23 @@ let MergeCellController = (_a11 = class extends Disposable {
7203
7331
  addMergeParams
7204
7332
  );
7205
7333
  return {
7334
+ preRedos: [
7335
+ { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams }
7336
+ ],
7206
7337
  redos: [
7207
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
7208
7338
  {
7209
7339
  id: AddWorksheetMergeMutation.id,
7210
7340
  params: addMergeParams
7211
7341
  }
7212
7342
  ],
7343
+ preUndos: [
7344
+ { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams }
7345
+ ],
7213
7346
  undos: [
7214
7347
  {
7215
7348
  id: AddWorksheetMergeMutation.id,
7216
7349
  params: undoRemoveMergeParams
7217
- },
7218
- { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams }
7350
+ }
7219
7351
  ]
7220
7352
  };
7221
7353
  }
@@ -7253,26 +7385,28 @@ let MergeCellController = (_a11 = class extends Disposable {
7253
7385
  }, undoAddMergeParams = AddMergeUndoMutationFactory(
7254
7386
  this._injector,
7255
7387
  addMergeParams
7256
- ), redos = [
7388
+ ), preRedos = [
7257
7389
  {
7258
7390
  id: RemoveWorksheetMergeMutation.id,
7259
7391
  params: removeMergeParams
7260
- },
7392
+ }
7393
+ ], redos = [
7261
7394
  {
7262
7395
  id: AddWorksheetMergeMutation.id,
7263
7396
  params: addMergeParams
7264
7397
  }
7398
+ ], preUndos = [
7399
+ {
7400
+ id: RemoveWorksheetMergeMutation.id,
7401
+ params: undoAddMergeParams
7402
+ }
7265
7403
  ], undos = [
7266
7404
  {
7267
7405
  id: AddWorksheetMergeMutation.id,
7268
7406
  params: undoRemoveMergeParams
7269
- },
7270
- {
7271
- id: RemoveWorksheetMergeMutation.id,
7272
- params: undoAddMergeParams
7273
7407
  }
7274
7408
  ];
7275
- return { redos, undos };
7409
+ return { redos, undos, preRedos, preUndos };
7276
7410
  }
7277
7411
  _handleDeleteRangeMoveUpCommand(config, unitId, subUnitId) {
7278
7412
  const workbook = getWorkbook(this._univerInstanceService, unitId);
@@ -7303,26 +7437,28 @@ let MergeCellController = (_a11 = class extends Disposable {
7303
7437
  }, undoAddMergeParams = AddMergeUndoMutationFactory(
7304
7438
  this._injector,
7305
7439
  addMergeParams
7306
- ), redos = [
7440
+ ), preRedos = [
7307
7441
  {
7308
7442
  id: RemoveWorksheetMergeMutation.id,
7309
7443
  params: removeMergeParams
7310
- },
7444
+ }
7445
+ ], redos = [
7311
7446
  {
7312
7447
  id: AddWorksheetMergeMutation.id,
7313
7448
  params: addMergeParams
7314
7449
  }
7450
+ ], preUndos = [
7451
+ {
7452
+ id: RemoveWorksheetMergeMutation.id,
7453
+ params: undoAddMergeParams
7454
+ }
7315
7455
  ], undos = [
7316
7456
  {
7317
7457
  id: AddWorksheetMergeMutation.id,
7318
7458
  params: undoRemoveMergeParams
7319
- },
7320
- {
7321
- id: RemoveWorksheetMergeMutation.id,
7322
- params: undoAddMergeParams
7323
7459
  }
7324
7460
  ];
7325
- return { redos, undos };
7461
+ return { redos, undos, preRedos, preUndos };
7326
7462
  }
7327
7463
  _handleDeleteRangeMoveLeftCommand(config, unitId, subUnitId) {
7328
7464
  const workbook = getWorkbook(this._univerInstanceService, unitId);
@@ -7370,8 +7506,10 @@ let MergeCellController = (_a11 = class extends Disposable {
7370
7506
  ranges: addMergeData
7371
7507
  }, undoAddMergeParams = AddMergeUndoMutationFactory(this._injector, addMergeParams);
7372
7508
  return {
7509
+ preRedos: [
7510
+ { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams }
7511
+ ],
7373
7512
  redos: [
7374
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
7375
7513
  {
7376
7514
  id: AddWorksheetMergeMutation.id,
7377
7515
  params: addMergeParams
@@ -7381,7 +7519,9 @@ let MergeCellController = (_a11 = class extends Disposable {
7381
7519
  {
7382
7520
  id: AddWorksheetMergeMutation.id,
7383
7521
  params: undoRemoveMergeParams
7384
- },
7522
+ }
7523
+ ],
7524
+ preUndos: [
7385
7525
  { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams }
7386
7526
  ]
7387
7527
  };
@@ -7429,9 +7569,8 @@ let MergeCellController = (_a11 = class extends Disposable {
7429
7569
  }
7430
7570
  }));
7431
7571
  }
7432
- }, __name(_a11, "MergeCellController"), _a11);
7572
+ }, __name(_a12, "MergeCellController"), _a12);
7433
7573
  MergeCellController = __decorateClass$8([
7434
- OnLifecycle(LifecycleStages.Steady, MergeCellController),
7435
7574
  __decorateParam$8(0, Inject(ICommandService)),
7436
7575
  __decorateParam$8(1, Inject(RefRangeService)),
7437
7576
  __decorateParam$8(2, Inject(IUniverInstanceService)),
@@ -7451,295 +7590,399 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
7451
7590
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7452
7591
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7453
7592
  return kind && result && __defProp$7(target, key, result), result;
7454
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a12;
7455
- let NumfmtService = (_a12 = class extends Disposable {
7456
- constructor(_resourceManagerService, _univerInstanceService, _logService) {
7457
- super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._logService = _logService;
7458
- }
7459
- getValue(unitId, subUnitId, row, col) {
7460
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7461
- if (!workbook)
7462
- return;
7463
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7464
- if (!worksheet)
7465
- return;
7466
- const styles = workbook.getStyles(), cell = worksheet.getCellRaw(row, col);
7467
- if (cell != null && cell.s) {
7468
- const style = styles.get(cell.s);
7469
- if (style != null && style.n)
7470
- return style.n;
7471
- }
7472
- return null;
7593
+ }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a13;
7594
+ let NumberCellDisplayController = (_a13 = class extends Disposable {
7595
+ constructor(_sheetInterceptorService) {
7596
+ super(), this._sheetInterceptorService = _sheetInterceptorService, this._initialize();
7473
7597
  }
7474
- deleteValues(unitId, subUnitId, values) {
7475
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7476
- if (!workbook)
7477
- return;
7478
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7479
- if (!worksheet)
7480
- return;
7481
- const styles = workbook.getStyles();
7482
- values.forEach((range) => {
7483
- Range.foreach(range, (row, col) => {
7484
- const cell = worksheet.getCellRaw(row, col);
7485
- if (!cell)
7486
- return;
7487
- const oldStyleId = cell == null ? void 0 : cell.s, newStyle = { ...oldStyleId && styles.get(oldStyleId) || {} };
7488
- delete newStyle.n;
7489
- const newStyleId = styles.setValue(newStyle);
7490
- cell.s = newStyleId;
7491
- });
7492
- });
7598
+ _initialize() {
7599
+ this._initInterceptorCellContent();
7493
7600
  }
7494
- setValues(unitId, subUnitId, values) {
7495
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7496
- if (!workbook)
7497
- return;
7498
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7499
- if (!worksheet)
7500
- return;
7501
- const styles = workbook.getStyles(), matrix = worksheet.getCellMatrix();
7502
- values.forEach((value) => {
7503
- value.ranges.forEach((range) => {
7504
- Range.foreach(range, (row, col) => {
7505
- const cell = worksheet.getCellRaw(row, col);
7506
- if (cell) {
7507
- const newStyle = { ...styles.getStyleByCell(cell) || {}, n: { pattern: value.pattern } }, styleId = styles.setValue(newStyle);
7508
- cell.s = styleId;
7509
- const type = getCellTypeByPattern(cell, value.pattern);
7510
- cell.v !== void 0 && (cell.t = type, cell.v = getCellValue(type, cell));
7511
- } else {
7512
- const style = { n: { pattern: value.pattern } }, styleId = styles.setValue(style);
7513
- styleId && matrix.setValue(row, col, { s: styleId });
7514
- }
7515
- });
7516
- });
7517
- });
7601
+ _initInterceptorCellContent() {
7602
+ this.disposeWithMe(
7603
+ this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
7604
+ priority: 11,
7605
+ effect: InterceptorEffectEnum.Value | InterceptorEffectEnum.Style,
7606
+ handler: /* @__PURE__ */ __name((cell, location, next) => {
7607
+ var _a21;
7608
+ const style = location.workbook.getStyles().getStyleByCell(cell);
7609
+ return (_a21 = style == null ? void 0 : style.n) != null && _a21.pattern ? next({ ...cell }) : (cell == null ? void 0 : cell.t) === CellValueType.NUMBER && typeof (cell == null ? void 0 : cell.v) == "number" ? next({
7610
+ ...cell,
7611
+ v: stripErrorMargin(cell.v)
7612
+ }) : next({ ...cell });
7613
+ }, "handler")
7614
+ })
7615
+ );
7518
7616
  }
7519
- }, __name(_a12, "NumfmtService"), _a12);
7520
- NumfmtService = __decorateClass$7([
7521
- __decorateParam$7(0, IResourceManagerService),
7522
- __decorateParam$7(1, IUniverInstanceService),
7523
- __decorateParam$7(2, ILogService)
7524
- ], NumfmtService);
7525
- const getAllWorkbookPermissionPoint = /* @__PURE__ */ __name(() => [
7526
- WorkbookEditablePermission,
7527
- WorkbookPrintPermission,
7528
- WorkbookCommentPermission,
7529
- WorkbookViewPermission,
7530
- WorkbookCopyPermission,
7531
- WorkbookExportPermission,
7532
- WorkbookManageCollaboratorPermission,
7533
- WorkbookCreateSheetPermission,
7534
- WorkbookDeleteSheetPermission,
7535
- WorkbookRenameSheetPermission,
7536
- WorkbookHideSheetPermission,
7537
- WorkbookDuplicatePermission,
7538
- WorkbookSharePermission,
7539
- WorkbookMoveSheetPermission,
7540
- WorkbookCopySheetPermission,
7541
- WorkbookViewHistoryPermission,
7542
- WorkbookRecoverHistoryPermission
7543
- ], "getAllWorkbookPermissionPoint"), defaultWorkbookPermissionPoints = [
7544
- P.Edit,
7545
- P.Print,
7546
- P.Comment,
7547
- P.View,
7548
- P.Copy,
7549
- P.Export,
7550
- P.ManageCollaborator,
7551
- P.CreateSheet,
7552
- P.DeleteSheet,
7553
- P.RenameSheet,
7554
- P.HideSheet,
7555
- P.Duplicate,
7556
- P.Share,
7557
- P.MoveSheet,
7558
- P.CopySheet,
7559
- P.RecoverHistory,
7560
- P.ViewHistory
7561
- ];
7617
+ }, __name(_a13, "NumberCellDisplayController"), _a13);
7618
+ NumberCellDisplayController = __decorateClass$7([
7619
+ OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController),
7620
+ __decorateParam$7(0, Inject(SheetInterceptorService))
7621
+ ], NumberCellDisplayController);
7562
7622
  var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7563
7623
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7564
7624
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7565
7625
  return kind && result && __defProp$6(target, key, result), result;
7566
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a13;
7567
- let WorkbookPermissionService = (_a13 = class extends Disposable {
7568
- constructor(_permissionService, _univerInstanceService, _rangeProtectionRuleModel) {
7569
- super(), this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._rangeProtectionRuleModel = _rangeProtectionRuleModel, this._init();
7626
+ }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a14;
7627
+ let RangeProtectionCache = (_a14 = class extends Disposable {
7628
+ constructor(_ruleModel, _permissionService, _univerInstanceService) {
7629
+ super();
7630
+ __publicField(this, "_cellRuleCache", /* @__PURE__ */ new Map());
7631
+ __publicField(this, "_permissionIdCache", /* @__PURE__ */ new Map());
7632
+ __publicField(this, "_cellInfoCache", /* @__PURE__ */ new Map());
7633
+ this._ruleModel = _ruleModel, this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._initUpdateCellRuleCache(), this._initUpdateCellInfoCache(), this._initCache();
7570
7634
  }
7571
- _init() {
7572
- const handleWorkbook = /* @__PURE__ */ __name((workbook) => {
7573
- const unitId = workbook.getUnitId();
7574
- getAllWorkbookPermissionPoint().forEach((F) => {
7575
- const instance = new F(unitId);
7576
- this._permissionService.addPermissionPoint(instance);
7577
- });
7578
- }, "handleWorkbook");
7635
+ _initCache() {
7579
7636
  this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {
7580
- handleWorkbook(workbook);
7581
- }), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
7582
- handleWorkbook(workbook);
7583
- })), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
7584
- const unitId = workbook.getUnitId();
7585
- workbook.getSheets().forEach((worksheet) => {
7586
- const subUnitId = worksheet.getSheetId();
7587
- this._rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).forEach((rule) => {
7588
- [RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint].forEach((F) => {
7589
- const instance = new F(unitId, subUnitId, rule.permissionId);
7590
- this._permissionService.deletePermissionPoint(instance.id);
7591
- });
7592
- }), [...getAllWorksheetPermissionPoint(), ...getAllWorksheetPermissionPointByPointPanel()].forEach((F) => {
7593
- const instance = new F(unitId, subUnitId);
7594
- this._permissionService.deletePermissionPoint(instance.id);
7637
+ workbook.getSheets().forEach((sheet) => {
7638
+ const unitId = workbook.getUnitId(), subUnitId = sheet.getSheetId();
7639
+ this.reBuildCache(unitId, subUnitId);
7640
+ });
7641
+ });
7642
+ }
7643
+ _initUpdateCellInfoCache() {
7644
+ this._permissionService.permissionPointUpdate$.pipe(
7645
+ filter((permission) => permission.type === M.SelectRange),
7646
+ map((permission) => permission)
7647
+ ).subscribe((permission) => {
7648
+ const { subUnitId, unitId, permissionId } = permission, ruleId = this._permissionIdCache.get(permissionId);
7649
+ if (!ruleId)
7650
+ return;
7651
+ const ruleInstance = this._ruleModel.getRule(unitId, subUnitId, ruleId);
7652
+ if (!ruleInstance)
7653
+ return;
7654
+ const cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
7655
+ ruleInstance.ranges.forEach((range) => {
7656
+ const { startRow, endRow, startColumn, endColumn } = range;
7657
+ for (let i = startRow; i <= endRow; i++)
7658
+ for (let j = startColumn; j <= endColumn; j++)
7659
+ cellInfoMap.delete(`${i}-${j}`);
7660
+ });
7661
+ }), this._ruleModel.ruleChange$.subscribe((info) => {
7662
+ var _a21;
7663
+ const { unitId, subUnitId } = info, cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
7664
+ info.rule.ranges.forEach((range) => {
7665
+ Range.foreach(range, (row, col) => {
7666
+ cellInfoMap.delete(`${row}-${col}`);
7595
7667
  });
7596
- }), getAllWorkbookPermissionPoint().forEach((F) => {
7597
- const instance = new F(unitId);
7598
- this._permissionService.deletePermissionPoint(instance.id);
7668
+ }), info.type === "set" && ((_a21 = info.oldRule) == null || _a21.ranges.forEach((range) => {
7669
+ Range.foreach(range, (row, col) => {
7670
+ this._cellInfoCache.delete(`${row}-${col}`);
7671
+ });
7672
+ }));
7673
+ });
7674
+ }
7675
+ _initUpdateCellRuleCache() {
7676
+ this._ruleModel.ruleChange$.subscribe((ruleChange) => {
7677
+ const { type } = ruleChange;
7678
+ type === "add" ? this._addCellRuleCache(ruleChange) : type === "delete" ? this._deleteCellRuleCache(ruleChange) : (this._deleteCellRuleCache({ ...ruleChange, rule: ruleChange.oldRule }), this._addCellRuleCache(ruleChange));
7679
+ });
7680
+ }
7681
+ _ensureRuleMap(unitId, subUnitId) {
7682
+ let subUnitMap = this._cellRuleCache.get(unitId);
7683
+ subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._cellRuleCache.set(unitId, subUnitMap));
7684
+ let cellMap = subUnitMap.get(subUnitId);
7685
+ return cellMap || (cellMap = /* @__PURE__ */ new Map(), subUnitMap.set(subUnitId, cellMap)), cellMap;
7686
+ }
7687
+ _ensureCellInfoMap(unitId, subUnitId) {
7688
+ let subUnitMap = this._cellInfoCache.get(unitId);
7689
+ subUnitMap || (subUnitMap = /* @__PURE__ */ new Map(), this._cellInfoCache.set(unitId, subUnitMap));
7690
+ let cellMap = subUnitMap.get(subUnitId);
7691
+ return cellMap || (cellMap = /* @__PURE__ */ new Map(), subUnitMap.set(subUnitId, cellMap)), cellMap;
7692
+ }
7693
+ _addCellRuleCache(ruleChange) {
7694
+ const { subUnitId, unitId, rule } = ruleChange, cellMap = this._ensureRuleMap(unitId, subUnitId);
7695
+ rule.ranges.forEach((range) => {
7696
+ const { startRow, endRow, startColumn, endColumn } = range;
7697
+ for (let i = startRow; i <= endRow; i++)
7698
+ for (let j = startColumn; j <= endColumn; j++)
7699
+ cellMap.set(`${i}-${j}`, rule.id);
7700
+ }), this._permissionIdCache.set(rule.permissionId, rule.id);
7701
+ }
7702
+ _deleteCellRuleCache(ruleChange) {
7703
+ const { subUnitId, unitId, rule } = ruleChange, cellMap = this._ensureRuleMap(unitId, subUnitId), cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
7704
+ rule.ranges.forEach((range) => {
7705
+ const { startRow, endRow, startColumn, endColumn } = range;
7706
+ for (let i = startRow; i <= endRow; i++)
7707
+ for (let j = startColumn; j <= endColumn; j++)
7708
+ cellMap.delete(`${i}-${j}`), cellInfoMap.delete(`${i}-${j}`);
7709
+ }), this._permissionIdCache.delete(rule.permissionId);
7710
+ }
7711
+ reBuildCache(unitId, subUnitId) {
7712
+ const cellRuleMap = this._ensureRuleMap(unitId, subUnitId), cellInfoMap = this._ensureCellInfoMap(unitId, subUnitId);
7713
+ cellRuleMap.clear(), cellInfoMap.clear(), this._ruleModel.getSubunitRuleList(unitId, subUnitId).forEach((rule) => {
7714
+ var _a21, _b, _c, _d, _e, _f;
7715
+ const edit = (_c = (_b = this._permissionService.getPermissionPoint((_a21 = new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId)) == null ? void 0 : _a21.id)) == null ? void 0 : _b.value) != null ? _c : !0, view = (_f = (_e = this._permissionService.getPermissionPoint((_d = new RangeProtectionPermissionViewPoint(unitId, subUnitId, rule.permissionId)) == null ? void 0 : _d.id)) == null ? void 0 : _e.value) != null ? _f : !0, selectionProtection = {
7716
+ [P.Edit]: edit,
7717
+ [P.View]: view,
7718
+ ruleId: rule.id,
7719
+ ranges: rule.ranges
7720
+ };
7721
+ rule.ranges.forEach((range) => {
7722
+ const { startRow, endRow, startColumn, endColumn } = range;
7723
+ for (let i = startRow; i <= endRow; i++)
7724
+ for (let j = startColumn; j <= endColumn; j++)
7725
+ cellRuleMap.set(`${i}-${j}`, rule.id), cellInfoMap.set(`${i}-${j}`, selectionProtection);
7726
+ }), this._permissionIdCache.set(rule.permissionId, rule.id);
7727
+ });
7728
+ }
7729
+ getCellInfo(unitId, subUnitId, row, col) {
7730
+ var _a21, _b, _c, _d, _e, _f, _g, _h;
7731
+ const cellMap = this._ensureCellInfoMap(unitId, subUnitId), cacheValue = cellMap.get(`${row}-${col}`);
7732
+ if (cacheValue)
7733
+ return cacheValue;
7734
+ let view = !0, edit = !0;
7735
+ const ruleId = (_b = (_a21 = this._cellRuleCache.get(unitId)) == null ? void 0 : _a21.get(subUnitId)) == null ? void 0 : _b.get(`${row}-${col}`);
7736
+ if (!ruleId)
7737
+ return;
7738
+ const rule = this._ruleModel.getRule(unitId, subUnitId, ruleId);
7739
+ if (rule) {
7740
+ view = (_e = (_d = this._permissionService.getPermissionPoint((_c = new RangeProtectionPermissionViewPoint(unitId, subUnitId, rule.permissionId)) == null ? void 0 : _c.id)) == null ? void 0 : _d.value) != null ? _e : !0, edit = (_h = (_g = this._permissionService.getPermissionPoint((_f = new RangeProtectionPermissionEditPoint(unitId, subUnitId, rule.permissionId)) == null ? void 0 : _f.id)) == null ? void 0 : _g.value) != null ? _h : !0;
7741
+ const selectionProtection = {
7742
+ [P.Edit]: edit,
7743
+ [P.View]: view,
7744
+ ruleId,
7745
+ ranges: rule.ranges
7746
+ };
7747
+ return cellMap.set(`${row}-${col}`, selectionProtection), selectionProtection;
7748
+ }
7749
+ }
7750
+ deleteUnit(unitId) {
7751
+ this._cellRuleCache.delete(unitId), this._cellInfoCache.delete(unitId);
7752
+ const workbook = this._univerInstanceService.getUnit(unitId);
7753
+ workbook == null || workbook.getSheets().forEach((sheet) => {
7754
+ const subUnitId = sheet.getSheetId();
7755
+ this._ruleModel.getSubunitRuleList(unitId, subUnitId).forEach((rule) => {
7756
+ this._permissionIdCache.delete(rule.permissionId);
7599
7757
  });
7600
- }));
7758
+ });
7601
7759
  }
7602
- }, __name(_a13, "WorkbookPermissionService"), _a13);
7603
- WorkbookPermissionService = __decorateClass$6([
7604
- OnLifecycle(LifecycleStages.Starting, WorkbookPermissionService),
7605
- __decorateParam$6(0, Inject(IPermissionService)),
7606
- __decorateParam$6(1, Inject(IUniverInstanceService)),
7607
- __decorateParam$6(2, Inject(RangeProtectionRuleModel))
7608
- ], WorkbookPermissionService);
7760
+ }, __name(_a14, "RangeProtectionCache"), _a14);
7761
+ RangeProtectionCache = __decorateClass$6([
7762
+ __decorateParam$6(0, Inject(RangeProtectionRuleModel)),
7763
+ __decorateParam$6(1, Inject(IPermissionService)),
7764
+ __decorateParam$6(2, Inject(IUniverInstanceService))
7765
+ ], RangeProtectionCache);
7766
+ const getAllRangePermissionPoint = /* @__PURE__ */ __name(() => [RangeProtectionPermissionViewPoint, RangeProtectionPermissionEditPoint], "getAllRangePermissionPoint"), getDefaultRangePermission = /* @__PURE__ */ __name((unitId = "unitId", subUnitId = "subUnitId", permissionId = "permissionId") => getAllRangePermissionPoint().reduce((r, F) => {
7767
+ const i = new F(unitId, subUnitId, permissionId);
7768
+ return r[i.subType] = i.value, r;
7769
+ }, {}), "getDefaultRangePermission");
7609
7770
  var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7610
7771
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7611
7772
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7612
7773
  return kind && result && __defProp$5(target, key, result), result;
7613
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
7614
- const SHEET_DEFINED_NAME_PLUGIN = "SHEET_DEFINED_NAME_PLUGIN";
7615
- var _a14;
7616
- let DefinedNameDataController = (_a14 = class extends Disposable {
7617
- constructor(_definedNamesService, _resourceManagerService) {
7618
- super(), this._definedNamesService = _definedNamesService, this._resourceManagerService = _resourceManagerService, this._initialize();
7774
+ }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5"), _a15;
7775
+ let RangeProtectionRenderModel = (_a15 = class {
7776
+ constructor(_selectionProtectionRuleModel, _permissionService) {
7777
+ __publicField(this, "_cache", new LRUMap(1e4));
7778
+ this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._permissionService = _permissionService, this._init();
7619
7779
  }
7620
- _initialize() {
7621
- this._initSnapshot();
7780
+ _init() {
7781
+ this._permissionService.permissionPointUpdate$.pipe(
7782
+ filter$1((permission) => permission.type === M.SelectRange),
7783
+ filter$1((permission) => getAllRangePermissionPoint().some((F) => permission instanceof F)),
7784
+ map$1((permission) => permission)
7785
+ ).subscribe((permission) => {
7786
+ const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(permission.unitId, permission.subUnitId);
7787
+ for (const rule of ruleMap)
7788
+ rule.permissionId === permission.permissionId && rule.ranges.forEach((range) => {
7789
+ Range.foreach(range, (row, col) => {
7790
+ const key = this._createKey(permission.unitId, permission.subUnitId, row, col);
7791
+ this._cache.delete(key);
7792
+ });
7793
+ });
7794
+ }), this._selectionProtectionRuleModel.ruleChange$.subscribe((info) => {
7795
+ var _a21;
7796
+ info.rule.ranges.forEach((range) => {
7797
+ Range.foreach(range, (row, col) => {
7798
+ const key = this._createKey(info.unitId, info.subUnitId, row, col);
7799
+ this._cache.delete(key);
7800
+ });
7801
+ }), info.type === "set" && ((_a21 = info.oldRule) == null || _a21.ranges.forEach((range) => {
7802
+ Range.foreach(range, (row, col) => {
7803
+ const key = this._createKey(info.unitId, info.subUnitId, row, col);
7804
+ this._cache.delete(key);
7805
+ });
7806
+ }));
7807
+ });
7622
7808
  }
7623
- _initSnapshot() {
7624
- const toJson = /* @__PURE__ */ __name((unitId) => {
7625
- const map2 = this._definedNamesService.getDefinedNameMap(unitId);
7626
- return map2 ? JSON.stringify(map2) : "";
7627
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
7628
- if (!json)
7629
- return {};
7630
- try {
7631
- return JSON.parse(json);
7632
- } catch {
7633
- return {};
7809
+ _createKey(unitId, subUnitId, row, col) {
7810
+ return `${unitId}_${subUnitId}_${row}_${col}`;
7811
+ }
7812
+ getCellInfo(unitId, subUnitId, row, col) {
7813
+ const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(unitId, subUnitId), defaultV = [];
7814
+ if (!ruleMap || !ruleMap.length)
7815
+ return defaultV;
7816
+ const key = this._createKey(unitId, subUnitId, row, col), cacheValue = this._cache.get(key);
7817
+ if (cacheValue)
7818
+ return cacheValue;
7819
+ const result = [];
7820
+ for (const rule of ruleMap)
7821
+ if (rule.ranges.some((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col)) {
7822
+ const permissionMap = getAllRangePermissionPoint().reduce((result2, F) => {
7823
+ var _a21;
7824
+ const instance = new F(unitId, subUnitId, rule.permissionId), permission = this._permissionService.getPermissionPoint(instance.id);
7825
+ return result2[instance.subType] = (_a21 = permission == null ? void 0 : permission.value) != null ? _a21 : instance.value, result2;
7826
+ }, {});
7827
+ result.push({ ...permissionMap, ruleId: rule.id, ranges: rule.ranges });
7634
7828
  }
7635
- }, "parseJson");
7636
- this.disposeWithMe(
7637
- this._resourceManagerService.registerPluginResource({
7638
- pluginName: SHEET_DEFINED_NAME_PLUGIN,
7639
- businesses: [UniverInstanceType.UNIVER_SHEET],
7640
- toJson: /* @__PURE__ */ __name((unitId) => toJson(unitId), "toJson"),
7641
- parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
7642
- onUnLoad: /* @__PURE__ */ __name((unitId) => {
7643
- this._definedNamesService.removeUnitDefinedName(unitId);
7644
- }, "onUnLoad"),
7645
- onLoad: /* @__PURE__ */ __name((unitId, value) => {
7646
- this._definedNamesService.registerDefinedNames(unitId, value);
7647
- }, "onLoad")
7648
- })
7649
- );
7829
+ return this._cache.set(key, result), result;
7650
7830
  }
7651
- }, __name(_a14, "DefinedNameDataController"), _a14);
7652
- DefinedNameDataController = __decorateClass$5([
7653
- OnLifecycle(LifecycleStages.Ready, DefinedNameDataController),
7654
- __decorateParam$5(0, IDefinedNamesService),
7655
- __decorateParam$5(1, IResourceManagerService)
7656
- ], DefinedNameDataController);
7657
- const getAllRangePermissionPoint = /* @__PURE__ */ __name(() => [RangeProtectionPermissionViewPoint, RangeProtectionPermissionEditPoint], "getAllRangePermissionPoint"), getDefaultRangePermission = /* @__PURE__ */ __name((unitId = "unitId", subUnitId = "subUnitId", permissionId = "permissionId") => getAllRangePermissionPoint().reduce((r, F) => {
7658
- const i = new F(unitId, subUnitId, permissionId);
7659
- return r[i.subType] = i.value, r;
7660
- }, {}), "getDefaultRangePermission");
7831
+ clear() {
7832
+ this._cache.clear();
7833
+ }
7834
+ }, __name(_a15, "RangeProtectionRenderModel"), _a15);
7835
+ RangeProtectionRenderModel = __decorateClass$5([
7836
+ OnLifecycle(LifecycleStages.Ready, RangeProtectionRenderModel),
7837
+ __decorateParam$5(0, Inject(RangeProtectionRuleModel)),
7838
+ __decorateParam$5(1, Inject(IPermissionService))
7839
+ ], RangeProtectionRenderModel);
7840
+ const IExclusiveRangeService = createIdentifier("univer.exclusive-range-service"), _ExclusiveRangeService = class _ExclusiveRangeService extends Disposable {
7841
+ constructor() {
7842
+ super(...arguments);
7843
+ /**
7844
+ * Exclusive range data structure is as follows: unitId -> sheetId -> feature -> range
7845
+ */
7846
+ __publicField(this, "_exclusiveRanges", /* @__PURE__ */ new Map());
7847
+ }
7848
+ _ensureUnitMap(unitId) {
7849
+ return this._exclusiveRanges.has(unitId) || this._exclusiveRanges.set(unitId, /* @__PURE__ */ new Map()), this._exclusiveRanges.get(unitId);
7850
+ }
7851
+ _ensureSubunitMap(unitId, sheetId) {
7852
+ const unitMap = this._ensureUnitMap(unitId);
7853
+ return unitMap.has(sheetId) || unitMap.set(sheetId, /* @__PURE__ */ new Map()), unitMap.get(sheetId);
7854
+ }
7855
+ _ensureFeature(unitId, sheetId, feature) {
7856
+ const subunitMap = this._ensureSubunitMap(unitId, sheetId);
7857
+ return subunitMap.has(feature) || subunitMap.set(feature, []), subunitMap.get(feature);
7858
+ }
7859
+ addExclusiveRange(unitId, sheetId, feature, ranges) {
7860
+ this._ensureFeature(unitId, sheetId, feature).push(...ranges);
7861
+ }
7862
+ getExclusiveRanges(unitId, sheetId, feature) {
7863
+ var _a21, _b;
7864
+ return (_b = (_a21 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a21.get(sheetId)) == null ? void 0 : _b.get(feature);
7865
+ }
7866
+ clearExclusiveRanges(unitId, sheetId, feature) {
7867
+ this._ensureFeature(unitId, sheetId, feature), this._exclusiveRanges.get(unitId).get(sheetId).set(feature, []);
7868
+ }
7869
+ clearExclusiveRangesByGroupId(unitId, sheetId, feature, groupId) {
7870
+ const featureMap = this.getExclusiveRanges(unitId, sheetId, feature);
7871
+ if (featureMap) {
7872
+ const newFeatureMap = featureMap.filter((item) => item.groupId !== groupId);
7873
+ this._exclusiveRanges.get(unitId).get(sheetId).set(feature, newFeatureMap);
7874
+ }
7875
+ }
7876
+ getInterestGroupId(selections) {
7877
+ const interestGroupId = [];
7878
+ return selections.forEach((selection) => {
7879
+ var _a21;
7880
+ const range = selection.range, { unitId, sheetId } = range;
7881
+ if (!unitId || !sheetId) return;
7882
+ const featureMap = (_a21 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a21.get(sheetId);
7883
+ if (featureMap)
7884
+ for (const feature of featureMap.keys()) {
7885
+ const featureMapRanges = featureMap.get(feature);
7886
+ if (featureMapRanges) {
7887
+ for (const featureMapRange of featureMapRanges)
7888
+ if (Rectangle.intersects(range, featureMapRange.range)) {
7889
+ interestGroupId.push(feature);
7890
+ break;
7891
+ }
7892
+ }
7893
+ }
7894
+ }), interestGroupId;
7895
+ }
7896
+ };
7897
+ __name(_ExclusiveRangeService, "ExclusiveRangeService");
7898
+ let ExclusiveRangeService = _ExclusiveRangeService;
7661
7899
  var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7662
7900
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7663
7901
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7664
7902
  return kind && result && __defProp$4(target, key, result), result;
7665
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a15;
7666
- let RangeProtectionRenderModel = (_a15 = class {
7667
- constructor(_selectionProtectionRuleModel, _permissionService) {
7668
- __publicField(this, "_cache", new LRUMap(1e4));
7669
- this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._permissionService = _permissionService, this._init();
7903
+ }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a16;
7904
+ let NumfmtService = (_a16 = class extends Disposable {
7905
+ constructor(_resourceManagerService, _univerInstanceService, _logService) {
7906
+ super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._logService = _logService;
7907
+ }
7908
+ getValue(unitId, subUnitId, row, col) {
7909
+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7910
+ if (!workbook)
7911
+ return;
7912
+ const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7913
+ if (!worksheet)
7914
+ return;
7915
+ const styles = workbook.getStyles(), cell = worksheet.getCellRaw(row, col);
7916
+ if (cell != null && cell.s) {
7917
+ const style = styles.get(cell.s);
7918
+ if (style != null && style.n)
7919
+ return style.n;
7920
+ }
7921
+ return null;
7670
7922
  }
7671
- _init() {
7672
- this._permissionService.permissionPointUpdate$.pipe(
7673
- filter((permission) => permission.type === M.SelectRange),
7674
- filter((permission) => getAllRangePermissionPoint().some((F) => permission instanceof F)),
7675
- map$1((permission) => permission)
7676
- ).subscribe((permission) => {
7677
- const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(permission.unitId, permission.subUnitId);
7678
- for (const rule of ruleMap)
7679
- rule.permissionId === permission.permissionId && rule.ranges.forEach((range) => {
7680
- Range.foreach(range, (row, col) => {
7681
- const key = this._createKey(permission.unitId, permission.subUnitId, row, col);
7682
- this._cache.delete(key);
7683
- });
7684
- });
7685
- }), this._selectionProtectionRuleModel.ruleChange$.subscribe((info) => {
7686
- var _a20;
7687
- info.rule.ranges.forEach((range) => {
7688
- Range.foreach(range, (row, col) => {
7689
- const key = this._createKey(info.unitId, info.subUnitId, row, col);
7690
- this._cache.delete(key);
7691
- });
7692
- }), info.type === "set" && ((_a20 = info.oldRule) == null || _a20.ranges.forEach((range) => {
7923
+ deleteValues(unitId, subUnitId, values) {
7924
+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7925
+ if (!workbook)
7926
+ return;
7927
+ const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7928
+ if (!worksheet)
7929
+ return;
7930
+ const styles = workbook.getStyles();
7931
+ values.forEach((range) => {
7932
+ Range.foreach(range, (row, col) => {
7933
+ const cell = worksheet.getCellRaw(row, col);
7934
+ if (!cell)
7935
+ return;
7936
+ const oldStyleId = cell == null ? void 0 : cell.s, newStyle = { ...oldStyleId && styles.get(oldStyleId) || {} };
7937
+ delete newStyle.n;
7938
+ const newStyleId = styles.setValue(newStyle);
7939
+ cell.s = newStyleId;
7940
+ });
7941
+ });
7942
+ }
7943
+ setValues(unitId, subUnitId, values) {
7944
+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7945
+ if (!workbook)
7946
+ return;
7947
+ const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7948
+ if (!worksheet)
7949
+ return;
7950
+ const styles = workbook.getStyles(), matrix = worksheet.getCellMatrix();
7951
+ values.forEach((value) => {
7952
+ value.ranges.forEach((range) => {
7693
7953
  Range.foreach(range, (row, col) => {
7694
- const key = this._createKey(info.unitId, info.subUnitId, row, col);
7695
- this._cache.delete(key);
7954
+ const cell = worksheet.getCellRaw(row, col);
7955
+ if (cell) {
7956
+ const newStyle = { ...styles.getStyleByCell(cell) || {}, n: { pattern: value.pattern } }, styleId = styles.setValue(newStyle);
7957
+ cell.s = styleId;
7958
+ const type = getCellTypeByPattern(cell, value.pattern);
7959
+ cell.v !== void 0 && (cell.t = type, cell.v = getCellValue(type, cell));
7960
+ } else {
7961
+ const style = { n: { pattern: value.pattern } }, styleId = styles.setValue(style);
7962
+ styleId && matrix.setValue(row, col, { s: styleId });
7963
+ }
7696
7964
  });
7697
- }));
7965
+ });
7698
7966
  });
7699
7967
  }
7700
- _createKey(unitId, subUnitId, row, col) {
7701
- return `${unitId}_${subUnitId}_${row}_${col}`;
7702
- }
7703
- getCellInfo(unitId, subUnitId, row, col) {
7704
- const key = this._createKey(unitId, subUnitId, row, col), cacheValue = this._cache.get(key);
7705
- if (cacheValue)
7706
- return cacheValue;
7707
- const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(unitId, subUnitId), defaultV = [];
7708
- if (!ruleMap || !ruleMap.length)
7709
- return defaultV;
7710
- const result = [];
7711
- for (const rule of ruleMap)
7712
- if (rule.ranges.some((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col)) {
7713
- const permissionMap = getAllRangePermissionPoint().reduce((result2, F) => {
7714
- var _a20;
7715
- const instance = new F(unitId, subUnitId, rule.permissionId), permission = this._permissionService.getPermissionPoint(instance.id);
7716
- return result2[instance.subType] = (_a20 = permission == null ? void 0 : permission.value) != null ? _a20 : instance.value, result2;
7717
- }, {});
7718
- result.push({ ...permissionMap, ruleId: rule.id, ranges: rule.ranges });
7719
- }
7720
- return this._cache.set(key, result), result;
7721
- }
7722
- clear() {
7723
- this._cache.clear();
7724
- }
7725
- }, __name(_a15, "RangeProtectionRenderModel"), _a15);
7726
- RangeProtectionRenderModel = __decorateClass$4([
7727
- OnLifecycle(LifecycleStages.Ready, RangeProtectionRenderModel),
7728
- __decorateParam$4(0, Inject(RangeProtectionRuleModel)),
7729
- __decorateParam$4(1, Inject(IPermissionService))
7730
- ], RangeProtectionRenderModel);
7968
+ }, __name(_a16, "NumfmtService"), _a16);
7969
+ NumfmtService = __decorateClass$4([
7970
+ __decorateParam$4(0, IResourceManagerService),
7971
+ __decorateParam$4(1, IUniverInstanceService),
7972
+ __decorateParam$4(2, ILogService)
7973
+ ], NumfmtService);
7731
7974
  var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7732
7975
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7733
7976
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7734
7977
  return kind && result && __defProp$3(target, key, result), result;
7735
7978
  }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
7736
7979
  const mutationIdByRowCol = [InsertColMutation.id, InsertRowMutation.id, RemoveColMutation.id, RemoveRowMutation.id], mutationIdArrByMove = [MoveRowsMutation.id, MoveColsMutation.id];
7737
- var _a16;
7738
- let RangeProtectionRefRangeService = (_a16 = class extends Disposable {
7739
- constructor(_selectionProtectionRuleModel, _univerInstanceService, _commandService, _refRangeService, _selectionProtectionRenderModel) {
7980
+ var _a17;
7981
+ let RangeProtectionRefRangeService = (_a17 = class extends Disposable {
7982
+ constructor(_selectionProtectionRuleModel, _univerInstanceService, _commandService, _refRangeService, _selectionProtectionRenderModel, _rangeProtectionCache) {
7740
7983
  super();
7741
7984
  __publicField(this, "disposableCollection", new DisposableCollection());
7742
- this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._refRangeService = _refRangeService, this._selectionProtectionRenderModel = _selectionProtectionRenderModel, this._onRefRangeChange(), this._correctPermissionRange();
7985
+ this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._refRangeService = _refRangeService, this._selectionProtectionRenderModel = _selectionProtectionRenderModel, this._rangeProtectionCache = _rangeProtectionCache, this._onRefRangeChange(), this._correctPermissionRange(), this._initReBuildCache();
7743
7986
  }
7744
7987
  _onRefRangeChange() {
7745
7988
  const registerRefRange = /* @__PURE__ */ __name((unitId, subUnitId) => {
@@ -7930,14 +8173,23 @@ let RangeProtectionRefRangeService = (_a16 = class extends Disposable {
7930
8173
  _checkIsRightRange(range) {
7931
8174
  return range.startRow <= range.endRow && range.startColumn <= range.endColumn;
7932
8175
  }
7933
- }, __name(_a16, "RangeProtectionRefRangeService"), _a16);
8176
+ _initReBuildCache() {
8177
+ this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
8178
+ if (mutationIdByRowCol.includes(command.id) || mutationIdArrByMove.includes(command.id)) {
8179
+ const { unitId, subUnitId } = command.params;
8180
+ this._rangeProtectionCache.reBuildCache(unitId, subUnitId);
8181
+ }
8182
+ }));
8183
+ }
8184
+ }, __name(_a17, "RangeProtectionRefRangeService"), _a17);
7934
8185
  RangeProtectionRefRangeService = __decorateClass$3([
7935
8186
  OnLifecycle(LifecycleStages.Ready, RangeProtectionRefRangeService),
7936
8187
  __decorateParam$3(0, Inject(RangeProtectionRuleModel)),
7937
8188
  __decorateParam$3(1, Inject(IUniverInstanceService)),
7938
8189
  __decorateParam$3(2, ICommandService),
7939
8190
  __decorateParam$3(3, Inject(RefRangeService)),
7940
- __decorateParam$3(4, Inject(RangeProtectionRenderModel))
8191
+ __decorateParam$3(4, Inject(RangeProtectionRenderModel)),
8192
+ __decorateParam$3(5, Inject(RangeProtectionCache))
7941
8193
  ], RangeProtectionRefRangeService);
7942
8194
  var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7943
8195
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -7945,10 +8197,10 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
7945
8197
  return kind && result && __defProp$2(target, key, result), result;
7946
8198
  }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
7947
8199
  const PLUGIN_NAME$1 = "SHEET_RANGE_PROTECTION_PLUGIN";
7948
- var _a17;
7949
- let RangeProtectionService = (_a17 = class extends Disposable {
7950
- constructor(_selectionProtectionRuleModel, _permissionService, _resourceManagerService) {
7951
- super(), this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._permissionService = _permissionService, this._resourceManagerService = _resourceManagerService, this._initSnapshot(), this._initRuleChange();
8200
+ var _a18;
8201
+ let RangeProtectionService = (_a18 = class extends Disposable {
8202
+ constructor(_selectionProtectionRuleModel, _permissionService, _resourceManagerService, _selectionProtectionCache) {
8203
+ super(), this._selectionProtectionRuleModel = _selectionProtectionRuleModel, this._permissionService = _permissionService, this._resourceManagerService = _resourceManagerService, this._selectionProtectionCache = _selectionProtectionCache, this._initSnapshot(), this._initRuleChange();
7952
8204
  }
7953
8205
  _initRuleChange() {
7954
8206
  this.disposeWithMe(
@@ -8022,130 +8274,121 @@ let RangeProtectionService = (_a17 = class extends Disposable {
8022
8274
  });
8023
8275
  }, "onLoad"),
8024
8276
  onUnLoad: /* @__PURE__ */ __name((unitId) => {
8025
- this._selectionProtectionRuleModel.deleteUnitModel(unitId);
8277
+ this._selectionProtectionRuleModel.deleteUnitModel(unitId), this._selectionProtectionCache.deleteUnit(unitId);
8026
8278
  }, "onUnLoad")
8027
8279
  })
8028
8280
  );
8029
8281
  }
8030
- }, __name(_a17, "RangeProtectionService"), _a17);
8282
+ }, __name(_a18, "RangeProtectionService"), _a18);
8031
8283
  RangeProtectionService = __decorateClass$2([
8032
8284
  __decorateParam$2(0, Inject(RangeProtectionRuleModel)),
8033
8285
  __decorateParam$2(1, Inject(IPermissionService)),
8034
- __decorateParam$2(2, Inject(IResourceManagerService))
8286
+ __decorateParam$2(2, Inject(IResourceManagerService)),
8287
+ __decorateParam$2(3, Inject(RangeProtectionCache))
8035
8288
  ], RangeProtectionService);
8289
+ const getAllWorkbookPermissionPoint = /* @__PURE__ */ __name(() => [
8290
+ WorkbookEditablePermission,
8291
+ WorkbookPrintPermission,
8292
+ WorkbookCommentPermission,
8293
+ WorkbookViewPermission,
8294
+ WorkbookCopyPermission,
8295
+ WorkbookExportPermission,
8296
+ WorkbookManageCollaboratorPermission,
8297
+ WorkbookCreateSheetPermission,
8298
+ WorkbookDeleteSheetPermission,
8299
+ WorkbookRenameSheetPermission,
8300
+ WorkbookHideSheetPermission,
8301
+ WorkbookDuplicatePermission,
8302
+ WorkbookSharePermission,
8303
+ WorkbookMoveSheetPermission,
8304
+ WorkbookCopySheetPermission,
8305
+ WorkbookViewHistoryPermission,
8306
+ WorkbookRecoverHistoryPermission
8307
+ ], "getAllWorkbookPermissionPoint"), defaultWorkbookPermissionPoints = [
8308
+ P.Edit,
8309
+ P.Print,
8310
+ P.Comment,
8311
+ P.View,
8312
+ P.Copy,
8313
+ P.Export,
8314
+ P.ManageCollaborator,
8315
+ P.CreateSheet,
8316
+ P.DeleteSheet,
8317
+ P.RenameSheet,
8318
+ P.HideSheet,
8319
+ P.Duplicate,
8320
+ P.Share,
8321
+ P.MoveSheet,
8322
+ P.CopySheet,
8323
+ P.RecoverHistory,
8324
+ P.ViewHistory
8325
+ ];
8036
8326
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
8037
8327
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
8038
8328
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
8039
8329
  return kind && result && __defProp$1(target, key, result), result;
8040
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a18;
8041
- let NumberCellDisplayController = (_a18 = class extends Disposable {
8042
- constructor(_sheetInterceptorService) {
8043
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._initialize();
8044
- }
8045
- _initialize() {
8046
- this._initInterceptorCellContent();
8047
- }
8048
- _initInterceptorCellContent() {
8049
- this.disposeWithMe(
8050
- this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
8051
- priority: 11,
8052
- handler: /* @__PURE__ */ __name((cell, location, next) => {
8053
- var _a20;
8054
- const style = location.workbook.getStyles().getStyleByCell(cell);
8055
- return (_a20 = style == null ? void 0 : style.n) != null && _a20.pattern ? next({ ...cell }) : (cell == null ? void 0 : cell.t) === CellValueType.NUMBER && typeof (cell == null ? void 0 : cell.v) == "number" ? next({
8056
- ...cell,
8057
- v: stripErrorMargin(cell.v)
8058
- }) : next({ ...cell });
8059
- }, "handler")
8060
- })
8061
- );
8062
- }
8063
- }, __name(_a18, "NumberCellDisplayController"), _a18);
8064
- NumberCellDisplayController = __decorateClass$1([
8065
- OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController),
8066
- __decorateParam$1(0, Inject(SheetInterceptorService))
8067
- ], NumberCellDisplayController);
8068
- const IExclusiveRangeService = createIdentifier("univer.exclusive-range-service"), _ExclusiveRangeService = class _ExclusiveRangeService extends Disposable {
8069
- constructor() {
8070
- super(...arguments);
8071
- /**
8072
- * Exclusive range data structure is as follows: unitId -> sheetId -> feature -> range
8073
- */
8074
- __publicField(this, "_exclusiveRanges", /* @__PURE__ */ new Map());
8075
- }
8076
- _ensureUnitMap(unitId) {
8077
- return this._exclusiveRanges.has(unitId) || this._exclusiveRanges.set(unitId, /* @__PURE__ */ new Map()), this._exclusiveRanges.get(unitId);
8078
- }
8079
- _ensureSubunitMap(unitId, sheetId) {
8080
- const unitMap = this._ensureUnitMap(unitId);
8081
- return unitMap.has(sheetId) || unitMap.set(sheetId, /* @__PURE__ */ new Map()), unitMap.get(sheetId);
8082
- }
8083
- _ensureFeature(unitId, sheetId, feature) {
8084
- const subunitMap = this._ensureSubunitMap(unitId, sheetId);
8085
- return subunitMap.has(feature) || subunitMap.set(feature, []), subunitMap.get(feature);
8086
- }
8087
- addExclusiveRange(unitId, sheetId, feature, ranges) {
8088
- this._ensureFeature(unitId, sheetId, feature).push(...ranges);
8089
- }
8090
- getExclusiveRanges(unitId, sheetId, feature) {
8091
- var _a20, _b;
8092
- return (_b = (_a20 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a20.get(sheetId)) == null ? void 0 : _b.get(feature);
8093
- }
8094
- clearExclusiveRanges(unitId, sheetId, feature) {
8095
- this._ensureFeature(unitId, sheetId, feature), this._exclusiveRanges.get(unitId).get(sheetId).set(feature, []);
8096
- }
8097
- clearExclusiveRangesByGroupId(unitId, sheetId, feature, groupId) {
8098
- const featureMap = this.getExclusiveRanges(unitId, sheetId, feature);
8099
- if (featureMap) {
8100
- const newFeatureMap = featureMap.filter((item) => item.groupId !== groupId);
8101
- this._exclusiveRanges.get(unitId).get(sheetId).set(feature, newFeatureMap);
8102
- }
8330
+ }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a19;
8331
+ let WorkbookPermissionService = (_a19 = class extends Disposable {
8332
+ constructor(_permissionService, _univerInstanceService, _rangeProtectionRuleModel) {
8333
+ super(), this._permissionService = _permissionService, this._univerInstanceService = _univerInstanceService, this._rangeProtectionRuleModel = _rangeProtectionRuleModel, this._init();
8103
8334
  }
8104
- getInterestGroupId(selections) {
8105
- const interestGroupId = [];
8106
- return selections.forEach((selection) => {
8107
- var _a20;
8108
- const range = selection.range, { unitId, sheetId } = range;
8109
- if (!unitId || !sheetId) return;
8110
- const featureMap = (_a20 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a20.get(sheetId);
8111
- if (featureMap)
8112
- for (const feature of featureMap.keys()) {
8113
- const featureMapRanges = featureMap.get(feature);
8114
- if (featureMapRanges) {
8115
- for (const featureMapRange of featureMapRanges)
8116
- if (Rectangle.intersects(range, featureMapRange.range)) {
8117
- interestGroupId.push(feature);
8118
- break;
8119
- }
8120
- }
8121
- }
8122
- }), interestGroupId;
8335
+ _init() {
8336
+ const handleWorkbook = /* @__PURE__ */ __name((workbook) => {
8337
+ const unitId = workbook.getUnitId();
8338
+ getAllWorkbookPermissionPoint().forEach((F) => {
8339
+ const instance = new F(unitId);
8340
+ this._permissionService.addPermissionPoint(instance);
8341
+ });
8342
+ }, "handleWorkbook");
8343
+ this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {
8344
+ handleWorkbook(workbook);
8345
+ }), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
8346
+ handleWorkbook(workbook);
8347
+ })), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
8348
+ const unitId = workbook.getUnitId();
8349
+ workbook.getSheets().forEach((worksheet) => {
8350
+ const subUnitId = worksheet.getSheetId();
8351
+ this._rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).forEach((rule) => {
8352
+ [RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint].forEach((F) => {
8353
+ const instance = new F(unitId, subUnitId, rule.permissionId);
8354
+ this._permissionService.deletePermissionPoint(instance.id);
8355
+ });
8356
+ }), [...getAllWorksheetPermissionPoint(), ...getAllWorksheetPermissionPointByPointPanel()].forEach((F) => {
8357
+ const instance = new F(unitId, subUnitId);
8358
+ this._permissionService.deletePermissionPoint(instance.id);
8359
+ });
8360
+ }), getAllWorkbookPermissionPoint().forEach((F) => {
8361
+ const instance = new F(unitId);
8362
+ this._permissionService.deletePermissionPoint(instance.id);
8363
+ });
8364
+ }));
8123
8365
  }
8124
- };
8125
- __name(_ExclusiveRangeService, "ExclusiveRangeService");
8126
- let ExclusiveRangeService = _ExclusiveRangeService;
8127
- const PLUGIN_CONFIG_KEY = "sheets.config", defaultPluginConfig = {};
8366
+ }, __name(_a19, "WorkbookPermissionService"), _a19);
8367
+ WorkbookPermissionService = __decorateClass$1([
8368
+ OnLifecycle(LifecycleStages.Starting, WorkbookPermissionService),
8369
+ __decorateParam$1(0, Inject(IPermissionService)),
8370
+ __decorateParam$1(1, Inject(IUniverInstanceService)),
8371
+ __decorateParam$1(2, Inject(RangeProtectionRuleModel))
8372
+ ], WorkbookPermissionService);
8128
8373
  var __defProp2 = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __defNormalProp2 = /* @__PURE__ */ __name((obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value, "__defNormalProp"), __decorateClass = /* @__PURE__ */ __name((decorators, target, key, kind) => {
8129
8374
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
8130
8375
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
8131
8376
  return kind && result && __defProp2(target, key, result), result;
8132
8377
  }, "__decorateClass"), __decorateParam = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam"), __publicField2 = /* @__PURE__ */ __name((obj, key, value) => __defNormalProp2(obj, typeof key != "symbol" ? key + "" : key, value), "__publicField");
8133
8378
  const PLUGIN_NAME = "SHEET_PLUGIN";
8134
- var _a19;
8135
- let UniverSheetsPlugin = (_a19 = class extends Plugin {
8379
+ var _a20;
8380
+ let UniverSheetsPlugin = (_a20 = class extends Plugin {
8136
8381
  constructor(_config = defaultPluginConfig, _injector, _configService) {
8137
8382
  super(), this._config = _config, this._injector = _injector, this._configService = _configService;
8138
8383
  const { ...rest } = this._config;
8139
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initConfig(), this._initDependencies(_injector);
8140
- }
8141
- onRendered() {
8384
+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initConfig(), this._initDependencies();
8142
8385
  }
8143
8386
  _initConfig() {
8144
- var _a20;
8145
- (_a20 = this._config) != null && _a20.onlyRegisterFormulaRelatedMutations && this._configService.setConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY, !0);
8387
+ var _a21;
8388
+ (_a21 = this._config) != null && _a21.onlyRegisterFormulaRelatedMutations && this._configService.setConfig(ONLY_REGISTER_FORMULA_RELATED_MUTATIONS_KEY, !0);
8146
8389
  }
8147
- _initDependencies(sheetInjector) {
8148
- var _a20, _b;
8390
+ _initDependencies() {
8391
+ var _a21, _b;
8149
8392
  const dependencies = [
8150
8393
  // services
8151
8394
  [BorderStyleManagerService],
@@ -8166,6 +8409,7 @@ let UniverSheetsPlugin = (_a19 = class extends Plugin {
8166
8409
  // range protection
8167
8410
  [RangeProtectionRenderModel],
8168
8411
  [RangeProtectionRuleModel],
8412
+ [RangeProtectionCache],
8169
8413
  [RangeProtectionRefRangeService],
8170
8414
  [RangeProtectionService],
8171
8415
  [IExclusiveRangeService, {
@@ -8173,11 +8417,14 @@ let UniverSheetsPlugin = (_a19 = class extends Plugin {
8173
8417
  deps: [SheetsSelectionsService]
8174
8418
  }]
8175
8419
  ];
8176
- (_a20 = this._config) != null && _a20.notExecuteFormula || dependencies.push([CalculateResultApplyController]), mergeOverrideWithDependencies(dependencies, (_b = this._config) == null ? void 0 : _b.override).forEach((d) => {
8177
- sheetInjector.add(d);
8420
+ (_a21 = this._config) != null && _a21.notExecuteFormula || dependencies.push([CalculateResultApplyController]), mergeOverrideWithDependencies(dependencies, (_b = this._config) == null ? void 0 : _b.override).forEach((d) => {
8421
+ this._injector.add(d);
8178
8422
  }), this._injector.get(SheetInterceptorService), this._injector.get(RangeProtectionService), this._injector.get(IExclusiveRangeService);
8179
8423
  }
8180
- }, __name(_a19, "UniverSheetsPlugin"), _a19);
8424
+ onStarting(_injector) {
8425
+ this._injector.get(MergeCellController);
8426
+ }
8427
+ }, __name(_a20, "UniverSheetsPlugin"), _a20);
8181
8428
  __publicField2(UniverSheetsPlugin, "pluginName", PLUGIN_NAME);
8182
8429
  __publicField2(UniverSheetsPlugin, "type", UniverInstanceType.UNIVER_SHEET);
8183
8430
  UniverSheetsPlugin = __decorateClass([
@@ -8594,8 +8841,8 @@ const AddWorksheetMergeCommand = {
8594
8841
  type: CommandType.COMMAND,
8595
8842
  id: "sheet.command.add-worksheet-merge-all",
8596
8843
  handler: /* @__PURE__ */ __name(async (accessor) => {
8597
- var _a20;
8598
- const commandService = accessor.get(ICommandService), selections = (_a20 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
8844
+ var _a21;
8845
+ const commandService = accessor.get(ICommandService), selections = (_a21 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
8599
8846
  if (!(selections != null && selections.length))
8600
8847
  return !1;
8601
8848
  const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
@@ -8613,8 +8860,8 @@ const AddWorksheetMergeCommand = {
8613
8860
  type: CommandType.COMMAND,
8614
8861
  id: "sheet.command.add-worksheet-merge-vertical",
8615
8862
  handler: /* @__PURE__ */ __name(async (accessor) => {
8616
- var _a20;
8617
- const commandService = accessor.get(ICommandService), selections = (_a20 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
8863
+ var _a21;
8864
+ const commandService = accessor.get(ICommandService), selections = (_a21 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
8618
8865
  if (!(selections != null && selections.length))
8619
8866
  return !1;
8620
8867
  const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
@@ -8633,8 +8880,8 @@ const AddWorksheetMergeCommand = {
8633
8880
  type: CommandType.COMMAND,
8634
8881
  id: "sheet.command.add-worksheet-merge-horizontal",
8635
8882
  handler: /* @__PURE__ */ __name(async (accessor) => {
8636
- var _a20;
8637
- const commandService = accessor.get(ICommandService), selections = (_a20 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a20.map((s) => s.range);
8883
+ var _a21;
8884
+ const commandService = accessor.get(ICommandService), selections = (_a21 = accessor.get(SheetsSelectionsService).getCurrentSelections()) == null ? void 0 : _a21.map((s) => s.range);
8638
8885
  if (!(selections != null && selections.length))
8639
8886
  return !1;
8640
8887
  const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
@@ -8684,12 +8931,12 @@ const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, pa
8684
8931
  type: CommandType.COMMAND,
8685
8932
  id: "sheet.command.set-hide-gridlines",
8686
8933
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
8687
- var _a20;
8934
+ var _a21;
8688
8935
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
8689
8936
  if (!target) return !1;
8690
8937
  const { unitId, subUnitId } = target;
8691
8938
  let hideGridlines = BooleanNumber.FALSE;
8692
- params && (hideGridlines = (_a20 = params.hideGridlines) != null ? _a20 : BooleanNumber.FALSE);
8939
+ params && (hideGridlines = (_a21 = params.hideGridlines) != null ? _a21 : BooleanNumber.FALSE);
8693
8940
  const workbook = univerInstanceService.getUniverSheetInstance(unitId);
8694
8941
  if (!workbook || !workbook.getSheetBySheetId(subUnitId)) return !1;
8695
8942
  const setHideGridlinesMutationParams = {
@@ -8724,12 +8971,12 @@ const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, pa
8724
8971
  type: CommandType.COMMAND,
8725
8972
  id: "sheet.command.set-worksheet-right-to-left",
8726
8973
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
8727
- var _a20;
8974
+ var _a21;
8728
8975
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
8729
8976
  if (!target) return !1;
8730
8977
  const { unitId, subUnitId } = target;
8731
8978
  let rightToLeft = BooleanNumber.FALSE;
8732
- params && (rightToLeft = (_a20 = params.rightToLeft) != null ? _a20 : BooleanNumber.FALSE);
8979
+ params && (rightToLeft = (_a21 = params.rightToLeft) != null ? _a21 : BooleanNumber.FALSE);
8733
8980
  const setWorksheetRightToLeftMutationParams = {
8734
8981
  rightToLeft,
8735
8982
  unitId,
@@ -8819,6 +9066,7 @@ export {
8819
9066
  NumfmtService,
8820
9067
  OperatorType,
8821
9068
  RangeMergeUtil,
9069
+ RangeProtectionCache,
8822
9070
  RangeProtectionPermissionEditPoint,
8823
9071
  RangeProtectionPermissionViewPoint,
8824
9072
  RangeProtectionRefRangeService,
@@ -8920,6 +9168,7 @@ export {
8920
9168
  SetWorksheetShowCommand,
8921
9169
  SheetInterceptorService,
8922
9170
  SheetsSelectionsService,
9171
+ P as UnitAction,
8923
9172
  M as UnitObject,
8924
9173
  UniverSheetsPlugin,
8925
9174
  WorkbookCommentPermission,