@univerjs/sheets 0.2.14 → 0.3.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/lib/cjs/index.js +3 -3
  2. package/lib/es/index.js +1560 -1325
  3. package/lib/types/basics/rangeMerge.d.ts +1 -1
  4. package/lib/types/basics/selection.d.ts +1 -0
  5. package/lib/types/commands/commands/__tests__/add-merge-command.spec.d.ts +16 -0
  6. package/lib/types/commands/commands/set-border-command.d.ts +9 -9
  7. package/lib/types/commands/commands/utils/selection-utils.d.ts +1 -1
  8. package/lib/types/commands/commands/utils/target-util.d.ts +1 -2
  9. package/lib/types/commands/operations/selection.operation.d.ts +2 -0
  10. package/lib/types/controllers/merge-cell.controller.d.ts +3 -3
  11. package/lib/types/index.d.ts +66 -63
  12. package/lib/types/model/range-protection-rule.model.d.ts +9 -7
  13. package/lib/types/model/range-protection.cache.d.ts +30 -0
  14. package/lib/types/services/border-style-manager.service.d.ts +1 -1
  15. package/lib/types/services/permission/permission-point/index.d.ts +32 -32
  16. package/lib/types/services/permission/range-permission/range-protection.ref-range.d.ts +9 -6
  17. package/lib/types/services/permission/range-permission/range-protection.service.d.ts +3 -1
  18. package/lib/types/services/permission/worksheet-permission/index.d.ts +1 -1
  19. package/lib/types/services/permission/worksheet-permission/utils.d.ts +2 -2
  20. package/lib/types/services/ref-range/util.d.ts +5 -5
  21. package/lib/types/services/sheet-interceptor/interceptor-const.d.ts +4 -2
  22. package/lib/types/services/sheet-interceptor/sheet-interceptor.service.d.ts +2 -2
  23. package/lib/types/sheets-plugin.d.ts +2 -2
  24. package/lib/umd/index.js +2 -2
  25. package/package.json +13 -13
  26. package/lib/types/commands/commands/utils/merged-cell-util.d.ts +0 -6
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();
@@ -87,7 +87,7 @@ let SheetsSelectionsService = (_a = class extends RxDisposable {
87
87
  const { unitId, sheetId } = current;
88
88
  this._ensureWorkbookSelection(unitId).setSelections(
89
89
  sheetId,
90
- unitIdOrSelections,
90
+ unitIdOrSelections != null ? unitIdOrSelections : selectionDatas,
91
91
  worksheetIdOrType != null ? worksheetIdOrType : 2
92
92
  /* MOVE_END */
93
93
  );
@@ -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",
@@ -2719,7 +2737,7 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2719
2737
  const mergeConfigData = worksheet.getConfig().mergeData, mergeAppendData = params.ranges;
2720
2738
  for (let i = 0; i < mergeAppendData.length; i++)
2721
2739
  mergeConfigData.push(mergeAppendData[i]);
2722
- return !0;
2740
+ return worksheet.getSpanModel().rebuild(mergeConfigData), !0;
2723
2741
  }, "handler")
2724
2742
  }, RemoveMergeUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
2725
2743
  const universheet = accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId);
@@ -2754,15 +2772,15 @@ const RemoveRowCommandId = "sheet.command.remove-row", RemoveRowCommand = {
2754
2772
  const configMerge = mergeConfigData[i], removeMerge = mergeRemoveData[j];
2755
2773
  Rectangle.intersects(configMerge, removeMerge) && mergeConfigData.splice(i, 1);
2756
2774
  }
2757
- return !0;
2775
+ return worksheet.getSpanModel().rebuild(mergeConfigData), !0;
2758
2776
  }, "handler")
2759
2777
  }, RemoveWorksheetMergeCommand = {
2760
2778
  type: CommandType.COMMAND,
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",
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",
2873
3166
  type: CommandType.COMMAND,
2874
3167
  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, {
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,260 +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), mergeData = worksheet.getConfig().mergeData;
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
- }, hasMerge = /* @__PURE__ */ __name((row, column) => {
2961
- let res = null;
2962
- return mergeData.forEach((merge2) => {
2963
- Rectangle.intersects(merge2, {
2964
- startColumn: column,
2965
- endColumn: column,
2966
- startRow: row,
2967
- endRow: row
2968
- }) && (res = merge2);
2969
- }), res;
2970
- }, "hasMerge");
2971
- function setBorderStyle(range2, defaultStyle, reserve) {
2972
- range2.startRow < 0 || range2.startColumn < 0 || forEach(range2, (row, column) => {
2973
- var _a21, _b;
2974
- const rectangle = hasMerge(row, column);
2975
- let bdStyle = defaultStyle;
2976
- if (rectangle && (defaultStyle.bc_tr || defaultStyle.ml_tr || defaultStyle.bl_tr || defaultStyle.tl_mr || defaultStyle.tl_bc || defaultStyle.tl_br)) {
2977
- if (reserve) {
2978
- const style2 = Tools.deepClone(
2979
- (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s
2980
- );
2981
- bdStyle = style2 != null && style2.bd ? Object.assign(style2.bd, defaultStyle) : defaultStyle;
2982
- }
2983
- mr.setValue(rectangle.startRow, rectangle.startColumn, {
2984
- s: {
2985
- bd: bdStyle
2986
- }
2987
- });
2988
- } else {
2989
- if (reserve) {
2990
- const style2 = Tools.deepClone((_b = mr.getValue(row, column)) == null ? void 0 : _b.s);
2991
- bdStyle = style2 != null && style2.bd ? Object.assign(style2.bd, defaultStyle) : defaultStyle;
2992
- }
2993
- mr.setValue(row, column, { s: { bd: bdStyle } });
2994
- }
2995
- });
2996
- }
2997
- __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) => {
2998
- var _a21, _b, _c, _d;
2999
- const rectangle = hasMerge(row, column);
3000
- if (rectangle) {
3001
- if (rectangle.endColumn !== range.endColumn) {
3002
- const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
3003
- mr.setValue(row, column, {
3004
- s: {
3005
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: Tools.deepClone(border) }) : { r: Tools.deepClone(border) }
3006
- }
3007
- });
3008
- }
3009
- if (rectangle.startColumn !== range.startColumn) {
3010
- const style2 = (_b = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _b.s;
3011
- mr.setValue(row, column, {
3012
- s: {
3013
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: Tools.deepClone(border) }) : { l: Tools.deepClone(border) }
3014
- }
3015
- });
3016
- }
3017
- } else {
3018
- if (column !== range.endColumn) {
3019
- const style2 = (_c = mr.getValue(row, column)) == null ? void 0 : _c.s;
3020
- mr.setValue(row, column, {
3021
- s: {
3022
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: Tools.deepClone(border) }) : { r: Tools.deepClone(border) }
3023
- }
3024
- });
3025
- }
3026
- if (column !== range.startColumn) {
3027
- const style2 = (_d = mr.getValue(row, column)) == null ? void 0 : _d.s;
3028
- mr.setValue(row, column, {
3029
- s: {
3030
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: Tools.deepClone(border) }) : { l: Tools.deepClone(border) }
3031
- }
3032
- });
3033
- }
3034
- }
3035
- }), horizontal && forEach(range, (row, column) => {
3036
- var _a21, _b, _c, _d;
3037
- const rectangle = hasMerge(row, column);
3038
- if (rectangle) {
3039
- if (rectangle.endRow !== range.endRow) {
3040
- const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
3041
- mr.setValue(row, column, {
3042
- s: {
3043
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: Tools.deepClone(border) }) : { b: Tools.deepClone(border) }
3044
- }
3045
- });
3046
- }
3047
- if (rectangle.startRow !== range.startRow) {
3048
- const style2 = (_b = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _b.s;
3049
- mr.setValue(row, column, {
3050
- s: {
3051
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: Tools.deepClone(border) }) : { t: Tools.deepClone(border) }
3052
- }
3053
- });
3054
- }
3055
- } else {
3056
- if (row !== range.endRow) {
3057
- const style2 = (_c = mr.getValue(row, column)) == null ? void 0 : _c.s;
3058
- mr.setValue(row, column, {
3059
- s: {
3060
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: Tools.deepClone(border) }) : { b: Tools.deepClone(border) }
3061
- }
3062
- });
3063
- }
3064
- if (row !== range.startRow) {
3065
- const style2 = (_d = mr.getValue(row, column)) == null ? void 0 : _d.s;
3066
- mr.setValue(row, column, {
3067
- s: {
3068
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: Tools.deepClone(border) }) : { t: Tools.deepClone(border) }
3069
- }
3070
- });
3071
- }
3072
- }
3073
- }), !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) => {
3074
- var _a21, _b, _c, _d, _e, _f, _g, _h;
3075
- const rectangle = hasMerge(row, column);
3076
- if (rectangle) {
3077
- if (rectangle.endColumn !== range.endColumn) {
3078
- const style2 = (_a21 = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _a21.s;
3079
- mr.setValue(row, column, {
3080
- s: {
3081
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: null }) : { r: null }
3082
- }
3083
- });
3084
- }
3085
- if (rectangle.startColumn !== range.startColumn) {
3086
- const style2 = (_b = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _b.s;
3087
- mr.setValue(row, column, {
3088
- s: {
3089
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: null }) : { l: null }
3090
- }
3091
- });
3092
- }
3093
- if (rectangle.endRow !== range.endRow) {
3094
- const style2 = (_c = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _c.s;
3095
- mr.setValue(row, column, {
3096
- s: {
3097
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: null }) : { b: null }
3098
- }
3099
- });
3100
- }
3101
- if (rectangle.startRow !== range.startRow) {
3102
- const style2 = (_d = mr.getValue(rectangle.startRow, rectangle.startColumn)) == null ? void 0 : _d.s;
3103
- mr.setValue(row, column, {
3104
- s: {
3105
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: null }) : { t: null }
3106
- }
3107
- });
3108
- }
3109
- } else {
3110
- if (column !== range.endColumn) {
3111
- const style2 = (_e = mr.getValue(row, column)) == null ? void 0 : _e.s;
3112
- mr.setValue(row, column, {
3113
- s: {
3114
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { r: null }) : { r: null }
3115
- }
3116
- });
3117
- }
3118
- if (column !== range.startColumn) {
3119
- const style2 = (_f = mr.getValue(row, column)) == null ? void 0 : _f.s;
3120
- mr.setValue(row, column, {
3121
- s: {
3122
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { l: null }) : { l: null }
3123
- }
3124
- });
3125
- }
3126
- if (row !== range.endRow) {
3127
- const style2 = (_g = mr.getValue(row, column)) == null ? void 0 : _g.s;
3128
- mr.setValue(row, column, {
3129
- s: {
3130
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { b: null }) : { b: null }
3131
- }
3132
- });
3133
- }
3134
- if (row !== range.startRow) {
3135
- const style2 = (_h = mr.getValue(row, column)) == null ? void 0 : _h.s;
3136
- mr.setValue(row, column, {
3137
- s: {
3138
- bd: style2 != null && style2.bd ? Object.assign(style2.bd, { t: null }) : { t: null }
3139
- }
3140
- });
3141
- }
3142
- }
3143
- }));
3144
- 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, {
3145
3220
  unitId,
3146
- subUnitId,
3147
- cellValue: mr.getData()
3148
- }, undoSetRangeValuesMutationParams = SetRangeValuesUndoMutationFactory(
3149
- accessor,
3150
- setRangeValuesMutationParams
3151
- );
3152
- return commandService.syncExecuteCommand(SetRangeValuesMutation.id, setRangeValuesMutationParams) ? (undoRedoService.pushUndoRedo({
3153
- unitID: unitId,
3154
- undoMutations: [{ id: SetRangeValuesMutation.id, params: undoSetRangeValuesMutationParams }],
3155
- redoMutations: [{ id: SetRangeValuesMutation.id, params: setRangeValuesMutationParams }]
3156
- }), !0) : !1;
3221
+ subUnitId
3222
+ });
3157
3223
  }, "handler")
3158
3224
  }, SetColHiddenUndoMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3159
3225
  if (accessor.get(IUniverInstanceService).getUniverSheetInstance(params.unitId) == null)
