@univerjs/sheets-data-validation-ui 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +14 -14
package/lib/cjs/index.js
CHANGED
|
@@ -991,7 +991,7 @@ const menuSchema = {
|
|
|
991
991
|
//#endregion
|
|
992
992
|
//#region package.json
|
|
993
993
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
994
|
-
var version = "1.0.0-beta.
|
|
994
|
+
var version = "1.0.0-beta.2";
|
|
995
995
|
|
|
996
996
|
//#endregion
|
|
997
997
|
//#region src/views/components/DataValidationOptions.tsx
|
package/lib/es/index.js
CHANGED
|
@@ -990,7 +990,7 @@ const menuSchema = {
|
|
|
990
990
|
//#endregion
|
|
991
991
|
//#region package.json
|
|
992
992
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
993
|
-
var version = "1.0.0-beta.
|
|
993
|
+
var version = "1.0.0-beta.2";
|
|
994
994
|
|
|
995
995
|
//#endregion
|
|
996
996
|
//#region src/views/components/DataValidationOptions.tsx
|
package/lib/index.js
CHANGED
|
@@ -990,7 +990,7 @@ const menuSchema = {
|
|
|
990
990
|
//#endregion
|
|
991
991
|
//#region package.json
|
|
992
992
|
var name = "@univerjs/sheets-data-validation-ui";
|
|
993
|
-
var version = "1.0.0-beta.
|
|
993
|
+
var version = "1.0.0-beta.2";
|
|
994
994
|
|
|
995
995
|
//#endregion
|
|
996
996
|
//#region src/views/components/DataValidationOptions.tsx
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-data-validation`,`@univerjs/data-validation`,`rxjs`,`@univerjs/engine-render`,`@univerjs/sheets-numfmt`,`@univerjs/sheets-ui`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationUi={},e.UniverUi,e.UniverCore,e.UniverSheets,e.UniverSheetsDataValidation,e.UniverDataValidation,e.rxjs,e.UniverEngineRender,e.UniverSheetsNumfmt,e.UniverSheetsUi,e.UniverDesign,e.React,e.React,e.UniverEngineFormula,e.UniverSheetsFormulaUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends n.Disposable{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,t){super(),this._univerInstanceService=e,this._sidebarService=t,v(this,`_open$`,new o.BehaviorSubject(!1)),v(this,`open$`,this._open$.pipe((0,o.distinctUntilChanged)())),v(this,`_activeRule`,void 0),v(this,`_activeRule$`,new o.BehaviorSubject(void 0)),v(this,`activeRule$`,this._activeRule$.asObservable()),v(this,`_closeDisposable`,null),v(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET).pipe((0,o.filter)(e=>!e)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===`DataValidationPanel`&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=(0,n.toDisposable)(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};x=b([y(0,n.IUniverInstanceService),y(1,t.ISidebarService)],x);let S=`sheets-data-validation-ui.config`,C={},w=`gray.100`,T=`gray.600`,E=class extends n.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=i,this._sheetsDataValidationValidatorService=a,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.VALIDATE_CELL,{handler:async(e,t,r)=>{let i=await e,{row:a,col:o,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,a,o),f=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(i===!1)return r(Promise.resolve(!1));if(!f||f.errorStyle!==n.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));let p=this._dataValidatorRegistryService.getValidatorItem(f.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,c,a,o)===n.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:p.getRuleFinalError(f,{row:a,col:o,unitId:s,subUnitId:c})},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}}),r(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:e},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};E=b([y(0,(0,n.Inject)(r.SheetInterceptorService)),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(a.DataValidatorRegistryService)),y(3,t.IDialogService),y(4,(0,n.Inject)(n.LocaleService)),y(5,(0,n.Inject)(i.SheetsDataValidationValidatorService))],E);let D=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return(0,n.dateKit)();if(typeof e==`number`||!Number.isNaN(+e))return(0,n.dateKit)(n.numfmt.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let t=(0,n.dateKit)(e);if(t.isValid())return t};function O(e,t){if(e===(0,c.getPatternType)(t))return t;switch(e){case`datetime`:return`yyyy-MM-dd hh:mm:ss`;case`date`:return`yyyy-MM-dd`;case`time`:return`HH:mm:ss`}}let k=class extends n.Disposable{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,s,c,l,u){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._dataValidationModel=n,this._sheetsSelectionsService=r,this._cellDropdownManagerService=i,this._sheetDataValidationModel=a,this._commandService=s,this._editorBridgeService=c,this._injector=l,this._configService=u,v(this,`_activeDropdown`,void 0),v(this,`_activeDropdown$`,new o.Subject),v(this,`_currentPopup`,null),v(this,`activeDropdown$`,this._activeDropdown$.asObservable()),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}_getDropdownByCell(e,t,r,i){let a=e?this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=t?a.getSheetBySheetId(t):a.getActiveSheet();if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),r,i);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);return c==null?void 0:c.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(e=>!(e.primary&&this._getDropdownByCell(e.primary.unitId,e.primary.sheetId,e.primary.actualRow,e.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e){let{location:o}=e,{row:c,col:u,unitId:d,subUnitId:f,workbook:p,worksheet:m}=o;this._currentPopup&&this._currentPopup.dispose(),this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);let h=this._sheetDataValidationModel.getRuleByLocation(d,f,c,u);if(!h)return;let g=this._dataValidatorRegistryService.getValidatorItem(h.type);if(!(g!=null&&g.dropdownType))return;let _,v=async(e,i)=>{var a,o;if(!e)return!0;let _=e,v=m.getCell(c,u),y=_.format(i===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),b=(a=n.numfmt.parseDate(y))==null?void 0:a.v,x=i===`time`?b%1:b,S=p.getStyles().getStyleByCell(v),C=(S==null||(o=S.n)==null?void 0:o.pattern)??``;return h.errorStyle!==n.DataValidationErrorStyle.STOP||await g.validator({value:x,unitId:d,subUnitId:f,row:c,column:u,worksheet:m,workbook:p,interceptValue:y.replace(`Z`,``).replace(`T`,` `),t:n.CellValueType.NUMBER},h)?(await this._commandService.executeCommand(r.SetRangeValuesCommand.id,{unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:O(i,C)}}}}),await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0):(this._injector.has(E)&&this._injector.get(E).showReject(g.getRuleFinalError(h,{row:c,col:u,unitId:d,subUnitId:f})),!1)},y;switch(g.dropdownType){case a.DataValidatorDropdownType.DATE:{var b;let e=(0,i.getCellValueOrigin)(m.getCellRaw(c,u)),t=D(e),n=!!((b=h.bizInfo)!=null&&b.showTime);y={location:o,type:`datepicker`,props:{showTime:n,onChange:e=>v(e,n?`datetime`:`date`),defaultValue:t,patternType:`date`}};break}case a.DataValidatorDropdownType.TIME:{let e=(0,i.getCellValueOrigin)(m.getCellRaw(c,u));y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`time`),defaultValue:D(e),patternType:`time`}};break}case a.DataValidatorDropdownType.DATETIME:{let e=(0,i.getCellValueOrigin)(m.getCellRaw(c,u));y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`datetime`),defaultValue:D(e),patternType:`datetime`}};break}case a.DataValidatorDropdownType.LIST:case a.DataValidatorDropdownType.MULTIPLE_LIST:{var x,S;let e=g.dropdownType===a.DataValidatorDropdownType.MULTIPLE_LIST,p=async n=>{let i=e?(0,r.serializeListOptions)(n):n[0]??``,a={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:i,p:null,f:null,si:null}};return this._commandService.executeCommand(r.SetRangeValuesCommand.id,a),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!e},v=(h==null?void 0:h.renderMode)===n.DataValidationRenderMode.CUSTOM||(h==null?void 0:h.renderMode)===void 0,b=g.getListWithColor(h,d,f),C=(0,i.getDataValidationCellValue)(m.getCellRaw(c,u));y={location:o,type:`list`,props:{onChange:e=>p(e),options:b.map(e=>({label:e.label,value:e.label,color:v||e.color?e.color||`gray.100`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(j.id,{ruleId:h.uid}),_==null||_.dispose()},defaultValue:C,multiple:e,showEdit:((x=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:x.showEditOnDropdown)??!0,showSearch:((S=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:S.showSearchOnDropdown)??!0}};break}case a.DataValidatorDropdownType.CASCADE:y={type:`cascader`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u)).split(`/`),options:JSON.parse(h.formula1??`[]`)},location:o};break;case a.DataValidatorDropdownType.COLOR:y={type:`color`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u))},location:o};break;default:throw Error(`[DataValidationDropdownManagerService]: unknown type!`)}if(_=this._cellDropdownManagerService.showDropdown({...y,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!_)throw Error(`[DataValidationDropdownManagerService]: cannot show dropdown!`);let C=new n.DisposableCollection;C.add(_),C.add({dispose:()=>{var e,t;(e=this._activeDropdown)==null||(t=e.onHide)==null||t.call(e)}}),this._currentPopup=C}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,t,r,i,a){let o=this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=o.getSheetBySheetId(t);if(!s)return;let c=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),r,i);if(!c)return;let l=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!l||!l.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:o,worksheet:s,row:r,col:i,unitId:e,subUnitId:t},onHide:a})}};k=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(a.DataValidatorRegistryService)),y(2,(0,n.Inject)(i.SheetDataValidationModel)),y(3,(0,n.Inject)(r.SheetsSelectionsService)),y(4,(0,n.Inject)(l.ISheetCellDropdownManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,n.ICommandService),y(7,l.IEditorBridgeService),y(8,(0,n.Inject)(n.Injector)),y(9,n.IConfigService)],k);let A=`DataValidationPanel`,j={id:`data-validation.operation.open-validation-panel`,type:n.CommandType.OPERATION,handler(e,i){if(!i)return!1;let{ruleId:o,isAdd:s}=i,c=e.get(x),l=e.get(a.DataValidationModel),u=e.get(n.IUniverInstanceService),d=e.get(t.ISidebarService),f=(0,r.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=o?l.getRuleById(p,m,o):void 0;c.open(),c.setActiveRule(h&&{unitId:p,subUnitId:m,rule:h});let g=d.open({id:A,header:{title:s?`sheets-data-validation-ui.panel.addTitle`:`sheets-data-validation-ui.panel.title`},children:{label:A},width:312,onClose:()=>c.close()});return c.setCloseDisposable(g),!0}},M={id:`data-validation.operation.close-validation-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).close(),!0}},N={id:`data-validation.operation.toggle-validation-panel`,type:n.CommandType.OPERATION,handler(e){let t=e.get(n.ICommandService),r=e.get(x);return r.open(),r.isOpen?t.executeCommand(M.id):t.executeCommand(j.id),!0}},P={type:n.CommandType.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(k),{unitId:r,subUnitId:i,row:a,column:o}=t,s=n.activeDropdown,c=s==null?void 0:s.location;return c&&c.unitId===r&&c.subUnitId===i&&c.row===a&&c.col===o||n.showDataValidationDropdown(r,i,a,o),!0}},F={type:n.CommandType.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(k).hideDropdown(),!0):!1}};function I(e,t){let n=(0,i.createDefaultNewRule)(e);return{...n,...t,uid:n.uid,ranges:n.ranges}}let L={type:n.CommandType.COMMAND,id:`data-validation.command.insert-quick-rule`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),o=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);if(!a||!o.length||!(t!=null&&t.rule))return!1;let s=I(e,t.rule);return e.get(n.ICommandService).syncExecuteCommand(i.AddSheetDataValidationCommand.id,{unitId:a.workbook.getUnitId(),subUnitId:a.worksheet.getSheetId(),rule:s})}},R={type:n.CommandType.COMMAND,id:`data-validation.command.clear-quick-rule`,handler(e,t){var a;let o=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),s=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);return!o||!s.length||!(t!=null&&(a=t.types)!=null&&a.length)?!1:e.get(n.ICommandService).syncExecuteCommand(i.ClearRangeDataValidationCommand.id,{unitId:o.workbook.getUnitId(),subUnitId:o.worksheet.getSheetId(),ranges:s,types:t.types})}},z={type:n.CommandType.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService));if(!a)return!1;let{workbook:o,worksheet:s}=a;if(!e.get(r.SheetsSelectionsService).getCurrentSelections().length)return!1;let c=I(e,t==null?void 0:t.rule),l=e.get(n.ICommandService),u={rule:c,unitId:o.getUnitId(),subUnitId:s.getSheetId()};return l.syncExecuteCommand(i.AddSheetDataValidationCommand.id,u)?(l.syncExecuteCommand(j.id,{ruleId:c.uid,isAdd:!0}),!0):!1}},B=`SHEETS_DATA_VALIDATION_DROPDOWN_PRESETS`;function ee({onChange:e}){let i=(0,t.useDependency)(n.LocaleService),a=[[i.t(`sheets-data-validation-ui.ribbon.presets.yes`),i.t(`sheets-data-validation-ui.ribbon.presets.no`)],[i.t(`sheets-data-validation-ui.ribbon.presets.notStarted`),i.t(`sheets-data-validation-ui.ribbon.presets.inProgress`),i.t(`sheets-data-validation-ui.ribbon.presets.completed`)],[`A`,`B`,`C`]];return(0,f.jsxs)(`div`,{className:`univer-box-border univer-w-[360px]`,children:[(0,f.jsx)(`div`,{className:`univer-px-2 univer-text-sm univer-font-semibold`,children:i.t(`sheets-data-validation-ui.ribbon.dropdownPresetTitle`)}),(0,f.jsx)(`div`,{className:`univer-mt-2 univer-grid univer-grid-cols-3 univer-gap-1.5`,children:a.map(t=>(0,f.jsx)(`button`,{type:`button`,"aria-label":t.join(` / `),className:`univer-flex univer-min-h-20 univer-cursor-pointer univer-flex-col univer-items-start univer-gap-1.5 univer-rounded-md univer-border-0 univer-bg-gray-50 univer-p-3 univer-text-left univer-text-sm univer-leading-5 univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-800 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700`,onClick:()=>e((0,r.serializeListOptions)(t)),children:t.map(e=>(0,f.jsx)(`span`,{className:`univer-w-full univer-break-words`,children:e},e))},t.join(`\0`)))}),(0,f.jsx)(u.Separator,{className:`univer-mt-2`})]})}let V=`sheet.menu.data-validation`,H=`sheet.menu.quick-dropdown`,U=`sheet.menu.quick-date`,te={type:n.DataValidationType.CHECKBOX,operator:void 0,formula1:void 0,formula2:void 0},W={type:n.DataValidationType.DATE,operator:void 0,formula1:void 0,formula2:void 0},ne={...W,bizInfo:{showTime:!0}};function re(e){return{type:n.DataValidationType.LIST,operator:void 0,formula1:e,formula2:``,renderMode:n.DataValidationRenderMode.CUSTOM}}function ie(e){return e===void 0?{}:{rule:re(String(e))}}function ae(e){return{hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function oe(e){return{id:V,type:t.MenuItemType.SUBITEMS,icon:`DataValidationIcon`,tooltip:`sheets-data-validation-ui.title`,hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function se(e){return{id:L.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`CheckboxIcon`,tooltip:`sheets-data-validation-ui.checkbox.title`,params:{rule:te},selectionsCommandId:L.id,selections:[{label:`sheets-data-validation-ui.ribbon.setCheckbox`,value:n.DataValidationType.CHECKBOX,params:{rule:te}},{label:`sheets-data-validation-ui.ribbon.clearCheckbox`,id:R.id,value:n.DataValidationType.CHECKBOX,params:{types:[n.DataValidationType.CHECKBOX]}}],...ae(e)}}function G(e){let i=e.get(n.LocaleService),a=(0,r.serializeListOptions)([i.t(`sheets-data-validation-ui.ribbon.presets.option1`),i.t(`sheets-data-validation-ui.ribbon.presets.option2`)]);return{id:H,type:t.MenuItemType.SUBITEMS,icon:`DropdownListIcon`,tooltip:`sheets-data-validation-ui.list.title`,selectionsCommandId:L.id,selections:[{label:{name:B,hoverable:!1,selectable:!1},params:ie},{id:z.id,label:`sheets-data-validation-ui.ribbon.editDropdown`,value:a,params:{rule:re(a)}},{id:R.id,label:`sheets-data-validation-ui.ribbon.clearDropdown`,value:n.DataValidationType.LIST,params:{types:[n.DataValidationType.LIST,n.DataValidationType.LIST_MULTIPLE]}}],...ae(e)}}function ce(e){return{id:U,commandId:L.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`DatePickerIcon`,tooltip:`sheets-data-validation-ui.date.title`,params:{rule:W},selectionsCommandId:L.id,selections:[{label:`sheets-data-validation-ui.date.title`,value:n.DataValidationType.DATE,params:{rule:W}},{label:`sheets-data-validation-ui.ribbon.dateTime`,value:n.DataValidationType.DATE,params:{rule:ne}},{id:z.id,label:`sheets-data-validation-ui.list.edit`,value:n.DataValidationType.DATE,params:{rule:W}},{id:R.id,label:`sheets-data-validation-ui.panel.removeRule`,value:n.DataValidationType.DATE,params:{types:[n.DataValidationType.DATE]}}],...ae(e)}}function le(){return{id:j.id,title:`sheets-data-validation-ui.panel.title`,type:t.MenuItemType.BUTTON}}function ue(){return{id:z.id,title:`sheets-data-validation-ui.panel.add`,type:t.MenuItemType.BUTTON}}let de={[t.RibbonInsertGroup.CELL]:{[L.id]:{order:0,menuItemFactory:se},[H]:{order:1,menuItemFactory:G},[U]:{order:2,menuItemFactory:ce}},[t.RibbonDataGroup.RULES]:{[V]:{order:0,gridLayout:{row:1,column:1,showLabel:!0},menuItemFactory:oe,[j.id]:{order:0,menuItemFactory:le},[z.id]:{order:1,menuItemFactory:ue}}}};var fe=`@univerjs/sheets-data-validation-ui`,pe=`1.0.0-beta.1`;function K({ref:e,...t}){let{icon:n,id:r,className:i,extend:a,...o}=t,s=`univerjs-icon univerjs-icon-${r} ${i||``}`.trim(),c=(0,d.useRef)(`_${_e()}`);return me(n,`${r}`,{defIds:n.defIds,idSuffix:c.current},{ref:e,className:s,...o},a)}function me(e,t,n,r,i){return(0,d.createElement)(e.tag,{key:t,...he(e,n,i),...r},(ge(e,n).children||[]).map((r,a)=>me(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function he(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function ge(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function _e(){return Math.random().toString(36).substring(2,8)}K.displayName=`UniverIcon`;let ve={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:13,x:1.5,y:1.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 8L6.8 10.3L11.5 5.6`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},ye=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`checkbox-icon`,ref:t,icon:ve}))});ye.displayName=`CheckboxIcon`;let be={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},xe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`data-validation-icon`,ref:t,icon:be}))});xe.displayName=`DataValidationIcon`;let Se={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:12,x:1.5,y:2.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.5 6.5H14.5M5 1.5V4M11 1.5V4`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 9H6M8 9H9.5M11.5 9H12M4.5 12H6M8 12H9.5`,strokeLinecap:`round`,strokeWidth:1.2}}]},Ce=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`date-picker-icon`,ref:t,icon:Se}))});Ce.displayName=`DatePickerIcon`;let we={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Te=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`delete-icon`,ref:t,icon:we}))});Te.displayName=`DeleteIcon`;let Ee={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 5.5H2C1.72386 5.5 1.5 5.27614 1.5 5V2C1.5 1.72386 1.72386 1.5 2 1.5H14C14.2761 1.5 14.5 1.72386 14.5 2V5C14.5 5.27614 14.2761 5.5 14 5.5H13`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.5 3.5L10.5 5.5L12.5 3.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2 7.5H14C14.2761 7.5 14.5 7.72386 14.5 8V14C14.5 14.2761 14.2761 14.5 14 14.5H2C1.72386 14.5 1.5 14.2761 1.5 14V8C1.5 7.72386 1.72386 7.5 2 7.5Z`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.5 9.5H9.5M3.5 12.5H7.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},De=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`dropdown-list-icon`,ref:t,icon:Ee}))});De.displayName=`DropdownListIcon`;let Oe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:7,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:15,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:15,r:1.1,fill:`currentColor`}}]},ke=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`grip-vertical-icon`,ref:t,icon:Oe}))});ke.displayName=`GripVerticalIcon`;let Ae={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z`}}]},je=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`increase-icon`,ref:t,icon:Ae}))});je.displayName=`IncreaseIcon`;let Me={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Ne=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:Me}))});Ne.displayName=`MoreDownIcon`;let Pe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Fe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(K,Object.assign({},e,{id:`more-up-icon`,ref:t,icon:Pe}))});Fe.displayName=`MoreUpIcon`;function Ie(e){let r=(0,t.useDependency)(n.LocaleService),i=(0,t.useDependency)(t.ComponentManager),{value:a,onChange:o,extraComponent:s}=e,[c,l]=(0,d.useState)(!1),p=s?i.get(s):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{className:`univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0`,onClick:()=>l(!c),children:[r.t(`sheets-data-validation-ui.panel.options`),c?(0,f.jsx)(Fe,{className:`univer-ml-1`}):(0,f.jsx)(Ne,{className:`univer-ml-1`})]}),c&&(0,f.jsxs)(f.Fragment,{children:[p?(0,f.jsx)(p,{value:a,onChange:o}):null,(0,f.jsx)(u.FormLayout,{label:r.t(`sheets-data-validation-ui.panel.invalid`),children:(0,f.jsxs)(u.RadioGroup,{value:`${a.errorStyle??n.DataValidationErrorStyle.WARNING}`,onChange:e=>o({...a,errorStyle:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.WARNING}`,children:r.t(`sheets-data-validation-ui.panel.showWarning`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.STOP}`,children:r.t(`sheets-data-validation-ui.panel.rejectInput`)})]})}),(0,f.jsx)(u.FormLayout,{label:r.t(`sheets-data-validation-ui.panel.messageInfo`),children:(0,f.jsx)(u.Checkbox,{checked:a.showErrorMessage,onChange:()=>o({...a,showErrorMessage:!a.showErrorMessage}),children:r.t(`sheets-data-validation-ui.panel.showInfo`)})}),a.showErrorMessage?(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Input,{value:a.error,onChange:e=>o({...a,error:e})})}):null]})]})}let Le=e=>(0,n.debounce)(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function Re(e,t,r){var i;if(t){var a;return((a=e.getUnit(t))==null||(a=a.getSheetBySheetName(r))==null?void 0:a.getSheetId())||``}return((i=e.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetName(r))==null?void 0:i.getSheetId())||``}function ze(){let e=(0,t.useDependency)(x),{unitId:n,subUnitId:r,rule:i}=(0,t.useObservable)(e.activeRule$,e.activeRule)||{};return!n||!r||!i?null:(0,f.jsx)(Be,{activeRuleInfo:{unitId:n,subUnitId:r,rule:i}})}function Be(e){var s;let[c,l]=(0,d.useState)(0),h=(0,t.useDependency)(x),{unitId:g,subUnitId:_,rule:v}=e.activeRuleInfo,y=v.uid,b=(0,t.useDependency)(a.DataValidatorRegistryService),S=(0,t.useDependency)(n.IUniverInstanceService),C=(0,t.useDependency)(t.ComponentManager),w=(0,t.useDependency)(n.ICommandService),T=(0,t.useDependency)(a.DataValidationModel),E=(0,t.useDependency)(n.LocaleService),D=(0,t.useObservable)(()=>S.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),O=(0,t.useObservable)(()=>(D==null?void 0:D.activeSheet$)??(0,o.of)(null),void 0,void 0,[]),[k,A]=(0,d.useState)(v),j=b.getValidatorItem(k.type),[M,N]=(0,d.useState)(!1),P=b.getValidatorsByScope(a.DataValidatorRegistryScope.SHEET),[F,I]=(0,d.useState)(()=>k.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),L=(0,d.useMemo)(()=>Le(w),[w]),[R,z]=(0,d.useState)(!1),[B,ee]=(0,d.useState)(!1),V=(0,d.useRef)(null),H=(0,t.useDependency)(r.SheetsSelectionsService);(0,d.useEffect)(()=>()=>{let e=H.getCurrentLastSelection();e&&H.setSelections([e])},[H]),(0,d.useEffect)(()=>{let e,t=w.onCommandExecuted(t=>{(t.id===n.UndoCommand.id||t.id===n.RedoCommand.id)&&(e!==void 0&&clearTimeout(e),e=setTimeout(()=>{let e=T.getRuleById(g,_,y);l(e=>e+1),e&&(A(e),I(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20))});return()=>{t.dispose(),e!==void 0&&clearTimeout(e)}},[w,T,y,_,g]);let U=(0,t.useEvent)(e=>{let t=e.split(`,`).filter(Boolean).map(p.deserializeRangeWithSheet).map(e=>{let t=e.sheetName;if(t){let n=Re(S,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if((0,n.isUnitRangesEqual)(t,F))return;I(t);let r=t.filter(e=>(!e.unitId||e.unitId===g)&&(!e.sheetId||e.sheetId===_)).map(e=>e.range);if(A({...k,ranges:r}),r.length===0)return;let a={unitId:g,subUnitId:_,ruleId:y,ranges:r};L(i.UpdateSheetDataValidationRangeCommand.id,a)}),te=(0,d.useMemo)(()=>F.map(e=>(0,p.serializeRange)(e.range)).join(`,`),[]);if(!j)return null;let W=j.operators,ne=j.operatorNames,re=k.operator?a.TWO_FORMULA_OPERATOR_COUNT.includes(k.operator):!1,ie=()=>{(O==null?void 0:O.getSheetId())!==_&&w.syncExecuteCommand(r.SetWorksheetActiveOperation.id,{unitId:g,subUnitId:_})},ae=()=>{var e;if((e=V.current)!=null&&(e=e.editor)!=null&&e.isFocus()){var t;U((t=V.current)==null?void 0:t.getValue())}!k.ranges.length||R||(j.validatorFormula(k,g,_).success?h.setActiveRule(null):N(!0),ie())},oe=e=>{if((0,n.shallowEqual)(e,(0,a.getRuleSetting)(k)))return;A({...k,...e});let t={unitId:g,subUnitId:_,ruleId:y,setting:e};L(i.UpdateSheetDataValidationSettingCommand.id,t,void 0)},se=async()=>{await w.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:y,unitId:g,subUnitId:_}),h.setActiveRule(null),ie()},G={type:k.type,operator:k.operator,formula1:k.formula1,formula2:k.formula2,allowBlank:k.allowBlank},ce=e=>{let t=b.getValidatorItem(e);if(!t)return;let n=t.operators,r=T.getRuleById(g,_,y),o=e===(r==null?void 0:r.type)||e.includes(`list`)&&r!=null&&r.type.includes(`list`)?{...r,type:e}:{...k,type:e,operator:n[0],formula1:void 0,formula2:void 0};A(o),w.executeCommand(i.UpdateSheetDataValidationSettingCommand.id,{unitId:g,subUnitId:_,ruleId:k.uid,setting:(0,a.getRuleSetting)(o)})},le=C.get(j.formulaInput),ue=(0,a.getRuleOptions)(k),de=e=>{(0,n.shallowEqual)(e,(0,a.getRuleOptions)(k))||(A({...k,...e}),L(i.UpdateSheetDataValidationOptionsCommand.id,{unitId:g,subUnitId:_,ruleId:y,options:e}))},fe=W.length&&!k.operator;return(0,f.jsxs)(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[(0,f.jsx)(u.FormLayout,{label:E.t(`sheets-data-validation-ui.panel.range`),error:!k.ranges.length||R?E.t(`sheets-data-validation-ui.panel.rangeError`):``,children:(0,f.jsx)(m.RangeSelector,{selectorRef:V,unitId:g,subUnitId:_,initialValue:te,onChange:(e,t)=>{var n;!B&&(n=V.current)!=null&&n.verify()&&U(t)},onFocusChange:(e,t)=>{var n;ee(e),!e&&t&&(n=V.current)!=null&&n.verify()&&U(t)},onVerify:e=>z(!e)})}),(0,f.jsx)(u.FormLayout,{label:E.t(`sheets-data-validation-ui.panel.type`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:k.type,options:P==null||(s=P.sort((e,t)=>e.order-t.order))==null?void 0:s.map(e=>({label:E.t(e.title),value:e.id})),onChange:ce})}),W!=null&&W.length?(0,f.jsx)(u.FormLayout,{label:E.t(`sheets-data-validation-ui.panel.operator`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:`${k.operator}`,options:[{value:``,label:E.t(`sheets-data-validation-ui.operators.legal`)},...W.map((e,t)=>({value:`${e}`,label:ne[t]}))],onChange:e=>{oe({...G,operator:e})}})}):null,le&&!fe?(0,f.jsx)(le,{isTwoFormula:re,value:{formula1:k.formula1,formula2:k.formula2},onChange:e=>{oe({...G,...e})},showError:M,validResult:j.validatorFormula(k,g,_),unitId:g,subUnitId:_,ruleId:y},c+k.type):null,(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:k.allowBlank??!0,onChange:()=>oe({...G,allowBlank:!(k.allowBlank??!0)}),children:E.t(`sheets-data-validation-ui.panel.allowBlank`)})}),(0,f.jsx)(Ie,{value:ue,onChange:de,extraComponent:j.optionsInput}),(0,f.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[(0,f.jsx)(u.Button,{className:`univer-ml-3`,onClick:se,children:E.t(`sheets-data-validation-ui.panel.removeRule`)}),(0,f.jsx)(u.Button,{className:`univer-ml-3`,variant:`primary`,onClick:ae,children:E.t(`sheets-data-validation-ui.panel.done`)})]})]})}let Ve=e=>{let{rule:r,onClick:o,unitId:s,subUnitId:c,disable:m}=e,h=(0,t.useDependency)(a.DataValidatorRegistryService),g=(0,t.useDependency)(n.ICommandService),_=(0,t.useDependency)(l.IMarkSelectionService),v=h.getValidatorItem(r.type),y=(0,d.useRef)(void 0),[b,x]=(0,d.useState)(!1),S=(0,t.useDependency)(n.ThemeService),C=(0,d.useMemo)(()=>{let e=S.getColorFromTheme(`primary.600`),t=S.getColorFromTheme(`loop-color.2`),r=S.getColorFromTheme(t)??e,i=new n.ColorKit(r).toRgb();return{fill:`rgba(${i.r}, ${i.g}, ${i.b}, 0.1)`,stroke:r}},[(0,t.useObservable)(S.currentTheme$)]);return(0,d.useEffect)(()=>()=>{if(y.current){var e;(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)})}},[_]),(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-p-2 univer-pr-9 rtl:univer-pl-9 rtl:univer-pr-2`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!m,"univer-opacity-50":m}),onClick:o,onMouseEnter:()=>{m||(x(!0),y.current=r.ranges.map(e=>_.addShape({range:e,style:C,primary:null})))},onMouseLeave:()=>{var e;x(!1),(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)}),y.current=void 0},children:[(0,f.jsx)(`div`,{className:`univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-gray-0`,children:v==null?void 0:v.generateRuleName(r)}),(0,f.jsx)(`div`,{className:`univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300`,children:r.ranges.map(e=>(0,p.serializeRange)(e)).join(`,`)}),b&&(0,f.jsx)(`div`,{className:`univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 rtl:univer-left-2 rtl:univer-right-auto dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700`,onClick:e=>{g.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:r.uid,unitId:s,subUnitId:c}),e.stopPropagation()},children:(0,f.jsx)(Te,{})})]})};function He(e){let a=(0,t.useDependency)(i.SheetDataValidationModel),s=(0,t.useDependency)(n.IUniverInstanceService),c=(0,t.useDependency)(n.ICommandService),l=(0,t.useDependency)(n.Injector),d=(0,t.useDependency)(x),p=(0,t.useDependency)(n.LocaleService),{workbook:m}=e,h=(0,t.useObservable)(m.activeSheet$,void 0,!0),g=m.getUnitId(),_=h==null?void 0:h.getSheetId(),v=(0,t.useObservable)(()=>a.ruleChange$.pipe((0,o.filter)(e=>e.unitId===g&&e.subUnitId===_),(0,o.map)(()=>a.getRules(g,_)),(0,o.startWith)(a.getRules(g,_))),[],!1,[a,_,g]),y=async()=>{let e=(0,i.createDefaultNewRule)(l),t={unitId:g,subUnitId:_,rule:e};await c.executeCommand(i.AddSheetDataValidationCommand.id,t),d.setActiveRule({unitId:g,subUnitId:_,rule:e})},b=()=>{c.executeCommand(i.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:_})},S=(e=>{let t=s.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET),i=t.getActiveSheet(),a=t.getUnitId(),o=i.getSheetId();return e.map(e=>(0,r.checkRangesEditablePermission)(l,a,o,e.ranges)?{...e}:{...e,disable:!0})})(v),C=S==null?void 0:S.some(e=>e.disable);return(0,f.jsxs)(`div`,{className:`univer-pb-4`,children:[S==null?void 0:S.map(e=>(0,f.jsx)(Ve,{unitId:g,subUnitId:_,onClick:()=>{e.disable||d.setActiveRule({unitId:g,subUnitId:_,rule:e})},rule:e,disable:e.disable??!1},e.uid)),(0,f.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[v.length&&!C?(0,f.jsx)(u.Button,{onClick:b,children:p.t(`sheets-data-validation-ui.panel.removeAll`)}):null,(0,f.jsx)(u.Button,{variant:`primary`,onClick:y,children:p.t(`sheets-data-validation-ui.panel.add`)})]})]})}let Ue=()=>{let e=(0,t.useDependency)(x),r=(0,t.useObservable)(e.activeRule$,e.activeRule),i=(0,t.useDependency)(n.IUniverInstanceService),a=(0,t.useObservable)(()=>i.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),s=(0,t.useObservable)(()=>(a==null?void 0:a.activeSheet$)??(0,o.of)(null),void 0,void 0,[]);return!a||!s?null:r&&(r.subUnitId===s.getSheetId()||r.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?(0,f.jsx)(ze,{},r.rule.uid):(0,f.jsx)(He,{workbook:a})};function We(e){var r;let{value:i,onChange:a}=e,o=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:(r=i.bizInfo)==null?void 0:r.showTime,onChange:e=>{a({...i,bizInfo:{...i.bizInfo,showTime:e}})},children:o.t(`sheets-data-validation-ui.showTime.label`)})})}We.componentKey=`DATE_SHOW_TIME_OPTION`;let Ge=e=>{let{isTwoFormula:r=!1,value:i,onChange:a,showError:o,validResult:s}=e,c=(0,t.useDependency)(n.LocaleService),l=o?s==null?void 0:s.formula1:``,d=o?s==null?void 0:s.formula2:``;return r?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({...i,formula1:e})}})}),(0,f.jsx)(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-data-validation-ui.panel.formulaAnd`)}),(0,f.jsx)(u.FormLayout,{error:d,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula2,onChange:e=>{a==null||a({...i,formula2:e})}})})]}):(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({formula1:e})}})})};function Ke(e){let{value:r,onChange:i,showError:a,validResult:o}=e,s=(0,t.useDependency)(n.LocaleService),c=a?o==null?void 0:o.formula1:``,l=a?o==null?void 0:o.formula2:``,[p,m]=(0,d.useState)((r==null?void 0:r.formula1)!==void 0||(r==null?void 0:r.formula2)!==void 0);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:p,onChange:e=>{e?m(!0):(m(!1),i==null||i({...r,formula1:void 0,formula2:void 0}))},children:s.t(`sheets-data-validation-ui.checkbox.tips`)})}),p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.checked`),error:c,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula1,onChange:e=>{i==null||i({...r,formula1:e||void 0})}})}):null,p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.unchecked`),error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula2,onChange:e=>{i==null||i({...r,formula2:e||void 0})}})}):null]})}function qe(e){let{unitId:n,subUnitId:r,value:i,onChange:a,showError:o,validResult:s}=e,c=o?s==null?void 0:s.formula1:void 0,l=(0,d.useRef)(null),[p,h]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=l.current)!=null&&t.isClickOutSide(e)&&h(!1)}),(0,f.jsx)(u.FormLayout,{error:c,children:(0,f.jsx)(m.FormulaEditor,{ref:l,className:(0,u.clsx)(`univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,u.borderClassName),initValue:(i==null?void 0:i.formula1)??`=`,unitId:n,subUnitId:r,isFocus:p,isSupportAcrossSheet:!0,onChange:e=>{let t=(e??``).trim();t!==(i==null?void 0:i.formula1)&&(a==null||a({...i,formula1:t}))},onFocus:()=>h(!0)})})}function Je(e,t){let n=new Set,i=[];return e.forEach(e=>{!e.label||n.has(e.label)||(n.add(e.label),i.push(e))}),{formula1:(0,r.serializeListOptions)(i.map(e=>e.label)),formula2:i.map(e=>e.color===t?``:e.color).join(`,`)}}let Ye=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Xe=e=>{let{value:r,onChange:i,disabled:a}=e,[o,s]=(0,d.useState)(!1),c=(0,t.useDependency)(n.ThemeService);(0,t.useObservable)(c.currentTheme$);let l=r.includes(`.`)&&c.isValidThemeColor(r)?c.getColorFromTheme(r):r;return(0,f.jsx)(u.Dropdown,{align:`start`,disabled:a,open:o,onOpenChange:s,overlay:(0,f.jsx)(`div`,{className:`univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5`,children:Ye.map(e=>(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,u.borderClassName),style:{background:e},onClick:()=>{i(e),s(!1)}},e))}),children:(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-gray-0 univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0`,u.borderClassName),children:[(0,f.jsx)(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:l}}),(0,f.jsx)(Ne,{})]})})},Ze=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-cursor-move`,`draggableHandle`),children:(0,f.jsx)(ke,{})}),(0,f.jsx)(Xe,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),(0,f.jsx)(u.Input,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:(0,f.jsx)(`div`,{className:`univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200`,children:(0,f.jsx)(Te,{onClick:()=>a(t.id)})})]})},Qe=()=>{};function $e(e){let{value:s,onChange:c=Qe,unitId:l,subUnitId:p,validResult:h,showError:g,ruleId:_}=e,{formula1:v=``,formula2:y=``}=s||{},[b,S]=(0,d.useState)(()=>(0,n.isFormulaString)(v)?`1`:`0`),[C,T]=(0,d.useState)(b===`1`?v:`=`),[E,D]=(0,d.useState)(b===`1`?v:`=`),O=(0,t.useDependency)(n.LocaleService),k=(0,t.useDependency)(a.DataValidatorRegistryService),A=(0,t.useDependency)(a.DataValidationModel),j=(0,t.useDependency)(i.DataValidationFormulaController),M=(0,t.useDependency)(x),[N,P]=(0,d.useState)(()=>y.split(`,`)),F=k.getValidatorItem(n.DataValidationType.LIST),[I,L]=(0,d.useState)([]),[R,z]=(0,d.useState)(``),B=g?h==null?void 0:h.formula1:``,ee=(0,t.useObservable)((0,d.useMemo)(()=>A.ruleChange$.pipe((0,o.debounceTime)(16)),[])),V=(0,t.useEvent)(c);(0,d.useEffect)(()=>{let e=!1,t=setTimeout(()=>{let t=A.getRuleById(l,p,_);(0,n.isFormulaString)(t==null?void 0:t.formula1)&&F&&t&&F.getListAsync(t,l,p).then(t=>{e||L(t)})},100);return()=>{e=!0,clearTimeout(t)}},[A,ee,F,_,p,l]),(0,d.useEffect)(()=>{(0,n.isFormulaString)(v)&&v!==E&&(T(v),D(v))},[E,v]);let[H,U]=(0,d.useState)(()=>{let e=b===`1`?[]:(0,r.deserializeListOptions)(v),t=y.split(`,`);return e.map((e,r)=>({label:e,color:t[r]||`gray.100`,isRef:!1,id:(0,n.generateRandomId)(4)}))}),te=(e,t,n)=>{let r=H.find(t=>t.id===e);r&&(r.label=t,r.color=n,U([...H]))},W=e=>{let t=H.findIndex(t=>t.id===e);t!==-1&&(H.splice(t,1),U([...H]))},ne=(0,d.useMemo)(()=>I.map((e,t)=>({label:e,color:N[t]||`gray.100`,id:`${t}`,isRef:!0})),[N,I]),re=(e,t,n)=>{let r=[...N];r[+e]=n,P(r),V({formula1:v,formula2:r.join(`,`)})},ie=()=>{U([...H,{label:``,color:w,isRef:!1,id:(0,n.generateRandomId)(4)}])};(0,d.useEffect)(()=>{b!==`1`&&V(Je(H,w))},[H,V,b]);let ae=(0,t.useEvent)(async e=>{if(!(0,n.isFormulaString)(e)){V==null||V({formula1:``,formula2:y});return}j.getFormulaRefCheck(e)?(V==null||V({formula1:(0,n.isFormulaString)(e)?e:``,formula2:y}),z(``)):(V==null||V({formula1:``,formula2:y}),T(`=`),z(O.t(`sheets-data-validation-ui.validFail.formulaError`)))}),oe=(0,d.useRef)(null),[se,G]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=oe.current)!=null&&t.isClickOutSide(e)&&G(!1)}),(0,d.useEffect)(()=>{se?M.setFocusFormulaEditorActiveRuleSubUnitId(p):M.setFocusFormulaEditorActiveRuleSubUnitId(null)},[se,p,M]),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{label:O.t(`sheets-data-validation-ui.list.options`),children:(0,f.jsxs)(u.RadioGroup,{value:b,onChange:e=>{S(e),T(E),e===`1`&&V({formula1:E===`=`?``:E,formula2:N.join(`,`)})},children:[(0,f.jsx)(u.Radio,{value:`0`,children:O.t(`sheets-data-validation-ui.list.customOptions`)}),(0,f.jsx)(u.Radio,{value:`1`,children:O.t(`sheets-data-validation-ui.list.refOptions`)})]})}),b===`1`?(0,f.jsxs)(u.FormLayout,{error:B||R||void 0,children:[(0,f.jsx)(m.FormulaEditor,{ref:oe,className:(0,u.clsx)(`univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,u.borderClassName),initValue:C,unitId:l,subUnitId:p,isFocus:se,isSupportAcrossSheet:!0,onFocus:()=>G(!0),onChange:(e=``)=>{let t=(e??``).trim();D(t),ae(t)}}),ne.length>0&&(0,f.jsx)(`div`,{className:`univer-mt-3`,children:ne.map(e=>(0,f.jsx)(Ze,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:re}},e.id))})]}):(0,f.jsx)(u.FormLayout,{error:B,children:(0,f.jsxs)(`div`,{children:[(0,f.jsx)(u.DraggableList,{list:H,onListChange:U,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>(0,f.jsx)(Ze,{item:e,commonProps:{onItemChange:te,onItemDelete:W}},e.id),idKey:`id`}),(0,f.jsxs)(`a`,{className:`univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800`,onClick:ie,children:[(0,f.jsx)(je,{className:`univer-mr-1`}),O.t(`sheets-data-validation-ui.list.add`)]})]})})]})}let et=[[i.CUSTOM_FORMULA_INPUT_NAME,qe],[i.BASE_FORMULA_INPUT_NAME,Ge],[i.LIST_FORMULA_INPUT_NAME,$e],[i.CHECKBOX_FORMULA_INPUT_NAME,Ke]];function tt(e){let{value:r,onChange:i}=e,a=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{label:a.t(`sheets-data-validation-ui.renderMode.label`),children:(0,f.jsxs)(u.RadioGroup,{value:`${r.renderMode??n.DataValidationRenderMode.CUSTOM}`,onChange:e=>i({...r,renderMode:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.CUSTOM}`,children:a.t(`sheets-data-validation-ui.renderMode.chip`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.ARROW}`,children:a.t(`sheets-data-validation-ui.renderMode.arrow`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.TEXT}`,children:a.t(`sheets-data-validation-ui.renderMode.text`)})]})})}tt.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;let q=class extends n.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({CheckboxIcon:ye,DataValidationIcon:xe,DatePickerIcon:Ce,DropdownListIcon:De}))}_registerComponents(){[[A,Ue],[tt.componentKey,tt],[We.componentKey,We],[B,ee],...et].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};q=b([y(0,(0,n.Inject)(t.ComponentManager)),y(1,(0,n.Inject)(t.IconManager))],q);let J=`SHEET_DATA_VALIDATION_ALERT`,nt=class extends n.Disposable{constructor(e,t,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,o.debounceTime)(100)).subscribe(e=>{if(e){let r=this._univerInstanceService.getUnit(e.location.unitId,n.UniverInstanceType.UNIVER_SHEET),i=r.getSheetBySheetId(e.location.subUnitId);if(!i)return;let a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(J);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:i})===n.DataValidationStatus.INVALID){var t;let n=this._cellAlertManagerService.currentAlert.get(J),r=n==null||(t=n.alert)==null?void 0:t.location;if(r&&r.row===e.location.row&&r.col===e.location.col&&r.subUnitId===e.location.subUnitId&&r.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(J);return}let i=this._dataValidationModel.getValidator(a.type);if(!i){this._cellAlertManagerService.removeAlert(J);return}this._cellAlertManagerService.showAlert({type:l.CellAlertType.ERROR,title:this._localeService.t(`sheets-data-validation-ui.error.title`),message:i==null?void 0:i.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:J});return}}this._cellAlertManagerService.removeAlert(J)}))}};nt=b([y(0,(0,n.Inject)(l.HoverManagerService)),y(1,(0,n.Inject)(l.CellAlertManagerService)),y(2,n.IUniverInstanceService),y(3,(0,n.Inject)(n.LocaleService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],nt);let Y=class extends n.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,u=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),d=(0,l.virtualizeDiscreteRanges)([a,o]),[f,p]=d.ranges,{mapRange:m,projectRange:h}=d,g=r.AutoFillTools.getAutoFillRepeatRange(f,p),_=new Map;_.set(``,g.flatMap(e=>m(n.Rectangle.getPositionRange(e.relativeRange,{startRow:e.repeatStartCell.row,endRow:e.repeatStartCell.row,startColumn:e.repeatStartCell.col,endColumn:e.repeatStartCell.col})))),this._sheetDataValidationModel.getRules(s,c).forEach(e=>{let t=e.ranges.flatMap(e=>{let t=h(e),r=t&&(0,n.getIntersectRange)(t,f);return r?[n.Rectangle.getRelativeRange(r,f)]:[]}),r=g.flatMap(e=>t.flatMap(t=>{let r=(0,n.getIntersectRange)(t,e.relativeRange);return r?m(n.Rectangle.getPositionRange(r,{startRow:e.repeatStartCell.row,endRow:e.repeatStartCell.row,startColumn:e.repeatStartCell.col,endColumn:e.repeatStartCell.col})):[]}));r.length&&_.set(e.uid,r)});let v=Array.from(_,([e,t])=>({id:e,ranges:t.length>1?n.Rectangle.mergeRanges(t):t}));u.addRangeRules(v);let{redoMutations:y,undoMutations:b}=(0,i.getDataValidationDiffMutations)(s,c,u.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,t===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:b,redos:y}},a={id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:e=>{let{source:t,unitId:i,subUnitId:a}=e,{projectRange:o}=(0,l.virtualizeDiscreteRanges)([t]);this._sheetDataValidationModel.getRules(i,a).some(e=>e.type===n.DataValidationType.CHECKBOX&&e.ranges.some(e=>o(e)!==null))&&this._autoFillService.setDisableApplyType(r.AUTO_FILL_APPLY_TYPE.SERIES,!0)},onFillData:(n,i,a)=>a===r.AUTO_FILL_APPLY_TYPE.COPY||a===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===r.AUTO_FILL_APPLY_TYPE.SERIES?t(n,a):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};Y=b([y(0,r.IAutoFillService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector))],Y);let rt=[l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA],X=class extends n.Disposable{constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,this._univerInstanceService=r,v(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>!e||!this._copyInfo||rt.includes(r.pasteType)?{redos:[],undos:[]}:this._generateMutations(e,t,r)})}_collect(e,t,i){let a=new Map;this._copyInfo={unitId:e,subUnitId:t,rules:a};let o=this._injector.invoke(n=>(0,r.rangeToDiscreteRange)(i,n,e,t));if(!o)return;let{projectRange:s}=(0,l.virtualizeDiscreteRanges)([o]);this._sheetDataValidationModel.getRules(e,t).forEach(e=>{let t=e.ranges.flatMap(e=>{let t=s(e);return t?[t]:[]});t.length&&a.set(e.uid,t.length>1?n.Rectangle.mergeRanges(t):t)})}_generateMutations(e,t,a){let o=this._copyInfo;if(!o)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,range:u}=e,{unitId:d,subUnitId:f,range:p}=t,{copyType:m=l.COPY_TYPE.COPY}=a;if(!(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:d,subUnitId:f}))return{redos:[],undos:[]};if(m===l.COPY_TYPE.CUT&&d===s&&f===c)return this._copyInfo=null,{redos:[],undos:[]};let h=(0,l.virtualizeDiscreteRanges)([u]).ranges[0],g=(0,l.virtualizeDiscreteRanges)([p]),_=g.ranges[0],v=(0,l.getRepeatRange)(h,_,!0),y=g.mapRange(_),b=e=>v.flatMap(({startRange:t})=>e.flatMap(e=>g.mapRange(n.Rectangle.getPositionRange(e,t))));if(d!==s||f!==c){let e=this._sheetDataValidationModel.getRuleObjectMatrix(d,f).clone(),t=new Map,n=[{id:``,ranges:y}];o.rules.forEach((e,r)=>{let i=`${c}-${r}`,a=this._sheetDataValidationModel.getRuleById(s,c,r);!this._sheetDataValidationModel.getRuleById(d,f,i)&&a&&t.set(i,{...a,uid:i}),n.push({id:i,ranges:b(e)})}),e.addRangeRules(n);let{redoMutations:r,undoMutations:a}=(0,i.getDataValidationDiffMutations)(d,f,e.diffWithAddition(this._sheetDataValidationModel.getRules(d,f),t.values()),this._injector,`patched`,!1);if(m===l.COPY_TYPE.CUT){let e=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone();e.addRangeRules([{id:``,ranges:(0,l.virtualizeDiscreteRanges)([u]).mapRange(h)}]);let{redoMutations:t,undoMutations:n}=(0,i.getDataValidationDiffMutations)(s,c,e.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,!1);r.push(...t),a.push(...n)}return{redos:r,undos:a}}else{let e=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),t=[{id:``,ranges:y},...Array.from(o.rules,([e,t])=>({id:e,ranges:b(t)}))];e.addRangeRules(t);let{redoMutations:n,undoMutations:r}=(0,i.getDataValidationDiffMutations)(d,f,e.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,!1);return{redos:n,undos:r}}}};X=b([y(0,l.ISheetClipboardService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector)),y(3,(0,n.Inject)(n.IUniverInstanceService))],X);let it=class extends n.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===i.AddSheetDataValidationCommand.id){let{unitId:t,subUnitId:n,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}if(e.id===i.UpdateSheetDataValidationRangeCommand.id){let{unitId:t,subUnitId:n,ranges:i}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}}))}};it=b([y(0,(0,n.Inject)(n.LocaleService)),y(1,n.ICommandService),y(2,(0,n.Inject)(r.SheetPermissionCheckController))],it);let at={tr:{size:6,color:`#fe4b4b`}},ot=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=i,this._dropdownManagerService=a,this._sheetDataValidationModel=o,this._dataValidatorRegistryService=s,this._sheetInterceptorService=c,this._dataValidationCacheService=l,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(de)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{if(!e.visible){var t;((t=this._dropdownManagerService.activeDropdown)==null?void 0:t.trigger)===`editor-bridge`&&this._dropdownManagerService.hideDropdown();return}let r=this._editorBridgeService.getEditCellState();if(r){let{unitId:e,sheetId:t,row:i,column:a}=r,o=this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=this._sheetDataValidationModel.getRuleByLocation(e,t,i,a);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);if(!(c!=null&&c.dropdownType))return;let l=o.getActiveSheet();if(!l)return;let u=this._dropdownManagerService.activeDropdown,d=u==null?void 0:u.location;if(d&&d.unitId===e&&d.subUnitId===t&&d.row===i&&d.col===a)return;this._dropdownManagerService.showDropdown({location:{unitId:e,subUnitId:t,row:i,col:a,workbook:o,worksheet:l},trigger:`editor-bridge`,closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o;let{row:s,col:c,unitId:u,subUnitId:d,workbook:f,worksheet:p}=t,m=this._sheetDataValidationModel.getRuleIdByLocation(u,d,s,c);if(!m)return r(e);let h=this._sheetDataValidationModel.getRuleById(u,d,m);if(!h)return r(e);let g=this._dataValidationCacheService.getValue(u,d,s,c)??n.DataValidationStatus.VALID,_=this._dataValidatorRegistryService.getValidatorItem(h.type),v=t.rawData,y,b={get value(){return y===void 0&&(y=(0,i.getCellValueOrigin)(v)??null),y}},x={get value(){return`${b.value??``}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===n.DataValidationStatus.INVALID?at:null},e.customRender=[...(e==null?void 0:e.customRender)??[],..._!=null&&_.canvasRender?[_.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(_==null||(o=_.skipDefaultFontRender)==null?void 0:o.call(_,h,b.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,..._==null?void 0:_.getExtraStyle(h,x.value,{get style(){let t=f.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},s,c)},e.interceptorAutoHeight=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoHeight)==null?void 0:r.call(n,o)},e.interceptorAutoWidth=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoWidth)==null?void 0:r.call(n,o)},e.coverable=((e==null?void 0:e.coverable)??!0)&&h.type!==n.DataValidationType.LIST&&h.type!==n.DataValidationType.LIST_MULTIPLE,r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(100)).subscribe(e=>{if(e.length===0)return;let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};ot=b([y(0,n.ICommandService),y(1,t.IMenuManagerService),y(2,s.IRenderManagerService),y(3,n.IUniverInstanceService),y(4,(0,n.Inject)(l.AutoHeightController)),y(5,(0,n.Inject)(k)),y(6,(0,n.Inject)(i.SheetDataValidationModel)),y(7,(0,n.Inject)(a.DataValidatorRegistryService)),y(8,(0,n.Inject)(r.SheetInterceptorService)),y(9,(0,n.Inject)(i.DataValidationCacheService)),y(10,(0,n.Optional)(l.IEditorBridgeService))],ot);let st=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._dataValidationCacheService=o,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o;let{row:s,col:c,unitId:u,subUnitId:d,workbook:f,worksheet:p}=t,m=this._sheetDataValidationModel.getRuleIdByLocation(u,d,s,c);if(!m)return r(e);let h=this._sheetDataValidationModel.getRuleById(u,d,m);if(!h)return r(e);let g=this._dataValidationCacheService.getValue(u,d,s,c)??n.DataValidationStatus.VALID,_=this._dataValidatorRegistryService.getValidatorItem(h.type),v=(0,i.getCellValueOrigin)(p.getCellRaw(s,c)),y=`${v??``}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===n.DataValidationStatus.INVALID?at:null},e.customRender=[...(e==null?void 0:e.customRender)??[],..._!=null&&_.canvasRender?[_.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(_==null||(o=_.skipDefaultFontRender)==null?void 0:o.call(_,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,..._==null?void 0:_.getExtraStyle(h,y,{get style(){let t=f.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},s,c)},e.interceptorAutoHeight=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoHeight)==null?void 0:r.call(n,o)},e.interceptorAutoWidth=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoWidth)==null?void 0:r.call(n,o)},e.coverable=((e==null?void 0:e.coverable)??!0)&&h.type!==n.DataValidationType.LIST&&h.type!==n.DataValidationType.LIST_MULTIPLE,r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(16)).subscribe(e=>{let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};st=b([y(0,n.ICommandService),y(1,s.IRenderManagerService),y(2,(0,n.Inject)(l.AutoHeightController)),y(3,(0,n.Inject)(a.DataValidatorRegistryService)),y(4,(0,n.Inject)(r.SheetInterceptorService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,(0,n.Inject)(i.DataValidationCacheService))],st);let ct=class extends n.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe((0,n.bufferDebounceTime)(16)).subscribe(e=>{var t;if(!e.length)return;let n=new Set;e.forEach(e=>{n.add(e.subUnitId)}),n.forEach(e=>{var t;(t=this._sheetSkeletonManagerService.getSkeletonParam(e))==null||t.skeleton.makeDirty(!0)}),(t=this._context.mainComponent)==null||t.makeForceDirty()}))}};ct=b([y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(l.SheetSkeletonManagerService))],ct);let lt=class{_calc(e,t){let{vt:r,ht:i}=t||{},a=e.endX-e.startX-12,o=e.endY-e.startY,s=((t==null?void 0:t.fs)??10)*1.6,c=0,l=0;switch(r){case n.VerticalAlign.TOP:l=0;break;case n.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(i){case n.HorizontalAlign.LEFT:c=6;break;case n.HorizontalAlign.RIGHT:c=6+(a-s);break;default:c=6+(a-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((t==null?void 0:t.fs)??10)*1.6,height:((t==null?void 0:t.fs)??10)*1.6}}constructor(e,t,n,r,i,a){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=i,this._dataValidationModel=a}calcCellAutoHeight(e){let{style:t}=e;return((t==null?void 0:t.fs)??10)*1.6}calcCellAutoWidth(e){let{style:t}=e;return((t==null?void 0:t.fs)??10)*1.6}async _parseFormula(e,t,r){var a,o,s;let{formula1:c=i.CHECKBOX_FORMULA_1,formula2:l=i.CHECKBOX_FORMULA_2}=e,u=await this._formulaService.getRuleFormulaResult(t,r,e.uid),d=(0,i.getFormulaResult)(u==null||(a=u[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]),f=(0,i.getFormulaResult)(u==null||(o=u[1])==null||(o=o.result)==null||(o=o[0])==null?void 0:o[0]),p=(0,i.isLegalFormulaResult)(String(d))&&(0,i.isLegalFormulaResult)(String(f));return{formula1:(0,n.isFormulaString)(c)?(0,i.getFormulaResult)(u==null||(s=u[0])==null||(s=s.result)==null||(s=s[0])==null?void 0:s[0]):c,formula2:(0,n.isFormulaString)(l)?f:l,isFormulaValid:p}}drawWith(e,t){var n,r;let{style:a,primaryWithCoord:o,unitId:c,subUnitId:l,worksheet:u,row:d,col:f}=t,p=o.isMergedMainCell?o.mergeInfo:o,m=(0,i.getCellValueOrigin)(u.getCellRaw(d,f)),h=this._dataValidationModel.getRuleByLocation(c,l,d,f);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g||!((n=g.skipDefaultFontRender)!=null&&n.call(g,h,m,{unitId:c,subUnitId:l,row:d,column:f})))return;let{formula1:_}=g.parseFormulaSync(h,c,l),v=this._calc(p,a),{a:y,d:b}=e.getTransform(),x=(0,s.fixLineWidthByScale)(v.left,y),S=(0,s.fixLineWidthByScale)(v.top,b),C=s.Transform.create().composeMatrix({left:x,top:S,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),w=p.endX-p.startX,T=p.endY-p.startY;e.save(),e.beginPath(),e.rect(p.startX,p.startY,w,T),e.clip();let E=C.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);let D=((a==null?void 0:a.fs)??10)*1.6,O=String(m)===String(_),k=this._themeService.getColorFromTheme(`primary.600`);s.CheckboxShape.drawWith(e,{checked:O,width:D,height:D,fill:(a==null||(r=a.cl)==null?void 0:r.rgb)??k}),e.restore()}isHit(e,t){let n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),i=r.top,a=r.top+r.height,o=r.left,s=r.left+r.width,{x:c,y:l}=e;return c<=s&&c>=o&&l<=a&&l>=i}async onPointerDown(e,t){var n;if(t.button===2)return;let{primaryWithCoord:a,unitId:o,subUnitId:s,worksheet:c,row:l,col:u}=e,d=(0,i.getCellValueOrigin)(c.getCellRaw(l,u)),f=this._dataValidationModel.getRuleByLocation(o,s,l,u);if(!f)return;let p=this._dataValidationModel.getValidator(f.type);if(!p||!((n=p.skipDefaultFontRender)!=null&&n.call(p,f,d,{unitId:o,subUnitId:s,row:l,column:u})))return;let{formula1:m,formula2:h}=await this._parseFormula(f,o,s),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===(0,i.transformCheckboxValue)(String(m))?h:m,p:null}};this._commandService.executeCommand(r.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};lt=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(i.DataValidationFormulaService)),y(3,(0,n.Inject)(n.ThemeService)),y(4,(0,n.Inject)(s.IRenderManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel))],lt);let Z=class{constructor(e){this.injector=e,v(this,`canvasRender`,null),v(this,`dropdownType`,void 0),v(this,`optionsInput`,void 0),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}};Z=b([y(0,(0,n.Inject)(n.Injector))],Z);var ut=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CHECKBOX),v(this,`canvasRender`,this.injector.createInstance(lt)),v(this,`formulaInput`,i.CHECKBOX_FORMULA_INPUT_NAME)}},dt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CUSTOM),v(this,`formulaInput`,i.CUSTOM_FORMULA_INPUT_NAME)}},ft=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DATE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME),v(this,`optionsInput`,We.componentKey),v(this,`dropdownType`,a.DataValidatorDropdownType.DATE)}},pt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DECIMAL),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};function mt(e,t){let n=s.FontCache.getTextSize(e,t),r=n.width+8,{ba:i,bd:a}=n;return{width:r,height:i+a+0,ba:i}}function ht(e,t,n,r){let i=n-26,a=r-12,o=e.map(e=>({layout:mt(e,t),text:e})),s,c=[];o.forEach(e=>{let{layout:t}=e,{width:n,height:r}=t;!s||s.width+n+4>i?(s={width:n,height:r,items:[{...e,left:0}]},c.push(s)):(s.items.push({...e,left:s.width+4}),s.width=s.width+n+4)});let l=0,u=0;return c.forEach((e,t)=>{u=Math.max(u,e.width),t===c.length-1?l+=e.height:l+=e.height+4}),{lines:c,totalHeight:l,contentWidth:i,contentHeight:a,cellAutoHeight:l+12,calcAutoWidth:u+26}}var gt=class extends s.Shape{static drawWith(e,t){let{fontString:n,info:r,fill:i,color:a}=t,{layout:o,text:c}=r;e.save(),s.Rect.drawWith(e,{width:o.width,height:o.height,radius:8,fill:i||`gray.100`}),e.translateWithPrecision(4,o.ba),e.font=n,e.fillStyle=a,e.fillText(c,0,0),e.restore()}};let _t=new Path2D(`M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z`),vt=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,v(this,`zIndex`,void 0),v(this,`_dropdownInfoMap`,new Map)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a){let o=r-14+4,s=4;switch(a){case n.VerticalAlign.MIDDLE:s=(i-14)/2+4;break;case n.VerticalAlign.BOTTOM:s=i-14+4;break;default:break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle=T,e.fill(_t),e.restore()}drawWith(e,t,r,a){let{primaryWithCoord:o,row:c,col:l,style:u,data:d,subUnitId:f}=t,p=o.isMergedMainCell?o.mergeInfo:o,{leftOffset:m=0,rightOffset:h=0,topOffset:g=0,downOffset:_=0}=(d==null?void 0:d.fontRenderExtension)||{},v=this._ensureMap(f),y=this._generateKey(c,l),b=o.isMergedMainCell?o.mergeInfo.startRow:c,x=o.isMergedMainCell?o.mergeInfo.startColumn:l,S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,b,x);if(!S)return;let C=this._dataValidationModel.getValidator(S.type);if(!C)return;let w={startX:p.startX+m,endX:p.endX-h,startY:p.startY+g,endY:p.endY-_},T=w.endX-w.startX,E=w.endY-w.startY,{cl:D}=u||{},O=(typeof D==`object`?D==null?void 0:D.rgb:D)??`#000`,k=(0,s.getFontStyleString)(u??void 0),{vt:A,ht:j}=u||{},M=A??n.VerticalAlign.MIDDLE,N=(0,i.getCellValueOrigin)(d)??``,P=C.parseCellValue(N),F=C.getListWithColorMap(S),I=ht(P,k,T,E);this._drawDownIcon(e,w,T,E,M),e.save(),e.translateWithPrecision(w.startX,w.startY),e.beginPath(),e.rect(0,0,T-14,E),e.clip(),e.translateWithPrecision(6,6);let L=0;switch(M){case n.VerticalAlign.MIDDLE:L=(I.contentHeight-I.totalHeight)/2;break;case n.VerticalAlign.BOTTOM:L=I.contentHeight-I.totalHeight;break;default:break}e.translateWithPrecision(0,L),I.lines.forEach((t,r)=>{e.save();let{width:i,height:a,items:o}=t,s=0;switch(j){case n.HorizontalAlign.RIGHT:s=I.contentWidth-i;break;case n.HorizontalAlign.CENTER:s=(I.contentWidth-i)/2;break;default:break}e.translate(s,r*(a+4)),o.forEach(t=>{e.save(),e.translateWithPrecision(t.left,0),gt.drawWith(e,{...k,info:t,color:O,fill:F[t.text]}),e.restore()}),e.restore()}),e.restore(),v.set(y,{left:w.startX,top:w.startY,width:I.contentWidth+6+14,height:I.contentHeight+12})}calcCellAutoHeight(e){let{primaryWithCoord:t,style:n,data:r,row:a,col:o}=e,{leftOffset:c=0,rightOffset:l=0,topOffset:u=0,downOffset:d=0}=(r==null?void 0:r.fontRenderExtension)||{},f=t.isMergedMainCell?t.mergeInfo:t,p={startX:f.startX+c,endX:f.endX-l,startY:f.startY+u,endY:f.endY-d},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!m)return;let h=this._dataValidationModel.getValidator(m.type);if(!h)return;let g=p.endX-p.startX,_=p.endY-p.startY,v=(0,i.getCellValueOrigin)(r)??``;return ht(h.parseCellValue(v),(0,s.getFontStyleString)(n??void 0),g,_).cellAutoHeight}calcCellAutoWidth(e){let{primaryWithCoord:t,style:n,data:r,row:a,col:o}=e,{leftOffset:c=0,rightOffset:l=0,topOffset:u=0,downOffset:d=0}=(r==null?void 0:r.fontRenderExtension)||{},f=t.isMergedMainCell?t.mergeInfo:t,p={startX:f.startX+c,endX:f.endX-l,startY:f.startY+u,endY:f.endY-d},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!m)return;let h=this._dataValidationModel.getValidator(m.type);if(!h)return;let g=p.endX-p.startX,_=p.endY-p.startY,v=(0,i.getCellValueOrigin)(r)??``;return ht(h.parseCellValue(v),(0,s.getFontStyleString)(n??void 0),g,_).calcAutoWidth}isHit(e,t){let{primaryWithCoord:n}=t,{endX:r}=n.isMergedMainCell?n.mergeInfo:n,{x:i}=e;return i>=r-14&&i<=r}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(P.id,o)}onPointerEnter(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.DEFAULT)}};vt=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(s.IRenderManagerService)),y(3,(0,n.Inject)(i.SheetDataValidationModel))],vt);var yt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST_MULTIPLE),v(this,`canvasRender`,this.injector.createInstance(vt)),v(this,`dropdownType`,a.DataValidatorDropdownType.MULTIPLE_LIST)}};let bt=new Path2D(`M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z`);function xt(e,t,r,i,a,o,s=!0){let c=0,l=s?3:0;switch(a){case n.VerticalAlign.BOTTOM:c=t-i-l;break;case n.VerticalAlign.MIDDLE:c=(t-i)/2;break;default:c=l;break}c=Math.max(3,c);let u=0;switch(o){case n.HorizontalAlign.CENTER:u=(e-r)/2;break;case n.HorizontalAlign.RIGHT:u=e-r;break;default:break}return u=Math.max(6,u),{paddingLeft:u,paddingTop:c}}let St=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,v(this,`_dropdownInfoMap`,new Map),v(this,`zIndex`,void 0)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a,o,s){let{t:c=n.DEFAULT_STYLES.pd.t,b:l=n.DEFAULT_STYLES.pd.b}=s,u=r-14,d;switch(o){case n.VerticalAlign.MIDDLE:d=(i-4)/2;break;case n.VerticalAlign.BOTTOM:d=i-l-a-3+(a/2-4/2);break;default:d=c+3+(a/2-4/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+d),e.fillStyle=T,e.fill(bt),e.restore()}drawWith(e,t,r){let{primaryWithCoord:a,row:o,col:c,style:l,data:u,subUnitId:d}=t,f=a.isMergedMainCell?a.mergeInfo:a,p=a.isMergedMainCell?a.mergeInfo.startRow:o,m=a.isMergedMainCell?a.mergeInfo.startColumn:c,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,p,m);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let{leftOffset:_=0,rightOffset:v=0,topOffset:y=0,downOffset:b=0}=(u==null?void 0:u.fontRenderExtension)||{};if(!h||!g||!g||g.id.indexOf(n.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;let x={startX:f.startX+_,endX:f.endX-v,startY:f.startY+y,endY:f.endY-b},S=x.endX-x.startX,C=x.endY-x.startY,w=this._ensureMap(d),E=this._generateKey(o,c),D=g.getListWithColorMap(h),O=`${(0,i.getCellValueOrigin)(u)??``}`,k=D[O],{tb:A,vt:j,ht:M,pd:N}=l||{};A??=n.WrapStrategy.WRAP,j??=n.VerticalAlign.BOTTOM,M??=n.DEFAULT_STYLES.ht,N??=n.DEFAULT_STYLES.pd;let P=(0,s.getFontStyleString)(l).fontCache;if(h.renderMode===n.DataValidationRenderMode.ARROW){var F,I,L;let{l:t=n.DEFAULT_STYLES.pd.l,t:i=n.DEFAULT_STYLES.pd.t,r:a=n.DEFAULT_STYLES.pd.r,b:o=n.DEFAULT_STYLES.pd.b}=N,c=S-t-a-14-4,u=new s.DocSimpleSkeleton(O,P,A===n.WrapStrategy.WRAP,c,1/0);u.calculate();let d=u.getTotalWidth(),f=u.getTotalHeight(),{paddingTop:p,paddingLeft:m}=xt(c,C-i-o,d,f,j,M,!0);this._drawDownIcon(e,x,S,C,f,j,N),e.save(),e.translateWithPrecision(x.startX+t,x.startY+i),e.beginPath(),e.rect(0,0,S-t-a,C-i-o),e.clip(),e.translateWithPrecision(0,p),e.save(),e.translateWithPrecision(m,0),e.beginPath(),e.rect(0,0,c,f),e.clip(),s.Text.drawWith(e,{text:O,fontStyle:P,width:c,height:f,color:l==null||(F=l.cl)==null?void 0:F.rgb,strokeLine:!!(l!=null&&(I=l.st)!=null&&I.s),underline:!!(l!=null&&(L=l.ul)!=null&&L.s),warp:A===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},u),e.restore(),e.restore(),w.set(E,{left:x.endX-14+r.rowHeaderWidth,top:x.startY+i+r.columnHeaderHeight,width:14,height:C-i-o})}else{var R,z,B;e.save(),e.translateWithPrecision(x.startX,x.startY),e.beginPath(),e.rect(0,0,S,C),e.clip();let t=S-12-4-14-4,i=new s.DocSimpleSkeleton(O,P,A===n.WrapStrategy.WRAP,t,1/0);i.calculate();let a=i.getTotalWidth(),o=i.getTotalHeight(),c=o+2,u=Math.max(S-12,1),{paddingTop:d}=xt(u,C,a,c,j,M);e.translateWithPrecision(6,d),s.Rect.drawWith(e,{width:u,height:c,fill:k||`gray.100`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,t,o),e.clip(),s.Text.drawWith(e,{text:O,fontStyle:P,width:t,height:o,color:l==null||(R=l.cl)==null?void 0:R.rgb,strokeLine:!!(l!=null&&(z=l.st)!=null&&z.s),underline:!!(l!=null&&(B=l.ul)!=null&&B.s),warp:A===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},i),e.restore(),e.translateWithPrecision(t+4+4,(o-4)/2),e.fillStyle=T,e.fill(bt),e.restore(),w.set(E,{left:x.startX+6+r.rowHeaderWidth,top:x.startY+d+r.columnHeaderHeight,width:u,height:c})}}calcCellAutoHeight(e){let{primaryWithCoord:t,style:r,data:a,row:o,col:c}=e,l=t.isMergedMainCell?t.mergeInfo:t,{leftOffset:u=0,rightOffset:d=0,topOffset:f=0,downOffset:p=0}=(a==null?void 0:a.fontRenderExtension)||{},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!m||m.renderMode===n.DataValidationRenderMode.TEXT)return;let h={startX:l.startX+u,endX:l.endX-d,startY:l.startY+f,endY:l.endY-p},g=h.endX-h.startX,_=`${(0,i.getCellValueOrigin)(a)??``}`,{tb:v,pd:y}=r||{},{t:b=n.DEFAULT_STYLES.pd.t,b:x=n.DEFAULT_STYLES.pd.b}=y??{};if(v??=n.WrapStrategy.WRAP,m.renderMode===n.DataValidationRenderMode.ARROW){let{l:e=n.DEFAULT_STYLES.pd.l,r:t=n.DEFAULT_STYLES.pd.r}=y??{},i=g-e-t-14-4,a=new s.DocSimpleSkeleton(_,(0,s.getFontStyleString)(r).fontCache,v===n.WrapStrategy.WRAP,i,1/0);return a.calculate(),a.getTotalHeight()+b+x+6}else{let e=Math.max(g-12-4-14-4,10),t=new s.DocSimpleSkeleton(_,(0,s.getFontStyleString)(r).fontCache,v===n.WrapStrategy.WRAP,e,1/0);return t.calculate(),t.getTotalHeight()+6+2}}calcCellAutoWidth(e){let{primaryWithCoord:t,style:r,data:a,row:o,col:c}=e,l=t.isMergedMainCell?t.mergeInfo:t,{leftOffset:u=0,rightOffset:d=0,topOffset:f=0,downOffset:p=0}=(a==null?void 0:a.fontRenderExtension)||{},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!m||m.renderMode===n.DataValidationRenderMode.TEXT)return;let h={startX:l.startX+u,endX:l.endX-d,startY:l.startY+f,endY:l.endY-p},g=h.endX-h.startX,_=`${(0,i.getCellValueOrigin)(a)??``}`,{tb:v,pd:y}=r||{},{l:b=n.DEFAULT_STYLES.pd.l,r:x=n.DEFAULT_STYLES.pd.r}=y??{};v??=n.WrapStrategy.WRAP;let S=26;switch(m.renderMode){case n.DataValidationRenderMode.ARROW:S=18+x+b;break;case n.DataValidationRenderMode.CUSTOM:S=34+x+b+8/2+1;break;default:S=34+x+b+8/2+1}let C=g-S,w=new s.DocSimpleSkeleton(_,(0,s.getFontStyleString)(r).fontCache,v===n.WrapStrategy.WRAP,C,1/0);return w.calculate(),w.getTotalWidth()+S}isHit(e,t){let{subUnitId:r,row:i,col:a}=t,o=this._ensureMap(r).get(this._generateKey(i,a)),s=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,a);if(!s||!o||s.renderMode===n.DataValidationRenderMode.TEXT)return!1;let{top:c,left:l,width:u,height:d}=o,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=c&&p<=c+d}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(P.id,o)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};St=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(n.LocaleService)),y(2,n.ICommandService),y(3,(0,n.Inject)(s.IRenderManagerService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],St);var Ct=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST),v(this,`canvasRender`,this.injector.createInstance(St)),v(this,`dropdownType`,a.DataValidatorDropdownType.LIST),v(this,`optionsInput`,tt.componentKey),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}},wt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.TEXT_LENGTH),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}},Tt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.WHOLE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};let Et=class extends n.RxDisposable{constructor(e,t){super(),this._injector=e,this._dataValidatorRegistryService=t,this._registerValidatorViews()}_registerValidatorViews(){[pt,Tt,wt,ft,ut,Ct,yt,dt].forEach(e=>{let t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Et=b([y(0,(0,n.Inject)(n.Injector)),y(1,(0,n.Inject)(a.DataValidatorRegistryService))],Et);let Q=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([q]),this._injector.get(q),[[x],[k],[nt],[Y],[ot],[it],[X],[Et]].forEach(e=>{this._injector.add(e)}),[z,L,R,P,F,M,j,N].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(X),this._injector.get(it),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[ct])}onRendered(){this._injector.get(Et),this._injector.get(ot)}onSteady(){this._injector.get(Y)}};v(Q,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v(Q,`packageName`,fe),v(Q,`version`,pe),v(Q,`type`,n.UniverInstanceType.UNIVER_SHEET),Q=b([(0,n.DependentOn)(a.UniverDataValidationPlugin,s.UniverRenderEnginePlugin,r.UniverSheetsPlugin,t.UniverMobileUIPlugin,l.UniverSheetsMobileUIPlugin,i.UniverSheetsDataValidationPlugin),y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],Q);let $=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([q]),this._injector.get(q),[[x],[k],[nt],[Y],[ot],[it],[X],[E],[Et]].forEach(e=>{this._injector.add(e)}),[z,L,R,P,F,M,j,N].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(X),this._injector.get(it),this._injector.get(E),this._injector.get(nt),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[ct])}onRendered(){this._injector.get(Et),this._injector.get(ot)}onSteady(){this._injector.get(Y)}};v($,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v($,`packageName`,fe),v($,`version`,pe),v($,`type`,n.UniverInstanceType.UNIVER_SHEET),$=b([(0,n.DependentOn)(a.UniverDataValidationPlugin,s.UniverRenderEnginePlugin,r.UniverSheetsPlugin,l.UniverSheetsUIPlugin,i.UniverSheetsDataValidationPlugin),y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],$),e.SheetsDataValidationUIMenuSchema=de,Object.defineProperty(e,"UniverSheetsDataValidationMobileUIPlugin",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"UniverSheetsDataValidationUIPlugin",{enumerable:!0,get:function(){return $}})});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("@univerjs/ui"),require("@univerjs/core"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("rxjs"),require("@univerjs/engine-render"),require("@univerjs/sheets-numfmt"),require("@univerjs/sheets-ui"),require("@univerjs/design"),require("react"),require("react/jsx-runtime"),require("@univerjs/engine-formula"),require("@univerjs/sheets-formula-ui")):typeof define==`function`&&define.amd?define([`exports`,`@univerjs/ui`,`@univerjs/core`,`@univerjs/sheets`,`@univerjs/sheets-data-validation`,`@univerjs/data-validation`,`rxjs`,`@univerjs/engine-render`,`@univerjs/sheets-numfmt`,`@univerjs/sheets-ui`,`@univerjs/design`,`react`,`react/jsx-runtime`,`@univerjs/engine-formula`,`@univerjs/sheets-formula-ui`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.UniverSheetsDataValidationUi={},e.UniverUi,e.UniverCore,e.UniverSheets,e.UniverSheetsDataValidation,e.UniverDataValidation,e.rxjs,e.UniverEngineRender,e.UniverSheetsNumfmt,e.UniverSheetsUi,e.UniverDesign,e.React,e.React,e.UniverEngineFormula,e.UniverSheetsFormulaUi))})(this,function(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function h(e){"@babel/helpers - typeof";return h=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},h(e)}function g(e,t){if(h(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(h(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function _(e){var t=g(e,`string`);return h(t)==`symbol`?t:t+``}function v(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function y(e,t){return function(n,r){t(n,r,e)}}function b(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}let x=class extends n.Disposable{get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}constructor(e,t){super(),this._univerInstanceService=e,this._sidebarService=t,v(this,`_open$`,new o.BehaviorSubject(!1)),v(this,`open$`,this._open$.pipe((0,o.distinctUntilChanged)())),v(this,`_activeRule`,void 0),v(this,`_activeRule$`,new o.BehaviorSubject(void 0)),v(this,`activeRule$`,this._activeRule$.asObservable()),v(this,`_closeDisposable`,null),v(this,`_focusFormulaEditorActiveRuleSubUnitId`,null),this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET).pipe((0,o.filter)(e=>!e)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(e=>{e.id===`DataValidationPanel`&&(e.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}dispose(){var e;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(e=this._closeDisposable)==null||e.dispose()}open(){this._open$.next(!0)}close(){var e;this._open$.next(!1),(e=this._closeDisposable)==null||e.dispose()}setCloseDisposable(e){this._closeDisposable=(0,n.toDisposable)(()=>{e.dispose(),this._closeDisposable=null})}setActiveRule(e){this._activeRule=e,this._activeRule$.next(e)}setFocusFormulaEditorActiveRuleSubUnitId(e){this._focusFormulaEditorActiveRuleSubUnitId=e}getFocusFormulaEditorActiveRuleSubUnitId(){return this._focusFormulaEditorActiveRuleSubUnitId}};x=b([y(0,n.IUniverInstanceService),y(1,t.ISidebarService)],x);let S=`sheets-data-validation-ui.config`,C={},w=`gray.100`,T=`gray.600`,E=class extends n.Disposable{constructor(e,t,n,r,i,a){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=i,this._sheetsDataValidationValidatorService=a,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(r.VALIDATE_CELL,{handler:async(e,t,r)=>{let i=await e,{row:a,col:o,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,a,o),f=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(i===!1)return r(Promise.resolve(!1));if(!f||f.errorStyle!==n.DataValidationErrorStyle.STOP)return r(Promise.resolve(!0));let p=this._dataValidatorRegistryService.getValidatorItem(f.type);return!p||await this._sheetsDataValidationValidatorService.validatorCell(s,c,a,o)===n.DataValidationStatus.VALID?r(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:p.getRuleFinalError(f,{row:a,col:o,unitId:s,subUnitId:c})},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}}),r(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t(`sheets-data-validation-ui.alert.title`)},id:`reject-input-dialog`,children:{title:e},footer:{title:(0,d.createElement)(u.Button,{variant:`primary`,onClick:()=>this._dialogService.close(`reject-input-dialog`)},this._localeService.t(`sheets-data-validation-ui.alert.ok`))},onClose:()=>{this._dialogService.close(`reject-input-dialog`)}})}};E=b([y(0,(0,n.Inject)(r.SheetInterceptorService)),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(a.DataValidatorRegistryService)),y(3,t.IDialogService),y(4,(0,n.Inject)(n.LocaleService)),y(5,(0,n.Inject)(i.SheetsDataValidationValidatorService))],E);let D=e=>{if(e==null||typeof e==`boolean`)return;if(e===``)return(0,n.dateKit)();if(typeof e==`number`||!Number.isNaN(+e))return(0,n.dateKit)(n.numfmt.format(`yyyy-MM-dd HH:mm:ss`,Number(e)));let t=(0,n.dateKit)(e);if(t.isValid())return t};function O(e,t){if(e===(0,c.getPatternType)(t))return t;switch(e){case`datetime`:return`yyyy-MM-dd hh:mm:ss`;case`date`:return`yyyy-MM-dd`;case`time`:return`HH:mm:ss`}}let k=class extends n.Disposable{get activeDropdown(){return this._activeDropdown}constructor(e,t,n,r,i,a,s,c,l,u){super(),this._univerInstanceService=e,this._dataValidatorRegistryService=t,this._dataValidationModel=n,this._sheetsSelectionsService=r,this._cellDropdownManagerService=i,this._sheetDataValidationModel=a,this._commandService=s,this._editorBridgeService=c,this._injector=l,this._configService=u,v(this,`_activeDropdown`,void 0),v(this,`_activeDropdown$`,new o.Subject),v(this,`_currentPopup`,null),v(this,`activeDropdown$`,this._activeDropdown$.asObservable()),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}_getDropdownByCell(e,t,r,i){let a=e?this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET);if(!a)return;let o=t?a.getSheetBySheetId(t):a.getActiveSheet();if(!o)return;let s=this._dataValidationModel.getRuleByLocation(a.getUnitId(),o.getSheetId(),r,i);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);return c==null?void 0:c.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(e=>{e&&e.every(e=>!(e.primary&&this._getDropdownByCell(e.primary.unitId,e.primary.sheetId,e.primary.actualRow,e.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(e){let{location:o}=e,{row:c,col:u,unitId:d,subUnitId:f,workbook:p,worksheet:m}=o;this._currentPopup&&this._currentPopup.dispose(),this._activeDropdown=e,this._activeDropdown$.next(this._activeDropdown);let h=this._sheetDataValidationModel.getRuleByLocation(d,f,c,u);if(!h)return;let g=this._dataValidatorRegistryService.getValidatorItem(h.type);if(!(g!=null&&g.dropdownType))return;let _,v=async(e,i)=>{var a,o;if(!e)return!0;let _=e,v=m.getCell(c,u),y=_.format(i===`date`?`YYYY-MM-DD 00:00:00`:`YYYY-MM-DD HH:mm:ss`),b=(a=n.numfmt.parseDate(y))==null?void 0:a.v,x=i===`time`?b%1:b,S=p.getStyles().getStyleByCell(v),C=(S==null||(o=S.n)==null?void 0:o.pattern)??``;return h.errorStyle!==n.DataValidationErrorStyle.STOP||await g.validator({value:x,unitId:d,subUnitId:f,row:c,column:u,worksheet:m,workbook:p,interceptValue:y.replace(`Z`,``).replace(`T`,` `),t:n.CellValueType.NUMBER},h)?(await this._commandService.executeCommand(r.SetRangeValuesCommand.id,{unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:x,t:2,p:null,f:null,si:null,s:{n:{pattern:O(i,C)}}}}),await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0):(this._injector.has(E)&&this._injector.get(E).showReject(g.getRuleFinalError(h,{row:c,col:u,unitId:d,subUnitId:f})),!1)},y;switch(g.dropdownType){case a.DataValidatorDropdownType.DATE:{var b;let e=(0,i.getCellValueOrigin)(m.getCellRaw(c,u)),t=D(e),n=!!((b=h.bizInfo)!=null&&b.showTime);y={location:o,type:`datepicker`,props:{showTime:n,onChange:e=>v(e,n?`datetime`:`date`),defaultValue:t,patternType:`date`}};break}case a.DataValidatorDropdownType.TIME:{let e=(0,i.getCellValueOrigin)(m.getCellRaw(c,u));y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`time`),defaultValue:D(e),patternType:`time`}};break}case a.DataValidatorDropdownType.DATETIME:{let e=(0,i.getCellValueOrigin)(m.getCellRaw(c,u));y={location:o,type:`datepicker`,props:{onChange:e=>v(e,`datetime`),defaultValue:D(e),patternType:`datetime`}};break}case a.DataValidatorDropdownType.LIST:case a.DataValidatorDropdownType.MULTIPLE_LIST:{var x,S;let e=g.dropdownType===a.DataValidatorDropdownType.MULTIPLE_LIST,p=async n=>{let i=e?(0,r.serializeListOptions)(n):n[0]??``,a={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:i,p:null,f:null,si:null}};return this._commandService.executeCommand(r.SetRangeValuesCommand.id,a),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!e},v=(h==null?void 0:h.renderMode)===n.DataValidationRenderMode.CUSTOM||(h==null?void 0:h.renderMode)===void 0,b=g.getListWithColor(h,d,f),C=(0,i.getDataValidationCellValue)(m.getCellRaw(c,u));y={location:o,type:`list`,props:{onChange:e=>p(e),options:b.map(e=>({label:e.label,value:e.label,color:v||e.color?e.color||`gray.100`:`transparent`})),onEdit:()=>{this._commandService.executeCommand(j.id,{ruleId:h.uid}),_==null||_.dispose()},defaultValue:C,multiple:e,showEdit:((x=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:x.showEditOnDropdown)??!0,showSearch:((S=this._configService.getConfig(`sheets-data-validation-ui.config`))==null?void 0:S.showSearchOnDropdown)??!0}};break}case a.DataValidatorDropdownType.CASCADE:y={type:`cascader`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e.join(`/`),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u)).split(`/`),options:JSON.parse(h.formula1??`[]`)},location:o};break;case a.DataValidatorDropdownType.COLOR:y={type:`color`,props:{onChange:e=>{let n={unitId:d,subUnitId:f,range:{startColumn:u,endColumn:u,startRow:c,endRow:c},value:{v:e,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(r.SetRangeValuesCommand.id,n),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(l.SetCellEditVisibleOperation.id,{visible:!1,eventType:s.DeviceInputEventType.Keyboard,unitId:d,keycode:t.KeyCode.ESC}),!0},defaultValue:(0,i.getDataValidationCellValue)(m.getCellRaw(c,u))},location:o};break;default:throw Error(`[DataValidationDropdownManagerService]: unknown type!`)}if(_=this._cellDropdownManagerService.showDropdown({...y,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!_)throw Error(`[DataValidationDropdownManagerService]: cannot show dropdown!`);let C=new n.DisposableCollection;C.add(_),C.add({dispose:()=>{var e,t;(e=this._activeDropdown)==null||(t=e.onHide)==null||t.call(e)}}),this._currentPopup=C}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(e,t,r,i,a){let o=this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=o.getSheetBySheetId(t);if(!s)return;let c=this._dataValidationModel.getRuleByLocation(o.getUnitId(),s.getSheetId(),r,i);if(!c)return;let l=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!l||!l.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:o,worksheet:s,row:r,col:i,unitId:e,subUnitId:t},onHide:a})}};k=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(a.DataValidatorRegistryService)),y(2,(0,n.Inject)(i.SheetDataValidationModel)),y(3,(0,n.Inject)(r.SheetsSelectionsService)),y(4,(0,n.Inject)(l.ISheetCellDropdownManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,n.ICommandService),y(7,l.IEditorBridgeService),y(8,(0,n.Inject)(n.Injector)),y(9,n.IConfigService)],k);let A=`DataValidationPanel`,j={id:`data-validation.operation.open-validation-panel`,type:n.CommandType.OPERATION,handler(e,i){if(!i)return!1;let{ruleId:o,isAdd:s}=i,c=e.get(x),l=e.get(a.DataValidationModel),u=e.get(n.IUniverInstanceService),d=e.get(t.ISidebarService),f=(0,r.getSheetCommandTarget)(u);if(!f)return!1;let{unitId:p,subUnitId:m}=f,h=o?l.getRuleById(p,m,o):void 0;c.open(),c.setActiveRule(h&&{unitId:p,subUnitId:m,rule:h});let g=d.open({id:A,header:{title:s?`sheets-data-validation-ui.panel.addTitle`:`sheets-data-validation-ui.panel.title`},children:{label:A},width:312,onClose:()=>c.close()});return c.setCloseDisposable(g),!0}},M={id:`data-validation.operation.close-validation-panel`,type:n.CommandType.OPERATION,handler(e){return e.get(x).close(),!0}},N={id:`data-validation.operation.toggle-validation-panel`,type:n.CommandType.OPERATION,handler(e){let t=e.get(n.ICommandService),r=e.get(x);return r.open(),r.isOpen?t.executeCommand(M.id):t.executeCommand(j.id),!0}},P={type:n.CommandType.OPERATION,id:`sheet.operation.show-data-validation-dropdown`,handler(e,t){if(!t)return!1;let n=e.get(k),{unitId:r,subUnitId:i,row:a,column:o}=t,s=n.activeDropdown,c=s==null?void 0:s.location;return c&&c.unitId===r&&c.subUnitId===i&&c.row===a&&c.col===o||n.showDataValidationDropdown(r,i,a,o),!0}},F={type:n.CommandType.OPERATION,id:`sheet.operation.hide-data-validation-dropdown`,handler(e,t){return t?(e.get(k).hideDropdown(),!0):!1}};function I(e,t){let n=(0,i.createDefaultNewRule)(e);return{...n,...t,uid:n.uid,ranges:n.ranges}}let L={type:n.CommandType.COMMAND,id:`data-validation.command.insert-quick-rule`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),o=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);if(!a||!o.length||!(t!=null&&t.rule))return!1;let s=I(e,t.rule);return e.get(n.ICommandService).syncExecuteCommand(i.AddSheetDataValidationCommand.id,{unitId:a.workbook.getUnitId(),subUnitId:a.worksheet.getSheetId(),rule:s})}},R={type:n.CommandType.COMMAND,id:`data-validation.command.clear-quick-rule`,handler(e,t){var a;let o=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService)),s=e.get(r.SheetsSelectionsService).getCurrentSelections().map(e=>e.range);return!o||!s.length||!(t!=null&&(a=t.types)!=null&&a.length)?!1:e.get(n.ICommandService).syncExecuteCommand(i.ClearRangeDataValidationCommand.id,{unitId:o.workbook.getUnitId(),subUnitId:o.worksheet.getSheetId(),ranges:s,types:t.types})}},z={type:n.CommandType.COMMAND,id:`data-validation.command.addRuleAndOpen`,handler(e,t){let a=(0,r.getSheetCommandTarget)(e.get(n.IUniverInstanceService));if(!a)return!1;let{workbook:o,worksheet:s}=a;if(!e.get(r.SheetsSelectionsService).getCurrentSelections().length)return!1;let c=I(e,t==null?void 0:t.rule),l=e.get(n.ICommandService),u={rule:c,unitId:o.getUnitId(),subUnitId:s.getSheetId()};return l.syncExecuteCommand(i.AddSheetDataValidationCommand.id,u)?(l.syncExecuteCommand(j.id,{ruleId:c.uid,isAdd:!0}),!0):!1}},B=`SHEETS_DATA_VALIDATION_DROPDOWN_PRESETS`;function ee({onChange:e}){let i=(0,t.useDependency)(n.LocaleService),a=[[i.t(`sheets-data-validation-ui.ribbon.presets.yes`),i.t(`sheets-data-validation-ui.ribbon.presets.no`)],[i.t(`sheets-data-validation-ui.ribbon.presets.notStarted`),i.t(`sheets-data-validation-ui.ribbon.presets.inProgress`),i.t(`sheets-data-validation-ui.ribbon.presets.completed`)],[`A`,`B`,`C`]];return(0,f.jsxs)(`div`,{className:`univer-box-border univer-w-[360px]`,children:[(0,f.jsx)(`div`,{className:`univer-px-2 univer-text-sm univer-font-semibold`,children:i.t(`sheets-data-validation-ui.ribbon.dropdownPresetTitle`)}),(0,f.jsx)(`div`,{className:`univer-mt-2 univer-grid univer-grid-cols-3 univer-gap-1.5`,children:a.map(t=>(0,f.jsx)(`button`,{type:`button`,"aria-label":t.join(` / `),className:`univer-flex univer-min-h-20 univer-cursor-pointer univer-flex-col univer-items-start univer-gap-1.5 univer-rounded-md univer-border-0 univer-bg-gray-50 univer-p-3 univer-text-left univer-text-sm univer-leading-5 univer-text-gray-900 univer-transition-colors hover:univer-bg-gray-100 focus-visible:univer-outline-none focus-visible:univer-ring-2 focus-visible:univer-ring-primary-600 focus-visible:univer-ring-offset-0 dark:!univer-bg-gray-800 dark:!univer-text-gray-0 dark:hover:!univer-bg-gray-700`,onClick:()=>e((0,r.serializeListOptions)(t)),children:t.map(e=>(0,f.jsx)(`span`,{className:`univer-w-full univer-break-words`,children:e},e))},t.join(`\0`)))}),(0,f.jsx)(u.Separator,{className:`univer-mt-2`})]})}let V=`sheet.menu.data-validation`,H=`sheet.menu.quick-dropdown`,U=`sheet.menu.quick-date`,te={type:n.DataValidationType.CHECKBOX,operator:void 0,formula1:void 0,formula2:void 0},W={type:n.DataValidationType.DATE,operator:void 0,formula1:void 0,formula2:void 0},ne={...W,bizInfo:{showTime:!0}};function re(e){return{type:n.DataValidationType.LIST,operator:void 0,formula1:e,formula2:``,renderMode:n.DataValidationRenderMode.CUSTOM}}function ie(e){return e===void 0?{}:{rule:re(String(e))}}function ae(e){return{hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function G(e){return{id:V,type:t.MenuItemType.SUBITEMS,icon:`DataValidationIcon`,tooltip:`sheets-data-validation-ui.title`,hidden$:(0,t.getMenuHiddenObservable)(e,n.UniverInstanceType.UNIVER_SHEET),disabled$:(0,l.getCurrentRangeDisable$)(e,{workbookTypes:[r.WorkbookEditablePermission],worksheetTypes:[r.WorksheetSetCellStylePermission,r.WorksheetEditPermission],rangeTypes:[r.RangeProtectionPermissionEditPoint]})}}function oe(e){return{id:L.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`CheckboxIcon`,tooltip:`sheets-data-validation-ui.checkbox.title`,params:{rule:te},selectionsCommandId:L.id,selections:[{label:`sheets-data-validation-ui.ribbon.setCheckbox`,value:n.DataValidationType.CHECKBOX,params:{rule:te}},{label:`sheets-data-validation-ui.ribbon.clearCheckbox`,id:R.id,value:n.DataValidationType.CHECKBOX,params:{types:[n.DataValidationType.CHECKBOX]}}],...ae(e)}}function K(e){let i=e.get(n.LocaleService),a=(0,r.serializeListOptions)([i.t(`sheets-data-validation-ui.ribbon.presets.option1`),i.t(`sheets-data-validation-ui.ribbon.presets.option2`)]);return{id:H,type:t.MenuItemType.SUBITEMS,icon:`DropdownListIcon`,tooltip:`sheets-data-validation-ui.list.title`,selectionsCommandId:L.id,selections:[{label:{name:B,hoverable:!1,selectable:!1},params:ie},{id:z.id,label:`sheets-data-validation-ui.ribbon.editDropdown`,value:a,params:{rule:re(a)}},{id:R.id,label:`sheets-data-validation-ui.ribbon.clearDropdown`,value:n.DataValidationType.LIST,params:{types:[n.DataValidationType.LIST,n.DataValidationType.LIST_MULTIPLE]}}],...ae(e)}}function se(e){return{id:U,commandId:L.id,type:t.MenuItemType.BUTTON_SELECTOR,icon:`DatePickerIcon`,tooltip:`sheets-data-validation-ui.date.title`,params:{rule:W},selectionsCommandId:L.id,selections:[{label:`sheets-data-validation-ui.date.title`,value:n.DataValidationType.DATE,params:{rule:W}},{label:`sheets-data-validation-ui.ribbon.dateTime`,value:n.DataValidationType.DATE,params:{rule:ne}},{id:z.id,label:`sheets-data-validation-ui.list.edit`,value:n.DataValidationType.DATE,params:{rule:W}},{id:R.id,label:`sheets-data-validation-ui.panel.removeRule`,value:n.DataValidationType.DATE,params:{types:[n.DataValidationType.DATE]}}],...ae(e)}}function ce(){return{id:j.id,title:`sheets-data-validation-ui.panel.title`,type:t.MenuItemType.BUTTON}}function le(){return{id:z.id,title:`sheets-data-validation-ui.panel.add`,type:t.MenuItemType.BUTTON}}let ue={[t.RibbonInsertGroup.CELL]:{[L.id]:{order:0,menuItemFactory:oe},[H]:{order:1,menuItemFactory:K},[U]:{order:2,menuItemFactory:se}},[t.RibbonDataGroup.RULES]:{[V]:{order:0,gridLayout:{row:1,column:1,showLabel:!0},menuItemFactory:G,[j.id]:{order:0,menuItemFactory:ce},[z.id]:{order:1,menuItemFactory:le}}}};var de=`@univerjs/sheets-data-validation-ui`,fe=`1.0.0-beta.2`;function q({ref:e,...t}){let{preserveStrokeWidth:n,icon:r,id:i,className:a,extend:o,...s}=t,c=`univerjs-icon univerjs-icon-${i} ${a||``}`.trim(),l=`_${(0,d.useId)()}`,u=(0,d.useRef)(null);return(0,d.useImperativeHandle)(e,()=>u.current),(0,d.useLayoutEffect)(()=>{if(!(!n||!u.current||u.current.localName!==r.tag))return ge(u.current)},[n,r]),pe(r,`${i}`,{defIds:r.defIds,idSuffix:l},{ref:u,className:c,...s},o)}function pe(e,t,n,r,i){return(0,d.createElement)(e.tag,{key:t,...me(e,n,i),...r},(he(e,n).children||[]).map((r,a)=>pe(r,`${t}-${e.tag}-${a}`,n,void 0,i)))}function me(e,t,n){let r={...e.attrs};n!=null&&n.colorChannel1&&r.fill===`colorChannel1`&&(r.fill=n.colorChannel1),n!=null&&n.colorChannel1&&r.stroke===`colorChannel1`&&(r.stroke=n.colorChannel1),e.tag===`mask`&&r.id&&(r.id+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{e===`mask`&&typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});let{defIds:i}=t;return!i||i.length===0?r:(e.tag===`use`&&r[`xlink:href`]&&(r[`xlink:href`]+=t.idSuffix),Object.entries(r).forEach(([e,n])=>{typeof n==`string`&&(r[e]=n.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))}),r)}function he(e,t){var n;let{defIds:r}=t;return!r||r.length===0?e:e.tag===`defs`&&(n=e.children)!=null&&n.length?{...e,children:e.children.map(e=>typeof e.attrs.id==`string`&&r&&r.includes(e.attrs.id)?{...e,attrs:{...e.attrs,id:e.attrs.id+t.idSuffix}}:e)}:e}function ge(e){let t=e.viewBox.baseVal,n=Math.max(t.width,t.height);if(!Number.isFinite(n)||n<=0||t.width<=0||t.height<=0)return()=>void 0;let r=16/n,i=Array.from(e.querySelectorAll(`circle, ellipse, line, path, polygon, polyline, rect, text, textPath, tspan, use`)).flatMap(e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.strokeWidth);return t.stroke===`none`||Number.parseFloat(t.strokeOpacity)===0||t.vectorEffect===`non-scaling-stroke`||!Number.isFinite(n)||n<=0?[]:[{element:e,hadStyleAttribute:e.hasAttribute(`style`),originalStrokeWidth:n,strokeWidth:_e(e.style,`stroke-width`)}]}).map(e=>({appliedStrokeWidth:null,element:e.element,hadStyleAttribute:e.hadStyleAttribute,isReleased:!1,originalStrokeWidth:e.originalStrokeWidth,strokeWidth:e.strokeWidth}));if(i.length===0)return()=>void 0;let a=(e,n)=>{if(t.width<=0||t.height<=0||e<=0||n<=0)return;let a=Math.min(e/t.width,n/t.height);!Number.isFinite(a)||a<=0||i.forEach(e=>{if(e.isReleased)return;if(e.appliedStrokeWidth!==null&&(e.element.style.getPropertyValue(`stroke-width`)!==e.appliedStrokeWidth||e.element.style.getPropertyPriority(`stroke-width`)!==e.strokeWidth.priority)){e.appliedStrokeWidth=null,e.isReleased=!0;return}let t=e.originalStrokeWidth*r/a,n=`${Number(t.toFixed(12))}px`;e.element.style.setProperty(`stroke-width`,n,e.strokeWidth.priority),e.appliedStrokeWidth=n})},o=e.getBoundingClientRect();a(o.width,o.height);let s=typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{if(t.some(t=>t.target===e)){let t=e.getBoundingClientRect();a(t.width,t.height)}});return s==null||s.observe(e),()=>{s==null||s.disconnect(),i.forEach(e=>{e.appliedStrokeWidth!==null&&(ve(e.element.style,`stroke-width`,e.appliedStrokeWidth,e.strokeWidth.priority,e.strokeWidth),!e.hadStyleAttribute&&e.element.style.length===0&&e.element.removeAttribute(`style`))})}}function _e(e,t){return{priority:e.getPropertyPriority(t),value:e.getPropertyValue(t)}}function ve(e,t,n,r,i){e.getPropertyValue(t)===n&&e.getPropertyPriority(t)===r&&(i.value?e.setProperty(t,i.value,i.priority):e.removeProperty(t))}q.displayName=`UniverIcon`;let ye={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:13,x:1.5,y:1.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 8L6.8 10.3L11.5 5.6`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},be=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`checkbox-icon`,ref:t,icon:ye}))});be.displayName=`CheckboxIcon`;let xe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 17 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M1.4917 3.07803C1.4917 2.19437 2.20804 1.47803 3.0917 1.47803H5.6917C6.57536 1.47803 7.2917 2.19437 7.2917 3.07803V5.67803C7.2917 6.56168 6.57535 7.27803 5.6917 7.27803H3.0917C2.20804 7.27803 1.4917 6.56168 1.4917 5.67803V3.07803ZM3.0917 2.67803C2.87078 2.67803 2.6917 2.85711 2.6917 3.07803V5.67803C2.6917 5.89894 2.87079 6.07803 3.0917 6.07803H5.6917C5.91261 6.07803 6.0917 5.89894 6.0917 5.67803V3.07803C6.0917 2.85711 5.91261 2.67803 5.6917 2.67803H3.0917Z`,fillRule:`evenodd`,clipRule:`evenodd`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.6175 2.45279C14.8518 2.68711 14.8518 3.06701 14.6175 3.30132L11.6151 6.30365C11.3957 6.52307 11.0451 6.53897 10.8067 6.34031L8.80915 4.67566C8.55458 4.46352 8.52019 4.08518 8.73233 3.83062C8.94447 3.57605 9.32281 3.54166 9.57737 3.7538L11.154 5.06767L13.769 2.45278C14.0033 2.21847 14.3832 2.21848 14.6175 2.45279Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M14.1175 9.19746C14.3518 9.43178 14.3518 9.81168 14.1175 10.046L12.5418 11.6217L14.1175 13.1975C14.3518 13.4318 14.3518 13.8117 14.1175 14.046C13.8832 14.2803 13.5033 14.2803 13.269 14.046L11.6933 12.4703L10.1175 14.046C9.88321 14.2803 9.50331 14.2803 9.269 14.046C9.03468 13.8117 9.03468 13.4318 9.269 13.1975L10.8447 11.6217L9.269 10.046C9.03468 9.81168 9.03468 9.43178 9.269 9.19746C9.50331 8.96315 9.88321 8.96315 10.1175 9.19746L11.6933 10.7732L13.269 9.19746C13.5033 8.96315 13.8832 8.96315 14.1175 9.19746Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M3.0917 8.72168C2.20804 8.72168 1.4917 9.43802 1.4917 10.3217V12.9217C1.4917 13.8053 2.20804 14.5217 3.0917 14.5217H5.6917C6.57535 14.5217 7.2917 13.8053 7.2917 12.9217V10.3217C7.2917 9.43802 6.57536 8.72168 5.6917 8.72168H3.0917ZM2.6917 10.3217C2.6917 10.1008 2.87078 9.92168 3.0917 9.92168H5.6917C5.91261 9.92168 6.0917 10.1008 6.0917 10.3217V12.9217C6.0917 13.1426 5.91261 13.3217 5.6917 13.3217H3.0917C2.87079 13.3217 2.6917 13.1426 2.6917 12.9217V10.3217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Se=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`data-validation-icon`,ref:t,icon:xe}))});Se.displayName=`DataValidationIcon`;let Ce={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`rect`,attrs:{width:13,height:12,x:1.5,y:2.5,stroke:`currentColor`,rx:1.5,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M1.5 6.5H14.5M5 1.5V4M11 1.5V4`,strokeLinecap:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M4.5 9H6M8 9H9.5M11.5 9H12M4.5 12H6M8 12H9.5`,strokeLinecap:`round`,strokeWidth:1.2}}]},we=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`date-picker-icon`,ref:t,icon:Ce}))});we.displayName=`DatePickerIcon`;let Te={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M5.3313 1.4667C5.3313 1.13533 5.59993 0.866699 5.9313 0.866699H10.069C10.4004 0.866699 10.669 1.13533 10.669 1.4667C10.669 1.79807 10.4004 2.0667 10.069 2.0667H5.9313C5.59993 2.0667 5.3313 1.79807 5.3313 1.4667Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M1.09985 3.64443C1.09985 3.31306 1.36848 3.04443 1.69985 3.04443H14.2999C14.6312 3.04443 14.8999 3.31306 14.8999 3.64443C14.8999 3.9758 14.6312 4.24443 14.2999 4.24443H1.69985C1.36848 4.24443 1.09985 3.9758 1.09985 3.64443Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M6.12398 8.30171C6.35829 8.0674 6.73819 8.0674 6.97251 8.30171L8.00007 9.32928L9.02764 8.30171C9.26195 8.0674 9.64185 8.0674 9.87617 8.30171C10.1105 8.53603 10.1105 8.91593 9.87617 9.15024L8.8486 10.1778L9.87617 11.2054C10.1105 11.4397 10.1105 11.8196 9.87617 12.0539C9.64185 12.2882 9.26195 12.2882 9.02764 12.0539L8.00007 11.0263L6.97251 12.0539C6.73819 12.2882 6.35829 12.2882 6.12398 12.0539C5.88966 11.8196 5.88966 11.4397 6.12398 11.2054L7.15154 10.1778L6.12398 9.15024C5.88966 8.91593 5.88966 8.53603 6.12398 8.30171Z`}},{tag:`path`,attrs:{fill:`currentColor`,d:`M4.75332 5.22217C3.86966 5.22217 3.15332 5.93851 3.15332 6.82217V12.5331C3.15332 13.9691 4.31738 15.1332 5.75332 15.1332H10.2465C11.6825 15.1332 12.8465 13.9691 12.8465 12.5331V6.82217C12.8465 5.93851 12.1302 5.22217 11.2465 5.22217H4.75332ZM4.35332 6.82217C4.35332 6.60125 4.53241 6.42217 4.75332 6.42217H11.2465C11.4674 6.42217 11.6465 6.60125 11.6465 6.82217V12.5331C11.6465 13.3063 11.0197 13.9332 10.2465 13.9332H5.75332C4.98012 13.9332 4.35332 13.3063 4.35332 12.5331V6.82217Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Ee=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`delete-icon`,ref:t,icon:Te}))});Ee.displayName=`DeleteIcon`;let De={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{stroke:`currentColor`,d:`M8 5.5H2C1.72386 5.5 1.5 5.27614 1.5 5V2C1.5 1.72386 1.72386 1.5 2 1.5H14C14.2761 1.5 14.5 1.72386 14.5 2V5C14.5 5.27614 14.2761 5.5 14 5.5H13`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M8.5 3.5L10.5 5.5L12.5 3.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M2 7.5H14C14.2761 7.5 14.5 7.72386 14.5 8V14C14.5 14.2761 14.2761 14.5 14 14.5H2C1.72386 14.5 1.5 14.2761 1.5 14V8C1.5 7.72386 1.72386 7.5 2 7.5Z`,strokeLinejoin:`round`,strokeWidth:1.2}},{tag:`path`,attrs:{stroke:`currentColor`,d:`M3.5 9.5H9.5M3.5 12.5H7.5`,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1.2}}]},Oe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`dropdown-list-icon`,ref:t,icon:De}))});Oe.displayName=`DropdownListIcon`;let ke={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 20 20`,width:`1em`,height:`1em`},children:[{tag:`circle`,attrs:{cx:7,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:5,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:10,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:7,cy:15,r:1.1,fill:`currentColor`}},{tag:`circle`,attrs:{cx:13,cy:15,r:1.1,fill:`currentColor`}}]},Ae=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`grip-vertical-icon`,ref:t,icon:ke}))});Ae.displayName=`GripVerticalIcon`;let je={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M8.6 1.99991C8.60001 1.66854 8.33138 1.39991 8.00001 1.3999C7.66864 1.3999 7.40001 1.66853 7.4 1.9999L7.39996 7.3999H1.9999C1.66853 7.3999 1.3999 7.66853 1.3999 7.9999C1.3999 8.33127 1.66853 8.5999 1.9999 8.5999H7.39995L7.3999 13.9999C7.3999 14.3313 7.66853 14.5999 7.9999 14.5999C8.33127 14.5999 8.5999 14.3313 8.5999 13.9999L8.59995 8.5999H13.9999C14.3313 8.5999 14.5999 8.33127 14.5999 7.9999C14.5999 7.66853 14.3313 7.3999 13.9999 7.3999H8.59996L8.6 1.99991Z`}}]},Me=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`increase-icon`,ref:t,icon:je}))});Me.displayName=`IncreaseIcon`;let Ne={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Pe=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`more-down-icon`,ref:t,icon:Ne}))});Pe.displayName=`MoreDownIcon`;let Fe={tag:`svg`,attrs:{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 16 16`,width:`1em`,height:`1em`},children:[{tag:`path`,attrs:{fill:`currentColor`,d:`M4.64645 9.85355C4.45118 9.65829 4.45118 9.34171 4.64645 9.14645L7.64645 6.14645C7.84171 5.95118 8.15829 5.95118 8.35355 6.14645L11.3536 9.14645C11.5488 9.34171 11.5488 9.65829 11.3536 9.85355C11.1583 10.0488 10.8417 10.0488 10.6464 9.85355L8 7.20711L5.35355 9.85355C5.15829 10.0488 4.84171 10.0488 4.64645 9.85355Z`,fillRule:`evenodd`,clipRule:`evenodd`}}]},Ie=(0,d.forwardRef)(function(e,t){return(0,d.createElement)(q,Object.assign({},e,{id:`more-up-icon`,ref:t,icon:Fe}))});Ie.displayName=`MoreUpIcon`;function Le(e){let r=(0,t.useDependency)(n.LocaleService),i=(0,t.useDependency)(t.ComponentManager),{value:a,onChange:o,extraComponent:s}=e,[c,l]=(0,d.useState)(!1),p=s?i.get(s):null;return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsxs)(`div`,{className:`univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-gray-0`,onClick:()=>l(!c),children:[r.t(`sheets-data-validation-ui.panel.options`),c?(0,f.jsx)(Ie,{className:`univer-ml-1`}):(0,f.jsx)(Pe,{className:`univer-ml-1`})]}),c&&(0,f.jsxs)(f.Fragment,{children:[p?(0,f.jsx)(p,{value:a,onChange:o}):null,(0,f.jsx)(u.FormLayout,{label:r.t(`sheets-data-validation-ui.panel.invalid`),children:(0,f.jsxs)(u.RadioGroup,{value:`${a.errorStyle??n.DataValidationErrorStyle.WARNING}`,onChange:e=>o({...a,errorStyle:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.WARNING}`,children:r.t(`sheets-data-validation-ui.panel.showWarning`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationErrorStyle.STOP}`,children:r.t(`sheets-data-validation-ui.panel.rejectInput`)})]})}),(0,f.jsx)(u.FormLayout,{label:r.t(`sheets-data-validation-ui.panel.messageInfo`),children:(0,f.jsx)(u.Checkbox,{checked:a.showErrorMessage,onChange:()=>o({...a,showErrorMessage:!a.showErrorMessage}),children:r.t(`sheets-data-validation-ui.panel.showInfo`)})}),a.showErrorMessage?(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Input,{value:a.error,onChange:e=>o({...a,error:e})})}):null]})]})}let Re=e=>(0,n.debounce)(async(t,n,r,i)=>{let a=await e.executeCommand(t,n,r);i==null||i(a)},1e3);function ze(e,t,r){var i;if(t){var a;return((a=e.getUnit(t))==null||(a=a.getSheetBySheetName(r))==null?void 0:a.getSheetId())||``}return((i=e.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET))==null||(i=i.getSheetBySheetName(r))==null?void 0:i.getSheetId())||``}function Be(){let e=(0,t.useDependency)(x),{unitId:n,subUnitId:r,rule:i}=(0,t.useObservable)(e.activeRule$,e.activeRule)||{};return!n||!r||!i?null:(0,f.jsx)(Ve,{activeRuleInfo:{unitId:n,subUnitId:r,rule:i}})}function Ve(e){var s;let[c,l]=(0,d.useState)(0),h=(0,t.useDependency)(x),{unitId:g,subUnitId:_,rule:v}=e.activeRuleInfo,y=v.uid,b=(0,t.useDependency)(a.DataValidatorRegistryService),S=(0,t.useDependency)(n.IUniverInstanceService),C=(0,t.useDependency)(t.ComponentManager),w=(0,t.useDependency)(n.ICommandService),T=(0,t.useDependency)(a.DataValidationModel),E=(0,t.useDependency)(n.LocaleService),D=(0,t.useObservable)(()=>S.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),O=(0,t.useObservable)(()=>(D==null?void 0:D.activeSheet$)??(0,o.of)(null),void 0,void 0,[]),[k,A]=(0,d.useState)(v),j=b.getValidatorItem(k.type),[M,N]=(0,d.useState)(!1),P=b.getValidatorsByScope(a.DataValidatorRegistryScope.SHEET),[F,I]=(0,d.useState)(()=>k.ranges.map(e=>({unitId:``,sheetId:``,range:e}))),L=(0,d.useMemo)(()=>Re(w),[w]),[R,z]=(0,d.useState)(!1),[B,ee]=(0,d.useState)(!1),V=(0,d.useRef)(null),H=(0,t.useDependency)(r.SheetsSelectionsService);(0,d.useEffect)(()=>()=>{let e=H.getCurrentLastSelection();e&&H.setSelections([e])},[H]),(0,d.useEffect)(()=>{let e,t=w.onCommandExecuted(t=>{(t.id===n.UndoCommand.id||t.id===n.RedoCommand.id)&&(e!==void 0&&clearTimeout(e),e=setTimeout(()=>{let e=T.getRuleById(g,_,y);l(e=>e+1),e&&(A(e),I(e.ranges.map(e=>({unitId:``,sheetId:``,range:e}))))},20))});return()=>{t.dispose(),e!==void 0&&clearTimeout(e)}},[w,T,y,_,g]);let U=(0,t.useEvent)(e=>{let t=e.split(`,`).filter(Boolean).map(p.deserializeRangeWithSheet).map(e=>{let t=e.sheetName;if(t){let n=ze(S,e.unitId,t);return{...e,sheetId:n}}return{...e,sheetId:``}});if((0,n.isUnitRangesEqual)(t,F))return;I(t);let r=t.filter(e=>(!e.unitId||e.unitId===g)&&(!e.sheetId||e.sheetId===_)).map(e=>e.range);if(A({...k,ranges:r}),r.length===0)return;let a={unitId:g,subUnitId:_,ruleId:y,ranges:r};L(i.UpdateSheetDataValidationRangeCommand.id,a)}),te=(0,d.useMemo)(()=>F.map(e=>(0,p.serializeRange)(e.range)).join(`,`),[]);if(!j)return null;let W=j.operators,ne=j.operatorNames,re=k.operator?a.TWO_FORMULA_OPERATOR_COUNT.includes(k.operator):!1,ie=()=>{(O==null?void 0:O.getSheetId())!==_&&w.syncExecuteCommand(r.SetWorksheetActiveOperation.id,{unitId:g,subUnitId:_})},ae=()=>{var e;if((e=V.current)!=null&&(e=e.editor)!=null&&e.isFocus()){var t;U((t=V.current)==null?void 0:t.getValue())}!k.ranges.length||R||(j.validatorFormula(k,g,_).success?h.setActiveRule(null):N(!0),ie())},G=e=>{if((0,n.shallowEqual)(e,(0,a.getRuleSetting)(k)))return;A({...k,...e});let t={unitId:g,subUnitId:_,ruleId:y,setting:e};L(i.UpdateSheetDataValidationSettingCommand.id,t,void 0)},oe=async()=>{await w.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:y,unitId:g,subUnitId:_}),h.setActiveRule(null),ie()},K={type:k.type,operator:k.operator,formula1:k.formula1,formula2:k.formula2,allowBlank:k.allowBlank},se=e=>{let t=b.getValidatorItem(e);if(!t)return;let n=t.operators,r=T.getRuleById(g,_,y),o=e===(r==null?void 0:r.type)||e.includes(`list`)&&r!=null&&r.type.includes(`list`)?{...r,type:e}:{...k,type:e,operator:n[0],formula1:void 0,formula2:void 0};A(o),w.executeCommand(i.UpdateSheetDataValidationSettingCommand.id,{unitId:g,subUnitId:_,ruleId:k.uid,setting:(0,a.getRuleSetting)(o)})},ce=C.get(j.formulaInput),le=(0,a.getRuleOptions)(k),ue=e=>{(0,n.shallowEqual)(e,(0,a.getRuleOptions)(k))||(A({...k,...e}),L(i.UpdateSheetDataValidationOptionsCommand.id,{unitId:g,subUnitId:_,ruleId:y,options:e}))},de=W.length&&!k.operator;return(0,f.jsxs)(`div`,{"data-u-comp":`data-validation-detail`,className:`univer-py-2`,children:[(0,f.jsx)(u.FormLayout,{label:E.t(`sheets-data-validation-ui.panel.range`),error:!k.ranges.length||R?E.t(`sheets-data-validation-ui.panel.rangeError`):``,children:(0,f.jsx)(m.RangeSelector,{selectorRef:V,unitId:g,subUnitId:_,initialValue:te,onChange:(e,t)=>{var n;!B&&(n=V.current)!=null&&n.verify()&&U(t)},onFocusChange:(e,t)=>{var n;ee(e),!e&&t&&(n=V.current)!=null&&n.verify()&&U(t)},onVerify:e=>z(!e)})}),(0,f.jsx)(u.FormLayout,{label:E.t(`sheets-data-validation-ui.panel.type`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:k.type,options:P==null||(s=P.sort((e,t)=>e.order-t.order))==null?void 0:s.map(e=>({label:E.t(e.title),value:e.id})),onChange:se})}),W!=null&&W.length?(0,f.jsx)(u.FormLayout,{label:E.t(`sheets-data-validation-ui.panel.operator`),children:(0,f.jsx)(u.Select,{className:`univer-w-full`,value:`${k.operator}`,options:[{value:``,label:E.t(`sheets-data-validation-ui.operators.legal`)},...W.map((e,t)=>({value:`${e}`,label:ne[t]}))],onChange:e=>{G({...K,operator:e})}})}):null,ce&&!de?(0,f.jsx)(ce,{isTwoFormula:re,value:{formula1:k.formula1,formula2:k.formula2},onChange:e=>{G({...K,...e})},showError:M,validResult:j.validatorFormula(k,g,_),unitId:g,subUnitId:_,ruleId:y},c+k.type):null,(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:k.allowBlank??!0,onChange:()=>G({...K,allowBlank:!(k.allowBlank??!0)}),children:E.t(`sheets-data-validation-ui.panel.allowBlank`)})}),(0,f.jsx)(Le,{value:le,onChange:ue,extraComponent:j.optionsInput}),(0,f.jsxs)(`div`,{className:`univer-mt-5 univer-flex univer-flex-row univer-justify-end`,children:[(0,f.jsx)(u.Button,{className:`univer-ml-3`,onClick:oe,children:E.t(`sheets-data-validation-ui.panel.removeRule`)}),(0,f.jsx)(u.Button,{className:`univer-ml-3`,variant:`primary`,onClick:ae,children:E.t(`sheets-data-validation-ui.panel.done`)})]})]})}let He=e=>{let{rule:r,onClick:o,unitId:s,subUnitId:c,disable:m}=e,h=(0,t.useDependency)(a.DataValidatorRegistryService),g=(0,t.useDependency)(n.ICommandService),_=(0,t.useDependency)(l.IMarkSelectionService),v=h.getValidatorItem(r.type),y=(0,d.useRef)(void 0),[b,x]=(0,d.useState)(!1),S=(0,t.useDependency)(n.ThemeService),C=(0,d.useMemo)(()=>{let e=S.getColorFromTheme(`primary.600`),t=S.getColorFromTheme(`loop-color.2`),r=S.getColorFromTheme(t)??e,i=new n.ColorKit(r).toRgb();return{fill:`rgba(${i.r}, ${i.g}, ${i.b}, 0.1)`,stroke:r}},[(0,t.useObservable)(S.currentTheme$)]);return(0,d.useEffect)(()=>()=>{if(y.current){var e;(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)})}},[_]),(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-bg-secondary univer-relative univer--mx-2 univer-box-border univer-flex univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden univer-rounded-md univer-p-2 univer-pr-9 rtl:univer-pl-9 rtl:univer-pr-2`,{"hover:univer-bg-gray-50 dark:hover:!univer-bg-gray-700":!m,"univer-opacity-50":m}),onClick:o,onMouseEnter:()=>{m||(x(!0),y.current=r.ranges.map(e=>_.addShape({range:e,style:C,primary:null})))},onMouseLeave:()=>{var e;x(!1),(e=y.current)==null||e.forEach(e=>{e&&_.removeShape(e)}),y.current=void 0},children:[(0,f.jsx)(`div`,{className:`univer-truncate univer-text-sm univer-font-medium univer-leading-[22px] univer-text-gray-900 dark:!univer-text-gray-0`,children:v==null?void 0:v.generateRuleName(r)}),(0,f.jsx)(`div`,{className:`univer-text-secondary univer-truncate univer-text-xs univer-leading-[18px] dark:!univer-text-gray-300`,children:r.ranges.map(e=>(0,p.serializeRange)(e)).join(`,`)}),b&&(0,f.jsx)(`div`,{className:`univer-absolute univer-right-2 univer-top-[19px] univer-flex univer-size-5 univer-items-center univer-justify-center univer-rounded hover:univer-bg-gray-200 rtl:univer-left-2 rtl:univer-right-auto dark:!univer-text-gray-300 dark:hover:!univer-bg-gray-700`,onClick:e=>{g.executeCommand(i.RemoveSheetDataValidationCommand.id,{ruleId:r.uid,unitId:s,subUnitId:c}),e.stopPropagation()},children:(0,f.jsx)(Ee,{})})]})};function Ue(e){let a=(0,t.useDependency)(i.SheetDataValidationModel),s=(0,t.useDependency)(n.IUniverInstanceService),c=(0,t.useDependency)(n.ICommandService),l=(0,t.useDependency)(n.Injector),d=(0,t.useDependency)(x),p=(0,t.useDependency)(n.LocaleService),{workbook:m}=e,h=(0,t.useObservable)(m.activeSheet$,void 0,!0),g=m.getUnitId(),_=h==null?void 0:h.getSheetId(),v=(0,t.useObservable)(()=>a.ruleChange$.pipe((0,o.filter)(e=>e.unitId===g&&e.subUnitId===_),(0,o.map)(()=>a.getRules(g,_)),(0,o.startWith)(a.getRules(g,_))),[],!1,[a,_,g]),y=async()=>{let e=(0,i.createDefaultNewRule)(l),t={unitId:g,subUnitId:_,rule:e};await c.executeCommand(i.AddSheetDataValidationCommand.id,t),d.setActiveRule({unitId:g,subUnitId:_,rule:e})},b=()=>{c.executeCommand(i.RemoveSheetAllDataValidationCommand.id,{unitId:g,subUnitId:_})},S=(e=>{let t=s.getCurrentUnitOfType(n.UniverInstanceType.UNIVER_SHEET),i=t.getActiveSheet(),a=t.getUnitId(),o=i.getSheetId();return e.map(e=>(0,r.checkRangesEditablePermission)(l,a,o,e.ranges)?{...e}:{...e,disable:!0})})(v),C=S==null?void 0:S.some(e=>e.disable);return(0,f.jsxs)(`div`,{className:`univer-pb-4`,children:[S==null?void 0:S.map(e=>(0,f.jsx)(He,{unitId:g,subUnitId:_,onClick:()=>{e.disable||d.setActiveRule({unitId:g,subUnitId:_,rule:e})},rule:e,disable:e.disable??!1},e.uid)),(0,f.jsxs)(`div`,{className:`univer-mt-4 univer-flex univer-flex-row univer-justify-end univer-gap-2`,children:[v.length&&!C?(0,f.jsx)(u.Button,{onClick:b,children:p.t(`sheets-data-validation-ui.panel.removeAll`)}):null,(0,f.jsx)(u.Button,{variant:`primary`,onClick:y,children:p.t(`sheets-data-validation-ui.panel.add`)})]})]})}let We=()=>{let e=(0,t.useDependency)(x),r=(0,t.useObservable)(e.activeRule$,e.activeRule),i=(0,t.useDependency)(n.IUniverInstanceService),a=(0,t.useObservable)(()=>i.getCurrentTypeOfUnit$(n.UniverInstanceType.UNIVER_SHEET),void 0,void 0,[]),s=(0,t.useObservable)(()=>(a==null?void 0:a.activeSheet$)??(0,o.of)(null),void 0,void 0,[]);return!a||!s?null:r&&(r.subUnitId===s.getSheetId()||r.subUnitId===e.getFocusFormulaEditorActiveRuleSubUnitId())?(0,f.jsx)(Be,{},r.rule.uid):(0,f.jsx)(Ue,{workbook:a})};function Ge(e){var r;let{value:i,onChange:a}=e,o=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:(r=i.bizInfo)==null?void 0:r.showTime,onChange:e=>{a({...i,bizInfo:{...i.bizInfo,showTime:e}})},children:o.t(`sheets-data-validation-ui.showTime.label`)})})}Ge.componentKey=`DATE_SHOW_TIME_OPTION`;let Ke=e=>{let{isTwoFormula:r=!1,value:i,onChange:a,showError:o,validResult:s}=e,c=(0,t.useDependency)(n.LocaleService),l=o?s==null?void 0:s.formula1:``,d=o?s==null?void 0:s.formula2:``;return r?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({...i,formula1:e})}})}),(0,f.jsx)(`div`,{className:`-univer-mt-2 univer-mb-1 univer-text-sm univer-text-gray-400`,children:c.t(`sheets-data-validation-ui.panel.formulaAnd`)}),(0,f.jsx)(u.FormLayout,{error:d,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula2,onChange:e=>{a==null||a({...i,formula2:e})}})})]}):(0,f.jsx)(u.FormLayout,{error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:c.t(`sheets-data-validation-ui.panel.formulaPlaceholder`),value:i==null?void 0:i.formula1,onChange:e=>{a==null||a({formula1:e})}})})};function qe(e){let{value:r,onChange:i,showError:a,validResult:o}=e,s=(0,t.useDependency)(n.LocaleService),c=a?o==null?void 0:o.formula1:``,l=a?o==null?void 0:o.formula2:``,[p,m]=(0,d.useState)((r==null?void 0:r.formula1)!==void 0||(r==null?void 0:r.formula2)!==void 0);return(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{children:(0,f.jsx)(u.Checkbox,{checked:p,onChange:e=>{e?m(!0):(m(!1),i==null||i({...r,formula1:void 0,formula2:void 0}))},children:s.t(`sheets-data-validation-ui.checkbox.tips`)})}),p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.checked`),error:c,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula1,onChange:e=>{i==null||i({...r,formula1:e||void 0})}})}):null,p?(0,f.jsx)(u.FormLayout,{label:s.t(`sheets-data-validation-ui.checkbox.unchecked`),error:l,children:(0,f.jsx)(u.Input,{className:`univer-w-full`,placeholder:s.t(`sheets-data-validation-ui.panel.valuePlaceholder`),value:r==null?void 0:r.formula2,onChange:e=>{i==null||i({...r,formula2:e||void 0})}})}):null]})}function Je(e){let{unitId:n,subUnitId:r,value:i,onChange:a,showError:o,validResult:s}=e,c=o?s==null?void 0:s.formula1:void 0,l=(0,d.useRef)(null),[p,h]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=l.current)!=null&&t.isClickOutSide(e)&&h(!1)}),(0,f.jsx)(u.FormLayout,{error:c,children:(0,f.jsx)(m.FormulaEditor,{ref:l,className:(0,u.clsx)(`univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,u.borderClassName),initValue:(i==null?void 0:i.formula1)??`=`,unitId:n,subUnitId:r,isFocus:p,isSupportAcrossSheet:!0,onChange:e=>{let t=(e??``).trim();t!==(i==null?void 0:i.formula1)&&(a==null||a({...i,formula1:t}))},onFocus:()=>h(!0)})})}function Ye(e,t){let n=new Set,i=[];return e.forEach(e=>{!e.label||n.has(e.label)||(n.add(e.label),i.push(e))}),{formula1:(0,r.serializeListOptions)(i.map(e=>e.label)),formula2:i.map(e=>e.color===t?``:e.color).join(`,`)}}let Xe=[`#FFFFFF`,`#FEE7E7`,`#FEF0E6`,`#EFFBD0`,`#E4F4FE`,`#E8ECFD`,`#F1EAFA`,`#FDE8F3`,`#E5E5E5`,`#FDCECE`,`#FDC49B`,`#DEF6A2`,`#9FDAFF`,`#D0D9FB`,`#E3D5F6`,`#FBD0E8`,`#656565`,`#FE4B4B`,`#FF8C51`,`#8BBB11`,`#0B9EFB`,`#3A60F7`,`#9E6DE3`,`#F248A6`],Ze=e=>{let{value:r,onChange:i,disabled:a}=e,[o,s]=(0,d.useState)(!1),c=(0,t.useDependency)(n.ThemeService);(0,t.useObservable)(c.currentTheme$);let l=r.includes(`.`)&&c.isValidThemeColor(r)?c.getColorFromTheme(r):r;return(0,f.jsx)(u.Dropdown,{align:`start`,disabled:a,open:o,onOpenChange:s,overlay:(0,f.jsx)(`div`,{className:`univer-box-border univer-grid univer-w-fit univer-grid-cols-6 univer-flex-wrap univer-gap-2 univer-p-1.5`,children:Xe.map(e=>(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-box-border univer-size-4 univer-cursor-pointer univer-rounded`,u.borderClassName),style:{background:e},onClick:()=>{i(e),s(!1)}},e))}),children:(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-box-border univer-inline-flex univer-h-8 univer-w-16 univer-cursor-pointer univer-items-center univer-justify-between univer-gap-2 univer-rounded-lg univer-bg-gray-0 univer-px-2.5 univer-transition-colors univer-duration-200 hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0`,u.borderClassName),children:[(0,f.jsx)(`div`,{className:`univer-box-border univer-size-4 univer-rounded univer-text-base`,style:{background:l}}),(0,f.jsx)(Pe,{})]})})},Qe=e=>{let{item:t,commonProps:n,className:r}=e,{onItemChange:i,onItemDelete:a}=n;return(0,f.jsxs)(`div`,{className:(0,u.clsx)(`univer-flex univer-items-center univer-gap-2`,r),children:[!t.isRef&&(0,f.jsx)(`div`,{className:(0,u.clsx)(`univer-cursor-move`,`draggableHandle`),children:(0,f.jsx)(Ae,{})}),(0,f.jsx)(Ze,{value:t.color,onChange:e=>{i(t.id,t.label,e)}}),(0,f.jsx)(u.Input,{disabled:t.isRef,value:t.label,onChange:e=>{i(t.id,e,t.color)}}),t.isRef?null:(0,f.jsx)(`div`,{className:`univer-ml-1 univer-cursor-pointer univer-rounded univer-text-base hover:univer-bg-gray-200`,children:(0,f.jsx)(Ee,{onClick:()=>a(t.id)})})]})},$e=()=>{};function et(e){let{value:s,onChange:c=$e,unitId:l,subUnitId:p,validResult:h,showError:g,ruleId:_}=e,{formula1:v=``,formula2:y=``}=s||{},[b,S]=(0,d.useState)(()=>(0,n.isFormulaString)(v)?`1`:`0`),[C,T]=(0,d.useState)(b===`1`?v:`=`),[E,D]=(0,d.useState)(b===`1`?v:`=`),O=(0,t.useDependency)(n.LocaleService),k=(0,t.useDependency)(a.DataValidatorRegistryService),A=(0,t.useDependency)(a.DataValidationModel),j=(0,t.useDependency)(i.DataValidationFormulaController),M=(0,t.useDependency)(x),[N,P]=(0,d.useState)(()=>y.split(`,`)),F=k.getValidatorItem(n.DataValidationType.LIST),[I,L]=(0,d.useState)([]),[R,z]=(0,d.useState)(``),B=g?h==null?void 0:h.formula1:``,ee=(0,t.useObservable)((0,d.useMemo)(()=>A.ruleChange$.pipe((0,o.debounceTime)(16)),[])),V=(0,t.useEvent)(c);(0,d.useEffect)(()=>{let e=!1,t=setTimeout(()=>{let t=A.getRuleById(l,p,_);(0,n.isFormulaString)(t==null?void 0:t.formula1)&&F&&t&&F.getListAsync(t,l,p).then(t=>{e||L(t)})},100);return()=>{e=!0,clearTimeout(t)}},[A,ee,F,_,p,l]),(0,d.useEffect)(()=>{(0,n.isFormulaString)(v)&&v!==E&&(T(v),D(v))},[E,v]);let[H,U]=(0,d.useState)(()=>{let e=b===`1`?[]:(0,r.deserializeListOptions)(v),t=y.split(`,`);return e.map((e,r)=>({label:e,color:t[r]||`gray.100`,isRef:!1,id:(0,n.generateRandomId)(4)}))}),te=(e,t,n)=>{let r=H.find(t=>t.id===e);r&&(r.label=t,r.color=n,U([...H]))},W=e=>{let t=H.findIndex(t=>t.id===e);t!==-1&&(H.splice(t,1),U([...H]))},ne=(0,d.useMemo)(()=>I.map((e,t)=>({label:e,color:N[t]||`gray.100`,id:`${t}`,isRef:!0})),[N,I]),re=(e,t,n)=>{let r=[...N];r[+e]=n,P(r),V({formula1:v,formula2:r.join(`,`)})},ie=()=>{U([...H,{label:``,color:w,isRef:!1,id:(0,n.generateRandomId)(4)}])};(0,d.useEffect)(()=>{b!==`1`&&V(Ye(H,w))},[H,V,b]);let ae=(0,t.useEvent)(async e=>{if(!(0,n.isFormulaString)(e)){V==null||V({formula1:``,formula2:y});return}j.getFormulaRefCheck(e)?(V==null||V({formula1:(0,n.isFormulaString)(e)?e:``,formula2:y}),z(``)):(V==null||V({formula1:``,formula2:y}),T(`=`),z(O.t(`sheets-data-validation-ui.validFail.formulaError`)))}),G=(0,d.useRef)(null),[oe,K]=(0,d.useState)(!1);return(0,t.useSidebarClick)(e=>{var t;(t=G.current)!=null&&t.isClickOutSide(e)&&K(!1)}),(0,d.useEffect)(()=>{oe?M.setFocusFormulaEditorActiveRuleSubUnitId(p):M.setFocusFormulaEditorActiveRuleSubUnitId(null)},[oe,p,M]),(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(u.FormLayout,{label:O.t(`sheets-data-validation-ui.list.options`),children:(0,f.jsxs)(u.RadioGroup,{value:b,onChange:e=>{S(e),T(E),e===`1`&&V({formula1:E===`=`?``:E,formula2:N.join(`,`)})},children:[(0,f.jsx)(u.Radio,{value:`0`,children:O.t(`sheets-data-validation-ui.list.customOptions`)}),(0,f.jsx)(u.Radio,{value:`1`,children:O.t(`sheets-data-validation-ui.list.refOptions`)})]})}),b===`1`?(0,f.jsxs)(u.FormLayout,{error:B||R||void 0,children:[(0,f.jsx)(m.FormulaEditor,{ref:G,className:(0,u.clsx)(`univer-box-border univer-h-8 univer-w-full univer-cursor-pointer univer-items-center univer-rounded-lg univer-bg-gray-0 univer-pt-2 univer-transition-colors hover:univer-border-primary-600 dark:!univer-bg-gray-700 dark:!univer-text-gray-0 [&>div:first-child]:univer-px-2.5 [&>div]:univer-h-5 [&>div]:univer-ring-transparent`,u.borderClassName),initValue:C,unitId:l,subUnitId:p,isFocus:oe,isSupportAcrossSheet:!0,onFocus:()=>K(!0),onChange:(e=``)=>{let t=(e??``).trim();D(t),ae(t)}}),ne.length>0&&(0,f.jsx)(`div`,{className:`univer-mt-3`,children:ne.map(e=>(0,f.jsx)(Qe,{className:`univer-mb-3`,item:e,commonProps:{onItemChange:re}},e.id))})]}):(0,f.jsx)(u.FormLayout,{error:B,children:(0,f.jsxs)(`div`,{children:[(0,f.jsx)(u.DraggableList,{list:H,onListChange:U,rowHeight:28,margin:[0,12],draggableHandle:`.draggableHandle`,itemRender:e=>(0,f.jsx)(Qe,{item:e,commonProps:{onItemChange:te,onItemDelete:W}},e.id),idKey:`id`}),(0,f.jsxs)(`a`,{className:`univer-text-primary univer-flex univer-w-fit univer-cursor-pointer univer-flex-row univer-items-center univer-rounded univer-p-1 univer-px-2 univer-text-sm hover:univer-bg-primary-50 dark:hover:!univer-bg-gray-800`,onClick:ie,children:[(0,f.jsx)(Me,{className:`univer-mr-1`}),O.t(`sheets-data-validation-ui.list.add`)]})]})})]})}let tt=[[i.CUSTOM_FORMULA_INPUT_NAME,Je],[i.BASE_FORMULA_INPUT_NAME,Ke],[i.LIST_FORMULA_INPUT_NAME,et],[i.CHECKBOX_FORMULA_INPUT_NAME,qe]];function nt(e){let{value:r,onChange:i}=e,a=(0,t.useDependency)(n.LocaleService);return(0,f.jsx)(u.FormLayout,{label:a.t(`sheets-data-validation-ui.renderMode.label`),children:(0,f.jsxs)(u.RadioGroup,{value:`${r.renderMode??n.DataValidationRenderMode.CUSTOM}`,onChange:e=>i({...r,renderMode:+e}),children:[(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.CUSTOM}`,children:a.t(`sheets-data-validation-ui.renderMode.chip`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.ARROW}`,children:a.t(`sheets-data-validation-ui.renderMode.arrow`)}),(0,f.jsx)(u.Radio,{value:`${n.DataValidationRenderMode.TEXT}`,children:a.t(`sheets-data-validation-ui.renderMode.text`)})]})})}nt.componentKey=`LIST_RENDER_MODE_OPTION_INPUT`;let J=class extends n.Disposable{constructor(e,t){super(),this._componentManager=e,this._iconManager=t,this._registerIcons(),this._registerComponents()}_registerIcons(){this.disposeWithMe(this._iconManager.register({CheckboxIcon:be,DataValidationIcon:Se,DatePickerIcon:we,DropdownListIcon:Oe}))}_registerComponents(){[[A,We],[nt.componentKey,nt],[Ge.componentKey,Ge],[B,ee],...tt].forEach(([e,t])=>{this.disposeWithMe(this._componentManager.register(e,t))})}};J=b([y(0,(0,n.Inject)(t.ComponentManager)),y(1,(0,n.Inject)(t.IconManager))],J);let Y=`SHEET_DATA_VALIDATION_ALERT`,rt=class extends n.Disposable{constructor(e,t,n,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe((0,o.debounceTime)(100)).subscribe(e=>{if(e){let r=this._univerInstanceService.getUnit(e.location.unitId,n.UniverInstanceType.UNIVER_SHEET),i=r.getSheetBySheetId(e.location.subUnitId);if(!i)return;let a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(Y);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:r,worksheet:i})===n.DataValidationStatus.INVALID){var t;let n=this._cellAlertManagerService.currentAlert.get(Y),r=n==null||(t=n.alert)==null?void 0:t.location;if(r&&r.row===e.location.row&&r.col===e.location.col&&r.subUnitId===e.location.subUnitId&&r.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(Y);return}let i=this._dataValidationModel.getValidator(a.type);if(!i){this._cellAlertManagerService.removeAlert(Y);return}this._cellAlertManagerService.showAlert({type:l.CellAlertType.ERROR,title:this._localeService.t(`sheets-data-validation-ui.error.title`),message:i==null?void 0:i.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:Y});return}}this._cellAlertManagerService.removeAlert(Y)}))}};rt=b([y(0,(0,n.Inject)(l.HoverManagerService)),y(1,(0,n.Inject)(l.CellAlertManagerService)),y(2,n.IUniverInstanceService),y(3,(0,n.Inject)(n.LocaleService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],rt);let X=class extends n.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){let e=()=>({redos:[],undos:[]}),t=(e,t)=>{let{source:a,target:o,unitId:s,subUnitId:c}=e,u=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),d=(0,l.virtualizeDiscreteRanges)([a,o]),[f,p]=d.ranges,{mapRange:m,projectRange:h}=d,g=r.AutoFillTools.getAutoFillRepeatRange(f,p),_=new Map;_.set(``,g.flatMap(e=>m(n.Rectangle.getPositionRange(e.relativeRange,{startRow:e.repeatStartCell.row,endRow:e.repeatStartCell.row,startColumn:e.repeatStartCell.col,endColumn:e.repeatStartCell.col})))),this._sheetDataValidationModel.getRules(s,c).forEach(e=>{let t=e.ranges.flatMap(e=>{let t=h(e),r=t&&(0,n.getIntersectRange)(t,f);return r?[n.Rectangle.getRelativeRange(r,f)]:[]}),r=g.flatMap(e=>t.flatMap(t=>{let r=(0,n.getIntersectRange)(t,e.relativeRange);return r?m(n.Rectangle.getPositionRange(r,{startRow:e.repeatStartCell.row,endRow:e.repeatStartCell.row,startColumn:e.repeatStartCell.col,endColumn:e.repeatStartCell.col})):[]}));r.length&&_.set(e.uid,r)});let v=Array.from(_,([e,t])=>({id:e,ranges:t.length>1?n.Rectangle.mergeRanges(t):t}));u.addRangeRules(v);let{redoMutations:y,undoMutations:b}=(0,i.getDataValidationDiffMutations)(s,c,u.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,t===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT);return{undos:b,redos:y}},a={id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:e=>{let{source:t,unitId:i,subUnitId:a}=e,{projectRange:o}=(0,l.virtualizeDiscreteRanges)([t]);this._sheetDataValidationModel.getRules(i,a).some(e=>e.type===n.DataValidationType.CHECKBOX&&e.ranges.some(e=>o(e)!==null))&&this._autoFillService.setDisableApplyType(r.AUTO_FILL_APPLY_TYPE.SERIES,!0)},onFillData:(n,i,a)=>a===r.AUTO_FILL_APPLY_TYPE.COPY||a===r.AUTO_FILL_APPLY_TYPE.ONLY_FORMAT||a===r.AUTO_FILL_APPLY_TYPE.SERIES?t(n,a):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(a))}};X=b([y(0,r.IAutoFillService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector))],X);let it=[l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,l.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA],at=class extends n.Disposable{constructor(e,t,n,r){super(),this._sheetClipboardService=e,this._sheetDataValidationModel=t,this._injector=n,this._univerInstanceService=r,v(this,`_copyInfo`,void 0),this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:i.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(e,t,n)=>this._collect(e,t,n),onPasteCells:(e,t,n,r)=>!e||!this._copyInfo||it.includes(r.pasteType)?{redos:[],undos:[]}:this._generateMutations(e,t,r)})}_collect(e,t,i){let a=new Map;this._copyInfo={unitId:e,subUnitId:t,rules:a};let o=this._injector.invoke(n=>(0,r.rangeToDiscreteRange)(i,n,e,t));if(!o)return;let{projectRange:s}=(0,l.virtualizeDiscreteRanges)([o]);this._sheetDataValidationModel.getRules(e,t).forEach(e=>{let t=e.ranges.flatMap(e=>{let t=s(e);return t?[t]:[]});t.length&&a.set(e.uid,t.length>1?n.Rectangle.mergeRanges(t):t)})}_generateMutations(e,t,a){let o=this._copyInfo;if(!o)return{redos:[],undos:[]};let{unitId:s,subUnitId:c,range:u}=e,{unitId:d,subUnitId:f,range:p}=t,{copyType:m=l.COPY_TYPE.COPY}=a;if(!(0,r.getSheetCommandTarget)(this._univerInstanceService,{unitId:d,subUnitId:f}))return{redos:[],undos:[]};if(m===l.COPY_TYPE.CUT&&d===s&&f===c)return this._copyInfo=null,{redos:[],undos:[]};let h=(0,l.virtualizeDiscreteRanges)([u]).ranges[0],g=(0,l.virtualizeDiscreteRanges)([p]),_=g.ranges[0],v=(0,l.getRepeatRange)(h,_,!0),y=g.mapRange(_),b=e=>v.flatMap(({startRange:t})=>e.flatMap(e=>g.mapRange(n.Rectangle.getPositionRange(e,t))));if(d!==s||f!==c){let e=this._sheetDataValidationModel.getRuleObjectMatrix(d,f).clone(),t=new Map,n=[{id:``,ranges:y}];o.rules.forEach((e,r)=>{let i=`${c}-${r}`,a=this._sheetDataValidationModel.getRuleById(s,c,r);!this._sheetDataValidationModel.getRuleById(d,f,i)&&a&&t.set(i,{...a,uid:i}),n.push({id:i,ranges:b(e)})}),e.addRangeRules(n);let{redoMutations:r,undoMutations:a}=(0,i.getDataValidationDiffMutations)(d,f,e.diffWithAddition(this._sheetDataValidationModel.getRules(d,f),t.values()),this._injector,`patched`,!1);if(m===l.COPY_TYPE.CUT){let e=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone();e.addRangeRules([{id:``,ranges:(0,l.virtualizeDiscreteRanges)([u]).mapRange(h)}]);let{redoMutations:t,undoMutations:n}=(0,i.getDataValidationDiffMutations)(s,c,e.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,!1);r.push(...t),a.push(...n)}return{redos:r,undos:a}}else{let e=this._sheetDataValidationModel.getRuleObjectMatrix(s,c).clone(),t=[{id:``,ranges:y},...Array.from(o.rules,([e,t])=>({id:e,ranges:b(t)}))];e.addRangeRules(t);let{redoMutations:n,undoMutations:r}=(0,i.getDataValidationDiffMutations)(d,f,e.diff(this._sheetDataValidationModel.getRules(s,c)),this._injector,`patched`,!1);return{redos:n,undos:r}}}};at=b([y(0,l.ISheetClipboardService),y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(n.Injector)),y(3,(0,n.Inject)(n.IUniverInstanceService))],at);let ot=class extends n.Disposable{constructor(e,t,n){super(),this._localeService=e,this._commandService=t,this._sheetPermissionCheckController=n,this._commandExecutedListener()}_commandExecutedListener(){this.disposeWithMe(this._commandService.beforeCommandExecuted(e=>{if(e.id===i.AddSheetDataValidationCommand.id){let{unitId:t,subUnitId:n,rule:{ranges:i}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}if(e.id===i.UpdateSheetDataValidationRangeCommand.id){let{unitId:t,subUnitId:n,ranges:i}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[r.WorkbookEditablePermission],rangeTypes:[r.RangeProtectionPermissionEditPoint],worksheetTypes:[r.WorksheetEditPermission,r.WorksheetSetCellStylePermission]},i,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t(`sheets-data-validation-ui.permission.dialog.setStyleErr`))}}))}};ot=b([y(0,(0,n.Inject)(n.LocaleService)),y(1,n.ICommandService),y(2,(0,n.Inject)(r.SheetPermissionCheckController))],ot);let st={tr:{size:6,color:`#fe4b4b`}},ct=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o,s,c,l,u){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=i,this._dropdownManagerService=a,this._sheetDataValidationModel=o,this._dataValidatorRegistryService=s,this._sheetInterceptorService=c,this._dataValidationCacheService=l,this._editorBridgeService=u,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(ue)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{if(!e.visible){var t;((t=this._dropdownManagerService.activeDropdown)==null?void 0:t.trigger)===`editor-bridge`&&this._dropdownManagerService.hideDropdown();return}let r=this._editorBridgeService.getEditCellState();if(r){let{unitId:e,sheetId:t,row:i,column:a}=r,o=this._univerInstanceService.getUnit(e,n.UniverInstanceType.UNIVER_SHEET);if(!o)return;let s=this._sheetDataValidationModel.getRuleByLocation(e,t,i,a);if(!s)return;let c=this._dataValidatorRegistryService.getValidatorItem(s.type);if(!(c!=null&&c.dropdownType))return;let l=o.getActiveSheet();if(!l)return;let u=this._dropdownManagerService.activeDropdown,d=u==null?void 0:u.location;if(d&&d.unitId===e&&d.subUnitId===t&&d.row===i&&d.col===a)return;this._dropdownManagerService.showDropdown({location:{unitId:e,subUnitId:t,row:i,col:a,workbook:o,worksheet:l},trigger:`editor-bridge`,closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o;let{row:s,col:c,unitId:u,subUnitId:d,workbook:f,worksheet:p}=t,m=this._sheetDataValidationModel.getRuleIdByLocation(u,d,s,c);if(!m)return r(e);let h=this._sheetDataValidationModel.getRuleById(u,d,m);if(!h)return r(e);let g=this._dataValidationCacheService.getValue(u,d,s,c)??n.DataValidationStatus.VALID,_=this._dataValidatorRegistryService.getValidatorItem(h.type),v=t.rawData,y,b={get value(){return y===void 0&&(y=(0,i.getCellValueOrigin)(v)??null),y}},x={get value(){return`${b.value??``}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===n.DataValidationStatus.INVALID?st:null},e.customRender=[...(e==null?void 0:e.customRender)??[],..._!=null&&_.canvasRender?[_.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(_==null||(o=_.skipDefaultFontRender)==null?void 0:o.call(_,h,b.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,..._==null?void 0:_.getExtraStyle(h,x.value,{get style(){let t=f.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},s,c)},e.interceptorAutoHeight=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoHeight)==null?void 0:r.call(n,o)},e.interceptorAutoWidth=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoWidth)==null?void 0:r.call(n,o)},e.coverable=((e==null?void 0:e.coverable)??!0)&&h.type!==n.DataValidationType.LIST&&h.type!==n.DataValidationType.LIST_MULTIPLE,r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(100)).subscribe(e=>{if(e.length===0)return;let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};ct=b([y(0,n.ICommandService),y(1,t.IMenuManagerService),y(2,s.IRenderManagerService),y(3,n.IUniverInstanceService),y(4,(0,n.Inject)(l.AutoHeightController)),y(5,(0,n.Inject)(k)),y(6,(0,n.Inject)(i.SheetDataValidationModel)),y(7,(0,n.Inject)(a.DataValidatorRegistryService)),y(8,(0,n.Inject)(r.SheetInterceptorService)),y(9,(0,n.Inject)(i.DataValidationCacheService)),y(10,(0,n.Optional)(l.IEditorBridgeService))],ct);let lt=class extends n.RxDisposable{constructor(e,t,n,r,i,a,o){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=i,this._sheetDataValidationModel=a,this._dataValidationCacheService=o,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(r.INTERCEPTOR_POINT.CELL_CONTENT,{effect:n.InterceptorEffectEnum.Style,priority:r.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,r)=>{var a,o;let{row:s,col:c,unitId:u,subUnitId:d,workbook:f,worksheet:p}=t,m=this._sheetDataValidationModel.getRuleIdByLocation(u,d,s,c);if(!m)return r(e);let h=this._sheetDataValidationModel.getRuleById(u,d,m);if(!h)return r(e);let g=this._dataValidationCacheService.getValue(u,d,s,c)??n.DataValidationStatus.VALID,_=this._dataValidatorRegistryService.getValidatorItem(h.type),v=(0,i.getCellValueOrigin)(p.getCellRaw(s,c)),y=`${v??``}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===n.DataValidationStatus.INVALID?st:null},e.customRender=[...(e==null?void 0:e.customRender)??[],..._!=null&&_.canvasRender?[_.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:(e==null||(a=e.fontRenderExtension)==null?void 0:a.isSkip)||(_==null||(o=_.skipDefaultFontRender)==null?void 0:o.call(_,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,..._==null?void 0:_.getExtraStyle(h,y,{get style(){let t=f.getStyles();return(typeof(e==null?void 0:e.s)==`string`?t.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},s,c)},e.interceptorAutoHeight=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoHeight)==null?void 0:r.call(n,o)},e.interceptorAutoWidth=()=>{var t,n,r;let i=(t=this._renderManagerService.getRenderUnitById(u))==null||(t=t.with(l.SheetSkeletonManagerService).getSkeletonParam(d))==null?void 0:t.skeleton;if(!i)return;let a=i.worksheet.getMergedCell(s,c),o={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:i.getCellWithCoordByIndex((a==null?void 0:a.startRow)??s,(a==null?void 0:a.startColumn)??c),unitId:u,subUnitId:d,row:s,col:c,workbook:f,worksheet:p};return _==null||(n=_.canvasRender)==null||(r=n.calcCellAutoWidth)==null?void 0:r.call(n,o)},e.coverable=((e==null?void 0:e.coverable)??!0)&&h.type!==n.DataValidationType.LIST&&h.type!==n.DataValidationType.LIST_MULTIPLE,r(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe((0,o.filter)(e=>e.source===`command`),(0,o.bufferTime)(16)).subscribe(e=>{let t=[];e.forEach(e=>{if(e.rule.type===n.DataValidationType.LIST_MULTIPLE||e.rule.type===n.DataValidationType.LIST){var r;(r=e.rule)!=null&&r.ranges&&t.push(...e.rule.ranges)}}),t.length&&(0,n.sequenceExecute)(this._autoHeightController.getUndoRedoParamsOfAutoHeight(t).redos,this._commandService)})}};lt=b([y(0,n.ICommandService),y(1,s.IRenderManagerService),y(2,(0,n.Inject)(l.AutoHeightController)),y(3,(0,n.Inject)(a.DataValidatorRegistryService)),y(4,(0,n.Inject)(r.SheetInterceptorService)),y(5,(0,n.Inject)(i.SheetDataValidationModel)),y(6,(0,n.Inject)(i.DataValidationCacheService))],lt);let ut=class extends n.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe((0,n.bufferDebounceTime)(16)).subscribe(e=>{var t;if(!e.length)return;let n=new Set;e.forEach(e=>{n.add(e.subUnitId)}),n.forEach(e=>{var t;(t=this._sheetSkeletonManagerService.getSkeletonParam(e))==null||t.skeleton.makeDirty(!0)}),(t=this._context.mainComponent)==null||t.makeForceDirty()}))}};ut=b([y(1,(0,n.Inject)(i.SheetDataValidationModel)),y(2,(0,n.Inject)(l.SheetSkeletonManagerService))],ut);let dt=class{_calc(e,t){let{vt:r,ht:i}=t||{},a=e.endX-e.startX-12,o=e.endY-e.startY,s=((t==null?void 0:t.fs)??10)*1.6,c=0,l=0;switch(r){case n.VerticalAlign.TOP:l=0;break;case n.VerticalAlign.BOTTOM:l=0+(o-s);break;default:l=0+(o-s)/2;break}switch(i){case n.HorizontalAlign.LEFT:c=6;break;case n.HorizontalAlign.RIGHT:c=6+(a-s);break;default:c=6+(a-s)/2;break}return{left:e.startX+c,top:e.startY+l,width:((t==null?void 0:t.fs)??10)*1.6,height:((t==null?void 0:t.fs)??10)*1.6}}constructor(e,t,n,r,i,a){this._commandService=e,this._univerInstanceService=t,this._formulaService=n,this._themeService=r,this._renderManagerService=i,this._dataValidationModel=a}calcCellAutoHeight(e){let{style:t}=e;return((t==null?void 0:t.fs)??10)*1.6}calcCellAutoWidth(e){let{style:t}=e;return((t==null?void 0:t.fs)??10)*1.6}async _parseFormula(e,t,r){var a,o,s;let{formula1:c=i.CHECKBOX_FORMULA_1,formula2:l=i.CHECKBOX_FORMULA_2}=e,u=await this._formulaService.getRuleFormulaResult(t,r,e.uid),d=(0,i.getFormulaResult)(u==null||(a=u[0])==null||(a=a.result)==null||(a=a[0])==null?void 0:a[0]),f=(0,i.getFormulaResult)(u==null||(o=u[1])==null||(o=o.result)==null||(o=o[0])==null?void 0:o[0]),p=(0,i.isLegalFormulaResult)(String(d))&&(0,i.isLegalFormulaResult)(String(f));return{formula1:(0,n.isFormulaString)(c)?(0,i.getFormulaResult)(u==null||(s=u[0])==null||(s=s.result)==null||(s=s[0])==null?void 0:s[0]):c,formula2:(0,n.isFormulaString)(l)?f:l,isFormulaValid:p}}drawWith(e,t){var n,r;let{style:a,primaryWithCoord:o,unitId:c,subUnitId:l,worksheet:u,row:d,col:f}=t,p=o.isMergedMainCell?o.mergeInfo:o,m=(0,i.getCellValueOrigin)(u.getCellRaw(d,f)),h=this._dataValidationModel.getRuleByLocation(c,l,d,f);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g||!((n=g.skipDefaultFontRender)!=null&&n.call(g,h,m,{unitId:c,subUnitId:l,row:d,column:f})))return;let{formula1:_}=g.parseFormulaSync(h,c,l),v=this._calc(p,a),{a:y,d:b}=e.getTransform(),x=(0,s.fixLineWidthByScale)(v.left,y),S=(0,s.fixLineWidthByScale)(v.top,b),C=s.Transform.create().composeMatrix({left:x,top:S,scaleX:1,scaleY:1,angle:0,skewX:0,skewY:0,flipX:!1,flipY:!1}),w=p.endX-p.startX,T=p.endY-p.startY;e.save(),e.beginPath(),e.rect(p.startX,p.startY,w,T),e.clip();let E=C.getMatrix();e.transform(E[0],E[1],E[2],E[3],E[4],E[5]);let D=((a==null?void 0:a.fs)??10)*1.6,O=String(m)===String(_),k=this._themeService.getColorFromTheme(`primary.600`);s.CheckboxShape.drawWith(e,{checked:O,width:D,height:D,fill:(a==null||(r=a.cl)==null?void 0:r.rgb)??k}),e.restore()}isHit(e,t){let n=t.primaryWithCoord.isMergedMainCell?t.primaryWithCoord.mergeInfo:t.primaryWithCoord,r=this._calc(n,t.style),i=r.top,a=r.top+r.height,o=r.left,s=r.left+r.width,{x:c,y:l}=e;return c<=s&&c>=o&&l<=a&&l>=i}async onPointerDown(e,t){var n;if(t.button===2)return;let{primaryWithCoord:a,unitId:o,subUnitId:s,worksheet:c,row:l,col:u}=e,d=(0,i.getCellValueOrigin)(c.getCellRaw(l,u)),f=this._dataValidationModel.getRuleByLocation(o,s,l,u);if(!f)return;let p=this._dataValidationModel.getValidator(f.type);if(!p||!((n=p.skipDefaultFontRender)!=null&&n.call(p,f,d,{unitId:o,subUnitId:s,row:l,column:u})))return;let{formula1:m,formula2:h}=await this._parseFormula(f,o,s),g={range:{startColumn:a.actualColumn,endColumn:a.actualColumn,startRow:a.actualRow,endRow:a.actualRow},value:{v:String(d)===(0,i.transformCheckboxValue)(String(m))?h:m,p:null}};this._commandService.executeCommand(r.SetRangeValuesCommand.id,g)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};dt=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(i.DataValidationFormulaService)),y(3,(0,n.Inject)(n.ThemeService)),y(4,(0,n.Inject)(s.IRenderManagerService)),y(5,(0,n.Inject)(i.SheetDataValidationModel))],dt);let Z=class{constructor(e){this.injector=e,v(this,`canvasRender`,null),v(this,`dropdownType`,void 0),v(this,`optionsInput`,void 0),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}};Z=b([y(0,(0,n.Inject)(n.Injector))],Z);var ft=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CHECKBOX),v(this,`canvasRender`,this.injector.createInstance(dt)),v(this,`formulaInput`,i.CHECKBOX_FORMULA_INPUT_NAME)}},pt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.CUSTOM),v(this,`formulaInput`,i.CUSTOM_FORMULA_INPUT_NAME)}},mt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DATE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME),v(this,`optionsInput`,Ge.componentKey),v(this,`dropdownType`,a.DataValidatorDropdownType.DATE)}},ht=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.DECIMAL),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};function gt(e,t){let n=s.FontCache.getTextSize(e,t),r=n.width+8,{ba:i,bd:a}=n;return{width:r,height:i+a+0,ba:i}}function _t(e,t,n,r){let i=n-26,a=r-12,o=e.map(e=>({layout:gt(e,t),text:e})),s,c=[];o.forEach(e=>{let{layout:t}=e,{width:n,height:r}=t;!s||s.width+n+4>i?(s={width:n,height:r,items:[{...e,left:0}]},c.push(s)):(s.items.push({...e,left:s.width+4}),s.width=s.width+n+4)});let l=0,u=0;return c.forEach((e,t)=>{u=Math.max(u,e.width),t===c.length-1?l+=e.height:l+=e.height+4}),{lines:c,totalHeight:l,contentWidth:i,contentHeight:a,cellAutoHeight:l+12,calcAutoWidth:u+26}}var vt=class extends s.Shape{static drawWith(e,t){let{fontString:n,info:r,fill:i,color:a}=t,{layout:o,text:c}=r;e.save(),s.Rect.drawWith(e,{width:o.width,height:o.height,radius:8,fill:i||`gray.100`}),e.translateWithPrecision(4,o.ba),e.font=n,e.fillStyle=a,e.fillText(c,0,0),e.restore()}};let yt=new Path2D(`M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z`),bt=class{constructor(e,t,n,r){this._commandService=e,this._univerInstanceService=t,this._renderManagerService=n,this._dataValidationModel=r,v(this,`zIndex`,void 0),v(this,`_dropdownInfoMap`,new Map)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a){let o=r-14+4,s=4;switch(a){case n.VerticalAlign.MIDDLE:s=(i-14)/2+4;break;case n.VerticalAlign.BOTTOM:s=i-14+4;break;default:break}e.save(),e.translateWithPrecision(t.startX+o,t.startY+s),e.fillStyle=T,e.fill(yt),e.restore()}drawWith(e,t,r,a){let{primaryWithCoord:o,row:c,col:l,style:u,data:d,subUnitId:f}=t,p=o.isMergedMainCell?o.mergeInfo:o,{leftOffset:m=0,rightOffset:h=0,topOffset:g=0,downOffset:_=0}=(d==null?void 0:d.fontRenderExtension)||{},v=this._ensureMap(f),y=this._generateKey(c,l),b=o.isMergedMainCell?o.mergeInfo.startRow:c,x=o.isMergedMainCell?o.mergeInfo.startColumn:l,S=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,b,x);if(!S)return;let C=this._dataValidationModel.getValidator(S.type);if(!C)return;let w={startX:p.startX+m,endX:p.endX-h,startY:p.startY+g,endY:p.endY-_},T=w.endX-w.startX,E=w.endY-w.startY,{cl:D}=u||{},O=(typeof D==`object`?D==null?void 0:D.rgb:D)??`#000`,k=(0,s.getFontStyleString)(u??void 0),{vt:A,ht:j}=u||{},M=A??n.VerticalAlign.MIDDLE,N=(0,i.getCellValueOrigin)(d)??``,P=C.parseCellValue(N),F=C.getListWithColorMap(S),I=_t(P,k,T,E);this._drawDownIcon(e,w,T,E,M),e.save(),e.translateWithPrecision(w.startX,w.startY),e.beginPath(),e.rect(0,0,T-14,E),e.clip(),e.translateWithPrecision(6,6);let L=0;switch(M){case n.VerticalAlign.MIDDLE:L=(I.contentHeight-I.totalHeight)/2;break;case n.VerticalAlign.BOTTOM:L=I.contentHeight-I.totalHeight;break;default:break}e.translateWithPrecision(0,L),I.lines.forEach((t,r)=>{e.save();let{width:i,height:a,items:o}=t,s=0;switch(j){case n.HorizontalAlign.RIGHT:s=I.contentWidth-i;break;case n.HorizontalAlign.CENTER:s=(I.contentWidth-i)/2;break;default:break}e.translate(s,r*(a+4)),o.forEach(t=>{e.save(),e.translateWithPrecision(t.left,0),vt.drawWith(e,{...k,info:t,color:O,fill:F[t.text]}),e.restore()}),e.restore()}),e.restore(),v.set(y,{left:w.startX,top:w.startY,width:I.contentWidth+6+14,height:I.contentHeight+12})}calcCellAutoHeight(e){let{primaryWithCoord:t,style:n,data:r,row:a,col:o}=e,{leftOffset:c=0,rightOffset:l=0,topOffset:u=0,downOffset:d=0}=(r==null?void 0:r.fontRenderExtension)||{},f=t.isMergedMainCell?t.mergeInfo:t,p={startX:f.startX+c,endX:f.endX-l,startY:f.startY+u,endY:f.endY-d},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!m)return;let h=this._dataValidationModel.getValidator(m.type);if(!h)return;let g=p.endX-p.startX,_=p.endY-p.startY,v=(0,i.getCellValueOrigin)(r)??``;return _t(h.parseCellValue(v),(0,s.getFontStyleString)(n??void 0),g,_).cellAutoHeight}calcCellAutoWidth(e){let{primaryWithCoord:t,style:n,data:r,row:a,col:o}=e,{leftOffset:c=0,rightOffset:l=0,topOffset:u=0,downOffset:d=0}=(r==null?void 0:r.fontRenderExtension)||{},f=t.isMergedMainCell?t.mergeInfo:t,p={startX:f.startX+c,endX:f.endX-l,startY:f.startY+u,endY:f.endY-d},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,a,o);if(!m)return;let h=this._dataValidationModel.getValidator(m.type);if(!h)return;let g=p.endX-p.startX,_=p.endY-p.startY,v=(0,i.getCellValueOrigin)(r)??``;return _t(h.parseCellValue(v),(0,s.getFontStyleString)(n??void 0),g,_).calcAutoWidth}isHit(e,t){let{primaryWithCoord:n}=t,{endX:r}=n.isMergedMainCell?n.mergeInfo:n,{x:i}=e;return i>=r-14&&i<=r}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(P.id,o)}onPointerEnter(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;return(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null?void 0:r.setCursor(s.CURSOR_TYPE.DEFAULT)}};bt=b([y(0,n.ICommandService),y(1,n.IUniverInstanceService),y(2,(0,n.Inject)(s.IRenderManagerService)),y(3,(0,n.Inject)(i.SheetDataValidationModel))],bt);var xt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST_MULTIPLE),v(this,`canvasRender`,this.injector.createInstance(bt)),v(this,`dropdownType`,a.DataValidatorDropdownType.MULTIPLE_LIST)}};let St=new Path2D(`M3.32201 4.84556C3.14417 5.05148 2.85583 5.05148 2.67799 4.84556L0.134292 1.90016C-0.152586 1.56798 0.0505937 1 0.456301 1L5.5437 1C5.94941 1 6.15259 1.56798 5.86571 1.90016L3.32201 4.84556Z`);function Ct(e,t,r,i,a,o,s=!0){let c=0,l=s?3:0;switch(a){case n.VerticalAlign.BOTTOM:c=t-i-l;break;case n.VerticalAlign.MIDDLE:c=(t-i)/2;break;default:c=l;break}c=Math.max(3,c);let u=0;switch(o){case n.HorizontalAlign.CENTER:u=(e-r)/2;break;case n.HorizontalAlign.RIGHT:u=e-r;break;default:break}return u=Math.max(6,u),{paddingLeft:u,paddingTop:c}}let wt=class{constructor(e,t,n,r,i){this._univerInstanceService=e,this._localeService=t,this._commandService=n,this._renderManagerService=r,this._dataValidationModel=i,v(this,`_dropdownInfoMap`,new Map),v(this,`zIndex`,void 0)}_ensureMap(e){let t=this._dropdownInfoMap.get(e);return t||(t=new Map,this._dropdownInfoMap.set(e,t)),t}_generateKey(e,t){return`${e}.${t}`}_drawDownIcon(e,t,r,i,a,o,s){let{t:c=n.DEFAULT_STYLES.pd.t,b:l=n.DEFAULT_STYLES.pd.b}=s,u=r-14,d;switch(o){case n.VerticalAlign.MIDDLE:d=(i-4)/2;break;case n.VerticalAlign.BOTTOM:d=i-l-a-3+(a/2-4/2);break;default:d=c+3+(a/2-4/2);break}e.save(),e.translateWithPrecision(t.startX+u,t.startY+d),e.fillStyle=T,e.fill(St),e.restore()}drawWith(e,t,r){let{primaryWithCoord:a,row:o,col:c,style:l,data:u,subUnitId:d}=t,f=a.isMergedMainCell?a.mergeInfo:a,p=a.isMergedMainCell?a.mergeInfo.startRow:o,m=a.isMergedMainCell?a.mergeInfo.startColumn:c,h=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,p,m);if(!h)return;let g=this._dataValidationModel.getValidator(h.type);if(!g)return;let{leftOffset:_=0,rightOffset:v=0,topOffset:y=0,downOffset:b=0}=(u==null?void 0:u.fontRenderExtension)||{};if(!h||!g||!g||g.id.indexOf(n.DataValidationType.LIST)!==0||!g.skipDefaultFontRender(h))return;let x={startX:f.startX+_,endX:f.endX-v,startY:f.startY+y,endY:f.endY-b},S=x.endX-x.startX,C=x.endY-x.startY,w=this._ensureMap(d),E=this._generateKey(o,c),D=g.getListWithColorMap(h),O=`${(0,i.getCellValueOrigin)(u)??``}`,k=D[O],{tb:A,vt:j,ht:M,pd:N}=l||{};A??=n.WrapStrategy.WRAP,j??=n.VerticalAlign.BOTTOM,M??=n.DEFAULT_STYLES.ht,N??=n.DEFAULT_STYLES.pd;let P=(0,s.getFontStyleString)(l).fontCache;if(h.renderMode===n.DataValidationRenderMode.ARROW){var F,I,L;let{l:t=n.DEFAULT_STYLES.pd.l,t:i=n.DEFAULT_STYLES.pd.t,r:a=n.DEFAULT_STYLES.pd.r,b:o=n.DEFAULT_STYLES.pd.b}=N,c=S-t-a-14-4,u=new s.DocSimpleSkeleton(O,P,A===n.WrapStrategy.WRAP,c,1/0);u.calculate();let d=u.getTotalWidth(),f=u.getTotalHeight(),{paddingTop:p,paddingLeft:m}=Ct(c,C-i-o,d,f,j,M,!0);this._drawDownIcon(e,x,S,C,f,j,N),e.save(),e.translateWithPrecision(x.startX+t,x.startY+i),e.beginPath(),e.rect(0,0,S-t-a,C-i-o),e.clip(),e.translateWithPrecision(0,p),e.save(),e.translateWithPrecision(m,0),e.beginPath(),e.rect(0,0,c,f),e.clip(),s.Text.drawWith(e,{text:O,fontStyle:P,width:c,height:f,color:l==null||(F=l.cl)==null?void 0:F.rgb,strokeLine:!!(l!=null&&(I=l.st)!=null&&I.s),underline:!!(l!=null&&(L=l.ul)!=null&&L.s),warp:A===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},u),e.restore(),e.restore(),w.set(E,{left:x.endX-14+r.rowHeaderWidth,top:x.startY+i+r.columnHeaderHeight,width:14,height:C-i-o})}else{var R,z,B;e.save(),e.translateWithPrecision(x.startX,x.startY),e.beginPath(),e.rect(0,0,S,C),e.clip();let t=S-12-4-14-4,i=new s.DocSimpleSkeleton(O,P,A===n.WrapStrategy.WRAP,t,1/0);i.calculate();let a=i.getTotalWidth(),o=i.getTotalHeight(),c=o+2,u=Math.max(S-12,1),{paddingTop:d}=Ct(u,C,a,c,j,M);e.translateWithPrecision(6,d),s.Rect.drawWith(e,{width:u,height:c,fill:k||`gray.100`,radius:8}),e.save(),e.translateWithPrecision(4,1),e.beginPath(),e.rect(0,0,t,o),e.clip(),s.Text.drawWith(e,{text:O,fontStyle:P,width:t,height:o,color:l==null||(R=l.cl)==null?void 0:R.rgb,strokeLine:!!(l!=null&&(z=l.st)!=null&&z.s),underline:!!(l!=null&&(B=l.ul)!=null&&B.s),warp:A===n.WrapStrategy.WRAP,hAlign:n.HorizontalAlign.LEFT},i),e.restore(),e.translateWithPrecision(t+4+4,(o-4)/2),e.fillStyle=T,e.fill(St),e.restore(),w.set(E,{left:x.startX+6+r.rowHeaderWidth,top:x.startY+d+r.columnHeaderHeight,width:u,height:c})}}calcCellAutoHeight(e){let{primaryWithCoord:t,style:r,data:a,row:o,col:c}=e,l=t.isMergedMainCell?t.mergeInfo:t,{leftOffset:u=0,rightOffset:d=0,topOffset:f=0,downOffset:p=0}=(a==null?void 0:a.fontRenderExtension)||{},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!m||m.renderMode===n.DataValidationRenderMode.TEXT)return;let h={startX:l.startX+u,endX:l.endX-d,startY:l.startY+f,endY:l.endY-p},g=h.endX-h.startX,_=`${(0,i.getCellValueOrigin)(a)??``}`,{tb:v,pd:y}=r||{},{t:b=n.DEFAULT_STYLES.pd.t,b:x=n.DEFAULT_STYLES.pd.b}=y??{};if(v??=n.WrapStrategy.WRAP,m.renderMode===n.DataValidationRenderMode.ARROW){let{l:e=n.DEFAULT_STYLES.pd.l,r:t=n.DEFAULT_STYLES.pd.r}=y??{},i=g-e-t-14-4,a=new s.DocSimpleSkeleton(_,(0,s.getFontStyleString)(r).fontCache,v===n.WrapStrategy.WRAP,i,1/0);return a.calculate(),a.getTotalHeight()+b+x+6}else{let e=Math.max(g-12-4-14-4,10),t=new s.DocSimpleSkeleton(_,(0,s.getFontStyleString)(r).fontCache,v===n.WrapStrategy.WRAP,e,1/0);return t.calculate(),t.getTotalHeight()+6+2}}calcCellAutoWidth(e){let{primaryWithCoord:t,style:r,data:a,row:o,col:c}=e,l=t.isMergedMainCell?t.mergeInfo:t,{leftOffset:u=0,rightOffset:d=0,topOffset:f=0,downOffset:p=0}=(a==null?void 0:a.fontRenderExtension)||{},m=this._dataValidationModel.getRuleByLocation(e.unitId,e.subUnitId,o,c);if(!m||m.renderMode===n.DataValidationRenderMode.TEXT)return;let h={startX:l.startX+u,endX:l.endX-d,startY:l.startY+f,endY:l.endY-p},g=h.endX-h.startX,_=`${(0,i.getCellValueOrigin)(a)??``}`,{tb:v,pd:y}=r||{},{l:b=n.DEFAULT_STYLES.pd.l,r:x=n.DEFAULT_STYLES.pd.r}=y??{};v??=n.WrapStrategy.WRAP;let S=26;switch(m.renderMode){case n.DataValidationRenderMode.ARROW:S=18+x+b;break;case n.DataValidationRenderMode.CUSTOM:S=34+x+b+8/2+1;break;default:S=34+x+b+8/2+1}let C=g-S,w=new s.DocSimpleSkeleton(_,(0,s.getFontStyleString)(r).fontCache,v===n.WrapStrategy.WRAP,C,1/0);return w.calculate(),w.getTotalWidth()+S}isHit(e,t){let{subUnitId:r,row:i,col:a}=t,o=this._ensureMap(r).get(this._generateKey(i,a)),s=this._dataValidationModel.getRuleByLocation(t.unitId,t.subUnitId,i,a);if(!s||!o||s.renderMode===n.DataValidationRenderMode.TEXT)return!1;let{top:c,left:l,width:u,height:d}=o,{x:f,y:p}=e;return f>=l&&f<=l+u&&p>=c&&p<=c+d}onPointerDown(e,t){if(t.button===2)return;let{unitId:n,subUnitId:r,row:i,col:a}=e,o={unitId:n,subUnitId:r,row:i,column:a};this._commandService.executeCommand(P.id,o)}onPointerEnter(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.POINTER)}onPointerLeave(e,t){var r;(r=(0,s.getCurrentTypeOfRenderer)(n.UniverInstanceType.UNIVER_SHEET,this._univerInstanceService,this._renderManagerService))==null||(r=r.mainComponent)==null||r.setCursor(s.CURSOR_TYPE.DEFAULT)}};wt=b([y(0,n.IUniverInstanceService),y(1,(0,n.Inject)(n.LocaleService)),y(2,n.ICommandService),y(3,(0,n.Inject)(s.IRenderManagerService)),y(4,(0,n.Inject)(i.SheetDataValidationModel))],wt);var Tt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.LIST),v(this,`canvasRender`,this.injector.createInstance(wt)),v(this,`dropdownType`,a.DataValidatorDropdownType.LIST),v(this,`optionsInput`,nt.componentKey),v(this,`formulaInput`,i.LIST_FORMULA_INPUT_NAME)}},Et=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.TEXT_LENGTH),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}},Dt=class extends Z{constructor(...e){super(...e),v(this,`id`,n.DataValidationType.WHOLE),v(this,`formulaInput`,i.BASE_FORMULA_INPUT_NAME)}};let Ot=class extends n.RxDisposable{constructor(e,t){super(),this._injector=e,this._dataValidatorRegistryService=t,this._registerValidatorViews()}_registerValidatorViews(){[ht,Dt,Et,mt,ft,Tt,xt,pt].forEach(e=>{let t=this._injector.createInstance(e),n=this._dataValidatorRegistryService.getValidatorItem(t.id);n&&(n.formulaInput=t.formulaInput,n.canvasRender=t.canvasRender,n.dropdownType=t.dropdownType,n.optionsInput=t.optionsInput)})}};Ot=b([y(0,(0,n.Inject)(n.Injector)),y(1,(0,n.Inject)(a.DataValidatorRegistryService))],Ot);let Q=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([J]),this._injector.get(J),[[x],[k],[rt],[X],[ct],[ot],[at],[Ot]].forEach(e=>{this._injector.add(e)}),[z,L,R,P,F,M,j,N].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(at),this._injector.get(ot),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[ut])}onRendered(){this._injector.get(Ot),this._injector.get(ct)}onSteady(){this._injector.get(X)}};v(Q,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v(Q,`packageName`,de),v(Q,`version`,fe),v(Q,`type`,n.UniverInstanceType.UNIVER_SHEET),Q=b([(0,n.DependentOn)(a.UniverDataValidationPlugin,s.UniverRenderEnginePlugin,r.UniverSheetsPlugin,t.UniverMobileUIPlugin,l.UniverSheetsMobileUIPlugin,i.UniverSheetsDataValidationPlugin),y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],Q);let $=class extends n.Plugin{constructor(e=C,t,r,i){super(),this._config=e,this._injector=t,this._commandService=r,this._configService=i;let{menu:a,...o}=(0,n.merge)({},C,this._config);a&&this._configService.setConfig(`menu`,a,{merge:!0}),this._configService.setConfig(S,o)}onStarting(){this._injector.add([J]),this._injector.get(J),[[x],[k],[rt],[X],[ct],[ot],[at],[E],[Ot]].forEach(e=>{this._injector.add(e)}),[z,L,R,P,F,M,j,N].forEach(e=>{this._commandService.registerCommand(e)})}onReady(){this._injector.get(at),this._injector.get(ot),this._injector.get(E),this._injector.get(rt),this._injector.get(s.IRenderManagerService).registerRenderModule(n.UniverInstanceType.UNIVER_SHEET,[ut])}onRendered(){this._injector.get(Ot),this._injector.get(ct)}onSteady(){this._injector.get(X)}};v($,`pluginName`,`SHEET_DATA_VALIDATION_UI_PLUGIN`),v($,`packageName`,de),v($,`version`,fe),v($,`type`,n.UniverInstanceType.UNIVER_SHEET),$=b([(0,n.DependentOn)(a.UniverDataValidationPlugin,s.UniverRenderEnginePlugin,r.UniverSheetsPlugin,l.UniverSheetsUIPlugin,i.UniverSheetsDataValidationPlugin),y(1,(0,n.Inject)(n.Injector)),y(2,n.ICommandService),y(3,n.IConfigService)],$),e.SheetsDataValidationUIMenuSchema=ue,Object.defineProperty(e,"UniverSheetsDataValidationMobileUIPlugin",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"UniverSheetsDataValidationUIPlugin",{enumerable:!0,get:function(){return $}})});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Data validation UI for Univer Sheets.",
|
|
6
6
|
"author": "DreamNum Co., Ltd. <developer@univer.ai>",
|
|
@@ -58,18 +58,18 @@
|
|
|
58
58
|
"rxjs": ">=7.0.0"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@univerjs/icons": "1.
|
|
62
|
-
"@univerjs/core": "1.0.0-beta.
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/engine-
|
|
66
|
-
"@univerjs/
|
|
67
|
-
"@univerjs/sheets-
|
|
68
|
-
"@univerjs/sheets-
|
|
69
|
-
"@univerjs/
|
|
70
|
-
"@univerjs/sheets
|
|
71
|
-
"@univerjs/
|
|
72
|
-
"@univerjs/
|
|
61
|
+
"@univerjs/icons": "1.38.0",
|
|
62
|
+
"@univerjs/core": "1.0.0-beta.2",
|
|
63
|
+
"@univerjs/data-validation": "1.0.0-beta.2",
|
|
64
|
+
"@univerjs/design": "1.0.0-beta.2",
|
|
65
|
+
"@univerjs/engine-render": "1.0.0-beta.2",
|
|
66
|
+
"@univerjs/engine-formula": "1.0.0-beta.2",
|
|
67
|
+
"@univerjs/sheets-data-validation": "1.0.0-beta.2",
|
|
68
|
+
"@univerjs/sheets-formula-ui": "1.0.0-beta.2",
|
|
69
|
+
"@univerjs/sheets-ui": "1.0.0-beta.2",
|
|
70
|
+
"@univerjs/sheets": "1.0.0-beta.2",
|
|
71
|
+
"@univerjs/ui": "1.0.0-beta.2",
|
|
72
|
+
"@univerjs/sheets-numfmt": "1.0.0-beta.2"
|
|
73
73
|
},
|
|
74
74
|
"devDependencies": {
|
|
75
75
|
"postcss": "^8.5.25",
|
|
@@ -78,7 +78,7 @@
|
|
|
78
78
|
"tailwindcss": "3.4.18",
|
|
79
79
|
"typescript": "^6.0.3",
|
|
80
80
|
"vitest": "^4.1.10",
|
|
81
|
-
"@univerjs-infra/shared": "1.0.0-beta.
|
|
81
|
+
"@univerjs-infra/shared": "1.0.0-beta.2"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"test": "vitest run",
|