@univerjs/sheets-data-validation-ui 0.12.4-insiders.20251211-c28f914 → 0.12.4-insiders.20251212-6c41730
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 +13 -14
package/lib/cjs/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var At=Object.defineProperty;var Lt=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var L=(e,t,n)=>Lt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),C=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),re=require("rxjs"),Pt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),T=require("react"),g=require("react/jsx-runtime"),tt=require("@univerjs/engine-formula"),ot=require("@univerjs/sheets-formula-ui");var jt=Object.getOwnPropertyDescriptor,xt=(e,t,n,a)=>{for(var r=a>1?void 0:a?jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ht=(e,t)=>(n,a)=>t(n,a,e);let ce=class extends o.Disposable{constructor(t,n){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ue&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ce=xt([ht(0,o.IUniverInstanceService),ht(1,E.ISidebarService)],ce);const ve="#ECECEC",st="sheets-data-validation-ui.config",xe={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},_e=(e,t)=>(n,a)=>t(n,a,e);let De=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:r,col:i,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,r,i),d=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!d||d.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(d.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,c,r,i)===o.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(d,{row:r,col:i,unitId:s,subUnitId:c})},footer:{title:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};De=Ft([_e(0,o.Inject(H.SheetInterceptorService)),_e(1,o.Inject(C.SheetDataValidationModel)),_e(2,o.Inject(Y.DataValidatorRegistryService)),_e(3,E.IDialogService),_e(4,o.Inject(o.LocaleService)),_e(5,o.Inject(C.SheetsDataValidationValidatorService))],De);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,a)=>{for(var r=a>1?void 0:a?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},oe=(e,t)=>(n,a)=>t(n,a,e);const He=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Bt(e,t){const n=Pt.getPatternType(t);if(e===n)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 me=class extends o.Disposable{constructor(t,n,a,r,i,s,c,l,d,h,v){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=c,this._commandService=l,this._editorBridgeService=d,this._injector=h,this._configService=v,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const c=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),a,r);if(!c)return;const l=this._dataValidatorRegistryService.getValidatorItem(c.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,M,R,y;const{location:n}=t,{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._sheetDataValidationModel.getRuleByLocation(i,s,a,r);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(m,D)=>{var A,x,k;if(!m)return!0;const I=m,f=l.getCell(a,r),w=I.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),F=(A=o.numfmt.parseDate(w))==null?void 0:A.v,B=D==="time"?F%1:F,j=c.getStyles().getStyleByCell(f),W=(k=(x=j==null?void 0:j.n)==null?void 0:x.pattern)!=null?k:"";return d.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:B,unitId:i,subUnitId:s,row:a,column:r,worksheet:l,workbook:c,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},d)?(await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:B,t:2,p:null,f:null,si:null,s:{n:{pattern:Bt(D,W)}}}}),await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(De)&&this._injector.get(De).showReject(h.getRuleFinalError(d,{row:a,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m),I=!!((O=d.bizInfo)!=null&&O.showTime);S={location:n,type:"datepicker",props:{showTime:I,onChange:f=>u(f,I?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const m=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async j=>{const W=C.serializeListOptions(j),A={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:W,p:null,f:null,si:null}};return this._commandService.executeCommand(H.SetRangeValuesCommand.id,A),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!m},I=(d==null?void 0:d.renderMode)===o.DataValidationRenderMode.CUSTOM||(d==null?void 0:d.renderMode)===void 0,f=h.getListWithColor(d,i,s),w=C.getDataValidationCellValue(l.getCellRaw(a,r)),F=()=>{this._commandService.executeCommand(fe.id,{ruleId:d.uid}),v==null||v.dispose()},B=f.map(j=>({label:j.label,value:j.label,color:I||j.color?j.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:j=>D(j),options:B,onEdit:F,defaultValue:w,multiple:m,showEdit:(R=(M=this._configService.getConfig(st))==null?void 0:M.showEditOnDropdown)!=null?R:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(a,r)).split("/"),options:JSON.parse((y=d.formula1)!=null?y:"[]")},location:n};break}case Y.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(a,r))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(v=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!v)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(v),p.add({dispose:()=>{var m,D;(D=(m=this._activeDropdown)==null?void 0:m.onHide)==null||D.call(m)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const c=s.getSheetBySheetId(n);if(!c)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),c.getSheetId(),a,r);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!d||!d.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:c,row:a,col:r,unitId:t,subUnitId:n},onHide:i})}};me=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(Y.DataValidatorRegistryService)),oe(2,E.IZenZoneService),oe(3,o.Inject(C.SheetDataValidationModel)),oe(4,o.Inject(H.SheetsSelectionsService)),oe(5,o.Inject(N.ISheetCellDropdownManagerService)),oe(6,o.Inject(C.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,N.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],me);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,r=e.get(ce),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),c=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:h}=l,v=n?i.getRuleById(d,h,n):void 0;r.open(),r.setActiveRule(v&&{unitId:d,subUnitId:h,rule:v});const u=c.open({id:Ue,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},lt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ce).close(),!0}},St={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(ce);return n.open(),n.isOpen?t.executeCommand(lt.id):t.executeCommand(fe.id),!0}},We={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(me),{unitId:a,subUnitId:r,row:i,column:s}=t,c=n.activeDropdown,l=c==null?void 0:c.location;return l&&l.unitId===a&&l.subUnitId===r&&l.row===i&&l.col===s||n.showDataValidationDropdown(a,r,i,s),!0}},_t={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=H.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:r}=n,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),c=a.getUnitId(),l=r.getSheetId(),d={rule:i,unitId:c,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,d)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Wt=Object.getOwnPropertyDescriptor,$t=(e,t,n,a)=>{for(var r=a>1?void 0:a?Wt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(n,a)=>t(n,a,e);const ge="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(ge);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:n,worksheet:a})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(ge),c=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(c&&c.row===e.location.row&&c.col===e.location.col&&c.subUnitId===e.location.subUnitId&&c.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(ge);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(ge);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(r,e.location),location:e.location,width:200,height:74,key:ge});return}}this._cellAlertManagerService.removeAlert(ge)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(ge)}))}};Oe=$t([Ie(0,o.Inject(N.HoverManagerService)),Ie(1,o.Inject(N.CellAlertManagerService)),Ie(2,o.IUniverInstanceService),Ie(3,o.Inject(o.LocaleService)),Ie(4,E.IZenZoneService),Ie(5,o.Inject(C.SheetDataValidationModel))],Oe);var Ht=Object.getOwnPropertyDescriptor,Yt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ht(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ye=(e,t)=>(n,a)=>t(n,a,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,r)=>{const{source:i,target:s,unitId:c,subUnitId:l}=a,d=this._sheetDataValidationModel.getRuleObjectMatrix(c,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[v,u]=h.ranges,{mapFunc:S}=h,p={row:v.startRow,col:v.startColumn},O=N.getAutoFillRepeatRange(v,u),M=new o.ObjectMatrix,R=new Set;O.forEach(f=>{const w=f.repeatStartCell,F=f.relativeRange,B={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},j={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(F,(W,A)=>{const x=o.Rectangle.getPositionRange({startRow:W,startColumn:A,endColumn:A,endRow:W},B),{row:k,col:z}=S(x.startRow,x.startColumn),q=this._sheetDataValidationModel.getRuleIdByLocation(c,l,k,z)||"",te=o.Rectangle.getPositionRange({startRow:W,startColumn:A,endColumn:A,endRow:W},j),{row:K,col:ne}=S(te.startRow,te.startColumn);M.setValue(K,ne,q),R.add(q)})});const y=Array.from(R).map(f=>({id:f,ranges:o.queryObjectMatrix(M,w=>w===f)}));d.addRangeRules(y);const m=d.diff(this._sheetDataValidationModel.getRules(c,l)),{redoMutations:D,undoMutations:I}=C.getDataValidationDiffMutations(c,l,m,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:D}},n={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:r,unitId:i,subUnitId:s}=a;for(const c of r.rows)for(const l of r.cols){const d=this._sheetDataValidationModel.getRuleByLocation(i,s,c,l);if(d&&d.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(a,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Yt([Ye(0,N.IAutoFillService),Ye(1,o.Inject(C.SheetDataValidationModel)),Ye(2,o.Inject(o.Injector))],we);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(n,a)=>t(n,a,e);let Ve=class extends o.Disposable{constructor(t,n,a){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:c}=t||{},{range:l,unitId:d,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:c,unitId:d,subUnitId:h})}})}_collect(t,n,a){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(a,l,t,n));if(!i)return;const{rows:s,cols:c}=i;s.forEach((l,d)=>{c.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);r.setValue(d,v,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(n.unitId!==r||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]),u=N.getRepeatRange(d,h,!0),S=new Map;u.forEach(({startRange:R})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((m,D,I)=>{const f=o.Rectangle.getPositionRange({startRow:m,endRow:m,startColumn:D,endColumn:D},R),w=`${i}-${I}`,F=this._sheetDataValidationModel.getRuleById(r,i,I);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,w)&&F&&S.set(w,{...F,uid:w});const{row:B,col:j}=v(f.startRow,f.startColumn);l.add(w),c.setValue(B,j,w)})});const p=Array.from(l).map(R=>({id:R,ranges:o.queryObjectMatrix(c,y=>y===R)}));s.addRangeRules(p);const{redoMutations:O,undoMutations:M}=C.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:O,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]);N.getRepeatRange(d,h,!0).forEach(({startRange:M})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((y,m,D)=>{const I=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:m,endColumn:m},M),{row:f,col:w}=v(I.startRow,I.startColumn);c.setValue(f,w,D),l.add(D)})});const S=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(c,R=>R===M)}));s.addRangeRules(S);const{redoMutations:p,undoMutations:O}=C.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:p,undos:O}}}};Ve=zt([Xe(0,N.ISheetClipboardService),Xe(1,o.Inject(C.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var Kt=Object.getOwnPropertyDescriptor,Zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends o.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===C.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:a}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===C.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:a}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=Zt([ze(0,o.Inject(o.LocaleService)),ze(1,o.ICommandService),ze(2,o.Inject(H.SheetPermissionCheckController))],Ee);const It="sheet.menu.data-validation";function Gt(e){return{id:It,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function qt(e){return{id:fe.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Jt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const Qt={[E.RibbonDataGroup.RULES]:{[It]:{order:0,menuItemFactory:Gt,[fe.id]:{order:0,menuItemFactory:qt},[$e.id]:{order:1,menuItemFactory:Jt}}}};var en=Object.getOwnPropertyDescriptor,Ct=(e,t,n,a)=>{for(var r=a>1?void 0:a?en(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(n,a)=>t(n,a,e);const yt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s,c,l,d,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=c,this._sheetInterceptorService=l,this._dataValidationCacheService=d,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:r,row:i,column:s}=t,c=this._univerInstanceService.getUniverSheetInstance(a);if(!c)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,r,i,s);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(d!=null&&d.dropdownType))return;const h=c.getActiveSheet();if(!h)return;const v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===a&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:r,row:i,col:s,workbook:c,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var R,y,m,D,I;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const v=(R=this._dataValidationCacheService.getValue(i,s,a,r))!=null?R:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let p;const O={get value(){var f;return p!==void 0||(p=(f=C.getCellValueOrigin(S))!=null?f:null),p}},M={get value(){var f;return`${(f=O.value)!=null?f:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((m=e==null?void 0:e.fontRenderExtension)==null?void 0:m.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,O.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const f=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?f.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var B,j,W,A,x,k;const f=(j=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(a,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((W=w==null?void 0:w.startRow)!=null?W:a,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(k=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:k.call(x,F)},e.interceptorAutoWidth=()=>{var B,j,W,A,x,k;const f=(j=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(a,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((W=w==null?void 0:w.startRow)!=null?W:a,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(k=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:k.call(x,F)},e.coverable=((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=Ct([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(me)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],Me);let gt=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var M,R,y,m,D;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const v=(M=this._dataValidationCacheService.getValue(i,s,a,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(a,r),p=C.getCellValueOrigin(S),O=`${p!=null?p:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt:null},e.customRender=[...(R=e==null?void 0:e.customRender)!=null?R:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((m=u==null?void 0:u.skipDefaultFontRender)==null?void 0:m.call(u,h,p,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const I=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var F,B,j,W,A,x;const I=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(a,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((j=f==null?void 0:f.startRow)!=null?j:a,(W=f==null?void 0:f.startColumn)!=null?W:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoHeight)==null?void 0:x.call(A,w)},e.interceptorAutoWidth=()=>{var F,B,j,W,A,x;const I=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(a,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((j=f==null?void 0:f.startRow)!=null?j:a,(W=f==null?void 0:f.startColumn)!=null?W:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoWidth)==null?void 0:x.call(A,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};gt=Ct([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],gt);var tn=Object.getOwnPropertyDescriptor,nn=(e,t,n,a)=>{for(var r=a>1?void 0:a?tn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(n,a)=>t(n,a,e);let Fe=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(r=>{n.add(r.subUnitId)}),n.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Fe=nn([pt(1,o.Inject(C.SheetDataValidationModel)),pt(2,o.Inject(N.SheetSkeletonManagerService))],Fe);function Se({ref:e,...t}){const{icon:n,id:a,className:r,extend:i,...s}=t,c=`univerjs-icon univerjs-icon-${a} ${r||""}`.trim(),l=T.useRef(`_${on()}`);return Rt(n,`${a}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},i)}function Rt(e,t,n,a,r){return T.createElement(e.tag,{key:t,...an(e,n,r),...a},(rn(e,n).children||[]).map((i,s)=>Rt(i,`${t}-${e.tag}-${s}`,n,void 0,r)))}function an(e,t,n){const a={...e.attrs};n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:r}=t;return!r||r.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(([i,s])=>{typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),a}function rn(e,t){var a;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((a=e.children)!=null&&a.length)?{...e,children:e.children.map(r=>typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+t.idSuffix}}:r)}:e}function on(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const sn={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"}}]},Dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:sn}))});Dt.displayName="DataValidationIcon";const ln={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"}}]},ct=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:ln}))});ct.displayName="DeleteIcon";const cn={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"}}]},wt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:cn}))});wt.displayName="IncreaseIcon";const dn={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"}}]},dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:dn}))});dt.displayName="MoreDownIcon";const un={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"}}]},Vt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:un}))});Vt.displayName="MoreUpIcon";const hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Et=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:hn}))});Et.displayName="SequenceIcon";function gn(e){var d;const t=E.useDependency(o.LocaleService),n=E.useDependency(E.ComponentManager),{value:a,onChange:r,extraComponent:i}=e,[s,c]=T.useState(!1),l=i?n.get(i):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Vt,{className:"univer-ml-1"}):g.jsx(dt,{className:"univer-ml-1"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:r}):null,g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(V.RadioGroup,{value:`${(d=a.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...a,errorStyle:+h}),children:[g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(V.Checkbox,{checked:a.showErrorMessage,onChange:()=>r({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(V.FormLayout,{children:g.jsx(V.Input,{value:a.error,onChange:h=>r({...a,error:h})})}):null]})]})}const pn=e=>o.debounce(async(t,n,a,r)=>{const i=await e.executeCommand(t,n,a);r==null||r(i)},1e3);function vn(e,t,n){var a,r,i,s;return t?((r=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function mn(){var b,$;const[e,t]=T.useState(0),n=E.useDependency(ce),a=E.useObservable(n.activeRule$,n.activeRule),{unitId:r,subUnitId:i,rule:s}=a||{},c=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),v=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),S=E.useDependency(o.LocaleService),[p,O]=T.useState(s),M=l.getValidatorItem(p.type),[R,y]=T.useState(!1),m=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,I]=T.useState(()=>p.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),f=T.useMemo(()=>pn(v),[v]),[w,F]=T.useState(!1),[B,j]=T.useState(!1),W=T.useRef(null),A=E.useDependency(H.SheetsSelectionsService);if(T.useEffect(()=>()=>{const _=A.getCurrentLastSelection();_&&A.setSelections([_])},[A]),T.useEffect(()=>{v.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const U=u.getRuleById(r,i,c);t(X=>X+1),U&&(O(U),I(U.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[v,u,c,i,r]),!M)return null;const x=M.operators,k=M.operatorNames,z=p.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,q=()=>{var _,U,X;(U=(_=W.current)==null?void 0:_.editor)!=null&&U.isFocus()&&te((X=W.current)==null?void 0:X.getValue()),!(!p.ranges.length||w)&&(M.validatorFormula(p,r,i).success?n.setActiveRule(null):y(!0))},te=E.useEvent(_=>{const U=_.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(ee=>{const ut=ee.sheetName;if(ut){const Ot=vn(d,ee.unitId,ut);return{...ee,sheetId:Ot}}return{...ee,sheetId:""}});if(o.isUnitRangesEqual(U,D))return;I(U);const X=U.filter(ee=>(!ee.unitId||ee.unitId===r)&&(!ee.sheetId||ee.sheetId===i)).map(ee=>ee.range);if(O({...p,ranges:X}),X.length===0)return;const ie={unitId:r,subUnitId:i,ruleId:c,ranges:X};f(C.UpdateSheetDataValidationRangeCommand.id,ie)}),K=_=>{if(o.shallowEqual(_,Y.getRuleSetting(p)))return;O({...p,..._});const U={unitId:r,subUnitId:i,ruleId:c,setting:_};f(C.UpdateSheetDataValidationSettingCommand.id,U,void 0)},ne=async()=>{await v.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:r,subUnitId:i}),n.setActiveRule(null)},ae={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},de=_=>{const U=l.getValidatorItem(_);if(!U)return;const X=U.operators,ie=u.getRuleById(r,i,c),ee=_===(ie==null?void 0:ie.type)||_.includes("list")&&(ie!=null&&ie.type.includes("list"))?{...ie,type:_}:{...p,type:_,operator:X[0],formula1:void 0,formula2:void 0};O(ee),v.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:p.uid,setting:Y.getRuleSetting(ee)})},ue=h.get(M.formulaInput),Q=T.useMemo(()=>D.map(_=>tt.serializeRange(_.range)).join(","),[]),Z=Y.getRuleOptions(p),le=_=>{o.shallowEqual(_,Y.getRuleOptions(p))||(O({...p,..._}),f(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:c,options:_}))},J=x.length&&!p.operator;return g.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.range"),error:!p.ranges.length||w?S.t("dataValidation.panel.rangeError"):"",children:g.jsx(ot.RangeSelector,{selectorRef:W,unitId:r,subUnitId:i,initialValue:Q,onChange:(_,U)=>{var X;!B&&((X=W.current)!=null&&X.verify())&&te(U)},onFocusChange:(_,U)=>{var X;j(_),!_&&U&&((X=W.current)!=null&&X.verify())&&te(U)},onVerify:_=>F(!_)})}),g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.type"),children:g.jsx(V.Select,{className:"univer-w-full",value:p.type,options:(b=m==null?void 0:m.sort((_,U)=>_.order-U.order))==null?void 0:b.map(_=>({label:S.t(_.title),value:_.id})),onChange:de})}),x!=null&&x.length?g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.operator"),children:g.jsx(V.Select,{className:"univer-w-full",value:`${p.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...x.map((_,U)=>({value:`${_}`,label:k[U]}))],onChange:_=>{K({...ae,operator:_})}})}):null,ue&&!J?g.jsx(ue,{isTwoFormula:z,value:{formula1:p.formula1,formula2:p.formula2},onChange:_=>{K({...ae,..._})},showError:R,validResult:M.validatorFormula(p,r,i),unitId:r,subUnitId:i,ruleId:c},e+p.type):null,g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:($=p.allowBlank)!=null?$:!0,onChange:()=>{var _;return K({...ae,allowBlank:!((_=p.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(gn,{value:Z,onChange:le,extraComponent:M.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(V.Button,{className:"univer-ml-3",onClick:ne,children:S.t("dataValidation.panel.removeRule")}),g.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:q,children:S.t("dataValidation.panel.done")})]})]})}const fn=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),d=s.getValidatorItem(t.type),h=T.useRef(void 0),[v,u]=T.useState(!1),S=E.useDependency(o.ThemeService),p=E.useObservable(S.currentTheme$),O=T.useMemo(()=>{var I;const R=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),m=(I=S.getColorFromTheme(y))!=null?I:R,D=new o.ColorKit(m).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:m}},[p]),M=R=>{c.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:r}),R.stopPropagation()};return T.useEffect(()=>()=>{var R;h.current&&((R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}))},[l]),g.jsxs("div",{className:V.clsx(`
|
|
1
|
+
"use strict";var At=Object.defineProperty;var Lt=(e,t,n)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var L=(e,t,n)=>Lt(e,typeof t!="symbol"?t+"":t,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@univerjs/core"),P=require("@univerjs/engine-render"),H=require("@univerjs/sheets"),C=require("@univerjs/sheets-data-validation"),Y=require("@univerjs/data-validation"),E=require("@univerjs/ui"),re=require("rxjs"),Pt=require("@univerjs/sheets-numfmt"),N=require("@univerjs/sheets-ui"),V=require("@univerjs/design"),T=require("react"),g=require("react/jsx-runtime"),tt=require("@univerjs/engine-formula"),ot=require("@univerjs/sheets-formula-ui");var jt=Object.getOwnPropertyDescriptor,xt=(e,t,n,a)=>{for(var r=a>1?void 0:a?jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ht=(e,t)=>(n,a)=>t(n,a,e);let ce=class extends o.Disposable{constructor(t,n){super();L(this,"_open$",new re.BehaviorSubject(!1));L(this,"open$",this._open$.pipe(re.distinctUntilChanged()));L(this,"_activeRule");L(this,"_activeRule$",new re.BehaviorSubject(void 0));L(this,"activeRule$",this._activeRule$.asObservable());L(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(re.filter(a=>!a)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(a=>{a.id===Ue&&(a.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};ce=xt([ht(0,o.IUniverInstanceService),ht(1,E.ISidebarService)],ce);const ve="#ECECEC",st="sheets-data-validation-ui.config",xe={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},_e=(e,t)=>(n,a)=>t(n,a,e);let De=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=a,this._localeService=r,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(H.VALIDATE_CELL,{handler:async(e,t,n)=>{const a=await e,{row:r,col:i,unitId:s,subUnitId:c}=t,l=this._dataValidationModel.getRuleIdByLocation(s,c,r,i),d=l?this._dataValidationModel.getRuleById(s,c,l):void 0;if(a===!1)return n(Promise.resolve(!1));if(!d||d.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(d.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,c,r,i)===o.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(d,{row:r,col:i,unitId:s,subUnitId:c})},footer:{title:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:T.createElement(V.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};De=Ft([_e(0,o.Inject(H.SheetInterceptorService)),_e(1,o.Inject(C.SheetDataValidationModel)),_e(2,o.Inject(Y.DataValidatorRegistryService)),_e(3,E.IDialogService),_e(4,o.Inject(o.LocaleService)),_e(5,o.Inject(C.SheetsDataValidationValidatorService))],De);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,a)=>{for(var r=a>1?void 0:a?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},oe=(e,t)=>(n,a)=>t(n,a,e);const He=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function Bt(e,t){const n=Pt.getPatternType(t);if(e===n)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 me=class extends o.Disposable{constructor(t,n,a,r,i,s,c,l,d,h,v){super();L(this,"_activeDropdown");L(this,"_activeDropdown$",new re.Subject);L(this,"_currentPopup",null);L(this,"activeDropdown$",this._activeDropdown$.asObservable());L(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=a,this._dataValidationModel=r,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=c,this._commandService=l,this._editorBridgeService=d,this._injector=h,this._configService=v,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,a,r){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const c=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),a,r);if(!c)return;const l=this._dataValidatorRegistryService.getValidatorItem(c.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var O,M,R,y;const{location:n}=t,{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const d=this._sheetDataValidationModel.getRuleByLocation(i,s,a,r);if(!d)return;const h=this._dataValidatorRegistryService.getValidatorItem(d.type);if(!(h!=null&&h.dropdownType))return;let v;const u=async(m,D)=>{var A,x,k;if(!m)return!0;const I=m,f=l.getCell(a,r),w=I.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),F=(A=o.numfmt.parseDate(w))==null?void 0:A.v,B=D==="time"?F%1:F,j=c.getStyles().getStyleByCell(f),W=(k=(x=j==null?void 0:j.n)==null?void 0:x.pattern)!=null?k:"";return d.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:B,unitId:i,subUnitId:s,row:a,column:r,worksheet:l,workbook:c,interceptValue:w.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},d)?(await this._commandService.executeCommand(H.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:B,t:2,p:null,f:null,si:null,s:{n:{pattern:Bt(D,W)}}}}),await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0):(this._injector.has(De)&&this._injector.get(De).showReject(h.getRuleFinalError(d,{row:a,col:r,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case Y.DataValidatorDropdownType.DATE:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m),I=!!((O=d.bizInfo)!=null&&O.showTime);S={location:n,type:"datepicker",props:{showTime:I,onChange:f=>u(f,I?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case Y.DataValidatorDropdownType.TIME:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"time"),defaultValue:D,patternType:"time"}};break}case Y.DataValidatorDropdownType.DATETIME:{const m=C.getCellValueOrigin(l.getCellRaw(a,r)),D=He(m);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"datetime"),defaultValue:D,patternType:"datetime"}};break}case Y.DataValidatorDropdownType.LIST:case Y.DataValidatorDropdownType.MULTIPLE_LIST:{const m=h.dropdownType===Y.DataValidatorDropdownType.MULTIPLE_LIST,D=async j=>{const W=C.serializeListOptions(j),A={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:W,p:null,f:null,si:null}};return this._commandService.executeCommand(H.SetRangeValuesCommand.id,A),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!m},I=(d==null?void 0:d.renderMode)===o.DataValidationRenderMode.CUSTOM||(d==null?void 0:d.renderMode)===void 0,f=h.getListWithColor(d,i,s),w=C.getDataValidationCellValue(l.getCellRaw(a,r)),F=()=>{this._commandService.executeCommand(fe.id,{ruleId:d.uid}),v==null||v.dispose()},B=f.map(j=>({label:j.label,value:j.label,color:I||j.color?j.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:j=>D(j),options:B,onEdit:F,defaultValue:w,multiple:m,showEdit:(R=(M=this._configService.getConfig(st))==null?void 0:M.showEditOnDropdown)!=null?R:!0}};break}case Y.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(a,r)).split("/"),options:JSON.parse((y=d.formula1)!=null?y:"[]")},location:n};break}case Y.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:r,endColumn:r,startRow:a,endRow:a},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(H.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(N.SetCellEditVisibleOperation.id,{visible:!1,eventType:P.DeviceInputEventType.Keyboard,unitId:i,keycode:E.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(a,r))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(v=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!v)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const p=new o.DisposableCollection;p.add(v),p.add({dispose:()=>{var m,D;(D=(m=this._activeDropdown)==null?void 0:m.onHide)==null||D.call(m)}}),this._currentPopup=p}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,a,r,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const c=s.getSheetBySheetId(n);if(!c)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),c.getSheetId(),a,r);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!d||!d.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:c,row:a,col:r,unitId:t,subUnitId:n},onHide:i})}};me=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(Y.DataValidatorRegistryService)),oe(2,E.IZenZoneService),oe(3,o.Inject(C.SheetDataValidationModel)),oe(4,o.Inject(H.SheetsSelectionsService)),oe(5,o.Inject(N.ISheetCellDropdownManagerService)),oe(6,o.Inject(C.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,N.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],me);const Ue="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:a}=t,r=e.get(ce),i=e.get(Y.DataValidationModel),s=e.get(o.IUniverInstanceService),c=e.get(E.ISidebarService),l=H.getSheetCommandTarget(s);if(!l)return!1;const{unitId:d,subUnitId:h}=l,v=n?i.getRuleById(d,h,n):void 0;r.open(),r.setActiveRule(v&&{unitId:d,subUnitId:h,rule:v});const u=c.open({id:Ue,header:{title:a?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Ue},width:312,onClose:()=>r.close()});return r.setCloseDisposable(u),!0}},lt={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(ce).close(),!0}},St={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(ce);return n.open(),n.isOpen?t.executeCommand(lt.id):t.executeCommand(fe.id),!0}},We={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(me),{unitId:a,subUnitId:r,row:i,column:s}=t,c=n.activeDropdown,l=c==null?void 0:c.location;return l&&l.unitId===a&&l.subUnitId===r&&l.row===i&&l.col===s||n.showDataValidationDropdown(a,r,i,s),!0}},_t={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(me).hideDropdown(),!0):!1}},$e={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=H.getSheetCommandTarget(t);if(!n)return!1;const{workbook:a,worksheet:r}=n,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),c=a.getUnitId(),l=r.getSheetId(),d={rule:i,unitId:c,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,d)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Wt=Object.getOwnPropertyDescriptor,$t=(e,t,n,a)=>{for(var r=a>1?void 0:a?Wt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ie=(e,t)=>(n,a)=>t(n,a,e);const ge="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,a,r,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=a,this._zenZoneService=r,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(re.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),a=n.getSheetBySheetId(e.location.subUnitId);if(!a)return;const r=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!r){this._cellAlertManagerService.removeAlert(ge);return}if(this._dataValidationModel.validator(r,{...e.location,workbook:n,worksheet:a})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(ge),c=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(c&&c.row===e.location.row&&c.col===e.location.col&&c.subUnitId===e.location.subUnitId&&c.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(ge);return}const l=this._dataValidationModel.getValidator(r.type);if(!l){this._cellAlertManagerService.removeAlert(ge);return}this._cellAlertManagerService.showAlert({type:N.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(r,e.location),location:e.location,width:200,height:74,key:ge});return}}this._cellAlertManagerService.removeAlert(ge)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(ge)}))}};Oe=$t([Ie(0,o.Inject(N.HoverManagerService)),Ie(1,o.Inject(N.CellAlertManagerService)),Ie(2,o.IUniverInstanceService),Ie(3,o.Inject(o.LocaleService)),Ie(4,E.IZenZoneService),Ie(5,o.Inject(C.SheetDataValidationModel))],Oe);var Ht=Object.getOwnPropertyDescriptor,Yt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Ht(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Ye=(e,t)=>(n,a)=>t(n,a,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(a,r)=>{const{source:i,target:s,unitId:c,subUnitId:l}=a,d=this._sheetDataValidationModel.getRuleObjectMatrix(c,l).clone(),h=N.virtualizeDiscreteRanges([i,s]),[v,u]=h.ranges,{mapFunc:S}=h,p={row:v.startRow,col:v.startColumn},O=N.getAutoFillRepeatRange(v,u),M=new o.ObjectMatrix,R=new Set;O.forEach(f=>{const w=f.repeatStartCell,F=f.relativeRange,B={startRow:p.row,startColumn:p.col,endColumn:p.col,endRow:p.row},j={startRow:w.row,startColumn:w.col,endColumn:w.col,endRow:w.row};o.Range.foreach(F,(W,A)=>{const x=o.Rectangle.getPositionRange({startRow:W,startColumn:A,endColumn:A,endRow:W},B),{row:k,col:z}=S(x.startRow,x.startColumn),q=this._sheetDataValidationModel.getRuleIdByLocation(c,l,k,z)||"",te=o.Rectangle.getPositionRange({startRow:W,startColumn:A,endColumn:A,endRow:W},j),{row:K,col:ne}=S(te.startRow,te.startColumn);M.setValue(K,ne,q),R.add(q)})});const y=Array.from(R).map(f=>({id:f,ranges:o.queryObjectMatrix(M,w=>w===f)}));d.addRangeRules(y);const m=d.diff(this._sheetDataValidationModel.getRules(c,l)),{redoMutations:D,undoMutations:I}=C.getDataValidationDiffMutations(c,l,m,this._injector,"patched",r===N.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:D}},n={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:a=>{const{source:r,unitId:i,subUnitId:s}=a;for(const c of r.rows)for(const l of r.cols){const d=this._sheetDataValidationModel.getRuleByLocation(i,s,c,l);if(d&&d.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(N.APPLY_TYPE.SERIES,!0);return}}},onFillData:(a,r,i)=>i===N.APPLY_TYPE.COPY||i===N.APPLY_TYPE.ONLY_FORMAT||i===N.APPLY_TYPE.SERIES?t(a,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Yt([Ye(0,N.IAutoFillService),Ye(1,o.Inject(C.SheetDataValidationModel)),Ye(2,o.Inject(o.Injector))],we);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},Xe=(e,t)=>(n,a)=>t(n,a,e);let Ve=class extends o.Disposable{constructor(t,n,a){super();L(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=a,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,a)=>this._collect(t,n,a),onPasteCells:(t,n,a,r)=>{const{copyType:i=N.COPY_TYPE.COPY,pasteType:s}=r,{range:c}=t||{},{range:l,unitId:d,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:c,unitId:d,subUnitId:h})}})}_collect(t,n,a){const r=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:r};const i=this._injector.invoke(l=>H.rangeToDiscreteRange(a,l,t,n));if(!i)return;const{rows:s,cols:c}=i;s.forEach((l,d)=>{c.forEach((h,v)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);r.setValue(d,v,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===N.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,N.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:r,subUnitId:i}=this._copyInfo;if(n.unitId!==r||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]),u=N.getRepeatRange(d,h,!0),S=new Map;u.forEach(({startRange:R})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((m,D,I)=>{const f=o.Rectangle.getPositionRange({startRow:m,endRow:m,startColumn:D,endColumn:D},R),w=`${i}-${I}`,F=this._sheetDataValidationModel.getRuleById(r,i,I);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,w)&&F&&S.set(w,{...F,uid:w});const{row:B,col:j}=v(f.startRow,f.startColumn);l.add(w),c.setValue(B,j,w)})});const p=Array.from(l).map(R=>({id:R,ranges:o.queryObjectMatrix(c,y=>y===R)}));s.addRangeRules(p);const{redoMutations:O,undoMutations:M}=C.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:O,undos:M}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(r,i).clone(),c=new o.ObjectMatrix,l=new Set,{ranges:[d,h],mapFunc:v}=N.virtualizeDiscreteRanges([n.copyRange,t]);N.getRepeatRange(d,h,!0).forEach(({startRange:M})=>{var R;(R=this._copyInfo)==null||R.matrix.forValue((y,m,D)=>{const I=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:m,endColumn:m},M),{row:f,col:w}=v(I.startRow,I.startColumn);c.setValue(f,w,D),l.add(D)})});const S=Array.from(l).map(M=>({id:M,ranges:o.queryObjectMatrix(c,R=>R===M)}));s.addRangeRules(S);const{redoMutations:p,undoMutations:O}=C.getDataValidationDiffMutations(r,i,s.diff(this._sheetDataValidationModel.getRules(r,i)),this._injector,"patched",!1);return{redos:p,undos:O}}}};Ve=zt([Xe(0,N.ISheetClipboardService),Xe(1,o.Inject(C.SheetDataValidationModel)),Xe(2,o.Inject(o.Injector))],Ve);var Kt=Object.getOwnPropertyDescriptor,Zt=(e,t,n,a)=>{for(var r=a>1?void 0:a?Kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},ze=(e,t)=>(n,a)=>t(n,a,e);let Ee=class extends o.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===C.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:a}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===C.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:a}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[H.WorkbookEditablePermission],rangeTypes:[H.RangeProtectionPermissionEditPoint],worksheetTypes:[H.WorksheetEditPermission,H.WorksheetSetCellStylePermission]},a,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=Zt([ze(0,o.Inject(o.LocaleService)),ze(1,o.ICommandService),ze(2,o.Inject(H.SheetPermissionCheckController))],Ee);const It="sheet.menu.data-validation";function Gt(e){return{id:It,type:E.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:E.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:N.getCurrentRangeDisable$(e,{workbookTypes:[H.WorkbookEditablePermission],worksheetTypes:[H.WorksheetSetCellStylePermission,H.WorksheetEditPermission],rangeTypes:[H.RangeProtectionPermissionEditPoint]})}}function qt(e){return{id:fe.id,title:"dataValidation.panel.title",type:E.MenuItemType.BUTTON}}function Jt(e){return{id:$e.id,title:"dataValidation.panel.add",type:E.MenuItemType.BUTTON}}const Qt={[E.RibbonDataGroup.RULES]:{[It]:{order:0,menuItemFactory:Gt,[fe.id]:{order:0,menuItemFactory:qt},[$e.id]:{order:1,menuItemFactory:Jt}}}};var en=Object.getOwnPropertyDescriptor,Ct=(e,t,n,a)=>{for(var r=a>1?void 0:a?en(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},G=(e,t)=>(n,a)=>t(n,a,e);const yt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s,c,l,d,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=a,this._autoHeightController=r,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=c,this._sheetInterceptorService=l,this._dataValidationCacheService=d,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(Qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:a,sheetId:r,row:i,column:s}=t,c=this._univerInstanceService.getUniverSheetInstance(a);if(!c)return;const l=this._sheetDataValidationModel.getRuleByLocation(a,r,i,s);if(!l)return;const d=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(d!=null&&d.dropdownType))return;const h=c.getActiveSheet();if(!h)return;const v=this._dropdownManagerService.activeDropdown,u=v==null?void 0:v.location;if(u&&u.unitId===a&&u.subUnitId===r&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:a,subUnitId:r,row:i,col:s,workbook:c,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var R,y,m,D,I;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const v=(R=this._dataValidationCacheService.getValue(i,s,a,r))!=null?R:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let p;const O={get value(){var f;return p!==void 0||(p=(f=C.getCellValueOrigin(S))!=null?f:null),p}},M={get value(){var f;return`${(f=O.value)!=null?f:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((m=e==null?void 0:e.fontRenderExtension)==null?void 0:m.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,O.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,M.value,{get style(){const f=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?f.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var B,j,W,A,x,k;const f=(j=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(a,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((W=w==null?void 0:w.startRow)!=null?W:a,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(k=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoHeight)==null?void 0:k.call(x,F)},e.interceptorAutoWidth=()=>{var B,j,W,A,x,k;const f=(j=(B=this._renderManagerService.getRenderById(i))==null?void 0:B.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:j.skeleton;if(!f)return;const w=f.worksheet.getMergedCell(a,r),F={data:e,style:f.getStyles().getStyleByCell(e),primaryWithCoord:f.getCellWithCoordByIndex((W=w==null?void 0:w.startRow)!=null?W:a,(A=w==null?void 0:w.startColumn)!=null?A:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(k=(x=u==null?void 0:u.canvasRender)==null?void 0:x.calcCellAutoWidth)==null?void 0:k.call(x,F)},e.coverable=((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=Ct([G(0,o.ICommandService),G(1,E.IMenuManagerService),G(2,P.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(N.AutoHeightController)),G(5,o.Inject(me)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(Y.DataValidatorRegistryService)),G(8,o.Inject(H.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(N.IEditorBridgeService))],Me);let gt=class extends o.RxDisposable{constructor(e,t,n,a,r,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=a,this._sheetInterceptorService=r,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(H.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:H.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var M,R,y,m,D;const{row:a,col:r,unitId:i,subUnitId:s,workbook:c,worksheet:l}=t,d=this._sheetDataValidationModel.getRuleIdByLocation(i,s,a,r);if(!d)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,d);if(!h)return n(e);const v=(M=this._dataValidationCacheService.getValue(i,s,a,r))!=null?M:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(a,r),p=C.getCellValueOrigin(S),O=`${p!=null?p:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...v===o.DataValidationStatus.INVALID?yt:null},e.customRender=[...(R=e==null?void 0:e.customRender)!=null?R:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((m=u==null?void 0:u.skipDefaultFontRender)==null?void 0:m.call(u,h,p,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,O,{get style(){const I=c.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},a,r)},e.interceptorAutoHeight=()=>{var F,B,j,W,A,x;const I=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(a,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((j=f==null?void 0:f.startRow)!=null?j:a,(W=f==null?void 0:f.startColumn)!=null?W:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoHeight)==null?void 0:x.call(A,w)},e.interceptorAutoWidth=()=>{var F,B,j,W,A,x;const I=(B=(F=this._renderManagerService.getRenderById(i))==null?void 0:F.with(N.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:B.skeleton;if(!I)return;const f=I.worksheet.getMergedCell(a,r),w={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((j=f==null?void 0:f.startRow)!=null?j:a,(W=f==null?void 0:f.startColumn)!=null?W:r),unitId:i,subUnitId:s,row:a,col:r,workbook:c,worksheet:l};return(x=(A=u==null?void 0:u.canvasRender)==null?void 0:A.calcCellAutoWidth)==null?void 0:x.call(A,w)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(re.filter(e=>e.source==="command"),re.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var a;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(a=n.rule)!=null&&a.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};gt=Ct([G(0,o.ICommandService),G(1,P.IRenderManagerService),G(2,o.Inject(N.AutoHeightController)),G(3,o.Inject(Y.DataValidatorRegistryService)),G(4,o.Inject(H.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],gt);var tn=Object.getOwnPropertyDescriptor,nn=(e,t,n,a)=>{for(var r=a>1?void 0:a?tn(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(r=s(r)||r);return r},pt=(e,t)=>(n,a)=>t(n,a,e);let Fe=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var a;if(!t.length)return;const n=new Set;t.forEach(r=>{n.add(r.subUnitId)}),n.forEach(r=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(r))==null||i.skeleton.makeDirty(!0)}),(a=this._context.mainComponent)==null||a.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};Fe=nn([pt(1,o.Inject(C.SheetDataValidationModel)),pt(2,o.Inject(N.SheetSkeletonManagerService))],Fe);function Se({ref:e,...t}){const{icon:n,id:a,className:r,extend:i,...s}=t,c=`univerjs-icon univerjs-icon-${a} ${r||""}`.trim(),l=T.useRef(`_${on()}`);return Rt(n,`${a}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:c,...s},i)}function Rt(e,t,n,a,r){return T.createElement(e.tag,{key:t,...an(e,n,r),...a},(rn(e,n).children||[]).map((i,s)=>Rt(i,`${t}-${e.tag}-${s}`,n,void 0,r)))}function an(e,t,n){const a={...e.attrs};n!=null&&n.colorChannel1&&a.fill==="colorChannel1"&&(a.fill=n.colorChannel1),e.tag==="mask"&&a.id&&(a.id=a.id+t.idSuffix),Object.entries(a).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:r}=t;return!r||r.length===0||(e.tag==="use"&&a["xlink:href"]&&(a["xlink:href"]=a["xlink:href"]+t.idSuffix),Object.entries(a).forEach(([i,s])=>{typeof s=="string"&&(a[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),a}function rn(e,t){var a;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((a=e.children)!=null&&a.length)?{...e,children:e.children.map(r=>typeof r.attrs.id=="string"&&n&&n.includes(r.attrs.id)?{...r,attrs:{...r.attrs,id:r.attrs.id+t.idSuffix}}:r)}:e}function on(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const sn={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"}}]},Dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:sn}))});Dt.displayName="DataValidationIcon";const ln={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"}}]},ct=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:ln}))});ct.displayName="DeleteIcon";const cn={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"}}]},wt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:cn}))});wt.displayName="IncreaseIcon";const dn={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"}}]},dt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:dn}))});dt.displayName="MoreDownIcon";const un={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"}}]},Vt=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:un}))});Vt.displayName="MoreUpIcon";const hn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Et=T.forwardRef(function(t,n){return T.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:hn}))});Et.displayName="SequenceIcon";function gn(e){var d;const t=E.useDependency(o.LocaleService),n=E.useDependency(E.ComponentManager),{value:a,onChange:r,extraComponent:i}=e,[s,c]=T.useState(!1),l=i?n.get(i):null;return g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>c(!s),children:[t.t("dataValidation.panel.options"),s?g.jsx(Vt,{className:"univer-ml-1"}):g.jsx(dt,{className:"univer-ml-1"})]}),s&&g.jsxs(g.Fragment,{children:[l?g.jsx(l,{value:a,onChange:r}):null,g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:g.jsxs(V.RadioGroup,{value:`${(d=a.errorStyle)!=null?d:o.DataValidationErrorStyle.WARNING}`,onChange:h=>r({...a,errorStyle:+h}),children:[g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),g.jsx(V.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),g.jsx(V.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:g.jsx(V.Checkbox,{checked:a.showErrorMessage,onChange:()=>r({...a,showErrorMessage:!a.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),a.showErrorMessage?g.jsx(V.FormLayout,{children:g.jsx(V.Input,{value:a.error,onChange:h=>r({...a,error:h})})}):null]})]})}const pn=e=>o.debounce(async(t,n,a,r)=>{const i=await e.executeCommand(t,n,a);r==null||r(i)},1e3);function vn(e,t,n){var a,r,i,s;return t?((r=(a=e.getUnit(t))==null?void 0:a.getSheetBySheetName(n))==null?void 0:r.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function mn(){var b,$;const[e,t]=T.useState(0),n=E.useDependency(ce),a=E.useObservable(n.activeRule$,n.activeRule),{unitId:r,subUnitId:i,rule:s}=a||{},c=s.uid,l=E.useDependency(Y.DataValidatorRegistryService),d=E.useDependency(o.IUniverInstanceService),h=E.useDependency(E.ComponentManager),v=E.useDependency(o.ICommandService),u=E.useDependency(Y.DataValidationModel),S=E.useDependency(o.LocaleService),[p,O]=T.useState(s),M=l.getValidatorItem(p.type),[R,y]=T.useState(!1),m=l.getValidatorsByScope(Y.DataValidatorRegistryScope.SHEET),[D,I]=T.useState(()=>p.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),f=T.useMemo(()=>pn(v),[v]),[w,F]=T.useState(!1),[B,j]=T.useState(!1),W=T.useRef(null),A=E.useDependency(H.SheetsSelectionsService);if(T.useEffect(()=>()=>{const _=A.getCurrentLastSelection();_&&A.setSelections([_])},[A]),T.useEffect(()=>{v.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const U=u.getRuleById(r,i,c);t(X=>X+1),U&&(O(U),I(U.ranges.map(X=>({unitId:"",sheetId:"",range:X}))))},20)})},[v,u,c,i,r]),!M)return null;const x=M.operators,k=M.operatorNames,z=p.operator?Y.TWO_FORMULA_OPERATOR_COUNT.includes(p.operator):!1,q=()=>{var _,U,X;(U=(_=W.current)==null?void 0:_.editor)!=null&&U.isFocus()&&te((X=W.current)==null?void 0:X.getValue()),!(!p.ranges.length||w)&&(M.validatorFormula(p,r,i).success?n.setActiveRule(null):y(!0))},te=E.useEvent(_=>{const U=_.split(",").filter(Boolean).map(tt.deserializeRangeWithSheet).map(ee=>{const ut=ee.sheetName;if(ut){const Ot=vn(d,ee.unitId,ut);return{...ee,sheetId:Ot}}return{...ee,sheetId:""}});if(o.isUnitRangesEqual(U,D))return;I(U);const X=U.filter(ee=>(!ee.unitId||ee.unitId===r)&&(!ee.sheetId||ee.sheetId===i)).map(ee=>ee.range);if(O({...p,ranges:X}),X.length===0)return;const ie={unitId:r,subUnitId:i,ruleId:c,ranges:X};f(C.UpdateSheetDataValidationRangeCommand.id,ie)}),K=_=>{if(o.shallowEqual(_,Y.getRuleSetting(p)))return;O({...p,..._});const U={unitId:r,subUnitId:i,ruleId:c,setting:_};f(C.UpdateSheetDataValidationSettingCommand.id,U,void 0)},ne=async()=>{await v.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:c,unitId:r,subUnitId:i}),n.setActiveRule(null)},ae={type:p.type,operator:p.operator,formula1:p.formula1,formula2:p.formula2,allowBlank:p.allowBlank},de=_=>{const U=l.getValidatorItem(_);if(!U)return;const X=U.operators,ie=u.getRuleById(r,i,c),ee=_===(ie==null?void 0:ie.type)||_.includes("list")&&(ie!=null&&ie.type.includes("list"))?{...ie,type:_}:{...p,type:_,operator:X[0],formula1:void 0,formula2:void 0};O(ee),v.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:r,subUnitId:i,ruleId:p.uid,setting:Y.getRuleSetting(ee)})},ue=h.get(M.formulaInput),Q=T.useMemo(()=>D.map(_=>tt.serializeRange(_.range)).join(","),[]),Z=Y.getRuleOptions(p),le=_=>{o.shallowEqual(_,Y.getRuleOptions(p))||(O({...p,..._}),f(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:r,subUnitId:i,ruleId:c,options:_}))},J=x.length&&!p.operator;return g.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.range"),error:!p.ranges.length||w?S.t("dataValidation.panel.rangeError"):"",children:g.jsx(ot.RangeSelector,{selectorRef:W,unitId:r,subUnitId:i,initialValue:Q,onChange:(_,U)=>{var X;!B&&((X=W.current)!=null&&X.verify())&&te(U)},onFocusChange:(_,U)=>{var X;j(_),!_&&U&&((X=W.current)!=null&&X.verify())&&te(U)},onVerify:_=>F(!_)})}),g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.type"),children:g.jsx(V.Select,{className:"univer-w-full",value:p.type,options:(b=m==null?void 0:m.sort((_,U)=>_.order-U.order))==null?void 0:b.map(_=>({label:S.t(_.title),value:_.id})),onChange:de})}),x!=null&&x.length?g.jsx(V.FormLayout,{label:S.t("dataValidation.panel.operator"),children:g.jsx(V.Select,{className:"univer-w-full",value:`${p.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...x.map((_,U)=>({value:`${_}`,label:k[U]}))],onChange:_=>{K({...ae,operator:_})}})}):null,ue&&!J?g.jsx(ue,{isTwoFormula:z,value:{formula1:p.formula1,formula2:p.formula2},onChange:_=>{K({...ae,..._})},showError:R,validResult:M.validatorFormula(p,r,i),unitId:r,subUnitId:i,ruleId:c},e+p.type):null,g.jsx(V.FormLayout,{children:g.jsx(V.Checkbox,{checked:($=p.allowBlank)!=null?$:!0,onChange:()=>{var _;return K({...ae,allowBlank:!((_=p.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),g.jsx(gn,{value:Z,onChange:le,extraComponent:M.optionsInput}),g.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[g.jsx(V.Button,{className:"univer-ml-3",onClick:ne,children:S.t("dataValidation.panel.removeRule")}),g.jsx(V.Button,{className:"univer-ml-3",variant:"primary",onClick:q,children:S.t("dataValidation.panel.done")})]})]})}const fn=e=>{const{rule:t,onClick:n,unitId:a,subUnitId:r,disable:i}=e,s=E.useDependency(Y.DataValidatorRegistryService),c=E.useDependency(o.ICommandService),l=E.useDependency(N.IMarkSelectionService),d=s.getValidatorItem(t.type),h=T.useRef(void 0),[v,u]=T.useState(!1),S=E.useDependency(o.ThemeService),p=E.useObservable(S.currentTheme$),O=T.useMemo(()=>{var I;const R=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),m=(I=S.getColorFromTheme(y))!=null?I:R,D=new o.ColorKit(m).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:m}},[p]),M=R=>{c.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:a,subUnitId:r}),R.stopPropagation()};return T.useEffect(()=>()=>{var R;h.current&&((R=h.current)==null||R.forEach(y=>{y&&l.removeShape(y)}))},[l]),g.jsxs("div",{className:V.clsx(`
|
|
2
2
|
univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
|
|
3
3
|
univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
|
|
4
4
|
univer-rounded-md univer-p-2 univer-pr-9
|
package/lib/es/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { DataValidatorRegistryService as Me, DataValidatorDropdownType as pe, Da
|
|
|
9
9
|
import { ISidebarService as sr, IDialogService as uo, IZenZoneService as lr, KeyCode as gt, MenuItemType as gn, getMenuHiddenObservable as ho, RibbonDataGroup as po, IMenuManagerService as go, useDependency as F, ComponentManager as vn, useObservable as Oe, useEvent as tn, useSidebarClick as dr } from "@univerjs/ui";
|
|
10
10
|
import { filter as mn, BehaviorSubject as On, distinctUntilChanged as vo, Subject as mo, debounceTime as cr, bufferTime as ur, of as fo } from "rxjs";
|
|
11
11
|
import { getPatternType as _o } from "@univerjs/sheets-numfmt";
|
|
12
|
-
import { ISheetCellDropdownManagerService as Co, IEditorBridgeService as hr, SetCellEditVisibleOperation as vt, HoverManagerService as So, CellAlertManagerService as Io, CellAlertType as wo, IAutoFillService as Ro, APPLY_TYPE as ot, virtualizeDiscreteRanges as nn, getAutoFillRepeatRange as yo, ISheetClipboardService as Mo, COPY_TYPE as An,
|
|
12
|
+
import { ISheetCellDropdownManagerService as Co, IEditorBridgeService as hr, SetCellEditVisibleOperation as vt, HoverManagerService as So, CellAlertManagerService as Io, CellAlertType as wo, IAutoFillService as Ro, APPLY_TYPE as ot, virtualizeDiscreteRanges as nn, getAutoFillRepeatRange as yo, ISheetClipboardService as Mo, COPY_TYPE as An, PREDEFINED_HOOK_NAME_PASTE as mt, getRepeatRange as Pn, getCurrentRangeDisable$ as bo, AutoHeightController as pr, SheetSkeletonManagerService as lt, IMarkSelectionService as Eo } from "@univerjs/sheets-ui";
|
|
13
13
|
import { Button as Ke, FormLayout as Y, RadioGroup as fn, Radio as Ae, Checkbox as At, Input as Pe, Select as Ln, clsx as ke, borderClassName as Rt, DraggableList as Do, Dropdown as Vo } from "@univerjs/design";
|
|
14
14
|
import { createElement as Ie, useRef as ht, forwardRef as nt, useState as W, useMemo as dt, useEffect as Le } from "react";
|
|
15
15
|
import { jsxs as H, Fragment as ct, jsx as C } from "react/jsx-runtime";
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import { DataValidatorRegistryService as Me, DataValidatorDropdownType as pe, Da
|
|
|
9
9
|
import { ISidebarService as sr, IDialogService as uo, IZenZoneService as lr, KeyCode as gt, MenuItemType as gn, getMenuHiddenObservable as ho, RibbonDataGroup as po, IMenuManagerService as go, useDependency as F, ComponentManager as vn, useObservable as Oe, useEvent as tn, useSidebarClick as dr } from "@univerjs/ui";
|
|
10
10
|
import { filter as mn, BehaviorSubject as On, distinctUntilChanged as vo, Subject as mo, debounceTime as cr, bufferTime as ur, of as fo } from "rxjs";
|
|
11
11
|
import { getPatternType as _o } from "@univerjs/sheets-numfmt";
|
|
12
|
-
import { ISheetCellDropdownManagerService as Co, IEditorBridgeService as hr, SetCellEditVisibleOperation as vt, HoverManagerService as So, CellAlertManagerService as Io, CellAlertType as wo, IAutoFillService as Ro, APPLY_TYPE as ot, virtualizeDiscreteRanges as nn, getAutoFillRepeatRange as yo, ISheetClipboardService as Mo, COPY_TYPE as An,
|
|
12
|
+
import { ISheetCellDropdownManagerService as Co, IEditorBridgeService as hr, SetCellEditVisibleOperation as vt, HoverManagerService as So, CellAlertManagerService as Io, CellAlertType as wo, IAutoFillService as Ro, APPLY_TYPE as ot, virtualizeDiscreteRanges as nn, getAutoFillRepeatRange as yo, ISheetClipboardService as Mo, COPY_TYPE as An, PREDEFINED_HOOK_NAME_PASTE as mt, getRepeatRange as Pn, getCurrentRangeDisable$ as bo, AutoHeightController as pr, SheetSkeletonManagerService as lt, IMarkSelectionService as Eo } from "@univerjs/sheets-ui";
|
|
13
13
|
import { Button as Ke, FormLayout as Y, RadioGroup as fn, Radio as Ae, Checkbox as At, Input as Pe, Select as Ln, clsx as ke, borderClassName as Rt, DraggableList as Do, Dropdown as Vo } from "@univerjs/design";
|
|
14
14
|
import { createElement as Ie, useRef as ht, forwardRef as nt, useState as W, useMemo as dt, useEffect as Le } from "react";
|
|
15
15
|
import { jsxs as H, Fragment as ct, jsx as C } from "react/jsx-runtime";
|
package/lib/umd/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("@univerjs/ui"),require("rxjs"),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/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/data-validation","@univerjs/ui","rxjs","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/design","react","react/jsx-runtime","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsDataValidation,U.UniverDataValidation,U.UniverUi,U.rxjs,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverDesign,U.React,U.React,U.UniverEngineFormula,U.UniverSheetsFormulaUi))})(this,(function(U,o,O,Y,C,X,b,ae,At,W,M,R,p,Ye,Xe){"use strict";var lr=Object.defineProperty;var dr=(U,o,O)=>o in U?lr(U,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):U[o]=O;var P=(U,o,O)=>dr(U,typeof o!="symbol"?o+"":o,O);var xe;var Lt=Object.getOwnPropertyDescriptor,Pt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Lt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(n,r)=>t(n,r,e);let de=class extends o.Disposable{constructor(t,n){super();P(this,"_open$",new ae.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new ae.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(r=>!r)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(r=>{r.id===Pe&&(r.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};de=Pt([ht(0,o.IUniverInstanceService),ht(1,b.ISidebarService)],de);const ve="#ECECEC",ze="sheets-data-validation-ui.config",Le={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,r)=>{for(var a=r>1?void 0:r?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ie=(e,t)=>(n,r)=>t(n,r,e);let Ce=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(Y.VALIDATE_CELL,{handler:async(e,t,n)=>{const r=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(r===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ce=Ft([Ie(0,o.Inject(Y.SheetInterceptorService)),Ie(1,o.Inject(C.SheetDataValidationModel)),Ie(2,o.Inject(X.DataValidatorRegistryService)),Ie(3,b.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(C.SheetsDataValidationValidatorService))],Ce);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,r)=>{for(var a=r>1?void 0:r?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},oe=(e,t)=>(n,r)=>t(n,r,e);const Ke=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function jt(e,t){const n=At.getPatternType(t);if(e===n)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 ge=class extends o.Disposable{constructor(t,n,r,a,i,s,d,l,c,h,g){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new ae.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=r,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=g,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,r,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),r,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var A,T,w,y;const{location:n}=t,{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,r,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,D)=>{var L,k,B;if(!f)return!0;const I=f,m=l.getCell(r,a),E=I.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),j=(L=o.numfmt.parseDate(E))==null?void 0:L.v,$=D==="time"?j%1:j,F=d.getStyles().getStyleByCell(m),H=(B=(k=F==null?void 0:F.n)==null?void 0:k.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:$,unitId:i,subUnitId:s,row:r,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(Y.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:$,t:2,p:null,f:null,si:null,s:{n:{pattern:jt(D,H)}}}}),await this._commandService.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0):(this._injector.has(Ce)&&this._injector.get(Ce).showReject(h.getRuleFinalError(c,{row:r,col:a,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const f=C.getCellValueOrigin(l.getCellRaw(r,a)),D=Ke(f),I=!!((A=c.bizInfo)!=null&&A.showTime);S={location:n,type:"datepicker",props:{showTime:I,onChange:m=>u(m,I?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const f=C.getCellValueOrigin(l.getCellRaw(r,a)),D=Ke(f);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"time"),defaultValue:D,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const f=C.getCellValueOrigin(l.getCellRaw(r,a)),D=Ke(f);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"datetime"),defaultValue:D,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,D=async F=>{const H=C.serializeListOptions(F),L={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:H,p:null,f:null,si:null}};return this._commandService.executeCommand(Y.SetRangeValuesCommand.id,L),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!f},I=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,m=h.getListWithColor(c,i,s),E=C.getDataValidationCellValue(l.getCellRaw(r,a)),j=()=>{this._commandService.executeCommand(fe.id,{ruleId:c.uid}),g==null||g.dispose()},$=m.map(F=>({label:F.label,value:F.label,color:I||F.color?F.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:F=>D(F),options:$,onEdit:j,defaultValue:E,multiple:f,showEdit:(w=(T=this._configService.getConfig(ze))==null?void 0:T.showEditOnDropdown)!=null?w:!0}};break}case X.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(r,a)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:n};break}case X.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(r,a))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,D;(D=(f=this._activeDropdown)==null?void 0:f.onHide)==null||D.call(f)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,r,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),r,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:r,col:a,unitId:t,subUnitId:n},onHide:i})}};ge=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(X.DataValidatorRegistryService)),oe(2,b.IZenZoneService),oe(3,o.Inject(C.SheetDataValidationModel)),oe(4,o.Inject(Y.SheetsSelectionsService)),oe(5,o.Inject(W.ISheetCellDropdownManagerService)),oe(6,o.Inject(C.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,W.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],ge);const Pe="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:r}=t,a=e.get(de),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=n?i.getRuleById(c,h,n):void 0;a.open(),a.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Pe,header:{title:r?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Pe},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Ze={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(de).close(),!0}},pt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(de);return n.open(),n.isOpen?t.executeCommand(Ze.id):t.executeCommand(fe.id),!0}},Ue={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(ge),{unitId:r,subUnitId:a,row:i,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===r&&l.subUnitId===a&&l.row===i&&l.col===s||n.showDataValidationDropdown(r,a,i,s),!0}},vt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ge).hideDropdown(),!0):!1}},Fe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=Y.getSheetCommandTarget(t);if(!n)return!1;const{workbook:r,worksheet:a}=n,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),d=r.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Bt=Object.getOwnPropertyDescriptor,Wt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Bt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ye=(e,t)=>(n,r)=>t(n,r,e);const me="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ae.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),r=n.getSheetBySheetId(e.location.subUnitId);if(!r)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:n,worksheet:r})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(me);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:W.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:me});return}}this._cellAlertManagerService.removeAlert(me)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(me)}))}};Oe=Wt([ye(0,o.Inject(W.HoverManagerService)),ye(1,o.Inject(W.CellAlertManagerService)),ye(2,o.IUniverInstanceService),ye(3,o.Inject(o.LocaleService)),ye(4,b.IZenZoneService),ye(5,o.Inject(C.SheetDataValidationModel))],Oe);var $t=Object.getOwnPropertyDescriptor,Ht=(e,t,n,r)=>{for(var a=r>1?void 0:r?$t(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ge=(e,t)=>(n,r)=>t(n,r,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=r,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=W.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:S}=h,v={row:g.startRow,col:g.startColumn},A=W.getAutoFillRepeatRange(g,u),T=new o.ObjectMatrix,w=new Set;A.forEach(m=>{const E=m.repeatStartCell,j=m.relativeRange,$={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},F={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(j,(H,L)=>{const k=o.Rectangle.getPositionRange({startRow:H,startColumn:L,endColumn:L,endRow:H},$),{row:B,col:K}=S(k.startRow,k.startColumn),J=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ne=o.Rectangle.getPositionRange({startRow:H,startColumn:L,endColumn:L,endRow:H},F),{row:Z,col:re}=S(ne.startRow,ne.startColumn);T.setValue(Z,re,J),w.add(J)})});const y=Array.from(w).map(m=>({id:m,ranges:o.queryObjectMatrix(T,E=>E===m)}));c.addRangeRules(y);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:I}=C.getDataValidationDiffMutations(d,l,f,this._injector,"patched",a===W.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:D}},n={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:r=>{const{source:a,unitId:i,subUnitId:s}=r;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(W.APPLY_TYPE.SERIES,!0);return}}},onFillData:(r,a,i)=>i===W.APPLY_TYPE.COPY||i===W.APPLY_TYPE.ONLY_FORMAT||i===W.APPLY_TYPE.SERIES?t(r,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Ht([Ge(0,W.IAutoFillService),Ge(1,o.Inject(C.SheetDataValidationModel)),Ge(2,o.Inject(o.Injector))],we);var xt=Object.getOwnPropertyDescriptor,Yt=(e,t,n,r)=>{for(var a=r>1?void 0:r?xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},qe=(e,t)=>(n,r)=>t(n,r,e);let De=class extends o.Disposable{constructor(t,n,r){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=r,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,a)=>{const{copyType:i=W.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,r){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:a};const i=this._injector.invoke(l=>Y.rangeToDiscreteRange(r,l,t,n));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);a.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_COL_WIDTH,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_VALUE,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(n.unitId!==a||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=W.virtualizeDiscreteRanges([n.copyRange,t]),u=W.getRepeatRange(c,h,!0),S=new Map;u.forEach(({startRange:w})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((f,D,I)=>{const m=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:D,endColumn:D},w),E=`${i}-${I}`,j=this._sheetDataValidationModel.getRuleById(a,i,I);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,E)&&j&&S.set(E,{...j,uid:E});const{row:$,col:F}=g(m.startRow,m.startColumn);l.add(E),d.setValue($,F,E)})});const v=Array.from(l).map(w=>({id:w,ranges:o.queryObjectMatrix(d,y=>y===w)}));s.addRangeRules(v);const{redoMutations:A,undoMutations:T}=C.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:A,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=W.virtualizeDiscreteRanges([n.copyRange,t]);W.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((y,f,D)=>{const I=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:f,endColumn:f},T),{row:m,col:E}=g(I.startRow,I.startColumn);d.setValue(m,E,D),l.add(D)})});const S=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,w=>w===T)}));s.addRangeRules(S);const{redoMutations:v,undoMutations:A}=C.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:v,undos:A}}}};De=Yt([qe(0,W.ISheetClipboardService),qe(1,o.Inject(C.SheetDataValidationModel)),qe(2,o.Inject(o.Injector))],De);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Je=(e,t)=>(n,r)=>t(n,r,e);let Ee=class extends o.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===C.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:r}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===C.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:r}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=zt([Je(0,o.Inject(o.LocaleService)),Je(1,o.ICommandService),Je(2,o.Inject(Y.SheetPermissionCheckController))],Ee);const gt="sheet.menu.data-validation";function Kt(e){return{id:gt,type:b.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(e,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function Zt(e){return{id:fe.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function Gt(e){return{id:Fe.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const qt={[b.RibbonDataGroup.RULES]:{[gt]:{order:0,menuItemFactory:Kt,[fe.id]:{order:0,menuItemFactory:Zt},[Fe.id]:{order:1,menuItemFactory:Gt}}}};var Jt=Object.getOwnPropertyDescriptor,ft=(e,t,n,r)=>{for(var a=r>1?void 0:r?Jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},G=(e,t)=>(n,r)=>t(n,r,e);const mt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:r,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(r);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(r,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const g=this._dropdownManagerService.activeDropdown,u=g==null?void 0:g.location;if(u&&u.unitId===r&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:r,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var w,y,f,D,I;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const g=(w=this._dataValidationCacheService.getValue(i,s,r,a))!=null?w:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let v;const A={get value(){var m;return v!==void 0||(v=(m=C.getCellValueOrigin(S))!=null?m:null),v}},T={get value(){var m;return`${(m=A.value)!=null?m:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,A.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const m=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?m.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var $,F,H,L,k,B;const m=(F=($=this._renderManagerService.getRenderById(i))==null?void 0:$.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!m)return;const E=m.worksheet.getMergedCell(r,a),j={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((H=E==null?void 0:E.startRow)!=null?H:r,(L=E==null?void 0:E.startColumn)!=null?L:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(B=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:B.call(k,j)},e.interceptorAutoWidth=()=>{var $,F,H,L,k,B;const m=(F=($=this._renderManagerService.getRenderById(i))==null?void 0:$.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!m)return;const E=m.worksheet.getMergedCell(r,a),j={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((H=E==null?void 0:E.startRow)!=null?H:r,(L=E==null?void 0:E.startColumn)!=null?L:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(B=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:B.call(k,j)},e.coverable=((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=ft([G(0,o.ICommandService),G(1,b.IMenuManagerService),G(2,O.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(W.AutoHeightController)),G(5,o.Inject(ge)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(X.DataValidatorRegistryService)),G(8,o.Inject(Y.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(W.IEditorBridgeService))],Me);let St=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var T,w,y,f,D;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const g=(T=this._dataValidationCacheService.getValue(i,s,r,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(r,a),v=C.getCellValueOrigin(S),A=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(w=e==null?void 0:e.customRender)!=null?w:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,A,{get style(){const I=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var j,$,F,H,L,k;const I=($=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!I)return;const m=I.worksheet.getMergedCell(r,a),E={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((F=m==null?void 0:m.startRow)!=null?F:r,(H=m==null?void 0:m.startColumn)!=null?H:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(k=(L=u==null?void 0:u.canvasRender)==null?void 0:L.calcCellAutoHeight)==null?void 0:k.call(L,E)},e.interceptorAutoWidth=()=>{var j,$,F,H,L,k;const I=($=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!I)return;const m=I.worksheet.getMergedCell(r,a),E={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((F=m==null?void 0:m.startRow)!=null?F:r,(H=m==null?void 0:m.startColumn)!=null?H:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(k=(L=u==null?void 0:u.canvasRender)==null?void 0:L.calcCellAutoWidth)==null?void 0:k.call(L,E)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};St=ft([G(0,o.ICommandService),G(1,O.IRenderManagerService),G(2,o.Inject(W.AutoHeightController)),G(3,o.Inject(X.DataValidatorRegistryService)),G(4,o.Inject(Y.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],St);var Qt=Object.getOwnPropertyDescriptor,en=(e,t,n,r)=>{for(var a=r>1?void 0:r?Qt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(n,r)=>t(n,r,e);let ke=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var r;if(!t.length)return;const n=new Set;t.forEach(a=>{n.add(a.subUnitId)}),n.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(r=this._context.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=en([_t(1,o.Inject(C.SheetDataValidationModel)),_t(2,o.Inject(W.SheetSkeletonManagerService))],ke);function Se({ref:e,...t}){const{icon:n,id:r,className:a,extend:i,...s}=t,d=`univerjs-icon univerjs-icon-${r} ${a||""}`.trim(),l=R.useRef(`_${rn()}`);return It(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:d,...s},i)}function It(e,t,n,r,a){return R.createElement(e.tag,{key:t,...tn(e,n,a),...r},(nn(e,n).children||[]).map((i,s)=>It(i,`${t}-${e.tag}-${s}`,n,void 0,a)))}function tn(e,t,n){const r={...e.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:a}=t;return!a||a.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function nn(e,t){var r;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((r=e.children)!=null&&r.length)?{...e,children:e.children.map(a=>typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?{...a,attrs:{...a.attrs,id:a.attrs.id+t.idSuffix}}:a)}:e}function rn(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const an={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"}}]},Ct=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:an}))});Ct.displayName="DataValidationIcon";const on={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"}}]},Qe=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:on}))});Qe.displayName="DeleteIcon";const sn={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"}}]},yt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:sn}))});yt.displayName="IncreaseIcon";const ln={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:ln}))});et.displayName="MoreDownIcon";const dn={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"}}]},wt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:dn}))});wt.displayName="MoreUpIcon";const cn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Dt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:cn}))});Dt.displayName="SequenceIcon";function un(e){var c;const t=b.useDependency(o.LocaleService),n=b.useDependency(b.ComponentManager),{value:r,onChange:a,extraComponent:i}=e,[s,d]=R.useState(!1),l=i?n.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(wt,{className:"univer-ml-1"}):p.jsx(et,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:r,onChange:a}):null,p.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(M.RadioGroup,{value:`${(c=r.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...r,errorStyle:+h}),children:[p.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(M.Checkbox,{checked:r.showErrorMessage,onChange:()=>a({...r,showErrorMessage:!r.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),r.showErrorMessage?p.jsx(M.FormLayout,{children:p.jsx(M.Input,{value:r.error,onChange:h=>a({...r,error:h})})}):null]})]})}const hn=e=>o.debounce(async(t,n,r,a)=>{const i=await e.executeCommand(t,n,r);a==null||a(i)},1e3);function pn(e,t,n){var r,a,i,s;return t?((a=(r=e.getUnit(t))==null?void 0:r.getSheetBySheetName(n))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function vn(){var V,x;const[e,t]=R.useState(0),n=b.useDependency(de),r=b.useObservable(n.activeRule$,n.activeRule),{unitId:a,subUnitId:i,rule:s}=r||{},d=s.uid,l=b.useDependency(X.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),g=b.useDependency(o.ICommandService),u=b.useDependency(X.DataValidationModel),S=b.useDependency(o.LocaleService),[v,A]=R.useState(s),T=l.getValidatorItem(v.type),[w,y]=R.useState(!1),f=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[D,I]=R.useState(()=>v.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),m=R.useMemo(()=>hn(g),[g]),[E,j]=R.useState(!1),[$,F]=R.useState(!1),H=R.useRef(null),L=b.useDependency(Y.SheetsSelectionsService);if(R.useEffect(()=>()=>{const _=L.getCurrentLastSelection();_&&L.setSelections([_])},[L]),R.useEffect(()=>{g.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const N=u.getRuleById(a,i,d);t(z=>z+1),N&&(A(N),I(N.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[g,u,d,i,a]),!T)return null;const k=T.operators,B=T.operatorNames,K=v.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,J=()=>{var _,N,z;(N=(_=H.current)==null?void 0:_.editor)!=null&&N.isFocus()&&ne((z=H.current)==null?void 0:z.getValue()),!(!v.ranges.length||E)&&(T.validatorFormula(v,a,i).success?n.setActiveRule(null):y(!0))},ne=b.useEvent(_=>{const N=_.split(",").filter(Boolean).map(Ye.deserializeRangeWithSheet).map(te=>{const Ot=te.sheetName;if(Ot){const sr=pn(c,te.unitId,Ot);return{...te,sheetId:sr}}return{...te,sheetId:""}});if(o.isUnitRangesEqual(N,D))return;I(N);const z=N.filter(te=>(!te.unitId||te.unitId===a)&&(!te.sheetId||te.sheetId===i)).map(te=>te.range);if(A({...v,ranges:z}),z.length===0)return;const le={unitId:a,subUnitId:i,ruleId:d,ranges:z};m(C.UpdateSheetDataValidationRangeCommand.id,le)}),Z=_=>{if(o.shallowEqual(_,X.getRuleSetting(v)))return;A({...v,..._});const N={unitId:a,subUnitId:i,ruleId:d,setting:_};m(C.UpdateSheetDataValidationSettingCommand.id,N,void 0)},re=async()=>{await g.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),n.setActiveRule(null)},ie={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},he=_=>{const N=l.getValidatorItem(_);if(!N)return;const z=N.operators,le=u.getRuleById(a,i,d),te=_===(le==null?void 0:le.type)||_.includes("list")&&(le!=null&&le.type.includes("list"))?{...le,type:_}:{...v,type:_,operator:z[0],formula1:void 0,formula2:void 0};A(te),g.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:v.uid,setting:X.getRuleSetting(te)})},pe=h.get(T.formulaInput),ee=R.useMemo(()=>D.map(_=>Ye.serializeRange(_.range)).join(","),[]),q=X.getRuleOptions(v),ce=_=>{o.shallowEqual(_,X.getRuleOptions(v))||(A({...v,..._}),m(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=k.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||E?S.t("dataValidation.panel.rangeError"):"",children:p.jsx(Xe.RangeSelector,{selectorRef:H,unitId:a,subUnitId:i,initialValue:ee,onChange:(_,N)=>{var z;!$&&((z=H.current)!=null&&z.verify())&&ne(N)},onFocusChange:(_,N)=>{var z;F(_),!_&&N&&((z=H.current)!=null&&z.verify())&&ne(N)},onVerify:_=>j(!_)})}),p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.type"),children:p.jsx(M.Select,{className:"univer-w-full",value:v.type,options:(V=f==null?void 0:f.sort((_,N)=>_.order-N.order))==null?void 0:V.map(_=>({label:S.t(_.title),value:_.id})),onChange:he})}),k!=null&&k.length?p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.operator"),children:p.jsx(M.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...k.map((_,N)=>({value:`${_}`,label:B[N]}))],onChange:_=>{Z({...ie,operator:_})}})}):null,pe&&!Q?p.jsx(pe,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:_=>{Z({...ie,..._})},showError:w,validResult:T.validatorFormula(v,a,i),unitId:a,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:(x=v.allowBlank)!=null?x:!0,onChange:()=>{var _;return Z({...ie,allowBlank:!((_=v.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),p.jsx(un,{value:q,onChange:ce,extraComponent:T.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(M.Button,{className:"univer-ml-3",onClick:re,children:S.t("dataValidation.panel.removeRule")}),p.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:J,children:S.t("dataValidation.panel.done")})]})]})}const gn=e=>{const{rule:t,onClick:n,unitId:r,subUnitId:a,disable:i}=e,s=b.useDependency(X.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(W.IMarkSelectionService),c=s.getValidatorItem(t.type),h=R.useRef(void 0),[g,u]=R.useState(!1),S=b.useDependency(o.ThemeService),v=b.useObservable(S.currentTheme$),A=R.useMemo(()=>{var I;const w=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),f=(I=S.getColorFromTheme(y))!=null?I:w,D=new o.ColorKit(f).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:f}},[v]),T=w=>{d.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:r,subUnitId:a}),w.stopPropagation()};return R.useEffect(()=>()=>{var w;h.current&&((w=h.current)==null||w.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:M.clsx(`
|
|
1
|
+
(function(U,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("@univerjs/core"),require("@univerjs/engine-render"),require("@univerjs/sheets"),require("@univerjs/sheets-data-validation"),require("@univerjs/data-validation"),require("@univerjs/ui"),require("rxjs"),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/core","@univerjs/engine-render","@univerjs/sheets","@univerjs/sheets-data-validation","@univerjs/data-validation","@univerjs/ui","rxjs","@univerjs/sheets-numfmt","@univerjs/sheets-ui","@univerjs/design","react","react/jsx-runtime","@univerjs/engine-formula","@univerjs/sheets-formula-ui"],o):(U=typeof globalThis<"u"?globalThis:U||self,o(U.UniverSheetsDataValidationUi={},U.UniverCore,U.UniverEngineRender,U.UniverSheets,U.UniverSheetsDataValidation,U.UniverDataValidation,U.UniverUi,U.rxjs,U.UniverSheetsNumfmt,U.UniverSheetsUi,U.UniverDesign,U.React,U.React,U.UniverEngineFormula,U.UniverSheetsFormulaUi))})(this,(function(U,o,O,Y,C,X,b,ae,At,W,M,R,p,Ye,Xe){"use strict";var lr=Object.defineProperty;var dr=(U,o,O)=>o in U?lr(U,o,{enumerable:!0,configurable:!0,writable:!0,value:O}):U[o]=O;var P=(U,o,O)=>dr(U,typeof o!="symbol"?o+"":o,O);var xe;var Lt=Object.getOwnPropertyDescriptor,Pt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Lt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ht=(e,t)=>(n,r)=>t(n,r,e);let de=class extends o.Disposable{constructor(t,n){super();P(this,"_open$",new ae.BehaviorSubject(!1));P(this,"open$",this._open$.pipe(ae.distinctUntilChanged()));P(this,"_activeRule");P(this,"_activeRule$",new ae.BehaviorSubject(void 0));P(this,"activeRule$",this._activeRule$.asObservable());P(this,"_closeDisposable",null);this._univerInstanceService=t,this._sidebarService=n,this.disposeWithMe(this._univerInstanceService.getCurrentTypeOfUnit$(o.UniverInstanceType.UNIVER_SHEET).pipe(ae.filter(r=>!r)).subscribe(()=>{this.close()})),this.disposeWithMe(this._sidebarService.sidebarOptions$.subscribe(r=>{r.id===Pe&&(r.visible||setTimeout(()=>{this._sidebarService.sidebarOptions$.next({visible:!1})}))}))}get activeRule(){return this._activeRule}get isOpen(){return this._open$.getValue()}dispose(){var t;super.dispose(),this._open$.next(!1),this._open$.complete(),this._activeRule$.complete(),(t=this._closeDisposable)==null||t.dispose()}open(){this._open$.next(!0)}close(){var t;this._open$.next(!1),(t=this._closeDisposable)==null||t.dispose()}setCloseDisposable(t){this._closeDisposable=o.toDisposable(()=>{t.dispose(),this._closeDisposable=null})}setActiveRule(t){this._activeRule=t,this._activeRule$.next(t)}};de=Pt([ht(0,o.IUniverInstanceService),ht(1,b.ISidebarService)],de);const ve="#ECECEC",ze="sheets-data-validation-ui.config",Le={};var Ut=Object.getOwnPropertyDescriptor,Ft=(e,t,n,r)=>{for(var a=r>1?void 0:r?Ut(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ie=(e,t)=>(n,r)=>t(n,r,e);let Ce=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._sheetInterceptorService=e,this._dataValidationModel=t,this._dataValidatorRegistryService=n,this._dialogService=r,this._localeService=a,this._sheetsDataValidationValidatorService=i,this._initEditorBridgeInterceptor()}_initEditorBridgeInterceptor(){this.disposeWithMe(this._sheetInterceptorService.writeCellInterceptor.intercept(Y.VALIDATE_CELL,{handler:async(e,t,n)=>{const r=await e,{row:a,col:i,unitId:s,subUnitId:d}=t,l=this._dataValidationModel.getRuleIdByLocation(s,d,a,i),c=l?this._dataValidationModel.getRuleById(s,d,l):void 0;if(r===!1)return n(Promise.resolve(!1));if(!c||c.errorStyle!==o.DataValidationErrorStyle.STOP)return n(Promise.resolve(!0));const h=this._dataValidatorRegistryService.getValidatorItem(c.type);return!h||await this._sheetsDataValidationValidatorService.validatorCell(s,d,a,i)===o.DataValidationStatus.VALID?n(Promise.resolve(!0)):(this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:h.getRuleFinalError(c,{row:a,col:i,unitId:s,subUnitId:d})},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}}),n(Promise.resolve(!1)))}}))}showReject(e){this._dialogService.open({width:368,title:{title:this._localeService.t("dataValidation.alert.title")},id:"reject-input-dialog",children:{title:e},footer:{title:R.createElement(M.Button,{variant:"primary",onClick:()=>this._dialogService.close("reject-input-dialog")},this._localeService.t("dataValidation.alert.ok"))},onClose:()=>{this._dialogService.close("reject-input-dialog")}})}};Ce=Ft([Ie(0,o.Inject(Y.SheetInterceptorService)),Ie(1,o.Inject(C.SheetDataValidationModel)),Ie(2,o.Inject(X.DataValidatorRegistryService)),Ie(3,b.IDialogService),Ie(4,o.Inject(o.LocaleService)),Ie(5,o.Inject(C.SheetsDataValidationValidatorService))],Ce);var kt=Object.getOwnPropertyDescriptor,Nt=(e,t,n,r)=>{for(var a=r>1?void 0:r?kt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},oe=(e,t)=>(n,r)=>t(n,r,e);const Ke=e=>{if(e==null||typeof e=="boolean")return;if(e==="")return o.dayjs();if(typeof e=="number"||!Number.isNaN(+e))return o.dayjs(o.numfmt.format("yyyy-MM-dd HH:mm:ss",Number(e)));const t=o.dayjs(e);if(t.isValid())return t};function jt(e,t){const n=At.getPatternType(t);if(e===n)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 ge=class extends o.Disposable{constructor(t,n,r,a,i,s,d,l,c,h,g){super();P(this,"_activeDropdown");P(this,"_activeDropdown$",new ae.Subject);P(this,"_currentPopup",null);P(this,"activeDropdown$",this._activeDropdown$.asObservable());P(this,"_zenVisible",!1);this._univerInstanceService=t,this._dataValidatorRegistryService=n,this._zenZoneService=r,this._dataValidationModel=a,this._sheetsSelectionsService=i,this._cellDropdownManagerService=s,this._sheetDataValidationModel=d,this._commandService=l,this._editorBridgeService=c,this._injector=h,this._configService=g,this._init(),this._initSelectionChange(),this.disposeWithMe(()=>{this._activeDropdown$.complete()})}get activeDropdown(){return this._activeDropdown}_init(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(t=>{this._zenVisible=t,t&&this.hideDropdown()}))}_getDropdownByCell(t,n,r,a){const i=t?this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET):this._univerInstanceService.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET);if(!i)return;const s=n?i.getSheetBySheetId(n):i.getActiveSheet();if(!s)return;const d=this._dataValidationModel.getRuleByLocation(i.getUnitId(),s.getSheetId(),r,a);if(!d)return;const l=this._dataValidatorRegistryService.getValidatorItem(d.type);return l==null?void 0:l.dropdownType}_initSelectionChange(){this.disposeWithMe(this._sheetsSelectionsService.selectionMoveEnd$.subscribe(t=>{t&&t.every(n=>!(n.primary&&this._getDropdownByCell(n.primary.unitId,n.primary.sheetId,n.primary.actualRow,n.primary.actualColumn)))&&this.hideDropdown()}))}showDropdown(t){var A,T,w,y;const{location:n}=t,{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=n;if(this._currentPopup&&this._currentPopup.dispose(),this._zenVisible)return;this._activeDropdown=t,this._activeDropdown$.next(this._activeDropdown);const c=this._sheetDataValidationModel.getRuleByLocation(i,s,r,a);if(!c)return;const h=this._dataValidatorRegistryService.getValidatorItem(c.type);if(!(h!=null&&h.dropdownType))return;let g;const u=async(f,D)=>{var L,k,B;if(!f)return!0;const I=f,m=l.getCell(r,a),E=I.format(D==="date"?"YYYY-MM-DD 00:00:00":"YYYY-MM-DD HH:mm:ss"),j=(L=o.numfmt.parseDate(E))==null?void 0:L.v,$=D==="time"?j%1:j,F=d.getStyles().getStyleByCell(m),H=(B=(k=F==null?void 0:F.n)==null?void 0:k.pattern)!=null?B:"";return c.errorStyle!==o.DataValidationErrorStyle.STOP||await h.validator({value:$,unitId:i,subUnitId:s,row:r,column:a,worksheet:l,workbook:d,interceptValue:E.replace("Z","").replace("T"," "),t:o.CellValueType.NUMBER},c)?(await this._commandService.executeCommand(Y.SetRangeValuesCommand.id,{unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:$,t:2,p:null,f:null,si:null,s:{n:{pattern:jt(D,H)}}}}),await this._commandService.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0):(this._injector.has(Ce)&&this._injector.get(Ce).showReject(h.getRuleFinalError(c,{row:r,col:a,unitId:i,subUnitId:s})),!1)};let S;switch(h.dropdownType){case X.DataValidatorDropdownType.DATE:{const f=C.getCellValueOrigin(l.getCellRaw(r,a)),D=Ke(f),I=!!((A=c.bizInfo)!=null&&A.showTime);S={location:n,type:"datepicker",props:{showTime:I,onChange:m=>u(m,I?"datetime":"date"),defaultValue:D,patternType:"date"}};break}case X.DataValidatorDropdownType.TIME:{const f=C.getCellValueOrigin(l.getCellRaw(r,a)),D=Ke(f);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"time"),defaultValue:D,patternType:"time"}};break}case X.DataValidatorDropdownType.DATETIME:{const f=C.getCellValueOrigin(l.getCellRaw(r,a)),D=Ke(f);S={location:n,type:"datepicker",props:{onChange:I=>u(I,"datetime"),defaultValue:D,patternType:"datetime"}};break}case X.DataValidatorDropdownType.LIST:case X.DataValidatorDropdownType.MULTIPLE_LIST:{const f=h.dropdownType===X.DataValidatorDropdownType.MULTIPLE_LIST,D=async F=>{const H=C.serializeListOptions(F),L={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:H,p:null,f:null,si:null}};return this._commandService.executeCommand(Y.SetRangeValuesCommand.id,L),this._editorBridgeService.isVisible().visible&&await this._commandService.executeCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!f},I=(c==null?void 0:c.renderMode)===o.DataValidationRenderMode.CUSTOM||(c==null?void 0:c.renderMode)===void 0,m=h.getListWithColor(c,i,s),E=C.getDataValidationCellValue(l.getCellRaw(r,a)),j=()=>{this._commandService.executeCommand(fe.id,{ruleId:c.uid}),g==null||g.dispose()},$=m.map(F=>({label:F.label,value:F.label,color:I||F.color?F.color||ve:"transparent"}));S={location:n,type:"list",props:{onChange:F=>D(F),options:$,onEdit:j,defaultValue:E,multiple:f,showEdit:(w=(T=this._configService.getConfig(ze))==null?void 0:T.showEditOnDropdown)!=null?w:!0}};break}case X.DataValidatorDropdownType.CASCADE:{S={type:"cascader",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:D.join("/"),p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(r,a)).split("/"),options:JSON.parse((y=c.formula1)!=null?y:"[]")},location:n};break}case X.DataValidatorDropdownType.COLOR:{S={type:"color",props:{onChange:D=>{const I={unitId:i,subUnitId:s,range:{startColumn:a,endColumn:a,startRow:r,endRow:r},value:{v:D,p:null,f:null,si:null}};return this._commandService.syncExecuteCommand(Y.SetRangeValuesCommand.id,I),this._editorBridgeService.isVisible().visible&&this._commandService.syncExecuteCommand(W.SetCellEditVisibleOperation.id,{visible:!1,eventType:O.DeviceInputEventType.Keyboard,unitId:i,keycode:b.KeyCode.ESC}),!0},defaultValue:C.getDataValidationCellValue(l.getCellRaw(r,a))},location:n};break}default:throw new Error("[DataValidationDropdownManagerService]: unknown type!")}if(g=this._cellDropdownManagerService.showDropdown({...S,onHide:()=>{this._activeDropdown=null,this._activeDropdown$.next(null)}}),!g)throw new Error("[DataValidationDropdownManagerService]: cannot show dropdown!");const v=new o.DisposableCollection;v.add(g),v.add({dispose:()=>{var f,D;(D=(f=this._activeDropdown)==null?void 0:f.onHide)==null||D.call(f)}}),this._currentPopup=v}hideDropdown(){this._activeDropdown&&(this._currentPopup&&this._currentPopup.dispose(),this._currentPopup=null,this._activeDropdown=null,this._activeDropdown$.next(null))}showDataValidationDropdown(t,n,r,a,i){const s=this._univerInstanceService.getUnit(t,o.UniverInstanceType.UNIVER_SHEET);if(!s)return;const d=s.getSheetBySheetId(n);if(!d)return;const l=this._dataValidationModel.getRuleByLocation(s.getUnitId(),d.getSheetId(),r,a);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!c||!c.dropdownType){this.hideDropdown();return}this.showDropdown({location:{workbook:s,worksheet:d,row:r,col:a,unitId:t,subUnitId:n},onHide:i})}};ge=Nt([oe(0,o.IUniverInstanceService),oe(1,o.Inject(X.DataValidatorRegistryService)),oe(2,b.IZenZoneService),oe(3,o.Inject(C.SheetDataValidationModel)),oe(4,o.Inject(Y.SheetsSelectionsService)),oe(5,o.Inject(W.ISheetCellDropdownManagerService)),oe(6,o.Inject(C.SheetDataValidationModel)),oe(7,o.ICommandService),oe(8,W.IEditorBridgeService),oe(9,o.Inject(o.Injector)),oe(10,o.IConfigService)],ge);const Pe="DataValidationPanel",fe={id:"data-validation.operation.open-validation-panel",type:o.CommandType.OPERATION,handler(e,t){if(!t)return!1;const{ruleId:n,isAdd:r}=t,a=e.get(de),i=e.get(X.DataValidationModel),s=e.get(o.IUniverInstanceService),d=e.get(b.ISidebarService),l=Y.getSheetCommandTarget(s);if(!l)return!1;const{unitId:c,subUnitId:h}=l,g=n?i.getRuleById(c,h,n):void 0;a.open(),a.setActiveRule(g&&{unitId:c,subUnitId:h,rule:g});const u=d.open({id:Pe,header:{title:r?"dataValidation.panel.addTitle":"dataValidation.panel.title"},children:{label:Pe},width:312,onClose:()=>a.close()});return a.setCloseDisposable(u),!0}},Ze={id:"data-validation.operation.close-validation-panel",type:o.CommandType.OPERATION,handler(e){return e.get(de).close(),!0}},pt={id:"data-validation.operation.toggle-validation-panel",type:o.CommandType.OPERATION,handler(e){const t=e.get(o.ICommandService),n=e.get(de);return n.open(),n.isOpen?t.executeCommand(Ze.id):t.executeCommand(fe.id),!0}},Ue={type:o.CommandType.OPERATION,id:"sheet.operation.show-data-validation-dropdown",handler(e,t){if(!t)return!1;const n=e.get(ge),{unitId:r,subUnitId:a,row:i,column:s}=t,d=n.activeDropdown,l=d==null?void 0:d.location;return l&&l.unitId===r&&l.subUnitId===a&&l.row===i&&l.col===s||n.showDataValidationDropdown(r,a,i,s),!0}},vt={type:o.CommandType.OPERATION,id:"sheet.operation.hide-data-validation-dropdown",handler(e,t){return t?(e.get(ge).hideDropdown(),!0):!1}},Fe={type:o.CommandType.COMMAND,id:"data-validation.command.addRuleAndOpen",handler(e){const t=e.get(o.IUniverInstanceService),n=Y.getSheetCommandTarget(t);if(!n)return!1;const{workbook:r,worksheet:a}=n,i=C.createDefaultNewRule(e),s=e.get(o.ICommandService),d=r.getUnitId(),l=a.getSheetId(),c={rule:i,unitId:d,subUnitId:l};return s.syncExecuteCommand(C.AddSheetDataValidationCommand.id,c)?(s.syncExecuteCommand(fe.id,{ruleId:i.uid,isAdd:!0}),!0):!1}};var Bt=Object.getOwnPropertyDescriptor,Wt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Bt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},ye=(e,t)=>(n,r)=>t(n,r,e);const me="SHEET_DATA_VALIDATION_ALERT";let Oe=class extends o.Disposable{constructor(e,t,n,r,a,i){super(),this._hoverManagerService=e,this._cellAlertManagerService=t,this._univerInstanceService=n,this._localeService=r,this._zenZoneService=a,this._dataValidationModel=i,this._init()}_init(){this._initCellAlertPopup(),this._initZenService()}_initCellAlertPopup(){this.disposeWithMe(this._hoverManagerService.currentCell$.pipe(ae.debounceTime(100)).subscribe(e=>{var t;if(e){const n=this._univerInstanceService.getUnit(e.location.unitId,o.UniverInstanceType.UNIVER_SHEET),r=n.getSheetBySheetId(e.location.subUnitId);if(!r)return;const a=this._dataValidationModel.getRuleByLocation(e.location.unitId,e.location.subUnitId,e.location.row,e.location.col);if(!a){this._cellAlertManagerService.removeAlert(me);return}if(this._dataValidationModel.validator(a,{...e.location,workbook:n,worksheet:r})===o.DataValidationStatus.INVALID){const s=this._cellAlertManagerService.currentAlert.get(me),d=(t=s==null?void 0:s.alert)==null?void 0:t.location;if(d&&d.row===e.location.row&&d.col===e.location.col&&d.subUnitId===e.location.subUnitId&&d.unitId===e.location.unitId){this._cellAlertManagerService.removeAlert(me);return}const l=this._dataValidationModel.getValidator(a.type);if(!l){this._cellAlertManagerService.removeAlert(me);return}this._cellAlertManagerService.showAlert({type:W.CellAlertType.ERROR,title:this._localeService.t("dataValidation.error.title"),message:l==null?void 0:l.getRuleFinalError(a,e.location),location:e.location,width:200,height:74,key:me});return}}this._cellAlertManagerService.removeAlert(me)}))}_initZenService(){this.disposeWithMe(this._zenZoneService.visible$.subscribe(e=>{e&&this._cellAlertManagerService.removeAlert(me)}))}};Oe=Wt([ye(0,o.Inject(W.HoverManagerService)),ye(1,o.Inject(W.CellAlertManagerService)),ye(2,o.IUniverInstanceService),ye(3,o.Inject(o.LocaleService)),ye(4,b.IZenZoneService),ye(5,o.Inject(C.SheetDataValidationModel))],Oe);var $t=Object.getOwnPropertyDescriptor,Ht=(e,t,n,r)=>{for(var a=r>1?void 0:r?$t(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Ge=(e,t)=>(n,r)=>t(n,r,e);let we=class extends o.Disposable{constructor(e,t,n){super(),this._autoFillService=e,this._sheetDataValidationModel=t,this._injector=n,this._initAutoFill()}_initAutoFill(){const e=()=>({redos:[],undos:[]}),t=(r,a)=>{const{source:i,target:s,unitId:d,subUnitId:l}=r,c=this._sheetDataValidationModel.getRuleObjectMatrix(d,l).clone(),h=W.virtualizeDiscreteRanges([i,s]),[g,u]=h.ranges,{mapFunc:S}=h,v={row:g.startRow,col:g.startColumn},A=W.getAutoFillRepeatRange(g,u),T=new o.ObjectMatrix,w=new Set;A.forEach(m=>{const E=m.repeatStartCell,j=m.relativeRange,$={startRow:v.row,startColumn:v.col,endColumn:v.col,endRow:v.row},F={startRow:E.row,startColumn:E.col,endColumn:E.col,endRow:E.row};o.Range.foreach(j,(H,L)=>{const k=o.Rectangle.getPositionRange({startRow:H,startColumn:L,endColumn:L,endRow:H},$),{row:B,col:K}=S(k.startRow,k.startColumn),J=this._sheetDataValidationModel.getRuleIdByLocation(d,l,B,K)||"",ne=o.Rectangle.getPositionRange({startRow:H,startColumn:L,endColumn:L,endRow:H},F),{row:Z,col:re}=S(ne.startRow,ne.startColumn);T.setValue(Z,re,J),w.add(J)})});const y=Array.from(w).map(m=>({id:m,ranges:o.queryObjectMatrix(T,E=>E===m)}));c.addRangeRules(y);const f=c.diff(this._sheetDataValidationModel.getRules(d,l)),{redoMutations:D,undoMutations:I}=C.getDataValidationDiffMutations(d,l,f,this._injector,"patched",a===W.APPLY_TYPE.ONLY_FORMAT);return{undos:I,redos:D}},n={id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeFillData:r=>{const{source:a,unitId:i,subUnitId:s}=r;for(const d of a.rows)for(const l of a.cols){const c=this._sheetDataValidationModel.getRuleByLocation(i,s,d,l);if(c&&c.type===o.DataValidationType.CHECKBOX){this._autoFillService.setDisableApplyType(W.APPLY_TYPE.SERIES,!0);return}}},onFillData:(r,a,i)=>i===W.APPLY_TYPE.COPY||i===W.APPLY_TYPE.ONLY_FORMAT||i===W.APPLY_TYPE.SERIES?t(r,i):e(),onAfterFillData:()=>{}};this.disposeWithMe(this._autoFillService.addHook(n))}};we=Ht([Ge(0,W.IAutoFillService),Ge(1,o.Inject(C.SheetDataValidationModel)),Ge(2,o.Inject(o.Injector))],we);var xt=Object.getOwnPropertyDescriptor,Yt=(e,t,n,r)=>{for(var a=r>1?void 0:r?xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},qe=(e,t)=>(n,r)=>t(n,r,e);let De=class extends o.Disposable{constructor(t,n,r){super();P(this,"_copyInfo");this._sheetClipboardService=t,this._sheetDataValidationModel=n,this._injector=r,this._initCopyPaste()}_initCopyPaste(){this._sheetClipboardService.addClipboardHook({id:C.DATA_VALIDATION_PLUGIN_NAME,onBeforeCopy:(t,n,r)=>this._collect(t,n,r),onPasteCells:(t,n,r,a)=>{const{copyType:i=W.COPY_TYPE.COPY,pasteType:s}=a,{range:d}=t||{},{range:l,unitId:c,subUnitId:h}=n;return this._generateMutations(l,{copyType:i,pasteType:s,copyRange:d,unitId:c,subUnitId:h})}})}_collect(t,n,r){const a=new o.ObjectMatrix;this._copyInfo={unitId:t,subUnitId:n,matrix:a};const i=this._injector.invoke(l=>Y.rangeToDiscreteRange(r,l,t,n));if(!i)return;const{rows:s,cols:d}=i;s.forEach((l,c)=>{d.forEach((h,g)=>{const u=this._sheetDataValidationModel.getRuleIdByLocation(t,n,l,h);a.setValue(c,g,u!=null?u:"")})})}_generateMutations(t,n){if(!this._copyInfo)return{redos:[],undos:[]};if(n.copyType===W.COPY_TYPE.CUT)return this._copyInfo=null,{redos:[],undos:[]};if(!this._copyInfo||!this._copyInfo.matrix.getSizeOf()||!n.copyRange)return{redos:[],undos:[]};if([W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_COL_WIDTH,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_VALUE,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMAT,W.PREDEFINED_HOOK_NAME_PASTE.SPECIAL_PASTE_FORMULA].includes(n.pasteType))return{redos:[],undos:[]};const{unitId:a,subUnitId:i}=this._copyInfo;if(n.unitId!==a||i!==n.subUnitId){const s=this._sheetDataValidationModel.getRuleObjectMatrix(n.unitId,n.subUnitId).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=W.virtualizeDiscreteRanges([n.copyRange,t]),u=W.getRepeatRange(c,h,!0),S=new Map;u.forEach(({startRange:w})=>{var y;(y=this._copyInfo)==null||y.matrix.forValue((f,D,I)=>{const m=o.Rectangle.getPositionRange({startRow:f,endRow:f,startColumn:D,endColumn:D},w),E=`${i}-${I}`,j=this._sheetDataValidationModel.getRuleById(a,i,I);!this._sheetDataValidationModel.getRuleById(n.unitId,n.subUnitId,E)&&j&&S.set(E,{...j,uid:E});const{row:$,col:F}=g(m.startRow,m.startColumn);l.add(E),d.setValue($,F,E)})});const v=Array.from(l).map(w=>({id:w,ranges:o.queryObjectMatrix(d,y=>y===w)}));s.addRangeRules(v);const{redoMutations:A,undoMutations:T}=C.getDataValidationDiffMutations(n.unitId,n.subUnitId,s.diffWithAddition(this._sheetDataValidationModel.getRules(n.unitId,n.subUnitId),S.values()),this._injector,"patched",!1);return{redos:A,undos:T}}else{const s=this._sheetDataValidationModel.getRuleObjectMatrix(a,i).clone(),d=new o.ObjectMatrix,l=new Set,{ranges:[c,h],mapFunc:g}=W.virtualizeDiscreteRanges([n.copyRange,t]);W.getRepeatRange(c,h,!0).forEach(({startRange:T})=>{var w;(w=this._copyInfo)==null||w.matrix.forValue((y,f,D)=>{const I=o.Rectangle.getPositionRange({startRow:y,endRow:y,startColumn:f,endColumn:f},T),{row:m,col:E}=g(I.startRow,I.startColumn);d.setValue(m,E,D),l.add(D)})});const S=Array.from(l).map(T=>({id:T,ranges:o.queryObjectMatrix(d,w=>w===T)}));s.addRangeRules(S);const{redoMutations:v,undoMutations:A}=C.getDataValidationDiffMutations(a,i,s.diff(this._sheetDataValidationModel.getRules(a,i)),this._injector,"patched",!1);return{redos:v,undos:A}}}};De=Yt([qe(0,W.ISheetClipboardService),qe(1,o.Inject(C.SheetDataValidationModel)),qe(2,o.Inject(o.Injector))],De);var Xt=Object.getOwnPropertyDescriptor,zt=(e,t,n,r)=>{for(var a=r>1?void 0:r?Xt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},Je=(e,t)=>(n,r)=>t(n,r,e);let Ee=class extends o.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===C.AddSheetDataValidationCommand.id){const{unitId:t,subUnitId:n,rule:{ranges:r}}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}if(e.id===C.UpdateSheetDataValidationRangeCommand.id){const{unitId:t,subUnitId:n,ranges:r}=e.params;this._sheetPermissionCheckController.permissionCheckWithRanges({workbookTypes:[Y.WorkbookEditablePermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint],worksheetTypes:[Y.WorksheetEditPermission,Y.WorksheetSetCellStylePermission]},r,t,n)||this._sheetPermissionCheckController.blockExecuteWithoutPermission(this._localeService.t("permission.dialog.setStyleErr"))}}))}};Ee=zt([Je(0,o.Inject(o.LocaleService)),Je(1,o.ICommandService),Je(2,o.Inject(Y.SheetPermissionCheckController))],Ee);const gt="sheet.menu.data-validation";function Kt(e){return{id:gt,type:b.MenuItemType.SUBITEMS,icon:"DataValidationIcon",tooltip:"dataValidation.title",hidden$:b.getMenuHiddenObservable(e,o.UniverInstanceType.UNIVER_SHEET),disabled$:W.getCurrentRangeDisable$(e,{workbookTypes:[Y.WorkbookEditablePermission],worksheetTypes:[Y.WorksheetSetCellStylePermission,Y.WorksheetEditPermission],rangeTypes:[Y.RangeProtectionPermissionEditPoint]})}}function Zt(e){return{id:fe.id,title:"dataValidation.panel.title",type:b.MenuItemType.BUTTON}}function Gt(e){return{id:Fe.id,title:"dataValidation.panel.add",type:b.MenuItemType.BUTTON}}const qt={[b.RibbonDataGroup.RULES]:{[gt]:{order:0,menuItemFactory:Kt,[fe.id]:{order:0,menuItemFactory:Zt},[Fe.id]:{order:1,menuItemFactory:Gt}}}};var Jt=Object.getOwnPropertyDescriptor,ft=(e,t,n,r)=>{for(var a=r>1?void 0:r?Jt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},G=(e,t)=>(n,r)=>t(n,r,e);const mt={tr:{size:6,color:"#fe4b4b"}};let Me=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s,d,l,c,h){super(),this._commandService=e,this._menuManagerService=t,this._renderManagerService=n,this._univerInstanceService=r,this._autoHeightController=a,this._dropdownManagerService=i,this._sheetDataValidationModel=s,this._dataValidatorRegistryService=d,this._sheetInterceptorService=l,this._dataValidationCacheService=c,this._editorBridgeService=h,this._initMenu(),this._initDropdown(),this._initViewModelIntercept(),this._initAutoHeight()}_initMenu(){this._menuManagerService.mergeMenu(qt)}_initDropdown(){this._editorBridgeService&&this.disposeWithMe(this._editorBridgeService.visible$.subscribe(e=>{var n;if(!e.visible){((n=this._dropdownManagerService.activeDropdown)==null?void 0:n.trigger)==="editor-bridge"&&this._dropdownManagerService.hideDropdown();return}const t=this._editorBridgeService.getEditCellState();if(t){const{unitId:r,sheetId:a,row:i,column:s}=t,d=this._univerInstanceService.getUniverSheetInstance(r);if(!d)return;const l=this._sheetDataValidationModel.getRuleByLocation(r,a,i,s);if(!l)return;const c=this._dataValidatorRegistryService.getValidatorItem(l.type);if(!(c!=null&&c.dropdownType))return;const h=d.getActiveSheet();if(!h)return;const g=this._dropdownManagerService.activeDropdown,u=g==null?void 0:g.location;if(u&&u.unitId===r&&u.subUnitId===a&&u.row===i&&u.col===s)return;this._dropdownManagerService.showDropdown({location:{unitId:r,subUnitId:a,row:i,col:s,workbook:d,worksheet:h},trigger:"editor-bridge",closeOnOutSide:!1})}}))}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var w,y,f,D,I;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const g=(w=this._dataValidationCacheService.getValue(i,s,r,a))!=null?w:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=t.rawData;let v;const A={get value(){var m;return v!==void 0||(v=(m=C.getCellValueOrigin(S))!=null?m:null),v}},T={get value(){var m;return`${(m=A.value)!=null?m:""}`}};return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(y=e==null?void 0:e.customRender)!=null?y:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((f=e==null?void 0:e.fontRenderExtension)==null?void 0:f.isSkip)||((D=u==null?void 0:u.skipDefaultFontRender)==null?void 0:D.call(u,h,A.value,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,T.value,{get style(){const m=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?m.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var $,F,H,L,k,B;const m=(F=($=this._renderManagerService.getRenderById(i))==null?void 0:$.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!m)return;const E=m.worksheet.getMergedCell(r,a),j={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((H=E==null?void 0:E.startRow)!=null?H:r,(L=E==null?void 0:E.startColumn)!=null?L:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(B=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoHeight)==null?void 0:B.call(k,j)},e.interceptorAutoWidth=()=>{var $,F,H,L,k,B;const m=(F=($=this._renderManagerService.getRenderById(i))==null?void 0:$.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:F.skeleton;if(!m)return;const E=m.worksheet.getMergedCell(r,a),j={data:e,style:m.getStyles().getStyleByCell(e),primaryWithCoord:m.getCellWithCoordByIndex((H=E==null?void 0:E.startRow)!=null?H:r,(L=E==null?void 0:E.startColumn)!=null?L:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(B=(k=u==null?void 0:u.canvasRender)==null?void 0:k.calcCellAutoWidth)==null?void 0:B.call(k,j)},e.coverable=((I=e==null?void 0:e.coverable)!=null?I:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(100)).subscribe(e=>{if(e.length===0)return;const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};Me=ft([G(0,o.ICommandService),G(1,b.IMenuManagerService),G(2,O.IRenderManagerService),G(3,o.IUniverInstanceService),G(4,o.Inject(W.AutoHeightController)),G(5,o.Inject(ge)),G(6,o.Inject(C.SheetDataValidationModel)),G(7,o.Inject(X.DataValidatorRegistryService)),G(8,o.Inject(Y.SheetInterceptorService)),G(9,o.Inject(C.DataValidationCacheService)),G(10,o.Optional(W.IEditorBridgeService))],Me);let St=class extends o.RxDisposable{constructor(e,t,n,r,a,i,s){super(),this._commandService=e,this._renderManagerService=t,this._autoHeightController=n,this._dataValidatorRegistryService=r,this._sheetInterceptorService=a,this._sheetDataValidationModel=i,this._dataValidationCacheService=s,this._initViewModelIntercept(),this._initAutoHeight()}_initViewModelIntercept(){this.disposeWithMe(this._sheetInterceptorService.intercept(Y.INTERCEPTOR_POINT.CELL_CONTENT,{effect:o.InterceptorEffectEnum.Style,priority:Y.InterceptCellContentPriority.DATA_VALIDATION,handler:(e,t,n)=>{var T,w,y,f,D;const{row:r,col:a,unitId:i,subUnitId:s,workbook:d,worksheet:l}=t,c=this._sheetDataValidationModel.getRuleIdByLocation(i,s,r,a);if(!c)return n(e);const h=this._sheetDataValidationModel.getRuleById(i,s,c);if(!h)return n(e);const g=(T=this._dataValidationCacheService.getValue(i,s,r,a))!=null?T:o.DataValidationStatus.VALID,u=this._dataValidatorRegistryService.getValidatorItem(h.type),S=l.getCellRaw(r,a),v=C.getCellValueOrigin(S),A=`${v!=null?v:""}`;return(!e||e===t.rawData)&&(e={...t.rawData}),e.markers={...e==null?void 0:e.markers,...g===o.DataValidationStatus.INVALID?mt:null},e.customRender=[...(w=e==null?void 0:e.customRender)!=null?w:[],...u!=null&&u.canvasRender?[u.canvasRender]:[]],e.fontRenderExtension={...e==null?void 0:e.fontRenderExtension,isSkip:((y=e==null?void 0:e.fontRenderExtension)==null?void 0:y.isSkip)||((f=u==null?void 0:u.skipDefaultFontRender)==null?void 0:f.call(u,h,v,t))},e.interceptorStyle={...e==null?void 0:e.interceptorStyle,...u==null?void 0:u.getExtraStyle(h,A,{get style(){const I=d.getStyles();return(typeof(e==null?void 0:e.s)=="string"?I.get(e==null?void 0:e.s):e==null?void 0:e.s)||{}}},r,a)},e.interceptorAutoHeight=()=>{var j,$,F,H,L,k;const I=($=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!I)return;const m=I.worksheet.getMergedCell(r,a),E={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((F=m==null?void 0:m.startRow)!=null?F:r,(H=m==null?void 0:m.startColumn)!=null?H:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(k=(L=u==null?void 0:u.canvasRender)==null?void 0:L.calcCellAutoHeight)==null?void 0:k.call(L,E)},e.interceptorAutoWidth=()=>{var j,$,F,H,L,k;const I=($=(j=this._renderManagerService.getRenderById(i))==null?void 0:j.with(W.SheetSkeletonManagerService).getSkeletonParam(s))==null?void 0:$.skeleton;if(!I)return;const m=I.worksheet.getMergedCell(r,a),E={data:e,style:I.getStyles().getStyleByCell(e),primaryWithCoord:I.getCellWithCoordByIndex((F=m==null?void 0:m.startRow)!=null?F:r,(H=m==null?void 0:m.startColumn)!=null?H:a),unitId:i,subUnitId:s,row:r,col:a,workbook:d,worksheet:l};return(k=(L=u==null?void 0:u.canvasRender)==null?void 0:L.calcCellAutoWidth)==null?void 0:k.call(L,E)},e.coverable=((D=e==null?void 0:e.coverable)!=null?D:!0)&&!(h.type===o.DataValidationType.LIST||h.type===o.DataValidationType.LIST_MULTIPLE),n(e)}}))}_initAutoHeight(){this._sheetDataValidationModel.ruleChange$.pipe(ae.filter(e=>e.source==="command"),ae.bufferTime(16)).subscribe(e=>{const t=[];if(e.forEach(n=>{var r;(n.rule.type===o.DataValidationType.LIST_MULTIPLE||n.rule.type===o.DataValidationType.LIST)&&(r=n.rule)!=null&&r.ranges&&t.push(...n.rule.ranges)}),t.length){const n=this._autoHeightController.getUndoRedoParamsOfAutoHeight(t);o.sequenceExecute(n.redos,this._commandService)}})}};St=ft([G(0,o.ICommandService),G(1,O.IRenderManagerService),G(2,o.Inject(W.AutoHeightController)),G(3,o.Inject(X.DataValidatorRegistryService)),G(4,o.Inject(Y.SheetInterceptorService)),G(5,o.Inject(C.SheetDataValidationModel)),G(6,o.Inject(C.DataValidationCacheService))],St);var Qt=Object.getOwnPropertyDescriptor,en=(e,t,n,r)=>{for(var a=r>1?void 0:r?Qt(t,n):t,i=e.length-1,s;i>=0;i--)(s=e[i])&&(a=s(a)||a);return a},_t=(e,t)=>(n,r)=>t(n,r,e);let ke=class extends o.Disposable{constructor(e,t,n){super(),this._context=e,this._sheetDataValidationModel=t,this._sheetSkeletonManagerService=n,this._initSkeletonChange()}_initSkeletonChange(){const e=t=>{var r;if(!t.length)return;const n=new Set;t.forEach(a=>{n.add(a.subUnitId)}),n.forEach(a=>{var i;(i=this._sheetSkeletonManagerService.getSkeletonParam(a))==null||i.skeleton.makeDirty(!0)}),(r=this._context.mainComponent)==null||r.makeForceDirty()};this.disposeWithMe(this._sheetDataValidationModel.validStatusChange$.pipe(o.bufferDebounceTime(16)).subscribe(e))}};ke=en([_t(1,o.Inject(C.SheetDataValidationModel)),_t(2,o.Inject(W.SheetSkeletonManagerService))],ke);function Se({ref:e,...t}){const{icon:n,id:r,className:a,extend:i,...s}=t,d=`univerjs-icon univerjs-icon-${r} ${a||""}`.trim(),l=R.useRef(`_${rn()}`);return It(n,`${r}`,{defIds:n.defIds,idSuffix:l.current},{ref:e,className:d,...s},i)}function It(e,t,n,r,a){return R.createElement(e.tag,{key:t,...tn(e,n,a),...r},(nn(e,n).children||[]).map((i,s)=>It(i,`${t}-${e.tag}-${s}`,n,void 0,a)))}function tn(e,t,n){const r={...e.attrs};n!=null&&n.colorChannel1&&r.fill==="colorChannel1"&&(r.fill=n.colorChannel1),e.tag==="mask"&&r.id&&(r.id=r.id+t.idSuffix),Object.entries(r).forEach(([i,s])=>{i==="mask"&&typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))});const{defIds:a}=t;return!a||a.length===0||(e.tag==="use"&&r["xlink:href"]&&(r["xlink:href"]=r["xlink:href"]+t.idSuffix),Object.entries(r).forEach(([i,s])=>{typeof s=="string"&&(r[i]=s.replace(/url\(#(.*)\)/,`url(#$1${t.idSuffix})`))})),r}function nn(e,t){var r;const{defIds:n}=t;return!n||n.length===0?e:e.tag==="defs"&&((r=e.children)!=null&&r.length)?{...e,children:e.children.map(a=>typeof a.attrs.id=="string"&&n&&n.includes(a.attrs.id)?{...a,attrs:{...a.attrs,id:a.attrs.id+t.idSuffix}}:a)}:e}function rn(){return Math.random().toString(36).substring(2,8)}Se.displayName="UniverIcon";const an={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"}}]},Ct=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"data-validation-icon",ref:n,icon:an}))});Ct.displayName="DataValidationIcon";const on={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"}}]},Qe=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"delete-icon",ref:n,icon:on}))});Qe.displayName="DeleteIcon";const sn={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"}}]},yt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"increase-icon",ref:n,icon:sn}))});yt.displayName="IncreaseIcon";const ln={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M11.3536 6.14645C11.5488 6.34171 11.5488 6.65829 11.3536 6.85355L8.35355 9.85355C8.15829 10.0488 7.84171 10.0488 7.64645 9.85355L4.64645 6.85355C4.45118 6.65829 4.45118 6.34171 4.64645 6.14645C4.84171 5.95118 5.15829 5.95118 5.35355 6.14645L8 8.79289L10.6464 6.14645C10.8417 5.95118 11.1583 5.95118 11.3536 6.14645Z",fillRule:"evenodd",clipRule:"evenodd"}}]},et=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"more-down-icon",ref:n,icon:ln}))});et.displayName="MoreDownIcon";const dn={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"}}]},wt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"more-up-icon",ref:n,icon:dn}))});wt.displayName="MoreUpIcon";const cn={tag:"svg",attrs:{xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 16 16",width:"1em",height:"1em"},children:[{tag:"path",attrs:{fill:"currentColor",d:"M6 5C6.55228 5 7 4.55228 7 4C7 3.44772 6.55228 3 6 3C5.44772 3 5 3.44772 5 4C5 4.55228 5.44772 5 6 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M6 9C6.55228 9 7 8.55229 7 8C7 7.44772 6.55228 7 6 7C5.44772 7 5 7.44772 5 8C5 8.55229 5.44772 9 6 9Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M7 12C7 12.5523 6.55228 13 6 13C5.44772 13 5 12.5523 5 12C5 11.4477 5.44772 11 6 11C6.55228 11 7 11.4477 7 12Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 5C10.5523 5 11 4.55228 11 4C11 3.44772 10.5523 3 10 3C9.44771 3 9 3.44772 9 4C9 4.55228 9.44771 5 10 5Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M11 8C11 8.55229 10.5523 9 10 9C9.44771 9 9 8.55229 9 8C9 7.44772 9.44771 7 10 7C10.5523 7 11 7.44772 11 8Z"}},{tag:"path",attrs:{fill:"currentColor",d:"M10 13C10.5523 13 11 12.5523 11 12C11 11.4477 10.5523 11 10 11C9.44771 11 9 11.4477 9 12C9 12.5523 9.44771 13 10 13Z"}}]},Dt=R.forwardRef(function(t,n){return R.createElement(Se,Object.assign({},t,{id:"sequence-icon",ref:n,icon:cn}))});Dt.displayName="SequenceIcon";function un(e){var c;const t=b.useDependency(o.LocaleService),n=b.useDependency(b.ComponentManager),{value:r,onChange:a,extraComponent:i}=e,[s,d]=R.useState(!1),l=i?n.get(i):null;return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:"univer-mb-3 univer-flex univer-cursor-pointer univer-items-center univer-text-sm univer-text-gray-900 dark:!univer-text-white",onClick:()=>d(!s),children:[t.t("dataValidation.panel.options"),s?p.jsx(wt,{className:"univer-ml-1"}):p.jsx(et,{className:"univer-ml-1"})]}),s&&p.jsxs(p.Fragment,{children:[l?p.jsx(l,{value:r,onChange:a}):null,p.jsx(M.FormLayout,{label:t.t("dataValidation.panel.invalid"),children:p.jsxs(M.RadioGroup,{value:`${(c=r.errorStyle)!=null?c:o.DataValidationErrorStyle.WARNING}`,onChange:h=>a({...r,errorStyle:+h}),children:[p.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.WARNING}`,children:t.t("dataValidation.panel.showWarning")}),p.jsx(M.Radio,{value:`${o.DataValidationErrorStyle.STOP}`,children:t.t("dataValidation.panel.rejectInput")})]})}),p.jsx(M.FormLayout,{label:t.t("dataValidation.panel.messageInfo"),children:p.jsx(M.Checkbox,{checked:r.showErrorMessage,onChange:()=>a({...r,showErrorMessage:!r.showErrorMessage}),children:t.t("dataValidation.panel.showInfo")})}),r.showErrorMessage?p.jsx(M.FormLayout,{children:p.jsx(M.Input,{value:r.error,onChange:h=>a({...r,error:h})})}):null]})]})}const hn=e=>o.debounce(async(t,n,r,a)=>{const i=await e.executeCommand(t,n,r);a==null||a(i)},1e3);function pn(e,t,n){var r,a,i,s;return t?((a=(r=e.getUnit(t))==null?void 0:r.getSheetBySheetName(n))==null?void 0:a.getSheetId())||"":((s=(i=e.getCurrentUnitForType(o.UniverInstanceType.UNIVER_SHEET))==null?void 0:i.getSheetBySheetName(n))==null?void 0:s.getSheetId())||""}function vn(){var V,x;const[e,t]=R.useState(0),n=b.useDependency(de),r=b.useObservable(n.activeRule$,n.activeRule),{unitId:a,subUnitId:i,rule:s}=r||{},d=s.uid,l=b.useDependency(X.DataValidatorRegistryService),c=b.useDependency(o.IUniverInstanceService),h=b.useDependency(b.ComponentManager),g=b.useDependency(o.ICommandService),u=b.useDependency(X.DataValidationModel),S=b.useDependency(o.LocaleService),[v,A]=R.useState(s),T=l.getValidatorItem(v.type),[w,y]=R.useState(!1),f=l.getValidatorsByScope(X.DataValidatorRegistryScope.SHEET),[D,I]=R.useState(()=>v.ranges.map(_=>({unitId:"",sheetId:"",range:_}))),m=R.useMemo(()=>hn(g),[g]),[E,j]=R.useState(!1),[$,F]=R.useState(!1),H=R.useRef(null),L=b.useDependency(Y.SheetsSelectionsService);if(R.useEffect(()=>()=>{const _=L.getCurrentLastSelection();_&&L.setSelections([_])},[L]),R.useEffect(()=>{g.onCommandExecuted(_=>{(_.id===o.UndoCommand.id||_.id===o.RedoCommand.id)&&setTimeout(()=>{const N=u.getRuleById(a,i,d);t(z=>z+1),N&&(A(N),I(N.ranges.map(z=>({unitId:"",sheetId:"",range:z}))))},20)})},[g,u,d,i,a]),!T)return null;const k=T.operators,B=T.operatorNames,K=v.operator?X.TWO_FORMULA_OPERATOR_COUNT.includes(v.operator):!1,J=()=>{var _,N,z;(N=(_=H.current)==null?void 0:_.editor)!=null&&N.isFocus()&&ne((z=H.current)==null?void 0:z.getValue()),!(!v.ranges.length||E)&&(T.validatorFormula(v,a,i).success?n.setActiveRule(null):y(!0))},ne=b.useEvent(_=>{const N=_.split(",").filter(Boolean).map(Ye.deserializeRangeWithSheet).map(te=>{const Ot=te.sheetName;if(Ot){const sr=pn(c,te.unitId,Ot);return{...te,sheetId:sr}}return{...te,sheetId:""}});if(o.isUnitRangesEqual(N,D))return;I(N);const z=N.filter(te=>(!te.unitId||te.unitId===a)&&(!te.sheetId||te.sheetId===i)).map(te=>te.range);if(A({...v,ranges:z}),z.length===0)return;const le={unitId:a,subUnitId:i,ruleId:d,ranges:z};m(C.UpdateSheetDataValidationRangeCommand.id,le)}),Z=_=>{if(o.shallowEqual(_,X.getRuleSetting(v)))return;A({...v,..._});const N={unitId:a,subUnitId:i,ruleId:d,setting:_};m(C.UpdateSheetDataValidationSettingCommand.id,N,void 0)},re=async()=>{await g.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:d,unitId:a,subUnitId:i}),n.setActiveRule(null)},ie={type:v.type,operator:v.operator,formula1:v.formula1,formula2:v.formula2,allowBlank:v.allowBlank},he=_=>{const N=l.getValidatorItem(_);if(!N)return;const z=N.operators,le=u.getRuleById(a,i,d),te=_===(le==null?void 0:le.type)||_.includes("list")&&(le!=null&&le.type.includes("list"))?{...le,type:_}:{...v,type:_,operator:z[0],formula1:void 0,formula2:void 0};A(te),g.executeCommand(C.UpdateSheetDataValidationSettingCommand.id,{unitId:a,subUnitId:i,ruleId:v.uid,setting:X.getRuleSetting(te)})},pe=h.get(T.formulaInput),ee=R.useMemo(()=>D.map(_=>Ye.serializeRange(_.range)).join(","),[]),q=X.getRuleOptions(v),ce=_=>{o.shallowEqual(_,X.getRuleOptions(v))||(A({...v,..._}),m(C.UpdateSheetDataValidationOptionsCommand.id,{unitId:a,subUnitId:i,ruleId:d,options:_}))},Q=k.length&&!v.operator;return p.jsxs("div",{"data-u-comp":"data-validation-detail",className:"univer-py-2",children:[p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.range"),error:!v.ranges.length||E?S.t("dataValidation.panel.rangeError"):"",children:p.jsx(Xe.RangeSelector,{selectorRef:H,unitId:a,subUnitId:i,initialValue:ee,onChange:(_,N)=>{var z;!$&&((z=H.current)!=null&&z.verify())&&ne(N)},onFocusChange:(_,N)=>{var z;F(_),!_&&N&&((z=H.current)!=null&&z.verify())&&ne(N)},onVerify:_=>j(!_)})}),p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.type"),children:p.jsx(M.Select,{className:"univer-w-full",value:v.type,options:(V=f==null?void 0:f.sort((_,N)=>_.order-N.order))==null?void 0:V.map(_=>({label:S.t(_.title),value:_.id})),onChange:he})}),k!=null&&k.length?p.jsx(M.FormLayout,{label:S.t("dataValidation.panel.operator"),children:p.jsx(M.Select,{className:"univer-w-full",value:`${v.operator}`,options:[{value:"",label:S.t("dataValidation.operators.legal")},...k.map((_,N)=>({value:`${_}`,label:B[N]}))],onChange:_=>{Z({...ie,operator:_})}})}):null,pe&&!Q?p.jsx(pe,{isTwoFormula:K,value:{formula1:v.formula1,formula2:v.formula2},onChange:_=>{Z({...ie,..._})},showError:w,validResult:T.validatorFormula(v,a,i),unitId:a,subUnitId:i,ruleId:d},e+v.type):null,p.jsx(M.FormLayout,{children:p.jsx(M.Checkbox,{checked:(x=v.allowBlank)!=null?x:!0,onChange:()=>{var _;return Z({...ie,allowBlank:!((_=v.allowBlank)==null||_)})},children:S.t("dataValidation.panel.allowBlank")})}),p.jsx(un,{value:q,onChange:ce,extraComponent:T.optionsInput}),p.jsxs("div",{className:"univer-mt-5 univer-flex univer-flex-row univer-justify-end",children:[p.jsx(M.Button,{className:"univer-ml-3",onClick:re,children:S.t("dataValidation.panel.removeRule")}),p.jsx(M.Button,{className:"univer-ml-3",variant:"primary",onClick:J,children:S.t("dataValidation.panel.done")})]})]})}const gn=e=>{const{rule:t,onClick:n,unitId:r,subUnitId:a,disable:i}=e,s=b.useDependency(X.DataValidatorRegistryService),d=b.useDependency(o.ICommandService),l=b.useDependency(W.IMarkSelectionService),c=s.getValidatorItem(t.type),h=R.useRef(void 0),[g,u]=R.useState(!1),S=b.useDependency(o.ThemeService),v=b.useObservable(S.currentTheme$),A=R.useMemo(()=>{var I;const w=S.getColorFromTheme("primary.600"),y=S.getColorFromTheme("loop-color.2"),f=(I=S.getColorFromTheme(y))!=null?I:w,D=new o.ColorKit(f).toRgb();return{fill:`rgba(${D.r}, ${D.g}, ${D.b}, 0.1)`,stroke:f}},[v]),T=w=>{d.executeCommand(C.RemoveSheetDataValidationCommand.id,{ruleId:t.uid,unitId:r,subUnitId:a}),w.stopPropagation()};return R.useEffect(()=>()=>{var w;h.current&&((w=h.current)==null||w.forEach(y=>{y&&l.removeShape(y)}))},[l]),p.jsxs("div",{className:M.clsx(`
|
|
2
2
|
univer-bg-secondary univer-relative univer--ml-2 univer--mr-2 univer-box-border univer-flex
|
|
3
3
|
univer-w-[287px] univer-cursor-pointer univer-flex-col univer-justify-between univer-overflow-hidden
|
|
4
4
|
univer-rounded-md univer-p-2 univer-pr-9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/sheets-data-validation-ui",
|
|
3
|
-
"version": "0.12.4-insiders.
|
|
3
|
+
"version": "0.12.4-insiders.20251212-6c41730",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Data validation UI for Univer Sheets",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -54,19 +54,18 @@
|
|
|
54
54
|
"rxjs": ">=7.0.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@flatten-js/interval-tree": "^1.1.3",
|
|
58
57
|
"@univerjs/icons": "^1.0.2",
|
|
59
|
-
"@univerjs/core": "0.12.4-insiders.
|
|
60
|
-
"@univerjs/
|
|
61
|
-
"@univerjs/design": "0.12.4-insiders.
|
|
62
|
-
"@univerjs/engine-render": "0.12.4-insiders.
|
|
63
|
-
"@univerjs/
|
|
64
|
-
"@univerjs/
|
|
65
|
-
"@univerjs/sheets-
|
|
66
|
-
"@univerjs/sheets-
|
|
67
|
-
"@univerjs/sheets-
|
|
68
|
-
"@univerjs/ui": "0.12.4-insiders.
|
|
69
|
-
"@univerjs/
|
|
58
|
+
"@univerjs/core": "0.12.4-insiders.20251212-6c41730",
|
|
59
|
+
"@univerjs/data-validation": "0.12.4-insiders.20251212-6c41730",
|
|
60
|
+
"@univerjs/design": "0.12.4-insiders.20251212-6c41730",
|
|
61
|
+
"@univerjs/engine-render": "0.12.4-insiders.20251212-6c41730",
|
|
62
|
+
"@univerjs/engine-formula": "0.12.4-insiders.20251212-6c41730",
|
|
63
|
+
"@univerjs/sheets": "0.12.4-insiders.20251212-6c41730",
|
|
64
|
+
"@univerjs/sheets-numfmt": "0.12.4-insiders.20251212-6c41730",
|
|
65
|
+
"@univerjs/sheets-data-validation": "0.12.4-insiders.20251212-6c41730",
|
|
66
|
+
"@univerjs/sheets-formula-ui": "0.12.4-insiders.20251212-6c41730",
|
|
67
|
+
"@univerjs/sheets-ui": "0.12.4-insiders.20251212-6c41730",
|
|
68
|
+
"@univerjs/ui": "0.12.4-insiders.20251212-6c41730"
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
71
|
"postcss": "^8.5.6",
|
|
@@ -74,7 +73,7 @@
|
|
|
74
73
|
"rxjs": "^7.8.2",
|
|
75
74
|
"tailwindcss": "3.4.18",
|
|
76
75
|
"typescript": "^5.9.3",
|
|
77
|
-
"vite": "^7.2.
|
|
76
|
+
"vite": "^7.2.7",
|
|
78
77
|
"vitest": "^4.0.15",
|
|
79
78
|
"@univerjs-infra/shared": "0.12.4"
|
|
80
79
|
},
|