@@ -3209,7 +3275,7 @@ const SetBorderBasicCommand = {
3209
3275
  type: CommandType.COMMAND,
3210
3276
  id: "sheet.command.set-col-visible-on-cols",
3211
3277
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3212
- var _a20, _b;
3278
+ var _a21, _b;
3213
3279
  const { unitId, subUnitId, ranges } = params, sheetInterceptorService = accessor.get(SheetInterceptorService), commandService = accessor.get(ICommandService), instanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(instanceService, { unitId, subUnitId });
3214
3280
  if (!target) return !1;
3215
3281
  const { worksheet } = target, redoMutationParams = {
@@ -3219,6 +3285,7 @@ const SetBorderBasicCommand = {
3219
3285
  }, setSelectionOperationParams = {
3220
3286
  unitId,
3221
3287
  subUnitId,
3288
+ reveal: !0,
3222
3289
  selections: ranges.map((r) => ({ range: r, primary: getPrimaryForRange(r, worksheet), style: null }))
3223
3290
  }, undoMutationParams = SetColVisibleUndoMutationFactory(accessor, redoMutationParams), undoSetSelectionsOperationParams = {
3224
3291
  unitId,
@@ -3240,7 +3307,7 @@ const SetBorderBasicCommand = {
3240
3307
  undoMutations: [
3241
3308
  { id: SetColHiddenMutation.id, params: undoMutationParams },
3242
3309
  { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
3243
- ...(_a20 = intercepted.undos) != null ? _a20 : []
3310
+ ...(_a21 = intercepted.undos) != null ? _a21 : []
3244
3311
  ],
3245
3312
  redoMutations: [
3246
3313
  ...(_b = intercepted.preRedos) != null ? _b : [],
@@ -3254,8 +3321,8 @@ const SetBorderBasicCommand = {
3254
3321
  type: CommandType.COMMAND,
3255
3322
  id: "sheet.command.set-selected-cols-visible",
3256
3323
  handler: /* @__PURE__ */ __name(async (accessor) => {
3257
- var _a20;
3258
- 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);
3259
3326
  if (!(ranges != null && ranges.length)) return !1;
3260
3327
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService));
3261
3328
  if (!target) return !1;
@@ -3270,9 +3337,9 @@ const SetBorderBasicCommand = {
3270
3337
  type: CommandType.COMMAND,
3271
3338
  id: "sheet.command.set-col-hidden",
3272
3339
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3273
- var _a20, _b, _c, _d;
3340
+ var _a21, _b, _c, _d;
3274
3341
  const selectionManagerService = accessor.get(SheetsSelectionsService), sheetInterceptorService = accessor.get(SheetInterceptorService), univerInstanceService = accessor.get(IUniverInstanceService), commandService = accessor.get(ICommandService);
3275
- 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);
3276
3343
  if (!(ranges != null && ranges.length)) return !1;
3277
3344
  const target = getSheetCommandTarget(univerInstanceService, params);
3278
3345
  if (!target) return !1;
@@ -3289,6 +3356,7 @@ const SetBorderBasicCommand = {
3289
3356
  }, undoMutationParams = SetColHiddenUndoMutationFactory(accessor, redoMutationParams), undoSetSelectionsOperationParams = {
3290
3357
  unitId,
3291
3358
  subUnitId,
3359
+ reveal: !0,
3292
3360
  selections: ranges.map((range) => ({
3293
3361
  range,
3294
3362
  primary: getPrimaryForRange(range, worksheet),
@@ -3382,8 +3450,8 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3382
3450
  }, SetFrozenCommand = {
3383
3451
  type: CommandType.COMMAND,
3384
3452
  id: "sheet.command.set-frozen",
3385
- handler: /* @__PURE__ */ __name(async (accessor, params) => {
3386
- 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 });
3387
3455
  if (!target) return !1;
3388
3456
  const { unitId, subUnitId, worksheet } = target, { startColumn, startRow, xSplit, ySplit } = params;
3389
3457
  if (startRow >= worksheet.getRowCount() || startColumn >= worksheet.getColumnCount() || xSplit >= worksheet.getColumnCount() || ySplit >= worksheet.getRowCount())
@@ -3402,7 +3470,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3402
3470
  }, SetFrozenCancelCommand = {
3403
3471
  type: CommandType.COMMAND,
3404
3472
  id: "sheet.command.set-frozen-cancel",
3405
- handler: /* @__PURE__ */ __name(async (accessor) => {
3473
+ handler: /* @__PURE__ */ __name((accessor) => {
3406
3474
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
3407
3475
  if (!target) return !1;
3408
3476
  const { unitId, subUnitId } = target, redoMutationParams = {
@@ -3473,12 +3541,13 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3473
3541
  type: CommandType.COMMAND,
3474
3542
  id: "sheet.command.set-specific-rows-visible",
3475
3543
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3476
- var _a20, _b, _c;
3544
+ var _a21, _b, _c;
3477
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 });
3478
3546
  if (!target) return !1;
3479
3547
  const { worksheet } = target, redoMutationParams = { unitId, subUnitId, ranges }, setSelectionOperationParams = {
3480
3548
  unitId,
3481
3549
  subUnitId,
3550
+ reveal: !0,
3482
3551
  selections: ranges.map((range) => ({
3483
3552
  range,
3484
3553
  primary: getPrimaryForRange(range, worksheet),
@@ -3505,7 +3574,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3505
3574
  return result.result && interceptedResult.result && undoRedoService.pushUndoRedo({
3506
3575
  unitID: unitId,
3507
3576
  undoMutations: [
3508
- ...(_a20 = intercepted.preUndos) != null ? _a20 : [],
3577
+ ...(_a21 = intercepted.preUndos) != null ? _a21 : [],
3509
3578
  { id: SetRowHiddenMutation.id, params: undoMutationParams },
3510
3579
  { id: SetSelectionsOperation.id, params: undoSetSelectionsOperationParams },
3511
3580
  ...(_b = intercepted.undos) != null ? _b : []
@@ -3522,8 +3591,8 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3522
3591
  type: CommandType.COMMAND,
3523
3592
  id: "sheet.command.set-selected-rows-visible",
3524
3593
  handler: /* @__PURE__ */ __name(async (accessor) => {
3525
- var _a20;
3526
- 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);
3527
3596
  if (!(ranges != null && ranges.length)) return !1;
3528
3597
  const target = getSheetCommandTarget(univerInstanceService);
3529
3598
  if (!target) return !1;
@@ -3538,9 +3607,9 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3538
3607
  type: CommandType.COMMAND,
3539
3608
  id: "sheet.command.set-rows-hidden",
3540
3609
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3541
- var _a20, _b, _c, _d, _e, _f;
3610
+ var _a21, _b, _c, _d, _e, _f;
3542
3611
  const selectionManagerService = accessor.get(SheetsSelectionsService), commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), sheetInterceptorService = accessor.get(SheetInterceptorService);
3543
- 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);
3544
3613
  if (!(ranges != null && ranges.length)) return !1;
3545
3614
  const target = getSheetCommandTarget(univerInstanceService, params);
3546
3615
  if (!target) return !1;
@@ -3556,6 +3625,7 @@ const SetFrozenMutationFactory = /* @__PURE__ */ __name((accessor, params) => {
3556
3625
  }, undoMutationParams = SetRowHiddenUndoMutationFactory(accessor, redoMutationParams), undoSetSelectionsOperationParams = {
3557
3626
  unitId,
3558
3627
  subUnitId,
3628
+ reveal: !0,
3559
3629
  selections: ranges.map((range) => ({
3560
3630
  range,
3561
3631
  primary: getPrimaryForRange(range, worksheet),
@@ -3625,10 +3695,10 @@ const SetStyleCommand = {
3625
3695
  type: CommandType.COMMAND,
3626
3696
  id: "sheet.command.set-style",
3627
3697
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
3628
- var _a20;
3698
+ var _a21;
3629
3699
  const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
3630
3700
  if (!target) return !1;
3631
- 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);
3632
3702
  if (!(ranges != null && ranges.length))
3633
3703
  return !1;
3634
3704
  const cellValue = new ObjectMatrix(), iterator = createRangeIteratorWithSkipFilteredRows(worksheet);
@@ -4004,7 +4074,7 @@ const SetStyleCommand = {
4004
4074
  id: "sheet.mutation.set-worksheet-col-width",
4005
4075
  type: CommandType.MUTATION,
4006
4076
  handler: /* @__PURE__ */ __name((accessor, params) => {
4007
- var _a20;
4077
+ var _a21;
4008
4078
  const univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4009
4079
  if (!target) return !1;
4010
4080
  const { worksheet } = target, defaultColumnWidth = worksheet.getConfig().defaultColumnWidth, manager = worksheet.getColumnManager(), ranges = params.ranges;
@@ -4012,7 +4082,7 @@ const SetStyleCommand = {
4012
4082
  const range = ranges[i];
4013
4083
  for (let j = range.startColumn; j < range.endColumn + 1; j++) {
4014
4084
  const column = manager.getColumnOrCreate(j);
4015
- 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;
4016
4086
  }
4017
4087
  }
4018
4088
  return !0;
@@ -4080,8 +4150,8 @@ const SetStyleCommand = {
4080
4150
  type: CommandType.COMMAND,
4081
4151
  id: "sheet.command.set-worksheet-col-width",
4082
4152
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4083
- var _a20, _b, _c, _d;
4084
- 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);
4085
4155
  if (!(selections != null && selections.length)) return !1;
4086
4156
  const target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
4087
4157
  if (!target) return !1;
@@ -4166,7 +4236,7 @@ const SetStyleCommand = {
4166
4236
  type: CommandType.COMMAND,
4167
4237
  id: "sheet.command.set-worksheet-name",
4168
4238
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4169
- var _a20, _b;
4239
+ var _a21, _b;
4170
4240
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), sheetInterceptorService = accessor.get(SheetInterceptorService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
4171
4241
  if (!target) return !1;
4172
4242
  const { unitId, subUnitId } = target, redoMutationParams = {
@@ -4180,7 +4250,7 @@ const SetStyleCommand = {
4180
4250
  id: SetWorksheetNameCommand.id,
4181
4251
  params
4182
4252
  }), redos = [
4183
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
4253
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
4184
4254
  { id: SetWorksheetNameMutation.id, params: redoMutationParams },
4185
4255
  ...interceptorCommands.redos
4186
4256
  ], undos = [
@@ -4266,14 +4336,14 @@ const SetStyleCommand = {
4266
4336
  id: "sheet.mutation.set-worksheet-row-height",
4267
4337
  type: CommandType.MUTATION,
4268
4338
  handler: /* @__PURE__ */ __name((accessor, params) => {
4269
- var _a20;
4339
+ var _a21;
4270
4340
  const { ranges, rowHeight } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4271
4341
  if (!target) return !1;
4272
- const { worksheet } = target, defaultRowHeight = worksheet.getConfig().defaultRowHeight, manager = worksheet.getRowManager();
4342
+ const { worksheet } = target, manager = worksheet.getRowManager(), defaultRowHeight = worksheet.getConfig().defaultRowHeight;
4273
4343
  for (const { startRow, endRow } of ranges)
4274
4344
  for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
4275
4345
  const row = manager.getRowOrCreate(rowIndex);
4276
- 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);
4277
4347
  }
4278
4348
  return !0;
4279
4349
  }, "handler")
@@ -4281,14 +4351,14 @@ const SetStyleCommand = {
4281
4351
  id: "sheet.mutation.set-worksheet-row-is-auto-height",
4282
4352
  type: CommandType.MUTATION,
4283
4353
  handler: /* @__PURE__ */ __name((accessor, params) => {
4284
- var _a20;
4354
+ var _a21;
4285
4355
  const { ranges, autoHeightInfo } = params, univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4286
4356
  if (!target) return !1;
4287
4357
  const manager = target.worksheet.getRowManager();
4288
4358
  for (const { startRow, endRow } of ranges)
4289
4359
  for (let rowIndex = startRow; rowIndex <= endRow; rowIndex++) {
4290
4360
  const row = manager.getRowOrCreate(rowIndex);
4291
- 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;
4292
4362
  }
4293
4363
  return !0;
4294
4364
  }, "handler")
@@ -4310,7 +4380,7 @@ const SetStyleCommand = {
4310
4380
  id: "sheet.command.delta-row-height",
4311
4381
  // eslint-disable-next-line max-lines-per-function
4312
4382
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4313
- var _a20, _b;
4383
+ var _a21, _b;
4314
4384
  const selections = accessor.get(SheetsSelectionsService).getCurrentSelections(), sheetInterceptorService = accessor.get(SheetInterceptorService);
4315
4385
  if (!(selections != null && selections.length))
4316
4386
  return !1;
@@ -4370,7 +4440,7 @@ const SetStyleCommand = {
4370
4440
  return result.result && interceptedResult.result ? (undoRedoService.pushUndoRedo({
4371
4441
  unitID: unitId,
4372
4442
  undoMutations: [
4373
- ...(_a20 = intercepted.preUndos) != null ? _a20 : [],
4443
+ ...(_a21 = intercepted.preUndos) != null ? _a21 : [],
4374
4444
  {
4375
4445
  id: SetWorksheetRowHeightMutation.id,
4376
4446
  params: undoMutationParams
@@ -4400,8 +4470,8 @@ const SetStyleCommand = {
4400
4470
  id: "sheet.command.set-row-height",
4401
4471
  // eslint-disable-next-line max-lines-per-function
4402
4472
  handler: /* @__PURE__ */ __name((accessor, params) => {
4403
- var _a20, _b, _c, _d;
4404
- 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);
4405
4475
  if (!(selections != null && selections.length))
4406
4476
  return !1;
4407
4477
  const target = getSheetCommandTarget(univerInstanceService, params);
@@ -4461,10 +4531,10 @@ const SetStyleCommand = {
4461
4531
  type: CommandType.COMMAND,
4462
4532
  id: "sheet.command.set-row-is-auto-height",
4463
4533
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4464
- var _a20, _b;
4534
+ var _a21, _b;
4465
4535
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), selectionManagerService = accessor.get(SheetsSelectionsService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService, params);
4466
4536
  if (!target) return !1;
4467
- 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);
4468
4538
  if (!(ranges != null && ranges.length))
4469
4539
  return !1;
4470
4540
  const redoMutationParams = {
@@ -4757,7 +4827,7 @@ const factorySetNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) =
4757
4827
  type: CommandType.COMMAND,
4758
4828
  id: "sheet.command.set-workbook-name",
4759
4829
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
4760
- var _a20;
4830
+ var _a21;
4761
4831
  if (!accessor.get(IUniverInstanceService).getUnit(params.unitId, UniverInstanceType.UNIVER_SHEET)) return !1;
4762
4832
  const interceptedCommands = accessor.get(SheetInterceptorService).onCommandExecute({
4763
4833
  id: SetWorkbookNameCommand.id,
@@ -4766,18 +4836,18 @@ const factorySetNumfmtUndoMutation = /* @__PURE__ */ __name((accessor, option) =
4766
4836
  name: params.name,
4767
4837
  unitId: params.unitId
4768
4838
  }, redos = [
4769
- ...(_a20 = interceptedCommands.preRedos) != null ? _a20 : [],
4839
+ ...(_a21 = interceptedCommands.preRedos) != null ? _a21 : [],
4770
4840
  { id: SetWorkbookNameMutation.id, params: redoMutationParams },
4771
4841
  ...interceptedCommands.redos
4772
4842
  ], commandService = accessor.get(ICommandService);
4773
4843
  return sequenceExecute(redos, commandService).result;
4774
4844
  }, "handler")
4775
4845
  };
4776
- var __defProp$f = Object.defineProperty, __getOwnPropDesc$f = Object.getOwnPropertyDescriptor, __decorateClass$f = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4777
- 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--)
4778
4848
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4779
- return kind && result && __defProp$f(target, key, result), result;
4780
- }, "__decorateClass$f"), _a4;
4849
+ return kind && result && __defProp$g(target, key, result), result;
4850
+ }, "__decorateClass$g"), _a4;
4781
4851
  let WorksheetProtectionRuleModel = (_a4 = class {
4782
4852
  constructor() {
4783
4853
  /**
@@ -4804,18 +4874,18 @@ let WorksheetProtectionRuleModel = (_a4 = class {
4804
4874
  this._ensureSubUnitMap(unitId).set(rule.subUnitId, rule), this._ruleChange.next({ unitId, rule, type: "add", subUnitId: rule.subUnitId });
4805
4875
  }
4806
4876
  deleteRule(unitId, subUnitId) {
4807
- var _a20, _b, _c;
4808
- 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);
4809
4879
  rule && ((_c = this._model.get(unitId)) == null || _c.delete(subUnitId), this._ruleChange.next({ unitId, rule, type: "delete", subUnitId }));
4810
4880
  }
4811
4881
  setRule(unitId, subUnitId, rule) {
4812
- var _a20, _b;
4882
+ var _a21, _b;
4813
4883
  const oldRule = this.getRule(unitId, subUnitId);
4814
- 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 }));
4815
4885
  }
4816
4886
  getRule(unitId, subUnitId) {
4817
- var _a20, _b;
4818
- 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);
4819
4889
  }
4820
4890
  toObject() {
4821
4891
  const result = {};
@@ -4860,7 +4930,7 @@ let WorksheetProtectionRuleModel = (_a4 = class {
4860
4930
  return [unitId, subUnitId];
4861
4931
  }
4862
4932
  }, __name(_a4, "WorksheetProtectionRuleModel"), _a4);
4863
- WorksheetProtectionRuleModel = __decorateClass$f([
4933
+ WorksheetProtectionRuleModel = __decorateClass$g([
4864
4934
  OnLifecycle(LifecycleStages.Starting, WorksheetProtectionRuleModel)
4865
4935
  ], WorksheetProtectionRuleModel);
4866
4936
  const AddWorksheetProtectionMutation = {
@@ -4885,11 +4955,11 @@ const AddWorksheetProtectionMutation = {
4885
4955
  return accessor.get(WorksheetProtectionRuleModel).deleteRule(unitId, subUnitId), !0;
4886
4956
  }, "handler")
4887
4957
  };
4888
- var __defProp$e = Object.defineProperty, __getOwnPropDesc$e = Object.getOwnPropertyDescriptor, __decorateClass$e = /* @__PURE__ */ __name((decorators, target, key, kind) => {
4889
- 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--)
4890
4960
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
4891
- return kind && result && __defProp$e(target, key, result), result;
4892
- }, "__decorateClass$e"), _a5;
4961
+ return kind && result && __defProp$f(target, key, result), result;
4962
+ }, "__decorateClass$f"), _a5;
4893
4963
  let RangeProtectionRuleModel = (_a5 = class {
4894
4964
  constructor() {
4895
4965
  /**
@@ -4917,22 +4987,27 @@ let RangeProtectionRuleModel = (_a5 = class {
4917
4987
  this._ensureRuleMap(unitId, subUnitId).set(rule.id, rule), this._ruleChange.next({ unitId, subUnitId, rule, type: "add" });
4918
4988
  }
4919
4989
  deleteRule(unitId, subUnitId, id) {
4920
- var _a20, _b, _c, _d;
4921
- 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);
4922
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" }));
4923
4993
  }
4924
4994
  setRule(unitId, subUnitId, id, rule) {
4925
- var _a20, _b;
4995
+ var _a21, _b;
4926
4996
  const oldRule = this.getRule(unitId, subUnitId, id);
4927
- 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" }));
4928
4998
  }
4929
4999
  getRule(unitId, subUnitId, id) {
4930
- var _a20, _b;
4931
- 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);
4932
5002
  }
4933
5003
  getSubunitRuleList(unitId, subUnitId) {
4934
- var _a20;
4935
- 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;
4936
5011
  }
4937
5012
  _ensureRuleMap(unitId, subUnitId) {
4938
5013
  let subUnitMap = this._model.get(unitId);
@@ -4980,7 +5055,7 @@ let RangeProtectionRuleModel = (_a5 = class {
4980
5055
  return null;
4981
5056
  }
4982
5057
  }, __name(_a5, "RangeProtectionRuleModel"), _a5);
4983
- RangeProtectionRuleModel = __decorateClass$e([
5058
+ RangeProtectionRuleModel = __decorateClass$f([
4984
5059
  OnLifecycle(LifecycleStages.Starting, RangeProtectionRuleModel)
4985
5060
  ], RangeProtectionRuleModel);
4986
5061
  const getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
@@ -5017,11 +5092,11 @@ const getAllWorksheetPermissionPoint = /* @__PURE__ */ __name(() => [
5017
5092
  P.SetRowStyle,
5018
5093
  P.Sort
5019
5094
  ];
5020
- var __defProp$d = Object.defineProperty, __getOwnPropDesc$d = Object.getOwnPropertyDescriptor, __decorateClass$d = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5021
- 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--)
5022
5097
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5023
- return kind && result && __defProp$d(target, key, result), result;
5024
- }, "__decorateClass$d"), _a6;
5098
+ return kind && result && __defProp$e(target, key, result), result;
5099
+ }, "__decorateClass$e"), _a6;
5025
5100
  let WorksheetProtectionPointModel = (_a6 = class {
5026
5101
  constructor() {
5027
5102
  __publicField(this, "_model", /* @__PURE__ */ new Map());
@@ -5032,13 +5107,13 @@ let WorksheetProtectionPointModel = (_a6 = class {
5032
5107
  this._ensureSubUnitMap(rule.unitId).set(rule.subUnitId, rule), this._pointChange.next(rule);
5033
5108
  }
5034
5109
  deleteRule(unitId, subUnitId) {
5035
- var _a20, _b, _c;
5036
- 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);
5037
5112
  rule && ((_c = (_b = this._model) == null ? void 0 : _b.get(unitId)) == null || _c.delete(subUnitId), this._pointChange.next(rule));
5038
5113
  }
5039
5114
  getRule(unitId, subUnitId) {
5040
- var _a20, _b;
5041
- 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);
5042
5117
  }
5043
5118
  toObject() {
5044
5119
  const result = {};
@@ -5077,14 +5152,14 @@ let WorksheetProtectionPointModel = (_a6 = class {
5077
5152
  return [unitId, subUnitId];
5078
5153
  }
5079
5154
  }, __name(_a6, "WorksheetProtectionPointModel"), _a6);
5080
- WorksheetProtectionPointModel = __decorateClass$d([
5155
+ WorksheetProtectionPointModel = __decorateClass$e([
5081
5156
  OnLifecycle(LifecycleStages.Starting, WorksheetProtectionPointModel)
5082
5157
  ], WorksheetProtectionPointModel);
5083
- var __defProp$c = Object.defineProperty, __getOwnPropDesc$c = Object.getOwnPropertyDescriptor, __decorateClass$c = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5084
- 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--)
5085
5160
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5086
- return kind && result && __defProp$c(target, key, result), result;
5087
- }, "__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");
5088
5163
  const RULE_MODEL_PLUGIN_NAME = "SHEET_WORKSHEET_PROTECTION_PLUGIN", POINT_MODEL_PLUGIN_NAME = "SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN";
5089
5164
  var _a7;
5090
5165
  let WorksheetPermissionService = (_a7 = class extends RxDisposable {
@@ -5220,15 +5295,15 @@ let WorksheetPermissionService = (_a7 = class extends RxDisposable {
5220
5295
  );
5221
5296
  }
5222
5297
  }, __name(_a7, "WorksheetPermissionService"), _a7);
5223
- WorksheetPermissionService = __decorateClass$c([
5298
+ WorksheetPermissionService = __decorateClass$d([
5224
5299
  OnLifecycle(LifecycleStages.Starting, WorksheetPermissionService),
5225
- __decorateParam$c(0, Inject(IPermissionService)),
5226
- __decorateParam$c(1, Inject(IUniverInstanceService)),
5227
- __decorateParam$c(2, Inject(Injector)),
5228
- __decorateParam$c(3, Inject(WorksheetProtectionRuleModel)),
5229
- __decorateParam$c(4, Inject(WorksheetProtectionPointModel)),
5230
- __decorateParam$c(5, Inject(IResourceManagerService)),
5231
- __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))
5232
5307
  ], WorksheetPermissionService);
5233
5308
  const SetWorksheetPermissionPointsMutation = {
5234
5309
  id: "sheet.mutation.set-worksheet-permission-points",
@@ -5410,7 +5485,7 @@ const SetWorksheetPermissionPointsMutation = {
5410
5485
  id: ReorderRangeCommandId,
5411
5486
  type: CommandType.COMMAND,
5412
5487
  handler: /* @__PURE__ */ __name((accessor, params) => {
5413
- var _a20, _b;
5488
+ var _a21, _b;
5414
5489
  const { subUnitId, unitId, range, order } = params, commandService = accessor.get(ICommandService), reorderMutation = {
5415
5490
  id: ReorderRangeMutation.id,
5416
5491
  params: {
@@ -5423,7 +5498,7 @@ const SetWorksheetPermissionPointsMutation = {
5423
5498
  id: ReorderRangeMutation.id,
5424
5499
  params: ReorderRangeUndoMutationFactory(reorderMutation.params)
5425
5500
  }, interceptorCommands = accessor.get(SheetInterceptorService).onCommandExecute({ id: ReorderRangeCommand.id, params }), redos = [
5426
- ...(_a20 = interceptorCommands.preRedos) != null ? _a20 : [],
5501
+ ...(_a21 = interceptorCommands.preRedos) != null ? _a21 : [],
5427
5502
  reorderMutation,
5428
5503
  ...interceptorCommands.redos
5429
5504
  ], undos = [
@@ -5438,15 +5513,15 @@ const SetWorksheetPermissionPointsMutation = {
5438
5513
  }), !0) : !1;
5439
5514
  }, "handler")
5440
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";
5441
- var __defProp$b = Object.defineProperty, __getOwnPropDesc$b = Object.getOwnPropertyDescriptor, __decorateClass$b = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5442
- 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--)
5443
5518
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5444
- return kind && result && __defProp$b(target, key, result), result;
5445
- }, "__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;
5446
5521
  let BasicWorksheetController = (_a8 = class extends Disposable {
5447
5522
  // eslint-disable-next-line max-lines-per-function
5448
5523
  constructor(_commandService, _configService, _dataSyncPrimaryController) {
5449
- var _a20;
5524
+ var _a21;
5450
5525
  super(), this._commandService = _commandService, this._configService = _configService, this._dataSyncPrimaryController = _dataSyncPrimaryController, [
5451
5526
  SetRangeValuesMutation,
5452
5527
  InsertColMutation,
@@ -5468,9 +5543,9 @@ let BasicWorksheetController = (_a8 = class extends Disposable {
5468
5543
  EmptyMutation,
5469
5544
  SetWorksheetColWidthMutation
5470
5545
  ].forEach((mutation) => {
5471
- var _a21;
5472
- this._commandService.registerCommand(mutation), (_a21 = this._dataSyncPrimaryController) == null || _a21.registerSyncingMutations(mutation);
5473
- }), ((_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) || [
5474
5549
  ClearSelectionAllCommand,
5475
5550
  ClearSelectionContentCommand,
5476
5551
  ClearSelectionFormatCommand,
@@ -5561,17 +5636,17 @@ let BasicWorksheetController = (_a8 = class extends Disposable {
5561
5636
  ].forEach((command) => this.disposeWithMe(this._commandService.registerCommand(command))), this._configService.setConfig(MAX_CELL_PER_SHEET_KEY, MAX_CELL_PER_SHEET_DEFAULT);
5562
5637
  }
5563
5638
  }, __name(_a8, "BasicWorksheetController"), _a8);
5564
- BasicWorksheetController = __decorateClass$b([
5639
+ BasicWorksheetController = __decorateClass$c([
5565
5640
  OnLifecycle(LifecycleStages.Starting, BasicWorksheetController),
5566
- __decorateParam$b(0, ICommandService),
5567
- __decorateParam$b(1, IConfigService),
5568
- __decorateParam$b(2, Optional(DataSyncPrimaryController))
5641
+ __decorateParam$c(0, ICommandService),
5642
+ __decorateParam$c(1, IConfigService),
5643
+ __decorateParam$c(2, Optional(DataSyncPrimaryController))
5569
5644
  ], BasicWorksheetController);
5570
- var __defProp$a = Object.defineProperty, __getOwnPropDesc$a = Object.getOwnPropertyDescriptor, __decorateClass$a = /* @__PURE__ */ __name((decorators, target, key, kind) => {
5571
- 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--)
5572
5647
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
5573
- return kind && result && __defProp$a(target, key, result), result;
5574
- }, "__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;
5575
5650
  let CalculateResultApplyController = (_a9 = class extends Disposable {
5576
5651
  constructor(_univerInstanceService, _commandService) {
5577
5652
  super(), this._univerInstanceService = _univerInstanceService, this._commandService = _commandService, this._initialize();
@@ -5623,11 +5698,60 @@ let CalculateResultApplyController = (_a9 = class extends Disposable {
5623
5698
  }), cellDataMatrix.clone();
5624
5699
  }
5625
5700
  }, __name(_a9, "CalculateResultApplyController"), _a9);
5626
- CalculateResultApplyController = __decorateClass$a([
5701
+ CalculateResultApplyController = __decorateClass$b([
5627
5702
  OnLifecycle(LifecycleStages.Ready, CalculateResultApplyController),
5628
- __decorateParam$a(0, Inject(IUniverInstanceService)),
5629
- __decorateParam$a(1, ICommandService)
5703
+ __decorateParam$b(0, Inject(IUniverInstanceService)),
5704
+ __decorateParam$b(1, ICommandService)
5630
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);
5631
5755
  const EffectRefRangId = {
5632
5756
  MoveRangeCommandId,
5633
5757
  InsertRowCommandId,
@@ -5723,9 +5847,9 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5723
5847
  });
5724
5848
  const cacheMatrix = new ObjectMatrix();
5725
5849
  return Range.foreach(range, (row, col) => {
5726
- var _a20;
5850
+ var _a21;
5727
5851
  if (order.hasOwnProperty(row)) {
5728
- 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;
5729
5853
  cacheMatrix.setValue(row, col, cloneCell);
5730
5854
  }
5731
5855
  }), cacheMatrix.forValue((row, col, cellData) => {
@@ -5760,8 +5884,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5760
5884
  matrix.setValue(row, col, 1);
5761
5885
  }), matrix.moveColumns(fromCol, count, toCol), queryObjectMatrix(matrix, (value) => value === 1);
5762
5886
  }, "handleMoveColsCommon"), handleMoveRange = /* @__PURE__ */ __name((param, targetRange) => {
5763
- var _a20, _b;
5764
- 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;
5765
5889
  if (!toRange || !fromRange)
5766
5890
  return [];
5767
5891
  const operators = [];
@@ -5781,8 +5905,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5781
5905
  }
5782
5906
  return operators;
5783
5907
  }, "handleMoveRange"), handleMoveRangeCommon = /* @__PURE__ */ __name((param, targetRange) => {
5784
- var _a20, _b;
5785
- 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;
5786
5910
  if (!toRange || !fromRange)
5787
5911
  return [targetRange];
5788
5912
  if (!Rectangle.intersects(fromRange, targetRange) && !Rectangle.intersects(toRange, targetRange))
@@ -5806,9 +5930,9 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5806
5930
  endRow: toRange.endRow - rowOffset
5807
5931
  };
5808
5932
  return loopToRange && Range.foreach(loopToRange, (row, col) => {
5809
- var _a21;
5933
+ var _a22;
5810
5934
  const targetRow = row + rowOffset, targetCol = col + columnOffset;
5811
- 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);
5812
5936
  }), queryObjectMatrix(matrix, (value) => value === 1);
5813
5937
  }, "handleMoveRangeCommon"), handleBaseRemoveRange = /* @__PURE__ */ __name((_removeRange, _targetRange) => {
5814
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");
@@ -5836,8 +5960,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5836
5960
  }
5837
5961
  return { step: 0, length: 0 };
5838
5962
  }, "handleBaseRemoveRange"), handleIRemoveCol = /* @__PURE__ */ __name((param, targetRange) => {
5839
- var _a20;
5840
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
5963
+ var _a21;
5964
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5841
5965
  if (!range)
5842
5966
  return [];
5843
5967
  const operators = [], result = handleBaseRemoveRange(range, targetRange);
@@ -5853,8 +5977,8 @@ const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER, handleRangeTypeInput = /* @__P
5853
5977
  }
5854
5978
  return operators;
5855
5979
  }, "handleIRemoveCol"), handleIRemoveRow = /* @__PURE__ */ __name((param, targetRange) => {
5856
- var _a20;
5857
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
5980
+ var _a21;
5981
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5858
5982
  if (!range)
5859
5983
  return [];
5860
5984
  const operators = [], result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
@@ -5926,8 +6050,8 @@ function handleBaseMoveRange(fromRange, toRange, targetRange) {
5926
6050
  }
5927
6051
  __name(handleBaseMoveRange, "handleBaseMoveRange");
5928
6052
  const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5929
- var _a20;
5930
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6053
+ var _a21;
6054
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5931
6055
  if (!range)
5932
6056
  return [];
5933
6057
  const operators = [], result = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange)), { step, length } = result;
@@ -5937,8 +6061,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5937
6061
  length
5938
6062
  }), operators;
5939
6063
  }, "handleInsertRow"), handleInsertCol = /* @__PURE__ */ __name((param, targetRange) => {
5940
- var _a20;
5941
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6064
+ var _a21;
6065
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5942
6066
  if (!range)
5943
6067
  return [];
5944
6068
  const operators = [], result = handleBaseInsertRange(range, targetRange), { step, length } = result;
@@ -5948,8 +6072,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5948
6072
  length
5949
6073
  }), operators;
5950
6074
  }, "handleInsertCol"), handleInsertRangeMoveDown = /* @__PURE__ */ __name((param, targetRange) => {
5951
- var _a20;
5952
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6075
+ var _a21;
6076
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5953
6077
  if (!range)
5954
6078
  return [];
5955
6079
  const operators = [], result = handleBaseInsertRange(rotateRange(range), rotateRange(targetRange)), { step, length } = result;
@@ -5959,8 +6083,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5959
6083
  length
5960
6084
  }), operators;
5961
6085
  }, "handleInsertRangeMoveDown"), handleInsertRangeMoveDownCommon = /* @__PURE__ */ __name((param, targetRange) => {
5962
- var _a20;
5963
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6086
+ var _a21;
6087
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5964
6088
  if (!range)
5965
6089
  return [targetRange];
5966
6090
  const moveCount = range.endRow - range.startRow + 1, bottomRange = {
@@ -5979,8 +6103,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5979
6103
  matrix.setValue(row + moveCount, col, 1);
5980
6104
  }), queryObjectMatrix(matrix, (v) => v === 1);
5981
6105
  }, "handleInsertRangeMoveDownCommon"), handleInsertRangeMoveRight = /* @__PURE__ */ __name((param, targetRange) => {
5982
- var _a20;
5983
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6106
+ var _a21;
6107
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5984
6108
  if (!range)
5985
6109
  return [];
5986
6110
  const operators = [], result = handleBaseInsertRange(range, targetRange), { step, length } = result;
@@ -5990,8 +6114,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
5990
6114
  length
5991
6115
  }), operators;
5992
6116
  }, "handleInsertRangeMoveRight"), handleInsertRangeMoveRightCommon = /* @__PURE__ */ __name((param, targetRange) => {
5993
- var _a20;
5994
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6117
+ var _a21;
6118
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
5995
6119
  if (!range)
5996
6120
  return [targetRange];
5997
6121
  const moveCount = range.endColumn - range.startColumn + 1, bottomRange = {
@@ -6010,8 +6134,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6010
6134
  matrix.setValue(row, col + moveCount, 1);
6011
6135
  }), queryObjectMatrix(matrix, (v) => v === 1);
6012
6136
  }, "handleInsertRangeMoveRightCommon"), handleDeleteRangeMoveLeft = /* @__PURE__ */ __name((param, targetRange) => {
6013
- var _a20;
6014
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6137
+ var _a21;
6138
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6015
6139
  if (!range)
6016
6140
  return [];
6017
6141
  const operators = [], result = handleBaseRemoveRange(range, targetRange);
@@ -6027,8 +6151,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6027
6151
  }
6028
6152
  return operators;
6029
6153
  }, "handleDeleteRangeMoveLeft"), handleDeleteRangeMoveLeftCommon = /* @__PURE__ */ __name((param, targetRange) => {
6030
- var _a20;
6031
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6154
+ var _a21;
6155
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6032
6156
  if (!range)
6033
6157
  return [targetRange];
6034
6158
  const rightRange = {
@@ -6050,8 +6174,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6050
6174
  });
6051
6175
  }), queryObjectMatrix(matrix, (v) => v === 1);
6052
6176
  }, "handleDeleteRangeMoveLeftCommon"), handleDeleteRangeMoveUp = /* @__PURE__ */ __name((param, targetRange) => {
6053
- var _a20;
6054
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6177
+ var _a21;
6178
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6055
6179
  if (!range)
6056
6180
  return [];
6057
6181
  const operators = [], result = handleBaseRemoveRange(rotateRange(range), rotateRange(targetRange));
@@ -6067,8 +6191,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6067
6191
  }
6068
6192
  return operators;
6069
6193
  }, "handleDeleteRangeMoveUp"), handleDeleteRangeMoveUpCommon = /* @__PURE__ */ __name((param, targetRange) => {
6070
- var _a20;
6071
- const range = (_a20 = param.params) == null ? void 0 : _a20.range;
6194
+ var _a21;
6195
+ const range = (_a21 = param.params) == null ? void 0 : _a21.range;
6072
6196
  if (!range)
6073
6197
  return [targetRange];
6074
6198
  const bottomRange = {
@@ -6089,8 +6213,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6089
6213
  });
6090
6214
  }), queryObjectMatrix(matrix, (v) => v === 1);
6091
6215
  }, "handleDeleteRangeMoveUpCommon"), handleRemoveRowCommon = /* @__PURE__ */ __name((param, targetRange) => {
6092
- var _a20;
6093
- 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();
6094
6218
  return Range.foreach(targetRange, (row, col) => {
6095
6219
  matrix.setValue(row, col, 1);
6096
6220
  }), ranges.forEach((range) => {
@@ -6210,7 +6334,8 @@ const handleInsertRow = /* @__PURE__ */ __name((param, targetRange) => {
6210
6334
  case EffectRefRangId.RemoveRowCommandId:
6211
6335
  return handleRemoveRowCommon(commandInfo.params, range);
6212
6336
  }
6213
- return runRefRangeMutations(operator, range);
6337
+ const resultRange = runRefRangeMutations(operator, range);
6338
+ return resultRange ? [resultRange] : [];
6214
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");
6215
6340
  function adjustRangeOnMutation(range, mutation) {
6216
6341
  const { id, params } = mutation;
@@ -6264,7 +6389,7 @@ function adjustRangeOnMutation(range, mutation) {
6264
6389
  }
6265
6390
  __name(adjustRangeOnMutation, "adjustRangeOnMutation");
6266
6391
  function getEffectedRangesOnCommand(command, deps) {
6267
- var _a20, _b, _c, _d, _e, _f;
6392
+ var _a21, _b, _c, _d, _e, _f;
6268
6393
  const { selectionManagerService } = deps;
6269
6394
  switch (command.id) {
6270
6395
  case EffectRefRangId.MoveColsCommandId: {
@@ -6319,7 +6444,7 @@ function getEffectedRangesOnCommand(command, deps) {
6319
6444
  return [command.params.range];
6320
6445
  case EffectRefRangId.DeleteRangeMoveUpCommandId:
6321
6446
  case EffectRefRangId.InsertRangeMoveDownCommandId: {
6322
- 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]);
6323
6448
  return range ? [range] : [];
6324
6449
  }
6325
6450
  case EffectRefRangId.DeleteRangeMoveLeftCommandId:
@@ -6406,8 +6531,8 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
6406
6531
  super(), this._unitId = _unitId, this._subUnitId = _subUnitId, this._range = _range, this._callback = _callback, this._skipIntersects = _skipIntersects;
6407
6532
  }
6408
6533
  onMutation(mutation) {
6409
- var _a20, _b;
6410
- 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)
6411
6536
  return;
6412
6537
  if (mutation.id === MoveRangeMutation.id) {
6413
6538
  const params = mutation.params;
@@ -6433,8 +6558,8 @@ const MERGE_REDO = createInterceptorKey("MERGE_REDO"), MERGE_UNDO = createInterc
6433
6558
  };
6434
6559
  __name(_WatchRange, "WatchRange");
6435
6560
  let WatchRange = _WatchRange;
6436
- var _a10;
6437
- let RefRangeService = (_a10 = class extends Disposable {
6561
+ var _a11;
6562
+ let RefRangeService = (_a11 = class extends Disposable {
6438
6563
  constructor(_commandService, _sheetInterceptorService, _univerInstanceService, _selectionManagerService) {
6439
6564
  super();
6440
6565
  __publicField(this, "interceptor", new InterceptorManager({ MERGE_REDO, MERGE_UNDO }));
@@ -6555,8 +6680,8 @@ let RefRangeService = (_a10 = class extends Disposable {
6555
6680
  []
6556
6681
  ).reduce(
6557
6682
  (result2, currentValue) => {
6558
- var _a20, _b;
6559
- 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;
6560
6685
  },
6561
6686
  { redos: [], undos: [], preUndos: [], preRedos: [] }
6562
6687
  ), preRedos = this.interceptor.fetchThroughInterceptors(this.interceptor.getInterceptPoints().MERGE_REDO)(
@@ -6642,7 +6767,7 @@ let RefRangeService = (_a10 = class extends Disposable {
6642
6767
  registerToService.dispose(), teardownWatching.dispose();
6643
6768
  });
6644
6769
  }
6645
- }, __name(_a10, "RefRangeService"), _a10);
6770
+ }, __name(_a11, "RefRangeService"), _a11);
6646
6771
  RefRangeService = __decorateClass$9([
6647
6772
  OnLifecycle(LifecycleStages.Ready, RefRangeService),
6648
6773
  __decorateParam$9(0, ICommandService),
@@ -6655,13 +6780,13 @@ function getUnitId(univerInstanceService) {
6655
6780
  }
6656
6781
  __name(getUnitId, "getUnitId");
6657
6782
  function getSubUnitId(univerInstanceService) {
6658
- var _a20;
6659
- 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();
6660
6785
  }
6661
6786
  __name(getSubUnitId, "getSubUnitId");
6662
6787
  function getSelectionRanges(selectionManagerService) {
6663
- var _a20;
6664
- 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)) || [];
6665
6790
  }
6666
6791
  __name(getSelectionRanges, "getSelectionRanges");
6667
6792
  function getRefRangId(unitId, subUnitId) {
@@ -6730,8 +6855,8 @@ function getAddMergeMutationRangeByType(selection, type) {
6730
6855
  }
6731
6856
  __name(getAddMergeMutationRangeByType, "getAddMergeMutationRangeByType");
6732
6857
  const MERGE_CELL_INTERCEPTOR_CHECK = createInterceptorKey("mergeCellPermissionCheck");
6733
- var _a11;
6734
- let MergeCellController = (_a11 = class extends Disposable {
6858
+ var _a12;
6859
+ let MergeCellController = (_a12 = class extends Disposable {
6735
6860
  constructor(_commandService, _refRangeService, _univerInstanceService, _injector, _sheetInterceptorService, _selectionManagerService) {
6736
6861
  super();
6737
6862
  __publicField(this, "disposableCollection", new DisposableCollection());
@@ -6742,14 +6867,14 @@ let MergeCellController = (_a11 = class extends Disposable {
6742
6867
  const self = this;
6743
6868
  this._sheetInterceptorService.interceptCommand({
6744
6869
  getMutations(commandInfo) {
6745
- var _a20;
6870
+ var _a21;
6746
6871
  switch (commandInfo.id) {
6747
6872
  case ClearSelectionAllCommand.id:
6748
6873
  case ClearSelectionFormatCommand.id: {
6749
- 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();
6750
6875
  if (!worksheet)
6751
6876
  return { redos: [], undos: [] };
6752
- 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);
6753
6878
  if (selections && selections.length > 0 && selections.some(
6754
6879
  (range) => mergeData.some((item) => Rectangle.intersects(item, range))
6755
6880
  )) {
@@ -6846,10 +6971,10 @@ let MergeCellController = (_a11 = class extends Disposable {
6846
6971
  }
6847
6972
  _onRefRangeChange() {
6848
6973
  const registerRefRange = /* @__PURE__ */ __name((unitId, subUnitId) => {
6849
- const workbook2 = this._univerInstanceService.getUniverSheetInstance(unitId);
6850
- if (!workbook2)
6974
+ const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
6975
+ if (!workbook)
6851
6976
  return;
6852
- const workSheet = workbook2 == null ? void 0 : workbook2.getSheetBySheetId(subUnitId);
6977
+ const workSheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
6853
6978
  if (!workSheet)
6854
6979
  return;
6855
6980
  this.disposableCollection.dispose();
@@ -6860,7 +6985,7 @@ let MergeCellController = (_a11 = class extends Disposable {
6860
6985
  }, "registerRefRange");
6861
6986
  this.disposeWithMe(
6862
6987
  this._commandService.onCommandExecuted((commandInfo) => {
6863
- if (commandInfo.id === SetWorksheetActivateCommand.id) {
6988
+ if (commandInfo.id === SetWorksheetActiveOperation.id) {
6864
6989
  const params = commandInfo.params, sheetId = params.subUnitId, unitId = params.unitId;
6865
6990
  if (!sheetId || !unitId)
6866
6991
  return;
@@ -6873,13 +6998,10 @@ let MergeCellController = (_a11 = class extends Disposable {
6873
6998
  registerRefRange(params.unitId, params.subUnitId);
6874
6999
  }
6875
7000
  })
6876
- );
6877
- const workbook = this._univerInstanceService.getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
6878
- if (workbook) {
7001
+ ), this._univerInstanceService.getCurrentTypeOfUnit$(UniverInstanceType.UNIVER_SHEET).pipe(first((workbook) => !!workbook)).subscribe((workbook) => {
6879
7002
  const sheet = workbook.getActiveSheet();
6880
- if (!sheet) return;
6881
- registerRefRange(workbook.getUnitId(), sheet.getSheetId());
6882
- }
7003
+ sheet && registerRefRange(workbook.getUnitId(), sheet.getSheetId());
7004
+ });
6883
7005
  }
6884
7006
  _handleMoveRowsCommand(params, unitId, subUnitId) {
6885
7007
  const workbook = getWorkbook(this._univerInstanceService, unitId);
@@ -7209,19 +7331,23 @@ let MergeCellController = (_a11 = class extends Disposable {
7209
7331
  addMergeParams
7210
7332
  );
7211
7333
  return {
7334
+ preRedos: [
7335
+ { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams }
7336
+ ],
7212
7337
  redos: [
7213
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
7214
7338
  {
7215
7339
  id: AddWorksheetMergeMutation.id,
7216
7340
  params: addMergeParams
7217
7341
  }
7218
7342
  ],
7343
+ preUndos: [
7344
+ { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams }
7345
+ ],
7219
7346
  undos: [
7220
7347
  {
7221
7348
  id: AddWorksheetMergeMutation.id,
7222
7349
  params: undoRemoveMergeParams
7223
- },
7224
- { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams }
7350
+ }
7225
7351
  ]
7226
7352
  };
7227
7353
  }
@@ -7259,26 +7385,28 @@ let MergeCellController = (_a11 = class extends Disposable {
7259
7385
  }, undoAddMergeParams = AddMergeUndoMutationFactory(
7260
7386
  this._injector,
7261
7387
  addMergeParams
7262
- ), redos = [
7388
+ ), preRedos = [
7263
7389
  {
7264
7390
  id: RemoveWorksheetMergeMutation.id,
7265
7391
  params: removeMergeParams
7266
- },
7392
+ }
7393
+ ], redos = [
7267
7394
  {
7268
7395
  id: AddWorksheetMergeMutation.id,
7269
7396
  params: addMergeParams
7270
7397
  }
7398
+ ], preUndos = [
7399
+ {
7400
+ id: RemoveWorksheetMergeMutation.id,
7401
+ params: undoAddMergeParams
7402
+ }
7271
7403
  ], undos = [
7272
7404
  {
7273
7405
  id: AddWorksheetMergeMutation.id,
7274
7406
  params: undoRemoveMergeParams
7275
- },
7276
- {
7277
- id: RemoveWorksheetMergeMutation.id,
7278
- params: undoAddMergeParams
7279
7407
  }
7280
7408
  ];
7281
- return { redos, undos };
7409
+ return { redos, undos, preRedos, preUndos };
7282
7410
  }
7283
7411
  _handleDeleteRangeMoveUpCommand(config, unitId, subUnitId) {
7284
7412
  const workbook = getWorkbook(this._univerInstanceService, unitId);
@@ -7309,26 +7437,28 @@ let MergeCellController = (_a11 = class extends Disposable {
7309
7437
  }, undoAddMergeParams = AddMergeUndoMutationFactory(
7310
7438
  this._injector,
7311
7439
  addMergeParams
7312
- ), redos = [
7440
+ ), preRedos = [
7313
7441
  {
7314
7442
  id: RemoveWorksheetMergeMutation.id,
7315
7443
  params: removeMergeParams
7316
- },
7444
+ }
7445
+ ], redos = [
7317
7446
  {
7318
7447
  id: AddWorksheetMergeMutation.id,
7319
7448
  params: addMergeParams
7320
7449
  }
7450
+ ], preUndos = [
7451
+ {
7452
+ id: RemoveWorksheetMergeMutation.id,
7453
+ params: undoAddMergeParams
7454
+ }
7321
7455
  ], undos = [
7322
7456
  {
7323
7457
  id: AddWorksheetMergeMutation.id,
7324
7458
  params: undoRemoveMergeParams
7325
- },
7326
- {
7327
- id: RemoveWorksheetMergeMutation.id,
7328
- params: undoAddMergeParams
7329
7459
  }
7330
7460
  ];
7331
- return { redos, undos };
7461
+ return { redos, undos, preRedos, preUndos };
7332
7462
  }
7333
7463
  _handleDeleteRangeMoveLeftCommand(config, unitId, subUnitId) {
7334
7464
  const workbook = getWorkbook(this._univerInstanceService, unitId);
@@ -7370,20 +7500,16 @@ let MergeCellController = (_a11 = class extends Disposable {
7370
7500
  unitId,
7371
7501
  subUnitId,
7372
7502
  ranges: removeMergeData
7373
- }, undoRemoveMergeParams = RemoveMergeUndoMutationFactory(
7374
- this._injector,
7375
- removeMergeParams
7376
- ), addMergeParams = {
7503
+ }, undoRemoveMergeParams = RemoveMergeUndoMutationFactory(this._injector, removeMergeParams), addMergeParams = {
7377
7504
  unitId,
7378
7505
  subUnitId,
7379
7506
  ranges: addMergeData
7380
- }, undoAddMergeParams = AddMergeUndoMutationFactory(
7381
- this._injector,
7382
- addMergeParams
7383
- );
7507
+ }, undoAddMergeParams = AddMergeUndoMutationFactory(this._injector, addMergeParams);
7384
7508
  return {
7509
+ preRedos: [
7510
+ { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams }
7511
+ ],
7385
7512
  redos: [
7386
- { id: RemoveWorksheetMergeMutation.id, params: removeMergeParams },
7387
7513
  {
7388
7514
  id: AddWorksheetMergeMutation.id,
7389
7515
  params: addMergeParams
@@ -7393,7 +7519,9 @@ let MergeCellController = (_a11 = class extends Disposable {
7393
7519
  {
7394
7520
  id: AddWorksheetMergeMutation.id,
7395
7521
  params: undoRemoveMergeParams
7396
- },
7522
+ }
7523
+ ],
7524
+ preUndos: [
7397
7525
  { id: RemoveWorksheetMergeMutation.id, params: undoAddMergeParams }
7398
7526
  ]
7399
7527
  };
@@ -7416,7 +7544,7 @@ let MergeCellController = (_a11 = class extends Disposable {
7416
7544
  mergeData.forEach((merge2) => {
7417
7545
  let { startRow, endRow, startColumn, endColumn, rangeType } = merge2;
7418
7546
  Rectangle.intersects(merge2, sourceRange) || (isRowMove ? sourceStart < startRow && targetStart > endRow ? (startRow -= moveLength, endRow -= moveLength) : sourceStart > endRow && targetStart <= startRow && (startRow += moveLength, endRow += moveLength) : sourceStart < startColumn && targetStart > endColumn ? (startColumn -= moveLength, endColumn -= moveLength) : sourceStart > endColumn && targetStart <= startColumn && (startColumn += moveLength, endColumn += moveLength)), merge2.startRow === merge2.endRow && merge2.startColumn === merge2.endColumn || adjustedMergedCells.push({ startRow, endRow, startColumn, endColumn, rangeType });
7419
- }), worksheet.getConfig().mergeData = adjustedMergedCells, this.disposableCollection.dispose();
7547
+ }), worksheet.setMergeData(adjustedMergedCells), this.disposableCollection.dispose();
7420
7548
  const { unitId, subUnitId } = command.params, handler = /* @__PURE__ */ __name((config) => this.refRangeHandle(config, unitId, subUnitId), "handler");
7421
7549
  adjustedMergedCells.forEach((range) => {
7422
7550
  this.disposableCollection.add(this._refRangeService.registerRefRange(range, handler, unitId, subUnitId));
@@ -7433,7 +7561,7 @@ let MergeCellController = (_a11 = class extends Disposable {
7433
7561
  mergeData.forEach((merge2) => {
7434
7562
  let { startRow, endRow, startColumn, endColumn, rangeType } = merge2;
7435
7563
  isAddOperation ? isRowOperation ? operationStart <= startRow && (startRow += operationCount, endRow += operationCount) : operationStart <= startColumn && (startColumn += operationCount, endColumn += operationCount) : isRowOperation ? operationEnd < startRow && (startRow -= operationCount, endRow -= operationCount) : operationEnd < startColumn && (startColumn -= operationCount, endColumn -= operationCount), merge2.startRow === merge2.endRow && merge2.startColumn === merge2.endColumn || adjustedMergedCells.push({ startRow, endRow, startColumn, endColumn, rangeType });
7436
- }), worksheet.getConfig().mergeData = adjustedMergedCells, this.disposableCollection.dispose();
7564
+ }), worksheet.setMergeData(adjustedMergedCells), this.disposableCollection.dispose();
7437
7565
  const { unitId, subUnitId } = command.params, handler = /* @__PURE__ */ __name((config) => this.refRangeHandle(config, unitId, subUnitId), "handler");
7438
7566
  adjustedMergedCells.forEach((range2) => {
7439
7567
  this.disposableCollection.add(this._refRangeService.registerRefRange(range2, handler, unitId, subUnitId));
@@ -7441,9 +7569,8 @@ let MergeCellController = (_a11 = class extends Disposable {
7441
7569
  }
7442
7570
  }));
7443
7571
  }
7444
- }, __name(_a11, "MergeCellController"), _a11);
7572
+ }, __name(_a12, "MergeCellController"), _a12);
7445
7573
  MergeCellController = __decorateClass$8([
7446
- OnLifecycle(LifecycleStages.Steady, MergeCellController),
7447
7574
  __decorateParam$8(0, Inject(ICommandService)),
7448
7575
  __decorateParam$8(1, Inject(RefRangeService)),
7449
7576
  __decorateParam$8(2, Inject(IUniverInstanceService)),
@@ -7463,295 +7590,399 @@ var __defProp$7 = Object.defineProperty, __getOwnPropDesc$7 = Object.getOwnPrope
7463
7590
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$7(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7464
7591
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7465
7592
  return kind && result && __defProp$7(target, key, result), result;
7466
- }, "__decorateClass$7"), __decorateParam$7 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$7"), _a12;
7467
- let NumfmtService = (_a12 = class extends Disposable {
7468
- constructor(_resourceManagerService, _univerInstanceService, _logService) {
7469
- super(), this._resourceManagerService = _resourceManagerService, this._univerInstanceService = _univerInstanceService, this._logService = _logService;
7470
- }
7471
- getValue(unitId, subUnitId, row, col) {
7472
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7473
- if (!workbook)
7474
- return;
7475
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7476
- if (!worksheet)
7477
- return;
7478
- const styles = workbook.getStyles(), cell = worksheet.getCellRaw(row, col);
7479
- if (cell != null && cell.s) {
7480
- const style = styles.get(cell.s);
7481
- if (style != null && style.n)
7482
- return style.n;
7483
- }
7484
- 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();
7485
7597
  }
7486
- deleteValues(unitId, subUnitId, values) {
7487
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7488
- if (!workbook)
7489
- return;
7490
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7491
- if (!worksheet)
7492
- return;
7493
- const styles = workbook.getStyles();
7494
- values.forEach((range) => {
7495
- Range.foreach(range, (row, col) => {
7496
- const cell = worksheet.getCellRaw(row, col);
7497
- if (!cell)
7498
- return;
7499
- const oldStyleId = cell == null ? void 0 : cell.s, newStyle = { ...oldStyleId && styles.get(oldStyleId) || {} };
7500
- delete newStyle.n;
7501
- const newStyleId = styles.setValue(newStyle);
7502
- cell.s = newStyleId;
7503
- });
7504
- });
7598
+ _initialize() {
7599
+ this._initInterceptorCellContent();
7505
7600
  }
7506
- setValues(unitId, subUnitId, values) {
7507
- const workbook = this._univerInstanceService.getUniverSheetInstance(unitId);
7508
- if (!workbook)
7509
- return;
7510
- const worksheet = workbook == null ? void 0 : workbook.getSheetBySheetId(subUnitId);
7511
- if (!worksheet)
7512
- return;
7513
- const styles = workbook.getStyles(), matrix = worksheet.getCellMatrix();
7514
- values.forEach((value) => {
7515
- value.ranges.forEach((range) => {
7516
- Range.foreach(range, (row, col) => {
7517
- const cell = worksheet.getCellRaw(row, col);
7518
- if (cell) {
7519
- const newStyle = { ...styles.getStyleByCell(cell) || {}, n: { pattern: value.pattern } }, styleId = styles.setValue(newStyle);
7520
- cell.s = styleId;
7521
- const type = getCellTypeByPattern(cell, value.pattern);
7522
- cell.v !== void 0 && (cell.t = type, cell.v = getCellValue(type, cell));
7523
- } else {
7524
- const style = { n: { pattern: value.pattern } }, styleId = styles.setValue(style);
7525
- styleId && matrix.setValue(row, col, { s: styleId });
7526
- }
7527
- });
7528
- });
7529
- });
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
+ );
7530
7616
  }
7531
- }, __name(_a12, "NumfmtService"), _a12);
7532
- NumfmtService = __decorateClass$7([
7533
- __decorateParam$7(0, IResourceManagerService),
7534
- __decorateParam$7(1, IUniverInstanceService),
7535
- __decorateParam$7(2, ILogService)
7536
- ], NumfmtService);
7537
- const getAllWorkbookPermissionPoint = /* @__PURE__ */ __name(() => [
7538
- WorkbookEditablePermission,
7539
- WorkbookPrintPermission,
7540
- WorkbookCommentPermission,
7541
- WorkbookViewPermission,
7542
- WorkbookCopyPermission,
7543
- WorkbookExportPermission,
7544
- WorkbookManageCollaboratorPermission,
7545
- WorkbookCreateSheetPermission,
7546
- WorkbookDeleteSheetPermission,
7547
- WorkbookRenameSheetPermission,
7548
- WorkbookHideSheetPermission,
7549
- WorkbookDuplicatePermission,
7550
- WorkbookSharePermission,
7551
- WorkbookMoveSheetPermission,
7552
- WorkbookCopySheetPermission,
7553
- WorkbookViewHistoryPermission,
7554
- WorkbookRecoverHistoryPermission
7555
- ], "getAllWorkbookPermissionPoint"), defaultWorkbookPermissionPoints = [
7556
- P.Edit,
7557
- P.Print,
7558
- P.Comment,
7559
- P.View,
7560
- P.Copy,
7561
- P.Export,
7562
- P.ManageCollaborator,
7563
- P.CreateSheet,
7564
- P.DeleteSheet,
7565
- P.RenameSheet,
7566
- P.HideSheet,
7567
- P.Duplicate,
7568
- P.Share,
7569
- P.MoveSheet,
7570
- P.CopySheet,
7571
- P.RecoverHistory,
7572
- P.ViewHistory
7573
- ];
7617
+ }, __name(_a13, "NumberCellDisplayController"), _a13);
7618
+ NumberCellDisplayController = __decorateClass$7([
7619
+ OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController),
7620
+ __decorateParam$7(0, Inject(SheetInterceptorService))
7621
+ ], NumberCellDisplayController);
7574
7622
  var __defProp$6 = Object.defineProperty, __getOwnPropDesc$6 = Object.getOwnPropertyDescriptor, __decorateClass$6 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7575
7623
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$6(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7576
7624
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7577
7625
  return kind && result && __defProp$6(target, key, result), result;
7578
- }, "__decorateClass$6"), __decorateParam$6 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$6"), _a13;
7579
- let WorkbookPermissionService = (_a13 = class extends Disposable {
7580
- constructor(_permissionService, _univerInstanceService, _rangeProtectionRuleModel) {
7581
- 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();
7582
7634
  }
7583
- _init() {
7584
- const handleWorkbook = /* @__PURE__ */ __name((workbook) => {
7585
- const unitId = workbook.getUnitId();
7586
- getAllWorkbookPermissionPoint().forEach((F) => {
7587
- const instance = new F(unitId);
7588
- this._permissionService.addPermissionPoint(instance);
7589
- });
7590
- }, "handleWorkbook");
7635
+ _initCache() {
7591
7636
  this._univerInstanceService.getAllUnitsForType(UniverInstanceType.UNIVER_SHEET).forEach((workbook) => {
7592
- handleWorkbook(workbook);
7593
- }), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
7594
- handleWorkbook(workbook);
7595
- })), this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(UniverInstanceType.UNIVER_SHEET).subscribe((workbook) => {
7596
- const unitId = workbook.getUnitId();
7597
- workbook.getSheets().forEach((worksheet) => {
7598
- const subUnitId = worksheet.getSheetId();
7599
- this._rangeProtectionRuleModel.getSubunitRuleList(unitId, subUnitId).forEach((rule) => {
7600
- [RangeProtectionPermissionEditPoint, RangeProtectionPermissionViewPoint].forEach((F) => {
7601
- const instance = new F(unitId, subUnitId, rule.permissionId);
7602
- this._permissionService.deletePermissionPoint(instance.id);
7603
- });
7604
- }), [...getAllWorksheetPermissionPoint(), ...getAllWorksheetPermissionPointByPointPanel()].forEach((F) => {
7605
- const instance = new F(unitId, subUnitId);
7606
- 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}`);
7607
7667
  });
7608
- }), getAllWorkbookPermissionPoint().forEach((F) => {
7609
- const instance = new F(unitId);
7610
- 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);
7611
7757
  });
7612
- }));
7758
+ });
7613
7759
  }
7614
- }, __name(_a13, "WorkbookPermissionService"), _a13);
7615
- WorkbookPermissionService = __decorateClass$6([
7616
- OnLifecycle(LifecycleStages.Starting, WorkbookPermissionService),
7617
- __decorateParam$6(0, Inject(IPermissionService)),
7618
- __decorateParam$6(1, Inject(IUniverInstanceService)),
7619
- __decorateParam$6(2, Inject(RangeProtectionRuleModel))
7620
- ], 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");
7621
7770
  var __defProp$5 = Object.defineProperty, __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor, __decorateClass$5 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7622
7771
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$5(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7623
7772
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7624
7773
  return kind && result && __defProp$5(target, key, result), result;
7625
- }, "__decorateClass$5"), __decorateParam$5 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$5");
7626
- const SHEET_DEFINED_NAME_PLUGIN = "SHEET_DEFINED_NAME_PLUGIN";
7627
- var _a14;
7628
- let DefinedNameDataController = (_a14 = class extends Disposable {
7629
- constructor(_definedNamesService, _resourceManagerService) {
7630
- 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();
7631
7779
  }
7632
- _initialize() {
7633
- 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
+ });
7634
7808
  }
7635
- _initSnapshot() {
7636
- const toJson = /* @__PURE__ */ __name((unitId) => {
7637
- const map2 = this._definedNamesService.getDefinedNameMap(unitId);
7638
- return map2 ? JSON.stringify(map2) : "";
7639
- }, "toJson"), parseJson = /* @__PURE__ */ __name((json) => {
7640
- if (!json)
7641
- return {};
7642
- try {
7643
- return JSON.parse(json);
7644
- } catch {
7645
- 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 });
7646
7828
  }
7647
- }, "parseJson");
7648
- this.disposeWithMe(
7649
- this._resourceManagerService.registerPluginResource({
7650
- pluginName: SHEET_DEFINED_NAME_PLUGIN,
7651
- businesses: [UniverInstanceType.UNIVER_SHEET],
7652
- toJson: /* @__PURE__ */ __name((unitId) => toJson(unitId), "toJson"),
7653
- parseJson: /* @__PURE__ */ __name((json) => parseJson(json), "parseJson"),
7654
- onUnLoad: /* @__PURE__ */ __name((unitId) => {
7655
- this._definedNamesService.removeUnitDefinedName(unitId);
7656
- }, "onUnLoad"),
7657
- onLoad: /* @__PURE__ */ __name((unitId, value) => {
7658
- this._definedNamesService.registerDefinedNames(unitId, value);
7659
- }, "onLoad")
7660
- })
7661
- );
7829
+ return this._cache.set(key, result), result;
7662
7830
  }
7663
- }, __name(_a14, "DefinedNameDataController"), _a14);
7664
- DefinedNameDataController = __decorateClass$5([
7665
- OnLifecycle(LifecycleStages.Ready, DefinedNameDataController),
7666
- __decorateParam$5(0, IDefinedNamesService),
7667
- __decorateParam$5(1, IResourceManagerService)
7668
- ], DefinedNameDataController);
7669
- const getAllRangePermissionPoint = /* @__PURE__ */ __name(() => [RangeProtectionPermissionViewPoint, RangeProtectionPermissionEditPoint], "getAllRangePermissionPoint"), getDefaultRangePermission = /* @__PURE__ */ __name((unitId = "unitId", subUnitId = "subUnitId", permissionId = "permissionId") => getAllRangePermissionPoint().reduce((r, F) => {
7670
- const i = new F(unitId, subUnitId, permissionId);
7671
- return r[i.subType] = i.value, r;
7672
- }, {}), "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;
7673
7899
  var __defProp$4 = Object.defineProperty, __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor, __decorateClass$4 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7674
7900
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$4(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7675
7901
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7676
7902
  return kind && result && __defProp$4(target, key, result), result;
7677
- }, "__decorateClass$4"), __decorateParam$4 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$4"), _a15;
7678
- let RangeProtectionRenderModel = (_a15 = class {
7679
- constructor(_selectionProtectionRuleModel, _permissionService) {
7680
- __publicField(this, "_cache", new LRUMap(1e4));
7681
- 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;
7682
7922
  }
7683
- _init() {
7684
- this._permissionService.permissionPointUpdate$.pipe(
7685
- filter((permission) => permission.type === M.SelectRange),
7686
- filter((permission) => getAllRangePermissionPoint().some((F) => permission instanceof F)),
7687
- map$1((permission) => permission)
7688
- ).subscribe((permission) => {
7689
- const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(permission.unitId, permission.subUnitId);
7690
- for (const rule of ruleMap)
7691
- rule.permissionId === permission.permissionId && rule.ranges.forEach((range) => {
7692
- Range.foreach(range, (row, col) => {
7693
- const key = this._createKey(permission.unitId, permission.subUnitId, row, col);
7694
- this._cache.delete(key);
7695
- });
7696
- });
7697
- }), this._selectionProtectionRuleModel.ruleChange$.subscribe((info) => {
7698
- var _a20;
7699
- info.rule.ranges.forEach((range) => {
7700
- Range.foreach(range, (row, col) => {
7701
- const key = this._createKey(info.unitId, info.subUnitId, row, col);
7702
- this._cache.delete(key);
7703
- });
7704
- }), 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) => {
7705
7953
  Range.foreach(range, (row, col) => {
7706
- const key = this._createKey(info.unitId, info.subUnitId, row, col);
7707
- 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
+ }
7708
7964
  });
7709
- }));
7965
+ });
7710
7966
  });
7711
7967
  }
7712
- _createKey(unitId, subUnitId, row, col) {
7713
- return `${unitId}_${subUnitId}_${row}_${col}`;
7714
- }
7715
- getCellInfo(unitId, subUnitId, row, col) {
7716
- const key = this._createKey(unitId, subUnitId, row, col), cacheValue = this._cache.get(key);
7717
- if (cacheValue)
7718
- return cacheValue;
7719
- const ruleMap = this._selectionProtectionRuleModel.getSubunitRuleList(unitId, subUnitId), defaultV = [];
7720
- if (!ruleMap || !ruleMap.length)
7721
- return defaultV;
7722
- const result = [];
7723
- for (const rule of ruleMap)
7724
- if (rule.ranges.some((range) => range.startRow <= row && range.endRow >= row && range.startColumn <= col && range.endColumn >= col)) {
7725
- const permissionMap = getAllRangePermissionPoint().reduce((result2, F) => {
7726
- var _a20;
7727
- const instance = new F(unitId, subUnitId, rule.permissionId), permission = this._permissionService.getPermissionPoint(instance.id);
7728
- return result2[instance.subType] = (_a20 = permission == null ? void 0 : permission.value) != null ? _a20 : instance.value, result2;
7729
- }, {});
7730
- result.push({ ...permissionMap, ruleId: rule.id, ranges: rule.ranges });
7731
- }
7732
- return this._cache.set(key, result), result;
7733
- }
7734
- clear() {
7735
- this._cache.clear();
7736
- }
7737
- }, __name(_a15, "RangeProtectionRenderModel"), _a15);
7738
- RangeProtectionRenderModel = __decorateClass$4([
7739
- OnLifecycle(LifecycleStages.Ready, RangeProtectionRenderModel),
7740
- __decorateParam$4(0, Inject(RangeProtectionRuleModel)),
7741
- __decorateParam$4(1, Inject(IPermissionService))
7742
- ], 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);
7743
7974
  var __defProp$3 = Object.defineProperty, __getOwnPropDesc$3 = Object.getOwnPropertyDescriptor, __decorateClass$3 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7744
7975
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$3(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
7745
7976
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
7746
7977
  return kind && result && __defProp$3(target, key, result), result;
7747
7978
  }, "__decorateClass$3"), __decorateParam$3 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$3");
7748
7979
  const mutationIdByRowCol = [InsertColMutation.id, InsertRowMutation.id, RemoveColMutation.id, RemoveRowMutation.id], mutationIdArrByMove = [MoveRowsMutation.id, MoveColsMutation.id];
7749
- var _a16;
7750
- let RangeProtectionRefRangeService = (_a16 = class extends Disposable {
7751
- constructor(_selectionProtectionRuleModel, _univerInstanceService, _commandService, _refRangeService, _selectionProtectionRenderModel) {
7980
+ var _a17;
7981
+ let RangeProtectionRefRangeService = (_a17 = class extends Disposable {
7982
+ constructor(_selectionProtectionRuleModel, _univerInstanceService, _commandService, _refRangeService, _selectionProtectionRenderModel, _rangeProtectionCache) {
7752
7983
  super();
7753
7984
  __publicField(this, "disposableCollection", new DisposableCollection());
7754
- 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();
7755
7986
  }
7756
7987
  _onRefRangeChange() {
7757
7988
  const registerRefRange = /* @__PURE__ */ __name((unitId, subUnitId) => {
@@ -7942,14 +8173,23 @@ let RangeProtectionRefRangeService = (_a16 = class extends Disposable {
7942
8173
  _checkIsRightRange(range) {
7943
8174
  return range.startRow <= range.endRow && range.startColumn <= range.endColumn;
7944
8175
  }
7945
- }, __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);
7946
8185
  RangeProtectionRefRangeService = __decorateClass$3([
7947
8186
  OnLifecycle(LifecycleStages.Ready, RangeProtectionRefRangeService),
7948
8187
  __decorateParam$3(0, Inject(RangeProtectionRuleModel)),
7949
8188
  __decorateParam$3(1, Inject(IUniverInstanceService)),
7950
8189
  __decorateParam$3(2, ICommandService),
7951
8190
  __decorateParam$3(3, Inject(RefRangeService)),
7952
- __decorateParam$3(4, Inject(RangeProtectionRenderModel))
8191
+ __decorateParam$3(4, Inject(RangeProtectionRenderModel)),
8192
+ __decorateParam$3(5, Inject(RangeProtectionCache))
7953
8193
  ], RangeProtectionRefRangeService);
7954
8194
  var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPropertyDescriptor, __decorateClass$2 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
7955
8195
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$2(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
@@ -7957,10 +8197,10 @@ var __defProp$2 = Object.defineProperty, __getOwnPropDesc$2 = Object.getOwnPrope
7957
8197
  return kind && result && __defProp$2(target, key, result), result;
7958
8198
  }, "__decorateClass$2"), __decorateParam$2 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$2");
7959
8199
  const PLUGIN_NAME$1 = "SHEET_RANGE_PROTECTION_PLUGIN";
7960
- var _a17;
7961
- let RangeProtectionService = (_a17 = class extends Disposable {
7962
- constructor(_selectionProtectionRuleModel, _permissionService, _resourceManagerService) {
7963
- 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();
7964
8204
  }
7965
8205
  _initRuleChange() {
7966
8206
  this.disposeWithMe(
@@ -8034,130 +8274,121 @@ let RangeProtectionService = (_a17 = class extends Disposable {
8034
8274
  });
8035
8275
  }, "onLoad"),
8036
8276
  onUnLoad: /* @__PURE__ */ __name((unitId) => {
8037
- this._selectionProtectionRuleModel.deleteUnitModel(unitId);
8277
+ this._selectionProtectionRuleModel.deleteUnitModel(unitId), this._selectionProtectionCache.deleteUnit(unitId);
8038
8278
  }, "onUnLoad")
8039
8279
  })
8040
8280
  );
8041
8281
  }
8042
- }, __name(_a17, "RangeProtectionService"), _a17);
8282
+ }, __name(_a18, "RangeProtectionService"), _a18);
8043
8283
  RangeProtectionService = __decorateClass$2([
8044
8284
  __decorateParam$2(0, Inject(RangeProtectionRuleModel)),
8045
8285
  __decorateParam$2(1, Inject(IPermissionService)),
8046
- __decorateParam$2(2, Inject(IResourceManagerService))
8286
+ __decorateParam$2(2, Inject(IResourceManagerService)),
8287
+ __decorateParam$2(3, Inject(RangeProtectionCache))
8047
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
+ ];
8048
8326
  var __defProp$1 = Object.defineProperty, __getOwnPropDesc$1 = Object.getOwnPropertyDescriptor, __decorateClass$1 = /* @__PURE__ */ __name((decorators, target, key, kind) => {
8049
8327
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc$1(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
8050
8328
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
8051
8329
  return kind && result && __defProp$1(target, key, result), result;
8052
- }, "__decorateClass$1"), __decorateParam$1 = /* @__PURE__ */ __name((index, decorator) => (target, key) => decorator(target, key, index), "__decorateParam$1"), _a18;
8053
- let NumberCellDisplayController = (_a18 = class extends Disposable {
8054
- constructor(_sheetInterceptorService) {
8055
- super(), this._sheetInterceptorService = _sheetInterceptorService, this._initialize();
8056
- }
8057
- _initialize() {
8058
- this._initInterceptorCellContent();
8059
- }
8060
- _initInterceptorCellContent() {
8061
- this.disposeWithMe(
8062
- this._sheetInterceptorService.intercept(INTERCEPTOR_POINT.CELL_CONTENT, {
8063
- priority: 11,
8064
- handler: /* @__PURE__ */ __name((cell, location, next) => {
8065
- var _a20;
8066
- const style = location.workbook.getStyles().getStyleByCell(cell);
8067
- 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({
8068
- ...cell,
8069
- v: stripErrorMargin(cell.v)
8070
- }) : next({ ...cell });
8071
- }, "handler")
8072
- })
8073
- );
8074
- }
8075
- }, __name(_a18, "NumberCellDisplayController"), _a18);
8076
- NumberCellDisplayController = __decorateClass$1([
8077
- OnLifecycle(LifecycleStages.Ready, NumberCellDisplayController),
8078
- __decorateParam$1(0, Inject(SheetInterceptorService))
8079
- ], NumberCellDisplayController);
8080
- const IExclusiveRangeService = createIdentifier("univer.exclusive-range-service"), _ExclusiveRangeService = class _ExclusiveRangeService extends Disposable {
8081
- constructor() {
8082
- super(...arguments);
8083
- /**
8084
- * Exclusive range data structure is as follows: unitId -> sheetId -> feature -> range
8085
- */
8086
- __publicField(this, "_exclusiveRanges", /* @__PURE__ */ new Map());
8087
- }
8088
- _ensureUnitMap(unitId) {
8089
- return this._exclusiveRanges.has(unitId) || this._exclusiveRanges.set(unitId, /* @__PURE__ */ new Map()), this._exclusiveRanges.get(unitId);
8090
- }
8091
- _ensureSubunitMap(unitId, sheetId) {
8092
- const unitMap = this._ensureUnitMap(unitId);
8093
- return unitMap.has(sheetId) || unitMap.set(sheetId, /* @__PURE__ */ new Map()), unitMap.get(sheetId);
8094
- }
8095
- _ensureFeature(unitId, sheetId, feature) {
8096
- const subunitMap = this._ensureSubunitMap(unitId, sheetId);
8097
- return subunitMap.has(feature) || subunitMap.set(feature, []), subunitMap.get(feature);
8098
- }
8099
- addExclusiveRange(unitId, sheetId, feature, ranges) {
8100
- this._ensureFeature(unitId, sheetId, feature).push(...ranges);
8101
- }
8102
- getExclusiveRanges(unitId, sheetId, feature) {
8103
- var _a20, _b;
8104
- return (_b = (_a20 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a20.get(sheetId)) == null ? void 0 : _b.get(feature);
8105
- }
8106
- clearExclusiveRanges(unitId, sheetId, feature) {
8107
- this._ensureFeature(unitId, sheetId, feature), this._exclusiveRanges.get(unitId).get(sheetId).set(feature, []);
8108
- }
8109
- clearExclusiveRangesByGroupId(unitId, sheetId, feature, groupId) {
8110
- const featureMap = this.getExclusiveRanges(unitId, sheetId, feature);
8111
- if (featureMap) {
8112
- const newFeatureMap = featureMap.filter((item) => item.groupId !== groupId);
8113
- this._exclusiveRanges.get(unitId).get(sheetId).set(feature, newFeatureMap);
8114
- }
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();
8115
8334
  }
8116
- getInterestGroupId(selections) {
8117
- const interestGroupId = [];
8118
- return selections.forEach((selection) => {
8119
- var _a20;
8120
- const range = selection.range, { unitId, sheetId } = range;
8121
- if (!unitId || !sheetId) return;
8122
- const featureMap = (_a20 = this._exclusiveRanges.get(unitId)) == null ? void 0 : _a20.get(sheetId);
8123
- if (featureMap)
8124
- for (const feature of featureMap.keys()) {
8125
- const featureMapRanges = featureMap.get(feature);
8126
- if (featureMapRanges) {
8127
- for (const featureMapRange of featureMapRanges)
8128
- if (Rectangle.intersects(range, featureMapRange.range)) {
8129
- interestGroupId.push(feature);
8130
- break;
8131
- }
8132
- }
8133
- }
8134
- }), 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
+ }));
8135
8365
  }
8136
- };
8137
- __name(_ExclusiveRangeService, "ExclusiveRangeService");
8138
- let ExclusiveRangeService = _ExclusiveRangeService;
8139
- 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);
8140
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) => {
8141
8374
  for (var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target, i = decorators.length - 1, decorator; i >= 0; i--)
8142
8375
  (decorator = decorators[i]) && (result = (kind ? decorator(target, key, result) : decorator(result)) || result);
8143
8376
  return kind && result && __defProp2(target, key, result), result;
8144
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");
8145
8378
  const PLUGIN_NAME = "SHEET_PLUGIN";
8146
- var _a19;
8147
- let UniverSheetsPlugin = (_a19 = class extends Plugin {
8379
+ var _a20;
8380
+ let UniverSheetsPlugin = (_a20 = class extends Plugin {
8148
8381
  constructor(_config = defaultPluginConfig, _injector, _configService) {
8149
8382
  super(), this._config = _config, this._injector = _injector, this._configService = _configService;
8150
8383
  const { ...rest } = this._config;
8151
- this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initConfig(), this._initDependencies(_injector);
8152
- }
8153
- onRendered() {
8384
+ this._configService.setConfig(PLUGIN_CONFIG_KEY, rest), this._initConfig(), this._initDependencies();
8154
8385
  }
8155
8386
  _initConfig() {
8156
- var _a20;
8157
- (_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);
8158
8389
  }
8159
- _initDependencies(sheetInjector) {
8160
- var _a20, _b;
8390
+ _initDependencies() {
8391
+ var _a21, _b;
8161
8392
  const dependencies = [
8162
8393
  // services
8163
8394
  [BorderStyleManagerService],
@@ -8178,6 +8409,7 @@ let UniverSheetsPlugin = (_a19 = class extends Plugin {
8178
8409
  // range protection
8179
8410
  [RangeProtectionRenderModel],
8180
8411
  [RangeProtectionRuleModel],
8412
+ [RangeProtectionCache],
8181
8413
  [RangeProtectionRefRangeService],
8182
8414
  [RangeProtectionService],
8183
8415
  [IExclusiveRangeService, {
@@ -8185,11 +8417,14 @@ let UniverSheetsPlugin = (_a19 = class extends Plugin {
8185
8417
  deps: [SheetsSelectionsService]
8186
8418
  }]
8187
8419
  ];
8188
- (_a20 = this._config) != null && _a20.notExecuteFormula || dependencies.push([CalculateResultApplyController]), mergeOverrideWithDependencies(dependencies, (_b = this._config) == null ? void 0 : _b.override).forEach((d) => {
8189
- 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);
8190
8422
  }), this._injector.get(SheetInterceptorService), this._injector.get(RangeProtectionService), this._injector.get(IExclusiveRangeService);
8191
8423
  }
8192
- }, __name(_a19, "UniverSheetsPlugin"), _a19);
8424
+ onStarting(_injector) {
8425
+ this._injector.get(MergeCellController);
8426
+ }
8427
+ }, __name(_a20, "UniverSheetsPlugin"), _a20);
8193
8428
  __publicField2(UniverSheetsPlugin, "pluginName", PLUGIN_NAME);
8194
8429
  __publicField2(UniverSheetsPlugin, "type", UniverInstanceType.UNIVER_SHEET);
8195
8430
  UniverSheetsPlugin = __decorateClass([
@@ -8352,9 +8587,7 @@ function hasValueFromMatrixWithSpanInfo(cell, matrix) {
8352
8587
  }
8353
8588
  __name(hasValueFromMatrixWithSpanInfo, "hasValueFromMatrixWithSpanInfo");
8354
8589
  function getMatrixWithSpanInfo(worksheet, startRow, startColumn, endRow, endColumn) {
8355
- const matrix = worksheet.getCellMatrix(), mergedCellsInRange = worksheet.getSnapshot().mergeData.filter(
8356
- (rect) => Rectangle.intersects({ startRow, startColumn, endRow, endColumn }, rect)
8357
- ), returnCellMatrix = new ObjectMatrix();
8590
+ const matrix = worksheet.getCellMatrix(), mergedCellsInRange = worksheet.getSpanModel().getMergedCellRange(startRow, startColumn, endRow, endColumn), returnCellMatrix = new ObjectMatrix();
8358
8591
  return matrix.forValue((row, col) => {
8359
8592
  const v = matrix.getValue(row, col);
8360
8593
  v && returnCellMatrix.setValue(row, col, v);
@@ -8608,8 +8841,8 @@ const AddWorksheetMergeCommand = {
8608
8841
  type: CommandType.COMMAND,
8609
8842
  id: "sheet.command.add-worksheet-merge-all",
8610
8843
  handler: /* @__PURE__ */ __name(async (accessor) => {
8611
- var _a20;
8612
- 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);
8613
8846
  if (!(selections != null && selections.length))
8614
8847
  return !1;
8615
8848
  const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
@@ -8627,8 +8860,8 @@ const AddWorksheetMergeCommand = {
8627
8860
  type: CommandType.COMMAND,
8628
8861
  id: "sheet.command.add-worksheet-merge-vertical",
8629
8862
  handler: /* @__PURE__ */ __name(async (accessor) => {
8630
- var _a20;
8631
- 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);
8632
8865
  if (!(selections != null && selections.length))
8633
8866
  return !1;
8634
8867
  const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
@@ -8647,8 +8880,8 @@ const AddWorksheetMergeCommand = {
8647
8880
  type: CommandType.COMMAND,
8648
8881
  id: "sheet.command.add-worksheet-merge-horizontal",
8649
8882
  handler: /* @__PURE__ */ __name(async (accessor) => {
8650
- var _a20;
8651
- 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);
8652
8885
  if (!(selections != null && selections.length))
8653
8886
  return !1;
8654
8887
  const workbook = accessor.get(IUniverInstanceService).getCurrentUnitForType(UniverInstanceType.UNIVER_SHEET);
@@ -8698,12 +8931,12 @@ const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, pa
8698
8931
  type: CommandType.COMMAND,
8699
8932
  id: "sheet.command.set-hide-gridlines",
8700
8933
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
8701
- var _a20;
8934
+ var _a21;
8702
8935
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), univerInstanceService = accessor.get(IUniverInstanceService), target = getSheetCommandTarget(univerInstanceService);
8703
8936
  if (!target) return !1;
8704
8937
  const { unitId, subUnitId } = target;
8705
8938
  let hideGridlines = BooleanNumber.FALSE;
8706
- params && (hideGridlines = (_a20 = params.hideGridlines) != null ? _a20 : BooleanNumber.FALSE);
8939
+ params && (hideGridlines = (_a21 = params.hideGridlines) != null ? _a21 : BooleanNumber.FALSE);
8707
8940
  const workbook = univerInstanceService.getUniverSheetInstance(unitId);
8708
8941
  if (!workbook || !workbook.getSheetBySheetId(subUnitId)) return !1;
8709
8942
  const setHideGridlinesMutationParams = {
@@ -8738,12 +8971,12 @@ const SetHideGridlinesUndoMutationFactory = /* @__PURE__ */ __name((accessor, pa
8738
8971
  type: CommandType.COMMAND,
8739
8972
  id: "sheet.command.set-worksheet-right-to-left",
8740
8973
  handler: /* @__PURE__ */ __name(async (accessor, params) => {
8741
- var _a20;
8974
+ var _a21;
8742
8975
  const commandService = accessor.get(ICommandService), undoRedoService = accessor.get(IUndoRedoService), target = getSheetCommandTarget(accessor.get(IUniverInstanceService), params);
8743
8976
  if (!target) return !1;
8744
8977
  const { unitId, subUnitId } = target;
8745
8978
  let rightToLeft = BooleanNumber.FALSE;
8746
- params && (rightToLeft = (_a20 = params.rightToLeft) != null ? _a20 : BooleanNumber.FALSE);
8979
+ params && (rightToLeft = (_a21 = params.rightToLeft) != null ? _a21 : BooleanNumber.FALSE);
8747
8980
  const setWorksheetRightToLeftMutationParams = {
8748
8981
  rightToLeft,
8749
8982
  unitId,
@@ -8833,6 +9066,7 @@ export {
8833
9066
  NumfmtService,
8834
9067
  OperatorType,
8835
9068
  RangeMergeUtil,
9069
+ RangeProtectionCache,
8836
9070
  RangeProtectionPermissionEditPoint,
8837
9071
  RangeProtectionPermissionViewPoint,
8838
9072
  RangeProtectionRefRangeService,
@@ -8934,6 +9168,7 @@ export {
8934
9168
  SetWorksheetShowCommand,
8935
9169
  SheetInterceptorService,
8936
9170
  SheetsSelectionsService,
9171
+ P as UnitAction,
8937
9172
  M as UnitObject,
8938
9173
  UniverSheetsPlugin,
8939
9174
  WorkbookCommentPermission,